src/gba/gui/gui-runner.h (view raw)
1/* Copyright (c) 2013-2016 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#ifndef GUI_RUNNER_H
7#define GUI_RUNNER_H
8
9#include "gba/context/context.h"
10#include "gba/gui/remap.h"
11#include "util/circle-buffer.h"
12#include "util/gui.h"
13
14enum GBAGUIInput {
15 GBA_GUI_INPUT_INCREASE_BRIGHTNESS = GUI_INPUT_USER_START,
16 GBA_GUI_INPUT_DECREASE_BRIGHTNESS,
17 GBA_GUI_INPUT_SCREEN_MODE,
18};
19
20struct GBAGUIBackground {
21 struct GUIBackground d;
22 struct GBAGUIRunner* p;
23
24 uint32_t* screenshot;
25 int screenshotId;
26};
27
28struct GBAGUIRunnerLux {
29 struct GBALuminanceSource d;
30 int luxLevel;
31};
32
33struct GBAGUIRunner {
34 struct GBAContext context;
35 struct GUIParams params;
36
37 struct GBAGUIBackground background;
38 struct GBAGUIRunnerLux luminanceSource;
39
40 struct GUIMenuItem* configExtra;
41 size_t nConfigExtra;
42
43 struct GUIInputKeys* keySources;
44
45 float fps;
46 int64_t lastFpsCheck;
47 int32_t totalDelta;
48 struct CircleBuffer fpsBuffer;
49
50 void (*setup)(struct GBAGUIRunner*);
51 void (*teardown)(struct GBAGUIRunner*);
52 void (*gameLoaded)(struct GBAGUIRunner*);
53 void (*gameUnloaded)(struct GBAGUIRunner*);
54 void (*prepareForFrame)(struct GBAGUIRunner*);
55 void (*drawFrame)(struct GBAGUIRunner*, bool faded);
56 void (*drawScreenshot)(struct GBAGUIRunner*, const uint32_t* pixels, bool faded);
57 void (*paused)(struct GBAGUIRunner*);
58 void (*unpaused)(struct GBAGUIRunner*);
59 void (*incrementScreenMode)(struct GBAGUIRunner*);
60 uint16_t (*pollGameInput)(struct GBAGUIRunner*);
61};
62
63void GBAGUIInit(struct GBAGUIRunner*, const char* port);
64void GBAGUIDeinit(struct GBAGUIRunner*);
65void GBAGUIRun(struct GBAGUIRunner*, const char* path);
66void GBAGUIRunloop(struct GBAGUIRunner*);
67
68#endif