Colour integers and Bit depths

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Colour integers and Bit depths

Post 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
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
Masterkiller
Member
Member
Posts: 153
Joined: Sat May 05, 2007 6:20 pm

Post 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 :)
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Colour integers and Bit depths

Post 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 :wink: Try writing 0xffffffff (white) instead.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post 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
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post 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.
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post 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 =\
~ Lukem95 [ Cake ]
Release: 0.08b
Image
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post 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
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post 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.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post 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
User avatar
lukem95
Member
Member
Posts: 536
Joined: Fri Aug 03, 2007 6:03 am
Location: Cambridge, UK

Post 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.
~ Lukem95 [ Cake ]
Release: 0.08b
Image
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Post 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
Post Reply