alien_routines.s 35 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732
  1. *---------------------GLENS ALIEN ROUTINES-------------------*
  2. ************************************************
  3. ****** SETUP ALIEN POINTERS ******
  4. ************************************************
  5. Setup_Alien_Pointers
  6. move.l #alien_pointers,a0
  7. move.l #alien_structures,a1
  8. move.w #MAX_ALIENS-1,d0
  9. assign_alien_mem
  10. move.l a1,(a0)+
  11. add.l #alien_struct_size,a1
  12. dbra d0,assign_alien_mem
  13. move.l #$ffffffff,alien_draw_structures
  14. move.l #$ffffffff,alien_draw_structures_buff
  15. move.l #$ffffffff,pri_alien_draw_structures
  16. move.l #$ffffffff,pri_alien_draw_structures_buff
  17. move.l #alien_draw_structures,alien_draw_ptr
  18. move.l #alien_draw_structures_buff,alien_draw_ptr_buff
  19. move.l #pri_alien_draw_structures,pri_alien_draw_ptr
  20. move.l #pri_alien_draw_structures_buff,pri_alien_draw_ptr_buff
  21. move.l #$ffffffff,active_alien_pointers
  22. move.l #alien_pointers,current_add_alien_ptr
  23. move.l #active_alien_pointers,current_alien_list_ptr
  24. rts
  25. ************************************************
  26. ****** BUFFER ALIEN LISTS ******
  27. ************************************************
  28. Buffer_Alien_Lists
  29. move.l alien_draw_ptr,d0
  30. move.l alien_draw_ptr_buff,alien_draw_ptr
  31. move.l d0,alien_draw_ptr_buff
  32. move.l pri_alien_draw_ptr,d0
  33. move.l pri_alien_draw_ptr_buff,pri_alien_draw_ptr
  34. move.l d0,pri_alien_draw_ptr_buff
  35. rts
  36. ************************************************
  37. ****** DRAW CURRENT ALIEN LIST ******
  38. ************************************************
  39. Draw_Current_Alien_List
  40. move.w #BLITTER_NASTY+$8000,dmacon(a6)
  41. move.l alien_draw_ptr,a0
  42. bsr Split_Draw_Aliens
  43. move.l pri_alien_draw_ptr,a0
  44. bsr Split_Draw_Aliens
  45. move.w #BLITTER_NASTY,dmacon(a6)
  46. rts
  47. ************************************************
  48. ****** SPLIT DRAW ALIENS ******
  49. ************************************************
  50. Split_Draw_Aliens
  51. *send list pointer in a0
  52. *Will not require tests to see if can draw on screen as alien
  53. *will not be in list if not on screen
  54. blits_not_fin
  55. btst #14,dmaconr(a6)
  56. bne.s blits_not_fin
  57. move.l #$ffff0000,bltafwm(a6)
  58. move.w #-2,bltamod(a6)
  59. move.w #-2,bltbmod(a6)
  60. draw_aliens_loop
  61. cmp.l #$ffffffff,(a0)
  62. beq finished_drawing_aliens
  63. move.l current_alien_draw_position,a3
  64. move.l current_alien_split_draw_position,a4
  65. move.l alien_struct_ptr(a0),a1 ;pointer to alien struct
  66. move.w alien_x(a1),d0
  67. sub.w scroll_x_position,d0
  68. add.w alien_shift,d0
  69. move.w d0,d1
  70. andi.w #$fff0,d0
  71. asr.w #3,d0
  72. ext.l d0
  73. add.l d0,a3 ;x position calc
  74. add.l d0,a4
  75. andi.w #$f,d1 ;calc shift
  76. ror.w #4,d1
  77. move.w d1,d0
  78. or.w #$FCA,d0
  79. swap d0
  80. move.w d1,d0
  81. move.w alien_y(a1),d1
  82. sub.w scroll_y_position,d1
  83. move.w d1,d7
  84. muls #BPR,d1
  85. add.l d1,a3 ;y position
  86. move.l a3,alien_scr_pos(a0) ;store for later
  87. move.l alien_type_ptr(a1),a2 ;reference
  88. *----test to see if alien over split point---------------
  89. move.w split_position,d2
  90. move.w d7,d1 ;alien y
  91. cmp.w d2,d1
  92. bge alien_not_split_but_below_split
  93. *alien is below split line
  94. add.w alien_y_size(a2),d1
  95. cmp.w d2,d1
  96. ble alien_not_split
  97. *--------------------Code if alien is split---------------------
  98. sub.w d7,d2 ;portion above split
  99. move.w alien_y_size(a2),d1
  100. sub.w d2,d1 ;remaining height
  101. move.w #1,alien_split(a0)
  102. move.w alien_x_words(a2),d7
  103. asl.w #6,d2
  104. add.w d7,d2
  105. move.w d2,alien_draw_height(a0) ;blit size 1
  106. asl.w #6,d1
  107. add.w d7,d1
  108. move.w d1,alien_draw_height2(a0) ;blit size 2
  109. move.l a4,alien_split_scr(a0)
  110. *d1 and d2 are blit sizes for the two blits
  111. btst.b #DIRECTION_ALIEN,alien_type_flags(a2)
  112. beq.s not_a_directional_alien
  113. moveq #0,d7
  114. move.w alien_direction(a1),d7
  115. asl #2,d7
  116. move.l alien_mask(a2),a5
  117. move.l (a5,d7),d6
  118. move.l alien_graphics(a2),a5
  119. move.l (a5,d7),a5
  120. bra.s finished_getting_graphics
  121. not_a_directional_alien
  122. move.l alien_graphics(a2),a5
  123. move.l alien_mask(a2),d6
  124. finished_getting_graphics
  125. move.w alien_draw_frame(a0),d7
  126. btst #7,d7 ;alien hit
  127. beq.s alien_not_split_hit
  128. bclr #7,d7
  129. mulu alien_frame_size(a2),d7
  130. move.l d6,a5
  131. add.l d7,d6
  132. move.l d6,a5
  133. moveq #0,d7 ;no inc for graphics
  134. bra.s get_on_with_split_blit
  135. alien_not_split_hit
  136. mulu alien_frame_size(a2),d7
  137. add.l d7,a5
  138. add.l d7,d6
  139. moveq #0,d7
  140. move.w alien_plane_size(a2),d7
  141. get_on_with_split_blit
  142. *assume blit a pointer will be pointing to next part of alien
  143. *graphics and mask - therefore dont re-init
  144. move.l d0,bltcon0(a6) ;shifts etc
  145. move.l a3,bltcpth(a6) ;scr pos
  146. move.l a3,bltdpth(a6) ;dest
  147. move.l a5,bltbpth(a6)
  148. move.l d6,bltapth(a6)
  149. move.w alien_mod(a2),bltcmod(a6)
  150. move.w alien_mod(a2),bltdmod(a6)
  151. move.w d2,bltsize(a6)
  152. wait_for_alien_to_draw_p1_part1
  153. btst #14,dmaconr(a6)
  154. bne.s wait_for_alien_to_draw_p1_part1
  155. move.l a4,bltcpth(a6) ;scr pos
  156. move.l a4,bltdpth(a6) ;dest
  157. move.w d1,bltsize(a6)
  158. wait_for_alien_to_draw_p1_part2
  159. btst #14,dmaconr(a6)
  160. bne.s wait_for_alien_to_draw_p1_part2
  161. add.l d7,a5
  162. add.l #PLANE_INC,a3
  163. add.l #PLANE_INC,a4
  164. move.l a3,bltcpth(a6) ;scr pos
  165. move.l a3,bltdpth(a6) ;dest
  166. move.l a5,bltbpth(a6)
  167. move.l d6,bltapth(a6)
  168. move.w d2,bltsize(a6)
  169. wait_for_alien_to_draw_p2_part1
  170. btst #14,dmaconr(a6)
  171. bne.s wait_for_alien_to_draw_p2_part1
  172. move.l a4,bltcpth(a6) ;scr pos
  173. move.l a4,bltdpth(a6) ;dest
  174. move.w d1,bltsize(a6)
  175. wait_for_alien_to_draw_p2_part2
  176. btst #14,dmaconr(a6)
  177. bne.s wait_for_alien_to_draw_p2_part2
  178. add.l d7,a5
  179. add.l #PLANE_INC,a3
  180. add.l #PLANE_INC,a4
  181. move.l a3,bltcpth(a6) ;scr pos
  182. move.l a3,bltdpth(a6) ;dest
  183. move.l a5,bltbpth(a6)
  184. move.l d6,bltapth(a6)
  185. move.w d2,bltsize(a6)
  186. wait_for_alien_to_draw_p3_part1
  187. btst #14,dmaconr(a6)
  188. bne.s wait_for_alien_to_draw_p3_part1
  189. move.l a4,bltcpth(a6) ;scr pos
  190. move.l a4,bltdpth(a6) ;dest
  191. move.w d1,bltsize(a6)
  192. wait_for_alien_to_draw_p3_part2
  193. btst #14,dmaconr(a6)
  194. bne.s wait_for_alien_to_draw_p3_part2
  195. add.l d7,a5
  196. add.l #PLANE_INC,a3
  197. add.l #PLANE_INC,a4
  198. move.l a3,bltcpth(a6) ;scr pos
  199. move.l a3,bltdpth(a6) ;dest
  200. move.l a5,bltbpth(a6)
  201. move.l d6,bltapth(a6)
  202. move.w d2,bltsize(a6)
  203. wait_for_alien_to_draw_p4_part1
  204. btst #14,dmaconr(a6)
  205. bne.s wait_for_alien_to_draw_p4_part1
  206. move.l a4,bltcpth(a6) ;scr pos
  207. move.l a4,bltdpth(a6) ;dest
  208. move.w d1,bltsize(a6)
  209. wait_for_alien_to_draw_p4_part2
  210. btst #14,dmaconr(a6)
  211. bne.s wait_for_alien_to_draw_p4_part2
  212. bra finished_drawing_single_alien
  213. *--------------------Code if alien not split--------------------
  214. alien_not_split_but_below_split
  215. sub.l #SCROLL_HEIGHT*BPR,a3
  216. move.l a3,alien_scr_pos(a0) ;store for later
  217. alien_not_split
  218. clr.w alien_split(a0)
  219. btst.b #DIRECTION_ALIEN,alien_type_flags(a2)
  220. beq.s not_a_directional_normal_alien
  221. moveq #0,d7
  222. move.w alien_direction(a1),d7
  223. asl #2,d7
  224. move.l alien_mask(a2),a4
  225. move.l (a4,d7),d6
  226. move.l alien_graphics(a2),a4
  227. move.l (a4,d7),a4
  228. bra.s finished_getting_normal_graphics
  229. not_a_directional_normal_alien
  230. move.l alien_graphics(a2),a4
  231. move.l alien_mask(a2),d6
  232. finished_getting_normal_graphics
  233. move.w alien_draw_frame(a0),d7
  234. btst #7,d7
  235. beq.s alien_not_hit_normal
  236. bclr #7,d7
  237. mulu alien_frame_size(a2),d7
  238. add.l d7,d6
  239. move.l d6,a4
  240. moveq #0,d7
  241. bra.s get_on_with_normal_blit
  242. alien_not_hit_normal
  243. mulu alien_frame_size(a2),d7
  244. add.l d7,a4
  245. add.l d7,d6
  246. move.w alien_plane_size(a2),d7
  247. get_on_with_normal_blit
  248. move.l d0,bltcon0(a6) ;shifts etc
  249. move.l a3,bltcpth(a6) ;scr pos
  250. move.l a3,bltdpth(a6) ;dest
  251. move.l a4,bltbpth(a6)
  252. move.l d6,bltapth(a6)
  253. move.w alien_mod(a2),bltcmod(a6)
  254. move.w alien_mod(a2),bltdmod(a6)
  255. move.w alien_blit_size(a2),bltsize(a6)
  256. wait_for_alien_to_draw_p1
  257. btst #14,dmaconr(a6)
  258. bne.s wait_for_alien_to_draw_p1
  259. add.l #PLANE_INC,a3 ;next plane
  260. add.l d7,a4 ;next bob plane
  261. move.l a3,bltcpth(a6) ;scr pos
  262. move.l a3,bltdpth(a6) ;dest
  263. move.l a4,bltbpth(a6)
  264. move.l d6,bltapth(a6)
  265. move.w alien_blit_size(a2),bltsize(a6)
  266. wait_for_alien_to_draw_p2
  267. btst #14,dmaconr(a6)
  268. bne.s wait_for_alien_to_draw_p2
  269. add.l #PLANE_INC,a3 ;next plane
  270. add.l d7,a4 ;next bob plane
  271. move.l a3,bltcpth(a6) ;scr pos
  272. move.l a3,bltdpth(a6) ;dest
  273. move.l a4,bltbpth(a6)
  274. move.l d6,bltapth(a6)
  275. move.w alien_blit_size(a2),bltsize(a6)
  276. wait_for_alien_to_draw_p3
  277. btst #14,dmaconr(a6)
  278. bne.s wait_for_alien_to_draw_p3
  279. add.l #PLANE_INC,a3 ;next plane
  280. add.l d7,a4 ;next bob plane
  281. move.l a3,bltcpth(a6) ;scr pos
  282. move.l a3,bltdpth(a6) ;dest
  283. move.l a4,bltbpth(a6)
  284. move.l d6,bltapth(a6)
  285. move.w alien_blit_size(a2),bltsize(a6)
  286. wait_for_alien_to_draw_p4
  287. btst #14,dmaconr(a6)
  288. bne.s wait_for_alien_to_draw_p4
  289. finished_drawing_single_alien
  290. *delete does not require struct pointer but only type struct ptr - so
  291. *write into the struct ptr (saves defining another one in the struct)
  292. move.l a2,alien_struct_ptr(a0)
  293. add.l #alien_draw_size,a0
  294. bra draw_aliens_loop
  295. finished_drawing_aliens
  296. rts
  297. alien_shift dc.w 0
  298. current_alien_draw_position dc.l 0
  299. current_alien_split_draw_position dc.l 0
  300. ************************************************
  301. ****** DELETE ALIEN LIST ******
  302. ************************************************
  303. Delete_Alien_List
  304. move.l alien_draw_ptr,a0
  305. bsr Delete_Split_Aliens
  306. move.l pri_alien_draw_ptr,a0
  307. bsr Delete_Split_Aliens
  308. rts
  309. ************************************************
  310. ****** DELETE SPLIT ALIENS ******
  311. ************************************************
  312. Delete_Split_Aliens
  313. *send list in a0
  314. *Copy bitmap from copyback scroll area over aliens
  315. delete_blits_not_fin
  316. btst #14,dmaconr(a6)
  317. bne.s delete_blits_not_fin
  318. move.l #$ffffffff,bltafwm(a6)
  319. move.l #$09f00000,bltcon0(a6)
  320. delete_aliens_loop
  321. cmp.l #$ffffffff,(a0)
  322. beq finished_deleting_aliens
  323. *--------------------->
  324. *the alien type struct is now contained in alien_struct_ptr
  325. *this is because delete does not need it and it may have been
  326. *grabbed by an alien that has been added
  327. move.l alien_struct_ptr(a0),a2
  328. *---------------------|
  329. move.l alien_scr_pos(a0),a3
  330. move.l a3,a5
  331. add.l add_size,a5 ;copy back position
  332. *----test to see if alien over split point---------------
  333. tst.w alien_split(a0)
  334. beq delete_alien_not_split
  335. move.w alien_draw_height(a0),d2 ;blit size 1
  336. move.w alien_draw_height2(a0),d1 ;blit size 1
  337. *--------------------Code if alien is split---------------------
  338. *d1 and d2 are blit sizes for the two blits
  339. move.l alien_split_scr(a0),a4
  340. move.l a4,d7
  341. add.l add_size,d7 ;copy back position
  342. move.l a3,bltdpth(a6) ;dest
  343. move.l a5,bltapth(a6)
  344. move.w alien_mod(a2),bltamod(a6)
  345. move.w alien_mod(a2),bltdmod(a6)
  346. move.w d2,bltsize(a6)
  347. wait_for_alien_to_delete_p1_part1
  348. btst #14,dmaconr(a6)
  349. bne.s wait_for_alien_to_delete_p1_part1
  350. move.l a4,bltdpth(a6) ;scr pos
  351. move.l d7,bltapth(a6) ;dest
  352. move.w d1,bltsize(a6)
  353. wait_for_alien_to_delete_p1_part2
  354. btst #14,dmaconr(a6)
  355. bne.s wait_for_alien_to_delete_p1_part2
  356. add.l #PLANE_INC,a3
  357. add.l #PLANE_INC,a4
  358. add.l #PLANE_INC,a5
  359. add.l #PLANE_INC,d7
  360. move.l a3,bltdpth(a6) ;dest
  361. move.l a5,bltapth(a6)
  362. move.w d2,bltsize(a6)
  363. wait_for_alien_to_delete_p2_part1
  364. btst #14,dmaconr(a6)
  365. bne.s wait_for_alien_to_delete_p2_part1
  366. move.l a4,bltdpth(a6) ;scr pos
  367. move.l d7,bltapth(a6) ;dest
  368. move.w d1,bltsize(a6)
  369. wait_for_alien_to_delete_p2_part2
  370. btst #14,dmaconr(a6)
  371. bne.s wait_for_alien_to_delete_p2_part2
  372. add.l #PLANE_INC,a3
  373. add.l #PLANE_INC,a4
  374. add.l #PLANE_INC,a5
  375. add.l #PLANE_INC,d7
  376. move.l a3,bltdpth(a6) ;dest
  377. move.l a5,bltapth(a6)
  378. move.w d2,bltsize(a6)
  379. wait_for_alien_to_delete_p3_part1
  380. btst #14,dmaconr(a6)
  381. bne.s wait_for_alien_to_delete_p3_part1
  382. move.l a4,bltdpth(a6) ;scr pos
  383. move.l d7,bltapth(a6) ;dest
  384. move.w d1,bltsize(a6)
  385. wait_for_alien_to_delete_p3_part2
  386. btst #14,dmaconr(a6)
  387. bne.s wait_for_alien_to_delete_p3_part2
  388. add.l #PLANE_INC,a3
  389. add.l #PLANE_INC,a4
  390. add.l #PLANE_INC,a5
  391. add.l #PLANE_INC,d7
  392. move.l a3,bltdpth(a6) ;dest
  393. move.l a5,bltapth(a6)
  394. move.w d2,bltsize(a6)
  395. wait_for_alien_to_delete_p4_part1
  396. btst #14,dmaconr(a6)
  397. bne.s wait_for_alien_to_delete_p4_part1
  398. move.l a4,bltdpth(a6) ;scr pos
  399. move.l d7,bltapth(a6) ;dest
  400. move.w d1,bltsize(a6)
  401. wait_for_alien_to_delete_p4_part2
  402. btst #14,dmaconr(a6)
  403. bne.s wait_for_alien_to_delete_p4_part2
  404. bra finished_deleting_single_alien
  405. *--------------------Code if alien not split--------------------
  406. delete_alien_not_split
  407. move.l a3,bltdpth(a6) ;dest
  408. move.l a5,bltapth(a6)
  409. move.w alien_mod(a2),bltamod(a6)
  410. move.w alien_mod(a2),bltdmod(a6)
  411. move.w alien_blit_size(a2),bltsize(a6)
  412. wait_for_alien_to_delete_p1
  413. btst #14,dmaconr(a6)
  414. bne.s wait_for_alien_to_delete_p1
  415. add.l #PLANE_INC,a3 ;next plane
  416. add.l #PLANE_INC,a5
  417. move.l a5,bltapth(a6) ;scr pos
  418. move.l a3,bltdpth(a6) ;dest
  419. move.w alien_blit_size(a2),bltsize(a6)
  420. wait_for_alien_to_delete_p2
  421. btst #14,dmaconr(a6)
  422. bne.s wait_for_alien_to_delete_p2
  423. add.l #PLANE_INC,a3 ;next plane
  424. add.l #PLANE_INC,a5
  425. move.l a5,bltapth(a6) ;scr pos
  426. move.l a3,bltdpth(a6) ;dest
  427. move.w alien_blit_size(a2),bltsize(a6)
  428. wait_for_alien_to_delete_p3
  429. btst #14,dmaconr(a6)
  430. bne.s wait_for_alien_to_delete_p3
  431. add.l #PLANE_INC,a3 ;next plane
  432. add.l #PLANE_INC,a5
  433. move.l a3,bltdpth(a6) ;scr pos
  434. move.l a5,bltapth(a6) ;dest
  435. move.w alien_blit_size(a2),bltsize(a6)
  436. wait_for_alien_to_delete_p4
  437. btst #14,dmaconr(a6)
  438. bne.s wait_for_alien_to_delete_p4
  439. finished_deleting_single_alien
  440. add.l #alien_draw_size,a0
  441. bra delete_aliens_loop
  442. finished_deleting_aliens
  443. rts
  444. ************************************************
  445. ****** ADD ALIEN TO LIST ******
  446. ************************************************
  447. Add_Alien_To_List
  448. *send x,y in d0 and d1
  449. *send type in d2
  450. *send in data in d3 - optional
  451. movem.l a0-a2,-(sp)
  452. move.l current_add_alien_ptr,a0
  453. cmp.l #$ffffffff,(a0)
  454. beq.s alien_list_full
  455. move.l (a0)+,a1
  456. move.l a0,current_add_alien_ptr
  457. move.w d0,alien_x(a1)
  458. move.w d1,alien_y(a1)
  459. clr.w alien_frame(a1)
  460. clr.w alien_flags(a1) ;clears alien_c_pad as well
  461. clr.l alien_map_pos(a1)
  462. move.l #Species_Table,a0
  463. ext.l d2
  464. asl #2,d2
  465. move.l (a0,d2.w),alien_type_ptr(a1)
  466. move.l alien_type_ptr(a1),a2
  467. move.l alien_pattern_ptr(a2),alien_pat_ptr(a1)
  468. move.w alien_frame_rate(a2),alien_frame_counter(a1)
  469. move.w alien_hit_count(a2),alien_hits(a1)
  470. move.w d3,alien_data(a1)
  471. move.l current_alien_list_ptr,a0
  472. move.l a1,(a0)+
  473. move.l #$ffffffff,(a0)
  474. move.l a0,current_alien_list_ptr
  475. movem.l (sp)+,a0-a2
  476. alien_list_full
  477. rts
  478. ************************************************
  479. ****** SIMPLE ADD ALIEN TO LIST ******
  480. ************************************************
  481. Simple_Add_Alien_To_List
  482. *send x,y in d0 and d1
  483. *send pointer in d2
  484. *d3 alien data is optional
  485. *no stack saves made
  486. move.l current_add_alien_ptr,a0
  487. cmp.l #$ffffffff,(a0)
  488. beq.s salien_list_full
  489. move.l (a0)+,a1
  490. move.l a0,current_add_alien_ptr
  491. move.w d0,alien_x(a1)
  492. move.w d1,alien_y(a1)
  493. clr.l alien_map_pos(a1) ;make non-map alien
  494. clr.b alien_work(a1) ;do we need this?
  495. clr.l alien_frame(a1) 'clears and flags & cpad as well
  496. move.w #4,alien_direction(a1) ;test
  497. move.l d2,alien_type_ptr(a1)
  498. move.l alien_type_ptr(a1),a2
  499. move.l alien_pattern_ptr(a2),alien_pat_ptr(a1)
  500. move.w alien_frame_rate(a2),alien_frame_counter(a1)
  501. move.w alien_hit_count(a2),alien_hits(a1)
  502. move.w d3,alien_data(a1)
  503. move.l current_alien_list_ptr,a0
  504. move.l a1,(a0)+
  505. move.l #$ffffffff,(a0)
  506. move.l a0,current_alien_list_ptr
  507. salien_list_full
  508. rts
  509. ************************************************
  510. ****** PROCESS ALIENS ******
  511. ************************************************
  512. Process_Aliens
  513. *Only a quick version just so can see aliens up and running
  514. move.l #active_alien_pointers,a0
  515. move.l alien_draw_ptr,a1
  516. move.l pri_alien_draw_ptr,a6
  517. move.l a0,a3
  518. process_loop
  519. cmp.l #$ffffffff,(a0)
  520. beq finished_processing_aliens
  521. move.l (a0),a2
  522. *Dont draw alien if out of screen
  523. move.w alien_x(a2),d0
  524. move.w alien_y(a2),d1
  525. sub.w scroll_x_position,d0
  526. sub.w scroll_y_position,d1
  527. move.l alien_type_ptr(a2),a4
  528. move.w alien_frame(a2),alien_draw_frame(a1)
  529. move.w alien_frame(a2),alien_draw_frame(a6)
  530. *-----------------Test Alien Flags----------------
  531. btst.b #ALIEN_HIT,alien_flags(a2)
  532. beq.s alien_not_hit
  533. btst.b #ALIEN_PRI,alien_type_flags(a4)
  534. beq.s using_norm_list
  535. bset.b #7,alien_draw_frame+1(a6)
  536. bra.s alien_not_hit
  537. using_norm_list
  538. bset.b #7,alien_draw_frame+1(a1)
  539. alien_not_hit
  540. *-----------------Update alien frame-------------
  541. tst alien_frame_rate(a4)
  542. bmi.s dont_update_alien_frame
  543. subq.w #1,alien_frame_counter(a2)
  544. bgt.s dont_update_alien_frame
  545. addq.w #1,alien_frame(a2)
  546. move.w alien_frame_rate(a4),alien_frame_counter(a2)
  547. move.w alien_number_frames(a4),d2
  548. cmp.w alien_frame(a2),d2
  549. bgt.s dont_update_alien_frame
  550. clr.w alien_frame(a2)
  551. dont_update_alien_frame
  552. *---
  553. *-----------------Process alien pattern-------------
  554. movem.l a3/a1,-(sp)
  555. move.l #Alien_Commands,a3
  556. move.l alien_pat_ptr(a2),a5
  557. process_alien_pattern_loop
  558. cmp.w #START_COMMANDS,(a5)
  559. bgt.s process_alien_command
  560. *else update alien position using x and y values
  561. move.w (a5)+,d2
  562. add.w d2,alien_x(a2)
  563. move.w (a5)+,d2
  564. add.w d2,alien_y(a2)
  565. bra.s done_alien_process
  566. process_alien_command
  567. moveq #0,d7
  568. move.w (a5)+,d7
  569. sub.w #OBJECT_SET_PAT,d7
  570. asl.w #2,d7
  571. move.l (a3,d7),a1
  572. jsr (a1)
  573. bra.s process_alien_pattern_loop
  574. done_alien_process
  575. movem.l (sp)+,a3/a1
  576. move.l a5,alien_pat_ptr(a2)
  577. btst.b #ALIEN_DEAD,alien_flags(a2)
  578. bne kill_off_alien
  579. *---------Only draw alien if on screen----------------
  580. btst.b #OFF_SCREEN_ALIEN,alien_type_flags(a4)
  581. beq.s dont_bother_checking_off_Screen
  582. cmp.w #-48-64,d0
  583. ble.s set_alien_map_bit
  584. cmp.w #320+64,d0
  585. bge.s set_alien_map_bit
  586. cmp.w #-48-64,d1
  587. ble.s set_alien_map_bit
  588. cmp.w #240+32+64,d1
  589. bge.s set_alien_map_bit
  590. bra.s dont_bother_checking_off_Screen
  591. set_alien_map_bit
  592. tst alien_map_pos(a2)
  593. beq.s see_if_alien_needs_to_call_anything
  594. move.l alien_map_pos(a2),a5
  595. bclr.b #ALIEN_BUSY,(a5)
  596. see_if_alien_needs_to_call_anything
  597. * Call routine for alien going out
  598. moveq #0,d7
  599. move.b alien_type_number(a4),d7
  600. asl.w #2,d7
  601. move.l #Alien_Out_Call_Table,a5
  602. move.l (a5,d7.w),d7
  603. beq.s remove_alien_from_list
  604. move.l d7,a5
  605. jsr (a5)
  606. bra.s remove_alien_from_list
  607. dont_bother_checking_off_Screen
  608. cmp.w #-48,d0
  609. ble.s dont_draw_alien
  610. cmp.w #320+32,d0
  611. bge.s dont_draw_alien
  612. cmp.w #-48,d1
  613. ble.s dont_draw_alien
  614. cmp.w #240+32,d1
  615. bge.s dont_draw_alien
  616. btst.b #ALIEN_PRI,alien_type_flags(a4)
  617. bne.s add_to_pri_list
  618. move.l a2,alien_struct_ptr(a1)
  619. add.l #alien_draw_size,a1
  620. bra.s dont_draw_alien
  621. add_to_pri_list
  622. move.l a2,alien_struct_ptr(a6)
  623. add.l #alien_draw_size,a6
  624. dont_draw_alien
  625. move.l a2,(a3)+ ;so will be processed next time round
  626. bra.s get_next_alien
  627. kill_off_alien
  628. tst.l alien_map_pos(a2)
  629. beq.s remove_alien_from_list ;alien not added via map
  630. move.l alien_map_pos(a2),a5
  631. clr.b (a5) ;never coming back
  632. remove_alien_from_list
  633. move.l current_add_alien_ptr,a5
  634. subq.l #4,a5
  635. move.l a2,(a5)
  636. btst.b #ATTACHED_ALIEN,alien_type_flags(a4)
  637. beq.s not_an_attached_alien
  638. move.l alien_work+4(a2),a4 ;kill any attached aliens
  639. cmp.l #0,a4 ;ensure alien still attached (must do cmp as move to an does not set flags)
  640. beq.s not_an_attached_alien
  641. bset.b #ALIEN_DEAD,alien_flags(a4)
  642. not_an_attached_alien
  643. move.l a5,current_add_alien_ptr
  644. get_next_alien
  645. clr.b alien_flags(a2)
  646. addq.l #4,a0
  647. bra process_loop
  648. finished_processing_aliens
  649. move.l #$ffffffff,(a1) ;term draw list
  650. move.l #$ffffffff,(a6)
  651. move.l a6,end_alien_draw_ptr
  652. move.l #$dff000,a6
  653. move.l #$ffffffff,(a3) ;active aliens list
  654. move.l a3,current_alien_list_ptr
  655. rts
  656. *----------------Alien Pattern Commmands
  657. Alien_Commands
  658. dc.l Alien_Object_Set_Pat
  659. dc.l Alien_Object_Set_Frame
  660. dc.l Alien_Object_Kill
  661. dc.l Alien_Object_Add
  662. dc.l Alien_Object_Simple_Add
  663. dc.l Alien_Bullet_List_Add
  664. dc.l Alien_Pattern_Restart
  665. dc.l Alien_Sound_Effect_1
  666. dc.l Alien_Sound_Effect_2
  667. dc.l Alien_Sound_Effect_3
  668. dc.l Alien_Sound_Effect_4
  669. dc.l Alien_Execute_Code
  670. dc.l Alien_Object_Simple_Add_Lots
  671. dc.l Alien_Object_Set_Counter
  672. dc.l Alien_Object_Until
  673. dc.l Alien_Hit_Pattern_Restart
  674. dc.l Alien_Dont_Go_Anywhere
  675. dc.l Alien_Pause_Anim
  676. dc.l Alien_Cont_Anim
  677. dc.l Alien_Object_Simple_Add_Transform
  678. dc.l Alien_Update_Score
  679. dc.l Alien_Attach_X
  680. dc.l Alien_Kill_Next_Alien
  681. dc.l Alien_Object_Simple_Add_Connect
  682. dc.l Alien_Attach_Y
  683. dc.l Alien_Attach_XY
  684. dc.l Alien_Object_Decrease
  685. dc.l Alien_Object_Test
  686. dc.l Alien_Object_Increase
  687. dc.l Alien_Get_Random_Pig_Noise
  688. dc.l Alien_Add_To_Map
  689. dc.l Alien_Restart_Pattern_Skip_Pos
  690. dc.l Alien_Distance_Check
  691. dc.l Alien_Start_Script
  692. dc.l Alien_Wave_Test
  693. dc.l Alien_Object_Simple_Add_Transform_Wave
  694. dc.l Alien_Burn_Block_Routine
  695. dc.l Alien_Activate_Script
  696. dc.l Alien_Check_Hits
  697. dc.l Alien_Object_Set_Random_Counter
  698. dc.l Alien_Set_Alien_Direction
  699. dc.l Alien_Set_Variable
  700. dc.l Alien_BlowUp_Next_Alien
  701. dc.l Alien_Botch
  702. dc.l Alien_Pattern_Botch
  703. dc.l Alien_Change_Type
  704. Alien_Change_Type
  705. move.l (a5)+,alien_type_ptr(a2)
  706. rts
  707. Alien_Set_Variable
  708. move.l a4,d7
  709. move.l (a5)+,a4
  710. move.w (a5)+,(a4)
  711. move.l d7,a4
  712. rts
  713. Alien_Set_Alien_Direction
  714. move.w (a5)+,alien_direction(a2)
  715. rts
  716. Alien_Object_Set_Counter
  717. move.w (a5)+,alien_counter(a2)
  718. rts
  719. Alien_Object_Set_Random_Counter
  720. move.w d0,d6
  721. move.w d1,d7
  722. move.w (a5)+,d0
  723. move.w (a5)+,d1
  724. bsr Get_Random_Number
  725. move.w d0,alien_counter(a2)
  726. move.w d6,d0
  727. move.w d7,d1
  728. rts
  729. Alien_Object_Until
  730. subq.w #1,alien_counter(a2)
  731. bne.s alien_counter_not_zero
  732. addq.l #4,a5
  733. rts
  734. alien_counter_not_zero
  735. move.l (a5)+,a5
  736. rts
  737. Alien_Sound_Effect_1
  738. move.w (a5)+,sound_chan1
  739. rts
  740. Alien_Sound_Effect_2
  741. move.w (a5)+,sound_chan2
  742. rts
  743. Alien_Sound_Effect_3
  744. move.w (a5)+,sound_chan3
  745. rts
  746. Alien_Sound_Effect_4
  747. move.w (a5)+,sound_chan4
  748. rts
  749. Alien_Bullet_List_Add
  750. movem.l a0-a1/a3/d0/d1,-(sp)
  751. move.w alien_x(a2),d0
  752. move.w alien_y(a2),d1
  753. add.w (a5)+,d0
  754. add.w (a5)+,d1
  755. move.l (a5)+,d2
  756. bsr Add_Bullet_To_List
  757. movem.l (sp)+,a0-a1/a3/d0/d1
  758. rts
  759. Alien_Object_Add
  760. movem.l d0-d1,-(sp)
  761. move.w alien_x(a2),d0
  762. move.w alien_y(a2),d1
  763. add.w (a5)+,d0
  764. add.w (a5)+,d1
  765. move.w (a5)+,d2
  766. bsr Add_Alien_To_List
  767. movem.l (sp)+,d0-d1
  768. rts
  769. Alien_Object_Simple_Add
  770. movem.l a0-a2/d0-d1,-(sp)
  771. move.w alien_x(a2),d0
  772. move.w alien_y(a2),d1
  773. add.w (a5)+,d0
  774. add.w (a5)+,d1
  775. move.l (a5)+,d2
  776. bsr Simple_Add_Alien_To_List
  777. movem.l (sp)+,a0-a2/d0-d1
  778. rts
  779. Alien_Object_Simple_Add_Lots
  780. movem.l a0-a2/d0-d1,-(sp)
  781. move.w alien_x(a2),d0
  782. move.w alien_y(a2),d1
  783. add.w (a5)+,d0
  784. add.w (a5)+,d1
  785. Keep_Adding_Simples
  786. move.l (a5)+,d2
  787. cmp.l #$ffffffff,d2
  788. beq.s finished_adding_simples
  789. bsr Simple_Add_Alien_To_List
  790. bra.s Keep_Adding_Simples
  791. finished_adding_simples
  792. movem.l (sp)+,a0-a2/d0-d1
  793. rts
  794. Alien_Object_Set_Frame
  795. move.w (a5)+,alien_frame(a2)
  796. rts
  797. Alien_Object_Set_Pat
  798. move.l (a5)+,a5
  799. rts
  800. Alien_Pattern_Restart
  801. move.l alien_pattern_ptr(a4),a5
  802. rts
  803. Alien_Object_Kill
  804. bset.b #ALIEN_DEAD,alien_flags(a2)
  805. rts
  806. Alien_Execute_Code
  807. move.l (a5)+,a1
  808. jsr (a1)
  809. rts
  810. Alien_Hit_Pattern_Restart
  811. move.l alien_pattern_ptr(a4),a5
  812. bclr.b #ALIEN_HIT_PAT,alien_hit_info(a2)
  813. rts
  814. Alien_Dont_Go_Anywhere
  815. subq.l #6,a5
  816. rts
  817. Alien_Pause_Anim
  818. move.w #30000,alien_frame_counter(a2)
  819. rts
  820. Alien_Cont_Anim
  821. clr.w alien_frame_counter(a2)
  822. rts
  823. Alien_Object_Simple_Add_Transform
  824. movem.l a0-a2/d0-d1,-(sp)
  825. move.w alien_x(a2),d0
  826. move.w alien_y(a2),d1
  827. move.l alien_map_pos(a2),d7
  828. clr.l alien_map_pos(a2)
  829. move.w alien_hits(a2),d6
  830. add.w (a5)+,d0
  831. add.w (a5)+,d1
  832. move.l (a5)+,d2
  833. bsr Simple_Add_Alien_To_List
  834. move.l d7,alien_map_pos(a1)
  835. move.w d6,alien_hits(a1)
  836. movem.l (sp)+,a0-a2/d0-d1
  837. rts
  838. Alien_Botch
  839. movem.l a0-a2/d0-d1,-(sp)
  840. move.w alien_x(a2),d0
  841. move.w alien_y(a2),d1
  842. move.l alien_work+4(a2),d7
  843. move.l (a5)+,d2
  844. bsr Simple_Add_Alien_To_List
  845. move.l d7,alien_work+4(a1)
  846. movem.l (sp)+,a0-a2/d0-d1
  847. rts
  848. Alien_Pattern_Botch
  849. movem.l a0-a2/d0-d1,-(sp)
  850. move.w alien_x(a2),d0
  851. move.w alien_y(a2),d1
  852. move.l (a5)+,d2
  853. bsr Simple_Add_Alien_To_List
  854. move.l (a5)+,alien_pat_ptr(a1)
  855. movem.l (sp)+,a0-a2/d0-d1
  856. rts
  857. Alien_Update_Score
  858. move.w (a5)+,d7
  859. add.w d7,inter_score
  860. rts
  861. Alien_Attach_X
  862. move.l a0,d7
  863. move.l alien_work+8(a2),a0
  864. move.w alien_x(a0),alien_x(a2)
  865. move.l d7,a0
  866. rts
  867. Alien_Kill_Next_Alien
  868. move.l a0,d7 ;kill attached alien
  869. move.l alien_work+4(a2),a0
  870. bset.b #ALIEN_DEAD,alien_flags(a0)
  871. clr.l alien_work+4(a2) ;clear - i.e no attached
  872. move.l d7,a0
  873. rts
  874. Alien_BlowUp_Next_Alien
  875. move.l a0,d7 ;kill attached alien
  876. move.l a1,d6
  877. move.l alien_work+4(a2),a0
  878. move.l alien_type_ptr(a0),a1
  879. move.l alien_dead_pattern(a1),alien_pat_ptr(a0)
  880. clr.l alien_work+4(a2) ;clear - i.e no attached
  881. move.l d7,a0
  882. move.l d6,d1
  883. rts
  884. Alien_Object_Simple_Add_Connect
  885. movem.l a0-a2/d0-d1,-(sp)
  886. move.w alien_x(a2),d0
  887. move.w alien_y(a2),d1
  888. add.w (a5)+,d0
  889. add.w (a5)+,d1
  890. move.l (a5)+,d2
  891. move.l a2,d7
  892. bsr Simple_Add_Alien_To_List
  893. move.l d7,alien_work+8(a1) ;reference to master
  894. move.l a1,d7
  895. movem.l (sp)+,a0-a2/d0-d1
  896. move.l d7,alien_work+4(a2) ;reference to slave (for killing)
  897. rts
  898. Alien_Attach_Y
  899. move.l a0,d7
  900. move.l alien_work+8(a2),a0
  901. move.w alien_y(a0),alien_y(a2)
  902. move.l d7,a0
  903. rts
  904. Alien_Attach_XY
  905. move.l a0,d7
  906. move.l alien_work+8(a2),a0
  907. move.w alien_x(a0),alien_x(a2)
  908. move.w alien_y(a0),alien_y(a2)
  909. move.l d7,a0
  910. rts
  911. Alien_Object_Decrease
  912. move.l a6,d7
  913. move.l (a5)+,a6
  914. subq.w #1,(a6)
  915. move.l d7,a6
  916. rts
  917. Alien_Object_Test
  918. move.l a6,d7
  919. move.l (a5)+,a6
  920. move.w (a5)+,d6
  921. cmp.w (a6),d6
  922. beq.s use_the_pointer
  923. move.l d7,a6
  924. addq.l #4,a5
  925. rts
  926. use_the_pointer
  927. move.l (a5)+,a5
  928. move.l d7,a6
  929. rts
  930. Alien_Object_Increase
  931. move.l a6,d7
  932. move.l (a5)+,a6
  933. addq.w #1,(a6)
  934. move.l d7,a6
  935. rts
  936. Alien_Get_Random_Pig_Noise
  937. moveq #0,d5
  938. move.l a1,d7
  939. move.l random_direction_ptr,a1
  940. move.b (a1)+,d5
  941. cmp.b #-1,(a1)
  942. bne.s not_end_get_pn
  943. move.l #random_direction_table,a1
  944. not_end_get_pn
  945. move.l a1,random_direction_ptr
  946. lsl.w d5
  947. move.l #Random_Pig_Noise_Table,a1
  948. move.w (a1,d5),sound_chan3
  949. move.l d7,a1
  950. rts
  951. Random_Pig_Noise_Table
  952. dc.w Sound_PigDie
  953. dc.w Sound_PigDie4
  954. dc.w Sound_PigDie3
  955. dc.w Sound_PigDie3
  956. dc.w Sound_PigDie2
  957. dc.w Sound_PigDie
  958. dc.w Sound_PigDie4
  959. dc.w Sound_PigDie2
  960. dc.w Sound_PigDie3
  961. dc.w Sound_PigDie4
  962. dc.w Sound_PigDie
  963. dc.w Sound_PigDie
  964. dc.w Sound_PigDie2
  965. dc.w Sound_PigDie3
  966. Alien_Object_Simple_Add_Transform_Wave
  967. movem.l a0-a2/d0-d1,-(sp)
  968. move.w alien_x(a2),d0
  969. move.w alien_y(a2),d1
  970. move.l alien_script(a2),d7
  971. add.w (a5)+,d0
  972. add.w (a5)+,d1
  973. move.l (a5)+,d2
  974. bsr Simple_Add_Alien_To_List
  975. move.l d7,alien_script(a1)
  976. movem.l (sp)+,a0-a2/d0-d1
  977. rts
  978. Alien_Add_To_Map
  979. move.l a5,d7
  980. moveq #0,d4
  981. move.w alien_x(a2),d4
  982. move.w alien_y(a2),d3
  983. move.l current_alien_map_pointer,a5
  984. asr #4,d4
  985. asr #4,d3
  986. mulu #BIGGEST_MAP_X,d3
  987. add.l d4,d3
  988. move.b alien_type_number(a4),d2
  989. add.b #128,d2 ;i.e active at moment
  990. add.l d3,a5
  991. move.b d2,(a5)
  992. move.l a5,alien_map_pos(a2)
  993. move.l d7,a5
  994. rts
  995. Alien_Restart_Pattern_Skip_Pos
  996. move.l alien_pattern_ptr(a4),a5
  997. addq.l #4,a5
  998. rts
  999. Alien_Distance_Check
  1000. move.w (a5)+,d5
  1001. move.w alien_x(a2),d6
  1002. move.w alien_y(a2),d7
  1003. sub.w actual_player_map_x_position,d6
  1004. bpl.s dont_neg_guard_x
  1005. neg.w d6
  1006. dont_neg_guard_x
  1007. cmp.w d5,d6
  1008. bgt.s dont_add_guard
  1009. sub.w actual_player_map_y_position,d7
  1010. bpl.s dont_neg_guard_y
  1011. neg.w d7
  1012. dont_neg_guard_y
  1013. cmp.w d5,d7
  1014. bgt.s dont_add_guard
  1015. move.l (a5)+,a5
  1016. rts
  1017. dont_add_guard
  1018. addq.l #4,a5
  1019. rts
  1020. Alien_Start_Script
  1021. movem.l a0/a1,-(sp)
  1022. move.l (a5)+,a0 ;var containing address
  1023. move.l switch_list_pointer,a1
  1024. move.l (a0),(a1)+
  1025. move.l #$ffffffff,(a1)
  1026. move.l a1,switch_list_pointer
  1027. movem.l (sp)+,a0/a1
  1028. rts
  1029. Alien_Wave_Test
  1030. move.l a1,d7
  1031. move.l alien_script(a2),a1
  1032. subq.w #1,(a1)+
  1033. bne.s dont_jump_in_script
  1034. move.l (a1),a5 ;do bonus part of script
  1035. dont_jump_in_script
  1036. move.l d7,a1
  1037. rts
  1038. Alien_Activate_Script
  1039. movem.l a0/a1,-(sp)
  1040. move.l switch_list_pointer,a1
  1041. move.l (a5)+,(a1)+ ;var containing address
  1042. move.l #$ffffffff,(a1)
  1043. move.l a1,switch_list_pointer
  1044. movem.l (sp)+,a0/a1
  1045. rts
  1046. Alien_Check_Hits
  1047. move.w (a5)+,d7
  1048. move.l (a5)+,d6
  1049. cmp.w alien_hits(a2),d7
  1050. beq.s No_Problem_Hits_Intact
  1051. move.l d6,a5
  1052. No_Problem_Hits_Intact
  1053. rts
  1054. ********************************************
  1055. ** BURN POST BLOCK ***
  1056. ********************************************
  1057. Alien_Burn_Block_Routine
  1058. move.w (a5)+,d2 ;block to add
  1059. movem.l d0-d1/a3/a5,-(sp)
  1060. move.w alien_x(a2),d0
  1061. move.w alien_y(a2),d1
  1062. move.w scroll_x_position,d3
  1063. andi.w #$fff0,d3
  1064. sub.w d3,d0
  1065. sub.w scroll_y_position,d1
  1066. bsr Draw_68000_Block_Into_CopyBack
  1067. movem.l (sp)+,d0-d1/a3/a5
  1068. rts
  1069. *----------------End Alien pattern commands
  1070. ************************************************
  1071. ****** DO ALIEN COLLISION ******
  1072. ************************************************
  1073. Do_Alien_Collision
  1074. *Test aliens against bullets
  1075. move.l #Active_Alien_Pointers,a0
  1076. test_alien_loop
  1077. move.l (a0)+,a1
  1078. cmp.l #$ffffffff,a1
  1079. beq finished_testing_aliens
  1080. move.l alien_type_ptr(a1),a4
  1081. btst.b #ALIEN_NO_COLLISION,alien_type_flags(a4)
  1082. bne.s test_alien_loop
  1083. move.w alien_x(a1),d0
  1084. move.w alien_y(a1),d1
  1085. move.w d0,d2
  1086. move.w d1,d3
  1087. add.w alien_x_size(a4),d2
  1088. add.w alien_y_size(a4),d3
  1089. move.l #Active_Bullet_Pointers,a2
  1090. test_bullet_loop
  1091. move.l (a2)+,a3
  1092. cmp.l #$ffffffff,a3
  1093. beq finished_testing_bullets
  1094. tst.w bullet_dead_flag(a3)
  1095. bne.s test_bullet_loop
  1096. move.l bullet_type_ptr(a3),a5
  1097. *test x side
  1098. cmp.w bullet_x(a3),d2
  1099. blt.s test_bullet_loop ;not hit
  1100. move.w bullet_x(a3),d4
  1101. add.w alien_x_size(a5),d4
  1102. cmp.w d4,d0
  1103. bgt.s test_bullet_loop ;not hit
  1104. *test y
  1105. cmp.w bullet_y(a3),d3
  1106. blt.s test_bullet_loop ;not hit
  1107. move.w bullet_y(a3),d4
  1108. add.w alien_y_size(a5),d4
  1109. cmp.w d4,d1
  1110. bgt.s test_bullet_loop ;not hit
  1111. *----Bullet has hit alien---
  1112. btst #NO_EXPLODE,alien_type_flags(a5) ;bullet
  1113. bne.s bullet_no_die
  1114. tst.w alien_hit_count(a5)
  1115. ble.s bullet_dead_pal
  1116. move.w alien_hits(a1),d4
  1117. sub.w d4,bullet_hits(a3)
  1118. bgt.s bullet_no_die
  1119. bullet_dead_pal
  1120. move.w #Sound_Thud2,sound_chan2
  1121. move.w #1,bullet_dead_flag(a3)
  1122. bullet_no_die
  1123. btst.b #ONE_HIT,alien_type_flags(a4)
  1124. beq.s not_a_one_hit_alien
  1125. btst.b #ALIEN_HIT,alien_flags(a1)
  1126. bne.s test_bullet_loop
  1127. not_a_one_hit_alien
  1128. subq.w #1,alien_hits(a1) ;no longer gun power
  1129. bgt.s alien_not_dead_yet
  1130. move.l alien_dead_pattern(a4),alien_pat_ptr(a1)
  1131. bra.s not_a_hit_pattern_alien
  1132. alien_not_dead_yet
  1133. bset.b #ALIEN_HIT,alien_flags(a1)
  1134. btst.b #HIT_PATTERN,alien_type_flags(a4)
  1135. beq.s not_a_hit_pattern_alien
  1136. bset.b #ALIEN_HIT_PAT,alien_hit_info(a1) ;test bit and set
  1137. bne test_bullet_loop
  1138. ignor_test
  1139. move.l alien_hit_pattern(a4),alien_pat_ptr(a1)
  1140. not_a_hit_pattern_alien
  1141. bra test_bullet_loop
  1142. finished_testing_bullets
  1143. bra test_alien_loop
  1144. finished_testing_aliens
  1145. rts
  1146. ************************************************
  1147. ****** DO PLAYER ALIEN COLLISION ******
  1148. ************************************************
  1149. Do_Player_Alien_Collision
  1150. *Test aliens against player
  1151. move.w actual_player_map_x_position,d5
  1152. add.w player_x_in,d5
  1153. move.w actual_player_map_y_position,d6
  1154. add.w player_y_in,d6
  1155. move.l #Man_Alien_Collision_Table,a3
  1156. move.l #Active_Alien_Pointers,a0
  1157. test_player_alien_loop
  1158. move.l (a0)+,a1
  1159. cmp.l #$ffffffff,a1
  1160. beq.s finished_testing_player_aliens
  1161. move.l alien_type_ptr(a1),a2
  1162. btst.b #PLAYER_NO_COLLISION,alien_type_flags(a2)
  1163. bne.s test_player_alien_loop
  1164. move.w alien_x(a1),d0
  1165. move.w alien_y(a1),d1
  1166. move.w d0,d2
  1167. move.w d1,d3
  1168. add.w alien_x_size(a2),d2
  1169. add.w alien_y_size(a2),d3
  1170. *test x side
  1171. cmp.w d5,d2
  1172. blt test_player_alien_loop ;not hit
  1173. move.w d5,d4
  1174. add.w #16,d4 ;***for now
  1175. cmp.w d4,d0
  1176. bgt test_player_alien_loop ;not hit
  1177. *test y
  1178. cmp.w d6,d3
  1179. blt test_player_alien_loop ;not hit
  1180. move.w d6,d4
  1181. add.w #16,d4
  1182. cmp.w d4,d1
  1183. bgt.s test_player_alien_loop ;not hit
  1184. *----Player has hit alien---
  1185. moveq #0,d7
  1186. move.b alien_type_number(a2),d7
  1187. lsl.w #2,d7
  1188. move.l (a3,d7.l),d7
  1189. beq.s dont_call_hit_routine
  1190. move.l d7,a4
  1191. jsr (a4)
  1192. dont_call_hit_routine
  1193. *----------
  1194. bra test_player_alien_loop
  1195. finished_testing_player_aliens
  1196. rts
  1197. ************************************************
  1198. ****** EXTRACT PIGS FROM ALIEN LIST ******
  1199. ************************************************
  1200. Extract_Pigs_From_Alien_List
  1201. move.l #pig_list,a0
  1202. move.l #Active_Alien_Pointers,a1
  1203. move.l #Alien1_Graphics_Table,d0
  1204. extract_pig_loop
  1205. move.l (a1)+,a2
  1206. cmp.l #$ffffffff,a2
  1207. beq.s end_extract_pig
  1208. move.l alien_type_ptr(a2),a3
  1209. cmp.l alien_graphics(a3),d0
  1210. bne.s extract_pig_loop
  1211. add_pig_to_loop
  1212. move.l a2,(a0)+
  1213. bra.s extract_pig_loop
  1214. end_extract_pig
  1215. move.l #$ffffffff,(a0)
  1216. rts
  1217. ************************************************
  1218. ****** DO PIG ON PIG COLLISION ******
  1219. ************************************************
  1220. Do_Pig_On_Pig_Collision
  1221. *send alien structure pointer in a2
  1222. *send x and y incs in d0 and d1
  1223. *will return if hit another alien in variable pig_hit_flags
  1224. *This is rather sloppy collision, but I dont want to waste
  1225. *to much CPU time testing pigs on pigs becuase its such a small
  1226. *enhancement and such a lot of processing.
  1227. *--set up test values
  1228. move.w d0,d5 ;move inc values
  1229. move.w d1,d6
  1230. move.w alien_x(a2),d0
  1231. move.w alien_y(a2),d1
  1232. move.l alien_type_ptr(a2),a3
  1233. move.w d0,d2
  1234. move.w d1,d3
  1235. addq.w #4,d0
  1236. addq.w #4,d1
  1237. add.w #PIG_ALIEN_WIDTH-4,d2
  1238. add.w #PIG_ALIEN_HEIGHT-4,d3
  1239. *--
  1240. clr.b pig_hit_flags
  1241. move.l #Pig_list,a4
  1242. test_alien_on_alien_loop
  1243. move.l (a4)+,a5
  1244. cmp.l #$ffffffff,a5
  1245. beq finished_testing_pigs_on_pigs
  1246. cmp.l a2,a5
  1247. beq.s test_alien_on_alien_loop ;dont test self on self
  1248. *-- Need to do two tests -one for x and one for y
  1249. *-- First test for when X added on
  1250. *test x side
  1251. movem.w d0/d2,-(sp)
  1252. add.w d5,d0
  1253. add.w d5,d2
  1254. move.w alien_x(a5),d4
  1255. addq.w #4,d4
  1256. cmp.w d4,d2
  1257. blt.s test_for_y_added_on ;not hit
  1258. add.w #PIG_ALIEN_WIDTH-8,d4
  1259. cmp.w d4,d0
  1260. bgt.s test_for_y_added_on ;not hit
  1261. *test y
  1262. move.w alien_y(a5),d4
  1263. addq.w #4,d4
  1264. cmp.w d4,d3
  1265. blt.s test_for_y_added_on ;not hit
  1266. add.w #PIG_ALIEN_HEIGHT-8,d4
  1267. cmp.w d4,d1
  1268. bgt.s test_for_y_added_on ;not hit
  1269. bset.b #0,pig_hit_flags ;x hit
  1270. test_for_y_added_on
  1271. movem.w (sp)+,d0/d2 ;restore x
  1272. *test x side
  1273. movem.w d1/d3,-(sp)
  1274. add.w d6,d1
  1275. add.w d6,d3
  1276. move.w alien_x(a5),d4
  1277. addq.w #4,d4
  1278. cmp.w d4,d2
  1279. blt no_hit_on_alien_y ;not hit
  1280. add.w #PIG_ALIEN_WIDTH-8,d4
  1281. cmp.w d4,d0
  1282. bgt.s no_hit_on_alien_y ;not hit
  1283. *test y
  1284. move.w alien_y(a5),d4
  1285. addq.w #4,d4
  1286. cmp.w d4,d3
  1287. blt.s no_hit_on_alien_y ;not hit
  1288. add.w #PIG_ALIEN_HEIGHT-8,d4
  1289. cmp.w d4,d1
  1290. bgt.s no_hit_on_alien_y ;not hit
  1291. bset.b #1,pig_hit_flags
  1292. no_hit_on_alien_y
  1293. movem.w (sp)+,d1/d3
  1294. cmp.w #3,d7
  1295. bne test_alien_on_alien_loop ;exit if x,y hit
  1296. finished_testing_pigs_on_pigs
  1297. rts
  1298. pig_hit_flags
  1299. dc.b 0
  1300. even
  1301. *--------------------Alien structure definition------------------
  1302. *---Alien Bit Flags
  1303. ALIEN_DEAD EQU 0
  1304. ALIEN_HIT EQU 1
  1305. ALIEN_PRIORITY EQU 2
  1306. ALIEN_HIT_PAT EQU 3
  1307. *---Alien map flags
  1308. ALIEN_BUSY EQU 7
  1309. *---Alien add list structure
  1310. rsreset
  1311. Add_Alien_Number rs.w 1
  1312. Add_X_Position rs.w 1
  1313. Add_Y_Position rs.w 1
  1314. Add_Map_Position rs.l 1
  1315. Add_Struct_Size rs.w 1
  1316. *---Alien Structure
  1317. rsreset
  1318. alien_x rs.w 1
  1319. alien_y rs.w 1
  1320. alien_type_ptr rs.l 1 ;pointer to struct containing info
  1321. alien_pat_ptr rs.l 1
  1322. alien_frame_counter rs.w 1
  1323. alien_frame rs.w 1
  1324. alien_flags rs.b 1
  1325. alien_c_pad rs.b 1
  1326. alien_hit_info rs.w 1
  1327. alien_hits rs.w 1
  1328. alien_counter rs.w 1
  1329. alien_direction rs.w 1 ;only used for such aliens
  1330. alien_data rs.w 1 ;for working on
  1331. alien_data_extra rs.w 1
  1332. alien_work rs.w 6
  1333. *alien_list_data rs.w 20 ;list data - christ this should have been re-written
  1334. alien_script rs.l 1 ;in case needs to have user defined script
  1335. alien_map_pos rs.l 1 ;if added via map != 0
  1336. alien_struct_size rs.w 1
  1337. *---Alien Draw Structure
  1338. rsreset
  1339. *--- ^ = filled in at draw time
  1340. alien_struct_ptr rs.l 1
  1341. alien_draw_frame rs.w 1
  1342. alien_scr_pos rs.l 1 ;^
  1343. alien_split rs.w 1 ;^
  1344. alien_split_scr rs.l 1 ;^
  1345. alien_draw_height rs.w 1 ;^
  1346. alien_draw_height2 rs.w 1 ;^
  1347. alien_draw_size rs.w 1