all repos — mgba @ a27cb6c040a0515d004456c20a0842ec2bcbf652

mGBA Game Boy Advance Emulator

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