From eb39617ad0bd6a6aa8ce589f66e880396389d7a5 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 10 Feb 2018 17:11:16 -0500 Subject: [PATCH] Allows cartridges to filter based on the actor talking to them; corrects outstanding_machines access error. --- .../Implementation/MultiCRTMachine.cpp | 13 +++++++------ Machines/MSX/Cartridges/ASCII16kb.hpp | 6 +++--- Machines/MSX/Cartridges/ASCII8kb.hpp | 10 +++++----- Machines/MSX/Cartridges/Konami.hpp | 12 ++++++------ Machines/MSX/Cartridges/KonamiWithSCC.hpp | 16 ++++++++-------- Machines/MSX/DiskROM.cpp | 2 +- Machines/MSX/DiskROM.hpp | 2 +- Machines/MSX/MSX.cpp | 4 +++- Machines/MSX/ROMSlotHandler.hpp | 2 +- .../Mac/Clock Signal.xcodeproj/project.pbxproj | 12 ++++++------ 10 files changed, 41 insertions(+), 38 deletions(-) diff --git a/Analyser/Dynamic/MultiMachine/Implementation/MultiCRTMachine.cpp b/Analyser/Dynamic/MultiMachine/Implementation/MultiCRTMachine.cpp index 5f6cb013a..a735b5a76 100644 --- a/Analyser/Dynamic/MultiMachine/Implementation/MultiCRTMachine.cpp +++ b/Analyser/Dynamic/MultiMachine/Implementation/MultiCRTMachine.cpp @@ -34,10 +34,11 @@ void MultiCRTMachine::perform_parallel(const std::function lock(mutex); condition.wait(lock); - } while(outstanding_machines); + if(!outstanding_machines) break; + } } void MultiCRTMachine::perform_serial(const std::function &function) { @@ -89,17 +90,17 @@ bool MultiCRTMachine::get_clock_is_unlimited() { } void MultiCRTMachine::did_change_machine_order() { - // TODO + // TODO: shuffle delegates and announce potential output rate changes. } void MultiCRTMachine::set_delegate(::CRTMachine::Machine::Delegate *delegate) { - // TODO + // TODO: } void MultiCRTMachine::machine_did_change_clock_rate(Machine *machine) { - // TODO + // TODO: consider passing along. } void MultiCRTMachine::machine_did_change_clock_is_unlimited(Machine *machine) { - // TODO + // TODO: consider passing along. } diff --git a/Machines/MSX/Cartridges/ASCII16kb.hpp b/Machines/MSX/Cartridges/ASCII16kb.hpp index 35b5c22b7..3b34f86a0 100644 --- a/Machines/MSX/Cartridges/ASCII16kb.hpp +++ b/Machines/MSX/Cartridges/ASCII16kb.hpp @@ -19,18 +19,18 @@ class ASCII16kbROMSlotHandler: public ROMSlotHandler { ASCII16kbROMSlotHandler(MSX::MemoryMap &map, int slot) : map_(map), slot_(slot) {} - void write(uint16_t address, uint8_t value) override { + void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override { // printf("A16 %04x ", address); switch(address >> 11) { default: confidence_counter_.add_miss(); break; case 0xc: - if(address == 0x6000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && address == 0x6000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x4000, 0x4000, 0x4000); break; case 0xe: - if(address == 0x7000 || address == 0x77ff) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && (address == 0x7000 || address == 0x77ff)) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x4000, 0x8000, 0x4000); break; } diff --git a/Machines/MSX/Cartridges/ASCII8kb.hpp b/Machines/MSX/Cartridges/ASCII8kb.hpp index ae6e48656..dab987e98 100644 --- a/Machines/MSX/Cartridges/ASCII8kb.hpp +++ b/Machines/MSX/Cartridges/ASCII8kb.hpp @@ -19,26 +19,26 @@ class ASCII8kbROMSlotHandler: public ROMSlotHandler { ASCII8kbROMSlotHandler(MSX::MemoryMap &map, int slot) : map_(map), slot_(slot) {} - void write(uint16_t address, uint8_t value) override { + void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override { // printf("A8 %04x ", address); switch(address >> 11) { default: confidence_counter_.add_miss(); break; case 0xc: - if(address == 0x6000 || address == 0x60ff) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && (address == 0x6000 || address == 0x60ff)) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0x4000, 0x2000); break; case 0xd: - if(address == 0x6800 || address == 0x68ff) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && (address == 0x6800 || address == 0x68ff)) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0x6000, 0x2000); break; case 0xe: - if(address == 0x7000 || address == 0x70ff) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && (address == 0x7000 || address == 0x70ff)) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0x8000, 0x2000); break; case 0xf: - if(address == 0x7800 || address == 0x78ff) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && (address == 0x7800 || address == 0x78ff)) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0xa000, 0x2000); break; } diff --git a/Machines/MSX/Cartridges/Konami.hpp b/Machines/MSX/Cartridges/Konami.hpp index 047844a07..5d15d38ce 100644 --- a/Machines/MSX/Cartridges/Konami.hpp +++ b/Machines/MSX/Cartridges/Konami.hpp @@ -19,22 +19,22 @@ class KonamiROMSlotHandler: public ROMSlotHandler { KonamiROMSlotHandler(MSX::MemoryMap &map, int slot) : map_(map), slot_(slot) {} - void write(uint16_t address, uint8_t value) override { -// printf("K %04x ", address); + void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override { +// printf("K %04x[%c] ", address, pc_is_outside_bios ? '.' : '+'); switch(address >> 13) { default: - confidence_counter_.add_miss(); + if(pc_is_outside_bios) confidence_counter_.add_miss(); break; case 3: - if(address == 0x6000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && address == 0x6000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0x6000, 0x2000); break; case 4: - if(address == 0x8000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && address == 0x8000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0x8000, 0x2000); break; case 5: - if(address == 0xa000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && address == 0xa000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0xa000, 0x2000); break; } diff --git a/Machines/MSX/Cartridges/KonamiWithSCC.hpp b/Machines/MSX/Cartridges/KonamiWithSCC.hpp index f5a579b42..b7327d0df 100644 --- a/Machines/MSX/Cartridges/KonamiWithSCC.hpp +++ b/Machines/MSX/Cartridges/KonamiWithSCC.hpp @@ -20,22 +20,22 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler { KonamiWithSCCROMSlotHandler(MSX::MemoryMap &map, int slot, Konami::SCC &scc) : map_(map), slot_(slot), scc_(scc) {} - void write(uint16_t address, uint8_t value) override { + void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override { // printf("KSCC %04x ", address); switch(address >> 11) { default: - confidence_counter_.add_miss(); + if(pc_is_outside_bios) confidence_counter_.add_miss(); break; case 0x0a: - if(address == 0x5000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && address == 0x5000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0x4000, 0x2000); break; case 0x0e: - if(address == 0x7000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && address == 0x7000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0x6000, 0x2000); break; case 0x12: - if(address == 0x9000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && address == 0x9000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); if((value&0x3f) == 0x3f) { scc_is_visible_ = true; map_.unmap(slot_, 0x8000, 0x2000); @@ -46,14 +46,14 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler { break; case 0x13: if(scc_is_visible_) { - confidence_counter_.add_hit(); + if(pc_is_outside_bios) confidence_counter_.add_hit(); scc_.write(address, value); } else { - confidence_counter_.add_miss(); + if(pc_is_outside_bios) confidence_counter_.add_miss(); } break; case 0x16: - if(address == 0xb000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); + if(pc_is_outside_bios && address == 0xb000) confidence_counter_.add_hit(); else confidence_counter_.add_equivocal(); map_.map(slot_, value * 0x2000, 0xa000, 0x2000); break; } diff --git a/Machines/MSX/DiskROM.cpp b/Machines/MSX/DiskROM.cpp index 4382768f4..2025098b9 100644 --- a/Machines/MSX/DiskROM.cpp +++ b/Machines/MSX/DiskROM.cpp @@ -16,7 +16,7 @@ DiskROM::DiskROM(const std::vector &rom) : set_is_double_density(true); } -void DiskROM::write(uint16_t address, uint8_t value) { +void DiskROM::write(uint16_t address, uint8_t value, bool pc_is_outside_bios) { switch(address) { case 0x7ff8: case 0x7ff9: case 0x7ffa: case 0x7ffb: set_register(address, value); diff --git a/Machines/MSX/DiskROM.hpp b/Machines/MSX/DiskROM.hpp index b7cce1c1d..bab03d380 100644 --- a/Machines/MSX/DiskROM.hpp +++ b/Machines/MSX/DiskROM.hpp @@ -22,7 +22,7 @@ class DiskROM: public ROMSlotHandler, public WD::WD1770 { public: DiskROM(const std::vector &rom); - void write(uint16_t address, uint8_t value) override; + void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) override; uint8_t read(uint16_t address) override; void run_for(HalfCycles half_cycles) override; diff --git a/Machines/MSX/MSX.cpp b/Machines/MSX/MSX.cpp index 43fa774b4..c5b61e83a 100644 --- a/Machines/MSX/MSX.cpp +++ b/Machines/MSX/MSX.cpp @@ -348,6 +348,7 @@ class ConcreteMachine: if(read_pointers_[address >> 13] == unpopulated_) { performed_unmapped_access_ = true; } + pc_address_ = address; // This is retained so as to be able to name the source of an access to cartridge handlers. case CPU::Z80::PartialMachineCycle::Read: if(read_pointers_[address >> 13]) { *cycle.value = read_pointers_[address >> 13][address & 8191]; @@ -365,7 +366,7 @@ class ConcreteMachine: if(memory_slots_[slot_hit].handler) { update_audio(); memory_slots_[slot_hit].handler->run_for(memory_slots_[slot_hit].cycles_since_update.flush()); - memory_slots_[slot_hit].handler->write(address, *cycle.value); + memory_slots_[slot_hit].handler->write(address, *cycle.value, read_pointers_[pc_address_ >> 13] != memory_slots_[0].read_pointers[pc_address_ >> 13]); } } break; @@ -664,6 +665,7 @@ class ConcreteMachine: int pc_zero_accesses_ = 0; bool performed_unmapped_access_ = false; + uint16_t pc_address_; }; } diff --git a/Machines/MSX/ROMSlotHandler.hpp b/Machines/MSX/ROMSlotHandler.hpp index 2ae628785..4dc567e6c 100644 --- a/Machines/MSX/ROMSlotHandler.hpp +++ b/Machines/MSX/ROMSlotHandler.hpp @@ -47,7 +47,7 @@ class ROMSlotHandler { virtual void run_for(HalfCycles half_cycles) {} /*! Announces an attempt to write @c value to @c address. */ - virtual void write(uint16_t address, uint8_t value) = 0; + virtual void write(uint16_t address, uint8_t value, bool pc_is_outside_bios) = 0; /*! Seeks the result of a read at @c address; this is used only if the area is unmapped. */ virtual uint8_t read(uint16_t address) { return 0xff; } diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index bf70503cc..617d6fc15 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -2674,16 +2674,16 @@ 4BBB70A1202011C2002FE009 /* Implementation */ = { isa = PBXGroup; children = ( - 4BBB70A2202011C2002FE009 /* MultiConfigurationTarget.hpp */, + 4B1B88BE202E3DB200B67DFF /* MultiConfigurable.cpp */, 4BBB70A3202011C2002FE009 /* MultiConfigurationTarget.cpp */, 4BBB70A6202014E2002FE009 /* MultiCRTMachine.cpp */, - 4BBB70A7202014E2002FE009 /* MultiCRTMachine.hpp */, - 4B1B88B9202E2EC100B67DFF /* MultiKeyboardMachine.cpp */, - 4B1B88BA202E2EC100B67DFF /* MultiKeyboardMachine.hpp */, - 4B1B88BE202E3DB200B67DFF /* MultiConfigurable.cpp */, - 4B1B88BF202E3DB200B67DFF /* MultiConfigurable.hpp */, 4B1B88C6202E469300B67DFF /* MultiJoystickMachine.cpp */, + 4B1B88B9202E2EC100B67DFF /* MultiKeyboardMachine.cpp */, + 4B1B88BF202E3DB200B67DFF /* MultiConfigurable.hpp */, + 4BBB70A2202011C2002FE009 /* MultiConfigurationTarget.hpp */, + 4BBB70A7202014E2002FE009 /* MultiCRTMachine.hpp */, 4B1B88C7202E469300B67DFF /* MultiJoystickMachine.hpp */, + 4B1B88BA202E2EC100B67DFF /* MultiKeyboardMachine.hpp */, ); path = Implementation; sourceTree = "";