src/gba/interface.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 INTERFACE_H
7#define INTERFACE_H
8
9#include "util/common.h"
10
11enum GBALogLevel {
12 GBA_LOG_FATAL = 0x01,
13 GBA_LOG_ERROR = 0x02,
14 GBA_LOG_WARN = 0x04,
15 GBA_LOG_INFO = 0x08,
16 GBA_LOG_DEBUG = 0x10,
17 GBA_LOG_STUB = 0x20,
18
19 GBA_LOG_GAME_ERROR = 0x100,
20 GBA_LOG_SWI = 0x200,
21 GBA_LOG_STATUS = 0x400,
22 GBA_LOG_SIO = 0x800,
23
24 GBA_LOG_ALL = 0xF3F,
25};
26
27enum GBAKey {
28 GBA_KEY_A = 0,
29 GBA_KEY_B = 1,
30 GBA_KEY_SELECT = 2,
31 GBA_KEY_START = 3,
32 GBA_KEY_RIGHT = 4,
33 GBA_KEY_LEFT = 5,
34 GBA_KEY_UP = 6,
35 GBA_KEY_DOWN = 7,
36 GBA_KEY_R = 8,
37 GBA_KEY_L = 9,
38 GBA_KEY_MAX,
39 GBA_KEY_NONE = -1
40};
41
42enum GBASIOMode {
43 SIO_NORMAL_8 = 0,
44 SIO_NORMAL_32 = 1,
45 SIO_MULTI = 2,
46 SIO_UART = 3,
47 SIO_GPIO = 8,
48 SIO_JOYBUS = 12
49};
50
51struct GBA;
52struct GBAAudio;
53struct GBASIO;
54struct GBAThread;
55struct GBAVideoRenderer;
56
57typedef void (*GBALogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args);
58
59struct GBAAVStream {
60 void (*postVideoFrame)(struct GBAAVStream*, struct GBAVideoRenderer* renderer);
61 void (*postAudioFrame)(struct GBAAVStream*, int16_t left, int16_t right);
62 void (*postAudioBuffer)(struct GBAAVStream*, struct GBAAudio*);
63};
64
65struct GBAKeyCallback {
66 uint16_t (*readKeys)(struct GBAKeyCallback*);
67};
68
69struct GBARotationSource {
70 void (*sample)(struct GBARotationSource*);
71
72 int32_t (*readTiltX)(struct GBARotationSource*);
73 int32_t (*readTiltY)(struct GBARotationSource*);
74
75 int32_t (*readGyroZ)(struct GBARotationSource*);
76};
77
78struct GBALuminanceSource {
79 void (*sample)(struct GBALuminanceSource*);
80
81 uint8_t (*readLuminance)(struct GBALuminanceSource*);
82};
83
84struct GBARTCSource {
85 void (*sample)(struct GBARTCSource*);
86
87 time_t (*unixTime)(struct GBARTCSource*);
88};
89
90struct GBASIODriver {
91 struct GBASIO* p;
92
93 bool (*init)(struct GBASIODriver* driver);
94 void (*deinit)(struct GBASIODriver* driver);
95 bool (*load)(struct GBASIODriver* driver);
96 bool (*unload)(struct GBASIODriver* driver);
97 uint16_t (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value);
98 int32_t (*processEvents)(struct GBASIODriver* driver, int32_t cycles);
99};
100
101#endif