Skip to content
This repository has been archived by the owner on Sep 11, 2023. It is now read-only.

add mappers to mesen-x #102

Merged
merged 20 commits into from
Jun 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions Core/Bmc830752C.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#pragma once
#include "stdafx.h"
#include "BaseMapper.h"

class Bmc830752C : public BaseMapper
{
private:
uint8_t _regs[2];

protected:
uint16_t GetPRGPageSize() override { return 0x4000; }
uint16_t GetCHRPageSize() override { return 0x2000; }

void InitMapper() override
{
_regs[0] = _regs[1] = 0;
UpdateState();
}

void StreamState(bool saving) override
{
BaseMapper::StreamState(saving);
Stream(_regs[0], _regs[1]);
}

void UpdateState()
{
uint8_t bank = (_regs[1] & 0x0F) << 3;
SelectPRGPage(0, bank | (_regs[0] & 0x07));
SelectPRGPage(1, bank | 0x07);

SelectCHRPage(0, 0);

SetMirroringType((_regs[1] & 0x60) ? MirroringType::Horizontal : MirroringType::Vertical);
}

void WriteRegister(uint16_t addr, uint8_t value) override
{
if ((addr >= 0xA000) && (addr < 0xC000)) {
_regs[1] = value;
} else {
_regs[0] = value;
}

UpdateState();
}
};
18 changes: 18 additions & 0 deletions Core/Core.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@
<ClInclude Include="Mapper237.h" />
<ClInclude Include="Mapper183.h" />
<ClInclude Include="Mapper253.h" />
<ClInclude Include="Mapper541.h" />
<ClInclude Include="Mapper43.h" />
<ClInclude Include="Mapper83.h" />
<ClInclude Include="Mapper319.h" />
Expand All @@ -791,6 +792,7 @@
<ClInclude Include="Mapper60.h" />
<ClInclude Include="Mapper375.h" />
<ClInclude Include="Mapper380.h" />
<ClInclude Include="Mapper389.h" />
<ClInclude Include="Mapper449.h" />
<ClInclude Include="MMC1_155.h" />
<ClInclude Include="MMC3_114.h" />
Expand Down Expand Up @@ -818,6 +820,8 @@
<ClInclude Include="MMC3_391.h" />
<ClInclude Include="MMC3_393.h" />
<ClInclude Include="MMC3_395.h" />
<ClInclude Include="Mapper396.h" />
<ClInclude Include="MMC3_399.h" />
<ClInclude Include="MMC3_401.h" />
<ClInclude Include="MMC3_410.h" />
<ClInclude Include="MMC3_411.h" />
Expand All @@ -829,6 +833,7 @@
<ClInclude Include="MMC3_444.h" />
<ClInclude Include="MMC3_445.h" />
<ClInclude Include="MMC3_534.h" />
<ClInclude Include="MMC3_516.h" />
<ClInclude Include="Mapper57.h" />
<ClInclude Include="Mapper61.h" />
<ClInclude Include="Mapper62.h" />
Expand All @@ -839,6 +844,18 @@
<ClInclude Include="Mapper240.h" />
<ClInclude Include="Mapper242.h" />
<ClInclude Include="Mapper246.h" />
<ClInclude Include="Mapper453.h" />
<ClInclude Include="Mapper438.h" />
<ClInclude Include="Mapper437.h" />
<ClInclude Include="Mapper433.h" />
<ClInclude Include="Mapper429.h" />
<ClInclude Include="Mapper417.h" />
<ClInclude Include="Mapper416.h" />
<ClInclude Include="Mapper415.h" />
<ClInclude Include="Mapper414.h" />
<ClInclude Include="Mapper409.h" />
<ClInclude Include="Mapper403.h" />
<ClInclude Include="Mapper402.h" />
<ClInclude Include="Mapper58.h" />
<ClInclude Include="MMC3_115.h" />
<ClInclude Include="MMC3_37.h" />
Expand All @@ -861,6 +878,7 @@
<ClInclude Include="Namco163.h" />
<ClInclude Include="Namco163Audio.h" />
<ClInclude Include="MMC1_105.h" />
<ClInclude Include="MMC1_404.h" />
<ClInclude Include="NovelDiamond.h" />
<ClInclude Include="NsfCart31.h" />
<ClInclude Include="NsfeLoader.h" />
Expand Down
57 changes: 57 additions & 0 deletions Core/Core.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,12 @@
<ClInclude Include="Mapper319.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper541.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper396.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Sunsoft89.h">
<Filter>Nes\Mappers\Sunsoft</Filter>
</ClInclude>
Expand Down Expand Up @@ -805,6 +811,9 @@
<ClInclude Include="MMC3_534.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
<ClInclude Include="MMC3_516.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
<ClInclude Include="Waixing178.h">
<Filter>Nes\Mappers\Waixing</Filter>
</ClInclude>
Expand Down Expand Up @@ -832,6 +841,39 @@
<ClInclude Include="Mapper234.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper453.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper438.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper437.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper433.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper431.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper429.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper417.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper416.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper415.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper414.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper409.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="MMC3_197.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
Expand Down Expand Up @@ -931,6 +973,12 @@
<ClInclude Include="Mapper117.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper403.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper402.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="A12Watcher.h">
<Filter>Nes\Mappers</Filter>
</ClInclude>
Expand All @@ -943,6 +991,9 @@
<ClInclude Include="MMC1_105.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
<ClInclude Include="MMC1_404.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
<ClInclude Include="MMC1_550.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
Expand Down Expand Up @@ -1456,6 +1507,9 @@
<ClInclude Include="Mapper380.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper389.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
<ClInclude Include="Mapper449.h">
<Filter>Nes\Mappers\Unnamed</Filter>
</ClInclude>
Expand Down Expand Up @@ -1516,6 +1570,9 @@
<ClInclude Include="MMC3_395.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
<ClInclude Include="MMC3_399.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
<ClInclude Include="MMC3_401.h">
<Filter>Nes\Mappers\MMC</Filter>
</ClInclude>
Expand Down
63 changes: 63 additions & 0 deletions Core/MMC1_404.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#pragma once
#include "MMC1.h"

// JY012005 - 1998 Super HiK 8-in-1 (JY-021B) multicart.

class MMC1_404 : public MMC1
{
private:
uint8_t _outerPrgBank;
uint8_t _outerChrBank;
uint8_t _prgMask;
uint8_t _reg;

protected:
void InitMapper() override
{
AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write);
MMC1::InitMapper();
}

void Reset(bool softReset) override
{
MMC1::Reset(softReset);

_outerPrgBank = 0;
_outerChrBank = 0;
_prgMask = 0x0F;
_reg = 0;

UpdateState();
}

void StreamState(bool saving) override
{
MMC1::StreamState(saving);
Stream(_outerPrgBank, _outerChrBank, _prgMask, _reg);
}

void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType) override
{
MMC1::SelectCHRPage(slot, _outerChrBank | (page & 0x1F), memoryType);
}

void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType) override
{
MMC1::SelectPRGPage(slot, _outerPrgBank | (page & _prgMask), memoryType);
}

void WriteRegister(uint16_t addr, uint8_t value) override
{
if(addr < 0x8000) {
if (!(_reg & 0x80)) {
_reg = value;
_prgMask = (_reg & 0x40) ? 0x07 : 0x0F;
_outerPrgBank = ((_reg & 0x0F) << 3) & ~_prgMask;
_outerChrBank = ((_reg & 0x0F) << 5);
UpdateState();
}
} else {
MMC1::WriteRegister(addr, value);
}
}
};
55 changes: 55 additions & 0 deletions Core/MMC3_399.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#pragma once
#include "stdafx.h"
#include "MMC3.h"

class MMC3_399 : public MMC3
{
private:
uint8_t _regs[4];

protected:
virtual uint16_t GetPRGPageSize() override { return 0x2000; }
virtual uint16_t GetCHRPageSize() override { return 0x1000; }

virtual void InitMapper() override
{
_regs[0] = _regs[2] = 0;
_regs[1] = _regs[3] = 1;

MMC3::InitMapper();
}

virtual void StreamState(bool saving) override
{
MMC3::StreamState(saving);
Stream(_regs[0], _regs[1], _regs[2], _regs[3]);
}

void UpdatePrgMapping() override
{
SelectPRGPage(0, 0);
SelectPRGPage(1, _regs[0]);
SelectPRGPage(2, _regs[1]);
SelectPRGPage(3, -1);
}

void UpdateChrMapping() override
{
SelectCHRPage(0, _regs[2]);
SelectCHRPage(1, _regs[3]);
}

void WriteRegister(uint16_t addr, uint8_t value) override
{
if (addr < 0xA000) {
if (addr & 1) {
_regs[0 | (value >> 7)] = value;
} else {
_regs[2 | (value >> 7)] = value;
}
UpdateState();
} else {
MMC3::WriteRegister(addr, value);
}
}
};
40 changes: 40 additions & 0 deletions Core/MMC3_516.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#pragma once
#include "stdafx.h"
#include "MMC3_126.h"

class MMC3_516 : public MMC3
{
private:
uint8_t _outerReg;

protected:
void InitMapper() override
{
_outerReg = 0;
MMC3::InitMapper();
}

void StreamState(bool saving) override
{
MMC3::StreamState(saving);
Stream(_outerReg);
}

void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override
{
MMC3::SelectCHRPage(slot, ((_outerReg << 5) & 0x180) | (page & 0x7F), memoryType);
}

void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override
{
MMC3::SelectPRGPage(slot, ((_outerReg << 4) & 0x30) | (page & 0x0F), memoryType);
}

void WriteRegister(uint16_t addr, uint8_t value) override
{
if (addr & 0x10) {
_outerReg = addr & 0x0F;
}
MMC3::WriteRegister(addr, value);
}
};
Loading