Skip to content

Commit

Permalink
NES: Added Rainbow support (mapper 682)
Browse files Browse the repository at this point in the history
  • Loading branch information
SourMesen committed Oct 8, 2024
1 parent 8e6846e commit d751502
Show file tree
Hide file tree
Showing 43 changed files with 2,281 additions and 282 deletions.
5 changes: 5 additions & 0 deletions Core/Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="NES\Epsm.h" />
<ClInclude Include="NES\Mappers\Homebrew\Rainbow.h" />
<ClInclude Include="NES\Mappers\Homebrew\RainbowAudio.h" />
<ClInclude Include="NES\Debugger\IExtModeMapperDebug.h" />
<ClInclude Include="NES\Mappers\Homebrew\FlashS29.h" />
<ClInclude Include="NES\OpnInterface.h" />
<ClInclude Include="SMS\Input\ColecoVisionController.h" />
<ClInclude Include="Debugger\AddressInfo.h" />
Expand Down Expand Up @@ -852,6 +856,7 @@
<ClCompile Include="NES\APU\BaseExpansionAudio.cpp" />
<ClCompile Include="NES\Loaders\StudyBoxLoader.cpp" />
<ClCompile Include="NES\Loaders\UnifLoader.cpp" />
<ClCompile Include="NES\Mappers\Homebrew\Rainbow.cpp" />
<ClCompile Include="Shared\Utilities\emu2413.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='PGO Profile|x64'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
Expand Down
15 changes: 15 additions & 0 deletions Core/Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2928,6 +2928,18 @@
<ClInclude Include="NES\OpnInterface.h">
<Filter>NES</Filter>
</ClInclude>
<ClInclude Include="NES\Mappers\Homebrew\Rainbow.h">
<Filter>NES\Mappers\Homebrew</Filter>
</ClInclude>
<ClInclude Include="NES\Mappers\Homebrew\RainbowAudio.h">
<Filter>NES\Mappers\Homebrew</Filter>
</ClInclude>
<ClInclude Include="NES\Debugger\IExtModeMapperDebug.h">
<Filter>NES\Mappers\Homebrew</Filter>
</ClInclude>
<ClInclude Include="NES\Mappers\Homebrew\FlashS29.h">
<Filter>NES\Mappers\Homebrew</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Shared\Video\RotateFilter.cpp">
Expand Down Expand Up @@ -3266,6 +3278,9 @@
<ClCompile Include="NES\Epsm.cpp">
<Filter>NES</Filter>
</ClCompile>
<ClCompile Include="NES\Mappers\Homebrew\Rainbow.cpp">
<Filter>NES\Mappers\Homebrew</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<Filter Include="PCE">
Expand Down
1 change: 1 addition & 0 deletions Core/Debugger/DebugUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class DebugUtilities
case MemoryType::NesInternalRam:
case MemoryType::NesMemory:
case MemoryType::NesNametableRam:
case MemoryType::NesMapperRam:
case MemoryType::NesPaletteRam:
case MemoryType::NesPpuMemory:
case MemoryType::NesPrgRom:
Expand Down
8 changes: 4 additions & 4 deletions Core/Debugger/PpuTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,12 +242,12 @@ class PpuTools

void GetTileView(GetTileViewOptions options, uint8_t *source, uint32_t srcSize, const uint32_t* palette, uint32_t *outBuffer);

virtual DebugTilemapTileInfo GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState) = 0;
virtual DebugTilemapTileInfo GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState, BaseState& ppuToolsState) = 0;
virtual FrameInfo GetTilemapSize(GetTilemapOptions options, BaseState& state) = 0;
virtual DebugTilemapInfo GetTilemap(GetTilemapOptions options, BaseState& state, uint8_t* vram, uint32_t* palette, uint32_t* outBuffer) = 0;
virtual DebugTilemapInfo GetTilemap(GetTilemapOptions options, BaseState& state, BaseState& ppuToolsState, uint8_t* vram, uint32_t* palette, uint32_t* outBuffer) = 0;

virtual DebugSpritePreviewInfo GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state) = 0;
virtual void GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview) = 0;
virtual DebugSpritePreviewInfo GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state, BaseState& ppuToolsState) = 0;
virtual void GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, BaseState& ppuToolsState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview) = 0;

int32_t GetTilePixel(AddressInfo tileAddress, TileFormat format, int32_t x, int32_t y);
void SetTilePixel(AddressInfo tileAddress, TileFormat format, int32_t x, int32_t y, int32_t color);
Expand Down
8 changes: 4 additions & 4 deletions Core/GBA/Debugger/GbaPpuTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void GbaPpuTools::SetMemoryAccessData(uint16_t scanline, uint8_t* data)
memcpy(_memoryAccess + scanline * 308 * 4, data, 308 * 4);
}

DebugTilemapInfo GbaPpuTools::GetTilemap(GetTilemapOptions options, BaseState& baseState, uint8_t* vram, uint32_t* palette, uint32_t* outBuffer)
DebugTilemapInfo GbaPpuTools::GetTilemap(GetTilemapOptions options, BaseState& baseState, BaseState& ppuToolsState, uint8_t* vram, uint32_t* palette, uint32_t* outBuffer)
{
GbaPpuState& state = (GbaPpuState&)baseState;
FrameInfo outputSize = GetTilemapSize(options, state);
Expand Down Expand Up @@ -256,7 +256,7 @@ FrameInfo GbaPpuTools::GetTilemapSize(GetTilemapOptions options, BaseState& base
return { 0, 0 };
}

DebugTilemapTileInfo GbaPpuTools::GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState)
DebugTilemapTileInfo GbaPpuTools::GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState, BaseState& ppuToolsState)
{
DebugTilemapTileInfo result = {};

Expand Down Expand Up @@ -397,7 +397,7 @@ void GbaPpuTools::GetSpritePreview(GetSpritePreviewOptions options, BaseState& b
}
}

DebugSpritePreviewInfo GbaPpuTools::GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state)
DebugSpritePreviewInfo GbaPpuTools::GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state, BaseState& ppuToolsState)
{
DebugSpritePreviewInfo info = {};
info.Height = 256;
Expand Down Expand Up @@ -586,7 +586,7 @@ void GbaPpuTools::GetSpriteInfo(DebugSpriteInfo& sprite, uint32_t* spritePreview
}
}

void GbaPpuTools::GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview)
void GbaPpuTools::GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, BaseState& ppuToolsState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview)
{
GbaPpuState& state = (GbaPpuState&)baseState;
for(int i = 0; i < 128; i++) {
Expand Down
8 changes: 4 additions & 4 deletions Core/GBA/Debugger/GbaPpuTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class GbaPpuTools final : public PpuTools

void SetMemoryAccessData(uint16_t scanline, uint8_t* data);

DebugTilemapInfo GetTilemap(GetTilemapOptions options, BaseState& state, uint8_t* vram, uint32_t* palette, uint32_t *outBuffer) override;
DebugTilemapInfo GetTilemap(GetTilemapOptions options, BaseState& state, BaseState& ppuToolsState, uint8_t* vram, uint32_t* palette, uint32_t *outBuffer) override;
FrameInfo GetTilemapSize(GetTilemapOptions options, BaseState& state) override;
DebugTilemapTileInfo GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState) override;
DebugTilemapTileInfo GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState, BaseState& ppuToolsState) override;

DebugSpritePreviewInfo GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state) override;
void GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview) override;
DebugSpritePreviewInfo GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state, BaseState& ppuToolsState) override;
void GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, BaseState& ppuToolsState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview) override;

DebugPaletteInfo GetPaletteInfo(GetPaletteInfoOptions options) override;
void SetPaletteColor(int32_t colorIndex, uint32_t color) override;
Expand Down
8 changes: 4 additions & 4 deletions Core/Gameboy/Debugger/GbPpuTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ GbPpuTools::GbPpuTools(Debugger* debugger, Emulator *emu) : PpuTools(debugger, e
{
}

DebugTilemapInfo GbPpuTools::GetTilemap(GetTilemapOptions options, BaseState& baseState, uint8_t* vram, uint32_t* palette, uint32_t* outBuffer)
DebugTilemapInfo GbPpuTools::GetTilemap(GetTilemapOptions options, BaseState& baseState, BaseState& ppuToolsState, uint8_t* vram, uint32_t* palette, uint32_t* outBuffer)
{
GbPpuState& state = (GbPpuState&)baseState;
uint32_t offset = options.Layer == 1 ? 0x1C00 : 0x1800;
Expand Down Expand Up @@ -108,7 +108,7 @@ FrameInfo GbPpuTools::GetTilemapSize(GetTilemapOptions options, BaseState& state
return { 256, 256 };
}

DebugTilemapTileInfo GbPpuTools::GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState)
DebugTilemapTileInfo GbPpuTools::GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState, BaseState& ppuToolsState)
{
DebugTilemapTileInfo result = {};

Expand Down Expand Up @@ -158,7 +158,7 @@ DebugTilemapTileInfo GbPpuTools::GetTilemapTileInfo(uint32_t x, uint32_t y, uint
return result;
}

DebugSpritePreviewInfo GbPpuTools::GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state)
DebugSpritePreviewInfo GbPpuTools::GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state, BaseState& ppuToolsState)
{
DebugSpritePreviewInfo info = {};
info.Height = 256;
Expand Down Expand Up @@ -241,7 +241,7 @@ void GbPpuTools::GetSpriteInfo(DebugSpriteInfo& sprite, uint32_t* spritePreview,
}
}

void GbPpuTools::GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview)
void GbPpuTools::GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, BaseState& ppuToolsState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview)
{
GbPpuState& state = (GbPpuState&)baseState;
for(int i = 0; i < 40; i++) {
Expand Down
8 changes: 4 additions & 4 deletions Core/Gameboy/Debugger/GbPpuTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class GbPpuTools final : public PpuTools
public:
GbPpuTools(Debugger* debugger, Emulator *emu);

DebugTilemapInfo GetTilemap(GetTilemapOptions options, BaseState& state, uint8_t* vram, uint32_t* palette, uint32_t *outBuffer) override;
DebugTilemapInfo GetTilemap(GetTilemapOptions options, BaseState& state, BaseState& ppuToolsState, uint8_t* vram, uint32_t* palette, uint32_t *outBuffer) override;
FrameInfo GetTilemapSize(GetTilemapOptions options, BaseState& state) override;
DebugTilemapTileInfo GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState) override;
DebugTilemapTileInfo GetTilemapTileInfo(uint32_t x, uint32_t y, uint8_t* vram, GetTilemapOptions options, BaseState& baseState, BaseState& ppuToolsState) override;

DebugSpritePreviewInfo GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state) override;
void GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview) override;
DebugSpritePreviewInfo GetSpritePreviewInfo(GetSpritePreviewOptions options, BaseState& state, BaseState& ppuToolsState) override;
void GetSpriteList(GetSpritePreviewOptions options, BaseState& baseState, BaseState& ppuToolsState, uint8_t* vram, uint8_t* oamRam, uint32_t* palette, DebugSpriteInfo outBuffer[], uint32_t* spritePreviews, uint32_t* screenPreview) override;

DebugPaletteInfo GetPaletteInfo(GetPaletteInfoOptions options) override;
void SetPaletteColor(int32_t colorIndex, uint32_t color) override;
Expand Down
77 changes: 64 additions & 13 deletions Core/NES/BaseMapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,24 @@ void BaseMapper::SetCpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, PrgMe
case PrgMemoryType::PrgRom: source = _prgRom; sourceSize = _prgSize; break;
case PrgMemoryType::SaveRam: source = _saveRam; sourceSize = _saveRamSize; break;
case PrgMemoryType::WorkRam: source = _workRam; sourceSize = _workRamSize; break;
case PrgMemoryType::MapperRam: source = _mapperRam; sourceSize = _mapperRamSize; break;
}

int firstSlot = startAddr >> 8;
int slotCount = (endAddr - startAddr + 1) >> 8;
for(int i = 0; i < slotCount; i++) {
_prgMemoryOffset[firstSlot + i] = sourceOffset + i * 0x100;
_prgMemoryType[firstSlot + i] = type;
_prgMemoryAccess[firstSlot + i] = (MemoryAccessType)accessType;
if(sourceSize == 0) {
_prgPages[i] = nullptr;
_prgMemoryAccess[i] = MemoryAccessType::NoAccess;
} else {
while(sourceOffset >= sourceSize) {
sourceOffset -= sourceSize;
}
_prgPages[firstSlot + i] = source + sourceOffset;
_prgMemoryOffset[firstSlot + i] = sourceOffset + i * 0x100;
_prgMemoryType[firstSlot + i] = type;
_prgMemoryAccess[firstSlot + i] = (MemoryAccessType)accessType;
}
}

SetCpuMemoryMapping(startAddr, endAddr, source, sourceOffset, sourceSize, accessType);
Expand Down Expand Up @@ -233,6 +243,9 @@ void BaseMapper::SetPpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, uint1
pageCount = _nametableCount;
defaultAccessType |= MemoryAccessType::Write;
break;

default:
throw new std::runtime_error("Invalid parameter");
}

if(pageCount == 0) {
Expand Down Expand Up @@ -285,14 +298,27 @@ void BaseMapper::SetPpuMemoryMapping(uint16_t startAddr, uint16_t endAddr, ChrMe
sourceMemory = _nametableRam;
sourceSize = _ntRamSize;
break;

case ChrMemoryType::MapperRam:
sourceMemory = _mapperRam;
sourceSize = _mapperRamSize;
break;
}

int firstSlot = startAddr >> 8;
int slotCount = (endAddr - startAddr + 1) >> 8;
for(int i = 0; i < slotCount; i++) {
_chrMemoryOffset[firstSlot + i] = sourceOffset + i * 256;
_chrMemoryType[firstSlot + i] = type;
_chrMemoryAccess[firstSlot + i] = (MemoryAccessType)accessType;
if(sourceSize == 0) {
_chrPages[i] = nullptr;
_chrMemoryAccess[i] = MemoryAccessType::NoAccess;
} else {
while(sourceOffset >= sourceSize) {
sourceOffset -= sourceSize;
}
_chrMemoryOffset[firstSlot + i] = sourceOffset + i * 256;
_chrMemoryType[firstSlot + i] = type;
_chrMemoryAccess[firstSlot + i] = (MemoryAccessType)accessType;
}
}

SetPpuMemoryMapping(startAddr, endAddr, sourceMemory, sourceOffset, sourceSize, accessType);
Expand Down Expand Up @@ -534,6 +560,7 @@ void BaseMapper::Serialize(Serializer& s)
SVArray(_chrRam, _chrRamSize);
SVArray(_workRam, _workRamSize);
SVArray(_saveRam, _saveRamSize);
SVArray(_mapperRam, _mapperRamSize);
SVArray(_nametableRam, _ntRamSize);

SVArray(_prgMemoryOffset, 0x100);
Expand Down Expand Up @@ -647,8 +674,13 @@ void BaseMapper::Initialize(NesConsole* console, RomData& romData)
_workRam = new uint8_t[_workRamSize];
_emu->RegisterMemory(MemoryType::NesWorkRam, _workRam, _workRamSize);

_mapperRamSize = GetMapperRamSize();
_mapperRam = new uint8_t[_mapperRamSize];
_emu->RegisterMemory(MemoryType::NesMapperRam, _mapperRam, _mapperRamSize);

_console->InitializeRam(_saveRam, _saveRamSize);
_console->InitializeRam(_workRam, _workRamSize);
_console->InitializeRam(_mapperRam, _mapperRamSize);

_nametableCount = GetNametableCount();
if(_nametableCount == 0) {
Expand Down Expand Up @@ -728,6 +760,7 @@ BaseMapper::~BaseMapper()
delete[] _prgRom;
delete[] _saveRam;
delete[] _workRam;
delete[] _mapperRam;
delete[] _nametableRam;
}

Expand Down Expand Up @@ -941,7 +974,16 @@ void BaseMapper::DebugWriteVram(uint16_t addr, uint8_t value, bool disableSideEf
void BaseMapper::WriteVram(uint16_t addr, uint8_t value)
{
_emu->ProcessPpuWrite<CpuType::Nes>(addr, value, MemoryType::NesPpuMemory);
MapperWriteVram(addr, value);
}

void BaseMapper::MapperWriteVram(uint16_t addr, uint8_t value)
{
InternalWriteVram(addr, value);
}

void BaseMapper::InternalWriteVram(uint16_t addr, uint8_t value)
{
if(_chrMemoryAccess[addr >> 8] & MemoryAccessType::Write) {
_chrPages[addr >> 8][(uint8_t)addr] = value;
}
Expand Down Expand Up @@ -969,16 +1011,19 @@ AddressInfo BaseMapper::GetAbsoluteAddress(uint16_t relativeAddr)
info.Address = relativeAddr & _internalRamMask;
info.Type = MemoryType::NesInternalRam;
} else {
uint8_t *prgAddr = _prgPages[relativeAddr >> 8] + (uint8_t)relativeAddr;
if(prgAddr >= _prgRom && prgAddr < _prgRom + _prgSize) {
info.Address = (uint32_t)(prgAddr - _prgRom);
uint8_t *addr = _prgPages[relativeAddr >> 8] + (uint8_t)relativeAddr;
if(addr >= _prgRom && addr < _prgRom + _prgSize) {
info.Address = (uint32_t)(addr - _prgRom);
info.Type = MemoryType::NesPrgRom;
} else if(prgAddr >= _workRam && prgAddr < _workRam + _workRamSize) {
info.Address = (uint32_t)(prgAddr - _workRam);
} else if(addr >= _workRam && addr < _workRam + _workRamSize) {
info.Address = (uint32_t)(addr - _workRam);
info.Type = MemoryType::NesWorkRam;
} else if(prgAddr >= _saveRam && prgAddr < _saveRam + _saveRamSize) {
info.Address = (uint32_t)(prgAddr - _saveRam);
} else if(addr >= _saveRam && addr < _saveRam + _saveRamSize) {
info.Address = (uint32_t)(addr - _saveRam);
info.Type = MemoryType::NesSaveRam;
} else if(addr >= _mapperRam && addr < _mapperRam + _mapperRamSize) {
info.Address = (uint32_t)(addr - _mapperRam);
info.Type = MemoryType::NesMapperRam;
} else {
info.Address = -1;
info.Type = MemoryType::None;
Expand All @@ -1000,6 +1045,9 @@ void BaseMapper::GetPpuAbsoluteAddress(uint16_t relativeAddr, AddressInfo& info)
} else if(addr >= _chrRam && addr < _chrRam + _chrRamSize) {
info.Address = (uint32_t)(addr - _chrRam);
info.Type = MemoryType::NesChrRam;
} else if(addr >= _mapperRam && addr < _mapperRam + _mapperRamSize) {
info.Address = (uint32_t)(addr - _mapperRam);
info.Type = MemoryType::NesMapperRam;
} else if(addr >= _nametableRam && addr < _nametableRam + _nametableCount * BaseMapper::NametableSize) {
info.Address = (uint32_t)(addr - _nametableRam);
info.Type = MemoryType::NesNametableRam;
Expand All @@ -1025,6 +1073,7 @@ AddressInfo BaseMapper::GetRelativeAddress(AddressInfo& addr)
case MemoryType::NesPrgRom: ptrAddress = _prgRom; break;
case MemoryType::NesWorkRam: ptrAddress = _workRam; break;
case MemoryType::NesSaveRam: ptrAddress = _saveRam; break;
case MemoryType::NesMapperRam: ptrAddress = _mapperRam; break;
case MemoryType::NesInternalRam: return { (int32_t)(addr.Address & _internalRamMask), MemoryType::NesMemory };
default: return { GetPpuRelativeAddress(addr), MemoryType::NesPpuMemory };
}
Expand All @@ -1049,6 +1098,7 @@ int32_t BaseMapper::GetPpuRelativeAddress(AddressInfo& addr)
case MemoryType::NesChrRom: ptrAddress = _chrRom; break;
case MemoryType::NesChrRam: ptrAddress = _chrRam; break;
case MemoryType::NesNametableRam: ptrAddress = _nametableRam; break;
case MemoryType::NesMapperRam: ptrAddress = _mapperRam; break;
case MemoryType::NesPaletteRam: return 0x3F00 | (addr.Address & 0x1F); break;
default: return -1;
}
Expand Down Expand Up @@ -1106,6 +1156,7 @@ CartridgeState BaseMapper::GetState()
state.SaveRamPageSize = GetSaveRamPageSize();

vector<MapperStateEntry> entries = GetMapperStateEntries();
assert(entries.size() <= 200);
state.CustomEntryCount = (uint32_t)entries.size();
for(int i = 0; i < entries.size(); i++) {
state.CustomEntries[i] = entries[i];
Expand Down
Loading

0 comments on commit d751502

Please sign in to comment.