Either it's really difficult or the thing is very very badly explained...
Wrong: for FreeVGA, its both
First: why does FreeVGA says that the graphics controller does the interface between the host system bus and the video memory, but the "Graphics Registers" include fields related to the rasterization of the display memory? (such as the 256-Color Shift Mode and the Shift Register interleave Mode fields) Yet, the Memory Plane Write Enable, Chain 4 and Odd/Even Host Memory Write Adressing Disable fields are on sequencer registers, why? Doesn't make sense!
First of all, the layout of the VGA 'sub-chips' isn't completely logical from the programmers perspective. For writing to memory, the data is apparently passed through both the GC and the Sequencer (as both have registers regarding such operations), for display, almost all chips have a take in the business. You can still make a pretty good distinction between registers dealing with the host-videomemory link and the videomemory-display link. A wild stab at how this happened to be is that the sequencer operates as the memory controller, so that all reads and writes to both connectors on the card are routed through here. Most likely the latest nvidia card doesnt do things this way anymore.
In essence, forget about chip purposes. Thats like pretending the existence of an utopia.
Then, I don't understand how the hardware mixes the "addressing modes" with the "Read Modes" and the "Write Modes"... Are the read and write modes only valid when in normal addressing mode? Also I don't understand the difference between Chain 4 mode and Odd/Even... I've read the descriptions in freevga but it seems the same thing! :
There are two steps involved.
1: the address provided by the host is translated to an address in video memory, and possibly a mask for each of the planes depending on the addressing mode.
2a: for writes, the latches are read, the written data is transformed according to the current write mode, and the output is sent to the memory. The planes that are actually written depend on the plane mask register and the mask generated in step 1 (which are afaik ANDed together).
2b: for reads, the requested address in video memory is read and the result is computed according to the read mode. The plane that is accessed depends on a register (planar mode) and/or the address (odd/even, chain 4). I haven't tested out thoroughly how everything works here, so you might want to be conservative and leave the read mode and read plane set to defaults when using oddeven or chain4 addressing.
Now, what's the problem in programming the display memory when a pixel spans across all the planes? Why don't we just enable Chain 4 mode?
Chain 4 just selects one plane out of the possible four when writing. The net effect is that a pixel spread over planes is described in 4 addresses rather than just one, and that you don't need to bother with changing the registers that select which one is being written/read.
And... what are the things that people usually call "planar mode" and "linear mode"?
planar mode: both odd/even and chain4 addressing are disabled. The address provided by the processor is mapped directly to video memory, and the read/write modes work as in the text book. This is basically the direct mapping how the VGA's video memory really works.
linear mode: Chain 4 addressing. One byte written or read from the VGA maps to exactly one byte on one plane in video memory. Normally this implies 256 color modes where one byte maps to exactly one pixel. Main advantage: easiest to program.
There is a (hopefully) more reader-friendly piece of vga documentation on the wiki:
VGA Hardware (I wrote it, all comments welcome
![Very Happy :D](./images/smilies/icon_biggrin.gif)
) . If you want some practical advice on daily vga programming you might want to consider reading "Graphics Programming Black Book" as well (freely downloadable as pdf somewhere)
HTH.