scanner_routines.s 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. *********************************************
  2. **** SET UP SCANNER DATA ****
  3. *********************************************
  4. Setup_Scanner_Data
  5. bsr Clear_Hostage_Indicators
  6. move.l #scanner_point_data,scanner_points_list_end
  7. move.w #$ffff,scanner_point_data
  8. move.w #$ffff,points_on_scanner
  9. bsr Setup_Points_Of_Interest
  10. bsr Dim_Scanner
  11. rts
  12. *********************************************
  13. **** CONVERT CLIP DATA ****
  14. *********************************************
  15. Convert_Clip_Data
  16. move.l #scanner_x_clip_data,a0
  17. move.w #31-1,d0
  18. convert_data_loop
  19. move.w (a0),d1
  20. mulu #(1152/31),d1
  21. move.w d1,(a0)+
  22. move.w (a0),d1
  23. mulu #(1152/31),d1
  24. subq.w #1,d1 ;cos bits on scanner two high
  25. move.w d1,(a0)+
  26. dbra d0,convert_data_loop
  27. rts
  28. *********************************************
  29. **** SETUP POINTS OF INTEREST ****
  30. *********************************************
  31. Setup_Points_Of_Interest
  32. clr.w number_of_hostages
  33. move.l current_alien_map_pointer,a5
  34. moveq #0,d1
  35. move.l #generic_map_header,a1
  36. move.w map_data_y(a1),d3
  37. subq.w #1,d3
  38. scanner_x_loop
  39. moveq #0,d0
  40. move.w map_data_x(a1),d2
  41. subq.w #1,d2
  42. move.l a5,a0
  43. scanner_setup_loop
  44. move.b (a0),d5
  45. cmp.b #GENERATOR,d5
  46. bne.s check_for_hos
  47. move.w d0,generator_x
  48. move.w d1,generator_y
  49. move.l a0,generator_map_pos
  50. check_for_hos
  51. cmp.b #HOSTAGE,d5
  52. bne.s keep_checking_map
  53. addq.w #1,number_of_hostages
  54. bsr Add_Scanner_Point
  55. keep_checking_map
  56. addq.l #1,a0
  57. add.w #16,d0
  58. subq.w #1,d2
  59. bne.s scanner_setup_loop
  60. add.l #BIGGEST_MAP_X,a5 ;next line
  61. add.w #16,d1
  62. subq.w #1,d3
  63. bne.s scanner_x_loop
  64. bsr Display_Hostage_Indicators
  65. rts
  66. DOT_DIST EQU 72
  67. *********************************************
  68. **** REMOVE HOSTAGE SCANNER POINT ****
  69. *********************************************
  70. Remove_Hostage_Scanner_Point
  71. *alien info in a1
  72. moveq #0,d7 ;use as flag
  73. move.l #scanner_point_data,a0
  74. move.l a0,a5
  75. remove_hos_loop
  76. cmp.w #$ffff,(a0)
  77. beq.s found_end_of_list
  78. tst d7
  79. bne.s copy_list_data
  80. move.l scanner_map_pos(a0),a4
  81. cmp.l alien_map_pos(a1),a4
  82. bne.s copy_list_data
  83. moveq #1,d7
  84. bra.s update_list_pos
  85. copy_list_data
  86. move.l scanner_point_x(a0),scanner_point_x(a5)
  87. move.l scanner_map_pos(a0),scanner_map_pos(a5)
  88. add.l #scanner_data_size,a5
  89. update_list_pos
  90. add.l #scanner_data_size,a0
  91. bra.s remove_hos_loop
  92. found_end_of_list
  93. move.w #$ffff,(a5)
  94. move.l a5,scanner_points_list_end
  95. subq.w #1,number_of_hostages
  96. bne not_collected_all_hostages
  97. move.w number_of_hostages,d7
  98. bsr Remove_Hostage_Char
  99. rts
  100. not_collected_all_hostages
  101. move.w number_of_hostages,d7
  102. bsr Remove_Hostage_Char
  103. rts
  104. *************************************************
  105. **** COLLECTED LAST HOSTAGE *****
  106. *************************************************
  107. Collected_Last_Hostage
  108. *use block d6 and d7 pos
  109. move.w #-1,number_of_hostages
  110. move.l #scanner_point_data,a2
  111. move.l generator_map_pos,a0
  112. move.w generator_x,d0
  113. move.w generator_y,d1
  114. sub.w #DOT_DIST,d1
  115. move.w d0,scanner_point_x(a2)
  116. move.w d1,scanner_point_y(a2)
  117. move.l a0,scanner_map_pos(a2)
  118. add.l #scanner_data_size,a2
  119. add.w #DOT_DIST,d1
  120. move.w d0,scanner_point_x(a2)
  121. move.w d1,scanner_point_y(a2)
  122. move.l a0,scanner_map_pos(a2)
  123. add.l #scanner_data_size,a2
  124. sub.w #DOT_DIST,d0
  125. move.w d0,scanner_point_x(a2)
  126. move.w d1,scanner_point_y(a2)
  127. move.l a0,scanner_map_pos(a2)
  128. add.l #scanner_data_size,a2
  129. add.w #DOT_DIST*2,d0
  130. move.w d0,scanner_point_x(a2)
  131. move.w d1,scanner_point_y(a2)
  132. move.l a0,scanner_map_pos(a2)
  133. add.l #scanner_data_size,a2
  134. sub.w #DOT_DIST,d0
  135. add.w #DOT_DIST,d1
  136. move.w d0,scanner_point_x(a2)
  137. move.w d1,scanner_point_y(a2)
  138. move.l a0,scanner_map_pos(a2)
  139. add.l #scanner_data_size,a2
  140. move.w #$ffff,(a2)
  141. move.w d6,d0
  142. andi.w #$fff0,d0
  143. move.w d7,d1
  144. sub.w #160,d1
  145. move.l #Fire_Key_object,d2
  146. bsr Simple_Add_Alien_To_List
  147. move.w #Sound_Switch,sound_chan4
  148. rts
  149. *********************************************
  150. **** ADD SCANNER POINT ****
  151. *********************************************
  152. Add_Scanner_Point
  153. move.l scanner_points_list_end,a2
  154. move.w d0,scanner_point_x(a2)
  155. move.w d1,scanner_point_y(a2)
  156. move.l a0,scanner_map_pos(a2)
  157. add.l #scanner_data_size,a2
  158. move.w #$ffff,(a2)
  159. move.l a2,scanner_points_list_end
  160. rts
  161. scanner_points_list_end
  162. dc.l scanner_point_data
  163. *********************************************
  164. **** DISPLAY POINTS ON SCANNER ****
  165. *********************************************
  166. Display_Points_On_Scanner
  167. clr.w d2
  168. moveq #0,d0
  169. moveq #0,d1
  170. move.w actual_player_map_x_position,d0
  171. move.w actual_player_map_y_position,d1
  172. move.w d1,d3
  173. sub.w #240*2,d1
  174. add.w #240*2,d3
  175. sub.w #288*2,d0
  176. move.l #scanner_x_clip_data,a2
  177. move.l #scanner_point_data,a0
  178. move.l #points_on_scanner,a3
  179. add_points_to_scanner_loop
  180. cmp.w #$ffff,(a0)
  181. beq done_adding_points_to_scanner
  182. move.w scanner_point_y(a0),d4
  183. cmp.w d1,d4
  184. ble not_point_on_scanner
  185. cmp.w d3,d4
  186. bgt not_point_on_scanner
  187. move.w d0,d5
  188. move.w d0,d6
  189. *Test x against position using clipper
  190. sub.w d1,d4
  191. ext.l d4
  192. divs #((240*4)/31)+1,d4 ;number from 0 - 31
  193. ext.l d4
  194. asl #2,d4
  195. add.w (a2,d4),d5
  196. move.w scanner_point_x(a0),d7
  197. cmp.w d5,d7
  198. ble not_point_on_scanner
  199. add.w 2(a2,d4),d6
  200. cmp.w d6,d7
  201. bgt not_point_on_scanner
  202. *Is point on scanner (d7 = x and d4 = y)
  203. asr #2,d4
  204. addq.b #1,d2
  205. *Plot point on scanner
  206. sub.w d0,d7
  207. moveq #0,d6
  208. ext.l d7
  209. divs #(288*4)/31,d7
  210. move.l #scanner1+4,a4
  211. move.w d7,d6
  212. asr #4,d7 ;get sprite 0 - 3
  213. muls #(SCANNER_HEIGHT+2)*4,d7
  214. add.l d7,a4 ;get sprite
  215. addq.l #4,a4 ;get past header info
  216. clr.b scanner_sprpos(a3)
  217. moveq #0,d7 ;flag
  218. andi.w #$f,d6
  219. cmp.w #8,d6
  220. blt.s in_first_byte
  221. subq.w #8,d6
  222. addq.l #1,a4
  223. moveq #1,d7
  224. in_first_byte
  225. asl #2,d4
  226. add.l d4,a4 ;actual place
  227. neg.b d6
  228. add.b #$7,d6 ;pixel position
  229. move.l a4,scanner_mem_pos(a3)
  230. move.b d6,scanner_pix_pos(a3)
  231. bchg d6,(a4)
  232. bchg d6,4(a4)
  233. subq.b #1,d6
  234. bge.s not_gone_over_bound
  235. addq.l #1,a4
  236. tst d7
  237. beq.s not_onto_next_sprite_draw
  238. add.l #((SCANNER_HEIGHT+2)*4)-2,a4
  239. move.b #1,scanner_sprpos(a3)
  240. not_onto_next_sprite_draw
  241. bchg #7,(a4)
  242. bchg #7,4(a4)
  243. bra.s done_big_pix
  244. not_gone_over_bound
  245. bchg d6,(a4)
  246. bchg d6,4(a4)
  247. done_big_pix
  248. done_draw_point
  249. add.l #scanner_pixels_size,a3
  250. not_point_on_scanner
  251. add.l #scanner_data_size,a0
  252. bra add_points_to_scanner_loop
  253. done_adding_points_to_scanner
  254. move.w #$ffff,(a3)
  255. tst d2
  256. beq.s no_hostages_plotted
  257. bsr Brighten_Scanner
  258. rts
  259. no_hostages_plotted
  260. bsr Dim_Scanner
  261. rts
  262. *********************************************
  263. **** BRIGHTEN SCANNER ****
  264. *********************************************
  265. Brighten_Scanner
  266. move.l #sprite_cols+2,a0
  267. move.w #$0d0,9*4(a0)
  268. move.w #$0d0,13*4(a0)
  269. move.w #$0a2,11*4(a0)
  270. move.w #$0a2,15*4(a0)
  271. rts
  272. *********************************************
  273. **** DIM SCANNER ****
  274. *********************************************
  275. Dim_Scanner
  276. move.l #sprite_cols+2,a0
  277. move.w #$0a0,9*4(a0)
  278. move.w #$0a0,13*4(a0)
  279. move.w #$071,11*4(a0)
  280. move.w #$071,15*4(a0)
  281. rts
  282. *********************************************
  283. **** DELETE POINTS FROM SCANNER ****
  284. *********************************************
  285. Delete_Points_From_Scanner
  286. move.l #points_on_scanner,a0
  287. moveq #0,d0
  288. delete_points_loop
  289. cmp.w #$ffff,(a0)
  290. beq.s all_points_deleted
  291. move.l scanner_mem_pos(a0),a1
  292. move.b scanner_pix_pos(a0),d0
  293. bchg d0,(a1)
  294. bchg d0,4(a1)
  295. subq.b #1,d0
  296. bge.s del_not_gone_over_bound
  297. addq.l #1,a1
  298. tst.b scanner_sprpos(a0)
  299. beq.s not_onto_next_sprite_del
  300. add.l #((SCANNER_HEIGHT+2)*4)-2,a1
  301. not_onto_next_sprite_del
  302. bchg #7,(a1)
  303. bchg #7,4(a1)
  304. bra.s done_del_big_pix
  305. del_not_gone_over_bound
  306. bchg d0,(a1)
  307. bchg d0,4(a1)
  308. done_del_big_pix
  309. add.l #scanner_pixels_size,a0
  310. bra.s delete_points_loop
  311. all_points_deleted
  312. rts
  313. *****************************************
  314. ****** CLEAR KEY INDICATORS *******
  315. *****************************************
  316. Clear_Key_Indicators
  317. move.l #scanner1+39*4,a0
  318. move.l #scanner2+39*4,a1
  319. move.w #7-1,d0
  320. clear_key_chars
  321. clr.w (a0)
  322. clr.w (a1)
  323. addq.l #4,a0
  324. addq.l #4,a1
  325. dbra d0,clear_key_chars
  326. rts
  327. *****************************************
  328. ****** CLEAR HOSTAGE INDICATORS *******
  329. *****************************************
  330. Clear_Hostage_Indicators
  331. move.l #scanner1+33*4,a0
  332. move.l #scanner2+33*4,a1
  333. move.w #5-1,d0
  334. clear_hos_chars
  335. clr.w (a0)
  336. clr.w (a1)
  337. addq.l #4,a0
  338. addq.l #4,a1
  339. dbra d0,clear_hos_chars
  340. rts
  341. *********************************************
  342. **** SET END KEY ON SCANNER ****
  343. *********************************************
  344. Set_End_Key_On_Scanner
  345. move.l #scanner1+33*4,a0
  346. move.l #scanner2+33*4,a1
  347. move.w #%0000000000010100,(a0)
  348. move.w #%0011000000000000,(a1)
  349. move.w #%0000000000010100,4(a0)
  350. move.w #%0100100000000000,4(a1)
  351. move.w #%0000000000111111,8(a0)
  352. move.w #%1100100000000000,8(a1)
  353. move.w #%0000000000000000,12(a0)
  354. move.w #%0100100000000000,12(a1)
  355. move.w #%0000000000000000,16(a0)
  356. move.w #%0011000000000000,16(a1)
  357. rts
  358. *****************************************
  359. ****** DISPLAY HOSTAGE INDICATORS *******
  360. *****************************************
  361. Display_Hostage_Indicators
  362. move.w number_of_hostages,d0
  363. cmp.w #7,d0
  364. ble.s dont_draw_more_than_display
  365. move.w #7,d0
  366. dont_draw_more_than_display
  367. tst d0
  368. beq.s none_to_display
  369. subq.w #1,d0
  370. display_all_hos
  371. move.w d0,d7
  372. bsr Display_Hostage_Char
  373. dbra d0,display_all_hos
  374. none_to_display
  375. rts
  376. *****************************************
  377. ****** DISPLAY HOSTAGE CHAR *******
  378. *****************************************
  379. Display_Hostage_Char
  380. *send num in d7
  381. cmp.w #7,d7
  382. ble.s hostage_on_scanner
  383. rts
  384. hostage_on_scanner
  385. cmp.w #4,d7
  386. blt.s second_sprite
  387. move.l #scanner1+33*4,a0
  388. subq.w #4,d7
  389. bra.s copy_hostage_data_in
  390. second_sprite
  391. move.l #scanner2+33*4,a0
  392. copy_hostage_data_in
  393. lsl #2,d7
  394. move.w #$a,d6
  395. lsl d7,d6
  396. or.w d6,(a0)
  397. or.w d6,4(a0)
  398. or.w d6,12(a0)
  399. or.w d6,16(a0)
  400. move.w #$e,d6
  401. lsl d7,d6
  402. or.w d6,8(a0)
  403. rts
  404. *****************************************
  405. ****** REMOVE HOSTAGE CHAR *******
  406. *****************************************
  407. Remove_Hostage_Char
  408. *send num in d7
  409. cmp.w #7,d7
  410. ble.s clear_hostage_on_scanner
  411. rts
  412. clear_hostage_on_scanner
  413. cmp.w #4,d7
  414. blt.s clear_second_sprite
  415. move.l #scanner1+33*4,a0
  416. subq.w #4,d7
  417. bra.s clear_hostage_data_in
  418. clear_second_sprite
  419. move.l #scanner2+33*4,a0
  420. clear_hostage_data_in
  421. lsl #2,d7
  422. move.w #$fff0,d6
  423. rol d7,d6
  424. and.w d6,(a0)
  425. and.w d6,4(a0)
  426. and.w d6,8(a0)
  427. and.w d6,12(a0)
  428. and.w d6,16(a0)
  429. rts
  430. *****************************************
  431. ****** DISPLAY KEY CHAR *******
  432. *****************************************
  433. Display_Key_Char
  434. *send num in d7
  435. cmp.w #7,d7
  436. ble.s key_on_scanner
  437. rts
  438. key_on_scanner
  439. cmp.w #4,d7
  440. blt.s key_second_sprite
  441. move.l #scanner1+39*4,a0
  442. subq.w #4,d7
  443. bra.s copy_key_data_in
  444. key_second_sprite
  445. move.l #scanner2+39*4,a0
  446. copy_key_data_in
  447. lsl #2,d7
  448. move.w #$4,d6
  449. lsl d7,d6
  450. or.w d6,(a0)
  451. or.w d6,8(a0)
  452. or.w d6,12(a0)
  453. or.w d6,20(a0)
  454. move.w #$a,d6
  455. lsl d7,d6
  456. or.w d6,4(a0)
  457. move.w #$c,d6
  458. lsl d7,d6
  459. or.w d6,16(a0)
  460. or.w d6,24(a0)
  461. rts
  462. *****************************************
  463. ****** REMOVE KEY CHAR *******
  464. *****************************************
  465. Remove_Key_Char
  466. *send num in d7
  467. cmp.w #7,d7
  468. ble.s clear_key_on_scanner
  469. rts
  470. clear_key_on_scanner
  471. cmp.w #4,d7
  472. blt.s key_clear_second_sprite
  473. move.l #scanner1+39*4,a0
  474. subq.w #4,d7
  475. bra.s clear_key_data_in
  476. key_clear_second_sprite
  477. move.l #scanner2+39*4,a0
  478. clear_key_data_in
  479. lsl #2,d7
  480. move.w #$fff0,d6
  481. rol d7,d6
  482. and.w d6,(a0)
  483. and.w d6,4(a0)
  484. and.w d6,8(a0)
  485. and.w d6,12(a0)
  486. and.w d6,16(a0)
  487. and.w d6,20(a0)
  488. and.w d6,24(a0)
  489. rts
  490. generator_x dc.w 0
  491. generator_y dc.w 0
  492. generator_map_pos dc.l 0