aboutsummaryrefslogtreecommitdiff
path: root/space/src/vectors/nmi.s
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <msabate@suse.com>2023-11-12 09:39:05 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-02-04 21:02:11 +0100
commitdb9cb2118e7b2575ed3b0f535e50dd85c24df25a (patch)
tree8bfe1a7e48bd85e2e9ab0c650c248a7bed1955b7 /space/src/vectors/nmi.s
parentcb854722b9890c171f7d0600812a7e9a3a2a25c9 (diff)
downloadcode.nes-db9cb2118e7b2575ed3b0f535e50dd85c24df25a.tar.gz
code.nes-db9cb2118e7b2575ed3b0f535e50dd85c24df25a.zip
space: Simplify the code and its goals
Originally this was supposed to be a sort of mini game, but that would have probably made it too complex for newcomers. Thus, let's just keep it to subpixel movement and shooting bullets, which is already a big step from the `basics/sprite.s` example. Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'space/src/vectors/nmi.s')
-rw-r--r--space/src/vectors/nmi.s24
1 files changed, 21 insertions, 3 deletions
diff --git a/space/src/vectors/nmi.s b/space/src/vectors/nmi.s
index 4bc3dde..e049239 100644
--- a/space/src/vectors/nmi.s
+++ b/space/src/vectors/nmi.s
@@ -1,14 +1,32 @@
-;; Non-Maskable Interrupts handler.
+;; See `basics/sprite.s` for more info. I'm not doing anything fancier here.
nmi:
- ;; As mentioned on the `main` subroutine, rendering will be skipped until
- ;; the proper flag is set.
bit $20
bpl @next
+ ;; Save registers.
+ pha
+ txa
+ pha
+ tya
+ pha
+
;; We can start rendering stuff.
OAM_WRITE_SPRITES
+ ;; Reset scroll.
+ bit $2002 ; PPUSTATUS
+ lda #$00
+ sta $2005 ; PPUSCROLL
+ sta $2005 ; PPUSCROLL
+
;; And unset the render flag so the `main` code is unblocked.
UNSET_RENDER_FLAG
+
+ ;; Restore registers.
+ pla
+ tay
+ pla
+ tax
+ pla
@next:
rti