How To? -- Switch to 80x50 with in/outs VGA registries

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
StrangeBrew
Posts: 7
Joined: Tue Feb 01, 2011 6:37 pm

How To? -- Switch to 80x50 with in/outs VGA registries

Post by StrangeBrew »

Hello.

Disclaimer: I promise I'll RTFM/STFW later in life.

I'd like to use the 80x50 textmode resolution. I can't use BIOS interrupts because I'm in protected mode.
I'm sure there's a way of using in and out with the VGA registries so that the 80x50 mode is selected. Anybody have some free of charge code snippets I can use?

Thank you for reading.
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: How To? -- Switch to 80x50 with in/outs VGA registries

Post by Combuster »

Disclaimer: I promise I'll RTFM/STFW later in life.
I'll murder you now, but it doesn't matter because I promise I will stick to the rules after having done so. :roll:
Anybody have some free of charge code snippets I can use?
You only need one line: set the character height from 16 to 8 and your goal is achieved.
"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 ]
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by egos »

That's correct (if vertical resolution is equal to 400). There are some additional registers: CRT x0A, x0B and x14.
If you have seen bad English in my words, tell me what's wrong, please.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by Gigasoft »

Well, uploading a font that fits your programmed character height helps too.
User avatar
StrangeBrew
Posts: 7
Joined: Tue Feb 01, 2011 6:37 pm

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by StrangeBrew »

Only one line of code? Then my approach which half-works is definitely wrong...

Code: Select all

	outb(0x3D4, 0x9);
	outb(0x3D5, 0x7);
	outb(0x3C4, 0x1);
	outb(0x3C5, 0x0);
	outb(0x3C4, 0x3);
	outb(0x3C5, 0x3F);
Tosi
Member
Member
Posts: 255
Joined: Tue Jun 15, 2010 9:27 am
Location: Flyover State, United States
Contact:

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by Tosi »

Look up a register dump for the mode you want. While there are some at the wiki at VGA Hardware, none of them are for the mode you want. As Combuster said all you need to do is change the character height. After this you do need to poke a new font into VGA memory. However, if you aren't willing to read the documentation that tells you what is required to do this, you will never get anywhere.
User avatar
StrangeBrew
Posts: 7
Joined: Tue Feb 01, 2011 6:37 pm

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by StrangeBrew »

So I have to construct my own font? Combuster you lied to me about that one line of code. :mrgreen:
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: How To? -- Switch to 80x50 with in/outs VGA registries

Post by Combuster »

I'd like to use the 80x50 textmode resolution.
And I lied where? In fact, you have the correct resolution (720x400) on boot. :twisted:

And yes, I was well aware about the font, and to be honest it was I left it out to see if the message got across and a smart (lack of) question came back or if a bigger rant was required.

And no, you don't have to construct your own font.
"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 ]
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by egos »

Conventionally speaking, Combuster is right. Valid font/visible cursor is additional service for 80x50 char res :D

Here are reg dump values from my tables:
CRT x09: 47 (originally 4F)
CRT x0A: 06 (originally 0D or 0E)
CRT x0B: 07 (originally 0E or 0F)
CRT x14: 1F (I think it's simply max value)

For font loading: look here.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
StrangeBrew
Posts: 7
Joined: Tue Feb 01, 2011 6:37 pm

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by StrangeBrew »

Thanks egos.
My version that I posted earlier doesn't set the CRT[0x09] bit for 200-400 line conversion but works the same as your code...

So to clarify, must I use a 8x8 font set of my own making, or is there a premade set in VGA?
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: How To? -- Switch to 80x50 with in/outs VGA registries

Post by Combuster »

If you haven't messed up with the real-mode settings, there is a font in the VGA rom and you can usually get to it, but it might be easier to just rip that font offline and then include it in your project - that way you also have a font for graphics mode. (The VGA fonts are public domain).

But as I said, you don't need to build a font: http://dimensionalrift.homelinux.net/co ... ont8_8.asm (unicode-based)
"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
StrangeBrew
Posts: 7
Joined: Tue Feb 01, 2011 6:37 pm

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by StrangeBrew »

Thanks, but you just said one doesn't need to build his own font because the VGA ROM already has a set.
I found Chris Giese's examples but I'm having a tough time converting his code because he uses some alien functions, like set_plane().

Right now I have 80x50 textmode but the fonts are twice as big and if I try to use SEQ_REG[0x3] with the documented values every character gets transformed into a box colored in the foreground color. I imagine there's something else I have to set?
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: How To? -- Switch to 80x50 with in/outs VGA registries

Post by egos »

Did you see this?
I wrote:Font loading:
graph[0x05] = 0x00 (bit 4 = 0)
graph[0x06] = 0x0C (bit 1 = 0)
seq[0x02] = 0x04 (0100b)
seq[0x04] = 0x06/0x07 (bit 2 = 1)

Characters and attributes writing (normal mode):
graph[0x05] = 0x10 (bit 4 = 1)
graph[0x06] = 0x0E (bit 1 = 1)
seq[0x02] = 0x03 (0011b)
seq[0x04] = 0x02/0x03 (bit 2 = 0)
If you have seen bad English in my words, tell me what's wrong, please.
Post Reply