Skip to content

Commit 67de6e6

Browse files
committed
use 255 for auto detect
1 parent a2db964 commit 67de6e6

File tree

8 files changed

+14
-18
lines changed

8 files changed

+14
-18
lines changed

build.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const { spawnSync } = require('child_process');
66
console.log('TetrisGYM buildscript');
77
console.time('build');
88

9-
const mappers = [0, 1, 3, 4, 5];
9+
const mappers = [255, 1, 3, 4, 5];
1010

1111
// options handling
1212

@@ -43,7 +43,7 @@ console.log(`using ${nativeCC65 ? 'system' : 'wasm'} ca65/ld65`);
4343

4444
// mapper options
4545

46-
const mapper = args.find((d) => d.startsWith('-m'))?.slice(2) ?? 0;
46+
const mapper = args.find((d) => d.startsWith('-m'))?.slice(2) ?? 255;
4747

4848
if (!mappers.includes(+mapper)) {
4949
console.error(

src/constants.asm

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
.ifndef INES_MAPPER ; is set via ca65 flags
2-
INES_MAPPER := 0 ; supports 0 (autodetect 1/3), 1, 3, 4 and 5 (MMC1 / CNROM / MMC3 / MMC5)
2+
INES_MAPPER := 255 ; 1 (MMC1), 3 (CNROM), 4 (MMC3), 5 (MMC5), and 255 (autodetect 1/3)
33
.endif
44

5-
HAS_MMC = INES_MAPPER = 1 || INES_MAPPER = 4 || INES_MAPPER = 5
6-
75
.ifndef SAVE_HIGHSCORES
86
SAVE_HIGHSCORES := 1
97
.endif

src/header.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
INES_MIRROR = 0 ; 0 = horizontal mirroring, 1 = vertical mirroring (ignored in MMC1)
1313
INES_SRAM = 1 ; 1 = battery backed SRAM at $6000-7FFF
1414

15-
; Override INES_MAPPER for mode 0 (auto detect)
16-
.if INES_MAPPER = 0
15+
; Override INES_MAPPER for mode 255 (auto detect)
16+
.if INES_MAPPER = 255
1717
.if CNROM_OVERRIDE
1818
_INES_MAPPER = 3 ; Test CNROM on Emulator/Flashcart
1919
.else

src/io.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ MMC5_CHR_BANK0 := $5123 ; 4kb page index
6262
MMC5_CHR_BANK1 := $5127
6363

6464
.macro RESET_MMC1
65-
.if INES_MAPPER = 0 .or INES_MAPPER = 1
65+
.if INES_MAPPER = 1 .or INES_MAPPER = 255
6666
: inc :- ; increments inc ($aa), writing a negative value to prg
6767
; https://www.nesdev.org/wiki/MMC1#Reset
6868
.endif

src/main.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ mainLoop:
5555
.include "util/menuthrottle.asm"
5656
.include "util/modetext.asm"
5757
.include "util/mapper.asm"
58-
.if INES_MAPPER = 0
58+
.if INES_MAPPER = 255
5959
.include "util/autodetect.asm"
6060
.endif
6161

src/ram.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ dasOnlyShiftDisabled: .res 1 ; $63A
210210

211211
invisibleFlag: .res 1 ; $63B ; 0 for normal mode, non-zero for Invisible playfield rendering. Reset on game init and game over.
212212

213-
mapperId: .res 1 ; $63C ; For INES_MAPPER 0 (autodetect). 0 = CNROM. 1 = MMC1.
213+
mapperId: .res 1 ; $63C ; For INES_MAPPER 255 (autodetect). 0 = CNROM. 1 = MMC1.
214214

215215
.res $38
216216

src/reset.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ reset: cld
5353

5454
mapperInit:
5555
; autodetect
56-
.if INES_MAPPER = 0
56+
.if INES_MAPPER = 255
5757
setMMC1PRG ; initialize mmc1 just in case
5858
; cnrom can pass one of these tests but not both.
5959
; Start with the one it's supposed to fail.

src/util/mapper.asm

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
.endmacro
3131

3232
_setMMC1Control:
33-
.if INES_MAPPER = 0 .or INES_MAPPER = 1
3433
RESET_MMC1
3534
sta MMC1_Control
3635
lsr a
@@ -41,15 +40,14 @@ _setMMC1Control:
4140
sta MMC1_Control
4241
lsr a
4342
sta MMC1_Control
44-
.endif
4543
rts
4644

4745
changeCHRBanks:
4846
; accum should be 0 or 2 (CHRBankset0 or CHRBankset1)
4947
sta generalCounter
5048

5149
; autodetect
52-
.if INES_MAPPER = 0
50+
.if INES_MAPPER = 255
5351
ldx mapperId
5452
beq @cnrom
5553
changeCHRBanksMMC1
@@ -112,7 +110,7 @@ changeCHRBanks:
112110

113111
setHorizontalMirroring:
114112
; autodetect
115-
.if INES_MAPPER = 0
113+
.if INES_MAPPER = 255
116114
lda mapperId
117115
beq @cnrom
118116
lda #%10011
@@ -140,10 +138,10 @@ setHorizontalMirroring:
140138
rts
141139

142140
setVerticalMirroring:
143-
; Unused except during mapper detect for INES_MAPPER 0
141+
; Unused except during mapper detect for INES_MAPPER 255
144142

145143
; autodetect
146-
.if INES_MAPPER = 0
144+
.if INES_MAPPER = 255
147145
lda mapperId
148146
beq @cnrom
149147
lda #%10010
@@ -170,7 +168,7 @@ setVerticalMirroring:
170168
.endif
171169
rts
172170

173-
.if INES_MAPPER = 0 .or INES_MAPPER = 3
171+
.if INES_MAPPER = 3 .or INES_MAPPER = 255
174172
; bus conflict workaround
175173
cnromBanks:
176174
.byte $00,$01

0 commit comments

Comments
 (0)