Issues with VGA video memory banking

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
Chickin
Posts: 2
Joined: Sat Mar 07, 2026 12:58 pm
Location: Toulouse, France
Discord: @chick_chicky
GitHub: https://github.com/ChickChicky

Issues with VGA video memory banking

Post by Chickin »

I'm at the very beginning of my OS; I have a boot loader set up that loads kernel code, sets a video mode and jumps to the kernel (in protected mode).
I have implemented basic font rendering as it runs in a graphical mode.
Up until now, I have been using video mode 13h. However, I need something much larger and with more colors, so for testing I am using mode 117h (detecting supported modes is not the main focus right now, I assume that 117h is).
However, I am having trouble with accessing the whole screen; as it is, I have about 32 lines accessible at address A0000h. Using the 10h interrupt with ax=4F05h and bx=0000, setting dx to the window index does shift everything down once in the kernel. However, I need to access the whole screen while in protected mode, and I can't use BIOS interrupts. So I tried both while still in real mode and after switching into protected mode to write to the VGA register 0Dh on port 3D5h, to no success.
This is how my code for video modes looks like so far:

Code: Select all

; Switch to mode 117h
mov ax, $4F02
mov bx, $0117
int $10

; Switching to window 1 (working)
mov ax, $4F05
mov bx, $0000
mov dx, $0001
int $10

; Should do the same? (seemingly does nothing)
mov dx, $03D4 ; also tried with $03B4
mov al, $0D
out dx, al
inc dx
mov al, $01
out dx, al
Maybe I'm wrong, but RetrOS-32 seems not to have to deal with that, despite also having a 1024x768x256 mode that would not fit into the default video display memory.
I have tried searching about this online and on the forum, to no avail. Am I misunderstanding something?

Also, techhelpmanual.com (which is where I first read about how to change the window) also mentions that the window can be changed with the function specified in the mode info structure, which I have not attempted to call yet; how do I pass arguments to it and would it still work after switching to protected mode?

(The OS is ran inside of QEmu, and is using Fasm for the assembler)

TLDR; Once in protected mode, how does one switch the bank index with SVGA modes with multiple banks?

Any help would be greatly appreciated.
alexfru
Member
Member
Posts: 1123
Joined: Tue Mar 04, 2014 5:27 am

Re: Issues with VGA video memory banking

Post by alexfru »

0x100+ video modes are VESA, not VGA modes.

What you want to do is set such a mode with the "Linear Frame Buffer" (LFB) enabled (set bit 14 of video mode to 1).
You'll also need to query the physical address of the buffer.
See vesalfb.c for an example.

If the LFB is not available in your video card, you're kinda screwed.
You'll need to either call the BIOS (switching CPU modes every time) or emulate BIOS' instructions in protected mode.
Or just stick to VGA modes, 320x200x8bpp or 640x480x4bpp.

I'm pretty sure this has been asked and discussed many times before.
Chickin
Posts: 2
Joined: Sat Mar 07, 2026 12:58 pm
Location: Toulouse, France
Discord: @chick_chicky
GitHub: https://github.com/ChickChicky

Re: Issues with VGA video memory banking

Post by Chickin »

My bad,
I did read several times that VESA modes used a LFB, whose address was supposed to get returned by the 4F01h call, but I always was coming back to this page which obviously doesn't include the VESA mode info. Moreover, RetrOS-32 does in fact use the memory location provided in the mode info.
Thanks for the help!
Post Reply