VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
GeoRam.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 "Cartridge.h"
16
17namespace vc64 {
18
19class GeoRAM final : public Cartridge {
20
21 CartridgeTraits traits = {
22
23 .type = CRT_GEO_RAM,
24 .title = "GeoRam",
25 .memory = 0, // Set in constructor
26 .battery = true
27 };
28
29 virtual const CartridgeTraits &getCartridgeTraits() const override { return traits; }
30
31private:
32
33 // Selected RAM bank
34 u8 bank = 0;
35
36 // Selected page inside the selected RAM bank
37 u8 page = 0;
38
39
40 //
41 // Initializing
42 //
43
44public:
45
46 GeoRAM(C64 &ref) : Cartridge(ref) { };
47 GeoRAM(C64 &ref, isize kb);
48
49
50 //
51 // Methods from CoreObject
52 //
53
54private:
55
56 void _dump(Category category, std::ostream& os) const override;
57
58
59 //
60 // Methods from CoreComponent
61 //
62
63public:
64
65 GeoRAM& operator= (const GeoRAM& other) {
66
67 Cartridge::operator=(other);
68
69 CLONE(bank)
70 CLONE(page)
71
72 return *this;
73 }
74 virtual void clone(const Cartridge &other) override { *this = (const GeoRAM &)other; }
75
76 template <class T>
77 void serialize(T& worker)
78 {
79 if (isResetter(worker)) return;
80
81 worker
82
83 << bank
84 << page;
85
86 } CARTRIDGE_SERIALIZERS(serialize);
87
88
89 //
90 // Accessing cartridge memory
91 //
92
93public:
94
95 u8 peekIO1(u16 addr) override;
96 u8 spypeekIO1(u16 addr) const override;
97 u8 peekIO2(u16 addr) override;
98 u8 spypeekIO2(u16 addr) const override;
99 void pokeIO1(u16 addr, u8 value) override;
100 void pokeIO2(u16 addr, u8 value) override;
101
102private:
103
104 // Maps an address to the proper position in cartridge RAM
105 isize offset(u8 addr) const;
106};
107
108}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16