mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-23 05:29:23 +00:00
Allows cartridges to filter based on the actor talking to them; corrects outstanding_machines access error.
This commit is contained in:
parent
43b682a5af
commit
eb39617ad0
@ -34,10 +34,11 @@ void MultiCRTMachine::perform_parallel(const std::function<void(::CRTMachine::Ma
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
while(true) {
|
||||||
std::unique_lock<std::mutex> lock(mutex);
|
std::unique_lock<std::mutex> lock(mutex);
|
||||||
condition.wait(lock);
|
condition.wait(lock);
|
||||||
} while(outstanding_machines);
|
if(!outstanding_machines) break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiCRTMachine::perform_serial(const std::function<void (::CRTMachine::Machine *)> &function) {
|
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() {
|
void MultiCRTMachine::did_change_machine_order() {
|
||||||
// TODO
|
// TODO: shuffle delegates and announce potential output rate changes.
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiCRTMachine::set_delegate(::CRTMachine::Machine::Delegate *delegate) {
|
void MultiCRTMachine::set_delegate(::CRTMachine::Machine::Delegate *delegate) {
|
||||||
// TODO
|
// TODO:
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiCRTMachine::machine_did_change_clock_rate(Machine *machine) {
|
void MultiCRTMachine::machine_did_change_clock_rate(Machine *machine) {
|
||||||
// TODO
|
// TODO: consider passing along.
|
||||||
}
|
}
|
||||||
|
|
||||||
void MultiCRTMachine::machine_did_change_clock_is_unlimited(Machine *machine) {
|
void MultiCRTMachine::machine_did_change_clock_is_unlimited(Machine *machine) {
|
||||||
// TODO
|
// TODO: consider passing along.
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,18 @@ class ASCII16kbROMSlotHandler: public ROMSlotHandler {
|
|||||||
ASCII16kbROMSlotHandler(MSX::MemoryMap &map, int slot) :
|
ASCII16kbROMSlotHandler(MSX::MemoryMap &map, int slot) :
|
||||||
map_(map), slot_(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);
|
// printf("A16 %04x ", address);
|
||||||
switch(address >> 11) {
|
switch(address >> 11) {
|
||||||
default:
|
default:
|
||||||
confidence_counter_.add_miss();
|
confidence_counter_.add_miss();
|
||||||
break;
|
break;
|
||||||
case 0xc:
|
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);
|
map_.map(slot_, value * 0x4000, 0x4000, 0x4000);
|
||||||
break;
|
break;
|
||||||
case 0xe:
|
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);
|
map_.map(slot_, value * 0x4000, 0x8000, 0x4000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -19,26 +19,26 @@ class ASCII8kbROMSlotHandler: public ROMSlotHandler {
|
|||||||
ASCII8kbROMSlotHandler(MSX::MemoryMap &map, int slot) :
|
ASCII8kbROMSlotHandler(MSX::MemoryMap &map, int slot) :
|
||||||
map_(map), slot_(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);
|
// printf("A8 %04x ", address);
|
||||||
switch(address >> 11) {
|
switch(address >> 11) {
|
||||||
default:
|
default:
|
||||||
confidence_counter_.add_miss();
|
confidence_counter_.add_miss();
|
||||||
break;
|
break;
|
||||||
case 0xc:
|
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);
|
map_.map(slot_, value * 0x2000, 0x4000, 0x2000);
|
||||||
break;
|
break;
|
||||||
case 0xd:
|
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);
|
map_.map(slot_, value * 0x2000, 0x6000, 0x2000);
|
||||||
break;
|
break;
|
||||||
case 0xe:
|
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);
|
map_.map(slot_, value * 0x2000, 0x8000, 0x2000);
|
||||||
break;
|
break;
|
||||||
case 0xf:
|
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);
|
map_.map(slot_, value * 0x2000, 0xa000, 0x2000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -19,22 +19,22 @@ class KonamiROMSlotHandler: public ROMSlotHandler {
|
|||||||
KonamiROMSlotHandler(MSX::MemoryMap &map, int slot) :
|
KonamiROMSlotHandler(MSX::MemoryMap &map, int slot) :
|
||||||
map_(map), slot_(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("K %04x ", address);
|
// printf("K %04x[%c] ", address, pc_is_outside_bios ? '.' : '+');
|
||||||
switch(address >> 13) {
|
switch(address >> 13) {
|
||||||
default:
|
default:
|
||||||
confidence_counter_.add_miss();
|
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
||||||
break;
|
break;
|
||||||
case 3:
|
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);
|
map_.map(slot_, value * 0x2000, 0x6000, 0x2000);
|
||||||
break;
|
break;
|
||||||
case 4:
|
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);
|
map_.map(slot_, value * 0x2000, 0x8000, 0x2000);
|
||||||
break;
|
break;
|
||||||
case 5:
|
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);
|
map_.map(slot_, value * 0x2000, 0xa000, 0x2000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -20,22 +20,22 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler {
|
|||||||
KonamiWithSCCROMSlotHandler(MSX::MemoryMap &map, int slot, Konami::SCC &scc) :
|
KonamiWithSCCROMSlotHandler(MSX::MemoryMap &map, int slot, Konami::SCC &scc) :
|
||||||
map_(map), slot_(slot), 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);
|
// printf("KSCC %04x ", address);
|
||||||
switch(address >> 11) {
|
switch(address >> 11) {
|
||||||
default:
|
default:
|
||||||
confidence_counter_.add_miss();
|
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
||||||
break;
|
break;
|
||||||
case 0x0a:
|
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);
|
map_.map(slot_, value * 0x2000, 0x4000, 0x2000);
|
||||||
break;
|
break;
|
||||||
case 0x0e:
|
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);
|
map_.map(slot_, value * 0x2000, 0x6000, 0x2000);
|
||||||
break;
|
break;
|
||||||
case 0x12:
|
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) {
|
if((value&0x3f) == 0x3f) {
|
||||||
scc_is_visible_ = true;
|
scc_is_visible_ = true;
|
||||||
map_.unmap(slot_, 0x8000, 0x2000);
|
map_.unmap(slot_, 0x8000, 0x2000);
|
||||||
@ -46,14 +46,14 @@ class KonamiWithSCCROMSlotHandler: public ROMSlotHandler {
|
|||||||
break;
|
break;
|
||||||
case 0x13:
|
case 0x13:
|
||||||
if(scc_is_visible_) {
|
if(scc_is_visible_) {
|
||||||
confidence_counter_.add_hit();
|
if(pc_is_outside_bios) confidence_counter_.add_hit();
|
||||||
scc_.write(address, value);
|
scc_.write(address, value);
|
||||||
} else {
|
} else {
|
||||||
confidence_counter_.add_miss();
|
if(pc_is_outside_bios) confidence_counter_.add_miss();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x16:
|
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);
|
map_.map(slot_, value * 0x2000, 0xa000, 0x2000);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ DiskROM::DiskROM(const std::vector<uint8_t> &rom) :
|
|||||||
set_is_double_density(true);
|
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) {
|
switch(address) {
|
||||||
case 0x7ff8: case 0x7ff9: case 0x7ffa: case 0x7ffb:
|
case 0x7ff8: case 0x7ff9: case 0x7ffa: case 0x7ffb:
|
||||||
set_register(address, value);
|
set_register(address, value);
|
||||||
|
@ -22,7 +22,7 @@ class DiskROM: public ROMSlotHandler, public WD::WD1770 {
|
|||||||
public:
|
public:
|
||||||
DiskROM(const std::vector<uint8_t> &rom);
|
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;
|
uint8_t read(uint16_t address) override;
|
||||||
void run_for(HalfCycles half_cycles) override;
|
void run_for(HalfCycles half_cycles) override;
|
||||||
|
|
||||||
|
@ -348,6 +348,7 @@ class ConcreteMachine:
|
|||||||
if(read_pointers_[address >> 13] == unpopulated_) {
|
if(read_pointers_[address >> 13] == unpopulated_) {
|
||||||
performed_unmapped_access_ = true;
|
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:
|
case CPU::Z80::PartialMachineCycle::Read:
|
||||||
if(read_pointers_[address >> 13]) {
|
if(read_pointers_[address >> 13]) {
|
||||||
*cycle.value = read_pointers_[address >> 13][address & 8191];
|
*cycle.value = read_pointers_[address >> 13][address & 8191];
|
||||||
@ -365,7 +366,7 @@ class ConcreteMachine:
|
|||||||
if(memory_slots_[slot_hit].handler) {
|
if(memory_slots_[slot_hit].handler) {
|
||||||
update_audio();
|
update_audio();
|
||||||
memory_slots_[slot_hit].handler->run_for(memory_slots_[slot_hit].cycles_since_update.flush());
|
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;
|
} break;
|
||||||
|
|
||||||
@ -664,6 +665,7 @@ class ConcreteMachine:
|
|||||||
|
|
||||||
int pc_zero_accesses_ = 0;
|
int pc_zero_accesses_ = 0;
|
||||||
bool performed_unmapped_access_ = false;
|
bool performed_unmapped_access_ = false;
|
||||||
|
uint16_t pc_address_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ class ROMSlotHandler {
|
|||||||
virtual void run_for(HalfCycles half_cycles) {}
|
virtual void run_for(HalfCycles half_cycles) {}
|
||||||
|
|
||||||
/*! Announces an attempt to write @c value to @c address. */
|
/*! 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. */
|
/*! 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; }
|
virtual uint8_t read(uint16_t address) { return 0xff; }
|
||||||
|
@ -2674,16 +2674,16 @@
|
|||||||
4BBB70A1202011C2002FE009 /* Implementation */ = {
|
4BBB70A1202011C2002FE009 /* Implementation */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
4BBB70A2202011C2002FE009 /* MultiConfigurationTarget.hpp */,
|
4B1B88BE202E3DB200B67DFF /* MultiConfigurable.cpp */,
|
||||||
4BBB70A3202011C2002FE009 /* MultiConfigurationTarget.cpp */,
|
4BBB70A3202011C2002FE009 /* MultiConfigurationTarget.cpp */,
|
||||||
4BBB70A6202014E2002FE009 /* MultiCRTMachine.cpp */,
|
4BBB70A6202014E2002FE009 /* MultiCRTMachine.cpp */,
|
||||||
4BBB70A7202014E2002FE009 /* MultiCRTMachine.hpp */,
|
|
||||||
4B1B88B9202E2EC100B67DFF /* MultiKeyboardMachine.cpp */,
|
|
||||||
4B1B88BA202E2EC100B67DFF /* MultiKeyboardMachine.hpp */,
|
|
||||||
4B1B88BE202E3DB200B67DFF /* MultiConfigurable.cpp */,
|
|
||||||
4B1B88BF202E3DB200B67DFF /* MultiConfigurable.hpp */,
|
|
||||||
4B1B88C6202E469300B67DFF /* MultiJoystickMachine.cpp */,
|
4B1B88C6202E469300B67DFF /* MultiJoystickMachine.cpp */,
|
||||||
|
4B1B88B9202E2EC100B67DFF /* MultiKeyboardMachine.cpp */,
|
||||||
|
4B1B88BF202E3DB200B67DFF /* MultiConfigurable.hpp */,
|
||||||
|
4BBB70A2202011C2002FE009 /* MultiConfigurationTarget.hpp */,
|
||||||
|
4BBB70A7202014E2002FE009 /* MultiCRTMachine.hpp */,
|
||||||
4B1B88C7202E469300B67DFF /* MultiJoystickMachine.hpp */,
|
4B1B88C7202E469300B67DFF /* MultiJoystickMachine.hpp */,
|
||||||
|
4B1B88BA202E2EC100B67DFF /* MultiKeyboardMachine.hpp */,
|
||||||
);
|
);
|
||||||
path = Implementation;
|
path = Implementation;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
Loading…
Reference in New Issue
Block a user