Last active
March 22, 2017 21:32
-
-
Save gnacu/2369d63a231952ae7c351baa85b2f37c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chktimer ;Timer vector cannot be in ZP. | |
;If timer vector MSB is 0, RTS. | |
;Checks timer, JSR if reached. | |
lda timervec+2 | |
beq timerexit | |
lda jiffyhi | |
cmp timer+2 | |
bcc timerexit ;Not reached | |
bne timervec ;Reached | |
lda jiffymi | |
cmp timer+1 | |
bcc timerexit ;Not reached | |
bne timervec ;Reached | |
lda jiffylo | |
cmp timer+0 | |
bcc timerexit ;Not reached | |
timervec jsr $00 ;Self-modifying | |
bcs timerexit | |
lda #0 | |
sta timervec+2 ;Clear the timer | |
timerexit | |
rts | |
timer .byte 0,0,0 | |
settimer ;Copy ZP Vector to JSR's addr | |
lda $fb | |
sta timervec+1 | |
lda $fc | |
sta timervec+2 | |
;Write .X.Y relative time. | |
stx timer+0 | |
sty timer+1 | |
clc | |
;Add current Jiffy Time. | |
lda jiffylo | |
adc timer+0 | |
sta timer+0 | |
lda jiffymi | |
adc timer+1 | |
sta timer+1 | |
lda jiffyhi | |
adc #0 | |
sta timer+2 | |
rts | |
;AMAZINGLY, Assembles to just 88 bytes. | |
;abcdefghijklmnopqrstuvwxyz | |
;abcdefghijklmnopqrstuvwxyz | |
;abcdefghijklmnopqrstuvwxyz | |
;abcdefghi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment