all repos — mgba @ 819062a9a587785547a25c73f1169ee33bc522e1

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#include "debugger/debugger.h"
 20
 21enum mPlatform {
 22	PLATFORM_NONE = -1,
 23#ifdef M_CORE_GBA
 24	PLATFORM_GBA,
 25#endif
 26#ifdef M_CORE_GB
 27	PLATFORM_GB,
 28#endif
 29};
 30
 31struct mRTCSource;
 32struct mCoreConfig;
 33struct mCoreSync;
 34struct mStateExtdata;
 35struct mCore {
 36	void* cpu;
 37	void* board;
 38	struct mDebugger* debugger;
 39
 40#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
 41	struct mDirectorySet dirs;
 42#endif
 43#ifndef MINIMAL_CORE
 44	struct mInputMap inputMap;
 45#endif
 46	struct mCoreConfig config;
 47	struct mCoreOptions opts;
 48
 49	bool (*init)(struct mCore*);
 50	void (*deinit)(struct mCore*);
 51
 52	enum mPlatform (*platform)(struct mCore*);
 53
 54	void (*setSync)(struct mCore*, struct mCoreSync*);
 55	void (*loadConfig)(struct mCore*, const struct mCoreConfig*);
 56
 57	void (*desiredVideoDimensions)(struct mCore*, unsigned* width, unsigned* height);
 58	void (*setVideoBuffer)(struct mCore*, color_t* buffer, size_t stride);
 59	void (*getVideoBuffer)(struct mCore*, color_t** buffer, size_t* stride);
 60
 61	struct blip_t* (*getAudioChannel)(struct mCore*, int ch);
 62	void (*setAudioBufferSize)(struct mCore*, size_t samples);
 63	size_t (*getAudioBufferSize)(struct mCore*);
 64
 65	void (*setAVStream)(struct mCore*, struct mAVStream*);
 66
 67	bool (*isROM)(struct VFile* vf);
 68	bool (*loadROM)(struct mCore*, struct VFile* vf);
 69	bool (*loadSave)(struct mCore*, struct VFile* vf);
 70	bool (*loadTemporarySave)(struct mCore*, struct VFile* vf);
 71	void (*unloadROM)(struct mCore*);
 72
 73	bool (*loadBIOS)(struct mCore*, struct VFile* vf, int biosID);
 74	bool (*selectBIOS)(struct mCore*, int biosID);
 75
 76	bool (*loadPatch)(struct mCore*, struct VFile* vf);
 77
 78	void (*reset)(struct mCore*);
 79	void (*runFrame)(struct mCore*);
 80	void (*runLoop)(struct mCore*);
 81	void (*step)(struct mCore*);
 82
 83	size_t (*stateSize)(struct mCore*);
 84	bool (*loadState)(struct mCore*, const void* state);
 85	bool (*saveState)(struct mCore*, void* state);
 86
 87	void (*setKeys)(struct mCore*, uint32_t keys);
 88	void (*addKeys)(struct mCore*, uint32_t keys);
 89	void (*clearKeys)(struct mCore*, uint32_t keys);
 90
 91	int32_t (*frameCounter)(struct mCore*);
 92	int32_t (*frameCycles)(struct mCore*);
 93	int32_t (*frequency)(struct mCore*);
 94
 95	void (*getGameTitle)(struct mCore*, char* title);
 96	void (*getGameCode)(struct mCore*, char* title);
 97
 98	void (*setRTC)(struct mCore*, struct mRTCSource*);
 99	void (*setRotation)(struct mCore*, struct mRotationSource*);
100	void (*setRumble)(struct mCore*, struct mRumble*);
101
102	uint32_t (*busRead8)(struct mCore*, uint32_t address);
103	uint32_t (*busRead16)(struct mCore*, uint32_t address);
104	uint32_t (*busRead32)(struct mCore*, uint32_t address);
105
106	void (*busWrite8)(struct mCore*, uint32_t address, uint8_t);
107	void (*busWrite16)(struct mCore*, uint32_t address, uint16_t);
108	void (*busWrite32)(struct mCore*, uint32_t address, uint32_t);
109
110	uint32_t (*rawRead8)(struct mCore*, uint32_t address);
111	uint32_t (*rawRead16)(struct mCore*, uint32_t address);
112	uint32_t (*rawRead32)(struct mCore*, uint32_t address);
113
114	void (*rawWrite8)(struct mCore*, uint32_t address, uint8_t);
115	void (*rawWrite16)(struct mCore*, uint32_t address, uint16_t);
116	void (*rawWrite32)(struct mCore*, uint32_t address, uint32_t);
117
118	bool (*supportsDebuggerType)(struct mCore*, enum mDebuggerType);
119	struct mDebuggerPlatform* (*debuggerPlatform)(struct mCore*);
120	struct CLIDebuggerSystem* (*cliDebuggerSystem)(struct mCore*);
121	void (*attachDebugger)(struct mCore*, struct mDebugger*);
122	void (*detachDebugger)(struct mCore*);
123
124	struct mCheatDevice* (*cheatDevice)(struct mCore*);
125
126	size_t (*savedataClone)(struct mCore*, void** sram);
127	bool (*savedataLoad)(struct mCore*, const void* sram, size_t size);
128};
129
130#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
131struct mCore* mCoreFind(const char* path);
132bool mCoreLoadFile(struct mCore* core, const char* path);
133
134bool mCoreAutoloadSave(struct mCore* core);
135bool mCoreAutoloadPatch(struct mCore* core);
136
137bool mCoreSaveState(struct mCore* core, int slot, int flags);
138bool mCoreLoadState(struct mCore* core, int slot, int flags);
139struct VFile* mCoreGetState(struct mCore* core, int slot, bool write);
140void mCoreDeleteState(struct mCore* core, int slot);
141
142void mCoreTakeScreenshot(struct mCore* core);
143#endif
144
145void mCoreInitConfig(struct mCore* core, const char* port);
146void mCoreLoadConfig(struct mCore* core);
147void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config);
148
149#endif