UNIF BMC-70in1/BMC-70in1B board support (Defined as mapper #236 in Nestopia)

This commit is contained in:
Souryo 2016-11-07 19:09:08 -05:00
parent 298324f7fd
commit ee28265c78
8 changed files with 115 additions and 3 deletions

View file

@ -363,6 +363,11 @@ bool BaseMapper::HasChrRam()
return _chrRamSize > 0; return _chrRamSize > 0;
} }
bool BaseMapper::HasChrRom()
{
return !_onlyChrRam;
}
void BaseMapper::AddRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation) void BaseMapper::AddRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation)
{ {
for(int i = startAddr; i <= endAddr; i++) { for(int i = startAddr; i <= endAddr; i++) {

View file

@ -177,6 +177,7 @@ protected:
void RestoreOriginalPrgRam(); void RestoreOriginalPrgRam();
void InitializeChrRam(int32_t chrRamSize = -1); void InitializeChrRam(int32_t chrRamSize = -1);
bool HasChrRam(); bool HasChrRam();
bool HasChrRom();
void AddRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation = MemoryOperation::Any); void AddRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation = MemoryOperation::Any);
void RemoveRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation = MemoryOperation::Any); void RemoveRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation = MemoryOperation::Any);

94
Core/Bmc70in1.h Normal file
View file

@ -0,0 +1,94 @@
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
class Bmc70in1 : public BaseMapper
{
private:
uint8_t _bankMode;
uint8_t _outerBank;
uint8_t _prgReg;
uint8_t _chrReg;
uint8_t _dipSwitch;
bool _useOuterBank;
protected:
uint16_t GetPRGPageSize() { return 0x4000; }
uint16_t GetCHRPageSize() { return 0x2000; }
bool AllowRegisterRead() { return true; }
void InitMapper() override
{
_prgReg = 0;
_chrReg = 0;
if(HasChrRom()) {
_useOuterBank = false;
_dipSwitch = 0x0C;
} else {
_useOuterBank = true;
_dipSwitch = 0x05;
}
SelectCHRPage(0, 0);
UpdateState();
}
void Reset(bool softReset) override
{
BaseMapper::Reset(softReset);
_bankMode = 0;
_outerBank = 0;
_dipSwitch = (_dipSwitch + 1) & 0x0F;
}
void UpdateState()
{
switch(_bankMode) {
case 0x00: case 0x10:
SelectPRGPage(0, _outerBank | _prgReg);
SelectPRGPage(1, _outerBank | 7);
break;
case 0x20:
SelectPrgPage2x(0, (_outerBank | _prgReg) & 0xFE);
break;
case 0x30:
SelectPRGPage(0, _outerBank | _prgReg);
SelectPRGPage(1, _outerBank | _prgReg);
break;
}
if(!_useOuterBank) {
SelectCHRPage(0, _chrReg);
}
}
uint8_t ReadRegister(uint16_t addr) override
{
if(_bankMode == 0x10) {
return InternalReadRam((addr & 0xFFF0) | _dipSwitch);
} else {
return InternalReadRam(addr);
}
}
void WriteRegister(uint16_t addr, uint8_t value) override
{
if(addr & 0x4000) {
_bankMode = addr & 0x30;
_prgReg = addr & 0x07;
} else {
SetMirroringType(addr & 0x20 ? MirroringType::Horizontal : MirroringType::Vertical);
if(_useOuterBank) {
_outerBank = (addr & 0x03) << 3;
} else {
_chrReg = addr & 0x07;
}
}
UpdateState();
}
};

View file

@ -419,6 +419,7 @@
<ClInclude Include="Bmc51.h" /> <ClInclude Include="Bmc51.h" />
<ClInclude Include="Bmc63.h" /> <ClInclude Include="Bmc63.h" />
<ClInclude Include="A65AS.h" /> <ClInclude Include="A65AS.h" />
<ClInclude Include="Bmc70in1.h" />
<ClInclude Include="BnRom.h" /> <ClInclude Include="BnRom.h" />
<ClInclude Include="Bs5.h" /> <ClInclude Include="Bs5.h" />
<ClInclude Include="Caltron41.h" /> <ClInclude Include="Caltron41.h" />

View file

@ -1003,6 +1003,9 @@
<ClInclude Include="Ghostbusters63in1.h"> <ClInclude Include="Ghostbusters63in1.h">
<Filter>Nes\Mappers\Unif</Filter> <Filter>Nes\Mappers\Unif</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="Bmc70in1.h">
<Filter>Nes\Mappers\Unif</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="stdafx.cpp"> <ClCompile Include="stdafx.cpp">

View file

@ -13,6 +13,7 @@
#include "BF9096.h" #include "BF9096.h"
#include "Bmc51.h" #include "Bmc51.h"
#include "Bmc63.h" #include "Bmc63.h"
#include "Bmc70in1.h"
#include "Bmc190in1.h" #include "Bmc190in1.h"
#include "Bmc235.h" #include "Bmc235.h"
#include "Bmc255.h" #include "Bmc255.h"
@ -223,7 +224,7 @@ Supported mappers:
|176|177|178|179|180|---|182|183|184|185|186|187|188|189|===|191| |176|177|178|179|180|---|182|183|184|185|186|187|188|189|===|191|
|192|193|194|195|196|197| |199|200|201|202|203|204|205|206|207| |192|193|194|195|196|197| |199|200|201|202|203|204|205|206|207|
|???|209|210|211|212|213|214|215|216|217|218|219|220|221|222|???| |???|209|210|211|212|213|214|215|216|217|218|219|220|221|222|???|
|???|225|226|227|228|229|230|231|232|233|234|235|???|===|238|===| |???|225|226|227|228|229|230|231|232|233|234|235|236|===|238|===|
|240|241|242|243|244|245|246|===|===|249|250|===|252|253|254|255| |240|241|242|243|244|245|246|===|===|249|250|===|252|253|254|255|
----------------------------------------------------------------- -----------------------------------------------------------------
*/ */
@ -232,6 +233,8 @@ const uint16_t MapperFactory::FdsMapperID;
const uint16_t MapperFactory::NsfMapperID; const uint16_t MapperFactory::NsfMapperID;
const uint16_t MapperFactory::UnknownBoard; const uint16_t MapperFactory::UnknownBoard;
const uint16_t MapperFactory::UnifA65AS; const uint16_t MapperFactory::UnifA65AS;
const uint16_t MapperFactory::UnifBmc70in1;
const uint16_t MapperFactory::UnifBmc70in1B;
const uint16_t MapperFactory::UnifBmc190in1; const uint16_t MapperFactory::UnifBmc190in1;
const uint16_t MapperFactory::UnifBs5; const uint16_t MapperFactory::UnifBs5;
const uint16_t MapperFactory::UnifCoolboy; const uint16_t MapperFactory::UnifCoolboy;
@ -458,6 +461,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
case 233: return new Mapper233(); case 233: return new Mapper233();
case 234: return new Mapper234(); case 234: return new Mapper234();
case 235: return new Bmc235(); case 235: return new Bmc235();
case 236: return new Bmc70in1();
case 238: return new MMC3_238(); case 238: return new MMC3_238();
case 240: return new Mapper240(); case 240: return new Mapper240();
case 241: return new Mapper241(); case 241: return new Mapper241();
@ -474,6 +478,8 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
case 255: return new Bmc255(); case 255: return new Bmc255();
case MapperFactory::UnifA65AS: return new A65AS(); case MapperFactory::UnifA65AS: return new A65AS();
case MapperFactory::UnifBmc70in1: return new Bmc70in1();
case MapperFactory::UnifBmc70in1B: return new Bmc70in1();
case MapperFactory::UnifBmc190in1: return new Bmc190in1(); case MapperFactory::UnifBmc190in1: return new Bmc190in1();
case MapperFactory::UnifBs5: return new Bs5(); case MapperFactory::UnifBs5: return new Bs5();
case MapperFactory::UnifCoolboy: return new MMC3_Coolboy(); case MapperFactory::UnifCoolboy: return new MMC3_Coolboy();

View file

@ -28,6 +28,8 @@ class MapperFactory
static const uint16_t UnifBs5 = 65519; static const uint16_t UnifBs5 = 65519;
static const uint16_t UnifBmc190in1 = 65518; static const uint16_t UnifBmc190in1 = 65518;
static const uint16_t UnifGhostbusters63in1 = 65517; static const uint16_t UnifGhostbusters63in1 = 65517;
static const uint16_t UnifBmc70in1 = 65516;
static const uint16_t UnifBmc70in1B = 65515;
static shared_ptr<BaseMapper> InitializeFromFile(string romFilename, stringstream *filestream, string ipsFilename, int32_t archiveFileIndex); static shared_ptr<BaseMapper> InitializeFromFile(string romFilename, stringstream *filestream, string ipsFilename, int32_t archiveFileIndex);
}; };

View file

@ -19,8 +19,8 @@ private:
{ "43272", MapperFactory::UnknownBoard }, { "43272", MapperFactory::UnknownBoard },
{ "603-5052", 238 }, { "603-5052", 238 },
{ "64in1NoRepeat", MapperFactory::UnknownBoard }, { "64in1NoRepeat", MapperFactory::UnknownBoard },
{ "70in1", MapperFactory::UnknownBoard }, { "70in1", MapperFactory::UnifBmc70in1 },
{ "70in1B", MapperFactory::UnknownBoard }, { "70in1B", MapperFactory::UnifBmc70in1B },
{ "810544-C-A1", MapperFactory::UnknownBoard }, { "810544-C-A1", MapperFactory::UnknownBoard },
{ "8157", MapperFactory::UnknownBoard }, { "8157", MapperFactory::UnknownBoard },
{ "8237", 215 }, { "8237", 215 },