home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
CEXPRESS.ZIP
/
SCREEN.ASM
/
FORMLFB.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-05-03
|
2KB
|
73 lines
;void format_left_b(strg,distance,color);
; unsigned char *strg,color;
; unsigned short distance;
EXTRN _memory_model:byte
EXTRN _video_page:byte
_TEXT SEGMENT BYTE PUBLIC 'CODE'
ASSUME CS:_TEXT
PUBLIC _format_left_b
_format_left_b proc near
push bp ;
mov bp,sp ;set stack frame
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 DS
mov bh,_video_page ;place page value in BH
cmp _memory_model,2 ;data near or far?
jb L0 ;jump if near
lds si,dword ptr[bp+4] ;DS:SI pts to Strg
inc bp ;add 2 to BP since dword ptr
inc bp ;
jmp short L00 ;
L0: mov si,[bp+4] ;near case
L00: cmp byte ptr [si],0 ;test for null string
je L4 ;
mov bl,[bp+8] ;attribute to BL
mov ah,3 ;function to get curs pos
int 10h ;cursor pos to DH-DL
push dx ;save starting curs pos
mov cx,1 ;number chr wrt each time
L1: mov al,[si] ;get a character
cmp al,0 ;test for end of string
je L3 ;
mov ah,9 ;func to write char
int 10h ;write the character
inc si ;inc string ptr
cmp dl,79 ;right edge of screen?
je L2 ;don't move cursor if so
inc dl ;inc col position
L2: mov ah,2 ;function to set cursor
int 10h ;forward cursor
jmp short L1 ;loop
L3: pop dx ;restore cursor values
L4: mov cx,[bp+6] ;get new cursor offset
test cx,8000h ;negative?
jz L5 ;jump if not
neg CX ;make positive
add dh,cl ;add to row offset
cmp dh,24 ;bottom of screen?
jb L6 ;jump if not
mov dh,24 ;else edge of screen
jmp short L6 ;to set cursor
L5: add dl,cl ;add to col offset
cmp dl,79 ;off screen?
jb L6 ;jump if not
mov dl,79 ;else edge of screen
L6: mov ah,2 ;BIOS func to set curs
int 10h ;set new cursor pos
pop ds ;
pop si ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_format_left_b endp
_TEXT ENDS
END