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