1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-23 03:32:32 +00:00
CLK/Machines/MSX/Cartridges/KonamiWithSCC.hpp

87 lines
2.2 KiB
C++
Raw Normal View History

//
// KonamiWithSCC.hpp
// Clock Signal
//
// Created by Thomas Harte on 04/01/2018.
// Copyright 2018 Thomas Harte. All rights reserved.
//
#pragma once
#include "../MemorySlotHandler.hpp"
#include "../../../Components/KonamiSCC/KonamiSCC.hpp"
namespace MSX::Cartridge {
2023-01-13 04:02:24 +00:00
class KonamiWithSCCROMSlotHandler: public MemorySlotHandler {
public:
KonamiWithSCCROMSlotHandler(MSX::MemorySlot &slot, Konami::SCC &scc) :
slot_(slot), scc_(scc) {}
void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) final {
switch(address >> 11) {
default:
if(pc_is_outside_bios) confidence_counter_.add_miss();
break;
case 0x0a:
2018-02-12 01:32:45 +00:00
if(pc_is_outside_bios) {
if(address == 0x5000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
}
2023-01-16 03:51:17 +00:00
slot_.map(value * 0x2000, 0x4000, 0x2000);
break;
case 0x0e:
2018-02-12 01:32:45 +00:00
if(pc_is_outside_bios) {
if(address == 0x7000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
}
2023-01-16 03:51:17 +00:00
slot_.map(value * 0x2000, 0x6000, 0x2000);
break;
case 0x12:
2018-02-12 01:32:45 +00:00
if(pc_is_outside_bios) {
if(address == 0x9000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
}
if((value&0x3f) == 0x3f) {
scc_is_visible_ = true;
slot_.map_handler(0x8000, 0x2000);
} else {
scc_is_visible_ = false;
2023-01-16 03:51:17 +00:00
slot_.map(value * 0x2000, 0x8000, 0x2000);
}
break;
case 0x13:
if(scc_is_visible_) {
if(pc_is_outside_bios) confidence_counter_.add_hit();
scc_.write(address, value);
} else {
if(pc_is_outside_bios) confidence_counter_.add_miss();
}
break;
case 0x16:
2018-02-12 01:32:45 +00:00
if(pc_is_outside_bios) {
if(address == 0xb000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
}
2023-01-16 03:51:17 +00:00
slot_.map(value * 0x2000, 0xa000, 0x2000);
break;
}
}
uint8_t read(uint16_t address) final {
if(scc_is_visible_ && address >= 0x9800 && address < 0xa000) {
confidence_counter_.add_hit();
return scc_.read(address);
}
confidence_counter_.add_miss();
return 0xff;
}
virtual std::string debug_type() final {
2019-03-02 23:07:05 +00:00
return "KSCC";
}
private:
MSX::MemorySlot &slot_;
Konami::SCC &scc_;
bool scc_is_visible_ = false;
};
}