2016-06-05 01:43:50 +00:00
|
|
|
//
|
|
|
|
// CSVic20.m
|
|
|
|
// Clock Signal
|
|
|
|
//
|
|
|
|
// Created by Thomas Harte on 04/06/2016.
|
|
|
|
// Copyright © 2016 Thomas Harte. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
#import "CSVic20.h"
|
|
|
|
|
2016-06-25 20:24:52 +00:00
|
|
|
#include "Vic20.hpp"
|
2016-10-03 11:42:05 +00:00
|
|
|
|
2016-07-05 17:28:27 +00:00
|
|
|
using namespace Commodore::Vic20;
|
|
|
|
|
2016-06-05 02:00:50 +00:00
|
|
|
@implementation CSVic20 {
|
2017-08-16 20:05:30 +00:00
|
|
|
std::unique_ptr<Machine> _vic20;
|
2016-07-05 02:01:07 +00:00
|
|
|
BOOL _joystickMode;
|
2016-06-05 02:00:50 +00:00
|
|
|
}
|
|
|
|
|
2016-10-03 11:42:05 +00:00
|
|
|
- (NSString *)userDefaultsPrefix { return @"vic20"; }
|
|
|
|
|
|
|
|
- (instancetype)init {
|
2017-08-27 20:36:21 +00:00
|
|
|
Machine *machine = Commodore::Vic20::Machine::Vic20();
|
|
|
|
|
|
|
|
self = [super initWithMachine:machine];
|
2017-08-16 20:05:30 +00:00
|
|
|
if(self) {
|
2017-08-27 20:36:21 +00:00
|
|
|
_vic20.reset(machine);
|
2016-10-03 11:42:05 +00:00
|
|
|
[self setCountry:CSVic20CountryEuropean];
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark - Keyboard map
|
|
|
|
|
2017-10-13 02:25:02 +00:00
|
|
|
/*- (void)setKey:(uint16_t)key isPressed:(BOOL)isPressed {
|
2017-10-15 02:36:31 +00:00
|
|
|
switch(key) {
|
|
|
|
case VK_UpArrow: _vic20->set_joystick_state(JoystickInput::Up, isPressed); break;
|
|
|
|
case VK_DownArrow: _vic20->set_joystick_state(JoystickInput::Down, isPressed); break;
|
|
|
|
case VK_LeftArrow: _vic20->set_joystick_state(JoystickInput::Left, isPressed); break;
|
|
|
|
case VK_RightArrow: _vic20->set_joystick_state(JoystickInput::Right, isPressed); break;
|
|
|
|
case VK_ANSI_A: _vic20->set_joystick_state(JoystickInput::Fire, isPressed); break;
|
2016-06-11 15:50:37 +00:00
|
|
|
}
|
2017-10-13 02:25:02 +00:00
|
|
|
}*/
|
2016-06-05 12:53:05 +00:00
|
|
|
|
2016-08-14 18:14:59 +00:00
|
|
|
#pragma mark - Public configuration options
|
|
|
|
|
2016-06-28 01:38:14 +00:00
|
|
|
- (void)setUseFastLoadingHack:(BOOL)useFastLoadingHack {
|
2016-08-14 18:14:59 +00:00
|
|
|
_useFastLoadingHack = useFastLoadingHack;
|
2016-06-28 01:38:14 +00:00
|
|
|
@synchronized(self) {
|
2017-08-16 20:05:30 +00:00
|
|
|
_vic20->set_use_fast_tape_hack(useFastLoadingHack ? true : false);
|
2016-06-28 01:38:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-10-03 11:42:05 +00:00
|
|
|
- (void)setCountry:(CSVic20Country)country {
|
|
|
|
_country = country;
|
|
|
|
Commodore::Vic20::Region region;
|
2017-08-16 20:05:30 +00:00
|
|
|
switch(country) {
|
2017-11-08 03:29:57 +00:00
|
|
|
case CSVic20CountryDanish: region = Commodore::Vic20::Danish; break;
|
|
|
|
case CSVic20CountryEuropean: region = Commodore::Vic20::European; break;
|
|
|
|
case CSVic20CountryJapanese: region = Commodore::Vic20::Japanese; break;
|
|
|
|
case CSVic20CountrySwedish: region = Commodore::Vic20::Swedish; break;
|
|
|
|
case CSVic20CountryAmerican: region = Commodore::Vic20::American; break;
|
2016-10-03 11:42:05 +00:00
|
|
|
}
|
|
|
|
|
2016-08-14 18:14:59 +00:00
|
|
|
@synchronized(self) {
|
2017-08-16 20:05:30 +00:00
|
|
|
_vic20->set_region(region);
|
2016-08-14 18:14:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)setMemorySize:(CSVic20MemorySize)memorySize {
|
|
|
|
_memorySize = memorySize;
|
|
|
|
@synchronized(self) {
|
|
|
|
switch(memorySize) {
|
2017-08-16 20:05:30 +00:00
|
|
|
case CSVic20MemorySize5Kb: _vic20->set_memory_size(Commodore::Vic20::Default); break;
|
|
|
|
case CSVic20MemorySize8Kb: _vic20->set_memory_size(Commodore::Vic20::ThreeKB); break;
|
|
|
|
case CSVic20MemorySize32Kb: _vic20->set_memory_size(Commodore::Vic20::ThirtyTwoKB); break;
|
2016-08-14 18:14:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-05 01:43:50 +00:00
|
|
|
@end
|