home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
CEXPRESS.ZIP
/
GRAPHIC.ASM
/
BOXUP.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-05-03
|
6KB
|
225 lines
;void box_up(box,col,row,width,depth);
; unsigned char *box,*col,*row,width,depth;
EXTRN _memory_model:byte
EXTRN _video_buffer:word
EXTRN _snow_protect:byte
box_seg EQU [bp-2]
box_ofs EQU [bp-4]
col_seg EQU [bp-6]
col_ofs EQU [bp-8]
row_seg EQU [bp-10]
row_ofs EQU [bp-12]
width EQU [bp-14]
depth EQU [bp-16]
snow EQU [bp-18]
endofbox EQU [bp-20]
toppos EQU [bp-22]
rghtpos EQU [bp-24]
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _box_up
_box_up proc near
push bp ;
mov bp,sp ;set stack frame
sub sp,24 ;make room to hold parameters
pushf ;
push di ;
push si ;
cmp _memory_model,0 ;near or far?
jle begin ;jump if near
inc bp ;else add 2 to BP
inc bp ;
begin: push ds ;save Turbo's DS
mov dx,_video_buffer ;grab _video_buffer
push dx ;save it
cmp _memory_model,2 ;data near or far?
jb L0 ;jump if near
push [bp+6] ;move parameters to SP offsets
push [bp+10]
push [bp+14]
push [bp+4]
push [bp+8]
push [bp+12]
push [bp+16]
push [bp+18]
jmp short L00
L0: push ds ;near case
push ds
push ds
push [bp+4]
push [bp+6]
push [bp+8]
mov al,[bp+10]
sub ah,ah
push ax
mov al,[bp+12]
push ax
L00: cmp _memory_model,0 ;check code model again
jle L000 ;jump if near
dec bp ;unadjust BP so all BP offsets same
dec bp ;
L000: pop depth ;set intermediate values
pop width
pop row_ofs
pop col_ofs
pop box_ofs
pop row_seg
pop col_seg
pop box_seg
mov ax,col_seg ;point ES:DI to Col
mov es,ax ;
mov di,col_ofs ;
mov al,_snow_protect ;grab _snow_protect
mov snow,al ;save it
sub cx,cx ;
mov cl,es:[di] ;get column position
jcxz F1 ;quit if column is zero
dec cx ;count from zero
cmp cx,79 ;in range?
jna G1 ;jump ahead if so
F1: jmp M1 ;else quit
G1: mov ax,box_seg ;point ES:DI to byte array
mov es,ax ;
mov di,box_ofs ;
mov ax,depth ;depth to AX
dec ax ;dec for test
cmp ax,24 ;in range?
jna H1 ;jump ahead if so
jmp M1 ;else quit routine
H1: inc ax ;readjust
mov bx,width ;width to BX
dec bx ;dec for test
cmp bx,79 ;in range?
jna I1 ;jump ahead if so
jmp M1 ;else quit
I1: inc bx ;readjust
mul bl ;width times depth
shl ax,1 ;double for attributes
add ax,di ;offset to end of Box
mov endofbox,ax ;save end of box ptr
mov di,ax ;pt ES:DI to end of Box
mov ax,row_seg ;point DS:SI to Row
mov ds,ax ;
mov si,row_ofs ;
sub ax,ax ;
mov al,[si] ;get row value
cmp ax,1 ;top row already?
je J1 ;quit if so
dec ax ;count from zero
cmp ax,24 ;in range?
jna K1 ;jump ahead if so
J1: jmp M1 ;else quit
K1: mov bx,ax ;copy in BX
add bx,depth ;add depth
cmp bx,25 ;in range?
ja J1 ;quit if so
mov [si],al ;reset row variable
mov bl,160 ;bytes per row
mul bl ;calculate row offset
shl cx,1 ;col offset
add ax,cx ;add to row offset
mov si,ax ;SI pts to topleft corner
mov toppos,si ;save it
mov ax,dx ;_video_buffer
mov ds,ax ;move to DS
mov ax,depth ;depth
mov cl,160 ;bytes per row
mul cl ;times depth
add si,ax ;DS:SI pts to topright
mov rghtpos,si ;save position
pop bx ;_video_buffer
cld ;set direction
mov si,toppos ;topright position
sub si,160 ;row higher
mov cx,width ;width
shl cx,1 ;double for MOVSB
call WriteIt ;write a char
mov ax,ds ;DS to AX
mov es,ax ;now ES pts to screen too
mov di,toppos ;top left position
mov si,di ;copy to SI
sub di,160 ;DI one row higher
mov ax,depth ;depth to AX
L1: mov cx,width ;width to CX
push di ;save target ptr
push si ;save source ptr
shl cx,1 ;double width for MOVSB
call Writeit ;write a char
pop si ;restore ptr
pop di ;restore ptr
add di,160 ;ptr down one row
add si,160 ;ditto
dec ax ;dec depth counter
jnz L1 ;loop till finished
mov ax,box_seg ;segment of Box
mov ds,ax ;move to DS
mov si,endofbox ;offset of end of Box
mov di,rghtpos ;ES:DI pts to bottomleft
sub di,160 ;one row higher
mov dx,width ;width
shl dx,1 ;double for attributes
sub si,dx ;DS:SI pts to last row
mov cx,dx ;use as counter
call Writeit ;write a char
std ;reverse direction flag
mov ax,ds ;DS pts to Box
mov es,ax ;now ES does too
mov di,endofbox ;offset to end of Box
sub di,2 ;last char of box
mov si,di ;copy to SI
sub si,dx ;offset to second row
mov ax,depth ;depth
dec ax ;minus one row
mov cx,width ;width
mul cl ;size of Box minus 1 row
mov cx,ax ;move to CX as counter
rep movsw ;shift all upwards
mov di,box_ofs ;offset of Box
mov si,endofbox ;end of box
mov cx,width ;width
cld ;direction flag forward
rep movsw ;move new data
jmp short N1 ;jump to end
M1: pop bx ;balance stack if error
N1: sti ;reenable interrupts
pop ds ;
pop si ;
pop di ;
popf ;
add sp,24 ;restore stack pointer
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_box_up endp
Writeit PROC
push dx ;save DX
push ax ;save AX
mov dx,3dah ;status byte address
mov bx,es ;get target segment
mov ax,ds ;get source segment
cmp ax,bx ;is source larger?
jna A1 ;jump if not
mov bx,ax ;else use source
A1: cmp byte ptr snow,0 ;protect against snow?
je D1 ;jump ahead if not
B1: in al,dx ;get status byte
test al,1 ;test bit
jnz B1 ;loop till 0
cli ;disable interrupts
C1: in al,dx ;get status byte
test al,1 ;test bit
jz C1 ;loop till 1
D1: movsb ;move a character
loop A1 ;go do next
pop ax ;restore AX
pop dx ;restore DX
ret ;
Writeit endp
_TEXT ENDS
END