TimeCoiner256

by kappatechy

Game: SMW

Description: Sets coins based on the timer (mod 256)

; Define some useful addresses
!coins = $7E0DBF
!timer_hundreds = $7E0F31
!timer_tens = $7E0F32
!timer_ones = $7E0F33

; This first chunk converts decimal back to hex
LDA !timer_hundreds
ASL
ADC !timer_hundreds
ASL
ASL
ADC !timer_tens
ASL
ADC !timer_hundreds
ASL
ADC !timer_tens
CMP #25 ; Prevent it from exceeding 255
BCC toohigh
ASL
ADC !timer_ones
BRA end

toohigh:
SEC
SBC #25
ASL
ADC !timer_ones
CMP #6
BCC toohigh_B
ADC #250
BRA end

toohigh_B:
SEC
SBC #6

end:
STA !coins        ; Store in the coins
RTL
back to listings