Mapper 189 support

This commit is contained in:
Souryo 2014-08-04 15:55:20 -04:00
parent 84e54c9b7d
commit 366d4aec80
5 changed files with 52 additions and 3 deletions

View File

@ -112,6 +112,7 @@
<ClInclude Include="InputDataMessage.h" />
<ClInclude Include="MessageType.h" />
<ClInclude Include="MMC2.h" />
<ClInclude Include="MMC3_189.h" />
<ClInclude Include="Movie.h" />
<ClInclude Include="MovieDataMessage.h" />
<ClInclude Include="Nanjing.h" />

View File

@ -188,6 +188,9 @@
<ClInclude Include="Nanjing.h">
<Filter>Header Files\Mappers</Filter>
</ClInclude>
<ClInclude Include="MMC3_189.h">
<Filter>Header Files\Mappers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CPU.cpp">

View File

@ -1,3 +1,5 @@
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
#include "CPU.h"
@ -61,7 +63,8 @@ class MMC3 : public BaseMapper
_wramWriteProtected = false;
}
void UpdateState()
protected:
virtual void UpdateState()
{
_currentRegister = _state.Reg8000 & 0x07;
_chrMode = (_state.Reg8000 & 0x80) >> 7;
@ -110,8 +113,7 @@ class MMC3 : public BaseMapper
}
protected:
void StreamState(bool saving)
virtual void StreamState(bool saving)
{
Stream<uint8_t>(_state.Reg8000);
Stream<uint8_t>(_state.RegA000);

41
Core/MMC3_189.h Normal file
View File

@ -0,0 +1,41 @@
#pragma once
#include "stdafx.h"
#include "MMC3.h"
class MMC3_189 : public MMC3
{
private:
uint8_t _prgReg = 0;
virtual uint16_t RegisterStartAddress() { return 0x4120; }
virtual void WriteRegister(uint16_t addr, uint8_t value)
{
if(addr <= 0x4FFF) {
_prgReg = value;
UpdateState();
} else {
MMC3::WriteRegister(addr, value);
}
}
virtual void UpdateState()
{
MMC3::UpdateState();
//"$4120-7FFF: [AAAA BBBB]"
//" 'A' and 'B' bits of the $4120 reg seem to be effectively OR'd."
uint8_t prgPage = (((_prgReg) | (_prgReg >> 4)) & 0x07) * 4;
SelectPRGPage(0, prgPage);
SelectPRGPage(1, prgPage+1);
SelectPRGPage(2, prgPage+2);
SelectPRGPage(3, prgPage+3);
}
virtual void StreamState(bool saving)
{
MMC3::StreamState(saving);
Stream<uint8_t>(_prgReg);
}
};

View File

@ -9,6 +9,7 @@
#include "MMC1.h"
#include "MMC2.h"
#include "MMC3.h"
#include "MMC3_189.h"
#include "Nanjing.h"
#include "NROM.h"
#include "UNROM.h"
@ -35,6 +36,7 @@ BaseMapper* MapperFactory::GetMapperFromID(uint8_t mapperID)
case 27: return new VRC2_4(VRCVariant::VRC4_27); //Untested
case 71: return new UNROM(); //TODO: "It's largely a clone of UNROM, and Camerica games were initially emulated under iNES Mapper 002 before 071 was assigned."
case 163: return new Nanjing();
case 189: return new MMC3_189();
default: Console::DisplayMessage(L"Unsupported mapper, cannot load file.");
}