Category : Assembly Language Source Code
Archive   : DSKPATCH.ZIP
Filename : CURSOR.ASM
; CURSOR.ASM Controls cursor movement and clear screen ;
; 04-04-89*CV ;
;---------------------------------------------------------------------;
CR EQU 13 ;Carriage return
LF EQU 10 ;Line feed
CGROUP GROUP CODE_SEG, DATA_SEG
ASSUME CS:CGROUP, DS:CGROUP
CODE_SEG SEGMENT PUBLIC
PUBLIC SEND_CRLF
;---------------------------------------------------------------------;
; This routine sends a carriage return-line feed pair to the ;
; display, using the DOS routines so that scrolling will be handled ;
; correctly. ;
;---------------------------------------------------------------------;
SEND_CRLF PROC NEAR
PUSH AX
PUSH DX
MOV AH,2
MOV DL,CR
INT 21h
MOV DL,LF
INT 21h
POP DX
POP AX
RET
SEND_CRLF ENDP
PUBLIC CURSOR_RIGHT
;---------------------------------------------------------------------;
; This procedure momes the cursor one position to the right or to ;
; the next line if the cursor was at the end of the line. ;
; ;
; Uses: SEND_CRLF ;
;---------------------------------------------------------------------;
CURSOR_RIGHT PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AH,3 ;Read the current cursor position
MOV BH,0 ;On page 0
INT 10h ;Read cursor position
MOV AH,2 ;Set new cursor position
INC DL ;Set column to next position
CMP DL,79 ;Make sure column <= 79
JBE OK
CALL SEND_CRLF ;Goto next line
JMP DONE
OK: INT 10h
DONE: POP DX
POP CX
POP BX
POP AX
RET
CURSOR_RIGHT ENDP
PUBLIC CLEAR_SCREEN
;---------------------------------------------------------------------;
; This procedure clears the entire screen. ;
;---------------------------------------------------------------------;
CLEAR_SCREEN PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
XOR AL,AL ;Blank entire window
XOR CX,CX ;Upper left corner is at (0,0)
MOV DH,24 ;Bottom line of screen is line 24
MOV DL,79 ;Right side is at column 79
MOV BH,7 ;Use normal attribute for blanks
MOV AH,6 ;Call for scroll-up function
INT 10h ;Clear the window
POP DX
POP CX
POP BX
POP AX
RET
CLEAR_SCREEN ENDP
PUBLIC GOTO_XY
;---------------------------------------------------------------------;
; This procedure moves the cursor ;
; ;
; DH Row (Y) ;
; DL Column (X) ;
;---------------------------------------------------------------------;
GOTO_XY PROC NEAR
PUSH AX
PUSH BX
MOV BH,0 ;Display page 0
MOV AH,2 ;Call for SET CURSOR POSITION
INT 10h
POP BX
POP AX
RET
GOTO_XY ENDP
PUBLIC CLEAR_TO_END_OF_LINE
DATA_SEG SEGMENT PUBLIC
EXTRN COLOR:BYTE
DATA_SEG ENDS
;---------------------------------------------------------------------;
; This procedure clears the line from the current cursor position ;
; to the end of that line. ;
;---------------------------------------------------------------------;
CLEAR_TO_END_OF_LINE PROC NEAR
PUSH AX
PUSH BX
PUSH CX
PUSH DX
MOV AH,3 ;Read current cursor position
XOR BH,BH ;On page 0
INT 10h ;Now have (X,Y) in DL, DH
MOV AH,6 ;Set up clear to end of line
XOR AL,AL ;Clear window
MOV CH,DH ;All on same line
MOV CL,DL ;Start at the cursor position
MOV DL,79 ;And stop at end of line
MOV BH,COLOR ;Use color from calling procedure
INT 10h
POP DX
POP CX
POP BX
POP AX
RET
CLEAR_TO_END_OF_LINE ENDP
CODE_SEG ENDS
END
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/