home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
games
/
gamesuite
/
!Amnesia
/
AmsHelp
/
SWIDocs
< prev
next >
Wrap
Text File
|
1995-01-29
|
26KB
|
1,023 lines
SWI Documentation for the Amnesia module version 1.10
=====================================================
Amnesia is a module which provides support for memory allocation and an
'object handler' primarily for use in video games. The Amnesia module has
many facilities and you are unlikely to need all of them. This document
contains full information regarding the SWIs so may look a bit daunting.
Don’t worry - it’s not half as complicated as it looks!
=======================================
Amnesia_Init
------------
Initialises the Amnesia module
On Entry
R0 = Area start
R1 = Area length
R2 = Area type
On Exit
R0 preserved
R1 preserved
R2 preserved
Interrupt status not altered. Executes in SVC mode.
SWI is not re-entrant.
Use
This SWI must be issued before using any other Amnesia facilities. R0 should
be word aligned (multiple of 4). The register meanings are as follows:
R0 = 0 : Claim from RMA.
R2 = 0 : Tidy mode - compact heap on each release of memory
R2 = 1 : Messy mode - compact heap when out of space
R2 = 2 : Static mode - compact heap only when instructed to do so
In tidy mode the module will shift the heap and gather all of the free space
together when blocks or tables are deallocated, so the heap is always tidy
and not fragmented. In messy mode the heap will be shifted if there is not
enough space for a requested allocation. Therefore the heap is usually in a
mess and fragmented. This mode tends to give you occasional big tidy-ups
instead of regular small ones. In static mode the heap is not shifted until
you specifically request it. This is so that BASIC programs have a chance to
re-read all of the pointers that they use.
To release the Amnesia block, call this SWI with R1=0.
The module can only support one heap at a time, although this heap can be
split up into blocks as you please.
The SWI may return errors as the memory block is checked for validity. All
of the following SWIs will return errors if called before a successful
Amnesia_Init.
=======================================
Amnesia_ClaimBlock
------------------
Claim a block of memory from the Amnesia heap.
On Entry
R0 = Address of pointer which will be used to reference the block.
R1 = Length required in bytes
R2 = Zero, or pointer to name string
R3 = Flags
On Exit
Pointer at R0 set to point to block, or [R0] = zero if allocation failed.
R1 = length allocated
Interrupts disabled in critical stages otherwise unaltered.
Executes in SVC mode. SWI must not be called from an interrupt routine.
Use
This SWI attempts to claim a block of memory within the Amnesia heap if
available. It may shift the heap in messy mode. R1 is rounded up to be a
multiple of 4. If the call is successful the block is then yours to do what
you like with. Always use the pointer at [R0] to access the block, as it may
change when the heap is tidied. You may supply R0 = 0, but Amnesia will no
longer be able to tidy the heap below the block.
The name pointed to by R2 may be up to 8 characters long and is for your use
only. Amnesia will take a copy.
The flags in R3 are as follows:
Bit 0 : If this bit is set, the block is static - it will not be moved by
heap tidying. Avoid static blocks if possible as they may cause Amnesia to
waste memory. Ideally all of your static blocks should be claimed before
your moveable ones.
Bit 1 : If set, the block claimed will be quad-word aligned +4 like blocks
returned by OS_Module. The address will end in 4 (so look like &xxxxxxx4).
Bit 2 : If this bit is set, the block is assumed to be accessed by an
interrupt routine (because it’s a sound sample, for example). If so,
interrupts are disabled when the block is moved during a heap tidy to prevent
problems.
Errors will be returned if there is no room.
=======================================
Amnesia_ReleaseBlock
--------------------
Release a previously claimed block of memory.
On Entry
R0 = Address of pointer (as above) or zero
On Exit
The call zeroes pointer at [R0] if release is valid ie [R0] is a pointer to
an Amnesia block.
Interrupt status unchanged.
Executes in SVC mode. SWI must not be called from an interrupt routine.
Use
This SWI will release a block which has been previously claimed with
Amnesia_ClaimBlock. If R0=0 then the whole Amnesia area is released. In
tidy mode the heap will be shifted to release the free space for future
allocations. The error Not a valid block may be returned.
=======================================
Amnesia_ExtendBlock
-------------------
Extends a block which has already been claimed
On Entry
R0 = Address of current pointer to block
R1 = New length required in bytes
On Exit
Pointer at [R0] may be changed if block is moved
R1 = new length allocated
Interrupt status unchanged.
Executes in SVC mode. SWI must not be called from an interrupt routine.
Use
This SWI tries to extend or shrink a previously claimed block. The heap may
be shifted in tidy or messy modes. May return the errors No room or Not an
allocated block. Its usual method is to claim another block, copy, and then
release the block to be extended.
=======================================
Amnesia_DescribeBlock
---------------------
Returns information about a block.
On Entry
R0 = pointer to block or block number
On Exit
R0 = block address
R1 = block size
R2 = start of data area
R3 = size of data area
R4 = pointer to name
R5 = pointer to block pointer (as passed in R0 to ClaimBlock)
R6 = block flags
Interrupt status unchanged.
Executes in SVC mode. SWI is re-entrant.
Use
This SWI returns information on a specified block.
=======================================
Amnesia_ClaimTable
------------------
Claims space for a table of objects and creates a header for that table
On Entry
R0 = Your handle for the table (0-31)
R1 = Flags
R2 = Zero or pointer to name
R3 = Number of objects
R4 = Size of a single object (bytes)
On Exit
R0-R3 Preserved
Interrupts disabled in critical stages otherwise unaltered.
Executes in SVC mode. SWI must not be called from an interrupt routine.
Use
This SWI sets up a table for subsequent use. A table is a list of objects
which usually represent sprites on the screen (aliens, missiles etc) but can
be used for other purposes. All objects in the new table are marked as
inactive. Returns an error if the allocation fails.
R1 contains information as follows:
bit | meaning if set
0 - objects require collision checking facilities.
The processing of tables is detailed with the SWI Amnesia_ProcessTable. If
the collision checking bit is set a collison checking table of a default
length will be claimed.
The possible errors are No room, not initialised, bad table type, bad handle.
=======================================
Amnesia_ReleaseTable
--------------------
Releases a previously claimed table
On Entry
R0 = Your handle for the table (0-31)
On Exit
R0 preserved
Interrupts disabled in critical stages otherwise unaltered.
Executes in SVC mode. SWI must not be called from an interrupt routine.
Use
Releases the space used by a table and its collision checking area if
present. May return errors if the table is corrupted.
=======================================
Amnesia_ExtendTable
-------------------
*** This SWI is not implemented ***
*** Please contact the author if you _really_ need it! ***
On Entry
R0 = Your handle for the table (0-31)
R2 = New number of objects
On Exit
R0, R2 Preserved
Interrupts disabled in critical stages otherwise unaltered.
Executes in SVC mode. SWI must not be called from an interrupt routine.
Use
This SWI extends or shrinks a current table if possible. Shrinking it may
delete objects. All new objects in the table are marked as inactive. Errors
are generated if the extend fails.
=======================================
Amnesia_WipeTable
-------------------
On Entry
R0 = Your handle for the table (0-31)
On Exit
R0 corrupted, others preserved.
Interrupts disabled in critical stages otherwise unaltered.
Executes in SVC mode. SWI must not be called from an interrupt routine.
Use
This SWI marks all objects in the specified table as inactive.
======