VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
CartridgeRom.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 "SubComponent.h"
16
17namespace vc64 {
18
19class CartridgeRom final : public SubComponent {
20
21 Descriptions descriptions = {{
22
23 .name = "CartridgeRom",
24 .description = "Cartridge ROM"
25 }};
26
27 friend class Cartridge;
28
29protected:
30
31 // Rom data
32 u8 *rom = nullptr;
33
34public:
35
36 // Size of the Rom data in bytes
37 u16 size = 0;
38
39 /* Load address. This value is taken from the .CRT file. Possible values
40 * are $8000 for chips mapping into the ROML area, $A000 for chips mapping
41 * into the ROMH area in 16KB game mode, and $E000 for chips mapping into
42 * the ROMH area in ultimax mode.
43 */
44 u16 loadAddress = 0;
45
46
47 //
48 // Initializing
49 //
50
51public:
52
53 CartridgeRom(C64 &ref);
54 CartridgeRom(C64 &ref, u16 _size, u16 _loadAddress, const u8 *buffer = nullptr);
55 ~CartridgeRom();
56
57
58 //
59 // Methods from Serializable
60 //
61
62public:
63
64 template <class T>
65 void serialize(T& worker)
66 {
67 if (isResetter(worker)) return;
68
69 worker
70
71 << size
72 << loadAddress;
73 }
74
75 void operator << (SerChecker &worker) override { serialize(worker); }
76 void operator << (SerCounter &worker) override;
77 void operator << (SerResetter &worker) override { serialize(worker); }
78 void operator << (SerReader &worker) override;
79 void operator << (SerWriter &worker) override;
80
81
82 //
83 // Methods from CoreComponent
84 //
85
86public:
87
88 const Descriptions &getDescriptions() const override { return descriptions; }
89
90
91 //
92 // Accessing
93 //
94
95public:
96
97 // Returns true if this Rom chip maps to ROML
98 bool mapsToL() const;
99
100 // Returns true if this Rom chip maps to ROMH
101 bool mapsToH() const;
102
103 // Returns true if this Rom chip maps to both ROML and ROMH
104 bool mapsToLH() const;
105
106 // Reads or writes a byte
107 u8 peek(u16 addr);
108 u8 spypeek(u16 addr) const;
109 void poke(u16 addr, u8 value) { }
110};
111
112}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16