Switch from graphics mode to textmode

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
SanderR
Member
Member
Posts: 70
Joined: Tue Aug 30, 2016 1:31 pm
Libera.chat IRC: SDR

Switch from graphics mode to textmode

Post 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!
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Switch from graphics mode to textmode

Post 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.
Post Reply