1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-25 18:30:07 +00:00

Started forcing a resolution on ROMs by doing. But have immediately misstepped. Rename coming momentarily...

This commit is contained in:
Thomas Harte 2016-08-27 18:17:40 -04:00
parent 82c8459055
commit a1b3a18d11
6 changed files with 148 additions and 3 deletions

View File

@ -340,6 +340,8 @@
4BC9DF4F1D04691600F44158 /* 6560.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9DF4D1D04691600F44158 /* 6560.cpp */; };
4BC9E1EE1D23449A003FCEE4 /* 6502InterruptTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BC9E1ED1D23449A003FCEE4 /* 6502InterruptTests.swift */; };
4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.m in Sources */ = {isa = PBXBuildFile; fileRef = 4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */; };
4BEE0A641D72454000532C7B /* PRG.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEE0A621D72454000532C7B /* PRG.cpp */; };
4BEE0A681D7248B300532C7B /* ROM.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BEE0A661D7248B300532C7B /* ROM.cpp */; };
4BEF6AAA1D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4BEF6AA91D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.mm */; };
4BEF6AAC1D35D1C400E73575 /* DPLLTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BEF6AAB1D35D1C400E73575 /* DPLLTests.swift */; };
4BF1354C1D6D2C300054B2EA /* StaticAnalyser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BF1354A1D6D2C300054B2EA /* StaticAnalyser.cpp */; };
@ -761,6 +763,10 @@
4BCA98C21D065CA20062F44C /* 6522.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = 6522.hpp; sourceTree = "<group>"; };
4BD5F1931D13528900631CD1 /* CSBestEffortUpdater.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CSBestEffortUpdater.h; path = Updater/CSBestEffortUpdater.h; sourceTree = "<group>"; };
4BD5F1941D13528900631CD1 /* CSBestEffortUpdater.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CSBestEffortUpdater.m; path = Updater/CSBestEffortUpdater.m; sourceTree = "<group>"; };
4BEE0A621D72454000532C7B /* PRG.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PRG.cpp; path = ROM/PRG.cpp; sourceTree = "<group>"; };
4BEE0A631D72454000532C7B /* PRG.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = PRG.hpp; path = ROM/PRG.hpp; sourceTree = "<group>"; };
4BEE0A661D7248B300532C7B /* ROM.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = ROM.cpp; path = ROM/ROM.cpp; sourceTree = "<group>"; };
4BEE0A671D7248B300532C7B /* ROM.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = ROM.hpp; path = ROM/ROM.hpp; sourceTree = "<group>"; };
4BEF6AA81D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DigitalPhaseLockedLoopBridge.h; sourceTree = "<group>"; };
4BEF6AA91D35CE9E00E73575 /* DigitalPhaseLockedLoopBridge.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DigitalPhaseLockedLoopBridge.mm; sourceTree = "<group>"; };
4BEF6AAB1D35D1C400E73575 /* DPLLTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DPLLTests.swift; sourceTree = "<group>"; };
@ -990,6 +996,7 @@
4BB697CA1D4B6D3E00248BDF /* TimedEventLoop.hpp */,
4BAB62AA1D3272D200DF5BA0 /* Disk */,
4B69FB3A1C4D908A00B5F0AA /* Tape */,
4BEE0A651D72454400532C7B /* ROM */,
);
name = Storage;
path = ../../Storage;
@ -1523,6 +1530,17 @@
path = Resources;
sourceTree = "<group>";
};
4BEE0A651D72454400532C7B /* ROM */ = {
isa = PBXGroup;
children = (
4BEE0A621D72454000532C7B /* PRG.cpp */,
4BEE0A631D72454000532C7B /* PRG.hpp */,
4BEE0A661D7248B300532C7B /* ROM.cpp */,
4BEE0A671D7248B300532C7B /* ROM.hpp */,
);
name = ROM;
sourceTree = "<group>";
};
4BF1354D1D6D2C360054B2EA /* StaticAnalyser */ = {
isa = PBXGroup;
children = (
@ -1945,6 +1963,7 @@
4BB697CE1D4BA44400248BDF /* CommodoreGCR.cpp in Sources */,
4BBF99151C8FBA6F0075DAFB /* CRTOpenGL.cpp in Sources */,
4B0CCC451C62D0B3001CAC5F /* CRT.cpp in Sources */,
4BEE0A681D7248B300532C7B /* ROM.cpp in Sources */,
4BB697C71D4B558F00248BDF /* Factors.cpp in Sources */,
4B55CE591C3B7D360093A61B /* ElectronDocument.swift in Sources */,
4B4DC82B1D2C27A4003C5BF8 /* SerialBus.cpp in Sources */,
@ -1954,6 +1973,7 @@
4BD5F1951D13528900631CD1 /* CSBestEffortUpdater.m in Sources */,
4B0BE4281D3481E700D5256B /* DigitalPhaseLockedLoop.cpp in Sources */,
4B73C71A1D036BD90074D992 /* Vic20Document.swift in Sources */,
4BEE0A641D72454000532C7B /* PRG.cpp in Sources */,
4BBF99181C8FBA6F0075DAFB /* TextureTarget.cpp in Sources */,
4BC76E691C98E31700E6EF73 /* FIRFilter.cpp in Sources */,
4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */,

View File

@ -79,9 +79,14 @@ std::list<Target> StaticAnalyser::GetTargets(const char *file_name)
{
// try instantiating as a ROM; failing that accept as a tape
try {
tapes.emplace_back(new Storage::Tape::PRG(file_name));
potential_platforms |= (TargetPlatformType)TargetPlatform::Commodore;
} catch(...) {}
}
catch(...)
{
try {
tapes.emplace_back(new Storage::Tape::PRG(file_name));
potential_platforms |= (TargetPlatformType)TargetPlatform::Commodore;
} catch(...) {}
}
}
// ROM

56
Storage/ROM/PRG.cpp Normal file
View File

@ -0,0 +1,56 @@
//
// PRG.cpp
// Clock Signal
//
// Created by Thomas Harte on 27/08/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#include "PRG.hpp"
#include <cstdio>
#include <sys/stat.h>
using namespace Storage::ROM;
PRG::PRG(const char *file_name) : _contents(nullptr)
{
struct stat file_stats;
stat(file_name, &file_stats);
// accept only files sized 1, 2, 4 or 8kb
if(
file_stats.st_size != 0x400 + 2 &&
file_stats.st_size != 0x800 + 2 &&
file_stats.st_size != 0x1000 + 2 &&
file_stats.st_size != 0x2000 + 2)
throw ErrorNotROM;
// get the loading address, and the rest of the contents
FILE *file = fopen(file_name, "rb");
int loading_address = fgetc(file);
loading_address |= fgetc(file) << 8;
_contents = new uint8_t[file_stats.st_size - 2];
fread(_contents, 1, (size_t)(file_stats.st_size - 2), file);
fclose(file);
// accept only files intended to load at 0xa000
if(loading_address != 0xa000)
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)
throw ErrorNotROM;
}
PRG::~PRG()
{
delete[] _contents;
}

35
Storage/ROM/PRG.hpp Normal file
View File

@ -0,0 +1,35 @@
//
// PRG.hpp
// Clock Signal
//
// Created by Thomas Harte on 27/08/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#ifndef PRG_hpp
#define PRG_hpp
#include <vector>
#include "ROM.hpp"
namespace Storage {
namespace ROM {
class PRG : public ROM {
public:
PRG(const char *file_name);
~PRG();
enum {
ErrorNotROM
};
private:
uint8_t *_contents;
uint16_t _size;
};
}
}
#endif /* PRG_hpp */

9
Storage/ROM/ROM.cpp Normal file
View File

@ -0,0 +1,9 @@
//
// ROM.cpp
// Clock Signal
//
// Created by Thomas Harte on 27/08/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#include "ROM.hpp"

20
Storage/ROM/ROM.hpp Normal file
View File

@ -0,0 +1,20 @@
//
// ROM.hpp
// Clock Signal
//
// Created by Thomas Harte on 27/08/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#ifndef ROM_hpp
#define ROM_hpp
namespace Storage {
namespace ROM {
class ROM {};
}
}
#endif /* ROM_hpp */