cursor_routines.s 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  1. *****************************************************************
  2. * MODULE TITLE :cursor_routines *
  3. * *
  4. * DESCRIPTION :software to move cursor and display *
  5. * additional information at the cursor *
  6. * when neccessary *
  7. * *
  8. * NAME DATE *
  9. * *
  10. * LIST OF ROUTINES :position_cursor *
  11. * position_note_info *
  12. * attach_pointer *
  13. * attach_note *
  14. * attach_graphics *
  15. * detach_pointer *
  16. * SetHiResSprite *
  17. * SetLoResSprite *
  18. *****************************************************************
  19. ***********************************************
  20. ***** SET HI RES SPRITE *****
  21. ***********************************************
  22. SetHiResSprite
  23. move #HI_RES_SPRITES,d0
  24. bsr SetCon3InCopperList
  25. rts
  26. ***********************************************
  27. ***** SET LO RES SPRITE *****
  28. ***********************************************
  29. SetLoResSprite
  30. move #LO_RES_SPRITES,d0
  31. bsr SetCon3InCopperList
  32. rts
  33. ***********************************************
  34. ***** SET CON3 IN COPPER LIST *****
  35. ***********************************************
  36. SetCon3InCopperList
  37. *Not very good code practice, but beats having a label for each
  38. *occurance in the copperl list and setting one by one!
  39. *D0 contains LO/HI res bit information to or into BPLCON3 occurances
  40. move.l #Copperl,a0
  41. CheckForCon3
  42. cmp.w #BPLCON3,(a0)
  43. bne.s NotCon3
  44. or.w d0,2(a0) ;Set sprite res
  45. NotCon3
  46. addq.w #4,a0
  47. cmp.l #end_copper,a0
  48. blt.s CheckForCon3
  49. rts
  50. ***********************************************
  51. ***** COMPENSATE FOR RES *****
  52. ***********************************************
  53. CompensateForRes
  54. ;assumes d0 is mouse x position
  55. btst #INTB_HIRES,screen_mode
  56. beq.s DontCompensate
  57. lsr.w d0
  58. DontCompensate
  59. rts
  60. **********************************************
  61. ***** POSITION CURSOR *****
  62. ***********************************************
  63. position_cursor
  64. move.w mousex_inc,d0
  65. add.w d0,mouse_x
  66. btst #INTB_HIRES,screen_mode ;Ok not a great way to do it!!!
  67. beq.s Check320Bounds
  68. cmp.w #639,mouse_x
  69. ble.s in_rangex
  70. move.w #639,mouse_x
  71. bra.s in_rangex
  72. Check320Bounds
  73. cmp.w #319,mouse_x
  74. ble.s in_rangex
  75. move.w #319,mouse_x
  76. in_rangex
  77. cmp.w #0,mouse_x
  78. bge.s still_range_x
  79. move.w #0,mouse_x
  80. still_range_x
  81. move.w mousey_inc,d0
  82. add.w d0,mouse_y
  83. cmp.w #256,mouse_y
  84. ble.s in_range_y
  85. move.w #256,mouse_y
  86. in_range_y
  87. cmp.w #0,mouse_y
  88. bge.s still_range_y
  89. move.w #0,mouse_y
  90. still_range_y
  91. cmp.b #0,pointer_state
  92. beq.s normal_state
  93. move.l #wait_pointer,a0
  94. move.w #27,d7
  95. bra.s do_other_mouse_stuff
  96. normal_state
  97. move.l #mouse_pointer,a0
  98. move.w #16,d7
  99. do_other_mouse_stuff
  100. move.w mouse_x,d0
  101. bsr CompensateForRes
  102. add.w #$81-1,d0 ;tricky positioning
  103. move.b #0,3(A0)
  104. asr.w #1,d0
  105. bcc.s no_bit_set
  106. bset #0,3(a0)
  107. no_bit_set
  108. move.b d0,1(a0)
  109. move.w mouse_y,d0
  110. add.w #$2c,d0
  111. btst #8,d0
  112. beq.s not_vert_set
  113. bset #2,3(a0)
  114. not_vert_set
  115. move.b d0,(a0)
  116. add.w d7,d0
  117. btst #8,d0
  118. beq.s not_vstop_set
  119. bset #1,3(a0)
  120. not_vstop_set
  121. move.b d0,2(a0)
  122. cmp.b #0,pointer_state
  123. beq.s normal_pointer
  124. move.l #wait_pointer,d0
  125. bra.s stuff_spr_data
  126. normal_pointer
  127. move.l #mouse_pointer,d0
  128. stuff_spr_data
  129. move.w d0,sprite0l
  130. swap d0
  131. move.w d0,sprite0h
  132. rts
  133. ***********************************************
  134. ***** ATTACH POINTER *****
  135. ***********************************************
  136. attach_pointer
  137. *routine for anyone to use
  138. **send sprite y size in d0
  139. **send sprite graphics in a0
  140. move.w d0,attach_pointer_size
  141. move.l #pointer_attach_bits+4,a2
  142. subq.w #1,d0
  143. fill_mouse_pointer
  144. move.w (a0)+,(a2)+
  145. move.w (a0)+,(a2)+
  146. dbra d2,fill_mouse_pointer
  147. move.l #$0,(a2)
  148. move.b #1,attach_information
  149. rts
  150. ***********************************************
  151. ***** ATTACH GRAPHICS *****
  152. ***********************************************
  153. attach_graphics
  154. move.w attach_pointer_size,d2
  155. move.l #pointer_attach_bits,a0
  156. move.l mouse_pointer,(a0)
  157. add.b #17,(a0) ;add to x
  158. bcc.s no_set_ex
  159. bset.b #2,3(a0)
  160. no_set_ex
  161. add.w #1,d2
  162. add.b d2,2(a0)
  163. bcc.s no_vstop_ex
  164. bset.b #1,3(a0)
  165. no_vstop_ex
  166. rts
  167. attach_pointer_size
  168. dc.w 0
  169. attach_information
  170. dc.b 0
  171. EVEN
  172. pointer_state
  173. dc.b 0
  174. EVEN
  175. ********************************
  176. *** POSITION BOX SPRITE ****
  177. ********************************
  178. position_box_sprite
  179. move.w mouse_x,d0
  180. move.w mouse_y,d1
  181. cmp.w #1,show_box
  182. bne.s blank_out_sprite
  183. cmp.w max_screen_pos,d1
  184. blt.s display_box_sprite
  185. blank_out_sprite
  186. move.l #blank,d0
  187. move.w d0,sprite2l
  188. swap d0
  189. move.w d0,sprite2h
  190. move.l #blank,d0
  191. move.w d0,sprite3l
  192. swap d0
  193. move.w d0,sprite3h
  194. rts
  195. display_box_sprite
  196. move.l current_map_ptr,a0
  197. cmp.w #8,map_block_size(a0)
  198. beq.s position_sprite8x8
  199. cmp.w #16,map_block_size(a0)
  200. beq.s position_sprite16x16
  201. cmp.w #32,map_block_size(a0)
  202. beq position_sprite32x32
  203. position_sprite8x8
  204. and.w #$fff8,d0
  205. and.w #$fff8,d1
  206. bsr CompensateForRes
  207. move.w #8,d2
  208. move.l #sprite8x8,a0
  209. bsr position_any_sprite
  210. move.l a0,d0
  211. move.w d0,sprite2l
  212. swap d0
  213. move.w d0,sprite2h
  214. move.l #blank,d0
  215. move.w d0,sprite3l
  216. swap d0
  217. move.w d0,sprite3h
  218. rts
  219. position_sprite16x16
  220. and.w #$fff0,d0
  221. and.w #$fff0,d1
  222. bsr CompensateForRes
  223. move.w #16,d2
  224. move.l #sprite16x16,a0
  225. bsr position_any_sprite
  226. move.l a0,d0
  227. move.w d0,sprite2l
  228. swap d0
  229. move.w d0,sprite2h
  230. move.l #blank,d0
  231. move.w d0,sprite3l
  232. swap d0
  233. move.w d0,sprite3h
  234. rts
  235. position_sprite32x32
  236. and.w #$ffe0,d0
  237. and.w #$ffe0,d1
  238. bsr CompensateForRes
  239. move.w #32,d2
  240. move.l #sprite32x321,a0
  241. bsr position_any_sprite
  242. move.l a0,d0
  243. move.w d0,sprite2l
  244. swap d0
  245. move.w d0,sprite2h
  246. move.w mouse_x,d0
  247. move.w mouse_y,d1
  248. and.w #$ffe0,d0
  249. and.w #$ffe0,d1
  250. bsr CompensateForRes
  251. btst #INTB_HIRES,screen_mode
  252. beq.s AddCurLoRes
  253. add.w #8,d0
  254. bra.s Position32Cur
  255. AddCurLoRes
  256. add.w #16,d0
  257. Position32Cur
  258. move.w #32,d2
  259. move.l #sprite32x322,a0
  260. bsr position_any_sprite
  261. move.l a0,d0
  262. move.w d0,sprite3l
  263. swap d0
  264. move.w d0,sprite3h
  265. rts
  266. show_box
  267. dc.w 1
  268. show_box2
  269. dc.w 1
  270. ********************************
  271. *** POSITION BOX SPRITE2 ****
  272. ********************************
  273. position_box_sprite2
  274. cmp.w #1,show_box2
  275. beq.s display_box_sprite2
  276. blank_box2
  277. move.l #blank,d0
  278. move.w d0,sprite6l
  279. swap d0
  280. move.w d0,sprite6h
  281. move.l #blank,d0
  282. move.w d0,sprite7l
  283. swap d0
  284. move.w d0,sprite7h
  285. rts
  286. display_box_sprite2
  287. move.w current_block,d0
  288. move.w current_page,d1
  289. mulu num_blocks_in_page,d1
  290. sub.w d1,d0
  291. move.l current_map_ptr,a0
  292. move.l #main_screen_struct,a1
  293. move.w screen_x_size(a1),d1
  294. divu map_block_size(a0),d1 ;divide factor
  295. divu d1,d0
  296. move.w d0,d1 ;y
  297. swap d0 ;x
  298. mulu map_block_size(a0),d1 ;y
  299. mulu map_block_size(a0),d0 ;x
  300. add.w #BUTTON_WINDOW_OFFSET-32,d1
  301. move.l page_pointer,a1
  302. move.w screen_y_pos(a1),d2
  303. add.w #BUTTON_WINDOW_OFFSET-32,d2
  304. cmp.w d2,d1
  305. blt blank_box2
  306. add.w #32,d2
  307. sub.w map_block_size(a0),d2
  308. cmp.w d2,d1
  309. bgt blank_box2
  310. sub.w screen_y_pos(a1),d1
  311. move.w d0,d6
  312. move.w d1,d7
  313. cmp.w #8,map_block_size(a0)
  314. beq.s position_sprite8x82
  315. cmp.w #16,map_block_size(a0)
  316. beq.s position_sprite16x162
  317. cmp.w #32,map_block_size(a0)
  318. beq position_sprite32x322
  319. position_sprite8x82
  320. and.w #$fff8,d0
  321. and.w #$fff8,d1
  322. bsr CompensateForRes
  323. move.w #8,d2
  324. move.l #sprite8x82,a0
  325. bsr position_any_sprite
  326. move.l a0,d0
  327. move.w d0,sprite6l
  328. swap d0
  329. move.w d0,sprite6h
  330. move.l #blank,d0
  331. move.w d0,sprite7l
  332. swap d0
  333. move.w d0,sprite7h
  334. rts
  335. position_sprite16x162
  336. and.w #$fff0,d0
  337. and.w #$fff0,d1
  338. bsr CompensateForRes
  339. move.w #16,d2
  340. move.l #sprite16x162,a0
  341. bsr position_any_sprite
  342. move.l a0,d0
  343. move.w d0,sprite6l
  344. swap d0
  345. move.w d0,sprite6h
  346. move.l #blank,d0
  347. move.w d0,sprite7l
  348. swap d0
  349. move.w d0,sprite7h
  350. rts
  351. position_sprite32x322
  352. and.w #$ffe0,d0
  353. and.w #$ffe0,d1
  354. bsr CompensateForRes
  355. move.w #32,d2
  356. move.l #sprite32x3212,a0
  357. bsr position_any_sprite
  358. move.l a0,d0
  359. move.w d0,sprite6l
  360. swap d0
  361. move.w d0,sprite6h
  362. move.w d6,d0
  363. move.w d7,d1
  364. bsr CompensateForRes
  365. btst #INTB_HIRES,screen_mode
  366. beq.s AddBoxLoRes
  367. add.w #8,d0
  368. bra.s Position32Box
  369. AddBoxLoRes
  370. add.w #16,d0
  371. Position32Box
  372. move.w #32,d2
  373. move.l #sprite32x3222,a0
  374. bsr position_any_sprite
  375. move.l a0,d0
  376. move.w d0,sprite7l
  377. swap d0
  378. move.w d0,sprite7h
  379. rts
  380. position_any_sprite
  381. *send in data in a0
  382. *x in d0
  383. *y in d1
  384. *height in d2
  385. gendo_other_mouse_stuff
  386. add.w #$81-1,d0 ;tricky positioning
  387. move.b #0,3(A0)
  388. asr.w #1,d0
  389. bcc.s genno_bit_set
  390. bset #0,3(a0)
  391. genno_bit_set
  392. move.b d0,1(a0)
  393. add.w #$2c,d1
  394. btst #8,d1
  395. beq.s gennot_vert_set
  396. bset #2,3(a0)
  397. gennot_vert_set
  398. move.b d1,(a0)
  399. add.w d2,d1
  400. btst #8,d1
  401. beq.s gennot_vstop_set
  402. bset #1,3(a0)
  403. gennot_vstop_set
  404. move.b d1,2(a0)
  405. rts
  406. ******************************************
  407. **** DISPLAY HELPFUL CURSOR *****
  408. ******************************************
  409. display_helpful_cursor
  410. * cmp.w #BUTTON_WINDOW_OFFSET,mouse_y
  411. * bge.s blank_out_help
  412. cmp.w #0,sprite_to_attach
  413. bne.s attach_help
  414. blank_out_help
  415. move.l #blank,d0
  416. move.w d0,sprite4l
  417. swap d0
  418. move.w d0,sprite4h
  419. bra.s quit_display_helpful
  420. attach_help
  421. cmp.w #WITH,sprite_to_attach
  422. bne.s check_next
  423. move.l #sprwith,a0
  424. bra.s position_it
  425. check_next
  426. cmp.w #TO,sprite_to_attach
  427. bne.s default_last
  428. move.l #sprto,a0
  429. bra.s position_it
  430. default_last
  431. move.l #sprpick,a0
  432. position_it
  433. move.w mouse_x,d0
  434. move.w mouse_y,d1
  435. bsr CompensateForRes
  436. add.w #18,d1
  437. move.w #10,d2
  438. bsr position_any_sprite
  439. move.l a0,d0
  440. move.w d0,sprite4l
  441. swap d0
  442. move.w d0,sprite4h
  443. quit_display_helpful
  444. rts
  445. **********************************
  446. *** BLANK SPRITES ****
  447. **********************************
  448. blank_sprites
  449. move.l #blank_sprite,d0
  450. move.w d0,sprite1l
  451. move.w d0,sprite2l
  452. move.w d0,sprite3l
  453. move.w d0,sprite4l
  454. move.w d0,sprite5l
  455. move.w d0,sprite6l
  456. move.w d0,sprite7l
  457. swap d0
  458. move.w d0,sprite1h
  459. move.w d0,sprite2h
  460. move.w d0,sprite3h
  461. move.w d0,sprite4h
  462. move.w d0,sprite5h
  463. move.w d0,sprite6h
  464. move.w d0,sprite7h
  465. rts