home *** CD-ROM | disk | FTP | other *** search
- ; _TR_SCROLL.ASM
- ;
- ; by Tom Rettig and Ralph Davis
- ; modified by Rick Spence
- ;
- ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
- ;
-
- COMMENT \
- This program scrolls the screen up or down. It expects
- 6 parameters: upper-left row, upper-left column,
- lower-right row, lower-right column, number of
- lines to scroll, and whether to scroll up or down.
-
- Calling syntax:
- CALL _tr_scroll WITH 5,1,24,10,5,'U'
-
- If it receives any invalid parameters, it will simply
- exit without performing any action.
- \
-
- PAGE 66,132
- ;
-
- PUBLIC __TR_SCROLL
-
- EXTRN __TR_DTOI:FAR
-
- ;******************************************
- _TR_SCRL_TEXT SEGMENT BYTE PUBLIC 'CODE'
- ASSUME CS:_TR_SCRL_TEXT
- ;-------------------------------------------
- __TR_SCROLL PROC FAR
- PUSH BP ; save caller's BP
- MOV BP,SP
- PUSH AX ; save all registers--
- ; none used to return a value
- PUSH BX
- PUSH CX
- PUSH DX
- PUSH DS
- PUSH SI
- PUSH DI
- MOV AH,3 ; Get current cursor position
- MOV BH,0 ; Current video page
- INT 10H ; in DX
- PUSH DX ; Save it for later
- LDS SI,[BP+6] ; Upper LH row in [SI]
- CALL NUMPARM ; Get parameter passed as
- ; double precision, converted
- ; to integer in AX
- CMP AX,0 ; Check for valid screen position
- JL EXIT ; (row between 0 and 24)
- CMP AX,24
- JG EXIT
-
- MOV DH,AL ; Place first parameter in DH
- ; to get it out of the way for now
- LDS SI,[BP+10] ; Get second parameter
- CALL NUMPARM ; Returned as integer in AX
- CMP AX,0 ; Check for valid screen position
- JL EXIT ; (column between 0 and 79)
- CMP AX,79
- JG EXIT
- MOV DL,AL ; Upper left column in DL
- ; for temporary safe-keeping
- PUSH DX ; Save coordinates for later.
- ; We will eventually pop them
- ; into CX.
-
- ; Next we get the screen attribute at the upper left hand
- ; row and column requested so we can pass that to the
- ; ROM-BIOS scrolling routine.
-
- XOR BH,BH ; Current video page
- MOV AH,2 ; BIOS function to set
- ; cursor position
- INT 10H ; Set cursor position prior
- ; to reading attribute
-
- MOV AH,8 ; service to read character/attribute
- INT 10H ; AH contains attribute at cursor
- MOV BH,AH ; place attribute in BH
-
- LDS SI,[BP+14] ; Get lower RH row.
- CALL NUMPARM ; Now integer in AX
- CMP AX,0 ; Row between 0 and 24?
- JL EXIT2
- CMP AX,24
- JG EXIT2
- MOV DH,AL ; Place in DH for INT 10H
- LDS SI,[BP+18] ; Get lower RH column
- CALL NUMPARM ; ...as integer in AX
- CMP AX,0 ; Column between 0 and 79?
- JL EXIT2
- CMP AX,79
- JG EXIT2
- MOV DL,AL ; DX now has lower row-col coords
- POP CX ; retrieve upper RH coordinates
- LDS SI,[BP+22] ; Get number of rows to scroll
- CALL NUMPARM ; AL now has number of lines requested
- CMP AX,0 ; Make sure it is between 0 and 25
- JL EXIT
- CMP AX,25
- JG EXIT
- PUSH BX ; Save BX
- LDS BX,[BP+26] ; point to 'U' or 'D'
- AND BYTE PTR [BX],0DFH ; convert to uppercase
- CMP BYTE PTR [BX],'U' ; Scroll up?
- JNE IS_DOWN
- POP BX ; Retrieve number of lines to
- ; scroll
- MOV AH,6 ; BIOS INT 10H function call 6
- ; scrolls up
- JMP DO_IT
- IS_DOWN:
- CMP BYTE PTR [BX],'D' ; Scroll down?
- POP BX ; Retrieve number of lines to
- ; scroll
- JNE EXIT ; Not U or D, syntax error--
- ; don't do anything.
- MOV AH,7 ; BIOS INT 10H function call 7
- ; scrolls down
- DO_IT:
-
- INT 10H ; scroll the screen
- JMP SHORT EXIT ; and exit.
-
- ;------------------------- ; restore cursor position
- ; and registers
- EXIT2: POP DX ; for error conditions
- ; prior to second PUSH
- EXIT: POP DX ; retrieve original cursor pos
- XOR BH,BH ; Set current video page
- MOV AH,2 ; INT 10H Function call 2
- ; sets cursor position
- INT 10H
- POP DI ; Restore registers
- POP SI
- POP DS
- POP DX
- POP CX
- POP BX
- POP AX
- POP BP
- RET
- ;
- __TR_SCROLL ENDP
- ;------------------------------------------------------
- NUMPARM PROC NEAR
-
- ; This procedure picks up a numeric parameter as
- ; a double precision number, then returns it
- ; as an integer in AX.
-
- ; It expects the address of the parameter in DS:SI.
-
- PUSH BX ; _TR_DTOI eats BX, CX, and DX
- PUSH CX
- PUSH DX
- PUSH [SI+6] ; pass parameters to _TR_DTOI
- PUSH [SI+4]
- PUSH [SI+2]
- PUSH [SI]
- CALL __TR_DTOI ; returns integer value in AX
- ADD SP,8
- POP DX
- POP CX
- POP BX
- RET
- NUMPARM ENDP
- ;-------------------------------------------------------
- _TR_SCRL_TEXT ENDS
- ;*******************************************************
- END
-
-