Newsgroups: comp.os.msdos.programmer,alt.msdos.programmer,alt.lang.asm
Path: news.teleport.com!news.world.net!news.sprintlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!MathWorks.Com!yeshua.marcam.com!charnel.ecst.csuchico.edu!csusac!csus.edu!netcom.com!obother
From: obother@netcom.com (Glen Blankenship)
Subject: Re: 2 character sets
Message-ID: <obotherCxH0Gz.M1y@netcom.com>
Followup-To: comp.os.msdos.programmer,alt.msdos.programmer,alt.lang.asm
Organization: Church of the Holy Toy
X-Newsreader: TIN [version 1.2 PL1]
References: <Cx6z20.1zH@cs.ruu.nl> <Cx78Iz.58p@cs.ruu.nl> <Cx7Arw.6B3@cs.ruu.nl>
Date: Mon, 10 Oct 1994 18:53:23 GMT
Lines: 89
Xref: news.teleport.com comp.os.msdos.programmer:47378 alt.msdos.programmer:10685 alt.lang.asm:3536

Jeroen van Disseldorp (jafcdiss@cs.ruu.nl) wrote:

> Some time ago, someone on the net posted a message about the possibility of
> using 2 character sets (ie 512 chars) at the same time in plain text-mode.
> 
> Well, I lost his e-mail address, and now I'm still waiting for a method of
> doing so.
> 
> Does ANYONE of you have ANY info on this ???

Kilian Hekhuis is correct when he says that this is a standard video BIOS
call.  With EGA and later cards, Int 10h Function 11h has a variety
of subfunctions that load different character sets.  Some load standard
ROM BIOS sets, and some load a user-specified set.  Some just load
the characters, and others load the characters and readjust the displayed
character height, which allows you to change the number of onscreen rows. 

The EGA can load up to four different "blocks", each containing a
different character set.  The VGA supports eight blocks.  All of the
Int 10h/Fxn 11h subfunctions allow you to specify which block to load
by placing the block number (0 to 3 for EGA, 0 to 7 for VGA) in the
BL register.

Then you need to tell the BIOS which block(s) to display.  You can display
two different blocks simultaneously:  which of the two blocks is used
depends on the foreground intensity bit in the character's attribute byte
(bit 3).  High-intensity foreground colors use one character set, while
low-intensity colors use the other.

By default, the BIOS uses block 0 for *both* attributes, so you only see
one character set.  But you can specify which blocks should be used
by calling Int 10h/Fxn 11h subfunction 3.  It accepts a value in BL
that is a (somewhat peculiar) bit-encoded pair of numbers.

The peculiar part is this:  With the EGA card, you specify the low-
intensity block with bits 0 and 1, and the high-intensity block
with bits 2 and 3.  So if you wanted to select, say block 2 for
high-intensity, and block 1 for low, the bit pattern you'd use
would be:

	0 0 0 0 1 0 0 1
        | | | | | | | |
        | | | | | | +-+---> Select block 1
        | | | | +-+-------> Select block 2
        +-+-+-+-----------> Unused (set to 0)
        

...so the number in BL would be 9.

Now, that's fairly straightforward, but then the VGA came along, and 
it had eight possible blocks instead of four.  Since you can't
encode eight numbers in only two bits, the scheme above won't work.

But the VGA designers wanted to preserve backward compatibilty with
the EGA, so they added bit *4* to bits 0 and 1 to specify the 
low-intensity block, and bit *5* to bits 2 and 3 for the 
high-intensity block:

             +-----+-+---> These bits select the low-intensity block
             |     | |
     0 0 0 1 0 1 1 0 0
     | | | |   | |
     | | | +---+-+-------> These bits select the high-intensity block
     | | |
     +-+-+---> Unused (set to 0)

The bit pattern shown above selects block 0 for low-intensity characters,
and block 7 for high-intensity.  The hex equivalent is 1Ch.

Note that all of this applies only to text modes.  Standard EGA/VGA
graphics modes allow user-specified character sets, but only one set
is active at a time.  Of course, once the BIOS prints a character
onscreen in graphics mode, it's just another bit pattern, so you could
conceivably use more than one font by changing fonts in midscreen.

Also note that changing the video mode will reset the character sets to
the BIOS defaults.  I once wrote a utility that created an underlined
font, then loaded it as the high-intensity block, so that the speed keys
in menued apps (which are usually displayed in high intensity) would be
underlined as well.  But if any application changed the screen mode, the
underlines disappeared.  In order to get them to "stick", I had to turn
the underline program into a TSR that hooked the BIOS video interrupt,
watched for mode changes, then reloaded the underlined font as warranted. 

---
Glen Blankenship
obother@netcom.com
g.blankensh2@genie.geis.com

