mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-21 21:33:54 +00:00
Eliminate macros.
This commit is contained in:
parent
bdb5abe47b
commit
a6c6a1c6da
@ -57,16 +57,18 @@ class Joystick: public Inputs::ConcreteJoystick {
|
|||||||
}) {}
|
}) {}
|
||||||
|
|
||||||
void did_set_input(const Input &digital_input, bool is_active) final {
|
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) {
|
switch(digital_input.type) {
|
||||||
default: return;
|
default: return;
|
||||||
case Input::Right: APPLY(0x02); break;
|
case Input::Right: apply(0x02); break;
|
||||||
case Input::Left: APPLY(0x01); break;
|
case Input::Left: apply(0x01); break;
|
||||||
case Input::Down: APPLY(0x08); break;
|
case Input::Down: apply(0x08); break;
|
||||||
case Input::Up: APPLY(0x10); break;
|
case Input::Up: apply(0x10); break;
|
||||||
case Input::Fire: APPLY(0x20); break;
|
case Input::Fire: apply(0x20); break;
|
||||||
}
|
}
|
||||||
#undef APPLY
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t get_state() {
|
uint8_t get_state() {
|
||||||
@ -795,24 +797,27 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface, CPU::MOS
|
|||||||
|
|
||||||
using namespace Oric;
|
using namespace Oric;
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
template <CPU::MOS6502Esque::Type processor> std::unique_ptr<Machine> machine(const Analyser::Static::Oric::Target &target, const ROMMachine::ROMFetcher &rom_fetcher) {
|
||||||
|
switch(target.disk_interface) {
|
||||||
|
default: return std::make_unique<ConcreteMachine<DiskInterface::None, processor>>(target, rom_fetcher);
|
||||||
|
case DiskInterface::Microdisc: return std::make_unique<ConcreteMachine<DiskInterface::Microdisc, processor>>(target, rom_fetcher);
|
||||||
|
case DiskInterface::Pravetz: return std::make_unique<ConcreteMachine<DiskInterface::Pravetz, processor>>(target, rom_fetcher);
|
||||||
|
case DiskInterface::Jasmin: return std::make_unique<ConcreteMachine<DiskInterface::Jasmin, processor>>(target, rom_fetcher);
|
||||||
|
case DiskInterface::BD500: return std::make_unique<ConcreteMachine<DiskInterface::BD500, processor>>(target, rom_fetcher);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<Machine> Machine::Oric(const Analyser::Static::Target *target_hint, const ROMMachine::ROMFetcher &rom_fetcher) {
|
std::unique_ptr<Machine> Machine::Oric(const Analyser::Static::Target *target_hint, const ROMMachine::ROMFetcher &rom_fetcher) {
|
||||||
auto *const oric_target = dynamic_cast<const Analyser::Static::Oric::Target *>(target_hint);
|
auto *const oric_target = dynamic_cast<const Analyser::Static::Oric::Target *>(target_hint);
|
||||||
|
|
||||||
#define DiskInterfaceSwitch(processor) \
|
|
||||||
switch(oric_target->disk_interface) { \
|
|
||||||
default: return std::make_unique<ConcreteMachine<DiskInterface::None, processor>>(*oric_target, rom_fetcher); \
|
|
||||||
case DiskInterface::Microdisc: return std::make_unique<ConcreteMachine<DiskInterface::Microdisc, processor>>(*oric_target, rom_fetcher); \
|
|
||||||
case DiskInterface::Pravetz: return std::make_unique<ConcreteMachine<DiskInterface::Pravetz, processor>>(*oric_target, rom_fetcher); \
|
|
||||||
case DiskInterface::Jasmin: return std::make_unique<ConcreteMachine<DiskInterface::Jasmin, processor>>(*oric_target, rom_fetcher); \
|
|
||||||
case DiskInterface::BD500: return std::make_unique<ConcreteMachine<DiskInterface::BD500, processor>>(*oric_target, rom_fetcher); \
|
|
||||||
}
|
|
||||||
|
|
||||||
switch(oric_target->processor) {
|
switch(oric_target->processor) {
|
||||||
case Processor::WDC65816: DiskInterfaceSwitch(CPU::MOS6502Esque::Type::TWDC65816);
|
case Processor::WDC65816: return machine<CPU::MOS6502Esque::Type::TWDC65816>(*oric_target, rom_fetcher);
|
||||||
case Processor::MOS6502: DiskInterfaceSwitch(CPU::MOS6502Esque::Type::T6502);
|
case Processor::MOS6502: return machine<CPU::MOS6502Esque::Type::T6502>(*oric_target, rom_fetcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DiskInterfaceSwitch
|
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user