From d63a95983d98547e562a80cb91ad359133914916 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Fri, 9 Feb 2018 09:10:56 -0500 Subject: [PATCH] Adds a couple of hard-stop conditions to the MSX, and respect for hard stops. --- .../MultiMachine/Implementation/MultiCRTMachine.cpp | 2 +- Machines/MSX/Cartridges/ASCII16kb.hpp | 1 + Machines/MSX/Cartridges/ASCII8kb.hpp | 1 + Machines/MSX/Cartridges/Konami.hpp | 1 + Machines/MSX/Cartridges/KonamiWithSCC.hpp | 1 + Machines/MSX/MSX.cpp | 11 +++++++++++ 6 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiCRTMachine.cpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiCRTMachine.cpp index d83b937e6..2f6bc1433 100644 --- a/Analyser/Dynamic/MultiMachine/Implementation/MultiCRTMachine.cpp +++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiCRTMachine.cpp @@ -46,7 +46,7 @@ Outputs::Speaker::Speaker *MultiCRTMachine::get_speaker() { void MultiCRTMachine::run_for(const Cycles cycles) { for(const auto &machine: machines_) { CRTMachine::Machine *crt_machine = machine->crt_machine(); - if(crt_machine) crt_machine->run_for(cycles); + if(crt_machine && crt_machine->get_confidence() >= 0.01f) crt_machine->run_for(cycles); } if(delegate_) delegate_->multi_crt_did_run_machines(); diff --git a/Machines/MSX/Cartridges/ASCII16kb.hpp b/Machines/MSX/Cartridges/ASCII16kb.hpp index 73b4ac16f..35b5c22b7 100644 --- a/Machines/MSX/Cartridges/ASCII16kb.hpp +++ b/Machines/MSX/Cartridges/ASCII16kb.hpp @@ -20,6 +20,7 @@ class ASCII16kbROMSlotHandler: public ROMSlotHandler { map_(map), slot_(slot) {} void write(uint16_t address, uint8_t value) override { +// printf("A16 %04x ", address); switch(address >> 11) { default: confidence_counter_.add_miss(); diff --git a/Machines/MSX/Cartridges/ASCII8kb.hpp b/Machines/MSX/Cartridges/ASCII8kb.hpp index 76016e9ff..ae6e48656 100644 --- a/Machines/MSX/Cartridges/ASCII8kb.hpp +++ b/Machines/MSX/Cartridges/ASCII8kb.hpp @@ -20,6 +20,7 @@ class ASCII8kbROMSlotHandler: public ROMSlotHandler { map_(map), slot_(slot) {} void write(uint16_t address, uint8_t value) override { +// printf("A8 %04x ", address); switch(address >> 11) { default: confidence_counter_.add_miss(); diff --git a/Machines/MSX/Cartridges/Konami.hpp b/Machines/MSX/Cartridges/Konami.hpp index aa8be8c4c..047844a07 100644 --- a/Machines/MSX/Cartridges/Konami.hpp +++ b/Machines/MSX/Cartridges/Konami.hpp @@ -20,6 +20,7 @@ class KonamiROMSlotHandler: public ROMSlotHandler { map_(map), slot_(slot) {} void write(uint16_t address, uint8_t value) override { +// printf("K %04x ", address); switch(address >> 13) { default: confidence_counter_.add_miss(); diff --git a/Machines/MSX/Cartridges/KonamiWithSCC.hpp b/Machines/MSX/Cartridges/KonamiWithSCC.hpp index caf74c085..f5a579b42 100644 --- a/Machines/MSX/Cartridges/KonamiWithSCC.hpp +++ b/Machines/MSX/Cartridges/KonamiWithSCC.hpp @@ -21,6 +21,7 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler { map_(map), slot_(slot), scc_(scc) {} void write(uint16_t address, uint8_t value) override { +// printf("KSCC %04x ", address); switch(address >> 11) { default: confidence_counter_.add_miss(); diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index f8d5ee544..5bbcce091 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -158,6 +158,7 @@ class ConcreteMachine: } float get_confidence() override { + if(performed_unmapped_access_ || pc_zero_accesses_ > 1) return 0.0f; if(memory_slots_[1].handler) { return memory_slots_[1].handler->get_confidence(); } @@ -340,6 +341,13 @@ class ConcreteMachine: break; } } + + if(!address) { + pc_zero_accesses_++; + } + if(read_pointers_[address >> 13] == unpopulated_) { + performed_unmapped_access_ = true; + } case CPU::Z80::PartialMachineCycle::Read: if(read_pointers_[address >> 13]) { *cycle.value = read_pointers_[address >> 13][address & 8191]; @@ -653,6 +661,9 @@ class ConcreteMachine: std::string input_text_; MSX::KeyboardMapper keyboard_mapper_; + + int pc_zero_accesses_ = 0; + bool performed_unmapped_access_ = false; }; }