include/mgba/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 GBA_INTERFACE_H
7#define GBA_INTERFACE_H
8
9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13#include <mgba/core/interface.h>
14#include <mgba/core/timing.h>
15
16enum GBASIOMode {
17 SIO_NORMAL_8 = 0,
18 SIO_NORMAL_32 = 1,
19 SIO_MULTI = 2,
20 SIO_UART = 3,
21 SIO_GPIO = 8,
22 SIO_JOYBUS = 12
23};
24
25enum GBASIOJOYCommand {
26 JOY_RESET = 0xFF,
27 JOY_POLL = 0x00,
28 JOY_TRANS = 0x14,
29 JOY_RECV = 0x15
30};
31
32struct GBA;
33struct GBAAudio;
34struct GBASIO;
35struct GBAVideoRenderer;
36
37extern const int GBA_LUX_LEVELS[10];
38
39enum {
40 mPERIPH_GBA_LUMINANCE = 0x1000,
41 mPERIPH_GBA_BATTLECHIP_GATE,
42};
43
44struct GBALuminanceSource {
45 void (*sample)(struct GBALuminanceSource*);
46
47 uint8_t (*readLuminance)(struct GBALuminanceSource*);
48};
49
50struct GBASIODriver {
51 struct GBASIO* p;
52
53 bool (*init)(struct GBASIODriver* driver);
54 void (*deinit)(struct GBASIODriver* driver);
55 bool (*load)(struct GBASIODriver* driver);
56 bool (*unload)(struct GBASIODriver* driver);
57 uint16_t (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value);
58};
59
60void GBASIOJOYCreate(struct GBASIODriver* sio);
61int GBASIOJOYSendCommand(struct GBASIODriver* sio, enum GBASIOJOYCommand command, uint8_t* data);
62
63struct GBASIOBattlechipGate {
64 struct GBASIODriver d;
65 struct mTimingEvent event;
66 uint16_t chipId;
67 uint16_t data[2];
68 int state;
69};
70
71void GBASIOBattlechipGateCreate(struct GBASIOBattlechipGate*);
72
73CXX_GUARD_END
74
75#endif