From 6153ada33b197773a4199c87eee10dbca4d5f194 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sun, 8 Jan 2017 14:46:19 -0500 Subject: [PATCH] Fixed Electron's support for automatically booting floppy disks. --- Machines/Electron/Electron.cpp | 17 ++++++++++++++--- Machines/Electron/Electron.hpp | 1 + StaticAnalyser/Acorn/StaticAnalyser.cpp | 19 +++++-------------- StaticAnalyser/StaticAnalyser.hpp | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 6052d48d0..b35ba4354 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -61,6 +61,7 @@ std::shared_ptr Machine::get_speaker() void Machine::clear_all_keys() { memset(key_states_, 0, sizeof(key_states_)); + if(is_holding_shift_) set_key_state(KeyShift, true); } void Machine::set_key_state(uint16_t key, bool isPressed) @@ -116,10 +117,9 @@ void Machine::configure_as_target(const StaticAnalyser::Target &target) set_typer_for_string(target.loadingCommand.c_str()); } - if(target.acorn.should_hold_shift) + if(target.acorn.should_shift_restart) { - set_key_state(KeyShift, true); - is_holding_shift_ = true; + shift_restart_counter_ = 1000000; } } @@ -398,6 +398,17 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin if(typer_) typer_->update((int)cycles); if(plus3_) plus3_->run_for_cycles(4*cycles); + if(shift_restart_counter_) + { + shift_restart_counter_ -= cycles; + if(shift_restart_counter_ <= 0) + { + shift_restart_counter_ = 0; + set_power_on(true); + set_key_state(KeyShift, true); + is_holding_shift_ = true; + } + } return cycles; } diff --git a/Machines/Electron/Electron.hpp b/Machines/Electron/Electron.hpp index 543d6abcc..bb9588f52 100644 --- a/Machines/Electron/Electron.hpp +++ b/Machines/Electron/Electron.hpp @@ -144,6 +144,7 @@ class Machine: // Disk std::unique_ptr plus3_; bool is_holding_shift_; + int shift_restart_counter_; // Outputs std::unique_ptr video_output_; diff --git a/StaticAnalyser/Acorn/StaticAnalyser.cpp b/StaticAnalyser/Acorn/StaticAnalyser.cpp index 50a5ad478..6a1e2be7a 100644 --- a/StaticAnalyser/Acorn/StaticAnalyser.cpp +++ b/StaticAnalyser/Acorn/StaticAnalyser.cpp @@ -69,7 +69,7 @@ void StaticAnalyser::Acorn::AddTargets( target.probability = 1.0; // TODO: a proper estimation target.acorn.has_dfs = false; target.acorn.has_adfs = false; - target.acorn.should_hold_shift = false; + target.acorn.should_shift_restart = false; // strip out inappropriate cartridges target.cartridges = AcornCartridgesFrom(cartridges); @@ -126,20 +126,11 @@ void StaticAnalyser::Acorn::AddTargets( target.acorn.has_dfs = !!dfs_catalogue; target.acorn.has_adfs = !!adfs_catalogue; - std::string adfs_command; Catalogue::BootOption bootOption = (dfs_catalogue ?: adfs_catalogue)->bootOption; - switch(bootOption) - { - case Catalogue::BootOption::None: adfs_command = "*CAT\n"; break; - case Catalogue::BootOption::LoadBOOT: adfs_command = "*LOAD !BOOT\n"; break; - case Catalogue::BootOption::RunBOOT: adfs_command = "*RUN !BOOT\n"; break; - case Catalogue::BootOption::ExecBOOT: adfs_command = "*EXEC !BOOT\n"; break; - } - -// if(target.acorn.has_dfs && bootOption != Catalogue::BootOption::None) -// target.acorn.should_hold_shift = true; -// else - target.loadingCommand = (target.acorn.has_dfs ? "" : "*MOUNT\n") + adfs_command; + if(bootOption != Catalogue::BootOption::None) + target.acorn.should_shift_restart = true; + else + target.loadingCommand = "*CAT\n"; } } diff --git a/StaticAnalyser/StaticAnalyser.hpp b/StaticAnalyser/StaticAnalyser.hpp index 6a2d2e0e3..ffef83a23 100644 --- a/StaticAnalyser/StaticAnalyser.hpp +++ b/StaticAnalyser/StaticAnalyser.hpp @@ -47,7 +47,7 @@ struct Target { struct { bool has_adfs; bool has_dfs; - bool should_hold_shift; + bool should_shift_restart; } acorn; struct {