home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / rettig.zip / TRSOURCE.EXE / _TR_SCRL.ASM < prev    next >
Assembly Source File  |  1990-10-22  |  7KB  |  177 lines

  1. ; _TR_SCROLL.ASM
  2. ;
  3. ; by Tom Rettig and Ralph Davis
  4. ; modified by Rick Spence
  5. ;
  6. ; Placed in the public domain by Tom Rettig Associates, 10/22/1990.
  7. ;
  8.  
  9. COMMENT \
  10.    This program scrolls the screen up or down.  It expects
  11.    6 parameters:  upper-left row, upper-left column,
  12.    lower-right row, lower-right column, number of 
  13.    lines to scroll, and whether to scroll up or down.
  14.    
  15.    Calling syntax:
  16.         CALL _tr_scroll WITH 5,1,24,10,5,'U'
  17.  
  18.    If it receives any invalid parameters, it will simply
  19.    exit without performing any action.
  20. \
  21.  
  22.         PAGE    66,132
  23. ;
  24.  
  25.         PUBLIC  __TR_SCROLL
  26.  
  27.         EXTRN   __TR_DTOI:FAR
  28.  
  29. ;******************************************
  30. _TR_SCRL_TEXT SEGMENT BYTE PUBLIC 'CODE'
  31.         ASSUME  CS:_TR_SCRL_TEXT
  32. ;-------------------------------------------
  33. __TR_SCROLL  PROC    FAR
  34.         PUSH    BP                   ; save caller's BP
  35.         MOV     BP,SP
  36.         PUSH    AX                   ; save all registers--
  37.                                      ; none used to return a value
  38.         PUSH    BX
  39.         PUSH    CX
  40.         PUSH    DX
  41.         PUSH    DS
  42.         PUSH    SI
  43.         PUSH    DI
  44.         MOV     AH,3                 ; Get current cursor position
  45.         MOV     BH,0                 ; Current video page
  46.         INT     10H                  ; in DX
  47.         PUSH    DX                   ; Save it for later
  48.         LDS     SI,[BP+6]            ; Upper LH row in [SI]
  49.         CALL    NUMPARM              ; Get parameter passed as
  50.                                      ; double precision, converted
  51.                                      ; to integer in AX
  52.         CMP     AX,0                 ; Check for valid screen position
  53.         JL      EXIT                 ; (row between 0 and 24)
  54.         CMP     AX,24               
  55.         JG      EXIT
  56.  
  57.         MOV     DH,AL                ; Place first parameter in DH
  58.                                      ; to get it out of the way for now
  59.         LDS     SI,[BP+10]           ; Get second parameter
  60.         CALL    NUMPARM              ; Returned as integer in AX
  61.         CMP     AX,0                 ; Check for valid screen position
  62.         JL      EXIT                 ; (column between 0 and 79)
  63.         CMP     AX,79
  64.         JG      EXIT
  65.         MOV     DL,AL                ; Upper left column in DL
  66.                                      ; for temporary safe-keeping
  67.         PUSH    DX                   ; Save coordinates for later.
  68.                                      ; We will eventually pop them 
  69.                                      ; into CX.
  70.  
  71.         ; Next we get the screen attribute at the upper left hand
  72.         ; row and column requested so we can pass that to the
  73.         ; ROM-BIOS scrolling routine.
  74.  
  75.         XOR     BH,BH                ; Current video page
  76.         MOV     AH,2                 ; BIOS function to set 
  77.                                      ; cursor position
  78.         INT     10H                  ; Set cursor position prior
  79.                                      ; to reading attribute
  80.  
  81.         MOV      AH,8                ; service to read character/attribute
  82.         INT      10H                 ; AH contains attribute at cursor
  83.         MOV      BH,AH               ; place attribute in BH
  84.          
  85.         LDS      SI,[BP+14]          ; Get lower RH row.
  86.         CALL     NUMPARM             ; Now integer in AX
  87.         CMP      AX,0                ; Row between 0 and 24?
  88.         JL       EXIT2
  89.         CMP      AX,24
  90.         JG       EXIT2
  91.         MOV      DH,AL               ; Place in DH for INT 10H
  92.         LDS      SI,[BP+18]          ; Get lower RH column
  93.         CALL     NUMPARM             ; ...as integer in AX
  94.         CMP      AX,0                ; Column between 0 and 79?
  95.         JL       EXIT2
  96.         CMP      AX,79
  97.         JG       EXIT2
  98.         MOV      DL,AL               ; DX now has lower row-col coords
  99.         POP      CX                  ; retrieve upper RH coordinates
  100.         LDS      SI,[BP+22]          ; Get number of rows to scroll
  101.         CALL     NUMPARM             ; AL now has number of lines requested
  102.         CMP      AX,0                ; Make sure it is between 0 and 25
  103.         JL       EXIT
  104.         CMP      AX,25
  105.         JG       EXIT
  106.         PUSH     BX                  ; Save BX
  107.         LDS      BX,[BP+26]          ; point to 'U' or 'D'
  108.         AND      BYTE PTR [BX],0DFH  ; convert to uppercase
  109.         CMP      BYTE PTR [BX],'U'   ; Scroll up?
  110.         JNE      IS_DOWN
  111.         POP      BX                  ; Retrieve number of lines to
  112.                                      ; scroll
  113.         MOV      AH,6                ; BIOS INT 10H function call 6
  114.                                      ; scrolls up
  115.         JMP      DO_IT
  116. IS_DOWN:
  117.         CMP      BYTE PTR [BX],'D'   ; Scroll down?
  118.         POP      BX                  ; Retrieve number of lines to
  119.                                      ; scroll
  120.         JNE      EXIT                ; Not U or D, syntax error--
  121.                                      ; don't do anything.
  122.         MOV      AH,7                ; BIOS INT 10H function call 7
  123.                                      ; scrolls down
  124. DO_IT:
  125.  
  126.         INT      10H                 ; scroll the screen
  127.         JMP      SHORT EXIT          ; and exit.
  128.  
  129. ;-------------------------           ; restore cursor position
  130.                                      ; and registers
  131. EXIT2:  POP     DX                   ; for error conditions
  132.                                      ; prior to second PUSH
  133. EXIT:   POP     DX                   ; retrieve original cursor pos
  134.         XOR     BH,BH                ; Set current video page
  135.         MOV     AH,2                 ; INT 10H Function call 2
  136.                                      ; sets cursor position
  137.         INT     10H
  138.         POP     DI                   ; Restore registers
  139.         POP     SI
  140.         POP     DS
  141.         POP     DX
  142.         POP     CX
  143.         POP     BX
  144.         POP     AX
  145.         POP     BP
  146.         RET
  147. ;
  148. __TR_SCROLL  ENDP
  149. ;------------------------------------------------------
  150. NUMPARM PROC   NEAR
  151.  
  152. ; This procedure picks up a numeric parameter as
  153. ; a double precision number, then returns it
  154. ; as an integer in AX.
  155.  
  156. ; It expects the address of the parameter in DS:SI.
  157.  
  158.         PUSH    BX        ; _TR_DTOI eats BX, CX, and DX
  159.         PUSH    CX
  160.         PUSH    DX
  161.         PUSH    [SI+6]    ; pass parameters to _TR_DTOI
  162.         PUSH    [SI+4]
  163.         PUSH    [SI+2]
  164.         PUSH    [SI]
  165.         CALL    __TR_DTOI  ; returns integer value in AX
  166.         ADD     SP,8
  167.         POP     DX
  168.         POP     CX
  169.         POP     BX
  170.         RET
  171. NUMPARM ENDP
  172. ;-------------------------------------------------------
  173. _TR_SCRL_TEXT   ENDS
  174. ;*******************************************************
  175.         END  
  176.  
  177.