all repos — mgba @ af77e5ab62a920000b8e33544ba2f2efa0cb42e9

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		ARMRunLoop(core->cpu);
336	}
337}
338
339static void _GBACoreRunLoop(struct mCore* core) {
340	ARMRunLoop(core->cpu);
341}
342
343static void _GBACoreStep(struct mCore* core) {
344	ARMRun(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 int32_t _GBACoreFrameCounter(const struct mCore* core) {
377	const struct GBA* gba = core->board;
378	return gba->video.frameCounter;
379}
380
381static int32_t _GBACoreFrameCycles(const struct mCore* core) {
382	UNUSED(core);
383	return VIDEO_TOTAL_LENGTH;
384}
385
386static int32_t _GBACoreFrequency(const struct mCore* core) {
387	UNUSED(core);
388	return GBA_ARM7TDMI_FREQUENCY;
389}
390
391static void _GBACoreGetGameTitle(const struct mCore* core, char* title) {
392	GBAGetGameTitle(core->board, title);
393}
394
395static void _GBACoreGetGameCode(const struct mCore* core, char* title) {
396	GBAGetGameCode(core->board, title);
397}
398
399static void _GBACoreSetRTC(struct mCore* core, struct mRTCSource* rtc) {
400	struct GBA* gba = core->board;
401	gba->rtcSource = rtc;
402}
403
404static void _GBACoreSetRotation(struct mCore* core, struct mRotationSource* rotation) {
405	struct GBA* gba = core->board;
406	gba->rotationSource = rotation;
407}
408
409static void _GBACoreSetRumble(struct mCore* core, struct mRumble* rumble) {
410	struct GBA* gba = core->board;
411	gba->rumble = rumble;
412}
413
414static uint32_t _GBACoreBusRead8(struct mCore* core, uint32_t address) {
415	struct ARMCore* cpu = core->cpu;
416	return cpu->memory.load8(cpu, address, 0);
417}
418
419static uint32_t _GBACoreBusRead16(struct mCore* core, uint32_t address) {
420	struct ARMCore* cpu = core->cpu;
421	return cpu->memory.load16(cpu, address, 0);
422
423}
424
425static uint32_t _GBACoreBusRead32(struct mCore* core, uint32_t address) {
426	struct ARMCore* cpu = core->cpu;
427	return cpu->memory.load32(cpu, address, 0);
428}
429
430static void _GBACoreBusWrite8(struct mCore* core, uint32_t address, uint8_t value) {
431	struct ARMCore* cpu = core->cpu;
432	cpu->memory.store8(cpu, address, value, 0);
433}
434
435static void _GBACoreBusWrite16(struct mCore* core, uint32_t address, uint16_t value) {
436	struct ARMCore* cpu = core->cpu;
437	cpu->memory.store16(cpu, address, value, 0);
438}
439
440static void _GBACoreBusWrite32(struct mCore* core, uint32_t address, uint32_t value) {
441	struct ARMCore* cpu = core->cpu;
442	cpu->memory.store32(cpu, address, value, 0);
443}
444
445static uint32_t _GBACoreRawRead8(struct mCore* core, uint32_t address, int segment) {
446	UNUSED(segment);
447	struct ARMCore* cpu = core->cpu;
448	return GBAView8(cpu, address);
449}
450
451static uint32_t _GBACoreRawRead16(struct mCore* core, uint32_t address, int segment) {
452	UNUSED(segment);
453	struct ARMCore* cpu = core->cpu;
454	return GBAView16(cpu, address);
455}
456
457static uint32_t _GBACoreRawRead32(struct mCore* core, uint32_t address, int segment) {
458	UNUSED(segment);
459	struct ARMCore* cpu = core->cpu;
460	return GBAView32(cpu, address);
461}
462
463static void _GBACoreRawWrite8(struct mCore* core, uint32_t address, int segment, uint8_t value) {
464	UNUSED(segment);
465	struct ARMCore* cpu = core->cpu;
466	GBAPatch8(cpu, address, value, NULL);
467}
468
469static void _GBACoreRawWrite16(struct mCore* core, uint32_t address, int segment, uint16_t value) {
470	UNUSED(segment);
471	struct ARMCore* cpu = core->cpu;
472	GBAPatch16(cpu, address, value, NULL);
473}
474
475static void _GBACoreRawWrite32(struct mCore* core, uint32_t address, int segment, uint32_t value) {
476	UNUSED(segment);
477	struct ARMCore* cpu = core->cpu;
478	GBAPatch32(cpu, address, value, NULL);
479}
480
481#ifdef USE_DEBUGGERS
482static bool _GBACoreSupportsDebuggerType(struct mCore* core, enum mDebuggerType type) {
483	UNUSED(core);
484	switch (type) {
485	case DEBUGGER_CLI:
486		return true;
487#ifdef USE_GDB_STUB
488	case DEBUGGER_GDB:
489		return true;
490#endif
491	default:
492		return false;
493	}
494}
495
496static struct mDebuggerPlatform* _GBACoreDebuggerPlatform(struct mCore* core) {
497	struct GBACore* gbacore = (struct GBACore*) core;
498	if (!gbacore->debuggerPlatform) {
499		gbacore->debuggerPlatform = ARMDebuggerPlatformCreate();
500	}
501	return gbacore->debuggerPlatform;
502}
503
504static struct CLIDebuggerSystem* _GBACoreCliDebuggerSystem(struct mCore* core) {
505	return &GBACLIDebuggerCreate(core)->d;
506}
507
508static void _GBACoreAttachDebugger(struct mCore* core, struct mDebugger* debugger) {
509	if (core->debugger) {
510		GBADetachDebugger(core->board);
511	}
512	GBAAttachDebugger(core->board, debugger);
513	core->debugger = debugger;
514}
515
516static void _GBACoreDetachDebugger(struct mCore* core) {
517	GBADetachDebugger(core->board);
518	core->debugger = NULL;
519}
520#endif
521
522static struct mCheatDevice* _GBACoreCheatDevice(struct mCore* core) {
523	struct GBACore* gbacore = (struct GBACore*) core;
524	if (!gbacore->cheatDevice) {
525		gbacore->cheatDevice = GBACheatDeviceCreate();
526		((struct ARMCore*) core->cpu)->components[CPU_COMPONENT_CHEAT_DEVICE] = &gbacore->cheatDevice->d;
527		ARMHotplugAttach(core->cpu, CPU_COMPONENT_CHEAT_DEVICE);
528		gbacore->cheatDevice->p = core;
529	}
530	return gbacore->cheatDevice;
531}
532
533static size_t _GBACoreSavedataClone(struct mCore* core, void** sram) {
534	struct GBA* gba = core->board;
535	size_t size = GBASavedataSize(&gba->memory.savedata);
536	if (!size) {
537		*sram = NULL;
538		return 0;
539	}
540	*sram = malloc(size);
541	struct VFile* vf = VFileFromMemory(*sram, size);
542	if (!vf) {
543		free(*sram);
544		*sram = NULL;
545		return 0;
546	}
547	bool success = GBASavedataClone(&gba->memory.savedata, vf);
548	vf->close(vf);
549	if (!success) {
550		free(*sram);
551		*sram = NULL;
552		return 0;
553	}
554	return size;
555}
556
557static bool _GBACoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {
558	struct VFile* vf = VFileMemChunk(sram, size);
559	if (!vf) {
560		return false;
561	}
562	struct GBA* gba = core->board;
563	bool success = true;
564	if (writeback) {
565		success = GBASavedataLoad(&gba->memory.savedata, vf);
566		vf->close(vf);
567	} else {
568		GBASavedataMask(&gba->memory.savedata, vf, true);
569	}
570	return success;
571}
572
573struct mCore* GBACoreCreate(void) {
574	struct GBACore* gbacore = malloc(sizeof(*gbacore));
575	struct mCore* core = &gbacore->d;
576	memset(&core->opts, 0, sizeof(core->opts));
577	core->cpu = NULL;
578	core->board = NULL;
579	core->debugger = NULL;
580	core->init = _GBACoreInit;
581	core->deinit = _GBACoreDeinit;
582	core->platform = _GBACorePlatform;
583	core->setSync = _GBACoreSetSync;
584	core->loadConfig = _GBACoreLoadConfig;
585	core->desiredVideoDimensions = _GBACoreDesiredVideoDimensions;
586	core->setVideoBuffer = _GBACoreSetVideoBuffer;
587	core->getPixels = _GBACoreGetPixels;
588	core->putPixels = _GBACorePutPixels;
589	core->getAudioChannel = _GBACoreGetAudioChannel;
590	core->setAudioBufferSize = _GBACoreSetAudioBufferSize;
591	core->getAudioBufferSize = _GBACoreGetAudioBufferSize;
592	core->setCoreCallbacks = _GBACoreSetCoreCallbacks;
593	core->setAVStream = _GBACoreSetAVStream;
594	core->isROM = GBAIsROM;
595	core->loadROM = _GBACoreLoadROM;
596	core->loadBIOS = _GBACoreLoadBIOS;
597	core->loadSave = _GBACoreLoadSave;
598	core->loadTemporarySave = _GBACoreLoadTemporarySave;
599	core->loadPatch = _GBACoreLoadPatch;
600	core->unloadROM = _GBACoreUnloadROM;
601	core->checksum = _GBACoreChecksum;
602	core->reset = _GBACoreReset;
603	core->runFrame = _GBACoreRunFrame;
604	core->runLoop = _GBACoreRunLoop;
605	core->step = _GBACoreStep;
606	core->stateSize = _GBACoreStateSize;
607	core->loadState = _GBACoreLoadState;
608	core->saveState = _GBACoreSaveState;
609	core->setKeys = _GBACoreSetKeys;
610	core->addKeys = _GBACoreAddKeys;
611	core->clearKeys = _GBACoreClearKeys;
612	core->frameCounter = _GBACoreFrameCounter;
613	core->frameCycles = _GBACoreFrameCycles;
614	core->frequency = _GBACoreFrequency;
615	core->getGameTitle = _GBACoreGetGameTitle;
616	core->getGameCode = _GBACoreGetGameCode;
617	core->setRTC = _GBACoreSetRTC;
618	core->setRotation = _GBACoreSetRotation;
619	core->setRumble = _GBACoreSetRumble;
620	core->busRead8 = _GBACoreBusRead8;
621	core->busRead16 = _GBACoreBusRead16;
622	core->busRead32 = _GBACoreBusRead32;
623	core->busWrite8 = _GBACoreBusWrite8;
624	core->busWrite16 = _GBACoreBusWrite16;
625	core->busWrite32 = _GBACoreBusWrite32;
626	core->rawRead8 = _GBACoreRawRead8;
627	core->rawRead16 = _GBACoreRawRead16;
628	core->rawRead32 = _GBACoreRawRead32;
629	core->rawWrite8 = _GBACoreRawWrite8;
630	core->rawWrite16 = _GBACoreRawWrite16;
631	core->rawWrite32 = _GBACoreRawWrite32;
632#ifdef USE_DEBUGGERS
633	core->supportsDebuggerType = _GBACoreSupportsDebuggerType;
634	core->debuggerPlatform = _GBACoreDebuggerPlatform;
635	core->cliDebuggerSystem = _GBACoreCliDebuggerSystem;
636	core->attachDebugger = _GBACoreAttachDebugger;
637	core->detachDebugger = _GBACoreDetachDebugger;
638#endif
639	core->cheatDevice = _GBACoreCheatDevice;
640	core->savedataClone = _GBACoreSavedataClone;
641	core->savedataRestore = _GBACoreSavedataRestore;
642	return core;
643}