bullet_routines.s 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264
  1. MAX_BULLETS EQU 50
  2. STANDARD_GUN EQU 0
  3. STANDARD_DOUBLED EQU 1*4
  4. STANDARD_GUN_TRIPLE EQU 2*4
  5. ROCKET_LAUNCHER EQU 3*4
  6. GRENADE EQU 4*4
  7. GRENADE_FRAMES EQU 4
  8. weapon_call_table
  9. dc.l Add_Standard_Fire
  10. dc.l Add_Double_Fire
  11. dc.l Add_Triple_Fire
  12. dc.l Add_Rocket
  13. dc.l Add_Grenade
  14. PLAYER_BASIC_BULLET_DELAY EQU 4
  15. PLAYER_TRIPLE_BULLET_DELAY EQU 4
  16. PLAYER_GRENADE_DELAY EQU 15
  17. PLAYER_ROCKET_LAUNCHER_DELAY EQU 19
  18. player_fire_delay dc.w PLAYER_BASIC_BULLET_DELAY
  19. homing_missiles dc.w 0
  20. current_weapon dc.w STANDARD_GUN
  21. *-----------------------All code for weapons--------------------
  22. ************************************************
  23. ****** CHECK PLAYER FIRE ******
  24. ************************************************
  25. Check_Player_Fire
  26. cmp.w #GRENADE,current_weapon
  27. bne.s regular_fire
  28. bsr Add_Sight
  29. regular_fire
  30. tst fire
  31. beq.s player_not_fired
  32. tst.w player_fire_delay
  33. bne.s player_not_fired
  34. moveq #0,d0
  35. move.w current_weapon,d0
  36. move.l #weapon_call_table,a0
  37. move.l (a0,d0),a0
  38. jsr (a0)
  39. player_not_fired
  40. tst player_fire_delay
  41. beq.s quit_player_fire
  42. subq.w #1,player_fire_delay
  43. quit_player_fire
  44. rts
  45. ************************************************
  46. ****** ADD SIGHT ******
  47. ************************************************
  48. Add_Sight
  49. move.w actual_player_map_x_position,d0
  50. move.w actual_player_map_y_position,d1
  51. *16 to get middle of player and -6 middle of sight (as 13 high)
  52. add.w #16-6,d0 ;middle of player
  53. add.w #16-6,d1
  54. move.w Grenade_Distance,d5
  55. move.w d5,d6
  56. move.l #Unit_Table,a0
  57. moveq #0,d7
  58. move.w last_direction,d7
  59. asl #2,d7
  60. muls (a0,d7),d5
  61. muls 2(a0,d7),d6
  62. add.w d5,d0
  63. add.w d6,d1
  64. move.w d0,sight_x
  65. move.w d1,sight_y
  66. move.w #CrossHair,d2
  67. bsr Add_Alien_To_List
  68. rts
  69. sight_x dc.w 0
  70. sight_y dc.w 0
  71. ************************************************
  72. ****** ADD GRENADE ******
  73. ************************************************
  74. Add_Grenade
  75. tst grenades_in_pack
  76. bne.s still_grenades_left
  77. move.w #Sound_GunEmpty,sound_chan2
  78. move.w players_weapon,current_weapon
  79. move.w gun_level,weapon_level
  80. bsr Display_Weapon_Power_Level
  81. bsr Display_Weapon_On_Panel
  82. bsr Display_Grenade_Packs
  83. rts
  84. still_grenades_left
  85. subq.w #1,grenades_in_pack
  86. bne.s not_at_end_of_pack
  87. subq.w #1,grenade_packs
  88. beq.s no_grenade_packs_left
  89. move.w #5,grenades_in_pack
  90. no_grenade_packs_left
  91. bsr Display_Grenade_Packs
  92. not_at_end_of_pack
  93. move.l #Target_Alien,d2
  94. move.w sight_x,d0
  95. move.w sight_y,d1
  96. bsr Simple_Add_Alien_To_List
  97. move.l a1,d7
  98. move.w Grenade_Distance,d3
  99. move.w d3,d4
  100. asr d4
  101. ext.l d4
  102. divu #GRENADE_FRAMES,d4
  103. ror #8,d4
  104. or.w d4,d3 ;store data in alien struct
  105. clr.l d0
  106. move.w last_direction,d0
  107. move.l #Grenade_table,a0
  108. asl.w #2,d0
  109. move.l (a0,d0),d2
  110. move.w actual_player_map_x_position,d0
  111. move.w actual_player_map_y_position,d1
  112. tst.b man_direction
  113. beq.s skip_inc_add
  114. move.w player_x_inc,d6
  115. add.w d6,d6
  116. add.w d6,d0
  117. move.w player_y_inc,d6
  118. add.w d6,d6
  119. add.w d6,d1
  120. skip_inc_add
  121. addq.w #8,d0
  122. addq.w #8,d1
  123. bsr Simple_Add_Alien_To_List
  124. move.l d7,alien_work(a1)
  125. move.w #PLAYER_GRENADE_DELAY,player_fire_delay
  126. rts
  127. MAX_GRENADE_DISTANCE EQU 104
  128. DEFAULT_DISTANCE EQU 60
  129. Grenade_Positioning dc.w 0
  130. Grenade_Distance dc.w DEFAULT_DISTANCE
  131. ************************************************
  132. ****** ADD STANDARD FIRE ******
  133. ************************************************
  134. Add_Standard_Fire
  135. move.w #PLAYER_BASIC_BULLET_DELAY,player_fire_delay
  136. move.w #Sound_GunFire,sound_chan2
  137. moveq #0,d0
  138. moveq #0,d1
  139. move.w last_direction,d0
  140. move.l #basic_bullet_table,a0
  141. asl.w #4,d0
  142. move.l (a0,d0),d2
  143. *Do bullet offsets
  144. move.l #player_frame_offsets,a0
  145. move.w player_current_frame,d1
  146. asl #2,d1
  147. asr #2,d0
  148. move.l (a0,d1),a0 ;offest table for frame
  149. move.w 2(a0,d0),d1
  150. move.w (a0,d0),d0
  151. *End
  152. add.w actual_player_map_x_position,d0
  153. add.w actual_player_map_y_position,d1
  154. bsr add_bullet_to_list
  155. rts
  156. ************************************************
  157. ****** ADD DOUBLE FIRE ******
  158. ************************************************
  159. Add_Double_Fire
  160. move.w #PLAYER_BASIC_BULLET_DELAY,player_fire_delay
  161. move.w #Sound_GunFire,sound_chan2
  162. moveq #0,d5
  163. moveq #0,d1
  164. move.w last_direction,d5
  165. move.l #basic_bullet_table,a0
  166. asl.w #4,d5
  167. move.l (a0,d5),d2
  168. *Do bullet offsets
  169. move.l #player_frame_offsets,a0
  170. move.l #double_fire_offsets,a4
  171. move.w player_current_frame,d1
  172. asl #2,d1
  173. asr #2,d5
  174. move.l (a0,d1),a0 ;offset table for frame
  175. move.w 2(a0,d5),d7
  176. move.w (a0,d5),d6
  177. *End
  178. move.w d6,d0
  179. move.w d7,d1
  180. add.w (a4,d5),d0
  181. add.w 2(a4,d5),d1
  182. add.w actual_player_map_x_position,d0
  183. add.w actual_player_map_y_position,d1
  184. bsr add_bullet_to_list
  185. move.w d6,d0
  186. move.w d7,d1
  187. sub.w (a4,d5),d0
  188. sub.w 2(a4,d5),d1
  189. add.w actual_player_map_x_position,d0
  190. add.w actual_player_map_y_position,d1
  191. bsr add_bullet_to_list
  192. rts
  193. double_fire_offsets
  194. dc.w 0,0
  195. dc.w 0,6 ;left_offsets
  196. dc.w 0,6 ;right_offsets
  197. dc.w 0,0
  198. dc.w 6,0 ;up_offsets
  199. dc.w -4,4 ;up_left_offsets
  200. dc.w -4,-4 ;up_right_offsets
  201. dc.w 0,0
  202. dc.w 6,0 ;down_offsets
  203. dc.w 4,4 ;down_left_offsets
  204. dc.w -4,4 ;down_right_offsets
  205. ************************************************
  206. ****** ADD TRIPLE FIRE ******
  207. ************************************************
  208. Add_Triple_Fire
  209. move.w #PLAYER_TRIPLE_BULLET_DELAY,player_fire_delay
  210. move.w #Sound_GunFire,sound_chan2
  211. moveq #0,d7
  212. move.w last_direction,d7
  213. move.l #basic_bullet_table,a4
  214. asl.w #4,d7
  215. move.l (a4,d7),d2
  216. *Do bullet offsets
  217. move.l #player_frame_offsets,a0
  218. move.w player_current_frame,d1
  219. asl #2,d1
  220. move.w d7,d0
  221. asr #2,d0
  222. move.l (a0,d1),a0 ;offest table for frame
  223. move.w 2(a0,d0),d1
  224. move.w (a0,d0),d0
  225. *End
  226. add.w actual_player_map_x_position,d0
  227. add.w actual_player_map_y_position,d1
  228. bsr add_bullet_to_list
  229. move.l 4(a4,d7),d2
  230. bsr add_bullet_to_list
  231. move.l 8(a4,d7),d2
  232. bsr add_bullet_to_list
  233. rts
  234. ************************************************
  235. ****** ADD ROCKET ******
  236. ************************************************
  237. Add_Rocket
  238. tst rockets_in_pack
  239. bne.s still_rockets_left
  240. move.w #Sound_GunEmpty,sound_chan2
  241. move.w players_weapon,current_weapon
  242. move.w gun_level,weapon_level
  243. bsr Display_Weapon_Power_Level
  244. bsr Display_Weapon_On_Panel
  245. bsr Display_Grenade_Packs
  246. rts
  247. still_rockets_left
  248. subq.w #1,rockets_in_pack
  249. bne.s not_at_end_of_rpack
  250. subq.w #1,rocket_packs
  251. beq.s no_rocket_packs_left
  252. move.w #5,rockets_in_pack
  253. no_rocket_packs_left
  254. bsr Display_Grenade_Packs
  255. not_at_end_of_rpack
  256. move.w #PLAYER_ROCKET_LAUNCHER_DELAY,player_fire_delay
  257. move.w #Sound_Rocket,sound_chan1
  258. moveq #0,d0
  259. move.w last_direction,d0
  260. move.l #Rocket_table,a0
  261. asl.w #2,d0
  262. move.l (a0,d0),d2
  263. *Do bullet offsets
  264. move.l #player_frame_offsets,a0
  265. move.w player_current_frame,d1
  266. asl #2,d1
  267. move.l (a0,d1),a0 ;offest table for frame
  268. move.w 2(a0,d0),d1
  269. move.w (a0,d0),d0
  270. *End
  271. add.w actual_player_map_x_position,d0
  272. add.w actual_player_map_y_position,d1
  273. bsr add_bullet_to_list
  274. rts
  275. ************************************************
  276. ****** GRENADE UPDATE ******
  277. ************************************************
  278. Grenade_Update
  279. *Called by alien routine when updating grenade
  280. sub.b #GRENADE_SPEED,alien_data+1(a2)
  281. bge dont_kill_grenade
  282. bset.b #ALIEN_DEAD,alien_flags(a2)
  283. move.l a2,d7
  284. move.l alien_work(a2),a2
  285. bset.b #ALIEN_DEAD,alien_flags(a2) ;kill target
  286. move.l d7,a2
  287. movem.l a0-a3/d0-d1,-(sp)
  288. *Test to see if grenade hit water
  289. move.l current_map_pointer,a3
  290. move.w alien_x(a2),d6
  291. move.w alien_y(a2),d7
  292. move.w d6,d0
  293. move.w d7,d1
  294. andi.w #$fff0,d6 ;get block co-cords
  295. andi.w #$fff0,d7
  296. asr.w #3,d6 ;word map
  297. asr.w #4,d7
  298. muls #BIGGEST_MAP_X*MAP_BLOCK_SIZE,d7
  299. ext.l d6
  300. add.l d6,a3
  301. add.l d7,a3
  302. moveq #0,d2
  303. move.w (a3),d2 ;block
  304. asl #BLOCK_STRUCT_MULT,d2
  305. move.l #block_data_information,a3
  306. move.b block_details(a3,d2.l),d7 ;our data
  307. btst #WATER_FLAG,d7
  308. beq.s explode_grenade_shell
  309. subq.w #3,d0 ;re-position splash
  310. subq.w #3,d1
  311. move.l #Generic_Splash_Object,d2
  312. bsr Simple_Add_Alien_To_List
  313. movem.l (sp)+,a0-a3/d0-d1
  314. rts
  315. explode_grenade_shell
  316. moveq #0,d0
  317. move.w grenade_level,d0
  318. asl #2,d0
  319. move.l #Grenade_Explosion_Types,a0
  320. move.l (a0,d0.l),a0
  321. jsr (a0)
  322. movem.l (sp)+,a0-a3/d0-d1
  323. move.w #Sound_Grenade,Sound_chan2
  324. rts
  325. dont_kill_grenade
  326. moveq #0,d6
  327. moveq #0,d1
  328. move.b alien_data+1(a2),d6
  329. move.b alien_data(a2),d1
  330. divu d1,d6
  331. cmp.w #GRENADE_FRAMES,d6
  332. blt.s not_going_down_grenade
  333. neg.w d6
  334. addq.w #7,d6
  335. not_going_down_grenade
  336. move.w d6,alien_frame(a2)
  337. *Add shadow
  338. movem.l a0-a2/d0-d1,-(sp)
  339. move.w alien_x(a2),d0
  340. move.w alien_y(a2),d1
  341. addq.w #4,d0
  342. addq.w #4,d1
  343. move.l #Grenade_Shadow,d2
  344. bsr Simple_Add_Alien_To_List -a1 = alien struct
  345. move.w d6,alien_frame(a1)
  346. movem.l (sp)+,a0-a2/d0-d1
  347. rts
  348. Level1_Grenade_Explosion
  349. move.w alien_x(a2),d0
  350. move.w alien_y(a2),d1
  351. moveq #0,d7
  352. move.b alien_type_number(a4),d7
  353. move.l #small_explo_bullet,d2
  354. bsr Add_Bullet_To_List
  355. move.l #Extra_Bullets_List_Level1,a2
  356. mulu #20,d7
  357. move.l (a2,d7.l),bullet_pat_ptr(a1)
  358. move.l #small_explo_bullet,d2
  359. bsr Add_Bullet_To_List
  360. move.l 4(a2,d7.l),bullet_pat_ptr(a1)
  361. subq.w #5,d0
  362. subq.w #5,d1
  363. move.l #Grenade_Explosion_Bullet,d2
  364. bsr Add_Bullet_To_List ;Will need to be a bullet
  365. rts
  366. Level2_Grenade_Explosion
  367. move.w alien_x(a2),d0
  368. move.w alien_y(a2),d1
  369. moveq #0,d7
  370. move.b alien_type_number(a4),d7
  371. move.l #small_explo_bullet,d2
  372. bsr Add_Bullet_To_List
  373. move.l #Extra_Bullets_List_Level1,a2
  374. mulu #20,d7
  375. move.l (a2,d7.l),bullet_pat_ptr(a1)
  376. move.l #small_explo_bullet,d2
  377. bsr Add_Bullet_To_List
  378. move.l 4(a2,d7.l),bullet_pat_ptr(a1)
  379. move.l #small_explo_bullet,d2
  380. bsr Add_Bullet_To_List
  381. move.l 8(a2,d7.l),bullet_pat_ptr(a1)
  382. move.l #small_explo_bullet,d2
  383. bsr Add_Bullet_To_List
  384. move.l 12(a2,d7.l),bullet_pat_ptr(a1)
  385. subq.w #5,d0
  386. subq.w #5,d1
  387. move.l #Grenade_Explosion_Bullet,d2
  388. bsr Add_Bullet_To_List ;Will need to be a bullet
  389. rts
  390. Level3_Grenade_Explosion
  391. move.w alien_x(a2),d0
  392. move.w alien_y(a2),d1
  393. moveq #0,d7
  394. move.b alien_type_number(a4),d7
  395. move.l #small_explo_bullet,d2
  396. bsr Add_Bullet_To_List
  397. move.l #Extra_Bullets_List_Level1,a2
  398. mulu #20,d7
  399. move.l (a2,d7.l),bullet_pat_ptr(a1)
  400. move.l #small_explo_bullet,d2
  401. bsr Add_Bullet_To_List
  402. move.l 4(a2,d7.l),bullet_pat_ptr(a1)
  403. move.l #small_explo_bullet,d2
  404. bsr Add_Bullet_To_List
  405. move.l 8(a2,d7.l),bullet_pat_ptr(a1)
  406. move.l #small_explo_bullet,d2
  407. bsr Add_Bullet_To_List
  408. move.l 12(a2,d7.l),bullet_pat_ptr(a1)
  409. subq.w #5,d0
  410. subq.w #5,d1
  411. move.l #Grenade_Explosion_Bullet,d2
  412. bsr Add_Bullet_To_List ;Will need to be a bullet
  413. move.l 16(a2,d7.l),bullet_pat_ptr(a1)
  414. rts
  415. Grenade_Explosion_Types
  416. dc.l Level1_Grenade_Explosion
  417. dc.l Level2_Grenade_Explosion
  418. dc.l Level3_Grenade_Explosion
  419. Extra_Bullets_List_Level1
  420. dc.l explo_bullet_patt7
  421. dc.l explo_bullet_patt5
  422. dc.l explo_bullet_patt4
  423. dc.l explo_bullet_patt3
  424. dc.l explo_grenade_patt1
  425. dc.l explo_bullet_patt1
  426. dc.l explo_bullet_patt3
  427. dc.l explo_bullet_patt7
  428. dc.l explo_bullet_patt6
  429. dc.l explo_grenade_patt2
  430. dc.l explo_bullet_patt5
  431. dc.l explo_bullet_patt6
  432. dc.l explo_bullet_patt1
  433. dc.l explo_bullet_patt2
  434. dc.l explo_grenade_patt3
  435. dc.l explo_bullet_patt3
  436. dc.l explo_bullet_patt2
  437. dc.l explo_bullet_patt8
  438. dc.l explo_bullet_patt5
  439. dc.l explo_grenade_patt4
  440. dc.l explo_bullet_patt8
  441. dc.l explo_bullet_patt6
  442. dc.l explo_bullet_patt4
  443. dc.l explo_bullet_patt3
  444. dc.l explo_grenade_patt5
  445. dc.l explo_bullet_patt2
  446. dc.l explo_bullet_patt4
  447. dc.l explo_bullet_patt7
  448. dc.l explo_bullet_patt6
  449. dc.l explo_grenade_patt6
  450. dc.l explo_bullet_patt8
  451. dc.l explo_bullet_patt7
  452. dc.l explo_bullet_patt2
  453. dc.l explo_bullet_patt1
  454. dc.l explo_grenade_patt7
  455. dc.l explo_bullet_patt1
  456. dc.l explo_bullet_patt4
  457. dc.l explo_bullet_patt8
  458. dc.l explo_bullet_patt5
  459. dc.l explo_grenade_patt8
  460. ************************************************
  461. ****** SETUP BULLET POINTERS ******
  462. ************************************************
  463. Setup_Bullet_Pointers
  464. move.l #bullet_pointers,a0
  465. move.l #bullet_structures,a1
  466. move.w #MAX_BULLETS-1,d0
  467. assign_bullet_mem
  468. move.l a1,(a0)+
  469. add.l #bullet_struct_size,a1
  470. dbra d0,assign_bullet_mem
  471. move.l #$ffffffff,active_bullet_pointers
  472. move.l #bullet_pointers,current_add_bullet_ptr
  473. move.l #active_bullet_pointers,current_bullet_list_ptr
  474. rts
  475. ************************************************
  476. ****** CHECK ROCKET EXPLO ******
  477. ************************************************
  478. Check_Rocket_Explo
  479. cmp.w #2,rocket_level
  480. beq.s do_explosive_tip
  481. rts
  482. do_explosive_tip
  483. move.l a0,d4
  484. move.l a1,d5
  485. move.l a2,d6
  486. move.l a3,d3
  487. move.l #Small_Explo_Bullet,d2
  488. move.w bullet_x(a2),d0
  489. move.w bullet_y(a2),d1
  490. move.w #8-1,d7
  491. move.l current_add_bullet_ptr,a0
  492. move.l current_bullet_list_ptr,a3
  493. move.l #rocket_full_8,a2
  494. add_rocket_explos_loop
  495. cmp.l #$ffffffff,(a0)
  496. beq.s rocket_bullet_list_full
  497. move.l (a0)+,a1
  498. move.w d0,bullet_x(a1)
  499. move.w d1,bullet_y(a1)
  500. clr.w bullet_frame(a1)
  501. clr.w bullet_dead_flag(a1)
  502. move.l d2,bullet_type_ptr(a1)
  503. clr.w bullet_frame_counter(a1)
  504. move.l (a2)+,bullet_pat_ptr(a1)
  505. move.w #6,bullet_hits(a1)
  506. move.l a1,(a3)+
  507. dbra d7,add_rocket_explos_loop
  508. rocket_bullet_list_full
  509. move.l a0,current_add_bullet_ptr
  510. move.l #$ffffffff,(a3)
  511. move.l a3,current_bullet_list_ptr
  512. move.l d4,a0
  513. move.l d5,a1
  514. move.l d6,a2
  515. move.l d3,a3
  516. rts
  517. rocket_full_8
  518. dc.l explo_bullet_patt1
  519. dc.l explo_bullet_patt2
  520. dc.l explo_bullet_patt3
  521. dc.l explo_bullet_patt4
  522. dc.l explo_bullet_patt5
  523. dc.l explo_bullet_patt6
  524. dc.l explo_bullet_patt7
  525. dc.l explo_bullet_patt8
  526. ************************************************
  527. ****** ADD BULLET TO LIST ******
  528. ************************************************
  529. Add_Bullet_To_List
  530. *send x,y in d0 and d1
  531. *send type in d2 (pointer)
  532. move.l current_add_bullet_ptr,a0
  533. cmp.l #$ffffffff,(a0)
  534. beq.s bullet_list_full
  535. move.l (a0)+,a1
  536. move.l a0,current_add_bullet_ptr
  537. move.w d0,bullet_x(a1)
  538. move.w d1,bullet_y(a1)
  539. clr.w bullet_frame(a1)
  540. clr.w bullet_dead_flag(a1)
  541. move.l d2,bullet_type_ptr(a1)
  542. clr.w bullet_frame_counter(a1)
  543. move.l d2,a3
  544. move.l alien_pattern_ptr(a3),bullet_pat_ptr(a1)
  545. move.w alien_hit_count(a3),bullet_hits(a1)
  546. move.l current_bullet_list_ptr,a0
  547. move.l a1,(a0)+
  548. move.l #$ffffffff,(a0)
  549. move.l a0,current_bullet_list_ptr
  550. bullet_list_full
  551. rts
  552. LONG_BULLET_HEIGHT EQU 8
  553. SMALL_BULLET_HEIGHT EQU 6
  554. GREEN_BULLET_HEIGHT EQU 7
  555. ************************************************
  556. ****** SET UP BULLET TYPE ******
  557. ************************************************
  558. Set_Up_Bullet_Type
  559. *First sort out graphics
  560. move.l #small_bullets,a0
  561. move.w gun_type,d0
  562. beq.s small_bullet_class
  563. cmp.w #4,d0
  564. beq.s green_bullet_class
  565. move.l #long_bullet_type,a1
  566. move.w #LONG_BULLET_HEIGHT,d1
  567. bra.s copy_bullet_data
  568. green_bullet_class
  569. move.l #green_bullet_type,a1
  570. move.w #GREEN_BULLET_HEIGHT,d1
  571. bra.s copy_bullet_data
  572. small_bullet_class
  573. move.l #small_bullet_type,a1
  574. move.w #SMALL_BULLET_HEIGHT,d1
  575. copy_bullet_data
  576. move.w d1,d2
  577. move.l a0,a2
  578. mulu #(2*5*8)/2,d1 (*5 cos includes mask)
  579. subq.w #1,d1
  580. copy_bullet_data_loop
  581. move.w (a1)+,(a0)+
  582. dbra d1,copy_bullet_data_loop
  583. *calculate data to put into structs
  584. *a2 = graphics
  585. move.w d2,d4
  586. asl d4
  587. move.w d4,d5 ;frame size
  588. asl #3,d4 ;plane size
  589. move.l #small_bullet_up,a4 ;start of structs
  590. move.w #NUMBER_OF_BULLET_STRUCTS-1,d7
  591. update_bullet_structs_loop
  592. moveq #0,d3
  593. move.b alien_type_number(a4),d3
  594. move.w d2,alien_x_size(a4)
  595. move.w d2,alien_y_size(a4)
  596. move.w d4,alien_plane_size(a4)
  597. move.w d5,alien_frame_size(a4)
  598. move.w d2,d6
  599. asl d6
  600. mulu d3,d6 ;give offset into data
  601. move.l a2,a3
  602. add.l d6,a3
  603. move.l a3,alien_graphics(a4)
  604. move.w d2,d6
  605. asl d6
  606. asl #5,d6
  607. ext.l d6
  608. add.l d6,a3
  609. move.l a3,alien_mask(a4)
  610. moveq #0,d6
  611. move.w d2,d6
  612. asl #6,d6
  613. add.w #2,d6
  614. move.w d6,alien_blit_size(a4)
  615. add.l #SIZE_OF_BULLET_STRUCT,a4
  616. dbra d7,update_bullet_structs_loop
  617. rts
  618. ************************************************
  619. ****** SET UP ROCKET TYPE ******
  620. ************************************************
  621. Set_Up_Rocket_Type
  622. clr.w d1
  623. tst rocket_level
  624. beq.s base_rocket_level
  625. move.w #10,d1 ;hits rocket can withstand
  626. base_rocket_level
  627. move.l #rocket_up,a0
  628. move.w #8-1,d0
  629. set_up_rocket_hits
  630. move.w d1,alien_hit_count(a0)
  631. add.l #alien_info_struct_size,a0
  632. dbra d0,set_up_rocket_hits
  633. rts
  634. ************************************************
  635. ****** PROCESS BULLETS ******
  636. ************************************************
  637. Process_Bullets
  638. *Only a quick version just so can see aliens up and running
  639. move.l #active_bullet_pointers,a0
  640. move.l end_alien_draw_ptr,a1
  641. move.l a0,a3
  642. process_bullet_loop
  643. cmp.l #$ffffffff,(a0)
  644. beq finished_processing_bullets
  645. move.l (a0),a2
  646. *-----------------Is bullet dead---------------------
  647. move.w bullet_x(a2),d0
  648. move.w bullet_y(a2),d1
  649. tst.w bullet_dead_flag(a2)
  650. bne bullet_dead
  651. *------------------Has bullet hit a block?--------------
  652. move.l alien_type_ptr(a2),a4
  653. btst.b #NO_EXPLODE,alien_type_flags(a4)
  654. bne bullet_not_hit_block
  655. move.l current_map_pointer,a4
  656. moveq #0,d2
  657. andi.w #$fff0,d0 ;get block co-cords
  658. andi.w #$fff0,d1
  659. move.w d0,d2
  660. move.w d1,d3
  661. asr.w #3,d2 ;word map
  662. asr.w #4,d3
  663. muls #BIGGEST_MAP_X*MAP_BLOCK_SIZE,d3
  664. add.l d2,a4
  665. add.l d3,a4
  666. move.w (a4),d2 ;block
  667. asl #BLOCK_STRUCT_MULT,d2
  668. move.l #block_data_information,a5
  669. add.l d2,a5
  670. move.b block_details(a5),d7 ;our data
  671. btst #BULLET_DIE_FLAG,d7
  672. beq.s bullet_not_hit_block
  673. move.w #Sound_Thud,Sound_Chan2 ;default sound
  674. clr.l d7
  675. move.b block_type(a5),d7
  676. andi.w #$f0,d7
  677. beq.s bullet_dead ; no data to act on
  678. lsr.w #2,d7 ;get data, but leave shifted up by 2
  679. move.l #bullet_hit_routine_table,a5
  680. move.l (a5,d7),a5
  681. jsr (a5) ;call bullet hit routine
  682. *----------What happens if bullet dead
  683. bullet_dead
  684. move.l bullet_type_ptr(a2),a4
  685. move.l alien_dead_pattern(a4),a5
  686. bra process_bullet_script
  687. bullet_not_hit_block
  688. *-----------------Is bullet out of bounds------------
  689. sub.w scroll_x_position,d0
  690. sub.w scroll_y_position,d1
  691. cmp.w #-16,d1
  692. ble kill_off_bullet
  693. cmp.w #240+16,d1
  694. bge kill_off_bullet
  695. cmp.w #-16,d0
  696. ble kill_off_bullet
  697. cmp.w #320+16,d0
  698. bge kill_off_bullet
  699. *----------------Great bullet in bounds so update bullet----
  700. move.l bullet_type_ptr(a2),a4
  701. move.l bullet_pat_ptr(a2),a5
  702. process_bullet_script
  703. movem.l a3/a0,-(sp)
  704. move.l #Bullet_Commands,a3
  705. process_bullet_commands
  706. cmp.w #START_COMMANDS,(a5)
  707. blt.s no_bullet_commands
  708. moveq #0,d7
  709. move.w (a5)+,d7
  710. sub.w #OBJECT_SET_PAT,d7
  711. asl.w #2,d7
  712. move.l (a3,d7),a0
  713. jsr (a0)
  714. bra.s process_bullet_commands
  715. no_bullet_commands
  716. move.w (a5)+,d0
  717. add.w d0,bullet_x(a2)
  718. move.w (a5)+,d1
  719. add.w d1,bullet_y(a2)
  720. done_commands
  721. move.l a5,bullet_pat_ptr(a2)
  722. movem.l (sp)+,a3/a0
  723. tst bullet_dead_flag(a2)
  724. bne.s kill_off_bullet
  725. *----------update bullet frames
  726. move.w bullet_frame(a2),alien_draw_frame(a1)
  727. subq.w #1,bullet_frame_counter(a2)
  728. bgt.s dont_update_bullet_frame
  729. addq.w #1,bullet_frame(a2)
  730. move.w alien_frame_rate(a4),bullet_frame_counter(a2)
  731. move.w alien_number_frames(a4),d2
  732. cmp.w bullet_frame(a2),d2
  733. bgt.s dont_update_bullet_frame
  734. clr.w bullet_frame(a2)
  735. dont_update_bullet_frame
  736. *----------------
  737. move.l a2,alien_struct_ptr(a1)
  738. add.l #alien_draw_size,a1
  739. move.l a2,(a3)+
  740. bra.s update_bullet_mem
  741. kill_off_bullet
  742. *put bullet back into list
  743. move.l current_add_bullet_ptr,a4
  744. subq.l #4,a4
  745. move.l (a0),(a4)
  746. move.l a4,current_add_bullet_ptr
  747. update_bullet_mem
  748. addq.l #4,a0
  749. bra process_bullet_loop
  750. finished_processing_bullets
  751. move.l #$ffffffff,(a3)
  752. move.l #$ffffffff,(a1) ;term draw list
  753. move.l a3,current_bullet_list_ptr
  754. rts
  755. *----------------Bullet Pattern Commmands
  756. Bullet_Commands
  757. dc.l Bullet_Object_Set_Pat
  758. dc.l Bullet_Object_Set_Frame
  759. dc.l Bullet_Object_Kill
  760. dc.l Bullet_Object_Add
  761. dc.l Bullet_Object_Simple_Add
  762. dc.l Bullet_Bullet_List_Add
  763. dc.l Bullet_Pattern_Restart
  764. dc.l Alien_Sound_Effect_1
  765. dc.l Alien_Sound_Effect_2
  766. dc.l Alien_Sound_Effect_3
  767. dc.l Alien_Sound_Effect_4
  768. dc.l Bullet_Execute_Code
  769. dc.l Bullet_Add_Lots
  770. Bullet_Bullet_List_Add
  771. movem.l a0-a1/a3,-(sp)
  772. move.w bullet_x(a2),d0
  773. move.w bullet_y(a2),d1
  774. add.w (a5)+,d0
  775. add.w (a5)+,d1
  776. move.l (a5)+,d2
  777. bsr Add_Bullet_To_List
  778. movem.l (sp)+,a0-a1/a3
  779. rts
  780. Bullet_Object_Add
  781. move.w bullet_x(a2),d0
  782. move.w bullet_y(a2),d1
  783. add.w (a5)+,d0
  784. add.w (a5)+,d1
  785. move.w (a5)+,d2
  786. bsr Add_Alien_To_List
  787. rts
  788. Bullet_Object_Simple_Add
  789. move.w bullet_x(a2),d0
  790. move.w bullet_y(a2),d1
  791. add.w (a5)+,d0
  792. add.w (a5)+,d1
  793. move.l (a5)+,d2
  794. bsr Simple_Add_Alien_To_List
  795. rts
  796. Bullet_Object_Set_Frame
  797. move.w (a5)+,bullet_frame(a2)
  798. rts
  799. Bullet_Object_Set_Pat
  800. move.l (a5)+,a5
  801. rts
  802. Bullet_Pattern_Restart
  803. move.l alien_pattern_ptr(a4),a5
  804. rts
  805. Bullet_Object_Kill
  806. move.w #1,bullet_dead_flag(a2)
  807. rts
  808. Bullet_Execute_Code
  809. move.l (a5)+,d7
  810. bsr Check_Rocket_Explo ;only ever be used for this
  811. rts
  812. Bullet_Add_Lots
  813. move.l a0,d5 ;faster than stack
  814. move.l a1,d6
  815. move.l a3,d7
  816. move.w bullet_x(a2),d0
  817. move.w bullet_y(a2),d1
  818. add.w (a5)+,d0
  819. add.w (a5)+,d1
  820. Bullet_Keep_Adding_Simples
  821. move.l (a5)+,d2
  822. cmp.l #$ffffffff,d2
  823. beq.s bullet_finished_adding_simples
  824. bsr Add_Bullet_To_List
  825. bra.s Bullet_Keep_Adding_Simples
  826. Bullet_finished_adding_simples
  827. move.l d5,a0 ;faster than stack
  828. move.l d6,a1
  829. move.l d7,a3
  830. rts
  831. *----------------End Bullet pattern commands
  832. basic_bullet_table
  833. dc.l 0,0,0,0 ;0
  834. dc.l small_bullet_left,small_bullet_left_b ;1
  835. dc.l small_bullet_left_c,0
  836. dc.l small_bullet_right,small_bullet_right_b ;2
  837. dc.l small_bullet_right_c,0
  838. dc.l 0,0,0,0 ;3
  839. dc.l small_bullet_up,small_bullet_up_b ;4
  840. dc.l small_bullet_up_c,0
  841. dc.l small_bullet_up_left,small_bullet_up_left_b ;5
  842. dc.l small_bullet_up_left_c,0
  843. dc.l small_bullet_up_right,small_bullet_up_right_b ;6
  844. dc.l small_bullet_up_right_c,0
  845. dc.l 0,0,0,0 ;7
  846. dc.l small_bullet_down,small_bullet_down_b ;8
  847. dc.l small_bullet_down_c,0
  848. dc.l small_bullet_down_left,small_bullet_down_left_b ;9
  849. dc.l small_bullet_down_left_c,0
  850. dc.l small_bullet_down_right,small_bullet_down_right_b ;10
  851. dc.l small_bullet_down_right_c,0
  852. rocket_table
  853. dc.l 0 ;0
  854. dc.l rocket_left ;1
  855. dc.l rocket_right ;2
  856. dc.l 0 ;3
  857. dc.l rocket_up ;4
  858. dc.l rocket_up_left ;5
  859. dc.l rocket_up_right ;6
  860. dc.l 0 ;7
  861. dc.l rocket_down ;8
  862. dc.l rocket_down_left ;9
  863. dc.l rocket_down_right ;10
  864. Grenade_Table
  865. dc.l 0 ;0
  866. dc.l Grenade_Left ;1
  867. dc.l Grenade_Right ;2
  868. dc.l 0 ;3
  869. dc.l Grenade_Up ;4
  870. dc.l Grenade_Up_left ;5
  871. dc.l Grenade_Up_right ;6
  872. dc.l 0 ;7
  873. dc.l Grenade_down ;8
  874. dc.l Grenade_down_left ;9
  875. dc.l Grenade_down_right ;10
  876. *basic bullet struct
  877. rsreset
  878. bullet_x rs.w 1
  879. bullet_y rs.w 1
  880. bullet_type_ptr rs.l 1 ;same as alien type ptr
  881. bullet_dead_flag rs.w 1
  882. bullet_pat_ptr rs.l 1
  883. bullet_frame rs.w 1
  884. bullet_frame_counter rs.w 1
  885. bullet_hits rs.w 1
  886. bullet_struct_size rs.w 1
  887. Unit_Table
  888. dc.w 0,0
  889. dc.w -1,0
  890. dc.w 1,0
  891. dc.w 0,0
  892. dc.w 0,-1
  893. dc.w -1,-1
  894. dc.w 1,-1
  895. dc.w 0,0
  896. dc.w 0,1
  897. dc.w -1,1
  898. dc.w 1,1
  899. player_frame_offsets
  900. dc.l player_bullet_offset_table_frame1
  901. dc.l player_bullet_offset_table_frame2
  902. dc.l player_bullet_offset_table_frame3 ;third
  903. dc.l player_bullet_offset_table_frame4
  904. dc.l player_bullet_offset_table_frame5
  905. dc.l player_bullet_offset_table_frame6
  906. player_bullet_offset_table_frame1
  907. dc.w 0,0
  908. dc.w BULLET_INC,14 ;left_offsets
  909. dc.w 28-BULLET_INC,14 ;right_offsets
  910. dc.w 0,0
  911. dc.w 17,1+BULLET_INC ;up_offets
  912. dc.w 0+BULLET_INC,4+BULLET_INC ;up_left_offsets
  913. dc.w 28-BULLET_INC,2+BULLET_INC ;up_right_offsets
  914. dc.w 0,0
  915. dc.w 11,27-BULLET_INC ;down_offsets
  916. dc.w 4+BULLET_INC,22-BULLET_INC ;down_left_offsets
  917. dc.w 28-BULLET_INC,25-BULLET_INC ;down_right_offsets
  918. player_bullet_offset_table_frame2
  919. dc.w 0,0
  920. dc.w -1+BULLET_INC,13 ;left_offsets
  921. dc.w 28-BULLET_INC,13 ;right_offsets
  922. dc.w 0,0
  923. dc.w 18,1+BULLET_INC ;up_offets
  924. dc.w 1+BULLET_INC,3+BULLET_INC ;up_left_offsets
  925. dc.w 27-BULLET_INC,1+BULLET_INC ;up_right_offsets
  926. dc.w 0,0
  927. dc.w 11,26-BULLET_INC ;down_offsets
  928. dc.w 3+BULLET_INC,21-BULLET_INC ;down_left_offsets
  929. dc.w 29-BULLET_INC,24-BULLET_INC ;down_right_offsets
  930. player_bullet_offset_table_frame3
  931. dc.w 0,0
  932. dc.w -1+BULLET_INC,12 ;left_offsets
  933. dc.w 27-BULLET_INC,12 ;right_offsets
  934. dc.w 0,0
  935. dc.w 19,1+BULLET_INC ;up_offets
  936. dc.w 2+BULLET_INC,2+BULLET_INC ;up_left_offsets
  937. dc.w 26-BULLET_INC,1+BULLET_INC ;up_right_offsets
  938. dc.w 0,0
  939. dc.w 9,26-BULLET_INC ;down_offsets
  940. dc.w 2+BULLET_INC,20-BULLET_INC ;down_left_offsets
  941. dc.w 30-BULLET_INC,24-BULLET_INC ;down_right_offsets
  942. player_bullet_offset_table_frame4
  943. dc.w 0,0
  944. dc.w 0+BULLET_INC,11 ;left_offsets
  945. dc.w 28-BULLET_INC,12 ;right_offsets
  946. dc.w 0,0
  947. dc.w 20,1+BULLET_INC ;up_offets
  948. dc.w 3+BULLET_INC,2+BULLET_INC ;up_left_offsets
  949. dc.w 27-BULLET_INC,1+BULLET_INC ;up_right_offsets
  950. dc.w 0,0
  951. dc.w 8,27-BULLET_INC ;down_offsets
  952. dc.w 1+BULLET_INC,20-BULLET_INC ;down_left_offsets
  953. dc.w 29-BULLET_INC,24-BULLET_INC ;down_right_offsets
  954. player_bullet_offset_table_frame5
  955. dc.w 0,0
  956. dc.w -1+BULLET_INC,12 ;left_offsets
  957. dc.w 28-BULLET_INC,13 ;right_offsets
  958. dc.w 0,0
  959. dc.w 19,1+BULLET_INC ;up_offets
  960. dc.w 2+BULLET_INC,2+BULLET_INC ;up_left_offsets
  961. dc.w 28-BULLET_INC,2+BULLET_INC ;up_right_offsets
  962. dc.w 0,0
  963. dc.w 9,26-BULLET_INC ;down_offsets
  964. dc.w 2+BULLET_INC,20-BULLET_INC ;down_left_offsets
  965. dc.w 28-BULLET_INC,25-BULLET_INC ;down_right_offsets
  966. player_bullet_offset_table_frame6
  967. dc.w 0,0
  968. dc.w -1+BULLET_INC,13 ;left_offsets
  969. dc.w 27-BULLET_INC,14 ;right_offsets
  970. dc.w 0,0
  971. dc.w 18,1+BULLET_INC ;up_offets
  972. dc.w 1+BULLET_INC,3+BULLET_INC ;up_left_offsets
  973. dc.w 29-BULLET_INC,3+BULLET_INC ;up_right_offsets
  974. dc.w 0,0
  975. dc.w 10,26-BULLET_INC ;down_offsets
  976. dc.w 3+BULLET_INC,19-BULLET_INC ;down_left_offsets
  977. dc.w 27-BULLET_INC,26-BULLET_INC ;down_right_offsets