2016-01-05 04:12:47 +00:00
|
|
|
//
|
|
|
|
// Atari2600.m
|
|
|
|
// CLK
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 14/07/2015.
|
2018-05-13 19:19:52 +00:00
|
|
|
// Copyright 2015 Thomas Harte. All rights reserved.
|
2016-01-05 04:12:47 +00:00
|
|
|
//
|
|
|
|
|
|
|
|
#import "CSAtari2600.h"
|
|
|
|
|
2016-07-05 20:39:31 +00:00
|
|
|
#include "Atari2600.hpp"
|
2016-01-05 04:12:47 +00:00
|
|
|
|
|
|
|
@implementation CSAtari2600 {
|
2018-02-13 02:46:21 +00:00
|
|
|
Atari2600::Machine *_atari2600;
|
|
|
|
__weak CSMachine *_machine;
|
2017-08-16 18:52:40 +00:00
|
|
|
}
|
|
|
|
|
2018-02-13 02:46:21 +00:00
|
|
|
- (instancetype)initWithAtari2600:(void *)atari2600 owner:(CSMachine *)machine {
|
|
|
|
self = [super init];
|
|
|
|
if(self) {
|
|
|
|
_atari2600 = (Atari2600::Machine *)atari2600;
|
|
|
|
_machine = machine;
|
2016-04-24 10:56:08 +00:00
|
|
|
}
|
2018-02-13 02:46:21 +00:00
|
|
|
return self;
|
2016-01-05 04:12:47 +00:00
|
|
|
}
|
|
|
|
|
2016-06-19 23:36:34 +00:00
|
|
|
- (void)setColourButton:(BOOL)colourButton {
|
2018-02-13 02:46:21 +00:00
|
|
|
@synchronized(_machine) {
|
|
|
|
_atari2600->set_switch_is_enabled(Atari2600SwitchColour, colourButton);
|
2016-06-19 23:36:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 02:46:50 +00:00
|
|
|
- (BOOL)colourButton {
|
|
|
|
@synchronized(_machine) {
|
|
|
|
return _atari2600->get_switch_is_enabled(Atari2600SwitchColour);
|
|
|
|
}
|
|
|
|
}
|
2018-02-13 02:46:21 +00:00
|
|
|
|
2018-02-15 02:46:50 +00:00
|
|
|
- (void)setLeftPlayerDifficultyButton:(BOOL)leftPlayerDifficultyButton {
|
2018-02-13 02:46:21 +00:00
|
|
|
@synchronized(_machine) {
|
|
|
|
_atari2600->set_switch_is_enabled(Atari2600SwitchLeftPlayerDifficulty, leftPlayerDifficultyButton);
|
2016-06-19 23:36:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 02:46:50 +00:00
|
|
|
- (BOOL)leftPlayerDifficultyButton {
|
|
|
|
@synchronized(_machine) {
|
|
|
|
return _atari2600->get_switch_is_enabled(Atari2600SwitchLeftPlayerDifficulty);
|
|
|
|
}
|
|
|
|
}
|
2018-02-13 02:46:21 +00:00
|
|
|
|
2018-02-15 02:46:50 +00:00
|
|
|
- (void)setRightPlayerDifficultyButton:(BOOL)rightPlayerDifficultyButton {
|
2018-02-13 02:46:21 +00:00
|
|
|
@synchronized(_machine) {
|
|
|
|
_atari2600->set_switch_is_enabled(Atari2600SwitchRightPlayerDifficulty, rightPlayerDifficultyButton);
|
2016-06-19 23:36:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-02-15 02:46:50 +00:00
|
|
|
- (BOOL)rightPlayerDifficultyButton {
|
|
|
|
@synchronized(_machine) {
|
|
|
|
return _atari2600->get_switch_is_enabled(Atari2600SwitchRightPlayerDifficulty);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-19 23:36:34 +00:00
|
|
|
- (void)toggleSwitch:(Atari2600Switch)toggleSwitch {
|
2018-02-13 02:46:21 +00:00
|
|
|
@synchronized(_machine) {
|
|
|
|
_atari2600->set_switch_is_enabled(toggleSwitch, true);
|
2016-06-19 23:36:34 +00:00
|
|
|
}
|
2018-02-13 02:46:21 +00:00
|
|
|
|
2016-06-19 23:36:34 +00:00
|
|
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
2018-03-30 14:25:01 +00:00
|
|
|
@synchronized(self->_machine) {
|
|
|
|
self->_atari2600->set_switch_is_enabled(toggleSwitch, false);
|
2016-06-19 23:36:34 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)pressResetButton {
|
|
|
|
[self toggleSwitch:Atari2600SwitchReset];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)pressSelectButton {
|
|
|
|
[self toggleSwitch:Atari2600SwitchSelect];
|
|
|
|
}
|
|
|
|
|
2016-01-05 04:12:47 +00:00
|
|
|
@end
|