diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index be8a0f5d0..3176ddd7e 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -57,16 +57,18 @@ class Joystick: public Inputs::ConcreteJoystick { }) {} void did_set_input(const Input &digital_input, bool is_active) final { -#define APPLY(b) if(is_active) state_ &= ~b; else state_ |= b; + const auto apply = [&](uint8_t bit) { + if(is_active) state_ &= ~bit; else state_ |= bit; + }; + switch(digital_input.type) { default: return; - case Input::Right: APPLY(0x02); break; - case Input::Left: APPLY(0x01); break; - case Input::Down: APPLY(0x08); break; - case Input::Up: APPLY(0x10); break; - case Input::Fire: APPLY(0x20); break; + case Input::Right: apply(0x02); break; + case Input::Left: apply(0x01); break; + case Input::Down: apply(0x08); break; + case Input::Up: apply(0x10); break; + case Input::Fire: apply(0x20); break; } -#undef APPLY } uint8_t get_state() { @@ -795,24 +797,27 @@ template std::unique_ptr machine(const Analyser::Static::Oric::Target &target, const ROMMachine::ROMFetcher &rom_fetcher) { + switch(target.disk_interface) { + default: return std::make_unique>(target, rom_fetcher); + case DiskInterface::Microdisc: return std::make_unique>(target, rom_fetcher); + case DiskInterface::Pravetz: return std::make_unique>(target, rom_fetcher); + case DiskInterface::Jasmin: return std::make_unique>(target, rom_fetcher); + case DiskInterface::BD500: return std::make_unique>(target, rom_fetcher); + } +} + +} + std::unique_ptr Machine::Oric(const Analyser::Static::Target *target_hint, const ROMMachine::ROMFetcher &rom_fetcher) { auto *const oric_target = dynamic_cast(target_hint); -#define DiskInterfaceSwitch(processor) \ - switch(oric_target->disk_interface) { \ - default: return std::make_unique>(*oric_target, rom_fetcher); \ - case DiskInterface::Microdisc: return std::make_unique>(*oric_target, rom_fetcher); \ - case DiskInterface::Pravetz: return std::make_unique>(*oric_target, rom_fetcher); \ - case DiskInterface::Jasmin: return std::make_unique>(*oric_target, rom_fetcher); \ - case DiskInterface::BD500: return std::make_unique>(*oric_target, rom_fetcher); \ - } - switch(oric_target->processor) { - case Processor::WDC65816: DiskInterfaceSwitch(CPU::MOS6502Esque::Type::TWDC65816); - case Processor::MOS6502: DiskInterfaceSwitch(CPU::MOS6502Esque::Type::T6502); + case Processor::WDC65816: return machine(*oric_target, rom_fetcher); + case Processor::MOS6502: return machine(*oric_target, rom_fetcher); } -#undef DiskInterfaceSwitch - return nullptr; }