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#include "core/config.h"
12#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
13#include "core/directories.h"
14#endif
15#ifndef MINIMAL_CORE
16#include "core/input.h"
17#endif
18#include "core/interface.h"
19
20enum mPlatform {
21 PLATFORM_NONE = -1,
22#ifdef M_CORE_GBA
23 PLATFORM_GBA,
24#endif
25#ifdef M_CORE_GB
26 PLATFORM_GB,
27#endif
28};
29
30struct mRTCSource;
31struct mCoreConfig;
32struct mCoreSync;
33struct mCore {
34 void* cpu;
35 void* board;
36
37#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
38 struct mDirectorySet dirs;
39#endif
40#ifndef MINIMAL_CORE
41 struct mInputMap inputMap;
42#endif
43 struct mCoreConfig config;
44 struct mCoreOptions opts;
45
46 bool (*init)(struct mCore*);
47 void (*deinit)(struct mCore*);
48
49 void (*setSync)(struct mCore*, struct mCoreSync*);
50 void (*loadConfig)(struct mCore*, const struct mCoreConfig*);
51
52 void (*desiredVideoDimensions)(struct mCore*, unsigned* width, unsigned* height);
53 void (*setVideoBuffer)(struct mCore*, color_t* buffer, size_t stride);
54 void (*getVideoBuffer)(struct mCore*, color_t** buffer, size_t* stride);
55
56 struct blip_t* (*getAudioChannel)(struct mCore*, int ch);
57
58 void (*setAVStream)(struct mCore*, struct mAVStream*);
59
60 bool (*isROM)(struct VFile* vf);
61 bool (*loadROM)(struct mCore*, struct VFile* vf);
62 bool (*loadSave)(struct mCore*, struct VFile* vf);
63 void (*unloadROM)(struct mCore*);
64
65 bool (*loadBIOS)(struct mCore*, struct VFile* vf, int biosID);
66 bool (*selectBIOS)(struct mCore*, int biosID);
67
68 bool (*loadPatch)(struct mCore*, struct VFile* vf);
69
70 void (*reset)(struct mCore*);
71 void (*runFrame)(struct mCore*);
72 void (*runLoop)(struct mCore*);
73 void (*step)(struct mCore*);
74
75 bool (*loadState)(struct mCore*, struct VFile*, int flags);
76 bool (*saveState)(struct mCore*, struct VFile*, int flags);
77
78 void (*setKeys)(struct mCore*, uint32_t keys);
79 void (*addKeys)(struct mCore*, uint32_t keys);
80 void (*clearKeys)(struct mCore*, uint32_t keys);
81
82 int32_t (*frameCounter)(struct mCore*);
83 int32_t (*frameCycles)(struct mCore*);
84 int32_t (*frequency)(struct mCore*);
85
86 void (*getGameTitle)(struct mCore*, char* title);
87
88 void (*setRTC)(struct mCore*, struct mRTCSource*);
89};
90
91#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
92struct mCore* mCoreFind(const char* path);
93bool mCoreLoadFile(struct mCore* core, const char* path);
94
95bool mCoreAutoloadSave(struct mCore* core);
96bool mCoreAutoloadPatch(struct mCore* core);
97
98bool mCoreSaveState(struct mCore* core, int slot, int flags);
99bool mCoreLoadState(struct mCore* core, int slot, int flags);
100struct VFile* mCoreGetState(struct mCore* core, int slot, bool write);
101void mCoreDeleteState(struct mCore* core, int slot);
102
103void mCoreTakeScreenshot(struct mCore* core);
104#endif
105
106void mCoreInitConfig(struct mCore* core, const char* port);
107void mCoreLoadConfig(struct mCore* core);
108void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config);
109
110#endif