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
11#include "core/interface.h"
12
13enum GBALogLevel {
14 GBA_LOG_FATAL = 0x01,
15 GBA_LOG_ERROR = 0x02,
16 GBA_LOG_WARN = 0x04,
17 GBA_LOG_INFO = 0x08,
18 GBA_LOG_DEBUG = 0x10,
19 GBA_LOG_STUB = 0x20,
20
21 GBA_LOG_GAME_ERROR = 0x100,
22 GBA_LOG_SWI = 0x200,
23 GBA_LOG_STATUS = 0x400,
24 GBA_LOG_SIO = 0x800,
25
26 GBA_LOG_ALL = 0xF3F,
27};
28
29enum GBASIOMode {
30 SIO_NORMAL_8 = 0,
31 SIO_NORMAL_32 = 1,
32 SIO_MULTI = 2,
33 SIO_UART = 3,
34 SIO_GPIO = 8,
35 SIO_JOYBUS = 12
36};
37
38struct GBA;
39struct GBAAudio;
40struct GBASIO;
41struct GBAThread;
42struct GBAVideoRenderer;
43
44typedef void (*GBALogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args);
45
46struct GBAAVStream {
47 void (*postVideoFrame)(struct GBAAVStream*, struct GBAVideoRenderer* renderer);
48 void (*postAudioFrame)(struct GBAAVStream*, int16_t left, int16_t right);
49 void (*postAudioBuffer)(struct GBAAVStream*, struct GBAAudio*);
50};
51
52extern const int GBA_LUX_LEVELS[10];
53
54struct GBALuminanceSource {
55 void (*sample)(struct GBALuminanceSource*);
56
57 uint8_t (*readLuminance)(struct GBALuminanceSource*);
58};
59
60struct GBASIODriver {
61 struct GBASIO* p;
62
63 bool (*init)(struct GBASIODriver* driver);
64 void (*deinit)(struct GBASIODriver* driver);
65 bool (*load)(struct GBASIODriver* driver);
66 bool (*unload)(struct GBASIODriver* driver);
67 uint16_t (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value);
68 int32_t (*processEvents)(struct GBASIODriver* driver, int32_t cycles);
69};
70
71#endif