all repos — mgba @ ce085623de93a4baf202a01a11cadadc347b71ba

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