main.s 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669
  1. *-(c) Glen Cumming 1993/1994/1995/1996 -*
  2. *- -*
  3. *-Hello and welcome to another episode in wasted opportunitys -*
  4. *-I hereby condem this code to the same hell as Squiz - a 1200 -*
  5. *-only game which I had ready a few months after the launch of -*
  6. *-the 1200 which had parallax scrolling, lots of colours all -*
  7. *-running at 50Hz - but no bastard was interested in helping me -*
  8. *-and Stuart develop it -*
  9. *-Well I bid the Amiga and games programming goodbye, its -*
  10. *-too much sodding work for naff all appreciation (CU AMIGA), -*
  11. *-I might as well spend my time writting shitty 'C' programs for-*
  12. *-a big company, working 37.5 hours a week and getting paid 18K -*
  13. *-or upwards. Games programming...I'd be lucky to get taken on -*
  14. *-at 12K and the hours - who wants to work 18 hours a day?? -*
  15. *- -*
  16. *-So here is the complete code for ABII, do with it what you -*
  17. *-like, I do not claim that it is much good, but someone out -*
  18. *-there may find a use for bits of it....towards the end of the -*
  19. *-game I got very sloppy - normally my code looks quite nice. -*
  20. *-If you do find it useful, give me a credit somewhere, or send -*
  21. *-me something you have done, if anyone wants anything -*
  22. *-explained (it is all simple though) drop me a line at : -*
  23. *-WHITEHOUSE BARN FARM, ENGLISH BICKNOR, NR.COLEFORD, GLOS, -*
  24. *-GL16 7PA, Tele: 01594 861453 -*
  25. section Bashii,CODE
  26. OPT C-,D+
  27. opt NODEBUG
  28. opt p=68000
  29. incdir "tools:devpac/include"
  30. include "exec/exec_lib.i"
  31. include "exec/exec.i"
  32. include "libraries/dosextens.i"
  33. incdir "code:AlienBashII"
  34. include "glens_code/equates.s"
  35. include "glens_code/game_equates.s"
  36. *Assembler directions
  37. LOAD_FROM_HARD_DISK EQU 0
  38. *final_version EQU 0
  39. *-----------Entry point to AlienBashII----------------*
  40. movem.l d0/a0,-(sp)
  41. jsr Open_Dos
  42. sub.l a1,a1
  43. move.l 4.w,a6
  44. jsr _LVOFindTask(a6)
  45. move.l d0,a4
  46. tst.l pr_CLI(a4) ; was it called from CLI?
  47. bne.s fromCLI ; if so, skip out this bit...
  48. lea pr_MsgPort(a4),a0
  49. move.l 4.w,a6
  50. jsr _LVOWaitPort(A6)
  51. lea pr_MsgPort(a4),a0
  52. jsr _LVOGetMsg(A6)
  53. move.l d0,returnMsg
  54. jsr Find_Program_Directory
  55. fromCLI
  56. movem.l (sp)+,d0/a0
  57. bsr Stop_System ;Stop tasking
  58. bsr Allocate_Game_Memory
  59. tst.l d0
  60. beq.s cant_start_game
  61. bsr Allocate_SFX ; have we lots of chip mem??
  62. tst.l d0 ;OK?
  63. beq.s cant_start_game
  64. jsr AGA_Enhancements ; can we have music during game - enough speed??
  65. bsr Setup_Int
  66. bsr Blank_Out_Workbench
  67. jsr Create_Fade_Palettes
  68. bsr Set_Up_Sound_Fx ; get offsets into allocted data
  69. bsr Convert_Clip_Data ; Set up scanner stuff (only needs doing once)
  70. bsr Load_Game_Basics
  71. bsr low_pas_filter_off
  72. bsr Scheduler
  73. bsr Replace_System ;Dealloc mem etc
  74. cant_start_game
  75. bsr Release_System ;Enable tasking again
  76. move.l d0,-(sp)
  77. tst.l returnMsg ; Is there a message?
  78. beq.s exitToDOS ; if not, skip...
  79. jsr Reset_To_Old_Directory
  80. move.l 4.w,a6
  81. jsr _LVOForbid(a6) ; note! No Permit needed!
  82. move.l returnMsg(pc),a1
  83. jsr _LVOReplyMsg(a6)
  84. exitToDOS
  85. jsr Close_Dos
  86. move.l (sp)+,d0 ; exit code
  87. rts
  88. returnMsg dc.l 0
  89. QUIT_GAME EQU -99
  90. GAME_LOOP EQU 0
  91. MAN_DEATH EQU 1*4
  92. INTRO EQU 2*4
  93. GAME_SETUP EQU 3*4
  94. CREDITS EQU 4*4
  95. HI_SCORES EQU 5*4
  96. GAME_OVER EQU 6*4
  97. INSTRUCTIONS EQU 7*4
  98. END_LEVEL EQU 8*4
  99. SHOP_SCREEN EQU 9*4
  100. HI_SCORE_ENTRY EQU 10*4
  101. NEXT_LEVEL EQU 11*4
  102. LEVEL_LOADING EQU 12*4
  103. SKIP_LEVEL EQU 13*4
  104. ******************************************
  105. ***** SCHEDULER *****
  106. ******************************************
  107. Scheduler
  108. cmp.w #QUIT_GAME,Schedule_entry
  109. beq.s Finished_Game
  110. moveq #0,d0
  111. move.w Schedule_entry,d0
  112. move.l #schedule_table,a0
  113. move.l (a0,d0),a0
  114. jsr (a0)
  115. bra.s Scheduler
  116. Finished_Game
  117. rts
  118. Schedule_Entry
  119. dc.w CREDITS
  120. Schedule_table
  121. dc.l Main_Game_Routine
  122. dc.l Man_Death_Routine
  123. dc.l Intro_Routine
  124. dc.l Set_Game_Environment
  125. dc.l Title_Screen
  126. dc.l Show_Hi_Scores
  127. dc.l Game_Over_Routine
  128. dc.l Show_Instructions
  129. dc.l End_Of_Level_Routine
  130. dc.l Open_Shop
  131. dc.l Enter_Hi_Score
  132. dc.l Set_Up_Next_Level
  133. dc.l Level_Loading_Routine
  134. dc.l Display_End_Text
  135. ************************************************************
  136. ***** MAIN GAME ROUTINE **********
  137. ************************************************************
  138. Main_Game_Routine
  139. bsr sync
  140. bsr Get_Stick_Readings
  141. bsr Process_Player_Movement
  142. bsr Frame_Dependant_Code
  143. bsr draw_blocks_for_scroll
  144. bsr Flash_Player
  145. bsr Sound_Effects
  146. cmp.w #GAME_LOOP,Schedule_Entry
  147. bne.s Exit_Game_Loop
  148. ifnd final_version
  149. btst.b #6,$bfe001
  150. bne.s Main_Game_Routine
  151. move.w #QUIT_GAME,Schedule_Entry
  152. endc
  153. Exit_Game_Loop
  154. rts
  155. ************************************************************
  156. ***** MAN DEATH ROUTINE **********
  157. ************************************************************
  158. Man_Death_Routine
  159. bsr sync
  160. tst count_down_to_death
  161. beq.s do_death_routine
  162. bsr Spin_Player
  163. bsr Flash_Red_Player
  164. bsr Display_Player
  165. subq.w #1,count_down_to_death
  166. bgt.s keep_spinning
  167. bsr Explode_Player
  168. bsr Remove_Player
  169. bra.s keep_spinning
  170. do_death_routine
  171. bsr Shake_Screen
  172. keep_spinning
  173. bsr Position_Scroll
  174. tst.b frame_skip
  175. bne.s MD_Speed_25_Hz_2
  176. MD_Speed_25_Hz_1
  177. bsr Buffer_Alien_Lists
  178. bsr Delete_Alien_List
  179. bsr Do_Alien_Collision
  180. bsr Extract_Pigs_From_Alien_List ;bah humbug
  181. bsr Process_Switch_Lists
  182. bsr Process_Aliens
  183. bsr Process_Bullets
  184. bra.s MD_Speed_50_Hz
  185. MD_Speed_25_Hz_2
  186. bsr Swap_Buffers
  187. bsr Draw_Current_Alien_List
  188. MD_Speed_50_Hz
  189. bchg #0,frame_skip
  190. bsr Sound_Effects
  191. cmp.w #MAN_DEATH,Schedule_Entry
  192. beq.s Man_Death_Routine
  193. move.w #150,Player_Invincible_Timer
  194. bsr Restore_Colours_Norm
  195. move.w old_sx,scroll_x_position
  196. move.w old_sy,scroll_y_position
  197. clr.w last_x_direc ;stop any unwanted velocity
  198. clr.w last_y_direc
  199. rts
  200. ************************************************************
  201. ***** INTRO ROUTINE **********
  202. ************************************************************
  203. Intro_Routine
  204. jsr Text_Test
  205. move.w #GAME_LOOP,Schedule_Entry
  206. rts
  207. ******************************************
  208. ******** SET GAME ENVIRONMENT ******
  209. ******************************************
  210. Set_Game_Environment
  211. bsr Reset_Main_Game_Vars
  212. bsr Reset_Level
  213. bsr Game_Set_Up ; set up pointers, lists, screens
  214. bsr Setup_System ; set up copper etc
  215. move.w #INTRO,Schedule_Entry
  216. rts
  217. ******************************************
  218. ******** TITLE SCREEN ******
  219. ******************************************
  220. Title_Screen
  221. jsr Display_Title_Picture
  222. rts
  223. ******************************************
  224. ******** GAME OVER ROUTINE ******
  225. ******************************************
  226. Game_Over_Routine
  227. tst.w QuitFromGame
  228. bne.s Continues_Not_Enabled_So_Continue
  229. tst.w Enable_Continues
  230. beq.s Continues_Not_Enabled_So_Continue
  231. tst.w Continue_Credits
  232. beq.s Continues_Not_Enabled_So_Continue
  233. jsr Check_For_Continue
  234. tst.w d0
  235. beq.s Continues_Not_Enabled_So_Continue
  236. rts
  237. Continues_Not_Enabled_So_Continue
  238. jsr Stop_Looping_Sample ;just in case
  239. jsr Game_Over_Screen
  240. bsr Return_From_Game
  241. rts
  242. ******************************************
  243. ******** RETURN FROM GAME ******
  244. ******************************************
  245. Return_From_Game
  246. jsr Black_Out_Everything
  247. jsr Switch_Off_Text_Screen
  248. move.w #BIT_PLANE_DMA,dmacon(a6) ;turn off screen
  249. move.l last_score,d0
  250. cmp.l score,d0
  251. bge.s no_hi_score
  252. move.w #HI_SCORE_ENTRY,schedule_entry
  253. bra.s dont_return_to_credits
  254. no_hi_score
  255. move.w #CREDITS,schedule_entry
  256. dont_return_to_credits
  257. bsr Reset_Buffers
  258. clr.l Sound_chan1
  259. clr.l Sound_Chan3
  260. move.w #1,loader_type
  261. move.w #1,level_loading_flag
  262. bsr Level_Loading_Routine
  263. rts
  264. ******************************************
  265. ******** SHOW INSTRUCTIONS ******
  266. ******************************************
  267. Show_Instructions
  268. jsr Display_Instructions_Picture
  269. rts
  270. ************************************************************
  271. ***** END OF LEVEL ROUTINE **********
  272. ************************************************************
  273. End_Of_Level_Routine
  274. bsr sync
  275. tst.w count_down_to_death
  276. bpl.s player_run_away
  277. subq.w #1,count_down_to_death
  278. bra.s Add_Rand_Expl
  279. player_run_away
  280. cmp.w #1,count_down_to_death
  281. bne.s player_not_safe
  282. clr.w count_down_to_death
  283. bsr Delete_Points_From_Scanner
  284. bsr Remove_Player
  285. move.w actual_player_map_x_position,d0
  286. move.w actual_player_map_y_position,d1
  287. addq.w #5,d0
  288. addq.w #4,d1
  289. move.l #Appear_Object,d2
  290. bsr Simple_Add_Alien_To_List
  291. bra.s player_not_safe
  292. Add_Rand_Expl
  293. bsr Add_Random_Explodes
  294. cmp.w #-100,count_down_to_death
  295. beq.s Display_End_Text
  296. player_not_safe
  297. bsr Shake_Screen
  298. bsr Position_Scroll
  299. tst.b frame_skip
  300. bne.s EL_Speed_25_Hz_2
  301. EL_Speed_25_Hz_1
  302. bsr Buffer_Alien_Lists
  303. bsr Delete_Alien_List
  304. bsr Process_Aliens
  305. bsr Process_Bullets
  306. bra.s EL_Speed_50_Hz
  307. EL_Speed_25_Hz_2
  308. bsr Swap_Buffers
  309. bsr Draw_Current_Alien_List
  310. EL_Speed_50_Hz
  311. bchg #0,frame_skip
  312. bsr Sound_Effects
  313. cmp.w #END_LEVEL,Schedule_Entry
  314. beq End_Of_Level_Routine
  315. Display_End_Text
  316. cmp.b #'H',Level_Number
  317. beq.s Completed_Game
  318. jsr Level_Over_Screen
  319. jsr Black_Out_Everything
  320. bsr Reset_Buffers
  321. move.w #1,level_loading_flag
  322. move.w #1,loader_type
  323. bsr Level_Loading_Routine
  324. move.w #SHOP_SCREEN,Schedule_Entry
  325. rts
  326. Completed_Game
  327. bsr Remove_Scanner
  328. bsr Remove_Player
  329. jsr Display_End_Game
  330. bsr Return_From_Game
  331. rts
  332. start_explosions
  333. move.w #-1,count_down_to_death
  334. rts
  335. ******************************************
  336. ******** ENTER HI SCORE ******
  337. ******************************************
  338. Enter_Hi_Score
  339. jsr Hi_Score_Screen
  340. rts
  341. ******************************************
  342. ******** SET UP NEXT LEVEL ******
  343. ******************************************
  344. Set_Up_Next_Level
  345. bsr Change_Level
  346. move.w #INTRO,schedule_entry
  347. rts
  348. ******************************************
  349. ******** GAME SET UP ******
  350. ******************************************
  351. Game_Set_Up
  352. clr.b frame_skip
  353. bsr Reset_Buffers
  354. bsr Level_Loading_Routine
  355. bsr Set_Up_Level_Pointers
  356. bsr Initialise_Level
  357. rts
  358. ************************************************************
  359. ***** S C R E E N S Y N C **********
  360. ************************************************************
  361. sync
  362. move.w #$0010,intreq(a6)
  363. wait_for_bit
  364. btst.b #4,intreqr+1(a6)
  365. beq.s wait_for_bit
  366. ifnd final_version
  367. Wait_R_Release
  368. btst.b #6,$bfe001
  369. beq.s Skip_R_Mouse
  370. btst.b #10,$dff016
  371. beq.s Wait_R_Release
  372. rts
  373. Skip_R_Mouse
  374. btst.b #6,$bfe001
  375. beq.s Skip_R_Mouse
  376. endc
  377. rts
  378. Wait_R_Mouse
  379. btst.b #10,$dff016
  380. beq.s Wait_R_Mouse
  381. rts
  382. ************************************************************
  383. ***** FRAME DEPENDANT CODE **********
  384. ************************************************************
  385. Frame_Dependant_Code
  386. tst.b frame_skip
  387. bne.s Speed_25_Hz_2
  388. Speed_25_Hz_1
  389. bsr Buffer_Alien_Lists
  390. bsr Delete_Alien_List
  391. bsr Do_Alien_Collision
  392. bsr Do_Player_Alien_Collision
  393. bsr Extract_Pigs_From_Alien_List ;bah humbug
  394. bsr Process_Switch_Lists
  395. bsr Process_Aliens
  396. bsr Process_Bullets
  397. bsr Check_Player_Fire
  398. bsr Delete_Points_From_Scanner
  399. bsr Display_Points_On_Scanner
  400. bra.s Speed_50_Hz
  401. Speed_25_Hz_2
  402. bsr Swap_Buffers
  403. bsr Check_Change_Weapon
  404. bsr Update_Panel
  405. bsr Draw_Current_Alien_List
  406. Speed_50_Hz
  407. bchg #0,frame_skip
  408. rts
  409. ************************************************************
  410. ***** RUN ALIEN CODE **********
  411. ************************************************************
  412. Run_Alien_Code
  413. bsr Move_Scroll
  414. tst frame_skip
  415. bne.s skip25
  416. bsr Buffer_Alien_Lists
  417. bsr Delete_Alien_List
  418. bsr Process_Aliens
  419. bra.s skip50
  420. skip25
  421. bsr Swap_Buffers
  422. bsr Draw_Current_Alien_List
  423. skip50
  424. bchg #0,frame_skip
  425. rts
  426. *************************************************************
  427. *** PROCESS PLAYER MOVEMENT ***
  428. *************************************************************
  429. Process_Player_Movement
  430. bsr Move_Scroll
  431. tst.b Invincible_Flag
  432. bne.s dont_display_player
  433. bra.s done_check_for_invin
  434. dont_display_player
  435. bsr Remove_Player
  436. bra.s perform_player_code
  437. done_check_for_invin
  438. bsr Display_Player
  439. perform_player_code
  440. bsr What_Is_Player_Standing_On
  441. bsr Move_Player
  442. bsr Work_Out_Scroll_Movement
  443. rts
  444. frame_skip
  445. dc.b 0
  446. EVEN
  447. *************************************************************
  448. *** GAME INCLUDES ***
  449. *************************************************************
  450. *----------------CODE------------------
  451. include "glens_code/object_code.s"
  452. include "glens_code/setup_routines.s"
  453. include "glens_code/interrupt_routines.s"
  454. include "glens_code/four_way_scrolltest.s"
  455. include "glens_code/buffer_routines.s"
  456. include "glens_code/sprite_routines.s"
  457. include "glens_code/player_routines.s"
  458. include "glens_code/collision_routines.s"
  459. include "glens_code/alien_routines.s"
  460. include "glens_code/bullet_routines.s"
  461. include "glens_code/bullet_hit_routines.s"
  462. include "glens_code/joy_routines.s"
  463. include "glens_code/player_alien_collisions.s"
  464. include "glens_code/panel_routines.s"
  465. include "glens_code/level_code.s"
  466. include "glens_code/map_routines.s"
  467. include "glens_code/block_effects.s"
  468. include "glens_code/alien_intelligence.s"
  469. include "glens_code/pig_intelligence.s"
  470. include "sound/game_sound.s"
  471. include "glens_code/scanner_routines.s"
  472. include "glens_code/switch_routines.s"
  473. include "glens_code/text_routines.s"
  474. include "glens_code/file_routines.s"
  475. include "glens_code/demo_routines.s"
  476. include "glens_code/hi_score_routines.s"
  477. include "glens_code/shop_routines.s"
  478. include "glens_code/instructions.s"
  479. include "glens_code/aga_stuff.s"
  480. *----------------DATA------------------
  481. section ALIENBASHII,DATA
  482. include "level_data/level_data.s"
  483. include "data/block_data_information.s"
  484. include "data/alien_data.s"
  485. include "data/alien_data2.s"
  486. include "data/alien_special_data.s"
  487. include "data/generator_attacks.s"
  488. include "data/weapon_data.s"
  489. include "data/map_buffer_data.s"
  490. include "data/scanner_data.s"
  491. include "data/man_explode_data.s"
  492. include "data/generator_explode_data.s"
  493. include "data/font_info_data.s"
  494. include "data/switch_data.s"
  495. include "data/alien_code_data.s"
  496. include "graphics/panel_graphics.s" ;fast mem graphics
  497. include "data/direc_data.s"
  498. shareware_pic
  499. incbin "graphics/reminder.pic"
  500. even
  501. include "graphics/stars.s"
  502. include "data/scrolly_data.s"
  503. include "data/instruction_pages.s"
  504. include "data/alien_graphics_data.s"
  505. include "sound/effects_data.s"
  506. include "data/text_routines_data.s"
  507. include "data/colour_data.s"
  508. small_bullet_type
  509. incbin "graphics/smallbulls.bin"
  510. green_bullet_type
  511. incbin "graphics/greenbulls.bin"
  512. long_bullet_type
  513. incbin "graphics/longbulls.bin"
  514. even
  515. Get_Ready_Graphics
  516. incbin "graphics/get_ready.bin"
  517. even
  518. Get_Ready_Names
  519. incbin "graphics/level_names.bin"
  520. incbin "graphics/level_numbers.bin"
  521. even
  522. *----------------GRAPHICS--------------
  523. section AlienBashII,Code_C
  524. scanner3
  525. include "graphics/newscanner.s"
  526. include "graphics/pause.s"
  527. include "graphics/alien_graphics.s"
  528. include "graphics/player_graphics.s"
  529. include "data/copper_list.s"
  530. malfont
  531. incbin "graphics/malfont.bin"
  532. smallfont
  533. incbin "graphics/smallerfont.bin"
  534. panel_graphics
  535. incbin "graphics/crappanel.bin"
  536. even
  537. Sound_Blank
  538. blank_data
  539. ds.w 4
  540. *- When I was planning on expanding this game, I started to split the -*
  541. *- game up into chunks for linking, however I did not finish so only -*
  542. *- a few bits have been done.....oh well -*
  543. xref Read_Keyboard
  544. xref Do_Rings
  545. xref Add_New_Ring
  546. xref Tube_Set_Up
  547. xref mt_init
  548. xref mt_end
  549. xref mt_music
  550. xref.w master_volume
  551. xdef.w music_chans_2
  552. xref.l current_song_ptr
  553. xdef.l Fast_Memory_Base
  554. xdef.w Chip_Type
  555. xdef.l Plane1
  556. xdef.l Plane2
  557. xdef.l Plane3
  558. xdef.l buff_Plane1
  559. xdef.l buff_Plane2
  560. xdef.l buff_Plane3
  561. xdef.l InPlane1_lo
  562. xdef.l InPlane2_lo
  563. xdef.l InPlane3_lo
  564. xdef.l InPlane1_hi
  565. xdef.l InPlane2_hi
  566. xdef.l InPlane3_hi
  567. xdef.w frame_skip
  568. xdef.w fade_music