I'm creating a graphical operating system, I'm currently using the mode 19 that I launch before the protect mode but I would like to have a higher resolution thanks in advance. My graphical activation in asm
graphicmode:
mov ax, 19; here select which mode you want
int 16
Thank you for your help :) My program run but I draw in 0xA0000 and I think my buffer is insufficient because I saw just a part of my screen. Can you help me? How can I use a bank switching? image
How to switch to Super VGA in c or asm?
For old 80x86 PCs with BIOS; almost all video cards support VBE (see https://en.wikipedia.org/wiki/VESA_BIOS_Extensions ). In this case, your code will want to ask it for a list of video mode numbers, then use those numbers to get information about each video mode and filter out video modes your software doesn't support, then choose the "best" video mode that is supported, and set that video mode. This is necessary because different computers support different video modes (you can't just expect a specific video mode like 800*600 to exist because your code will be broken and unusable when that video mode doesn't exist). There are 3 different ways to use the VBE functions - using real mode, using a 32-bit protected mode interface that was introduced with VBE2.0 that became obsolete/optional in VBE3.0, and using a 16-bit protected mode interface that was introduced in VBE3.0; however some of the functions aren't supported in some of the cases (e.g. the VBE2.0 32-bit protected mode interface mostly only supports functions that would be used after a video mode is set).
This means that (after boot), for BIOS, to support all video cards (with/without VBE, with/without 32-bit protected mode interface, and with/without 16-bit protected mode interface) changing video modes after boot is a major pain; especially when the OS is 64-bit and can't use virtual8086 mode (and has to implement an emulator/interpreter to execute real mode code without breaking all the OS's other device drivers).
For modern 80x86 PCs with UEFI (see https://en.wikipedia.org/wiki/Unified_Extensible_Firmware_Interface ), there are UEFI functions that do similar to VBE (get list of video modes, get details for video modes, set a video mode). The big differences are that the API supports multiple monitors and multiple video cards (VBE doesn't); and you can't use any of these functions after boot (after calling ExitBootServices()
).
The other option is to write native video card drivers instead of using the firmware/relying on the video card's ROM. This is very complex and very time consuming (because each video card needs different code); and you will always need a fallback to handle "Oops, video card is so new that I haven't written a native video driver for it yet", so it doesn't avoid needing to support the use of firmware (UEFI or BIOS/VBE) to find/set a video mode.
For an OS to work on all cases (old computers with BIOS, new computer with UEFIs, with/without native video driver) the only sane approach is:
boot loader sets up a default video mode for all monitors/video cards that it can, using VBE (if boot loader is designed for BIOS) or UEFI (GOP or UGA, if boot loader is designed for UEFI); then tells the kernel/OS details (address of frame buffer, pixel format, bytes per row of pixels, horizontal & vertical resolution) for each monitor, then OS uses those details to draw graphics; so that OS has no reason to care if the boot loader was using BIOS or UEFI.
Later during boot; OS tries to start a native video driver for each video card. If one is found, then OS can use it to change video mode and may try to find a better video mode (that wasn't given as an option to boot loader) during boot.
if there is no suitable video driver, then OS can't change video modes after boot; because supporting this is only possible if the firmware was BIOS and (for BIOS) it's too much hassle to bother. Note that the OS could still set some "video mode preferences" information somewhere on disk (e.g. in a boot config file) that boot loader will look for, and then reboot to get the boot loader to choose a different mode.
Note that modern monitors have a preferred/native resolution (and do "often low quality" scaling if the resolution is different) so for each monitor there's only really one good video mode that anyone would want to use; and if the OS isn't awful it will provide "resolution independence" (see https://en.wikipedia.org/wiki/Resolution_independence ). There are only 2 cases where the user would actually want to change video modes after boot - they've replaced their monitor, and they're doing it for performance reasons. Fortunately people don't replace their monitor very often (so rebooting is only a minor inconvenience in that case); and performance should not be a problem unless the user is trying to play 3D games (where "frames per second" is more important and the amount of processing is significantly higher) where the user is going to be annoyed anyway (unless there's a native video driver that supports hardware accelerated 3D). In other words, if you don't have a native video driver and can't change video modes after boot; almost nobody will care.
If you do expect the boot loader to set up video mode/s; then it's going to depend on the which boot loader. Most generic boot loaders (e.g. GRUB) will set a video mode for you and tell you the information for the video mode it set, so you don't have to do it at all.
If you're writing your own boot loaders; then the relevant specifications for VBE and UEFI are easily obtainable online (e.g. see the "external links" section of the corresponding Wikipedia pages linked to above); so you can read the specs and then try to write your code (and ask a more specific question if you have trouble).
My program run but I draw in 0xA0000 and I think my buffer is insufficient because I saw just a part of my screen. Can you help me? How can I use a bank switching?
For the old VGA "320*200 with 256 colors" mode everything fits in 64 KiB so you don't need any bank switching.
Note that for higher resolution video modes you will either need bank switching (which is awful for performance, not supported for UEFI, and too painful to bother with for BIOS) or you will have to use protected mode or long mode to access a linear frame buffer. Of course a graphical OS using higher resolution video modes is going to have many MiB of graphics data in RAM for things like icons and pictures and buffers; so real mode (which can't access more than about 640 KiB of RAM) is completely unusable anyway. For example, for performance reasons; you will end up needing a buffer in RAM where you do all the drawing (and then, when all the drawing is finished, you'll copy the resulting pixel data from your buffer in RAM to the video card's frame buffer); and for a video mode like "800x600 with 32 bits per pixel" that buffer in RAM will cost you about 1875 KiB of RAM all by itself.