Add mappers 326, 330

This commit is contained in:
negativeExponent
2022-02-17 16:02:40 +08:00
parent 4f022827b0
commit d14b2aa0cf
4 changed files with 239 additions and 0 deletions

98
src/boards/326.c Normal file
View File

@@ -0,0 +1,98 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022 negativeExponent
*
* 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
*
* NES 2.0 Mapper 326 is used for a bootleg version of Contra/Gryzor.
* as implemented from
* http://forums.nesdev.org/viewtopic.php?f=9&t=17352&p=218722#p218722
*/
#include "mapinc.h"
static uint8 PRG[3], CHR[8], NTAPage[4];
static SFORMAT StateRegs[] =
{
{ PRG, 3, "PRG" },
{ CHR, 8, "CHR" },
{ NTAPage, 4, "NT" },
{ 0 }
};
static void SyncPRG(void) {
setprg8(0x8000, PRG[0]);
setprg8(0xA000, PRG[1]);
setprg8(0xC000, PRG[2]);
setprg8(0xE000, ~0);
}
static void DoCHR(int x, uint8 V) {
CHR[x] = V;
setchr1(x << 10, V);
}
static void FixCHR(void) {
int x;
for (x = 0; x < 8; x++)
DoCHR(x, CHR[x]);
}
static void FASTAPASS(2) DoNTARAM(int w, uint8 V) {
NTAPage[w] = V;
setntamem(NTARAM + ((V & 1) << 10), 1, w);
}
static void FixNTAR(void) {
int x;
for (x = 0; x < 4; x++)
DoNTARAM(x, NTAPage[x]);
}
static DECLFW(M326Write) {
switch (A & 0xE010) {
case 0x8000: PRG[0] = V; SyncPRG(); break;
case 0xA000: PRG[1] = V; SyncPRG(); break;
case 0xC000: PRG[2] = V; SyncPRG(); break;
}
A &= 0x801F;
if ((A >= 0x8010) && (A <= 0x8017))
DoCHR(A - 0x8010, V);
else if ((A >= 0x8018) && (A <= 0x801B))
DoNTARAM(A - 0x8018, V);
}
static void M326Power(void) {
SyncPRG();
FixCHR();
FixNTAR();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, M326Write);
}
static void StateRestore(int version) {
SyncPRG();
FixCHR();
FixNTAR();
}
void Mapper326_Init(CartInfo *info) {
info->Power = M326Power;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

137
src/boards/330.c Normal file
View File

@@ -0,0 +1,137 @@
/* FCE Ultra - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2022 negativeExponent
*
* 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
*
* NES 2.0 Mapper 330 is used for a bootleg version of Contra/Gryzor.
* as implemented from
* http://forums.nesdev.org/viewtopic.php?f=9&t=17352&p=218722#p218722
*/
#include "mapinc.h"
static uint8 *WRAM;
static uint8 PRG[3], CHR[8], NTAPage[4];
static uint8 IRQa;
static uint16 IRQCount;
static SFORMAT StateRegs[] =
{
{ PRG, 3, "PRG" },
{ CHR, 8, "CHR" },
{ NTAPage, 4, "NT" },
{ &IRQa, 1, "IRQA" },
{ &IRQCount, 2, "IRQC" },
{ 0 }
};
static void SyncPRG(void) {
setprg8(0x8000, PRG[0]);
setprg8(0xA000, PRG[1]);
setprg8(0xC000, PRG[2]);
setprg8(0xE000, ~0);
}
static void DoCHR(int x, uint8 V) {
CHR[x] = V;
setchr1(x << 10, V);
}
static void FixCHR(void) {
int x;
for (x = 0; x < 8; x++)
DoCHR(x, CHR[x]);
}
static void FASTAPASS(2) DoNTARAM(int w, uint8 V) {
NTAPage[w] = V;
setntamem(NTARAM + ((V & 1) << 10), 1, w);
}
static void FixNTAR(void) {
int x;
for (x = 0; x < 4; x++)
DoNTARAM(x, NTAPage[x]);
}
static DECLFW(M330Write) {
if (!(A & 0x400)) {
if (A >= 0x8000 && A <= 0xB800)
DoCHR((A - 0x8000) >> 11, V);
else if (A >= 0xC000 && A <= 0xD800)
DoNTARAM((A - 0xC000) >> 11, V);
else if (A >= 0xE000 && A <= 0xF000) {
PRG[(A - 0xE000) >> 11] = V;
SyncPRG();
}
} else if ((A < 0xC000) && !(A & 0x4000)) {
if (A & 0x2000) {
IRQCount &= 0x00FF;
IRQCount |= (V & 0x7F) << 8;
IRQa = V & 0x80;
X6502_IRQEnd(FCEU_IQEXT);
} else {
IRQCount &= 0xFF00;
IRQCount |= V;
}
}
}
static void M330Power(void) {
int i;
for (i = 0; i < 4; i++)
PRG[i] = i;
for (i = 0; i < 8; i++)
CHR[i] = i;
for (i = 0; i < 4; i++)
NTAPage[i] = ~0;
IRQa = 0;
IRQCount = 0;
SyncPRG();
FixCHR();
FixNTAR();
SetReadHandler(0x6000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, M330Write);
}
static void FP_FASTAPASS(1) M330IRQHook(int a) {
if (IRQa) {
IRQCount += a;
if (IRQCount > 0x7FFF) {
X6502_IRQBegin(FCEU_IQEXT);
IRQa = 0;
IRQCount = 0;
}
}
}
static void StateRestore(int version) {
SyncPRG();
FixCHR();
FixNTAR();
}
void Mapper330_Init(CartInfo *info) {
info->Power = M330Power;
MapIRQHook = M330IRQHook;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
WRAM = (uint8 *)FCEU_gmalloc(8192);
SetupCartPRGMapping(0x10, WRAM, 8192, 1);
AddExState(WRAM, 8192, 0, "WRAM");
}

View File

@@ -730,9 +730,11 @@ INES_BOARD_BEGIN()
INES_BOARD( "FARID_SLROM_8-IN-1", 323, FARIDSLROM8IN1_Init )
INES_BOARD( "FARID_UNROM_8-IN-1", 324, FARIDUNROM_Init )
INES_BOARD( "MALISB", 325, UNLMaliSB_Init )
INES_BOARD( "Contra/Gryzor", 326, Mapper326_Init )
INES_BOARD( "10-24-C-A1", 327, BMC1024CA1_Init )
INES_BOARD( "RT-01", 328, UNLRT01_Init )
INES_BOARD( "EDU2000", 329, UNLEDU2000_Init )
INES_BOARD( "Sangokushi II: Haō no Tairiku", 330, Mapper330_Init )
INES_BOARD( "12-IN-1", 331, BMC12IN1_Init )
INES_BOARD( "WS", 332, BMCWS_Init )
INES_BOARD( "NEWSTAR-GRM070-8IN1", 333, BMC8IN1_Init )

View File

@@ -264,6 +264,8 @@ void Mapper288_Init(CartInfo *);
void Mapper293_Init(CartInfo *);
void Mapper297_Init(CartInfo *);
void Mapper319_Init(CartInfo *);
void Mapper326_Init(CartInfo *);
void Mapper330_Init(CartInfo *);
void Mapper334_Init(CartInfo *);
void Mapper353_Init(CartInfo *);
void Mapper356_Init(CartInfo *);