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 #23 from NovaSquirrel/master
Mapper updates
- Loading branch information
Showing
55 changed files
with
1,731 additions
and
468 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
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,65 @@ | ||
#pragma once | ||
#include "stdafx.h" | ||
#include "MMC3.h" | ||
|
||
class Bmc1024CA1 : public MMC3 | ||
{ | ||
private: | ||
uint8_t _exReg; | ||
|
||
protected: | ||
uint16_t GetChrRamPageSize() override { return 0x400; } | ||
uint32_t GetChrRamSize() override { return 0x2000; } | ||
uint32_t GetWorkRamSize() override { return 0x2000; } | ||
uint32_t GetWorkRamPageSize() override { return 0x2000; } | ||
bool ForceWorkRamSize() override { return true; } | ||
|
||
void InitMapper() override | ||
{ | ||
AddRegisterRange(0x6000, 0x7FFF, MemoryOperation::Write); | ||
_exReg = 0; | ||
MMC3::InitMapper(); | ||
} | ||
|
||
void StreamState(bool saving) override | ||
{ | ||
MMC3::StreamState(saving); | ||
Stream(_exReg); | ||
} | ||
|
||
void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override | ||
{ | ||
if (_exReg & 0x10) { | ||
MMC3::SelectCHRPage(slot, page, ChrMemoryType::ChrRam); | ||
} else if (_exReg & 0x20) { | ||
MMC3::SelectCHRPage(slot, ((_exReg & 0x07) << 7) | (page & 0xFF)); | ||
} else { | ||
MMC3::SelectCHRPage(slot, ((_exReg & 0x07) << 7) | (page & 0x7F)); | ||
} | ||
} | ||
|
||
void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override | ||
{ | ||
if(_exReg & 0x08) { | ||
MMC3::SelectPRGPage(slot, ((_exReg & 0x07) << 4) | (page & 0x1F)); | ||
} else { | ||
MMC3::SelectPRGPage(slot, ((_exReg & 0x07) << 4) | (page & 0x0F)); | ||
} | ||
} | ||
|
||
void WriteRegister(uint16_t addr, uint8_t value) override | ||
{ | ||
if(addr <= 0x7FFF) { | ||
if(CanWriteToWorkRam()) { | ||
WritePrgRam(addr, value); | ||
if ((_exReg & 0x07) == 0) { | ||
_exReg = addr & 0x3F; | ||
UpdatePrgMapping(); | ||
UpdateChrMapping(); | ||
} | ||
} | ||
} 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
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,59 @@ | ||
#pragma once | ||
#include "stdafx.h" | ||
#include "MMC3.h" | ||
|
||
class Bmc830134C : public MMC3 | ||
{ | ||
private: | ||
uint8_t _exReg; | ||
|
||
protected: | ||
void InitMapper() override | ||
{ | ||
_exReg = 0; | ||
MMC3::InitMapper(); | ||
AddRegisterRange(0x6800, 0x68FF, MemoryOperation::Write); | ||
} | ||
|
||
void Reset(bool softReset) override | ||
{ | ||
_exReg = 0; | ||
MMC3::Reset(softReset); | ||
UpdateState(); | ||
} | ||
|
||
void StreamState(bool saving) override | ||
{ | ||
MMC3::StreamState(saving); | ||
Stream(_exReg); | ||
} | ||
|
||
void SelectCHRPage(uint16_t slot, uint16_t page, ChrMemoryType memoryType = ChrMemoryType::Default) override | ||
{ | ||
MMC3::SelectCHRPage(slot, ((_exReg & 0x01) << 8) | ((_exReg & 0x02) << 6) | ((_exReg & 0x08) << 3) | (page & 0xFF)); | ||
} | ||
|
||
void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override | ||
{ | ||
if((_exReg & 0x06) == 0x06) { | ||
if(slot == 0) { | ||
MMC3::SelectPRGPage(0, ((_exReg & 0x06) << 3) | (page & 0x0F)); | ||
MMC3::SelectPRGPage(2, 0x32 | (page & 0x0F)); | ||
} else if (slot == 1) { | ||
MMC3::SelectPRGPage(1, ((_exReg & 0x06) << 3) | (page & 0x0F)); | ||
MMC3::SelectPRGPage(3, 0x32 | (page & 0x0F)); | ||
} | ||
} else | ||
MMC3::SelectPRGPage(slot, ((_exReg & 0x06) << 3) | (page & 0x0F)); | ||
} | ||
|
||
void WriteRegister(uint16_t addr, uint8_t value) override | ||
{ | ||
if(addr < 0x8000) { | ||
_exReg = 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,67 @@ | ||
#pragma once | ||
#include "stdafx.h" | ||
#include "BaseMapper.h" | ||
|
||
class Bmc891227 : public BaseMapper | ||
{ | ||
private: | ||
uint8_t _reg; | ||
|
||
protected: | ||
virtual uint16_t GetPRGPageSize() override { return 0x4000; } | ||
virtual uint16_t GetCHRPageSize() override { return 0x2000; } | ||
|
||
void InitMapper() override | ||
{ | ||
SelectCHRPage(0, 0); | ||
} | ||
|
||
void Reset(bool softReset) override | ||
{ | ||
if(!softReset) { | ||
_reg = 0; | ||
} | ||
UpdateState(); | ||
} | ||
|
||
void StreamState(bool saving) override | ||
{ | ||
BaseMapper::StreamState(saving); | ||
Stream(_reg); | ||
} | ||
|
||
void UpdateState() { | ||
uint8_t prgPage = _reg & 0x1F; | ||
|
||
SetCpuMemoryMapping(0x6000, 0x7FFF, PrgMemoryType::PrgRom, 0x2000, MemoryAccessType::Read); | ||
|
||
switch((_reg & 0x60) >> 5) { | ||
case 0: // NROM-128 | ||
SelectPRGPage(0, _reg & 0x1F); | ||
SelectPRGPage(1, _reg & 0x1F); | ||
break; | ||
|
||
case 1: // NROM-256 | ||
SelectPrgPage2x(0, _reg & 0x1E); | ||
break; | ||
|
||
default: // UNROM | ||
SelectPRGPage(0, _reg & 0x3F); | ||
SelectPRGPage(1, (_reg & 0x3F) | 7); | ||
break; | ||
} | ||
SetMirroringType(_reg & 0x80 ? MirroringType::Horizontal : MirroringType::Vertical); | ||
} | ||
|
||
void WriteRegister(uint16_t addr, uint8_t value) override | ||
{ | ||
if(addr < 0xC000) { | ||
_reg &= 0x07; | ||
_reg |= value & ~0x07; | ||
} else { | ||
_reg &= _reg & ~0x07; | ||
_reg |= value & 0x07; | ||
} | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
#include "stdafx.h" | ||
#include "BaseMapper.h" | ||
|
||
class BmcCtc09 : public BaseMapper | ||
{ | ||
protected: | ||
uint16_t GetPRGPageSize() override { return 0x4000; } | ||
uint16_t GetCHRPageSize() override { return 0x2000; } | ||
|
||
void InitMapper() override | ||
{ | ||
WriteRegister(0x8000, 0); | ||
WriteRegister(0xC000, 0); | ||
} | ||
|
||
void WriteRegister(uint16_t addr, uint8_t value) override | ||
{ | ||
if(addr >= 0xC000) { | ||
if (value & 0x10) { | ||
SelectPRGPage(0, ((value << 1) & 0x0E) | ((value >> 3) & 0x01)); | ||
SelectPRGPage(1, ((value << 1) & 0x0E) | ((value >> 3) & 0x01)); | ||
} else { | ||
SelectPrgPage2x(0, (value & 0x07) << 1); | ||
} | ||
SetMirroringType(((value & 0x40) == 0x40) ? MirroringType::Horizontal : MirroringType::Vertical); | ||
} else { | ||
SelectCHRPage(0, value & 0x0F); | ||
} | ||
} | ||
}; |
Oops, something went wrong.