all repos — mgba @ be3e884ba51609b058b0da46c7e8bded3d2a7376

mGBA Game Boy Advance Emulator

include/mgba/core/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 CORE_INTERFACE_H
 7#define CORE_INTERFACE_H
 8
 9#include <mgba-util/common.h>
10
11CXX_GUARD_START
12
13struct mCore;
14
15#ifdef COLOR_16_BIT
16typedef uint16_t color_t;
17#define BYTES_PER_PIXEL 2
18#else
19typedef uint32_t color_t;
20#define BYTES_PER_PIXEL 4
21#endif
22
23#define M_R5(X) ((X) & 0x1F)
24#define M_G5(X) (((X) >> 5) & 0x1F)
25#define M_B5(X) (((X) >> 10) & 0x1F)
26
27#define M_R8(X) (((((X) << 3) & 0xF8) * 0x21) >> 5)
28#define M_G8(X) (((((X) >> 2) & 0xF8) * 0x21) >> 5)
29#define M_B8(X) (((((X) >> 7) & 0xF8) * 0x21) >> 5)
30
31struct blip_t;
32
33struct mCoreCallbacks {
34	void* context;
35	void (*videoFrameStarted)(void* context);
36	void (*videoFrameEnded)(void* context);
37	void (*coreCrashed)(void* context);
38};
39
40struct mAVStream {
41	void (*videoDimensionsChanged)(struct mAVStream*, unsigned width, unsigned height);
42	void (*postVideoFrame)(struct mAVStream*, const color_t* buffer, size_t stride);
43	void (*postAudioFrame)(struct mAVStream*, int16_t left, int16_t right);
44	void (*postAudioBuffer)(struct mAVStream*, struct blip_t* left, struct blip_t* right);
45};
46
47struct mKeyCallback {
48	uint16_t (*readKeys)(struct mKeyCallback*);
49};
50
51struct mStopCallback {
52	void (*stop)(struct mStopCallback*);
53};
54
55struct mRotationSource {
56	void (*sample)(struct mRotationSource*);
57
58	int32_t (*readTiltX)(struct mRotationSource*);
59	int32_t (*readTiltY)(struct mRotationSource*);
60
61	int32_t (*readGyroZ)(struct mRotationSource*);
62};
63
64struct mRTCSource {
65	void (*sample)(struct mRTCSource*);
66
67	time_t (*unixTime)(struct mRTCSource*);
68};
69
70enum mRTCGenericType {
71	RTC_NO_OVERRIDE,
72	RTC_FIXED,
73	RTC_FAKE_EPOCH
74};
75
76struct mRTCGenericSource {
77	struct mRTCSource d;
78	struct mCore* p;
79	enum mRTCGenericType override;
80	int64_t value;
81};
82
83void mRTCGenericSourceInit(struct mRTCGenericSource* rtc, struct mCore* core);
84
85struct mRumble {
86	void (*setRumble)(struct mRumble*, int enable);
87};
88
89CXX_GUARD_END
90
91#endif