ViTi95 wrote on 2022-01-31, 17:36:
Using EGA/VGA Write Mode 2 it's a little bit complicated, you should read this book, it explains it very well with some examples http://vtda.org/books/Computing/Programming/E … DyckKliewer.pdf
The VGA 80x200 mode is set by changing the number of scanlines to draw per character in 80x25 text mode. In this "mode", only the first row is drawn per character (it's similar to the CGA 160x100 16 color hack). You can checkout how it's done in this repo: https://github.com/drwonky/cgax16demo
Also FastDoom supports this mode, the code it's a little bit messy but shows fine how to draw in this mode https://github.com/viti95/FastDoom/blob/maste … ASTDOOM/i_ibm.c, methods VGA16_DrawBackbuffer and I_InitGraphics.
Thanks. I'll have to check that out.
I also discovered something. If I set the chaining bit in graphics card sequencer register 4. It does something quite interesting (at least in DosBox, not sure about real hardware). It changes it from the normal EGA image-planar mode (where you have to select each plane you want to write to with sequencer register 2), to a byte-planar mode (where no plane selecting via register is required, as each consecutive byte writes to the next plane for that set of 8 pixels, and increments to the next set of 8 pixels after going through 4 bytes). This is a good compromise between packed pixel, where each byte contains RGBI data for 2 pixels, and fully planar mode where you can only write to one color channel at a time (switching color channels with a separate editing of sequencer register 4). Once this byte-planar mode is active, you don't need to do any more editing of the graphics card's registers. This means many fewer lines of code, as you don't need to keep switching color planes, and you also don't need to worry about the complexities of using Write Mode 2 (which from what I have read, operates in a very counterintuitive way, requiring you to read VRAM, not just write to it, in order to display an image).
In the following examples, each letter represents a single bit:
Normal EGA mode works like this (screen pixel dimensions are 16x4 in this example, and byte width is 2)
Four planes, one for each color channel
Plane B
BBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBB
BBBBBBBBBBBBBBBB
Plane G
GGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGG
GGGGGGGGGGGGGGGG
Plane R
RRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRR
RRRRRRRRRRRRRRRR
Plane I
IIIIIIIIIIIIIIII
IIIIIIIIIIIIIIII
IIIIIIIIIIIIIIII
IIIIIIIIIIIIIIII
Byte planar EGA mode works like this (screen pixel dimensions are 2x4 in this example, and byte width is 8 )
One plane with four color channels
RRRRRRRRGGGGGGGGBBBBBBBBIIIIIIIIRRRRRRRRGGGGGGGGBBBBBBBBIIIIIIII
RRRRRRRRGGGGGGGGBBBBBBBBIIIIIIIIRRRRRRRRGGGGGGGGBBBBBBBBIIIIIIII
RRRRRRRRGGGGGGGGBBBBBBBBIIIIIIIIRRRRRRRRGGGGGGGGBBBBBBBBIIIIIIII
RRRRRRRRGGGGGGGGBBBBBBBBIIIIIIIIRRRRRRRRGGGGGGGGBBBBBBBBIIIIIIII