(8959)  Fri 8 Oct 93 11:13p
By: Mike Melanson
To: Ken Chick
Re: VGA scroll(graphics)
St:                                                                  7202<>8960
---------------------------------------------------------------------------
@MSGID: 1:128/60.0 2cb6568a
Hey Ken,
        I'll expound on my last message:
        Remember that in order to change the starting address you must send
the high byte of the starting address to index 0Ch of the CRTC (3D4h) and
the low byte to index 0Dh of the same address.
        A useful way to implement vertical scrolling goes something like
this:
        1)  Push the initial line value onto the stack.
        2)  Pop the value into AX.
        3)  Add a row to the value.  If the screen is 80 bytes wide then
            add 80 to the value.
        4)  Push the value back onto the stack.
        5)  Since the high byte is already in AH and ready to be ported
            just place 0Ch into AL and send it to port 3D4h.
        6)  Pop the value back into AX and push a copy immediately back
            onto the stack because it needs to be preserved.
        7)  Since the low byte needs to be in AH exchange AL and AH.
        8)  Place the proper index, 0Dh, into AL and send the thing to port
            3D4h.
        9)  For later repetitions, don't re-initialize the offset to 0000h.
            Therefore, start with step 2.

        Here's a small example which assumes a screen with a logical width of
        80 bytes:
        mov     dx,3D4h ;the CRTC index
        mov     ax,0    ;the initial starting offset
        push    ax      ;preserve the initial value
loop:
        pop     ax      ;pop the current starting offset
        add     ax,80   ;add another row
        push    ax      ;preserve the current offset
        mov     al,0Ch  ;the high byte starting offset index
        out     dx,ax   ;port the high byte
        pop     ax      ;get the current row
        push    ax      ;copy the current row back to preservation
        xchg    al,ah   ;move the low byte to AH to be ported
        mov     al,0Dh  ;the low byte starting offset index
        out     dx,ax   ;port the low byte

        That will tell the video card to start scanning at a new offset.
        Horizontal panning is a little tougher as I'll explain in my next
message.

        Hope this helps...
                          -Mike




--- Maximus/2 2.01wb
 * Origin: The Programmers Playhouse (1:128/60)

@PATH: 128/60 103/100 209/209 270/101 260/1 362

---------------------------------------------------------------------------
(8960)  Fri 8 Oct 93 11:15p
By: Mike Melanson
To: Ken Chick
Re: VGA scroll(graphics)
St:                                                                       <8959
---------------------------------------------------------------------------
@MSGID: 1:128/60.0 2cb6571e
Hey Ken,
        Horizontal panning can be implemented using precisely the same method
that I presented for vertical panning, only the offset must be incremented
or decremented by 1 rather than a full row's worth of pixels.  However, there
are 2 problems with this:  1)  The screen will pan by a chunk of 8 pixels,
resulting in rather choppy scrolling and 2)  The screen will wraparound.
        The second problem is the easiest to solve:  Redefine the logical
screen width by porting the number of words the screen should be to the
logical screen width register, index 13h, of the CRTC, 3D4h.  To make the
logical screen width twice the width of the visible screen width, 640 pixels
640 pixels is 80 bytes, 80 bytes is 40 words and 40 words * 2 = 80 words, so
send 80 to the screen width register.
        To scroll through the intermediate pixels the panning register, index
13h, on the attribute controller, 3C0h, must be used.  I've never gotten this
to work directly so I have to use the BIOS service for this particular func-
tion.  To use INT 10h for this the following parameters must be passed:
        AX=1000h
        BL=13h
        BH={number of pixels within byte to be scrolled}

        Let's attempt an explanation through ASCII graphic illustration:
        Here's the first 2 bytes of VRAM:

        [X X X X X X X X]  [X X X X X X X X]
        0000h              0001h

        By default, the monitor begins scanning at the first bit of the first
byte:
         |
        [X X X X X X X X]  [X X X X X X X X]
        0000h              0001h

        When told to start scanning at the offset 0001h it starts here:

                            |
        [X X X X X X X X]  [X X X X X X X X]
        0000h              0001h

        When told to pan 3 individual pixels it starts scanning here:

                                  |
        [X X X X X X X X]  [X X X X X X X X]
        0000h              0001h

        But if the monitor is told to pan 8 pixels it will start scanning here:

                            |
        [X X X X X X X X]  [X X X X X X X X]
        0000h              0001h

        instead of at the beginning of the next byte.  To start scanning at the
next byte tell the card to scan at byte 0002h and at the 0th bit.

        Well, I hope I've given you a somewhat decent primer to graphic scroll-
ing on the VGA.  You know where to write for further questions...:)

        Hope this helps...
                          -Mike

--- Maximus/2 2.01wb
 * Origin: The Programmers Playhouse (1:128/60)

@PATH: 128/60 103/100 209/209 270/101 260/1 362
