Skip to content

Commit 32d8fd3

Browse files
Add mapper 270
1 parent ec4f5f5 commit 32d8fd3

File tree

3 files changed

+109
-0
lines changed

3 files changed

+109
-0
lines changed

src/ines.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ INES_BOARD_BEGIN()
821821
INES_BOARD( "8-in-1 JY-119", 267, Mapper267_Init )
822822
INES_BOARD( "COOLBOY/MINDKIDS", 268, Mapper268_Init ) /* Submapper distinguishes between COOLBOY and MINDKIDS */
823823
INES_BOARD( "Games Xplosion 121-in-1", 269, Mapper269_Init )
824+
INES_BOARD( "OneBus ($412C bankswitch)", 270, Mapper270_Init )
824825
INES_BOARD( "MGC-026", 271, Mapper271_Init )
825826
INES_BOARD( "Akumajō Special: Boku Dracula-kun", 272, Mapper272_Init )
826827
INES_BOARD( "80013-B", 274, Mapper274_Init )

src/ines.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ void Mapper266_Init(CartInfo *);
280280
void Mapper267_Init(CartInfo *);
281281
void Mapper268_Init(CartInfo *);
282282
void Mapper269_Init(CartInfo *);
283+
void Mapper270_Init(CartInfo *);
283284
void Mapper271_Init(CartInfo *);
284285
void Mapper272_Init(CartInfo *);
285286
void Mapper274_Init(CartInfo *);

src/mappers/mapper270.c

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
/* FCEUmm - NES/Famicom Emulator
2+
*
3+
* Copyright notice for this file:
4+
* Copyright (C) 2025 negativeExponent
5+
*
6+
* This program is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
*/
21+
22+
/* NES 2.0 Mapper 270 denotes OneBus console multicarts that use the consoles'
23+
* universal input/output (UIO) register $412C to bankswitch higher-order PRG
24+
* address lines or several PRG chips, and select CHR-RAM via $4242.*/
25+
26+
/* TODO: Family Pocket 638-in-1 freeze on jumper enable */
27+
28+
#include "mapinc.h"
29+
#include "onebus.h"
30+
31+
static uint8 reg4242; /* $4242 */
32+
static uint8 dipsw; /* jumper */
33+
34+
static void Sync(void) {
35+
uint16 mblock = 0;
36+
switch (iNESCart.submapper) {
37+
case 1:
38+
mblock |= (onebus.cpu41xx[0x2C] & 0x02) << 10; /* PRG/CHR A24 */
39+
break;
40+
case 2:
41+
mblock |= (onebus.cpu41xx[0x2C] & 0x02) << 10; /* PRG/CHR A24 */
42+
mblock |= (onebus.cpu41xx[0x2C] & 0x01) << 11; /* PRG/CHR A25 */
43+
break;
44+
case 3:
45+
mblock |= (onebus.cpu41xx[0x2C] & 0x04) << 9; /* PRG/CHR A24 */
46+
break;
47+
case 0:
48+
default:
49+
mblock |= (onebus.cpu41xx[0x2C] & 0x02) << 10; /* PRG/CHR A24 */
50+
mblock |= (onebus.cpu41xx[0x2C] & 0x04) << 9; /* PRG/CHR A24 */
51+
mblock |= (onebus.cpu41xx[0x2C] & 0x01) << 11; /* PRG/CHR A25 */
52+
break;
53+
}
54+
OneBus_FixPRG(0x07FF, mblock);
55+
if (reg4242 & 0x01) {
56+
/* CHR-RAM enabled, use 8K unbancked CHR RAM */
57+
setchr8(0);
58+
} else {
59+
OneBus_FixCHR(0x3FFF, mblock << 3);
60+
}
61+
OneBus_FixMIR();
62+
}
63+
64+
static DECLFR(M270ReadJumperDetect) {
65+
return dipsw << 3;
66+
}
67+
68+
static DECLFW(M270WriteCHRRAMEnable) {
69+
reg4242 = V;
70+
if (CHRptr[0] && (reg4242 & 0x01)) {
71+
SetupCartCHRMapping(0, CHRptr[0], CHRsize[0], TRUE);
72+
} else {
73+
SetupCartCHRMapping(0, PRGptr[0], PRGsize[0], FALSE);
74+
}
75+
Sync();
76+
}
77+
78+
static void M270Power(void) {
79+
dipsw = 0;
80+
reg4242 = 0;
81+
OneBus_Power();
82+
SetReadHandler(0x412C, 0x412C, M270ReadJumperDetect);
83+
SetWriteHandler(0x4242, 0x4242, M270WriteCHRRAMEnable);
84+
}
85+
86+
static void M270Reset(void) {
87+
SetupCartCHRMapping(0, PRGptr[0], PRGsize[0], FALSE);
88+
dipsw = !dipsw; /* toggle jumper */
89+
reg4242 = 0;
90+
onebus.cpu41xx[0x2C] = 0;
91+
OneBus_Reset();
92+
}
93+
94+
void Mapper270_Init(CartInfo *info) {
95+
int ws = (info->PRGRamSize + info->PRGRamSaveSize) / 1024;
96+
97+
if (!ws) {
98+
ws = 8;
99+
}
100+
101+
OneBus_Init(info, Sync, ws, info->battery);
102+
info->Power = M270Power;
103+
info->Reset = M270Reset;
104+
105+
AddExState(&reg4242, 1, 0, "CHRM");
106+
AddExState(&dipsw, 1, 0, "DPSW");
107+
}

0 commit comments

Comments
 (0)