Created
September 10, 2018 00:19
-
-
Save niconii/f2872415f2eca82b82706a9f35259673 to your computer and use it in GitHub Desktop.
Example SNES main loop
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
reset: | |
; initialize everything... | |
main: | |
; update game state... | |
; process sprites in a copy of OAM stored in WRAM... | |
; other stuff... | |
inc ReadyFlag ; signal that we're done processing for this frame | |
spin: | |
lda ReadyFlag ; wait until flag is cleared by NMI routine | |
bne spin | |
jmp main | |
nmi: | |
; save registers... | |
; set A to 8-bit and XY to 16-bit... | |
lda ReadyFlag ; if main loop not ready, skip to end | |
beq nmi_end | |
; turn on forced blank in case we take too long | |
; DMA to OAM... | |
; update graphics... | |
; poll controllers... | |
; other stuff... | |
; turn off forced blank | |
stz ReadyFlag ; since graphics were updated, clear flag | |
nmi_end: | |
; restore registers... | |
rti |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment