Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VGA Fonts

15 views
Skip to first unread message

Jon Bettencourt

unread,
Feb 27, 2001, 1:22:07 AM2/27/01
to
Does anybody have a QuickBASIC program that will put bitmap data into the
area of memory with the VGA's 8x8 screen font? Will this work with Windows?


Andreas Meile

unread,
Feb 27, 2001, 5:09:36 PM2/27/01
to
"Jon Bettencourt" <jonr...@napanet.net> schrieb im Newsbeitrag
news:9832550...@proxy.napanet.net...

> Does anybody have a QuickBASIC program that will put bitmap data into the
> area of memory with the VGA's 8x8 screen font?

About retrieving the font bitmaps in general: These patterns are stored in
the VGA BIOS. INT 10h, function AH=11h, sub function AL=30h. In the
following a small code snipped which demonstrates that:

' Get the VGA BIOS ROM address for the 8x14 pixel font
' $INCLUDE: 'qb.bi'
DIM dosIntEin AS RegTypeX, dosIntAus AS RegTypeX
dosIntEin.ax = &H1130 ' BIOS function to get the character data address
dosIntEin.bx = &H300 ' we want the 8x8 pixel font! Note: For the 8x14
font, use &H200, 8x16=&H600
CALL INTERRUPTX(&H10, dosIntEin, dosIntAus)

' Read the character bitmap pattern for "A"
DEF SEG = dosIntAus.es
start% = dosIntAus.bp + 8 * ASC("A") ' Note: Replace 8 to 14 or 16
accordingly for 8x14 and 8x16 font!
FOR i% = 0 TO 7 ' Note: 8x14 -> 13, 8x16 -> 15
h% = PEEK(start% + i%)
bin$ = ""
FOR j% = 1 TO 8
bin$ = CHR$(48 + (h% AND 1)) + bin$
h% = h% \ 2
NEXT j%
PRINT bin$
NEXT i%

If you want find a useful application for that, please check out my .BMP
library again at

http://dreael.catty.ch/Deutsch/Download/WindowsBitmapBibliothek.html

(Note: Use http://babelfish.altavista.com/translate.dyn to translate the
German texts).

Please have a look in BMP_LIB.BAS to the SUB procedure ErzeugeTextGrafik():
This procedure converts a rectangular section of the SCREEN 0 text mode
screen into a graphic which can be blitted with PUT. Small sample code for
demonstration:

' Converting text screen to an image
' $INCLUDE: 'bmp_lib.bi'
SCREEN 0
COLOR 14,9
LOCATE 5,52
PRINT "Hello"
COLOR 3,8
LOCATE 6,52
PRINT "Jon!!"
d$ = INPUT$(1)
DIM f #(40)
ErzeugeTextGrafik f#(), LBOUND(f#), 51, 4, 5, 2, 4, 8
SCREEN 7
PUT (60,45), f#, PSET
d$=INPUT$(1)
SCREEN 0
WIDTH 80, 25

Note: See section "Textbildschirmausschnitt als Grafik umwandeln" at
http://dreael.catty.ch/Deutsch/Download/WindowsBitmapBibliothek.html
It explains you the meaning of the parameters for this SUB procedure. Don't
forget to pay attention to the note about the 8x14 fonts issue in modern
graphic cards (ftp://ftp.vesa.org/pub/VBE/vbe3.pdf, section "Removal of
Unused VGA Fonts" on page 67).

If you actually want use a RAM based font in the SCREEN 0 textmode, the
following VGA BIOS functions may cover your needs:

INT 10h, AH=11h, AL=00h:
Load user defined font
INT 10h, AH=11h, AL=02h:
Copy 8x8 ROM font to the RAM (useful, if you only wish to user-redefine some
particular characters)
INT 10h, AH=11h, AL=03h:
Activate a user-defined font
INT 10h, AH=11h, AL=10h:
Load user font data from RAM into the the graphic card's RAM and activate
it.
INT 10h, AH=11h, AL=12h:
Load 8x8 ROM font into the the graphic card's RAM and activate it.

For details, please consult Ralph Brown's interrupt list at
http://www.ctyme.com/rbrown.htm . If you wish an example program, please let
me know that, :-) so I will publish a sample code to this discussion thread.

> Will this work with Windows?

Yes.

Andreas


Jon Bettencourt

unread,
Feb 28, 2001, 1:04:49 AM2/28/01
to

"Andreas Meile" <and...@hofen.ch> wrote in message
news:97h8kd$s3i$2...@news1.sunrise.ch...

> If you actually want use a RAM based font in the SCREEN 0 textmode, the
> following VGA BIOS functions may cover your needs:
>
> INT 10h, AH=11h, AL=00h:
> Load user defined font
> INT 10h, AH=11h, AL=02h:
> Copy 8x8 ROM font to the RAM (useful, if you only wish to user-redefine
some
> particular characters)
> INT 10h, AH=11h, AL=03h:
> Activate a user-defined font
> INT 10h, AH=11h, AL=10h:
> Load user font data from RAM into the the graphic card's RAM and activate
> it.
> INT 10h, AH=11h, AL=12h:
> Load 8x8 ROM font into the the graphic card's RAM and activate it.
>
> For details, please consult Ralph Brown's interrupt list at
> http://www.ctyme.com/rbrown.htm . If you wish an example program, please
let
> me know that, :-) so I will publish a sample code to this discussion
thread.

Yes, an example program would be very helpful.


Andreas Meile

unread,
Feb 28, 2001, 3:53:16 PM2/28/01
to
"Jon Bettencourt" <jonr...@napanet.net> schrieb im Newsbeitrag
news:98334045...@proxy.napanet.net...

>
> "Andreas Meile" <and...@hofen.ch> wrote in message
> news:97h8kd$s3i$2...@news1.sunrise.ch...
> > If you actually want use a RAM based font in the SCREEN 0 textmode, the
> > following VGA BIOS functions may cover your needs:
[...]

> > http://www.ctyme.com/rbrown.htm . If you wish an example program, please
> let
> > me know that, :-) so I will publish a sample code to this discussion
> thread.
>
> Yes, an example program would be very helpful.

Here you are:

' Demonstration of user defined fonts
' (c) 2001 by Andreas Meile

' $INCLUDE: 'qb.bi'

TYPE CharBuf
fontBitPat AS STRING * 8
END TYPE

DIM dosIntEin AS RegTypeX, dosIntAus AS RegTypeX

DIM fb(2) AS CharBuf

SCREEN 0
WIDTH 80, 50 ' we need a 8x8 font text video mode

' Demo 1
' This program modifies the letters "C", "D" and "E"

' Step 1: Create a copy of the ROM character set
' Note: We use table 0

dosIntEin.ax = &H1102
dosIntEin.bx = 0 ' font table 0
CALL INTERRUPTX(&H10, dosIntEin, dosIntAus)

' Step 2: Modify the characters C to E
FOR i% = 0 TO 2
t$ = ""
FOR j% = 0 TO 7
READ sc$
w% = 0
FOR k% = 1 TO 8
w% = 2 * w% - (MID$(sc$, k%, 1) <> " ")
NEXT k%
t$ = t$ + CHR$(w%)
NEXT j%
fb(i%).fontBitPat = t$
NEXT i%

' new shape for "C"
DATA "# ## #"
DATA "# #### #"
DATA "# ## #"
DATA " ###### "
DATA " #### "
DATA " #### "
DATA " ## ## "
DATA "## ##"
' new shape for "D"
DATA "# ## ##"
DATA "########"
DATA "### ###"
DATA "# #"
DATA "### ###"
DATA "########"
DATA "## ## "
DATA "# "
' new shape for "E"
DATA " # # "
DATA "# # # #"
DATA " ###### "
DATA " # # "
DATA " # # "
DATA " ###### "
DATA "# # # #"
DATA " # # "

' Load these 3 characters into the font RAM
dosIntEin.ax = &H1100
dosIntEin.bx = &H800 ' BH=8 (8 scanlines), BL=0 (font table 0)
dosIntEin.cx = 3 ' our 3 characters
dosIntEin.dx = ASC("C") ' start character "C"
dosIntEin.es = VARSEG(fb(0)) ' address of our buffer variable
dosIntEin.bp = VARPTR(fb(0))
CALL INTERRUPTX(&H10, dosIntEin, dosIntAus)

' Activate this font table
dosIntEin.ax = &H1103
dosIntEin.bx = 0 ' Table 0 for both 256 tables
CALL INTERRUPTX(&H10, dosIntEin, dosIntAus)

' Demonstrate it
PRINT "A B C D E F G H I J"
PRINT "Our own characters: C D E"
COLOR 4
PRINT "Swiss flags: D D D"
COLOR 2
PRINT "Mens: C C C"
COLOR 7
PRINT "Apple Macintosh key: E E E"

d$ = INPUT$(1)

' Demo 2: Here we create a 5x5 character block shape
' The special thing: We directly convert from a graphic

SCREEN 11 ' the graphic *must* be 1 bpp (bit per pixes)
FOR i% = 1 TO 19 STEP 3
CIRCLE (20, 20), i%, 1, , , 1!
NEXT i%
LOCATE 7, 1
PRINT "This graphic will be converted now"

DIM fd%(101)
' Cut stripes
' Important note: The size information will be overwritten with each
' loop. This ensures a continuous font bitmap data stream in the memory
FOR i% = 4 TO 0 STEP -1
GET (8 * i%, 0)-STEP(7, 39), fd%(20 * i%)
NEXT i%
d$ = INPUT$(1)

SCREEN 0
WIDTH 80, 50 ' we need a 8x8 font text video mode

' Copy ROM font to RAM

dosIntEin.ax = &H1102
dosIntEin.bx = 0 ' font table 0
CALL INTERRUPTX(&H10, dosIntEin, dosIntAus)

' Load theses 25 characters into RAM
' from Alt+192 ("À") to Alt+217 ("Ù") (25 characters)
dosIntEin.ax = &H1100
dosIntEin.bx = &H800 ' BH=8 (8 scanlines), BL=0 (font table 0)
dosIntEin.cx = 25 ' our 25 characters (5x5 block)
dosIntEin.dx = 192 ' start character Alt+192 ("À")
dosIntEin.es = VARSEG(fd%(2)) ' address of our buffer variable
dosIntEin.bp = VARPTR(fd%(2))
CALL INTERRUPTX(&H10, dosIntEin, dosIntAus)

' Important note: The actual font bitmap resolution in text mode on
' a VGA card is 9x8 (or 9x14/9x16) pixels. But we only can define 8 of
' these 9 pixels. The VGA hardware has the behaviour to simply repeat
' the 8th pixel for the characters 192-223, leaving backgrounded for all
' other characters. There's no way to user-define this rightmost pixel
' column!

' Activate this font table
dosIntEin.ax = &H1103
dosIntEin.bx = 0 ' Table 0 for both 256 tables
CALL INTERRUPTX(&H10, dosIntEin, dosIntAus)

' Show samples
PRINT "Samples of our block"
FOR i% = 0 TO 5
COLOR 3 + i%
FOR j% = 0 TO 4
LOCATE 4 + 2 * i% + j%, 3 + 7 * i%
FOR k% = 192 TO 212 STEP 5
PRINT CHR$(j% + k%);
NEXT k%
NEXT j%
NEXT i%
COLOR 7
d$ = INPUT$(1)

' Reset 8x8 font: Simply copy the ROM font back
dosIntEin.ax = &H1102
dosIntEin.bx = 0 ' font table 0
CALL INTERRUPTX(&H10, dosIntEin, dosIntAus)

SCREEN 0
WIDTH 80, 25

This demo can be downloaded as

http://dreael.catty.ch/UsenetBeilagen/FONTDEMO.ZIP

For more details, see http://www.ctyme.com/intr/rb-0143.htm ! Please notice
the 9 pixel width issue as commented in the program (does anybody know a
work-around for that?).

Andreas


0 new messages