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