VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
ActionReplay.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
17//
18// Action Replay (hardware version 3)
19//
20
21namespace vc64 {
22
23class ActionReplay3 final : public Cartridge {
24
25 CartridgeTraits traits = {
26
27 .type = CRT_ACTION_REPLAY3,
28 .title = "Action Replay 3",
29
30 .buttons = 2,
31 .button1 = "Freeze",
32 .button2 = "Reset"
33 };
34
35 virtual const CartridgeTraits &getCartridgeTraits() const override { return traits; }
36
37public:
38
39 using Cartridge::Cartridge;
40 CartridgeType getCartridgeType() const override { return CRT_ACTION_REPLAY3; }
41
42
43 //
44 // Accessing cartridge data
45 //
46
47 u8 peek(u16 addr) override;
48 u8 peekIO1(u16 addr) override { return 0; }
49 u8 spypeekIO1(u16 addr) const override { return 0; }
50 u8 peekIO2(u16 addr) override;
51 u8 spypeekIO2(u16 addr) const override;
52 void pokeIO1(u16 addr, u8 value) override;
53
54 // Sets the control register and triggers side effects
55 void setControlReg(u8 value);
56
57 isize bank() const { return control & 0x01; }
58 bool game() const { return !!(control & 0x02); }
59 bool exrom() const { return !(control & 0x08); }
60 bool disabled() const { return !!(control & 0x04); }
61
62
63 //
64 // Handling buttons
65 //
66
67 isize numButtons() const override { return 2; }
68 const char *getButtonTitle(isize nr) const override;
69 void pressButton(isize nr) override;
70 void releaseButton(isize nr) override;
71};
72
73
74//
75// Action Replay (hardware version 4 and above)
76//
77
78class ActionReplay : public Cartridge {
79
80 CartridgeTraits traits = {
81
82 .type = CRT_ACTION_REPLAY,
83 .title = "Action Replay",
84 .memory = KB(8),
85 .buttons = 2,
86 .button1 = "Freeze",
87 .button2 = "Reset"
88 };
89
90 virtual const CartridgeTraits &getCartridgeTraits() const override { return traits; }
91
92public:
93
94 using Cartridge::Cartridge;
95 void operator << (SerResetter &worker) override;
96 void resetCartConfig() override;
97
98
99 //
100 // Accessing cartridge data
101 //
102
103 u8 peek(u16 addr) override;
104 u8 peekIO1(u16 addr) override;
105 u8 spypeekIO1(u16 addr) const override;
106 u8 peekIO2(u16 addr) override;
107 u8 spypeekIO2(u16 addr) const override;
108
109 void poke(u16 addr, u8 value) override;
110 void pokeIO1(u16 addr, u8 value) override;
111 void pokeIO2(u16 addr, u8 value) override;
112
113 // Sets the control register and triggers side effects
114 void setControlReg(u8 value);
115
116 virtual isize bank() const { return (control >> 3) & 0x03; }
117 virtual bool game() const { return (control & 0x01) == 0; }
118 virtual bool exrom() const { return (control & 0x02) != 0; }
119 virtual bool disabled() const { return (control & 0x04) != 0; }
120 virtual bool resetFreezeMode() const { return (control & 0x40) != 0; }
121
122 // Returns true if the cartridge RAM shows up at the provided address
123 virtual bool ramIsEnabled(u16 addr) const;
124
125
126 //
127 // Handling buttons
128 //
129
130 isize numButtons() const override { return 2; }
131 const char *getButtonTitle(isize nr) const override;
132 void pressButton(isize nr) override;
133 void releaseButton(isize nr) override;
134};
135
136
137//
138// Atomic Power (a derivation of the Action Replay cartridge)
139//
140
141class AtomicPower final : public ActionReplay {
142
143 CartridgeTraits traits = {
144
145 .type = CRT_ATOMIC_POWER,
146 .title = "Atomic Power",
147 .memory = KB(8),
148 .buttons = 2,
149 .button1 = "Freeze",
150 .button2 = "Reset"
151 };
152
153 virtual const CartridgeTraits &getCartridgeTraits() const override { return traits; }
154
155public:
156
157 using ActionReplay::ActionReplay;
158 CartridgeType getCartridgeType() const override { return CRT_ATOMIC_POWER; }
159
160 /* Indicates if special ROM / RAM config has to be used. In contrast to
161 * the Action Replay cartridge, Atomic Power has the ability to map the
162 * on-board RAM to the ROMH area at $A000 - $BFFF. To enable this special
163 * configuration, the control register has to be configured as follows:
164 *
165 * Bit 0b10000000 (Extra ROM) is 0.
166 * Bit 0b01000000 (Freeze clear) is 0.
167 * Bit 0b00100000 (RAM enable) is 1.
168 * Bit 0b00000100 (Disable) is 0.
169 * Bit 0b00000010 (Exrom) is 1.
170 * Bit 0b00000001 (Game) is 0.
171 */
172 bool specialMapping() const { return (control & 0b11100111) == 0b00100010; }
173
174 bool game() const override;
175 bool exrom() const override;
176 bool ramIsEnabled(u16 addr) const override;
177};
178
179}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16