level_code.s 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. **************************************
  2. **** RESET LEVEL ****
  3. **************************************
  4. Reset_Level
  5. move.b #'A',level_number
  6. move.l #level_list,current_level_list_ptr
  7. rts
  8. **************************************
  9. **** SET UP LEVEL POINTERS ****
  10. **************************************
  11. Set_Up_Level_Pointers
  12. *level_graphics_ptr should be changed so it can act as a flag
  13. *to see if new graphics need to be loaded for the level
  14. move.l current_level_list_ptr,a0
  15. cmp.l #$ffffffff,(a0)
  16. bne.s not_end_of_level_list
  17. move.l #Level_List,current_level_list_ptr
  18. move.b #'A',level_number
  19. bra.s Set_Up_Level_Pointers
  20. not_end_of_level_list
  21. move.l (a0),a0
  22. move.l a0,current_level
  23. move.l background_block_graphics,level_background_blocks
  24. move.l level_palette_ptr(a0),level_palette
  25. move.l level_sprite_palette_ptr(a0),sprite_palette
  26. move.w level_map_x_start(a0),scroll_x_position
  27. move.w level_map_y_start(a0),scroll_y_position
  28. move.w #144,d0 ;player always starts in middle
  29. move.w #120,d1
  30. asl #PLAYER_SCALE,d0
  31. asl #PLAYER_SCALE,d1
  32. move.w d0,player_x_position
  33. move.w d1,player_y_position
  34. asr #PLAYER_SCALE,d0
  35. asr #PLAYER_SCALE,d1
  36. move.w d0,actual_x_position
  37. move.w d1,actual_y_position
  38. add.w level_map_x_start(a0),d0
  39. add.w level_map_y_start(a0),d1
  40. move.w d0,actual_player_map_x_position
  41. move.w d1,actual_player_map_y_position
  42. move.w d0,last_scrollx_position
  43. move.w d1,last_scrolly_position
  44. rts
  45. **************************************
  46. **** DO_LEVEL_COLOURS ****
  47. **************************************
  48. Do_Level_Colours
  49. move.l #copper_colours,a0
  50. move.l level_palette,a1
  51. bsr Insert_Colours
  52. rts
  53. **************************************
  54. **** DO_SPRITE_COLOURS ****
  55. **************************************
  56. Do_Sprite_Colours
  57. move.l #sprite_cols,a0
  58. move.l sprite_palette,a1
  59. bsr Insert_Sprite_Colours
  60. rts
  61. **************************************
  62. **** INITIALISE_LEVEL ****
  63. **************************************
  64. Initialise_Level
  65. *Set up custom base
  66. move.l #$dff000,a6
  67. *free scroll
  68. clr.w freeze_scroll
  69. *Set up alien strength
  70. bsr Set_Up_Alien_Strengths
  71. *Set up bullet data
  72. bsr Set_Up_Bullet_Type
  73. bsr Set_Up_Rocket_Type
  74. *Set up Variables
  75. bsr Set_Up_Variables
  76. bsr Set_Up_Gun_Power
  77. bsr Do_Sprite_Colours
  78. bsr Setup_Bullet_Pointers
  79. bsr Switch_Setup
  80. bsr Set_Up_Panel
  81. bsr Display_Total_Energy_Bars
  82. bsr Display_Total_Energy
  83. bsr Display_Player_Lives
  84. bsr Display_Weapon_Power_Level
  85. bsr Display_Grenade_Packs
  86. bsr Display_Weapon_On_Panel
  87. bsr Do_Money_Update ;clears cash indicator
  88. bsr Fill_Random_Table
  89. move.w #100,Player_Invincible_Timer ;start flashing buddy
  90. *Load in map data
  91. bsr Load_Map_Data
  92. bsr Setup_Scanner
  93. bsr Setup_Scanner_Data ;dependent on new map
  94. *Setup and draw map onto screen
  95. bsr Setup_Alien_Pointers
  96. bsr set_up_scroll_position
  97. move.l loader_pic_data,a0
  98. add.l #size_of_iff_header+4,a0
  99. move.l #black_list,a1
  100. move.l #share_cols+2,a2
  101. move.w #16-1,d7
  102. move.l #store_text_nums,a3
  103. move.w #1,fade_speed
  104. bsr Fade_32_List_To_List
  105. move.l current_level,a0
  106. move.w level_map_x_start(a0),d0
  107. move.w level_map_y_start(a0),d1
  108. *Insert specific sound player routine depending on level
  109. cmp.w #OFF,xtra_fx ;dont bother if sfx not loaded
  110. beq.s Insert_Regular_Player
  111. cmp.b #'B',level_number
  112. beq.s Insert_3_Chan_Player
  113. cmp.b #'G',level_number
  114. beq.s Insert_3_Chan_Player
  115. Insert_Regular_Player
  116. move.l #Sound_Effects_Normal,sound_effects_code
  117. bra.s Turn_On_Screen
  118. Insert_3_Chan_Player
  119. move.l #Sound_Effects_3_Chan,sound_effects_code
  120. Turn_On_Screen
  121. move.w #BIT_PLANE_DMA,dmacon(a6) ;hide sins
  122. bsr fill_screen_with_blocks
  123. rts
  124. **************************************
  125. **** SET UP VARIABLES ****
  126. **************************************
  127. Set_Up_Variables
  128. move.w gun_level,weapon_level
  129. move.w gun_type,weapon_power
  130. move.w #DEFAULT_DISTANCE,grenade_distance
  131. clr.w wasps_on_screen
  132. clr.w pigs_on_screen
  133. clr.w number_of_keys
  134. clr.w Inter_Score
  135. clr.w End_of_level_key
  136. clr.w last_x_direc
  137. clr.w last_y_direc
  138. clr.w player_x_inc
  139. clr.w player_y_inc
  140. clr.w generator_activate
  141. move.l current_level,a5
  142. move.l level_generator_pattern(a5),Generator_Level_Pattern
  143. move.l level_generator_pattern(a5),Chain_Generator_Level_Pattern ;botch
  144. move.b #PLAYER_DOWN,man_direction
  145. move.w #PLAYER_DOWN,last_direction
  146. clr.w player_current_frame
  147. clr.w sound_chan1
  148. clr.w sound_chan2
  149. clr.w sound_chan3
  150. clr.w sound_chan4
  151. bsr Clear_Key_Indicators
  152. rts
  153. **************************************
  154. **** RESET MAIN GAME VARS ****
  155. **************************************
  156. Reset_Main_Game_Vars
  157. bsr Reset_Energy_Bars
  158. move.w #2,current_energy_modules
  159. move.w current_energy_modules,d0
  160. asl #2,d0
  161. mulu #NUMBER_HITS_PER_UNIT,d0
  162. move.w d0,Player_Current_Energy
  163. move.w d0,Player_Energy_Limit
  164. clr.w QuitFromGame
  165. move.w #3,Player_Lives ;*****
  166. move.w #3,Continue_Credits
  167. clr.w Cash
  168. clr.l score
  169. clr.w stars_up
  170. clr.w title_pic_loaded
  171. move.w #STANDARD_GUN,weapon_power
  172. clr.w gun_level
  173. move.w #STANDARD_GUN,gun_type
  174. clr.w rocket_level
  175. clr.w grenade_level
  176. clr.w weapon_level
  177. clr.w rocket_packs
  178. clr.w rockets_in_pack
  179. clr.w grenade_packs
  180. clr.w grenades_in_pack
  181. bsr Set_Up_Shop_Prices
  182. rts
  183. **************************************
  184. **** FILL RANDOM TABLE ****
  185. **************************************
  186. Fill_Random_Table
  187. *Get number for seed
  188. move.w $dff006,old_seed ;good for a laugh
  189. move.l #random_direction_table,a4
  190. move.l a4,random_direction_ptr ;reset
  191. move.l #get_direction_from_num_table,a5
  192. move.w #NUMBER_OF_RAN_DIRS-1,d7
  193. get_random_dir
  194. moveq #0,d0
  195. move.w #7,d1
  196. bsr Get_Random_Number
  197. ext.l d0
  198. move.b (a5,d0),(a4)+
  199. dbra d7,get_random_dir
  200. rts
  201. get_direction_from_num_table
  202. dc.b %0000 ;up
  203. dc.b %0001 ;down right
  204. dc.b %0010 ;right
  205. dc.b %0101 ;down left
  206. dc.b %1000 ;down
  207. dc.b %0110 ;left
  208. dc.b %1001 ;up right
  209. dc.b %1101 ;up left
  210. ****************************************
  211. ****** SET UP GUN POWER *****
  212. ****************************************
  213. Set_Up_Gun_Power
  214. *STANDARD GUN - TRIPLE
  215. move.w weapon_power,d0
  216. asr #2,d0
  217. addq.w #1,d0
  218. move.w gun_level,d1
  219. addq.w #1,d1
  220. mulu d1,d0
  221. move.w d0,gun_power
  222. move.w weapon_power,current_weapon
  223. rts
  224. ****************************************
  225. ****** CHANGE LEVEL *****
  226. ****************************************
  227. Change_Level
  228. bsr Black_Out_Everything
  229. addq.l #4,current_level_list_ptr
  230. addq.b #1,level_number
  231. bsr Game_Set_Up
  232. bsr Setup_System
  233. rts
  234. *******************************************
  235. ***** LEVEL LOADING ROUTINE *******
  236. *******************************************
  237. Level_Loading_Routine
  238. *just for now clear planes
  239. move.w #$5200,shareware_screen_copper+2
  240. move.w #$38,sharestart
  241. move.w #$d0,sharestop
  242. move.w #((LO_RES_PLANE*5)/4)-1,d1
  243. move.l memory_base,a0
  244. tst loader_type
  245. bne.s skip_add_map
  246. add.l #(BIGGEST_MAP_X*BIGGEST_MAP_Y*3),a0
  247. skip_add_map
  248. move.l a0,d0
  249. clear_temp
  250. clr.l (a0)+
  251. dbra d1,clear_temp
  252. move.l #plane_positions,a2
  253. move.l d0,(a2)
  254. move.w d0,SHPlane1_lo
  255. swap d0
  256. move.w d0,SHPlane1_hi
  257. swap d0
  258. add.l #LO_RES_PLANE,d0
  259. move.l d0,4(a2)
  260. move.w d0,SHPlane2_lo
  261. swap d0
  262. move.w d0,SHPlane2_hi
  263. swap d0
  264. add.l #LO_RES_PLANE,d0
  265. move.l d0,8(a2)
  266. move.w d0,SHPlane3_lo
  267. swap d0
  268. move.w d0,SHPlane3_hi
  269. swap d0
  270. add.l #LO_RES_PLANE,d0
  271. move.l d0,12(a2)
  272. move.w d0,SHPlane4_lo
  273. swap d0
  274. move.w d0,SHPlane4_hi
  275. swap d0
  276. add.l #LO_RES_PLANE,d0
  277. move.l d0,16(a2)
  278. move.w d0,SHPlane5_lo
  279. swap d0
  280. move.w d0,SHPlane5_hi
  281. **********decompress nebula background*********
  282. moveq #0,d3 ;index into plane table
  283. move.w #320,d4 ;screen x size
  284. move.w #5*4,d7 ;number of planes ( *4 cos compare d3 with it - will inc by 4)
  285. move.w #320,d6 ; pixel count ( count down )
  286. move.w #320,d5 ; image loaded size
  287. move.l (a2,d3),a4 ;get first plane
  288. move.l loader_pic_data,a1
  289. addq.l #4,a1 ;skip ident
  290. move.w iff_cols(a1),d0
  291. move.l pic_data_size(a1),size_of_pic
  292. ext.l d0
  293. asl d0
  294. add.l #size_of_iff_header,a1
  295. add.l d0,a1
  296. move.l a1,picture_data
  297. moveq #0,d0 ;clear
  298. move.l size_of_pic,d2
  299. bsr compressed_data ;Display pic
  300. ***********Finished decompressing nebula pic*********
  301. bsr Clear_Black_Colours
  302. bsr Clear_Game_Colours
  303. move.l #Share_Cols,a0
  304. move.l #Black_List,a1
  305. bsr Insert_32Colours
  306. move.l #shareware_screen_copper,cop1lch(a6)
  307. clr.w copjmp1(a6)
  308. jsr Sync
  309. move.w #BIT_PLANE_DMA+SPRITE_DMA+$8000,dmacon(a6)
  310. move.l #black_list,a0
  311. move.l loader_pic_data,a1
  312. add.l #size_of_iff_header+4,a1
  313. move.l #share_cols+2,a2
  314. move.w #16-1,d7
  315. move.l #store_text_nums,a3
  316. move.w #1,fade_speed
  317. bsr Fade_32_List_To_List
  318. bsr Wait_For_Blit_To_Finish
  319. move.w #1,FadeAfterLoading
  320. clr.w loader_type
  321. rts
  322. loader_type dc.w 0 ;0=level load, 1=general load
  323. level_loading_flag dc.w 0
  324. *******************************************
  325. ***** WAIT FOR BLIT TO FINISH *******
  326. *******************************************
  327. Wait_For_Blit_To_Finish
  328. btst #14,dmaconr(a6)
  329. bne.s Wait_For_Blit_To_Finish
  330. rts
  331. **************************************
  332. **** SET UP ALIEN STRENGTHS ****
  333. **************************************
  334. Set_Up_Alien_Strengths
  335. move.l current_level,a0
  336. move.l level_strength_table(a0),a0
  337. cmp.l #0,a0
  338. beq.s finished_strengths
  339. Set_Up_Strengths_Loop
  340. cmp.l #$ffffffff,(a0)
  341. beq.s finished_strengths
  342. move.l (a0)+,a1
  343. move.w (a0)+,alien_hit_count(a1)
  344. bra.s Set_Up_Strengths_Loop
  345. finished_strengths
  346. rts
  347. level_background_blocks dc.l 0
  348. level_map dc.l 0
  349. current_level dc.l Level_1
  350. level_palette dc.l 0
  351. sprite_palette dc.l 0
  352. map_x_size dc.w 0
  353. map_y_size dc.w 0
  354. Generator_Activate dc.w 0
  355. Continue_Credits dc.w 0
  356. Enable_Continues dc.w 0