all repos — mgba @ 0a06f4dad025ed321de45acfb16d7a67c3b83a87

mGBA Game Boy Advance Emulator

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