OSDev.org
https://forum.osdev.org/

mode 03h bank switching
https://forum.osdev.org/viewtopic.php?f=1&t=23626
Page 1 of 1

Author:  stranger [ Fri May 20, 2011 7:03 am ]
Post subject:  mode 03h bank switching

Hi, how can I switch banks in text mode 03h to access more video memory than 32KB, that adress space window at 0xb8000 allows. Thanks.

Author:  Combuster [ Fri May 20, 2011 1:15 pm ]
Post subject:  Re: mode 03h bank switching

Technically, the VGA has no VESA-style bank-switching support at all. Instead it has a plane mask register where you can enable writes to one of four separate planes. Worse, in text mode, Odd-even mode is in use which partially overrides the plane selection based on bit 0 of the address. Text mode also dedicates banks to their respective purposes: you can only use plane 0+1 for character and attribute data, leaving 128k max to use.

There are two partial solutions here:
- change the mapping from 32k at 0xb8000 to 64k at 0xa0000, which allows you to access double the memory amount without the need of any planeswitching code.
- disable odd-even mode. You can then use the mask register to switch between planes 0-3, and write either characters, attributes, or font data. You get 4x the VGA ram at your disposal, or 2x more character-attribute pairs. You might also want to make sure you're in byte mode so that the display can actually display the newly accessible characters. If you do this, you'll have to adapt all writing routines to match. It also gives more opportunity to use VGA latches if you want to bother with them.

If you do both, you have access to 64k of characters and 64k of attributes, as well as the complete font set if you feel a need to change it.

Be careful though, VGA emulation in this regard is a bit flaky. Depending on the amount of tricks you try to pull off here, you'll lose increasingly more emulators that actually do what you want. Bochs and qemu(-clones) are generally the first to go. Real hardware is pretty conformant, fortunately.

Author:  stranger [ Sat May 21, 2011 11:56 am ]
Post subject:  Re: mode 03h bank switching

I have also find out that I can map 2*64KB starting at 0xa0000 so I can access whole textmode memory (character + attribute planes interleaved) without need for any switching. So this solves my problem, which was that screen wraps around 2*64KB border that I wasnt able to access. But out of curiosity, is there a way to make screen wrap before memory planes ends, for example at the 2*16KB border which is accessible in standard mode 03h?

Author:  Combuster [ Sat May 21, 2011 3:37 pm ]
Post subject:  Re: mode 03h bank switching

There's splitscreens (see the line compare register) which you can use to approximate wrapping.

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/