VGA in Pmode Not Working

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.
purage
On Probation
Posts: 119
Joined: Wed Feb 11, 2009 1:04 am

Re: VGA in Pmode Not Working

Post by purage »

Here is my real mode GDT:

Code: Select all

gdt:
	dw 0, 0, 0, 0	

	db 0xFF		
	db 0xFF		
	db 0x00
	db 0x00
	db 0x00
	db 10011010b
	db 0xCF
	db 0x00

	db 0xFF		
	db 0xFF		
	db 0x00
	db 0x00
	db 0x00
	db 10010010b
	db 0xCF
	db 0x00

	db 0xFF		
	db 0xFF		
	db 0x00
	db 0x00
	db 0x00
	db 11111010b
	db 0xCF
	db 0x00

	db 0xFF
	db 0xFF
	db 0x00
	db 0x00
	db 0x00
	db 11110010b	
	db 0xCF		
	db 0x00

	db 0x00		
	db 0x00
	db 0x00
	db 0x00
	db 0x00
	db 0; 10001001b
	db 0; 01000000b
	db 0x00

	;; code segment for realmode
	db 0xFF, 0xFF
	db 0, 0, 0
	db 0x9A
	db 0x8F, 0

	;; data segment for realmode
	db 0xFF, 0xFF
	db 0, 0, 0
	db 0x92
	db 0x8F, 0

gd_reg:
	dw 8192             ;<-- (with paging, should this be 4096?)
	dd gdt
Here is where cr0 gets set:

Code: Select all

	cli

	mov eax, cr0
	or al, 1
	mov cr0, eax

	jmp 0x8: _protected ; switch to 32 bits
I hope this was what you were looking for. thank you.
purage
On Probation
Posts: 119
Joined: Wed Feb 11, 2009 1:04 am

Re: VGA in Pmode Not Working

Post by purage »

I figured out what I should do. I will just enable 0x115 mode, enable paging, and map the LFB address to an address accessible to my kernel. I have a pretty good idea of what needs to be done and I already converted my loader to do the VESA mode switching part, so I am hoping that I can pull this off and start working with some prettier colors real soon. thanks anyway for looking at my code.
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: VGA in Pmode Not Working

Post by Combuster »

This is all like
"lets build the skyscraper because I couldn't be bothered to fix the fundament supporting it"

in other words: Bad Idea(tm)
"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 ]
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: VGA in Pmode Not Working

Post by jal »

Combuster wrote:This is all like "lets build the skyscraper because I couldn't be bothered to fix the fundament supporting it"
I thought it was more like "let's build a skyscraper because I failed to build a hut", but yeah, that is a bad idea. Somehow, however, I think the OP cannot be bothered, and will start the thread "VESA in Pmode Not Working".


JAL
User avatar
Creature
Member
Member
Posts: 548
Joined: Sat Dec 27, 2008 2:34 pm
Location: Belgium

Re: VGA in Pmode Not Working

Post by Creature »

Love4Boobies wrote:INDEX = (Y * 320 + X)
Are you sure that's correct? What about the colour depth?

PixelId = (Coord.Y * ScreenWidth + Coord.X) * ( ScreenBpp / 8 ))

Where ScreenBpp = Bits Per Pixel and PixelId is the index of the video buffer in bytes.
When the chance of succeeding is 99%, there is still a 50% chance of that success happening.
eddyb
Member
Member
Posts: 248
Joined: Fri Aug 01, 2008 7:52 am

Re: VGA in Pmode Not Working

Post by eddyb »

Creature wrote:
Love4Boobies wrote:INDEX = (Y * 320 + X)
Are you sure that's correct? What about the colour depth?

PixelId = (Coord.Y * ScreenWidth + Coord.X) * ( ScreenBpp / 8 ))

Where ScreenBpp = Bits Per Pixel and PixelId is the index of the video buffer in bytes.
He assumed a 8 bit depth and the width 320. But you are right, that's how it can be calculated for different depths.
purage
On Probation
Posts: 119
Joined: Wed Feb 11, 2009 1:04 am

Re: VGA in Pmode Not Working

Post by purage »

Actually smart mouth, I could start a thread with "Vesa in Pmode is working!!" And, all I asked for was some help, and I didn't get it because your moderator was too focused on my posting technique rather than my question and no one else offered up any suggestions, so I researched my own way, found it, implemented it, and now I don't need any help; case closed. Have a nice day. :twisted:
User avatar
Zenith
Member
Member
Posts: 224
Joined: Tue Apr 10, 2007 4:42 pm

Re: VGA in Pmode Not Working

Post by Zenith »

purage wrote:so I researched my own way, found it, implemented it, and now I don't need any help; case closed. Have a nice day.
I thought you were supposed to do that BEFORE you post about your problems? :twisted:

Oh well, congratulations - mind telling the forum what was wrong in your original code?
"Sufficiently advanced stupidity is indistinguishable from malice."
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: VGA in Pmode Not Working

Post by jal »

Zenith wrote:Oh well, congratulations - mind telling the forum what was wrong in your original code?
He probably won't, since instead of him looking cool (in his mind, for finding his problem) he'll look stupid (since no doubt it's a silly bug.


JAL
purage
On Probation
Posts: 119
Joined: Wed Feb 11, 2009 1:04 am

Re: VGA in Pmode Not Working

Post by purage »

Oh well, congratulations - mind telling the forum what was wrong in your original code?
Sure. It was a silly bug, my VESA driver didn't exist!
jal
Member
Member
Posts: 1385
Joined: Wed Oct 31, 2007 9:09 am

Re: VGA in Pmode Not Working

Post by jal »

purage wrote:Sure. It was a silly bug, my VESA driver didn't exist!
Must. Resist. Feeding. The. Troll.


JAL
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: VGA in Pmode Not Working

Post by Combuster »

@purage:

In every post I have posted suggestions as to what might be causing the problem. I am also trying to make your posting be more productive in the ability to get a response (which includes stripping emotional sentences, including source code - full source code - leaving out details is exactly what makes us miss the problem).

What you decided to post afterwards is not helpful to anybody and only constitutes a fight, so be careful with that in the future.

@jal:
There are sometimes when your freudian skills are better left unspoken for the greater good (i.e. not to offend people).

Thread locked
"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 ]
Locked