1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-10-07 21:57:46 +00:00

Added a block on the tape motor for a short period after each time the ROM routine is intercepted for a substituted byte read. To reduce the collision between fast tape and real tape loading.

This commit is contained in:
Thomas Harte 2017-07-06 22:33:54 -04:00
parent 2f42874fd3
commit a3684545b5
2 changed files with 13 additions and 2 deletions

View File

@ -22,7 +22,8 @@ Machine::Machine() :
hsync_(false), hsync_(false),
nmi_is_enabled_(false), nmi_is_enabled_(false),
tape_player_(ZX8081ClockRate), tape_player_(ZX8081ClockRate),
use_fast_tape_hack_(false) { use_fast_tape_hack_(false),
tape_advance_delay_(0) {
set_clock_rate(ZX8081ClockRate); set_clock_rate(ZX8081ClockRate);
tape_player_.set_motor_control(true); tape_player_.set_motor_control(true);
clear_all_keys(); clear_all_keys();
@ -53,7 +54,11 @@ int Machine::perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {
} }
if(is_zx81_) horizontal_counter_ %= 207; if(is_zx81_) horizontal_counter_ %= 207;
if(!use_fast_tape_hack_) tape_player_.run_for_cycles(cycle.length); if(!tape_advance_delay_) {
tape_player_.run_for_cycles(cycle.length);
} else {
tape_advance_delay_ = std::max(tape_advance_delay_ - cycle.length, 0);
}
if(nmi_is_enabled_ && !get_halt_line() && get_non_maskable_interrupt_line()) { if(nmi_is_enabled_ && !get_halt_line() && get_non_maskable_interrupt_line()) {
set_wait_line(true); set_wait_line(true);
@ -132,6 +137,11 @@ int Machine::perform_machine_cycle(const CPU::Z80::PartialMachineCycle &cycle) {
ram_[hl & ram_mask_] = (uint8_t)next_byte; ram_[hl & ram_mask_] = (uint8_t)next_byte;
*cycle.value = 0x00; *cycle.value = 0x00;
set_value_of_register(CPU::Z80::Register::ProgramCounter, tape_return_address_ - 1); set_value_of_register(CPU::Z80::Register::ProgramCounter, tape_return_address_ - 1);
// Assume that having read one byte quickly, we're probably going to be asked to read
// another shortly. Therefore, temporarily disable the tape motor for 1000 cycles in order
// to avoid fighting with real time. This is a stop-gap fix.
tape_advance_delay_ = 1000;
return 0; return 0;
} else { } else {
tape_player_.get_tape()->seek(time); tape_player_.get_tape()->seek(time);

View File

@ -94,6 +94,7 @@ class Machine:
uint8_t latched_video_byte_; uint8_t latched_video_byte_;
bool use_fast_tape_hack_; bool use_fast_tape_hack_;
int tape_advance_delay_;
}; };
} }