lorom

;A patch by SMILEuser96 that causes Samus to slowly lose her supplies, Power Bombs first, then Super Missiles, then Missiles, then Energy. Doesn't affect reserve tanks. No credit needed

org $9498B8	;\
DW $B600	;|Air Fool X-Ray BTS 06 and a pointer to free space. BTS 03-05 are overused :P
org $94B600	;/

	LDA $008D	;Used as a timer
	CMP #$0010	;Change this to change how fast Samus refills her stuff (lower value=faster. higher value=slower. I recommend either 10 or 20)
	BEQ Empty	;Branches to "Empty" routine if the value at 7FFA02 is the same as above CMP. In this case, 10 (hex)
	INC $008D	;Else, increase the timer.
	RTS		;Return

Empty:		;emptying routine, part 1
	LDA $09CE
	CMP #$0001
	BPL LoseBombs	;Loads power bombs to A, then compares it to 0. if higher than 0, one will be taken away
	LDA $09CA	;Else, check for supers...
	CMP #$0001
	BPL LoseSupers	;Same as above BPL...
	LDA $09C6
	CMP #$0001
	BPL LoseMissiles	;Should be obvious...
	LDA $09C2
	CMP #$0001
	BPL LoseEnergy	;...
	BRA End		;If everything is 0, reset timer, do nothing else and quit. (Check below)

		;Refill routine, part 2
LoseBombs:
	DEC $09CE	;takes 1 power bomb away
	BRA End		;BRAnching is used to save space

LoseSupers:
	DEC $09CA
	BRA End

LoseMissiles:
	DEC $09C6
	BRA End

LoseEnergy:
	DEC $09C2
	
End:
	STZ $008D
	RTS		;Resets the timer, does nothing else and quits.