1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-08-13 00:25:26 +00:00

Turning this into a slog: gave UEF a more appropriate name, got as far as now having to decide what to do about ROMs as to structure. I guess they're machine specific, so specific classes?

This commit is contained in:
Thomas Harte
2016-08-27 16:40:21 -04:00
parent 55ada536ac
commit 8c333059a8
4 changed files with 75 additions and 13 deletions

View File

@@ -41,7 +41,7 @@
- (BOOL)openUEFAtURL:(NSURL *)URL { - (BOOL)openUEFAtURL:(NSURL *)URL {
@synchronized(self) { @synchronized(self) {
try { try {
std::shared_ptr<Storage::UEF> tape(new Storage::UEF([URL fileSystemRepresentation])); std::shared_ptr<Storage::TapeUEF> tape(new Storage::TapeUEF([URL fileSystemRepresentation]));
_electron.set_tape(tape); _electron.set_tape(tape);
return YES; return YES;
} catch(...) { } catch(...) {

View File

@@ -7,8 +7,24 @@
// //
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include <cstdlib> #include <cstdlib>
#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; using namespace StaticAnalyser;
std::list<Target> StaticAnalyser::GetTargets(const char *file_name) std::list<Target> StaticAnalyser::GetTargets(const char *file_name)
@@ -21,7 +37,7 @@ std::list<Target> StaticAnalyser::GetTargets(const char *file_name)
char *lowercase_extension = nullptr; char *lowercase_extension = nullptr;
if(mixed_case_extension) if(mixed_case_extension)
{ {
lowercase_extension = strdup(mixed_case_extension); lowercase_extension = strdup(mixed_case_extension+1);
char *parser = lowercase_extension; char *parser = lowercase_extension;
while(*parser) while(*parser)
{ {
@@ -34,8 +50,52 @@ std::list<Target> StaticAnalyser::GetTargets(const char *file_name)
// union of all platforms this file might be a target for. // union of all platforms this file might be a target for.
std::list<std::shared_ptr<Storage::Disk>> disks; std::list<std::shared_ptr<Storage::Disk>> disks;
std::list<std::shared_ptr<Storage::Tape>> tapes; std::list<std::shared_ptr<Storage::Tape>> 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); printf("Lowercase extension: %s", lowercase_extension);

View File

@@ -10,6 +10,8 @@
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
using namespace Storage;
static float gzgetfloat(gzFile file) static float gzgetfloat(gzFile file)
{ {
uint8_t bytes[4]; uint8_t bytes[4];
@@ -41,7 +43,7 @@ static float gzgetfloat(gzFile file)
return result; return result;
} }
Storage::UEF::UEF(const char *file_name) : TapeUEF::TapeUEF(const char *file_name) :
_chunk_id(0), _chunk_length(0), _chunk_position(0), _chunk_id(0), _chunk_length(0), _chunk_position(0),
_time_base(1200) _time_base(1200)
{ {
@@ -67,17 +69,17 @@ Storage::UEF::UEF(const char *file_name) :
find_next_tape_chunk(); find_next_tape_chunk();
} }
Storage::UEF::~UEF() TapeUEF::~TapeUEF()
{ {
gzclose(_file); gzclose(_file);
} }
void Storage::UEF::reset() void TapeUEF::reset()
{ {
gzseek(_file, 12, SEEK_SET); gzseek(_file, 12, SEEK_SET);
} }
Storage::Tape::Pulse Storage::UEF::get_next_pulse() Tape::Pulse TapeUEF::get_next_pulse()
{ {
Pulse next_pulse; Pulse next_pulse;
@@ -145,7 +147,7 @@ Storage::Tape::Pulse Storage::UEF::get_next_pulse()
return next_pulse; return next_pulse;
} }
void Storage::UEF::find_next_tape_chunk() void TapeUEF::find_next_tape_chunk()
{ {
int reset_count = 0; int reset_count = 0;
_chunk_position = 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) 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) switch(_chunk_id)
{ {

View File

@@ -18,15 +18,15 @@ namespace Storage {
/*! /*!
Provides a @c Tape containing a UEF tape image, a slightly-convoluted description of pulses. Provides a @c Tape containing a UEF tape image, a slightly-convoluted description of pulses.
*/ */
class UEF : public Tape { class TapeUEF : public Tape {
public: public:
/*! /*!
Constructs a @c UEF containing content from the file with name @c file_name. 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. @throws ErrorNotUEF if this file could not be opened and recognised as a valid UEF.
*/ */
UEF(const char *file_name); TapeUEF(const char *file_name);
~UEF(); ~TapeUEF();
enum { enum {
ErrorNotUEF ErrorNotUEF