lorom


;Makes charge beam attract item pickups, Prime style
;by Black_Falcon

org $90B860	: DB $3C						;how long charge beam must be held down to fire a beam (default 3C)	
org $91D756	: DB $3C						;charge beam timer check for samus palette to change (should be equal to above value, default 3C)


org $86F057 : JSR CHECKCHARGE 				;hijack point

org $86F4AB	: 
CHECKCHARGE:	LDA $0CD0 : BEQ GTFO		;check if charge timer > 0
HERE:			LDA $0AF6 : CMP $1A4B,x : BEQ NEXT : BMI UP : BPL DOWN : BRA GTFO	;check item pickup's X position relative to samus
NEXT:			LDA $0AFA : CMP $1A93,x : BEQ GTFO : BPL LEFT : BMI RIGHT			;check item pickup's Y position relative to samus
UP:				DEC $1A4B,x : BRA NEXT		;go up
DOWN:			INC $1A4B,x : BRA NEXT		;go down
LEFT:			INC $1A93,x : BRA GTFO		;go left
RIGHT:			DEC $1A93,x					;go right
GTFO:			LDA $0AF6 : RTS				;go out

