1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-16 22:28:57 +00:00
CLK/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSAmstradCPC.mm
Thomas Harte 78ee46270b Transfers possession of keyboard mappings from the Mac side over to individual machines.
Specifically by establishing an intermediate representation of a useful mix between the American and British IBM and Mac keyboard layouts, and routing through that.
2017-10-12 22:25:02 -04:00

59 lines
1.4 KiB
Plaintext

//
// CSAmstradCPC.m
// Clock Signal
//
// Created by Thomas Harte on 30/07/2017.
// Copyright © 2017 Thomas Harte. All rights reserved.
//
#import "CSAmstradCPC.h"
#include "AmstradCPC.hpp"
#import "CSMachine+Subclassing.h"
#import "NSData+StdVector.h"
#import "NSBundle+DataResource.h"
@implementation CSAmstradCPC {
std::unique_ptr<AmstradCPC::Machine> _amstradCPC;
}
- (instancetype)init {
AmstradCPC::Machine *machine = AmstradCPC::Machine::AmstradCPC();
self = [super initWithMachine:machine];
if(self) {
_amstradCPC.reset(machine);
NSDictionary *roms = @{
@(AmstradCPC::ROMType::OS464) : @"os464",
@(AmstradCPC::ROMType::OS664) : @"os664",
@(AmstradCPC::ROMType::OS6128) : @"os6128",
@(AmstradCPC::ROMType::BASIC464) : @"basic464",
@(AmstradCPC::ROMType::BASIC664) : @"basic664",
@(AmstradCPC::ROMType::BASIC6128) : @"basic6128",
@(AmstradCPC::ROMType::AMSDOS) : @"amsdos",
};
for(NSNumber *key in roms.allKeys) {
AmstradCPC::ROMType type = (AmstradCPC::ROMType)key.integerValue;
NSString *name = roms[key];
NSData *data = [self rom:name];
if(data) {
_amstradCPC->set_rom(type, data.stdVector8);
} else {
NSLog(@"Amstrad CPC ROM missing: %@", name);
}
}
}
return self;
}
- (NSData *)rom:(NSString *)name {
return [[NSBundle mainBundle] dataForResource:name withExtension:@"rom" subdirectory:@"ROMImages/AmstradCPC"];
}
- (NSString *)userDefaultsPrefix { return @"amstradCPC"; }
@end