home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / games / gamesuite / !Amnesia / AmsHelp / Process < prev    next >
Text File  |  1995-01-29  |  4KB  |  106 lines

  1. Amnesia Table Processing - for Amnesia 1.00
  2. ===========================================
  3.  
  4. This file describes the technique of processing tables with Amnesia.
  5.  
  6. Overview
  7. --------
  8.  
  9. The method of table processing is designed to take most of the workload
  10. involved in a game away from the game program and into the optimised machine
  11. code routines within Amnesia.  This allows the game program to be written in
  12. a slower language, such as BASIC, whilst keeping the game fast and
  13. responsive.
  14.  
  15. The Process
  16. -----------
  17.  
  18. Table processing is controlled by two SWIs - Amnesia_SelectTable and
  19. Amnesia_ProcessTable.  These SWIs communicate using registers R0, R1 and R2. 
  20. A typical table process goes like this:
  21.  
  22. SYS "Amnesia_SelectTable",1,0,0 TO R0,R1,R2
  23. REPEAT
  24.   SYS "Amnesia_ProcessTable",R0,R1,R2 TO R0,R1,R2
  25.   IF (R2 AND (1<<8)) THEN PROCtimer
  26.   IF (R2 AND (1<<13)) THEN PROCgamewindow
  27. UNTIL R2=0
  28.  
  29. Amnesia_SelectTable is called to tell Amnesia which table you wish to
  30. processand what you want to do with that table.  Read its entry in the SWI
  31. docs for a full explanation.  With the parameters above it selects table 1
  32. for a standard process.
  33.  
  34. The values R0, R1 and R2 from Amnesia_SelectTable are passed straight to
  35. Amnesia_ProcessTable.  Amnesia_ProcessTable may return either
  36.  
  37.   •  An object for you to do something with.
  38.   •  R2=0, indicating that it has finished processing this table.
  39.   
  40. Here’s how it works.  When you call Amnesia_ProcessTable Amnesia looks
  41. through the table until it finds an object.  Then, it does all the work which
  42. you specified in the flags when you created the object.  This includes moving
  43. the object, running timers etc.  If there is nothing interesting happening
  44. with the object then Amnesia plots it if necessary and starts on the next
  45. object.
  46.  
  47. On the other hand, if there is something interesting happening, like a timer
  48. expiring or the object has moved outside of a certain area,
  49. Amnesia_ProcessTable will return the object 'For Attention'.  This means that
  50. the SWI returns to your program, with R1 pointing to the object which you
  51. have to deal with, and R2 containing a 'Reason Code'.
  52.  
  53. The value in R2 has a direct relation with the value in the objects flags. 
  54. For example, if the timer bit of the object is set (bit 8) and the timer
  55. expires, R2 will return with bit 8 set.  If the kill window bit is set (bit
  56. 16) and the object is outside of the kill window, then the SWI will return
  57. with bit 16 of R2 set, and so on.
  58.  
  59. When you have dealt with the object, you probably want to carry on processing
  60. the rest of the table by calling Amnesia_ProcessTable again.  However, so
  61. that Amnesia knows that you’re restarting from part-way through the table you
  62. don’t give it the R0, R1 and R2 from Amnesia_SelectTable.  Instead you give
  63. it the R0, R1 and R2 which it gave to you.  The ProcessTable SWI will then
  64. plot the object that you’ve just dealt with, work out how far it had got
  65. through the table, and carry on from there.
  66.  
  67. *** NOTE ***  If you call the ProcessTable SWI more than once you must pass
  68. the same R0, R1 and R2 which it generated, back to it.  Use the code above
  69. and make sure that things like PROCtimer and PROCgamewindow do not alter the
  70. variables R0, R1 or R2.  This is important.
  71.  
  72. To illustrate, this code would not work:
  73.  
  74. SYS "Amnesia_SelectTable",1,0,0 TO R0,R1,R2
  75. REPEAT
  76.   SYS "Amnesia_ProcessTable",R0,R1,R2 TO a,b,c
  77.   IF (c AND (1<<8)) THEN PROCtimer
  78.   IF (c AND (1<<13)) THEN PROCgamewindow
  79. UNTIL c=0
  80.  
  81. -------------------------------------------
  82.  
  83. Scanning a Table
  84. ================
  85.  
  86. The may be times when you wish to scan a table for a specified object without
  87. applying all of the effects of a process pass.  This can be achieved through
  88. a modified sort of process pass.
  89.  
  90. SYS "Amnesia_SelectTable",1,1,8,&1000 TO R0,R1,R2,R3
  91. REPEAT
  92.   SYS "Amnesia_ProcessTable",R0,R1,R2,R3 TO R0,R1,R2,R3
  93.   PROCscanfound
  94. UNTIL R2=0
  95.   
  96. This will return all the objects with the value &1000 at offset +8.  The
  97. value passed in R1 to Amnesia_SelectTable determines what sort of test is
  98. used for the scan.  The SWI docs have full infomation.
  99.  
  100. ****************************************************
  101.     This document is copyright A.Southgate 1994.
  102.     It may be freely distibuted and copied but
  103.     should not be modified, otherwise things will
  104.     get very confusing.
  105. ****************************************************
  106.