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