Mapper 235 support
This commit is contained in:
parent
6d56e48c77
commit
e2c844592e
7 changed files with 99 additions and 8 deletions
|
@ -87,6 +87,12 @@ void BaseMapper::SetCpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, uint8
|
|||
}
|
||||
}
|
||||
|
||||
void BaseMapper::RemoveCpuMemoryMapping(uint16_t startAddr, uint16_t endAddr)
|
||||
{
|
||||
//Unmap this section of memory (causing open bus behavior)
|
||||
SetCpuMemoryMapping(startAddr, endAddr, nullptr, MemoryAccessType::NoAccess);
|
||||
}
|
||||
|
||||
void BaseMapper::SetPpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, uint16_t pageNumber, ChrMemoryType type, int8_t accessType)
|
||||
{
|
||||
uint32_t pageCount = 0;
|
||||
|
|
|
@ -127,6 +127,7 @@ protected:
|
|||
virtual void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom);
|
||||
void SetCpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, int16_t pageNumber, PrgMemoryType type, int8_t accessType = -1);
|
||||
void SetCpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, uint8_t *source, int8_t accessType = -1);
|
||||
void RemoveCpuMemoryMapping(uint16_t startAddr, uint16_t endAddr);
|
||||
|
||||
virtual void SelectChrPage8x(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default);
|
||||
virtual void SelectChrPage4x(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default);
|
||||
|
|
68
Core/Bmc235.h
Normal file
68
Core/Bmc235.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "BaseMapper.h"
|
||||
|
||||
class Bmc235 : public BaseMapper
|
||||
{
|
||||
private:
|
||||
bool _openBus = false;
|
||||
protected:
|
||||
virtual uint16_t GetPRGPageSize() { return 0x4000; }
|
||||
virtual uint16_t GetCHRPageSize() { return 0x2000; }
|
||||
|
||||
void InitMapper()
|
||||
{
|
||||
SelectPrgPage2x(0, 0);
|
||||
SelectCHRPage(0, 0);
|
||||
}
|
||||
|
||||
void Reset(bool softReset)
|
||||
{
|
||||
SelectPrgPage2x(0, 0);
|
||||
_openBus = false;
|
||||
}
|
||||
|
||||
void StreamState(bool saving)
|
||||
{
|
||||
BaseMapper::StreamState(saving);
|
||||
Stream(_openBus);
|
||||
if(!saving && _openBus) {
|
||||
RemoveCpuMemoryMapping(0x8000, 0xFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
void WriteRegister(uint16_t addr, uint8_t value)
|
||||
{
|
||||
SetMirroringType((addr & 0x0400) ? MirroringType::ScreenAOnly : (addr & 0x2000) ? MirroringType::Horizontal : MirroringType::Vertical);
|
||||
|
||||
const uint8_t config[4][4][2] = {
|
||||
{ { 0x00, 0 }, { 0x00, 1 }, { 0x00, 1 }, { 0x00, 1 } },
|
||||
{ { 0x00, 0 }, { 0x00, 1 }, { 0x20, 0 }, { 0x00, 1 } },
|
||||
{ { 0x00, 0 }, { 0x00, 1 }, { 0x20, 0 }, { 0x40, 0 } },
|
||||
{ { 0x00, 0 }, { 0x20, 0 }, { 0x40, 0 }, { 0x60, 0 } }
|
||||
};
|
||||
|
||||
uint8_t mode;
|
||||
switch(GetPRGPageCount()) {
|
||||
case 64: mode = 0; break;
|
||||
case 128: mode = 1; break;
|
||||
case 256: mode = 2; break;
|
||||
default: mode = 3; break;
|
||||
};
|
||||
|
||||
uint8_t bank = config[mode][addr >> 8 & 0x03][0] | (addr & 0x1F);
|
||||
|
||||
_openBus = false;
|
||||
if(config[mode][addr >> 8 & 0x03][1]) {
|
||||
//Open bus
|
||||
_openBus = true;
|
||||
RemoveCpuMemoryMapping(0x8000, 0xFFFF);
|
||||
} else if(addr & 0x800) {
|
||||
bank = (bank << 1) | (addr >> 12 & 0x01);
|
||||
SelectPRGPage(0, bank);
|
||||
SelectPRGPage(1, bank);
|
||||
} else {
|
||||
SelectPrgPage2x(0, bank << 1);
|
||||
}
|
||||
}
|
||||
};
|
|
@ -425,6 +425,7 @@
|
|||
<ClInclude Include="FrameInfo.h" />
|
||||
<ClInclude Include="FrontFareast.h" />
|
||||
<ClInclude Include="GameDatabase.h" />
|
||||
<ClInclude Include="Bmc235.h" />
|
||||
<ClInclude Include="HdVideoFilter.h" />
|
||||
<ClInclude Include="Henggedianzi177.h" />
|
||||
<ClInclude Include="Henggedianzi179.h" />
|
||||
|
|
|
@ -769,6 +769,9 @@
|
|||
<ClInclude Include="Caltron41.h">
|
||||
<Filter>Nes\Mappers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Bmc235.h">
|
||||
<Filter>Nes\Mappers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "DaouInfosys.h"
|
||||
#include "FDS.h"
|
||||
#include "FrontFareast.h"
|
||||
#include "Bmc235.h"
|
||||
#include "GxRom.h"
|
||||
#include "Henggedianzi177.h"
|
||||
#include "Henggedianzi179.h"
|
||||
|
@ -136,7 +137,7 @@ Supported mappers: (... denotes bad mappers, --- denotes potentially bad mapper
|
|||
-----------------------------------------------------------------
|
||||
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| | 15|
|
||||
| 16| 17| 18| 19|...| 21| 22| 23| 24| 25| 26| 27| 28| | | 31|
|
||||
| 32| 33| 34| | 36| 37| 38|---| 40| 41| 42| | 44| 45| 46| 47|
|
||||
| 32| 33| 34| | 36| 37| 38|---| 40| 41| 42|---| 44| 45| 46| 47|
|
||||
| 48| 49| 50| | 52| | | | 56| 57| 58| | 60| 61| 62| |
|
||||
| 64| 65| 66| 67| 68| 69| 70| 71| 72| 73| 74| 75| 76| 77| 78| 79|
|
||||
| 80| | 82| | | 85| 86| 87| 88| 89| | 91| 92| 93| 94| 95|
|
||||
|
@ -148,7 +149,7 @@ Supported mappers: (... denotes bad mappers, --- denotes potentially bad mapper
|
|||
|176|177| |179|180| |182| |184|185| | | |189| |191|
|
||||
|192|193|194|195| | | | |200|201|202|203| |205|206|207|
|
||||
| | |210| | | | | | | |218| | | | | |
|
||||
| |225|226|227|228| |230|231|232| | | | | | | |
|
||||
| |225|226|227|228| |230|231|232| | |235| | | | |
|
||||
|240|241|242|243| | |246| | | | | |252| | | |
|
||||
-----------------------------------------------------------------
|
||||
*/
|
||||
|
@ -318,6 +319,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
|
|||
case 230: return new Mapper230();
|
||||
case 231: return new Mapper231();
|
||||
case 232: return new BF9096();
|
||||
case 235: return new Bmc235();
|
||||
case 240: return new Mapper240();
|
||||
case 241: return new Mapper241();
|
||||
case 242: return new Mapper242();
|
||||
|
|
|
@ -68,6 +68,16 @@ struct NESHeader
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t GetPrgCount()
|
||||
{
|
||||
if(PrgCount == 0) {
|
||||
//0 prg banks is a special value meaning 256 banks
|
||||
return 256;
|
||||
} else {
|
||||
return PrgCount;
|
||||
}
|
||||
}
|
||||
|
||||
bool HasBattery()
|
||||
{
|
||||
return (Byte6 & 0x02) == 0x02;
|
||||
|
@ -119,9 +129,9 @@ struct NESHeader
|
|||
uint32_t GetPrgSize()
|
||||
{
|
||||
if(GetRomHeaderVersion() == RomHeaderVersion::Nes2_0) {
|
||||
return (((Byte9 & 0x0F) << 4) | PrgCount) * 0x4000;
|
||||
return (((Byte9 & 0x0F) << 4) | GetPrgCount()) * 0x4000;
|
||||
} else {
|
||||
return PrgCount * 0x4000;
|
||||
return GetPrgCount() * 0x4000;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -182,16 +192,16 @@ struct NESHeader
|
|||
|
||||
void SanitizeHeader(size_t romLength)
|
||||
{
|
||||
size_t calculatedLength = sizeof(NESHeader) + 0x4000 * PrgCount;
|
||||
size_t calculatedLength = sizeof(NESHeader) + 0x4000 * GetPrgCount();
|
||||
while(calculatedLength > romLength) {
|
||||
PrgCount--;
|
||||
calculatedLength = sizeof(NESHeader) + 0x4000 * PrgCount;
|
||||
calculatedLength = sizeof(NESHeader) + 0x4000 * GetPrgCount();
|
||||
}
|
||||
|
||||
calculatedLength = sizeof(NESHeader) + 0x4000 * PrgCount + 0x2000 * ChrCount;
|
||||
calculatedLength = sizeof(NESHeader) + 0x4000 * GetPrgCount() + 0x2000 * ChrCount;
|
||||
while(calculatedLength > romLength) {
|
||||
ChrCount--;
|
||||
calculatedLength = sizeof(NESHeader) + 0x4000 * PrgCount + 0x2000 * ChrCount;
|
||||
calculatedLength = sizeof(NESHeader) + 0x4000 * GetPrgCount() + 0x2000 * ChrCount;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue