home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / rec / games / programm / 4784 < prev    next >
Encoding:
Text File  |  1992-11-21  |  4.0 KB  |  77 lines

  1. Newsgroups: rec.games.programmer
  2. Path: sparky!uunet!spool.mu.edu!uwm.edu!ux1.cso.uiuc.edu!news.cso.uiuc.edu!uxa.cso.uiuc.edu!jas37876
  3. From: jas37876@uxa.cso.uiuc.edu (John A. Slagel)
  4. Subject: FAQ: VGA ModeX & Mode13h Explanation
  5. Message-ID: <By2tv1.7JM@news.cso.uiuc.edu>
  6. Sender: usenet@news.cso.uiuc.edu (Net Noise owner)
  7. Organization: University of Illinois at Urbana
  8. Date: Sat, 21 Nov 1992 17:28:11 GMT
  9. Lines: 66
  10.  
  11.   If anyone is maintaining a FAQ, stick this one in there...
  12.   This is to take care of people's basic knowledge of VGA display
  13.   memory organization in mode 13h and mode X.
  14.  
  15. ----------------------------------------------------------------------
  16.             IBM VGA 256 Mode13H and ModeX Explanation
  17.  
  18.      The VGA card has 256K of memory located on the card.  This
  19. memory is divided into 4 bitplanes, each with 64K.  The pixels are
  20. stored in this order (In mode13h, 320x200 with 256 colors):
  21.  
  22.                     Plane3-------------------------------
  23.                     | 3,0 | 7,0 |     . . .     | 319,0 |    
  24.                Plane2---------------------------------  |
  25.                | 2,0 | 6,0 |      . . .      | 318,0 |  |
  26.           Plane1-----------------------------------  |  |
  27.           | 1,0 | 5,0 |      . . .        | 317,0 |  |  |
  28.      Plane0-------------------------------------  |  |  |
  29.      | 0,0 | 4,0 |     . . .           | 316,0 |  |  |  |
  30.      | 0,1 | 4,1 |                     | 316,1 |  |  |    
  31.      |                                         |  |  |  
  32.      |                                         |  |
  33.      |                                         |  |
  34.      |                                         |
  35.      |                               | 316,199 |
  36.  
  37.      The coordinates are in (x,y) format, each one representing an
  38. 8-bit pixel.  Notice how consecutive pixels are located in
  39. different bit planes.   Also, notice that in 320x200 mode, only
  40. (160x200=32000) 32000 bytes are used per page out of the 64000 possible.
  41.      To access VGA memory, the programmer writes to the 64K segment
  42. located at A000h with a 16-bit offset.  The VGA card monitors the
  43. address lines and sees that segment A000 is being written to, so it
  44. grabs the 16-bit address and the 8-bit data value and then does
  45. something with them.  This depends on the current video mode and
  46. VGA register settings.
  47.      In mode 13H, the VGA card has the "Chain Four" bit in the
  48. Memory Mode Register set.  This makes the VGA card use the lower two
  49. address bits (A1 and A0) of the address being written to select
  50. which bit plane to write the pixel value to.  For example, if you
  51. write to address A000:0003, the lower two bits are 11b, which means
  52. the pixel would be written to plane 3.  This allows the programmer
  53. to access the display memory as if it is 64000 bytes of linear
  54. memory, which allows the use of the fast REP MOVSB command.
  55.      But, obviously, Mode13 is a waste of memory, because you can
  56. only access 64K of the 256K, so you can't do any page flipping,
  57. when you should be able to.
  58.      To overcome this, the programmer can simply turn off the
  59. "Chain4" bit.  Then the VGA card uses all the 16-bits of the
  60. address to offset into each plane.  So, we can now access all of
  61. the 64K on each page, but when we do, we will access 4 planes at
  62. the same time.  But, to overcome that, we can use the Map Mask
  63. register to select which plane to write to.  But, that means that
  64. for every pixel, we need to send an OUT to the VGA card, which
  65. slows down data transfer.  So, our routines need to be a lot more
  66. clever in order to avoid sending an OUT for every pixel. But then we can
  67. write to all 256K of memory and implement page flipping.
  68.      These modes with the Chain4 bit set off are known as ModeX or
  69. ModeY or tweaked VGA modes.   You can also change the resolution of
  70. these modes, since we can now access more than 64K of memory.
  71.  
  72. -- 
  73. -----------------------------------------------------------------------------
  74.  John A. Slagel              "My old man used to tell me, before he left this
  75.  j-slagel1@uiuc.edu           shitty world, never chase buses or women- you
  76.  (217) 337-7930               always get left behind." -The Marlboro Man
  77.