Add new mappers
Added iNES 1.0/2.0 mappers 134 - replaced Mapper134_init with Bs5652_Init 391 - NC7000M 402 - 831019C J-2282 Added UNIF boards: AB-G1L BS-110 WELL-NO-DG450 KG256
This commit is contained in:
210
src/boards/BS110.c
Normal file
210
src/boards/BS110.c
Normal file
@@ -0,0 +1,210 @@
|
||||
/* FCE Ultra - NES/Famicom Emulator
|
||||
*
|
||||
* Copyright notice for this file:
|
||||
* Copyright (C) 2008 -2020 dragon2snow,loong2snow from www.nesbbs.com
|
||||
*
|
||||
* 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"
|
||||
|
||||
|
||||
extern uint8 *WRAM;
|
||||
extern uint32 WRAMSIZE;
|
||||
|
||||
//extern uint8 *CHRRAM;
|
||||
//extern uint32 CHRRAMSIZE;
|
||||
|
||||
uint8 mmc3_reg[8];
|
||||
uint8 exRegs[8];
|
||||
uint8 pointer;
|
||||
uint8 locked;
|
||||
uint8 readDIP;
|
||||
uint16 prgAND;
|
||||
uint16 chrAND;
|
||||
uint16 prgOR;
|
||||
uint16 chrOR;
|
||||
uint8 nrom;
|
||||
uint8 nrom128;
|
||||
uint8 dipswitch;
|
||||
|
||||
|
||||
static SFORMAT BS110_StateRegs[] =
|
||||
{
|
||||
{ exRegs, 8, "REGS" },
|
||||
{ mmc3_reg, 8, "MMC3R" },
|
||||
{ &pointer, 1, "POINT" },
|
||||
{ &readDIP, 1, "RDIP" },
|
||||
{ &prgAND, 1, "PRGAND" },
|
||||
{ &chrAND, 1, "CHRAND" },
|
||||
{ &prgOR, 1, "PRGOR" },
|
||||
{ &chrOR, 1, "CHROR" },
|
||||
{ &nrom, 1, "NROM" },
|
||||
{ &nrom128, 1, "N128" },
|
||||
{ &dipswitch, 1, "DIP" },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
int BS110GetPRGBank(int bank)
|
||||
{
|
||||
if (~bank & 1 && (pointer & 0x40)) bank ^= 2;
|
||||
return bank & 2 ? 0xFE | bank & 1 : mmc3_reg[6 | bank & 1];
|
||||
}
|
||||
|
||||
void BS110SyncPRG_GNROM(int A14, int AND, int OR) {
|
||||
setprg8(0x8000, (BS110GetPRGBank(0) &~A14) &AND | OR);
|
||||
setprg8(0xA000, (BS110GetPRGBank(1) &~A14) &AND | OR);
|
||||
setprg8(0xC000, (BS110GetPRGBank(0) | A14) &AND | OR);
|
||||
setprg8(0xE000, (BS110GetPRGBank(1) | A14) &AND | OR);
|
||||
}
|
||||
|
||||
static void BS110CW(uint32 A, uint8 V) {
|
||||
|
||||
uint8 block = ((exRegs[1]) & 0x03);
|
||||
uint8 mask = 0x7F;
|
||||
setchr1(A, (block << 7) | (V & mask));
|
||||
|
||||
}
|
||||
|
||||
static void BS110PW(uint32 A, uint8 V) {
|
||||
if ((exRegs[1] >> 2) & 0x01)
|
||||
{
|
||||
uint8 mask = 0x0F;
|
||||
uint8 block = (exRegs[1] & 3) << 4;
|
||||
if ((exRegs[1] >> 3) & 0x01)
|
||||
{
|
||||
setprg8(0x8000, (BS110GetPRGBank(0)) & mask | block);
|
||||
setprg8(0xA000, (BS110GetPRGBank(1)) & mask | block);
|
||||
setprg8(0xC000, (BS110GetPRGBank(0)) & mask | block);
|
||||
setprg8(0xE000, (BS110GetPRGBank(1)) & mask | block);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
setprg8(0x8000, (BS110GetPRGBank(0)) & mask | block);
|
||||
setprg8(0xA000, (BS110GetPRGBank(1)) & mask | block);
|
||||
setprg8(0xC000, (BS110GetPRGBank(0) | 2) & mask | block);
|
||||
setprg8(0xE000, (BS110GetPRGBank(1) | 2) & mask | block);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint8 mask = 0x0F;
|
||||
uint8 block = (exRegs[1] & 3) << 4;
|
||||
setprg8(A, block | (V & mask));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static DECLFW(BS110WriteHi) {
|
||||
|
||||
A = A & 0xE001;
|
||||
|
||||
if (A < 0xC000)
|
||||
{
|
||||
if (A == 0x8000)
|
||||
pointer = MMC3_cmd ^ V;
|
||||
if (A == 0x8001)
|
||||
mmc3_reg[MMC3_cmd & 0x07] = V;
|
||||
|
||||
MMC3_CMDWrite(A, V);
|
||||
FixMMC3PRG(MMC3_cmd);
|
||||
FixMMC3CHR(MMC3_cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
MMC3_IRQWrite(A, V);
|
||||
}
|
||||
}
|
||||
|
||||
static DECLFW(BS110WriteLo) {
|
||||
|
||||
exRegs[1] = A;
|
||||
exRegs[0] = V;
|
||||
FixMMC3PRG(MMC3_cmd);
|
||||
FixMMC3CHR(MMC3_cmd);
|
||||
|
||||
}
|
||||
static DECLFR(BS110ReadHi)
|
||||
{
|
||||
if ((A == 0xCB00) && ((exRegs[1] & 0x0F) == 0x08))
|
||||
return dipswitch;
|
||||
else
|
||||
return CartBR(A);
|
||||
|
||||
}
|
||||
|
||||
static void BS110Power(void) {
|
||||
dipswitch = 0;
|
||||
mmc3_reg[0] = 0x00; mmc3_reg[1] = 0x02;
|
||||
mmc3_reg[2] = 0x04; mmc3_reg[3] = 0x05; mmc3_reg[4] = 0x06; mmc3_reg[5] = 0x07;
|
||||
mmc3_reg[6] = 0x00; mmc3_reg[7] = 0x01;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0;i<4;i++)
|
||||
{
|
||||
exRegs[i] = 0;
|
||||
}
|
||||
|
||||
GenMMC3Power();
|
||||
SetWriteHandler(0x6000, 0x7FFF, BS110WriteLo);
|
||||
SetWriteHandler(0x8000, 0xFFFF, BS110WriteHi);
|
||||
SetReadHandler(0x8000, 0xFFFF, BS110ReadHi);
|
||||
}
|
||||
|
||||
static void BS110Reset(void) {
|
||||
|
||||
dipswitch++;
|
||||
mmc3_reg[0] = 0x00; mmc3_reg[1] = 0x02;
|
||||
mmc3_reg[2] = 0x04; mmc3_reg[3] = 0x05; mmc3_reg[4] = 0x06; mmc3_reg[5] = 0x07;
|
||||
mmc3_reg[6] = 0x00; mmc3_reg[7] = 0x01;
|
||||
int i = 0;
|
||||
|
||||
for (i = 0;i<4;i++)
|
||||
{
|
||||
exRegs[i] = 0;
|
||||
}
|
||||
|
||||
MMC3RegReset();
|
||||
}
|
||||
static void BS110Close(void) {
|
||||
if (WRAM)
|
||||
FCEU_gfree(WRAM);
|
||||
WRAM = NULL;
|
||||
}
|
||||
|
||||
void BS110_Init(CartInfo *info) {
|
||||
GenMMC3_Init(info, 512, 512, 0, 0);
|
||||
pwrap = BS110PW;
|
||||
cwrap = BS110CW;
|
||||
info->Power = BS110Power;
|
||||
info->Reset = BS110Reset;
|
||||
info->Close = BS110Close;
|
||||
|
||||
WRAMSIZE = 8192;
|
||||
WRAM = (uint8*)FCEU_gmalloc(WRAMSIZE);
|
||||
SetupCartPRGMapping(0x10, WRAM, WRAMSIZE, 1);
|
||||
AddExState(WRAM, WRAMSIZE, 0, "WRAM");
|
||||
|
||||
//CHRRAMSIZE = 8192;
|
||||
//CHRRAM = (uint8*)FCEU_gmalloc(CHRRAMSIZE);
|
||||
//SetupCartCHRMapping(0x10, CHRRAM, CHRRAMSIZE, 1);
|
||||
//AddExState(CHRRAM, CHRRAMSIZE, 0, "CHRR");
|
||||
|
||||
AddExState(EXPREGS, 3, 0, "EXPR");
|
||||
AddExState(BS110_StateRegs, ~0, 0, 0);
|
||||
}
|
||||
Reference in New Issue
Block a user