2018-01-05 03:18:18 +00:00
|
|
|
//
|
|
|
|
// KonamiWithSCC.hpp
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 04/01/2018.
|
|
|
|
// Copyright © 2018 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef KonamiWithSCC_hpp
|
|
|
|
#define KonamiWithSCC_hpp
|
|
|
|
|
|
|
|
#include "../ROMSlotHandler.hpp"
|
2018-01-07 01:15:55 +00:00
|
|
|
#include "../../../Components/KonamiSCC/KonamiSCC.hpp"
|
2018-01-05 03:18:18 +00:00
|
|
|
|
|
|
|
namespace MSX {
|
|
|
|
namespace Cartridge {
|
|
|
|
|
|
|
|
class KonamiWithSCCROMSlotHandler: public ROMSlotHandler {
|
|
|
|
public:
|
2018-01-07 01:15:55 +00:00
|
|
|
KonamiWithSCCROMSlotHandler(MSX::MemoryMap &map, int slot, Konami::SCC &scc) :
|
|
|
|
map_(map), slot_(slot), scc_(scc) {}
|
2018-01-05 03:18:18 +00:00
|
|
|
|
2018-02-10 22:11:16 +00:00
|
|
|
void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override {
|
2018-02-09 14:10:56 +00:00
|
|
|
// printf("KSCC %04x ", address);
|
2018-01-05 03:18:18 +00:00
|
|
|
switch(address >> 11) {
|
2018-01-23 02:50:56 +00:00
|
|
|
default:
|
2018-02-10 22:11:16 +00:00
|
|
|
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
2018-01-23 02:50:56 +00:00
|
|
|
break;
|
2018-01-05 03:18:18 +00:00
|
|
|
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();
|
|
|
|
}
|
2018-01-23 03:13:16 +00:00
|
|
|
map_.map(slot_, value * 0x2000, 0x4000, 0x2000);
|
2018-01-05 03:18:18 +00:00
|
|
|
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();
|
|
|
|
}
|
2018-01-23 03:13:16 +00:00
|
|
|
map_.map(slot_, value * 0x2000, 0x6000, 0x2000);
|
2018-01-05 03:18:18 +00:00
|
|
|
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();
|
|
|
|
}
|
2018-01-07 01:15:55 +00:00
|
|
|
if((value&0x3f) == 0x3f) {
|
|
|
|
scc_is_visible_ = true;
|
|
|
|
map_.unmap(slot_, 0x8000, 0x2000);
|
|
|
|
} else {
|
|
|
|
scc_is_visible_ = false;
|
2018-01-23 03:13:16 +00:00
|
|
|
map_.map(slot_, value * 0x2000, 0x8000, 0x2000);
|
2018-01-07 01:15:55 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 0x13:
|
2018-01-23 02:50:56 +00:00
|
|
|
if(scc_is_visible_) {
|
2018-02-10 22:11:16 +00:00
|
|
|
if(pc_is_outside_bios) confidence_counter_.add_hit();
|
2018-01-23 02:50:56 +00:00
|
|
|
scc_.write(address, value);
|
|
|
|
} else {
|
2018-02-10 22:11:16 +00:00
|
|
|
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
2018-01-23 02:50:56 +00:00
|
|
|
}
|
2018-01-05 03:18:18 +00:00
|
|
|
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();
|
|
|
|
}
|
2018-01-23 03:13:16 +00:00
|
|
|
map_.map(slot_, value * 0x2000, 0xa000, 0x2000);
|
2018-01-05 03:18:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-07 01:15:55 +00:00
|
|
|
uint8_t read(uint16_t address) override {
|
|
|
|
if(scc_is_visible_ && address >= 0x9800 && address < 0xa000) {
|
2018-01-23 02:50:56 +00:00
|
|
|
confidence_counter_.add_hit();
|
2018-01-07 01:15:55 +00:00
|
|
|
return scc_.read(address);
|
|
|
|
}
|
2018-01-23 02:50:56 +00:00
|
|
|
confidence_counter_.add_miss();
|
2018-01-07 01:15:55 +00:00
|
|
|
return 0xff;
|
|
|
|
}
|
|
|
|
|
2018-02-01 12:53:52 +00:00
|
|
|
virtual void print_type() override {
|
|
|
|
printf("KSCC");
|
|
|
|
}
|
|
|
|
|
2018-01-05 03:18:18 +00:00
|
|
|
private:
|
|
|
|
MSX::MemoryMap &map_;
|
|
|
|
int slot_;
|
2018-01-07 01:15:55 +00:00
|
|
|
Konami::SCC &scc_;
|
|
|
|
bool scc_is_visible_ = false;
|
2018-01-05 03:18:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* KonamiWithSCC_hpp */
|