home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsd / duamodule / DUAmodule / DUAmodSWIs < prev   
Encoding:
Text File  |  1996-03-25  |  36.9 KB  |  900 lines

  1.  
  2. DUAmodSWIs:
  3.   SWI calls for DrawUtilsA module V1.12 (24 Mar 96)
  4.   -------------------------------------------------
  5.  
  6. Introduction
  7. ============
  8. This module provides a number of SWI calls concerned with the pre-processing
  9. and display of drawfiles. The module can render all of the object types
  10. currently used by Draw (including text area objects), and also sprite
  11. objects containing the new 'deep-colour' (32 thousand & 16 million colour)
  12. sprites introduced with RISC OS 3.5.
  13.  
  14. The SWI calls are:
  15.    Name                  Number
  16.    -------------------   ------
  17.    DF_LastErrorA         &4B0C0
  18.    DF_Verify             &4B0C1
  19.    DF_ListUnknownFonts   &4B0C2
  20.    DF_ChangeFont         &4B0C3
  21.    DF_CompileFontTable   &4B0C4
  22.    DF_SetBBoxes          &4B0C5
  23.    DF_GetPageSize        &4B0C6
  24.    DF_GetImageSize       &4B0C7
  25.    DF_Render             &4B0C8
  26.    DF_TextAreaExtent     &4B0C9  (support for DrawUtilsB module)
  27.  
  28. The module should only be used with RISC OS version 3.1 or later.
  29.  
  30. All SWI calls (except DF_LastErrorA) perform error checking on their entry
  31. parameters and on the drawfile header (up to and including the image
  32. bounding box). DF_Verify provides a means of checking the structure of the
  33. drawfile in detail; the other calls perform a lesser (sometimes minimal)
  34. degree of error checking, and it is recommended that the file be verified
  35. before using these calls. 
  36.  
  37.  
  38. Error reporting
  39. ===============
  40. With the exception of DF_LastErrorA and (in part) DF_Verify, reporting of
  41. any error condition can be made in one of two ways depending on the setting
  42. of bit 0 of the control flags parameter passed in R0.
  43.  
  44. If bit 0 of the control flags is set, then a standard os error block is
  45. returned and the error can be trapped (e.g.) in Basic with an ON ERROR
  46. statement (you can also use the 'X' form of the SWI). The error code value
  47. is always the same as the module base chunk number (&4B0C0) and the error
  48. text is:
  49.  
  50.   DrawUtils(A) module error: code, tag, pos, offset
  51.  
  52. where code, tag, pos and offset are in decimal with meanings as explained
  53. below. These values can also be obtained by calling DF_LastErrorA
  54. immediately the error is returned (i.e. before any other calls to the module
  55. which would over-write the internal error status block). In Basic this could
  56. be implemented as:
  57.  
  58.     DEF PROCchange_font
  59.       LOCAL fault%
  60.       LOCAL ERROR : ON ERROR LOCAL fault% = TRUE
  61.       IF NOT(fault%) THEN
  62.         REM prepare for call
  63.         SYS "DF_ChangeFont", 1, other parameters...
  64.         REM no error, continue
  65.       ELSE
  66.         SYS "DF_LastErrorA" TO code%, tag%, pos%, offset%
  67.         REM report error and/or
  68.         REM take corrective action
  69.       ENDIF
  70.       RESTORE ERROR
  71.     ENDPROC
  72.  
  73. If bit 0 of the control flags is clear then details of the error are
  74. returned in R0 - R3 (code%, tag%, pos% and offset% respectively). In this
  75. case, if R0 = 0 on return it indicates that no error has occurred. The full
  76. error description can be obtained by recording R0 - R3 on return, or only R0
  77. and then calling DF_LastErrorA. In Basic the latter method could be
  78. implemented as:
  79.  
  80.     DEF PROCchange_font
  81.       REM prepare for call
  82.       SYS "DF_ChangeFont", 0, other parameters... TO code%, other results
  83.       IF code% = 0 THEN
  84.         REM no error, continue
  85.       ELSE
  86.         SYS "DF_LastErrorA", TO code%, tag%, pos%, offset%
  87.         REM (actually we already had code% before this call)
  88.         REM report error and/or
  89.         REM take corrective action
  90.       ENDIF
  91.     ENDPROC
  92.  
  93. In both examples, code% is a non-zero error code (see list below), tag% is
  94. the tag type of the object causing the error (e.g. 1 = text object, 2 = path
  95. object), pos% is the position of the object in bytes from the start of the
  96. file, and offset% is the location of the error-causing sequence in bytes
  97. from the start of the object. In many cases, offset will be zero since the
  98. location of the error-causing sequence will be evident from the error code.
  99.  
  100.  
  101.  
  102. SWI calls
  103. =========
  104.  
  105. For all SWI calls-
  106.     Interupts are enabled
  107.     Fast interupts are enabled
  108.     Processor is in SVC mode
  109.     SWI is not re-entrant
  110.  
  111.  
  112.  
  113. DF_LastErrorA  (SWI &4B0C0)
  114. ===========================
  115.  
  116. Purpose: return contents of module error status block.
  117.  
  118. On entry:   registers unused
  119.  
  120. On exit:    R0    = error code
  121.             R1    = tag of type of object containing error
  122.             R2    = position of object
  123.             R3    = offset to error sequence
  124.  
  125. This call returns details of the last error to occur for any of the other
  126. module SWI calls; see the explanation of error reporting above for details.
  127. If there was no error then R0 = 0 and the other registers are undefined.
  128.  
  129.  
  130.  
  131. DF_Verify  (SWI &4B0C1)
  132. =======================
  133.  
  134. Purpose: verify a drawfile.
  135.  
  136. On entry:   R0    = control flags
  137.             R1    = pointer to buffer containing drawfile 
  138.                     (in user area, address > &8000)
  139.             R2    = drawfile size (bytes, must be correct)
  140.             R3    = pointer to message block (in user area,
  141.                     address > &8000, minimum size 64 bytes)
  142.             R4    = message block size (bytes)
  143.             R5    = unused
  144.             R6    = pointer to first object to verify } only if R0
  145.             R7    = pointer to last object to verify  } bit 3 set
  146.  
  147.    control flags: bit   meaning when set
  148.                   ----  ----------------
  149.                    0    determines method of error reporting
  150.                   1-2   reserved (should be zero)
  151.                    3    use R6 and R7 on entry as explained below
  152.                   4-31  reserved (should be zero)
  153.  
  154. On exit:    R0    = depends on method of error reporting
  155.           R1 - R4 = preserved
  156.             R5    = number of errors listed in message block
  157.             R6    = -1 if whole file verified, else zero
  158.                     or updated object pointer if R0 bit 3 set
  159.             R7    = status flags (only if R6 = -1)
  160.  
  161.     If bit 0 of control flags = 0 then any error in the
  162.     entry parameters or drawfile header is reported in
  163.     R0 - R3 (other registers are undefined); R0 = 0 means
  164.     no error has occurred.
  165.  
  166.     status flags: bit   meaning when set
  167.                   ----  ----------------
  168.                    0    other error (not unknown font) in drawfile
  169.                    1    unknown font(s) used
  170.                    2    image and/or object bounding box(es) may
  171.                         be incorrect
  172.                    3    options object present
  173.                    4    deep colour sprites present
  174.  
  175. Verifying (a) specified object(s)
  176. ---------------------------------
  177. If R0 bit 3 is set, then on entry R6 and R7 are pointers to the first and
  178. last objects respectively to verify (use R7 = R6 to verify a single object).
  179. R0-R4 should be set as described above. On exit, R6 points to the next
  180. object (or the location after the end of file) or is returned unaltered if
  181. the call exited because of a bad object size error or insufficint space in
  182. the message block. The number of errors is returned in R5 and R7 is used as
  183. described above but its value obviously depends on which object(s) were
  184. verified. The module expects the font table (if present) to be located
  185. immediately after the drawfile header, and verifies this irrespective of the
  186. R6 and R7 values. Also, if a group object or tagged object is encountered,
  187. all objects contained therein will be verified irrespective of the R7 value.
  188.  
  189. Message block format
  190. --------------------
  191. Any error in the entry parameters or the drawfile header is reported as
  192. described above. Otherwise, the file is scanned and a list of errors (if
  193. any) is built up in the message block. The format of the block is:
  194.  
  195.     block +  0 : error code (of first error)
  196.           +  4 : tag               "
  197.           +  8 : position          "
  198.           + 12 : offset            "
  199.  
  200.     block + 16 : error code (of second error)
  201.           + 20 : tag               "
  202.           + 24 : position          "
  203.           + 28 : offset            "
  204.  
  205. The error code is non-zero (see list below). Tag is the tag type of the
  206. object containing the error. Position is its position in bytes from the
  207. start of the file. Offset is the location of the error-causing sequence in
  208. bytes from the start of the object; this is zero if the location of the
  209. error-causing sequence can be determined from the error code.
  210.  
  211. Compilation of the error list continues until the whole file has been
  212. verified, or there is no room to list more errors in the message block, or a
  213. bad object size error is encountered at the top level (i.e. not inside a
  214. group or tagged object). 
  215.  
  216. Fonts listed in the font table but not used in any type of text object are
  217. ignored.
  218.  
  219. Use of an unknown font in any type of text object is listed as an error in
  220. the message block.
  221.  
  222. Only the first error encountered in an object is listed; scanning then
  223. proceeds to the next object (unless it was an unknown font usage error in
  224. which case it is listed in the message block and scanning continues within
  225. the object). Verification is terminated if a bad object size error is
  226. encountered at the top level (i.e. not inside a group object or tagged
  227. object)
  228.  
  229. If an error is found in the header of a group object or tagged object then
  230. the object(s) contained within it are not examined.
  231.  
  232. All objects contained within a group object are examined before proceeding
  233. to the object following the group object (therefore all objects are examined
  234. in the order in which they occur in the file).
  235.  
  236. In the case of objects contained inside a group object, the first error
  237. encountered is reported and scanning proceeds to the next object (in the
  238. group) unless it was a bad object size error in which case scanning
  239. continues at the object after the group object.
  240.  
  241. Status flags
  242. ------------
  243. If no errors are found then bits 0 and 1 of status flags are clear. If only
  244. unknown font usage errors are found, then bit 1 of status flags is set. If
  245. any other type of error is found then bit 0 of status flags is set; in this
  246. case further processing or display of the file is not recommended.
  247.  
  248. During verification, the module checks for invalid object bounding boxes
  249. (width or height <= 0) and, if found, issues a warning by setting bit 2 of
  250. status flags. The verification routine does not check that the bounding
  251. boxes are set correctly. An invalid bounding box is not reported as an error
  252. unless it applies to a (transformed) sprite object. In the case of text area
  253. objects, an error is also reported if all of the text column objects have
  254. invalid bounding boxes.
  255.  
  256. If deep colour sprites (32 thousand or 16 million colour) are found then bit
  257. 4 of status flags is set. It is left to the software calling the module to
  258. determine if the host machine is capable of displaying these sprites.
  259.  
  260.  
  261.  
  262. DF_ListUnknownFonts  (SWI &4B0C2)
  263. =================================
  264.  
  265. Purpose: obtain a list of unknown fonts used in the drawfile.
  266.  
  267. On entry:   R0    = control flags
  268.             R1    = pointer to buffer containing drawfile 
  269.                     (in user area, address > &8000)
  270.             R2    = drawfile size (bytes, must be correct)
  271.             R3    = pointer to message block (in user area,
  272.                     address > &8000, minimum size 64 bytes)
  273.             R4    = message block size (bytes)
  274.  
  275.    control flags: bit   meaning when set
  276.                   ----  ----------------
  277.                    0    determines method of error reporting
  278.                   1-31  reserved (should be zero)
  279.  
  280. On exit:    R0    = depends on method of error reporting
  281.           R1 - R4 = preserved
  282.             R5    = number of fonts listed in message block
  283.             R6    = -1 if whole file processed, else zero
  284.  
  285.     If bit 0 of control flags = 0 then any error is reported
  286.     in R0 - R3 (other registers are undefined); R0 = 0 means
  287.     no error has occurred.
  288.  
  289. A list of unknown fonts is written into the message block. The structure of
  290. the block is:
  291.  
  292.     block +  0 : first font
  293.     block + 40 : second font
  294.     block + 80 : third font, etc.
  295.  
  296. Each font name is terminated with a null character (zero byte). Compilation
  297. of the list continues until the whole file has been processed, or there is
  298. no room to list more fonts in the message block, or an error is found. With
  299. the exception of those relating to path objects and sprite objects, this
  300. call can return most of the errors recognized by DF_Verify. Each distinct
  301. font is listed once only irrespective of the number of times it is used in
  302. the drawfile. Fonts listed in the font table but not used in any text
  303. objects are ignored. Unknown fonts used only in text area objects and not
  304. listed in the font table are returned.
  305.  
  306.  
  307.  
  308. DF_ChangeFont  (SWI &4B0C3)
  309. ===========================
  310.  
  311. Purpose: replace one or more fonts in the drawfile.
  312.  
  313. On entry:   R0    = control flags
  314.             R1    = pointer to buffer containing drawfile 
  315.                     (in user area, address > &8000)
  316.             R2    = drawfile size (bytes, must be correct)
  317.             R3    = pointer to block containing search list
  318.                     (in user area, address > &8000)
  319.             R4    = pointer to block containing replace list
  320.                     (in user area, address > &8000)
  321.  
  322.  
  323.    control flags: bit   meaning when set
  324.                   ----  ----------------
  325.                    0    determines method of error reporting
  326.                    1    return new size of drawfile only (i.e.
  327.                         without altering file)
  328.                   2-31  reserved (should be zero)
  329.  
  330. On exit:    R0    = depends on method of error reporting
  331.           R1 - R4 = preserved
  332.             R5    = new drawfile size (bytes)
  333.  
  334.     If bit 0 of control flags = 0 then any error is reported
  335.     in R0 - R3 (other registers are undefined); R0 = 0 means
  336.     no error has occurred.
  337.  
  338. On entry R3 points to a list of font names to search for and R4 points to a
  339. list of replacements. The structure of the blocks is:
  340.  
  341.     search_block +  0 : unknown font 1
  342.     search_block + 40 : unknown font 2
  343.     (may be others at 40 byte intervals)
  344.     search_block + 80 : null string terminator
  345.  
  346.     replace_block +  0 : replacement font 1 (or null string)
  347.     replace_block + 40 : replacement font 2 (or null string)
  348.     (may be others at 40 byte intervals)
  349.  
  350. Font names can be terminated with any control character (ASCII code < 32).
  351. The search list is terminated by a null string. For each font in the search
  352. list, the corresponding position in the replace list should contain either a
  353. replacement font or a null string if no substitution is to be performed for
  354. that particular font. The system font cannot appear in either list. Unknown
  355. fonts used only in text area objects and not listed in the font table are
  356. replaced. The module assumes that the buffer holding the drawfile is large
  357. enough to accommodate any increase in file size that may result from this
  358. call.
  359.  
  360. The list returned by DF_ListUnknownFonts can be used as the search list, but
  361. you must add the null string terminator.
  362.  
  363.  
  364.  
  365. DF_CompileFontTable  (SWI &4B0C4)
  366. =================================
  367.  
  368. Purpose: update the drawfile font table.
  369.  
  370. On entry:   R0    = control flags
  371.             R1    = pointer to buffer containing drawfile 
  372.                     (in user area, address > &8000)
  373.             R2    = drawfile size (bytes, must be correct)
  374.  
  375.    control flags: bit   meaning when set
  376.                   ----  ----------------
  377.                    0    determines method of error reporting
  378.                    1    return new size of drawfile only (i.e.
  379.                         without altering file)
  380.                   2-31  reserved (should be zero)
  381.  
  382. On exit:    R0    = depends on method of error reporting
  383.           R1 - R4 = preserved
  384.             R5    = new drawfile size (bytes)
  385.  
  386.     If bit 0 of control flags = 0 then any error is reported
  387.     in R0 - R3 (other registers are undefined); R0 = 0 means
  388.     no error has occurred.
  389.  
  390. This call may be useful whether or not font substitution has been performed
  391. using DF_ChangeFont. Fonts listed in the font table but not used in any text
  392. objects are removed. Fonts used only in text area objects and not listed in
  393. the font table are included (if there is no font table then one will be
  394. inserted). If a font table is present and there are no text objects of any
  395. type then the font table is deleted. This call will not cause duplication of
  396. any font in the font table, but neither will it remove such duplication if
  397. present originally. The module assumes that the buffer holding the drawfile
  398. is large enough to accommodate any increase in file size that may result
  399. from this call.
  400.  
  401.  
  402.  
  403. DF_SetBBoxes  (SWI &4B0C5)
  404. ==========================
  405.  
  406. Purpose: set object bounding boxes correctly.
  407.  
  408. On entry:   R0    = control flags
  409.             R1    = pointer to buffer containing drawfile 
  410.                     (in user area, address > &8000)
  411.             R2    = drawfile size (bytes, must be correct)
  412.  
  413.    control flags: bit   meaning when set
  414.                   ----  ----------------
  415.                    0    determines method of error reporting
  416.                    1    update options object (if present)
  417.                   2-31  reserved (should be zero)
  418.  
  419. On exit:    R0    = depends on method of error reporting
  420.             R1    = image bounding box xmin (in Draw units)
  421.             R2    = image bounding box ymin       "
  422.             R3    = image bounding box xmax       "
  423.             R4    = image bounding box ymax       "
  424.             R5    = page size code
  425.  
  426.     If bit 0 of control flags = 0 then any error is reported
  427.     in R0 - R3 (other registers are undefined); R0 = 0 means
  428.     no error has occurred.
  429.  
  430. The bounding box for each text object and path object is calculated and
  431. written into the object header. The bounding box for each text area object
  432. is set according to its text column objects (except any with width or height
  433. <= 0). The bounding box for each group object and tagged object is set
  434. according to the objects contained within it. Unknown objects are ignored,
  435. as are sprite objects with an invalid bounding box. The image bounding box
  436. (in the drawfile header) is set according to all objects with a valid
  437. bounding box in the file. If bit 1 of control flags is set, the smallest
  438. paper 'A' size required to hold the image is determined and used to update
  439. the options object (if one is present).
  440.  
  441. The page size code returned in R5 is the paper 'A' size plus 1 multiplied by
  442. 256 plus 1 if landscape orientation is required (e.g. A4 portrait = &500, A4
  443. landscape = &501, A5 portrait = &600, A5 landscape = &601).
  444.  
  445.  
  446.  
  447. DF_GetPageSize  (SWI &4B0C6)
  448. ============================
  449.  
  450. Purpose: obtain window and page size for image.
  451.  
  452. On entry:   R0    = control flags
  453.             R1    = pointer to buffer containing drawfile 
  454.                     (in user area, address > &8000)
  455.             R2    = drawfile size (bytes, must be correct)
  456.             R3    = unused
  457.             R4    = unused
  458.             R5    = zoom factor multiplied by 1000 (125 - 8000)
  459.  
  460.    control flags: bit   meaning when set
  461.                   ----  ----------------
  462.                    0    determines method of error reporting
  463.                    1    use image bounding box to determine window/page size
  464.                         (only applies if no options object is present)
  465.                   2-31  reserved (should be zero)
  466.  
  467. On exit:    R0    = depends on method of error reporting
  468.             R1    = preserved
  469.             R2    = preserved
  470.             R3    = window width (os units)
  471.             R4    = window height (os units)
  472.             R5    = page size code
  473.             R6    = 1 if options object used, else zero
  474.  
  475.     If bit 0 of control flags = 0 then any error is reported
  476.     in R0 - R3 (other registers are undefined); R0 = 0 means
  477.     no error has occurred.
  478.  
  479. This call returns the page size code for the image and the corresponding
  480. window size (in os units) for the specified zoom factor. The latter could be
  481. passed to Wimp_SetExtent to set the window size prior to displaying the
  482. image.
  483.  
  484. Note that this call is only applicable to 'simple mode' rendering (see
  485. description of DF_Render). For 'transform' mode rendering, the image
  486. bounding box should be obtained with DF_GetImageSize and transformed as
  487. appropriate to determine the required window size.
  488.  
  489. See DF_SetBBoxes for an explanation of the page size code.
  490.  
  491. If an options object is present, the page size is determined from it and
  492. used to calculate the window size.
  493.  
  494. In the absence of an options object, the page/window sizes are determined
  495. according to bit 1 of the control flags passed in R0. If the bit is clear,
  496. the bounding boxes of the top level objects (i.e. not those inside group
  497. objects or tagged objects) are used to define the image size (negative
  498. values are treated as zero). The smallest paper 'A' size required to contain
  499. the image is then determined and used to calculate the window size. If the
  500. bit is set, the page/window size is determined from the image bounding box
  501. in the drawfile header. This means that (in the absence of an options
  502. object), the page size can be specified by setting the image bounding box
  503. coordinates slightly smaller than the page size.
  504.  
  505. The module allows a zoom factor of one eighth to eight times actual size;
  506. multiplying by 1000 gives an allowable range of 125 - 8000 for the zoom
  507. parameter passed in R5.
  508.  
  509.  
  510.  
  511. DF_GetImageSize  (SWI &4B0C7)
  512. =============================
  513.  
  514. Purpose: obtain image size.
  515.  
  516. On entry:   R0    = control flags
  517.             R1    = pointer to buffer containing drawfile 
  518.                     (in user area, address > &8000)
  519.             R2    = drawfile size (bytes, must be correct)
  520.  
  521.    control flags: bit   meaning when set
  522.                   ----  ----------------
  523.                    0    determines method of error reporting
  524.                    1    return values in millipoints, else in
  525.                         Draw units
  526.                   2-31  reserved (should be zero)
  527.  
  528. On exit:    R0    = depends on method of error reporting
  529.             R1    = image xmin
  530.             R2    = image ymin
  531.             R3    = image xmax
  532.             R4    = image ymax
  533.  
  534.     If bit 0 of control flags = 0 then any error is reported
  535.     in R0 - R3 (other registers are undefined); R0 = 0 means
  536.     no error has occurred.
  537.  
  538. This call examines the bounding boxes of the top-level objects (not those
  539. inside group objects or tagged objects) and returns the image size in Draw
  540. units or millipoints. Negative values may be returned.
  541.  
  542.  
  543.  
  544. DF_Render  (SWI &4B0C8)
  545. =======================
  546.  
  547. Purpose: display a drawfile.
  548.  
  549. This swi can operate in 'simple' mode (bit 1 of R0 clear) or 'transform'
  550. mode (bit 1 of R0 set):
  551.  
  552. Simple mode does not allow independent horizontal and vertical scaling or
  553. rotation of the image. It is intended for use where a single drawfile is
  554. displayed in a window rather than as part of a larger document. Because the
  555. transformation calculations are omitted this mode is slightly faster than
  556. transform mode. In this mode the window should have its work area origin
  557. (co-ordinate 0,0) at the bottom left corner.
  558.  
  559. Transform mode allows separate horizontal and vertical scaling and rotation
  560. of the image and positioning of the drawfile anywhere within a user-defined
  561. work area co-ordinate system. Thus the drawfile can be displayed as part of
  562. a larger document.
  563.  
  564. DF_Render (Simple mode)
  565. -----------------------
  566. On entry:   R0    = control flags
  567.             R1    = pointer to buffer containing drawfile 
  568.             R2    = drawfile size (bytes, must be correct)
  569.             R3    = pointer to first object to render  } only if R0
  570.             R4    = pointer to last object to render   } bit 3 is set
  571.             R5    = zoom factor multiplied by 1000
  572.                       (allowable range 125 - 8000)
  573.             R6    = pointer to Wimp redraw block
  574.  
  575. R1 and R6 must point to locations in the user area (address > &8000).
  576.  
  577.    control flags: bit   meaning when set
  578.                   ----  ----------------
  579.                    0    determines method of error reporting
  580.                    1    must be clear for 'simple' rendering 
  581.                    2    reserved (should be zero)
  582.                    3    use R3 and R4 as described below
  583.                   4-31  reserved (should be zero)
  584.  
  585. On exit:    R0    = depends on method of error reporting
  586.           R1 - R2 = preserved
  587.             R3    = updated object pointer (only if R0 bit 3 set)
  588.           R4 - R7 = preserved
  589.             R8    = number of objects rendered
  590.  
  591.     If bit 0 of control flags = 0 then any error is reported
  592.     in R0 - R3 (other registers are undefined); R0 = 0 means
  593.     no error has occurred.
  594.  
  595. Zoom factor and redraw block
  596. ----------------------------
  597. On entry, R5 contains the zoom factor multiplied by 1000 (allowable range
  598. 125 - 8000) and R6 contains a pointer to a Wimp redraw block as returned by
  599. Wimp_RedrawWindow and Wimp_GetRectangle. The coordinates of the rectangle to
  600. be redrawn (four entries starting at redraw_block+28) are compared with the
  601. object bounding boxes (after scaling) to determine which objects need to be
  602. rendered. The bounding boxes must therefore be set correctly. If the
  603. drawfile is displayed in a Wimp window, the window must have its work area
  604. origin (co-ordinate 0,0) at the bottom left corner.
  605.  
  606. The module calculates the screen position of the drawfile origin as
  607.   screen_x0 = (redraw_block+4) - (redraw_block+20)
  608.   screen_y0 = (redraw_block+16) - (redraw_block+24)
  609.  
  610. Rendering (a) specified object(s)
  611. ---------------------------------
  612. If R0 bit 3 is set, then on entry R3 and R4 are pointers to the first and
  613. last objects respectively to render (other registers should be set as
  614. described above). Use R4 = R3 to render a single object. If a group object
  615. or tagged object is encountered, all objects contained therein are rendered
  616. irrespective of R4. On exit R3 points to the next object (or the location
  617. after the end of the file). The module expects the font table (if present)
  618. to be located immediately after the drawfile header.
  619.  
  620. Objects rendered count
  621. ----------------------
  622. On exit R8 contains the number of displayable objects rendered (i.e. text,
  623. path, sprite, text area, transformed text and transformed sprite objects) as
  624. determined by comparing the object bounding box with the redraw rectangle.
  625.  
  626.  
  627. DF_Render (Transform mode)
  628. --------------------------
  629. On entry:   R0    = control flags
  630.             R1    = pointer to buffer containing drawfile 
  631.             R2    = drawfile size (bytes, must be correct)
  632.             R3    = pointer to first object to render  } only if R0 
  633.             R4    = pointer to last object to render   } bit 3 is set
  634.             R5    = pointer to transformation matrix
  635.             R6    = pointer to Wimp redraw block
  636.             R7    = flatness value for path object rendering
  637.                     (only used if R0 bit 2 is set)
  638.  
  639. R1, R5 and R6 must point to locations in the user area (address > &8000).
  640.  
  641.    control flags: bit   meaning when set
  642.                   ----  ----------------
  643.                    0    determines method of error reporting
  644.                    1    must be set for 'transform' rendering 
  645.                    2    use flatness value in R7
  646.                    3    use R3 and R4 as described below
  647.                   4-31  reserved (should be zero)
  648.  
  649. On exit:    R0    = depends on method of error reporting
  650.           R1 - R2 = preserved
  651.             R3    = updated object pointer (only if R0 bit 3 set)
  652.           R4 - R7 = preserved
  653.             R8    = number of objects rendered
  654.  
  655.     If bit 0 of control flags = 0 then any error is reported
  656.     in R0 - R3 (other registers are undefined); R0 = 0 means
  657.     no error has occurred.
  658.  
  659. Transformation matrix and redraw block
  660. --------------------------------------
  661. The transformation matrix is a 24 byte block with the format
  662.  
  663.   block +  0 = xscale *  COS(angle) * 65536
  664.   block +  4 = xscale *  SIN(angle) * 65536
  665.   block +  8 = yscale * -SIN(angle) * 65536
  666.   block + 12 = yscale *  COS(angle) * 65536
  667.   block + 16 = x_position
  668.   block + 20 = y_position
  669.  
  670. where xscale and yscale are the horizontal and vertical scale factors (which
  671. are effectively applied before rotation), angle defines rotation of the
  672. image, and x_position and y_position specify the location of the drawfile
  673. origin within the window in work area co-ordinates. The scale factors can be
  674. zero or negative; no lower or upper limit is imposed. Any co-ordinate system
  675. can be used for the window work area; e.g. to align the drawfile origin with
  676. the bottom left corner of the work area use block+16 = work_area_xmin and
  677. block+20 = work_area_ymin.
  678.  
  679. The Wimp redraw block is that returned by Wimp_RedrawWindow and
  680. Wimp_GetRectangle.
  681.  
  682. The flatness value in R7 is only used if bit 2 of the control flags
  683. parameter is set. Otherwise the module calculates a suitable flatness value
  684. from the scale factors defined in the transformation matrix.
  685.  
  686. The module calculates the screen position of the drawfile origin as
  687.   screen_x0 = x_position - (redraw_block+20) + (redraw_block+4)
  688.   screen_y0 = y_position - (redraw_block+24) + (redraw_block+16)
  689.  
  690. After scaling and rotation, the drawfile object bounding boxes are compared
  691. with the graphics clip-rectangle (four entries starting at redraw_block+28)
  692. to determine which objects need to be rendered. The bounding boxes must
  693. therefore be set correctly.
  694.  
  695. Rendering (a) specified object(s)
  696. ---------------------------------
  697. If R0 bit 3 is set, then on entry R3 and R4 are pointers to the first and
  698. last objects respectively to render (other registers should be set as
  699. described above). Use R4 = R3 to render a single object. If a group object
  700. or tagged object is encountered, all objects contained therein are rendered
  701. irrespective of R4. On exit R3 points to the next object (or the location
  702. after the end of the file). The module expects the font table (if present)
  703. to be located immediately after the drawfile header.
  704.  
  705. Objects rendered count
  706. ----------------------
  707. On exit R8 contains the number of displayable objects rendered (i.e. text,
  708. path, sprite, text area, transformed text and transformed sprite objects) as
  709. determined by comparing the object bounding box with the redraw rectangle.
  710.  
  711.  
  712.  
  713. DF_TextAreaExtent  (SWI &4B0C9)
  714. ===============================
  715.  
  716. Purpose: determine the actual area of a text area object.
  717.  
  718. A text area object consists of one or more rectangular areas over which some
  719. text will be formatted. This call returns the number of areas used and the
  720. fractional usage of the last one. This call is not actually relevant to
  721. rendering a drawfile, but is included as support for the DrawUtilsB module.
  722. It allows some degree of automation of sizing and positioning of the text
  723. column objects (the rectangular areas over which the text is formatted).
  724. After completing the text area object, DF_TextAreaExtent could be called and
  725. the text column object coordinates then adjusted manually (the bounding box
  726. entries in the text area object header should be adjusted accordingly).
  727.  
  728. On entry:   R0    = control flags
  729.             R1    = pointer to buffer containing drawfile 
  730.             R2    = drawfile size (bytes, must be correct)
  731.             R3    = pointer to text area object
  732.  
  733. R1 and R3 must point to locations in the user area (address > &8000).
  734.  
  735.    control flags: bit   meaning when set
  736.                   ----  ----------------
  737.                    0    determines method of error reporting
  738.                   1-31  reserved (should be zero)
  739.  
  740. On exit:    R0    = depends on method of error reporting
  741.           R1 - R3 = preserved
  742.             R4    = number of areas used
  743.             R5    = fractional usage of last area
  744.  
  745.     If bit 0 of control flags = 0 then any error is reported
  746.     in R0 - R3 (other registers are undefined); R0 = 0 means
  747.     no error has occurred.
  748.  
  749. The maximum number of areas that could be used is equal to the number of
  750. text column objects in the text area object. If R4 is greater than this
  751. value then the text has 'overflowed'. Otherwise, R4 contains the number of
  752. areas used and R5 gives the proportion of the last area used:
  753.  
  754.         distance from top of area to bottom of last text line
  755.   R5 =  —————————————————————————————————————————————————————  x  65536
  756.                            height of area
  757.  
  758.  
  759.  
  760. Error codes
  761. ===========
  762. With the exception of error codes less than 100, most of these errors are
  763. only returned in the message block by DF_Verify. DF_ChangeFont can also
  764. return most errors except those relating to path objects and sprite objects.
  765.  
  766. Entry parameter / general errors
  767. --------------------------------
  768.   1. Invalid message block pointer (block must be in user workspace,
  769.      address > &8000).
  770.   2. Message block is too small (minimum size is 64 bytes).
  771.   3. Invalid pointer to buffer containing drawfile (must be in user
  772.      workspace, address > &8000).
  773.   4. Invalid drawfile size (must be at least 40 bytes and a multiple of 4).
  774.   5. Invalid zoom factor (allowable range is 125 - 8000 denoting one eighth
  775.      to eight times normal size)
  776.   6. Invalid redraw block pointer (Wimp redraw block block must be in user
  777.      workspace, address > &8000).
  778.   7. Unknown SWI (module recognizes SWI numbers &4B0C0 - &4B0C9).
  779.   8. Not used.
  780.   9. Module cannot obtain workspace in RMA.
  781.  10. Not used.
  782.  11. Invalid pointer to block containing font list (block must be in user
  783.      workspace, address > &8000). May be returned by DF_ChangeFont.
  784.  12. Invalid font name in font list (too long or contains illegal
  785.      characters). May be returned by DF_ChangeFont.
  786.  13. Font list contains system font. May be returned by DF_ChangeFont.
  787.  14. Font table full (fonts 1-255 are defined, cannot insert any more). May
  788.      be returned by DF_CompileFontTable.
  789.  15. Invalid pointer to transformation matrix (for DF_Render).
  790.  16. Invalid pointer to text area object (for DF_TextAreaExtent).
  791.  
  792. Drawfile header / general errors
  793. --------------------------------
  794.  31. Not a drawfile (first word of file is incorrect).
  795.  32. Unknown drawfile version (second word is not 201).
  796.  33. Drawfile is too small (less than 40 bytes).
  797.  34. Invalid drawfile size (not a multiple of four bytes).
  798.  35. Image bounding box in drawfile header is invalid (width or height
  799.      <= 0). May be returned by DF_GetPageSize and DF_Render.
  800.  36. Invalid object size (too small or not a multiple of four bytes).
  801.      Can be returned for any object.
  802.  
  803. Font table errors
  804. -----------------
  805. 101. Two or more font tables in drawfile.
  806. 102. Font table appears after (transformed) text object.
  807. 103. Invalid font table termination (must only be null chars to word
  808.      boundary).
  809. 104. Font number in font table is zero.
  810. 105. Invalid font name (too long or contains illegal characters).
  811. 106. Font name terminator is not null character.
  812.  
  813. Text object errors
  814. ------------------
  815. 201. Text object appears before font table.
  816. 202. Font number is < 0 or > 255.
  817. 203. Unknown font.
  818. 204. Font size too low (< 1 pt).
  819. 205. Invalid object termination (must only be null chars to word boundary).
  820. 206. Text contains illegal characters (control chars or ASCII 127).
  821. 207. Illegal font flags in transformed text object.
  822. 208. Font is not defined in font table.
  823.  
  824. Path object errors
  825. ------------------
  826. 301. Non-zero reserved bits in path style description.
  827. 302. Illegal number of elements in dash pattern definition.
  828. 303. Path object has no components.
  829. 304. Early path end.
  830. 305. Path does not start with a move.
  831. 306. Early path closure.
  832. 307. Unknown path component.
  833.  
  834. Sprite object errors
  835. --------------------
  836. 401. Invalid object bounding box (width or height <= 0).
  837. 402. Sprite size inconsistent with object size.
  838. 403. Invalid sprite dimensions (width or height <= 0).
  839. 404. Invalid sprite offset (< &2C).
  840. 405. Sprite defined in unknown mode.
  841. 406. Invalid sprite palette size.
  842. 407. Invalid mask offset (< &2C).
  843. 408. Image size inconsistent with sprite dimensions.
  844. 409. Mask size inconsistent with sprite dimensions.
  845. 410. Unknown sprite type (from top byte of mode entry).
  846.  
  847. Text area object errors
  848. -----------------------
  849. 501. Text column object: invalid size (must be 24 bytes).
  850. 502. Text column object: inverted bounding box (width or height < 0).
  851. 503. Invalid termination for text column objects.
  852. 504. Total area defined by text column objects invalid (width or 
  853.      height <= 0).
  854. 505. Non-zero reserved words in object header.
  855. 506. No text column objects.
  856. 507. Multiple initializer ('\!') sequences.
  857. 508. Invalid initializer (not '\! 1').
  858. 509. Invalid termination for escape sequence (most require '/' or newline).
  859.      Newline = ASCII 10.
  860. 510. Absent initializer.
  861. 511. Late '\D' sequence (must appear before text).
  862. 512. Multiple '\D' sequences.
  863. 513. Invalid '\D' sequence (value < 1 or syntax error).
  864. 514. Number of text column objects inconsistent with '\D' sequence.
  865. 515. '\F' sequence: illegal font number (< 0 or > 99) or syntax error.
  866. 516. '\F' sequence: unknown font.
  867. 517. '\F' sequence: invalid font size (< 1 pt) or syntax error.
  868. 518. '\A' sequence: invalid alignment code (not L, R, D or C).
  869. 519. '\M' sequence: illegal value or syntax error.
  870. 520. '\C' or '\B' sequence: illegal value or syntax error.
  871. 521. '\L' sequence: illegal value or syntax error.
  872. 522. '\P' sequence: illegal value or syntax error.
  873. 523. '\U' sequence: illegal value or syntax error.
  874. 524. '\V' sequence: illegal value or syntax error.
  875. 525. Font selection ('\n') sequence : illegal value or syntax error.
  876. 526. No font selected at start of text.
  877. 527. Illegal character in text (control char or ASCII 127).
  878. 528. Invalid text area termination (must be newline + null character(s) to
  879.      word boundary). Newline = ASCII 10.
  880. 529. Font selection ('\n') sequence selects an undefined font.
  881.  
  882. Options object errors
  883. ---------------------
  884. 601. Bounding box entries are non-zero.
  885. 602. Unrecognized page size.
  886. 603. Reserved bits are non-zero.
  887. 604. Invalid grid spacing (<= 0).
  888. 605. Invalid grid division (<= 0).
  889. 606. Zoom multiplier or divisor out of range (< 1 or > 8).
  890.  
  891.  
  892.  
  893.  
  894. Comments concerning this software to:
  895.     James McQueen
  896.     9/2 15 Croftbank Street
  897.     Springburn
  898.     Glasgow
  899.     G21 4LP
  900.