Page 1 of 1

Switch from graphics mode to textmode

Posted: Tue Jun 08, 2021 4:40 am
by SanderR
Hello everyone,

First of all thanks to the author who wrote the tutorial about VGA.

The thing is, I want my OS to be able to switch back to textmode. Since the tutorial is full of warnings about unhealthy switching habbits, I would like to ask what the best method is to switch back from vga to textmode.

Thank you in advantage!

Re: Switch from graphics mode to textmode

Posted: Tue Jun 08, 2021 5:38 am
by Gigasoft
In text mode, plane 0 holds character indices, plane 1 holds attributes and plane 2 holds up to 8 different fonts with 256 characters of 32 bytes each. Each byte represents one character row.

Important register settings:
Graphics register 5 should be set to 0x10. (chain odd/even when reading, 2 bit mode off, 8 bit mode off)
Graphics register 6 should be set to 0x0e. (graphics mode off, chain odd/even when writing, decode B8000-BFFFF - required for Bochs)
Sequencer register 1 bit 2 should be set. (word mode)
Sequencer register 2 should be set to 0x03. (write to planes 0 and 1)
Attribute register 16 should have bits 0 and 6 cleared. (no graphics mode, no 8 bit color)
CRTC register 9 bits 0-4 should be programmed with the font height minus one.
CRTC register 20 should have bits 5 and 6 cleared. (no doubleword addressing)
CRTC register 23 should have bit 6 cleared. (word mode)

Other things to consider are things such as the cursor, underline location, blinking, font selection, 9 dot mode and line graphics continuity mode.