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
/
MARKER.ASM
< prev
next >
Wrap
Assembly Source File
|
1988-12-08
|
14KB
|
404 lines
PAGE ,132
TITLE MARKER.ASM
;UPDATE HISTORY
;==============
;
; 10 sep 1984 FT1a Fix bug in st_locator - getkey lost SI/DI
; - return character lost
; 14 sep 1984 FT1a Allow Function keys to be passed back as well
; as characters in rq_locator, st_locator.
; Arrow keys & SEL keys are still trapped out in
; rq_locator cos they're used.
; 15 nov 1984 Convert to C86 V2.2
; 4 nov 1984 2.00.2 fix bug - pass function key bit back in rq-locator
; Special key defines
; ===================
SEL equ 118h ;Select Key [10-sep-84]
UP equ 11Bh ;Up Arrow Key [10-sep-84]
LEFT equ 11Ch ;Left Arrow Key [10-sep-84]
DOWN equ 11Dh ;Down Arrow Key [10-sep-84]
RIGHT equ 11Eh ;Right Arrow Key [10-sep-84]
include asmc.h
SEGEND CODE
SEGDEF DATA
EXTRN l_type:BYTE, m_col:BYTE, gbmod:BYTE, m_type:BYTE
EXTRN m_tab:BYTE, x_start:WORD, x_stop:WORD, m_sca:BYTE, ws_wmo:BYTE
EXTRN y_start:WORD, ymax:WORD, xmax:WORD
Lmmul DW 1
Lmx DW 0
Lmy DW 0
fkey_flag DW 0 ;arrow key pressed [10-sep-84]
SEGEND DATA
SEGDEF CODE
PUBLIC polymark, rq_locator, st_locator
IF @bigmodel
EXTRN gdc_nb:FAR, chk_col:FAR, a_mode:FAR, line:FAR, a_wmode:FAR
EXTRN getkey:FAR, conout:FAR, a_patrn:FAR, eseg_sav:FAR
ELSE
EXTRN gdc_nb:NEAR, chk_col:NEAR, a_mode:NEAR, line:NEAR, a_wmode:NEAR
EXTRN getkey:NEAR, conout:NEAR, a_patrn:NEAR, eseg_sav:NEAR
ENDIF
;************************************************************************
;* *
;* F U N C T I O N polymark(count, array) *
;* int count, *array; *
;* *
;* entry: 8[bp] number of markers to show *
;* 10[bp] pointer to array of 'xy' points at *
;* which to place markers. *
;* *
;************************************************************************
;The x,y coordinate information is represented by 3 bit 2's
;complement numbers in the range of +-3 x, +-3 y. end of character
;is represented by bit 8 being set on the last vector byte.
;
; bit 7 6 5 4 3 2 1 0
; | | | | |
; | \ / \ /
; end x y
Lsho_mark PROC NEAR
mov al,BYTE PTR m_type ;get marker type and use to
and al,0FH ;point into marker table.
xor ah,ah ;clear highDB.
mov cl,4 ;table length.
shl ax,cl
lea si, m_tab
add si,ax ;point si to marker table.
L1: lea di, x_start
call Lvect ;find start of line.
lea di, x_stop
call Lvect ;find end of line.
lea ax, x_start
push ax
call line ;draw stroke.
add sp,2
test BYTE PTR -1[si],80H ;test for end of line bit.
jz L1
ret
Lsho_mark ENDP
Lvect PROC NEAR
mov ax,-2[bp] ;get x value.
mov [di],ax
mov ax,-4[bp] ;get y value.
mov 2[di],ax
lodsb ;get stroke info
mov bx,ax
and ax,7 ;mask to y value
test al,4 ;negative ?
jz L2
or ax,0FFF8H ;sign extend
L2: mov cl,BYTE PTR m_sca
xor ch,ch
push cx
imul cx ;multiply by scale value
mov cx,2
idiv cx
; shr ax,1 ;and divide by two.
add 2[di],ax ;subtract to y offset
and bx,38H ;mask to x value
shr bx,1 ;shift to 3 lsb
shr bx,1
shr bx,1
test bl,4 ;negative ?
jz L3
or bx,0FFF8H ;sign extend
L3: mov ax,bx
pop cx ;recover scale
imul cx ;multiply by scale value
mov cx,2
idiv cx
; test BYTE PTR gbmod,1 ;are we in high res ?
; jnz L3a ;skip if we are.
; shr ax,1 ;and divide by two.
L3a: add [di],ax ;add to x offset
ret
Lvect ENDP
;
PROCDEF polymark
push si
push di
push bp
mov bp,sp
sub sp,4 ;reserve space for xad offset -2[bp]} & yad {-4[bp]}
mov ax,cs:WORD PTR eseg_sav
mov es,ax
call gdc_nb
mov al,BYTE PTR l_type ;get and save old line type.
push ax
mov BYTE PTR l_type,00 ;set up line type for solid lines.
call a_patrn ;set pattern multiplier.
pop ax ;restore old line type.
mov BYTE PTR l_type,al
mov al,BYTE PTR m_col ;check for correct colour.
call chk_col
test BYTE PTR gbmod,2 ;are we in vector mode ?
jnz L0a
or BYTE PTR gbmod,12H
call a_mode
L0a: mov cx,8[bp] ;get number of markers.
mov si,10[bp] ;point to marker array elements.
cld
Ldo_marks:
lodsw ;get initial x
mov -2[bp],ax ;save it.
lodsw ;get initial y
mov -4[bp],ax ;save it.
push cx
push si
call Lsho_mark ;display it
pop si
pop cx
loop Ldo_marks ;loop until done
mov sp,bp ;restore stack position
pop bp
pop di
pop si
ret
PROCEND polymark
;**************************************************************************
;* *
;* F U N C T I O N rq_locator(dev, x_strt, y_strt, char, x_end, y_end) *
;* int dev, x_strt, y_strt; *
;* int *char; *
;* int *x_end, *y_end; *
;* *
;* purpose: Place a moveable cross_hair on the display at *
;* [x_strt, y_strt] and move it around with the *
;* arrow keys until a character is typed or a *
;* Function key pressed (not arrow or SEL). *
;* The keystroke and the final 'xy' positions are *
;* returned in 'char', 'x_end' & 'y_end'. *
;* The cross_hair is then removed. *
;* The cross_hair is assumed to be marker type 1 *
;* *
;* entry: 8[bp] included for GSX86MWC.OLB compatibility. *
;* 10[bp] starting 'x' co-ordinate *
;* 12[bp] starting 'y' co-ordinate *
;* 14[bp] pointer to returned character *
;* 16[bp] pointer to ending 'x' co-ordinate *
;* 18[bp] pointer to ending 'y' co-ordinate *
;* *
;**************************************************************************
Lmsh_m PROC NEAR
mov ax,[si] ;show the marker at 'xy' end.
mov WORD PTR x_start,ax
mov ax,[di]
mov WORD PTR y_start,ax
lea ax, x_start
push ax
mov ax,1
push ax
call polymark
add sp,4
ret
Lmsh_m ENDP
PROCDEF rq_locator
push si
push di
push bp
mov bp,sp
sub sp,8 ;make room to save the old marker info.
mov ax,cs:WORD PTR eseg_sav
mov es,ax
mov al,BYTE PTR m_type ;save all the marker info on the stack.
mov -2[bp],ax
mov al,BYTE PTR m_col
mov -4[bp],ax
mov al,BYTE PTR m_sca
mov -6[bp],ax
mov al,BYTE PTR ws_wmo
mov -8[bp],ax
mov BYTE PTR m_type,1 ; '+'
mov BYTE PTR m_col,3
mov BYTE PTR m_sca,3
mov BYTE PTR ws_wmo,1 ;COMPLIMENT mode.
mov ax,10[bp] ;get starting 'x' and copy to 'x_end' & 'Lmx'.
mov di,16[bp]
mov si,di
mov Lmx,ax
stosw
mov ax,12[bp] ;get starting 'y' and copy to 'y_end' & 'Lmy'.
mov di,18[bp]
mov [di],ax
mov Lmy,ax
call gdc_nb
call a_wmode
Lm0: call Lmsh_m ;show marker at 'x_end', 'y_end'.
Lm1: lea ax, Lmy
push ax
lea ax, Lmx
push ax
call st_locator
add sp,4
or ax,ax
jz Lm1
test fkey_flag,100H ;was an arrow key pressed ? [10-sep-84]
jnz Lm2 ;yup [14-sep-84]
mov bx,14[bp] ;get character pointer and save character.
mov WORD PTR [bx],ax ;allow function bit return ********
call Lmsh_m ;remove marker and exit.
jmp Lmexit
Lm2: call Lmsh_m ;remove old marker.
mov ax,Lmx ;update x_end.
mov [si],ax
mov ax,Lmy ;update y_end.
mov [di],ax
jmp Lm0
Lmexit: mov ax,-8[bp]
mov BYTE PTR ws_wmo,al
call a_wmode
mov ax,-6[bp] ;restore all the marker info from the stack.
mov BYTE PTR m_sca,al
mov ax,-4[bp]
mov BYTE PTR m_col,al
mov ax,-2[bp]
mov BYTE PTR m_type,al
mov sp,bp
pop bp
pop di
pop si
ret
PROCEND rq_locator
;************************************************************************
;* *
;* F U N C T I O N st_locator(x, y) *
;* int *x, *y; *
;* *
;* purpose: Updates 'x' &;or 'y' if an arrow key was *
;* pressed. Updates Lmul if SELECT was pressed. *
;* Returns '\0' in AX if SELECT or no character *
;* was typed, otherwise, returns the character. *
;* *
;************************************************************************
PROCDEF st_locator
push si
push di
push bp
mov bp,sp
call getkey ;get keystroke (if any) [10-sep-84]
mov di,10[bp] ;addr of y coordinate
mov si,8[bp] ;addr of x coordinate
mov bx,cs:WORD PTR eseg_sav
mov es,bx
push ax ;save keystroke value for exit [10-sep-84]
or ax,ax ;was keystoke entered
jnz Ls1 ;yup
jmp Lsexit
Ls1: mov fkey_flag,ax ;save in case function key [10-sep-84]
and fkey_flag,100H
test fkey_flag,100H ;q. function key
jnz ls2 ;yup
jmp lsexit1
Ls2: cmp ax,SEL ;SELECT ? [10-sep-84]
jnz Ls4
mov ax,Lmmul
dec ax
jz Ls3
mov Lmmul,1
jmp Lsexit
Ls3: mov Lmmul,10
jmp Lsexit
Ls4: cmp ax,UP ;UP ? [10-sep-84]
jnz Ls5
mov ax,[di]
add ax,Lmmul
cmp WORD PTR ymax,ax
jns Ls4a
mov ax,WORD PTR ymax
Ls4a: mov [di],ax
jmp Lsexit1
Ls5: cmp ax,DOWN ;DOWN ? [10-sep-84]
jnz Ls6
mov ax,[di]
sub ax,Lmmul
or ax,ax
jns Ls5a
xor ax,ax
Ls5a: mov [di],ax
inc ax
jmp Lsexit1
Ls6: cmp ax,LEFT ;LEFT ? [10-sep-84]
jnz Ls7
mov ax,[si]
sub ax,Lmmul
or ax,ax
jns Ls6a
xor ax,ax
Ls6a: mov [si],ax
inc ax
jmp Lsexit1
Ls7: cmp ax,RIGHT ;RIGHT ? [10-sep-84]
jnz Ls8
mov ax,[si]
add ax,Lmmul
cmp WORD PTR xmax,ax
jns Ls7a
mov ax,WORD PTR xmax
Ls7a: mov [si],ax
jmp Lsexit1
Ls8: mov fkey_flag,0 ;unknown function key pressed [14-sep-84]
jmp Lsexit1 ;turn off flag & continue [14-sep-84]
Lsexit: pop ax ;retrieve keystroke ... [10-sep-84]
xor ax,ax ;.. then lose it [10-sep-84]
mov fkey_flag,0
jmp Lsexit2 ;continue [10-sep-84]
Lsexit1:
pop ax ;retrieve keystroke [10-sep-84]
Lsexit2: ; [10-sep-84]
pop bp
pop di
pop si
ret
PROCEND st_locator
include epilogue.h
END