diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 606bbdebf..918b44f77 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -136,7 +136,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin // CPU or 6560 costs. if(_use_fast_tape_hack && _tape.has_tape() && address == 0xf92f && operation == CPU6502::BusOperation::ReadOpcode) { - while(!_userPortVIA->get_interrupt_line() && !_keyboardVIA->get_interrupt_line()) + while(!_userPortVIA->get_interrupt_line() && !_keyboardVIA->get_interrupt_line() && !_tape.get_tape()->is_at_end()) { _userPortVIA->run_for_half_cycles(2); _keyboardVIA->run_for_half_cycles(2); @@ -184,7 +184,10 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin _is_running_at_zero_cost = true; set_clock_is_unlimited(true); } - if(address < 0xe000 && operation == CPU6502::BusOperation::ReadOpcode) + if( + (address < 0xe000 && operation == CPU6502::BusOperation::ReadOpcode) || + _tape.get_tape()->is_at_end() + ) { _is_running_at_zero_cost = false; set_clock_is_unlimited(false); diff --git a/Storage/Tape/Tape.cpp b/Storage/Tape/Tape.cpp index 8cff0314c..d0283ffbe 100644 --- a/Storage/Tape/Tape.cpp +++ b/Storage/Tape/Tape.cpp @@ -50,6 +50,11 @@ void TapePlayer::set_tape(std::shared_ptr tape) get_next_pulse(); } +std::shared_ptr TapePlayer::get_tape() +{ + return _tape; +} + bool TapePlayer::has_tape() { return (bool)_tape; diff --git a/Storage/Tape/Tape.hpp b/Storage/Tape/Tape.hpp index ca3100f9b..cbf330e49 100644 --- a/Storage/Tape/Tape.hpp +++ b/Storage/Tape/Tape.hpp @@ -78,6 +78,7 @@ class TapePlayer: public TimedEventLoop { void set_tape(std::shared_ptr tape); bool has_tape(); + std::shared_ptr get_tape(); void run_for_cycles(int number_of_cycles); void run_for_input_pulse();