delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/23/09:28:59

From: "Kalum Somaratna aka Grendel" <kalum AT newmail DOT net>
To: djgpp AT delorie DOT com
Date: Tue, 23 Nov 1999 17:49:20 +0600
MIME-Version: 1.0
Subject: Re: fprintf() and using under graphic modes
In-reply-to: <81cbge$bb2$2@portraits.wsisiz.edu.pl>
X-mailer: Pegasus Mail for Win32 (v3.12)
Message-ID: <94339412201@out.newmail.net>
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On 22 Nov 99, at 22:03, Chaos wrote:

> 
> First, I'm wondering what is your "magic" video card. Secondly, I 
have
> tested LFB method on my RIVA 128 (VESA 3.0). Using fprintf 
didn't cause any
> sudden errors or screen garbage. The text was appearing right as 
it supose
> to. I will do some more intensive test to ensure correctness. Eli 
Zarestki
> (big thnx 4 that) also mentioned about checking no of columns 
and rows in my
> specific mode(ScreenCols() and ScreenRows() functions), 
640x480x256c - 0x101
> in my case. It turned out that there is 80 columns and 30 rows. 
The number
> of rows can make some problems but I'm looking forward to solve 
it.
> 

First of all my "magic" card happens to be an ancient Cirrus Logic 
GD5430 with 1MB video ram and it supports VESA 1.2 (BTW 
Please don't laugh as I am prone to having heart attacks). To get 
VESA 3.0 support I use UNIVBE.

Rather than using printf to draw text I think you should try to write 
your own font drawing routines which directly write to memory. If 
you want you can check out the allegro library for examples on 
how it handles fonts.

The reasons for using Font drawing routines IMHO are,
1. When you draw a font you are directly writing to video memory. 
printf on the other hand is much slooower because it generates an 
interrupt (10h) which is intercepted by the DPMI server which 
switches the CPU into real mode and generates the interrupt which 
is handled by the BIOS which draws the text (BTW BIOS routines 
are often very slow) afterwards the DPMI server switches the CPU 
into Protected mode and your program resumes etc...

As you can see IMHO just a simple printf can take a lot of time 
and instructions relative to a Font routine which draws the text 
directly to screen.

And BTW I don't think it's possible to use printf to position text 
exactly at certain x,y coordinate's on the screen (for ex if you want 
to print some text starting at x=337 and y=108 how do you instruct 
printf etc.. to do it? On the other hand a graphics mode based font 
routine will have no problem as you can give the coordinates 
directly to it).
 
So I think that although coding for a Font Drawing routine might be 
harder it's worth it, because It will be faster than printf and it also 
will be fully compatible with the graphics mode you are using.

Happy Hacking!
Kalum

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019