I would like to know how to display more than 256 colors in DOS I already know about the color palette which can hold 256 colors and can be changed, but as soon as you change them the colors on the screen change. So how would I display more than 256 colors on the screen? It seems to me that this would be possible, since in my OS (windows) it looks as if it can display more than 256 colors. Any resources that can show me how to do this would be helpful, thanks.

Dani AI

Generated

Short answer for : classic VGA 8‑bit modes (Mode 13h and other 256‑colour VGA modes) use one byte per pixel as an index into a 256‑entry palette, so you cannot show more than 256 distinct palette entries at once on that hardware mode. (en.wikipedia.org)

What Windows appears to do is use SVGA/VESA "truecolor" modes (15/16/24/32 bpp) provided by the card and its drivers. Under DOS you can request those modes through the VESA BIOS Extensions (VBE), which expose mode lists, bits‑per‑pixel and either a banked or a linear frame buffer. (en.wikipedia.org)

Practical workflow you can follow in DOS real mode:

  • Call VBE func 0x4F00 to get controller info and the mode list.
  • Call 0x4F01 per mode to find one with the desired BitsPerPixel and check the ModeInfo block (PhysBasePtr and the LFB bit).
  • Call 0x4F02 to set the mode (OR the mode number with 0x4000 to request the Linear Frame Buffer if supported).
    If the card only supports banked access, use VBE func 0x4F05 to switch the 64KB window while drawing. If you get an LFB address you will typically need a DPMI/DOS‑extender or unreal/protected mode to map and use that physical address from your program. Example calls and mapping patterns are documented in VBE/DJGPP resources. (android.googlesource.com)

If you cannot use truecolor (hardware/BIOS lacks support), old demos used mid‑frame palette changes (raster interrupts) to fake extra colours per scanline — impressive but timing‑sensitive and fragile on many modern cards and emulators. For reliable >256 colours in DOS, VBE truecolor modes plus proper LFB mapping (or banked access) is the practical route. (en.wikipedia.org)

Assembly snippet (conceptual) for the set‑mode step:

; get VBE controller info
mov ax, 0x4F00
mov es, seg vbeInfo
mov di, offset vbeInfo
int 0x10
cmp ax, 0x004F
jne .no_vbe

; set mode (request LFB)
mov ax, 0x4F02
mov bx, mode_number | 0x4000
int 0x10
cmp ax, 0x004F
jne .set_failed

Recommended Answers

All 2 Replies

You can't display more than 256 different colors at the same time with VGA.

I found a site which says that you can display 262144 (2^18; 6 bits each for red, green and blue) colors with VGA (that means you will have to modify the palette to display other colors). Here's the link (it's in C, though, but you should be able to make sense out of it): http://www.theparticle.com/pgraph.html

Read in "The Palette..." section.

Hope this helps.

You can't? It seems like you can because displaying high quality movies and images themselves looks as if they use more than 256 colors at once, is there something else that can be used to display more colors on the screen? But if you can't then thanks for the link.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.