Accessing ROM BIOS Font in Linux.

classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Accessing ROM BIOS Font in Linux.

Anthony W. Henry
A task I used to do regularly when programming in Turbo Pascal
was to read the BIOS Rom Font.    I first picked this up to make
"Splash" Screens for Text Mode programs that wrote out big
several lines high using the character it was made of
 
FFFFF  PPPPP         CCC
F            P        P      C
FFF       PPPP        C
F            P                C
F            P                  CCC
 
Something like that.    Using the ROM Bios font
allowed me to make a call like BigWord('FPC');
without having the font be part of the program.
I haven't been able to locate my old source but can probably
find them.   If I remember correctly they are located at
16 bit real mode address F000:FA6E.     I also used
them as a failsafe while in Graphics mode if BGI font
file was not loaded.   I wrote text output routines using
putpixel and the ROM fonts.    I also used them when
divising my own 2d graphics primitives in Pascals
built in assembler (I never completely finished this). 
 
I'm looking into doing some SDL programming and want
a fallback text output method if font files aren't available.
 
The question.   Is this font accessible from linux; do I have
to be root ?    How do I make the 16 bit segment/offset address
into a 32 bit pointer to access these fonts ? 
 
Thank You,
 
Anthony.
 
 
 
 

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Michael Van Canneyt


On Thu, 17 Jan 2008, [hidden email] wrote:

> A task I used to do regularly when programming in Turbo Pascal
> was to read the BIOS Rom Font.    I first picked this up to make
> "Splash" Screens for Text Mode programs that wrote out big
> several lines high using the character it was made of
>
> FFFFF  PPPPP         CCC
> F            P        P      C
> FFF       PPPP        C
> F            P                C
> F            P                  CCC
>
> Something like that.    Using the ROM Bios font
> allowed me to make a call like BigWord('FPC');
> without having the font be part of the program.
> I haven't been able to locate my old source but can probably
> find them.   If I remember correctly they are located at
> 16 bit real mode address F000:FA6E.     I also used
> them as a failsafe while in Graphics mode if BGI font
> file was not loaded.   I wrote text output routines using
> putpixel and the ROM fonts.    I also used them when
> divising my own 2d graphics primitives in Pascals
> built in assembler (I never completely finished this).  
>
> I'm looking into doing some SDL programming and want
> a fallback text output method if font files aren't available.
>
> The question.   Is this font accessible from linux; do I have
> to be root ?    How do I make the 16 bit segment/offset address
> into a 32 bit pointer to access these fonts ?  

This font is not accessible. Linux does not allow direct hardware
access unless you write a device driver.

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Vinzent Höfler
In reply to this post by Anthony W. Henry
On Thursday 17 January 2008 01:27, [hidden email] wrote:

> The question.   Is this font accessible from linux; do I have
> to be root ?

Yes. Yes.

"/dev/mem" should be the raw memory device (where even the BIOS "image"
can be read from), but this device which is only accessible to root.

> How do I make the 16 bit segment/offset address
> into a 32 bit pointer to access these fonts ?

The same as in the old days: Multiply the segment with 16 and add the
offset, which gives you the 32 bit (absolute/physical) address. This is
basically the offset into the "/dev/mem" device file and thus can be
fed to the (f)seek...


Vinzent.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Michael Van Canneyt


On Thu, 17 Jan 2008, Vinzent Hoefler wrote:

> On Thursday 17 January 2008 01:27, [hidden email] wrote:
>
> > The question.   Is this font accessible from linux; do I have
> > to be root ?
>
> Yes. Yes.
>
> "/dev/mem" should be the raw memory device (where even the BIOS "image"
> can be read from), but this device which is only accessible to root.

But you cannot use this font to write to the screen directly ?

Michael.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Vinzent Höfler
On Thursday 17 January 2008 11:47, Michael Van Canneyt wrote:

> On Thu, 17 Jan 2008, Vinzent Hoefler wrote:
> > On Thursday 17 January 2008 01:27, [hidden email] wrote:
> > > The question.   Is this font accessible from linux; do I have
> > > to be root ?
> >
> > Yes. Yes.
> >
> > "/dev/mem" should be the raw memory device (where even the BIOS
> > "image" can be read from), but this device which is only accessible
> > to root.
>
> But you cannot use this font to write to the screen directly ?

Probably not, no. ;)

But well, I don't read "I wrote text output routines using
putpixel and the ROM fonts." as "write to the screen directly". Rather
more like "if I did't know which font to use, I'd use the BIOS font."


Vinzent.
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Anthony Henry
In reply to this post by Vinzent Höfler
On Thu, 2008-01-17 at 11:48 +0100, Vinzent Hoefler wrote:

> On Thursday 17 January 2008 01:27, [hidden email] wrote:
>
> > The question.   Is this font accessible from linux; do I have
> > to be root ?
>
> Yes. Yes.
>
> "/dev/mem" should be the raw memory device (where even the BIOS "image"
> can be read from), but this device which is only accessible to root.
>
> > How do I make the 16 bit segment/offset address
> > into a 32 bit pointer to access these fonts ?
>
> The same as in the old days: Multiply the segment with 16 and add the
> offset, which gives you the 32 bit (absolute/physical) address. This is
> basically the offset into the "/dev/mem" device file and thus can be
> fed to the (f)seek...
>
>
> Vinzent.

          Thank you,  I have tended to shy away from touching
stuff in /dev except when administrating my system.  I just
learned something new about Linux :).   This doesn't sound
like I can use this conveniently.  

And yes I did mean if I can't find another font to use the
BIOS font as a fall back.  I'm sure I can find a Free Font
somewhere and link it into my code.  

Anthony

> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Anthony Henry
In reply to this post by Michael Van Canneyt
On Thu, 2008-01-17 at 11:47 +0100, Michael Van Canneyt wrote:

>
> On Thu, 17 Jan 2008, Vinzent Hoefler wrote:
>
> > On Thursday 17 January 2008 01:27, [hidden email] wrote:
> >
> > > The question.   Is this font accessible from linux; do I have
> > > to be root ?
> >
> > Yes. Yes.
> >
> > "/dev/mem" should be the raw memory device (where even the BIOS "image"
> > can be read from), but this device which is only accessible to root.
>
> But you cannot use this font to write to the screen directly ?

   Actually, I read the font and drew to the screen. :)
I first used this to make Banners in Text Mode out of the
Letters themselves. (A was made out of A, B or B's etc...).

    At one time I almost completed a set of 256 color 2d
graphics primitives in Pascal and assembler.  I used the
BIOS font in my OutTextXY procedure.  I just
remembered where I had some of the code this morning.

http://home.comcast.net/~anthonyh63/mysoftware/vesa.zip

   These routines are not complete and are mostly useless
today.  (Real mode DOS.)  The routines in question are in
WRITETXT.SRC which was used as an include file rather then
a unit.  Include files were a habit I picked up from
programming with Turbo 3.0 even though this work was done
under Turbo 6. :)

  Upon rereading the source I had forgotten you also had
to make a BIOS call to get the address though it returned
an identical address for most BIOS's. (If memory serves).

  Thanks to everyone who answered.  I'm checking the Linux
newsgroups now to see if there is a way to hack
a BIOS call under Linux but I don't have a lot of hope :)
(rightfully so, people shouldn't make direct BIOS calls
 in an application now.)
I'll probably end up linking a binary font into the program.

Anthony.

>
> Michael.
> _______________________________________________
> fpc-pascal maillist  -  [hidden email]
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Mark Morgan Lloyd-5
In reply to this post by Michael Van Canneyt
Michael Van Canneyt wrote:

>> The question.   Is this font accessible from linux; do I have
>> to be root ?    How do I make the 16 bit segment/offset address
>> into a 32 bit pointer to access these fonts ?  
>
> This font is not accessible. Linux does not allow direct hardware
> access unless you write a device driver.

What exactly are you trying to do- read the pixels that make up the BIOS fount
so that you can plot them as blocks in a text- or graphics-mode session? I'd
have thought it would be better practice to store a fount file as constant
data (possibly a resource) inside the program- there's plenty of fount editors
etc. available from DOS days.

Alternatively are you talking about simply getting the entire program to use a
fount similar to that provided by the PC hardware? If so that's going to be
entirely down to the session manager, irrespective of whether the program is
running on the system console or inside xterm, konsole or Teraterm: it might
vary for every user.

If it's text mode you're probably limited to a single 256-character fount
(under DOS you could use a 512-character fount at the expense of colours), in
graphics mode you've obviously got more flexibility. I remember a description
from Dosemu of how to convert a PC fount into a file suitable for direct use
by X, it would not surprise me if there are some fairly good ones available
prepackaged.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Anthony Henry

On Thu, 2008-01-17 at 15:32 +0000, Mark Morgan Lloyd wrote:

> Michael Van Canneyt wrote:
>
> >> The question.   Is this font accessible from linux; do I have
> >> to be root ?    How do I make the 16 bit segment/offset address
> >> into a 32 bit pointer to access these fonts ?  
> >
> > This font is not accessible. Linux does not allow direct hardware
> > access unless you write a device driver.
>
> What exactly are you trying to do- read the pixels that make up the BIOS fount
> so that you can plot them as blocks in a text- or graphics-mode session?

Yes...  I've done this in the past... (late 80's early 90's :)

>  I'd
> have thought it would be better practice to store a fount file as constant
> data (possibly a resource) inside the program- there's plenty of fount editors
> etc. available from DOS days.

Your completely right. I still think like a DOS programmer
sometimes. (Keeping program code small..).

  I was actually thinking of using it as fall back font. (Font
files missing).  It was going to be graphics mode programming.
 I think if I follow through with this project then
 converting a Bit Font to an Array Constant is really the way
 to go.  I really don't have to worry about the few Kilobytes
it will add to the program file :).   Anyone know any good
GPL'd or Public Domain bit fonts ?

Anthony



_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Marco van de Voort
In reply to this post by Michael Van Canneyt
> On Thu, 17 Jan 2008, [hidden email] wrote:
> > a fallback text output method if font files aren't available.
> >
> > The question.   Is this font accessible from linux; do I have
> > to be root ?    How do I make the 16 bit segment/offset address
> > into a 32 bit pointer to access these fonts ?  
>
> This font is not accessible. Linux does not allow direct hardware
> access unless you write a device driver.

(Don't know Linux, but under FreeBSD you can get it from the stdout handle
using ioctls. You can do this without root, but you need to be the owner of
tty that is considered local (ttyv)

Fontdemo in the demoes package demonstrates this feature. The ioctls belong
to a FreeBSD subsystem that is called "syscons". It also allows kbd
remapping)
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Mark Morgan Lloyd-5
In reply to this post by Anthony Henry
Anthony W.Henry wrote:

>  I really don't have to worry about the few Kilobytes
> it will add to the program file :).   Anyone know any good
> GPL'd or Public Domain bit fonts ?

Remember that you can easily preprocess it with RLL. I'd expect a bitmap fount
to be very compressible.

Google for "Programmer's fonts" etc., there's plenty around; otherwise look to
see what's bundled with things like FreeDOS. If you like I'll send you my
favourite as a .fon file- I might have it in other formats but have limited
time to look for things. Please mail me direct (see below) if you want a copy.

One thing I'd add is that using Delphi it's possible (although not trivial) to
embed a .fon as a resource in an executable. I don't know the extent to which
this can be done using (in particular) Lazarus on Windows or on Linux.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Anthony Henry

On Sat, 2008-01-19 at 13:19 +0000, Mark Morgan Lloyd wrote:
> Anthony W.Henry wrote:
>
> >  I really don't have to worry about the few Kilobytes
> > it will add to the program file :).   Anyone know any good
> > GPL'd or Public Domain bit fonts ?
>
> Remember that you can easily preprocess it with RLL. I'd expect a bitmap fount
> to be very compressible.
>

[snip]

> One thing I'd add is that using Delphi it's possible (although not trivial) to
> embed a .fon as a resource in an executable. I don't know the extent to which
> this can be done using (in particular) Lazarus on Windows or on Linux.
>

   I imagine the easiest way is bin2obj and just make it a constant
array in the program.   :)    That is a useful trick and much easier
then resources.  (I most recently used it to make a bitmap CGI hit
counter. the Digit jpg's where all stored as Const arrays of byte
and the CGI recursively called itself.  

Anthony

_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: Accessing ROM BIOS Font in Linux.

Mark Morgan Lloyd-5
Anthony W.Henry wrote:

>> One thing I'd add is that using Delphi it's possible (although not trivial) to
>> embed a .fon as a resource in an executable. I don't know the extent to which
>> this can be done using (in particular) Lazarus on Windows or on Linux.
>
>    I imagine the easiest way is bin2obj and just make it a constant
> array in the program.   :)    That is a useful trick and much easier
> then resources.

That's true (and interesting), but I was thinking about the bigger picture
where a program was running under Windows or X and you wanted to pass a custom
fount to the overall graphical environment rather than having to plot
individual pixels.

--
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/mailman/listinfo/fpc-pascal