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

Mesenx #149

Merged
merged 2 commits into from
Jan 22, 2023
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
52 changes: 33 additions & 19 deletions Core/BmcResetNromX1n1.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,58 @@
#include "stdafx.h"
#include "BaseMapper.h"

// BMC-RESETNROM-XIN1
// - Sheng Tian 2-in-1(Unl,ResetBase)[p1] - Kung Fu (Spartan X), Super Mario Bros (alt)
// - Sheng Tian 2-in-1(Unl,ResetBase)[p2] - B-Wings, Twin-beeSMB1 (wrong mirroring)
// BMC-RESETNROM-XIN1 (Mapper 343)
// submapper 1 - Sheng Tian 2-in-1(Unl,ResetBase)[p1] - Kung Fu (Spartan X), Super Mario Bros (alt)
// submapper 1 - Sheng Tian 2-in-1(Unl,ResetBase)[p2] - B-Wings, Twin-beeSMB1 (wrong mirroring)

class BmcResetNromX1n1 : public BaseMapper
{
private:
uint8_t _game;

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

void InitMapper() override
{
_game = 0;

RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Write);
if (!_romInfo.IsNes20Header || !_romInfo.IsInDatabase) {
if (_romInfo.Hash.PrgChrCrc32 == 0x3470F395 || // Sheng Tian 2-in-1(Unl,ResetBase)[p1].unf
_romInfo.Hash.PrgChrCrc32 == 0x39F9140F) { // Sheng Tian 2-in-1(Unl,ResetBase)[p2].unf
_romInfo.SubMapperID = 1;
}
}
}

void Reset(bool softReset) override
{
if(softReset == true) {
_game++;
_game &= (GetPRGPageCount() - 1);
} else {
if(!softReset) {
_game = 0;
}

SelectPRGPage(0, _game);
SelectCHRPage(0, _game);
UpdateState();
}

if(_romInfo.Hash.PrgChrCrc32 == 0x3470F395) {
// Sheng Tian 2-in-1(Unl,ResetBase)[p1].unf
SetMirroringType(MirroringType::Vertical);
void StreamState(bool saving) override
{
BaseMapper::StreamState(saving);
Stream(_game);
}

void UpdateState()
{
if(_romInfo.SubMapperID == 1) {
SelectPrgPage2x(0, _game << 1);
} else {
// Sheng Tian 2-in-1(Unl,ResetBase)[p2].unf
SetMirroringType(MirroringType::Horizontal);
SelectPRGPage(0, _game);
SelectPRGPage(1, _game);
}
SelectCHRPage(0, _game);
SetMirroringType((_game & 0x80) ? MirroringType::Vertical : MirroringType::Horizontal);
}

void WriteRegister(uint16_t addr, uint8_t value) override
{
_game = ~value;
UpdateState();
}
};
5 changes: 4 additions & 1 deletion Core/MMC3_52.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class MMC3_52 : public MMC3
protected:
virtual uint16_t RegisterStartAddress() override { return 0x6000; }
virtual uint16_t RegisterEndAddress() override { return 0xFFFF; }
virtual uint16_t GetChrRamPageSize() override { return (_romInfo.SubMapperID == 13) ? 0x400 : 0; }

virtual void StreamState(bool saving) override
{
Expand All @@ -32,7 +33,9 @@ class MMC3_52 : public MMC3
page &= 0xFF;
page |= (((_extraReg & 0x20) >> 3) | ((_extraReg & 0x10) >> 4)) << 7;
}

if((_romInfo.SubMapperID == 13) && ((_extraReg & 3) == 3)) {
memoryType = ChrMemoryType::ChrRam;
}
MMC3::SelectCHRPage(slot, page, memoryType);
}

Expand Down
7 changes: 3 additions & 4 deletions Core/MapperFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,15 +777,16 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
case 340: return new BmcK3036();
case 341: return new BmcTj03();
case 342: break; //COOLGIRL
//343
case 343: return new BmcResetNromX1n1();
case 344: return new MMC3_BmcGn26();
case 345: return new MMC3_BmcL6in1();
case 346: return new Kaiser7012();
case 347: return new Kaiser7030();
case 348: return new Bmc830118C();
case 349: return new BmcG146();
case 350: return new Bmc891227();
// 351-352:
// 351
case 352: return new UnlKs106C();
case 353: return new MMC3_353();
case 356: return new MMC3_356();
case 357: return new Mapper357();
Expand Down Expand Up @@ -920,8 +921,6 @@ BaseMapper* MapperFactory::GetMapperFromID(RomData &romData)
case UnifBoards::Unl255in1: return new Unl255in1();
case UnifBoards::Unl8237A: return new Unl8237A(); //mapper 215.1
case UnifBoards::UnlPuzzle: return new UnlPuzzle();
case UnifBoards::Ks106C: return new UnlKs106C(); //mapper 352, sub 1
case UnifBoards::ResetNromX1n1: return new BmcResetNromX1n1(); //352

case MapperFactory::StudyBoxMapperID: return new StudyBox();
case MapperFactory::NsfMapperID: return new NsfMapper();
Expand Down
4 changes: 2 additions & 2 deletions Core/UnifLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ std::unordered_map<string, int> UnifLoader::_boardMappings = std::unordered_map<
{ "BJ-56", 526 },
{ "KS7021A", 525 },
{ "MINDKIDS", 268 },
{ "KS106C", UnifBoards::Ks106C },
{ "RESETNROM-XIN1", UnifBoards::ResetNromX1n1 },
{ "KS106C", 352 },
{ "RESETNROM-XIN1", 343 },
{ "T4A54A", 134 },
{ "WX-KB4K", 134 },
{ "BS-5652", 134 },
Expand Down
2 changes: 1 addition & 1 deletion Core/UnlKs106C.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "stdafx.h"
#include "BaseMapper.h"

// UNL-KS106C
// UNL-KS106C (Mapper 352)
// - Kaiser 4-in-1(Unl,KS106C)[p1] - B-Wings, Kung Fu, 1942, SMB1 (wrong mirroring)

class UnlKs106C : public BaseMapper
Expand Down