all repos — mgba @ 1e6f812003d145725ce65c72feba612dd11dce66

mGBA Game Boy Advance Emulator

src/core/core.h (view raw)

 1/* Copyright (c) 2013-2016 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 M_CORE_H
 7#define M_CORE_H
 8
 9#include "util/common.h"
10
11#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
12#include "core/directories.h"
13#endif
14
15struct VFile;
16struct mRTCSource;
17
18#ifdef COLOR_16_BIT
19typedef uint16_t color_t;
20#define BYTES_PER_PIXEL 2
21#else
22typedef uint32_t color_t;
23#define BYTES_PER_PIXEL 4
24#endif
25
26struct mCoreSync;
27struct mCore {
28	void* cpu;
29	void* board;
30
31#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
32	struct mDirectorySet dirs;
33#endif
34
35	bool (*init)(struct mCore*);
36	void (*deinit)(struct mCore*);
37
38	void (*setSync)(struct mCore*, struct mCoreSync*);
39
40	void (*desiredVideoDimensions)(struct mCore*, unsigned* width, unsigned* height);
41	void (*setVideoBuffer)(struct mCore*, color_t* buffer, size_t stride);
42
43	bool (*isROM)(struct VFile* vf);
44	bool (*loadROM)(struct mCore*, struct VFile* vf);
45	bool (*loadSave)(struct mCore*, struct VFile* vf);
46	void (*unloadROM)(struct mCore*);
47
48	bool (*loadBIOS)(struct mCore*, struct VFile* vf, int biosID);
49	bool (*selectBIOS)(struct mCore*, int biosID);
50
51	void (*reset)(struct mCore*);
52	void (*runFrame)(struct mCore*);
53	void (*runLoop)(struct mCore*);
54	void (*step)(struct mCore*);
55
56	void (*setKeys)(struct mCore*, uint32_t keys);
57	void (*addKeys)(struct mCore*, uint32_t keys);
58	void (*clearKeys)(struct mCore*, uint32_t keys);
59
60	int32_t (*frameCounter)(struct mCore*);
61	int32_t (*frameCycles)(struct mCore*);
62	int32_t (*frequency)(struct mCore*);
63
64	void (*setRTC)(struct mCore*, struct mRTCSource*);
65};
66
67bool mCoreLoadFile(struct mCore* core, const char* path);
68bool mCoreAutoloadSave(struct mCore* core);
69
70#endif