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
37enum GBAVideoLayer {
38 GBA_LAYER_BG0 = 0,
39 GBA_LAYER_BG1,
40 GBA_LAYER_BG2,
41 GBA_LAYER_BG3,
42 GBA_LAYER_OBJ,
43 GBA_LAYER_WIN0,
44 GBA_LAYER_WIN1,
45 GBA_LAYER_OBJWIN,
46};
47
48struct GBA;
49struct GBAAudio;
50struct GBASIO;
51struct GBAVideoRenderer;
52struct VFile;
53
54extern MGBA_EXPORT const int GBA_LUX_LEVELS[10];
55
56enum {
57 mPERIPH_GBA_LUMINANCE = 0x1000,
58 mPERIPH_GBA_BATTLECHIP_GATE,
59};
60
61bool GBAIsROM(struct VFile* vf);
62bool GBAIsMB(struct VFile* vf);
63bool GBAIsBIOS(struct VFile* vf);
64
65struct GBALuminanceSource {
66 void (*sample)(struct GBALuminanceSource*);
67
68 uint8_t (*readLuminance)(struct GBALuminanceSource*);
69};
70
71struct GBASIODriver {
72 struct GBASIO* p;
73
74 bool (*init)(struct GBASIODriver* driver);
75 void (*deinit)(struct GBASIODriver* driver);
76 bool (*load)(struct GBASIODriver* driver);
77 bool (*unload)(struct GBASIODriver* driver);
78 uint16_t (*writeRegister)(struct GBASIODriver* driver, uint32_t address, uint16_t value);
79};
80
81void GBASIOJOYCreate(struct GBASIODriver* sio);
82
83enum GBASIOBattleChipGateFlavor {
84 GBA_FLAVOR_BATTLECHIP_GATE = 4,
85 GBA_FLAVOR_PROGRESS_GATE = 5,
86 GBA_FLAVOR_BEAST_LINK_GATE = 6,
87 GBA_FLAVOR_BEAST_LINK_GATE_US = 7,
88};
89
90struct GBASIOBattlechipGate {
91 struct GBASIODriver d;
92 struct mTimingEvent event;
93 uint16_t chipId;
94 uint16_t data[2];
95 int state;
96 int flavor;
97};
98
99void GBASIOBattlechipGateCreate(struct GBASIOBattlechipGate*);
100
101void GBAEReaderQueueCard(struct GBA* gba, const void* data, size_t size);
102
103CXX_GUARD_END
104
105#endif