diff options
| author | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-05-12 21:20:33 +0200 |
|---|---|---|
| committer | Miquel Sabaté Solà <mikisabate@gmail.com> | 2025-05-12 21:20:33 +0200 |
| commit | ad830a7f81871e15f43d7255f7af5463d9dd0bc5 (patch) | |
| tree | 6217d30e13a96f8bc3a7675ab3e45c9e9c3f967a /src/jetpac.s | |
| parent | d2cab2f600b4a5efea34fce9e17de0c2ba964c6c (diff) | |
| download | jetpac.nes-ad830a7f81871e15f43d7255f7af5463d9dd0bc5.tar.gz jetpac.nes-ad830a7f81871e15f43d7255f7af5463d9dd0bc5.zip | |
reset: Do not zero out RAM
This is usually done so the programmer can forget about initializing in
the future, but it not only hides programming mistakes, but we are also
resetting memory addresses which are never to be used by this simple
game. Hence, just skip resetting RAM altogether.
Last but not least, sprite initialization in `reset` code has also been
optimized so instead of around 2000 cycles it takes half of that. This
is done by only touching the first byte of the four bytes for a sprite
in OAM, which is enough for hiding random sprites and the cost of extra
`inx` instructions is far cheaper than all the extra `sta` to absolute
address with X-index from the old code.
Signed-off-by: Miquel Sabaté Solà <mikisabate@gmail.com>
Diffstat (limited to 'src/jetpac.s')
| -rw-r--r-- | src/jetpac.s | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/jetpac.s b/src/jetpac.s index 65b5d11..10f6df3 100644 --- a/src/jetpac.s +++ b/src/jetpac.s @@ -45,9 +45,17 @@ .include "vectors.s" .proc main - ;; Disable the PPU. + ;; Disable the PPU and zero out variables which shadow PPU registers. lda #0 sta PPU::MASK + sta PPU::zp_mask + sta PPU::zp_control + + ;; Initialize other global variables which the rest of the game assume to + ;; have zero as their initial values. + sta Globals::zp_flags + sta Joypad::zp_buttons1 + sta Joypad::zp_buttons2 ;; Initialize the assets for the game. jsr Assets::init |
