Merge pull request #519 from NRS-NewRisingSun/mappers4

More multicart mappers
This commit is contained in:
LibretroAdmin
2022-07-28 05:35:46 +02:00
committed by GitHub
12 changed files with 670 additions and 2 deletions

View File

@@ -100,7 +100,7 @@ static void sync () {
setprg32(0x8000, (MMC1_reg[3] &prgAND | prgOR &~prgAND) >>1);
}
chrAND =reg[2] &0x10? 0x1F: reg[2] &0x20? 0x7F: 0xFF;
chrAND =reg[2] &0x10 && ~reg[2] &0x20? 0x1F: reg[2] &0x20? 0x7F: 0xFF;
chrOR =reg[0] <<1;
if (reg[2] &0x01) /* CHR RAM mode */
setchr8r(0x10, 0);
@@ -265,6 +265,11 @@ static DECLFW(writeReg) {
sync();
}
static DECLFW(writeFDSMirroring) {
MMC3_mirroring =V >>3 &1;
sync();
}
static void Mapper351_power(void) {
int i;
for (i =0; i <4; i++) reg[i] =0;
@@ -281,6 +286,7 @@ static void Mapper351_power(void) {
SetReadHandler(0x6000, 0xFFFF, CartBR);
SetReadHandler(0x5000, 0x5FFF, readDIP);
SetWriteHandler(0x5000, 0x5FFF, writeReg);
SetWriteHandler(0x4025, 0x4025, writeFDSMirroring);
applyMode();
sync();
}

68
src/boards/441.c Normal file
View File

@@ -0,0 +1,68 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
*
* 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
*/
/* 850335C PCB */
#include "mapinc.h"
#include "mmc3.h"
static void Mapper441_PRGWrap(uint32 A, uint8 V) {
int prgAND =EXPREGS[0] &0x08? 0x0F: 0x1F;
int prgOR =EXPREGS[0] <<4 &0x30;
if (EXPREGS[0] &0x04) {
if (~A &0x4000) {
setprg8(A, ~2 &V &prgAND | prgOR &~prgAND);
setprg8(A |0x4000, 2 |V &prgAND | prgOR &~prgAND);
}
} else
setprg8(A, V &prgAND | prgOR &~prgAND);
}
static void Mapper441_CHRWrap(uint32 A, uint8 V) {
int chrAND =EXPREGS[0] &0x40? 0x7F: 0xFF;
int chrOR =EXPREGS[0] <<3 &0x180;
setchr1(A, V &chrAND | chrOR &~chrAND);
}
static DECLFW(Mapper441_Write) {
if (~EXPREGS[0] &0x80) EXPREGS[0] =V;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
static void Mapper441_Reset(void) {
EXPREGS[0] =0;
MMC3RegReset();
}
static void Mapper441_Power(void) {
EXPREGS[0] =0;
GenMMC3Power();
SetWriteHandler(0x6000, 0x7FFF, Mapper441_Write);
}
void Mapper441_Init(CartInfo *info) {
GenMMC3_Init(info, 256, 256, 0, 0);
cwrap = Mapper441_CHRWrap;
pwrap = Mapper441_PRGWrap;
info->Power = Mapper441_Power;
info->Reset = Mapper441_Reset;
AddExState(EXPREGS, 1, 0, "EXPR");
}

83
src/boards/449.c Normal file
View File

@@ -0,0 +1,83 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
*
* 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"
static uint16 latchAddr;
static uint8 latchData;
static SFORMAT StateRegs[] =
{
{ &latchAddr, 2, "ADDR" },
{ &latchData, 1, "DATA" },
{ 0 }
};
static void Mapper449_Sync(void)
{
int prg =latchAddr >>2 &0x1F | latchAddr >>3 &0x20;
if (~latchAddr &0x080)
{
setprg16(0x8000, prg);
setprg16(0xC000, prg |7);
}
else
{
if (latchAddr &0x001)
{
setprg32(0x8000, prg >>1);
}
else
{
setprg16(0x8000, prg);
setprg16(0xC000, prg);
}
}
setchr8(latchData);
setmirror(latchAddr &0x002? MI_H: MI_V);
}
static DECLFW(Mapper449_WriteLatch)
{
latchData =V;
latchAddr =A &0xFFFF;
Mapper449_Sync();
}
static void Mapper449_Reset(void)
{
latchAddr =latchData =0;
Mapper449_Sync();
}
static void Mapper449_Power(void)
{
latchAddr =latchData =0;
Mapper449_Sync();
SetWriteHandler(0x8000, 0xFFFF, Mapper449_WriteLatch);
SetReadHandler(0x6000, 0xFFFF, CartBR);
}
void Mapper449_Init(CartInfo *info)
{
info->Power = Mapper449_Power;
info->Reset = Mapper449_Reset;
AddExState(StateRegs, ~0, 0, 0);
}

77
src/boards/455.c Normal file
View File

@@ -0,0 +1,77 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
*
* 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
*/
/* N625836 PCB */
#include "mapinc.h"
#include "mmc3.h"
static void Mapper455_PRGWrap(uint32 A, uint8 V) {
int prgAND =EXPREGS[1] &0x01? 0x1F: 0x0F;
int prgOR =EXPREGS[0] >>2 &0x07 | EXPREGS[1] <<1 &0x08 | EXPREGS[0] >>2 &0x10;
if (EXPREGS[0] &0x01) {
if (EXPREGS[0] &0x02) {
setprg32(0x8000, prgOR >>1);
} else {
setprg16(0x8000, prgOR);
setprg16(0xC000, prgOR);
}
} else {
prgOR <<=1;
setprg8(A, V &prgAND | prgOR &~prgAND);
}
}
static void Mapper455_CHRWrap(uint32 A, uint8 V) {
int chrAND =EXPREGS[1] &0x02? 0xFF: 0x7F;
int chrOR =(EXPREGS[0] >>2 &0x07 | EXPREGS[1] <<1 &0x08 | EXPREGS[0] >>2 &0x10) <<4;
setchr1(A, V &chrAND | chrOR &~chrAND);
}
static DECLFW(Mapper455_Write) {
if (A &0x100) {
EXPREGS[0] =V;
EXPREGS[1] =A &0xFF;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
}
static void Mapper455_Reset(void) {
EXPREGS[0] =1;
EXPREGS[1] =0;
MMC3RegReset();
}
static void Mapper455_Power(void) {
EXPREGS[0] =1;
EXPREGS[1] =0;
GenMMC3Power();
SetWriteHandler(0x4100, 0x5FFF, Mapper455_Write);
}
void Mapper455_Init(CartInfo *info) {
GenMMC3_Init(info, 256, 256, 0, 0);
cwrap = Mapper455_CHRWrap;
pwrap = Mapper455_PRGWrap;
info->Power = Mapper455_Power;
info->Reset = Mapper455_Reset;
AddExState(EXPREGS, 2, 0, "EXPR");
}

94
src/boards/460.c Normal file
View File

@@ -0,0 +1,94 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
*
* 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 uint8 *CHRRAM =NULL;
static DECLFR(Mapper460_ReadOB)
{
return X.DB;
}
static void Mapper460_PRGWrap(uint32 A, uint8 V) {
int prgAND =0x0F;
int prgOR =EXPREGS[0] <<4;
if (EXPREGS[0] &0x20) {
if (~A &0x4000) {
setprg8(A, (EXPREGS[0] &0x10? ~2: ~0) &V &prgAND | prgOR &~prgAND);
setprg8(A |0x4000, (EXPREGS[0] &0x10? 2: 0) |V &prgAND | prgOR &~prgAND);
}
} else
setprg8(A, V &prgAND | prgOR &~prgAND);
/* Menu selection by selectively connecting reg's D7 to PRG /CE or not */
if (EXPREGS[0] &0x80 && EXPREGS[1] &1)
SetReadHandler(0x8000, 0xFFFF, Mapper460_ReadOB);
else
SetReadHandler(0x8000, 0xFFFF, CartBR);
}
static void Mapper460_CHRWrap(uint32 A, uint8 V) {
if (EXPREGS[0] &0x04) {
setchr2(0x0000, DRegBuf[0] &0xFE);
setchr2(0x0800, DRegBuf[0] |0x01);
setchr2(0x1000, DRegBuf[2]);
setchr2(0x1800, DRegBuf[5]);
} else
setchr8r(0x10, 0);
}
static DECLFW(Mapper460_WriteExtra) {
if (A001B &0x80 && ~A001B &0x40) EXPREGS[0] =A &0xFF;
FixMMC3PRG(MMC3_cmd);
FixMMC3CHR(MMC3_cmd);
}
static void Mapper460_Reset(void) {
EXPREGS[0] =0;
EXPREGS[1]++;
MMC3RegReset();
}
static void Mapper460_Power(void) {
EXPREGS[0] =0;
EXPREGS[1] =0;
GenMMC3Power();
SetWriteHandler(0x6000, 0x7FFF, Mapper460_WriteExtra);
}
static void Mapper460_close(void) {
if (CHRRAM) FCEU_gfree(CHRRAM);
CHRRAM =NULL;
}
void Mapper460_Init(CartInfo *info) {
GenMMC3_Init(info, 128, 512, 0, 0);
cwrap = Mapper460_CHRWrap;
pwrap = Mapper460_PRGWrap;
info->Power = Mapper460_Power;
info->Reset = Mapper460_Reset;
info->Close = Mapper460_close;
AddExState(EXPREGS, 2, 0, "EXPR");
CHRRAM =(uint8 *)FCEU_gmalloc(8192);
SetupCartCHRMapping(0x10, CHRRAM, 8192, 1);
AddExState(CHRRAM, 8192, 0, "CRAM");
}

77
src/boards/463.c Normal file
View File

@@ -0,0 +1,77 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
*
* 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"
static uint8 regs[4] = { 0 };
static uint8 dipswitch = 0;
static SFORMAT StateRegs[] = {
{ regs, 4, "EXPR" },
{ &dipswitch, 1, "DPSW" },
{ 0 }
};
static void Mapper463_Sync(void)
{
if (regs[0] &4)
{
setprg16(0x8000, regs[1]);
setprg16(0xC000, regs[1]);
}
else
{
setprg32(0x8000, regs[1] >>1);
}
setchr8(regs[2]);
setmirror(regs[0] &1? MI_H: MI_V);
}
static DECLFW(Mapper463_Write5000)
{
if (A &(0x10 << dipswitch))
{
regs[A &3] =V;
Mapper463_Sync();
}
}
static void Mapper463_Reset(void)
{
dipswitch =(dipswitch +1) &7;
regs[0] =regs[1] =regs[2] =regs[3] =0;
Mapper463_Sync();
}
static void Mapper463_Power(void)
{
dipswitch =0;
regs[0] =regs[1] =regs[2] =regs[3] =0;
Mapper463_Sync();
SetWriteHandler(0x5000, 0x5FFF, Mapper463_Write5000);
SetReadHandler(0x6000, 0xFFFF, CartBR);
}
void Mapper463_Init(CartInfo *info)
{
info->Power = Mapper463_Power;
info->Reset = Mapper463_Reset;
AddExState(StateRegs, ~0, 0, 0);
}

89
src/boards/465.c Normal file
View File

@@ -0,0 +1,89 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
*
* 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"
static uint16 latchAddr;
static uint8 latchData;
static SFORMAT StateRegs[] =
{
{ &latchAddr, 2, "ADDR" },
{ &latchData, 1, "DATA" },
{ 0 }
};
static void Mapper465_Sync(void)
{
int prg =latchAddr >>2 &0x1F | latchAddr >>5 &0x20;
if (latchAddr &0x200)
{
setprg16(0x8000, prg &~7 | latchData &7);
setprg16(0xC000, prg | 7);
}
else
{
if (latchAddr &0x001)
{
setprg32(0x8000, prg >>1);
}
else
{
setprg16(0x8000, prg);
setprg16(0xC000, prg);
}
}
setchr8(0);
setmirror(latchAddr &0x002? MI_H: MI_V);
}
static DECLFW(Mapper465_WriteLatch)
{
if (latchAddr &0x200)
{
latchData =V;
}
else
{
latchAddr =A &0xFFFF;
}
Mapper465_Sync();
}
static void Mapper465_Reset(void)
{
latchAddr =latchData =0;
Mapper465_Sync();
}
static void Mapper465_Power(void)
{
latchAddr =latchData =0;
Mapper465_Sync();
SetWriteHandler(0x8000, 0xFFFF, Mapper465_WriteLatch);
SetReadHandler(0x6000, 0xFFFF, CartBR);
}
void Mapper465_Init(CartInfo *info)
{
info->Power = Mapper465_Power;
info->Reset = Mapper465_Reset;
AddExState(StateRegs, ~0, 0, 0);
}

100
src/boards/466.c Normal file
View File

@@ -0,0 +1,100 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022
*
* 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"
static uint8 regs[3];
static SFORMAT StateRegs[] =
{
{ regs, 3, "EXPR" },
{ 0 }
};
static DECLFR(Mapper466_ReadOB)
{
return X.DB;
}
static void Mapper466_Sync(void)
{
int prg =regs[1] <<5 | regs[0] <<1 &0x1E | regs[0] >>5 &1;
/* Return open bus when selecting unpopulated PRG chip */
if (prg &0x20 && PRGsize[0] <1024*1024)
SetReadHandler(0x8000, 0xFFFF, Mapper466_ReadOB);
else
SetReadHandler(0x8000, 0xFFFF, CartBR);
if (regs[0] &0x40)
{
if (regs[0] &0x10)
{
setprg16(0x8000, prg);
setprg16(0xC000, prg);
}
else
{
setprg32(0x8000, prg >>1);
}
}
else
{
setprg16(0x8000, prg &~7 | regs[2] &7);
setprg16(0xC000, prg &~7 | 7);
}
setprg8r(0x10, 0x6000, 0);
setchr8(0);
setmirror(regs[0] &0x80? MI_H: MI_V);
}
static DECLFW(Mapper466_Write5000)
{
regs[A >>11 &1] =A &0xFF;
Mapper466_Sync();
}
static DECLFW(Mapper466_WriteLatch)
{
regs[2] =V;
Mapper466_Sync();
}
static void Mapper466_Reset(void)
{
regs[0] =regs[1] =0;
Mapper466_Sync();
}
static void Mapper466_Power(void)
{
regs[0] =regs[1] =0;
Mapper466_Sync();
SetWriteHandler(0x5000, 0x5FFF, Mapper466_Write5000);
SetWriteHandler(0x8000, 0xFFFF, Mapper466_WriteLatch);
SetReadHandler(0x6000, 0xFFFF, CartBR);
}
void Mapper466_Init(CartInfo *info)
{
info->Power = Mapper466_Power;
info->Reset = Mapper466_Reset;
AddExState(StateRegs, ~0, 0, 0);
}

View File

@@ -757,3 +757,57 @@ static void M435Sync(void) {
void Mapper435_Init(CartInfo *info) {
Latch_Init(info, M435Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1);
}
/*------------------ Map 459 ---------------------------*/
static void M459Sync(void) {
int p =latche >>5;
int c =latche &0x03 | latche >>2 &0x04 | latche >>4 &0x08;
if (latche &0x04) {
setprg32(0x8000, p);
} else {
setprg16(0x8000, p <<1);
setprg16(0xC000, p <<1 |7);
}
setchr8(c &(latche &0x08? 0x0F: 0x08));
setmirror(latche &0x100? MI_H: MI_V);
}
void Mapper459_Init(CartInfo *info) {
Latch_Init(info, M459Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1);
}
/*------------------ Map 461 ---------------------------*/
static void M461Sync(void) {
int p =latche <<1 | latche >>5 &1;
int c =latche >>8;
if (latche &0x10) {
setprg16(0x8000, p);
setprg16(0xC000, p);
} else {
setprg32(0x8000, p >>1);
}
setchr8(c);
setmirror(latche &0x80? MI_H: MI_V);
}
void Mapper461_Init(CartInfo *info) {
Latch_Init(info, M461Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1);
}
/*------------------ Map 464 ---------------------------*/
static void M464Sync(void) {
int p =latche >>7;
int c =latche &0x1F;
if (latche &0x40) {
setprg32(0x8000, p >> 1);
} else {
setprg16(0x8000, p);
setprg16(0xC000, p);
}
setchr8(c);
setmirror(latche &0x20? MI_H: MI_V);
}
void Mapper464_Init(CartInfo *info) {
Latch_Init(info, M464Sync, NULL, 0x0000, 0x8000, 0xFFFF, 1);
}

View File

@@ -587,7 +587,7 @@ void BMCK3046_Init(CartInfo *info) {
static void Mapper429_Sync(void) {
setprg32(0x8000, latche >>2);
setchr8(latche &3);
setchr8(latche);
}
static void Mapper429_Reset(void) {

View File

@@ -815,10 +815,20 @@ INES_BOARD_BEGIN()
INES_BOARD( "820401/T-217", 436, Mapper436_Init )
INES_BOARD( "NTDEC TH2348", 437, Mapper437_Init )
INES_BOARD( "K-3071", 438, Mapper438_Init )
INES_BOARD( "850335C", 441, Mapper441_Init )
INES_BOARD( "NC-3000M", 443, Mapper443_Init )
INES_BOARD( "NC-7000M/NC-8000M", 444, Mapper444_Init )
INES_BOARD( "22-in-1 King Series", 449, Mapper449_Init )
INES_BOARD( "DS-9-27", 452, Mapper452_Init )
INES_BOARD( "N625836", 455, Mapper455_Init )
INES_BOARD( "K6C3001A", 456, Mapper456_Init )
INES_BOARD( "8-in-1", 459, Mapper459_Init )
INES_BOARD( "FC-29-40/K-3101", 460, Mapper460_Init )
INES_BOARD( "0324", 461, Mapper461_Init )
INES_BOARD( "YH810X1", 463, Mapper463_Init )
INES_BOARD( "NTDEC 9012", 464, Mapper464_Init )
INES_BOARD( "ET-120", 465, Mapper465_Init )
INES_BOARD( "Keybyte Computer", 466, Mapper466_Init )
INES_BOARD( "47-2", 467, Mapper467_Init )
INES_BOARD( "SA-9602B", 513, SA9602B_Init )
INES_BOARD( "Brilliant Com Cocoma Pack", 516, Mapper516_Init )

View File

@@ -323,10 +323,20 @@ void Mapper435_Init(CartInfo *);
void Mapper436_Init(CartInfo *);
void Mapper437_Init(CartInfo *);
void Mapper438_Init(CartInfo *);
void Mapper441_Init(CartInfo *);
void Mapper443_Init(CartInfo *);
void Mapper444_Init(CartInfo *);
void Mapper449_Init(CartInfo *);
void Mapper452_Init(CartInfo *);
void Mapper455_Init(CartInfo *);
void Mapper456_Init(CartInfo *);
void Mapper459_Init(CartInfo *);
void Mapper460_Init(CartInfo *);
void Mapper461_Init(CartInfo *);
void Mapper463_Init(CartInfo *);
void Mapper464_Init(CartInfo *);
void Mapper465_Init(CartInfo *);
void Mapper466_Init(CartInfo *);
void Mapper467_Init(CartInfo *);
void Mapper516_Init(CartInfo *);
void Mapper523_Init(CartInfo *);