mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-03 08:05:40 +00:00
Merge pull request #867 from TomHarte/ElectronStarCommand
Pause longer for Electron commands that start with a modifier.
This commit is contained in:
commit
8142487d57
@ -1089,7 +1089,7 @@ template <bool has_fdc> class ConcreteMachine:
|
|||||||
return Utility::TypeRecipient<CharacterMapper>::can_type(c);
|
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);
|
return z80_.get_is_resetting() ? Cycles(3'400'000) : Cycles(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -452,8 +452,17 @@ class ConcreteMachine:
|
|||||||
evaluate_interrupts();
|
evaluate_interrupts();
|
||||||
}
|
}
|
||||||
|
|
||||||
HalfCycles get_typer_delay() const final {
|
HalfCycles get_typer_delay(const std::string &text) const final {
|
||||||
return m6502_.get_is_resetting() ? Cycles(750'000) : Cycles(0);
|
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 {
|
HalfCycles get_typer_frequency() const final {
|
||||||
|
@ -36,6 +36,10 @@ enum Key: uint16_t {
|
|||||||
KeyBreak = 0xfffd,
|
KeyBreak = 0xfffd,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
constexpr bool is_modifier(Key key) {
|
||||||
|
return (key == KeyShift) || (key == KeyControl) || (key == KeyFunc);
|
||||||
|
}
|
||||||
|
|
||||||
struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper {
|
struct KeyboardMapper: public MachineTypes::MappedKeyboardMachine::KeyboardMapper {
|
||||||
uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final;
|
uint16_t mapped_key_for_key(Inputs::Keyboard::Key key) const final;
|
||||||
};
|
};
|
||||||
|
@ -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.
|
/// 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) {
|
void add_typer(const std::string &string) {
|
||||||
if(!typer_) {
|
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 {
|
} else {
|
||||||
typer_->append(string);
|
typer_->append(string);
|
||||||
}
|
}
|
||||||
@ -137,7 +137,7 @@ class TypeRecipient: public Typer::Delegate {
|
|||||||
typer_ = nullptr;
|
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); }
|
virtual HalfCycles get_typer_frequency() const { return HalfCycles(0); }
|
||||||
std::unique_ptr<Typer> typer_;
|
std::unique_ptr<Typer> typer_;
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ template<bool is_zx81> class ConcreteMachine:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MARK: - Typer timing
|
// 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);
|
return z80_.get_is_resetting() ? Cycles(7'000'000) : Cycles(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user