all repos — mgba @ 36b3f07ed18afe430689933beb31c052e49b52bb

mGBA Game Boy Advance Emulator

src/ds/extra/cli.c (view raw)

 1/* Copyright (c) 2013-2015 Jeffrey Pfau
 2 *
 3 * This Source Code Form is subject to the terms of the Mozilla Public
 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 6#include "cli.h"
 7
 8#include "arm/debugger/cli-debugger.h"
 9
10#ifdef USE_CLI_DEBUGGER
11
12static void _DSCLIDebuggerInit(struct CLIDebuggerSystem*);
13static bool _DSCLIDebuggerCustom(struct CLIDebuggerSystem*);
14static uint32_t _DSCLIDebuggerLookupIdentifier(struct CLIDebuggerSystem*, const char* name, struct CLIDebugVector* dv);
15
16static void _frame(struct CLIDebugger*, struct CLIDebugVector*);
17
18struct CLIDebuggerCommandSummary _DSCLIDebuggerCommands[] = {
19	{ "frame", _frame, 0, "Frame advance" },
20	{ 0, 0, 0, 0 }
21};
22
23struct DSCLIDebugger* DSCLIDebuggerCreate(struct mCore* core) {
24	struct DSCLIDebugger* debugger = malloc(sizeof(struct DSCLIDebugger));
25	ARMCLIDebuggerCreate(&debugger->d);
26	debugger->d.init = _DSCLIDebuggerInit;
27	debugger->d.deinit = NULL;
28	debugger->d.custom = _DSCLIDebuggerCustom;
29	debugger->d.lookupIdentifier = _DSCLIDebuggerLookupIdentifier;
30
31	debugger->d.name = "DS";
32	debugger->d.commands = _DSCLIDebuggerCommands;
33
34	debugger->core = core;
35
36	return debugger;
37}
38
39static void _DSCLIDebuggerInit(struct CLIDebuggerSystem* debugger) {
40	struct DSCLIDebugger* dsDebugger = (struct DSCLIDebugger*) debugger;
41
42	dsDebugger->frameAdvance = false;
43}
44
45static bool _DSCLIDebuggerCustom(struct CLIDebuggerSystem* debugger) {
46	return false;
47}
48
49static uint32_t _DSCLIDebuggerLookupIdentifier(struct CLIDebuggerSystem* debugger, const char* name, struct CLIDebugVector* dv) {
50	UNUSED(debugger);
51	dv->type = CLIDV_ERROR_TYPE;
52	return 0;
53}
54
55static void _frame(struct CLIDebugger* debugger, struct CLIDebugVector* dv) {
56	UNUSED(dv);
57	debugger->d.state = DEBUGGER_CUSTOM;
58
59	struct DSCLIDebugger* dsDebugger = (struct DSCLIDebugger*) debugger->system;
60	dsDebugger->frameAdvance = true;
61}
62#endif