;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Snapdown, cstutor89
;; Displays Message 2, shakes the floor, and lowers the wall down on Mario
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

dcb "INIT"	
		LDA #$02
		STA $1426
		RTL

dcb "MAIN"	
		PHB			; \
		PHK			;  | main sprite function, just calls local subroutine
		PLB			;  |
		JSR SPRITE_MAIN		;  |
		PLB			;  |
		RTL			; /

SPRITE_MAIN:	LDA $9D		;\ If sprites are locked...
		BNE Return	;/ Go to "Return".
		LDA $13		;\
		AND #$0F
		CMP #$0F
		BNE Return	;/ Only run code every 80 frames.	
		LDA #$02	;\ Make sure that new tiles are uploaded from the bottom of the screen
		STA $56		;/
		LDA $1469
		CMP #$5F
		BCS DestroySprite
		REP #$20	; 16-bit (accumulator).
		DEC $1468	; Make the screen scroll downwards automatically.
		SEP #$20	; 8-bit (accumulator).
		LDA #$0E	; Shake ground forever
		STA $1887
Return:		RTS

DestroySprite:	LDA $1468
		BNE Return
		LDA #$04
		STA $14C8,x
		RTS