diff --git a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm index d2a6f48ce..05ea202d8 100644 --- a/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm +++ b/OSBindings/Mac/Clock Signal/Machine/Wrappers/CSElectron.mm @@ -41,7 +41,7 @@ - (BOOL)openUEFAtURL:(NSURL *)URL { @synchronized(self) { try { - std::shared_ptr tape(new Storage::UEF([URL fileSystemRepresentation])); + std::shared_ptr tape(new Storage::TapeUEF([URL fileSystemRepresentation])); _electron.set_tape(tape); return YES; } catch(...) { diff --git a/StaticAnalyser/StaticAnalyser.cpp b/StaticAnalyser/StaticAnalyser.cpp index 9f387cf2d..2d2bf9576 100644 --- a/StaticAnalyser/StaticAnalyser.cpp +++ b/StaticAnalyser/StaticAnalyser.cpp @@ -7,8 +7,24 @@ // #include "StaticAnalyser.hpp" + #include +#include "../Storage/Disk/Formats/D64.hpp" +#include "../Storage/Disk/Formats/G64.hpp" + +#include "../Storage/Tape/Formats/CommodoreTAP.hpp" +#include "../Storage/Tape/Formats/TapePRG.hpp" +#include "../Storage/Tape/Formats/TapeUEF.hpp" + +typedef int TargetPlatformType; +enum class TargetPlatform: TargetPlatformType { + Acorn = 1 << 0, + Atari2600 = 1 << 1, + Commodore = 1 << 2 +}; + + using namespace StaticAnalyser; std::list StaticAnalyser::GetTargets(const char *file_name) @@ -21,7 +37,7 @@ std::list StaticAnalyser::GetTargets(const char *file_name) char *lowercase_extension = nullptr; if(mixed_case_extension) { - lowercase_extension = strdup(mixed_case_extension); + lowercase_extension = strdup(mixed_case_extension+1); char *parser = lowercase_extension; while(*parser) { @@ -34,8 +50,52 @@ std::list StaticAnalyser::GetTargets(const char *file_name) // union of all platforms this file might be a target for. std::list> disks; std::list> tapes; + TargetPlatformType potential_platforms = 0; - // Obtain the union of all platforms that +#define Format(extension, list, class, platforms) \ + if(!strcmp(lowercase_extension, extension)) \ + { \ + try { \ + list.emplace_back(new Storage::class(file_name));\ + potential_platforms |= (TargetPlatformType)(platforms);\ + } catch(...) {}\ + } + + // A26 + if(!strcmp(lowercase_extension, "a26")) + { + } + + // BIN + if(!strcmp(lowercase_extension, "bin")) + { + } + + Format("d64", disks, D64, TargetPlatform::Commodore) // D64 + Format("g64", disks, G64, TargetPlatform::Commodore) // G64 + + // PRG + if(!strcmp(lowercase_extension, "prg")) + { + // try instantiating as a ROM; failing that accept as a tape + try { + tapes.emplace_back(new Storage::TapePRG(file_name)); + potential_platforms |= (TargetPlatformType)TargetPlatform::Commodore; + } catch(...) {} + } + + // ROM + if(!strcmp(lowercase_extension, "rom")) + { + } + + Format("tap", tapes, CommodoreTAP, TargetPlatform::Commodore) // TAP + Format("uef", tapes, TapeUEF, TargetPlatform::Acorn) // UEF (tape) + +#undef Format + + // Hand off to platform-specific determination of whether these things are actually compatible and, + // if so, how to load them. (TODO) printf("Lowercase extension: %s", lowercase_extension); diff --git a/Storage/Tape/Formats/TapeUEF.cpp b/Storage/Tape/Formats/TapeUEF.cpp index 7ed0d8818..7cb0140cf 100644 --- a/Storage/Tape/Formats/TapeUEF.cpp +++ b/Storage/Tape/Formats/TapeUEF.cpp @@ -10,6 +10,8 @@ #include #include +using namespace Storage; + static float gzgetfloat(gzFile file) { uint8_t bytes[4]; @@ -41,7 +43,7 @@ static float gzgetfloat(gzFile file) return result; } -Storage::UEF::UEF(const char *file_name) : +TapeUEF::TapeUEF(const char *file_name) : _chunk_id(0), _chunk_length(0), _chunk_position(0), _time_base(1200) { @@ -67,17 +69,17 @@ Storage::UEF::UEF(const char *file_name) : find_next_tape_chunk(); } -Storage::UEF::~UEF() +TapeUEF::~TapeUEF() { gzclose(_file); } -void Storage::UEF::reset() +void TapeUEF::reset() { gzseek(_file, 12, SEEK_SET); } -Storage::Tape::Pulse Storage::UEF::get_next_pulse() +Tape::Pulse TapeUEF::get_next_pulse() { Pulse next_pulse; @@ -145,7 +147,7 @@ Storage::Tape::Pulse Storage::UEF::get_next_pulse() return next_pulse; } -void Storage::UEF::find_next_tape_chunk() +void TapeUEF::find_next_tape_chunk() { int reset_count = 0; _chunk_position = 0; @@ -234,7 +236,7 @@ void Storage::UEF::find_next_tape_chunk() } } -bool Storage::UEF::chunk_is_finished() +bool TapeUEF::chunk_is_finished() { switch(_chunk_id) { @@ -250,7 +252,7 @@ bool Storage::UEF::chunk_is_finished() } } -bool Storage::UEF::get_next_bit() +bool TapeUEF::get_next_bit() { switch(_chunk_id) { diff --git a/Storage/Tape/Formats/TapeUEF.hpp b/Storage/Tape/Formats/TapeUEF.hpp index e67bdd9e7..fa68c83b9 100644 --- a/Storage/Tape/Formats/TapeUEF.hpp +++ b/Storage/Tape/Formats/TapeUEF.hpp @@ -18,15 +18,15 @@ namespace Storage { /*! Provides a @c Tape containing a UEF tape image, a slightly-convoluted description of pulses. */ -class UEF : public Tape { +class TapeUEF : public Tape { public: /*! Constructs a @c UEF containing content from the file with name @c file_name. @throws ErrorNotUEF if this file could not be opened and recognised as a valid UEF. */ - UEF(const char *file_name); - ~UEF(); + TapeUEF(const char *file_name); + ~TapeUEF(); enum { ErrorNotUEF