1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-27 01:31:42 +00:00

Added a test call, further mutated result structure.

This commit is contained in:
Thomas Harte 2016-08-27 14:25:16 -04:00
parent e68ff64045
commit 55ada536ac
3 changed files with 40 additions and 22 deletions

View File

@ -10,6 +10,7 @@
#include <algorithm> #include <algorithm>
#include "../../../Storage/Tape/Formats/TapePRG.hpp" #include "../../../Storage/Tape/Formats/TapePRG.hpp"
#include "../../../StaticAnalyser/StaticAnalyser.hpp"
using namespace Commodore::Vic20; using namespace Commodore::Vic20;
@ -244,6 +245,9 @@ void Machine::set_rom(ROMSlot slot, size_t length, const uint8_t *data)
void Machine::set_prg(const char *file_name, size_t length, const uint8_t *data) void Machine::set_prg(const char *file_name, size_t length, const uint8_t *data)
{ {
// TEST!
StaticAnalyser::GetTargets(file_name);
if(length > 2) if(length > 2)
{ {
_rom_address = (uint16_t)(data[0] | (data[1] << 8)); _rom_address = (uint16_t)(data[0] | (data[1] << 8));

View File

@ -7,24 +7,38 @@
// //
#include "StaticAnalyser.hpp" #include "StaticAnalyser.hpp"
#include <cstdlib>
using namespace StaticAnalyser; using namespace StaticAnalyser;
std::list<Target> GetTargets(std::shared_ptr<Storage::Disk> disk, std::shared_ptr<Storage::Tape> tape, std::shared_ptr<std::vector<uint8_t>> rom) std::list<Target> StaticAnalyser::GetTargets(const char *file_name)
{ {
std::list<Target> targets; std::list<Target> targets;
if(disk) // Get the extension, if any; it will be assumed that extensions are reliable, so an extension is a broad-phase
// test as to file format.
const char *mixed_case_extension = strrchr(file_name, '.');
char *lowercase_extension = nullptr;
if(mixed_case_extension)
{ {
lowercase_extension = strdup(mixed_case_extension);
char *parser = lowercase_extension;
while(*parser)
{
*parser = (char)tolower(*parser);
parser++;
}
} }
if(tape) // Collect all disks, tapes and ROMs as can be extrapolated from this file, forming the
{ // 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::Tape>> tapes;
if(rom) // Obtain the union of all platforms that
{
}
printf("Lowercase extension: %s", lowercase_extension);
free(lowercase_extension);
return targets; return targets;
} }

View File

@ -32,25 +32,25 @@ struct Target {
Unexpanded, Unexpanded,
EightKB, EightKB,
ThirtyTwoKB ThirtyTwoKB
} Vic20; } vic20;
} MemoryModel; } memoryModel;
union { union {
enum class Electron { struct {
ADFS, bool adfs;
DFS bool dfs;
} Electron; } acorn;
enum class Vic20 { struct {
C1540 bool c1540;
} Vic20; } vic20;
} ExternalHardware; } externalHardware;
std::string loadingCommand; std::string loadingCommand;
union { union {
enum class BBCElectron { struct {
HoldShift bool holdShift;
} BBCElectron; } acorn;
} LoadingMethod; } loadingMethod;
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;