How to : use modeX (tweaking your VGA card into hi-res)

Written by : Peter Quiring (Jan 12/97)


ModeX has become quite a popular thing to mess around with in the past 5 years. It involves setting up your simply VGA card into 320x200 256 colours mode and then 'tweaking' it into special modes. These modes are totally undocumented but work on most VGA video cards. Now if you need help in getting into Standard VGA mode see the 'VGA Tutorial'.

Chain-4 RAM:
All tweaked modes still use the 64k RAM avail to VGA cards (segment 0a000h). This is enough for the standard mode (320x200 = 64000 bytes). But for some of the tweaked modes such as 320x400 this is not enough. So in these modes RAM is divided up into chain-4 RAM. Basically the current image on screen is split up into 4 planes. Byte 1 of VRAM can access the 1st byte of each plane, byte 2 can access the 2nd byte of each plane, etc. The order of each pixel and plane used is as follows:
Pixel #0 = plane #0 byte 0
Pixel #1 = plane #1 byte 0
Pixel #2 = plane #2 byte 0
Pixel #3 = plane #3 byte 0
Pixel #4 = plane #0 byte 1
Pixel #5 = plane #1 byte 1
Pixel #6 = plane #2 byte 1
Pixel #7 = plane #3 byte 1
etc.
Where pixel #0 is the top left corner, etc.
Here is how you tell the VGA card which plane you want to access:
  ;enable writes to plane(s)
  mov al,2
  mov ah,plane#   ;this must be 1,2,4 or 8 (or any combination ANDed together)
  mov dx,3c4h
  out dx,ax       ;this will enable to planes indicated by ah
Bits 0-3 of AH represent each plane. bit 0 is plane #0, bit 1 is plane #1, etc. If you enable more that one plane then writes to VRAM will update all planes enabled. To clear VRAM quickly just enable ALL planes and write to the whole 64k VRAM segment which will always clear the screen in any modeX mode.
And to tell the VGA which planes to use for reading the following is used:
  ;enable reads to plane(s)
  mov al,4
  mov ah,plane#   ;this must be 1,2,4 or 8 (or any combination ANDed together)
  mov dx,3ceh
  out dx,ax       ;this will enable to planes indicated by ah
And that's it. I'm not sure what happens if you enable multi-planes for reading, just don't.

Here is the source, it can show you how to setup the modes and such.
MODEX.ASM
MODEX.INCThis holds all the modes and stuff.

If anything is confusing well, just compile and modeX program and play around with it, it's got some documentation and should be easy to follow.
Hope you have fun...

Copyright © 1995-2005 Nexus Systems Privacy
SourceForge.net Logo