diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2023-11-12 09:39:05 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-02-04 21:02:11 +0100 |
| commit | db9cb2118e7b2575ed3b0f535e50dd85c24df25a (patch) | |
| tree | 8bfe1a7e48bd85e2e9ab0c650c248a7bed1955b7 /space/src/vectors/reset.s | |
| parent | cb854722b9890c171f7d0600812a7e9a3a2a25c9 (diff) | |
| download | code.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/reset.s')
| -rw-r--r-- | space/src/vectors/reset.s | 47 |
1 files changed, 10 insertions, 37 deletions
diff --git a/space/src/vectors/reset.s b/space/src/vectors/reset.s index afc9fa5..1216146 100644 --- a/space/src/vectors/reset.s +++ b/space/src/vectors/reset.s @@ -1,39 +1,25 @@ .segment "CODE" +;; Check `basics/sprite.s` for a deeper look on the logic below. I have only +;; added code after configuration/reset is done. reset: - ;; Ignore IRQs and disable decimal mode. sei cld - - ;; Disable APU frame IRQ. ldx #$40 - stx APU::FRAME_COUNTER + stx $4017 - ;; Set up the stack register with the proper value. ldx #$ff txs - ;; And now disable, in this order, NMI, rendering and DMC IRQs. Note that - ;; `x` was set to $ff, so increasing it by one results in a zero, which is - ;; the value then stored in the aforementioned memory locations. inx - stx PPU::CONTROL - stx PPU::MASK - stx APU::DMC - - ;;; - ;; NOTE: If you are using a mapper which needs some special configuration, - ;; now it would be a good time set it up. I am not using a special mapper, - ;; so there's nothing from me to do here. - ;;; + stx $2000 + stx $2001 + stx $4010 - ;; First of the two VBLANK waits. @vblankwait1: - bit PPU::STATUS + bit $2002 bpl @vblankwait1 - ;; Clear RAM memory. Notice that we are not clearing $200-$2ff, this is done - ;; later. ldx #0 lda #0 @ram_reset_loop: @@ -47,30 +33,17 @@ reset: inx bne @ram_reset_loop - ;; Reset sprites by moving them off-screen. lda #$ef @sprite_reset_loop: sta $200, x inx bne @sprite_reset_loop - ;; Write "sprites" into OAM. - OAM_WRITE_SPRITES - - ;; Last VBLANK wait. @vblankwait2: - bit PPU::STATUS + bit $2002 bpl @vblankwait2 - ;; Reset palettes. - PPU_ADDR $3F00 - - lda #$0F - ldx #$20 -@palettes_reset_loop: - sta PPU::DATA - dex - bne @palettes_reset_loop + ;;; + ;; NOTE: configuration/reset is done, the code below is our actual program :D - ;; Jump into the main subroutine. jmp main |
