Advertisement
KSSBrawl_

Tetris Attack garbage fall check code

Aug 22nd, 2023
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1. ;-------------------------------------------------
  2. ;-------------------------------------------------
  3. ; garbage_fall_check_template
  4. ; Template macro for checking if a combo
  5. ; garbage block should fall.
  6. ;
  7. ; width Width of garbage block
  8. ;-------------------------------------------------
  9. ;-------------------------------------------------
  10. .macro garbage_fall_check_template width
  11. .repeat width, i
  12. .if i < width - 1
  13. .define label .sprintf("@space%da", i + 2)
  14. .else
  15. .define label "@space1b"
  16. .endif
  17. lda a:panel_hover_timers+016+(i<<1),y
  18. beq .ident(label)
  19. jmp @mark_as_not_falling
  20. .ident (label):
  21. .undef label ; undefine to allow reuse
  22. .endrep
  23. ;- - - - - - - - - - - - - - - - - - - - - - - - -
  24. .repeat width, i
  25. .if i < width - 1
  26. .define label .sprintf("@space%db", i + 2)
  27. .else
  28. .define label "@bextend"
  29. .endif
  30. lda a:panel_attrs_2+016+(i<<1),y
  31. beq .ident(label)
  32. jmp @space1c
  33. .ident (label):
  34. .undef label ; undefine to allow reuse
  35. .endrep
  36. jmp @mark_as_falling
  37. @space1c:
  38. ;- - - - - - - - - - - - - - - - - - - - - - - - -
  39. .repeat width, i
  40. .if i < width - 1
  41. .define label .sprintf("@space%dc", i + 2)
  42. .else
  43. .define label "@space1d"
  44. .endif
  45. lda a:panel_attrs_1+016+(i<<1),y
  46. bit #ATTR1_IS_FALLING
  47. bne :+
  48. jmp @mark_as_not_falling
  49. : bit #ATTR1_UNK_0020
  50. beq .ident(label)
  51. jmp @mark_as_not_falling
  52. .ident (label):
  53. .undef label ; undefine to allow reuse
  54. .endrep
  55. ;- - - - - - - - - - - - - - - - - - - - - - - - -
  56. .repeat width, i
  57. .if i < width - 1
  58. .define label .sprintf("@space%dd", i + 2)
  59. .else
  60. .define label "@mark_as_falling"
  61. .endif
  62. lda a:panel_attrs_2+016+(i<<1),y
  63. bit #ATTR2_IS_QUEUED | ATTR2_IS_SWAPPING
  64. beq :+
  65. jmp @mark_as_not_falling
  66. : cmp #$00ff ; check if garbage is at bottom of board
  67. bne .ident(label)
  68. jmp @mark_as_not_falling
  69. .ident (label):
  70. .undef label ; undefine to allow reuse
  71. .endrep
  72. ;- - - - - - - - - - - - - - - - - - - - - - - - -
  73. .repeat width, i
  74. lda a:panel_attrs_1+(i<<1),y
  75. ora #ATTR1_IS_FALLING
  76. sta a:panel_attrs_1+(i<<1),y
  77. .if i = 0
  78. jsr code_86a4a2
  79. .elseif i = 1
  80. jsr code_86a4cd
  81. .elseif i = 2
  82. jsr code_86a4f8
  83. .elseif i = 3
  84. jsr code_86a523
  85. .elseif i = 4
  86. jsr code_86a54e
  87. .elseif i = 5
  88. jsr code_86a579
  89. .endif
  90. .endrep
  91. rts
  92. ;- - - - - - - - - - - - - - - - - - - - - - - - -
  93. @mark_as_not_falling:
  94. .if width = 6
  95. tyx
  96. lda f:array_7e84f6,x
  97. and #$1f00
  98. xba
  99. sta $04
  100. jsr code_86a254
  101. lda $02
  102. pha
  103. .endif
  104. .repeat width, i
  105. lda a:panel_attrs_1+(i<<1),y
  106. and #~ATTR1_IS_FALLING
  107. sta a:panel_attrs_1+(i<<1),y
  108. .endrep
  109. jsr code_86a286
  110. .if width = 6
  111. pla
  112. sta $02
  113. bne @return
  114. .endif
  115. tyx
  116. .repeat width, i
  117. lda f:array_7e84f6+(i<<1),x
  118. and #~$8000
  119. sta f:array_7e84f6+(i<<1),x
  120. .endrep
  121. ;- - - - - - - - - - - - - - - - - - - - - - - - -
  122. @return: rts
  123. .endmac
  124. ;-------------------------------------------------
  125. ;-------------------------------------------------
  126. garbage_fall_check_3_wide:
  127. garbage_fall_check_template 3
  128.  
  129. garbage_fall_check_4_wide:
  130. garbage_fall_check_template 4
  131.  
  132. garbage_fall_check_5_wide:
  133. garbage_fall_check_template 5
  134.  
  135. garbage_fall_check_6_wide:
  136. garbage_fall_check_template 6
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement