Add mappers 382, 534, 539

This commit is contained in:
negativeExponent
2020-02-05 12:00:54 +08:00
parent 43ca4755bb
commit 7ba3350900
5 changed files with 306 additions and 2 deletions

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

@@ -0,0 +1,98 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2020 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 382 - denotes the 830928C circuit board,
* used on a 512 KiB 5-in-1 and a 1 MiB 9-in-1 multicart containing
* the BNROM game Journey to the West and Capcom/Konami UNROM games.
*/
#include "mapinc.h"
static uint8 preg[2];
static uint8 mode;
static uint8 mirr;
static uint8 lock;
static SFORMAT StateRegs[] = {
{ &preg[0], 1, "PRG0" },
{ &preg[1], 1, "PRG1" },
{ &mode, 1, "MODE" },
{ &mirr, 1, "MIRR" },
{ &lock, 1, "LOCK" },
{ 0 }
};
static void Sync(void) {
switch (mode) {
case 1:
/* bnrom */
setprg32(0x8000, (preg[1] << 2) | (preg[0] & 3));
break;
default:
/* unrom */
setprg16(0x8000, (preg[1] << 3) | (preg[0] & 7));
setprg16(0xC000, (preg[1] << 3) | 7);
break;
}
setchr8(0);
setmirror(mirr ^ 1);
/* FCEU_printf("inB[0]:%02x outB[1]:%02x mode:%02x mirr:%02x lock:%02x\n", preg[0], preg[1], mode, mirr, lock); */
}
static DECLFW(M382Write) {
if (!lock) {
preg[1] = (A & 0x07);
mode = (A & 0x08) >> 3;
mirr = (A & 0x10) >> 4;
lock = (A & 0x20) >> 5;
}
/* inner bank subject to bus conflicts */
preg[0] = V & CartBR(A);
Sync();
}
static void M382Power(void) {
preg[0] = preg[1] = 0;
mode = 0;
mirr = 0;
lock = 0;
Sync();
SetReadHandler(0x8000, 0xFFFF, CartBR);
SetWriteHandler(0x8000, 0xFFFF, M382Write);
}
static void M382Reset(void) {
preg[1] = 0;
mode = 0;
mirr = 0;
lock = 0;
Sync();
}
static void StateRestore(int version) {
Sync();
}
void Mapper382_Init(CartInfo* info) {
info->Power = M382Power;
info->Reset = M382Reset;
GameStateRestore = StateRestore;
AddExState(&StateRegs, ~0, 0, 0);
}

99
src/boards/534.c Normal file
View File

@@ -0,0 +1,99 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2020 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 534 - 2-in-1 数独/五子棋 (Sudoku/Gomoku, NJ064) */
#include "mapinc.h"
#include "mmc3.h"
static uint32 GetPRGBank(uint32 bank)
{
if (~bank & 1 && (MMC3_cmd & 0x40)) bank ^= 2;
return (bank & 2) ? (0xFE | (bank & 1)) : DRegBuf[6 | (bank & 1)];
}
void SyncPRG_GNROM(int A14, int AND, int OR) {
setprg8(0x8000, (GetPRGBank(0) & ~A14) & AND | OR);
setprg8(0xA000, (GetPRGBank(1) & ~A14) & AND | OR);
setprg8(0xC000, (GetPRGBank(0) | A14) & AND | OR);
setprg8(0xE000, (GetPRGBank(1) | A14) & AND | OR);
}
static void M534PW(uint32 A, uint8 V) {
if (EXPREGS[0] & 0x40)
SyncPRG_GNROM(EXPREGS[3] & 0x02, 0x0F, ((EXPREGS[0] & 3) << 4));
else
setprg8(A, (V & 0x1F) | ((EXPREGS[0] & 0x2) << 4));
}
static void M534CW(uint32 A, uint8 V) {
setchr1(A, (V & 0xFF) | ((EXPREGS[2] & 0x0F) << 3) | ((EXPREGS[0] & 0x18) << 4));
}
static DECLFR(M534Read) {
if (EXPREGS[1] & 0x01)
return (EXPREGS[4] | (X.DB & ~0x03));
else
return CartBR(A);
}
static DECLFW(M534IRQWrite) {
MMC3_IRQWrite(0xC000 | (A & 1), V ^ 0xFF);
}
static DECLFW(M534WriteLo) {
if ((A & 0x800) && (!(EXPREGS[3] & 0x80) || (A & 3) == 2)) {
EXPREGS[A & 3] = V;
FixMMC3CHR(MMC3_cmd);
FixMMC3PRG(MMC3_cmd);
}
}
static void M534Power(void) {
EXPREGS[0] = 0x00;
EXPREGS[1] = 0x00;
EXPREGS[2] = 0x00;
EXPREGS[3] = 0x00;
GenMMC3Power();
SetWriteHandler(0x6000, 0x6FFF, M534WriteLo);
SetWriteHandler(0xC000, 0xDFFF, M534IRQWrite);
}
static void M534Reset(void) {
EXPREGS[0] = 0x00;
EXPREGS[1] = 0x00;
EXPREGS[2] = 0x00;
EXPREGS[3] = 0x00;
EXPREGS[4] = (EXPREGS[4] + 1) & 7;
FCEU_printf("dipswitch = %d\n", EXPREGS[4]);
MMC3RegReset();
}
static void M534Close(void) {
}
void Mapper534_Init(CartInfo *info) {
GenMMC3_Init(info, 512, 512, 0, 0);
pwrap = M534PW;
cwrap = M534CW;
info->Power = M534Power;
info->Reset = M534Reset;
info->Close = M534Close;
AddExState(EXPREGS, 5, 0, "EXPR");
}

101
src/boards/539.c Normal file
View File

@@ -0,0 +1,101 @@
/* FCEUmm - NES/Famicom Emulator
*
* Copyright notice for this file:
* Copyright (C) 2020 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.
*/
#include "mapinc.h"
static uint8 preg;
static uint8 mirr;
static uint8 WRAM[8192];
static SFORMAT StateRegs[] =
{
{ &preg, 1, "PREG" },
{ &mirr, 1, "MIRR" }
};
static uint32 GetWRAMAddress(uint32 A) {
return ((A & 0x1FFF) |
((A < 0xC000) ? 0x1000 : 0x0000) |
((A < 0x8000) ? 0x0800 : 0x000));
}
static void Sync(void) {
setprg8(0x6000, 13);
setprg8(0x8000, 12);
setprg8(0xA000, preg);
setprg8(0xC000, 14);
setprg8(0xE000, 15);
setchr8(0);
setmirror(((mirr & 8) >> 3) ^ 1);
}
static DECLFR(M539Read) {
switch (A >> 8) {
case 0x60: case 0x62: case 0x64: case 0x65: case 0x82: case 0xC0: case 0xC1: case 0xC2:
case 0xC3: case 0xC4: case 0xC5: case 0xC6: case 0xC7: case 0xC8: case 0xC9: case 0xCA:
case 0xCB: case 0xCC: case 0xCD: case 0xCE: case 0xCF: case 0xD0: case 0xD1: case 0xDF:
return WRAM[GetWRAMAddress(A)];
default:
return CartBR(A);
}
}
static DECLFW(M539Write) {
switch (A >> 8) {
case 0x60: case 0x62: case 0x64: case 0x65: case 0x82: case 0xC0: case 0xC1: case 0xC2:
case 0xC3: case 0xC4: case 0xC5: case 0xC6: case 0xC7: case 0xC8: case 0xC9: case 0xCA:
case 0xCB: case 0xCC: case 0xCD: case 0xCE: case 0xCF: case 0xD0: case 0xD1: case 0xDF:
WRAM[GetWRAMAddress(A)] = V;
break;
default:
switch (A & 0xF000) {
case 0xA000:
preg = V;
Sync();
break;
case 0xF000:
if ((A & 0x25) == 0x25) {
mirr = V;
Sync();
}
break;
}
break;
}
}
static void M539Power(void) {
preg = 0;
mirr = 0;
Sync();
SetReadHandler(0x6000, 0xFFFF, M539Read);
SetWriteHandler(0x6000, 0xFFFF, M539Write);
}
static void StateRestore(int version) {
Sync();
}
void Mapper539_Init(CartInfo *info) {
info->Power = M539Power;
GameStateRestore = StateRestore;
AddExState(WRAM, 8192, 0, "WRAM");
AddExState(&StateRegs, ~0, 0, 0);
}

View File

@@ -668,11 +668,14 @@ static BMAPPINGLocal bmap[] = {
{(uint8_t*)"Realtec 8031", 390, Mapper390_Init },
{(uint8_t*)"60-1064-16L (FDS)", 538, Mapper538_Init },
{(uint8_t*)"LittleCom 160-in-1", 541, Mapper541_Init },
{(uint8_t*)"8-in-1 JY-119", 267, Mapper267_Init },
{(uint8_t*)"8-in-1 JY-119", 267, Mapper267_Init },
{(uint8_t*)"MMC3 BMC PIRATE", 294, Bs5652_Init}, /* nesdev redirects this as mapper 134 */
{(uint8_t*)"TXC 01-22110-000", 297, Mapper297_Init},
{(uint8_t*)"Bitcorp 31-in-1", 360, Mapper360_Init},
{(uint8_t*)"Sachen 3014", 533, Mapper533_Init},
{(uint8_t*)"Sachen 3014", 533, Mapper533_Init},
{(uint8_t*)"830928C", 382, Mapper382_Init},
{(uint8_t*)"NJ064", 534, Mapper534_Init},
{(uint8_t*)"Kid Ikarus (FDS)", 539, Mapper539_Init},
/* UNIF to NES 2.0 BOARDS */

View File

@@ -250,10 +250,13 @@ void Mapper357_Init(CartInfo *);
void Mapper360_Init(CartInfo *);
void Mapper372_Init(CartInfo *);
void Mapper374_Init(CartInfo *);
void Mapper382_Init(CartInfo *);
void Mapper381_Init(CartInfo *);
void Mapper390_Init(CartInfo *);
void Mapper533_Init(CartInfo *);
void Mapper534_Init(CartInfo *);
void Mapper538_Init(CartInfo *);
void Mapper539_Init(CartInfo *);
void Mapper541_Init(CartInfo *);
#endif