home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.update.uu.se
/
ftp.update.uu.se.2014.03.zip
/
ftp.update.uu.se
/
pub
/
rainbow
/
msdos
/
decus
/
RB140
/
grlib03a.arj
/
VECT.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-12-08
|
13KB
|
382 lines
PAGE ,132
;VECT.ASM
;UPDATE HISTORY
;==============
; 15 nov 1984 Convert to CI86 V2.2
include asmc.h
SEGEND CODE
SEGDEF DATA
EXTRN l_col:BYTE, l_wid:BYTE, gbmod:BYTE, ymax:WORD
EXTRN x_start:WORD, y_start:WORD, p1:BYTE, gp_buff:BYTE
Lx_st DW 1
Ly_st DW 1
Lx_sp DW 1
Ly_sp DW 1
Lflag DB 1
Oct DW Oct0, Oct1, Oct2, Oct3, Oct4, Oct5, Oct6, Oct7
SEGEND DATA
SEGDEF CODE
PUBLIC polyline, line, point, rectangle
IF @bigmodel
EXTRN gdc_nb:FAR, chk_col:FAR, a_mode:FAR, cxy2cp:FAR
EXTRN a_patrn:FAR, fifo_mt:FAR, eseg_sav:NEAR
ELSE
EXTRN gdc_nb:NEAR, chk_col:NEAR, a_mode:NEAR, cxy2cp:NEAR
EXTRN a_patrn:NEAR, fifo_mt:NEAR, eseg_sav:NEAR
ENDIF
;******************************************************************************
;* *
;* F U N C T I O N polyline(pnts, array) *
;* int pnts, *array; *
;* *
;* purpose: Draw a line joining the points defined in 'array' *
;* *
;* entry: 6[bp] number of points to join *
;* 8[bp] array containing 'xy' points *
;* *
;******************************************************************************
PROCDEF polyline
push si
push bp
mov bp,sp
call gdc_nb
call a_patrn ;set up pat_reg & pat_mult for current line
;type as held in l_type.
mov al,BYTE PTR l_col ;check for correct colour.
call chk_col
test BYTE PTR gbmod,2
jnz L11 ;skip if already in vector mode.
or BYTE PTR gbmod,12H ;enable vector mode and writes.
call a_mode
L11: mov al,78H
out 57H,al ;set pramDBs 8 and 9
mov al,0FFH
out 56H,al
out 56H,al
L0: mov cx,6[bp] ;get count.
dec cx ;# lines = 1 less than # points.
js L2
mov si,8[bp] ;get pointer to array
L1: push cx ;we don't want it corupted
push si ;send array pointer to line_
call line
add sp,2
pop cx
add si,4 ;point to last point plotted
loop L1 ;keep going until array is exhausted
L2: pop bp
pop si
ret
PROCEND polyline
;******************************************************************************
; *
; F U N C T I O N line(array) int *array; *
; *
; purpose: Draw a vector *
; *
; entry: 8[bp] points to xy array layed out as: *
; *
; Lx_st = starting x location *
; Ly_st = starting y location *
; Lx_sp= ending x location *
; Ly_sp= ending y location *
; *
;******************************************************************************
PROCDEF line
push di
push si
push bp
mov bp,sp
sub sp,2 ;local l_wid.
mov ax,cs:WORD PTR eseg_sav ;reclaim ES just in case !!!!!
mov es,ax
mov si,8[bp] ;get the array pointer
lea di, Lx_st
cld
mov cx,4
rep movsw ;move to the local variable area.
mov al, BYTE PTR l_wid
xor ah,ah
mov -2[bp],ax
mov ax,Lx_st ;is this a single point draw?
cmp Lx_sp,ax ;if yes then start=stop coordinates.
jnz L10 ;jump if definitely not.
mov ax,Ly_st ;maybe. check y coordinates.
cmp Ly_sp,ax
jnz L10 ;jump if definitely not.
jmp L14
;Convert the starting x,y coordinate pair into a cursor positionDW value.
L10: mov ax,WORD PTR ymax ;convert 'y' values from bottom left origin
sub ax,Ly_sp ;to top left origin.
mov Ly_sp,ax
mov ax,WORD PTR ymax
sub ax,Ly_st ;upper 16 bits
mov Ly_st,ax
L12: mov ax,Lx_st
mov WORD PTR x_start,ax
mov ax,Ly_st
mov WORD PTR y_start,ax
call cxy2cp
mov bx,Ly_sp ;compute delta y
sub bx,Ly_st ;delta y negative now?
jns Lquad34 ;jump if not [must be either quad 3 or 4]
Lquad12:
neg bx ;delta y is negative, make absolute
mov ax,Lx_sp ;compute delta x
sub ax,Lx_st ;delta x negative?
js Lquad2 ;jump if yes
Lquad1:
cmp ax,bx ;octant 2?
jbe Loct3 ;jump if not
Loct2: mov dl,2 ;direction of write
jmp Lvxind ;abs[deltax]>abs[deltay], independent axis=x-axis
Loct3: or ax,ax
jz Loct4
mov dl,3 ;direction of write
jmp Lvyind ;abs[deltax]=<abs[deltay], independent axis=y-axis
Lquad2:
neg ax ;delta x is negative, make absolute
cmp ax,bx ;octant 4?
jae Loct5 ;jump if not
Loct4: mov dl,4 ;direction of write
jmp Lvyind ;abs[deltax]=<abs[deltay], independent axis=y-axis
Loct5: mov dl,5 ;direction of write
jmp Lvxind ;abs[deltax]>abs[deltay], independent axis=x-axis
Lquad34:
mov ax,Lx_sp ;compute delta x
sub ax,Lx_st
jns Lquad4 ;jump if delta x is positive
Lquad3:
neg ax ;make delta x absolute instead of negative
cmp ax,bx ;octant 6?
jbe Loct7 ;jump if not
Loct6: mov dl,6 ;direction of write
jmp Lvxind ;abs[deltax]>abs[deltay], independent axis=x-axis
Loct7: mov dl,7 ;direction of write
jmp Lvyind ;abs[deltax]<=abs[deltay], independent axis=y-axis
Lquad4:
cmp ax,bx ;octant 0?
jae Loct1 ;jump if not
Loct0: mov dl,0 ;direction of write
jmp Lvyind ;abs[deltax]<abs[deltay], independent axis=y-axis
Loct1: or bx,bx
jz Loct2
mov dl,1 ;direction of write
jmp Lvxind ;abs[deltax]=>[deltay], independent axis=x-axis
Lvyind: xchg ax,bx ;put independent axis in ax, dependent in bx
Lvxind: and ax,03FFFH ;limit to 14 bits
mov BYTE PTR p1, dl
mov dx,bx
mov WORD PTR p1+1,ax ;DC=abs[delta x]-1
shl bx,1 ;multiply delta y by two
sub bx,ax
and bx,03FFFH ;limit to 14 bits
mov WORD PTR p1+3,bx ;D=2*abs[delta y]-abs[delta x]
mov bx,dx ;restore [abs[delta y]
sub bx,ax
shl bx,1
and bx,03FFFH ;limit to 14 bits
mov WORD PTR p1+5,bx ;D2=2*[abs[delta y]-abs[delta x]]
mov bx,dx
shl bx,1
dec bx
and bx,03FFFH ;limit to 14 bits
mov WORD PTR p1+7,bx ;D1=2*abs[delta y]-1
call fifo_mt ;check the FIFO just in case we're too quick.
mov al,4CH ;issue the FIGS command
out 57H,al
lea si, p1
lodsb ;send p1_ parameter.
or al,8
out 56H,al ;issue a parameterDB
mov cx,8 ;issue the 8DBs of DC,D,D2,D1
L13: lodsb ;fetchDB
out 56H,al ;issue to the GDC
loop L13 ;loop until all 8 done
mov al,6CH ;start the drawing process in motion
out 57H,al ;by issuing FIGD
dec WORD PTR -2[bp]
jz L14
mov al, BYTE PTR p1
xor ah,ah
shl ax,1
lea bx,Oct
add bx,ax
call [bx]
jmp L12
L14: mov sp,bp
pop bp
pop si
pop di
ret
Oct0:
dec WORD PTR Lx_st
dec WORD PTR Lx_sp
ret
Oct1:
dec WORD PTR Lx_st
inc WORD PTR Ly_st
dec WORD PTR Lx_sp
inc WORD PTR Ly_sp
ret
Oct2:
inc WORD PTR Ly_st
inc WORD PTR Ly_sp
ret
Oct3:
inc WORD PTR Lx_st
inc WORD PTR Ly_st
inc WORD PTR Lx_sp
inc WORD PTR Ly_sp
ret
Oct4:
inc WORD PTR Lx_st
inc WORD PTR Lx_sp
ret
Oct5:
inc WORD PTR Lx_st
dec WORD PTR Ly_st
inc WORD PTR Lx_sp
dec WORD PTR Ly_sp
ret
Oct6:
dec WORD PTR Ly_st
dec WORD PTR Ly_sp
ret
Oct7:
dec WORD PTR Lx_st
dec WORD PTR Ly_st
dec WORD PTR Lx_sp
dec WORD PTR Ly_sp
ret
PROCEND line
;*****************************************************************************
;* *
;* F U N C T I O N point(x, y) *
;* *
;* purpose: Draw a pixel *
;* *
;* entry: 4[bp] x location *
;* 6[bp] y location *
;* *
;*****************************************************************************
PROCDEF point
push bp
mov bp,sp
call gdc_nb
mov al,BYTE PTR l_col ;check that colour is OK
call chk_col
test BYTE PTR gbmod,2
jnz Lp0
or BYTE PTR gbmod,12H
call a_mode
Lp0: mov ax,4[bp]
mov WORD PTR x_start,ax
mov ax,WORD PTR ymax
sub ax,6[bp]
mov WORD PTR y_start,ax
call cxy2cp ;convert 'xy' to cursor pos. & send to GDC.
mov al,4CH ;assert the FIGS command
out 57H,al
mov al,2 ;line drawn to the right.
out 56H,al
mov al,6CH ;tell the GDC to draw the pixel when ready.
out 57H,al
pop bp
ret
PROCEND point
;************************************************************************
;* *
;* F U N C T I O N rectangle(array) int *array; *
;* *
;* purpose: draw a rectangle by defining the top right and *
;* bottom left points. *
;* entry: 6[bp] has the pointer to the 'xy' array *
;* *
;* 0[array] bottom left 'x' *
;* 2[array] bottom left 'y' *
;* 4[array] top right 'x' *
;* 6[array] top right 'y' *
;* *
;* NOTE: both 'y' values are relative to a bottom left origin *
;* *
;************************************************************************
PROCDEF rectangle
push si
push bp
mov bp,sp
mov ax,cs:WORD PTR eseg_sav ;cautious as ever
mov es,ax
cld
mov si,6[bp] ;point SI to the source array.
lea bx, gp_buff ;point BX to gen. purpose buffer area.
lodsw ;get X1
mov [bx],ax ;bot_lft 'x'
mov 12[bx],ax ;top_lft 'x'
mov 16[bx],ax ;bot_lft 'x'
lodsw ;get Y1
mov 2[bx],ax ;bot_lft 'y'
mov 6[bx],ax ;bot_rgt 'y'
mov 18[bx],ax ;bot_lft 'y'
lodsw ;get X2
mov 4[bx],ax ;bot_rgt 'x'
mov 8[bx],ax ;top_rgt 'x'
lodsw ;get Y2
mov 10[bx],ax ;top_rgt 'y'
mov 14[bx],ax ;top_lft 'y'
push bx
mov ax,5
push ax
call polyline
add sp,4
pop bp
pop si
ret
PROCEND rectangle
include epilogue.h
END