Author Topic: How do I switch monitor to 24bit or 32bit color in 16bit ASM?  (Read 16778 times)

Offline ben321

  • Full Member
  • **
  • Posts: 185
I'm planning to write a 16bit DOS program that switches the computer monitor to the full 16million-colors mode, so I can do better graphics. I know I can use INT to call interrupt functions but all of those only allow up to 8-bit 256 colors in video mode 0x13. But how does a program switch the monitor to a full 24bit or 32bit color mode, like is used in most versions of Windows to display full colors?

Offline fredericopissarra

  • Full Member
  • **
  • Posts: 373
  • Country: br
Re: How do I switch monitor to 24bit or 32bit color in 16bit ASM?
« Reply #1 on: July 05, 2021, 11:56:35 AM »
It isn't easy to use WIDESCREEN graphics modes without the help of vendors drivers, but you can use relative high resolution graphics modes using VESA BIOS EXTENSIONS (VBE), through int 0x10, and deal with "banks" of memory to fill the framebuffer, in real mode.

It's easy to switch to those modes (1024 x 768 with 24 bits RGB pixels, for example) and use a 'linear frame buffer' in PROTECTED MODE. In real mode you have to use `int 0x10` to switch portions of the screen and map them in Video Memory. Why is that? Consider that real mode video memory start at physical address 0xA0000 and spans to 0xBFFFF. This gives you 128 KiB of memory available to video. With 1024 x 768, RGB mode you must have a 1024*768*3 bytes frame buffer: almost 2.4 MiB of memory (18 times more memory), sou you must break this in chunks of 64 KiB (1 segment).

Here's the specfication for VBE 3 (the last spec available), and an article from OSDev to help you understand how to use it: VESA Tutorial

Offline ben321

  • Full Member
  • **
  • Posts: 185
Re: How do I switch monitor to 24bit or 32bit color in 16bit ASM?
« Reply #2 on: September 01, 2021, 11:42:24 PM »
It isn't easy to use WIDESCREEN graphics modes without the help of vendors drivers, but you can use relative high resolution graphics modes using VESA BIOS EXTENSIONS (VBE), through int 0x10, and deal with "banks" of memory to fill the framebuffer, in real mode.

It's easy to switch to those modes (1024 x 768 with 24 bits RGB pixels, for example) and use a 'linear frame buffer' in PROTECTED MODE. In real mode you have to use `int 0x10` to switch portions of the screen and map them in Video Memory. Why is that? Consider that real mode video memory start at physical address 0xA0000 and spans to 0xBFFFF. This gives you 128 KiB of memory available to video. With 1024 x 768, RGB mode you must have a 1024*768*3 bytes frame buffer: almost 2.4 MiB of memory (18 times more memory), sou you must break this in chunks of 64 KiB (1 segment).

Here's the specfication for VBE 3 (the last spec available), and an article from OSDev to help you understand how to use it: VESA Tutorial

Int 0x10 is how to switch video modes in general, including standard VGA mode, etc. For example mode number 0 is a 40 column text mode. So that begs the question, what is the mode number for vesa mode?

Offline fredericopissarra

  • Full Member
  • **
  • Posts: 373
  • Country: br
Re: How do I switch monitor to 24bit or 32bit color in 16bit ASM?
« Reply #3 on: September 02, 2021, 09:59:28 AM »
Int 0x10 is how to switch video modes in general, including standard VGA mode, etc. For example mode number 0 is a 40 column text mode. So that begs the question, what is the mode number for vesa mode?
I've already gave you the links for VBE3 specification and for a VBE tutorial. Read them.