Namco 108 (Mapper 206, 76, 88, 95, 154) support

This commit is contained in:
Souryo 2016-01-01 12:34:16 -05:00
parent b821350385
commit 8fdc25c5d4
9 changed files with 165 additions and 22 deletions

View file

@ -270,6 +270,11 @@
<ClInclude Include="Bandai74161_7432.h" />
<ClInclude Include="BF909x.h" />
<ClInclude Include="BnRom.h" />
<ClInclude Include="Namco108.h" />
<ClInclude Include="Namco108_154.h" />
<ClInclude Include="Namco108_76.h" />
<ClInclude Include="Namco108_88.h" />
<ClInclude Include="Namco108_95.h" />
<ClInclude Include="Sachen_145.h" />
<ClInclude Include="CodeDataLogger.h" />
<ClInclude Include="CpRom.h" />

View file

@ -305,6 +305,21 @@
<ClInclude Include="Sachen_148.h">
<Filter>Header Files\Mappers</Filter>
</ClInclude>
<ClInclude Include="Namco108.h">
<Filter>Header Files\Mappers</Filter>
</ClInclude>
<ClInclude Include="Namco108_76.h">
<Filter>Header Files\Mappers</Filter>
</ClInclude>
<ClInclude Include="Namco108_88.h">
<Filter>Header Files\Mappers</Filter>
</ClInclude>
<ClInclude Include="Namco108_154.h">
<Filter>Header Files\Mappers</Filter>
</ClInclude>
<ClInclude Include="Namco108_95.h">
<Filter>Header Files\Mappers</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="CPU.cpp">

View file

@ -21,7 +21,6 @@ class MMC3 : public BaseMapper
};
uint8_t _currentRegister;
uint8_t _registers[8];
uint8_t _chrMode;
uint8_t _prgMode;
@ -64,31 +63,17 @@ class MMC3 : public BaseMapper
}
protected:
virtual void UpdateState()
{
_currentRegister = _state.Reg8000 & 0x07;
_chrMode = (_state.Reg8000 & 0x80) >> 7;
_prgMode = (_state.Reg8000 & 0x40) >> 6;
uint8_t _registers[8];
virtual void UpdateMirroring()
{
if(GetMirroringType() != MirroringType::FourScreens) {
SetMirroringType(((_state.RegA000 & 0x01) == 0x01) ? MirroringType::Horizontal : MirroringType::Vertical);
}
}
_wramEnabled = (_state.RegA001 & 0x80) == 0x80;
_wramWriteProtected = (_state.RegA001 & 0x40) == 0x40;
if(_prgMode == 0) {
SelectPRGPage(0, _registers[6]);
SelectPRGPage(1, _registers[7]);
SelectPRGPage(2, -2);
SelectPRGPage(3, -1);
} else if(_prgMode == 1) {
SelectPRGPage(0, -2);
SelectPRGPage(1, _registers[7]);
SelectPRGPage(2, _registers[6]);
SelectPRGPage(3, -1);
}
virtual void UpdateChrMapping()
{
if(_chrMode == 0) {
SelectCHRPage(0, _registers[0] & 0xFE);
SelectCHRPage(1, _registers[0] | 0x01);
@ -110,6 +95,32 @@ class MMC3 : public BaseMapper
SelectCHRPage(6, _registers[1] & 0xFE);
SelectCHRPage(7, _registers[1] | 0x01);
}
}
virtual void UpdateState()
{
_currentRegister = _state.Reg8000 & 0x07;
_chrMode = (_state.Reg8000 & 0x80) >> 7;
_prgMode = (_state.Reg8000 & 0x40) >> 6;
UpdateMirroring();
_wramEnabled = (_state.RegA001 & 0x80) == 0x80;
_wramWriteProtected = (_state.RegA001 & 0x40) == 0x40;
if(_prgMode == 0) {
SelectPRGPage(0, _registers[6]);
SelectPRGPage(1, _registers[7]);
SelectPRGPage(2, -2);
SelectPRGPage(3, -1);
} else if(_prgMode == 1) {
SelectPRGPage(0, -2);
SelectPRGPage(1, _registers[7]);
SelectPRGPage(2, _registers[6]);
SelectPRGPage(3, -1);
}
UpdateChrMapping();
SetCpuMemoryMapping(0x6000, 0x7FFF, 0, HasBattery() ? PrgMemoryType::SaveRam : PrgMemoryType::WorkRam);
}
@ -149,7 +160,7 @@ class MMC3 : public BaseMapper
UpdateState();
}
void WriteRegister(uint16_t addr, uint8_t value)
virtual void WriteRegister(uint16_t addr, uint8_t value)
{
switch((MMC3Registers)(addr & 0xE001)) {
case MMC3Registers::Reg8000:

View file

@ -18,6 +18,11 @@
#include "MMC3_189.h"
#include "MMC4.h"
#include "MMC5.h"
#include "Namco108.h"
#include "Namco108_76.h"
#include "Namco108_88.h"
#include "Namco108_95.h"
#include "Namco108_154.h"
#include "Nanjing.h"
#include "Nina01.h"
#include "Nina03_06.h"
@ -72,11 +77,14 @@ BaseMapper* MapperFactory::GetMapperFromID(ROMLoader &romLoader)
case 70: return new Bandai74161_7432(false);
case 71: return new BF909x();
case 75: return new VRC1();
case 76: return new Namco108_76();
case 79: return new Nina03_06(false);
case 80: return new TaitoX1005();
case 87: return new JalecoJfxx(false);
case 88: return new Namco108_88();
case 89: return new Sunsoft89();
case 93: return new Sunsoft93();
case 95: return new Namco108_95();
case 101: return new JalecoJfxx(true);
case 113: return new Nina03_06(true);
case 145: return new Sachen_145();
@ -85,10 +93,12 @@ BaseMapper* MapperFactory::GetMapperFromID(ROMLoader &romLoader)
case 148: return new Sachen_148();
case 149: return new Sachen_149();
case 152: return new Bandai74161_7432(true);
case 154: return new Namco108_154();
case 163: return new Nanjing();
case 184: return new Sunsoft184();
case 185: return new CNROM(true);
case 189: return new MMC3_189();
case 206: return new Namco108();
}
MessageManager::DisplayMessage("Error", "Unsupported mapper, cannot load game.");

29
Core/Namco108.h Normal file
View file

@ -0,0 +1,29 @@
#pragma once
#include "stdafx.h"
#include "MMC3.h"
class Namco108 : public MMC3
{
protected:
virtual void UpdateMirroring()
{
//Do nothing - Namco 108 has hardwired mirroring only
//"Mirroring is hardwired, one game uses 4-screen mirroring (Gauntlet, DRROM)."
}
void WriteRegister(uint16_t addr, uint8_t value)
{
//Redirect all 0x8000-0xFFFF writes to 0x8000-0x8001, all other features do not exist in this version
addr &= 0x8001;
if(addr == 0x8000) {
//Disable CHR Mode 1 and PRG Mode 1
//"PRG always has the last two 8KiB banks fixed to the end."
//"CHR always gives the left pattern table (0000-0FFF) the two 2KiB banks, and the right pattern table (1000-1FFF) the four 1KiB banks."
value &= 0x3F;
}
MMC3::WriteRegister(addr, value);
}
};

14
Core/Namco108_154.h Normal file
View file

@ -0,0 +1,14 @@
#pragma once
#include "stdafx.h"
#include "Namco108_88.h"
class Namco108_154 : public Namco108_88
{
protected:
virtual void WriteRegister(uint16_t addr, uint8_t value)
{
SetMirroringType((value & 0x40) == 0x40 ? MirroringType::ScreenBOnly : MirroringType::ScreenAOnly);
Namco108_88::WriteRegister(addr, value);
}
};

18
Core/Namco108_76.h Normal file
View file

@ -0,0 +1,18 @@
#pragma once
#include "stdafx.h"
#include "Namco108.h"
class Namco108_76 : public Namco108
{
virtual uint16_t GetCHRPageSize() { return 0x0800; }
protected:
virtual void UpdateChrMapping()
{
SelectCHRPage(0, _registers[2]);
SelectCHRPage(1, _registers[3]);
SelectCHRPage(2, _registers[4]);
SelectCHRPage(3, _registers[5]);
}
};

21
Core/Namco108_88.h Normal file
View file

@ -0,0 +1,21 @@
#pragma once
#include "stdafx.h"
#include "Namco108.h"
class Namco108_88 : public Namco108
{
protected:
virtual void UpdateChrMapping()
{
_registers[0] &= 0x3F;
_registers[1] &= 0x3F;
_registers[2] |= 0x40;
_registers[3] |= 0x40;
_registers[4] |= 0x40;
_registers[5] |= 0x40;
Namco108::UpdateChrMapping();
}
};

20
Core/Namco108_95.h Normal file
View file

@ -0,0 +1,20 @@
#pragma once
#include "stdafx.h"
#include "Namco108.h"
class Namco108_95 : public Namco108
{
protected:
virtual void WriteRegister(uint16_t addr, uint8_t value)
{
Namco108::WriteRegister(addr, value);
if(addr & 0x01) {
uint8_t nameTable1 = (_registers[0] >> 5) & 0x01;
uint8_t nameTable2 = (_registers[1] >> 5) & 0x01;
SetMirroringType(_nesNametableRam[nameTable1], _nesNametableRam[nameTable1], _nesNametableRam[nameTable2], _nesNametableRam[nameTable2]);
}
}
};