VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
RomFile.h
1// -----------------------------------------------------------------------------
2// This file is part of VirtualC64
3//
4// Copyright (C) Dirk W. Hoffmann. www.dirkwhoffmann.de
5// This FILE is dual-licensed. You are free to choose between:
6//
7// - The GNU General Public License v3 (or any later version)
8// - The Mozilla Public License v2
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR MPL-2.0
11// -----------------------------------------------------------------------------
12
13#pragma once
14
15#include "AnyFile.h"
16#include "C64Types.h"
17#include "MemoryTypes.h"
18
19namespace vc64 {
20
21struct RomSignature { RomType type; isize size; isize offset; u8 magic[3]; };
22
23class RomFile : public AnyFile {
24
25private:
26
27 // Accepted header signatures
28 static const RomSignature signatures[];
29
30 // Rom type (Basic, Character, Kernal, or VC1541)
31 FileType romFileType = FILETYPE_UNKNOWN;
32
33public:
34
35 //
36 // Class methods
37 //
38
39 static bool isCompatible(const fs::path &name);
40 static bool isCompatible(std::istream &stream);
41
42 static bool isRomStream(RomType type, std::istream &stream);
43 static bool isBasicRomStream(std::istream &stream);
44 static bool isCharRomStream(std::istream &stream);
45 static bool isKernalRomStream(std::istream &stream);
46 static bool isVC1541RomStream(std::istream &stream);
47
48 static bool isRomFile(RomType type, const fs::path &path);
49 static bool isBasicRomFile(const fs::path &path);
50 static bool isCharRomFile(const fs::path &path);
51 static bool isKernalRomFile(const fs::path &path);
52 static bool isVC1541RomFile(const fs::path &path);
53
54 static bool isRomBuffer(RomType type, const u8 *buf, isize len);
55 static bool isBasicRomBuffer(const u8 *buf, isize len);
56 static bool isCharRomBuffer(const u8 *buf, isize len);
57 static bool isKernalRomBuffer(const u8 *buf, isize len);
58 static bool isVC1541RomBuffer(const u8 *buf, isize len);
59
60
61 //
62 // Initializing
63 //
64
65 RomFile(const fs::path &path) throws { init(path); }
66 RomFile(const fs::path &path, std::istream &stream) throws { init(path, stream); }
67 RomFile(const u8 *buf, isize len) throws { init(buf, len); }
68
69
70 //
71 // Methods from CoreObject
72 //
73
74 const char *objectName() const override { return "RomFile"; }
75
76
77 //
78 // Methods from AnyFile
79 //
80
81 bool isCompatiblePath(const fs::path &path) override { return isCompatible(path); }
82 bool isCompatibleStream(std::istream &stream) override { return isCompatible(stream); }
83 FileType type() const override { return romFileType; }
84 void finalizeRead() override;
85};
86
87}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16