Working with VGA Text Mode

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
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

Working with VGA Text Mode

Post by PearOs »

So this I have everything working except when I do mode 90x60 and clear the console, and write "hello world" I only see half the text. Which is odd... So I looked over this code that I used as a base and noticed something:

Code: Select all

void set_text_mode(int hi_res)
{
	unsigned rows, cols, ht, i;

	if(hi_res)
	{
		write_regs(g_90x60_text);
		cols = 90;
		rows = 60;
		ht = 8;
	}
	else
	{
		write_regs(g_80x25_text);
		cols = 80;
		rows = 25;
		ht = 16;
	}
/* set font */
	if(ht >= 16)
		write_font(g_8x16_font, 16);
	else
		write_font(g_8x8_font, 8);
/* tell the BIOS what we've done, so BIOS text output works OK */
	pokew(0x40, 0x4A, cols);	/* columns on screen */
	pokew(0x40, 0x4C, cols * rows * 2); /* framebuffer size */
	pokew(0x40, 0x50, 0);		/* cursor pos'n */
	pokeb(0x40, 0x60, ht - 1);	/* cursor shape */
	pokeb(0x40, 0x61, ht - 2);
	pokeb(0x40, 0x84, rows - 1);	/* rows on screen - 1 */
	pokeb(0x40, 0x85, ht);		/* char height */
/* set white-on-black attributes for all text */
	for(i = 0; i < cols * rows; i++)
		pokeb(0xB800, i * 2 + 1, 7);
}
They are informing the BIOS of the change, well I'm in long mode, so if this is the case I can't do that. But I think peekb and pokeb are just setting values in Memory. Am I correct? I tried this theory and nothing changes. So what do I do? Thanks, Matt

Original Source: http://files.osdev.org/mirrors/geezer/o ... cs/modes.c

Image:
Attachments
Weird.png
PearOs
Member
Member
Posts: 194
Joined: Mon Apr 08, 2013 3:03 pm
Location: Usually at my keyboard!

Re: Working with VGA Text Mode (Solved)

Post by PearOs »

Nevermind, I was setting the new font wrong. :P Thanks though.
User avatar
sortie
Member
Member
Posts: 931
Joined: Wed Mar 21, 2012 3:01 pm
Libera.chat IRC: sortie

Re: Working with VGA Text Mode

Post by sortie »

Note how you are writing to the video card registers, so you are talking directly with the hardware (or whatever emulation there is of VGA cards these days) rather than with the BIOS. The BIOS won't work in long mode, but talking with the hardware directly works everywhere. :-)
Post Reply