home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
CEXPRESS.ZIP
/
SCREEN.ASM
/
FORMRTB.ASM
< prev
next >
Wrap
Assembly Source File
|
1989-05-03
|
2KB
|
81 lines
;void format_right_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_right_b
_format_right_b 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 ;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: sub cx,cx ;clear CX
cmp byte ptr[si],0 ;test for null string
je L3 ;
L000: inc si ;move SI to end of string
inc cx ;inc string length counter
cmp byte ptr[si],0 ;test for end of string
jne L000 ;loop
dec si ;pull back pointer
mov di,cx ;DI counts string len
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
mov ah,9 ;func to write char
int 10h ;write the character
dec si ;dec string ptr
cmp dl,0 ;left edge of screen?
je L2 ;don't move cursor if so
dec dl ;dec col position
L2: mov ah,2 ;function to set cursor
int 10h ;forward cursor
dec di ;dec string len ctr
jnz L1 ;loop till finished
pop dx ;restore cursor values
L3: mov cx,[bp+6] ;get new cursor offset
test cx,8000h ;negative?
jz L4 ;jump if not
neg CX ;make positive
add dh,cl ;add to row offset
cmp dh,24 ;bottom of screen?
jb L5 ;jump if not
mov dh,24 ;else edge of screen
jmp short L5 ;to set cursor
L4: add dl,cl ;add to col offset
cmp dl,79 ;off screen?
jb L5 ;jump if not
mov dl,79 ;else edge of screen
L5: mov ah,2 ;BIOS func to set curs
int 10h ;set new cursor pos
pop ds ;
pop si ;
pop di ;
pop bp ;
cmp _memory_model,0 ;quit
jle quit ;
db 0CBh ;RET far
quit: ret ;RET near
_format_right_b endp
_TEXT ENDS
END