Question

Is it possible to program in a color depth of 24 bits on a DOS machine? I know VGA supports 8 bit color depth, but is there a way to finagle out 24 bits? Research on Google has turned up nothing. I am programming on FreeDOS instead of MS-DOS, if that affects the answer.

Was it helpful?

Solution

Yes, it is possible. You should read about VESA and appropriate drivers. Here is several functions

Then you will be able to do:

  mov ax,4f02h
  mov bx,103h
  int 10h

This usually provides ax with 004fh if VESA is inited and 103h (800x600x256) mode is set, you may use 11bh (1280x1024x16M) for example (http://www.delorie.com/djgpp/doc/rbinter/it/83/0.html)

UPDATE: I'm attaching some code from my very very very old pascal program:

{ preserve space for vesa info structure, in asm it will look like sets of db, dw }
tmodes=array[0..0] of word;
    tvesainfo=
     record
      abSignature:array[1..4] of char;
      lwVersion,hwVersion:byte;
      pfszOEMStr:pchar;
      rAbilities:longint;
{$F+}
      pfawModes:^tmodes;
{$F-}
      abData:array[1..238] of byte;
     end;

{ just pascal function, which calls ax 4f00 int 10h, passes address of structure above to fetch information from vesa driver, can be just simplified to asm block in it }
function vesatest(var vi:tvesainfo):boolean;
var
   os,sg:word;
   res:word;
begin
 os:=seg(vi);
 sg:=ofs(vi);
 asm
  mov ax,4f00h
  mov es,os
  mov di,sg
  int 10h
  mov res,ax
 end;
 if res=$004f then vesatest:=true
  else vesatest:=false;
end;

{ call function above and display basic information about vesa driver installed }
 if vesatest(vesainfo)=false then
  begin
   writeln('This computer doesn''t have VESA');
   halt(254);
  end;
 writeln('VESA signature - ',vesainfo.abSignature);
 writeln('VESA version - ',vesainfo.hwVersion,'.',vesainfo.lwVersion);
 writeln('VESA manufacturer - ',vesainfo.pfszOEMStr);

OTHER TIPS

Most of the modern videocards comes with a VBE2-Bios or a VBE3-Bios and with an own modetable of vbe modenumbers maybe with a resolutions up to 2048x1536 pixel and with 8, 15 or 16, 24 or 32 bits per pixel and with a aspect ratio of 4:3, 4:5, 16:9 and 16x10.

Note: Starting with VBE version 2.0, VESA will no longer define new VESA mode 
numbers and it will no longer be mandatory to support these old mode numbers
(....from the older VBE 1.x modelist).

So the VBE-modenumber can be differrent from VBE2/3-bios to VBE2/3-bios. Maybe some vbe-bios provides the same resolutions, but uses different modenumbers. Starting with VBE version 2.0 we have to use the modetable that comes within the vbe-bios and we habe to check each number by number to become the mode specific information of each number for to know wich resolution and how many bits per pixel we can use with it.

More details can be found in the public ducument "vbe3.pdf" on vesa.org (costfree, but need register and login).

...

At last i have written a little pure DOS based demo(with asm sourcode) that shows how to use a videomode with an own CRT-parameter table. This demo is using a resolution of 1024x768x32 with 100hz refreshrate. Addititinal this demo use the linear framebuffe(LFB; located in the 4.GB) and VBE hardware triple buffering.

For to write to the LFB using 32bit adresses this demo switch into the 16 bit unrealmode. So it can not be used together with EMS memorymanager like EMM386.EXE. Tested with a MSI Geforce 4 TI4200(64MB; AGPx4) and a 19" CRT from Samsung and a 19" CRT from Samtron both with a capacity of 96 khz and 160hz. www.alice-dsl.net/freecracmaps/Tool/Neutrip.zip

Dirk

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top