diff options
| author | Miquel Sabaté Solà <msabate@suse.com> | 2023-12-03 07:45:53 +0100 |
|---|---|---|
| committer | Miquel Sabaté Solà <msabate@suse.com> | 2023-12-03 07:45:53 +0100 |
| commit | dd7a4efc643c20c56b845aa11af1fec4b0760d92 (patch) | |
| tree | b3e213c7ba4dbff04691f41bd80975bfd1eb600e /include/reset.s | |
| download | aoc2023.nes-dd7a4efc643c20c56b845aa11af1fec4b0760d92.tar.gz aoc2023.nes-dd7a4efc643c20c56b845aa11af1fec4b0760d92.zip | |
First day of advent of code
Signed-off-by: Miquel Sabaté Solà <msabate@suse.com>
Diffstat (limited to 'include/reset.s')
| -rw-r--r-- | include/reset.s | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/reset.s b/include/reset.s new file mode 100644 index 0000000..e68d3db --- /dev/null +++ b/include/reset.s @@ -0,0 +1,63 @@ +;; Common `reset` procedure for NROM "games". Check `basics/sprite.s` on +;; @mssola/NES for a proper explanation on the code (will be open soon, +;; promise!). +reset: + sei + cld + + ldx #$40 + stx $4017 + + ldx #$ff + txs + + inx + stx $2000 + stx $2001 + stx $4010 + +@vblankwait1: + bit $2002 + bpl @vblankwait1 + + ldx #0 + lda #0 +@ram_reset_loop: + sta $000, x + sta $100, x + sta $300, x + sta $400, x + sta $500, x + sta $600, x + sta $700, x + inx + bne @ram_reset_loop + + lda #$ef +@sprite_reset_loop: + sta $200, x + inx + bne @sprite_reset_loop + + lda #$00 + sta $2003 + lda #$02 + sta $4014 + +@vblankwait2: + bit $2002 + bpl @vblankwait2 + + lda #$3F + sta $2006 + lda #$00 + sta $2006 + + lda #$0F + ldx #$20 +@palettes_reset_loop: + sta $2007 + dex + bne @palettes_reset_loop + + jmp main |
