home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
simtel
/
sigm
/
vols200
/
vol259
/
gsx03.lbr
/
ART2DVSP.AQ6
/
ART2DVSP.A86
Wrap
Text File
|
1986-03-22
|
21KB
|
811 lines
;**************************************************************************
;* DEVICE SPECIFIC ROUTINES *
;* *
;* These routines and equates are device dependant. *
;* *
;* *
;* *
;**************************************************************************
;Hist
;Name Date Modification
dseg
copyright db 'GSX-86 V1.3 29 Dec 83'
db 'IBM ARTIST 2 Color screen driver'
db 'Serial No. XXXX-0000-654321'
db 'Digital Research, Inc. '
cseg
;
public init_lut
public load_lut
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
public color_map_table
;
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
EJECT
;****************************************************************
; screen coordinate equates *
; these must be changed to the values for specific machines *
;****************************************************************
;
nec_status equ 2e0h ;Nec 7220 status port
nec_param equ 2e0h ;Nec 7220 parameter port
nec_command equ 2e1h ;Nec 7220 command port
nec_data equ 2e1h ;Nec 7220 data port
xresmx equ 639 ;X - Maximum resolution.
yresmx equ 239 ;Y - Maximum resolution.
xsize equ 320 ;size of pixel in microns
ysize equ 640 ;
num_planes equ 4 ;number of graphics planes 1-4
num_colors equ 16 ;number of simultaneous colors
graph_plane equ 0 ;start of graphics segment
plane_size equ 2 ;size of plane in 16k word increments
words_line equ 40 ;used to compute addresses
chars_line equ 80 ;number of characters per line
lines_page equ 24 ;lines per alpha screen
last_escape equ 19 ;last escape function id
last_dri_escape equ 19 ;last dri defined escape
mouse equ true ;mouse driver to be included
;
;****************************************************************
; device dependant equates *
; these may not require change by the oem *
;****************************************************************
;
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
val_inc_big equ 10 ;maximum valuator increment
val_inc_small equ 1 ;minimum valuator increment
;
;***************************************************************
;Nec 7220 standard equates
; device independent equates NOT TO BE MODIFIED
;***************************************************************
;
;7220 commands equates
;
reset equ 00h
sync equ 0eh ;sync parameters (display enabled)
stop equ 0ch
vsyncm equ 6fh ;vertical sync mode (master)
vsyncs equ 6eh
cchar equ 4bh
start equ 6bh
zoom equ 46h
curs equ 49h
pram equ 70h
pitch equ 47h
wdat equ 20h
gmask equ 4ah
figs equ 4ch
figd equ 6ch
gchrd equ 68h
rdat equ 0a0h
curd equ 0e0h
lprd equ 0c0h
dmar equ 0a4h
dmaw equ 24h
;
;7220 init parameter bytes
;
mixed equ 00h ;mixed alpha and graphics mode
graph equ 02h ;graphic only mode
interl equ 09h ;interlaced mode
nonint equ 00h ;noninterlaced mode
refrsh equ 04h ;refresh enabled
norefr equ 00h ;refresh disabled
glitch equ 00h ;drawing during full display
noglit equ 10h ;drawing during retrace only
;
;7220 status bits equates
;
drdy equ 00000001b ;data ready status
fifofu equ 00000010b ;fifo full status
fifoem equ 00000100b ;fifo empty status
drinpr equ 00001000b ;drawing in progress
dmaexe equ 00010000b ;dma execute
vsyact equ 00100000b ;vertical sync active
hsyact equ 01000000b ;horizontal sync active
lgtpen equ 10000000b ;light pen detect
;
;****************************************************************
; IBM STANDARD ROM BIOS CALLS *
;****************************************************************
SCREEN equ 10H ;interrupts to use for rom routine I/O
KEYBD equ 16H
rev_vid_on equ 70h ;turn on reverse video bits
rev_vid_off equ 07h ;turn off reverse video bits
;
read_cur_pos equ 3 ;bios rom calls for char I/O
set_cur_pos equ 2
read_char equ 8
write_char equ 9
get_character equ 0 ;keyboard read
;
eject
jmp entry ;if we come in from here, go to real entry
;************************************************************************
;* init_lut *
;* initialize the hardware/software color lookup table *
;* *
;* this moves the default table to the realized color table *
;* If the machine has a hardware video lookup table *
;* it should be initialized here. *
;************************************************************************
init_lut:
push ds
pop es
mov di,offset requested_color_table
mov cx,48
mov ax,0
rep stosw ;clear out the table
mov di,offset realized_color_table
mov si,offset default_color_table
mov cx,48
rep movsw ;store defaults in this table
ret
;************************************************************************
;* load_lut *
;* loads lookup table *
;* si contains address of request_color_table entry *
;* ax contains color index requested *
;* Orriginal data in request_color_table *
;* *
;* If a display has a hardware video lookup table *
;* the selected index should be mapped to the req value *
;************************************************************************
load_lut:
ret
;****************************************
;escape func 2
; Enter Graphics Mode
;****************************************
escfn2:
call escfn8 ;
call escfn9 ;home and erase the screen
call rotate_font ; init the font table
mov al,reset ; reset the controller
call write_command
mov al,vsyncm ; put NEC 7220 in master mode
call write_command
mov al,reset ; now init the controller
call write_command
mov bx,offset sync_parms ; init the sync parameters
call write_parameter_block
mov al,pitch
call write_command
mov al,words_line ; set the pitch to 1024 pixels
call write_parameter
mov al,zoom
call write_command
mov al,0
call write_parameter ; set the zoom to X1
mov al,cchar ; set the cursor characteristics
call write_command
mov bx,offset cchar_parms
call write_parameter_block
mov al,pram ; load the parameter ram
call write_command
mov bx,offset pram_parms
call write_parameter_block ; Set the start address of the ram
call clearmem
mov al,start
call write_command ; start the NEC 7220
if mouse
mov bl,1
call mouse_function ;initialize the mouse
endif
ret
;
;****************************************
;escape func 3
; Exit Graphics Mode
;****************************************
escfn3: ;
call escfn8 ;home
call escfn9 ;clear to end of screen
if mouse
mov bl,2
call mouse_function
endif
ret
;
;****************************************
;escape func 4
; Cursor Up
;****************************************
escfn4:
mov ah,read_cur_pos
int screen
cmp dh,0 ;is cursor at top of screen
jz escfn4done ;if so, then done
dec dh
mov ah,set_cur_pos
int screen
escfn4done:
ret
;
;****************************************
;escape func 5
; Cursor Down
;****************************************
escfn5:
mov ah,read_cur_pos
int screen
cmp dh,lines_page ;is cursor at bottom of screen?
jz escfn5done ;if so, done
inc dh
mov ah,set_cur_pos
int screen
escfn5done:
ret
;
;****************************************
;escape func 6
; Cursor Right
;****************************************
escfn6:
mov ah,read_cur_pos
int screen
cmp dl,chars_line ;is cursor at edge of screen?
jz escfn6done ;if so, done
inc dl
mov ah,set_cur_pos
int screen
escfn6done:
ret
;
;****************************************
;escape func 7
; Cursor Left
;****************************************
escfn7:
mov ah,read_cur_pos
int screen
cmp dl,0 ;is cursor at edge of screen?
jz escfn7done ;if so, done
dec dl
mov ah,set_cur_pos
int screen
escfn7done:
ret
;
;****************************************
;escape func 8
; Home Cursor
;****************************************
escfn8:
mov dx,0
mov ah,set_cur_pos
int screen ; move cursor home
ret
;
;****************************************
;escape func 9
; Erase to end of screen
;****************************************
escfn9:
mov ah,read_cur_pos ;get current cursor position
int screen
push dx ;save it
xor cx,cx
mov cl,dl ;compute number of spaces to write
neg cl
add cl,chars_line ;wrap cl around bytes_line
xor ax,ax
mov al,dh ;add bytes_line * number of columns
neg al
add al,lines_page
dec al ;don't count the line we're on
mov bl,chars_line
mul bl ;bl=number of lines * bytes_line
add cx,ax
dec cx ;that last spot causes scroll
mov bx,rev_vid_off ;page zero and reverse off
mov ah,write_char
mov al,20h
int screen ;write cx spaces out
pop dx ;get original cursor position
mov ah,set_cur_pos
int screen ;restore cursor position
ret
;
;****************************************
;escape func 10
; Erase to end of line
;****************************************
escf10:
mov ah,read_cur_pos ;get current cursor position
int screen
push dx ;save it
xor cx,cx
mov cl,dl ;compute number of spaces to write
neg cl
add cl,chars_line
mov bx,rev_vid_off ;page zero and everything to black
mov al,20h
mov ah,write_char
int screen ;write cx spaces out
pop dx
mov ah,set_cur_pos
int screen ;restore cursor position
ret
;
;****************************************
;escape func 11
; Move Cursor to x,y
;****************************************
escf11:
les di,intin
mov ax, es:[di] ; get the row number (1-24)
mov dh,al
dec dh ; make zero relative
mov ax, es: W_2[di] ; get the column number (1-80)
mov dl,al
dec dl ; zero relative
mov ah,set_cur_pos
mov bx,0 ;page zero
int screen
ret
;
;****************************************
;escape func 12
; Output text
;****************************************
escf12:
les di,contrl
mov cx, es: W_4[di] ; get string length.
and cx, cx ; test if 0 count
jz esc12_done
les di,intin
esc120:
mov al, es:[di] ; load character to be output.
push es
push di
push cx
mov cx,1
xor bx,bx
mov bl,attribute
mov ah,write_char
int screen
call escfn6
pop cx
pop di
pop es
inc di
inc di
loop esc120
esc12_done:
ret
;****************************************
;escape func 13
; Reverse video on
;****************************************
escf13:
mov attribute,rev_vid_on
ret
;
;****************************************
;escape func 14
; Reverse video off
;****************************************
escf14:
mov attribute,rev_vid_off
ret
;
;****************************************
;escape func 15
; Return Current Cursor Address
;****************************************
escf15:
les di,intout
mov ah,read_cur_pos
int screen
xor ax,ax ;zero high byte
mov al,dh
inc al ;make one relative
mov es:[di],ax ;return row address
mov al,dl
inc al
mov es:W_2[di],ax ;return column address
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
mov ah,1
int KEYBD ;see if ros has character
jz get_loc_key_none
xor ah,ah
int KEYBD
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
mov ah,al
mov al,1 ;not a locator key so return status
ret
found_loc_key:
add si,2
mov bx,[si] ;get delta x value
add si,2
mov cx,[si]
mov al,2
ret
get_loc_key_none:
xor al,al
ret
include mouse.a86
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:
mov ah,1
int KEYBD ;see if ros has character
jz get_val_none
xor ah,ah
int KEYBD
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
mov ah,al
mov al,1 ;not a locator key so return status
ret
found_val_key:
add si,2
mov bx,[si] ;get delta x value
mov al,2
ret
get_val_none:
xor ax,ax
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:
mov ah,1
int KEYBD ; see if ros has character
jz choice_none
xor ah,ah
int KEYBD
mov bl,ah ; swap byte choice runs from 3b00-4400
mov bh,al
sub bx,3bh
jc choice_key ; make it zero based if <0 then reject
cmp bx,10 ; test if too large
jnc choice_none
inc bx ; make 1-10
mov al,1 ; bx = choice number
xor ah,ah
ret
choice_key:
mov ah,al
mov al,2
ret
choice_none:
xor al,al
ret
;
;****************************************
;* clearmem *
;* clears graphics memory *
;* uses ax,cx *
;* stores zeros in graphics plane *
;****************************************
clearmem:
mov cx,num_planes ; set the outer loop count up
mov al,stop
call write_command ; turn off the 7220 while clearing memory
clearmem_out_loop:
mov al,curs ; set the drawing cursor to the start address
call write_command
mov ax,graph_plane
call write_parameter
mov al,ah
call write_parameter
mov al,cl
dec al ; go from highest to lowest plane
call write_parameter
mov al,gmask ; set up the mask to solid
call write_command
mov al,0ffh
call write_parameter
call write_parameter
push cx ;save the plane count
mov cx,plane_size ;get the number of 16k blocks
clearmem_in_loop:
mov al,figs ;set the drawing count up
call write_command
mov al,2 ;top to bottom
call write_parameter
mov al,0ffh
call write_parameter ;16k words
mov al,03fh
call write_parameter
mov al,wdat+2 ;set the writeing mode to set to 0
call write_command
mov al,0ffh
call write_parameter
call write_parameter
loop clearmem_in_loop
pop cx
loop clearmem_out_loop
mov al,start
call write_command ;start the 7220 again
ret
;
;**************************************************************************
;write_command
; writes a command byte to the NEC 7220 controller
;
; Entry reg al contains byte to be written
; Uses dx,al
;**************************************************************************
write_command:
push dx
push ax
write_command_loop:
mov dx,nec_status
in al,dx
and al,fifofu ;test if fifo is full
nop
nop
jnz write_command_loop
mov dx,nec_command
pop ax
out dx,al
pop dx
ret
;**************************************************************************
;write_parameter
; writes a parameter byte to the NEC 7220 controller
;
; Entry reg al contains byte to be written
; Uses dx,al
;**************************************************************************
write_parameter:
push dx
push ax
write_parameter_loop:
mov dx,nec_status
in al,dx
and al,fifofu ;test if fifo is full
nop
nop
jnz write_parameter_loop
mov dx,nec_param
pop ax
out dx,al
pop dx
ret
EJECT
;
include COLNECRE.A86
dseg
;***************************************************************************
;* *
;* Data Area *
;* contains data for escape functions *
;* and the values returned on open_workstation *
;* *
;* *
;* *
;***************************************************************************
;
extrn font:byte
extrn contrl:dword
extrn intin:dword
extrn ptsin:dword
extrn intout:dword
extrn ptsout:dword
extrn realized_color_table:word
extrn requested_color_table:word
;color map table
;used to map color indecies to physical bitplane values
;
color_map_table db 00000000b ;black
db 00000101b ;red
db 00001100b ;green
db 00000110b ;blue
db 00001110b ;cyan
db 00001101b ;yellow
db 00000111b ;magenta
db 00001111b ;white
db 00000100b ;grey
db 00000001b ;light red
db 00001000b ;light green
db 00000010b ;light blue
db 00001010b ;light cyan
db 00001001b ;light yellow
db 00000011b ;light magenta
db 00001011b ;light white
;
;default color table
;
default_color_table dw 0000,0000,0000 ;index 0
dw 1000,0000,0000
dw 0000,1000,0000
dw 0000,0000,1000
dw 0000,1000,1000
dw 1000,1000,0000
dw 1000,0000,1000
dw 1000,1000,1000
dw 0000,0000,0000 ;index 8
dw 1000,0000,0000
dw 0000,1000,0000
dw 0000,0000,1000
dw 0000,1000,1000
dw 1000,1000,0000
dw 1000,0000,1000
dw 1000,1000,1000
;
mode_save db 0
;pram_parms parameter ram bytes
pram_parms db 8 ;byte count
db 0 ;low start address 1
db 0 ;high start address 1
db 000h ;low line count 240
db 00fh ;high line count
db 0
db 0
db 0
db 0
;sync_parms sync parameter bytes
sync_parms db 8 ;8 bytes
db graph+nonint+refrsh+noglit
db 38 ;n-2 words per line
db 61h ;horizontal sync-1/vertical sync
db 14h ;horizontal front porch-1/vertical sync
db 9 ;horizontal back porch
db 3h ;vertical front porch
db 0f0h ;active lines per field low
db 38h ;vertical back porch and active lines high
;
;cchar_parms cursor characteristic bytes
cchar_parms db 3 ;three bytes to send
db 0 ;n-1 lines per row
db 40h ;magic for the 7220
db 0 ;cursor height
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 4d36h ;right arrow shifted
dw cur_mot_min_x
dw 0
dw 4b00h ;left arrow unshifted
dw 0-cur_mot_max_x
dw 0
dw 4b34h ;left arrow shifted
dw 0-cur_mot_min_x
dw 0
dw 4800h ;up arrow unshifted
dw 0
dw cur_mot_max_y
dw 4838H ;up arrow shifted
dw 0
dw cur_mot_min_y
dw 5000h ;down arrow unshifted
dw 0
dw 0-cur_mot_max_y
dw 5032h ;down arrow shifted
dw 0
dw 0-cur_mot_min_y
dw 4700h ;home un shifted
dw 0-xresmx
dw 0-yresmx
dw 4737h ;home shifted
dw 0-xresmx
dw 0-yresmx
;
;val_tbl
; decoding of valuator input
;
val_tbl dw 4800h ;up arrow unshifted
dw val_inc_big
dw 4838H ;up arrow shifted
dw val_inc_small
dw 5000h ;down arrow unshifted
dw 0-val_inc_big
dw 5032h ;down arrow shifted
dw 0-val_inc_small