1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Fixed Electron's support for automatically booting floppy disks.

This commit is contained in:
Thomas Harte 2017-01-08 14:46:19 -05:00
parent 9d60172571
commit f3d9aec8fc
4 changed files with 21 additions and 18 deletions

View File

@ -61,6 +61,7 @@ std::shared_ptr<Outputs::Speaker> 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;
}

View File

@ -144,6 +144,7 @@ class Machine:
// Disk
std::unique_ptr<Plus3> plus3_;
bool is_holding_shift_;
int shift_restart_counter_;
// Outputs
std::unique_ptr<VideoOutput> video_output_;

View File

@ -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";
}
}

View File

@ -47,7 +47,7 @@ struct Target {
struct {
bool has_adfs;
bool has_dfs;
bool should_hold_shift;
bool should_shift_restart;
} acorn;
struct {