Lorom			;defines rom type

;Highjack stuff------------------------------------------

org $809B4E		;Highjack point in main HUD routine

JSR $CDC0		;Jump to free space

org $80CDC0		;said free space

;Code----------------------------------------------------

LDA $05D5		;load timer address
CMP #$0014		;check if it's at frame 20
BEQ BUTTONSTUFF	;if so, go to checktoggle
INC A			;increase timer
STA $05D5		;store back to timer
LDA $09C0		;load the thing I overwrote and end
RTS

BUTTONSTUFF:
LDA $8B			;load the held buttons array
BIT $09B8		;check for item cancle
BNE CANCLEHELD
LDA $09C0		;load overwritten stuff
RTS				;end

CANCLEHELD:
LDA $8F			;load pressed buttons array
BIT $09BC		;check for aim down being pushed
BNE LPRESSED
BIT $09BE		;check for aim up being pushed
BNE RPRESSED
LDA $09C0
RTS

RPRESSED:
JMP RIGHTSHIFT

;Aim down shifting----------------------------------------

LPRESSED:
LDA $09A6 : BIT #$0001		;check for wave
BNE WAVEON		;isg
BIT #$0004		;check for spazer
BNE SPAZERON	;isg
BIT #$0008		;check for plasma
BNE PLASMAON	;isg
BIT #$0002		;check for ice
BNE ICEON		;isg
LDA $09A8 : BIT #$0008		;check for plasma collected	
BEQ PLASMAON	;indg
LDA $09A6 : ORA #$0008 : STA $09A6		;turn on plasma
JSL $90AC8D		;resets the beam gfx and palette
LDA $09C0
RTS

WAVEON:
LDA $09A8		;load collected beams
BIT #$0002		;check for ice
BEQ ICEON		;if not, go to iceon
LDA $09A6 : ORA #$0002 : STA $09A6		;turn on ice
AND #$FFFE : STA $09A6		;turn off wave
JSL $90AC8D
LDA $09C0
RTS

SPAZERON:
LDA $09A8		;load collected beams
BIT #$0001		;check for wave
BEQ WAVEON		;if not go to waveon
LDA $09A6 : ORA #$0001 : STA $09A6		;turn on wave
AND #$FFFB : STA $09A6		;turn off spazer
JSL $90AC8D
LDA $09C0		
RTS

PLASMAON:
LDA $09A8		;load collected beams
BIT #$0004		;check for spazer
BEQ SPAZERON	;if not go to spazeron
LDA $09A6 : ORA #$0004 : STA $09A6		;turn on spazer	
AND #$FFF7 : STA $09A6		;turn off plasma
JSL $90AC8D
LDA $09C0
RTS

ICEON:
LDA $09A6 : AND #$FFFD : STA $09A6		;turn off ice
AND #$FFF7 : STA $09A6		;turn off plasma
AND #$FFFE : STA $09A6		;turn off wave
AND #$FFFB : STA $09A6		;turn off spazer
JSL $90AC8D		
LDA $09C0
RTS

END:
LDA $09C0
RTS

;Aim up shifting--------------------------------------------

RIGHTSHIFT:
LDA $09A6 : BIT #$0001		;check for wave
BNE WAVETWO		;isg
BIT #$0004		;check for spazer
BNE SPAZERTWO	;isg
BIT #$0008		;check for plasma
BNE GOTOPLASMA	;isg
BIT #$0002		;check for ice
BNE ICETWO		;isg
LDA $09A8 : BIT #$0002		;check for ice collected	
BEQ ICETWO		;indg
LDA $09A6 : ORA #$0002 : STA $09A6		;turn on ice
JSL $90AC8D
LDA $09C0
RTS

GOTOPLASMA:
JMP PLASMATWO

ICETWO:
LDA $09A8		;load collected beams
BIT #$0001		;check for wave
BEQ SPAZERTWO	;if not go to spazertwo
LDA $09A6 : ORA #$0001 : STA $09A6		;turn on wave
AND #$FFFD : STA $09A6		;turn off ice
JSL $90AC8D
LDA $09C0
RTS

WAVETWO:
LDA $09A8		;load collected beams
BIT #$0004		;check for spazer
BEQ SPAZERTWO	;if not, go to iceon
LDA $09A6 : ORA #$0004 : STA $09A6		;turn on spazer
AND #$FFFE : STA $09A6		;turn off wave
JSL $90AC8D
LDA $09C0
RTS

SPAZERTWO:
LDA $09A8		;load collected beams
BIT #$0008		;check for plasma
BEQ PLASMATWO	;if not go to plasmatwo
LDA $09A6 : ORA #$0008 : STA $09A6		;turn on plasma
AND #$FFFB : STA $09A6		;turn off spazer
JSL $90AC8D
LDA $09C0		
RTS

PLASMATWO:
LDA $09A6 : AND #$FFF7 : STA $09A6		;turn off plasma
AND #$FFFD : STA $09A6		;turn off ice
AND #$FFFE : STA $09A6		;turn off wave
AND #$FFFB : STA $09A6		;turn off spazer
JSL $90AC8D
LDA $09C0
RTS















