← A99A Prize-reveal tune gate Map AA79 → Brick state map
A99B: Register a brick hit
Resolves a hit on a brick: it classifies the tile's durability and queues the break animation the brick-field sweep plays.
Input
HL tile-map address of the struck brick
hit_brick A99B LD A,L Align the struck brick's tile-map address and save it for the rest of the hit.
A99C AND $DE
A99E LD L,A
A99F LD (hit_brick_addr),HL
A9A2 LD A,(bat_side) Pick the brick field's first cell in the tile map. With the bat on the right, the field starts at column 2.
A9A5 OR A
A9A6 JR NZ,hit_brick_left_bat
A9A8 LD DE,TILEMAP_BASE+$82
A9AB JR hit_brick_calc_index
hit_brick_left_bat A9AD LD DE,TILEMAP_BASE+$8C With the bat on the left, the field starts at column 12.
hit_brick_calc_index A9B0 AND A Convert the brick's tile-map position into its offset in the brick state map, the brick index doubled.
A9B1 SBC HL,DE
A9B3 LD A,L
A9B4 AND $1F
A9B6 SRL A
A9B8 SRL H
A9BA RR L
A9BC SRL H
A9BE RR L
A9C0 SRL L
A9C2 SRL L
A9C4 SRL L
A9C6 SRL L
A9C8 LD B,L
hit_brick_row_loop A9C9 ADD A,$09
A9CB DJNZ hit_brick_row_loop
A9CD ADD A,A
A9CE LD (hit_brick_index),A Save the brick's state-map offset.
A9D1 LD A,(hit_params) Branch on what struck the brick. A ball goes to the missile-shot test, and the starburst clears the brick outright. An inhabitant goes to the durability check.
A9D4 OR A
A9D5 JR Z,hit_brick_normal_path
A9D7 CP $02
A9D9 JR Z,hit_brick_mark
A9DB JP hit_brick_classify
hit_brick_normal_path A9DE LD A,(active_ball) A ball hit: only the secondary object that carries the missile shot force-clears the brick, and it sounds its own break note first. Ball A and a real ball B jump to the classifier.
A9E1 OR A
A9E2 JR Z,hit_brick_classify
A9E4 LD A,(missile_shot)
A9E7 OR A
A9E8 JR Z,hit_brick_classify
A9EA CALL sfx_brick_hit
hit_brick_mark A9ED LD A,(hit_brick_index) Queue the plain shatter in the brick's state map entry, from sub-frame zero, and score the combo. No durability check runs, so any tile empties, the golden brick included.
A9F0 LD E,A
A9F1 LD D,$00
A9F3 LD HL,brick_state_map
A9F6 ADD HL,DE
A9F7 LD (HL),$01
A9F9 INC HL
A9FA LD (HL),$00
A9FC CALL score_brick
A9FF RET
hit_brick_classify AA00 LD HL,(hit_brick_addr) Walk the durability table from its first class with the struck brick's tile in hand.
AA03 LD DE,brick_durability_classes
AA06 LD C,$01
hit_brick_scan AA08 LD A,(DE) A terminator byte closes the class the counter is on.
AA09 CP $FF
AA0B JR NZ,hit_brick_scan_match
AA0D INC C Bump the counter; run out of classes and the tile is unclassified, so the hit is dropped.
AA0E LD A,C
AA0F CP $13
AA11 RET Z
AA12 JR hit_brick_scan_next Otherwise continue the scan.
hit_brick_scan_match AA14 CP (HL) A byte equal to the struck tile names its class.
AA15 JR Z,hit_brick_found
hit_brick_scan_next AA17 INC DE Step to the next tile code and continue the walk.
AA18 JP hit_brick_scan
hit_brick_found AA1B LD A,C Only the prize classes reach the reveal roll.
AA1C CP $07
AA1E JR C,hit_brick_pick_sound
AA20 CP $10 Skip the finished markers too.
AA22 JR NC,hit_brick_pick_sound
AA24 LD A,(hit_params) An inhabitant step reveals nothing.
AA27 OR A
AA28 JR NZ,hit_brick_shatter
AA2A LD A,(ball_gem_frame) While the ball gem is out, a prize that claims the secondary object cannot be revealed.
AA2D OR A
AA2E JR NZ,hit_brick_force_shatter
AA30 LD A,(ball_b_in_play) The secondary object carries a ball while the missile shot or a real ball B is out. While it does, a prize that claims the secondary object cannot be revealed either.
AA33 OR A
AA34 JR Z,hit_brick_prize_roll
hit_brick_force_shatter AA36 LD A,C Force each prize that claims the secondary object down the plain path. This test is the bomb.
AA37 CP $08
AA39 JR Z,hit_brick_shatter
AA3B CP $09 This one is the missile prize.
AA3D JR Z,hit_brick_shatter
AA3F CP $0B This one is the double bat prize.
AA41 JR Z,hit_brick_shatter
hit_brick_prize_roll AA43 CALL next_random Prize-reveal 50/50 for a prize brick: the low bit of the latest random number. One outcome keeps the brick's own class, whose break animation ends on that class's prize glyph. A later hit takes the prize through the prize handler. The other falls through to the plain break animation, which shatters the slot empty.
AA46 AND $01
AA48 JR Z,hit_brick_pick_sound
hit_brick_shatter AA4A LD C,$01 The force paths land here: the brick takes the plain break sequence whatever its own class was.
hit_brick_pick_sound AA4C LD A,C The resolved class picks the sound: the plain break path plays the brick-destroyed sound.
AA4D CP $01
AA4F JR NZ,hit_brick_chirp_sound
AA51 CALL sfx_brick_destroyed
AA54 JR hit_brick_queue_anim
hit_brick_chirp_sound AA56 CP $06 The golden and silver brick classes play the brick-survives sound instead. The prize classes stay silent here and arm the tune below.
AA58 JR NC,hit_brick_arm_prize_tune
AA5A CALL sfx_brick_survives
AA5D JR hit_brick_queue_anim
hit_brick_arm_prize_tune AA5F LD A,$01 Reached when a struck brick's resolved durability class is a prize class. Arm the prize-reveal tune, then fall through to the break-animation queue, which queues the reveal sequence and scores the hit.
AA61 LD (prize_reveal_tune_gate),A
hit_brick_queue_anim AA64 LD HL,brick_state_map Queue the resolved class in the brick's state map entry, from sub-frame zero, so the brick-field sweep plays its break sequence.
AA67 LD A,(hit_brick_index)
AA6A LD E,A
AA6B LD D,$00
AA6D ADD HL,DE
AA6E LD (HL),C
AA6F INC HL
AA70 LD (HL),$00
AA72 CALL score_brick_if_ordinary
AA75 CALL apply_prize
AA78 RET
← A99A Prize-reveal tune gate Map AA79 → Brick state map
Fork me on GitHub