From b21e3d2588749568c777a84435905bef110f3479 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Thu, 20 Mar 2025 18:01:34 +0100 Subject: Clear VBlank on reset on all examples MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This was an oversight from the very first example that has propagated into the other ones. Signed-off-by: Miquel Sabaté Solà --- basics/chr-ram.s | 1 + basics/flicker.s | 1 + basics/input.s | 1 + basics/persist.s | 1 + basics/sprite.s | 5 ++++- basics/unrom.s | 1 + 6 files changed, 9 insertions(+), 1 deletion(-) (limited to 'basics') 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 -- cgit v1.2.3