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

Makes the Apple II a joystick machine.

Albeit that the values supplied to its joysticks do not currently make it into the emulated state.
This commit is contained in:
Thomas Harte 2018-06-11 22:16:32 -04:00
parent 2954373115
commit f1b430338e

View File

@ -11,6 +11,7 @@
#include "../../Activity/Source.hpp"
#include "../ConfigurationTarget.hpp"
#include "../CRTMachine.hpp"
#include "../JoystickMachine.hpp"
#include "../KeyboardMachine.hpp"
#include "../Utility/MemoryFuzzer.hpp"
#include "../Utility/StringSerialiser.hpp"
@ -51,6 +52,7 @@ class ConcreteMachine:
public Inputs::Keyboard,
public AppleII::Machine,
public Activity::Source,
public JoystickMachine::Machine,
public AppleII::Card::Delegate {
private:
struct VideoBusHandler : public AppleII::Video::BusHandler {
@ -173,6 +175,24 @@ class ConcreteMachine:
// MARK - quick loading
bool should_load_quickly_ = false;
// MARK - joysticks
std::vector<std::unique_ptr<Inputs::Joystick>> joysticks_;
class Joystick: public Inputs::ConcreteJoystick {
public:
Joystick() :
ConcreteJoystick({
Input(Input::Horizontal),
Input(Input::Vertical),
// The Apple II offers three buttons between two joysticks;
// this emulator puts three buttons on each joystick and
// combines them.
Input(Input::Fire, 0),
Input(Input::Fire, 1),
Input(Input::Fire, 2),
}) {}
};
public:
ConcreteMachine():
m6502_(*this),
@ -198,6 +218,10 @@ class ConcreteMachine:
// Also, start with randomised memory contents.
Memory::Fuzz(ram_, sizeof(ram_));
// Add a couple of joysticks.
joysticks_.emplace_back(new Joystick);
joysticks_.emplace_back(new Joystick);
}
~ConcreteMachine() {
@ -381,6 +405,13 @@ class ConcreteMachine:
case 0xc063: // Switch input 2.
*value &= 0x7f;
break;
case 0xc064: // Analogue input 0.
case 0xc065: // Analogue input 1.
case 0xc066: // Analogue input 2.
case 0xc067: // Analogue input 3.
*value &= 0x7f;
break;
}
} else {
// Write-only switches.
@ -397,6 +428,9 @@ class ConcreteMachine:
case 0xc056: update_video(); video_->set_low_resolution(); break;
case 0xc057: update_video(); video_->set_high_resolution(); break;
case 0xc070: // Reset analogue inputs.
break;
case 0xc010:
keyboard_input_ &= 0x7f;
if(string_serialiser_) {
@ -619,6 +653,11 @@ class ConcreteMachine:
Configurable::append_quick_load_tape_selection(selection_set, true);
return selection_set;
}
// MARK: JoystickMachine
std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() override {
return joysticks_;
}
};
}