home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
CEXPRESS.ZIP
/
GRAPHIC.ASM
/
SAVEBOX.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-05-03
|
2KB
|
80 lines
;void save_box(box,top_x,top_y,width,depth);
; unsigned char *box,top_x,top_y,width,depth;
EXTRN _memory_model:byte
EXTRN _video_buffer:word
EXTRN _snow_protect:byte
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _save_box
_save_box proc near
push bp ;
mov bp,sp ;set stack frame
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 ;DS changed
mov bl,_snow_protect ;getch _snow_protect
cmp _memory_model,2 ;data near or far?
jb L0 ;jump if near
les di,dword ptr[bp+4] ;ES:DI pts to Box
inc bp ;inc BP since dword ptr
inc bp ;
jmp short L00 ;
L0: mov ax,ds ;shift DS to ES
mov es,ax ;
mov di,[bp+4] ;NEAR case
L00: mov ax,_video_buffer ;fetch video address
mov ds,ax ;DS points to buffer
sub ax,ax ;
mov al,[bp+8] ;row in AX
dec ax ;count rows from 0
mov dl,160 ;160 bytes per row
mul dl ;AX times 160
sub dx,dx ;
mov dl,[bp+6] ;col in DX
dec dx ;count cols from 0
shl dx,1 ;double for attributes
add ax,dx ;offset of topleft corner
mov dh,[bp+10] ;width to DH
mov dl,[bp+12] ;depth to DL
sub cx,cx ;clear CX
cld ;set direction flag
L1: mov si,ax ;set DS:SI scrn ptr
mov cl,dh ;width counter
push dx ;save width, depth ctrs
push ax ;save line start ptr
L2: or bl,bl ;protect against snow?
je L5 ;jump ahead if not
mov dx,3dah ;status byte address
L3: in al,dx ;get status byte
test al,1 ;test bit
jnz L3 ;loop till 0
cli ;disable interrupts
L4: in al,dx ;get status byte
test al,1 ;test bit
jz L4 ;loop till 1
L5: movsw ;move word to buffer
loop L2 ;go do next in row
pop ax ;restore line start ptr
pop dx ;restore width,depth ctrs
add ax,160 ;forward ptr to next row
dec dl ;dec depth counter
jnz L1 ;loop if another line
L6: sti ;reenable interrupts
pop ds ;
pop si ;
pop di ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_save_box endp
_TEXT ENDS
END