Printing strings in graphics mode (320x200)

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.
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Printing strings in graphics mode (320x200)

Post by Gigasoft »

Yes, the cursor position is remembered by the BIOS and used.

Ok, from what I can tell, if BL is 0 when setting the font, DL specifies the number of rows directly, and you should set it to 14, instead of 1 as I thought. (If BL is 1, DL is set to 1 for 14 rows, 2 for 25 rows or 3 for 43 rows)

And as I've said numerous times, remember to set ES in printString.
Benjamin1996
Member
Member
Posts: 78
Joined: Sat Apr 10, 2010 7:00 am
Location: Denmark

Re: Printing strings in graphics mode (320x200)

Post by Benjamin1996 »

Gigasoft wrote:Yes, the cursor position is remembered by the BIOS and used.

Ok, from what I can tell, if BL is 0 when setting the font, DL specifies the number of rows directly, and you should set it to 14, instead of 1 as I thought. (If BL is 1, DL is set to 1 for 14 rows, 2 for 25 rows or 3 for 43 rows)

And as I've said numerous times, remember to set ES in printString.
I think I got it working now. I would like to use an 8x8 font, but it appears much larger than so, when running it?..
'getFont' & 'printString':

Code: Select all

getFont:
    mov ax, 0x1130
	xor bh, bh
	int 0x0010
	
	mov ax, 0x1120
	int 0x0010
    ret
printString:
    mov dx, cs
	mov es, dx

    mov ah, 0x000f
	int 0x0010
	
	mov ah, 0x0003
	int 0x0010
	
	mov cx, 44
	mov bl, 0x0007
	mov ax, 0x1301
	int 0x0010
	ret
This should do an 8x8 font, right?
-Well, this is how the text looks:
Capture.PNG
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Printing strings in graphics mode (320x200)

Post by Gigasoft »

Yes, that's the default 8x8 font. The getFont function is once again meaningless, since it just sets the font for CGA mode to what it already is (and you aren't even in CGA mode). You don't have to do anything to use the standard 8x8 font.
Benjamin1996
Member
Member
Posts: 78
Joined: Sat Apr 10, 2010 7:00 am
Location: Denmark

Re: Printing strings in graphics mode (320x200)

Post by Benjamin1996 »

Gigasoft wrote:Yes, that's the default 8x8 font. The getFont function is once again meaningless, since it just sets the font for CGA mode to what it already is (and you aren't even in CGA mode). You don't have to do anything to use the standard 8x8 font.
Isn't there anything I do (besides making my own) that'll allow me to use smaller fonts?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Printing strings in graphics mode (320x200)

Post by Combuster »

Getting a legible font is difficult, especially if it becomes smaller. The problem with mode 13 is that a font doubles in screen size compared to text mode, use mode 12 if you want 80x30 or 80x60 characters on screen. This makes plotting pixels nastier though.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Benjamin1996
Member
Member
Posts: 78
Joined: Sat Apr 10, 2010 7:00 am
Location: Denmark

Re: Printing strings in graphics mode (320x200)

Post by Benjamin1996 »

Combuster wrote:Getting a legible font is difficult, especially if it becomes smaller. The problem with mode 13 is that a font doubles in screen size compared to text mode, use mode 12 if you want 80x30 or 80x60 characters on screen. This makes plotting pixels nastier though.
Yeah.. mode 12h is 640x480 right?.. I already tried to do a simple 'drawVertLine' function in that mode.. what a pain.. I couldn't get it drawing the line the right length.. oh and by the way, I got kind of an off-topic question: Where can I download mkisofs on my Mac. I'm really getting tired of doing my OS development on a boot camped 32-bit Windows 7, when I'm running 64-bit Mac hardware!
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Printing strings in graphics mode (320x200)

Post by Gigasoft »

I don't see how drawing a vertical line in mode 12h poses a problem. Drawing a horizontal line is a bit more complicated, but shouldn't be too hard either.
Benjamin1996
Member
Member
Posts: 78
Joined: Sat Apr 10, 2010 7:00 am
Location: Denmark

Re: Printing strings in graphics mode (320x200)

Post by Benjamin1996 »

Gigasoft wrote:I don't see how drawing a vertical line in mode 12h poses a problem. Drawing a horizontal line is a bit more complicated, but shouldn't be too hard either.
How is a horizontal line more complicated?.. I mean, it's just finding the correct starting point, subtracting the ending X location from the starting X location, and then add one to the video-memory pointer, endX - startX times?
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Printing strings in graphics mode (320x200)

Post by Gigasoft »

No. If you had done some reading you wouldn't even be asking these questions.

Remember, in mode 12h, each addressable byte refers to 8 pixels.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Printing strings in graphics mode (320x200)

Post by Combuster »

We're three pages further, and I've yet to see an attempt by you to solve your own problems. You copy the code we posted here, or blatantly ignore it, post without describing what you actually tried, and a throughout lack of doing research (as Gigasoft pointed out above), and debugging (which I told you to do a page back)

My question to you: if you fail at doing something people have been doing for the past 15 years (like plotting pixels in EGA/VGA modes), with the resulting documentation and examples, how would you even begin to tackle the next problem that isn't as commonplace? As a hint, asking us to give you the correct code is the wrong answer.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply