'===========================================================================
' Subject: QBASIC SCREEN SCROLL               Date: 01-06-96 (09:50)       
'  Author: Barton Paul Levenson               Code: QBasic                 
'  Origin: FidoNet QUIK_BAS Echo            Packet: INTERRPT.ABC
'===========================================================================
DECLARE SUB Background (Row%, Col%, Row2%, Col2%)
DECLARE SUB Scroll (Dir$, Num%, Att%, Row%, Col%, Row2%, Col2%)
'----------
' SCROLLER tests a routine to scroll a rectangular portion of the screen.
'----------
        CALL Background(3, 10, 7, 20)
        LOCATE 24, 1: X$ = INPUT$(1)

        CALL Scroll("U", 1, 112, 3, 10, 7, 20)
        LOCATE 24, 1: X$ = INPUT$(1)

        COLOR 7, 0
END ' Main module

SUB Background (Row%, Col%, Row2%, Col2%)

'----------
' Background writes a traceable pattern to the screen.
'----------
        CLS
        Size% = Col2% - Col% + 1
        COLOR 0, 3

        FOR I% = Row% TO Row2%
                LOCATE I%, Col%
                PRINT STRING$(Size%, "*")
        NEXT I%

END SUB ' Background

'----------
' Scroll scrolls a rectangular portion of the screen up or down.
'----------
SUB Scroll (Dir$, Num%, Att%, Row%, Col%, Row2%, Col2%)
DIM Code(1 TO 9) AS INTEGER             ' Array to hold machine code.

        DEF SEG = VARSEG(Code(1))       ' Switch to data area.
        S% = VARPTR(Code(1))            ' Get the offset.

        IF Dir$ = "U" THEN D% = 6 ELSE D% = 7

        POKE (S% + 0), &HB4: POKE (S% + 1), D%          ' MOV AH, Direction.
        POKE (S% + 2), &HB0: POKE (S% + 3), Num%        ' MOV AL, # of lines.
        POKE (S% + 4), &HB7: POKE (S% + 5), Att%        ' MOV BH, Attribute.
        POKE (S% + 6), &HB5: POKE (S% + 7), Row% - 1    ' MOV CH, upper left.
        POKE (S% + 8), &HB1: POKE (S% + 9), Col% - 1    ' MOV CL, "
        POKE (S% + 10), &HB6: POKE (S% + 11), Row2% - 1 ' MOV DL, lower right.
        POKE (S% + 12), &HB2: POKE (S% + 13), Col2% - 1 ' MOV DH, "
        POKE (S% + 14), &HCD: POKE (S% + 15), &H10      ' INT 10h (BIOS).
        POKE (S% + 16), &HCB                            ' RETF.

        CALL ABSOLUTE(S%)               ' Do it.
        DEF SEG                         ' Go back where we started from.
END SUB ' Scroll

