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