home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 3 / PDCD_3.iso / games / gamesuite / !Amnesia / AmsHelp / Technical / ObjFound < prev    next >
Text File  |  1994-08-19  |  5KB  |  227 lines

  1.  
  2. ; Amnesia module object handling code
  3. ; This code was part of the module code which was assembled using !ExtAsm.
  4. ; Copyright A.Southgate 1994 but may be freely distributed and used in the
  5. ; creation of other code.
  6.  
  7. ; This is the code used my Amnesia when is finds an object during table
  8. ; processing.
  9.  
  10. ; On entry, R10 points to the found object.
  11. ; R11 is the R0 value passed to ProcessTable.
  12.  
  13. .objfound
  14. SUB R10,R10,R9; R10 now points to the found object
  15. STMFD R13!,{R7-R9}
  16. ; we need for later
  17. ; R7 as pointer to t struct
  18. ; R8 as end address
  19. ; R9 as object length
  20.  
  21. LDMIA R10,{R1-R8}
  22. BIC R2,R2,#%1111<<20
  23. STR R2,[R10,#o.flags]
  24. AND R9,R11,#&FF<<24; R9 = the trigger mask
  25. ORR R9,R9,#Amf_colch+Amf_attn+Amf_anim
  26. TST R11,#PF_plot
  27. ORRNE R9,R9,#Amf_plot+Amf_user_plot; request user plot if plots requested
  28. TST R2,#Amf_use_plot_ofs
  29. ORRNE R9,R9,#Amf_use_plot_ofs
  30. TST R2,#Amf_velocity + Amf_attn_timer + Amf_dest_timer + Amf_anim
  31. TSTEQ R2,#Amf_zero_vec + Amf_timer2
  32. BEQ skipvelocity
  33. TST R2,#Amf_velocity
  34. ADDNE R3,R3,R5
  35. ADDNE R4,R4,R6
  36. TST R2,#Amf_zero_vec
  37. MOVNE R5,#0
  38. MOVNE R6,#0
  39. TST R2,#Amf_gravity
  40. BLNE addgravity
  41. TST R2,#Amf_attn_timer + Amf_dest_timer + Amf_anim
  42. SUBNE R7,R7,R7,LSL #16
  43. CMP R7,#0; test for timer expiry
  44. ORRLT R9,R9,#Amf_attn_timer + Amf_dest_timer
  45. STMIA R10,{R1-R7}
  46. TST R2,#Amf_timer2
  47. BLNE runtimer2
  48. .skipvelocity
  49. TST R2,#Amf_game_horiz + Amf_game_vert + Amf_plot_window + Amf_kill_window
  50. BEQ nowindows
  51. STMFD R13!,{R2,R7}
  52. MOV R14,R2       ;NOTE
  53. MOV R5,R8,LSR #16
  54. MOV R6,R8,LSL #16; R1 is <<16 its real value
  55. ;        and don't forget the <<12 from pixels to coords
  56. MOV R5,R5,LSL #16
  57. SUB R1,R3,R5,LSR #17-coordshift
  58. ADD R3,R3,R5,LSR #17-coordshift
  59.  
  60. SUB R2,R4,R6,LSR #17-coordshift
  61. ADD R4,R4,R6,LSR #17-coordshift
  62. TST R14,#Amf_game_horiz + Amf_game_vert
  63. BEQ nogamewindow
  64. ADD R0,R12,#v.gamewindow  ;the game window triggers when any part of the
  65. ;             object    is outside of it
  66.  
  67. LDMIA R0,{R5-R8}
  68. CMP R1,R5
  69. CMPGE R7,R3
  70. ORRLT R9,R9,#Amf_game_horiz
  71. CMP R2,R6
  72. CMPGE R8,R4
  73. ORRLT R9,R9,#Amf_game_vert
  74. .nogamewindow
  75.  
  76. TST R14,#Amf_kill_window
  77. BEQ nokillwindow
  78. ADD R0,R12,#v.killwindow
  79. LDMIA R0,{R5-R8}       ;the kill window triggers if an object is entirely
  80. ;            outside of it.
  81. CMP R1,R7
  82. CMPLE R5,R3
  83. CMPLE R2,R8
  84. CMPLE R6,R4
  85. ORRGT R9,R9,#Amf_kill_window
  86. .nokillwindow
  87. TST R14,#Amf_plot_window
  88. BEQ noplotwindow
  89. TST R9,#Amf_use_plot_ofs
  90. LDRNE R5,[R12,#v.plotxofs]
  91. LDRNE R6,[R12,#v.plotyofs]
  92. ADDNE R1,R1,R5
  93. ADDNE R3,R3,R5
  94. ADDNE R2,R2,R6
  95. ADDNE R4,R4,R6
  96. ADD R0,R12,#v.plotwindow
  97. LDMIA R0,{R5-R8}       ;the plot window triggers if an object is entirely
  98. ;            outside of it.
  99. CMP R1,R7
  100. CMPLT R5,R3
  101. CMPLT R2,R8
  102. CMPLT R6,R4
  103. ORRGE R9,R9,#Amf_plot_window
  104. TST R9,#Amf_plot_window
  105. TSTNE R2,#Amf_colch_window
  106. ORRNE R9,R9,#Amf_colch_window
  107. .noplotwindow
  108. LDMFD R13!,{R2,R7}
  109. .nowindows
  110.  
  111. ; reset regs to return
  112. BIC R0,R11,#PF_advance; signal that we haven't finished
  113. MOV R1,R10
  114. AND R2,R9,R2
  115. TST R2,#Amf_plot_window
  116. BICNE R2,R2,#Amf_plot + Amf_user_plot
  117. BICS R9,R2,#Amf_imask
  118. LDMFD R13!,{R7-R9}
  119. LDMNEFD R13!,{R3-R9,PC}^ ; return if attention required
  120. .noadvance
  121. MOV R0,#0
  122. TST R2,#Amf_kill_window
  123. STRNE R0,[R10,#o.type]
  124.  
  125. TST R2,#Amf_dest_timer
  126. BEQ nodesttimer
  127. LDR R1,[R10,#o.timer]
  128. CMP R1,#0
  129. STRLT R0,[R10,#o.type]
  130. .nodesttimer
  131.  
  132. LDR R0,[R10,#o.type]
  133. CMP R0,#0
  134. BEQ objectdead
  135. TST R2,#Amf_plot
  136. BLNE plotobj     ;uses previous R0
  137.                 
  138. TST R2,#Amf_colch
  139. BEQ objectskip
  140. TST R2,#Amf_colch_window
  141. BNE objectskip
  142. BL colchadd
  143. LDMVSFD R13!,{R3-R9,PC}
  144. .objectskip
  145. .objectdead
  146. ;SWI OS_ReadEscapeState
  147. ;BCC lookforobj
  148. B lookforobj
  149. LDMFD R13!,{R3-R9,PC}
  150.  
  151. .runtimer2
  152. STMFD R13!,{R0}
  153. LDR R0,[R10,#o.timer2]
  154. SUBS R0,R0,R0,LSL #16
  155. STR R0,[R10,#o.timer2]
  156. BICGT R9,R9,#Amf_timer2
  157. LDMFD R13!,{R0}
  158. MOV PC,R14
  159.  
  160. .addgravity
  161. LDR R0,[R12,#v.gravx]
  162. ADD R5,R5,R0
  163. LDR R0,[R12,#v.gravy]
  164. ADD R6,R6,R0
  165. MOV PC,R14
  166.  
  167. .plotobj
  168. STMFD R13!,{R0-R3,R14}
  169. TST R2,#Amf_anim
  170. BLNE fastspranim
  171. TST R2,#Amf_use_plot_ofs
  172. LDRNE R3,[R12,#v.plotxofs]
  173. LDR R1,[R10,#o.x]
  174. ADDNE R1,R1,R3
  175. LDRNE R3,[R12,#v.plotyofs]
  176. LDR R2,[R10,#o.y]
  177. ADDNE R2,R2,R3
  178. MOV R1,R1,ASR #coordshift
  179. MOV R2,R2,ASR #coordshift
  180. SWI FastSpr_Plot
  181. LDMFD R13!,{R0-R3,PC}
  182.  
  183. .fastspranim
  184. TST R2,#Amf_timer2
  185. LDREQ R1,[R10,#o.timer]
  186. LDRNE R1,[R10,#o.timer2]
  187. AND R1,R1,#&FF<<24
  188. ORR R0,R0,R1,LSR #8
  189. MOV PC,R14
  190.  
  191. .colchadd
  192. STMFD R13!,{R1-R9,R14}
  193. LDR R0,[R12,#v.temp0]
  194. LDR R9,[R0,#4]; get colchtab addr
  195. CMP R9,#0
  196. BEQ colchnotable
  197. SUB R9,R9,#b.sizeof
  198. LDR R1,[R9,#c.writeofs]
  199. LDR R2,[R9,#c.size]
  200. CMP R1,R2
  201. BGE colchnoroom
  202. SUB R0,R10,R7;offset within table
  203. ADD R7,R9,R1; position to write to
  204. LDR R3,[R10,#o.x]
  205. LDR R4,[R10,#o.y]
  206. LDR R8,[R10,#o.size]
  207. MOV R5,R8,LSR #16
  208. MOV R6,R8,LSL #16; R6 is <<16 its real value
  209. MOV R5,R5,LSL #16; now so is R5
  210. SUB R1,R3,R5,LSR #17-coordshift
  211. ADD R3,R3,R5,LSR #17-coordshift
  212. SUB R2,R4,R6,LSR #17-coordshift
  213. ADD R4,R4,R6,LSR #17-coordshift
  214. STMIA R7!,{R0-R4}
  215. SUB R1,R7,R9; restore writeofs
  216. STR R1,[R9,#c.writeofs]
  217. LDMFD R13!,{R1-R9,PC}^
  218. .colchnotable
  219. LDMFD R13!,{R1-R9,R14}
  220. B colchnotableerr
  221.  
  222. .colchnoroom
  223. LDMFD R13!,{R1-R9,R14}
  224. B colchnoroomerr
  225.  
  226. ; Don't worry - I can't understand it either!
  227. ; Andy. 8-)