VBE fun

posted in Journal #259850
Published March 25, 2006
Advertisement
I was too tired tonight to work on anything serious (e.g. message passing), so I decided to spend some time on VBE (VGA Bios Extensions). I had already downloaded, built and installed VBE GRUB to the disk image, so all that's left was to write the actual graphics code.

VBE exposes 3 functional interfaces, one through BIOS calls (via INT 10), and 2 protected mode interfaces (VBE 2 and 3 interfaces). Unfortunately, the protected mode interfaces are:
1. Lame (e.g. no return values or status codes from VBE calls)
2. Not well-supported on graphics cards
3. Not supported by bochs

So, to properly write a VBE driver one would need to:
1. Keep switching from protected-mode to real-mode and back.
or
2. Run a v8086 task to handle all this.

#1 is obviously not a real option. #2 is possible, except that doing v8086 support isn't really a priority right now. So I just settled down on accepting whatever mode we're booted into, using the information provided by the boot-loader.

The most important info passed by the boot-loader is the linear frame buffer pointer (essentially a pointer to memory-mapped display video memory) and mode information; width, height and bpp among others. With this, I set to create a simple graphics library for bidirectional text rendering (remember: Arabic support is a top priority). And of course, I started with English, since it's much easier.

For now, we're using very basic bitmap fonts. The glyphs are stored statically in the source, until we get the file system and floppy disk drivers complete and stable enough (Don't blame me! I'm not the one working on these). This amounts to the following uber-ugliness:
	uint8 en_glyphs[127 - 32][8][10] =	{		// 32 - ' '		{			".........",			".........",			".........",			".........",			".........",			".........",			".........",			".........",		},		[snip]				// 48 - '0'		{			".........",			"...###...",			"..#...#..",			".#.....#.",			".#.....#.",			".#.....#.",			"..#...#..",			"...###...",		},		// 49 - '1'		{			".........",			"...##....",			"..#.#....",			"....#....",			"....#....",			"....#....",			"....#....",			"....#....",		},		// 50 - '2'		{			".........",			"..####...",			".#....#..",			"......#..",			".....#...",			"...#.....",			"..#......",			"..#####..",		},		// 51 - '3'		{			".........",			"..###....",			".#...#...",			"......#..",			"....##...",			"......#..",			".#...#...",			"..###....",		},		// 52 - '4'		{			".........",			"....#....",			"...##....",			"..#.#....",			".#..#....",			".######..",			"....#....",			"....#....",		},		// 53 - '5'		{			".........",			"..######.",			"..#......",			"..#####..",			".......#.",			".......#.",			".#....#..",			"..####...",		},		// 54 - '6'		{			".........",			"...####..",			"..#......",			"..#......",			"..#.###..",			"..##...#.",			"..#....#.",			"...####..",		},		// 55 - '7'		{			".........",			".#######.",			"......#..",			".....#...",			"....#....",			"...#.....",			"..#......",			".#.......",		},		// 56 - '8'		{			".........",			"..#####..",			".#.....#.",			".#.....#.",			"..#####..",			".#.....#.",			".#.....#.",			"..#####..",		},		// 57 - '9'		{			".........",			".........",			".........",			".........",			".........",			".........",			".........",			".........",		},				[snip]				// 65 - 'A'		{			".........",			"...##....",			"..#..#...",			"..#..#...",			".#....#..",			".######..",			"#......#.",			"#......#.",		},		// 66 - 'B'		{			".........",			".#####...",			".#....#..",			".#....#..",			".#####...",			".#....#..",			".#....#..",			".#####...",		},		// 67 - 'C'		{			".........",			".######..",			"#......#.",			"#........",			"#........",			"#........",			"#......#.",			".######..",		},		// 68 - 'D'		{			".........",			"###......",			"#..##....",			"#....#...",			"#.....#..",			"#....#...",			"#..##....",			"###......",		},		// 69 - 'E'		{			".........",			"########.",			"#........",			"#........",			"########.",			"#........",			"#........",			"########.",		},		// 70 - 'F'		{			".........",			"########.",			"#........",			"#........",			"########.",			"#........",			"#........",			"#........",		},				[snip]				// 90 - 'Z'		{			".........",			".#######.",			"......#..",			".....#...",			"....#....",			"...#.....",			"..#......",			".#######.",		},		[snip]				// 126 - '~'		{			".........",			".........",			".........",			".........",			".........",			".........",			".........",			".........",		},	};


The 'templates' are auto-generated; the comment with the ASCII code and display symbol, and the dot matrix. The generator is a small C++ program. I then fill the parts to be displayed with any non-dot non-zero symbol. As you can see, it's not complete yet - I've just worked on it until I was bored out of my skull, and then ran a simple test:



So yeah, it works, although the font looks so freaking ugly. Ideally, FreeType should be used for the fonts, but that's a bit too much into the future.
Next Entry VBE fun, #2
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement

Latest Entries

Opera 9 w000000t

1291 views

Damn

1178 views

VBE fun, #2

1286 views

VBE fun

1329 views

French, #1

1414 views

Mult-tasking

1175 views

DirectInput hooking

1062 views

MDX overlay sample

1330 views
Advertisement