1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00
CLK/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSAtari2600.mm

84 lines
1.9 KiB
Plaintext

//
// Atari2600.m
// CLK
//
// Created by Thomas Harte on 14/07/2015.
// Copyright © 2015 Thomas Harte. All rights reserved.
//
#import "CSAtari2600.h"
#include "Atari2600.hpp"
@implementation CSAtari2600 {
Atari2600::Machine *_atari2600;
__weak CSMachine *_machine;
}
- (instancetype)initWithAtari2600:(void *)atari2600 owner:(CSMachine *)machine {
self = [super init];
if(self) {
_atari2600 = (Atari2600::Machine *)atari2600;
_machine = machine;
}
return self;
}
- (void)setColourButton:(BOOL)colourButton {
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(Atari2600SwitchColour, colourButton);
}
}
- (BOOL)colourButton {
@synchronized(_machine) {
return _atari2600->get_switch_is_enabled(Atari2600SwitchColour);
}
}
- (void)setLeftPlayerDifficultyButton:(BOOL)leftPlayerDifficultyButton {
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(Atari2600SwitchLeftPlayerDifficulty, leftPlayerDifficultyButton);
}
}
- (BOOL)leftPlayerDifficultyButton {
@synchronized(_machine) {
return _atari2600->get_switch_is_enabled(Atari2600SwitchLeftPlayerDifficulty);
}
}
- (void)setRightPlayerDifficultyButton:(BOOL)rightPlayerDifficultyButton {
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(Atari2600SwitchRightPlayerDifficulty, rightPlayerDifficultyButton);
}
}
- (BOOL)rightPlayerDifficultyButton {
@synchronized(_machine) {
return _atari2600->get_switch_is_enabled(Atari2600SwitchRightPlayerDifficulty);
}
}
- (void)toggleSwitch:(Atari2600Switch)toggleSwitch {
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(toggleSwitch, true);
}
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
@synchronized(_machine) {
_atari2600->set_switch_is_enabled(toggleSwitch, false);
}
});
}
- (void)pressResetButton {
[self toggleSwitch:Atari2600SwitchReset];
}
- (void)pressSelectButton {
[self toggleSwitch:Atari2600SwitchSelect];
}
@end