all repos — mgba @ d86440e04f1dbfdcb954eeaae25ceee78ab26b65

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