AcornSearch - Acorn and RISC OS information searching
RISC OS Search
containing
"Nutty quip goes here!"
Home  |  About  |  Filebase Archive  |  StrongHelp Manuals  |  Newsgroups  |  Module Database
Offset:          40  (&28)
Set up by:     you

DSA mode:     This gives the character cache in this format
VDU mode:     Pointer to the font name to use, or 0 for system font
or:     A font handle.

cache format
When using direct screen access, the module will expect this
block to contain the bitmaps for all the characters it is asked to print.
Each character has size r_cbpc so it will expect to find the bitmap for ASCII
character 'n' at address char_start = (!r_caddr)+n*r_cbpc. The character
definition then consists of r_charh rows of r_cbpl each so
r_cbpc=r_charh*r_cbpl. 
NB r_cbpl need not be a multiple of 4 so this address need not be word aligned.

The format of a row is the same of that for a sprite file except there is
never any lhs wastage. Ie, the first pixel is aligned to the start of the
first word. Each character is r_charw pixels wide and thus requires
N=r_charw << r_bpp bits of storage. There are special cases when N is
small:

If 0 < N =< 8     then r_cbpl = 1 and the top 8-N bits of each byte are wasted.
If 8 < N =< 16     then r_cbpl = 2 and the top 16-N bits of each byte are wasted.
If N > 16          then r_cbpl is aligned to the next multiple of 4 bytes greater
               or equal to N. (eg 16 <N =< 32 => r_cbpl=4, 32 <N =< 64 => r_cbpl=8 etc).

The SWI ZapRedraw_CachedCharSize will calculate the values of r_cbpl and
r_cbpc for you from a given size of character.

Only TWO colours can be used in the defn of the character. Set all foreground
pixels to 1's and background pixels to 0's. Eg, in a 16 colour mode pixels
will be either 1111 or 0000. Unused bits at the end of the words (or bytes)
are ignored and so can contain rubbish. The real foreground and background
colours are masked in at redraw time.

Examples:

For 8*8 characters at 1 bit per pixel we have 1 byte per row. Eg "E" may be
cached as:
                      b0 .. b7
     row0     &7E          01111110
     row1     &06          01100000
     row2     &06          01100000
     row3     &7E          01111110
     row4     &06          01100000
     row5     &06          01100000
     row6     &7E          01111110
     row7     &00          00000000

If it was in a 16 colour mode then there would be one word per row and the
first rows would be:
                      b0 ......................... b31
     row0     &01111110     00001111111111111111111111110000
     row1     &00000110     00001111111100000000000000000000
     ...

In general you have:

     Word 0                                  Word (N/4)-1
     b0 .... b31    ...................      b0 ..... b31
     pix0 pix1 ......................pix(r_charw-1) 00000

In practice you first cache the font at one bit per pixel (eg use
ZapRedraw_ReadSystemChars) and then convert it to 'n' bits per pixel (for
the current mode) by use of ZapRedraw_ConvertBitmap.

[sh-index] Back to list of manuals