1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-26 09:29:45 +00:00

Pulls method call for tape fast loading checks out of inner loop for the Vic, Electron and ZX80/81.

This commit is contained in:
Thomas Harte 2018-02-19 16:57:24 -05:00
parent 6aaef97158
commit 3673cfe9be
3 changed files with 25 additions and 21 deletions

View File

@ -312,9 +312,6 @@ class ConcreteMachine:
delete[] rom_;
}
void set_rom(ROMSlot slot, const std::vector<uint8_t> &data) {
}
// Obtains the system ROMs.
bool set_rom_fetcher(const std::function<std::vector<std::unique_ptr<std::vector<uint8_t>>>(const std::string &machine, const std::vector<std::string> &names)> &roms_with_names) override {
auto roms = roms_with_names(
@ -396,6 +393,8 @@ class ConcreteMachine:
write_to_map(processor_read_memory_map_, rom_, rom_address_, 0x2000);
}
set_use_fast_tape();
return !media.tapes.empty() || (!media.disks.empty() && c1540_ != nullptr) || !media.cartridges.empty();
}
@ -516,10 +515,6 @@ class ConcreteMachine:
}
}
void set_use_fast_tape_hack(bool activate) {
use_fast_tape_hack_ = activate;
}
// to satisfy CPU::MOS6502::Processor
forceinline Cycles perform_bus_operation(CPU::MOS6502::BusOperation operation, uint16_t address, uint8_t *value) {
// run the phase-1 part of this cycle, in which the VIC accesses memory
@ -539,7 +534,7 @@ class ConcreteMachine:
// PC hits the start of the loop that just waits for an interesting tape interrupt to have
// occurred then skip both 6522s and the tape ahead to the next interrupt without any further
// CPU or 6560 costs.
if(use_fast_tape_hack_ && tape_->has_tape() && operation == CPU::MOS6502::BusOperation::ReadOpcode) {
if(use_fast_tape_hack_ && operation == CPU::MOS6502::BusOperation::ReadOpcode) {
if(address == 0xf7b2) {
// Address 0xf7b2 contains a JSR to 0xf8c0 that will fill the tape buffer with the next header.
// So cancel that via a double NOP and fill in the next header programmatically.
@ -674,7 +669,8 @@ class ConcreteMachine:
void set_selections(const Configurable::SelectionSet &selections_by_option) override {
bool quickload;
if(Configurable::get_quick_load_tape(selections_by_option, quickload)) {
set_use_fast_tape_hack(quickload);
allow_fast_tape_hack_ = quickload;
set_use_fast_tape();
}
}
@ -739,8 +735,12 @@ class ConcreteMachine:
// Tape
std::shared_ptr<Storage::Tape::BinaryTapePlayer> tape_;
bool use_fast_tape_hack_;
bool use_fast_tape_hack_ = false;
bool allow_fast_tape_hack_ = false;
bool is_running_at_zero_cost_ = false;
void set_use_fast_tape() {
use_fast_tape_hack_ = allow_fast_tape_hack_ && tape_->has_tape();
}
// Disk
std::shared_ptr<::Commodore::C1540::Machine> c1540_;

View File

@ -115,10 +115,6 @@ class ConcreteMachine:
if(is_holding_shift_) set_key_state(KeyShift, true);
}
void set_use_fast_tape_hack(bool activate) {
use_fast_tape_hack_ = activate;
}
void configure_as_target(const Analyser::Static::Target &target) override final {
if(target.loading_command.length()) {
type_string(target.loading_command);
@ -158,6 +154,7 @@ class ConcreteMachine:
slot = static_cast<ROMSlot>((static_cast<int>(slot) + 1)&15);
}
set_use_fast_tape_hack();
return !media.tapes.empty() || !media.disks.empty() || !media.cartridges.empty();
}
@ -283,7 +280,6 @@ class ConcreteMachine:
if(isReadOperation(operation)) {
if(
use_fast_tape_hack_ &&
tape_.has_tape() &&
(operation == CPU::MOS6502::BusOperation::ReadOpcode) &&
(
(address == 0xf4e5) || (address == 0xf4e6) || // double NOPs at 0xf4e5, 0xf6de, 0xf6fa and 0xfa51
@ -437,7 +433,8 @@ class ConcreteMachine:
void set_selections(const Configurable::SelectionSet &selections_by_option) override {
bool quickload;
if(Configurable::get_quick_load_tape(selections_by_option, quickload)) {
set_use_fast_tape_hack(quickload);
allow_fast_tape_hack_ = quickload;
set_use_fast_tape_hack();
}
Configurable::Display display;
@ -526,6 +523,10 @@ class ConcreteMachine:
// Tape
Tape tape_;
bool use_fast_tape_hack_ = false;
bool allow_fast_tape_hack_ = false;
void set_use_fast_tape_hack() {
use_fast_tape_hack_ = allow_fast_tape_hack_ && tape_.has_tape();
}
bool fast_load_is_in_data_ = false;
// Disk

View File

@ -158,7 +158,7 @@ template<bool is_zx81> class ConcreteMachine:
case CPU::Z80::PartialMachineCycle::ReadOpcode:
// Check for use of the fast tape hack.
if(use_fast_tape_hack_ && address == tape_trap_address_ && tape_player_.has_tape()) {
if(use_fast_tape_hack_ && address == tape_trap_address_) {
uint64_t prior_offset = tape_player_.get_tape()->get_offset();
int next_byte = parser_.get_next_byte(tape_player_.get_tape());
if(next_byte != -1) {
@ -290,6 +290,7 @@ template<bool is_zx81> class ConcreteMachine:
tape_player_.set_tape(media.tapes.front());
}
set_use_fast_tape();
return !media.tapes.empty();
}
@ -331,9 +332,6 @@ template<bool is_zx81> class ConcreteMachine:
}
// MARK: - Tape control
void set_use_fast_tape_hack(bool activate) {
use_fast_tape_hack_ = activate;
}
void set_use_automatic_tape_motor_control(bool enabled) {
use_automatic_tape_motor_control_ = enabled;
@ -366,7 +364,8 @@ template<bool is_zx81> class ConcreteMachine:
void set_selections(const Configurable::SelectionSet &selections_by_option) override {
bool quickload;
if(Configurable::get_quick_load_tape(selections_by_option, quickload)) {
set_use_fast_tape_hack(quickload);
allow_fast_tape_hack_ = quickload;
set_use_fast_tape();
}
bool autotapemotor;
@ -423,6 +422,10 @@ template<bool is_zx81> class ConcreteMachine:
bool has_latched_video_byte_ = false;
bool use_fast_tape_hack_ = false;
bool allow_fast_tape_hack_ = false;
void set_use_fast_tape() {
use_fast_tape_hack_ = allow_fast_tape_hack_ && tape_player_.has_tape();
}
bool use_automatic_tape_motor_control_;
HalfCycles tape_advance_delay_ = 0;