More mapper updates (#607)
* M061: Add CHR-ROM variant. * M227: Make DIP switch change only apply to submapper 1 * M242: Only assume DIP/solder pad read when A0-A7 are zero, corrects ET-187 and Xing-2462. Initialize M227's and M242's DIP switch setting on Hard Reset. * M052: Support CHR-RAM-less variant of submapper 14. * M364: Correct the outer bank register's address mask, for LT-953 multicart. * M047: Supprt larger-sized multicarts using a compatible PCB. Reset to menu. * M360: Add submapper 1. * M221: Rewrite, add submapper 1 variant. * M288: Remove bank masks to allow for already-existing larger cartridges. * M411: Add submappers. * M417: Add submapper 1. * M115: Add multicart functionalities. * M201: Simplify and correct the power-on value. CF-043, mentioned in the source code comment, needs no submapper; just a correct header with Horizontal mirroring. * M200: Correct the power-on value. * M432: Add submappers to distinguish three variants. * Add mapper 412. --------- Co-authored-by: NewRisingSun <8vytz1+dhp372pv94ebg@sharklasers.com>
This commit is contained in:
@@ -22,37 +22,52 @@
|
|||||||
|
|
||||||
#include "mapinc.h"
|
#include "mapinc.h"
|
||||||
|
|
||||||
static uint8 dipswitch;
|
static uint8 reg;
|
||||||
|
static uint8 submapper;
|
||||||
|
|
||||||
static SFORMAT StateRegs[] =
|
static SFORMAT StateRegs[] =
|
||||||
{
|
{
|
||||||
{ &dipswitch, 1, "DPSW" },
|
{ ®, 1, "DPSW" },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void Sync(void) {
|
static void Sync(void) {
|
||||||
|
if (~reg &0x20 && submapper ==1) {
|
||||||
|
setprg8(0x8000, 0x40);
|
||||||
|
setprg8(0xA000, 0x40);
|
||||||
|
setprg8(0xC000, 0x40);
|
||||||
|
setprg8(0xE000, 0x40);
|
||||||
|
} else
|
||||||
/* dip 0 and 1 is the same game SMB) */
|
/* dip 0 and 1 is the same game SMB) */
|
||||||
if (dipswitch < 2)
|
if ((reg &0x1F) < 2)
|
||||||
setprg32(0x8000, dipswitch >> 1);
|
setprg32(0x8000, reg >> 1 &0x0F);
|
||||||
else {
|
else {
|
||||||
setprg16(0x8000, dipswitch);
|
setprg16(0x8000, reg &0x1F);
|
||||||
setprg16(0xC000, dipswitch);
|
setprg16(0xC000, reg &0x1F);
|
||||||
}
|
}
|
||||||
setchr8(dipswitch);
|
setchr8(reg);
|
||||||
setmirror(((dipswitch & 0x10) >> 4) ^ 1);
|
setmirror(((reg & 0x10) >> 4) ^ 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFW(M360WriteReg) {
|
||||||
|
reg =V;
|
||||||
|
Sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M360Power(void) {
|
static void M360Power(void) {
|
||||||
dipswitch = 0;
|
reg = 0;
|
||||||
Sync();
|
Sync();
|
||||||
|
if (submapper ==1) SetWriteHandler(0x4100, 0x4FFF, M360WriteReg);
|
||||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
||||||
SetWriteHandler(0x8000, 0XFFFF, CartBW);
|
SetWriteHandler(0x8000, 0XFFFF, CartBW);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M360Reset(void) {
|
static void M360Reset(void) {
|
||||||
dipswitch = (dipswitch + 1) & 31;
|
if (submapper ==0)
|
||||||
|
reg = (reg + 1) & 31;
|
||||||
|
else
|
||||||
|
reg = 0;
|
||||||
Sync();
|
Sync();
|
||||||
FCEU_printf("dipswitch = %d\n", dipswitch);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StateRestore(int version) {
|
static void StateRestore(int version) {
|
||||||
@@ -60,6 +75,7 @@ static void StateRestore(int version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mapper360_Init(CartInfo *info) {
|
void Mapper360_Init(CartInfo *info) {
|
||||||
|
submapper = info->submapper;
|
||||||
info->Reset = M360Reset;
|
info->Reset = M360Reset;
|
||||||
info->Power = M360Power;
|
info->Power = M360Power;
|
||||||
GameStateRestore = StateRestore;
|
GameStateRestore = StateRestore;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ static DECLFW(M364Write) {
|
|||||||
static void M364Power(void) {
|
static void M364Power(void) {
|
||||||
EXPREGS[0] = 0;
|
EXPREGS[0] = 0;
|
||||||
GenMMC3Power();
|
GenMMC3Power();
|
||||||
SetWriteHandler(0x7000, 0x7FFF, M364Write);
|
SetWriteHandler(0x6000, 0x7FFF, M364Write);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper364_Init(CartInfo *info) {
|
void Mapper364_Init(CartInfo *info) {
|
||||||
|
|||||||
@@ -31,55 +31,80 @@
|
|||||||
#include "mapinc.h"
|
#include "mapinc.h"
|
||||||
#include "mmc3.h"
|
#include "mmc3.h"
|
||||||
|
|
||||||
|
uint8 submapper;
|
||||||
|
|
||||||
static void M411CW(uint32 A, uint8 V) {
|
static void M411CW(uint32 A, uint8 V) {
|
||||||
uint32 mask = (EXPREGS[1] & 2) ? 0xFF : 0x7F;
|
int chrAND, chrOR;
|
||||||
V &= mask;
|
switch(submapper) {
|
||||||
setchr1(A, V | ((EXPREGS[1] << 5) & 0x80) | ((EXPREGS[0] << 4) & 0x100));
|
default:chrOR =EXPREGS[1] <<5 &0x080 | EXPREGS[0] <<4 &0x100 | EXPREGS[1] <<2 &0x200;
|
||||||
|
chrAND =EXPREGS[1] &0x02? 0xFF: 0x7F;
|
||||||
|
break;
|
||||||
|
case 1: chrOR =EXPREGS[1] <<5 &0x080 | EXPREGS[1] <<2 &0x100;
|
||||||
|
chrAND =EXPREGS[1] &0x02? 0xFF: 0x7F;
|
||||||
|
break;
|
||||||
|
case 2: chrOR =EXPREGS[1] <<5 &0x080 | EXPREGS[0] <<4 &0x100 | EXPREGS[1] <<2 &0x200;
|
||||||
|
chrAND =EXPREGS[1] &0x02? 0xFF: 0x7F;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
setchr1(A, V &chrAND | chrOR &~chrAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M411PW(uint32 A, uint8 V) {
|
static void M411PW(uint32 A, uint8 V) {
|
||||||
/* NROM Mode */
|
int prgAND, prgOR;
|
||||||
if (EXPREGS[0] & 0x40)
|
switch(submapper) {
|
||||||
{
|
default:prgOR =EXPREGS[1] <<1 &0x10 | EXPREGS[1] >>1 &0x60;
|
||||||
uint32 bank = (EXPREGS[0] & 1) | ((EXPREGS[0] >> 2) & 2) | (EXPREGS[0] & 4) | (EXPREGS[1] & 8) | ((EXPREGS[1] >> 2) & 0x10);
|
prgAND =EXPREGS[1] &0x02? 0x1F: 0x0F;
|
||||||
|
break;
|
||||||
/* NROM-256 */
|
case 1: prgOR =EXPREGS[1] <<1 &0x10 | EXPREGS[1] >>1 &0x60;
|
||||||
if (EXPREGS[0] & 0x02) {
|
prgAND =EXPREGS[1] &0x02? 0x1F: 0x0F;
|
||||||
|
break;
|
||||||
|
case 2: prgOR =EXPREGS[1] <<1 &0x10 | EXPREGS[1] >>1 &0x60;
|
||||||
|
prgAND =EXPREGS[1] &0x01? 0x1F: 0x0F;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (EXPREGS[0] & 0x40) { /* NROM Mode */
|
||||||
|
uint32 bank = EXPREGS[0] &5 | EXPREGS[0] >>2 &2 | prgOR >>1;
|
||||||
|
if (EXPREGS[0] & 0x02) /* NROM-256 */
|
||||||
setprg32(0x8000, bank >> 1);
|
setprg32(0x8000, bank >> 1);
|
||||||
|
else { /* NROM-128 */
|
||||||
/* NROM-128 */
|
|
||||||
} else {
|
|
||||||
setprg16(0x8000, bank);
|
setprg16(0x8000, bank);
|
||||||
setprg16(0xC000, bank);
|
setprg16(0xC000, bank);
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
|
setprg8(A, V &prgAND | prgOR &~prgAND);
|
||||||
|
}
|
||||||
|
|
||||||
/* MMC3 Mode */
|
static DECLFR(M411Read5000) {
|
||||||
else
|
return EXPREGS[2];
|
||||||
{
|
|
||||||
uint32 mask = (EXPREGS[1] & 2) ? 0x1F : 0x0F;
|
|
||||||
V &= mask;
|
|
||||||
setprg8(A, V | ((EXPREGS[1] << 1) & 0x10) | ((EXPREGS[1] >> 1) & 0x20));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(M411Write5000) {
|
static DECLFW(M411Write5000) {
|
||||||
|
if (submapper ==2 || A &0x800) {
|
||||||
EXPREGS[A & 1] = V;
|
EXPREGS[A & 1] = V;
|
||||||
FixMMC3PRG(MMC3_cmd);
|
FixMMC3PRG(MMC3_cmd);
|
||||||
FixMMC3CHR(MMC3_cmd);
|
FixMMC3CHR(MMC3_cmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void M411Reset(void) {
|
||||||
|
EXPREGS[2]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M411Power(void) {
|
static void M411Power(void) {
|
||||||
EXPREGS[0] = 0x80;
|
EXPREGS[0] = 0x0;
|
||||||
EXPREGS[1] = 0x82;
|
EXPREGS[1] = 0x3;
|
||||||
|
EXPREGS[2] = 0x0; /* Serves as DIP value */
|
||||||
GenMMC3Power();
|
GenMMC3Power();
|
||||||
|
SetReadHandler(0x5000, 0x5FFF, M411Read5000);
|
||||||
SetWriteHandler(0x5000, 0x5FFF, M411Write5000);
|
SetWriteHandler(0x5000, 0x5FFF, M411Write5000);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper411_Init(CartInfo *info) {
|
void Mapper411_Init(CartInfo *info) {
|
||||||
|
submapper =info->submapper;
|
||||||
GenMMC3_Init(info, 256, 256, 0, 0);
|
GenMMC3_Init(info, 256, 256, 0, 0);
|
||||||
pwrap = M411PW;
|
pwrap = M411PW;
|
||||||
cwrap = M411CW;
|
cwrap = M411CW;
|
||||||
info->Power = M411Power;
|
info->Power = M411Power;
|
||||||
AddExState(EXPREGS, 2, 0, "EXPR");
|
info->Reset = M411Reset;
|
||||||
|
AddExState(EXPREGS, 3, 0, "EXPR");
|
||||||
}
|
}
|
||||||
|
|||||||
82
src/boards/412.c
Normal file
82
src/boards/412.c
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/* FCEUmm - NES/Famicom Emulator
|
||||||
|
*
|
||||||
|
* Copyright notice for this file:
|
||||||
|
* Copyright (C) 2020
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "mapinc.h"
|
||||||
|
#include "mmc3.h"
|
||||||
|
|
||||||
|
static void M412PW(uint32 A, uint8 V) {
|
||||||
|
int prgAND =0x0F | (EXPREGS[1] &0x02? 0x00: 0x20) | (EXPREGS[1] &0x10? 0x00: 0x10);
|
||||||
|
int prgOR =(EXPREGS[1] &0x40? 0x10: 0x00) | (EXPREGS[1] &0x04? 0x20: 0x00);
|
||||||
|
if (EXPREGS[2] &0x02) { /* NROM mode */
|
||||||
|
if (EXPREGS[2] &0x04) /* NROM-256 */
|
||||||
|
setprg32(0x8000, EXPREGS[2] >>4);
|
||||||
|
else {
|
||||||
|
setprg16(0x8000, EXPREGS[2] >>3);
|
||||||
|
setprg16(0xC000, EXPREGS[2] >>3);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
setprg8(A, V &prgAND | prgOR &~prgAND);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void M412CW(uint32 A, uint8 V) {
|
||||||
|
int chrAND =EXPREGS[1] &0x20? 0x7F: 0xFF;
|
||||||
|
int chrOR =(EXPREGS[1] &0x80? 0x80: 0x00) | (EXPREGS[1] &0x08? 0x100: 0x000);
|
||||||
|
if (EXPREGS[2] &0x02) /* (C)NROM mode */
|
||||||
|
setchr8(EXPREGS[0] >>2);
|
||||||
|
else
|
||||||
|
setchr1(A, (V & chrAND) | (chrOR & ~chrAND));
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFR(M412Read) {
|
||||||
|
return EXPREGS[4];
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFW(M412Write) {
|
||||||
|
if (~EXPREGS[1] &0x01) {
|
||||||
|
EXPREGS[A & 3] = V;
|
||||||
|
FixMMC3PRG(MMC3_cmd);
|
||||||
|
FixMMC3CHR(MMC3_cmd);
|
||||||
|
}
|
||||||
|
CartBW(A, V);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void M412Reset(void) {
|
||||||
|
EXPREGS[0] =EXPREGS[1] =EXPREGS[2] =EXPREGS[3] =0;
|
||||||
|
EXPREGS[4]++;
|
||||||
|
MMC3RegReset();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void M412Power(void) {
|
||||||
|
EXPREGS[0] =EXPREGS[1] =EXPREGS[2] =EXPREGS[3] =EXPREGS[4] =0;
|
||||||
|
GenMMC3Power();
|
||||||
|
SetReadHandler(0x5000, 0x5FFF, M412Read);
|
||||||
|
SetWriteHandler(0x6000, 0x7FFF, M412Write);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mapper412_Init(CartInfo *info) {
|
||||||
|
GenMMC3_Init(info, 512, 256, 0, 0);
|
||||||
|
cwrap = M412CW;
|
||||||
|
pwrap = M412PW;
|
||||||
|
info->Power = M412Power;
|
||||||
|
info->Reset = M412Reset;
|
||||||
|
AddExState(EXPREGS, 5, 0, "EXPR");
|
||||||
|
}
|
||||||
@@ -25,6 +25,7 @@ static uint8 creg[8];
|
|||||||
static uint8 nt[4];
|
static uint8 nt[4];
|
||||||
static uint8 IRQa;
|
static uint8 IRQa;
|
||||||
static uint16 IRQCount;
|
static uint16 IRQCount;
|
||||||
|
static uint8 submapper;
|
||||||
|
|
||||||
static SFORMAT StateRegs[] = {
|
static SFORMAT StateRegs[] = {
|
||||||
{ preg, 4, "PREG" },
|
{ preg, 4, "PREG" },
|
||||||
@@ -48,11 +49,18 @@ static void Sync(void) {
|
|||||||
static DECLFW(M417Write) {
|
static DECLFW(M417Write) {
|
||||||
switch ((A >> 4) & 7) {
|
switch ((A >> 4) & 7) {
|
||||||
case 0: preg[A & 3] = V; Sync(); break;
|
case 0: preg[A & 3] = V; Sync(); break;
|
||||||
case 1: creg[0 | (A & 3)] = V; Sync(); break;
|
case 1: creg[0 | (A & 3)] = V;
|
||||||
|
if (submapper ==1) nt[A & 3] =V >>7;
|
||||||
|
Sync();
|
||||||
|
break;
|
||||||
case 2: creg[4 | (A & 3)] = V; Sync(); break;break;
|
case 2: creg[4 | (A & 3)] = V; Sync(); break;break;
|
||||||
case 3: IRQCount = 0; IRQa = 1; break;
|
case 3: IRQCount = 0; IRQa = 1; break;
|
||||||
case 4: IRQa = 0; X6502_IRQEnd(FCEU_IQEXT); break;
|
case 4: IRQa = 0; X6502_IRQEnd(FCEU_IQEXT); break;
|
||||||
case 5: nt[A & 3] = V; Sync(); break;
|
case 5: if (submapper ==0) {
|
||||||
|
nt[A & 3] = V;
|
||||||
|
Sync();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,7 +72,7 @@ static void M417Power(void) {
|
|||||||
|
|
||||||
static void M417IRQHook(int a) {
|
static void M417IRQHook(int a) {
|
||||||
IRQCount += a;
|
IRQCount += a;
|
||||||
if (IRQa && IRQCount > 1024)
|
if (IRQa && IRQCount > (submapper ==1? 4096: 1024))
|
||||||
X6502_IRQBegin(FCEU_IQEXT);
|
X6502_IRQBegin(FCEU_IQEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,6 +81,7 @@ static void StateRestore(int version) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mapper417_Init(CartInfo *info) {
|
void Mapper417_Init(CartInfo *info) {
|
||||||
|
submapper =info->submapper;
|
||||||
info->Power = M417Power;
|
info->Power = M417Power;
|
||||||
MapIRQHook = M417IRQHook;
|
MapIRQHook = M417IRQHook;
|
||||||
GameStateRestore = StateRestore;
|
GameStateRestore = StateRestore;
|
||||||
|
|||||||
@@ -23,6 +23,8 @@
|
|||||||
#include "mapinc.h"
|
#include "mapinc.h"
|
||||||
#include "mmc3.h"
|
#include "mmc3.h"
|
||||||
|
|
||||||
|
uint8 submapper;
|
||||||
|
|
||||||
static void M432CW(uint32 A, uint8 V) {
|
static void M432CW(uint32 A, uint8 V) {
|
||||||
int chrAND = (EXPREGS[1] & 0x04) ? 0x7F : 0xFF;
|
int chrAND = (EXPREGS[1] & 0x04) ? 0x7F : 0xFF;
|
||||||
int chrOR = (EXPREGS[1] << 7) & 0x080 | (EXPREGS[1] << 5) & 0x100 | (EXPREGS[1] << 4) & 0x200;
|
int chrOR = (EXPREGS[1] << 7) & 0x080 | (EXPREGS[1] << 5) & 0x100 | (EXPREGS[1] << 4) & 0x200;
|
||||||
@@ -32,19 +34,17 @@ static void M432CW(uint32 A, uint8 V) {
|
|||||||
static void M432PW(uint32 A, uint8 V) {
|
static void M432PW(uint32 A, uint8 V) {
|
||||||
int prgAND = (EXPREGS[1] & 0x02) ? 0x0F : 0x1F;
|
int prgAND = (EXPREGS[1] & 0x02) ? 0x0F : 0x1F;
|
||||||
int prgOR = ((EXPREGS[1] << 4) & 0x10) | (EXPREGS[1] << 1) & 0x60;
|
int prgOR = ((EXPREGS[1] << 4) & 0x10) | (EXPREGS[1] << 1) & 0x60;
|
||||||
if ((A < 0xC000) || (~EXPREGS[1] & 0x40)) setprg8(A, (V & prgAND) | (prgOR & ~prgAND) & (EXPREGS[1] & 0x80?~2:~0));
|
if ((A < 0xC000) || (~EXPREGS[1] & 0x40)) setprg8(A, (V & prgAND) | (prgOR & ~prgAND) & (EXPREGS[1] &(submapper ==2? 0x20: 0x80)?~2:~0));
|
||||||
if ((A < 0xC000) && (EXPREGS[1] & 0x40)) setprg8(A | 0x4000, (V & prgAND) | (prgOR & ~prgAND) | (EXPREGS[1] & 0x80? 2: 0));
|
if ((A < 0xC000) && (EXPREGS[1] & 0x40)) setprg8(A | 0x4000, (V & prgAND) | (prgOR & ~prgAND) | (EXPREGS[1] &(submapper ==2? 0x20: 0x80)? 2: 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFR(M432Read) {
|
static DECLFR(M432Read) {
|
||||||
if (EXPREGS[0] & 1 || EXPREGS[1] & 0x20 && ROM_size <64)
|
if (submapper ==1? !!(EXPREGS[1] &0x20): !!(EXPREGS[0] &0x01)) return EXPREGS[2];
|
||||||
return EXPREGS[2];
|
|
||||||
return CartBR(A);
|
return CartBR(A);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(M432Write) {
|
static DECLFW(M432Write) {
|
||||||
EXPREGS[A & 1] = V;
|
EXPREGS[A & 1] = V;
|
||||||
if (~A &1 && ~V &1 && ROM_size <64) EXPREGS[1] &=~0x20; /* Writing 0 to register 0 clears register 1's DIP bit */
|
|
||||||
FixMMC3PRG(MMC3_cmd);
|
FixMMC3PRG(MMC3_cmd);
|
||||||
FixMMC3CHR(MMC3_cmd);
|
FixMMC3CHR(MMC3_cmd);
|
||||||
}
|
}
|
||||||
@@ -66,6 +66,7 @@ static void M432Power(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mapper432_Init(CartInfo *info) {
|
void Mapper432_Init(CartInfo *info) {
|
||||||
|
submapper =info->submapper;
|
||||||
GenMMC3_Init(info, 256, 256, 0, 0);
|
GenMMC3_Init(info, 256, 256, 0, 0);
|
||||||
cwrap = M432CW;
|
cwrap = M432CW;
|
||||||
pwrap = M432PW;
|
pwrap = M432PW;
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ static void M61Sync(void) {
|
|||||||
setprg16(0xC000, ((latche & 0xF) << 1) | (((latche & 0x20) >> 4)));
|
setprg16(0xC000, ((latche & 0xF) << 1) | (((latche & 0x20) >> 4)));
|
||||||
} else
|
} else
|
||||||
setprg32(0x8000, latche & 0xF);
|
setprg32(0x8000, latche & 0xF);
|
||||||
setchr8(0);
|
setchr8(latche >> 8);
|
||||||
setmirror(((latche >> 7) & 1) ^ 1);
|
setmirror(((latche >> 7) & 1) ^ 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -263,28 +263,19 @@ static void M200Sync(void) {
|
|||||||
|
|
||||||
void Mapper200_Init(CartInfo *info) {
|
void Mapper200_Init(CartInfo *info) {
|
||||||
submapper = info->submapper;
|
submapper = info->submapper;
|
||||||
Latch_Init(info, M200Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0);
|
Latch_Init(info, M200Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------ Map 201 ---------------------------*/
|
/*------------------ Map 201 ---------------------------*/
|
||||||
/* 2020-3-6 - Support for 21-in-1 (CF-043) (2006-V) (Unl) [p1].nes which has mixed mirroring
|
/* 2020-3-6 - Support for 21-in-1 (CF-043) (2006-V) (Unl) [p1].nes which has mixed mirroring
|
||||||
* found at the time labeled as submapper 15
|
NRS: No, all it needs is fixed horizontal mirroring. */
|
||||||
* 0x05658DED 128K PRG, 32K CHR */
|
|
||||||
static void M201Sync(void) {
|
static void M201Sync(void) {
|
||||||
if (latche & 8 || submapper == 15) {
|
setprg32(0x8000, latche);
|
||||||
setprg32(0x8000, latche & 3);
|
setchr8(latche);
|
||||||
setchr8(latche & 3);
|
|
||||||
} else {
|
|
||||||
setprg32(0x8000, 0);
|
|
||||||
setchr8(0);
|
|
||||||
}
|
|
||||||
if (submapper == 15)
|
|
||||||
setmirror(((latche & 0x07) == 0x07) ? MI_V : MI_H);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper201_Init(CartInfo *info) {
|
void Mapper201_Init(CartInfo *info) {
|
||||||
submapper = info->submapper;
|
Latch_Init(info, M201Sync, NULL, 0x0000, 0x8000, 0xFFFF, 0);
|
||||||
Latch_Init(info, M201Sync, NULL, 0xFFFF, 0x8000, 0xFFFF, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------ Map 202 ---------------------------*/
|
/*------------------ Map 202 ---------------------------*/
|
||||||
@@ -404,8 +395,7 @@ static void M227Sync(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasBattery && (latche & 0x80) == 0x80)
|
if (latche &0x80 && submapper >0) /* CHR-RAM write protection not used on single-game cartridges (submapper 0) */
|
||||||
/* CHR-RAM write protect hack, needed for some multicarts */
|
|
||||||
SetupCartCHRMapping(0, CHRptr[0], 0x2000, 0);
|
SetupCartCHRMapping(0, CHRptr[0], 0x2000, 0);
|
||||||
else
|
else
|
||||||
SetupCartCHRMapping(0, CHRptr[0], 0x2000, 1);
|
SetupCartCHRMapping(0, CHRptr[0], 0x2000, 1);
|
||||||
@@ -416,7 +406,7 @@ static void M227Sync(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DECLFR(M227Read) {
|
static DECLFR(M227Read) {
|
||||||
if (latche &0x0400)
|
if (latche &0x0400 && submapper ==1) /* Support DIP switch/solder pad only with submapper 1 multicarts */
|
||||||
return CartBR(A | dipswitch);
|
return CartBR(A | dipswitch);
|
||||||
else
|
else
|
||||||
return CartBR(A);
|
return CartBR(A);
|
||||||
@@ -430,6 +420,7 @@ static void Mapper227_Reset(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mapper227_Init(CartInfo *info) {
|
void Mapper227_Init(CartInfo *info) {
|
||||||
|
dipswitch = 0;
|
||||||
submapper =info->submapper;
|
submapper =info->submapper;
|
||||||
Latch_Init(info, M227Sync, M227Read, 0x0000, 0x8000, 0xFFFF, info->iNES2 && (info->PRGRamSize || info->PRGRamSaveSize) || info->battery);
|
Latch_Init(info, M227Sync, M227Read, 0x0000, 0x8000, 0xFFFF, info->iNES2 && (info->PRGRamSize || info->PRGRamSaveSize) || info->battery);
|
||||||
info->Reset = Mapper227_Reset;
|
info->Reset = Mapper227_Reset;
|
||||||
@@ -528,7 +519,7 @@ static void M242Sync(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DECLFR(M242Read) {
|
static DECLFR(M242Read) {
|
||||||
if (latche &0x0100)
|
if (latche &0x0100 && (latche &0x00FF) ==0)
|
||||||
return CartBR(A | dipswitch);
|
return CartBR(A | dipswitch);
|
||||||
else
|
else
|
||||||
return CartBR(A);
|
return CartBR(A);
|
||||||
@@ -542,6 +533,7 @@ static void Mapper242_Reset(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Mapper242_Init(CartInfo *info) {
|
void Mapper242_Init(CartInfo *info) {
|
||||||
|
dipswitch = 0;
|
||||||
M242TwoChips = info->PRGRomSize &0x20000 && info->PRGRomSize >0x20000;
|
M242TwoChips = info->PRGRomSize &0x20000 && info->PRGRomSize >0x20000;
|
||||||
Latch_Init(info, M242Sync, M242Read, 0x0000, 0x8000, 0xFFFF, info->iNES2 && (info->PRGRamSize || info->PRGRamSaveSize) || info->battery);
|
Latch_Init(info, M242Sync, M242Read, 0x0000, 0x8000, 0xFFFF, info->iNES2 && (info->PRGRamSize || info->PRGRamSaveSize) || info->battery);
|
||||||
info->Reset = Mapper242_Reset;
|
info->Reset = Mapper242_Reset;
|
||||||
@@ -554,8 +546,8 @@ void Mapper242_Init(CartInfo *info) {
|
|||||||
* - 64-in-1 (CF-015)
|
* - 64-in-1 (CF-015)
|
||||||
*/
|
*/
|
||||||
static void M288Sync(void) {
|
static void M288Sync(void) {
|
||||||
setchr8(latche & 7);
|
setchr8(latche);
|
||||||
setprg32(0x8000, (latche >> 3) & 3);
|
setprg32(0x8000, latche >> 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFR(M288Read) {
|
static DECLFR(M288Read) {
|
||||||
|
|||||||
@@ -563,7 +563,13 @@ static void M47CW(uint32 A, uint8 V) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DECLFW(M47Write) {
|
static DECLFW(M47Write) {
|
||||||
EXPREGS[0] = V & 1;
|
EXPREGS[0] = V;
|
||||||
|
FixMMC3PRG(MMC3_cmd);
|
||||||
|
FixMMC3CHR(MMC3_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void M47Reset(void) {
|
||||||
|
EXPREGS[0] = 0;
|
||||||
FixMMC3PRG(MMC3_cmd);
|
FixMMC3PRG(MMC3_cmd);
|
||||||
FixMMC3CHR(MMC3_cmd);
|
FixMMC3CHR(MMC3_cmd);
|
||||||
}
|
}
|
||||||
@@ -579,6 +585,7 @@ void Mapper47_Init(CartInfo *info) {
|
|||||||
GenMMC3_Init(info, 512, 256, 8, 0);
|
GenMMC3_Init(info, 512, 256, 8, 0);
|
||||||
pwrap = M47PW;
|
pwrap = M47PW;
|
||||||
cwrap = M47CW;
|
cwrap = M47CW;
|
||||||
|
info->Reset = M47Reset;
|
||||||
info->Power = M47Power;
|
info->Power = M47Power;
|
||||||
AddExState(EXPREGS, 1, 0, "EXPR");
|
AddExState(EXPREGS, 1, 0, "EXPR");
|
||||||
}
|
}
|
||||||
@@ -667,7 +674,7 @@ static void M52CW(uint32 A, uint8 V) {
|
|||||||
static void M52S14CW(uint32 A, uint8 V) {
|
static void M52S14CW(uint32 A, uint8 V) {
|
||||||
uint32 mask = 0xFF ^ ((EXPREGS[0] & 0x40) << 1);
|
uint32 mask = 0xFF ^ ((EXPREGS[0] & 0x40) << 1);
|
||||||
uint32 bank = EXPREGS[0] <<3 &0x80 | EXPREGS[0] <<7 &0x300;
|
uint32 bank = EXPREGS[0] <<3 &0x80 | EXPREGS[0] <<7 &0x300;
|
||||||
if (EXPREGS[0] &0x20)
|
if (CHRRAM && EXPREGS[0] &0x20)
|
||||||
setchr1r(0x10, A, bank | (V & mask));
|
setchr1r(0x10, A, bank | (V & mask));
|
||||||
else
|
else
|
||||||
setchr1(A, bank | (V & mask));
|
setchr1(A, bank | (V & mask));
|
||||||
@@ -703,7 +710,7 @@ void Mapper52_Init(CartInfo *info) {
|
|||||||
info->Reset = M52Reset;
|
info->Reset = M52Reset;
|
||||||
info->Power = M52Power;
|
info->Power = M52Power;
|
||||||
AddExState(EXPREGS, 2, 0, "EXPR");
|
AddExState(EXPREGS, 2, 0, "EXPR");
|
||||||
if (info->iNES2 && (info->submapper ==13 || info->submapper ==14)) {
|
if (info->iNES2 && info->CHRRomSize && info->CHRRamSize) {
|
||||||
CHRRAMSIZE = 8192;
|
CHRRAMSIZE = 8192;
|
||||||
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
|
CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
|
||||||
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
|
SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
|
||||||
@@ -828,45 +835,48 @@ void Mapper114_Init(CartInfo *info) {
|
|||||||
/* ---------------------------- Mapper 115 KN-658 board ------------------------------ */
|
/* ---------------------------- Mapper 115 KN-658 board ------------------------------ */
|
||||||
|
|
||||||
static void M115PW(uint32 A, uint8 V) {
|
static void M115PW(uint32 A, uint8 V) {
|
||||||
|
int prgOR =EXPREGS[0] &0xF | EXPREGS[0] >>2 &0x10;
|
||||||
if (EXPREGS[0] & 0x80) {
|
if (EXPREGS[0] & 0x80) {
|
||||||
if (EXPREGS[0] & 0x20)
|
if (EXPREGS[0] & 0x20)
|
||||||
setprg32(0x8000, (EXPREGS[0] & 0x0F) >> 1); /* real hardware tests, info 100% now lol */
|
setprg32(0x8000, prgOR >> 1);
|
||||||
else {
|
else {
|
||||||
setprg16(0x8000, (EXPREGS[0] & 0x0F));
|
setprg16(0x8000, prgOR);
|
||||||
setprg16(0xC000, (EXPREGS[0] & 0x0F));
|
setprg16(0xC000, prgOR);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
setprg8(A, V);
|
setprg8(A, V &0x1F | prgOR <<1 &~0x1F);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M115CW(uint32 A, uint8 V) {
|
static void M115CW(uint32 A, uint8 V) {
|
||||||
setchr1(A, (uint32)V | ((EXPREGS[1] & 1) << 8));
|
setchr1(A, V | EXPREGS[1] <<8);
|
||||||
}
|
|
||||||
|
|
||||||
static DECLFW(M115Write) {
|
|
||||||
if (A == 0x5080)
|
|
||||||
EXPREGS[2] = V; /* Extra prot hardware 2-in-1 mode */
|
|
||||||
else if (A == 0x6000)
|
|
||||||
EXPREGS[0] = V;
|
|
||||||
else if (A == 0x6001)
|
|
||||||
EXPREGS[1] = V;
|
|
||||||
FixMMC3PRG(MMC3_cmd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static DECLFR(M115Read) {
|
static DECLFR(M115Read) {
|
||||||
return EXPREGS[2];
|
return (A &3) ==2? EXPREGS[2]: X.DB;
|
||||||
|
}
|
||||||
|
|
||||||
|
static DECLFW(M115Write) {
|
||||||
|
EXPREGS[A &3] =V;
|
||||||
|
FixMMC3PRG(MMC3_cmd);
|
||||||
|
FixMMC3CHR(MMC3_cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void M115Reset(void) {
|
||||||
|
EXPREGS[2]++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void M115Power(void) {
|
static void M115Power(void) {
|
||||||
|
EXPREGS[2] =0;
|
||||||
GenMMC3Power();
|
GenMMC3Power();
|
||||||
SetWriteHandler(0x4100, 0x7FFF, M115Write);
|
SetWriteHandler(0x6000, 0x7FFF, M115Write);
|
||||||
SetReadHandler(0x5000, 0x5FFF, M115Read);
|
SetReadHandler(0x6000, 0x7FFF, M115Read);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mapper115_Init(CartInfo *info) {
|
void Mapper115_Init(CartInfo *info) {
|
||||||
GenMMC3_Init(info, 128, 512, 0, 0);
|
GenMMC3_Init(info, 128, 512, 0, 0);
|
||||||
cwrap = M115CW;
|
cwrap = M115CW;
|
||||||
pwrap = M115PW;
|
pwrap = M115PW;
|
||||||
|
info->Reset = M115Reset;
|
||||||
info->Power = M115Power;
|
info->Power = M115Power;
|
||||||
AddExState(EXPREGS, 3, 0, "EXPR");
|
AddExState(EXPREGS, 3, 0, "EXPR");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,71 +23,59 @@
|
|||||||
|
|
||||||
#include "mapinc.h"
|
#include "mapinc.h"
|
||||||
|
|
||||||
static uint16 cmd, bank;
|
static uint16 reg[2];
|
||||||
|
static uint8 submapper;
|
||||||
|
|
||||||
static SFORMAT StateRegs[] =
|
static SFORMAT StateRegs[] ={
|
||||||
{
|
{ reg, 4 | FCEUSTATE_RLSB, "REGS" },
|
||||||
{ &cmd, 2 | FCEUSTATE_RLSB, "CMD" },
|
|
||||||
{ &bank, 2 | FCEUSTATE_RLSB, "BANK" },
|
|
||||||
{ 0 }
|
{ 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
static void Sync(void) {
|
static DECLFR(Mapper221_ReadOB)
|
||||||
setmirror((cmd & 1) ^ 1);
|
{
|
||||||
|
return X.DB;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void sync(void) {
|
||||||
|
uint8 prg =reg[0] >>(submapper ==1? 2: 3) &0x40 | reg[0] >>2 &0x38 | reg[1] &0x07;
|
||||||
|
SetReadHandler(0x8000, 0xFFFF, prg <<14 >=PRGsize[0]? Mapper221_ReadOB: CartBR); /* Selecting unpopulated banks results in open bus */
|
||||||
|
if (reg[0] &(submapper ==1? 0x200: 0x100)) { /* UNROM */
|
||||||
|
setprg16(0x8000, prg);
|
||||||
|
setprg16(0xC000, prg |7);
|
||||||
|
} else
|
||||||
|
if (reg[0] &0x0002) /* NROM-256 */
|
||||||
|
setprg32(0x8000, prg >>1);
|
||||||
|
else { /* NROM-128 */
|
||||||
|
setprg16(0x8000, prg);
|
||||||
|
setprg16(0xC000, prg);
|
||||||
|
}
|
||||||
setchr8(0);
|
setchr8(0);
|
||||||
if (cmd & 2) {
|
SetupCartCHRMapping(0, CHRptr[0], 0x2000, submapper ==1? !(reg[0] &0x0400): !(reg[1] &0x0008));
|
||||||
if (cmd & 0x100) {
|
setmirror(reg[0] &0x0001? MI_H: MI_V);
|
||||||
setprg16(0x8000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | bank);
|
|
||||||
setprg16(0xC000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | 7);
|
|
||||||
} else {
|
|
||||||
setprg16(0x8000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | (bank & 6));
|
|
||||||
setprg16(0xC000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | ((bank & 6) | 1));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setprg16(0x8000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | bank);
|
|
||||||
setprg16(0xC000, ((cmd & 0x200) >> 3) | ((cmd & 0xfc) >> 2) | bank);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16 ass = 0;
|
static DECLFW(Mapper221Write) {
|
||||||
|
reg[A >>14 &1] =A;
|
||||||
static DECLFW(UNLN625092WriteCommand) {
|
sync();
|
||||||
cmd = A;
|
|
||||||
if (A == 0x80F8) {
|
|
||||||
setprg16(0x8000, ass);
|
|
||||||
setprg16(0xC000, ass);
|
|
||||||
} else {
|
|
||||||
Sync();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static DECLFW(UNLN625092WriteBank) {
|
|
||||||
bank = A & 7;
|
|
||||||
Sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UNLN625092Power(void) {
|
static void UNLN625092Power(void) {
|
||||||
cmd = 0;
|
reg[0] =reg[1] =0;
|
||||||
bank = 0;
|
sync();
|
||||||
Sync();
|
SetWriteHandler(0x8000, 0xFFFF, Mapper221Write);
|
||||||
SetReadHandler(0x8000, 0xFFFF, CartBR);
|
|
||||||
SetWriteHandler(0x8000, 0xBFFF, UNLN625092WriteCommand);
|
|
||||||
SetWriteHandler(0xC000, 0xFFFF, UNLN625092WriteBank);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UNLN625092Reset(void) {
|
static void UNLN625092Reset(void) {
|
||||||
cmd = 0;
|
reg[0] =reg[1] =0;
|
||||||
bank = 0;
|
sync();
|
||||||
ass++;
|
|
||||||
FCEU_printf("%04x\n", ass);
|
|
||||||
Sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void StateRestore(int version) {
|
static void StateRestore(int version) {
|
||||||
Sync();
|
sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
void UNLN625092_Init(CartInfo *info) {
|
void UNLN625092_Init(CartInfo *info) {
|
||||||
|
submapper =info->submapper;
|
||||||
info->Reset = UNLN625092Reset;
|
info->Reset = UNLN625092Reset;
|
||||||
info->Power = UNLN625092Power;
|
info->Power = UNLN625092Power;
|
||||||
GameStateRestore = StateRestore;
|
GameStateRestore = StateRestore;
|
||||||
|
|||||||
@@ -801,6 +801,7 @@ INES_BOARD_BEGIN()
|
|||||||
INES_BOARD( "retroUSB DPCMcart", 409, Mapper409_Init )
|
INES_BOARD( "retroUSB DPCMcart", 409, Mapper409_Init )
|
||||||
INES_BOARD( "JY-302", 410, Mapper410_Init )
|
INES_BOARD( "JY-302", 410, Mapper410_Init )
|
||||||
INES_BOARD( "A88S-1", 411, Mapper411_Init )
|
INES_BOARD( "A88S-1", 411, Mapper411_Init )
|
||||||
|
INES_BOARD( "Henggedianzi FK-206 JG", 412, Mapper412_Init )
|
||||||
INES_BOARD( "9999999-in-1", 414, Mapper414_Init )
|
INES_BOARD( "9999999-in-1", 414, Mapper414_Init )
|
||||||
INES_BOARD( "0353", 415, Mapper415_Init )
|
INES_BOARD( "0353", 415, Mapper415_Init )
|
||||||
INES_BOARD( "4-in-1/N-32", 416, Mapper416_Init )
|
INES_BOARD( "4-in-1/N-32", 416, Mapper416_Init )
|
||||||
|
|||||||
@@ -310,6 +310,7 @@ void Mapper404_Init(CartInfo *);
|
|||||||
void Mapper409_Init(CartInfo *);
|
void Mapper409_Init(CartInfo *);
|
||||||
void Mapper410_Init(CartInfo *);
|
void Mapper410_Init(CartInfo *);
|
||||||
void Mapper411_Init(CartInfo *);
|
void Mapper411_Init(CartInfo *);
|
||||||
|
void Mapper412_Init(CartInfo *);
|
||||||
void Mapper414_Init(CartInfo *);
|
void Mapper414_Init(CartInfo *);
|
||||||
void Mapper415_Init(CartInfo *);
|
void Mapper415_Init(CartInfo *);
|
||||||
void Mapper416_Init(CartInfo *);
|
void Mapper416_Init(CartInfo *);
|
||||||
|
|||||||
Reference in New Issue
Block a user