home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
games
/
gamesuite
/
!Amnesia
/
AmsHelp
/
Process
< prev
next >
Wrap
Text File
|
1995-01-29
|
4KB
|
106 lines
Amnesia Table Processing - for Amnesia 1.00
===========================================
This file describes the technique of processing tables with Amnesia.
Overview
--------
The method of table processing is designed to take most of the workload
involved in a game away from the game program and into the optimised machine
code routines within Amnesia. This allows the game program to be written in
a slower language, such as BASIC, whilst keeping the game fast and
responsive.
The Process
-----------
Table processing is controlled by two SWIs - Amnesia_SelectTable and
Amnesia_ProcessTable. These SWIs communicate using registers R0, R1 and R2.
A typical table process goes like this:
SYS "Amnesia_SelectTable",1,0,0 TO R0,R1,R2
REPEAT
SYS "Amnesia_ProcessTable",R0,R1,R2 TO R0,R1,R2
IF (R2 AND (1<<8)) THEN PROCtimer
IF (R2 AND (1<<13)) THEN PROCgamewindow
UNTIL R2=0
Amnesia_SelectTable is called to tell Amnesia which table you wish to
processand what you want to do with that table. Read its entry in the SWI
docs for a full explanation. With the parameters above it selects table 1
for a standard process.
The values R0, R1 and R2 from Amnesia_SelectTable are passed straight to
Amnesia_ProcessTable. Amnesia_ProcessTable may return either
• An object for you to do something with.
• R2=0, indicating that it has finished processing this table.
Here’s how it works. When you call Amnesia_ProcessTable Amnesia looks
through the table until it finds an object. Then, it does all the work which
you specified in the flags when you created the object. This includes moving
the object, running timers etc. If there is nothing interesting happening
with the object then Amnesia plots it if necessary and starts on the next
object.
On the other hand, if there is something interesting happening, like a timer
expiring or the object has moved outside of a certain area,
Amnesia_ProcessTable will return the object 'For Attention'. This means that
the SWI returns to your program, with R1 pointing to the object which you
have to deal with, and R2 containing a 'Reason Code'.
The value in R2 has a direct relation with the value in the objects flags.
For example, if the timer bit of the object is set (bit 8) and the timer
expires, R2 will return with bit 8 set. If the kill window bit is set (bit
16) and the object is outside of the kill window, then the SWI will return
with bit 16 of R2 set, and so on.
When you have dealt with the object, you probably want to carry on processing
the rest of the table by calling Amnesia_ProcessTable again. However, so
that Amnesia knows that you’re restarting from part-way through the table you
don’t give it the R0, R1 and R2 from Amnesia_SelectTable. Instead you give
it the R0, R1 and R2 which it gave to you. The ProcessTable SWI will then
plot the object that you’ve just dealt with, work out how far it had got
through the table, and carry on from there.
*** NOTE *** If you call the ProcessTable SWI more than once you must pass
the same R0, R1 and R2 which it generated, back to it. Use the code above
and make sure that things like PROCtimer and PROCgamewindow do not alter the
variables R0, R1 or R2. This is important.
To illustrate, this code would not work:
SYS "Amnesia_SelectTable",1,0,0 TO R0,R1,R2
REPEAT
SYS "Amnesia_ProcessTable",R0,R1,R2 TO a,b,c
IF (c AND (1<<8)) THEN PROCtimer
IF (c AND (1<<13)) THEN PROCgamewindow
UNTIL c=0
-------------------------------------------
Scanning a Table
================
The may be times when you wish to scan a table for a specified object without
applying all of the effects of a process pass. This can be achieved through
a modified sort of process pass.
SYS "Amnesia_SelectTable",1,1,8,&1000 TO R0,R1,R2,R3
REPEAT
SYS "Amnesia_ProcessTable",R0,R1,R2,R3 TO R0,R1,R2,R3
PROCscanfound
UNTIL R2=0
This will return all the objects with the value &1000 at offset +8. The
value passed in R1 to Amnesia_SelectTable determines what sort of test is
used for the scan. The SWI docs have full infomation.
****************************************************
This document is copyright A.Southgate 1994.
It may be freely distibuted and copied but
should not be modified, otherwise things will
get very confusing.
****************************************************