home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / asm / 80x0393 / vgascrol.txt < prev    next >
Encoding:
Text File  |  1993-10-09  |  5.5 KB  |  133 lines

  1. (8959)  Fri 8 Oct 93 11:13p
  2. By: Mike Melanson
  3. To: Ken Chick
  4. Re: VGA scroll(graphics)
  5. St:                                                                  7202<>8960
  6. ---------------------------------------------------------------------------
  7. @MSGID: 1:128/60.0 2cb6568a
  8. Hey Ken,
  9.         I'll expound on my last message:
  10.         Remember that in order to change the starting address you must send
  11. the high byte of the starting address to index 0Ch of the CRTC (3D4h) and
  12. the low byte to index 0Dh of the same address.
  13.         A useful way to implement vertical scrolling goes something like
  14. this:
  15.         1)  Push the initial line value onto the stack.
  16.         2)  Pop the value into AX.
  17.         3)  Add a row to the value.  If the screen is 80 bytes wide then
  18.             add 80 to the value.
  19.         4)  Push the value back onto the stack.
  20.         5)  Since the high byte is already in AH and ready to be ported
  21.             just place 0Ch into AL and send it to port 3D4h.
  22.         6)  Pop the value back into AX and push a copy immediately back
  23.             onto the stack because it needs to be preserved.
  24.         7)  Since the low byte needs to be in AH exchange AL and AH.
  25.         8)  Place the proper index, 0Dh, into AL and send the thing to port
  26.             3D4h.
  27.         9)  For later repetitions, don't re-initialize the offset to 0000h.
  28.             Therefore, start with step 2.
  29.  
  30.         Here's a small example which assumes a screen with a logical width of
  31.         80 bytes:
  32.         mov     dx,3D4h ;the CRTC index
  33.         mov     ax,0    ;the initial starting offset
  34.         push    ax      ;preserve the initial value
  35. loop:
  36.         pop     ax      ;pop the current starting offset
  37.         add     ax,80   ;add another row
  38.         push    ax      ;preserve the current offset
  39.         mov     al,0Ch  ;the high byte starting offset index
  40.         out     dx,ax   ;port the high byte
  41.         pop     ax      ;get the current row
  42.         push    ax      ;copy the current row back to preservation
  43.         xchg    al,ah   ;move the low byte to AH to be ported
  44.         mov     al,0Dh  ;the low byte starting offset index
  45.         out     dx,ax   ;port the low byte
  46.  
  47.         That will tell the video card to start scanning at a new offset.
  48.         Horizontal panning is a little tougher as I'll explain in my next
  49. message.
  50.  
  51.         Hope this helps...
  52.                           -Mike
  53.  
  54.  
  55.  
  56.  
  57. --- Maximus/2 2.01wb
  58.  * Origin: The Programmers Playhouse (1:128/60)
  59.  
  60. @PATH: 128/60 103/100 209/209 270/101 260/1 362
  61.  
  62. ---------------------------------------------------------------------------
  63. (8960)  Fri 8 Oct 93 11:15p
  64. By: Mike Melanson
  65. To: Ken Chick
  66. Re: VGA scroll(graphics)
  67. St:                                                                       <8959
  68. ---------------------------------------------------------------------------
  69. @MSGID: 1:128/60.0 2cb6571e
  70. Hey Ken,
  71.         Horizontal panning can be implemented using precisely the same method
  72. that I presented for vertical panning, only the offset must be incremented
  73. or decremented by 1 rather than a full row's worth of pixels.  However, there
  74. are 2 problems with this:  1)  The screen will pan by a chunk of 8 pixels,
  75. resulting in rather choppy scrolling and 2)  The screen will wraparound.
  76.         The second problem is the easiest to solve:  Redefine the logical
  77. screen width by porting the number of words the screen should be to the
  78. logical screen width register, index 13h, of the CRTC, 3D4h.  To make the
  79. logical screen width twice the width of the visible screen width, 640 pixels
  80. 640 pixels is 80 bytes, 80 bytes is 40 words and 40 words * 2 = 80 words, so
  81. send 80 to the screen width register.
  82.         To scroll through the intermediate pixels the panning register, index
  83. 13h, on the attribute controller, 3C0h, must be used.  I've never gotten this
  84. to work directly so I have to use the BIOS service for this particular func-
  85. tion.  To use INT 10h for this the following parameters must be passed:
  86.         AX=1000h
  87.         BL=13h
  88.         BH={number of pixels within byte to be scrolled}
  89.  
  90.         Let's attempt an explanation through ASCII graphic illustration:
  91.         Here's the first 2 bytes of VRAM:
  92.  
  93.         [X X X X X X X X]  [X X X X X X X X]
  94.         0000h              0001h
  95.  
  96.         By default, the monitor begins scanning at the first bit of the first
  97. byte:
  98.          |
  99.         [X X X X X X X X]  [X X X X X X X X]
  100.         0000h              0001h
  101.  
  102.         When told to start scanning at the offset 0001h it starts here:
  103.  
  104.                             |
  105.         [X X X X X X X X]  [X X X X X X X X]
  106.         0000h              0001h
  107.  
  108.         When told to pan 3 individual pixels it starts scanning here:
  109.  
  110.                                   |
  111.         [X X X X X X X X]  [X X X X X X X X]
  112.         0000h              0001h
  113.  
  114.         But if the monitor is told to pan 8 pixels it will start scanning here:
  115.  
  116.                             |
  117.         [X X X X X X X X]  [X X X X X X X X]
  118.         0000h              0001h
  119.  
  120.         instead of at the beginning of the next byte.  To start scanning at the
  121. next byte tell the card to scan at byte 0002h and at the 0th bit.
  122.  
  123.         Well, I hope I've given you a somewhat decent primer to graphic scroll-
  124. ing on the VGA.  You know where to write for further questions...:)
  125.  
  126.         Hope this helps...
  127.                           -Mike
  128.  
  129. --- Maximus/2 2.01wb
  130.  * Origin: The Programmers Playhouse (1:128/60)
  131.  
  132. @PATH: 128/60 103/100 209/209 270/101 260/1 362
  133.