Skip to content

Commit c821f8d

Browse files
committed
cleaner init
1 parent 2f56d2c commit c821f8d

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

src/reset.asm

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,5 @@
11
; incremented to reset MMC1 reg
2-
reset:
3-
.if INES_MAPPER = 4
4-
ldy #$00
5-
ldx #$06
6-
stx MMC3_BANK_SELECT
7-
sty MMC3_BANK_DATA
8-
inx
9-
iny
10-
stx MMC3_BANK_SELECT
11-
sty MMC3_BANK_DATA
12-
lda #$00
13-
stx MMC3_BANK_SELECT
14-
.endif
15-
cld
2+
reset: cld
163
sei
174
ldx #$00
185
stx PPUCTRL
@@ -25,8 +12,10 @@ reset:
2512
bpl @vsyncWait2
2613
dex
2714
txs
28-
.if INES_MAPPER <> 4
15+
.if INES_MAPPER = 1
2916
inc reset
17+
.elseif INES_MAPPER = 4
18+
jsr mmc3Init
3019
.endif
3120
lda #$10
3221
jsr setMMC1Control
@@ -38,6 +27,24 @@ reset:
3827
jsr changePRGBank
3928
jmp initRam
4029

30+
.if INES_MAPPER = 4
31+
; https://www.nesdev.org/wiki/MMC3
32+
mmc3Init:
33+
; 110: R6: Select 8 KB PRG ROM bank at $8000-$9FFF (or $C000-$DFFF)
34+
ldx #$06
35+
ldy #$00
36+
stx MMC3_BANK_SELECT
37+
sty MMC3_BANK_DATA
38+
39+
; 111: R7: Select 8 KB PRG ROM bank at $A000-$BFFF
40+
inx
41+
iny
42+
stx MMC3_BANK_SELECT
43+
sty MMC3_BANK_DATA
44+
rts
45+
.endif
46+
47+
4148
MMC1_PRG:
4249
.byte $00,$00,$00,$00,$00,$00,$00,$00
4350
.byte $00

src/util/core.asm

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,5 @@ changePRGBank:
371371
sta MMC1_PRG
372372
lsr a
373373
sta MMC1_PRG
374-
.elseif INES_MAPPER = 4
375-
asl a
376-
asl a
377-
ldx #$06
378-
stx MMC3_BANK_SELECT
379-
sta MMC3_BANK_DATA
380-
inx
381-
clc
382-
adc #$01
383-
stx MMC3_BANK_SELECT
384-
sta MMC3_BANK_DATA
385374
.endif
386375
rts

0 commit comments

Comments
 (0)