VirtualC64 v5.0 beta
Commodore 64 Emulator
Loading...
Searching...
No Matches
CmdQueueTypes.h
Go to the documentation of this file.
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// -----------------------------------------------------------------------------
13
14#pragma once
15
16#include "JoystickTypes.h"
17#include "Reflection.h"
18#include "Option.h"
19
20namespace vc64 {
21
22//
23// Enumerations
24//
25
106typedef CMD_TYPE CmdType;
107
108struct CmdTypeEnum : util::Reflection<CmdType, CmdType> {
109
110 static constexpr long minVal = 0;
111 static constexpr long maxVal = CMD_FOCUS;
112 static bool isValid(auto value) { return value >= minVal && value <= maxVal; }
113
114 static const char *prefix() { return "CMD"; }
115 static const char *key(long value)
116 {
117 switch (value) {
118
119 case CMD_NONE: return "NONE";
120
121 case CMD_CONFIG: return "CONFIG";
122
123 case CMD_ALARM_ABS: return "ALARM_ABS";
124 case CMD_ALARM_REL: return "ALARM_REL";
125 case CMD_INSPECTION_TARGET: return "INSPECTION_TARGET";
126
127 case CMD_CPU_BRK: return "CPU_BRK";
128 case CMD_CPU_NMI: return "CPU_NMI";
129
130 case CMD_BP_SET_AT: return "BP_SET_AT";
131 case CMD_BP_REMOVE_NR: return "BP_REMOVE_NR";
132 case CMD_BP_REMOVE_AT: return "BP_REMOVE_AT";
133 case CMD_BP_REMOVE_ALL: return "BP_REMOVE_ALL";
134 case CMD_BP_ENABLE_NR: return "BP_ENABLE_NR";
135 case CMD_BP_ENABLE_AT: return "BP_ENABLE_AT";
136 case CMD_BP_ENABLE_ALL: return "BP_ENABLE_ALL";
137 case CMD_BP_DISABLE_NR: return "BP_DISABLE_NR";
138 case CMD_BP_DISABLE_AT: return "BP_DISABLE_AT";
139 case CMD_BP_DISABLE_ALL: return "BP_DISABLE_ALL";
140
141 case CMD_WP_SET_AT: return "WP_SET_AT";
142 case CMD_WP_REMOVE_NR: return "WP_REMOVE_NR";
143 case CMD_WP_REMOVE_AT: return "WP_REMOVE_AT";
144 case CMD_WP_REMOVE_ALL: return "WP_REMOVE_ALL";
145 case CMD_WP_ENABLE_NR: return "WP_ENABLE_NR";
146 case CMD_WP_ENABLE_AT: return "WP_ENABLE_AT";
147 case CMD_WP_ENABLE_ALL: return "WP_ENABLE_ALL";
148 case CMD_WP_DISABLE_NR: return "WP_DISABLE_NR";
149 case CMD_WP_DISABLE_AT: return "WP_DISABLE_AT";
150 case CMD_WP_DISABLE_ALL: return "WP_DISABLE_ALL";
151
152 case CMD_KEY_PRESS: return "KEY_PRESS";
153 case CMD_KEY_RELEASE: return "KEY_RELEASE";
154 case CMD_KEY_RELEASE_ALL: return "KEY_RELEASE_ALL";
155 case CMD_KEY_TOGGLE: return "KEY_TOGGLE";
156
157 case CMD_MOUSE_MOVE_ABS: return "MOUSE_MOVE_ABS";
158 case CMD_MOUSE_MOVE_REL: return "MOUSE_MOVE_REL";
159 case CMD_MOUSE_EVENT: return "MOUSE_EVENT";
160
161 case CMD_JOY_EVENT: return "JOY_EVENT";
162
163 case CMD_DSK_TOGGLE_WP: return "DSK_TOGGLE_WP";
164 case CMD_DSK_MODIFIED: return "DSK_MODIFIED";
165 case CMD_DSK_UNMODIFIED: return "DSK_UNMODIFIED";
166
167 case CMD_DATASETTE_PLAY: return "DATASETTE_PLAY";
168 case CMD_DATASETTE_STOP: return "DATASETTE_STOP";
169 case CMD_DATASETTE_REWIND: return "DATASETTE_REWIND";
170
171 case CMD_CRT_BUTTON_PRESS: return "CRT_BUTTON_PRESS";
172 case CMD_CRT_BUTTON_RELEASE: return "CRT_BUTTON_RELEASE";
173 case CMD_CRT_SWITCH_LEFT: return "CRT_SWITCH_LEFT";
174 case CMD_CRT_SWITCH_NEUTRAL: return "CRT_SWITCH_NEUTRAL";
175 case CMD_CRT_SWITCH_RIGHT: return "CRT_SWITCH_RIGHT";
176
177 case CMD_RSH_EXECUTE: return "RSH_EXECUTE";
178
179 case CMD_FOCUS: return "FOCUS";
180
181 }
182 return "???";
183 }
184};
185
186//
187// Structures
188//
189
190typedef struct
191{
192 Option option;
193 i64 value;
194 isize id;
195}
196ConfigCmd;
197
198typedef struct
199{
200 u8 keycode;
201 double delay;
202}
203KeyCmd;
204
205typedef struct
206{
207 isize port;
208 double x;
209 double y;
210}
211CoordCmd;
212
213typedef struct
214{
215 isize port;
216 GamePadAction action;
217}
218GamePadCmd;
219
220typedef struct
221{
222 void *tape;
223}
224TapeCmd;
225
226typedef struct
227{
228 i64 cycle;
229 i64 value;
230}
231AlarmCmd;
232
233typedef struct
234{
235 const char *command;
236}
237ShellCmd;
238
239struct Cmd
240{
241 // Header
242 CmdType type;
243
244 // Payload
245 union {
246
247 struct { i64 value; i64 value2; };
248 ConfigCmd config;
249 KeyCmd key;
250 CoordCmd coord;
251 GamePadCmd action;
252 TapeCmd tape;
253 AlarmCmd alarm;
254 ShellCmd shell;
255 };
256
257 Cmd() { }
258 Cmd(CmdType type, i64 v1 = 0, i64 v2 = 0) : type(type), value(v1), value2(v2) { }
259 Cmd(CmdType type, const KeyCmd &cmd) : type(type), key(cmd) { }
260 Cmd(CmdType type, const CoordCmd &cmd) : type(type), coord(cmd) { }
261 Cmd(CmdType type, const GamePadCmd &cmd) : type(type), action(cmd) { }
262 Cmd(CmdType type, const TapeCmd &cmd) : type(type), tape(cmd) { }
263 Cmd(CmdType type, const AlarmCmd &cmd) : type(type), alarm(cmd) { }
264 Cmd(CmdType type, const ShellCmd &cmd) : type(type), shell(cmd) { }
265 Cmd(CmdType type, const ConfigCmd &cmd) : type(type), config(cmd) { }
266};
267
268}
VirtualC64 project namespace.
Definition CmdQueue.cpp:16
CMD_TYPE
Emulator command.
Definition CmdQueueTypes.h:28
@ CMD_WP_SET_AT
Set a watchpoint.
Definition CmdQueueTypes.h:57
@ CMD_BP_ENABLE_AT
Enable the breakpoint at an address.
Definition CmdQueueTypes.h:50
@ CMD_BP_MOVE_TO
Change the address of breakpoint.
Definition CmdQueueTypes.h:45
@ CMD_BP_DISABLE_ALL
Disable all brekpoints.
Definition CmdQueueTypes.h:54
@ CMD_CRT_SWITCH_RIGHT
Pull the cartridge switch right.
Definition CmdQueueTypes.h:98
@ CMD_KEY_PRESS
Press a key on the C64 keyboard.
Definition CmdQueueTypes.h:70
@ CMD_MOUSE_EVENT
Signal a mouse button event.
Definition CmdQueueTypes.h:78
@ CMD_CPU_NMI
Emulate an external expansion port NMI.
Definition CmdQueueTypes.h:41
@ CMD_DATASETTE_STOP
Press the datasette stop key.
Definition CmdQueueTypes.h:90
@ CMD_DATASETTE_PLAY
Press the datasette play key.
Definition CmdQueueTypes.h:89
@ CMD_WP_ENABLE_ALL
Enable all watchpoints.
Definition CmdQueueTypes.h:64
@ CMD_FOCUS
The emulator windows got or lost focus.
Definition CmdQueueTypes.h:104
@ CMD_BP_SET_AT
Set a breakpoint.
Definition CmdQueueTypes.h:44
@ CMD_DSK_MODIFIED
Signal that the disk has been saved.
Definition CmdQueueTypes.h:85
@ CMD_BP_DISABLE_NR
Disable the n-th breakpoint.
Definition CmdQueueTypes.h:52
@ CMD_BP_REMOVE_AT
Remove the breakpoint at an address.
Definition CmdQueueTypes.h:47
@ CMD_WP_DISABLE_NR
Disable the n-th watchpoint.
Definition CmdQueueTypes.h:65
@ CMD_BP_DISABLE_AT
Disable the breakpoint at an address.
Definition CmdQueueTypes.h:53
@ CMD_WP_DISABLE_AT
Disable the watchpoint at an address.
Definition CmdQueueTypes.h:66
@ CMD_CRT_BUTTON_RELEASE
Release a cartridge button.
Definition CmdQueueTypes.h:95
@ CMD_BP_ENABLE_ALL
Enable all brekpoints.
Definition CmdQueueTypes.h:51
@ CMD_JOY_EVENT
Signal a joystick button event.
Definition CmdQueueTypes.h:81
@ CMD_DSK_UNMODIFIED
Signan that the disk needs saving.
Definition CmdQueueTypes.h:86
@ CMD_WP_REMOVE_ALL
Remove all watchpoints.
Definition CmdQueueTypes.h:61
@ CMD_WP_REMOVE_AT
Remove the watchpoint at an address.
Definition CmdQueueTypes.h:60
@ CMD_WP_ENABLE_AT
Enable the watchpoint at an address.
Definition CmdQueueTypes.h:63
@ CMD_BP_REMOVE_ALL
Remove all brekpoints.
Definition CmdQueueTypes.h:48
@ CMD_WP_MOVE_TO
Change the address of watchpoint.
Definition CmdQueueTypes.h:58
@ CMD_DSK_TOGGLE_WP
Toggle write-protection.
Definition CmdQueueTypes.h:84
@ CMD_WP_DISABLE_ALL
Disable all watchpoints.
Definition CmdQueueTypes.h:67
@ CMD_NONE
None.
Definition CmdQueueTypes.h:29
@ CMD_DATASETTE_REWIND
Rewind the tape.
Definition CmdQueueTypes.h:91
@ CMD_MOUSE_MOVE_REL
Signal a mouse movement (relative)
Definition CmdQueueTypes.h:77
@ CMD_MOUSE_MOVE_ABS
Signal a mouse movement (absolute)
Definition CmdQueueTypes.h:76
@ CMD_ALARM_ABS
Schedule an alarm (absolute cycle)
Definition CmdQueueTypes.h:35
@ CMD_BP_REMOVE_NR
Remove the n-th breakpoint.
Definition CmdQueueTypes.h:46
@ CMD_KEY_TOGGLE
Press or release a key on the C64 keyboard.
Definition CmdQueueTypes.h:73
@ CMD_INSPECTION_TARGET
Sets the auto-inspection component.
Definition CmdQueueTypes.h:37
@ CMD_ALARM_REL
Schedule an alarm (relative cycle)
Definition CmdQueueTypes.h:36
@ CMD_CPU_BRK
Let the CPU execute a BRK instruction.
Definition CmdQueueTypes.h:40
@ CMD_KEY_RELEASE_ALL
Clear the keyboard matrix.
Definition CmdQueueTypes.h:72
@ CMD_WP_ENABLE_NR
Enable the n-th watchpoint.
Definition CmdQueueTypes.h:62
@ CMD_WP_REMOVE_NR
Remove the n-th watchpoint.
Definition CmdQueueTypes.h:59
@ CMD_BP_ENABLE_NR
Enable the n-th breakpoint.
Definition CmdQueueTypes.h:49
@ CMD_CRT_SWITCH_NEUTRAL
Put the cartridge switch in neutral position.
Definition CmdQueueTypes.h:97
@ CMD_CRT_BUTTON_PRESS
Press a cartridge button.
Definition CmdQueueTypes.h:94
@ CMD_CRT_SWITCH_LEFT
Pull the cartridge switch left.
Definition CmdQueueTypes.h:96
@ CMD_KEY_RELEASE
Release a key on the C64 keyboard.
Definition CmdQueueTypes.h:71
@ CMD_RSH_EXECUTE
Execute a script command.
Definition CmdQueueTypes.h:101
@ CMD_CONFIG
Configure the emulator.
Definition CmdQueueTypes.h:32