show_whole_map.s 7.2 KB

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