Page 1 of 1

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

Posted: Thu Feb 03, 2011 8:36 am
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.

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

Posted: Thu Feb 03, 2011 8:58 am
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.

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

Posted: Thu Feb 03, 2011 12:23 pm
by egos
That's correct (if vertical resolution is equal to 400). There are some additional registers: CRT x0A, x0B and x14.

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

Posted: Thu Feb 03, 2011 12:49 pm
by Gigasoft
Well, uploading a font that fits your programmed character height helps too.

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

Posted: Thu Feb 03, 2011 1:17 pm
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);

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

Posted: Thu Feb 03, 2011 1:29 pm
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.

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

Posted: Thu Feb 03, 2011 2:14 pm
by StrangeBrew
So I have to construct my own font? Combuster you lied to me about that one line of code. :mrgreen:

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

Posted: Thu Feb 03, 2011 4:21 pm
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.

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

Posted: Thu Feb 03, 2011 4:49 pm
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.

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

Posted: Thu Feb 03, 2011 5:37 pm
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?

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

Posted: Fri Feb 04, 2011 1:31 am
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)

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

Posted: Fri Feb 04, 2011 4:41 am
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?

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

Posted: Fri Feb 04, 2011 6:52 am
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)