mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-18 16:30:29 +00:00
Merge pull request #364 from TomHarte/TimingUpfront
Ensures the Coleco & MSX account for instruction lengths prior to outward accesses.
This commit is contained in:
commit
dd6f85d4db
@ -192,6 +192,9 @@ class ConcreteMachine:
|
|||||||
|
|
||||||
// MARK: Z80::BusHandler
|
// MARK: Z80::BusHandler
|
||||||
forceinline HalfCycles perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {
|
forceinline HalfCycles perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {
|
||||||
|
time_since_vdp_update_ += cycle.length;
|
||||||
|
time_since_sn76489_update_ += cycle.length;
|
||||||
|
|
||||||
uint16_t address = cycle.address ? *cycle.address : 0x0000;
|
uint16_t address = cycle.address ? *cycle.address : 0x0000;
|
||||||
switch(cycle.operation) {
|
switch(cycle.operation) {
|
||||||
case CPU::Z80::PartialMachineCycle::ReadOpcode:
|
case CPU::Z80::PartialMachineCycle::ReadOpcode:
|
||||||
@ -313,9 +316,6 @@ class ConcreteMachine:
|
|||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
time_since_vdp_update_ += cycle.length;
|
|
||||||
time_since_sn76489_update_ += cycle.length;
|
|
||||||
|
|
||||||
if(time_until_interrupt_ > 0) {
|
if(time_until_interrupt_ > 0) {
|
||||||
time_until_interrupt_ -= cycle.length;
|
time_until_interrupt_ -= cycle.length;
|
||||||
if(time_until_interrupt_ <= HalfCycles(0)) {
|
if(time_until_interrupt_ <= HalfCycles(0)) {
|
||||||
|
@ -282,6 +282,17 @@ class ConcreteMachine:
|
|||||||
|
|
||||||
// MARK: Z80::BusHandler
|
// MARK: Z80::BusHandler
|
||||||
forceinline HalfCycles perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {
|
forceinline HalfCycles perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {
|
||||||
|
// Per the best information I currently have, the MSX inserts an extra cycle into each opcode read,
|
||||||
|
// but otherwise runs without pause.
|
||||||
|
const HalfCycles addition((cycle.operation == CPU::Z80::PartialMachineCycle::ReadOpcode) ? 2 : 0);
|
||||||
|
const HalfCycles total_length = addition + cycle.length;
|
||||||
|
time_since_vdp_update_ += total_length;
|
||||||
|
time_since_ay_update_ += total_length;
|
||||||
|
memory_slots_[0].cycles_since_update += total_length;
|
||||||
|
memory_slots_[1].cycles_since_update += total_length;
|
||||||
|
memory_slots_[2].cycles_since_update += total_length;
|
||||||
|
memory_slots_[3].cycles_since_update += total_length;
|
||||||
|
|
||||||
uint16_t address = cycle.address ? *cycle.address : 0x0000;
|
uint16_t address = cycle.address ? *cycle.address : 0x0000;
|
||||||
switch(cycle.operation) {
|
switch(cycle.operation) {
|
||||||
case CPU::Z80::PartialMachineCycle::ReadOpcode:
|
case CPU::Z80::PartialMachineCycle::ReadOpcode:
|
||||||
@ -459,23 +470,12 @@ class ConcreteMachine:
|
|||||||
if(!tape_player_is_sleeping_)
|
if(!tape_player_is_sleeping_)
|
||||||
tape_player_.run_for(cycle.length.as_int());
|
tape_player_.run_for(cycle.length.as_int());
|
||||||
|
|
||||||
// Per the best information I currently have, the MSX inserts an extra cycle into each opcode read,
|
|
||||||
// but otherwise runs without pause.
|
|
||||||
const HalfCycles addition((cycle.operation == CPU::Z80::PartialMachineCycle::ReadOpcode) ? 2 : 0);
|
|
||||||
const HalfCycles total_length = addition + cycle.length;
|
|
||||||
|
|
||||||
if(time_until_interrupt_ > 0) {
|
if(time_until_interrupt_ > 0) {
|
||||||
time_until_interrupt_ -= total_length;
|
time_until_interrupt_ -= total_length;
|
||||||
if(time_until_interrupt_ <= HalfCycles(0)) {
|
if(time_until_interrupt_ <= HalfCycles(0)) {
|
||||||
z80_.set_interrupt_line(true, time_until_interrupt_);
|
z80_.set_interrupt_line(true, time_until_interrupt_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
time_since_vdp_update_ += total_length;
|
|
||||||
time_since_ay_update_ += total_length;
|
|
||||||
memory_slots_[0].cycles_since_update += total_length;
|
|
||||||
memory_slots_[1].cycles_since_update += total_length;
|
|
||||||
memory_slots_[2].cycles_since_update += total_length;
|
|
||||||
memory_slots_[3].cycles_since_update += total_length;
|
|
||||||
return addition;
|
return addition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user