This repository has been archived by the owner on Sep 11, 2023. It is now read-only.
forked from SourMesen/Mesen
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #102 from negativeExponent/mesenx
add mappers to mesen-x
- Loading branch information
Showing
23 changed files
with
1,068 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}; |
Oops, something went wrong.