all repos — mgba @ 9f5adf2dccff8e3a7a6703911fcc1a03bce4f616

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