board: Add support for Mapper 289

This commit is contained in:
Rupert Carmichael 2025-03-17 22:11:23 -04:00
parent d1f3575f24
commit 93e7805ab9
4 changed files with 212 additions and 0 deletions

View file

@ -138,6 +138,7 @@
#include "NstBoardBmc31in1.hpp"
#include "NstBoardBmc35in1.hpp"
#include "NstBoardBmc36in1.hpp"
#include "NstBoardBmc60311c.hpp"
#include "NstBoardBmc64in1.hpp"
#include "NstBoardBmc72in1.hpp"
#include "NstBoardBmc76in1.hpp"
@ -805,6 +806,7 @@ namespace Nes
{ "BMC-190IN1", Type::BMC_GOLDEN_190IN1 },
{ "BMC-42IN1RESETSWITCH", Type::BMC_SUPER_22GAMES },
{ "BMC-64IN1NOREPEAT", Type::BMC_Y2K_64IN1 },
{ "BMC-60311C", Type::BMC_60311C },
{ "BMC-70IN1", Type::BMC_GAME_800IN1 },
{ "BMC-70IN1B", Type::BMC_GAME_800IN1 },
{ "BMC-8157", Type::BMC_8157 },
@ -3419,6 +3421,12 @@ namespace Nes
id = Type::BENSHENG_BS5;
break;
case 289:
name = "BMC-60311C";
id = Type::BMC_60311C;
break;
case 298:
name = "UNL-TF1201";
@ -3680,6 +3688,7 @@ namespace Nes
case Type::BMC_72IN1 : return new Bmc::B72in1(c);
case Type::BMC_76IN1 :
case Type::BMC_SUPER_42IN1 : return new Bmc::B76in1(c);
case Type::BMC_60311C : return new Bmc::B60311c(c);
case Type::BMC_8157 : return new Bmc::B8157(c);
case Type::BMC_9999999IN1 : return new Bmc::B9999999in1(c);
case Type::BMC_FAMILY_4646B : return new Bmc::Family4646B(c);

View file

@ -272,6 +272,7 @@ namespace Nes
BMC_31IN1 = MakeId< 229, 512, 256, 0, 0, CRM_0, NMT_V, 0 >::ID,
BMC_35IN1 = MakeId< 203, 128, 64, 0, 0, CRM_0, NMT_V, 0 >::ID,
BMC_36IN1 = MakeId< 200, 128, 64, 0, 0, CRM_0, NMT_V, 0 >::ID,
BMC_60311C = MakeId< 289, 4096, 2048, 0, 0, CRM_32, NMT_X, 0 >::ID,
BMC_64IN1 = MakeId< 204, 128, 64, 0, 0, CRM_0, NMT_V, 0 >::ID,
BMC_72IN1 = MakeId< 225, 1024, 512, 0, 0, CRM_0, NMT_V, 0 >::ID,
BMC_76IN1 = MakeId< 226, 2048, 0, 0, 0, CRM_8, NMT_H, 0 >::ID,

View file

@ -0,0 +1,135 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2025 Rupert Carmichael
//
// This file is part of Nestopia.
//
// Nestopia 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.
//
// Nestopia 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 Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#include "NstBoard.hpp"
#include "NstBoardBmc60311c.hpp"
namespace Nes
{
namespace Core
{
namespace Boards
{
namespace Bmc
{
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("s", on)
#endif
void B60311c::SubReset(const bool hard)
{
Map( 0x6000U, &B60311c::Poke_6000 );
Map( 0x6001U, &B60311c::Poke_6001 );
Map( 0x8000U, 0xFFFFU, &B60311c::Poke_8000 );
if (hard)
{
regs[0] = 0;
regs[1] = 0;
latch = 0;
}
}
void B60311c::SubLoad(State::Loader& state,const dword baseChunk)
{
NST_VERIFY( (baseChunk == AsciiId<'B','6','3'>::V) );
if (baseChunk == AsciiId<'B','6','3'>::V)
{
while (const dword chunk = state.Begin())
{
if (chunk == AsciiId<'R','E','G'>::V)
{
State::Loader::Data<3> data( state );
latch = data[0];
regs[0] = data[1];
regs[1] = data[2];
}
state.End();
}
UpdatePrg();
}
}
void B60311c::SubSave(State::Saver& state) const
{
const byte data[3] =
{
static_cast<byte>(latch),
static_cast<byte>(regs[0]),
static_cast<byte>(regs[1])
};
state.Begin( AsciiId<'B','6','3'>::V ).Begin( AsciiId<'R','E','G'>::V ).Write( data ).End().End();
}
void B60311c::UpdatePrg()
{
if (regs[0] & 0x02)
{
prg.SwapBank<SIZE_16K,0x0000>( (latch & 0x07) | (regs[1] & ~0x07) );
prg.SwapBank<SIZE_16K,0x4000>( 0x07 | (regs[1] & ~0x07) );
}
else if (regs[0] & 0x01)
{
prg.SwapBank<SIZE_32K,0x0000>( regs[1] >> 1 );
}
else
{
prg.SwapBank<SIZE_16K,0x0000>( regs[1] );
prg.SwapBank<SIZE_16K,0x4000>( regs[1] );
}
chr.Source().SetSecurity(true, regs[0] & 0x04 ? false : true);
ppu.SetMirroring( (regs[0] & 0x08) ? Ppu::NMT_H : Ppu::NMT_V );
}
#ifdef NST_MSVC_OPTIMIZE
#pragma optimize("", on)
#endif
NES_POKE_D(B60311c,6000)
{
regs[0] = data;
UpdatePrg();
}
NES_POKE_D(B60311c,6001)
{
regs[1] = data;
UpdatePrg();
}
NES_POKE_D(B60311c,8000)
{
latch = data;
UpdatePrg();
}
}
}
}
}

View file

@ -0,0 +1,67 @@
////////////////////////////////////////////////////////////////////////////////////////
//
// Nestopia - NES/Famicom emulator written in C++
//
// Copyright (C) 2025 Rupert Carmichael
//
// This file is part of Nestopia.
//
// Nestopia 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.
//
// Nestopia 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 Nestopia; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
////////////////////////////////////////////////////////////////////////////////////////
#ifndef NST_BOARD_BMC_60311C_H
#define NST_BOARD_BMC_60311C_H
#ifdef NST_PRAGMA_ONCE
#pragma once
#endif
namespace Nes
{
namespace Core
{
namespace Boards
{
namespace Bmc
{
class B60311c : public Board
{
public:
explicit B60311c(const Context& c)
: Board(c) {}
private:
void SubReset(bool);
void SubSave(State::Saver&) const;
void SubLoad(State::Loader&,dword);
void UpdatePrg();
NES_DECL_POKE( 6000 );
NES_DECL_POKE( 6001 );
NES_DECL_POKE( 8000 );
uint regs[2];
uint latch;
};
}
}
}
}
#endif