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
63enum GBASIOBattleChipGateFlavor {
64 GBA_FLAVOR_BATTLECHIP_GATE = 4,
65 GBA_FLAVOR_PROGRESS_GATE = 5,
66 GBA_FLAVOR_BEAST_LINK_GATE = 6,
67 GBA_FLAVOR_BEAST_LINK_GATE_US = 7,
68};
69
70struct GBASIOBattlechipGate {
71 struct GBASIODriver d;
72 struct mTimingEvent event;
73 uint16_t chipId;
74 uint16_t data[2];
75 int state;
76 int flavor;
77};
78
79void GBASIOBattlechipGateCreate(struct GBASIOBattlechipGate*);
80
81CXX_GUARD_END
82
83#endif