1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-09-27 02:55:07 +00:00

Removed state mirroring in the machine-specific Mac UI classes.

This commit is contained in:
Thomas Harte 2018-02-14 21:46:50 -05:00
parent ddf1bf3cbf
commit 7b420d56e3
6 changed files with 45 additions and 7 deletions

View File

@ -130,6 +130,18 @@ class ConcreteMachine:
}
}
bool get_switch_is_enabled(Atari2600Switch input) override {
uint8_t port_input = bus_->mos6532_.get_port_input(1);
switch(input) {
case Atari2600SwitchReset: return !!(port_input & 0x01);
case Atari2600SwitchSelect: return !!(port_input & 0x02);
case Atari2600SwitchColour: return !!(port_input & 0x08);
case Atari2600SwitchLeftPlayerDifficulty: return !!(port_input & 0x40);
case Atari2600SwitchRightPlayerDifficulty: return !!(port_input & 0x80);
default: return false;
}
}
void set_reset_switch(bool state) override {
bus_->set_reset_line(state);
}

View File

@ -33,6 +33,9 @@ class Machine:
/// Sets the switch @c input to @c state.
virtual void set_switch_is_enabled(Atari2600Switch input, bool state) = 0;
/// Gets the state of switch @c input.
virtual bool get_switch_is_enabled(Atari2600Switch input) = 0;
// Presses or releases the reset button.
virtual void set_reset_switch(bool state) = 0;
};

View File

@ -341,10 +341,15 @@ template<bool is_zx81> class ConcreteMachine:
tape_player_.set_motor_control(false);
}
}
void set_tape_is_playing(bool is_playing) override final {
tape_player_.set_motor_control(is_playing);
}
bool get_tape_is_playing() override final {
return tape_player_.get_motor_control();
}
// MARK: - Typer timing
HalfCycles get_typer_delay() override final { return Cycles(7000000); }
HalfCycles get_typer_frequency() override final { return Cycles(390000); }

View File

@ -30,6 +30,7 @@ class Machine:
static Machine *ZX8081(const Analyser::Static::Target &target_hint);
virtual void set_tape_is_playing(bool is_playing) = 0;
virtual bool get_tape_is_playing() = 0;
};
}

View File

@ -25,29 +25,41 @@
}
- (void)setColourButton:(BOOL)colourButton {
_colourButton = colourButton;
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(Atari2600SwitchColour, colourButton);
}
}
- (void)setLeftPlayerDifficultyButton:(BOOL)leftPlayerDifficultyButton {
_leftPlayerDifficultyButton = leftPlayerDifficultyButton;
- (BOOL)colourButton {
@synchronized(_machine) {
return _atari2600->get_switch_is_enabled(Atari2600SwitchColour);
}
}
- (void)setLeftPlayerDifficultyButton:(BOOL)leftPlayerDifficultyButton {
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(Atari2600SwitchLeftPlayerDifficulty, leftPlayerDifficultyButton);
}
}
- (void)setRightPlayerDifficultyButton:(BOOL)rightPlayerDifficultyButton {
_rightPlayerDifficultyButton = rightPlayerDifficultyButton;
- (BOOL)leftPlayerDifficultyButton {
@synchronized(_machine) {
return _atari2600->get_switch_is_enabled(Atari2600SwitchLeftPlayerDifficulty);
}
}
- (void)setRightPlayerDifficultyButton:(BOOL)rightPlayerDifficultyButton {
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(Atari2600SwitchRightPlayerDifficulty, rightPlayerDifficultyButton);
}
}
- (BOOL)rightPlayerDifficultyButton {
@synchronized(_machine) {
return _atari2600->get_switch_is_enabled(Atari2600SwitchRightPlayerDifficulty);
}
}
- (void)toggleSwitch:(Atari2600Switch)toggleSwitch {
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(toggleSwitch, true);

View File

@ -28,9 +28,14 @@
- (void)setTapeIsPlaying:(BOOL)tapeIsPlaying {
@synchronized(_machine) {
_tapeIsPlaying = tapeIsPlaying;
_zx8081->set_tape_is_playing(tapeIsPlaying ? true : false);
}
}
- (BOOL)tapeIsPlaying {
@synchronized(_machine) {
return _zx8081->get_tape_is_playing();
}
}
@end