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;
41struct VFile;
42
43extern MGBA_EXPORT const int GBA_LUX_LEVELS[10];
44
45enum {
46 mPERIPH_GBA_LUMINANCE = 0x1000,
47 mPERIPH_GBA_BATTLECHIP_GATE,
48};
49
50bool GBAIsROM(struct VFile* vf);
51bool GBAIsMB(struct VFile* vf);
52bool GBAIsBIOS(struct VFile* vf);
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};
69
70void GBASIOJOYCreate(struct GBASIODriver* sio);
71int GBASIOJOYSendCommand(struct GBASIODriver* sio, enum GBASIOJOYCommand command, uint8_t* data);
72
73enum GBASIOBattleChipGateFlavor {
74 GBA_FLAVOR_BATTLECHIP_GATE = 4,
75 GBA_FLAVOR_PROGRESS_GATE = 5,
76 GBA_FLAVOR_BEAST_LINK_GATE = 6,
77 GBA_FLAVOR_BEAST_LINK_GATE_US = 7,
78};
79
80struct GBASIOBattlechipGate {
81 struct GBASIODriver d;
82 struct mTimingEvent event;
83 uint16_t chipId;
84 uint16_t data[2];
85 int state;
86 int flavor;
87};
88
89void GBASIOBattlechipGateCreate(struct GBASIOBattlechipGate*);
90
91void GBAEReaderQueueCard(struct GBA* gba, const void* data, size_t size);
92
93CXX_GUARD_END
94
95#endif