From 55ada536ac967dc4ab85d8db8492d6f68dd27c8c Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 27 Aug 2016 14:25:16 -0400 Subject: [PATCH] Added a test call, further mutated result structure. --- Machines/Commodore/Vic-20/Vic20.cpp | 4 ++++ StaticAnalyser/StaticAnalyser.cpp | 30 +++++++++++++++++++++-------- StaticAnalyser/StaticAnalyser.hpp | 28 +++++++++++++-------------- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 140f243d0..8fbc9eb60 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -10,6 +10,7 @@ #include #include "../../../Storage/Tape/Formats/TapePRG.hpp" +#include "../../../StaticAnalyser/StaticAnalyser.hpp" 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) { + // TEST! + StaticAnalyser::GetTargets(file_name); + if(length > 2) { _rom_address = (uint16_t)(data[0] | (data[1] << 8)); diff --git a/StaticAnalyser/StaticAnalyser.cpp b/StaticAnalyser/StaticAnalyser.cpp index a0c95f7c2..9f387cf2d 100644 --- a/StaticAnalyser/StaticAnalyser.cpp +++ b/StaticAnalyser/StaticAnalyser.cpp @@ -7,24 +7,38 @@ // #include "StaticAnalyser.hpp" +#include using namespace StaticAnalyser; -std::list GetTargets(std::shared_ptr disk, std::shared_ptr tape, std::shared_ptr> rom) +std::list StaticAnalyser::GetTargets(const char *file_name) { std::list 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> disks; + std::list> tapes; - if(rom) - { - } + // Obtain the union of all platforms that + printf("Lowercase extension: %s", lowercase_extension); + + free(lowercase_extension); return targets; } diff --git a/StaticAnalyser/StaticAnalyser.hpp b/StaticAnalyser/StaticAnalyser.hpp index e1dd0986c..2aa0073f3 100644 --- a/StaticAnalyser/StaticAnalyser.hpp +++ b/StaticAnalyser/StaticAnalyser.hpp @@ -32,25 +32,25 @@ struct Target { Unexpanded, EightKB, ThirtyTwoKB - } Vic20; - } MemoryModel; + } vic20; + } memoryModel; union { - enum class Electron { - ADFS, - DFS - } Electron; - enum class Vic20 { - C1540 - } Vic20; - } ExternalHardware; + struct { + bool adfs; + bool dfs; + } acorn; + struct { + bool c1540; + } vic20; + } externalHardware; std::string loadingCommand; union { - enum class BBCElectron { - HoldShift - } BBCElectron; - } LoadingMethod; + struct { + bool holdShift; + } acorn; + } loadingMethod; std::list> disks; std::list> tapes;