home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
utilities
/
utilst
/
zap
/
!Zap
/
Docs
/
Redraw
< prev
Wrap
Text File
|
1995-03-30
|
38KB
|
870 lines
*************************************************************************
* >Redraw - Documentation for the ZapRedraw module v0.22 *
*************************************************************************
Summary:
--------
The module ZapRedraw provides the "ZapRedraw_" SWI's which are capable of
drawing a rectangle of text characters on screen. It offers the following
features:
* Redraw may be by direct screen access (henceforth DSA) where the
data is poked into the screen memory or by the standard VDU redraw.
* Full colour provided (with your own definable palette). Supports up to 32
bits per pixel in DSA mode and 24 bit colour in VDU mode.
* DSA redraw can handle any size of bitmap characters. Special optimised
code is provided for 8 pixel wide characters in all modes.
Also 8*8 and 8*16 character sizes are given priority.
Up to 65536 characters can be defined.
* VDU redraw mode can handle any font and font size.
* Support is provided for cursors.
* Many extra SWIs perform all the work of creating cached bitmaps, updating
them on a mode change etc. Swi's are also provided for creating palettes
and other functions related to the redraw.
* An example program is provided which can be used as a template.
Limitations:
* All characters are equally spaced. Proportional spacing is not supported.
Copyright:
----------
The ZapRedraw module is copyright Dominic Symes 1994. Please contact me if
you wish to use it in a program other than Zap. See the Zap Copyright file
for my address.
Definitions required for the SWI's
==================================
ZapRedraw chunk prefix: ZapRedraw
ZapRedraw chunk number: &48480
All SWI numbers below are given as offsets from the chunk number.
'DSA' means direct screen access mode (characters poked into the screen).
'VDU' means VDU mode (operating system called to draw characters).
Pixel co-ordinates are used wherever possible to prevent rounding errors when
OS co-ordinates are not pixel aligned (these errors DO mess things up!).
Pixel co-ordinates are from the top left of the screen with the y axis
descending. By a 'pixel' I mean a hardware pixel (this differs from an OS
pixel in double-pixel emulation modes - this only crops up in the RISC OS 2
MODE 2 wimp!).
Zap redraw block:
-----------------
For several SWI's, R1 points to a redraw block of the type described below.
The SWI documentation will mention which data in the block is actually used
by that SWI (so should be filled in). Each offset in the block is named with
a name beginning 'r_'. The Basic program E-Library contains a procedure to
set these variables up should you be using the Basic assembler. The contents
of some offsets depends on which redraw mode is being used (VDU or DSA), this
is indicated by 'VDU:' and 'DSA:'.
Offset Name Function
&00 r_flags Flags word determining the type of redraw:
b0 Clear for DSA mode. Set for VDU redraw mode.
b1 Set for 'double height mode'. Only valid in DSA
mode. Draws each raster twice so actual character
height is 2*r_charh and spacing 2*r_linesp.
b2 Extension routine provided.
Only valid in DSA mode. See ZapRedraw_RedrawArea.
b3-31 Reserved - set to zero.
&04 r_minx Min x of redraw (pixels from lhs - inclusive)
&08 r_miny Min y of redraw (pixels from top - inclusive)
&0C r_maxx Max x of redraw (pixels form lhs - exclusive)
&10 r_maxy Max y of redraw (pixels from top - exclusive)
&14 r_screen DSA: Address of screen to write to or 0 to read the
current screen address.
VDU: ignored
&18 r_bpl DSA: Bytes per raster line of the screen
VDU: ignored
&1C r_bpp Log base 2 of number of bits per pixel
(ie 0=2 cols 1=4 cols 2=16 cols 3=256 cols
4=65536 cols 5=2^32 cols).
&20 r_charw Width of a character in pixels
&24 r_charh Height of a character in pixels
&28 r_caddr DSA: Address of character cache (format below)
VDU: Pointer to font name or 0 for system font
&2C r_cbpl DSA: Number of bytes per cached character line.
VDU: x os offset of where to print the font char
in the character 'box'. (eg 0 for system font)
&30 r_cbpc DSA: Number of bytes per cached character.
VDU: y os offset of where to print the font char
in the character 'box'. (eg char height-1 for
system font as VDU5 plots char downwards).
&34 r_linesp Line spacing in pixels.
&38 r_data Address of data (rectangle of characters) to print
on the screen (format below).
&3C r_scrollx Horizontal scroll offset in rectangle of characters
given in r_data of top left of redraw rectangle.
This is in pixels from the lhs of the characters.
Thus it equals n*r_charw+m where n is the number of
characters in and m is the number of pixels into
the n'th character.
&40 r_scrolly Vertical scroll offset in rectangle of characters
given in r_data of top left of redraw rectangle.
This is in pixels from the top of the characters.
Note that in single height mode each line is
r_charh+r_linesp pixels high and in double height
mode each line is 2*(r_charh+r_linesp) pixels high.
&44 r_palette Address of palette to be used for colour translation.
(see below).
&48 r_for Foreground colour to use at the start of a line as an
offset in the palette table.
&4C r_bac Background colour to use at the start of a line as
an offset in the palette table.
&50 r_workarea Pointer to an area of workspace for the SWI to use.
The size of this workspace depends on the SWI.
(It must be word aligned).
&54 r_magx Log base 2 of number of x os co-ords per pixel.
&58 r_magy Log base 2 of number of y os co-ords per pixel.
&5C r_xsize Width of screen in pixels.
&60 r_ysize Height of screen in pixels.
&64 r_mode Current screen mode.
Character cache format (r_caddr):
---------------------------------
When using VDU redraw, this should point to the name of the font to use, or
be zero for the system font.
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 run 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
ZapRed