Page 1 of 1

24bit vesa mode is not working properly [SOLVED]

Posted: Mon Aug 02, 2010 12:33 am
by Chandra
Last time I encountered a problem with the 1024x256x256color vesa mode, which I got the solution. This time I got struck in a new problem. First of all,let me make things clear.
I've been writing real mode DOS like 16 bit OS with GUI and extended mode support. I've been trying to implement GUI switching from 265 colors to True colors and vice versa.I've now been able to implement the 256 colors properly but when I switched to 24bit Vesa mode(using inline assembly in kernel) I'd encountered the following problem:

1.When I implement the putpixel function it is able to display only 3 colors & I think those colors are red, white and cyan(not sure though).I know I've passed the color bytes to the video memory properly(i.e 8bits red, 8bits green and 8bits blue) but even then any mixture of these color bytes donot output desired color.
2.When I output a pixel to (2,0) it displays a red color at that place.Following that if i output a pixel to (3,0) it displays cyan color again at (2,0). And again if I output a pixel to (4,0) it displays white color at again (2,0). Now if output a pixel to (5,0) then only the pixel moves one place right with the initial color red.This continues with every pixels. Moreover the origin(0,0) is also shifted to some place at right. What's going on?

I'm sorry to write long explanations but it because short explanation can't make things clear. Please Help.

Re: 24bit vesa mode is not working properly

Posted: Mon Aug 02, 2010 3:12 am
by djmauretto
Hello :D
Your calculation of memory address is wrong...
This is true:

Code: Select all

Pixel 2,0:
Memory OFFSET 0 1 2 3 4 5 6 7 8
              x x x x x x B G R

Pixel 3,0:
Memory OFFSET 0 1 2 3 4 5 6 7 8 9 10 11
              x x x x x x x x x B G  R

Pixel 4,0:
Memory OFFSET 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 
              x x x x x x x x x x x  x  B  G  R

Pixel 5,0:
Memory OFFSET 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
              x x x x x x x x x x x  x  x  x  x  B  G  R

Re: 24bit vesa mode is not working properly

Posted: Mon Aug 02, 2010 6:28 am
by NickJohnson
Each pixel in video memory is stored in three consecutive bytes (i.e. 24 bits). Based on your description, you are somehow trying to write all three color bytes to the same memory byte. Check that you're incrementing the pointer after plotting each channel, or doing something equivalent with offsets, and spacing the pixels three bytes apart.

Re: 24bit vesa mode is not working properly

Posted: Wed Aug 04, 2010 10:00 pm
by Chandra
Thanks guys. Now,will you please tell me what is the mode no. for 32 bit colors mode. I tried mode 0x138 but it didn't worked with bochs or qemu. If anybody knows please tell me.

Re: 24bit vesa mode is not working properly

Posted: Wed Aug 04, 2010 11:51 pm
by computafreak
There's information on Wikipedia which contains a large table of possible values for mode numbers, but you shouldn't rely on them. Starting with VBE 2, VESA deprecated the process of assigning or using standard mode numbers; your code has to use the BIOS or some other way to enumerate all the video modes and pick the best one. The OSDev Wiki has some information about that in the VBE entry.