lorom

org $90D0C9
JSR $F935
org $90D0F8
JSR $F935
org $90D124
JSR $F935

org $90F935
LDA $05D1               ;load timer 3
CMP #$0000              ;compare to 0 for no time
BEQ TIMEREND            ;if timer end, jump
DEC $05D1               ;if timer not ended, decriment
LDA $09C2               ;code that was replaced (samus health)
CMP #$001E              ;compare with 1E (value to stop shinesparks at)
RTS

TIMEREND:
LDA $0A1E               ;X-Direction Samus is moving
AND #$00FF              
CMP #$0004              ;moving left
BEQ Moveleft            ;if moving left, jump
LDA #$0029              ;load value for "vertical shinespark facing right"
BRA End                 ;then jump to storing value for position to end
Moveleft:
LDA #$002A              ;load value for "vertical shinespark facing left"
BRA End                 ;then jump to storing value for position to end

End:
STA $0A28               ;Potential new value for Samus's current position/state.
JSR $D2C9               ;code to run to end shinesparks
LDA $09C2               ;code that was replaced (samus health)
CMP #$001E              ;compare with 1E (value to stop shinesparks at)
RTS

;timer 3 incrimenter
org $91DA97
JSL $90F969
NOP

org $90F969
LDA $05D1        ;load timer 3
CMP #$0030
BMI SET          ;if minus go to SET
INC $05D1        ;incriment timer
INC $05D1        ;incriment timer
INC $05D1        ;incriment timer
BRA DONE         ;then go to code that was replaced
SET:             ;where we go if timer has not been set
LDA #$0030       ;load value to set to timer
STA $05D1        ;store to timer 3
DONE:
LDA $0ACE        ;code that was replaced
INC A            ;code that was replaced
INC A            ;code that was replaced
RTL

;timer 3 reset
org $90979C
JSR $F98B

org $90F98B
STA $0AD0
LDA $0A68       ;samus's super jump timer
CMP #$0000      ;value for super jump timer
BEQ ZERO
RTS
ZERO:
STZ $05D1
RTS