diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 8f4624052..faa4e010c 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -349,6 +349,7 @@ 4BC9DF451D044FCA00F44158 /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; }; 4BC9DF4F1D04691600F44158 /* 6560.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9DF4D1D04691600F44158 /* 6560.cpp */; }; 4BC9E1EE1D23449A003FCEE4 /* 6502InterruptTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9E1ED1D23449A003FCEE4 /* 6502InterruptTests.swift */; }; + 4BCA6CC81D9DD9F000C2D7B2 /* CommodoreROM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BCA6CC61D9DD9F000C2D7B2 /* CommodoreROM.cpp */; }; 4BD14B111D74627C0088EAD6 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD14B0F1D74627C0088EAD6 /* StaticAnalyser.cpp */; }; 4BD468F71D8DF41D0084958B /* 1770.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD468F51D8DF41D0084958B /* 1770.cpp */; }; 4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */; }; @@ -801,6 +802,8 @@ 4BC9DF4D1D04691600F44158 /* 6560.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 6560.cpp; sourceTree = ""; }; 4BC9DF4E1D04691600F44158 /* 6560.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6560.hpp; sourceTree = ""; }; 4BC9E1ED1D23449A003FCEE4 /* 6502InterruptTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 6502InterruptTests.swift; sourceTree = ""; }; + 4BCA6CC61D9DD9F000C2D7B2 /* CommodoreROM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommodoreROM.cpp; path = Encodings/CommodoreROM.cpp; sourceTree = ""; }; + 4BCA6CC71D9DD9F000C2D7B2 /* CommodoreROM.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CommodoreROM.hpp; path = Encodings/CommodoreROM.hpp; sourceTree = ""; }; 4BCA98C21D065CA20062F44C /* 6522.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6522.hpp; sourceTree = ""; }; 4BD14B0F1D74627C0088EAD6 /* StaticAnalyser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StaticAnalyser.cpp; path = ../../StaticAnalyser/Acorn/StaticAnalyser.cpp; sourceTree = ""; }; 4BD14B101D74627C0088EAD6 /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = StaticAnalyser.hpp; path = ../../StaticAnalyser/Acorn/StaticAnalyser.hpp; sourceTree = ""; }; @@ -1625,6 +1628,15 @@ path = 6560; sourceTree = ""; }; + 4BCA6CC91D9DD9F500C2D7B2 /* Encodings */ = { + isa = PBXGroup; + children = ( + 4BCA6CC61D9DD9F000C2D7B2 /* CommodoreROM.cpp */, + 4BCA6CC71D9DD9F000C2D7B2 /* CommodoreROM.hpp */, + ); + name = Encodings; + sourceTree = ""; + }; 4BD14B121D7462810088EAD6 /* Acorn */ = { isa = PBXGroup; children = ( @@ -1672,6 +1684,7 @@ 4BEE0A6A1D72496600532C7B /* Cartridge.cpp */, 4BEE0A6B1D72496600532C7B /* Cartridge.hpp */, 4BEE0A6C1D72496600532C7B /* Formats */, + 4BCA6CC91D9DD9F500C2D7B2 /* Encodings */, ); path = Cartridge; sourceTree = ""; @@ -2163,6 +2176,7 @@ 4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */, 4B3051301D98ACC600B4FED8 /* Plus3.cpp in Sources */, 4B30512D1D989E2200B4FED8 /* Drive.cpp in Sources */, + 4BCA6CC81D9DD9F000C2D7B2 /* CommodoreROM.cpp in Sources */, 4BA22B071D8817CE0008C640 /* Disk.cpp in Sources */, 4BC3B7521CD1956900F86E85 /* OutputShader.cpp in Sources */, 4B4C83701D4F623200CD541F /* D64.cpp in Sources */, diff --git a/StaticAnalyser/Commodore/StaticAnalyser.cpp b/StaticAnalyser/Commodore/StaticAnalyser.cpp index 28e5f1dba..2a3faae80 100644 --- a/StaticAnalyser/Commodore/StaticAnalyser.cpp +++ b/StaticAnalyser/Commodore/StaticAnalyser.cpp @@ -11,9 +11,33 @@ #include "File.hpp" #include "Tape.hpp" #include "Disk.hpp" +#include "../../Storage/Cartridge/Encodings/CommodoreROM.hpp" using namespace StaticAnalyser::Commodore; +static std::list> + Vic20CartridgesFrom(const std::list> &cartridges) +{ + std::list> vic20_cartridges; + + for(std::shared_ptr cartridge : cartridges) + { + const std::list &segments = cartridge->get_segments(); + + // only one mapped item is allowed + if(segments.size() != 1) continue; + + // which must be 16 kb in size + Storage::Cartridge::Cartridge::Segment segment = segments.front(); + if(segment.start_address != 0xa000) continue; + if(!Storage::Cartridge::Encodings::CommodoreROM::isROM(segment.data)) continue; + + vic20_cartridges.push_back(cartridge); + } + + return vic20_cartridges; +} + void StaticAnalyser::Commodore::AddTargets( const std::list> &disks, const std::list> &tapes, @@ -29,7 +53,7 @@ void StaticAnalyser::Commodore::AddTargets( bool is_disk = false; // strip out inappropriate cartridges -// target.cartridges = AcornCartridgesFrom(cartridges); + target.cartridges = Vic20CartridgesFrom(cartridges); // check disks for(auto &disk : disks) @@ -126,7 +150,6 @@ void StaticAnalyser::Commodore::AddTargets( } } - if(target.tapes.size() || target.cartridges.size() || target.disks.size()) destination.push_back(target); } diff --git a/Storage/Cartridge/Encodings/CommodoreROM.cpp b/Storage/Cartridge/Encodings/CommodoreROM.cpp new file mode 100644 index 000000000..cb4a03df7 --- /dev/null +++ b/Storage/Cartridge/Encodings/CommodoreROM.cpp @@ -0,0 +1,25 @@ +// +// CommodoreROM.cpp +// Clock Signal +// +// Created by Thomas Harte on 29/09/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#include "CommodoreROM.hpp" + +bool Storage::Cartridge::Encodings::CommodoreROM::isROM(const std::vector &contents) +{ + return + ( + contents.size() == 0x400 || + contents.size() == 0x800 || + contents.size() == 0x1000 || + contents.size() == 0x2000 + ) && + contents[4] == 0x41 && + contents[5] == 0x30 && + contents[6] == 0xc3 && + contents[7] == 0xc2 && + contents[8] == 0xcd; +} diff --git a/Storage/Cartridge/Encodings/CommodoreROM.hpp b/Storage/Cartridge/Encodings/CommodoreROM.hpp new file mode 100644 index 000000000..731e505e6 --- /dev/null +++ b/Storage/Cartridge/Encodings/CommodoreROM.hpp @@ -0,0 +1,27 @@ +// +// CommodoreROM.hpp +// Clock Signal +// +// Created by Thomas Harte on 29/09/2016. +// Copyright © 2016 Thomas Harte. All rights reserved. +// + +#ifndef CommodoreROM_hpp +#define CommodoreROM_hpp + +#include +#include + +namespace Storage { +namespace Cartridge { +namespace Encodings { +namespace CommodoreROM { + +bool isROM(const std::vector &); + +} +} +} +} + +#endif /* CommodoreROM_hpp */ diff --git a/Storage/Cartridge/Formats/PRG.cpp b/Storage/Cartridge/Formats/PRG.cpp index fcbfd36a7..43b5c85df 100644 --- a/Storage/Cartridge/Formats/PRG.cpp +++ b/Storage/Cartridge/Formats/PRG.cpp @@ -10,6 +10,7 @@ #include #include +#include "../Encodings/CommodoreROM.hpp" using namespace Storage::Cartridge; @@ -42,12 +43,7 @@ PRG::PRG(const char *file_name) throw ErrorNotROM; // also accept only cartridges with the proper signature - if( - contents[4] != 0x41 || - contents[5] != 0x30 || - contents[6] != 0xc3 || - contents[7] != 0xc2 || - contents[8] != 0xcd) + if(!Storage::Cartridge::Encodings::CommodoreROM::isROM(contents)) throw ErrorNotROM; _segments.emplace_back(0xa000, 0xa000 + data_length, std::move(contents));