1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-17 21:30:14 +00:00

Merge pull request #867 from TomHarte/ElectronStarCommand

Pause longer for Electron commands that start with a modifier.
This commit is contained in:
Thomas Harte 2021-01-31 12:34:19 -05:00 committed by GitHub
commit 8142487d57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 7 deletions

View File

@ -1089,7 +1089,7 @@ template <bool has_fdc> class ConcreteMachine:
return Utility::TypeRecipient<CharacterMapper>::can_type(c);
}
HalfCycles get_typer_delay() const final {
HalfCycles get_typer_delay(const std::string &) const final {
return z80_.get_is_resetting() ? Cycles(3'400'000) : Cycles(0);
}

View File

@ -452,8 +452,17 @@ class ConcreteMachine:
evaluate_interrupts();
}
HalfCycles get_typer_delay() const final {
return m6502_.get_is_resetting() ? Cycles(750'000) : Cycles(0);
HalfCycles get_typer_delay(const std::string &text) const final {
if(!m6502_.get_is_resetting()) {
return Cycles(0);
}
// Add a longer delay for a command at reset that involves pressing a modifier;
// empirically this seems to be a requirement, in order to avoid a collision with
// the system's built-in modifier-at-startup test (e.g. to perform shift+break).
CharacterMapper test_mapper;
const uint16_t *const sequence = test_mapper.sequence_for_character(text[0]);
return is_modifier(Key(sequence[0])) ? Cycles(1'000'000) : Cycles(750'000);
}
HalfCycles get_typer_frequency() const final {

View File

@ -31,11 +31,15 @@ enum Key: uint16_t {
KeyShift = 0x00d0 | 0x08, KeyControl = 0x00d0 | 0x04, KeyFunc = 0x00d0 | 0x02, KeyEscape = 0x00d0 | 0x01,
// Virtual keys.
KeyF1 = 0xfff0, KeyF2, KeyF3, KeyF4, KeyF5, KeyF6, KeyF7, KeyF8, KeyF9, KeyF0,
KeyF1 = 0xfff0, KeyF2, KeyF3, KeyF4, KeyF5, KeyF6, KeyF7, KeyF8, KeyF9, KeyF0,
KeyBreak = 0xfffd,
};
constexpr bool is_modifier(Key key) {
return (key == KeyShift) || (key == KeyControl) || (key == KeyFunc);
}
struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper {
uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final;
};

View File

@ -109,7 +109,7 @@ class TypeRecipient: public Typer::Delegate {
/// Attaches a typer to this class that will type @c string using @c character_mapper as a source.
void add_typer(const std::string &string) {
if(!typer_) {
typer_ = std::make_unique<Typer>(string, get_typer_delay(), get_typer_frequency(), character_mapper, this);
typer_ = std::make_unique<Typer>(string, get_typer_delay(string), get_typer_frequency(), character_mapper, this);
} else {
typer_->append(string);
}
@ -137,7 +137,7 @@ class TypeRecipient: public Typer::Delegate {
typer_ = nullptr;
}
virtual HalfCycles get_typer_delay() const { return HalfCycles(0); }
virtual HalfCycles get_typer_delay(const std::string &) const { return HalfCycles(0); }
virtual HalfCycles get_typer_frequency() const { return HalfCycles(0); }
std::unique_ptr<Typer> typer_;

View File

@ -387,7 +387,7 @@ template<bool is_zx81> class ConcreteMachine:
}
// MARK: - Typer timing
HalfCycles get_typer_delay() const final {
HalfCycles get_typer_delay(const std::string &) const final {
return z80_.get_is_resetting() ? Cycles(7'000'000) : Cycles(0);
}