CNROM (iNES mapper 3) support
This commit is contained in:
parent
eaa528ded8
commit
617f5ead23
7 changed files with 89 additions and 45 deletions
|
@ -154,46 +154,4 @@ class BaseMapper : public IMemoryHandler
|
|||
{
|
||||
_chrPages[AddrToCHRSlot(addr)][addr & (GetCHRPageSize() - 1)] = value;
|
||||
}
|
||||
};
|
||||
|
||||
class DefaultMapper : public BaseMapper
|
||||
{
|
||||
protected:
|
||||
virtual uint32_t GetPRGPageSize() { return 0x4000; }
|
||||
virtual uint32_t GetCHRPageSize() { return 0x2000; }
|
||||
|
||||
virtual void InitMapper()
|
||||
{
|
||||
if(_prgSize == 0x4000) {
|
||||
SelectPRGPage(0, 0);
|
||||
SelectPRGPage(1, 0);
|
||||
} else {
|
||||
SelectPRGPage(0, 0);
|
||||
SelectPRGPage(1, 1);
|
||||
}
|
||||
|
||||
SelectCHRPage(0, 0);
|
||||
}
|
||||
};
|
||||
|
||||
class Mapper2 : public BaseMapper
|
||||
{
|
||||
protected:
|
||||
virtual uint32_t GetPRGPageSize() { return 0x4000; }
|
||||
virtual uint32_t GetCHRPageSize() { return 0x2000; }
|
||||
|
||||
void InitMapper()
|
||||
{
|
||||
//First and last PRG page
|
||||
SelectPRGPage(0, 0);
|
||||
SelectPRGPage(1, 0xFF);
|
||||
|
||||
SelectCHRPage(0, 0);
|
||||
}
|
||||
|
||||
public:
|
||||
void WriteRAM(uint16_t addr, uint8_t value)
|
||||
{
|
||||
SelectPRGPage(0, value);
|
||||
}
|
||||
};
|
22
Core/CNROM.h
Normal file
22
Core/CNROM.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "BaseMapper.h"
|
||||
|
||||
class CNROM : public BaseMapper
|
||||
{
|
||||
protected:
|
||||
virtual uint32_t GetPRGPageSize() { return 0x8000; }
|
||||
virtual uint32_t GetCHRPageSize() { return 0x2000; }
|
||||
|
||||
void InitMapper()
|
||||
{
|
||||
SelectPRGPage(0, 0);
|
||||
SelectCHRPage(0, 0);
|
||||
}
|
||||
|
||||
public:
|
||||
void WriteRAM(uint16_t addr, uint8_t value)
|
||||
{
|
||||
SelectCHRPage(0, value);
|
||||
}
|
||||
};
|
|
@ -89,6 +89,7 @@
|
|||
<ItemGroup>
|
||||
<ClInclude Include="APU.h" />
|
||||
<ClInclude Include="BaseMapper.h" />
|
||||
<ClInclude Include="CNROM.h" />
|
||||
<ClInclude Include="ControlManager.h" />
|
||||
<ClInclude Include="IAudioDevice.h" />
|
||||
<ClInclude Include="IControlDevice.h" />
|
||||
|
@ -108,12 +109,14 @@
|
|||
<ClInclude Include="Nes_Apu\Nes_Oscs.h" />
|
||||
<ClInclude Include="Nes_Apu\Nes_Vrc6.h" />
|
||||
<ClInclude Include="Nes_Apu\Nonlinear_Buffer.h" />
|
||||
<ClInclude Include="NROM.h" />
|
||||
<ClInclude Include="PPU.h" />
|
||||
<ClInclude Include="CPU.h" />
|
||||
<ClInclude Include="MemoryManager.h" />
|
||||
<ClInclude Include="ROMLoader.h" />
|
||||
<ClInclude Include="stdafx.h" />
|
||||
<ClInclude Include="targetver.h" />
|
||||
<ClInclude Include="UNROM.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="APU.cpp" />
|
||||
|
|
|
@ -105,6 +105,15 @@
|
|||
<ClInclude Include="MMC1.h">
|
||||
<Filter>Header Files\Mappers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="NROM.h">
|
||||
<Filter>Header Files\Mappers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CNROM.h">
|
||||
<Filter>Header Files\Mappers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="UNROM.h">
|
||||
<Filter>Header Files\Mappers</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CPU.cpp">
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#include "stdafx.h"
|
||||
#include "BaseMapper.h"
|
||||
#include "NROM.h"
|
||||
#include "MMC1.h"
|
||||
#include "UNROM.h"
|
||||
#include "CNROM.h"
|
||||
#include "ROMLoader.h"
|
||||
|
||||
class MapperFactory
|
||||
|
@ -14,9 +16,11 @@ class MapperFactory
|
|||
|
||||
BaseMapper* mapper = nullptr;
|
||||
switch(mapperID) {
|
||||
case 0: mapper = new DefaultMapper(); break;
|
||||
case 0: mapper = new NROM(); break;
|
||||
case 1: mapper = new MMC1(); break;
|
||||
case 2: mapper = new Mapper2(); break;
|
||||
case 2: mapper = new UNROM(); break;
|
||||
case 3: mapper = new CNROM(); break;
|
||||
//case 4: mapper = new MMC3(); break;
|
||||
}
|
||||
|
||||
if(!mapper) {
|
||||
|
|
23
Core/NROM.h
Normal file
23
Core/NROM.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "BaseMapper.h"
|
||||
|
||||
class NROM : public BaseMapper
|
||||
{
|
||||
protected:
|
||||
virtual uint32_t GetPRGPageSize() { return 0x4000; }
|
||||
virtual uint32_t GetCHRPageSize() { return 0x2000; }
|
||||
|
||||
virtual void InitMapper()
|
||||
{
|
||||
if(_prgSize == 0x4000) {
|
||||
SelectPRGPage(0, 0);
|
||||
SelectPRGPage(1, 0);
|
||||
} else {
|
||||
SelectPRGPage(0, 0);
|
||||
SelectPRGPage(1, 1);
|
||||
}
|
||||
|
||||
SelectCHRPage(0, 0);
|
||||
}
|
||||
};
|
25
Core/UNROM.h
Normal file
25
Core/UNROM.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
#include "stdafx.h"
|
||||
#include "BaseMapper.h"
|
||||
|
||||
class UNROM : public BaseMapper
|
||||
{
|
||||
protected:
|
||||
virtual uint32_t GetPRGPageSize() { return 0x4000; }
|
||||
virtual uint32_t GetCHRPageSize() { return 0x2000; }
|
||||
|
||||
void InitMapper()
|
||||
{
|
||||
//First and last PRG page
|
||||
SelectPRGPage(0, 0);
|
||||
SelectPRGPage(1, -1);
|
||||
|
||||
SelectCHRPage(0, 0);
|
||||
}
|
||||
|
||||
public:
|
||||
void WriteRAM(uint16_t addr, uint8_t value)
|
||||
{
|
||||
SelectPRGPage(0, value);
|
||||
}
|
||||
};
|
Loading…
Add table
Reference in a new issue