;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;MONEY is Life
;;by Superyoshi
;;MFG659: fixed by MarioFanGamer659
;;
;; This sprite takes away 1 coin each second. If the Coin Counter hits 0, you die.
;; MFG659: usually you don't die by the generator if you're flashing or having a star
;; MFG659: and takes coins away even the sprite lock flag was set.
;; MFG659: I've those and more things fixed.
;; MFG659: Just replace the new generator with the old generator.
;;
;;Uses first extra bit: NO
;;Insert it as a generator (sprite number from D0 to FF).
;;
;;You need to give credit.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; defines
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
!Freeram = $7EC100
!Time = $37					; time beetween taking coins - 37 = one second
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite data
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite init JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

	PRINT "INIT ",pc
		;LDA #!Time			; time beetween taking coins - 37 = one second
		;STA !Freeram			; MFG659: But generators haven't got init routines 
	RTL                 


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; sprite code JSL
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    PRINT "MAIN ",pc 
		LDA $9D
		BNE RETURN
		LDA !Freeram
		DEC A
		STA !Freeram
		BNE RETURN
		LDA #$!Time
		STA $7EC100
		LDA $0DBF
		CMP #$01
		BEQ NOMONEY

	MONEY:
		LDA $0DBF
		CMP #$00
		BEQ RETURN
		DEC $0DBF
		LDA $0DBF
		CMP #$0B			; change 0B to where you want the WARNING Sound to begin + 1
		BCC WARNING			; comment this out to diable WARNING Sound

	RETURN:
		RTL

	WARNING:
		LDA #$2A
		STA $1DFC
		RTL
	
	NOMONEY:
		JSL $00F606
		RTL