mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-19 08:31:11 +00:00
Factored out Commodore is-a-ROM test, allowing it to be used from the Commodore analyser and thereby allowing ROMs to get as far as the machine again.
This commit is contained in:
parent
4010f36238
commit
abf47efd40
@ -349,6 +349,7 @@
|
|||||||
4BC9DF451D044FCA00F44158 /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; };
|
4BC9DF451D044FCA00F44158 /* ROMImages in Resources */ = {isa = PBXBuildFile; fileRef = 4BC9DF441D044FCA00F44158 /* ROMImages */; };
|
||||||
4BC9DF4F1D04691600F44158 /* 6560.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9DF4D1D04691600F44158 /* 6560.cpp */; };
|
4BC9DF4F1D04691600F44158 /* 6560.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9DF4D1D04691600F44158 /* 6560.cpp */; };
|
||||||
4BC9E1EE1D23449A003FCEE4 /* 6502InterruptTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9E1ED1D23449A003FCEE4 /* 6502InterruptTests.swift */; };
|
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 */; };
|
4BD14B111D74627C0088EAD6 /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD14B0F1D74627C0088EAD6 /* StaticAnalyser.cpp */; };
|
||||||
4BD468F71D8DF41D0084958B /* 1770.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD468F51D8DF41D0084958B /* 1770.cpp */; };
|
4BD468F71D8DF41D0084958B /* 1770.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BD468F51D8DF41D0084958B /* 1770.cpp */; };
|
||||||
4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */; };
|
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 = "<group>"; };
|
4BC9DF4D1D04691600F44158 /* 6560.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = 6560.cpp; sourceTree = "<group>"; };
|
||||||
4BC9DF4E1D04691600F44158 /* 6560.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6560.hpp; sourceTree = "<group>"; };
|
4BC9DF4E1D04691600F44158 /* 6560.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6560.hpp; sourceTree = "<group>"; };
|
||||||
4BC9E1ED1D23449A003FCEE4 /* 6502InterruptTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 6502InterruptTests.swift; sourceTree = "<group>"; };
|
4BC9E1ED1D23449A003FCEE4 /* 6502InterruptTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = 6502InterruptTests.swift; sourceTree = "<group>"; };
|
||||||
|
4BCA6CC61D9DD9F000C2D7B2 /* CommodoreROM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = CommodoreROM.cpp; path = Encodings/CommodoreROM.cpp; sourceTree = "<group>"; };
|
||||||
|
4BCA6CC71D9DD9F000C2D7B2 /* CommodoreROM.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = CommodoreROM.hpp; path = Encodings/CommodoreROM.hpp; sourceTree = "<group>"; };
|
||||||
4BCA98C21D065CA20062F44C /* 6522.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6522.hpp; sourceTree = "<group>"; };
|
4BCA98C21D065CA20062F44C /* 6522.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6522.hpp; sourceTree = "<group>"; };
|
||||||
4BD14B0F1D74627C0088EAD6 /* StaticAnalyser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StaticAnalyser.cpp; path = ../../StaticAnalyser/Acorn/StaticAnalyser.cpp; sourceTree = "<group>"; };
|
4BD14B0F1D74627C0088EAD6 /* StaticAnalyser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = StaticAnalyser.cpp; path = ../../StaticAnalyser/Acorn/StaticAnalyser.cpp; sourceTree = "<group>"; };
|
||||||
4BD14B101D74627C0088EAD6 /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = StaticAnalyser.hpp; path = ../../StaticAnalyser/Acorn/StaticAnalyser.hpp; sourceTree = "<group>"; };
|
4BD14B101D74627C0088EAD6 /* StaticAnalyser.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = StaticAnalyser.hpp; path = ../../StaticAnalyser/Acorn/StaticAnalyser.hpp; sourceTree = "<group>"; };
|
||||||
@ -1625,6 +1628,15 @@
|
|||||||
path = 6560;
|
path = 6560;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
4BCA6CC91D9DD9F500C2D7B2 /* Encodings */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
4BCA6CC61D9DD9F000C2D7B2 /* CommodoreROM.cpp */,
|
||||||
|
4BCA6CC71D9DD9F000C2D7B2 /* CommodoreROM.hpp */,
|
||||||
|
);
|
||||||
|
name = Encodings;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
4BD14B121D7462810088EAD6 /* Acorn */ = {
|
4BD14B121D7462810088EAD6 /* Acorn */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
@ -1672,6 +1684,7 @@
|
|||||||
4BEE0A6A1D72496600532C7B /* Cartridge.cpp */,
|
4BEE0A6A1D72496600532C7B /* Cartridge.cpp */,
|
||||||
4BEE0A6B1D72496600532C7B /* Cartridge.hpp */,
|
4BEE0A6B1D72496600532C7B /* Cartridge.hpp */,
|
||||||
4BEE0A6C1D72496600532C7B /* Formats */,
|
4BEE0A6C1D72496600532C7B /* Formats */,
|
||||||
|
4BCA6CC91D9DD9F500C2D7B2 /* Encodings */,
|
||||||
);
|
);
|
||||||
path = Cartridge;
|
path = Cartridge;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -2163,6 +2176,7 @@
|
|||||||
4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */,
|
4B2E2D9A1C3A06EC00138695 /* Atari2600.cpp in Sources */,
|
||||||
4B3051301D98ACC600B4FED8 /* Plus3.cpp in Sources */,
|
4B3051301D98ACC600B4FED8 /* Plus3.cpp in Sources */,
|
||||||
4B30512D1D989E2200B4FED8 /* Drive.cpp in Sources */,
|
4B30512D1D989E2200B4FED8 /* Drive.cpp in Sources */,
|
||||||
|
4BCA6CC81D9DD9F000C2D7B2 /* CommodoreROM.cpp in Sources */,
|
||||||
4BA22B071D8817CE0008C640 /* Disk.cpp in Sources */,
|
4BA22B071D8817CE0008C640 /* Disk.cpp in Sources */,
|
||||||
4BC3B7521CD1956900F86E85 /* OutputShader.cpp in Sources */,
|
4BC3B7521CD1956900F86E85 /* OutputShader.cpp in Sources */,
|
||||||
4B4C83701D4F623200CD541F /* D64.cpp in Sources */,
|
4B4C83701D4F623200CD541F /* D64.cpp in Sources */,
|
||||||
|
@ -11,9 +11,33 @@
|
|||||||
#include "File.hpp"
|
#include "File.hpp"
|
||||||
#include "Tape.hpp"
|
#include "Tape.hpp"
|
||||||
#include "Disk.hpp"
|
#include "Disk.hpp"
|
||||||
|
#include "../../Storage/Cartridge/Encodings/CommodoreROM.hpp"
|
||||||
|
|
||||||
using namespace StaticAnalyser::Commodore;
|
using namespace StaticAnalyser::Commodore;
|
||||||
|
|
||||||
|
static std::list<std::shared_ptr<Storage::Cartridge::Cartridge>>
|
||||||
|
Vic20CartridgesFrom(const std::list<std::shared_ptr<Storage::Cartridge::Cartridge>> &cartridges)
|
||||||
|
{
|
||||||
|
std::list<std::shared_ptr<Storage::Cartridge::Cartridge>> vic20_cartridges;
|
||||||
|
|
||||||
|
for(std::shared_ptr<Storage::Cartridge::Cartridge> cartridge : cartridges)
|
||||||
|
{
|
||||||
|
const std::list<Storage::Cartridge::Cartridge::Segment> &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(
|
void StaticAnalyser::Commodore::AddTargets(
|
||||||
const std::list<std::shared_ptr<Storage::Disk::Disk>> &disks,
|
const std::list<std::shared_ptr<Storage::Disk::Disk>> &disks,
|
||||||
const std::list<std::shared_ptr<Storage::Tape::Tape>> &tapes,
|
const std::list<std::shared_ptr<Storage::Tape::Tape>> &tapes,
|
||||||
@ -29,7 +53,7 @@ void StaticAnalyser::Commodore::AddTargets(
|
|||||||
bool is_disk = false;
|
bool is_disk = false;
|
||||||
|
|
||||||
// strip out inappropriate cartridges
|
// strip out inappropriate cartridges
|
||||||
// target.cartridges = AcornCartridgesFrom(cartridges);
|
target.cartridges = Vic20CartridgesFrom(cartridges);
|
||||||
|
|
||||||
// check disks
|
// check disks
|
||||||
for(auto &disk : disks)
|
for(auto &disk : disks)
|
||||||
@ -126,7 +150,6 @@ void StaticAnalyser::Commodore::AddTargets(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(target.tapes.size() || target.cartridges.size() || target.disks.size())
|
if(target.tapes.size() || target.cartridges.size() || target.disks.size())
|
||||||
destination.push_back(target);
|
destination.push_back(target);
|
||||||
}
|
}
|
||||||
|
25
Storage/Cartridge/Encodings/CommodoreROM.cpp
Normal file
25
Storage/Cartridge/Encodings/CommodoreROM.cpp
Normal file
@ -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<uint8_t> &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;
|
||||||
|
}
|
27
Storage/Cartridge/Encodings/CommodoreROM.hpp
Normal file
27
Storage/Cartridge/Encodings/CommodoreROM.hpp
Normal file
@ -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 <vector>
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace Storage {
|
||||||
|
namespace Cartridge {
|
||||||
|
namespace Encodings {
|
||||||
|
namespace CommodoreROM {
|
||||||
|
|
||||||
|
bool isROM(const std::vector<uint8_t> &);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CommodoreROM_hpp */
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include "../Encodings/CommodoreROM.hpp"
|
||||||
|
|
||||||
using namespace Storage::Cartridge;
|
using namespace Storage::Cartridge;
|
||||||
|
|
||||||
@ -42,12 +43,7 @@ PRG::PRG(const char *file_name)
|
|||||||
throw ErrorNotROM;
|
throw ErrorNotROM;
|
||||||
|
|
||||||
// also accept only cartridges with the proper signature
|
// also accept only cartridges with the proper signature
|
||||||
if(
|
if(!Storage::Cartridge::Encodings::CommodoreROM::isROM(contents))
|
||||||
contents[4] != 0x41 ||
|
|
||||||
contents[5] != 0x30 ||
|
|
||||||
contents[6] != 0xc3 ||
|
|
||||||
contents[7] != 0xc2 ||
|
|
||||||
contents[8] != 0xcd)
|
|
||||||
throw ErrorNotROM;
|
throw ErrorNotROM;
|
||||||
|
|
||||||
_segments.emplace_back(0xa000, 0xa000 + data_length, std::move(contents));
|
_segments.emplace_back(0xa000, 0xa000 + data_length, std::move(contents));
|
||||||
|
Loading…
Reference in New Issue
Block a user