Created
February 15, 2013 03:40
-
-
Save blondie7575/4958420 to your computer and use it in GitHub Desktop.
This file contains 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
mainloop: | |
// Wait for VBL to process commands | |
sbrs VBL,0 | |
rjmp mainloop | |
// See if there's a command pending | |
lds regS,CMDBUFFER_S | |
lds regT,CMDBUFFER_E | |
cp regS,regT | |
breq mainloop // No command at all | |
inc regS | |
cp regS,regT | |
breq mainloop // Half a command- keep waiting | |
// Dequeue the command from the buffer | |
dec regS | |
mov XL,regS | |
ldi XH,CMDBUFFER_H | |
ld cmdBufferL,X | |
inc XL // Not using X+ because we want to wrap the low byte | |
ld cmdBufferH,X | |
inc XL | |
sts CMDBUFFER_S,XL | |
// Switch on command buffer value | |
cpi cmdBufferL,0x01 | |
breq redirectTR1 | |
cpi cmdBufferL,0x02 | |
breq redirectTR2 | |
cpi cmdBufferL,0x03 | |
breq redirectTR3 | |
cpi cmdBufferL,0x04 | |
breq redirectTR4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment