all repos — mgba @ ef68c84e76bfd95b454bcbc3eec4d6946d23a282

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