home *** CD-ROM | disk | FTP | other *** search
/ RISC DISC 2 / RISC_DISC_2.iso / pd_share / program / gamesuite / !Amnesia / AmsHelp / SWIDocs < prev    next >
Encoding:
Text File  |  1995-01-29  |  24.9 KB  |  1,023 lines

  1.  
  2. SWI Documentation for the Amnesia module version 1.10
  3. =====================================================
  4.  
  5. Amnesia is a module which provides support for memory allocation and an
  6. 'object handler' primarily for use in video games.  The Amnesia module has
  7. many facilities and you are unlikely to need all of them.  This document
  8. contains full information regarding the SWIs so may look a bit daunting. 
  9. Don’t worry - it’s not half as complicated as it looks!
  10.  
  11. =======================================
  12.  
  13. Amnesia_Init
  14. ------------
  15.  
  16. Initialises the Amnesia module
  17.  
  18. On Entry
  19.  
  20. R0 = Area start
  21. R1 = Area length
  22. R2 = Area type
  23.  
  24. On Exit
  25.  
  26. R0 preserved
  27. R1 preserved
  28. R2 preserved
  29.  
  30. Interrupt status not altered.  Executes in SVC mode.
  31. SWI is not re-entrant. 
  32.  
  33. Use
  34.  
  35. This SWI must be issued before using any other Amnesia facilities.  R0 should
  36. be word aligned (multiple of 4).  The register meanings are as follows:
  37.  
  38. R0 = 0 : Claim from RMA.
  39.  
  40. R2 = 0 : Tidy mode - compact heap on each release of memory
  41. R2 = 1 : Messy mode - compact heap when out of space
  42. R2 = 2 : Static mode - compact heap only when instructed to do so
  43.  
  44. In tidy mode the module will shift the heap and gather all of the free space
  45. together when blocks or tables are deallocated, so the heap is always tidy
  46. and not fragmented.  In messy mode the heap will be shifted if there is not
  47. enough space for a requested allocation.  Therefore the heap is usually in a
  48. mess and fragmented.  This mode tends to give you occasional big tidy-ups
  49. instead of regular small ones.  In static mode the heap is not shifted until
  50. you specifically request it.  This is so that BASIC programs have a chance to
  51. re-read all of the pointers that they use.
  52.  
  53. To release the Amnesia block, call this SWI with R1=0.
  54.  
  55. The module can only support one heap at a time, although this heap can be
  56. split up into blocks as you please.
  57.  
  58. The SWI may return errors as the memory block is checked for validity.  All
  59. of the following SWIs will return errors if called before a successful
  60. Amnesia_Init.
  61.  
  62. =======================================
  63.  
  64. Amnesia_ClaimBlock
  65. ------------------
  66.  
  67. Claim a block of memory from the Amnesia heap.
  68.  
  69. On Entry
  70.  
  71. R0 = Address of pointer which will be used to reference the block.
  72. R1 = Length required in bytes
  73. R2 = Zero, or pointer to name string
  74. R3 = Flags
  75.  
  76. On Exit
  77.  
  78. Pointer at R0 set to point to block, or [R0] = zero if allocation failed.
  79. R1 = length allocated
  80.  
  81. Interrupts disabled in critical stages otherwise unaltered.
  82. Executes in SVC mode.  SWI must not be called from an interrupt routine.
  83.  
  84. Use
  85.  
  86. This SWI attempts to claim a block of memory within the Amnesia heap if
  87. available.  It may shift the heap in messy mode.  R1 is rounded up to be a
  88. multiple of 4.  If the call is successful the block is then yours to do what
  89. you like with.  Always use the pointer at [R0] to access the block, as it may
  90. change when the heap is tidied.  You may supply R0 = 0, but Amnesia will no
  91. longer be able to tidy the heap below the block.
  92.  
  93. The name pointed to by R2 may be up to 8 characters long and is for your use
  94. only.  Amnesia will take a copy.
  95.  
  96. The flags in R3 are as follows:
  97.  
  98. Bit 0 : If this bit is set, the block is static - it will not be moved by
  99. heap tidying.  Avoid static blocks if possible as they may cause Amnesia to
  100. waste memory.  Ideally all of your static blocks should be claimed before
  101. your moveable ones.
  102.  
  103. Bit 1 : If set, the block claimed will be quad-word aligned +4 like blocks
  104. returned by OS_Module.  The address will end in 4 (so look like &xxxxxxx4).
  105.  
  106. Bit 2 : If this bit is set, the block is assumed to be accessed by an
  107. interrupt routine (because it’s a sound sample, for example).  If so,
  108. interrupts are disabled when the block is moved during a heap tidy to prevent
  109. problems. 
  110.  
  111. Errors will be returned if there is no room.
  112.  
  113. =======================================
  114.  
  115. Amnesia_ReleaseBlock
  116. --------------------
  117.  
  118. Release a previously claimed block of memory.
  119.  
  120. On Entry
  121.  
  122. R0 = Address of pointer (as above) or zero
  123.  
  124. On Exit
  125.  
  126.  
  127. The call zeroes pointer at [R0] if release is valid ie [R0] is a pointer to
  128. an Amnesia block.
  129.  
  130. Interrupt status unchanged.
  131. Executes in SVC mode.  SWI must not be called from an interrupt routine. 
  132.  
  133. Use
  134.  
  135. This SWI will release a block which has been previously claimed with
  136. Amnesia_ClaimBlock.  If R0=0 then the whole Amnesia area is released.  In
  137. tidy mode the heap will be shifted to release the free space for future
  138. allocations.  The error Not a valid block may be returned.
  139.  
  140. =======================================
  141.  
  142. Amnesia_ExtendBlock
  143. -------------------
  144.  
  145. Extends a block which has already been claimed
  146.  
  147. On Entry
  148.  
  149. R0 = Address of current pointer to block
  150. R1 = New length required in bytes
  151.  
  152. On Exit
  153.  
  154. Pointer at [R0] may be changed if block is moved
  155. R1 = new length allocated
  156.  
  157. Interrupt status unchanged.
  158. Executes in SVC mode.  SWI must not be called from an interrupt routine. 
  159.  
  160. Use
  161.  
  162. This SWI tries to extend or shrink a previously claimed block.  The heap may
  163. be shifted in tidy or messy modes.  May return the errors No room or Not an
  164. allocated block.  Its usual method is to claim another block, copy, and then
  165. release the block to be extended.
  166.  
  167. =======================================
  168.  
  169. Amnesia_DescribeBlock
  170. ---------------------
  171.  
  172. Returns information about a block.
  173. On Entry
  174.  
  175. R0 = pointer to block or block number
  176.  
  177. On Exit
  178.  
  179. R0 = block address
  180. R1 = block size
  181. R2 = start of data area
  182. R3 = size of data area
  183. R4 = pointer to name
  184. R5 = pointer to block pointer (as passed in R0 to ClaimBlock)
  185. R6 = block flags
  186.  
  187. Interrupt status unchanged.
  188. Executes in SVC mode.  SWI is re-entrant. 
  189.  
  190. Use
  191.  
  192. This SWI returns information on a specified block.
  193.  
  194. =======================================
  195.  
  196. Amnesia_ClaimTable
  197. ------------------
  198.  
  199. Claims space for a table of objects and creates a header for that table
  200.  
  201. On Entry
  202.  
  203. R0 = Your handle for the table (0-31)
  204. R1 = Flags
  205. R2 = Zero or pointer to name
  206. R3 = Number of objects
  207. R4 = Size of a single object (bytes)
  208.  
  209. On Exit
  210.  
  211. R0-R3 Preserved
  212.  
  213. Interrupts disabled in critical stages otherwise unaltered.
  214. Executes in SVC mode.  SWI must not be called from an interrupt routine. 
  215.  
  216. Use
  217.  
  218. This SWI sets up a table for subsequent use.  A table is a list of objects
  219. which usually represent sprites on the screen (aliens, missiles etc) but can
  220. be used for other purposes.  All objects in the new table are marked as
  221. inactive.  Returns an error if the allocation fails.
  222.  
  223. R1 contains information as follows:
  224.  
  225. bit | meaning if set 
  226.  
  227. 0   - objects require collision checking facilities.
  228.  
  229. The processing of tables is detailed with the SWI Amnesia_ProcessTable.  If
  230. the collision checking bit is set a collison checking table of a default
  231. length will be claimed.
  232.  
  233. The possible errors are No room, not initialised, bad table type, bad handle.
  234.  
  235. =======================================
  236.  
  237. Amnesia_ReleaseTable
  238. --------------------
  239.  
  240. Releases a previously claimed table
  241.  
  242. On Entry
  243.  
  244. R0 = Your handle for the table (0-31)
  245.  
  246. On Exit
  247.  
  248. R0 preserved
  249.  
  250. Interrupts disabled in critical stages otherwise unaltered.
  251. Executes in SVC mode.  SWI must not be called from an interrupt routine. 
  252.  
  253. Use
  254.  
  255. Releases the space used by a table and its collision checking area if
  256. present.  May return errors if the table is corrupted.
  257.  
  258. =======================================
  259.  
  260. Amnesia_ExtendTable
  261. -------------------
  262.  
  263. *** This SWI is not implemented ***
  264. *** Please contact the author if you _really_ need it! ***
  265.  
  266. On Entry
  267.  
  268. R0 = Your handle for the table (0-31)
  269.  
  270. R2 = New number of objects
  271.  
  272. On Exit
  273.  
  274. R0, R2 Preserved
  275.  
  276. Interrupts disabled in critical stages otherwise unaltered.
  277. Executes in SVC mode.  SWI must not be called from an interrupt routine. 
  278.  
  279. Use
  280.  
  281. This SWI extends or shrinks a current table if possible.  Shrinking it may
  282. delete objects.  All new objects in the table are marked as inactive.  Errors
  283. are generated if the extend fails.
  284.  
  285. =======================================
  286.  
  287. Amnesia_WipeTable
  288. -------------------
  289.  
  290. On Entry
  291.  
  292. R0 = Your handle for the table (0-31)
  293.  
  294. On Exit
  295.  
  296. R0 corrupted, others preserved.
  297.  
  298. Interrupts disabled in critical stages otherwise unaltered.
  299. Executes in SVC mode.  SWI must not be called from an interrupt routine. 
  300.  
  301. Use
  302.  
  303. This SWI marks all objects in the specified table as inactive.
  304.  
  305. =======================================
  306.  
  307. Amnesia_Tidy
  308. ------------
  309.  
  310. Tidies the heap and makes all of the free space available.
  311.  
  312. On Entry
  313.  
  314. No parameters
  315.  
  316. On exit
  317.  
  318. No results
  319.  
  320. Interrupts disabled in critical stages otherwise unaltered.
  321. Executes in SVC mode.  SWI must not be called from an interrupt routine. 
  322.  
  323. Use
  324.  
  325. This SWI will tidy the Amnesia heap and collect all of the free space
  326. together.  In messy or tidy modes this will be performed automatically and
  327. this SWI need not be used.  In static mode you can call this SWI in response
  328. to the error No room in amnesia heap, and then update your pointers before
  329. resuming.  This SWI may return errors such as overwritten/nonsensical blocks
  330. in area.
  331.  
  332. =======================================
  333.  
  334. Amnesia_MakeObject
  335. ------------------
  336.  
  337. Creates an object in a table.
  338.  
  339. On Entry
  340.  
  341. R0 = Table handle
  342. R1 = Object type/sprite (non-zero)
  343. R2 = Object flags
  344. R3 = x coord
  345. R4 = y coord
  346. R5 = x velocity
  347. R6 = y velocity
  348. R7 = Timer value
  349. R8 = Object size
  350.  
  351. On Exit
  352.  
  353. R1 = address of object allocated, for you to fill in the rest if you need to.
  354. R1 = Zero, and carry set if no object could be created.
  355.  
  356. Interrupts disabled in critical stages otherwise unaltered.
  357. Executes in SVC mode.  SWI is not re-entrant. 
  358.  
  359. Use
  360.  
  361. This SWI creates an object (an entry in the table) with the given parameters
  362. if there is room.  No error will be returned if the object cannot be created
  363. because there is no room in the table, but R1 will be zero on exit.  The SWI
  364. tries to create an object as quickly as possible, but will scan the whole
  365. table for a free space if necessary.  When a space is found the module stores
  366. all passed registers using the form STMIA R10,{R1-R8} where R10 = the address
  367. of the new object, returned to you in R1.
  368.  
  369. The coordinates in R3,R4 are FastSpr style, shifted left twelve places.  The
  370. top left of the screen in (0,0) and the bottom right in, say, mode 13, is
  371. (320<<12, 256<<12).  The values in R5,R6 are added directly to these.
  372.  
  373. The flags in R2 have the following meaning:
  374.  
  375. bit | meaning if set
  376.  
  377. 0   - object needs plotting by the module
  378. 1   - object needs plotting by the user
  379. 2   - object has a velocity (R5,R6)
  380. 3   - object responds to gravity
  381. 4   - object should use the plot offsets for plotting
  382. 5   - object has a FastSpr animation
  383. 6   - make up the object size (R8 invalid)
  384. 7   - object has no timer (R7 invalid - use 0)
  385. 8   - object needs attention when timer expires
  386. 9   - object should be destroyed when timer expires
  387. 10  - reserved
  388. 11  - object should be collison-checked
  389. 12  - reserved
  390. 13  - velocity entries should be used and then zeroed (used by solid objects)
  391. 14  - object uses the game window
  392. 15  - object uses the plot window
  393. 16  - object uses the kill window
  394. 17  - object should be saved by Amnesia_SaveTable
  395. 24  - call for attention if trigger 1 set
  396. 25  - call for attention if trigger 2 set
  397. 26  - call for attention if trigger 3 set
  398. 27  - call for attention if trigger 4 set
  399. 28  - call for attention if trigger 5 set
  400. 29  - call for attention if trigger 6 set
  401. 30  - call for attention if trigger 7 set
  402. 31  - call for attention if trigger 8 set
  403.  
  404. If both the 'need attention when time expires' and 'destroy when timer
  405. expires' bits are set, you will get an attention request before the object is
  406. deleted.  If you reset the timer the deletion will not happen.
  407.               
  408. The timer in R7 has the following structure:
  409.  
  410. <byte 3><byte 2> | <byte 1 <byte 0>
  411.   timer value       timer decrement
  412.  
  413. Upon each process pass (each time Amnesia_Process is used on the object) the
  414. action SUB R7,R7,R7,LSL #16 is performed.  When this causes the timer to
  415. cross zero the timer is said to have expired and the action specified by the
  416. flags in R1 is taken.
  417.  
  418. The size should be specified in PIXELS in R8, in the following format:
  419.  
  420. <byte 3><byte 2> | <byte 1><byte 0>
  421.      x size             y size
  422.  
  423. If the 'make up the object size' bit is set the module attempts to read the
  424. object size from the FastSpr file.  If that fails the size is set to zero. 
  425. Object size is used for collison checking only.  Note that R8 cannot be
  426. passed from the BASIC SYS command and should be filled in using the returned
  427. address in R1 if necessary.
  428.  
  429. If the FastSpr animation bit is set, the word after the object timer is used
  430. to control the FastSpr animation.  Bits 31-24 are passed as the animation
  431. frame.
  432.  
  433. This SWI may return the error Table does not exist.
  434.  
  435. =======================================
  436.  
  437. Amnesia_MakeObjectSpace
  438. -----------------------
  439.  
  440. Finds a space for you to make an object yourself
  441.  
  442. On Entry
  443.  
  444. R0 = Table handle
  445.  
  446. On Exit
  447.  
  448. R0 preserved
  449. R1 = Address of available object, or zero if unable to allocate.
  450.  
  451. Interrupts disabled in critical stages otherwise unaltered.
  452. Executes in SVC mode.  SWI is not re-entrant. 
  453.  
  454. Use
  455.  
  456. This SWI finds a free object space in the given table if possible.  You must
  457. then fill in all of the parameters yourself if you wish to create an object. 
  458. The object data is undefined on return so must be overwritten.  May return a
  459. table does not exist error.
  460.  
  461. =======================================
  462.  
  463. Amnesia_SelectTable
  464. -------------------
  465.  
  466. Selects a table for subsequent processing.
  467.  
  468. On Entry
  469.  
  470. R0 = Table handle [+ user attn bits]
  471. R1 = Process type (0 -> normal, 1 -> scan (CMP), 2 -> scan (TST))
  472.  
  473. If R1=0
  474.   R2 = Plot action (0 -> plot, 1 -> don't)
  475.  
  476. If R1=1 or 2
  477.   R2 = offset in object
  478.   R3 = CMP or TST value
  479.   R4 = BIC value
  480.  
  481. On Exit
  482.  
  483. R0-R2 altered, ready to pass to Amnesia_ProcessTable
  484. R0 = table number + internal flags + user attn flags
  485. R1 = pointer to first object
  486. R2 = internal flags
  487. R3,R4 preserved
  488.  
  489.  
  490. Interrupt status unaltered.
  491. Executes in SVC mode.  SWI is re-entrant. 
  492.  
  493. Use
  494.  
  495. This SWI selects the table to be processed next.  Subsequent calls to
  496. Amnesia_ProcessTable will update objects, plot them if necessary, and may ask
  497. the user to process objects.  If a normal process is selected this SWI will
  498. also wipe the collision checking table if present.  If you wish to return
  499. objects with user attention bits (bits 24-31) in their flags, set the
  500. relevant bit or bits in R0.
  501.  
  502. If R1 = 0 the table is processed fully.
  503.  
  504. If R1 = 1 the table is scanned using a CMP instruction.  The value at offset
  505. R2 in each object is BICed with R4 and compared with the value of R3, and the
  506. object returned if identical.
  507.  
  508. If R1 = 2 the table is scanned using a TST instruction.  The value at offset
  509. R2 in each object is BICed with R4 and TSTed with the value of R3, and the
  510. object returned if any bit set in R3 is also set in the value at the selected
  511. offset.  If R3 = 0 all objects are returned.
  512.  
  513.  
  514. =======================================
  515.  
  516. Amnesia_ProcessTable
  517. --------------------
  518.  
  519. Processes one or more objects from a table.
  520.  
  521. On Entry
  522.  
  523. At the start of a process these registers should be those generated by
  524. Amnesia_SelectTable.
  525.  
  526. R0 = Table Handle plus flag bits
  527. R1 = Value from Amnesia_SelectTable or the previous Amnesia_ProcessTable
  528. R2 = Reason code/flags
  529. R3 = Scan value, if a scan is selected
  530.  
  531. On Exit
  532.  
  533. R0 = Table handle plus flag bits
  534. R1 = Updated pointer to current object which needs attention, or zero if end of table
  535. R2 = Reason code/flags
  536. R3 = Preserved
  537.  
  538.  
  539. Interrupt status unaltered.
  540. Executes in SVC mode.  SWI is re-entrant (!).
  541.  
  542. Use
  543.  
  544. Amnesia_ProcessTable should be called repeatedly after a single
  545. Amnesia_SelectTable to process the table.  The SWI will process the object as
  546. necessary, and it will return control to you if the object needs attention.
  547.  
  548. If R2 = 0 the end of the table has been reached and processing has finished. 
  549. You should not call this SWI again before selecting another table.
  550.  
  551. The module keeps no internal records of which table you are processing, so
  552. you may process objects/tables in any order.  The three or four parameters
  553. passed to Amnesia_ProcessTable fully define what is going on.
  554.  
  555. This SWI may return errors.  R0 will point to an error block as usual.
  556.  
  557. =======================================
  558.  
  559. Amnesia_DeleteObject
  560. --------------------
  561.  
  562. Deletes an object in a table
  563.  
  564. On Entry
  565.  
  566. R1 = Object address
  567.  
  568. On Exit
  569.  
  570. All registers preserved
  571.  
  572. Interrupt status unaltered.
  573. Executes in SVC mode.  SWI is re-entrant.
  574.  
  575. Use
  576.  
  577. Simply STRs zero at address R1.  Use to make your code look tidier if you
  578. like.
  579.  
  580. =======================================
  581.  
  582. Amnesia_CountObjects
  583. --------------------
  584.  
  585. Counts the number of objects in a table
  586.  
  587. On Entry
  588.  
  589. R0 = table number
  590.  
  591. On Exit
  592.  
  593. R0 = number of objects
  594.  
  595. Interrupt status unaltered.
  596. Executes in SVC mode.  SWI is re-entrant.
  597.  
  598. Use
  599.  
  600. Returns the number of active objects in the specified table.
  601.  
  602. =======================================
  603.  
  604. Amnesia_SetWindow
  605. -----------------
  606.  
  607. Sets an Amnesia window.
  608.  
  609. On Entry
  610.  
  611. R0 = window to set
  612. R1 = minimum x coordinate
  613. R2 = minimum y coordinate
  614. R3 = maximum x coordinate
  615. R4 = maximum y coordinate
  616.  
  617. On Exit
  618.  
  619. R0-R4 preserved
  620.  
  621. Interrupt status unaltered.
  622. Executes in SVC mode.  SWI is re-entrant.
  623.  
  624. Use
  625.  
  626. This SWI sets one of the windows held by Amnesia.  The window set is governed
  627. by R0.
  628.  
  629.  
  630. R0 = 0 : Set the game window.  This window is provided purely for the user,
  631. and will return for attention if an object is outside of this window.  It
  632. could be used, for example, to bounce a ball on the edge of the screen.  The
  633. plot offset is not added before this comparison.
  634.  
  635. R0 = 1 : Set the plot window.  If any part of an object is within this window
  636. the module will attempt to plot it.  The plot offset is added before the
  637. comparison.
  638.  
  639. R0 = 2 : Sets the kill window.  If a object wanders completely outside of
  640. this window it will be deleted if the relevant flag is set.  The plot offset
  641. is not added before comparison.
  642.  
  643. =======================================
  644.  
  645. Amnesia_ReadWindow
  646. ---------------------
  647.  
  648. Sets the game window.
  649.  
  650. On Entry
  651.  
  652. R0 = window to read
  653.  
  654. On Exit
  655.  
  656. R0 altered
  657. R1 = minimum x coordinate
  658. R2 = minimum y coordinate
  659. R3 = maximum x coordinate
  660. R4 = maximum y coordinate
  661.  
  662. Interrupt status unaltered.
  663. Executes in SVC mode.  SWI is re-entrant.
  664.  
  665. Use
  666.  
  667. Reads the settings of a window.
  668.  
  669. =======================================
  670.  
  671. Amnesia_SetPlotOffset
  672. ---------------------
  673.  
  674. Sets the plot offset.
  675.  
  676. On Entry
  677.  
  678. R0 = x offset
  679. R1 = y offset
  680.  
  681. On Exit
  682.  
  683. R0, R1 = Previous values
  684.  
  685. Interrupt status unaltered.
  686. Executes in SVC mode.  SWI is re-entrant.
  687.  
  688. Use
  689.  
  690. The plot offset is added to an object’s coordinates before passing them to
  691. FastSpr, if the relevant bit is set.  The coordinates are in pixels<<12.
  692.  
  693. =======================================
  694.  
  695. Amnesia_ReadPlotOffset
  696. ----------------------
  697.  
  698. Reads the plot offset.
  699.  
  700. On Entry
  701.  
  702. No parameters
  703.  
  704. On exit
  705.  
  706. R0 = x offset
  707. R1 = y offset
  708.  
  709. Interrupt status unaltered.
  710. Executes in SVC mode.  SWI is re-entrant.
  711.  
  712. Use
  713.  
  714. Returns the plot offset, for use by your own plotting code, for example.
  715.  
  716. =======================================
  717.  
  718. Amnesia_SetGravity
  719. ------------------
  720.  
  721. Sets the plot offset.
  722.  
  723. On Entry
  724.  
  725. R0 = x gravity
  726. R1 = y gravity
  727.  
  728. On Exit
  729.  
  730. R1 preserved
  731.  
  732. Interrupt status unaltered.
  733. Executes in SVC mode.  SWI is re-entrant.
  734.  
  735. Use
  736.  
  737. Gravity is added to an objects velocity on each process pass if bit 3 is set
  738. in the flags.  Any value, positive or negative, is permitted for R0 and R1.
  739.  
  740. =======================================
  741.  
  742. Amnesia_ReadGravity
  743. -------------------
  744.  
  745. Reads the gravity setting
  746.  
  747. On Entry
  748.  
  749. No parameters
  750.  
  751. On exit
  752.  
  753. R0 = x gravity
  754. R1 = y gravity
  755.  
  756. Interrupt status unaltered.
  757. Executes in SVC mode.  SWI is re-entrant.
  758.  
  759. Use
  760.  
  761. Returns the gravity setting.
  762.  
  763. =======================================
  764.  
  765.  
  766. Amnesia_CollisionCheck
  767. ----------------------
  768.  
  769. Performs collision checking between two tables
  770.  
  771. On Entry
  772.  
  773. R0 = First table number (0-31)
  774. R1 = Second table number (0-31)
  775.  
  776. On Exit
  777.  
  778. R0 = Address of colliding object in the first table, or 0 if no collision.
  779. R1 = Address of colliding object in second table.
  780. R2 = offset of object in first table.  Don't bother with these.
  781. R3 = offset of object in second table
  782.  
  783. Interrupt status unaltered.
  784. Executes in SVC mode.  SWI is re-entrant.
  785.  
  786. Use
  787.  
  788. This SWI performs a fast collision check between two tables, or between a
  789. table and itself.  The addresses of the objects are returned.  Collision
  790. checking can then be continued by calling the SWI again, until R2 returns
  791. zero.  An example coding is:
  792.  
  793.  
  794. .collisioncheck
  795. STMFD R13!,{R14}
  796. MOV R0,#1
  797. MOV R1,#2
  798. .loop
  799. SWI "Amnesia_CollisionCheck"
  800. CMP R2,#0
  801. BEQ done
  802. STMFD R13!,{R0-R1}
  803. MOV R0,#0
  804. STR R0,[R0]; delete both colliding objects
  805. STR R0,[R1];
  806. LDMFD R13!,{R0-R1}
  807. B loop
  808. .done
  809. LDMFD R13!,{PC}
  810.  
  811. For collision checking to work, the following must be true:
  812.  
  813. • Both tables must have been claimed with collision checking enabled
  814. • The objects in question must have the collision checking bit set in their
  815. flags
  816.  
  817. Collision checking between a table and itself is a special case.  Amnesia
  818. deals with the anomalies for you, to ensure that are not told about an object
  819. colliding with itself.  Half the number of checks are required.
  820.  
  821. The algorithm used is moderately fast.  Tables of bounding boxes are built up
  822. as objects are processed.  Subsequently each check between two objects takes
  823. six instructions to complete.  If two tables of 50 objects are checked
  824. against each other this takes 2500 checks (50×50) so that’s 15000
  825. instructions.  Obviously the amount collision checking should be minimised to
  826. reduce the processor time required.  With this in mind, if any object does
  827. not need a collision check, then do not set the collision check bit in the
  828. objects flags.
  829.  
  830. This SWI will return errors if the tables do not exist, or were not claimed
  831. with collision checking specified.
  832.  
  833. =======================================
  834.  
  835. Amnesia_LoadFile
  836. ----------------
  837.  
  838. Creates an Amnesia block and loads a file into it
  839.  
  840. On Entry
  841.  
  842. R0 = address of block pointer
  843. R1 = filename
  844. R2 = pathname
  845.  
  846. On Exit
  847.  
  848. [R0] = address of allocated block
  849. R1-R2 unchanged, R0 corrupted
  850.  
  851. Interrupt status unaltered.
  852. Executes in SVC mode.  SWI should not be called from an interrupt routine.
  853.  
  854. Use
  855.  
  856. This SWI loads a file into the Amnesia area, creating a block to do so.  R0
  857. is the address of the pointer which you wish to use for the block.  The block
  858. will be quad word aligned plus 4 bytes, like an OS_Module block.  The string
  859. pointed to by R1 is added after that pointed to by R2 to produce the complete
  860. filename.
  861.  
  862. ==================================
  863.  
  864. Amnesia_LoadHammered
  865. --------------------
  866.  
  867. Creates an Amnesia block and loads a file into it
  868.  
  869. On Entry
  870.  
  871. R0 = address of block pointer
  872. R1 = filename
  873. R2 = pathname
  874.  
  875. On Exit
  876.  
  877. [R0] = address of allocated block
  878. R1-R2 unchanged, R0 corrupted
  879.  
  880. Interrupt status unaltered.
  881. Executes in SVC mode.  SWI should not be called from an interrupt routine.
  882.  
  883. Use
  884.  
  885. Identical to Amnesia_LoadFile but decompresses the file if it is a Hammered
  886. file.
  887.  
  888. ==================================
  889.  
  890. Amnesia_SaveFile
  891. ----------------
  892.  
  893. Saves an Amnesia block
  894.  
  895. On Entry
  896.  
  897. R0 = address of block
  898. R1 = filename
  899. R2 = filetype
  900.  
  901. On Exit
  902.  
  903. R1-R2 unchanged, R0 corrupted
  904.  
  905. Interrupt status unaltered.
  906. Executes in SVC mode.  SWI should not be called from an interrupt routine.
  907.  
  908. Use
  909.  
  910. This SWI saves an Amnesia block as a file.
  911.  
  912. =======================================
  913.  
  914. Amnesia_LoadTable
  915. -----------------
  916.  
  917. Saves the objects in an Amnesia table
  918.  
  919. On Entry
  920.  
  921. R0 = table number
  922. R1 = filename
  923. R2 = pathname
  924.  
  925. On Exit
  926.  
  927. R1-R2 unchanged, R0 corrupted
  928.  
  929. Interrupt status unaltered.
  930. Executes in SVC mode.  SWI should not be called from an interrupt routine.
  931.  
  932. Use
  933.  
  934. This SWI loads objects from a file into an Amnesia table.  The object length
  935. and table name should match.  Objects already in the table are preserved.
  936.  
  937. =======================================
  938.  
  939. Amnesia_SaveTable
  940. -----------------
  941.  
  942. Saves the objects in an Amnesia table
  943.  
  944. On Entry
  945.  
  946. R0 = table number
  947. R1 = filename
  948.  
  949. On Exit
  950.  
  951. R1-R2 unchanged, R0 corrupted
  952.  
  953. Interrupt status unaltered.
  954. Executes in SVC mode.  SWI should not be called from an interrupt routine.
  955.  
  956. Use
  957.  
  958. This SWI saves the objects in an Amnesia table which have bit 17 set in their
  959. flags.
  960.  
  961. =======================================
  962.  
  963. Amnesia_GetTableAddr
  964. --------------------
  965.  
  966. Gets the address of a table.
  967.  
  968. On Entry
  969.  
  970. R0 = table number
  971.  
  972. On exit
  973.  
  974. R0 = table address
  975.  
  976. Interrupt status unaltered.
  977. Executes in SVC mode.  SWI is re entrant.
  978.  
  979. Use
  980.  
  981. This SWI returns the address of a table should you wish to manipulate it
  982. yourself.  A brief idea of the table structure can be gleaned fron the
  983. Headers document in the Technical directory.
  984.  
  985. =======================================
  986.  
  987. Amnesia_Blocks
  988. --------------
  989.  
  990. Prints a diagnostic report.
  991.  
  992. On Entry
  993.  
  994. No parameters
  995.  
  996. On exit
  997.  
  998. No results.
  999.  
  1000. Interrupt status unaltered.
  1001. Executes in SVC mode.  SWI should not be called from an interrupt routine.
  1002.  
  1003. Use
  1004.  
  1005. Prints a diagnostic report listing the current block allocations, showing if
  1006. the area is sound or not.  If an Amnesia has just returned an error the
  1007. report will tell you in which block the error occured.
  1008.  
  1009. This SWI is intended for use from the command line during software
  1010. development.  It can be invoked by the command *Amnesia Blocks (or *Amn.B.). 
  1011. Amnesia keeps a guard word at the start of each block, so this command will
  1012. you if you have written to memory past the end of a block and corrupted the
  1013. header of the next.
  1014.  
  1015. =======================================
  1016.  
  1017. ****************************************************
  1018.     This document is copyright A.Southgate 1995.
  1019.     It may be freely distibuted and copied but
  1020.     should not be modified, otherwise things will
  1021.     get very confusing.
  1022. ****************************************************
  1023.