fill_routines.s 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. *********************************************
  2. ******* FILL BLOCK FUNCTION *******
  3. *********************************************
  4. fill_block_function
  5. bsr make_screen_backup
  6. bsr display_undo
  7. move.l #fill_stack,a3
  8. move.w #$ffff,(a3)+
  9. move.w #$ffff,(a3)+ ;put on terminator
  10. bsr convert_mouse_and_store
  11. move.l current_map_ptr,a1
  12. divu map_block_size(a1),d0
  13. divu map_block_size(a1),d1
  14. add.w map_x_position,d0 ;x in map
  15. add.w map_y_position,d1 ;y in map
  16. bsr get_map_position
  17. moveq #0,d6
  18. tst map_datasize(a1)
  19. beq.s we_have_byte
  20. move.w (a0),d6 ;block type to fill
  21. bra.s test_for_same_block
  22. we_have_byte
  23. move.b (a0),d6
  24. test_for_same_block
  25. cmp.w current_block,d6
  26. beq quit_fill ;dest block and fill block are the same
  27. get_going_on_fill
  28. move.w map_x_position,d2 ;min x bound
  29. move.w map_y_position,d3 ;min y bound
  30. move.l #main_screen_struct,a2
  31. moveq #0,d4
  32. move.w screen_x_size(a2),d4
  33. divu map_block_size(a1),d4
  34. add.w d2,d4 ;max x bound
  35. cmp.w map_xsize(a1),d4
  36. ble.s not_exceedingxmax
  37. move.w map_xsize(a1),d4
  38. not_exceedingxmax
  39. subq.w #1,d4
  40. moveq #0,d5
  41. move.w max_map_screen_pos,d5
  42. divu map_block_size(a1),d5
  43. add.w d3,d5 ;max y bound
  44. cmp.w map_ysize(a1),d5
  45. ble.s nob_cheese_cracker_jack
  46. move.w map_ysize(a1),d5
  47. nob_cheese_cracker_jack
  48. subq.w #1,d5
  49. loop_until_all_filled
  50. bsr determine_fill_locations
  51. move.w -(a3),d1
  52. move.w -(a3),d0
  53. cmp.w #$ffff,(a3)
  54. beq.s done_all_fill
  55. bsr get_map_position
  56. bra.s loop_until_all_filled
  57. done_all_fill
  58. bsr display_map_on_screen
  59. quit_fill
  60. rts
  61. *********************************************
  62. ******* DETERMINE FILL LOCATIONS *******
  63. *********************************************
  64. determine_fill_locations
  65. *uses all data from above routines
  66. bsr stuff_data ;fills current block
  67. ***to the left
  68. cmp.w d2,d0
  69. ble.s cant_check_left
  70. subq.w #1,d0
  71. bsr get_map_position
  72. bsr test_data
  73. cmp.w d7,d6
  74. bne.s cant_use_left
  75. bsr stuff_data
  76. move.w d0,(a3)+ ;store on stack
  77. move.w d1,(a3)+
  78. cant_use_left
  79. addq.w #1,d0
  80. cant_check_left
  81. *****check to the right
  82. cmp.w d4,d0
  83. bge.s cant_check_right
  84. addq.w #1,d0
  85. bsr get_map_position
  86. bsr test_data
  87. cmp.w d7,d6
  88. bne.s cant_use_right
  89. bsr stuff_data
  90. move.w d0,(a3)+ ;store on stack
  91. move.w d1,(a3)+
  92. cant_use_right
  93. subq.w #1,d0
  94. cant_check_right
  95. *****check up
  96. cmp.w d3,d1
  97. ble.s cant_check_up
  98. subq.w #1,d1
  99. bsr get_map_position
  100. bsr test_data
  101. cmp.w d7,d6
  102. bne.s cant_use_up
  103. bsr stuff_data
  104. move.w d0,(a3)+ ;store on stack
  105. move.w d1,(a3)+
  106. cant_use_up
  107. addq.w #1,d1
  108. cant_check_up
  109. *****check down
  110. cmp.w d5,d1
  111. bge.s cant_check_down
  112. addq.w #1,d1
  113. bsr get_map_position
  114. bsr test_data
  115. cmp.w d7,d6
  116. bne.s cant_use_down
  117. bsr stuff_data
  118. move.w d0,(a3)+ ;store on stack
  119. move.w d1,(a3)+
  120. cant_use_down
  121. subq.w #1,d1
  122. cant_check_down
  123. rts
  124. *********************************************
  125. ******* STUFF DATA *******
  126. *********************************************
  127. stuff_data
  128. tst.w map_datasize(a1)
  129. beq.s map_is_byte_friend
  130. move.w current_block,(a0)
  131. bra.s done_stuff
  132. map_is_byte_friend
  133. move.w current_block,d7
  134. move.b d7,(a0)
  135. done_stuff
  136. rts
  137. *********************************************
  138. ******* TEST DATA *******
  139. *********************************************
  140. test_data
  141. moveq #0,d7
  142. tst.w map_datasize(a1)
  143. beq.s map_is_byte_friendtest
  144. move.w (a0),d7
  145. bra.s done_test
  146. map_is_byte_friendtest
  147. move.b (a0),d7
  148. done_test
  149. rts
  150. *********************************************
  151. ******* GET MAP POSITION *******
  152. *********************************************
  153. get_map_position
  154. *send in d0 and d1 x, y
  155. *returns mem position in a0
  156. movem.l a1/d0-d4,-(sp)
  157. move.w d0,d2
  158. move.w d1,d3
  159. moveq #0,d0
  160. moveq #0,d1
  161. move.w d2,d0
  162. move.w d3,d1
  163. move.l current_map_ptr,a0
  164. move.l map_mem(a0),a1
  165. move.w map_datasize(a0),d3
  166. asl d3,d0
  167. move.w map_xsize(a0),d4
  168. asl d3,d4
  169. mulu d4,d1
  170. add.l d0,a1
  171. add.l d1,a1 ;block position
  172. move.l a1,a0
  173. movem.l (sp)+,a1/d0-d4
  174. rts