[comp.sys.amiga.programmer] Here's an EASY one for you Character Set Interpretation

dac@prolix.pub.uu.oz.au (Andrew Clayton) (04/12/91)

In article <1097@cbmger.UUCP>, Peter Kittel GERMANY writes:

> In article <18f73ee5.ARN18a5@prolix.pub.uu.oz.au> dac@prolix.pub.uu.oz.au writes:
> >In article <1080@cbmger.UUCP>, Peter Kittel GERMANY writes:
> >
> >> Ehm, I think here's a flame necessary: WHY THE H*LL DO YOU ONLY RECOGNIZE
> >> 95 CHARACTERS??? From my counting, the Amiga character set holds excatly
> >
> > and if I had a 'read the bitmap from the font'
> >program, I could do it, I guess. But I don't. Yet. Is anyone going to answer
> >that one? [Remember - Arexx solutions only!]
> 
> Sorry, not yet ARexx literate. In AmigaBasic:
> FOR i=2 to 15:IF i=8 then i=10  ' skip Ctrl chars
> PRINT i,:FOR j=0 to 15:PRINT CHR$(i*16+j);"  ";:NEXT:PRINT:NEXT

Err, yeah, but that isn't what I want to do, Peter.

Harking back to my original question; there are bitmaps for each character in
a font, available [somehow] via pointers to structures in the font.  I need to
access the bitmap - AND INTERPRET IT.

0xFFFF = 1 1 1 1   1 1 1 1   1 1 1 1   1 1 1 1 == ****************
0x2525 = 0 0 1 0   0 1 0 1   0 0 1 0   0 1 0 1 ==   *  * *  *  * *
0xACAC = 1 0 1 0   1 1 0 0   1 0 1 0   1 1 0 0 == * * **  * * **
0x7337 = 0 1 1 1   0 0 1 1   0 1 1 1   0 0 1 1 ==  ***  ** ***  **

(That pattern doesn't make any sense, I just picked the numbers out of thin
air)

This was, I can take the BITMAP for '@' and print it out as a BIG character.

Trouble is, I don't know how to access the bitmap from Arexx, which is what my
original question was.

> >Manipulating characters that are generated by deadkeys is, to my eyes, a
> >hardship that I don't want to go through.
> 
> You don't need to consider dead keys. You just design the final accented
> chars. And thus things get really easy: For most of these MSB chars, you
> can duplicate the entry for one pure char with MSB==0 and simply add a
> little accent or umlaut to it, easy!

We are working at odds here, Peter; if I want to convert some text to BIGCHAR
format, I pass a string to my program, and it uses the character passed as a
jump into the font structure, and then I examine what bitmap is available, and
print out that character.  In actuality, with a 8*8 font, I would construct
eight lines of text seperately.  Here is how I currently do it, with my
self-supplied array [which is a 6 * 7 array!];

LenStart = 1
DO Lines = 1 to NumLines
  DO Chars = 1 to MaxCharsOnLine
    TempChar = SUBSTR(ARGLine,LenStart,1)                 /* Get Char      */
    IF TempChar = " " THEN TempChar = ""                  /* Is it a " "?  */
    DO Loop = 1 to 6
      String = "N" || TempChar || "." || Loop             /* String = NC.n */
      TextLine.Loop = TextLine.Loop || VALUE(String)      /* Magic Value!!!*/
    END
    LenStart = LenStart + 1                               /* Increment ^Char*/
  END
  DO Loop = 1 to 6        /* Print out the formatted character */
    Say TextLine.Loop     /* One row of characters a time */
    TextLine.Loop = " "   /* Delete the TextLine variables */
  END
END

[example of character set]

NA.1 = "  ___  ";  NG.1 = "  ___  ";  NM.1 = " _   _ ";  NS.1 = "  _____"
NA.2 = " /***\ ";  NG.2 = " /***\ ";  NM.2 = "|*\_/*|";  NS.2 = " /****/"
NA.3 = "|*|_|*|";  NG.3 = "|*| ~~ ";  NM.3 = "|*\*/*|";  NS.3 = "<*<__  "
NA.4 = "|*****|";  NG.4 = "|*| __ ";  NM.4 = "|*\*/*|";  NS.4 = " \***\ "
NA.5 = "|*| |*|";  NG.5 = "|*||**|";  NM.5 = "|*| |*|";  NS.5 = "____>*>"
NA.6 = "|*| |*|";  NG.6 = " \***/ ";  NM.6 = "|*| |*|";  NS.6 = "\****/ "

(****)

Example output:

rx bigchar silly game

   _____ _____  _      _     __   __         ___    ___   _   _  _____  
  /****/|*****||*|    |*|    \*\ /*/        /***\  /***\ |*\_/*||*****| 
 <*<__    |*|  |*|    |*|     \*X*/        |*| ~~ |*|_|*||*\*/*||*|__
  \***\   |*|  |*|    |*|      |*|         |*| __ |*****||*\*/*||****|  
 ____>*> _|*|_ |*|___ |*|___   |*|         |*||**||*| |*||*| |*||*|___  
 \****/ |*****||*****||*****|  |*|          \***/ |*| |*||*| |*||*****|

(***)

Capische?

> >Who is going to use ASCII 193 in the normal scheme of things?
> 
> Well, it's like all those security checks in a program: Were you *really*
> able to allocate those 16 bytes? Many people don't check for such little
> things, but one day, on a special situation: poof!

The whole problem is irrelevant if I jump straight into the font array based
upon the character's ASCII value.

> >[Offhand, I don't know what ASCII 193 even is :-)]

     ********************************************************************
     *[Oops, 'ASCII 193' is a misnomer; ASCII / ANSI only defines 0-127]*
     ********************************************************************

> From AmigaBasic manual, appendix A: it's a capital A with aigu accent.

:-) I always knew that the AmigaBasic manual served SOME purpose!

> >Those things with accents, graves, and umlauts on them?  Removing all that
> >extraneous data makes [the ascii part of] dumps easier to read!  Obviously!
>                         ^^^^^^^^^^^^^^           ^^^^^^ AAARRRRGGH!!!
> 1. The "other" part is also ascii, 2. I find it more readable when there
> are not suddenly holes in plain text.

No, they aren't.  They are outside of the standard ASCII / ANSI character
range. I'm not interested in getting into an argument about character set
standards, I didn't come here for an argument, or for 'being hit on the head'
lessons :-).

I thank you for your efforts though. You at least tried. 

Dac
--
David Andrew Clayton. // _l _  _ dac@prolix.pub.uu.oz.au    *or*|I post.I am.
Canberra, Australia.\X/ (_](_l(_ ccadfa.cc.adfa.oz.au!prolix!dac@munnari.oz

peterk@cbmger.UUCP (Peter Kittel GERMANY) (04/15/91)

In article <18fa0585.ARN1913@prolix.pub.uu.oz.au> dac@prolix.pub.uu.oz.au writes:
>In article <1097@cbmger.UUCP>, Peter Kittel GERMANY writes:
>> 
>> You don't need to consider dead keys. You just design the final accented
>> chars. And thus things get really easy: For most of these MSB chars, you
>> can duplicate the entry for one pure char with MSB==0 and simply add a
>> little accent or umlaut to it, easy!

(see below)

>We are working at odds here, Peter; if I want to convert some text to BIGCHAR
>format, I pass a string to my program, and it uses the character passed as a
>jump into the font structure, and then I examine what bitmap is available, and
>print out that character.  In actuality, with a 8*8 font, I would construct
>eight lines of text seperately.

Well, perhaps time for a *deep* look into the RKM's, fonts chapter...

>NA.1 = "  ___  ";  NG.1 = "  ___  ";  NM.1 = " _   _ ";  NS.1 = "  _____"
>NA.2 = " /***\ ";  NG.2 = " /***\ ";  NM.2 = "|*\_/*|";  NS.2 = " /****/"
>NA.3 = "|*|_|*|";  NG.3 = "|*| ~~ ";  NM.3 = "|*\*/*|";  NS.3 = "<*<__  "
>NA.4 = "|*****|";  NG.4 = "|*| __ ";  NM.4 = "|*\*/*|";  NS.4 = " \***\ "
>NA.5 = "|*| |*|";  NG.5 = "|*||**|";  NM.5 = "|*| |*|";  NS.5 = "____>*>"
>NA.6 = "|*| |*|";  NG.6 = " \***/ ";  NM.6 = "|*| |*|";  NS.6 = "\****/ "

Yes, I meant *these* tables where you easily could duplicate these
lines for the "A" and create entries for accented "A" in your text
editor (not at run time). Only the naming of your arrays could become
sort of a problem...

-- 
Best regards, Dr. Peter Kittel  // E-Mail to  \\  Only my personal opinions... 
Commodore Frankfurt, Germany  \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk

dac@prolix.pub.uu.oz.au (Andrew Clayton) (04/16/91)

In article <1116@cbmger.UUCP>, Peter Kittel GERMANY writes:

> (see below)
> 
> >We are working at odds here, Peter; if I want to convert some text to BIGCHAR
> 
> Well, perhaps time for a *deep* look into the RKM's, fonts chapter...

That's what I had to do; the nice person who sent me the structure convinced
me to have a look there, and do it in Modula. But I resisted temptation :-).

After jumping a few Arexx hurdles, I've managed to get fairly well into where
I want to be, but I have to use a few kludges, because offsets into structures
are just not easy to calculate in Arexx. You can't easily add numbers, you
can't easily use hex offsets. It's all pretty messy.

This is what I've done so far, I've now got to undecode the bitmaps using
charloc and chardata;

[in case anyone is slightly interested, here's what I've done so far]

/*rexx*/
/*** Load rexxsupport library **********************************************/

if ~show('l','rexxsupport.library') then
   if ~addlib('rexxsupport.library',0,-30) then
      do
         say "no library!"
         exit 5
         end

/*** Load preset offsets into structures ***********************************/

call offsets

/*** calculate GfxBase *****************************************************/

gfxbase = (showlist('l','graphics.library',,a))

/*** read TextFonts ********************************************************/

fontptr = (d2c(c2d(gfxbase,4) + TextFonts,4))
font = import(fontptr,4)

/*** calculate Charloc and CharData ****************************************/

locptr = (d2c(c2d(font,4) + Locoffset,4))
charloc = import(locptr,4)
dataptr = (d2c(c2d(font,4) + Dataoffset,4))
chardata = import(dataptr,4)

/*** Now display some values ***********************************************/

say "gfxbase =" c2x(gfxbase)
say "font    =" c2x(font)
say "charloc =" c2x(charloc)
say "chardata=" c2x(chardata)

/*convert the addresses to decimal*/

charloc = c2d(charloc)
chardata = c2d(chardata)
say charloc chardata

/* rest of program [when written] follows */

EXIT

/*** Offset precalc ********************************************************/

Offsets:

TextFonts  = 140
Locoffset  = 40
Dataoffset = 34

-----------------------------------end of Arexx----------------------------

> Yes, I meant *these* tables where you easily could duplicate these
> lines for the "A" and create entries for accented "A" in your text
> editor (not at run time). Only the naming of your arrays could become
> sort of a problem...

I admit, once they are created, it's no great hardship to fiddle with them,
but it's not an algorithmic solution to the problem, which is why I'm going
down the dim dark path of peeking into fonts and ripping out the information.

Now that I have the POINTERS [and some confidence in my ability to read memory
with Arexx] to the Font structure, I am home free. Just the tedious mucking
around with bit offsets, and expanding the bits, and then replacing them with
whatever character I want [Translate(image,1,*)]. Should be a piece of cake.
:-)

The only thing that stopped me completing it today, was todays news.

Thanks for your comments.

Dac
--