Skip to content

Commit 6db7256

Browse files
committed
working mmc3
1 parent 259c33a commit 6db7256

File tree

6 files changed

+28
-21
lines changed

6 files changed

+28
-21
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Toying with MMC3 in this branch. Only problem I'm aware of to solve is a screen flicker during initGameBackground. May come back to this later.
2-
31
# TetrisGYM
42

53
<div align="center">

build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ compile_flags=()
55
help () {
66
echo "Usage: $0 [-v] [-m <1|3>] [-a] [-s] [-k] [-h]"
77
echo "-v Enable verbose output"
8-
echo "-m Set mapper. Valid values are 1 and 3. Default 1."
8+
echo "-m Set mapper. Valid values are 1, 3 and 4. Default 1."
99
echo "-a Enable pressing select to end game"
1010
echo "-s Disable saving of high scores"
1111
echo "-k Enable Famicom Keyboard support"
@@ -17,7 +17,7 @@ while getopts "vm:askh" flag; do
1717
v) set -x ;;
1818
m)
1919
if ! [[ "${OPTARG}" =~ ^[134]$ ]]; then
20-
echo "Valid INES_MAPPER (-m) options are 1 or 3"
20+
echo "Valid INES_MAPPER (-m) options are 1, 3 or 4"
2121
exit 1
2222
fi
2323
compile_flags+=("-D INES_MAPPER=${OPTARG}")

src/gamemode/gametypemenu/menu.asm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ gameMode_gameTypeMenu:
1818
jsr changeCHRBank1
1919
.endif
2020
.if INES_MAPPER = 4
21+
; Horizontal mirroring
2122
lda #$1
22-
sta $A000
23+
sta MMC3_MIRRORING
2324
.endif
2425
lda #%10011 ; used to be $10 (enable horizontal mirroring)
2526
jsr setMMC1Control

src/gamemodestate/initbackground.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ gameModeState_initGameBackground:
4747
lda #%10011000
4848
sta PPUCTRL
4949
sta currentPpuCtrl
50+
.elseif INES_MAPPER = 4
51+
; Vertical mirroring (Prevents screen glitching)
52+
lda #$0
53+
sta MMC3_MIRRORING
5054
.endif
5155
jsr resetScroll
5256
jsr waitForVBlankAndEnableNmi

src/io.asm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ MMC1_Control := $8000
4646
MMC1_CHR0 := $BFFF
4747
MMC1_CHR1 := $DFFF
4848

49+
MMC3_BANK_SELECT := $8000
50+
MMC3_BANK_DATA := $8001
51+
MMC3_MIRRORING := $A000
52+
4953
.macro RESET_MMC1
5054
.if INES_MAPPER = 1
5155
inc $8000 ; initRam

src/util/core.asm

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,13 @@ changeCHRBank0:
315315
asl a
316316
asl a
317317
ldx #$00
318-
stx $8000
319-
sta $8001
318+
stx MMC3_BANK_SELECT
319+
sta MMC3_BANK_DATA
320320
inx
321321
clc
322322
adc #$02
323-
stx $8000
324-
sta $8001
323+
stx MMC3_BANK_SELECT
324+
sta MMC3_BANK_DATA
325325
.endif
326326
rts
327327

@@ -340,23 +340,23 @@ changeCHRBank1:
340340
asl a
341341
asl a
342342
ldx #$02
343-
stx $8000
344-
sta $8001
343+
stx MMC3_BANK_SELECT
344+
sta MMC3_BANK_DATA
345345
inx
346346
clc
347347
adc #$01
348-
stx $8000
349-
sta $8001
348+
stx MMC3_BANK_SELECT
349+
sta MMC3_BANK_DATA
350350
inx
351351
clc
352352
adc #$01
353-
stx $8000
354-
sta $8001
353+
stx MMC3_BANK_SELECT
354+
sta MMC3_BANK_DATA
355355
inx
356356
clc
357357
adc #$01
358-
stx $8000
359-
sta $8001
358+
stx MMC3_BANK_SELECT
359+
sta MMC3_BANK_DATA
360360
.endif
361361
rts
362362

@@ -375,12 +375,12 @@ changePRGBank:
375375
asl a
376376
asl a
377377
ldx #$06
378-
stx $8000
379-
sta $8001
378+
stx MMC3_BANK_SELECT
379+
sta MMC3_BANK_DATA
380380
inx
381381
clc
382382
adc #$01
383-
stx $8000
384-
sta $8001
383+
stx MMC3_BANK_SELECT
384+
sta MMC3_BANK_DATA
385385
.endif
386386
rts

0 commit comments

Comments
 (0)