Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2008-01

Accessing ROM BIOS Font in Linux.

13 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Unknown author

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.

Reply by email

Michael Van Canneyt
to Unknown author
Show quoted text 29 lines
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.

Reply by email

Michael Van Canneyt
to Vinzent Hoefler: Yes. Yes. "/dev/mem" should be the raw memory device (where even the BIOS "image" can be…
Vinzent Hoefler wrote 9 lines
On Thursday 17 January 2008 01:27, 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.

Reply by email

Vinzent Hoefler
to Unknown author: A task I used to do regularly when programming in Turbo Pascal was to read the BIOS Rom…
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.

Reply by email

Vinzent Hoefler
to Michael Van Canneyt: But you cannot use this font to write to the screen directly ? Michael.
Michael Van Canneyt wrote 12 lines
On Thu, 17 Jan 2008, Vinzent Hoefler wrote: > On Thursday 17 January 2008 01:27, 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.

Reply by email

Anthony W.Henry
to Vinzent Hoefler: Yes. Yes. "/dev/mem" should be the raw memory device (where even the BIOS "image" can be…
Vinzent Hoefler wrote 20 lines
On Thursday 17 January 2008 01:27, 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 - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Anthony W.Henry
to Michael Van Canneyt: But you cannot use this font to write to the screen directly ? Michael.
Michael Van Canneyt wrote 14 lines
On Thu, 17 Jan 2008, Vinzent Hoefler wrote: > On Thursday 17 January 2008 01:27, 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.

Show quoted text 5 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Mark Morgan Lloyd
to Michael Van Canneyt: This font is not accessible. Linux does not allow direct hardware access unless you write…
Michael Van Canneyt wrote 6 lines
> 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]

Reply by email

Anthony W.Henry
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 11 lines
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

Reply by email

Marco van de Voort
to Michael Van Canneyt: This font is not accessible. Linux does not allow direct hardware access unless you write…
Show quoted text 9 lines
On Thu, 17 Jan 2008, 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)

Reply by email

Mark Morgan Lloyd
to Anthony W.Henry: Yes... I've done this in the past... (late 80's early 90's :) Your completely right. I…
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]

Reply by email

Anthony W.Henry
to Mark Morgan Lloyd
Mark Morgan Lloyd wrote 9 lines
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

Reply by email

Mark Morgan Lloyd
to Anthony W.Henry
Anthony W.Henry wrote 7 lines
> 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]

Reply by email