VGA mode hack

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
mariuszp
Member
Member
Posts: 587
Joined: Sat Oct 16, 2010 3:38 pm

VGA mode hack

Post by mariuszp »

There isn't much information on the internet about this, and I really want it quite simple. I've made a panic screen, and I think it may have trouble when the GUI is enabled. My question is: how can I switch to 80x25 16-color text mode by modifying a VGA register or something? I can't use the BIOS in Protected Mode, and setting up VM86 is pointless when I only want this one, simple procedure Any help?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: VGA mode hack

Post by Combuster »

If you're using a VESA mode, forget it. You need VBE or a dedicated device-specific driver to tear it down as it is not in VGA mode. Most devices I have actually developed native drivers for will stick in graphics mode whatever VGA writes you do, with results varying between no change to garbled displays or even defective signals that can potentially blow up monitors or require epilepsy warnings.

If you're in a VGA mode, it is still some work to do it properly:
- Unlock VGA registers, disable screen
- Restore the font (it must come from somewhere, and your typical sources may not be reliable anymore)
- Write a register image corresponding to mode 3h
- Reload the DAC and palettes if they might be modified. (available regdumps occasionally include the palette by default)
- Enable screen again and write text.

In other words, there's no quick hack to do it and be fairly sure you get a visible coredump. If you want a simple and reliable method during crashes, you may want to consider setting up a serial connection instead.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
turdus
Member
Member
Posts: 496
Joined: Tue Feb 08, 2011 1:58 pm

Re: VGA mode hack

Post by turdus »

When I faced the same problem, I searched the wiki, and found this in a minute:
http://files.osdev.org/mirrors/geezer/o ... cs/modes.c
quite useful.
Post Reply