all repos — mgba @ 36553b89d0cb70174da4d386565892c288a0e6f6

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