Skip to content

Commit 38c28db

Browse files
Mapper 258: Fixed support for Super Hang-on
1 parent a3ffb90 commit 38c28db

File tree

2 files changed

+23
-41
lines changed

2 files changed

+23
-41
lines changed

Core/MMC3_215.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,15 @@ class MMC3_215 : public MMC3
3131

3232
uint8_t _exRegs[3];
3333

34-
uint16_t RegisterStartAddress() override { return 0x5000; }
35-
uint16_t RegisterEndAddress() override { return 0xFFFF; }
36-
3734
void InitMapper() override
3835
{
3936
_exRegs[0] = 0;
4037
_exRegs[1] = 3;
41-
_exRegs[2] = 0;
38+
_exRegs[2] = 4;
4239

4340
MMC3::InitMapper();
41+
42+
AddRegisterRange(0x5000, 0x5FFF, MemoryOperation::Write);
4443
}
4544

4645
void StreamState(bool saving) override

Core/Unl158B.h

Lines changed: 20 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,50 @@
11
#pragma once
22
#include "stdafx.h"
3-
#include "MMC3.h"
4-
#include "MemoryManager.h"
3+
#include "MMC3_215.h"
54

6-
class Unl158B : public MMC3
5+
class Unl158B : public MMC3_215
76
{
87
private:
9-
const uint8_t _protectionLut[8] = { 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0F, 0x00 };
8+
const uint8_t _protectionLut[8][8] = {
9+
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
10+
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00 },
11+
{ 0x00, 0x00, 0x00, 0x00, 0x03, 0x04, 0x00, 0x00 },
12+
{ 0x00, 0x00, 0x00, 0x01, 0x00, 0x04, 0x05, 0x00 },
13+
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
14+
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
15+
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
16+
{ 0x00, 0x00, 0x00, 0x01, 0x02, 0x04, 0x0F, 0x00 }
17+
};
18+
1019
uint8_t _reg;
1120

1221
protected:
1322
bool AllowRegisterRead() override { return true; }
1423

1524
void InitMapper() override
1625
{
17-
_reg = 0;
26+
_reg = 7;
27+
MMC3_215::InitMapper();
1828
AddRegisterRange(0x5000, 0x5FFF, MemoryOperation::Any);
1929
RemoveRegisterRange(0x8000, 0xFFFF, MemoryOperation::Read);
20-
MMC3::InitMapper();
21-
}
22-
23-
void Reset(bool softReset) override
24-
{
25-
_reg = 0;
26-
ResetMmc3();
27-
MMC3::Reset(softReset);
2830
}
2931

3032
void StreamState(bool saving) override
3133
{
32-
MMC3::StreamState(saving);
34+
MMC3_215::StreamState(saving);
3335
Stream(_reg);
3436
}
3537

36-
void SelectPRGPage(uint16_t slot, uint16_t page, PrgMemoryType memoryType = PrgMemoryType::PrgRom) override
37-
{
38-
if(_reg & 0x80) {
39-
uint32_t bank = _reg & 0x07;
40-
if(_reg & 0x20) {
41-
SelectPrgPage4x(0, (bank & 0x06) << 1);
42-
} else {
43-
SelectPrgPage2x(0, bank << 1);
44-
SelectPrgPage2x(1, bank << 1);
45-
}
46-
} else {
47-
MMC3::SelectPRGPage(slot, page & 0x0F);
48-
}
49-
}
50-
5138
uint8_t ReadRegister(uint16_t addr) override
5239
{
53-
return _console->GetMemoryManager()->GetOpenBus() | _protectionLut[addr & 0x07];
40+
return (_console->GetMemoryManager()->GetOpenBus() & 0xF0) | _protectionLut[_reg][addr & 0x07];
5441
}
5542

5643
void WriteRegister(uint16_t addr, uint8_t value) override
5744
{
58-
if(addr <= 0x5FFF) {
59-
if((addr & 0x07) == 0) {
60-
_reg = value;
61-
UpdatePrgMapping();
62-
}
63-
} else {
64-
MMC3::WriteRegister(addr, value);
45+
if((addr <= 0x5FFF) && ((addr & 0xF007) == 0x5002)) {
46+
_reg = value & 0x07;
6547
}
48+
MMC3_215::WriteRegister(addr, value);
6649
}
6750
};

0 commit comments

Comments
 (0)