1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 03:32:01 +00:00

Allows cartridges to filter based on the actor talking to them; corrects outstanding_machines access error.

This commit is contained in:
Thomas Harte 2018-02-10 17:11:16 -05:00
parent 43b682a5af
commit eb39617ad0
10 changed files with 41 additions and 38 deletions

View File

@ -34,10 +34,11 @@ void MultiCRTMachine::perform_parallel(const std::function<void(::CRTMachine::Ma
});
}
do {
while(true) {
std::unique_lock<std::mutex> lock(mutex);
condition.wait(lock);
} while(outstanding_machines);
if(!outstanding_machines) break;
}
}
void MultiCRTMachine::perform_serial(const std::function<void (::CRTMachine::Machine *)> &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.
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -16,7 +16,7 @@ DiskROM::DiskROM(const std::vector<uint8_t> &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);

View File

@ -22,7 +22,7 @@ class DiskROM: public ROMSlotHandler, public WD::WD1770 {
public:
DiskROM(const std::vector<uint8_t> &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;

View File

@ -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_;
};
}

View File

@ -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; }

View File

@ -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 = "<group>";