1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Adds joystick support to the IIgs.

This commit is contained in:
Thomas Harte 2021-02-16 19:39:22 -05:00
parent 96f2d802d9
commit 28bd620e7f
3 changed files with 31 additions and 18 deletions

View File

@ -63,8 +63,8 @@ class JoystickPair {
return (1.0f - static_cast<Joystick *>(joysticks_[channel >> 1].get())->axes[channel & 1]) < analogue_charge_ + analogue_biases_[channel];
}
inline void update_charge() {
analogue_charge_ = std::min(analogue_charge_ + 1.0f / 2820.0f, 1.1f);
inline void update_charge(float one_mhz_cycles = 1.0f) {
analogue_charge_ = std::min(analogue_charge_ + one_mhz_cycles * (1.0f / 2820.0f), 1.1f);
}
inline void access_c070() {

View File

@ -10,14 +10,15 @@
#include "../../../Activity/Source.hpp"
#include "../../MachineTypes.hpp"
#include "../../../Processors/65816/65816.hpp"
#include "../../../Analyser/Static/AppleIIgs/Target.hpp"
#include "ADB.hpp"
#include "MemoryMap.hpp"
#include "Video.hpp"
#include "Sound.hpp"
#include "../../../Processors/65816/65816.hpp"
#include "../../../Components/8530/z8530.hpp"
#include "../../../Components/AppleClock/AppleClock.hpp"
#include "../../../Components/AudioToggle/AudioToggle.hpp"
@ -25,6 +26,8 @@
#include "../../../Components/DiskII/MacintoshDoubleDensityDrive.hpp"
#include "../../../Components/DiskII/DiskIIDrive.hpp"
#include "../AppleII/Joystick.hpp"
#include "../../../Outputs/Speaker/Implementation/CompoundSource.hpp"
#include "../../../Outputs/Speaker/Implementation/LowpassSpeaker.hpp"
@ -37,7 +40,7 @@
namespace {
constexpr int CLOCK_RATE = 14318180;
constexpr int CLOCK_RATE = 14'318'180;
}
@ -48,11 +51,12 @@ class ConcreteMachine:
public Activity::Source,
public Apple::IIgs::Machine,
public MachineTypes::AudioProducer,
public MachineTypes::JoystickMachine,
public MachineTypes::MappedKeyboardMachine,
public MachineTypes::MediaTarget,
public MachineTypes::MouseMachine,
public MachineTypes::ScanProducer,
public MachineTypes::TimedMachine,
public MachineTypes::MappedKeyboardMachine,
public MachineTypes::MouseMachine,
public CPU::MOS6502Esque::BusHandler<uint32_t> {
public:
@ -516,32 +520,34 @@ class ConcreteMachine:
*value = rom_[rom_.size() - 65536 + address_suffix];
break;
// Analogue inputs. Joystick parts are TODO.
// Analogue inputs.
case Read(0xc061):
*value = adb_glu_->get_command_button() ? 0x80 : 0x00;
*value = (adb_glu_->get_command_button() || joysticks_.button(0)) ? 0x80 : 0x00;
is_1Mhz = true;
break;
case Read(0xc062):
*value = adb_glu_->get_option_button() ? 0x80 : 0x00;
*value = (adb_glu_->get_option_button() || joysticks_.button(1)) ? 0x80 : 0x00;
is_1Mhz = true;
break;
case Read(0xc060):
case Read(0xc063):
// Joystick buttons.
*value = 0x00;
*value = joysticks_.button(2) ? 0x80 : 0x00;
is_1Mhz = true;
break;
case Read(0xc064): case Read(0xc065): case Read(0xc066): case Read(0xc067):
case Read(0xc064):
case Read(0xc065):
case Read(0xc066):
case Read(0xc067): {
// Analogue inputs.
*value = 0x00;
const size_t input = address_suffix - 0xc064;
*value = joysticks_.analogue_channel_is_discharged(input) ? 0x00 : 0x80;
is_1Mhz = true;
break;
} break;
case Read(0xc070): case Write(0xc070):
// TODO: begin analogue channel charge.
joysticks_.access_c070();
is_1Mhz = true;
break;
@ -904,6 +910,8 @@ class ConcreteMachine:
}
}
joysticks_.update_charge(duration.as<float>() / 14.0f);
return duration;
}
@ -930,6 +938,10 @@ class ConcreteMachine:
return adb_glu_.last_valid()->get_mouse();
}
const std::vector<std::unique_ptr<Inputs::Joystick>> &get_joysticks() final {
return joysticks_.get_joysticks();
}
private:
CPU::WDC65816::Processor<ConcreteMachine, false> m65816_;
MemoryMap memory_;
@ -986,8 +998,9 @@ class ConcreteMachine:
};
friend AudioUpdater;
// MARK: - Keyboard.
// MARK: - Keyboard and joystick.
Apple::ADB::KeyboardMapper keyboard_mapper_;
Apple::II::JoystickPair joysticks_;
// MARK: - Cards.

View File

@ -62,7 +62,7 @@
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableAddressSanitizer = "YES"