home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Power-Programmierung
/
CD1.mdf
/
magazine
/
comp_lan
/
85_febr
/
casm.4
< prev
next >
Wrap
Text File
|
1988-07-25
|
3KB
|
91 lines
Listing 4
C to Assembler Interface
#define PAGE 0
/* video modes */
#define s40x25_bw 0
#define s40x25_color 1
#define s80x25_bw 2
#define s80x25_color 3
#define med_color 4
#define med_bw 5
#define high_bw 6
/* video functions */
#define set_type 256
#define set_cur 512
#define read_position 768
#define read_light_pen_position 1024
#define select_page 1280
#define scroll_up 1536
#define scroll_dn 1792
#define read_attribute_char 2048
#define write_attribute_char 2304
#define write_char 2560
#define set_palette 2816
#define write_dot 3072
#define read_dot 3328
#define write_teletype 3584
#define get_state 3840
/* macros */
#define curpos(row,col) dispio(set_cur,PAGE,(((int)row)<<8)+col)
#define SET_MODE dispio(s80x25_bw)
#define horline(ch,width) dispio(write_char+ch,PAGE,width)
#define hline(row,col,ch,width) curpos(row,col) ; horline(ch,width)
#define wrtchar(ch) dispio(write_char+ch,PAGE,1)
main()
{
int retvals [2] ;
int index ;
SET_MODE ;
hline(0,0,219,80) ; /* draw box around screen */
hline(24,0,219,80) ;
verline(0,0,219,24) ;
verline(0,79,219,24) ;
window(3,3,6,5) ;
window(10,10,5,6) ;
window(7,17,10,11) ;
window(15,40,10,6) ;
window(5,50,20,16) ;
curpos(0,0) ;
/* read cursor position */
for (index=0; index <4; index++ ) {
curpos(index,index+1) ;
dispio(read_position,PAGE,retvals) ;
printf("For page PAGE, Row:%u, Col:%u, cursor mode=%o,%o \n",
retvals[1]>>8, (retvals[1]<<8)>>8, retvals[0]>>8,(retvals[0]<<8)>>8) ;
}
/* get current video state */
dispio(get_state,retvals) ;
printf("Mode: %u, Columns: %u, Active Page: %u \n",
(retvals[0]<<8)>>8, retvals[0]>>8, retvals[1]>>8 ) ;
}
window(row,col,width,depth) /* start at row,col, i.e. left upper corner */
char row,col ;
{
/* first do 4 corners */
curpos(row,col) ;
wrtchar(214) ;
curpos(row+depth,col) ;
wrtchar(211) ;
curpos(row,col+width-1) ;
wrtchar(183) ;
curpos(row+depth,col+width-1) ;
wrtchar(189) ;
/* then connect corners with horizontal and vertical lines */
hline(row,col+1,196,width-2) ;
hline(row+depth,col+1,196,width-2) ;
verline(row+1,col,186,depth-1) ;
verline(row+1,col+width-1,186,depth-1) ;
}
verline(row,col,ch,len)
char row, col, ch, len ;
{
char cnt ;
for (cnt=len; cnt > 0; cnt--) {
curpos(row++,col) ;
wrtchar(ch) ;
}
}