mirror of
https://github.com/libretro/Mesen.git
synced 2025-03-03 22:07:10 +00:00
Bandai FCG/LZ93D50 (Mapper 16/153/157/159 support) - 24C01/24C02 EEPROM support is not implemented
This commit is contained in:
parent
f91d494744
commit
ecd82d7f91
122
Core/BandaiFcg.h
Normal file
122
Core/BandaiFcg.h
Normal file
@ -0,0 +1,122 @@
|
||||
#pragma once
|
||||
#include "BaseMapper.h"
|
||||
#include "CPU.h"
|
||||
|
||||
class BandaiFcg : public BaseMapper
|
||||
{
|
||||
private:
|
||||
bool _irqEnabled;
|
||||
uint16_t _irqCounter;
|
||||
uint16_t _irqReload;
|
||||
uint8_t _prgPage;
|
||||
uint8_t _prgBankSelect;
|
||||
uint8_t _chrRegs[8];
|
||||
|
||||
protected:
|
||||
uint16_t GetPRGPageSize() { return 0x4000; }
|
||||
uint16_t GetCHRPageSize() { return 0x400; }
|
||||
uint16_t RegisterStartAddress() { return 0x6000; }
|
||||
uint16_t RegisterEndAddress() { return 0xFFFF; }
|
||||
bool AllowRegisterRead() { return true; }
|
||||
|
||||
void InitMapper()
|
||||
{
|
||||
memset(_chrRegs, 0, sizeof(_chrRegs));
|
||||
_irqEnabled = false;
|
||||
_irqCounter = 0;
|
||||
_irqReload = 0;
|
||||
_prgPage = 0;
|
||||
_prgBankSelect = 0;
|
||||
|
||||
//Only allow reads from 0x6000 to 0xFFFF
|
||||
RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read);
|
||||
|
||||
if(_mapperID != 16 || GetPRGPageCount() >= 0x20) {
|
||||
//"For iNES Mapper 153 (with SRAM), the writeable ports must only be mirrored across $8000-$FFFF."
|
||||
//"Mappers 157 and 159 do not need to support the FCG-1 and -2 and so should only mirror the ports across $8000-$FFFF."
|
||||
RemoveRegisterRange(0x6000, 0x7FFF, MemoryOperation::Any);
|
||||
}
|
||||
|
||||
//Last bank
|
||||
SelectPRGPage(1, 0x0F);
|
||||
}
|
||||
|
||||
void StreamState(bool saving)
|
||||
{
|
||||
BaseMapper::StreamState(saving);
|
||||
|
||||
ArrayInfo<uint8_t> chrRegs{ _chrRegs, 8 };
|
||||
Stream(_irqEnabled, _irqCounter, _irqReload, _prgPage, _prgBankSelect, chrRegs);
|
||||
}
|
||||
|
||||
void ProcessCpuClock()
|
||||
{
|
||||
if(_irqEnabled) {
|
||||
//Checking counter before decrementing seems to be the only way to get both
|
||||
//Famicom Jump II - Saikyou no 7 Nin (J) and Magical Taruruuto-kun 2 - Mahou Daibouken (J)
|
||||
//to work without glitches with the same code.
|
||||
if(_irqCounter == 0) {
|
||||
CPU::SetIRQSource(IRQSource::External);
|
||||
}
|
||||
_irqCounter--;
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ReadRegister(uint16_t addr)
|
||||
{
|
||||
//Pretend EEPROM data is always 0
|
||||
return 0;
|
||||
}
|
||||
|
||||
void WriteRegister(uint16_t addr, uint8_t value)
|
||||
{
|
||||
switch(addr & 0x000F) {
|
||||
case 0x00: case 0x01: case 0x02: case 0x03: case 0x04: case 0x05: case 0x06: case 0x07:
|
||||
_chrRegs[addr & 0x07] = value;
|
||||
if(_mapperID == 153 || GetPRGPageCount() >= 0x20) {
|
||||
_prgBankSelect = 0;
|
||||
for(int i = 0; i < 8; i++) {
|
||||
_prgBankSelect |= (_chrRegs[i] & 0x01) << 4;
|
||||
}
|
||||
SelectPRGPage(0, _prgPage | _prgBankSelect);
|
||||
SelectPRGPage(1, 0x0F | _prgBankSelect);
|
||||
} else if(!HasChrRam() && _mapperID != 157) {
|
||||
SelectCHRPage(addr & 0x07, value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x08:
|
||||
_prgPage = value & 0x0F;
|
||||
SelectPRGPage(0, _prgPage | _prgBankSelect);
|
||||
break;
|
||||
|
||||
case 0x09:
|
||||
switch(value & 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;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x0A:
|
||||
//Wiki claims there is no reload value, however this seems to be the only way to make Famicom Jump II - Saikyou no 7 Nin work properly
|
||||
_irqEnabled = (value & 0x01) == 0x01;
|
||||
_irqCounter = _irqReload;
|
||||
CPU::ClearIRQSource(IRQSource::External);
|
||||
break;
|
||||
|
||||
case 0x0B:
|
||||
_irqReload = (_irqReload & 0xFF00) | value;
|
||||
break;
|
||||
|
||||
case 0x0C:
|
||||
_irqReload = (_irqReload & 0xFF) | (value << 8);
|
||||
break;
|
||||
|
||||
case 0x0D:
|
||||
//TODO: PRG RAM Enable / EEPROM Control
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
@ -267,6 +267,11 @@ void BaseMapper::InitializeChrRam(int32_t chrRamSize)
|
||||
}
|
||||
}
|
||||
|
||||
bool BaseMapper::HasChrRam()
|
||||
{
|
||||
return _chrRamSize > 0;
|
||||
}
|
||||
|
||||
void BaseMapper::AddRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation)
|
||||
{
|
||||
for(int i = startAddr; i <= endAddr; i++) {
|
||||
@ -386,6 +391,9 @@ void BaseMapper::Initialize(RomData &romData)
|
||||
//Assume there is CHR RAM if no CHR ROM exists
|
||||
_onlyChrRam = true;
|
||||
InitializeChrRam(romData.ChrRamSize);
|
||||
|
||||
//Map CHR RAM to 0x0000-0x1FFF by default when no CHR ROM exists
|
||||
SetPpuMemoryMapping(0x0000, 0x1FFF, 0, ChrMemoryType::ChrRam);
|
||||
_chrRomSize = _chrRamSize;
|
||||
} else if(romData.ChrRamSize >= 0) {
|
||||
InitializeChrRam(romData.ChrRamSize);
|
||||
|
@ -141,6 +141,7 @@ protected:
|
||||
|
||||
void RestoreOriginalPrgRam();
|
||||
void InitializeChrRam(int32_t chrRamSize = -1);
|
||||
bool HasChrRam();
|
||||
|
||||
void AddRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation = MemoryOperation::Any);
|
||||
void RemoveRegisterRange(uint16_t startAddr, uint16_t endAddr, MemoryOperation operation = MemoryOperation::Any);
|
||||
|
@ -386,6 +386,7 @@
|
||||
<ClInclude Include="ArkanoidController.h" />
|
||||
<ClInclude Include="AutoRomTest.h" />
|
||||
<ClInclude Include="Bandai74161_7432.h" />
|
||||
<ClInclude Include="BandaiFcg.h" />
|
||||
<ClInclude Include="BaseExpansionAudio.h" />
|
||||
<ClInclude Include="BaseFdsChannel.h" />
|
||||
<ClInclude Include="BaseMapper.h" />
|
||||
|
@ -71,6 +71,9 @@
|
||||
<Filter Include="Nes\Mappers\VRC">
|
||||
<UniqueIdentifier>{0de6642c-1ea6-4872-b21f-2c3009eee9ad}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Nes\Mappers\Bandai">
|
||||
<UniqueIdentifier>{2d5cebc1-c803-457f-bdeb-3c9dfba704ea}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="IAudioDevice.h">
|
||||
@ -196,9 +199,6 @@
|
||||
<ClInclude Include="Nina03_06.h">
|
||||
<Filter>Nes\Mappers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Bandai74161_7432.h">
|
||||
<Filter>Nes\Mappers</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BnRom.h">
|
||||
<Filter>Nes\Mappers</Filter>
|
||||
</ClInclude>
|
||||
@ -619,6 +619,12 @@
|
||||
<ClInclude Include="Vrc6Audio.h">
|
||||
<Filter>Nes\Mappers\VRC</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Bandai74161_7432.h">
|
||||
<Filter>Nes\Mappers\Bandai</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="BandaiFcg.h">
|
||||
<Filter>Nes\Mappers\Bandai</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="stdafx.cpp">
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "RomLoader.h"
|
||||
#include "AXROM.h"
|
||||
#include "Bandai74161_7432.h"
|
||||
#include "BandaiFcg.h"
|
||||
#include "BnRom.h"
|
||||
#include "BF909x.h"
|
||||
#include "BF9096.h"
|
||||
@ -115,7 +116,7 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
|
||||
case 12: return new MMC3_12();
|
||||
case 13: return new CpRom();
|
||||
case 15: return new Mapper15();
|
||||
case 16: break; //18 games
|
||||
case 16: return new BandaiFcg();
|
||||
case 18: return new JalecoSs88006();
|
||||
case 19: return new Namco163();
|
||||
case 21: return new VRC2_4(VRCVariant::VRC4a); //Conflicts: VRC4c
|
||||
@ -188,7 +189,10 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
|
||||
case 148: return new Sachen_148();
|
||||
case 149: return new Sachen_149();
|
||||
case 152: return new Bandai74161_7432(true);
|
||||
case 153: return new BandaiFcg();
|
||||
case 154: return new Namco108_154();
|
||||
case 157: return new BandaiFcg();
|
||||
case 159: return new BandaiFcg();
|
||||
case 163: return new Nanjing();
|
||||
case 180: return new UnRom_180();
|
||||
case 184: return new Sunsoft184();
|
||||
|
Loading…
x
Reference in New Issue
Block a user