db $42
JMP MarioBelow : JMP MarioAbove : JMP MarioSide
JMP SpriteV : JMP SpriteH : JMP MarioCape : JMP MarioFireball
JMP TopCorner : JMP BodyInside : JMP HeadInside

; player's bounce y-speed when holding jump
!bounce_hold = $B0

; player's bounce y-speed when not holding jump
!bounce_no_hold = $C4

; FreeRAM addresses that should match the ones in BreakTheTargets.asm
!RAM_hits = $0F5E
!RAM_total = $0F5F

MarioBelow:
	JSL destroy
	BRA solid

MarioAbove:
TopCorner:
	; player bounces
	LDA $15
	AND #%10000000
	BEQ +
	LDA #!bounce_hold		; holding jump
	STA $7D
	BRA ++
	+	
	LDA #!bounce_no_hold	; not holding jump
	STA $7D
	++
	
	BRA destroy

SpriteV:
	%check_sprite_kicked_vertical()
	BCS sprite_destroy
	RTL

SpriteH:
	%check_sprite_kicked_horizontal()
	BCC +
	BRA sprite_destroy	
	+
	RTL

MarioFireball:
	STZ $170B,X
	BRA destroy
	
MarioCape:
	BRA destroy

; become solid
BodyInside:
HeadInside:
MarioSide:
	RTL

solid:
	LDY #$01
	LDA #$30
	STA $1693
	RTL
	
sprite_destroy:
	%sprite_block_position()	
destroy:
	%erase_block()
	%create_smoke()
	
	; sfx
	LDA #$13
	CLC : ADC !RAM_hits
	STA $1DF9
	LDA #$25
	STA $1DFC
	
	INC !RAM_hits
	+
	
	RTL

print "Break the targets!"
