1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-02 01:31:15 +00:00

Adds hasty attempt at dynamic analysis to the MSX ROM handlers.

Logging for now, for further experimentation.
This commit is contained in:
Thomas Harte 2018-01-22 21:50:56 -05:00
parent d213341d9c
commit 8fb4409ebb
6 changed files with 48 additions and 8 deletions

View File

@ -21,11 +21,15 @@ class ASCII16kbROMSlotHandler: public ROMSlotHandler {
void write(uint16_t address, uint8_t value) {
switch(address >> 11) {
default: break;
default:
confidence_counter_.add_miss();
break;
case 0xc:
if(address == 0x6000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x4000, 0x4000);
break;
case 0xe:
if(address == 0x7000 || address == 0x77ff) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x8000, 0x4000);
break;
}

View File

@ -21,17 +21,23 @@ class ASCII8kbROMSlotHandler: public ROMSlotHandler {
void write(uint16_t address, uint8_t value) {
switch(address >> 11) {
default: break;
default:
confidence_counter_.add_miss();
break;
case 0xc:
if(address == 0x6000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x4000, 0x2000);
break;
case 0xd:
if(address == 0x6800) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x6000, 0x2000);
break;
case 0xe:
if(address == 0x7000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x8000, 0x2000);
break;
case 0xf:
if(address == 0x7800) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0xa000, 0x2000);
break;
}

View File

@ -21,14 +21,19 @@ class KonamiROMSlotHandler: public ROMSlotHandler {
void write(uint16_t address, uint8_t value) {
switch(address >> 13) {
default: break;
default:
confidence_counter_.add_miss();
break;
case 3:
if(address == 0x6000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x6000, 0x2000);
break;
case 4:
if(address == 0x8000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x8000, 0x2000);
break;
case 5:
if(address == 0xa000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0xa000, 0x2000);
break;
}

View File

@ -22,14 +22,19 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler {
void write(uint16_t address, uint8_t value) override {
switch(address >> 11) {
default: break;
default:
confidence_counter_.add_miss();
break;
case 0x0a:
if(address == 0x5000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x4000, 0x2000);
break;
case 0x0e:
if(address == 0x7000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0x6000, 0x2000);
break;
case 0x12:
if(address == 0x9000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
if((value&0x3f) == 0x3f) {
scc_is_visible_ = true;
map_.unmap(slot_, 0x8000, 0x2000);
@ -39,9 +44,15 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler {
}
break;
case 0x13:
if(scc_is_visible_) scc_.write(address, value);
if(scc_is_visible_) {
confidence_counter_.add_hit();
scc_.write(address, value);
} else {
confidence_counter_.add_miss();
}
break;
case 0x16:
if(address == 0xb000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal();
map_.map(slot_, value * 8192, 0xa000, 0x2000);
break;
}
@ -49,8 +60,10 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler {
uint8_t read(uint16_t address) override {
if(scc_is_visible_ && address >= 0x9800 && address < 0xa000) {
confidence_counter_.add_hit();
return scc_.read(address);
}
confidence_counter_.add_miss();
return 0xff;
}

View File

@ -154,6 +154,10 @@ class ConcreteMachine:
void run_for(const Cycles cycles) override {
z80_.run_for(cycles);
if(memory_slots_[1].handler) {
printf("%0.2f\n", memory_slots_[1].handler->get_confidence());
}
}
void configure_as_target(const StaticAnalyser::Target &target) override {

View File

@ -10,6 +10,7 @@
#define ROMSlotHandler_hpp
#include "../../ClockReceiver/ClockReceiver.hpp"
#include "../../DynamicAnalyser/ConfidenceCounter.hpp"
#include <cstddef>
#include <cstdint>
@ -57,12 +58,19 @@ class ROMSlotHandler {
/// Empty causes all out-of-bounds accesses to read a vacant bus.
Empty
};
/*!
Returns the wrapping strategy to apply to mapping requests from this ROM slot.
*/
/*! @returns The wrapping strategy to apply to mapping requests from this ROM slot. */
virtual WrappingStrategy wrapping_strategy() const {
return WrappingStrategy::Repeat;
}
/*! @returns The probability that this handler is correct for the data it owns. */
float get_confidence() {
return confidence_counter_.get_probability();
}
protected:
DynamicAnalyser::ConfidenceCounter confidence_counter_;
};
}