Page 1 of 1
Colour integers and Bit depths
Posted: Tue Mar 11, 2008 5:08 am
by lukem95
Im fiddling around with my bochs VBE driver at the moment, and have come to the bottom (it was quite obvious) as to why i cannot print any pixels. Well... at least i hope this is why anyway.
it sets fine, as the log reports, but i just get a blank screen. I'm using the LFB, and was sending pixel values there with no response...
this was because i was trying to send for example a "2" as the colour value in 32 bit mode.
My question is, what format do i need to send the colour code in (i know its RRRGGGBBB or something). And is there a particular way i need to do this?
thankyou for your help
Posted: Tue Mar 11, 2008 5:16 am
by Masterkiller
The value of the color in register in 32-bit depth color is 0xXXBBGGRR into memory it converts to RR GG BB XX. Try to use a loop like REP STOSD filling all the Linear Frame Buffer with the value of EAX, you should suppose to see filled screen with one color.
P.S. is pretty slow - for me it takes about half to one second to fill the screen for 800x600
Re: Colour integers and Bit depths
Posted: Tue Mar 11, 2008 5:17 am
by Combuster
lukem_95 wrote:this was because i was trying to send for example a "2" as the colour value in 32 bit mode.
That'd be near-black. No wonder you can't see a thing
Try writing 0xffffffff (white) instead.
Posted: Tue Mar 11, 2008 5:43 am
by lukem95
it still hates me i swear
i have no idea what im doing wrong.
im using
Code: Select all
void test_bochs()
{
unsigned long* tmp = (unsigned long*)0xE0000000;
for(int j=0; j < 768; j++) //y
{
for(int i=0; i < 1024; i++) //x
tmp[1024*j+i] = 0xffffffff; //white
}
}
to test it, and all i get is a blank (but resized) screen :S
Posted: Tue Mar 11, 2008 6:48 am
by bewing
Do you have a delay loop after this?
Bochs will only refresh the screen every 30K opcodes or something.
(oops -- right -- you are looping 768K times, so of course you should get an update)
Do you have VM paging turned off for this routine? You are sure you are writing to
physical memory directly?
You are certain that you issued:
Code: Select all
mov al, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED ; enable display
out dx, ax
-- the screen will always be black after a VBE_DISPI_DISABLED command.
Posted: Tue Mar 11, 2008 7:07 am
by lukem95
Code: Select all
<snip>
WriteCommand(VBE_DISPI_INDEX_ENABLE, VBE_DISPI_ENABLED | VBE_DISPI_LFB_ENABLED );
...
static void WriteCommand(unsigned short index, unsigned short value)
{
outw(VBE_DISPI_IOPORT_INDEX, index);
outw(VBE_DISPI_IOPORT_DATA, value);
}
</snip>
very sure =\
Posted: Tue Mar 11, 2008 7:23 am
by AJ
Hi,
What about the paging thing? Are you using paging? If so, is 0xE0000000 definitely paged in? If you have interrupt handlers which print info in text mode, your BSOD for a page fault exception would not appear as you are now in VESA mode.
Cheers,
Adam
Posted: Tue Mar 11, 2008 7:32 am
by lukem95
i have a beep function in my page fault code, because i had a problem with 16 colour VGA a while ago, and it meant that i couldn't print text in graphical mode.
so... it could be something to do with it going to a virtual address... but its not page faulting.
Posted: Tue Mar 11, 2008 9:34 am
by jal
lukem_95 wrote:so... it could be something to do with it going to a virtual address... but its not page faulting.
Have you tried disabling the paging, or is that going to crash the rest of your OS (don't know how far you got)? If so, try to switch to VESA and put something on screen in your start-up code (before you activate paging), see if it works there.
Oh, and this may seem dumb, but have you checked the Bochs output? Does it say it actually switches to VESA mode? And what about disabling the linear frame buffer and writing to 0xA0000?
JAL
Posted: Tue Mar 11, 2008 1:53 pm
by lukem95
ok,
bochs tells me i'v switched ok:
Code: Select all
00020189667i[CLVGA] VBE set xres (1024)
00020189687i[CLVGA] VBE set yres (768)
00020189707i[CLVGA] VBE set bpp (32)
00020189728i[CLVGA] VBE enabling x 1024, y 768, bpp 32, 3145728 bytes visible
Enabling paging won't kill my os... but a lot of stuff needs it, so id have to turn off a lot of features. ill try it before paging starts and post the results
...it is my paging code
thankyou for all your help.
Posted: Wed Mar 12, 2008 2:00 am
by jal
lukem_95 wrote:...it is my paging code :( thankyou for all your help.
In general, when more than one thing can be the cause of something going wrong, eliminate all but one, and go from there. Having multiple variables to take into account makes for difficult debugging (as you've experienced first hand).
JAL