all repos — mgba @ 5bcf56c5caccea4021abc92b461a0873978546f5

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#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	enum mPlatform (*platform)(struct mCore*);
 50
 51	void (*setSync)(struct mCore*, struct mCoreSync*);
 52	void (*loadConfig)(struct mCore*, const struct mCoreConfig*);
 53
 54	void (*desiredVideoDimensions)(struct mCore*, unsigned* width, unsigned* height);
 55	void (*setVideoBuffer)(struct mCore*, color_t* buffer, size_t stride);
 56	void (*getVideoBuffer)(struct mCore*, color_t** buffer, size_t* stride);
 57
 58	struct blip_t* (*getAudioChannel)(struct mCore*, int ch);
 59	void (*setAudioBufferSize)(struct mCore*, size_t samples);
 60	size_t (*getAudioBufferSize)(struct mCore*);
 61
 62	void (*setAVStream)(struct mCore*, struct mAVStream*);
 63
 64	bool (*isROM)(struct VFile* vf);
 65	bool (*loadROM)(struct mCore*, struct VFile* vf);
 66	bool (*loadSave)(struct mCore*, struct VFile* vf);
 67	void (*unloadROM)(struct mCore*);
 68
 69	bool (*loadBIOS)(struct mCore*, struct VFile* vf, int biosID);
 70	bool (*selectBIOS)(struct mCore*, int biosID);
 71
 72	bool (*loadPatch)(struct mCore*, struct VFile* vf);
 73
 74	void (*reset)(struct mCore*);
 75	void (*runFrame)(struct mCore*);
 76	void (*runLoop)(struct mCore*);
 77	void (*step)(struct mCore*);
 78
 79	bool (*loadState)(struct mCore*, struct VFile*, int flags);
 80	bool (*saveState)(struct mCore*, struct VFile*, int flags);
 81
 82	void (*setKeys)(struct mCore*, uint32_t keys);
 83	void (*addKeys)(struct mCore*, uint32_t keys);
 84	void (*clearKeys)(struct mCore*, uint32_t keys);
 85
 86	int32_t (*frameCounter)(struct mCore*);
 87	int32_t (*frameCycles)(struct mCore*);
 88	int32_t (*frequency)(struct mCore*);
 89
 90	void (*getGameTitle)(struct mCore*, char* title);
 91
 92	void (*setRTC)(struct mCore*, struct mRTCSource*);
 93};
 94
 95#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
 96struct mCore* mCoreFind(const char* path);
 97bool mCoreLoadFile(struct mCore* core, const char* path);
 98
 99bool mCoreAutoloadSave(struct mCore* core);
100bool mCoreAutoloadPatch(struct mCore* core);
101
102bool mCoreSaveState(struct mCore* core, int slot, int flags);
103bool mCoreLoadState(struct mCore* core, int slot, int flags);
104struct VFile* mCoreGetState(struct mCore* core, int slot, bool write);
105void mCoreDeleteState(struct mCore* core, int slot);
106
107void mCoreTakeScreenshot(struct mCore* core);
108#endif
109
110void mCoreInitConfig(struct mCore* core, const char* port);
111void mCoreLoadConfig(struct mCore* core);
112void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config);
113
114#endif