diff options
| author | Miquel Sabaté Solà <mssola@mssola.com> | 2026-02-13 00:03:07 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mssola@mssola.com> | 2026-02-13 00:03:07 +0100 |
| commit | 03a5882df17ea42aa0b4039173f85ea1e7ce99fe (patch) | |
| tree | b98c1ce699e9de7f44551b12e33c61f3d190497d /src | |
| parent | 7b8bcdab96353d4c6577345f8ed1a291fc041782 (diff) | |
| download | jetpac.nes-03a5882df17ea42aa0b4039173f85ea1e7ce99fe.tar.gz jetpac.nes-03a5882df17ea42aa0b4039173f85ea1e7ce99fe.zip | |
Remove vector.s
Instead of this, the 'reset' function can go into 'jetpac.s', as we
could consider it's part of the 'main' work. As a bonus, doing this
alignment gives us 3 bytes back from ROM space. Not that we care too
much about space, but it's amusing nonetheless.
The debug scope has been moved into its own file in include/. Admittedly
it's not the most crucial file in the project, but it makes things more
logical and it opens the door to more debugging utilities.
This leaves us with a vector.s file only containing interrupt
code. Thus, it just makes sense to rename it to interrupts.s, which in
the end makes things more organized.
Signed-off-by: Miquel Sabaté Solà <mssola@mssola.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/interrupts.s (renamed from src/vectors.s) | 69 | ||||
| -rw-r--r-- | src/jetpac.s | 67 |
2 files changed, 66 insertions, 70 deletions
diff --git a/src/vectors.s b/src/interrupts.s index e5d1a58..8c53af7 100644 --- a/src/vectors.s +++ b/src/interrupts.s @@ -1,74 +1,5 @@ -.segment "VECTORS" - .addr nmi, reset, irq - .segment "CODE" -;; Debug utilities. -.scope Debug - ;; Counter for frame drops. Only touched when PARTIAL is defined. - zp_frame_drops = $90 ; asan:ignore -.endscope - -;; Pretty standard reset function, nothing crazy. -.proc reset - ;; Disable interrupts and decimal mode. - sei - cld - - ;; Disable APU frame counter. - ldx #$40 - stx APU::m_frame_counter - - ;; Setup the stack. - ldx #$FF - txs - - ;; Disable NMIs and the APU's DMC. - inx - stx PPU::m_control - stx PPU::m_mask - stx APU::m_dmc - - ;; First PPU wait. - bit PPU::m_status -@vblankwait1: - bit PPU::m_status - bpl @vblankwait1 - - ;; Initialize the counter for frame drops before any NMIs can come in. - .ifdef PARTIAL - lda #0 - sta Debug::zp_frame_drops - .endif - - ;; Reset all sprites by simply moving the Y coordinate out of screen. - lda #$EF - ldx #0 -@sprite_reset_loop: - sta OAM::m_sprites, x - inx - inx - inx - inx - bne @sprite_reset_loop - - ;; DMA setup for sprite reset. - lda #$00 - sta OAM::m_address - lda #$02 - sta OAM::m_dma - - ;; Second PPU wait. After that the PPU is stable. -@vblankwait2: - bit PPU::m_status - bpl @vblankwait2 - - ;; NOTE: palettes are not initialized here as it's going to be one of the - ;; first things done on `main` code. - - jmp main -.endproc - .proc nmi ;; Should we skip it? bit Globals::zp_flags diff --git a/src/jetpac.s b/src/jetpac.s index 16fa292..79fec84 100644 --- a/src/jetpac.s +++ b/src/jetpac.s @@ -36,6 +36,7 @@ .include "../include/asm.s" .include "../include/joypad.s" .include "../include/globals.s" +.include "../include/debug.s" .include "assets.s" .include "background.s" @@ -45,7 +46,68 @@ .include "enemies.s" .include "title.s" .include "driver.s" -.include "vectors.s" +.include "interrupts.s" + +;; Pretty standard reset function, nothing crazy. +.proc reset + ;; Disable interrupts and decimal mode. + sei + cld + + ;; Disable APU frame counter. + ldx #$40 + stx APU::m_frame_counter + + ;; Setup the stack. + ldx #$FF + txs + + ;; Disable NMIs and the APU's DMC. + inx + stx PPU::m_control + stx PPU::m_mask + stx APU::m_dmc + + ;; First PPU wait. + bit PPU::m_status +@vblankwait1: + bit PPU::m_status + bpl @vblankwait1 + + ;; Initialize the counter for frame drops before any NMIs can come in. + .ifdef PARTIAL + lda #0 + sta Debug::zp_frame_drops + .endif + + ;; Reset all sprites by simply moving the Y coordinate out of screen. + lda #$EF + ldx #0 +@sprite_reset_loop: + sta OAM::m_sprites, x + inx + inx + inx + inx + bne @sprite_reset_loop + + ;; DMA setup for sprite reset. + lda #$00 + sta OAM::m_address + lda #$02 + sta OAM::m_dma + + ;; Second PPU wait. After that the PPU is stable. +@vblankwait2: + bit PPU::m_status + bpl @vblankwait2 + + ;; NOTE: palettes are not initialized here as it's going to be one of the + ;; first things done on `main` code. + + __fallthrough__ main +.endproc + .proc main ;; Disable the PPU and zero out variables which shadow PPU registers. @@ -148,3 +210,6 @@ ;; TODO: allow to start over, reset flags, control register, etc. jmp @over .endproc + +.segment "VECTORS" + .addr nmi, reset, irq |
