[comp.sys.ibm.pc] changing character sets

joe@erix.UUCP (02/20/87)

Has anybody any help with the following:

What I want to do:

        Dynamically  (i.e.  not at boot time)  Change the  system character
sets to my own character sets - at any time I'd  like to be able  to poke a
new character definition into the machine.

A few simple questions:
       
        1) Are the characters sets in RAM
        2) If so at what address
        3) How are the characters packed
        4) If I change the RAM character set (I assume it is in RAM)
           can I use bios calls to output the characters or what?

Any help is appreciated
			Joe Armstrong

zhahai@gaia.UUCP (02/24/87)

In article <1303@erix.UUCP> joe@erix.UUCP (Joe Armstrong) writes:
>What I want to do:
>        Dynamically  (i.e.  not at boot time)  Change the  system character
>sets to my own character sets - at any time I'd  like to be able  to poke a
>new character definition into the machine.
>
>A few simple questions:
>        1) Are the characters sets in RAM
>        2) If so at what address
>        3) How are the characters packed
>        4) If I change the RAM character set (I assume it is in RAM)
>           can I use bios calls to output the characters or what?
>			Joe Armstrong

By character set, I assume that you mean the screen representation of
characters, rather than the "meaning" associate with a particular byte
value (which would require changing all the software on the system, if
you wanted EBCDIC for example).

First, there are many different video boards avaliable for the IBM PC and
compatibles.  The most popular and widely used and emulated ones from IBM
are the Monochrome Display (and Printer) Adapter, the Color Graphics
Adapter, and the Enhanced Graphics Adapter - MDPA, CGA, and EGA.  The
dot representation of characters is fixed on ROMs in the MDPA and would be
hard to change thereby - unless you got a clone with sockets ROMS and could
create compatible EPROMS... but this is not dynamic.  The CGA has several
"modes" of display, some of which are "character modes" and some "graphic
modes", ie: bit mapped graphics ("All Points Addressable" in IBMese).  With
the character modes you are in the same fix as with the MDPA.  With the
graphic modes however, the dot representations are "drawn" on the screen by
software in the ROM BIOS code (Int 0x10).  Using the ROM BIOS, the patterns
for characters 0x00-0x7F are taken from the ROM BIOS (ie: software or firmware
ROM, readable by the CPU).  To change these, you would have to replace the
ROM BIOS software with some code in RAM which intercepts calls to Int 10
before it gets to the ROM BIOS - this would be dynamic as you seek.  For
characters 0x80-0xFF the ROM BIOS does not store the patterns - if you want
them you HAVE to define them yourself (remember, this is in graphic modes
only).  This is described in the IBM PC Tech Ref Manual, for example.  If
you have a CGA or compatible, use software which always goes thru the ROM
BIOS (rather than writing to the screen directly), can afford the slowdown
of the graphic mode characters (which take longer to display and scroll), 
then this might be the route for you.  If you only need a few special
character (which can be mapped to hi-bit-set character, 80-FF) this will be
especially easy.

If you have a "Monochrome Graphics Controller", such as made by Hercules and
their imitators, the situation is similar except you will definitely need to
write your own software, since the ROM BIOS doesnt know at all how to draw
characters in that graphics mode.

Finally, the good news: The EGA allows redefinition of the dot patterns for
each character for both graphic and character modes.  This is very often
compatible with software which expects a CGA or MDPA in character mode
(graphic modes are somewhat less perfectly compatible).  This means that with
an EGA or clone, your software can "load" new dot patterns which are used
for all character display, and is invisible to most software.  So if you want
to change the # to a British pound, your editor may not even be aware of the
substitution.  The details of this are beyond my scope tonight, but PC Tech
Journal has described the calls needed.  Please note that all you are changing
is the screen display: if you redefine $ to be a-umlaut, dont expect your
software to consider it a "letter" now - it will still treat it exactly as a
$ (perhaps a better example would be redefining the comma display - it may
now show as a European letter on the screen, but you can't use it inside an
identifier...).  That type of "semantic" redefinition is totally unprovided
for on the IBM PC.  Also note that you will need still other tricks to make
your printer display the "redefined" characters as you wish - there is not
sharing of info between them.

I hope this helps.  The technical details are beyond my limits tonight for
typing, and you may or may not want them anyway.  Perhaps someone else will
explain them further or give better references - this overview may help put
such details into perspective.  Good luck!   ~z~

-- 
Zhahai Stewart
{hao | nbires}!gaia!zhahai

cjdb@sphinx.UUCP (02/24/87)

In article <1303@erix.UUCP> joe@erix.UUCP (Joe Armstrong) writes:
>
>Has anybody any help with the following:
>
>What I want to do:
>
>        Dynamically  (i.e.  not at boot time)  Change the  system character
>sets to my own character sets - at any time I'd  like to be able  to poke a
>new character definition into the machine.
>

A simple way to do this is to buy a Hercules Graphics Card Plus. It
comes with an editor, and you can design any character you want and
put it anywhere you want, whenever you want. This is not perhaps what
you had in mind, but it's convenient.



-- 
Charles Blair   			    ..!ihnp4!gargoyle!sphinx!cjdb
The University of Chicago		          PMRCJDB@UCHIMVS1.Bitnet

jkg@gitpyr.UUCP (02/25/87)

OK, I'm going to stick my neck WAAAAYYYY out and answer this one. This
applies to the MDA or CGA in character modes ONLY. I have no experience
whatever with Hercules cards or the EGA.

In article <1303@erix.UUCP> joe@erix.UUCP (Joe Armstrong) writes:
>        Dynamically  (i.e.  not at boot time)  Change the  system character
>sets to my own character sets - at any time I'd  like to be able  to poke a
>new character definition into the machine.

>        1) Are the characters sets in RAM

No, there is a mask-programmed ROM on both the monochrome and color graphics
adaptors which cannot be changed (except by removal and replacement with a
different character ROM). It is usually a MOSTEK series 36000 8K x 8 ROM which 
handles ASCII character to pixel translation.

>        2) If so at what address

The ROM is not even in the CPU address space! The address lines of the ROM
are driven by the data outputs of the video RAM plus the row address lines 
of the 6845 CRT controller. You couldn't access the ROM directly if you
wanted to.

>        3) How are the characters packed

Interesting question. IBM used some goofball addressing scheme that makes 
the raster rows non-contiguous. I think the reason is so they could support 
all the character modes on the CGA without duplicating pixel data. I had
quite a bit of fun figuring this out (luckily, I had a Technical Reference
Manual handy).

>        4) If I change the RAM character set (I assume it is in RAM)
>           can I use bios calls to output the characters or what?

Don't know about this one. It should be possible to do define your own 
characters in graphics mode (this is how programs like PC-Paint and PC
StoryBoard get away with it), but it would require a fair amount of CPU 
overhead to manage the whole thing - in other words it would be really
ssllloooooowwwwww. My guess is that you would have to do direct screen 
writes to make it work.

Any MDA or CGA compatible card should use this same method for character 
formation. All bets are off for the EGA - I don't know anything about how 
it handles character formation. 

						Jim Greenlee
-- 
The Shadow...!{akgua,allegra,amd,hplabs,ihnp4,seismo,ut-ngp}!gatech!gitpyr!jkg

Jryy, abj lbh'ir tbar naq qbar vg! Whfg unq gb xrrc svqqyvat jvgu vg hagvy lbh
oebxr vg, qvqa'g lbh?!

dan@srs.UUCP (02/26/87)

In article <1303@erix.UUCP> joe@erix.UUCP (Joe Armstrong) writes:
  >  How do I change character sets at run time?
And zhahai@gaia.uucp replies:
  >  The CGA or HDA can help some, but the EGA is the only hardware answer.
You could also try using NANSI.SYS- it allows you to redefine character
sets on the fly- but only for output done via DOS, not via BIOS.
(Fortunately, buffered, raw DOS output with NANSI is about ten times faster 
than BIOS output, so you don't lose any speed that way.)
It's public domain, and should be easy to find.
- Dan Kegel
seismo!rochester!srs!dan