text_routines.s 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473
  1. GET_READY_WORDS EQU 10
  2. GET_READY_HEIGHT EQU 61
  3. GET_READY_PLANE EQU GET_READY_HEIGHT*GET_READY_WORDS*2
  4. GET_READY_Y_POS EQU 70
  5. GET_READY_BYTE_POS EQU ((20-GET_READY_WORDS)/2)*2
  6. *****************************************
  7. *** TEXT TEST *****
  8. *****************************************
  9. Text_Test
  10. bsr Copy_In_Level_Name
  11. move.w #$ff,scroll_value
  12. bsr Work_Out_Scroll_Movement ;dont ask - makes player appear in right place
  13. bsr Black_Colours
  14. bsr Draw_Initial_Aliens_On_Screen
  15. bsr Show_BackGround
  16. bsr Display_Scanner
  17. move.w #Sound_GetReady,sound_chan1
  18. bsr Sound_Effects
  19. bsr Wait_For_Fire_Press
  20. bsr Remove_Get_Ready
  21. bsr Do_Sprite_Colours
  22. bsr Do_Level_Colours
  23. rts
  24. *****************************************
  25. *** COPY IN LEVEL NAME *****
  26. *****************************************
  27. Copy_In_Level_Name
  28. clr.l d0
  29. move.b level_number,d0
  30. sub.w #'A',d0
  31. move.l #Get_Ready_Names,a0
  32. move.l a0,a1
  33. add.l #16*9*4*8,a1
  34. add.l d0,a1 ;get number
  35. mulu #18*8,d0 ;get name
  36. add.l d0,a0
  37. move.l #Get_Ready_Graphics,a2
  38. add.l #((GET_READY_WORDS*2)*37)+12,a2
  39. move.w #4-1,d1
  40. insert_level_number
  41. move.l a1,a3
  42. move.l a2,a4
  43. move.w #8-1,d2
  44. insert_number_lines
  45. move.b (a3),(a4)
  46. add.l #8,a3 ;next line
  47. add.l #GET_READY_WORDS*2,a4
  48. dbra d2,insert_number_lines
  49. add.l #8*8,a1 ;next plane
  50. add.l #GET_READY_PLANE,a2
  51. dbra d1,insert_level_number
  52. move.l #Get_Ready_Graphics,a2
  53. add.l #((GET_READY_WORDS*2)*53)+2,a2
  54. move.w #4-1,d1
  55. insert_level_name
  56. move.l a0,a3
  57. move.l a2,a4
  58. move.w #8-1,d2
  59. insert_name_lines
  60. movem.l a3-a4,-(sp)
  61. move.w #9-1,d3
  62. insert_name_words
  63. move.w (a3)+,(a4)+
  64. dbra d3,insert_name_words
  65. movem.l (sp)+,a3-a4
  66. add.l #18,a3 ;next line
  67. add.l #GET_READY_WORDS*2,a4
  68. dbra d2,insert_name_lines
  69. add.l #16*9*8,a0 ;next plane
  70. add.l #GET_READY_PLANE,a2
  71. dbra d1,insert_level_name
  72. rts
  73. *****************************************
  74. *** DRAW INITIAL ALIENS ON SCREEN *****
  75. *****************************************
  76. Draw_Initial_Aliens_On_Screen
  77. jsr Run_Alien_Code ;get aliens to draw on screen
  78. jsr Run_Alien_Code
  79. bsr Display_Get_Ready
  80. jsr Run_Alien_Code
  81. jsr Run_Alien_Code
  82. rts
  83. *****************************************
  84. *** WHITE COLOURS *****
  85. *****************************************
  86. White_Colours
  87. move.w #16-1,d0
  88. move.l #copper_colours+2,a0
  89. blank_them_all
  90. move.w #$fff,(a0)
  91. addq.l #4,a0
  92. dbra d0,blank_them_all
  93. rts
  94. *****************************************
  95. *** CLEAR BLACK COLOURS *****
  96. *****************************************
  97. Clear_Black_Colours
  98. move.w #32-1,d0
  99. move.l #black_list,a0
  100. clear_bls
  101. clr.w (a0)+
  102. dbra d0,clear_bls
  103. rts
  104. *****************************************
  105. *** SET COLOURS *****
  106. *****************************************
  107. Set_Colours
  108. *list in a0
  109. *col in d0
  110. move.w #16-1,d1
  111. set_bls
  112. move.w d0,(a0)+
  113. dbra d1,set_bls
  114. rts
  115. *****************************************
  116. *** SET COPPER COLOURS *****
  117. *****************************************
  118. Set_Copper_Colours
  119. *copper list in a0
  120. *col in d0
  121. move.w #16-1,d1
  122. addq.l #2,a0
  123. set_cbls
  124. move.w d0,(a0)
  125. addq.l #4,a0
  126. dbra d1,set_cbls
  127. rts
  128. *****************************************
  129. *** CLEAR GAME COLOURS *****
  130. *****************************************
  131. Clear_Game_Colours
  132. move.w #32-1,d0
  133. move.l #game_list,a0
  134. clear_gcs
  135. clr.w (a0)+
  136. dbra d0,clear_gcs
  137. rts
  138. *****************************************
  139. *** BLACK COLOURS *****
  140. *****************************************
  141. Black_Colours
  142. move.w #16-1,d0
  143. move.l #copper_colours+2,a0
  144. black_them_all
  145. clr.w (a0)
  146. addq.l #4,a0
  147. dbra d0,black_them_all
  148. rts
  149. *****************************************
  150. *** FADE TEXT TO BACKGROUND *****
  151. *****************************************
  152. Fade_Text_To_Background
  153. move.l #white_list,a0
  154. move.l level_palette,a1
  155. move.l #sprite_cols+2,a2
  156. move.w #8-1,d7
  157. move.l #store_text_nums,a3
  158. bsr Fade_List_To_List
  159. rts
  160. *****************************************
  161. *** FADE REST OF TEXT TO BACKGROUND*****
  162. *****************************************
  163. Fade_Rest_Of_Text_To_Background
  164. jsr Sync
  165. move.l #sprite_cols+2,a2
  166. move.w #8-1,d7
  167. move.l #store_text_nums,a3
  168. bsr Reduce_All_Colours
  169. rts
  170. *****************************************
  171. *** SHOW BACK GROUND *****
  172. *****************************************
  173. Show_BackGround
  174. move.l level_palette,a1
  175. move.l #copper_colours+2,a2
  176. move.w #16-1,d7
  177. stick_in_cols
  178. move.w (a1)+,(a2)
  179. addq.l #4,a2
  180. dbra d7,stick_in_cols
  181. rts
  182. *****************************************
  183. *** FADE LIST TO LIST *****
  184. *****************************************
  185. Fade_List_To_List
  186. *send current colour list in a0, dest colour in a1
  187. *send copper list ptr in a2
  188. *send store list in a3
  189. move.l a3,a5
  190. move.w #16-1,d0
  191. init_list_loop
  192. *init list
  193. move.w (a0)+,d1
  194. move.w (a1)+,d4
  195. move.w d1,d2
  196. move.w d2,d3
  197. andi.w #$f00,d1 ;get rgb of source
  198. lsr #8,d1
  199. andi.w #$f0,d2
  200. lsr #4,d2
  201. andi.w #$f,d3
  202. asl #6,d1
  203. asl #6,d2
  204. asl #6,d3
  205. move.w d1,(a5)+ ;store scaled values
  206. move.w d2,(a5)+
  207. move.w d3,(a5)+
  208. asr #6,d1
  209. asr #6,d2
  210. asr #6,d3
  211. move.w d4,d5 ;get rgb of dest
  212. move.w d5,d6
  213. andi.w #$f00,d4
  214. lsr #8,d4
  215. andi.w #$f0,d5
  216. lsr #4,d5
  217. andi.w #$f,d6
  218. sub.w d4,d1 ;get diff
  219. sub.w d5,d2
  220. sub.w d6,d3
  221. asl #6-4,d1 ;(vals *64)/16
  222. asl #6-4,d2
  223. asl #6-4,d3
  224. move.w d1,(a5)+ ;store reduce values
  225. move.w d2,(a5)+
  226. move.w d3,(a5)+
  227. dbra d0,init_list_loop
  228. reduce_all_colours
  229. move.w fade_speed,d0
  230. subq.w #1,d0
  231. wait_fade_speed
  232. jsr Sync
  233. dbra d0,wait_fade_speed
  234. move.l a2,a5 ;copper
  235. move.l a3,a4
  236. move.w #16-1,d1
  237. reduce_loop
  238. move.w 6(a4),d2
  239. move.w 8(a4),d3
  240. move.w 10(a4),d4
  241. sub.w d2,(a4)
  242. sub.w d3,2(a4)
  243. sub.w d4,4(a4)
  244. move.w (a4),d2
  245. move.w 2(a4),d3
  246. move.w 4(a4),d4
  247. asr #6,d2
  248. asr #6,d3
  249. asr #6,d4
  250. lsl #8,d2
  251. lsl #4,d3
  252. or.w d2,d4
  253. or.w d3,d4
  254. move.w d4,(a5)
  255. addq.l #4,a5
  256. add.l #12,a4
  257. dbra d1,reduce_loop
  258. dbra d7,reduce_all_colours
  259. rts
  260. *****************************************
  261. *** CREATE FADE PALETTES *****
  262. *****************************************
  263. Create_Fade_Palettes
  264. move.l #Level_1_Colour_List,a0
  265. move.l #Faded_Palettes,a1
  266. move.w #16-1,d0
  267. cr_fade_loop
  268. move.w (a0)+,d1
  269. move.w d1,d2
  270. move.w d2,d3
  271. andi.w #$f00,d1 ;get rgb of source
  272. lsr #8,d1
  273. andi.w #$f0,d2
  274. lsr #4,d2
  275. andi.w #$f,d3
  276. move.w d1,d4 ;store
  277. move.w d2,d5
  278. move.w d3,d6
  279. asl #6,d1
  280. asl #6,d2
  281. asl #6,d3
  282. asl #6-4,d4 ;(vals *64)/16
  283. asl #6-4,d5
  284. asl #6-4,d6
  285. move.l a1,a2
  286. move.w #4-1,d7
  287. store_fade_cols
  288. sub.w d4,d1
  289. sub.w d5,d2
  290. sub.w d6,d3
  291. movem.l d1-d3,-(sp)
  292. asr #6,d1
  293. asr #6,d2
  294. asr #6,d3
  295. lsl #8,d1
  296. lsl #4,d2
  297. or.w d1,d3
  298. or.w d2,d3
  299. move.w d3,(a2)
  300. add.l #32,a2 ;next palette
  301. movem.l (sp)+,d1-d3
  302. dbra d7,store_fade_cols
  303. addq.l #2,a1
  304. dbra d0,cr_fade_loop
  305. rts
  306. *****************************************
  307. *** FADE 32 LIST TO LIST *****
  308. *****************************************
  309. Fade_32_List_To_List
  310. *send current colour list in a0, dest colour in a1
  311. *send copper list ptr in a2
  312. *send store list in a3
  313. move.l a3,a5
  314. move.w #32-1,d0
  315. init_list_loop32
  316. *init list
  317. move.w (a0)+,d1
  318. move.w (a1)+,d4
  319. move.w d1,d2
  320. move.w d2,d3
  321. andi.w #$f00,d1 ;get rgb of source
  322. lsr #8,d1
  323. andi.w #$f0,d2
  324. lsr #4,d2
  325. andi.w #$f,d3
  326. asl #6,d1
  327. asl #6,d2
  328. asl #6,d3
  329. move.w d1,(a5)+ ;store scaled values
  330. move.w d2,(a5)+
  331. move.w d3,(a5)+
  332. asr #6,d1
  333. asr #6,d2
  334. asr #6,d3
  335. move.w d4,d5 ;get rgb of dest
  336. move.w d5,d6
  337. andi.w #$f00,d4
  338. lsr #8,d4
  339. andi.w #$f0,d5
  340. lsr #4,d5
  341. andi.w #$f,d6
  342. sub.w d4,d1 ;get diff
  343. sub.w d5,d2
  344. sub.w d6,d3
  345. asl #6-4,d1 ;(vals *64)/16
  346. asl #6-4,d2
  347. asl #6-4,d3
  348. move.w d1,(a5)+ ;store reduce values
  349. move.w d2,(a5)+
  350. move.w d3,(a5)+
  351. dbra d0,init_list_loop32
  352. reduce_all_colours32
  353. move.w fade_speed,d0
  354. subq.w #1,d0
  355. wait_fade_speed32
  356. jsr Sync
  357. dbra d0,wait_fade_speed32
  358. move.l a2,a5 ;copper
  359. move.l a3,a4
  360. move.w #32-1,d1
  361. reduce_loop32
  362. move.w 6(a4),d2
  363. move.w 8(a4),d3
  364. move.w 10(a4),d4
  365. sub.w d2,(a4)
  366. sub.w d3,2(a4)
  367. sub.w d4,4(a4)
  368. move.w (a4),d2
  369. move.w 2(a4),d3
  370. move.w 4(a4),d4
  371. asr #6,d2
  372. asr #6,d3
  373. asr #6,d4
  374. lsl #8,d2
  375. lsl #4,d3
  376. or.w d2,d4
  377. or.w d3,d4
  378. move.w d4,(a5)
  379. addq.l #4,a5
  380. add.l #12,a4
  381. dbra d1,reduce_loop32
  382. dbra d7,reduce_all_colours32
  383. rts
  384. *****************************************
  385. *** Wait_For_Fire_Press *****
  386. *****************************************
  387. Wait_For_Fire_Press
  388. clr.w Fire
  389. Wait_For_User_To_Get_Bored
  390. jsr Sync
  391. bsr get_stick_readings
  392. tst fire
  393. beq.s Wait_For_User_To_Get_Bored
  394. bsr Clear_Stick
  395. rts
  396. *****************************************
  397. *** TAKE COPY OF AREA *****
  398. *****************************************
  399. Take_Copy_Of_Area
  400. move.l copyback_area,a0
  401. move.l copy_store_area,a1
  402. move.w #(SINGLE_PLANE/4)-1,d0
  403. make_copy
  404. move.l (a0),(a1)+
  405. clr.l (a0)+
  406. dbra d0,make_copy
  407. rts
  408. *****************************************
  409. *** RESTORE COPY AREA *****
  410. *****************************************
  411. Restore_Copy_Area
  412. move.l copyback_area,a1
  413. move.l copy_store_area,a0
  414. move.w #(SINGLE_PLANE/4)-1,d0
  415. restore_copy
  416. move.l (a0)+,(a1)+
  417. dbra d0,restore_copy
  418. rts
  419. *****************************************
  420. *** WHITE_ALL_PALETTE *****
  421. *****************************************
  422. White_All_Palette
  423. move.l #sprite_cols+2,a0
  424. move.w #16-1,d0
  425. white_all
  426. move.w #$fff,(a0)
  427. addq.l #4,a0
  428. dbra d0,white_all
  429. rts
  430. *****************************************
  431. *** SWITCH ON TEXT SCREEN *****
  432. *****************************************
  433. Switch_On_Text_Screen
  434. jsr Sync
  435. move.l copyback_area,d0 ;insert into copper
  436. move.w d0,plane5_lo
  437. swap d0
  438. move.w d0,plane5_hi
  439. move.w #$5200,plane_control ;pow!
  440. rts
  441. *****************************************
  442. *** SWITCH OFF TEXT SCREEN *****
  443. *****************************************
  444. Switch_Off_Text_Screen
  445. jsr Sync
  446. move.w #$4200,plane_control
  447. rts
  448. *****************************************
  449. *** CENTER TEXT *****
  450. *****************************************
  451. Center_Text
  452. *send text in a4, will set d0 = position
  453. moveq #0,d0
  454. moveq #0,d5
  455. moveq #0,d7
  456. move.l a4,a5
  457. center_loop
  458. move.b (a5)+,d7
  459. ble.s got_the_cent_pos
  460. cmp.b #"j",d7
  461. bge.s cent_last_line
  462. cmp.b #"F",d7
  463. bge.s cent_middle_line
  464. move.l #malfont_width_table,a1
  465. sub.b #" ",d7
  466. bra.s get_cent_pos
  467. cent_middle_line
  468. move.l #malfont_width_table2,a1
  469. sub.b #"F",d7
  470. bra.s get_cent_pos
  471. cent_last_line
  472. move.l #malfont_width_table3,a1
  473. sub.b #"j",d7
  474. get_cent_pos
  475. move.b (a1,d7),d5
  476. add.w d5,d0
  477. bra.s center_loop
  478. got_the_cent_pos
  479. neg.w d0
  480. add.w #320,d0
  481. asr d0
  482. move.w scroll_value,d7
  483. andi.w #$f,d7
  484. sub.w #$f,d7
  485. neg.w d7
  486. add.w d7,d0
  487. rts
  488. *****************************************
  489. *** DISPLAY STRING *****
  490. *****************************************
  491. Display_String
  492. *Send in null terminated string along with start x and y co-ords in a4,d0,d1
  493. *mem area in a3
  494. move.w d0,d3 ;save
  495. letter_extract_and_draw
  496. clr.l d2
  497. move.b (a4)+,d2
  498. beq.s finished_drawing_string
  499. bpl.s not_a_new_line
  500. cmp.b #CENTER_LINE,d2
  501. beq.s cent_line
  502. move.w d3,d0
  503. add.w #MALFONT_HEIGHT,d1
  504. bra.s letter_extract_and_draw
  505. cent_line
  506. bsr Center_Text
  507. bra.s letter_extract_and_draw
  508. not_a_new_line
  509. bsr Draw_Letter
  510. bra.s letter_extract_and_draw
  511. finished_drawing_string
  512. rts
  513. *****************************************
  514. *** DRAW LETTER *****
  515. *****************************************
  516. Draw_Letter
  517. *send in x and y in d0 and d1
  518. *letter in d2
  519. *mem in a3
  520. movem.l d0-d1/d3/a3,-(sp)
  521. cmp.b #"j",d2
  522. bge.s last_line
  523. cmp.b #"F",d2
  524. bge.s middle_line
  525. move.l #malfont,a0
  526. move.l #malfont_width_table,a1
  527. sub.b #" ",d2
  528. bra.s get_letter_pos
  529. middle_line
  530. move.l #malfont+MALFONT_HEIGHT*40,a0
  531. move.l #malfont_width_table2,a1
  532. sub.b #"F",d2
  533. bra.s get_letter_pos
  534. last_line
  535. move.l #malfont+(MALFONT_HEIGHT*2)*40,a0
  536. move.l #malfont_width_table3,a1
  537. sub.b #"j",d2
  538. get_letter_pos
  539. moveq #0,d5
  540. moveq #0,d3 ;pix pos in reg
  541. moveq #0,d4
  542. move.b (a1,d2),d4 ;the width of char
  543. move.w d4,wait_width ;title screen scroll stuff
  544. move.w d4,d7
  545. tst.b d2
  546. beq.s pix_at_zero
  547. find_pix_position
  548. move.b (a1)+,d5
  549. add.w d5,d3
  550. subq.w #1,d2
  551. bne.s find_pix_position
  552. pix_at_zero
  553. *Right, d4 = width, d3 = pixel position of char in graphics
  554. move.w d3,d5
  555. andi.w #$f,d5 ;shift of char
  556. andi.w #$fff0,d3
  557. asr #3,d3 ;bytes in
  558. add.l d3,a0 ;graphics position
  559. move.l #malfont_mask_table,a2
  560. asl #2,d4
  561. move.l (a2,d4),d4
  562. ror.l d5,d4
  563. *right so now work out where graphics have to go
  564. mulu text_bpr,d1
  565. add.l d1,a3
  566. sub.w d5,d0 ;sub char offset from desired pix dest
  567. bpl.s no_problem
  568. move.w text_bpr,d1
  569. move.w d1,d6
  570. ext.l d6
  571. asl #3,d1
  572. add.w d1,d0 ;if minus treat as on prev line
  573. sub.l d6,a3
  574. no_problem
  575. move.w d0,d1
  576. ext.l d1
  577. andi.w #$fff0,d1 ;work out bytes in (word bound)
  578. asr #3,d1
  579. add.l d1,a3
  580. andi.w #$f,d0 ;shift
  581. ror #4,d0
  582. move.w d0,d1
  583. ori.w #$0fea,d0 ;AB+C=D
  584. swap d0 ;blit shift
  585. move.w d1,d0 ;b's shift
  586. wait_for_all_blits
  587. btst #14,dmaconr(a6)
  588. bne.s wait_for_all_blits
  589. move.l d4,malfont_mask
  590. move.l d0,bltcon0(a6)
  591. move.w text_bpr,d0
  592. subq.w #6,d0
  593. move.w d0,bltcmod(a6)
  594. move.w d0,bltdmod(a6)
  595. move.w #-6,bltbmod(a6)
  596. move.w #40-6,bltamod(a6)
  597. move.l a3,bltcpth(a6)
  598. move.l a3,bltdpth(a6)
  599. move.l a0,bltapth(a6) ;graphics
  600. move.l #malfont_mask,bltbpth(a6) ;char mask
  601. move.l #$ffffffff,bltafwm(a6)
  602. move.w #MALFONT_HEIGHT<<6+3,bltsize(a6)
  603. movem.l (sp)+,d0-d1/d3/a3
  604. add.w d7,d0 ;update x position
  605. rts
  606. *Text Commands
  607. CENTER_LINE EQU -2
  608. CHANGE_COLOUR EQU -3
  609. *****************************************
  610. *** CENTER SMALL TEXT *****
  611. *****************************************
  612. Center_Small_Text
  613. *send text in a4, will set d0 = position
  614. moveq #0,d0
  615. moveq #0,d5
  616. moveq #0,d7
  617. move.l a4,a5
  618. center_small_loop
  619. move.b (a5)+,d7
  620. cmp.b #-1,d7
  621. beq.s got_the_small_cent_pos
  622. cmp.b #CHANGE_COLOUR,d7
  623. bne.s not_change_c
  624. move.b (a5)+,d7
  625. bra.s center_small_loop
  626. not_change_c
  627. cmp.b #"e",d7
  628. bge.s small_cent_last_line
  629. move.l #smallfont_width_table,a1
  630. sub.b #" ",d7
  631. bra.s get_small_cent_pos
  632. small_cent_last_line
  633. move.l #smallfont_width_table2,a1
  634. sub.b #"e",d7
  635. get_small_cent_pos
  636. move.b (a1,d7),d5
  637. add.w d5,d0
  638. bra.s center_small_loop
  639. got_the_small_cent_pos
  640. neg.w d0
  641. move.w text_bpr,d7
  642. asl #3,d7
  643. add.w d7,d0
  644. asr d0
  645. rts
  646. *****************************************
  647. *** DISPLAY SMALL STRING *****
  648. *****************************************
  649. Display_Small_String
  650. *Send in null terminated string along with start x and y co-ords in a4,d0,d1
  651. *mem area in a3
  652. move.w #WHITE,default_colour
  653. Display_Small_String_Skip
  654. small_wait_for_all_blits_before_start
  655. btst #14,dmaconr(a6)
  656. bne.s small_wait_for_all_blits_before_start
  657. move.w text_bpr,d2
  658. subq.w #6,d2
  659. move.w d2,bltcmod(a6)
  660. move.w d2,bltdmod(a6)
  661. move.w #-6,bltbmod(a6)
  662. move.w #40-6,bltamod(a6)
  663. move.l #$ffffffff,bltafwm(a6)
  664. move.w d0,d3 ;save
  665. small_letter_extract_and_draw
  666. clr.l d2
  667. move.b (a4)+,d2
  668. beq.s finished_drawing_small_string
  669. bpl.s not_a_new_small_line
  670. cmp.b #CHANGE_COLOUR,d2
  671. bne.s not_col_change
  672. move.b (a4)+,d2
  673. ext.w d2
  674. move.w d2,default_colour
  675. bra.s small_letter_extract_and_draw
  676. not_col_change
  677. cmp.b #CENTER_LINE,d2
  678. beq.s cent_small_line
  679. move.w d3,d0
  680. add.w #SMALLFONT_HEIGHT,d1
  681. bra.s small_letter_extract_and_draw
  682. cent_small_line
  683. bsr Center_Small_Text
  684. bra.s small_letter_extract_and_draw
  685. not_a_new_small_line
  686. bsr Draw_Small_Letter
  687. bra.s small_letter_extract_and_draw
  688. finished_drawing_small_string
  689. rts
  690. default_colour dc.w WHITE
  691. *****************************************
  692. *** DRAW SMALL LETTER *****
  693. *****************************************
  694. Draw_Small_Letter
  695. *send in x and y in d0 and d1
  696. *letter in d2
  697. *mem in a3
  698. cmp.b #' ',d2
  699. bne.s not_a_space
  700. addq.w #5,d0
  701. rts
  702. not_a_space
  703. movem.l d0-d1/d3/a3,-(sp)
  704. cmp.b #"e",d2
  705. bge.s last_small_line
  706. move.l #smallfont,a0
  707. move.l #smallfont_width_table,a1
  708. sub.b #" ",d2
  709. bra.s get_small_letter_pos
  710. last_small_line
  711. move.l #smallfont+SMALLFONT_HEIGHT*40,a0
  712. move.l #smallfont_width_table2,a1
  713. sub.b #"e",d2
  714. get_small_letter_pos
  715. moveq #0,d5
  716. moveq #0,d3 ;pix pos in reg
  717. moveq #0,d4
  718. move.b (a1,d2),d4 ;the width of char
  719. move.w d4,d7
  720. tst.b d2
  721. beq.s small_pix_at_zero
  722. small_find_pix_position
  723. move.b (a1)+,d5
  724. add.w d5,d3
  725. subq.w #1,d2
  726. bne.s small_find_pix_position
  727. small_pix_at_zero
  728. *Right, d4 = width, d3 = pixel position of char in graphics
  729. move.w d3,d5
  730. andi.w #$f,d5 ;shift of char
  731. andi.w #$fff0,d3
  732. asr #3,d3 ;bytes in
  733. add.l d3,a0 ;graphics position
  734. move.l #malfont_mask_table,a2
  735. asl #2,d4
  736. move.l (a2,d4),d4
  737. ror.l d5,d4
  738. *right so now work out where graphics have to go
  739. mulu text_bpr,d1
  740. add.l d1,a3
  741. sub.w d5,d0 ;sub char offset from desired pix dest
  742. bpl.s small_no_problem
  743. move.w text_bpr,d1
  744. move.w d1,d6
  745. ext.l d6
  746. asl #3,d1
  747. add.w d1,d0 ;if minus treat as on prev line
  748. sub.l d6,a3
  749. small_no_problem
  750. move.w d0,d1
  751. ext.l d1
  752. andi.w #$fff0,d1 ;work out bytes in (word bound)
  753. asr #3,d1
  754. add.l d1,a3
  755. andi.w #$f,d0 ;shift
  756. ror #4,d0
  757. move.w d0,d1
  758. ori.w #$0fea,d0 ;AB+C=D
  759. swap d0 ;blit shift
  760. move.w d1,d0 ;b's shift
  761. move.w default_colour,d6
  762. draw_coloured_text
  763. lsr.w d6
  764. bcc.s dont_draw_plane
  765. small_wait_for_all_blits
  766. btst #14,dmaconr(a6)
  767. bne.s small_wait_for_all_blits
  768. move.l d4,malfont_mask
  769. move.l d0,bltcon0(a6)
  770. move.l a3,bltcpth(a6)
  771. move.l a3,bltdpth(a6)
  772. move.l a0,bltapth(a6) ;graphics
  773. move.l #malfont_mask,bltbpth(a6) ;char mask
  774. move.w #SMALLFONT_HEIGHT<<6+3,bltsize(a6)
  775. dont_draw_plane
  776. add.l Plane_Skip_Size,a3
  777. tst.w d6
  778. bne.s draw_coloured_text
  779. movem.l (sp)+,d0-d1/d3/a3
  780. add.w d7,d0 ;update x position
  781. rts
  782. Plane_Skip_Size
  783. dc.l LO_RES_PLANE
  784. *****************************************
  785. *** SET SPRITE TO SCREEN *****
  786. *****************************************
  787. Set_Sprite_To_Screen
  788. *send in colour to make in d0
  789. *Set the sprite colours to the game colours
  790. move.l #sprite_cols+2,a0
  791. move.l #copper_colours+2,a2
  792. move.l #black_list,a1
  793. move.l #game_list,a3
  794. move.w #16-1,d1
  795. set_sprite_to_game
  796. move.w (a2),(a0)
  797. move.w (a2),(a3)+
  798. move.w d0,(a1)+
  799. addq.l #4,a0
  800. addq.l #4,a2
  801. dbra d1,set_sprite_to_game
  802. rts
  803. *****************************************
  804. *** CHECK FOR CONTINUE *****
  805. *****************************************
  806. Check_For_Continue
  807. move.w Continue_Credits,d0
  808. add.w #48,d0
  809. move.b d0,Number_Of_Continues+14
  810. move.w #BPR,text_bpr
  811. bsr Take_Copy_Of_Area
  812. bsr Remove_Scanner
  813. bsr Remove_Player
  814. bsr White_All_Palette
  815. move.l #Continue_Text,a4
  816. move.w scroll_value,d0
  817. andi.w #$f,d0
  818. sub.w #$f,d0
  819. neg.w d0
  820. add.w #40,d0
  821. move.w #90,d1
  822. move.l copyback_area,a3
  823. bsr Display_String
  824. bsr Switch_On_Text_Screen
  825. Wait_For_Response
  826. jsr Sync
  827. bsr Read_Keyboard
  828. cmp.w #'N',d7
  829. beq.s Dont_Continue_Game
  830. cmp.w #'n',d7
  831. beq.s Dont_Continue_Game
  832. cmp.w #'Y',d7
  833. beq.s Continue_With_Game
  834. cmp.w #'y',d7
  835. beq.s Continue_With_Game
  836. bra.s Wait_For_Response
  837. Continue_With_Game
  838. subq.w #1,Continue_Credits
  839. clr.w Cash
  840. clr.w Cash_Request
  841. clr.l Score
  842. clr.w Inter_Score
  843. bsr Switch_Off_Text_Screen
  844. bsr Restore_Copy_Area
  845. move.w #3,Player_Lives
  846. move.w Player_Energy_Limit,Player_Current_Energy
  847. bsr Display_Total_Energy
  848. bsr Display_Player_Lives
  849. move.w #GAME_LOOP,Schedule_Entry
  850. bsr Do_Sprite_Colours
  851. bsr Display_Scanner
  852. bsr Display_Player
  853. move.w #1,d0
  854. rts
  855. Dont_Continue_Game
  856. bsr Switch_Off_Text_Screen
  857. clr.w d0
  858. rts
  859. *****************************************
  860. *** GAME OVER SCREEN *****
  861. *****************************************
  862. Game_Over_Screen
  863. move.w #BPR,text_bpr
  864. bsr Take_Copy_Of_Area
  865. bsr Remove_Scanner
  866. bsr Remove_Player
  867. bsr Delete_Points_From_Scanner
  868. move.l #Game_Over_Text,a4
  869. move.w scroll_value,d0
  870. andi.w #$f,d0
  871. sub.w #$f,d0
  872. neg.w d0
  873. add.w #60,d0
  874. move.w #90,d1
  875. move.l copyback_area,a3
  876. bsr Display_String
  877. move.l #black_list,a0
  878. move.w #16-1,d0
  879. fill_bl_wr
  880. move.w #$a00,(a0)+
  881. dbra d0,fill_bl_wr
  882. move.w #1,Fade_Speed
  883. jsr Sync
  884. move.l level_palette,a0
  885. move.l #black_list,a1
  886. move.l #copper_colours+2,a2
  887. move.w #10-1,d7
  888. move.l #store_text_nums,a3
  889. bsr Fade_List_To_List
  890. bsr Switch_On_Text_Screen
  891. move.w #$fff,d0
  892. bsr Set_Sprite_To_Screen
  893. *Fade text screen colours to black
  894. move.w #3,Fade_Speed
  895. jsr Sync
  896. move.l #Game_list,a0
  897. move.l #black_list,a1
  898. move.l #sprite_cols+2,a2
  899. move.w #12-1,d7
  900. move.l #store_text_nums,a3
  901. bsr Fade_List_To_List
  902. bsr Wait_For_Fire_Press
  903. rts
  904. Fade_Speed dc.w 1
  905. *****************************************
  906. *** BLACK OUT EVERYTHING *****
  907. *****************************************
  908. Black_Out_Everything
  909. move.l #copper_colours+2,a0
  910. move.l #sprite_cols+2,a1
  911. move.l #panel_colours+2,a2
  912. move.w #16-1,d0
  913. black_out_loop
  914. clr.w (a0)
  915. clr.w (a1)
  916. clr.w (a2)
  917. addq.l #4,a0
  918. addq.l #4,a1
  919. addq.l #4,a2
  920. dbra d0,black_out_loop
  921. rts
  922. *****************************************
  923. *** WAIT FOR USER FIRE PRESS *****
  924. *****************************************
  925. Wait_For_User_Fire_Press
  926. btst #7,$bfe001
  927. bne.s Wait_For_User_Fire_Press
  928. rts
  929. *****************************************
  930. *** LEVEL OVER SCREEN *****
  931. *****************************************
  932. Level_Over_Screen
  933. bsr Remove_Scanner
  934. bsr Remove_Player
  935. bsr Convert_Cash_To_String
  936. move.l #score_line+11,a5
  937. clr.w d7 ;convert zero's
  938. bsr Convert_Score_To_String
  939. move.w #BPR,text_bpr
  940. bsr Take_Copy_Of_Area
  941. move.l #Level_Over_Text,a4
  942. move.w #0,d0
  943. move.w #0,d1
  944. move.l copyback_area,a3
  945. bsr Display_String
  946. bsr Clear_Black_Colours
  947. move.w #1,Fade_Speed
  948. jsr Sync
  949. move.l level_palette,a0
  950. move.l #black_list,a1
  951. move.l #copper_colours+2,a2
  952. move.w #4-1,d7
  953. move.l #store_text_nums,a3
  954. bsr Fade_List_To_List
  955. bsr Switch_On_Text_Screen
  956. move.w #$fff,d0
  957. bsr Set_Sprite_To_Screen
  958. *Fade text screen colours to black
  959. move.w #3,Fade_Speed
  960. jsr Sync
  961. move.l #Game_list,a0
  962. move.l #black_list,a1
  963. move.l #sprite_cols+2,a2
  964. move.w #8-1,d7
  965. move.l #store_text_nums,a3
  966. bsr Fade_List_To_List
  967. bsr Wait_For_Fire_Press
  968. bsr Switch_Off_Text_Screen
  969. rts
  970. *****************************************
  971. *** DISPLAY END GAME *****
  972. *****************************************
  973. Display_End_Game
  974. bsr Clear_Black_Colours
  975. move.w #1,Fade_Speed
  976. move.l #black_list,a1
  977. move.l #panel_cols,a0
  978. move.l #panel_colours+2,a2
  979. move.w #16-1,d7
  980. move.l #store_text_nums,a3
  981. bsr Fade_List_To_List ;fade to black
  982. move.w #3,Fade_Speed
  983. move.l #black_list,a1
  984. move.l level_palette,a0
  985. move.l #copper_colours+2,a2
  986. move.w #16-1,d7
  987. move.l #store_text_nums,a3
  988. bsr Fade_List_To_List ;fade to black
  989. move.w #BIT_PLANE_DMA+SPRITE_DMA,dmacon(a6)
  990. move.l memory_base,d0
  991. move.w d0,SHPlane1_lo
  992. swap d0
  993. move.w d0,SHPlane1_hi
  994. swap d0
  995. add.l #LO_RES_PLANE,d0
  996. move.w d0,SHPlane2_lo
  997. swap d0
  998. move.w d0,SHPlane2_hi
  999. swap d0
  1000. add.l #LO_RES_PLANE,d0
  1001. move.w d0,SHPlane3_lo
  1002. swap d0
  1003. move.w d0,SHPlane3_hi
  1004. swap d0
  1005. add.l #LO_RES_PLANE,d0
  1006. move.w d0,SHPlane4_lo
  1007. swap d0
  1008. move.w d0,SHPlane4_hi
  1009. swap d0
  1010. add.l #LO_RES_PLANE,d0
  1011. move.w d0,SHPlane5_lo
  1012. swap d0
  1013. move.w d0,SHPlane5_hi
  1014. bsr Clear_Black_Colours
  1015. bsr Clear_Game_Colours
  1016. bsr Load_EndGame_Picture
  1017. move.l #shareware_screen_copper,cop1lch(a6)
  1018. clr.w copjmp1(a6)
  1019. jsr Sync
  1020. move.w #BIT_PLANE_DMA+$8000,dmacon(a6)
  1021. move.l #black_list,a0
  1022. move.l colour_map_ptr,a1
  1023. move.l #share_cols+2,a2
  1024. move.w #16-1,d7
  1025. move.l #store_text_nums,a3
  1026. bsr Fade_32_List_To_List
  1027. bsr Wait_For_Fire_Press
  1028. move.l #black_list,a1
  1029. move.l colour_map_ptr,a0
  1030. move.l #share_cols+2,a2
  1031. move.w #16-1,d7
  1032. move.l #store_text_nums,a3
  1033. bsr Fade_32_List_To_List
  1034. rts
  1035. *****************************************
  1036. *** DISPLAY GET READY *****
  1037. *****************************************
  1038. Display_Get_Ready
  1039. move.w split_position,d3
  1040. cmp.w #GET_READY_Y_POS,d3
  1041. bgt.s gr_before_split
  1042. move.l current_alien_split_draw_position,a3
  1043. move.w #GET_READY_Y_POS,d2
  1044. move.w d2,d4
  1045. sub.w d3,d4
  1046. mulu #BPR,d4
  1047. add.l d4,a3
  1048. bra.s do_the_bis
  1049. gr_before_split
  1050. move.l current_alien_draw_position,a3
  1051. add.l #GET_READY_Y_POS*BPR,a3
  1052. move.w #GET_READY_Y_POS,d2
  1053. do_the_bis
  1054. add.l #GET_READY_BYTE_POS,a3
  1055. move.w d2,get_ready_split
  1056. move.l a3,get_ready_mem_pos
  1057. move.l #get_ready_graphics,a1
  1058. move.l copy_store_area,a0
  1059. move.w #GET_READY_HEIGHT-1,d0
  1060. get_ready_y_loop
  1061. move.w #GET_READY_WORDS-1,d1
  1062. copy_back_and_in
  1063. *make mask
  1064. move.w (a1),d4
  1065. or.w GET_READY_PLANE(a1),d4
  1066. or.w GET_READY_PLANE*2(a1),d4
  1067. or.w GET_READY_PLANE*3(a1),d4
  1068. not.w d4
  1069. move.w (a3),(a0)+ ;back
  1070. and.w d4,(a3)
  1071. move.w (a1),d5
  1072. or.w d5,(a3) ;in
  1073. move.w PLANE_INC(a3),(a0)+ ;back
  1074. and.w d4,PLANE_INC(a3)
  1075. move.w GET_READY_PLANE(a1),d5
  1076. or.w d5,PLANE_INC(a3) ;in
  1077. add.l #PLANE_INC*2,a3
  1078. move.w (a3),(a0)+ ;back
  1079. and.w d4,(a3)
  1080. move.w GET_READY_PLANE*2(a1),d5
  1081. or.w d5,(a3) ;in
  1082. move.w PLANE_INC(a3),(a0)+ ;back
  1083. and.w d4,PLANE_INC(a3)
  1084. move.w GET_READY_PLANE*3(a1),d5
  1085. or.w d5,PLANE_INC(a3) ;in
  1086. sub.l #(PLANE_INC*2)-2,a3
  1087. addq.l #2,a1
  1088. dbra d1,copy_back_and_in
  1089. add.l #BPR-(GET_READY_WORDS*2),a3
  1090. addq.w #1,d2
  1091. cmp.w d2,d3
  1092. bne.s gr_stillbefore_split
  1093. move.l current_alien_split_draw_position,a3
  1094. add.l #GET_READY_BYTE_POS,a3
  1095. gr_stillbefore_split
  1096. dbra d0,get_ready_y_loop
  1097. rts
  1098. get_ready_mem_pos
  1099. dc.l 0
  1100. get_ready_split
  1101. dc.w 0
  1102. *****************************************
  1103. *** REMOVE GET READY *****
  1104. *****************************************
  1105. Remove_Get_Ready
  1106. move.w #$8080,d7 ;mask
  1107. keep_going_until_mask_complete
  1108. jsr Sync
  1109. move.w d7,d4
  1110. not.w d4
  1111. move.l get_ready_mem_pos,a3
  1112. move.w split_position,d3
  1113. move.w get_ready_split,d2
  1114. move.l copy_store_area,a0
  1115. move.w #GET_READY_HEIGHT-1,d0
  1116. get_rep_ready_y_loop
  1117. move.w #GET_READY_WORDS-1,d1
  1118. copy_rep_back
  1119. move.w (a0)+,d6
  1120. move.w (a3),d5
  1121. and.w d7,d6
  1122. and.w d4,d5
  1123. or.w d5,d6
  1124. move.w d6,(a3)
  1125. move.w (a0)+,d6
  1126. move.w PLANE_INC(a3),d5
  1127. and.w d7,d6
  1128. and.w d4,d5
  1129. or.w d5,d6
  1130. move.w d6,PLANE_INC(a3)
  1131. add.l #PLANE_INC*2,a3
  1132. move.w (a0)+,d6
  1133. move.w (a3),d5
  1134. and.w d7,d6
  1135. and.w d4,d5
  1136. or.w d5,d6
  1137. move.w d6,(a3)
  1138. move.w (a0)+,d6
  1139. move.w PLANE_INC(a3),d5
  1140. and.w d7,d6
  1141. and.w d4,d5
  1142. or.w d5,d6
  1143. move.w d6,PLANE_INC(a3)
  1144. sub.l #(PLANE_INC*2)-2,a3
  1145. dbra d1,copy_rep_back
  1146. add.l #BPR-(GET_READY_WORDS*2),a3
  1147. addq.w #1,d2
  1148. cmp.w d2,d3
  1149. bne.s gr_rep_stillbefore_split
  1150. move.l current_alien_split_draw_position,a3
  1151. add.l #GET_READY_BYTE_POS,a3
  1152. gr_rep_stillbefore_split
  1153. dbra d0,get_rep_ready_y_loop
  1154. cmp.w #$ffff,d7
  1155. beq.s finished_wipe
  1156. ror.w d7
  1157. or.w #$8080,d7
  1158. bra keep_going_until_mask_complete
  1159. finished_wipe
  1160. rts
  1161. ****************************************
  1162. **** CONVERT CASH TO STRING ********
  1163. ****************************************
  1164. Convert_Cash_To_String
  1165. move.w cash,d0
  1166. move.l #cash_line+10,a0
  1167. ext.l d0
  1168. move.l #10000,d1
  1169. convert_csh_loop
  1170. divu d1,d0
  1171. move.w d0,d2 ;units
  1172. clr.w d0
  1173. swap d0
  1174. add.b #'0',d2
  1175. move.b d2,(a0)+
  1176. cmp.w #1,d1
  1177. beq.s done_csh_convert
  1178. divu #10,d1
  1179. bra.s convert_csh_loop
  1180. done_csh_convert
  1181. rts
  1182. ****************************************
  1183. **** CONVERT SCORE TO STRING ********
  1184. ****************************************
  1185. Convert_Score_To_String
  1186. *send string in a5
  1187. *leading zero flag in d7 - 0 = keep zeros
  1188. move.l score,d0
  1189. clr.w d3
  1190. move.l #long_num_vals,a1
  1191. move.l (a1)+,d1
  1192. convert_scr_loop
  1193. clr.w d2
  1194. instance_count
  1195. sub.l d1,d0
  1196. bmi.s reached_end_c
  1197. addq.w #1,d2
  1198. bra.s instance_count
  1199. reached_end_c
  1200. add.l d1,d0
  1201. tst d7
  1202. beq.s forget_zeros
  1203. tst d2
  1204. bne.s forget_zeros
  1205. tst d3
  1206. bne.s forget_zeros
  1207. move.b #' ',(a5)+
  1208. bra.s done_z_tst
  1209. forget_zeros
  1210. move.w #1,d3
  1211. add.b #'0',d2
  1212. move.b d2,(a5)+
  1213. done_z_tst
  1214. cmp.w #1,d1
  1215. beq.s done_scr_loop
  1216. move.l (a1)+,d1
  1217. bra.s convert_scr_loop
  1218. done_scr_loop
  1219. rts