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

Eliminate joystick macros.

This commit is contained in:
Thomas Harte 2024-01-16 14:26:55 -05:00
parent 8c436c2df8
commit a047c6493a

View File

@ -60,36 +60,37 @@ class Joystick: public Inputs::ConcreteJoystick {
}) {}
void did_set_input(const Input &digital_input, bool is_active) final {
#define APPLY_KEMPSTON(b) if(is_active) kempston_ |= b; else kempston_ &= ~b;
#define APPLY_SINCLAIR(b) if(is_active) sinclair_ &= ~b; else sinclair_ |= b;
const auto apply_kempston = [&](uint8_t mask) {
if(is_active) kempston_ |= mask; else kempston_ &= ~mask;
};
const auto apply_sinclair = [&](uint16_t mask) {
if(is_active) sinclair_ &= ~mask; else sinclair_ |= mask;
};
switch(digital_input.type) {
default: return;
case Input::Right:
APPLY_KEMPSTON(0x01);
APPLY_SINCLAIR(0x0208);
apply_kempston(0x01);
apply_sinclair(0x0208);
break;
case Input::Left:
APPLY_KEMPSTON(0x02);
APPLY_SINCLAIR(0x0110);
apply_kempston(0x02);
apply_sinclair(0x0110);
break;
case Input::Down:
APPLY_KEMPSTON(0x04);
APPLY_SINCLAIR(0x0404);
apply_kempston(0x04);
apply_sinclair(0x0404);
break;
case Input::Up:
APPLY_KEMPSTON(0x08);
APPLY_SINCLAIR(0x0802);
apply_kempston(0x08);
apply_sinclair(0x0802);
break;
case Input::Fire:
APPLY_KEMPSTON(0x10);
APPLY_SINCLAIR(0x1001);
apply_kempston(0x10);
apply_sinclair(0x1001);
break;
}
#undef APPLY_KEMPSTON
#undef APPLY_SINCLAIR
}
/// @returns The value that a Kempston joystick interface would report if this joystick