mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-24 12:30:17 +00:00
Performed the basic metadata and routing for opening D64 files. Realised that I wasn't actually necessarily catching exceptions properly for all file opens, and fixed.
This commit is contained in:
parent
ee2a7c9415
commit
58297f1baf
@ -30,6 +30,7 @@
|
||||
4B3BA0CF1D318B44005DD7A7 /* MOS6522Bridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3BA0C91D318B44005DD7A7 /* MOS6522Bridge.mm */; };
|
||||
4B3BA0D01D318B44005DD7A7 /* MOS6532Bridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3BA0CB1D318B44005DD7A7 /* MOS6532Bridge.mm */; };
|
||||
4B3BA0D11D318B44005DD7A7 /* TestMachine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3BA0CD1D318B44005DD7A7 /* TestMachine.mm */; };
|
||||
4B4C83701D4F623200CD541F /* D64.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B4C836E1D4F623200CD541F /* D64.cpp */; };
|
||||
4B4DC8211D2C2425003C5BF8 /* Vic20.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B4DC81F1D2C2425003C5BF8 /* Vic20.cpp */; };
|
||||
4B4DC8281D2C2470003C5BF8 /* C1540.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B4DC8261D2C2470003C5BF8 /* C1540.cpp */; };
|
||||
4B4DC82B1D2C27A4003C5BF8 /* SerialBus.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B4DC8291D2C27A4003C5BF8 /* SerialBus.cpp */; };
|
||||
@ -408,6 +409,8 @@
|
||||
4B3BA0CB1D318B44005DD7A7 /* MOS6532Bridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MOS6532Bridge.mm; sourceTree = "<group>"; };
|
||||
4B3BA0CC1D318B44005DD7A7 /* TestMachine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestMachine.h; sourceTree = "<group>"; };
|
||||
4B3BA0CD1D318B44005DD7A7 /* TestMachine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestMachine.mm; sourceTree = "<group>"; };
|
||||
4B4C836E1D4F623200CD541F /* D64.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = D64.cpp; sourceTree = "<group>"; };
|
||||
4B4C836F1D4F623200CD541F /* D64.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = D64.hpp; sourceTree = "<group>"; };
|
||||
4B4DC81F1D2C2425003C5BF8 /* Vic20.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Vic20.cpp; sourceTree = "<group>"; };
|
||||
4B4DC8201D2C2425003C5BF8 /* Vic20.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Vic20.hpp; sourceTree = "<group>"; };
|
||||
4B4DC8261D2C2470003C5BF8 /* C1540.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = C1540.cpp; sourceTree = "<group>"; };
|
||||
@ -1027,6 +1030,8 @@
|
||||
children = (
|
||||
4BAB62B31D327F7E00DF5BA0 /* G64.cpp */,
|
||||
4BAB62B41D327F7E00DF5BA0 /* G64.hpp */,
|
||||
4B4C836E1D4F623200CD541F /* D64.cpp */,
|
||||
4B4C836F1D4F623200CD541F /* D64.hpp */,
|
||||
);
|
||||
path = Formats;
|
||||
sourceTree = "<group>";
|
||||
@ -1938,6 +1943,7 @@
|
||||
4B2A53A21D117D36003C6002 /* CSElectron.mm in Sources */,
|
||||
4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */,
|
||||
4BC3B7521CD1956900F86E85 /* OutputShader.cpp in Sources */,
|
||||
4B4C83701D4F623200CD541F /* D64.cpp in Sources */,
|
||||
4B14145B1B58879D00E04248 /* CPU6502.cpp in Sources */,
|
||||
4B2A53A01D117D36003C6002 /* CSMachine.mm in Sources */,
|
||||
4BC91B831D1F160E00884B76 /* CommodoreTAP.cpp in Sources */,
|
||||
|
@ -50,6 +50,7 @@ class Vic20Document: MachineDocument {
|
||||
switch pathExtension.lowercaseString {
|
||||
case "tap": vic20.openTAPAtURL(url)
|
||||
case "g64": vic20.openG64AtURL(url)
|
||||
case "d64": vic20.openD64AtURL(url)
|
||||
default:
|
||||
let fileWrapper = try NSFileWrapper(URL: url, options: NSFileWrapperReadingOptions(rawValue: 0))
|
||||
try self.readFromFileWrapper(fileWrapper, ofType: typeName)
|
||||
|
@ -116,6 +116,20 @@
|
||||
<key>NSDocumentClass</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).Vic20Document</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>d64</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Commodore 1540/1 Disk</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<integer>0</integer>
|
||||
<key>NSDocumentClass</key>
|
||||
<string>$(PRODUCT_MODULE_NAME).Vic20Document</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
|
@ -44,7 +44,7 @@
|
||||
std::shared_ptr<Storage::UEF> tape(new Storage::UEF([URL fileSystemRepresentation]));
|
||||
_electron.set_tape(tape);
|
||||
return YES;
|
||||
} catch(int exception) {
|
||||
} catch(...) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
- (void)setPRG:(nonnull NSData *)prg;
|
||||
- (BOOL)openTAPAtURL:(nonnull NSURL *)URL;
|
||||
- (BOOL)openG64AtURL:(nonnull NSURL *)URL;
|
||||
- (BOOL)openD64AtURL:(nonnull NSURL *)URL;
|
||||
|
||||
@property (nonatomic, assign) BOOL useFastLoadingHack;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "Vic20.hpp"
|
||||
#include "CommodoreTAP.hpp"
|
||||
#include "G64.hpp"
|
||||
#include "D64.hpp"
|
||||
|
||||
using namespace Commodore::Vic20;
|
||||
|
||||
@ -51,19 +52,31 @@ using namespace Commodore::Vic20;
|
||||
std::shared_ptr<Storage::CommodoreTAP> tape(new Storage::CommodoreTAP([URL fileSystemRepresentation]));
|
||||
_vic20.set_tape(tape);
|
||||
return YES;
|
||||
} catch(int exception) {
|
||||
} catch(...) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)openG64AtURL:(NSURL *)URL {
|
||||
return [self openDisk:^std::shared_ptr<Storage::Disk>{
|
||||
return std::shared_ptr<Storage::Disk>(new Storage::G64([URL fileSystemRepresentation]));
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)openD64AtURL:(NSURL *)URL {
|
||||
return [self openDisk:^std::shared_ptr<Storage::Disk>{
|
||||
return std::shared_ptr<Storage::Disk>(new Storage::D64([URL fileSystemRepresentation]));
|
||||
}];
|
||||
}
|
||||
|
||||
- (BOOL)openDisk:(std::shared_ptr<Storage::Disk> (^)())opener {
|
||||
@synchronized(self) {
|
||||
try {
|
||||
std::shared_ptr<Storage::G64> disk(new Storage::G64([URL fileSystemRepresentation]));
|
||||
std::shared_ptr<Storage::Disk> disk = opener();
|
||||
_vic20.set_disk(disk);
|
||||
return YES;
|
||||
} catch(int exception) {
|
||||
} catch(...) {
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
31
Storage/Disk/Formats/D64.cpp
Normal file
31
Storage/Disk/Formats/D64.cpp
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// D64.cpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 01/08/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#include "D64.hpp"
|
||||
|
||||
using namespace Storage;
|
||||
|
||||
D64::D64(const char *file_name)
|
||||
{
|
||||
throw ErrorNotD64;
|
||||
}
|
||||
|
||||
D64::~D64()
|
||||
{
|
||||
if(_file) fclose(_file);
|
||||
}
|
||||
|
||||
unsigned int D64::get_head_position_count()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::shared_ptr<Track> D64::get_track_at_position(unsigned int position)
|
||||
{
|
||||
return std::shared_ptr<Track>();
|
||||
}
|
44
Storage/Disk/Formats/D64.hpp
Normal file
44
Storage/Disk/Formats/D64.hpp
Normal file
@ -0,0 +1,44 @@
|
||||
//
|
||||
// D64.hpp
|
||||
// Clock Signal
|
||||
//
|
||||
// Created by Thomas Harte on 01/08/2016.
|
||||
// Copyright © 2016 Thomas Harte. All rights reserved.
|
||||
//
|
||||
|
||||
#ifndef D64_hpp
|
||||
#define D64_hpp
|
||||
|
||||
#include "../Disk.hpp"
|
||||
|
||||
namespace Storage {
|
||||
|
||||
/*!
|
||||
Provies a @c Disk containing a D64 disk image — a decoded sector dump of a C1540-format disk.
|
||||
*/
|
||||
class D64: public Disk {
|
||||
public:
|
||||
/*!
|
||||
Construct a @c D64 containing content from the file with name @c file_name.
|
||||
|
||||
@throws ErrorCantOpen if this file can't be opened.
|
||||
@throws ErrorNotD64 if the file doesn't appear to contain a .D64 format image.
|
||||
*/
|
||||
D64(const char *file_name);
|
||||
~D64();
|
||||
|
||||
enum {
|
||||
ErrorCantOpen,
|
||||
ErrorNotD64,
|
||||
};
|
||||
|
||||
// implemented to satisfy @c Disk
|
||||
unsigned int get_head_position_count();
|
||||
std::shared_ptr<Track> get_track_at_position(unsigned int position);
|
||||
|
||||
private:
|
||||
FILE *_file;
|
||||
};
|
||||
|
||||
};
|
||||
#endif /* D64_hpp */
|
Loading…
Reference in New Issue
Block a user