Skip to content

Commit f6bc06e

Browse files
Merge pull request #42 from zohassadar/mmc3
MMC3 Init Adjustment
2 parents 3ee4072 + 8da1f31 commit f6bc06e

File tree

3 files changed

+25
-26
lines changed

3 files changed

+25
-26
lines changed

src/io.asm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ MMC1_CHR1 := $DFFF
4949
MMC3_BANK_SELECT := $8000
5050
MMC3_BANK_DATA := $8001
5151
MMC3_MIRRORING := $A000
52+
MMC3_PRG_RAM := $A001
5253

5354
.macro RESET_MMC1
5455
.if INES_MAPPER = 1

src/reset.asm

Lines changed: 24 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,26 @@ 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+
lda #$80 ; enable PRG RAM
45+
sta MMC3_PRG_RAM
46+
rts
47+
.endif
48+
49+
4150
MMC1_PRG:
4251
.byte $00,$00,$00,$00,$00,$00,$00,$00
4352
.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)