show_whole_map.s 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. *TREV:
  2. *When re-coding the only thing you need to be aware of is the
  3. *routine Select_Map_Area, which allows the user to select a
  4. *position on the zoomed-out map to jump to.
  5. ******************************************
  6. ***** SHOW WHOLE MAP *****
  7. ******************************************
  8. show_whole_map
  9. move.l #show_map_window,a0
  10. jsr create_window
  11. move.l #show_map_buttons,a0
  12. jsr display_button_list
  13. bsr display_whole_map
  14. rts
  15. ******************************************
  16. ***** REMOVE SHOW MAP WINDOW *****
  17. ******************************************
  18. remove_show_map_window
  19. move.l #show_map_buttons,a0
  20. jsr remove_button_list
  21. move.l #show_map_window,a0
  22. jsr destroy_window
  23. rts
  24. MAP_SHOW_SIZE EQU 128
  25. WHOLE_ACR EQU 5 ;accuracy
  26. ACCURACY EQU 32
  27. ******************************************
  28. ***** DISPLAY WHOLE MAP *****
  29. ******************************************
  30. display_whole_map
  31. btst #14,dmaconr(a6)
  32. bne.s display_whole_map
  33. *work out map ratio
  34. move.l current_map_ptr,a1
  35. moveq #0,d0
  36. moveq #0,d1
  37. move.w map_xsize(a1),d0
  38. move.w map_ysize(a1),d1
  39. cmp.w d0,d1
  40. ble.s y_less_than_x
  41. x_less_than_y
  42. divu d0,d1
  43. move.w d1,d0
  44. moveq #1,d1 ;ratio divide value
  45. bra.s calc_ratio
  46. y_less_than_x
  47. divu d1,d0
  48. move.w d0,d1
  49. moveq #1,d0
  50. calc_ratio
  51. move.w #MAP_SHOW_SIZE,d2
  52. ext.l d2
  53. divu d0,d2
  54. move.w d2,x_show_size ;x size
  55. move.w #MAP_SHOW_SIZE,d2
  56. ext.l d2
  57. divu d1,d2
  58. move.w d2,y_show_size ;y size
  59. moveq #0,d2 ;increment values
  60. moveq #0,d3
  61. moveq #16,d5 ;y
  62. move.l #show_map_window,a0
  63. move.l window_start(a0),a0 ;mem start pos
  64. move.w map_xsize(a1),d0
  65. asl.w #WHOLE_ACR,d0
  66. ext.l d0
  67. divu x_show_size,d0
  68. move.w map_ysize(a1),d1
  69. asl.w #WHOLE_ACR,d1
  70. ext.l d1
  71. divu y_show_size,d1
  72. add.w #16,x_show_size
  73. add.w #16,y_show_size
  74. move.l map_mem(a1),a2
  75. move.l a2,a4 ;store for later
  76. do_pixel_y
  77. move.w #16,d4
  78. moveq #0,d2
  79. moveq #0,d7
  80. do_pixel_x
  81. tst map_datasize(a1)
  82. bne.s word_map
  83. move.b (a2),d7
  84. bra.s draw_coloured_pixel
  85. word_map
  86. move.w (a2),d7
  87. draw_coloured_pixel
  88. *need to find what colour to draw pixel
  89. bsr Find_Pixel_Colour
  90. bsr draw_pixel
  91. addq.w #1,d4
  92. cmp.w x_show_size,d4
  93. bge.s done_x_line
  94. *calculate block step for x
  95. add.w d0,d2
  96. move.w d2,d7
  97. andi.w #ACCURACY-1,d2
  98. asr.w #WHOLE_ACR,d7
  99. tst d7
  100. beq.s do_pixel_x
  101. move.w map_datasize(a1),d6
  102. ext.l d7
  103. asl.w d6,d7 ;number of bytes to increase
  104. add.l d7,a2
  105. bra.s do_pixel_x
  106. done_x_line
  107. addq.w #1,d5
  108. cmp.w y_show_size,d5
  109. bge.s done_y_line
  110. *calculate block step for y
  111. add.w d1,d3
  112. move.w d3,d7
  113. andi.w #ACCURACY-1,d3
  114. asr.w #WHOLE_ACR,d7
  115. movem.l d5,-(sp)
  116. tst d7
  117. beq.s dont_increase_y_block
  118. move.w map_xsize(a1),d6
  119. move.w map_datasize(a1),d5
  120. asl.w d5,d6 ;size of one line
  121. mulu d7,d6 ;number of lines to add
  122. add.l d6,a4
  123. dont_increase_y_block
  124. move.l a4,a2
  125. movem.l (sp)+,d5
  126. bra do_pixel_y
  127. done_y_line
  128. rts
  129. x_show_size dc.w 0
  130. y_show_size dc.w 0
  131. ******************************************
  132. ***** FIND PIXEL COLOUR *****
  133. ******************************************
  134. Find_Pixel_Colour
  135. *send block number in d7
  136. *map details in a1
  137. *returns colour in d7
  138. movem.l a0/d0-d2,-(sp)
  139. ext.l d7
  140. tst d7
  141. bne.s pix_blk_not_0
  142. moveq #0,d0
  143. move.w #0,d2
  144. bra.s dont_do_pix_calc
  145. pix_blk_not_0
  146. divu num_blocks_in_page,d7
  147. move.l d7,d2
  148. move.w d2,d0 ;page number
  149. asl #2,d0
  150. clr.w d2
  151. swap d2 ;block number
  152. dont_do_pix_calc
  153. move.l #picture_pages,a0
  154. move.l (a0,d0),a0 ;first page
  155. move.l screen_mem(a0),a0 ; page mem
  156. divu d1,d2 ;blocks in line / block number
  157. move.w d2,d1 ;number of lines down
  158. clr.w d2
  159. swap d2 ;position in line
  160. mulu map_block_size(a1),d1 ;lines down
  161. mulu #ScrPixelWidth/8,d1
  162. add.l d1,a0
  163. mulu map_block_size(a1),d2 ;in
  164. asr #3,d2 ;get to bytes
  165. add.l d2,a0 ;our block
  166. clr.w d7
  167. moveq #0,d0
  168. moveq #4-1,d1
  169. plane_loop_bit
  170. btst.b #0,(a0)
  171. beq.s dont_set_col_bit
  172. bset d0,d7
  173. dont_set_col_bit
  174. addq.w #1,d0
  175. add.l #(ScrPixelWidth/8)*ScrPixelHeight,a0
  176. dbra d1,plane_loop_bit
  177. movem.l (sp)+,a0/d0-d2
  178. rts
  179. colour_info
  180. ds.w 16
  181. ******************************************
  182. ***** DRAW PIXEL *****
  183. ******************************************
  184. draw_pixel
  185. *send mem in a0, x and y in d0 and d1
  186. *colour in d7
  187. movem.l a0/d4-d5/d1,-(sp)
  188. mulu #RES_BYTES,d5
  189. add.l d5,a0
  190. move.w d4,d5
  191. lsr.w #3,d4 ; get bytes
  192. andi.b #%111,d5 ; pixel bits
  193. moveq #7,d1
  194. sub.b d5,d1
  195. ext.l d4
  196. add.l d4,a0
  197. move.w #4-1,d5
  198. moveq #0,d4
  199. set_pix_col
  200. btst.l d4,d7
  201. beq.s skip_pix_set
  202. bset.b d1,(a0)
  203. skip_pix_set
  204. addq.w #1,d4
  205. add.l #RES_BYTES*256,a0
  206. dbra d5,set_pix_col
  207. movem.l (sp)+,a0/d4-d5/d1
  208. rts
  209. *********************************************
  210. **** SELECT MAP AREA ****
  211. *********************************************
  212. Select_Map_Area
  213. *calculate box display size
  214. move.l current_map_ptr,a0
  215. move.w map_xsize(a0),d0
  216. move.l #MAP_SHOW_SIZE*128,d6
  217. divu d0,d6
  218. mulu num_x_blocks_in_page,d6
  219. asr.l #7,d6
  220. move.w map_ysize(a0),d0
  221. move.l #MAP_SHOW_SIZE*128,d7
  222. divu d0,d7
  223. mulu num_y_blocks_in_page,d7
  224. asr.l #7,d7
  225. *Define box boundarys
  226. move.l #show_map_window,a0
  227. move.w window_x(a0),d2
  228. move.w window_y(a0),d3
  229. add.w #32,d2
  230. add.w #32-8,d3
  231. move.w d2,d4
  232. move.w d3,d5
  233. add.w #MAP_SHOW_SIZE,d4
  234. add.w #MAP_SHOW_SIZE,d5
  235. sub.w d6,d4
  236. sub.w d7,d5
  237. clr.w Box_X
  238. display_area_box
  239. jsr Sync
  240. tst.w Box_X
  241. beq.s Dont_Delete_Map_Win_Box
  242. move.w Box_X,d0
  243. move.w Box_Y,d1
  244. bsr Eor_Draw_Win_Box
  245. Dont_Delete_Map_Win_Box
  246. move.l #main_screen_struct,a0
  247. move.w mouse_x,d0
  248. move.w mouse_y,d1
  249. cmp.w d2,d0
  250. bge.s x_min_ok
  251. move.w d2,d0
  252. bra.s test_box_y
  253. x_min_ok
  254. cmp.w d4,d0
  255. ble.s test_box_y
  256. move.w d4,d0
  257. test_box_y
  258. cmp.w d3,d1
  259. bge.s y_max_ok
  260. move.w d3,d1
  261. bra.s draw_win_box
  262. y_max_ok
  263. cmp.w d5,d1
  264. ble.s draw_win_box
  265. move.w d5,d1
  266. draw_win_box
  267. move.w d0,Box_X
  268. move.w d1,Box_Y
  269. bsr Eor_Draw_Win_Box
  270. btst.b #6,$bfe001
  271. bne display_area_box ;wait until release
  272. move.l #show_map_window,a0
  273. sub.w window_x(a0),d0
  274. sub #32,d0
  275. sub.w #16+8,d1
  276. move.l current_map_ptr,a0
  277. mulu map_xsize(a0),d0
  278. mulu map_ysize(a0),d1
  279. asr.l #7,d0 ;should be map pos
  280. asr.l #7,d1
  281. move.w d0,map_x_position
  282. move.w d1,map_y_position
  283. bsr Remove_Show_Map_Window
  284. jsr display_map_on_screen
  285. rts
  286. Eor_Draw_Win_Box
  287. movem.l d0-d3,-(sp)
  288. move.w d0,d2
  289. move.w d1,d3
  290. add.w d6,d2
  291. movem.l d0-d7,-(sp)
  292. jsr EOR_Draw_Line
  293. movem.l (sp)+,d0-d7
  294. sub.w d6,d2
  295. add.w d7,d3
  296. movem.l d0-d7,-(sp)
  297. jsr EOR_Draw_Line
  298. movem.l (sp)+,d0-d7
  299. add.w d7,d1
  300. add.w d6,d2
  301. movem.l d0-d7,-(sp)
  302. jsr EOR_Draw_Line
  303. movem.l (sp)+,d0-d7
  304. add.w d6,d0
  305. sub.w d7,d3
  306. movem.l d0-d7,-(sp)
  307. jsr EOR_Draw_Line
  308. movem.l (sp)+,d0-d7
  309. movem.l (sp)+,d0-d3
  310. rts
  311. selected_x_pos
  312. dc.w 0
  313. selected_y_pos
  314. dc.w 0
  315. show_map_buttons
  316. dc.l show_whole_ok_button,SelectMapArea
  317. dc.l -1
  318. show_map_window
  319. dc.w 128+32+32
  320. dc.w 128+32+32
  321. dc.w 80-16
  322. dc.w 0
  323. dc.l 0
  324. dc.l 0
  325. dc.b "WHOLE MAP",0
  326. even
  327. show_whole_Ok_Button
  328. dc.w 90-48
  329. dc.w 128+32-8
  330. dc.w WINDOW ;frame type
  331. dc.b CUSTOM_BUTTON ;standard
  332. dc.b NOT_DEPRESSED
  333. dc.b 0
  334. dc.b 0 ;not used
  335. dc.l ok_custom_button
  336. dc.l 0 ;not used
  337. dc.l remove_show_map_window
  338. dc.b 0
  339. even
  340. SelectMapArea
  341. dc.w 16
  342. dc.w 16
  343. dc.w WINDOW ;frame type
  344. dc.b CUSTOM_BUTTON ;standard
  345. dc.b NOT_DEPRESSED
  346. dc.b 0
  347. dc.b 0 ;not used
  348. dc.l MapSelectButton ;not used
  349. dc.l 0 ;not used
  350. dc.l Select_Map_Area
  351. dc.b 0
  352. EVEN