all repos — mgba @ 79e0a0da49c24c166792285baea795edd232a4f5

mGBA Game Boy Advance Emulator

src/gba/core.c (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#include <mgba/gba/core.h>
  7
  8#include <mgba/core/core.h>
  9#include <mgba/core/log.h>
 10#include <mgba/internal/arm/debugger/debugger.h>
 11#include <mgba/internal/gba/cheats.h>
 12#include <mgba/internal/gba/gba.h>
 13#include <mgba/internal/gba/extra/cli.h>
 14#include <mgba/internal/gba/overrides.h>
 15#ifndef DISABLE_THREADING
 16#include <mgba/internal/gba/renderers/thread-proxy.h>
 17#endif
 18#include <mgba/internal/gba/renderers/video-software.h>
 19#include <mgba/internal/gba/savedata.h>
 20#include <mgba/internal/gba/serialize.h>
 21#include <mgba-util/memory.h>
 22#include <mgba-util/patch.h>
 23#include <mgba-util/vfs.h>
 24
 25#ifndef MINIMAL_CORE
 26#include <mgba/internal/gba/input.h>
 27#endif
 28
 29struct GBACore {
 30	struct mCore d;
 31	struct GBAVideoSoftwareRenderer renderer;
 32#ifndef DISABLE_THREADING
 33	struct GBAVideoThreadProxyRenderer threadProxy;
 34	int threadedVideo;
 35#endif
 36	int keys;
 37	struct mCPUComponent* components[CPU_COMPONENT_MAX];
 38	const struct Configuration* overrides;
 39	struct mDebuggerPlatform* debuggerPlatform;
 40	struct mCheatDevice* cheatDevice;
 41};
 42
 43static bool _GBACoreInit(struct mCore* core) {
 44	struct GBACore* gbacore = (struct GBACore*) core;
 45
 46	struct ARMCore* cpu = anonymousMemoryMap(sizeof(struct ARMCore));
 47	struct GBA* gba = anonymousMemoryMap(sizeof(struct GBA));
 48	if (!cpu || !gba) {
 49		free(cpu);
 50		free(gba);
 51		return false;
 52	}
 53	core->cpu = cpu;
 54	core->board = gba;
 55	core->debugger = NULL;
 56	gbacore->overrides = NULL;
 57	gbacore->debuggerPlatform = NULL;
 58	gbacore->cheatDevice = NULL;
 59
 60	GBACreate(gba);
 61	// TODO: Restore cheats
 62	memset(gbacore->components, 0, sizeof(gbacore->components));
 63	ARMSetComponents(cpu, &gba->d, CPU_COMPONENT_MAX, gbacore->components);
 64	ARMInit(cpu);
 65
 66	GBAVideoSoftwareRendererCreate(&gbacore->renderer);
 67	gbacore->renderer.outputBuffer = NULL;
 68
 69#ifndef DISABLE_THREADING
 70	gbacore->threadedVideo = false;
 71	GBAVideoThreadProxyRendererCreate(&gbacore->threadProxy, &gbacore->renderer.d);
 72#endif
 73
 74	gbacore->keys = 0;
 75	gba->keySource = &gbacore->keys;
 76
 77#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
 78	mDirectorySetInit(&core->dirs);
 79#endif
 80
 81#ifndef MINIMAL_CORE
 82	core->inputInfo = &GBAInputInfo;
 83#endif
 84	
 85	return true;
 86}
 87
 88static void _GBACoreDeinit(struct mCore* core) {
 89	ARMDeinit(core->cpu);
 90	GBADestroy(core->board);
 91	mappedMemoryFree(core->cpu, sizeof(struct ARMCore));
 92	mappedMemoryFree(core->board, sizeof(struct GBA));
 93#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
 94	mDirectorySetDeinit(&core->dirs);
 95#endif
 96
 97	struct GBACore* gbacore = (struct GBACore*) core;
 98	free(gbacore->debuggerPlatform);
 99	if (gbacore->cheatDevice) {
100		mCheatDeviceDestroy(gbacore->cheatDevice);
101	}
102	free(gbacore->cheatDevice);
103	mCoreConfigFreeOpts(&core->opts);
104	free(core);
105}
106
107static enum mPlatform _GBACorePlatform(const struct mCore* core) {
108	UNUSED(core);
109	return PLATFORM_GBA;
110}
111
112static void _GBACoreSetSync(struct mCore* core, struct mCoreSync* sync) {
113	struct GBA* gba = core->board;
114	gba->sync = sync;
115}
116
117static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) {
118	struct GBA* gba = core->board;
119	if (core->opts.mute) {
120		gba->audio.masterVolume = 0;
121	} else {
122		gba->audio.masterVolume = core->opts.volume;
123	}
124	gba->video.frameskip = core->opts.frameskip;
125
126#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
127	struct GBACore* gbacore = (struct GBACore*) core;
128	gbacore->overrides = mCoreConfigGetOverridesConst(config);
129#endif
130
131	const char* idleOptimization = mCoreConfigGetValue(config, "idleOptimization");
132	if (idleOptimization) {
133		if (strcasecmp(idleOptimization, "ignore") == 0) {
134			gba->idleOptimization = IDLE_LOOP_IGNORE;
135		} else if (strcasecmp(idleOptimization, "remove") == 0) {
136			gba->idleOptimization = IDLE_LOOP_REMOVE;
137		} else if (strcasecmp(idleOptimization, "detect") == 0) {
138			if (gba->idleLoop == IDLE_LOOP_NONE) {
139				gba->idleOptimization = IDLE_LOOP_DETECT;
140			} else {
141				gba->idleOptimization = IDLE_LOOP_REMOVE;
142			}
143		}
144	}
145
146	mCoreConfigCopyValue(&core->config, config, "gba.bios");
147
148#ifndef DISABLE_THREADING
149	mCoreConfigGetIntValue(config, "threadedVideo", &gbacore->threadedVideo);
150#endif
151}
152
153static void _GBACoreDesiredVideoDimensions(struct mCore* core, unsigned* width, unsigned* height) {
154	UNUSED(core);
155	*width = VIDEO_HORIZONTAL_PIXELS;
156	*height = VIDEO_VERTICAL_PIXELS;
157}
158
159static void _GBACoreSetVideoBuffer(struct mCore* core, color_t* buffer, size_t stride) {
160	struct GBACore* gbacore = (struct GBACore*) core;
161	gbacore->renderer.outputBuffer = buffer;
162	gbacore->renderer.outputBufferStride = stride;
163}
164
165static void _GBACoreGetPixels(struct mCore* core, const void** buffer, size_t* stride) {
166	struct GBACore* gbacore = (struct GBACore*) core;
167	gbacore->renderer.d.getPixels(&gbacore->renderer.d, stride, buffer);
168}
169
170static void _GBACorePutPixels(struct mCore* core, const void* buffer, size_t stride) {
171	struct GBACore* gbacore = (struct GBACore*) core;
172	gbacore->renderer.d.putPixels(&gbacore->renderer.d, stride, buffer);
173}
174
175static struct blip_t* _GBACoreGetAudioChannel(struct mCore* core, int ch) {
176	struct GBA* gba = core->board;
177	switch (ch) {
178	case 0:
179		return gba->audio.psg.left;
180	case 1:
181		return gba->audio.psg.right;
182	default:
183		return NULL;
184	}
185}
186
187static void _GBACoreSetAudioBufferSize(struct mCore* core, size_t samples) {
188	struct GBA* gba = core->board;
189	GBAAudioResizeBuffer(&gba->audio, samples);
190}
191
192static size_t _GBACoreGetAudioBufferSize(struct mCore* core) {
193	struct GBA* gba = core->board;
194	return gba->audio.samples;
195}
196
197static void _GBACoreSetCoreCallbacks(struct mCore* core, struct mCoreCallbacks* coreCallbacks) {
198	struct GBA* gba = core->board;
199	gba->coreCallbacks = coreCallbacks;
200}
201
202static void _GBACoreSetAVStream(struct mCore* core, struct mAVStream* stream) {
203	struct GBA* gba = core->board;
204	gba->stream = stream;
205	if (stream && stream->videoDimensionsChanged) {
206		stream->videoDimensionsChanged(stream, VIDEO_HORIZONTAL_PIXELS, VIDEO_VERTICAL_PIXELS);
207	}
208}
209
210static bool _GBACoreLoadROM(struct mCore* core, struct VFile* vf) {
211	if (GBAIsMB(vf)) {
212		return GBALoadMB(core->board, vf);
213	}
214	return GBALoadROM(core->board, vf);
215}
216
217static bool _GBACoreLoadBIOS(struct mCore* core, struct VFile* vf, int type) {
218	UNUSED(type);
219	if (!GBAIsBIOS(vf)) {
220		return false;
221	}
222	GBALoadBIOS(core->board, vf);
223	return true;
224}
225
226static bool _GBACoreLoadSave(struct mCore* core, struct VFile* vf) {
227	return GBALoadSave(core->board, vf);
228}
229
230static bool _GBACoreLoadTemporarySave(struct mCore* core, struct VFile* vf) {
231	struct GBA* gba = core->board;
232	GBASavedataMask(&gba->memory.savedata, vf, false);
233	return true; // TODO: Return a real value
234}
235
236static bool _GBACoreLoadPatch(struct mCore* core, struct VFile* vf) {
237	if (!vf) {
238		return false;
239	}
240	struct Patch patch;
241	if (!loadPatch(vf, &patch)) {
242		return false;
243	}
244	GBAApplyPatch(core->board, &patch);
245	return true;
246}
247
248static void _GBACoreUnloadROM(struct mCore* core) {
249	struct GBACore* gbacore = (struct GBACore*) core;
250	struct ARMCore* cpu = core->cpu;
251	if (gbacore->cheatDevice) {
252		ARMHotplugDetach(cpu, CPU_COMPONENT_CHEAT_DEVICE);
253		cpu->components[CPU_COMPONENT_CHEAT_DEVICE] = NULL;
254		mCheatDeviceDestroy(gbacore->cheatDevice);
255		gbacore->cheatDevice = NULL;
256	}
257	return GBAUnloadROM(core->board);
258}
259
260static void _GBACoreChecksum(const struct mCore* core, void* data, enum mCoreChecksumType type) {
261	struct GBA* gba = (struct GBA*) core->board;
262	switch (type) {
263	case CHECKSUM_CRC32:
264		memcpy(data, &gba->romCrc32, sizeof(gba->romCrc32));
265		break;
266	}
267	return;
268}
269
270static void _GBACoreReset(struct mCore* core) {
271	struct GBACore* gbacore = (struct GBACore*) core;
272	struct GBA* gba = (struct GBA*) core->board;
273	if (gbacore->renderer.outputBuffer) {
274		struct GBAVideoRenderer* renderer = &gbacore->renderer.d;
275#ifndef DISABLE_THREADING
276		if (gbacore->threadedVideo) {
277			renderer = &gbacore->threadProxy.d;
278		}
279#endif
280		GBAVideoAssociateRenderer(&gba->video, renderer);
281	}
282
283	struct GBACartridgeOverride override;
284	const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom;
285	if (cart) {
286		memcpy(override.id, &cart->id, sizeof(override.id));
287		if (GBAOverrideFind(gbacore->overrides, &override)) {
288			GBAOverrideApply(gba, &override);
289		}
290	}
291
292#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
293	if (!gba->biosVf && core->opts.useBios) {
294		struct VFile* bios = NULL;
295		bool found = false;
296		if (core->opts.bios) {
297			bios = VFileOpen(core->opts.bios, O_RDONLY);
298			if (bios && GBAIsBIOS(bios)) {
299				found = true;
300			} else if (bios) {
301				bios->close(bios);
302				bios = NULL;
303			}
304		}
305		if (!found) {
306			const char* configPath = mCoreConfigGetValue(&core->config, "gba.bios");
307			bios = VFileOpen(configPath, O_RDONLY);
308			if (bios && GBAIsBIOS(bios)) {
309				found = true;
310			} else if (bios) {
311				bios->close(bios);
312				bios = NULL;
313			}
314		}
315		if (!found) {
316			char path[PATH_MAX];
317			mCoreConfigDirectory(path, PATH_MAX);
318			strncat(path, PATH_SEP "gba_bios.bin", PATH_MAX - strlen(path));
319			bios = VFileOpen(path, O_RDONLY);
320			if (bios && GBIsBIOS(bios)) {
321				found = true;
322			} else if (bios) {
323				bios->close(bios);
324				bios = NULL;
325			}
326		}
327		if (bios) {
328			GBALoadBIOS(gba, bios);
329		}
330	}
331#endif
332
333	ARMReset(core->cpu);
334	if (core->opts.skipBios && gba->pristineRom) {
335		GBASkipBIOS(core->board);
336	}
337}
338
339static void _GBACoreRunFrame(struct mCore* core) {
340	struct GBA* gba = core->board;
341	int32_t frameCounter = gba->video.frameCounter;
342	while (gba->video.frameCounter == frameCounter) {
343		ARMv4RunLoop(core->cpu);
344	}
345}
346
347static void _GBACoreRunLoop(struct mCore* core) {
348	ARMv4RunLoop(core->cpu);
349}
350
351static void _GBACoreStep(struct mCore* core) {
352	ARMv4Run(core->cpu);
353}
354
355static size_t _GBACoreStateSize(struct mCore* core) {
356	UNUSED(core);
357	return sizeof(struct GBASerializedState);
358}
359
360static bool _GBACoreLoadState(struct mCore* core, const void* state) {
361	return GBADeserialize(core->board, state);
362}
363
364static bool _GBACoreSaveState(struct mCore* core, void* state) {
365	GBASerialize(core->board, state);
366	return true;
367}
368
369static void _GBACoreSetKeys(struct mCore* core, uint32_t keys) {
370	struct GBACore* gbacore = (struct GBACore*) core;
371	gbacore->keys = keys;
372}
373
374static void _GBACoreAddKeys(struct mCore* core, uint32_t keys) {
375	struct GBACore* gbacore = (struct GBACore*) core;
376	gbacore->keys |= keys;
377}
378
379static void _GBACoreClearKeys(struct mCore* core, uint32_t keys) {
380	struct GBACore* gbacore = (struct GBACore*) core;
381	gbacore->keys &= ~keys;
382}
383
384static void _GBACoreSetCursorLocation(struct mCore* core, int x, int y) {
385	UNUSED(core);
386	UNUSED(x);
387	UNUSED(y);
388}
389
390static void _GBACoreSetCursorDown(struct mCore* core, int x, int y, bool down) {
391	UNUSED(core);
392	UNUSED(down);
393}
394
395static int32_t _GBACoreFrameCounter(const struct mCore* core) {
396	const struct GBA* gba = core->board;
397	return gba->video.frameCounter;
398}
399
400static int32_t _GBACoreFrameCycles(const struct mCore* core) {
401	UNUSED(core);
402	return VIDEO_TOTAL_LENGTH;
403}
404
405static int32_t _GBACoreFrequency(const struct mCore* core) {
406	UNUSED(core);
407	return GBA_ARM7TDMI_FREQUENCY;
408}
409
410static void _GBACoreGetGameTitle(const struct mCore* core, char* title) {
411	GBAGetGameTitle(core->board, title);
412}
413
414static void _GBACoreGetGameCode(const struct mCore* core, char* title) {
415	GBAGetGameCode(core->board, title);
416}
417
418static void _GBACoreSetRTC(struct mCore* core, struct mRTCSource* rtc) {
419	struct GBA* gba = core->board;
420	gba->rtcSource = rtc;
421}
422
423static void _GBACoreSetRotation(struct mCore* core, struct mRotationSource* rotation) {
424	struct GBA* gba = core->board;
425	gba->rotationSource = rotation;
426}
427
428static void _GBACoreSetRumble(struct mCore* core, struct mRumble* rumble) {
429	struct GBA* gba = core->board;
430	gba->rumble = rumble;
431}
432
433static uint32_t _GBACoreBusRead8(struct mCore* core, uint32_t address) {
434	struct ARMCore* cpu = core->cpu;
435	return cpu->memory.load8(cpu, address, 0);
436}
437
438static uint32_t _GBACoreBusRead16(struct mCore* core, uint32_t address) {
439	struct ARMCore* cpu = core->cpu;
440	return cpu->memory.load16(cpu, address, 0);
441
442}
443
444static uint32_t _GBACoreBusRead32(struct mCore* core, uint32_t address) {
445	struct ARMCore* cpu = core->cpu;
446	return cpu->memory.load32(cpu, address, 0);
447}
448
449static void _GBACoreBusWrite8(struct mCore* core, uint32_t address, uint8_t value) {
450	struct ARMCore* cpu = core->cpu;
451	cpu->memory.store8(cpu, address, value, 0);
452}
453
454static void _GBACoreBusWrite16(struct mCore* core, uint32_t address, uint16_t value) {
455	struct ARMCore* cpu = core->cpu;
456	cpu->memory.store16(cpu, address, value, 0);
457}
458
459static void _GBACoreBusWrite32(struct mCore* core, uint32_t address, uint32_t value) {
460	struct ARMCore* cpu = core->cpu;
461	cpu->memory.store32(cpu, address, value, 0);
462}
463
464static uint32_t _GBACoreRawRead8(struct mCore* core, uint32_t address, int segment) {
465	UNUSED(segment);
466	struct ARMCore* cpu = core->cpu;
467	return GBAView8(cpu, address);
468}
469
470static uint32_t _GBACoreRawRead16(struct mCore* core, uint32_t address, int segment) {
471	UNUSED(segment);
472	struct ARMCore* cpu = core->cpu;
473	return GBAView16(cpu, address);
474}
475
476static uint32_t _GBACoreRawRead32(struct mCore* core, uint32_t address, int segment) {
477	UNUSED(segment);
478	struct ARMCore* cpu = core->cpu;
479	return GBAView32(cpu, address);
480}
481
482static void _GBACoreRawWrite8(struct mCore* core, uint32_t address, int segment, uint8_t value) {
483	UNUSED(segment);
484	struct ARMCore* cpu = core->cpu;
485	GBAPatch8(cpu, address, value, NULL);
486}
487
488static void _GBACoreRawWrite16(struct mCore* core, uint32_t address, int segment, uint16_t value) {
489	UNUSED(segment);
490	struct ARMCore* cpu = core->cpu;
491	GBAPatch16(cpu, address, value, NULL);
492}
493
494static void _GBACoreRawWrite32(struct mCore* core, uint32_t address, int segment, uint32_t value) {
495	UNUSED(segment);
496	struct ARMCore* cpu = core->cpu;
497	GBAPatch32(cpu, address, value, NULL);
498}
499
500#ifdef USE_DEBUGGERS
501static bool _GBACoreSupportsDebuggerType(struct mCore* core, enum mDebuggerType type) {
502	UNUSED(core);
503	switch (type) {
504	case DEBUGGER_CLI:
505		return true;
506#ifdef USE_GDB_STUB
507	case DEBUGGER_GDB:
508		return true;
509#endif
510	default:
511		return false;
512	}
513}
514
515static struct mDebuggerPlatform* _GBACoreDebuggerPlatform(struct mCore* core) {
516	struct GBACore* gbacore = (struct GBACore*) core;
517	if (!gbacore->debuggerPlatform) {
518		gbacore->debuggerPlatform = ARMDebuggerPlatformCreate();
519	}
520	return gbacore->debuggerPlatform;
521}
522
523static struct CLIDebuggerSystem* _GBACoreCliDebuggerSystem(struct mCore* core) {
524	return &GBACLIDebuggerCreate(core)->d;
525}
526
527static void _GBACoreAttachDebugger(struct mCore* core, struct mDebugger* debugger) {
528	if (core->debugger) {
529		GBADetachDebugger(core->board);
530	}
531	GBAAttachDebugger(core->board, debugger);
532	core->debugger = debugger;
533}
534
535static void _GBACoreDetachDebugger(struct mCore* core) {
536	GBADetachDebugger(core->board);
537	core->debugger = NULL;
538}
539#endif
540
541static struct mCheatDevice* _GBACoreCheatDevice(struct mCore* core) {
542	struct GBACore* gbacore = (struct GBACore*) core;
543	if (!gbacore->cheatDevice) {
544		gbacore->cheatDevice = GBACheatDeviceCreate();
545		((struct ARMCore*) core->cpu)->components[CPU_COMPONENT_CHEAT_DEVICE] = &gbacore->cheatDevice->d;
546		ARMHotplugAttach(core->cpu, CPU_COMPONENT_CHEAT_DEVICE);
547		gbacore->cheatDevice->p = core;
548	}
549	return gbacore->cheatDevice;
550}
551
552static size_t _GBACoreSavedataClone(struct mCore* core, void** sram) {
553	struct GBA* gba = core->board;
554	size_t size = GBASavedataSize(&gba->memory.savedata);
555	if (!size) {
556		*sram = NULL;
557		return 0;
558	}
559	*sram = malloc(size);
560	struct VFile* vf = VFileFromMemory(*sram, size);
561	if (!vf) {
562		free(*sram);
563		*sram = NULL;
564		return 0;
565	}
566	bool success = GBASavedataClone(&gba->memory.savedata, vf);
567	vf->close(vf);
568	if (!success) {
569		free(*sram);
570		*sram = NULL;
571		return 0;
572	}
573	return size;
574}
575
576static bool _GBACoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {
577	struct VFile* vf = VFileMemChunk(sram, size);
578	if (!vf) {
579		return false;
580	}
581	struct GBA* gba = core->board;
582	bool success = true;
583	if (writeback) {
584		success = GBASavedataLoad(&gba->memory.savedata, vf);
585		vf->close(vf);
586	} else {
587		GBASavedataMask(&gba->memory.savedata, vf, true);
588	}
589	return success;
590}
591
592struct mCore* GBACoreCreate(void) {
593	struct GBACore* gbacore = malloc(sizeof(*gbacore));
594	struct mCore* core = &gbacore->d;
595	memset(&core->opts, 0, sizeof(core->opts));
596	core->cpu = NULL;
597	core->board = NULL;
598	core->debugger = NULL;
599	core->init = _GBACoreInit;
600	core->deinit = _GBACoreDeinit;
601	core->platform = _GBACorePlatform;
602	core->setSync = _GBACoreSetSync;
603	core->loadConfig = _GBACoreLoadConfig;
604	core->desiredVideoDimensions = _GBACoreDesiredVideoDimensions;
605	core->setVideoBuffer = _GBACoreSetVideoBuffer;
606	core->getPixels = _GBACoreGetPixels;
607	core->putPixels = _GBACorePutPixels;
608	core->getAudioChannel = _GBACoreGetAudioChannel;
609	core->setAudioBufferSize = _GBACoreSetAudioBufferSize;
610	core->getAudioBufferSize = _GBACoreGetAudioBufferSize;
611	core->setCoreCallbacks = _GBACoreSetCoreCallbacks;
612	core->setAVStream = _GBACoreSetAVStream;
613	core->isROM = GBAIsROM;
614	core->loadROM = _GBACoreLoadROM;
615	core->loadBIOS = _GBACoreLoadBIOS;
616	core->loadSave = _GBACoreLoadSave;
617	core->loadTemporarySave = _GBACoreLoadTemporarySave;
618	core->loadPatch = _GBACoreLoadPatch;
619	core->unloadROM = _GBACoreUnloadROM;
620	core->checksum = _GBACoreChecksum;
621	core->reset = _GBACoreReset;
622	core->runFrame = _GBACoreRunFrame;
623	core->runLoop = _GBACoreRunLoop;
624	core->step = _GBACoreStep;
625	core->stateSize = _GBACoreStateSize;
626	core->loadState = _GBACoreLoadState;
627	core->saveState = _GBACoreSaveState;
628	core->setKeys = _GBACoreSetKeys;
629	core->addKeys = _GBACoreAddKeys;
630	core->clearKeys = _GBACoreClearKeys;
631	core->setCursorLocation = _GBACoreSetCursorLocation;
632	core->setCursorDown = _GBACoreSetCursorDown;
633	core->frameCounter = _GBACoreFrameCounter;
634	core->frameCycles = _GBACoreFrameCycles;
635	core->frequency = _GBACoreFrequency;
636	core->getGameTitle = _GBACoreGetGameTitle;
637	core->getGameCode = _GBACoreGetGameCode;
638	core->setRTC = _GBACoreSetRTC;
639	core->setRotation = _GBACoreSetRotation;
640	core->setRumble = _GBACoreSetRumble;
641	core->busRead8 = _GBACoreBusRead8;
642	core->busRead16 = _GBACoreBusRead16;
643	core->busRead32 = _GBACoreBusRead32;
644	core->busWrite8 = _GBACoreBusWrite8;
645	core->busWrite16 = _GBACoreBusWrite16;
646	core->busWrite32 = _GBACoreBusWrite32;
647	core->rawRead8 = _GBACoreRawRead8;
648	core->rawRead16 = _GBACoreRawRead16;
649	core->rawRead32 = _GBACoreRawRead32;
650	core->rawWrite8 = _GBACoreRawWrite8;
651	core->rawWrite16 = _GBACoreRawWrite16;
652	core->rawWrite32 = _GBACoreRawWrite32;
653#ifdef USE_DEBUGGERS
654	core->supportsDebuggerType = _GBACoreSupportsDebuggerType;
655	core->debuggerPlatform = _GBACoreDebuggerPlatform;
656	core->cliDebuggerSystem = _GBACoreCliDebuggerSystem;
657	core->attachDebugger = _GBACoreAttachDebugger;
658	core->detachDebugger = _GBACoreDetachDebugger;
659#endif
660	core->cheatDevice = _GBACoreCheatDevice;
661	core->savedataClone = _GBACoreSavedataClone;
662	core->savedataRestore = _GBACoreSavedataRestore;
663	return core;
664}