home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
d
/
drawprint
/
!DrawPrint
/
DUAmodSWIs
< prev
next >
Wrap
Text File
|
1995-01-28
|
28KB
|
673 lines
DUAmodSWIs:
SWI calls for DrawUtilsA module V1.02 (21 Apr 95)
-------------------------------------------------
Introduction
============
This module provides a number of SWI calls concerned with the pre-processing
and display of DrawFiles. The module can render all of the object types
currently used by Draw (including text area objects), and also sprite
objects containing the new 'deep-colour' (32 thousand & 16 million colour)
sprites introduced with RISC OS 3.5.
The SWI calls are:
Name Number
------------------- ------
DF_LastErrorA &4B0C0
DF_Verify &4B0C1
DF_ListUnknownFonts &4B0C2
DF_ChangeFont &4B0C3
DF_CompileFontTable &4B0C4
DF_SetBBoxes &4B0C5
DF_GetPageSize &4B0C6
DF_GetImageSize &4B0C7
DF_Render &4B0C8
The module should only be used with RISC OS version 3.1 or later.
All SWI calls (except DF_LastErrorA) perform error checking on their entry
parameters and on the DrawFile header (up to and including the image
bounding box). DF_Verify provides a means of checking the structure of the
DrawFile in detail; the other calls perform a lesser (sometimes minimal)
degree of error checking, and it is recommended that the file be verified
before using these calls.
Error reporting
===============
With the exception of DF_LastErrorA and (in part) DF_Verify, reporting of
any error condition can be made in one of two ways depending on the setting
of bit 0 of the control flags parameter passed in R0.
If bit 0 of the control flags is set, then a standard os error block is
returned and the error can be trapped (e.g.) in Basic with an ON ERROR
statement. However, the error code value is always the same as the module
base chunk number (&4B0C0) and the error text is always "DrawUtils(A) module
error". To identify the error, DF_LastErrorA should be called immediately
the error is returned (i.e. before any other calls to the module which would
over-write the internal error status block). In Basic this could be
implemented as:
DEF PROCchange_font
LOCAL fault%
LOCAL ERROR : ON ERROR LOCAL fault% = TRUE
IF NOT(fault%) THEN
REM prepare for call
SYS "DF_ChangeFont", 1, other parameters...
REM no error, continue
ELSE
SYS "DF_LastErrorA" TO code%, tag%, pos%, offset%
REM report error and/or
REM take corrective action
ENDIF
RESTORE ERROR
ENDPROC
If bit 0 of the control flags is clear then details of the error are
returned in R0 - R3 (code%, tag%, pos% and offset% respectively). In this
case, if R0 = 0 on return it indicates that no error has occurred. The full
error description can be obtained by recording R0 - R3 on return, or only R0
and then calling DF_LastErrorA. In Basic the latter method could be
implemented as:
DEF PROCchange_font
REM prepare for call
SYS "DF_ChangeFont", 0, other parameters... TO code%, other results
IF code% = 0 THEN
REM no error, continue
ELSE
SYS "DF_LastErrorA", TO code%, tag%, pos%, offset%
REM (actually we already had code% before this call)
REM report error and/or
REM take corrective action
ENDIF
ENDPROC
In both examples, code% is a non-zero error code (see list below), tag% is
the tag type of the object causing the error (e.g. 1 = text object, 2 = path
object), pos% is the position of the object in bytes from the start of the
file, and offset% is the location of the error-causing sequence in bytes
from the start of the object. In many cases, offset will be zero since the
location of the error-causing sequence will be evident from the error code.
DF_LastErrorA (SWI &4B0C0)
===========================
Purpose: return contents of module error status block.
On entry: registers unused
On exit: R0 = error code
R1 = tag of type of object containing error
R2 = position of object
R3 = offset to error sequence
This call returns details of the last error to occur for any of the other
module SWI calls; see the explanation of error reporting above for details.
If there was no error then R0 = 0 and the other registers are undefined.
DF_Verify (SWI &4B0C1)
=======================
Purpose: verify a DrawFile.
On entry: R0 = control flags
R1 = pointer to buffer containing DrawFile
(in user area, address > &8000)
R2 = DrawFile size (bytes, must be correct)
R3 = pointer to message block (in user area,
address > &8000, minimum size 64 bytes)
R4 = message block size (bytes)
control flags: bit meaning when set
---- ----------------
0 determines method of error reporting
1-31 reserved (should be zero)
On exit: R0 = depends on method of error reporting
R1 - R4 = preserved
R5 = number of errors listed in message block
R6 = -1 if whole file verified, else zero
R7 = status flags (only if R6 = -1)
If bit 0 of control flags = 0 then any error in the
entry parameters or DrawFile header is reported in
R0 - R3 (other registers are undefined); R0 = 0 means
no error has occurred.
status flags: bit meaning when set
---- ----------------
0 other error (not unknown font) in DrawFile
1 unknown font(s) used
2 image and/or object bounding box(es) may
be incorrect
3 options object present
4 deep colour sprites present
Any error in the entry parameters or the DrawFile header is reported as
described above. Otherwise, the file is scanned and a list of errors (if
any) is built up in the message block. The format of the block is:
block + 0 : error code (of first error)
+ 4 : tag "
+ 8 : position "
+ 12 : offset "
block + 16 : error code (of second error)
+ 20 : tag "
+ 24 : position "
+ 28 : offset "
The error code is non-zero (see list below). Tag is the tag type of the
object containing the error. Position is its position in bytes from the
start of the file. Offset is the location of the error-causing sequence in
bytes from the start of the object; this is zero if the location of the
error-causing sequence can be determined from the error code.
Compilation of the error list continues until the whole file has been
verified, or there is no room to list more errors in the message block, or a
bad object size error is encountered at the top level (i.e. not inside a
group or tagged object).
Fonts listed in the font table but not used in any type of text object are
ignored.
Use of an unknown font in any type of text object is listed as an error in
the message block.
Only the first error encountered in an object is listed; scanning then
proceeds to the next object (unless it was an unknown font usage error in
which case it is listed in the message block and scanning continues within
the object). Verification is terminated if a bad object size error is
encountered at the top level (i.e. not inside a group object or tagged
object)
If an error is found in the header of a group object or tagged object then
the object(s) contained within it are not examined.
All objects contained within a group object are examined before proceeding
to the object following the group object (therefore all objects are examined
in the order in which they occur in the file).
In the case of objects contained inside a group object, the first error
encountered is reported and scanning proceeds to the next object (in the
group) unless it was a bad object size error in which case scanning
continues at the object after the group object.
Status flags
------------
If no errors are found then bits 0 and 1 of status flags are clear. If only
unknown font usage errors are found, then bit 1 of status