home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
CEXPRESS.ZIP
/
GRAPHIC.ASM
/
SCRLHORZ.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-05-03
|
4KB
|
128 lines
;void scroll_horz(dir,top_x,top_y,width,depth,cols,color);
; unsigned char dir,top_x,top_y,width,depth,cols,color;
EXTRN _memory_model:byte
EXTRN _video_buffer:word
EXTRN _snow_protect:byte
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _scroll_horz
_scroll_horz 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 ;
mov bl,_snow_protect ;get _snow_protect before change DS
mov ax,_video_buffer ;fetch _video_buffer
mov es,ax ;move to ES
mov ds,ax ;copy in DS
sub ax,ax ;
mov al,[bp+8] ;top left row to AX
mov [bp+8],bl ;save _snow_protect
dec ax ;count from 0
cmp ax,24 ;in range?
jna L2 ;jump ahead if so
L1: jmp L8 ;else quit routine
L2: mov cl,160 ;bytes per row
mul cl ;times row count
sub cx,cx ;
mov cl,[bp+6] ;top left col to CX
dec cx ;count from 0
cmp cx,79 ;in range?
ja L1 ;quit if not
shl cx,1 ;double for attributes
add ax,cx ;add to row offset
sub dx,dx ;
mov dl,[bp+12] ;depth to DX
or dx,dx ;test for zero length
jz L1 ;quit if zero
mov cl,[bp+4] ;get direction flag
cmp cl,'L' ;test for 'L'
je L3 ;jump ahead if 'L'
cmp cl,'l' ;test for 'l'
je L3 ;jump ahead if 'l'
sub cx,cx ;
mov cl,[bp+10] ;width to CX
dec cx ;adjust
shl cx,1 ;double for attributes
add ax,cx ;add to x,y position
mov di,ax ;ES:DI pts to top right
sub cx,cx ;
mov cl,[bp+14] ;get cols to scroll
shl cx,1 ;double for attributes
sub ax,cx ;sub from top right pos
mov si,ax ;DS:SI pts to source
std ;set direction for 'R'
jmp short L4 ;jump ahead
L3: sub cx,cx ;
mov cl,[bp+14] ;cols to CX
shl cx,1 ;double for attributes
mov di,ax ;ES:DI pts leftmost char
add ax,cx ;offset to lst scrl char
mov si,ax ;DS:SI pts scrl char
cld ;set direction for 'L'
L4: sub cx,cx ;
mov cl,[bp+10] ;box width to DX
or cx,cx ;test for zero width
jz L8 ;quit routine if zero
sub ax,ax ;
mov al,[bp+14] ;number cols to scroll
or ax,ax ;test for zero cols
jnz L5 ;jump ahead if not zero
xchg ax,cx ;else cols = width
jmp short L6 ;jump ahead
L5: sub cx,ax ;width minus cols
cmp cx,0 ;more cols than width?
jge L6 ;jump ahead if not
sub ax,ax ;
mov al,[bp+10] ;else cols = width
mov cx,0 ;scroll = 0
L6: push ax ;save number cols
push cx ;save width counter
push si ;save source ptr
push di ;save destination ptr
push dx ;save row counter
push ax ;save number cols
cmp byte ptr[bp+8],0 ;protect against snow?
je L7 ;jump ahead if not
mov dx,3D8H ;CGA mode select register
mov al,25h ;shut off screen
out dx,al ;do it
L7: pop ax ;restore number cols
pop dx ;restore row counter
rep movsw ;move a row
mov cx,ax ;number cols scrolled
mov al,32 ;clear with spc char
mov ah,[bp+16] ;attribute for clear
rep stosw ;clear opened area
pop di ;restore destination ptr
add di,160 ;forward to next line
pop si ;restore source ptr
add si,160 ;forward to next line
pop cx ;restore width counter
pop ax ;restore num cols
dec dx ;dec the row counter
jnz L6 ;loop until finished
cmp byte ptr[bp+8],0 ;protected against snow?
je L8 ;jump if not
mov dx,3D8H ;CGA mode select register
mov al,41 ;80x25, blink enabled
out dx,al ;reenable video
L8: pop ds ;
pop si ;
pop di ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_scroll_horz endp
_TEXT ENDS
END