aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-20 18:01:34 +0100
committerMiquel Sabaté Solà <mikisabate@gmail.com>2025-03-20 18:01:34 +0100
commitb21e3d2588749568c777a84435905bef110f3479 (patch)
tree957615ee80680a21abcbe67427455f946fdf9486
parent49842414e2c570c511ef5c3c9e1860ee8d2fd504 (diff)
downloadcode.nes-b21e3d2588749568c777a84435905bef110f3479.tar.gz
code.nes-b21e3d2588749568c777a84435905bef110f3479.zip
Clear VBlank on reset on all examples
This was an oversight from the very first example that has propagated into the other ones. Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
-rw-r--r--basics/chr-ram.s1
-rw-r--r--basics/flicker.s1
-rw-r--r--basics/input.s1
-rw-r--r--basics/persist.s1
-rw-r--r--basics/sprite.s5
-rw-r--r--basics/unrom.s1
-rw-r--r--fx/blink.s1
-rw-r--r--scroll/include/reset.s1
-rw-r--r--scroll/roulette.s1
-rw-r--r--scroll/toggle.s1
-rw-r--r--space/src/vectors/reset.s1
11 files changed, 14 insertions, 1 deletions
diff --git a/basics/chr-ram.s b/basics/chr-ram.s
index bb2186e..48b2a74 100644
--- a/basics/chr-ram.s
+++ b/basics/chr-ram.s
@@ -75,6 +75,7 @@ chr:
stx $2001
stx $4010
+ bit $2002
@vblankwait1:
bit $2002
bpl @vblankwait1
diff --git a/basics/flicker.s b/basics/flicker.s
index 5677968..2cca1dd 100644
--- a/basics/flicker.s
+++ b/basics/flicker.s
@@ -184,6 +184,7 @@
stx $2001 ; PPUMASK
stx $4010 ; APU DMC
+ bit $2002 ; PPUSTATUS
@vblankwait1:
bit $2002 ; PPUSTATUS
bpl @vblankwait1
diff --git a/basics/input.s b/basics/input.s
index df49a66..c51a500 100644
--- a/basics/input.s
+++ b/basics/input.s
@@ -56,6 +56,7 @@
stx $2001
stx $4010
+ bit $2002
@vblankwait1:
bit $2002
bpl @vblankwait1
diff --git a/basics/persist.s b/basics/persist.s
index e7dfb07..49d3c81 100644
--- a/basics/persist.s
+++ b/basics/persist.s
@@ -80,6 +80,7 @@
reset_mmc1:
inc reset_mmc1
+ bit $2002
@vblankwait1:
bit $2002
bpl @vblankwait1
diff --git a/basics/sprite.s b/basics/sprite.s
index b9e183b..27beb91 100644
--- a/basics/sprite.s
+++ b/basics/sprite.s
@@ -174,7 +174,10 @@
;; will see how we can take advantage of this when we use the PPU properly
;; down the road.
- ;; First of the two waits.
+ ;; First of the two waits. The `bit` outside of the loop is not a typo, but
+ ;; since the VBlank flag is in an unknown state after reset, we clear it now
+ ;; so the next loop does not exit immediately by mistake.
+ bit $2002 ; PPUSTATUS
@vblankwait1:
bit $2002 ; PPUSTATUS
bpl @vblankwait1
diff --git a/basics/unrom.s b/basics/unrom.s
index eb49b17..60b52d6 100644
--- a/basics/unrom.s
+++ b/basics/unrom.s
@@ -139,6 +139,7 @@ bankswitch_nosave:
stx $2001
stx $4010
+ bit $2002
@vblankwait1:
bit $2002
bpl @vblankwait1
diff --git a/fx/blink.s b/fx/blink.s
index ce63b2c..2c21a8f 100644
--- a/fx/blink.s
+++ b/fx/blink.s
@@ -200,6 +200,7 @@
;; NOTE: and from here on initialization proceeds as usual.
+ bit $2002
@vblankwait1:
bit $2002
bpl @vblankwait1
diff --git a/scroll/include/reset.s b/scroll/include/reset.s
index 2402795..efe477e 100644
--- a/scroll/include/reset.s
+++ b/scroll/include/reset.s
@@ -14,6 +14,7 @@
stx PPU::MASK
stx APU::DMC
+ bit PPU::STATUS
@vblankwait1:
bit PPU::STATUS
bpl @vblankwait1
diff --git a/scroll/roulette.s b/scroll/roulette.s
index b0c2a61..037b8b6 100644
--- a/scroll/roulette.s
+++ b/scroll/roulette.s
@@ -155,6 +155,7 @@
BANK_REGISTER_SET 6, 0
BANK_REGISTER_SET 7, 1
+ bit $2002
@vblankwait1:
bit $2002
bpl @vblankwait1
diff --git a/scroll/toggle.s b/scroll/toggle.s
index 32fc39f..57f403f 100644
--- a/scroll/toggle.s
+++ b/scroll/toggle.s
@@ -223,6 +223,7 @@
stx PPU::MASK
stx APU::DMC
+ bit PPU::STATUS
@vblankwait1:
bit PPU::STATUS
bpl @vblankwait1
diff --git a/space/src/vectors/reset.s b/space/src/vectors/reset.s
index b024e65..df5cfa8 100644
--- a/space/src/vectors/reset.s
+++ b/space/src/vectors/reset.s
@@ -16,6 +16,7 @@
stx $2001
stx $4010
+ bit $2002
@vblankwait1:
bit $2002
bpl @vblankwait1