|
DataMuseum.dkPresents historical artifacts from the history of: CP/M |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about CP/M Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - download
Length: 20992 (0x5200) Types: TextFile Names: »APMCGIOS.A86«
└─⟦369075929⟧ Bits:30004202 GSX driver sourcer disk 1 └─ ⟦this⟧ »APMCGIOS.A86«
PAGESIZE 56 ;PC MOUSE support Erling Skjoldborg 850522 ;************************************************************************ ;* * ;* DEVICE SPECIFIC ROUTINES * ;* * ;* These routines and equates are device dependant. * ;* * ;* * ;************************************************************************ dseg copyright db 'GSX-86 V1.3 Aug. 84' db 'CR16 monochrome screen driver' db 'by LW - Christian Rovsing A/S' cseg public clearmem public check_escape public escfn0,escfn1,escfn2,escfn3 public escfn4,escfn5,escfn6,escfn7 public escfn8,escfn9,escf10,escf11 public escf12,escf13,escf14,escf15 public escf16,escf17,escf18,escf19 public concat public valuator,choice,get_char public plyfill_rot public abline,draw_char public next_address public enable_cross,move_cross,clip_cross,get_loc_key public device_table , size_table public gcurx,gcury public y1,y2,x1,x2 public lstlin public arstl2 extrn entry:near ;the place to jump to if this module ;is linked in first ; ;integer array indexing equates W_1 equ word ptr 0 W_2 equ word ptr 2 W_3 equ word ptr 4 W_4 equ word ptr 6 W_5 equ word ptr 8 W_6 equ word ptr 10 W_7 equ word ptr 12 W_8 equ word ptr 14 W_9 equ word ptr 16 W_10 equ word ptr 18 false equ 0 true equ not false val_inc_big equ 10 ;maximum valuator increment val_inc_small equ 1 ;minimum valuator increment syscall equ 224 mmcs_reg equ 0ffa6h ;midrange chip select EJECT ;**************************************************************** ; screen coordinate equates * ; these must be changed to the values for specific machines * ;**************************************************************** ; xresmx equ 639 ;X - Maximum resolution. yresmx equ 399 ;Y - Maximum resolution. xsize equ 169 ;size of pixel in microns ysize equ 200 ; plane_size equ 08000h ;size of graphics memory msb_first equ true ;set if msb is first out byte_swap equ false ;are bytes swapped multiseg equ true num_segs equ 4 ;number of graphics segments bytes_line equ 80 ;used to compute addresses chars_line equ 80 ;number of characters per line lines_page equ 25 ;lines per alpha screen last_dri_escape equ 19 ;last dri defined escape INCLUDE MOUSE.DEF ;**************************************************************** ; device dependant equates * ; these may or may not be necessary depending on hardware * ;**************************************************************** ; if multiseg next_line equ plane_size / num_segs ;offset to get to next segment else next_line equ bytes_line endif neg_next_line equ 0 - next_line move_to_first equ 0 - plane_size + bytes_line move_to_last equ plane_size - bytes_line ;from before first to last curwtx equ 16 ;1/2 width of cross hair curwty equ 8 ;1/2 height of cross hair cur_mot_max_x equ 16 ;how far cursor moves fast in x cur_mot_max_y equ 8 ;how far cursor moves fast in y cur_mot_min_x equ 1 ;how far cursor moves slow in x cur_mot_min_y equ 1 ;how far cursor moves slow in y jmp entry ;if we come in from here, go to real entry ;**************************************** ;* clearmem * ;* clears graphics memory * ;* uses ax,cx,di * ;* stores zeros in graphics plane * ;**************************************** clearmem: mov ax,graph_plane ; ld in graphics memory address mov es,ax mov cx,plane_size/2 ;number of bytes to zero xor ax,ax mov di,ax rep stosw ; store plane_size zeros in graphmem ret EJECT ;************************************************************************ ;* escape functions * ;* handle character I/O , alpha and graphics cursor * ;* * ;* ENTRY * ;* contrl points to segment and offset of contrl * ;* intin points to segment and offset of intin * ;* ptsin points to segment and offset of ptsin * ;* intout points to segment and offset of intout * ;* ptsout points to segment and offset of ptsout * ;* * ;* * ;************************************************************************ ;**************************************** ;check_escape ; checks escape function called ; against last_escape ;**************************************** check_escape: cmp bx,last_dri_escape jbe its_ok xor bx,bx ;do a nop if its not valid its_ok: ret ;**************************************** ;escape func 0 ; Nop ;**************************************** escfn0: ret EJECT ;**************************************** ;escape func 1 ; Inquire Addressable Character Cells ;**************************************** escfn1: les di,intout mov es:W_1ÆdiÅ, lines_page ; number of addressable rows. mov es:W_2ÆdiÅ, chars_line ; number of addressable columns. ret ;**************************************** ;escape func 2 ; Enter Graphics Mode ;**************************************** escfn2: mov dx,offset init_string mov cl,9 ;disable statusline and blinking cursor int syscall mov dx,mmcs_reg in ax,dx and ax,1111111000000000b add ah,10h mov graph_plane,ax call escfn8 ; home alpha cursor. call clearmem ; clear display call xios_setup ;setup for direct xios call mov cx,10h ;general graphics mode mov ax,30 ;IO-SCREEN function code call xios_call ;go set graphics mode mov si,offset graphic_cit ;pointer to crt init table call crt_init ;enter graphic mode if mouse mov bl,1 call mouse_function ;initialize the mouse endif ret EJECT ;**************************************** ;escape func 3 ; Exit Graphics Mode ;**************************************** escfn3: call xios_setup ;setup for direct xios call mov cx,1 ;general alpha mode mov ax,30 ;IO-SCREEN function code call xios_call ;go set alpha mode call clearmem mov si,offset alpha_cit ;pointer to crt init table call crt_init ;enter alpha mode mov dx,offset exit_string mov cl,9 ;enable blinking cursor int syscall call escfn8 ;home alpha cursor call escfn9 ;clear to end of screen if mouse mov bl,2 call mouse_function ;initialize the mouse endif ret ;**************************************** ;escape func 4 ; Cursor Up ;**************************************** escfn4: cmp cursor_row,0 je esc4done dec cursor_row mov dx,offset cursor_up mov cl,9 int syscall esc4done: ret EJECT ;**************************************** ;escape func 5 ; Cursor Down ;**************************************** escfn5: cmp cursor_row,lines_page-1 je esc5done inc cursor_row mov dx,offset cursor_down mov cl,9 int syscall esc5done: ret ;**************************************** ;escape func 6 ; Cursor Right ;**************************************** escfn6: cmp cursor_col,chars_line-1 je esc6done inc cursor_col mov dx,offset cursor_right mov cl,9 int syscall esc6done: ret EJECT ;**************************************** ;escape func 7 ; Cursor Left ;**************************************** escfn7: cmp cursor_col,0 je esc7done dec cursor_col mov dx,offset cursor_left mov cl,9 int syscall esc7done: ret ;**************************************** ;escape func 8 ; Home Cursor ;**************************************** escfn8: mov cursor_pos,0 mov dx,offset cursor_home mov cl,9 int syscall ret ;**************************************** ;escape func 9 ; Erase to end of screen ;**************************************** escfn9: mov dx,offset erase_eos mov cl,9 int syscall ret EJECT ;**************************************** ;escape func 10 ; Erase to end of line ;**************************************** escf10: mov dx,offset erase_eol mov cl,9 int syscall ret ;**************************************** ;escape func 11 ; Move Cursor to x,y ;**************************************** escf11: les di,intin mov ax, es:ÆdiÅ ; get the row number (1-25) mov cursor_row,al add cursor_row,1fh mov bl,10 div bl add ax,3030h mov curs_lin,ax les di,intin mov ax, es: W_2ÆdiÅ ; get the column number (1-80) mov cursor_col,al add cursor_col,1fh mov bl,10 div bl add ax,3030h mov curs_col,ax mov dx,offset cursor_xy mov cl,9 int syscall ret EJECT ;**************************************** ;escape func 12 ; Output text ;**************************************** escf12: les di,contrl mov cx, es: W_4ÆdiÅ ; get string length. jcxz esc12_done ; done if zero les di,intin esc120: mov dl,es:ÆdiÅ ; load character to be output. cmp dl,20h ; test if control or displayable jb esc121 cmp cursor_col,chars_line-1 je esc124 inc cursor_col jmps esc124 esc121: cmp dl,07 je esc124 cmp dl,08 jne esc122 cmp cursor_col,0 je esc125 dec cursor_col jmps esc124 esc122: cmp dl,0ah jne esc123 cmp cursor_row,lines_page-1 je esc125 inc cursor_row jmps esc124 esc123: cmp dl,0dh jne esc125 cmp cursor_col,0 je esc125 inc cursor_col esc124: push di push cx mov cl,2 int syscall ; output via xios pop cx pop di esc125: inc di inc di loop esc120 esc12_done: ret EJECT ;**************************************** ;escape func 13 ; Reverse video on ;**************************************** escf13: mov dx,offset reverse_on mov cl,9 int syscall ret ;**************************************** ;escape func 14 ; Reverse video off ;**************************************** escf14: mov dx,offset reverse_off mov cl,9 int syscall ret ;**************************************** ;escape func 15 ; Return Current Cursor Address ;**************************************** escf15: les di,intout mov dx,cursor_pos ;get cursor position add dx,101h ;make one relative xor ax,ax ;zero high byte xchg al,dh mov es:ÆdiÅ,ax ;return row address mov es:W_2ÆdiÅ,dx ;return column address ret EJECT ;**************************************** ;escape func 16 ; Return Tablet Status ;**************************************** escf16: les di,intout if mouse mov es:W_1ÆdiÅ, 1 ;return a 1 else mov es:W_1ÆdiÅ, 0 ;return a 0 endif ret ;**************************************** ;escape func 17 NOT SUPPORTED ; Hard Copy ;**************************************** escf17: ret ;**************************************** ;escape func 18 ; Place graphic cross-hair cursor at x,y ;**************************************** escf18: les di,ptsin mov ax,es:ÆdiÅ mov gcurx,ax mov ax,es:W_2ÆdiÅ mov gcury,ax call enable_cross ret ;**************************************** ;escape func 19 ; Remove cursor /Marker ;**************************************** escf19: jmp enable_cross ; locator is called before esc19. EJECT ; ; setup for xios call xios_setup: push es mov cl,9ah int syscall ; get sysdat segment mov entry_seg,es mov cl,9ch int syscall mov ax,es:10hÆbxÅ ; get uda segment mov uda_seg,ax pop es mov cl,99h int syscall ; get virtual console id mov vircons,al ret ; ; make xios call xios_call: push es push ds mov dl,vircons mov es,uda_seg mov ds,entry_seg callf cs:xios_entry pop ds pop es ret xios_off dw 0c03h entry_seg rw 1 xios_entry equ dword ptr xios_off uda_seg rw 1 vircons db 0 ;**************************************************************** ;crt_init * ; initialize the crt controller, mode and color register * ; with data from table. * ; entry: si = pointer to table * ; exit: none * ; * ;**************************************************************** crt_init: mov dx,0680h ;setup controller address and mov cx,length graphic_cit ;...nbr of registers to setup xor ah,ah ;start from reg. 0 ci_lp: mov al,ah ;get next register to setup out dx,al ;tell controller inc ah inc dx inc dx ;setup dataport address lodsb ;get table data and bump pointer out dx,al dec dx dec dx ;back to control port loop ci_lp ;till all table data send to controller mov dx,0688h ;mode control register port address lodsb ;get mode just after table out dx,al mov dx,0698h ;color select register port address lodsb ;get color value out dx,al ret EJECT ;**************************************************************** ;CONCAT * ; ENTRY Reg. BX - X-coordinate (dev. coord.) * ; Reg. AX - Y-coordinate (dev. coord.) * ; * ; EXIT Reg. DI - Physical address * ; Reg. BL - Byte index * ; * ; Reg. Used. AX, BX, CX, DX, DI * ; * ;**************************************************************** concat: and bx, 03ffh ;mask off 10 lsb for x-coord. mov cx, yresmx ;normalize y-coordinate sub cx, ax mov ax, cx shr ax,1 shr ax,1 mov dh,cl mov dl, bl ;save low order byte of x-coord and dl, 07h ;mask off data bit index. mov cl, 3 ;set count to 3 shr bx, cl ;shift out 3 lsb of x-coord. mov cl,bytes_line ;brute force calculation mul cl ;use shift and add if possible add ax, bx ;concatenate y and x coordinates in AX xor cl, cl xchg dh,cl and cl,3 jcxz concat1 concat0: add ax,next_line ;if odd address, then start at next_line loop concat0 concat1: mov di, ax ;di = memory address mov bx, dx ;bx = bit index into data byte ret EJECT ;************************************************************************ ;*get_loc_key * ;* Get Locator key * ;* Entry none * ;* Exit * ;* al=0 nothing happened * ;* * ;* al=1 button press * ;* ah = character information * ;* * ;* al=2 coordinate information * ;* bx = delta x * ;* cx = delta y * ;* * ;* * ;************************************************************************ get_loc_key: if mouse mov bl,3 call mouse_function and al,al jz get_loc_mouse ret get_loc_mouse: endif call get_char ;ask for character test al,al ;if no characters received jz get_loc_key_done ;nothing to do cmp bl,01h ;test if delta min/max toggle jne notins ;skip if not not deltamax ;flip the toggle xor ax,ax ;no character returned jmps get_loc_key_done notins: mov al,bl cmp al,1bh ;detect start of escape sequence jne get_loc_1 ;return character if not escape call get_char ;get second character in sequence test al,al jnz loc_1 ;if not available mov al,1bh ;return escape as character jmps get_loc_1 loc_1: push bx ;save for a while call get_char ;get last character of sequence test al,al ;if not available pop ax jz get_loc_1 ;return second character mov ah,bl ;setup ax for table scan mov si,offset loc_tbl mov cx,10 ;search table for locator key loc_key_search: cmp ax,ÆsiÅ jz found_loc_key add si,6 loop loc_key_search get_loc_1: mov ah,al mov al,1 ;not a locator key so return status jmps get_loc_key_done found_loc_key: mov bx,2ÆsiÅ ;get delta x value mov cx,4ÆsiÅ ;get delta y value cmp deltamax,0 je deltadone shl bx,1 shl bx,1 shl bx,1 ;8 times faster movements when maxmode shl cx,1 shl cx,1 shl cx,1 deltadone: mov al,2 get_loc_key_done: ret if mouse and sio1b include mouse1b.a86 else include mousepc.a86 endif EJECT ;************************************************************************ ;*valuator * ;* Get valuator increment * ;* Exit * ;* al=0 nothing happened * ;* * ;* al=1 button press * ;* ah = character information * ;* * ;* al=2 coordinate information * ;* bx = delta value * ;* * ;************************************************************************ valuator: call get_char test al,al jz get_val_done mov al,bl cmp al,1bh jne get_val_1 call get_char test al,al jnz val_1 mov al,1bh jmps get_val_1 val_1: push bx call get_char test al,al pop ax jz get_val_1 mov ah,bl mov si,offset val_tbl mov cx,4 ;search table for locator key val_key_search: cmp ax,ÆsiÅ jz found_val_key add si,4 loop val_key_search get_val_1: mov ah,al mov al,1 ;not a locator key so return status jmps get_val_done found_val_key: mov bx,2ÆsiÅ ;get delta x value mov al,2 get_val_done: ret EJECT ;************************************************************************ ;* Get choice for choice input * ;* Entry none * ;* * ;* Exit * ;* al=0 nothing happened * ;* * ;* al=1 choice value * ;* bx = choice number 1 to max choice keys * ;* * ;* al=2 button press * ;* ah = character * ;* * ;************************************************************************ choice: call get_char test al,al jz choice_done mov ah,bl ; in case of bad choice sub bl,30h jc choice_key ; make it zero based if <0 then reject cmp bx,10 ; test if too large jnc choice_key inc bx ; make 1-10 mov ax,1 ; bx = choice number jmps choice_done choice_key: mov al,2 choice_done: ret EJECT ;************************************************************************ ;*get_char * ;* Get character for string input * ;* Entry none * ;* * ;* Exit * ;* al=0 nothing happened * ;* * ;* al=1 button press * ;* bx = character information * ;* * ;************************************************************************ get_char: mov dl,0ffh mov cl,6 int syscall ; see if xios has character test al,al jz get_char_done mov bx,1 xchg bl,al get_char_done: ret include monommre.a86 ;*************************************************************************** ;* * ;* Data Area * ;* contains data for escape functions * ;* and the values returned on open_workstation * ;* * ;* * ;* * ;*************************************************************************** ; extrn txtclx:word ;text color index extrn txtcol:byte ;text writing mode extrn wrmode:word ;writing mode extrn plncol:byte ;polygon color index extrn bakcol:byte ;back ground color extrn style:word ;line style extrn contrl:dword extrn intin:dword extrn ptsin:dword extrn intout:dword extrn ptsout:dword ; ; graph_plane dw 0B000h ;start of graphics segment graphic_cit db 33h,28h,2ah,74h,6bh,00h,64h,64h,30h,03h,20h,00h,0,0,0,0 graph_m_and_c db 12h,07h alpha_cit db 68h,50h,55h,7fh,19h,0ch,19h,19h,30h,0fh,6eh,0fh,0,0,0,0 alpha_m_and_c db 24h,00h init_string db 1bh,'0',1bh,'Æ1v$';disable statline and cursor exit_string db 1bh,'1',1bh,'Æ0v$'; enable statusline and cursor cursor_up db 1bh,'ÆA$' cursor_down db 1bh,'ÆB$' cursor_right db 1bh,'ÆC$' cursor_left db 1bh,'ÆD$' cursor_home db 1bh,'ÆH$' erase_eos db 1bh,'ÆJ$' erase_eol db 1bh,'ÆK$' cursor_xy db 1bh,'Æ' curs_lin dw 0 db ';' curs_col dw 0 db 'H$' reverse_on db 1bh,'Æ7m','$' reverse_off db 1bh,'Æ0m','$' cursor_pos rw 0 cursor_col db 0 cursor_row db 0 ; attribute db 07h ;text attributes ; ;loc_tbl ; table of words for locator keys ; format ; word = key code ; word = delta x ; word = delta y loc_tbl dw 4d00h ;right arrow un shifted dw cur_mot_max_x dw 0 dw 435Bh ;right arrow shifted dw cur_mot_min_x dw 0 dw 4b00h ;left arrow unshifted dw 0-cur_mot_max_x dw 0 dw 445Bh ;left arrow shifted dw 0-cur_mot_min_x dw 0 dw 4800h ;up arrow unshifted dw 0 dw cur_mot_max_y dw 415BH ;up arrow shifted dw 0 dw cur_mot_min_y dw 5000h ;down arrow unshifted dw 0 dw 0-cur_mot_max_y dw 425Bh ;down arrow shifted dw 0 dw 0-cur_mot_min_y dw 4700h ;home un shifted dw 0-xresmx dw 0-yresmx dw 485Bh ;home shifted dw 0-xresmx dw 0-yresmx deltamax db 0ffh ; ;val_tbl ; decoding of valuator input ; val_tbl dw 415Bh ;up arrow unshifted dw val_inc_big dw 445BH ;up arrow shifted dw val_inc_small dw 425Bh ;down arrow unshifted dw 0-val_inc_big dw 435Bh ;down arrow shifted dw 0-val_inc_small ; END «eof»