demo_routines.s 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. *------------------------------------------------------------------------*
  2. *- Ohh...messy -*
  3. *------------------------------------------------------------------------*
  4. *---------------------All demo routines------------------
  5. **********************************************
  6. *** DISPLAY TITLE PICTURE ***
  7. **********************************************
  8. Display_Title_Picture
  9. *This needs to be done each time we want to display title
  10. *screen - it needs to be very fast
  11. move.w #$8204,title_screen_copper+2 ;turn off planes
  12. move.l #Credit_text,text_pointer
  13. move.w #80,text_bpr
  14. move.w #SELECTED_COLOUR,choice_1_colour
  15. move.w #NON_SELECTED_COLOUR,choice_2_colour
  16. move.w #NON_SELECTED_COLOUR,choice_3_colour
  17. clr.w current_choice
  18. move.l #ball_cols,a1
  19. move.l #hi_res_sprite_cols,a0
  20. jsr Insert_Sprite_Colours
  21. tst.w Title_Tune_Loaded
  22. bne.s Dont_Re_Load
  23. bsr Load_Intro_Tune
  24. bsr mt_init
  25. Dont_Re_Load
  26. clr.w Title_Tune_Loaded
  27. bsr Load_Title_Picture
  28. move.l #hires_copper_colours+2,a0
  29. bsr Insert_Cols
  30. tst.w stars_up
  31. bne.s Skip_Start_Up
  32. move.w #1,stars_up
  33. bsr Set_Up_Title_Sprites
  34. Skip_Start_Up
  35. move.w #BIT_PLANE_DMA+SPRITE_DMA+$8000,dmacon(a6)
  36. bsr Start_Up_Copper_List
  37. bsr Keep_Subbing
  38. bsr Update_Sprites
  39. bsr Do_Sprites
  40. bsr Keep_Subbing
  41. bsr Update_Sprites
  42. bsr Do_Sprites
  43. move.w #1,music_flag
  44. move.w #$c204,title_screen_copper+2
  45. Main_Title_Loop
  46. jsr Sync
  47. bsr Do_Sprites
  48. bsr Display_Hi_Res_Planes
  49. bsr Update_Scrolly
  50. tst fade_music
  51. bne.s freeze_options
  52. bsr Get_Player_Options
  53. freeze_options
  54. bsr Update_Sprites
  55. bsr Keep_Subbing
  56. tst.w fade_music
  57. beq.s dont_demo_fade
  58. subq.w #1,master_volume
  59. tst.w master_volume
  60. bne.s Main_Title_Loop
  61. bra.s stop_demo
  62. dont_demo_fade
  63. cmp.b #$75,$bfec01 ;check for escape
  64. bne.s no_key_p
  65. move.w #QUIT_GAME,schedule_entry
  66. no_key_p
  67. cmp.w #CREDITS,schedule_entry
  68. beq.s Main_Title_Loop
  69. cmp.w #HI_SCORES,Schedule_Entry
  70. beq.s Stop_Demo_Keep_Music_On
  71. move.w #1,fade_music
  72. bra.s Main_Title_Loop
  73. Stop_Demo
  74. bsr mt_end ;stop the music
  75. clr.w music_flag
  76. Stop_Demo_Keep_Music_On
  77. move.w #BIT_PLANE_DMA,dmacon(a6)
  78. bsr Test_Two_Button_Joystick
  79. rts
  80. **********************************************
  81. *** SHOW HI SCORES ***
  82. **********************************************
  83. Show_Hi_Scores
  84. clr.l movey_inc
  85. clr.l movey_inc+4
  86. move.w #1,fire
  87. move.w #1*8,shipx_vel
  88. bsr Update_Sprites
  89. move.w #$8204,title_screen_copper+2
  90. move.l #hi_score_titles,a4 ;title for hi scores
  91. bsr Display_Hi_Scores
  92. move.w #$9204,title_screen_copper+2
  93. move.w #BIT_PLANE_DMA+$8000,dmacon(a6)
  94. hi_scores_loop
  95. jsr Sync
  96. bsr Do_Sprites
  97. bsr Display_Hi_Score_Planes
  98. bsr Update_Sprites
  99. btst #7,$bfe001
  100. beq.s hi_scores_fire_pressed
  101. clr.w fire
  102. bra.s hi_scores_loop
  103. hi_scores_fire_pressed
  104. tst.w fire
  105. bne.s hi_scores_loop
  106. clr.w shipx_vel
  107. move.w #1,Title_Tune_Loaded
  108. move.w #CREDITS,schedule_entry
  109. rts
  110. **********************************************
  111. *** DISPLAY HI RES PLANES ***
  112. **********************************************
  113. Display_Hi_Res_Planes
  114. move.l memory_base,d0
  115. move.w vposr(a6),d1
  116. bpl.s skip_add_to_planes
  117. add.l #80,d0
  118. skip_add_to_planes
  119. move.w d0,HPlane1_Lo
  120. swap d0
  121. move.w d0,HPlane1_Hi
  122. swap d0
  123. add.l #HI_RES_PLANE,d0
  124. move.w d0,HPlane2_Lo
  125. swap d0
  126. move.w d0,HPlane2_Hi
  127. swap d0
  128. add.l #HI_RES_PLANE,d0
  129. move.w d0,HPlane3_Lo
  130. swap d0
  131. move.w d0,HPlane3_Hi
  132. swap d0
  133. add.l #HI_RES_PLANE,d0
  134. move.w d0,HPlane4_Lo
  135. swap d0
  136. move.w d0,HPlane4_Hi
  137. rts
  138. **********************************************
  139. *** START UP COPPER LIST ***
  140. **********************************************
  141. Start_Up_Copper_List
  142. move.l #title_screen_copper,cop1lch(a6)
  143. clr.w copjmp1(a6)
  144. rts
  145. SPRITE_SIZE EQU 11
  146. NUM_LAYERS EQU 3
  147. **********************************************
  148. *** SET UP TITLE SPRITES ***
  149. **********************************************
  150. Set_Up_Title_Sprites
  151. move.l memory_base,d0
  152. add.l #(HI_RES_PLANE*4)+RAPINA4_TUNE_LENGTH,d0
  153. move.l d0,sprite_pointer1
  154. add.l #(((SPRITE_SIZE+1)*4*23)+4)*NUM_LAYERS,d0
  155. move.l d0,sprite_pointerattach1
  156. add.l #(((SPRITE_SIZE+1)*4*23)+4)*NUM_LAYERS,d0
  157. move.l d0,sprite_pointer2
  158. add.l #(((SPRITE_SIZE+1)*4*23)+4)*NUM_LAYERS,d0
  159. move.l d0,sprite_pointerattach2
  160. move.l sprite_pointer1,a0
  161. move.l sprite_pointer2,a1
  162. move.l #sprite_graphic,a2
  163. *do the first set of sprites
  164. move.w #NUM_LAYERS-1,d2
  165. do_layers
  166. move.w #23-1,d0
  167. num_sprites
  168. move.w #((SPRITE_SIZE+1)*2)-1,d1
  169. move.l a2,a3
  170. sprite_copy
  171. move.w (a3),(a0)+
  172. move.w (a3)+,(a1)+
  173. dbra d1,sprite_copy
  174. dbra d0,num_sprites
  175. clr.l (a0)+
  176. clr.l (a1)+
  177. add.l #((SPRITE_SIZE+1)*4)*2,a2
  178. dbra d2,do_layers
  179. * do attached layer
  180. move.l sprite_pointerattach1,a0
  181. move.l sprite_pointerattach2,a1
  182. move.l #sprite_graphicattach,a2
  183. move.w #NUM_LAYERS-1,d2
  184. attacheddo_layers
  185. move.w #23-1,d0
  186. attachednum_sprites
  187. move.w #((SPRITE_SIZE+1)*2)-1,d1
  188. move.l a2,a3
  189. attachedsprite_copy
  190. move.w (a3),(a0)+
  191. move.w (a3)+,(a1)+
  192. dbra d1,attachedsprite_copy
  193. dbra d0,attachednum_sprites
  194. clr.l (a0)+
  195. clr.l (a1)+
  196. add.l #((SPRITE_SIZE+1)*4)*2,a2
  197. dbra d2,attacheddo_layers
  198. move.l memory_base,d0
  199. add.l #(HI_RES_PLANE*4)+RAPINA4_TUNE_LENGTH+((((SPRITE_SIZE+1)*4*23)+4)*NUM_LAYERS*4),d0
  200. move.l #pointer_block,a0
  201. move.l d0,(a0)+ ;1
  202. move.l d0,(a0)+
  203. add.l #512,d0
  204. move.l d0,(a0)+ ;3
  205. move.l d0,(a0)+
  206. add.l #512,d0
  207. move.l d0,(a0)+ ;3
  208. move.l d0,(a0)+
  209. add.l #512,d0
  210. move.l d0,(a0)+ ;4
  211. move.l d0,(a0)+
  212. add.l #512,d0
  213. move.l d0,(a0)+ ;5
  214. move.l d0,(a0)+
  215. move.w #(256*5)-1,d7
  216. move.l pointer_block,a0
  217. get_rans
  218. move.w #0,d0
  219. move.w #320,d1
  220. bsr Get_Random_Number
  221. move.w d0,(a0)+
  222. dbra d7,get_rans
  223. clr.w (a0)
  224. rts
  225. **********************************************
  226. *** GET PLAYER OPTIONS ***
  227. **********************************************
  228. Get_Player_Options
  229. bsr Get_Stick_Readings
  230. tst fire
  231. beq.s player_not_selected
  232. clr.w fire
  233. move.l #choice_schedule_entries,a0
  234. move.w current_choice,d0
  235. ext.l d0
  236. asl d0
  237. move.w (a0,d0),schedule_entry
  238. move.l #choice_table,a0 ;ensure choice high-lighted
  239. move.w current_choice,d0
  240. ext.l d0
  241. asl #2,d0
  242. move.l (a0,d0),a1
  243. move.w #SELECTED_COLOUR,(a1)
  244. rts
  245. player_not_selected
  246. move.l #choice_table,a0
  247. subq.w #1,joy_sample_timer
  248. bgt.s flash_prev
  249. ok_move_option
  250. move.w #JOY_SAMPLE_TIME,joy_sample_timer
  251. move.w current_choice,d0
  252. tst ydirec
  253. beq.s no_movement
  254. bpl.s player_up_options
  255. cmp.w #2,d0
  256. beq.s no_movement
  257. addq.w #1,current_choice
  258. bra.s flash_new_position
  259. player_up_options
  260. tst d0
  261. beq.s no_movement
  262. subq.w #1,current_choice
  263. flash_new_position
  264. *first reset - old flash option
  265. ext.l d0
  266. asl #2,d0
  267. move.l (a0,d0),a1
  268. move.w #NON_SELECTED_COLOUR,(a1)
  269. move.w #TIME_TO_FLASH,flash_timer
  270. clr.w flash_duration
  271. no_movement
  272. *check to see if flashing from previous movement
  273. flash_prev
  274. tst flash_timer
  275. beq.s have_completed_flash
  276. subq.w #1,flash_timer
  277. subq.w #1,flash_duration
  278. bgt.s not_time_to_change_colour
  279. move.w current_choice,d0
  280. ext.l d0
  281. asl #2,d0
  282. move.w #FLASH_PERIOD,flash_duration
  283. move.l (a0,d0),a1
  284. cmp.w #SELECTED_COLOUR,(a1)
  285. beq.s change_to_non_sc
  286. move.w #SELECTED_COLOUR,(a1)
  287. rts
  288. change_to_non_sc
  289. move.w #NON_SELECTED_COLOUR,(a1)
  290. not_time_to_change_colour
  291. rts
  292. have_completed_flash
  293. move.w current_choice,d0 ;not worried about speed
  294. ext.l d0
  295. asl #2,d0
  296. move.l (a0,d0),a1
  297. move.w #SELECTED_COLOUR,(a1)
  298. rts
  299. choice_table
  300. dc.l choice_1_colour
  301. dc.l choice_2_colour
  302. dc.l choice_3_colour
  303. choice_schedule_entries
  304. dc.w GAME_SETUP
  305. dc.w INSTRUCTIONS
  306. dc.w HI_SCORES
  307. TIME_TO_FLASH EQU 50
  308. FLASH_PERIOD EQU 2
  309. SELECTED_COLOUR EQU $FFF
  310. NON_SELECTED_COLOUR EQU $555
  311. JOY_SAMPLE_TIME EQU 8
  312. joy_sample_timer dc.w 0
  313. current_choice dc.w 0
  314. flash_timer dc.w TIME_TO_FLASH
  315. flash_duration dc.w 0
  316. *---------------------------BALL SPRITE CODE---------------------
  317. ************************************************************
  318. **** U P D A T E S P R I T E S ****
  319. ************************************************************
  320. update_sprites
  321. move.l a6,-(sp)
  322. move.l sprite_pointer1,a0
  323. move.l sprite_pointerattach1,a6
  324. move.l #movey_inc,a3
  325. moveq #4,d3 ;mulu value ;8 used as loop conter , decing by 4
  326. move.l #pointer_block,a5 ;pointer to different screen positions
  327. move.l #movex_incs,a4
  328. update_layers
  329. move.l (a5),a1
  330. move.w #23-1,d5
  331. move.w #$1c+12,d0 ;ypos
  332. add.w (a3),d0
  333. demo_fill_sprite
  334. cmpi.w #-12,(a3)
  335. bgt.s forget_it
  336. addq.l #2,a1
  337. addq.l #2,(a5)
  338. move.l (a5),a2
  339. cmp.l 12(a5),a2
  340. blt.s demo_past
  341. move.l 4(a5),(a5)
  342. move.l (a5),a1
  343. demo_past
  344. addi.w #12,d0
  345. addi.w #12,(a3)
  346. bra.s skip2
  347. forget_it
  348. cmp.w #12,(a3)
  349. blt.s forget_it2
  350. subq.l #2,a1
  351. subq.l #2,(a5)
  352. move.l (a5),a2
  353. cmp.l 4(a5),a2
  354. bge.s past2
  355. move.l 12(a5),(a5)
  356. subq.l #2,(a5)
  357. move.l (a5),a1
  358. past2
  359. subi.w #12,d0
  360. subi.w #12,(a3)
  361. forget_it2
  362. cmp.l 12(a5),a1
  363. blt.s skip
  364. move.l 4(a5),a1
  365. bra.s skip2
  366. skip
  367. cmp.l 4(a5),a1
  368. bge.s skip2
  369. move.l 12(a5),a1
  370. subq.l #2,a1
  371. skip2
  372. clr.b 3(a0)
  373. move.w shipx_vel,d6
  374. add.w d3,d6
  375. move.w (a4,d6.w),d4
  376. tst shipx_vel
  377. bpl.s do_nought
  378. neg.w d4
  379. do_nought
  380. add.w d4,(a1)
  381. past_add_to_x
  382. cmpi.w #320+9,(A1)
  383. ble.s not_bigger
  384. subi.w #320+18,(A1)
  385. bra.s finished_that
  386. not_bigger
  387. cmpi.w #0-9,(a1)
  388. bge.s finished_that
  389. addi.w #320+18,(a1)
  390. finished_that
  391. move.w (a1)+,d1
  392. addi.w #$81,d1
  393. lsr #1,d1
  394. bcc.s no_setbit
  395. bset.b #0,3(a0)
  396. no_setbit
  397. bset.b #7,3(a0) ;attach bit
  398. move.b d1,1(a0)
  399. past_setbit
  400. move.b d0,(a0)
  401. btst #8,d0
  402. beq.s demo_no_set
  403. bset.b #2,3(a0)
  404. demo_no_set
  405. add.w #11,d0
  406. move.b d0,2(a0)
  407. btst #8,d0
  408. beq.s no_set2
  409. bset.b #1,3(a0)
  410. no_set2
  411. move.l (a0),(a6)
  412. addq.w #1,d0 ; one line gap!!
  413. add.l #(12*4),a0
  414. add.l #(12*4),a6
  415. *The code below fill sprite test to see if a sprite has gone up or down
  416. *by the sprite length, if it has then the code effectively adds or subs
  417. *from a list so a new sprite is being processed top or bottom, hence the
  418. *way sprites appear to 'appear'. In the game this should only happen
  419. *a maximum of once a frame so we don't need to run this code again
  420. *if it cocks up then dbra back to fill_sprite
  421. dbra d5,forget_it2
  422. addq.l #2,a3
  423. addq.l #4,a0
  424. addq.l #4,a6
  425. subq #2,d3
  426. addq.l #8,a5
  427. cmpi.w #-2,d3
  428. bne update_layers
  429. move.l (sp)+,a6
  430. rts
  431. ************************************************************
  432. **** DO SPRITES ****
  433. ************************************************************
  434. do_sprites
  435. move.l sprite_pointer1,d0 ;double buffer sprites
  436. move.l sprite_pointer2,d1
  437. move.l d1,sprite_pointer1
  438. move.l d0,sprite_pointer2
  439. move.w d0,hsprite0l
  440. swap d0
  441. move.w d0,hsprite0h
  442. swap d0
  443. add.l #(12*4*23)+4,d0
  444. move.w d0,hsprite2l
  445. swap d0
  446. move.w d0,hsprite2h
  447. swap d0
  448. add.l #(12*4*23)+4,d0
  449. move.w d0,hsprite4l
  450. swap d0
  451. move.w d0,hsprite4h
  452. move.l sprite_pointerattach1,d0 ;double buffer sprites
  453. move.l sprite_pointerattach2,d1
  454. move.l d1,sprite_pointerattach1
  455. move.l d0,sprite_pointerattach2
  456. move.w d0,hsprite1l
  457. swap d0
  458. move.w d0,hsprite1h
  459. swap d0
  460. add.l #(12*4*23)+4,d0
  461. move.w d0,hsprite3l
  462. swap d0
  463. move.w d0,hsprite3h
  464. swap d0
  465. add.l #(12*4*23)+4,d0
  466. move.w d0,hsprite5l
  467. swap d0
  468. move.w d0,hsprite5h
  469. move.l #blank_data,d0
  470. move.w d0,hsprite6l
  471. move.w d0,hsprite7l
  472. swap d0
  473. move.w d0,hsprite6h
  474. move.w d0,hsprite7h
  475. rts
  476. keep_subbing
  477. sub.w #-4,movey_inc
  478. sub.w #-3,movey_inc+2
  479. sub.w #-2,movey_inc+4
  480. sub.w #-1,movey_inc+6
  481. rts
  482. shipx_vel
  483. dc.w 0
  484. movey_inc dc.w 0,0,0,0
  485. movex_incs dc.w 0,0,0,0
  486. dc.w 1,2,3,4
  487. stars_up dc.w 0
  488. title_pic_loaded dc.w 0
  489. Title_Tune_Loaded dc.w 0
  490. pointer_block
  491. ds.l 10
  492. sprite_pointer1 dc.l 0
  493. sprite_pointer2 dc.l 0
  494. sprite_pointerattach1 dc.l 0
  495. sprite_pointerattach2 dc.l 0
  496. **********************************************
  497. *** UPDATE SCROLLY ***
  498. **********************************************
  499. Update_Scrolly
  500. subq.w #2,wait_width
  501. bgt.s dont_add_letter
  502. moveq #0,d2
  503. move.l text_pointer,a0
  504. get_letter
  505. move.b (a0)+,d2
  506. bne.s not_end_of_message
  507. move.l #Credit_Text,a0
  508. bra.s get_letter
  509. not_end_of_message
  510. move.l a0,text_pointer
  511. move.w wait_width,d0
  512. add.w #640-12,d0
  513. move.w #510-MALFONT_HEIGHT,d1
  514. move.l memory_base,a3
  515. bsr Draw_Letter
  516. dont_add_letter
  517. *scroll!!
  518. scrolly_wait
  519. btst #14,dmaconr(a6)
  520. bne.s scrolly_wait
  521. move.l memory_base,a0
  522. add.l #(510-MALFONT_HEIGHT)*80,a0
  523. move.l a0,bltdpth(a6)
  524. addq.l #2,a0
  525. move.l a0,bltapth(a6)
  526. clr.w bltamod(a6)
  527. clr.w bltdmod(a6)
  528. move.l #$e9f00000,bltcon0(a6)
  529. move.l #$ffff0000,bltafwm(a6)
  530. move.w #MALFONT_HEIGHT<<6+40,bltsize(a6)
  531. rts
  532. scroll_pos dc.w 15
  533. wait_width dc.w 0
  534. text_pointer dc.l Credit_Text
  535. fade_music dc.w 0