Mapper 83 support

This commit is contained in:
Souryo 2016-10-30 11:46:06 -04:00
parent 6870dbbeb0
commit 66c4f13106
4 changed files with 166 additions and 7 deletions

View file

@ -478,6 +478,7 @@
<ClInclude Include="Mapper234.h" />
<ClInclude Include="Mapper183.h" />
<ClInclude Include="Mapper253.h" />
<ClInclude Include="Mapper83.h" />
<ClInclude Include="MMC3_123.h" />
<ClInclude Include="MMC3_126.h" />
<ClInclude Include="MMC3_134.h" />

View file

@ -958,6 +958,9 @@
<ClInclude Include="Mapper220.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper83.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">

152
Core/Mapper83.h Normal file
View file

@ -0,0 +1,152 @@
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"
#include "CPU.h"
#include "MemoryManager.h"
class Mapper83 : public BaseMapper
{
uint8_t _regs[11];
uint8_t _exRegs[4];
bool _is2kBank;
bool _isNot2kBank;
uint8_t _mode;
uint8_t _bank;
uint16_t _irqCounter;
bool _irqEnabled;
uint8_t _resetBit;
protected:
virtual uint16_t GetPRGPageSize() { return 0x2000; }
virtual uint16_t GetCHRPageSize() { return 0x400; }
virtual bool AllowRegisterRead() { return true; }
void InitMapper()
{
memset(_regs, 0, sizeof(_regs));
memset(_exRegs, 0, sizeof(_exRegs));
_is2kBank = false;
_isNot2kBank = false;
_mode = 0;
_bank = 0;
_irqCounter = 0;
_irqEnabled = false;
_resetBit = 0;
AddRegisterRange(0x5000, 0x5000, MemoryOperation::Read);
AddRegisterRange(0x5100, 0x5103, MemoryOperation::Any);
RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read);
UpdateState();
}
void StreamState(bool saving) override
{
BaseMapper::StreamState(saving);
ArrayInfo<uint8_t> regs{ _regs, 11 };
ArrayInfo<uint8_t> exRegs{ _exRegs, 4 };
Stream(regs, exRegs, _is2kBank, _isNot2kBank, _mode, _bank, _irqCounter, _irqEnabled, _resetBit);
}
void Reset(bool softReset) override
{
if(softReset) {
_resetBit ^= 1;
}
}
void ProcessCpuClock() override
{
if(_irqEnabled) {
_irqCounter--;
if(_irqCounter == 0) {
_irqEnabled = false;
_irqCounter = 0xFFFF;
CPU::SetIRQSource(IRQSource::External);
}
}
}
void UpdateState()
{
switch(_mode & 0x03) {
case 0: SetMirroringType(MirroringType::Vertical); break;
case 1: SetMirroringType(MirroringType::Horizontal); break;
case 2: SetMirroringType(MirroringType::ScreenAOnly); break;
case 3: SetMirroringType(MirroringType::ScreenBOnly); break;
}
if(_is2kBank && !_isNot2kBank) {
SelectChrPage2x(0, _regs[0] << 1);
SelectChrPage2x(1, _regs[1] << 1);
SelectChrPage2x(2, _regs[6] << 1);
SelectChrPage2x(3, _regs[7] << 1);
} else {
for(int i = 0; i < 8; i++) {
SelectCHRPage(i, _regs[i] | ((_bank & 0x30) << 4));
}
}
if(_mode & 0x40) {
SelectPrgPage2x(0, (_bank & 0x3F) << 1);
SelectPrgPage2x(1, ((_bank & 0x30) | 0x0F) << 1);
} else {
SelectPRGPage(0, _regs[8]);
SelectPRGPage(1, _regs[9]);
SelectPRGPage(2, _regs[10]);
SelectPRGPage(3, -1);
}
}
uint8_t ReadRegister(uint16_t addr) override
{
if(addr == 0x5000) {
return (MemoryManager::GetOpenBus() & 0xFC) | _resetBit;
} else {
return _exRegs[addr & 0x03];
}
}
void WriteRegister(uint16_t addr, uint8_t value) override
{
if(addr < 0x8000) {
_exRegs[addr & 0x03] = value;
} else if(addr >= 0x8300 && addr <= 0x8302) {
_mode &= 0xBF;
_regs[addr - 0x8300 + 8] = value;
UpdateState();
} else if(addr >= 0x8310 && addr <= 0x8317) {
_regs[addr - 0x8310] = value;
if(addr >= 0x8312 && addr <= 0x8315) {
_isNot2kBank = true;
}
UpdateState();
} else {
switch(addr) {
case 0x8000: _is2kBank = true; //no break
case 0xB000: case 0xB0FF: case 0xB1FF:
// Dragon Ball Z Party [p1] BMC
_bank = value;
_mode |= 0x40;
UpdateState();
break;
case 0x8100:
_mode = value | (_mode & 0x40);
UpdateState();
break;
case 0x8200:
_irqCounter = (_irqCounter & 0xFF00) | value;
CPU::ClearIRQSource(IRQSource::External);
break;
case 0x8201:
_irqEnabled = (_mode & 0x80) == 0x80;
_irqCounter = (_irqCounter & 0xFF) | (value << 8);
break;
}
}
}
};

View file

@ -50,6 +50,7 @@
#include "Mapper60.h"
#include "Mapper61.h"
#include "Mapper62.h"
#include "Mapper83.h"
#include "Mapper91.h"
#include "Mapper103.h"
#include "Mapper106.h"
@ -192,22 +193,23 @@ Supported mappers:
... : bad mappers
--- : potentially bad mappers
=== : not supported by both Nestopia & FCEUX
??? : No known roms
-----------------------------------------------------------------
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10| 11| 12| 13| 14| 15|
| 16| 17| 18| 19|...| 21| 22| 23| 24| 25| 26| 27| 28| | | 31|
| 32| 33| 34| 35| 36| 37| 38|---| 40| 41| 42|---| 44| 45| 46| 47|
| 48| 49| 50| 51| 52| 53| | | 56| 57| 58|===| 60| 61| 62| 63|
| 48| 49| 50| 51| 52| 53|???|???| 56| 57| 58|===| 60| 61| 62| 63|
| 64| 65| 66| 67| 68| 69| 70| 71| 72| 73| 74| 75| 76| 77| 78| 79|
| 80|===| 82| |===| 85| 86| 87| 88| 89| 90| 91| 92| 93| 94| 95|
| 96| 97|===| 99|...|101|===|103| |105|106|107|108|===|===|===|
|112|113|114|115| |117|118|119|120|121|===|123|===| |126|===|
| 80|===| 82| 83|===| 85| 86| 87| 88| 89| 90| 91| 92| 93| 94| 95|
| 96| 97|===| 99|...|101|===|103|???|105|106|107|108|===|===|===|
|112|113|114|115| |117|118|119|120|121|===|123|===|???|126|===|
|===|===|===|===|132|133|134|===|136|137|138|139|140|141|142|143|
|144|145|146|147|148|149|150|151|152|153|154|155|156|157| |159|
|144|145|146|147|148|149|150|151|152|153|154|155|156|157|???|159|
|---|===|162|163|164|165|166|167|168|===|170|171|172|173|===|175|
|176|177|178|179|180|---|182|183|184|185|186|187|188|189|===|191|
|192|193|194|195|196|197| |199|200|201|202|203|204|205|206|207|
| |209|210|211|212|213|214|215|216|217|218|219|220|221|222| |
| |225|226|227|228|229|230|231|232|233|234|235| |===|238|===|
|???|209|210|211|212|213|214|215|216|217|218|219|220|221|222|???|
|???|225|226|227|228|229|230|231|232|233|234|235|???|===|238|===|
|240|241|242|243|244|245|246|===|===|249|250|===|252|253|254|255|
-----------------------------------------------------------------
*/
@ -304,6 +306,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
case 79: return new Nina03_06(false);
case 80: return new TaitoX1005(false);
case 82: return new TaitoX1017();
case 83: return new Mapper83();
case 85: return new VRC7();
case 86: return new JalecoJf13();
case 87: return new JalecoJfxx(false);