Page 1 of 1

Working with VGA Text Mode

Posted: Wed May 08, 2013 10:48 pm
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:

Re: Working with VGA Text Mode (Solved)

Posted: Wed May 08, 2013 11:39 pm
by PearOs
Nevermind, I was setting the new font wrong. :P Thanks though.

Re: Working with VGA Text Mode

Posted: Sun May 12, 2013 10:16 am
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. :-)