VGA font issues

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
latios
Posts: 2
Joined: Mon Nov 04, 2019 2:29 pm

VGA font issues

Post by latios »

Somewhy if I write VGA font when I am entering 320x200 to 0xb800 my screen goes black. However, if I dont - it works, but when i return to 80x25 char mode all characters look like two vertical lines. Writing font to 0xA000 doesnt help at all, the screen in gfx is black. Can somewho help?
https://github.com/nergzd723/ethanium
Gigasoft
Member
Member
Posts: 871
Joined: Sat Nov 21, 2009 5:11 pm

Re: VGA font issues

Post by Gigasoft »

Not sure of what you mean. There is no font in graphics mode, of course. The font for character mode is stored in plane 2, so you have to set the map mask register to 4 and disable odd/even addressing. But if you use the BIOS to set up character mode, it will write the font for you. If it doesn't work right, check if you may have corrupted the BDA or the EBDA.
User avatar
bzt
Member
Member
Posts: 1584
Joined: Thu Oct 13, 2016 4:55 pm
Contact:

Re: VGA font issues

Post by bzt »

Hi,
latios wrote:Somewhy if I write VGA font when I am entering 320x200 to 0xb800 my screen goes black. However, if I dont - it works, but when i return to 80x25 char mode all characters look like two vertical lines. Writing font to 0xA000 doesnt help at all, the screen in gfx is black. Can somewho help?
https://github.com/nergzd723/ethanium
I haven't looked at your code yet, but what you describe looks like you're not setting the planes right.

VGA is capable of using several memories at addresses 0xB8000 and 0xA0000. You have to tell the card writing IO registers, which plane you want. Some video modes consist of more planes (like CGA), while others are using one contiguous plane (like the 320x200x256 mode). Regardless you can map the font memory too at those addresses, in which case you won't be accessing the frame buffer, but you'll accessing the font memory. That's the reason why I think you accidentally set up font access, therefore what you write does not go to the framebuffer (screen remains black), and when you return to 80x25 all font bitmaps are gone.

And another thing, as @Gigasoft pointed out, in graphical modes where you have pixels (like 320x200) the font memory is not used by the video card. You have to draw your own characters. VGA fonts are only rendered by the card in teletype mode (like 80x25 char mode), which describes the screen as attribute+character pairs, not pixels. You could use a BIOS interrupt to draw the font for you in graphical mode (that would access the font memory, read the bitmap, then switch back to framebuffer and draw the bitmap), but if you rely on BIOS then you should not set VGA registers yourself as that will confuse the BIOS routine.

Cheers,
bzt
Post Reply