key_handler.s 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. ************************************************
  2. **** READ KEYS ****
  3. ************************************************
  4. Read_Keys
  5. * I really dont care about this code
  6. bsr get_pressed_key
  7. cmp.b #'1',d0
  8. blt.s not_interested
  9. cmp.b #'3',d0
  10. bgt.s not_interested
  11. bsr Change_Edit_Mode
  12. rts
  13. not_interested
  14. cmp.b #'Q',d0
  15. beq quit_editor
  16. cmp.b #' ',d0
  17. beq pick_under_cursor
  18. cmp.b #'f',d0
  19. beq toggle_fullscreen
  20. cmp.b #'-',d0
  21. beq decrease_mouse_sense
  22. cmp.b #'=',d0
  23. beq increase_mouse_sense
  24. cmp.w #1,edit_mode
  25. bne no_key_pressed
  26. cmp.b #'C',d0
  27. beq select_copy_mode
  28. cmp.b #'P',d0
  29. beq select_paste_mode
  30. cmp.b #'X',d0
  31. beq select_cut_mode
  32. cmp.b #'F',d0
  33. beq select_fill_mode
  34. cmp.b #'s',d0
  35. beq select_show_all
  36. cmp.b #'j',d0
  37. beq flip_map_pages
  38. cmp.b #'p',d0
  39. beq pick_delete_block
  40. cmp.b #'g',d0
  41. beq change_grid_mode
  42. cmp.b #'u',d0
  43. beq select_undo
  44. cmp.b #'z',d0
  45. beq scroll_block_line_up
  46. cmp.b #'a',d0
  47. beq scroll_block_line_down
  48. cmp.b #CURSOR_UP,d0
  49. beq move_cursor_up
  50. cmp.b #CURSOR_DOWN,d0
  51. beq move_cursor_down
  52. cmp.b #CURSOR_LEFT,d0
  53. beq move_cursor_left
  54. cmp.b #CURSOR_RIGHT,d0
  55. beq move_cursor_right
  56. cmp.b #F1_KEY,d0
  57. beq select_key_buffer
  58. cmp.b #F2_KEY,d0
  59. beq select_key_buffer
  60. cmp.b #F3_KEY,d0
  61. beq select_key_buffer
  62. cmp.b #F4_KEY,d0
  63. beq select_key_buffer
  64. cmp.b #F5_KEY,d0
  65. beq select_key_buffer
  66. cmp.b #F6_KEY,d0
  67. beq select_key_buffer
  68. cmp.b #F7_KEY,d0
  69. beq select_key_buffer
  70. cmp.b #F8_KEY,d0
  71. beq select_key_buffer
  72. not_num_key
  73. cmp.b #',',d0 ;use < and > to select pages
  74. beq.s down_page
  75. cmp.b #'.',d0
  76. bne.s no_key_pressed ;end of chain
  77. cmp.w #3,current_page ;up page
  78. beq.s no_key_pressed
  79. addq.w #1,current_page
  80. bra.s key_change_page
  81. down_page
  82. tst.w current_page
  83. beq.s no_key_pressed
  84. subq.w #1,current_page
  85. key_change_page
  86. move.w current_page,d0
  87. move.l #picture_pages,a0
  88. ext.l d0
  89. asl.w #2,d0
  90. move.l (a0,d0.w),page_pointer
  91. bsr display_blocks_on_screen
  92. no_key_pressed
  93. rts
  94. select_paste_mode
  95. jsr paste_block
  96. rts
  97. select_cut_mode
  98. jsr cut_block
  99. rts
  100. select_copy_mode
  101. jsr copy_block
  102. rts
  103. select_fill_mode
  104. jsr fill_map
  105. rts
  106. select_show_all
  107. jsr show_whole_map
  108. rts
  109. decrease_mouse_sense
  110. subq.w #5,sensativity
  111. cmp.w #10,sensativity
  112. bge.s dont_dec_mouse
  113. move.w #10,sensativity
  114. dont_dec_mouse
  115. rts
  116. increase_mouse_sense
  117. addq.w #5,sensativity
  118. cmp.w #100,sensativity
  119. ble.s dont_inc_mouse
  120. move.w #100,sensativity
  121. dont_inc_mouse
  122. rts
  123. select_undo
  124. tst.w undo_on
  125. beq.s dont_call_undo
  126. jsr undo
  127. dont_call_undo
  128. rts
  129. pick_under_cursor
  130. tst.w edit_data_flag
  131. beq.s are_we_in_map_mode
  132. tst.w last_alien_displayed
  133. beq.s cannot_pick_alien
  134. clr.w d3
  135. jsr Display_Alien_String
  136. move.w #1,d3
  137. move.w last_alien_displayed,current_alien_number
  138. jsr Display_Alien_String
  139. cannot_pick_alien
  140. rts
  141. are_we_in_map_mode
  142. cmp.w #1,edit_mode
  143. bne.s not_in_em_mode
  144. bsr Remove_Selected_Block_Num
  145. move.l current_map_ptr,a1
  146. move.l map_mem(a1),a0
  147. move.w map_datasize(a1),d5
  148. bsr Convert_Mouse_And_Store
  149. divu map_block_size(a1),d0
  150. divu map_block_size(a1),d1
  151. add.w map_x_position,d0
  152. add.w map_y_position,d1
  153. mulu map_xsize(a1),d1
  154. add.w d0,d1
  155. asl.w d5,d1
  156. moveq #0,d0
  157. tst d5
  158. beq.s extract_byte_map
  159. move.w (a0,d1),d0
  160. bra.s update_block_details
  161. extract_byte_map
  162. move.b (a0,d1),d0
  163. update_block_details
  164. move.w d0,current_block
  165. bsr convert_block_number_to_memory
  166. bsr position_box_sprite2
  167. bsr Display_Selected_Block_Num
  168. not_in_em_mode
  169. rts
  170. toggle_fullscreen
  171. tst.w edit_data_flag ;this is so naff - why did I have a separate flag???
  172. bne.s change_full_mode
  173. tst.w edit_mode
  174. bne.s change_full_mode
  175. rts
  176. change_full_mode
  177. bsr sync ;ensure not near bottom
  178. tst.w fullscreen_mode
  179. beq set_fullscreen
  180. clr.w fullscreen_mode
  181. move.w #BUTTON_WINDOW_OFFSET,max_screen_pos
  182. move.w #BUTTON_WINDOW_OFFSET,screen_custom_y
  183. tst.w edit_data_flag
  184. beq.s not_in_edit_mode_ok
  185. move.w #BUTTON_WINDOW_OFFSET,map_screen_custom_y
  186. move.w #BUTTON_WINDOW_OFFSET,max_map_screen_pos
  187. bra.s replace_cop
  188. not_in_edit_mode_ok
  189. move.w #BUTTON_WINDOW_OFFSET-32,map_screen_custom_y
  190. move.w #BUTTON_WINDOW_OFFSET-32,max_map_screen_pos
  191. replace_cop
  192. move.w #14-1,d2
  193. move.l #full_screen,a0
  194. remove_end_cop
  195. move.l #$01fe0000,(a0)+
  196. dbra d2,remove_end_cop
  197. cmp.w #1,edit_mode
  198. bne.s remove_not_in_map_mode
  199. move.w #1,show_box2
  200. bsr position_box_sprite2
  201. bsr display_map_on_screen
  202. bsr display_blocks_on_screen
  203. remove_not_in_map_mode
  204. tst edit_data_flag
  205. beq.s remove_not_in_edit_data_mode
  206. bsr display_map_on_screen
  207. jsr display_alien_numbers
  208. remove_not_in_edit_data_mode
  209. rts
  210. set_fullscreen
  211. move.w #1,fullscreen_mode
  212. move.w #255,max_screen_pos
  213. move.w #255,screen_custom_y
  214. move.w #255,map_screen_custom_y
  215. move.w #256,max_map_screen_pos
  216. move.l #full_screen,a0
  217. move.l #end_copper,a1
  218. move.w #14-1,d2
  219. copy_end_cop
  220. move.l (a1)+,(a0)+
  221. dbra d2,copy_end_cop
  222. cmp.w #2,edit_mode
  223. bne.s not_in_graphics_mode
  224. move.l page_pointer,a0
  225. tst.w screen_y_pos(a0)
  226. beq.s not_in_graphics_mode
  227. clr.w screen_y_pos(a0)
  228. bsr display_graphic_page
  229. not_in_graphics_mode
  230. cmp.w #1,edit_mode
  231. bne.s not_in_map_mode
  232. clr.w show_box2
  233. bsr position_box_sprite2
  234. bsr display_map_on_screen
  235. not_in_map_mode
  236. tst.w edit_data_flag
  237. beq.s not_in_edit_data_mode
  238. bsr display_map_on_screen
  239. not_in_edit_data_mode
  240. rts
  241. quit_editor
  242. bsr kill_system
  243. rts
  244. change_grid_mode
  245. bchg.b #0,grid_on+1
  246. bsr display_blocks_on_screen
  247. rts
  248. flip_map_pages
  249. move.l current_map_ptr,a0
  250. move.w map_y_position,Map_Y_Val(a0)
  251. move.w map_x_position,Map_X_Val(a0)
  252. cmp.l #map_details,current_map_ptr
  253. beq.s Flip_To_Second_Map
  254. move.l #map_details,current_map_ptr
  255. clr.w current_map
  256. bra.s Update_For_New_Map
  257. Flip_To_Second_Map
  258. move.l #map_details2,current_map_ptr
  259. move.w #1,current_map
  260. Update_For_New_Map
  261. move.l current_map_ptr,a0
  262. move.w Map_Y_Val(a0),map_y_position
  263. move.w Map_X_Val(a0),map_x_position
  264. bsr Calculate_Blocks_In_One_Page
  265. bsr display_map_on_screen
  266. bsr Display_X_Y
  267. rts
  268. Change_Edit_Mode
  269. *determine mode in
  270. clr.w d1
  271. tst edit_mode
  272. beq.s not_in_map_or_graph
  273. cmp.w #2,edit_mode
  274. beq.s go_to_new_mode
  275. moveq #1,d1
  276. bra.s go_to_new_mode
  277. not_in_map_or_graph
  278. tst edit_data_flag
  279. beq not_in_any_mode
  280. move.w #2,d1
  281. go_to_new_mode
  282. *determine mode to change to
  283. ext.w d0
  284. sub.w #'1',d0
  285. cmp.w d0,d1
  286. beq.s not_in_any_mode ;dont bother to change
  287. tst d0
  288. beq.s go_to_graphic_mode
  289. cmp.w #1,d0
  290. beq.s go_to_edit_map_mode
  291. *go to data
  292. cmp.w #1,d1
  293. beq.s go_from_map2
  294. *go from graphic
  295. bsr remove_graphic_buttons
  296. bra.s go_to_data
  297. go_from_map2
  298. bsr remove_edit_buttons
  299. go_to_data
  300. jsr delete_buttons
  301. jsr draw_buttons
  302. jsr bring_up_data_function
  303. rts
  304. go_to_graphic_mode
  305. cmp.w #1,d1
  306. beq.s go_from_map
  307. *go from edit_data
  308. jsr exit_data_function
  309. bra.s bring_up_gr
  310. go_from_map
  311. bsr remove_edit_buttons
  312. bring_up_gr
  313. jsr delete_buttons
  314. jsr draw_buttons
  315. bsr display_graphic_buttons
  316. rts
  317. go_to_edit_map_mode
  318. tst d1
  319. beq.s go_from_graph
  320. *go from data
  321. jsr exit_data_function
  322. bra.s bring_up_map
  323. go_from_graph
  324. bsr remove_graphic_buttons
  325. bring_up_map
  326. jsr delete_buttons
  327. jsr draw_buttons
  328. bsr display_edit_buttons
  329. rts
  330. not_in_any_mode
  331. rts
  332. pick_delete_block
  333. move.l current_block_mem,delete_block_mem
  334. move.w current_block,d1
  335. move.w d1,delete_block
  336. move.l #Project_Del_Block,d0
  337. jsr Set_Project_Value
  338. rts
  339. delete_block
  340. dc.w 0
  341. delete_block_mem
  342. dc.l 0
  343. scroll_block_line_up
  344. bsr change_blocks_position_up
  345. rts
  346. scroll_block_line_down
  347. bsr change_blocks_position_down
  348. rts
  349. select_key_buffer
  350. add.w #16,d0
  351. neg.w d0
  352. move.w d0,-(sp)
  353. jsr remove_current_buff_name
  354. move.w (sp)+,d0
  355. move.w d0,current_buffer
  356. jsr calculate_buffer_mem
  357. jsr display_current_buff_name
  358. rts
  359. move_cursor_up
  360. bsr Remove_Selected_Block_Num
  361. move.l #main_screen_struct,a0
  362. moveq #0,d0
  363. move.w screen_x_size(a0),d0
  364. move.l current_map_ptr,a0
  365. divu map_block_size(a0),d0
  366. sub.w d0,current_block
  367. bsr convert_block_number_to_memory
  368. bsr position_box_sprite2
  369. bsr Display_Selected_Block_Num
  370. rts
  371. move_cursor_down
  372. bsr Remove_Selected_Block_Num
  373. move.l #main_screen_struct,a0
  374. moveq #0,d0
  375. move.w screen_x_size(a0),d0
  376. move.l current_map_ptr,a0
  377. divu map_block_size(a0),d0
  378. add.w d0,current_block
  379. bsr convert_block_number_to_memory
  380. bsr position_box_sprite2
  381. bsr Display_Selected_Block_Num
  382. rts
  383. move_cursor_left
  384. bsr Remove_Selected_Block_Num
  385. subq.w #1,current_block
  386. bsr convert_block_number_to_memory
  387. bsr position_box_sprite2
  388. bsr Display_Selected_Block_Num
  389. rts
  390. move_cursor_right
  391. bsr Remove_Selected_Block_Num
  392. addq.w #1,current_block
  393. bsr convert_block_number_to_memory
  394. bsr position_box_sprite2
  395. bsr Display_Selected_Block_Num
  396. rts
  397. fullscreen_mode dc.w 0
  398. max_screen_pos dc.w BUTTON_WINDOW_OFFSET
  399. max_map_screen_pos dc.w BUTTON_WINDOW_OFFSET-32