Page 1 of 1
Text-mode dot clock problems
Posted: Sun Mar 15, 2009 10:13 pm
by Firestryke31
I got a little bored trying to figure out why my OS couldn't load a program and decided to implement a custom font. This was much simpler than I thought, except for one thing. The VGA dot clock is at 9, giving me this:
when I want it to be at 8, giving me this:
Is there a way to do this without fiddling with the hardware? I'm perfectly willing to do a mode change if I need to, since right now I'm just tweaking the default boot video mode. I just couldn't figure out which mode I'd need to switch to to get what I want due to some of the modes having several results based on different things.
Re: Text-mode dot clock problems
Posted: Mon Mar 16, 2009 1:56 am
by johnsa
Mode 10h should use an 8x14 font... (640x350).
I personally like this mode as you get two full pages in vid-mem for flipping or doing other stuff during boot.
I take it you're using 640x480 (12h)?
Re: Text-mode dot clock problems
Posted: Mon Mar 16, 2009 3:09 am
by Combuster
The 9-dot font was introduced since it improved separation and readability of characters. However, there are some characters that do not like to be separated, like the box drawing characters. To cope, IBM added a feature that duplicates the 8th row into the 9th for that range of extended characters. (iirc, it was the 0xC0-0xDF range). There's a bit that enables or disables this feature, but it should be on by default due to its default use.
The other method is by indeed setting a 8-dot mode. You need one bit to make that happen, and three to do it correctly:
- disable screen
- change to 8 pixel characters
- choose the 25MHz pixel clock (the previous step modifies the resolution, which needs the corresponding dot clock if you don't want to fry fixed-frequency monitors)
- enable screen
You can get all the necessary register information from
The wiki and
FreeVGA
And of course you can set a graphics mode as johnsa suggested, but that usually means that you write all bits of a character manually, rather than having the VGA controller duke that out for you.
Re: Text-mode dot clock problems
Posted: Mon Mar 16, 2009 8:43 am
by Firestryke31
I would prefer having the BIOS do all of the hardware fiddling for me, so I'll try changing the video mode. However, I don't think I'm going to use a graphics mode, since I don't really want to do draw the fonts myself when I could have the hardware do the exact same thing for me. Any suggestions for a mode or am I going to have to decipher the various tables I find myself?
Edit: After a quick glance and trying a couple of things in Bochs, it looks like I'm going to have to mess with the hardware myself. Oh well.
Re: Text-mode dot clock problems
Posted: Mon Mar 16, 2009 10:01 am
by Troy Martin
Oh, and IMHO, the 'w' in your font looks waaaayy out of place.
Re: Text-mode dot clock problems
Posted: Mon Mar 16, 2009 12:41 pm
by Firestryke31
Yeah, I know. I was going to add a "BTW this font is temporary until I can get this to work" but I forgot.
Right now I'm struggling with poor documentation on how to disable the screen while I change the clock rates. I've read 3 or 4 different code dumps for changing the video mode but they just dump a series of uncommented numbers to the various ports with no explanation, and each of the code dumps started by doing something different. I'll search some more but if someone could save me a bunch of time and just tell me what I need that would be very nice.
Edit: NVM I think I found it. Just out 0x00 to port 0x03C4, then to port 0x03C5, right? Then to re-enable just do the same thing with 0x03 to the second port instead?
Edit: I got it working! Here's the final code (unoptimized!):
Code: Select all
;; use Reset register
mov al, 0x00
mov dx, 0x03C4
out dx, al
;; Complete disable
mov al, 0x00
mov dx, 0x03C5
out dx, al
;; use dot clock register
mov al, 0x01
mov dx, 0x03C4
out dx, al
;; use 8-dot clock
mov al, 0x01
mov dx, 0x03C5
out dx, al
;; use 640x??? instead of 720x???
mov al, 0xE3
mov dx, 0x03C2
out dx, al
;; use reset register
mov al, 0x00
mov dx, 0x03C4
out dx, al
;; complete enable
mov al, 0x03
mov dx, 0x03C5
out dx, al