alien_routines.s 33 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474
  1. Setup_Enemies
  2. ; Just in case (Glen will probably corrupt memory at some point)
  3. move.l #$ffffffff,BOBBACK1
  4. move.l #$ffffffff,BOBBACK2
  5. move.l #$ffffffff,FRIEND1
  6. move.l #$ffffffff,FRIEND2
  7. move.l #$ffffffff,CLEAR1
  8. move.l #$ffffffff,CLEAR2
  9. move.l #$ffffffff,SAVE1
  10. move.l #$ffffffff,SAVE2
  11. move.l #$ffffffff,LIST1
  12. move.l #$ffffffff,LIST2
  13. move.l #$ffffffff,Enemy_Store1
  14. move.l #$ffffffff,Enemy_Store2
  15. clr.l alien_map_position
  16. move.w #0,current_bonus
  17. move.w #1,current_bonus_counter
  18. ****
  19. ; Sets up virtual positions, later on the game will not work this way
  20. ****
  21. bsr Create_Enemy_Pointers
  22. move.l #Level_1_Enemies,a3 ; presets
  23. bsr Stuff_Preset_Enemies
  24. End_Setup_Aliens
  25. rts
  26. Create_Enemy_Pointers
  27. move.l Enemy_List,Last_Alien_in_list ; initialise tail var
  28. move.l #$ffffffff,([Enemy_List]) ; initialise list
  29. move.l #Enemy_Memory,a0
  30. move.l #Available_List,a1
  31. move.w #Max_No_Objects-1,d0 ; Alien store
  32. thingyi
  33. move.l a0,(a1)+
  34. add.l #Store_Size,a0
  35. dbra d0,thingyi
  36. no_space_left
  37. move.l a1,Available_Pointer
  38. rts
  39. Stuff_Preset_Enemies
  40. ; presets in a3
  41. cmp.w #$ffff,(a3)
  42. beq.s preset_enemies_done
  43. move.w (a3)+,d2 ; character
  44. move.w (a3)+,d0 ; X position
  45. move.w (a3)+,d1 ; Y position
  46. move.w (a3)+,d3 ; special data & mode2 bits
  47. bsr Add_An_Enemy
  48. bra.s stuff_preset_enemies
  49. preset_enemies_done
  50. rts
  51. Spawn_Preset_Enemies
  52. ; presets in a3
  53. ; alienX in d0
  54. ; alienY in d1
  55. move.w d0,d6
  56. move.w d1,d7
  57. spawny_loop
  58. cmp.w #$ffff,(a3)
  59. beq.s spawny_enemies_done
  60. move.w (a3)+,d2 ; character
  61. move.w (a3)+,d0 ; X offset
  62. move.w (a3)+,d1 ; Y offset
  63. move.w (a3)+,d3 ; Special data and mode bits
  64. btst.l #15,d2 ; custom needed
  65. beq.s no_thanks_custom
  66. move.l (a3)+,d4 ; custom bit ? nice eh
  67. no_thanks_custom
  68. add.w d6,d0 ; co-ords
  69. add.w d7,d1 ; co-ords
  70. bsr Add_An_Enemy ; stick it in
  71. bra.s spawny_loop
  72. spawny_enemies_done
  73. move.w d6,d0
  74. move.w d7,d1
  75. rts
  76. Create_Master_Slave_Chain
  77. ; presets in a3
  78. ; alienX in d0
  79. ; alienY in d1
  80. clr.w ms_first_time ; flag for first time through
  81. move.w d0,d6
  82. move.w d1,d7
  83. spawny_loop2
  84. cmp.w #$ffff,(a3)
  85. beq.s spawny_enemies_done2
  86. move.w (a3)+,d2 ; character
  87. move.w (a3)+,d0 ; X offset
  88. move.w (a3)+,d1 ; Y offset
  89. move.w (a3)+,d3 ; Special data and mode bits
  90. btst.l #15,d2 ; custom needed
  91. beq.s no_thanks_custom2
  92. move.l (a3)+,d4 ; custom bit ? nice eh
  93. no_thanks_custom2
  94. add.w d6,d0 ; co-ords
  95. add.w d7,d1 ; co-ords
  96. bsr Add_An_Enemy ; stick it in
  97. tst.l Add_Enemy_pointer ; *** Check if it was added
  98. beq.s serious_cock_up ; *** If this ever happens
  99. ; *** The game will look shit!
  100. tst.w ms_first_time
  101. bne.s not_first_time
  102. move.l a1,Master_Pointer ; ie alien which is generating
  103. move.w #1,ms_first_time ; this stuff is the master.
  104. not_first_time
  105. move.l a1,-(sp)
  106. move.l Master_Pointer,a1
  107. move.l Add_Enemy_Pointer,d3
  108. move.l d3,Alien_Slave_Pointer(a1)
  109. move.l (sp)+,a1
  110. move.l Add_Enemy_Pointer,d3 ; last added pointer
  111. move.l d3,Master_Pointer ; now becomes the master!
  112. bra.s spawny_loop2
  113. spawny_enemies_done2
  114. move.l Master_Pointer,a3
  115. clr.l Alien_Slave_Pointer(a3) ; has now more slaves in chain
  116. serious_cock_up
  117. move.w d6,d0
  118. move.w d7,d1
  119. rts
  120. ms_first_time dc.w 0
  121. Master_Pointer dc.l 0
  122. Replace_SaveBacks
  123. ****************************************************************
  124. * Function : Removes all alien bobs from a double buffered bob *
  125. ****************************************************************
  126. DoReplacePrelims
  127. BTST #DMAB_BLTDONE-8,DMACONR(a6)
  128. BNE.s DoReplacePrelims
  129. clr.w BLTAMOD(a6) ; to a buffer
  130. MOVE.l #$09f00000,BLTCON0(a6) ; straight D=A blit
  131. move.l #-1,BLTAFWM(a6) ; we want all the bits
  132. move.l REPLACE_AREA_BUFFER,a2 ; aliens draw at frame-2
  133. Replace_Next_Bob
  134. cmp.l #$ffffffff,(a2) ; last alien to erase?
  135. beq.s Aliens_Replaced ; yes then exit
  136. move.l (a2)+,a0 ; screen memory pointer
  137. move.l (a2)+,a5 ; graphics memory pointer
  138. move.l (a2)+,a1 ; graphics struct pointer
  139. WaitforlastReplace
  140. BTST #DMAB_BLTDONE-8,DMACONR(a6)
  141. BNE.s WaitforlastReplace
  142. move.w Alien_Mod(a1),BLTDMOD(a6) ; copying from the screen
  143. move.l Alien_Frame_Size(a1),d2 ;
  144. move.w Alien_Height(a1),d3 ;
  145. add.w d3,d2 ; add extra byte
  146. add.w d3,d2 ; add extra byte for padding
  147. move.w #4-1,d7 ; planes
  148. repl_plane_loop
  149. replP BTST #DMAB_BLTDONE-8,DMACONR(a6)
  150. BNE.s replP
  151. MOVE.L a5,BLTAPTH(a6) ; a0 graphics on screen
  152. MOVE.L a0,BLTDPTH(a6) ; a5 pointer to saveback mem
  153. MOVE.W Alien_D_Blit(a1),BLTSIZE(a6)
  154. add.l #BYTES_PER_ROW*SCROLL_HEIGHT,a0
  155. add.l d2,a5
  156. dbra d7,repl_plane_loop
  157. bra.s Replace_Next_Bob ; branch for next alien
  158. Aliens_Replaced
  159. rts
  160. *************
  161. Clear_NoSaves
  162. DoClearPrelims
  163. BTST #DMAB_BLTDONE-8,DMACONR(a6)
  164. BNE.s DoClearPrelims
  165. move.w #-2,BLTAMOD(a6) ; to a buffer
  166. move.w #-2,BLTBMOD(a6) ; to a buffer
  167. clr.w BLTBDAT(a6) ; sort this bollocks out
  168. move.l #$ffff0000,BLTAFWM(a6)
  169. move.l CLEAR_AREA_BUFFER,a2 ; aliens draw at frame-2
  170. Clear_Next_Bob
  171. cmp.l #$ffffffff,(a2) ; last alien to erase?
  172. beq.s Aliens_Replaced ; yes then exit
  173. move.l (a2)+,a0 ; screen memory pointer
  174. move.l (a2)+,a5 ; mask memory pointer
  175. move.l (a2)+,a1 ; graphics struct pointer
  176. move.l #$00000bca,d0 ; disable b (graphics)
  177. or.w (a2)+,d0 ; or shift
  178. swap.w d0 ; swap so in order
  179. MOVE.l d0,BLTCON0(a6)
  180. Waitforlastclear
  181. BTST #DMAB_BLTDONE-8,DMACONR(a6)
  182. BNE.s Waitforlastclear
  183. move.w Alien_Mod(a1),BLTCMOD(a6) ; copying from the screen
  184. move.w Alien_Mod(a1),BLTDMOD(a6) ; copying from the screen
  185. move.w #4-1,d7 ; planes
  186. clear_plane_loop
  187. clearP BTST #DMAB_BLTDONE-8,DMACONR(a6)
  188. BNE.s clearP
  189. MOVE.L a5,BLTAPTH(a6) ; mask
  190. * MOVE.L a5,BLTBPTH(a6) ; graphics ; not used
  191. move.l a0,BLTCPTH(a6) ; screen address
  192. MOVE.L a0,BLTDPTH(a6) ; screen address
  193. MOVE.W Alien_D_Blit(a1),BLTSIZE(a6)
  194. add.l #BYTES_PER_ROW*SCROLL_HEIGHT,a0
  195. dbra d7,clear_plane_loop
  196. bra.s Clear_Next_Bob ; branch for next alien
  197. Aliens_Cleared
  198. rts
  199. Object_Collision
  200. * This code really needs sorting out so that
  201. * types of aliens which collide are defined
  202. * correctly. ie We do not wish to kill platforms.
  203. move.l #Temporary_Object_List,a0
  204. next_object
  205. cmp.l #$ffffffff,(a0) ; end of list?
  206. beq object_collision_complete
  207. move.l (a0)+,a2
  208. move.l Enemy_List,a1
  209. next_object2
  210. cmp.l #$ffffffff,(a1) ;
  211. beq current_object_complete
  212. move.l (a1)+,a3 ;
  213. cmp.l a2,a3 ; same object ?
  214. beq.s next_object2
  215. btst.b #Alien_hit,Alien_Mode(a2) ; object already hit?
  216. bne.s next_object2
  217. btst.b #Alien_hit,Alien_Mode(a3) ; same again with obj 2
  218. bne.s next_object2
  219. ** Test Collision Pair **
  220. move.w Alien_Number(a2),d0
  221. move.w Alien_Number(a3),d1
  222. mulu.w #Character_Control_Size,d0
  223. mulu.w #Character_Control_Size,d1
  224. move.l d0,a4
  225. add.l #Character_Control_Block,a4
  226. move.l d1,a5
  227. add.l #Character_Control_Block,a5
  228. move.w Alien_X(a2),d0
  229. move.w Alien_Y(a2),d1
  230. add.w Character_Coll_Box_X(a4),d0
  231. add.w Character_Coll_Box_Y(a4),d1
  232. move.w d0,d2
  233. move.w d1,d3
  234. add.w Character_Coll_Box_DX(a4),d2
  235. add.w Character_Coll_Box_DY(a4),d3
  236. move.w Alien_X(a3),d4
  237. move.w Alien_Y(a3),d5
  238. add.w Character_Coll_Box_X(a5),d4
  239. add.w Character_Coll_Box_Y(a5),d5
  240. move.w d4,d6
  241. move.w d5,d7
  242. add.w Character_Coll_Box_DX(a5),d6
  243. add.w Character_Coll_Box_DY(a5),d7
  244. cmp.w d0,d4
  245. blt.s test_x_to_the_lefto
  246. text_x_to_the_righto
  247. cmp.w d2,d4
  248. blt.s x_in_boxo
  249. bra no_object_hit_alien
  250. test_x_to_the_lefto
  251. cmp.w d0,d6
  252. blt no_object_hit_alien
  253. x_in_boxo
  254. * Y collision
  255. cmp.w d1,d5
  256. blt.s test_y_aboveo
  257. text_y_belowo
  258. cmp.w d3,d5
  259. blt.s y_in_boxo
  260. bra no_object_hit_alien
  261. test_y_aboveo
  262. cmp.w d1,d7
  263. blt no_object_hit_alien
  264. y_in_boxo
  265. collision_happened
  266. btst.b #Alien_Object,Alien_Mode2(a3) ; did it hit another object?
  267. beq.s hit_an_alien_thats_all_right_then
  268. btst.b #Alien_Platform,Alien_Mode2(a3) ; did it hit a platform
  269. bne next_object2 ; do something about this shit code
  270. move.w Repeat_X(a2),d0
  271. tst.w d0
  272. bmi.s test_left_movement
  273. cmp.w Repeat_X(a3),d0
  274. blt.s object2wins
  275. bra.s object1wins
  276. test_left_movement
  277. cmp.w Repeat_X(a3),d0
  278. bgt.s object2wins
  279. object1wins
  280. move.l Character_Dead(a5),a4
  281. move.l a4,Alien_Flight(a3) ; set hit anim
  282. clr.w Repeat_Counter(a3)
  283. bset.b #Alien_OffScreen,Alien_Mode(a3)
  284. bset.b #Alien_Hit,Alien_Mode(a3)
  285. * bsr do_score_chance
  286. bra next_object2
  287. object2wins
  288. move.l Character_Dead(a4),a4
  289. move.l a4,Alien_Flight(a2) ; set hit anim
  290. clr.w Repeat_Counter(a2)
  291. bset.b #Alien_OffScreen,Alien_Mode(a2)
  292. bset.b #Alien_Hit,Alien_Mode(a2)
  293. * bsr do_score_chance
  294. bra next_object2
  295. hit_an_alien_thats_all_right_then
  296. move.l Character_Hit(a5),a5
  297. move.l a5,Alien_Flight(a3) ; set hit anim
  298. clr.w Repeat_Counter(a3)
  299. bset.b #Alien_OffScreen,Alien_Mode(a3)
  300. bset.b #Alien_Hit,Alien_Mode(a3)
  301. move.w #Sound_Slap,sound_chan1
  302. move.w d4,d0
  303. move.w d5,d1
  304. bsr do_score_chance
  305. cmp.w #BaseBall_Character,Alien_Number(a2)
  306. bne.s no_baseball
  307. move.l Character_Dead(a4),a4
  308. move.l a4,Alien_Flight(a2) ; set hit anim
  309. clr.w Repeat_Counter(a2)
  310. bset.b #Alien_OffScreen,Alien_Mode(a2)
  311. bset.b #Alien_Hit,Alien_Mode(a2)
  312. no_baseball
  313. no_object_hit_alien
  314. bra next_object2
  315. current_object_complete
  316. bra next_object
  317. object_collision_complete
  318. rts
  319. Player_Object_Collision
  320. tst.w current_bonus_counter
  321. beq.s reset_bonus
  322. subq.w #1,current_bonus_counter
  323. bra.s its1052
  324. reset_bonus
  325. move.w #0,current_bonus
  326. its1052
  327. clr.l Player_Object
  328. move.l Enemy_List,a0
  329. move.l #Temporary_Object_List,a1
  330. next_player_object
  331. cmp.l #$ffffffff,(a0) ; end of list?
  332. beq player_object_collision_complete
  333. * Must try to get this out of the loop
  334. move.w player_x,d0
  335. move.w player_y,d1
  336. add.w screen_x_position,d0
  337. add.w screen_y_position,d1
  338. move.w d0,d2
  339. move.w d1,d3
  340. add.w #15,d2 ; player width
  341. add.w #PLAYER_HEIGHT,d3 ; player height
  342. move.l (a0)+,a2 ; object1
  343. move.w Alien_Number(a2),d4
  344. mulu.w #Character_Control_Size,d4
  345. move.l d4,a4
  346. add.l #Character_Control_Block,a4
  347. btst.b #Alien_Platform,Alien_Mode2(a2)
  348. beq not_a_platform
  349. ** Test Alien Co-ordinates with that of the player
  350. add.w #8,d0
  351. add.w #PLAYER_HEIGHT,d1 ; feet co-ords
  352. move.w Alien_X(a2),d4
  353. move.w Alien_Y(a2),d5
  354. add.w Character_Coll_Box_X(a4),d4
  355. add.w Character_Coll_Box_Y(a4),d5
  356. move.w d4,d6
  357. move.w d5,d7
  358. add.w Character_Coll_Box_DX(a4),d6
  359. add.w Character_Coll_Box_DY(a4),d7
  360. cmp.w d4,d0
  361. blt.s no_pl_collision1
  362. cmp.w d5,d1
  363. blt.s no_pl_collision_test_y
  364. cmp.w d6,d0
  365. bgt.s no_pl_collision1
  366. cmp.w d7,d1
  367. bgt.s no_pl_collision1
  368. bra.s collision_happened_on_player
  369. no_pl_collision_test_y
  370. *This code checks player cannot fall through platform
  371. bsr check_player_fall_onto_platform
  372. tst d7
  373. bne.s collision_happened_on_player
  374. no_pl_collision1
  375. bra.s nothing_touching_player
  376. collision_happened_on_player
  377. ; set player y co-ordinate to that of the alien - height of player
  378. bsr check_player_on_platform
  379. tst d7
  380. beq.s nothing_touching_player
  381. player_hit_plat
  382. move.b #0,y_collision_jump_struct+in_air
  383. move.b #0,y_collision_fall_struct+in_air
  384. move.w #0,player_fall_velocity
  385. move.w #0,start_jump
  386. move.w #0,player_falling_flag
  387. move.w #ACTION_PLAYER_ON_GROUND,player_action
  388. move.w d5,d1
  389. sub.w #PLAYER_HEIGHT,d1
  390. sub.w screen_y_position,d1
  391. mulu.w #SCALE_FACTOR,d1
  392. move.w d1,player_y_scaled
  393. move.l a2,Player_Object ; player object address
  394. btst.b #Platform_Activate,Alien_Mode2(a2)
  395. beq.s dont_bother
  396. move.l Character_Hit(a4),a4
  397. move.l a4,Alien_Flight(a2) ; set hit anim
  398. clr.w Repeat_Counter(a2)
  399. dont_bother
  400. nothing_touching_player
  401. bra next_player_object
  402. not_a_platform
  403. btst.b #Alien_Hit,Alien_Mode(a2)
  404. bne next_player_object
  405. btst.b #Alien_Object,Alien_Mode2(a2)
  406. beq.s not_an_object
  407. move.l a2,(a1)+
  408. not_an_object
  409. * is a normal alien so do test for death and also jump on head
  410. move.w Alien_X(a2),d4
  411. move.w Alien_Y(a2),d5
  412. add.w Character_Coll_Box_X(a4),d4
  413. add.w Character_Coll_Box_Y(a4),d5
  414. move.w d4,d6
  415. move.w d5,d7
  416. add.w Character_Coll_Box_DX(a4),d6
  417. add.w Character_Coll_Box_DY(a4),d7
  418. btst.b #Alien_Bonus,Alien_Mode2(a2) ; for the baseball shit
  419. bne.s no_jump_collision
  420. cmp.w #ACTION_PLAYER_FALLING,player_action
  421. bne.s no_jump_collision
  422. * Test Jump on alien
  423. addq.w #2,d0
  424. subq.w #2,d2 ; mid of player
  425. subq.w #5,d3 ; feet box
  426. cmp.w d0,d4
  427. blt.s jumptest_x_to_the_left
  428. jumptest_x_to_the_right
  429. cmp.w d2,d4
  430. blt.s jumpx_in_box
  431. bra.s no_jp_collision1
  432. jumptest_x_to_the_left
  433. cmp.w d0,d6
  434. blt.s no_jp_collision1
  435. jumpx_in_box
  436. * Y collision ; test Y strip in alien
  437. cmp.w d3,d5
  438. blt.s jumptest_y_above
  439. jumptest_y_below
  440. add.w #5,d3
  441. cmp.w d3,d5
  442. blt.s player_jumped_on_alien
  443. bra.s no_jp_collision1
  444. jumptest_y_above
  445. *add.w #5,d3
  446. cmp.w d3,d7
  447. blt.s frig_code
  448. bra player_jumped_on_alien
  449. *cmp.w d4,d2
  450. *blt.s no_jp_collision1
  451. *cmp.w d5,d3
  452. *blt.s no_jp_collision1
  453. *cmp.w d6,d2
  454. *bgt.s no_jp_collision1
  455. *cmp.w d7,d3
  456. *bgt.s no_jp_collision1
  457. *bra player_jumped_on_alien
  458. frig_code
  459. *add.w #5,d3
  460. no_jp_collision1
  461. subq.w #2,d0
  462. addq.w #2,d2
  463. * Test player hit
  464. no_jump_collision
  465. cmp.w d0,d4
  466. blt.s test_x_to_the_left
  467. text_x_to_the_right
  468. cmp.w d2,d4
  469. blt.s x_in_box
  470. bra.s no_ob_collision
  471. test_x_to_the_left
  472. cmp.w d0,d6
  473. blt.s no_ob_collision
  474. x_in_box
  475. * Y collision
  476. cmp.w d1,d5
  477. blt.s test_y_above
  478. text_y_below
  479. cmp.w d3,d5
  480. blt.s y_in_box
  481. bra.s no_ob_collision
  482. test_y_above
  483. cmp.w d1,d7
  484. blt.s no_ob_collision
  485. y_in_box
  486. collision_happened_on_object
  487. btst.b #Alien_object,Alien_Mode2(a2)
  488. beq.s try_bonus
  489. bra.s hit_character_but_not_die
  490. try_bonus
  491. btst.b #Alien_Bonus,Alien_Mode2(a2)
  492. beq.s hit_nasty
  493. hit_character_but_not_die
  494. cmp.w #GlassBLOCK_CHARACTER,Alien_Number(a2)
  495. bne.s dont_bodge_it
  496. move.w #Sound_Cowbell,sound_chan1
  497. bset.b #Alien_Dead,Alien_Mode(a2)
  498. move.w #BASE_BALL,player_holding_object
  499. dont_bodge_it
  500. move.l Character_Hit(a4),a4
  501. move.l a4,Alien_Flight(a2) ; set hit anim
  502. clr.w Repeat_Counter(a2)
  503. bra next_player_object
  504. hit_nasty
  505. move.w #1,player_has_been_hit
  506. bra next_player_object
  507. no_ob_collision
  508. bra next_player_object
  509. player_jumped_on_alien
  510. move.b #0,y_collision_jump_struct+in_air
  511. move.b #0,y_collision_fall_struct+in_air
  512. move.w #0,player_fall_velocity
  513. move.w #0,start_jump
  514. move.w #0,player_falling_flag
  515. move.w #0,supress_repeat_jump
  516. move.w #1,fire
  517. tst.w ydirec
  518. bmi.s player_attempting_bum_flatten
  519. move.w #Sound_alienhit,sound_chan1
  520. bra.s done_player_alien_sounds
  521. player_attempting_bum_flatten
  522. move.w #Sound_bumhit,sound_chan1
  523. move.w player_x_velocity,d0
  524. asl d0
  525. move.w d0,player_x_velocity
  526. *we set both these bits - SPRING as there is code to bypass
  527. *various things if player sitting down - also set BOUNCE so only
  528. *a small jump is perfromed and not a SPRING jump - i.e clear it
  529. bset.b #BOUNCE_FLAG,player_control_bits
  530. bset.b #SPRING_FLAG,player_control_bits
  531. done_player_alien_sounds
  532. Set_alien_hit_anim
  533. move.l Character_Hit(a4),a4
  534. move.l a4,Alien_Flight(a2) ; set hit anim
  535. clr.w Repeat_Counter(a2)
  536. bset.b #Alien_OffScreen,Alien_Mode(a2)
  537. bset.b #Alien_Hit,Alien_Mode(a2)
  538. move.w d4,d0
  539. move.w d5,d1
  540. bsr do_score_chance
  541. move.w d2,d0
  542. subq.w #8,d0 ; centre star
  543. move.w d3,d1
  544. move.w #hitstar_character,d2
  545. bsr add_an_enemy
  546. bra next_player_object
  547. player_object_collision_complete
  548. move.l #$FFFFFFFF,(a1) ; end object list
  549. rts
  550. do_score_chance
  551. ; NOTE: buggers up a5
  552. tst.w ydirec
  553. bpl.s no_double_bum
  554. addq.w #1,current_bonus
  555. no_double_bum
  556. move.w #score_character,d2
  557. bsr add_an_enemy
  558. move.l add_enemy_pointer,a5
  559. move.w current_bonus,frame_number(a5)
  560. addq.w #1,current_bonus
  561. check_max_bonus
  562. cmp.w #12,current_bonus
  563. ble.s bonus_ok
  564. move.w #12,current_bonus
  565. bonus_ok
  566. move.w #50*3,current_bonus_counter
  567. rts
  568. current_bonus
  569. dc.w 1
  570. current_bonus_counter
  571. dc.w 0
  572. Move_Player_On_Object
  573. move.l Player_Object,a0
  574. tst.l a0
  575. beq.s no_object_on
  576. move.w Repeat_X(a0),d0
  577. move.w Repeat_Y(a0),d1
  578. mulu.w #SCALE_FACTOR,d0
  579. mulu.w #SCALE_FACTOR,d1
  580. add.w d0,player_x_scaled
  581. add.w d1,player_y_scaled
  582. no_object_on
  583. rts
  584. Move_Bobs
  585. *******************************************************************
  586. * Function : Handles the movement addition and deletion of aliens *
  587. * from an existance list *
  588. * Limits : So far this section has the following abilities *
  589. * Move Absolute/Relative, Speed *
  590. * Addition : This routine has been modified to include the Place *
  591. * bob procedure as this was found to be faster *
  592. *******************************************************************
  593. move.l Enemy_List,a0 ; all aliens to be processed
  594. move.l #Alien_Species,a2 ; all the varieties
  595. move.l OLDBOB_BUFFER,a3 ; planes to draw objects
  596. move.l CLEAR_LIST_BUFFER,a5 ; no saveback objects
  597. move.l Enemy_List_Buffer,a4 ; pointer for alien list processing
  598. New_Bob
  599. *-Next-Alien--------------------------------------------------------------
  600. cmp.l #$FFFFFFFF,(a0) ; no aliens left?
  601. beq aliens_processed ; yes then wrap up
  602. move.l (a0),a1 ; alien details
  603. co_ords
  604. move.w Alien_X(a1),d0 ; get last x pos of alien
  605. move.w Alien_Y(a1),d1 ; get last y pos of alien
  606. btst.b #Alien_Dying,Alien_Mode(a1) ; has alien already started to snuff it
  607. * bne.s Dont_Move_While_Dying
  608. bne dont_move_while_dying
  609. .
  610. move.w Screen_X_Position,d2
  611. move.w Screen_Y_Position,d3
  612. ********************
  613. *no boundary check *
  614. ********************
  615. *bra.s no_boundary_check
  616. no_boundary_check
  617. move.l a4,Last_Alien_in_List
  618. bsr Process_Character_Animation ; spawning etc
  619. move.l Last_Alien_in_List,a4
  620. btst.b #Alien_Dead,Alien_Mode(a1) ; remove if finally dead
  621. bne Remove_Alien
  622. move.w d0,Alien_X(a1) ; store new X
  623. move.w d1,Alien_Y(a1) ; store new Y
  624. Dont_Move_While_Dying
  625. Movement_Done
  626. *bra.s check_screen_visability
  627. ; Test for alien returning to map
  628. ; NOTE: Only testing x for now, this needs to be updated for
  629. ; maps which vary in the y axis
  630. move.w Screen_X_Position,d2
  631. sub.w #16*16,d2 ; 4 words
  632. cmp.w d2,d0
  633. blt.s out_of_screen_range
  634. add.w #16*16+320+16*16,d2 ; map window
  635. cmp.w d2,d0
  636. bgt.s out_of_screen_range
  637. bra.s check_screen_visability
  638. out_of_screen_range
  639. tst.l Alien_map_pointer(a1) ; has entry in map
  640. beq.s no_erase_from_map2 ; no then no bother
  641. bclr.b #ALIEN_BUSY,([Alien_map_pointer,a1]) ; clear busy flag
  642. bra.s remove_alien ; and remove alien
  643. no_erase_from_map2
  644. check_screen_visability
  645. move.w Screen_X_Position,d2
  646. move.w Screen_Y_Position,d3
  647. sub.w #48,d2 ; so it scrolls on smooth
  648. sub.w #0,d3 ; for use later
  649. cmp.w d2,d0
  650. blt.s NotVisable
  651. cmp.w d3,d1
  652. blt.s NotVisable
  653. add.w #320+48,d2 ; window width
  654. add.w #256-16,d3 ; for use later
  655. cmp.w d2,d0
  656. bgt.s NotVisable
  657. cmp.w d3,d1
  658. bgt.s NotVisable
  659. sub.w Screen_X_Position,d0 ; get a screen pos
  660. add.w #15,d0 ; NASTY
  661. sub.w current_scroll_pixel_offset,d0 ; SEE GLEN
  662. *sub.w Screen_Y_Position,d1 ; for the aliens
  663. bsr Place_Alien ; draw in the alien
  664. bra.s Visable
  665. NotVisable
  666. btst.b #Alien_OffScreen,Alien_Mode(a1) ; if alien should go now
  667. beq.s keep_processing
  668. tst.l Alien_map_pointer(a1) ; pos in map
  669. beq.s keep_in_map
  670. clr.b ([Alien_map_pointer,a1])
  671. keep_in_map
  672. bra.s Remove_Alien ; best remove it while it
  673. keep_processing
  674. Visable
  675. move.l a1,(a4)+ ; put alien back in
  676. bra.s Alien_Remains
  677. Remove_Alien
  678. no_erase_from_map
  679. alien_can_come_back_later
  680. move.l available_pointer,a6
  681. move.l a1,(a6)+
  682. move.l a6,available_pointer
  683. Alien_Remains
  684. addq.l #$4,a0 ; next alien post-box
  685. bra New_Bob
  686. aliens_processed
  687. move.l #$ffffffff,(a4) ; end of alien list marker
  688. move.l a4,Last_Alien_In_List ; its only polite really
  689. move.l #$ffffffff,(a3) ; end of aliens
  690. move.l #$ffffffff,(a5) ; end of nosaves
  691. move.l #$dff000,a6
  692. move.l Enemy_List,a0
  693. move.l Enemy_List_Buffer,Enemy_List ; replace list pointer
  694. move.l a0,Enemy_List_Buffer ; can be buffer next time
  695. RTS
  696. Add_An_Enemy
  697. ; Send Data d0 - x pos
  698. ; d1 - y pos
  699. ; d2 - character - corrupt
  700. ; d3 - Special Data
  701. ; Bit 15 in d2 set = Custom pattern in d4
  702. ; Then I will do the rest
  703. movem.l a0-a1,-(sp)
  704. clr.l Add_Enemy_Pointer ; for post-add manipulation
  705. move.l Available_Pointer,a0
  706. cmp.l #Available_List,a0 ; physically not possible to
  707. beq Cant_Add_Alien ; hold more data
  708. move.l -(a0),a1
  709. move.l a0,Available_Pointer ; save new stack pointer
  710. move.l Last_Alien_in_List,a0 ;
  711. move.l a1,(a0)+ ; store new alien pointer
  712. move.l a0,Last_Alien_In_List ; store new list pointer
  713. move.l #$ffffffff,(a0) ; put new tail marker
  714. btst.l #15,d2 ; custom pattern to set
  715. beq.s no_custom_pattern ;
  716. bclr.l #15,d2
  717. move.l d4,Alien_Flight(a1) ; custom pattern address
  718. move.w d2,Alien_Number(a1) ; character type
  719. mulu.w #Character_Control_Size,d2
  720. move.l #Character_Control_Block,a0
  721. add.l d2,a0
  722. move.l Character_Standard(a0),d2 ; default animation
  723. bra.s custom_was_set
  724. no_custom_pattern
  725. move.w d2,Alien_Number(a1) ; character type
  726. mulu.w #Character_Control_Size,d2
  727. move.l #Character_Control_Block,a0
  728. add.l d2,a0
  729. move.l Character_Standard(a0),d2 ; default animation
  730. move.l d2,Alien_Flight(a1)
  731. custom_was_set
  732. move.w Character_Flags(a0),d2 ; anim flags
  733. move.w d2,Alien_Mode(a1)
  734. move.b d3,Alien_Data+1(a1) ; only a byte
  735. *lsr.w #8,d3 ; get top byte
  736. *move.b d3,Alien_Mode2(a1) ; use as new mode bits
  737. clr.w alien_fall_velocity(a1)
  738. move.w #1,alien_in_air(a1)
  739. clr.w Alien_GFX_Number(a1)
  740. clr.w Frame_Number(a1)
  741. clr.w Frame_Counter(a1)
  742. clr.w Repeat_Counter(a1)
  743. move.w d0,Alien_X(a1)
  744. move.w d1,Alien_Y(a1)
  745. move.w #SET,Animation_Mode(a1)
  746. clr.w Animation_LoFrame(a1)
  747. clr.w Animation_HiFrame(a1)
  748. clr.w Animation_Speed(a1)
  749. clr.w Animation_Flags(a1)
  750. move.w #1,Alien_Hits(a1) ; needs work
  751. move.l alien_map_position,alien_map_pointer(a1)
  752. clr.l Alien_Slave_Pointer(a1) ; aliens under control
  753. move.l a1,add_enemy_pointer
  754. Cant_Add_Alien
  755. movem.l (sp)+,a0-a1
  756. rts
  757. add_enemy_pointer dc.l 0
  758. alien_map_position dc.l 0
  759. Place_Alien
  760. move.w Alien_GFX_Number(a1),d6 ; separate to char number
  761. btst.b #Alien_Left,Alien_Mode2(a1)
  762. beq.s walking_right
  763. addq.w #1,d6
  764. walking_right
  765. mulu.w #Graphics_Size,d6
  766. move.l a2,d5 ; alien species start
  767. add.l d6,d5 ; add offset
  768. move.l d5,Store_G_Pointer(a1) ; store species pointer
  769. move.l Alien_Graphics(a2,d6.w),d2 ; base of graphics
  770. move.l Alien_Mask(a2,d6.w),d3 ; mask
  771. move.l Alien_Frame_Size(a2,d6.w),d7
  772. mulu.w Frame_Number(a1),d7 ;
  773. add.l d7,d2 ; get graph pos
  774. add.l d7,d3
  775. Blit_Graphics
  776. MOVE.W D0,D6
  777. AND.W #$000F,D0
  778. AND.w #$FFF0,D6
  779. ASR.w #3,D6
  780. ext.l d6 ; could be negative so make long
  781. ROR.W #4,D0
  782. move.w d0,d7
  783. OR.W #$0fca,d0
  784. swap d0
  785. move.w d7,d0
  786. mulu.w #BYTES_PER_ROW,d1
  787. SORT_OUT_GRAPHICS
  788. ADD.l d1,D6
  789. add.l scroll_plane_position,d6
  790. MOVE.L d6,Store_Destination(a1) ; destination
  791. move.l d3,Store_Mask(a1) ; alien mask
  792. move.l d0,Store_Shift(a1) ; shift bits
  793. move.l a1,Store_Pointer(a1) ; alien pointer
  794. move.l d2,Store_Graphics(a1) ; graphics pointer
  795. ***
  796. *** Use this for separating on screen lists ? objects/aliens etc.
  797. ***
  798. btst.b #No_Saveback,Alien_Mode(a1) ; is it a friendly or ex
  799. bne.s dont_save
  800. move.l a1,(a3)+
  801. bra.s saved_as_required
  802. dont_save
  803. move.l a1,(a5)+
  804. saved_as_required
  805. rts
  806. Process_Character_Animation
  807. move.l a2,-(sp) ; need this
  808. move.l Alien_Flight(a1),a2
  809. ** Do frame Animation
  810. cmp.w #FLIP,Animation_Mode(a1) ; is it flip frame?
  811. bne.s no_flip_frame
  812. tst.w Frame_Counter(a1)
  813. beq.s reset_frame_counter
  814. subq.w #1,Frame_Counter(a1)
  815. bra.s Done_flip_Frame
  816. reset_frame_counter
  817. move.w Animation_Speed(a1),d4
  818. move.w d4,Frame_Counter(a1)
  819. move.w Frame_Number(a1),d4
  820. tst.w Animation_Flags(a1) ; going up or down?
  821. bne.s flip_down
  822. addq.w #1,d4
  823. cmp.w Animation_HiFrame(a1),d4 ; reached topframe?
  824. bne.s set_new_frame
  825. move.w #-1,Animation_Flags(a1) ; set down frame
  826. bra.s set_new_frame
  827. flip_down
  828. subq.w #1,d4
  829. cmp.w Animation_LoFrame(a1),d4 ; reached lowframe?
  830. bne.s set_new_frame
  831. move.w #0,Animation_Flags(a1)
  832. set_new_frame
  833. move.w d4,Frame_Number(a1)
  834. bra.s done_flip_frame
  835. no_flip_frame
  836. cmp.w #CYCLE,Animation_Mode(a1) ; is it cycle frame?
  837. bne.s no_cycle_frame
  838. tst.w Frame_Counter(a1)
  839. beq.s reset_CYCLE_frame
  840. subq.w #1,Frame_Counter(a1)
  841. bra.s Done_cycle_Frame
  842. reset_CYCLE_frame
  843. move.w Animation_Speed(a1),d4
  844. move.w d4,Frame_Counter(a1)
  845. move.w Frame_Number(a1),d4
  846. cmp.w Animation_HiFrame(a1),d4
  847. bne.s cycle_frame_ok
  848. move.w Animation_LoFrame(a1),d4
  849. bra.s set_cycle_frame
  850. cycle_frame_ok
  851. addq.w #1,d4
  852. set_cycle_frame
  853. move.w d4,Frame_Number(a1)
  854. no_cycle_frame
  855. done_flip_frame
  856. done_cycle_frame
  857. no_set_frame
  858. tst.w Repeat_Counter(a1) ; is movement in repeat?
  859. beq.s no_repeat_mode
  860. move.w Repeat_X(a1),d4
  861. move.w Repeat_Y(a1),d5
  862. bsr Add_Object_Deltas
  863. subq.w #1,Repeat_Counter(a1) ; decrement the counter
  864. bra repeat_increments
  865. no_repeat_mode
  866. check_command
  867. cmp.w #FIRST_COMMAND,(a2)
  868. blt.s no_new_command
  869. cmp.w #LAST_COMMAND,(a2)
  870. bgt.s no_new_command
  871. move.w (a2)+,d4
  872. sub.w #FIRST_COMMAND,d4
  873. move.l #Command_Pointers,a6
  874. move.l (a6,d4.w*4),a6
  875. jsr (a6)
  876. bra.s check_command ; DANGER of infinite loop
  877. no_new_command
  878. ******************
  879. * Move Character *
  880. ******************
  881. tst.w Repeat_Counter(a1) ; in case was set this time
  882. bne.s repeat_increments
  883. move.w (a2)+,d4
  884. move.w (a2)+,d5
  885. move.w d4,Repeat_X(a1) ; for player on object
  886. move.w d5,Repeat_Y(a1)
  887. bsr Add_Object_Deltas
  888. cmp.w #BaseBall_Character,Alien_Number(a1)
  889. bne.s repeat_increments
  890. repeat_increments
  891. cmp.w #BaseBall_Character,Alien_Number(a1)
  892. bne.s dont_do_ball
  893. btst.b #Alien_Hit,Alien_Mode(a1)
  894. bne.s dont_do_ball
  895. movem.l d3-d6/a0/a1/a3/a4,-(sp)
  896. move.w Alien_Number(a1),d2 ; character type
  897. mulu.w #Character_Control_Size,d2
  898. move.l #Character_Control_Block,a0
  899. add.l d2,a0
  900. bsr BaseBall_Collision ; a2 gets set if ball hits block
  901. movem.l (sp)+,d3-d6/a0/a1/a3/a4
  902. dont_do_ball
  903. btst.b #Ground_Collision,Alien_mode(a1)
  904. beq.s animation_done
  905. movem.l d3-d6/a0-a4,-(sp)
  906. move.w Alien_Number(a1),d2 ; character type
  907. mulu.w #Character_Control_Size,d2
  908. move.l #Character_Control_Block,a0
  909. add.l d2,a0
  910. bsr alien_ground_collision
  911. movem.l (sp)+,d3-d6/a0-a4
  912. animation_done
  913. move.l a2,Alien_Flight(a1) ; store new pointer
  914. move.l (sp)+,a2 ; restore
  915. rts
  916. Add_Object_Deltas
  917. ; Co-ords in d0,d1, alien pointer in a1
  918. ; delta-X in d4, delta-Y in d5
  919. btst.b #Alien_Left,Alien_Mode2(a1) ; is it going left
  920. beq.s delta_x_going_right
  921. neg.w d4 ; could add to a few more
  922. delta_x_going_right
  923. add.w d4,d0 ; add x delta to co-ord
  924. add.w d5,d1 ; add y delta to co-ord
  925. btst.b #Alien_Master,Alien_Mode2(a1)
  926. beq.s no_master_required
  927. movem.l a1,-(sp)
  928. slave_loop
  929. tst.l Alien_Slave_Pointer(a1)
  930. beq.s slaves_done
  931. move.l Alien_Slave_Pointer(a1),a1
  932. add.w d4,Alien_X(a1)
  933. add.w d5,Alien_Y(a1)
  934. bra.s slave_loop
  935. slaves_done
  936. movem.l (sp)+,a1
  937. no_master_required
  938. rts
  939. Command_Pointers
  940. dc.l Restart_Command
  941. dc.l Flip_Command
  942. dc.l Cycle_Command
  943. dc.l Set_Command
  944. dc.l Repeat_Command
  945. dc.l Spawn_Command
  946. dc.l Mode_Set_Command
  947. dc.l Mode_Clear_Command
  948. dc.l GFX_Command
  949. dc.l spring_block ; glens code
  950. dc.l freeze_command
  951. dc.l dog_talk
  952. dc.l Cast_Master_Slaves
  953. dc.l command_slaves_command
  954. dc.l new_anim_command
  955. dc.l activate_fruit_block ; glens code
  956. Restart_Command
  957. move.l (a2),a2 ; get address of start
  958. rts
  959. Flip_Command
  960. move.w #FLIP,Animation_Mode(a1)
  961. bra.s flip_params
  962. Cycle_Command
  963. move.w #CYCLE,Animation_Mode(a1)
  964. flip_params
  965. move.w (a2)+,d5
  966. move.w d5,Animation_LoFrame(a1)
  967. move.w d5,Frame_Number(a1)
  968. move.w (a2)+,Animation_HiFrame(a1)
  969. move.w (a2)+,d4
  970. move.w d4,Animation_Speed(a1)
  971. move.w d4,Frame_Counter(a1)
  972. clr.w Animation_Flags(a1)
  973. rts
  974. SET_command
  975. move.w #SET,Animation_Mode(a1) ; "SET" keyword
  976. move.w (a2)+,Frame_Number(a1) ; Frame to set
  977. rts
  978. Mode_Set_Command
  979. move.w (a2)+,d4 ; get mode bits
  980. or.w d4,Alien_Mode(a1) ; and then set them
  981. rts
  982. Mode_Clear_Command
  983. move.w (a2)+,d4 ; get mode bits
  984. not.w d4 ; invert the bits
  985. and.w d4,Alien_Mode(a1) ; and then clear them
  986. rts
  987. GFX_Command
  988. move.w (a2)+,d4 ; get new graphics
  989. move.w d4,Alien_GFX_Number(a1) ; and set it
  990. rts
  991. Spawn_command
  992. move.l a3,-(sp)
  993. move.l (a2)+,a3 ; list of aliens to spawn
  994. bsr spawn_preset_enemies ; oh no loops
  995. move.l (sp)+,a3 ; restore ol faithful
  996. rts
  997. Repeat_command
  998. move.w (a2)+,d4
  999. move.w d4,Repeat_X(a1)
  1000. move.w (a2)+,d5
  1001. move.w d5,Repeat_Y(a1)
  1002. cmp.w #DATA,(a2) ; is it special data
  1003. bne.s not_special_data
  1004. move.w Alien_Data(a1),Repeat_Counter(a1)
  1005. addq.l #2,a2 ; add on index
  1006. bra.s special_data
  1007. not_special_data
  1008. move.w (a2)+,Repeat_Counter(a1)
  1009. special_data
  1010. bsr Add_Object_Deltas
  1011. rts
  1012. freeze_command
  1013. move.b player_control_bits,d4
  1014. bchg #stuck_flag,d4
  1015. move.b d4,player_control_bits
  1016. rts
  1017. dog_talk
  1018. move.l (a2)+,d4 ; talk pointer
  1019. bsr character_speak
  1020. rts
  1021. Cast_Master_Slaves
  1022. move.l a3,-(sp)
  1023. move.l (a2)+,a3 ; list of aliens to spawn
  1024. bsr create_master_slave_chain ; oh no loops
  1025. move.l (sp)+,a3 ; restore ol faithful
  1026. rts
  1027. Command_Slaves_Command
  1028. move.w (a2)+,d4
  1029. sub.w #FIRST_COMMAND,d4
  1030. move.l #Command_Pointers,a6
  1031. move.l (a6,d4.w*4),a6
  1032. move.l Alien_Slave_Pointer(a1),d4
  1033. tst.l d4 ; check before entering loop
  1034. beq.s no_slaves_ooh
  1035. movem.l a1/d0-d1,-(sp)
  1036. move.l d4,a1 ; for first pass
  1037. slave_command_loop
  1038. tst.l a1
  1039. beq.s done_slave_commands ; should only call
  1040. ; routines which
  1041. ; set structure data! ie. a1
  1042. move.l a2,-(sp) ; save master anim pointer
  1043. jsr (a6) ; call anim routine
  1044. move.l a2,d3 ; save pointer to next
  1045. ; command for master
  1046. move.l (sp)+,a2 ; restore pointer for next
  1047. move.l Alien_Slave_Pointer(a1),a1 ; for next loop
  1048. bra.s slave_command_loop
  1049. done_slave_commands
  1050. move.l d3,a2
  1051. movem.l (sp)+,a1/d0-d1
  1052. no_slaves_ooh
  1053. rts
  1054. ; SLAVE ONLY commands
  1055. new_anim_command
  1056. move.l (a2)+,Alien_Flight(a1)
  1057. rts
  1058. Store_NoSaves
  1059. move.l CLEAR_LIST_BUFFER,a2
  1060. move.l CLEAR_AREA_BUFFER,a5 ; objects which clear
  1061. Store_Next_Bob
  1062. cmp.l #$ffffffff,(a2) ; last alien to save?
  1063. beq.s Aliens_stored ; yes then exit
  1064. move.l (a2)+,a4
  1065. move.l Store_G_Pointer(a4),a1
  1066. move.l Store_Destination(a4),a0
  1067. btst.b #Alien_Burn,Alien_Mode(a4) ; leave it in scroll?
  1068. beq.s do_clear_save
  1069. btst.b #Alien_Burn2,Alien_Mode(a4)
  1070. bne.s ok_really_burned
  1071. bset.b #Alien_Burn2,Alien_Mode(a4)
  1072. bra.s store_next_bob
  1073. ok_really_burned
  1074. bset.b #Alien_Dead,Alien_mode(a4) ; set dead
  1075. bra.s store_next_bob ; dont erase it
  1076. do_clear_save
  1077. move.l a0,(a5)+ ; screen memory pointer
  1078. move.l Store_Mask(a4),(a5)+ ; graphics memory pointer
  1079. move.l a1,(a5)+ ; graphics struct pointer
  1080. move.l Store_Shift(a4),d0 ; get shift
  1081. move.w d0,(a5)+ ; only want pure shift
  1082. bra.s store_next_bob
  1083. aliens_stored
  1084. move.l #$ffffffff,(a5) ; end the clear list
  1085. rts
  1086. SaveBack_Enemies
  1087. move.l SAVEBACK_BUFFER,d5 ; an address count of saveback graphics
  1088. move.l OLDBOB_BUFFER,a2
  1089. move.l REPLACE_AREA_BUFFER,a3 ; objects which saveback
  1090. PreSaveSetup
  1091. BTST #DMAB_BLTDONE-8,DMACONR(a6)
  1092. BNE.s PreSaveSetup
  1093. move.l #-1,BLTAFWM(a6) ; all data stored
  1094. clr.w BLTDMOD(a6) ; to a buffer
  1095. MOVE.l #$09f00000,BLTCON0(a6) ; straight D=A blit
  1096. Save_Next_Bob
  1097. cmp.l #$ffffffff,(a2) ; last alien to save?
  1098. beq Aliens_Saved ; yes then exit
  1099. move.l (a2)+,a4
  1100. move.l Store_G_Pointer(a4),a1
  1101. move.l Store_Destination(a4),a0
  1102. * Save parameters in replace list first
  1103. save_required
  1104. move.l a0,(a3)+ ; screen memory pointer
  1105. move.l d5,(a3)+ ; graphics memory pointer
  1106. move.l a1,(a3)+ ; graphics struct pointer
  1107. Waitforlastsave
  1108. BTST #DMAB_BLTDONE-8,DMACONR(a6)
  1109. BNE.s Waitforlastsave
  1110. move.w Alien_Mod(a1),BLTAMOD(a6) ; copying from the screen
  1111. move.l Alien_Frame_Size(a1),d2 ;
  1112. move.w Alien_Height(a1),d3 ;
  1113. add.w d3,d2 ; add extra byte
  1114. add.w d3,d2 ; add extra byte for padding
  1115. move.w #4-1,d7 ; planes
  1116. save_plane_loop
  1117. saveP BTST #DMAB_BLTDONE-8,DMACONR(a6)
  1118. BNE.s saveP
  1119. MOVE.L a0,BLTAPTH(a6) ; a0 graphics on screen
  1120. MOVE.L d5,BLTDPTH(a6) ; d5 pointer to saveback mem
  1121. MOVE.W Alien_D_Blit(a1),BLTSIZE(a6)
  1122. add.l #BYTES_PER_ROW*SCROLL_HEIGHT,a0
  1123. add.l d2,d5
  1124. dbra d7,save_plane_loop
  1125. bra Save_Next_Bob
  1126. Aliens_Saved
  1127. move.l #$ffffffff,(a3) ; end the saveback list
  1128. rts
  1129. Draw_Enemies_In
  1130. move.l OLDBOB_BUFFER,a2 ; aliens draw at frame-2
  1131. bsr.s Draw_New_Bobs
  1132. rts
  1133. Draw_NoSaves
  1134. move.l CLEAR_LIST_BUFFER,a2
  1135. bsr.s Draw_New_Bobs
  1136. rts
  1137. Draw_New_Bobs
  1138. PreDrawSetup
  1139. BTST #DMAB_BLTDONE-8,DMACONR(a6)
  1140. BNE.s PreDrawSetup
  1141. move.l #$FFFF0000,BLTAFWM(a6) ; mask off last word
  1142. move.w #-2,BLTAMOD(a6)
  1143. move.w #-2,BLTBMOD(a6)
  1144. Draw_Next_Bob
  1145. cmp.l #$ffffffff,(a2) ; last alien to draw?
  1146. beq Aliens_Drawn ; yes then exit
  1147. move.l (a2)+,a4
  1148. move.l Store_G_Pointer(a4),a1
  1149. move.l Store_Destination(a4),a0
  1150. WaitforlastDraw
  1151. BTST #DMAB_BLTDONE-8,DMACONR(a6)
  1152. BNE.s WaitforlastDraw
  1153. move.w Alien_Mod(a1),BLTCMOD(a6)
  1154. move.w Alien_Mod(a1),BLTDMOD(a6)
  1155. MOVE.L Store_Mask(a4),d2
  1156. MOVE.L Store_Graphics(a4),d3
  1157. MOVE.l Store_Shift(a4),BLTCON0(a6)
  1158. move.w #4-1,d7 ; planes
  1159. enemy_plane_loop
  1160. DrawP BTST #DMAB_BLTDONE-8,DMACONR(a6)
  1161. BNE.s DrawP
  1162. MOVE.L d2,BLTAPTH(a6) ; mask
  1163. MOVE.L d3,BLTBPTH(a6) ; graphics
  1164. move.l a0,BLTCPTH(a6) ; screen address
  1165. MOVE.L a0,BLTDPTH(a6) ; screen address
  1166. MOVE.W Alien_D_Blit(a1),BLTSIZE(a6)
  1167. add.l #BYTES_PER_ROW*SCROLL_HEIGHT,a0
  1168. add.l Alien_Plane_Size(a1),d3
  1169. dbra d7,enemy_plane_loop
  1170. bra Draw_Next_Bob
  1171. Aliens_Drawn
  1172. rts