all repos — mgba @ 407335e2f464828d5fe517372442fce798b58490

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#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
 12#include "core/directories.h"
 13#endif
 14#ifndef MINIMAL_CORE
 15#include "core/input.h"
 16#endif
 17#include "core/config.h"
 18
 19struct VFile;
 20struct mRTCSource;
 21struct mCoreConfig;
 22
 23#ifdef COLOR_16_BIT
 24typedef uint16_t color_t;
 25#define BYTES_PER_PIXEL 2
 26#else
 27typedef uint32_t color_t;
 28#define BYTES_PER_PIXEL 4
 29#endif
 30
 31struct blip_t;
 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*);
 51
 52	void (*desiredVideoDimensions)(struct mCore*, unsigned* width, unsigned* height);
 53	void (*setVideoBuffer)(struct mCore*, color_t* buffer, size_t stride);
 54
 55	struct blip_t* (*getAudioChannel)(struct mCore*, int ch);
 56
 57	bool (*isROM)(struct VFile* vf);
 58	bool (*loadROM)(struct mCore*, struct VFile* vf);
 59	bool (*loadSave)(struct mCore*, struct VFile* vf);
 60	void (*unloadROM)(struct mCore*);
 61
 62	bool (*loadBIOS)(struct mCore*, struct VFile* vf, int biosID);
 63	bool (*selectBIOS)(struct mCore*, int biosID);
 64
 65	bool (*loadPatch)(struct mCore*, struct VFile* vf);
 66
 67	void (*reset)(struct mCore*);
 68	void (*runFrame)(struct mCore*);
 69	void (*runLoop)(struct mCore*);
 70	void (*step)(struct mCore*);
 71
 72	bool (*loadState)(struct mCore*, struct VFile*, int flags);
 73	bool (*saveState)(struct mCore*, struct VFile*, int flags);
 74
 75	void (*setKeys)(struct mCore*, uint32_t keys);
 76	void (*addKeys)(struct mCore*, uint32_t keys);
 77	void (*clearKeys)(struct mCore*, uint32_t keys);
 78
 79	int32_t (*frameCounter)(struct mCore*);
 80	int32_t (*frameCycles)(struct mCore*);
 81	int32_t (*frequency)(struct mCore*);
 82
 83	void (*setRTC)(struct mCore*, struct mRTCSource*);
 84};
 85
 86#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
 87bool mCoreLoadFile(struct mCore* core, const char* path);
 88
 89bool mCoreAutoloadSave(struct mCore* core);
 90bool mCoreAutoloadPatch(struct mCore* core);
 91
 92bool mCoreSaveState(struct mCore* core, int slot, int flags);
 93bool mCoreLoadState(struct mCore* core, int slot, int flags);
 94struct VFile* mCoreGetState(struct mCore* core, int slot, bool write);
 95void mCoreDeleteState(struct mCore* core, int slot);
 96#endif
 97
 98void mCoreInitConfig(struct mCore* core, const char* port);
 99void mCoreLoadConfig(struct mCore* core);
100
101#endif