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 GBAStopCallback {
70 void (*stop)(struct GBAStopCallback*);
71};
72
73struct GBARotationSource {
74 void (*sample)(struct GBARotationSource*);
75
76 int32_t (*readTiltX)(struct GBARotationSource*);
77 int32_t (*readTiltY)(struct GBARotationSource*);
78
79 int32_t (*readGyroZ)(struct GBARotationSource*);
80};
81
82extern const int GBA_LUX_LEVELS[10];
83
84struct GBALuminanceSource {
85 void (*sample)(struct GBALuminanceSource*);
86
87 uint8_t (*readLuminance)(struct GBALuminanceSource*);
88};
89
90struct GBARTCSource {
91 void (*sample)(struct GBARTCSource*);
92
93 time_t (*unixTime)(struct GBARTCSource*);
94};
95
96struct GBASIODriver {
97 struct GBASIO* p;
98
99 bool (*init)(struct GBASIODriver* driver);
100 void (*deinit)(struct GBASIODriver* driver);
101 bool (*load)(struct GBASIODriver* driver);
102 bool (*unload)(struct GBASIODriver* driver);
103 uint16_t (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value);
104 int32_t (*processEvents)(struct GBASIODriver* driver, int32_t cycles);
105};
106
107#endif