all repos — mgba @ 2ab7289a059ab3055f00f0677f7c20bfed7591d5

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