all repos — mgba @ 480415c51e8a3f1af0535042a2dbaf35058e82c8

mGBA Game Boy Advance Emulator

src/gb/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/gb/core.h>
  7
  8#include <mgba/core/core.h>
  9#include <mgba/internal/gb/cheats.h>
 10#include <mgba/internal/gb/extra/cli.h>
 11#include <mgba/internal/gb/gb.h>
 12#include <mgba/internal/gb/mbc.h>
 13#include <mgba/internal/gb/overrides.h>
 14#include <mgba/internal/gb/renderers/software.h>
 15#include <mgba/internal/gb/serialize.h>
 16#include <mgba/internal/lr35902/lr35902.h>
 17#include <mgba/internal/lr35902/debugger/debugger.h>
 18#include <mgba-util/crc32.h>
 19#include <mgba-util/memory.h>
 20#include <mgba-util/patch.h>
 21#include <mgba-util/vfs.h>
 22
 23struct GBCore {
 24	struct mCore d;
 25	struct GBVideoSoftwareRenderer renderer;
 26	uint8_t keys;
 27	struct mCPUComponent* components[CPU_COMPONENT_MAX];
 28	const struct Configuration* overrides;
 29	struct mDebuggerPlatform* debuggerPlatform;
 30	struct mCheatDevice* cheatDevice;
 31};
 32
 33static bool _GBCoreInit(struct mCore* core) {
 34	struct GBCore* gbcore = (struct GBCore*) core;
 35
 36	struct LR35902Core* cpu = anonymousMemoryMap(sizeof(struct LR35902Core));
 37	struct GB* gb = anonymousMemoryMap(sizeof(struct GB));
 38	if (!cpu || !gb) {
 39		free(cpu);
 40		free(gb);
 41		return false;
 42	}
 43	core->cpu = cpu;
 44	core->board = gb;
 45	gbcore->overrides = NULL;
 46	gbcore->debuggerPlatform = NULL;
 47	gbcore->cheatDevice = NULL;
 48
 49	GBCreate(gb);
 50	memset(gbcore->components, 0, sizeof(gbcore->components));
 51	LR35902SetComponents(cpu, &gb->d, CPU_COMPONENT_MAX, gbcore->components);
 52	LR35902Init(cpu);
 53
 54	GBVideoSoftwareRendererCreate(&gbcore->renderer);
 55	gbcore->renderer.outputBuffer = NULL;
 56
 57	gbcore->keys = 0;
 58	gb->keySource = &gbcore->keys;
 59
 60#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
 61	mDirectorySetInit(&core->dirs);
 62#endif
 63	
 64	return true;
 65}
 66
 67static void _GBCoreDeinit(struct mCore* core) {
 68	LR35902Deinit(core->cpu);
 69	GBDestroy(core->board);
 70	mappedMemoryFree(core->cpu, sizeof(struct LR35902Core));
 71	mappedMemoryFree(core->board, sizeof(struct GB));
 72#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
 73	mDirectorySetDeinit(&core->dirs);
 74#endif
 75
 76	struct GBCore* gbcore = (struct GBCore*) core;
 77	free(gbcore->debuggerPlatform);
 78	if (gbcore->cheatDevice) {
 79		mCheatDeviceDestroy(gbcore->cheatDevice);
 80	}
 81	free(gbcore->cheatDevice);
 82	mCoreConfigFreeOpts(&core->opts);
 83	free(core);
 84}
 85
 86static enum mPlatform _GBCorePlatform(const struct mCore* core) {
 87	UNUSED(core);
 88	return PLATFORM_GB;
 89}
 90
 91static void _GBCoreSetSync(struct mCore* core, struct mCoreSync* sync) {
 92	struct GB* gb = core->board;
 93	gb->sync = sync;
 94}
 95
 96static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) {
 97	UNUSED(config);
 98
 99	struct GB* gb = core->board;
100	if (core->opts.mute) {
101		gb->audio.masterVolume = 0;
102	} else {
103		gb->audio.masterVolume = core->opts.volume;
104	}
105	gb->video.frameskip = core->opts.frameskip;
106	mCoreConfigCopyValue(&core->config, config, "gb.bios");
107	mCoreConfigCopyValue(&core->config, config, "gbc.bios");
108
109#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
110	struct GBCore* gbcore = (struct GBCore*) core;
111	gbcore->overrides = mCoreConfigGetOverridesConst(config);
112#endif
113}
114
115static void _GBCoreDesiredVideoDimensions(struct mCore* core, unsigned* width, unsigned* height) {
116	UNUSED(core);
117	*width = GB_VIDEO_HORIZONTAL_PIXELS;
118	*height = GB_VIDEO_VERTICAL_PIXELS;
119}
120
121static void _GBCoreSetVideoBuffer(struct mCore* core, color_t* buffer, size_t stride) {
122	struct GBCore* gbcore = (struct GBCore*) core;
123	gbcore->renderer.outputBuffer = buffer;
124	gbcore->renderer.outputBufferStride = stride;
125}
126
127static void _GBCoreGetPixels(struct mCore* core, const void** buffer, size_t* stride) {
128	struct GBCore* gbcore = (struct GBCore*) core;
129	gbcore->renderer.d.getPixels(&gbcore->renderer.d, stride, buffer);
130}
131
132static void _GBCorePutPixels(struct mCore* core, const void* buffer, size_t stride) {
133	struct GBCore* gbcore = (struct GBCore*) core;
134	gbcore->renderer.d.putPixels(&gbcore->renderer.d, stride, buffer);
135}
136
137static struct blip_t* _GBCoreGetAudioChannel(struct mCore* core, int ch) {
138	struct GB* gb = core->board;
139	switch (ch) {
140	case 0:
141		return gb->audio.left;
142	case 1:
143		return gb->audio.right;
144	default:
145		return NULL;
146	}
147}
148
149static void _GBCoreSetAudioBufferSize(struct mCore* core, size_t samples) {
150	struct GB* gb = core->board;
151	GBAudioResizeBuffer(&gb->audio, samples);
152}
153
154static size_t _GBCoreGetAudioBufferSize(struct mCore* core) {
155	struct GB* gb = core->board;
156	return gb->audio.samples;
157}
158
159static void _GBCoreSetCoreCallbacks(struct mCore* core, struct mCoreCallbacks* coreCallbacks) {
160	struct GB* gb = core->board;
161	gb->coreCallbacks = coreCallbacks;
162}
163
164static void _GBCoreSetAVStream(struct mCore* core, struct mAVStream* stream) {
165	struct GB* gb = core->board;
166	gb->stream = stream;
167	if (stream && stream->videoDimensionsChanged) {
168		stream->videoDimensionsChanged(stream, GB_VIDEO_HORIZONTAL_PIXELS, GB_VIDEO_VERTICAL_PIXELS);
169	}
170}
171
172static bool _GBCoreLoadROM(struct mCore* core, struct VFile* vf) {
173	return GBLoadROM(core->board, vf);
174}
175
176static bool _GBCoreLoadBIOS(struct mCore* core, struct VFile* vf, int type) {
177	UNUSED(type);
178	GBLoadBIOS(core->board, vf);
179	return true;
180}
181
182static bool _GBCoreLoadSave(struct mCore* core, struct VFile* vf) {
183	return GBLoadSave(core->board, vf);
184}
185
186static bool _GBCoreLoadTemporarySave(struct mCore* core, struct VFile* vf) {
187	struct GB* gb = core->board;
188	GBSavedataMask(gb, vf, false);
189	return true; // TODO: Return a real value
190}
191
192static bool _GBCoreLoadPatch(struct mCore* core, struct VFile* vf) {
193	if (!vf) {
194		return false;
195	}
196	struct Patch patch;
197	if (!loadPatch(vf, &patch)) {
198		return false;
199	}
200	GBApplyPatch(core->board, &patch);
201	return true;
202}
203
204static void _GBCoreUnloadROM(struct mCore* core) {
205	struct GBCore* gbcore = (struct GBCore*) core;
206	struct LR35902Core* cpu = core->cpu;
207	if (gbcore->cheatDevice) {
208		LR35902HotplugDetach(cpu, CPU_COMPONENT_CHEAT_DEVICE);
209		cpu->components[CPU_COMPONENT_CHEAT_DEVICE] = NULL;
210		mCheatDeviceDestroy(gbcore->cheatDevice);
211		gbcore->cheatDevice = NULL;
212	}
213	return GBUnloadROM(core->board);
214}
215
216static void _GBCoreChecksum(const struct mCore* core, void* data, enum mCoreChecksumType type) {
217	struct GB* gb = (struct GB*) core->board;
218	switch (type) {
219	case CHECKSUM_CRC32:
220		memcpy(data, &gb->romCrc32, sizeof(gb->romCrc32));
221		break;
222	}
223	return;
224}
225
226static void _GBCoreReset(struct mCore* core) {
227	struct GBCore* gbcore = (struct GBCore*) core;
228	struct GB* gb = (struct GB*) core->board;
229	if (gbcore->renderer.outputBuffer) {
230		GBVideoAssociateRenderer(&gb->video, &gbcore->renderer.d);
231	}
232
233	if (gb->memory.rom) {
234		struct GBCartridgeOverride override;
235		const struct GBCartridge* cart = (const struct GBCartridge*) &gb->memory.rom[0x100];
236		override.headerCrc32 = doCrc32(cart, sizeof(*cart));
237		if (GBOverrideFind(gbcore->overrides, &override)) {
238			GBOverrideApply(gb, &override);
239		}
240	}
241
242#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
243	if (!gb->biosVf && core->opts.useBios) {
244		struct VFile* bios = NULL;
245		bool found = false;
246		if (core->opts.bios) {
247			bios = VFileOpen(core->opts.bios, O_RDONLY);
248			if (bios && GBIsBIOS(bios)) {
249				found = true;
250			} else if (bios) {
251				bios->close(bios);
252				bios = NULL;
253			}
254		}
255		if (!found) {
256			GBDetectModel(gb);
257			const char* configPath;
258
259			switch (gb->model) {
260			case GB_MODEL_DMG:
261			case GB_MODEL_SGB: // TODO
262				configPath = mCoreConfigGetValue(&core->config, "gb.bios");
263				break;
264			case GB_MODEL_CGB:
265			case GB_MODEL_AGB:
266				configPath = mCoreConfigGetValue(&core->config, "gbc.bios");
267				break;
268			default:
269				break;
270			};
271			bios = VFileOpen(configPath, O_RDONLY);
272			if (bios && GBIsBIOS(bios)) {
273				found = true;
274			} else if (bios) {
275				bios->close(bios);
276				bios = NULL;
277			}
278		}
279		if (!found) {
280			char path[PATH_MAX];
281			mCoreConfigDirectory(path, PATH_MAX);
282			switch (gb->model) {
283			case GB_MODEL_DMG:
284			case GB_MODEL_SGB: // TODO
285				strncat(path, PATH_SEP "gb_bios.bin", PATH_MAX - strlen(path));
286				break;
287			case GB_MODEL_CGB:
288			case GB_MODEL_AGB:
289				strncat(path, PATH_SEP "gbc_bios.bin", PATH_MAX - strlen(path));
290				break;
291			default:
292				break;
293			};
294			bios = VFileOpen(path, O_RDONLY);
295			if (bios && GBIsBIOS(bios)) {
296				found = true;
297			} else if (bios) {
298				bios->close(bios);
299				bios = NULL;
300			}
301		}
302		if (bios) {
303			GBLoadBIOS(gb, bios);
304		}
305	}
306#endif
307
308	LR35902Reset(core->cpu);
309}
310
311static void _GBCoreRunFrame(struct mCore* core) {
312	struct GB* gb = core->board;
313	int32_t frameCounter = gb->video.frameCounter;
314	while (gb->video.frameCounter == frameCounter) {
315		LR35902Run(core->cpu);
316	}
317}
318
319static void _GBCoreRunLoop(struct mCore* core) {
320	LR35902Run(core->cpu);
321}
322
323static void _GBCoreStep(struct mCore* core) {
324	struct LR35902Core* cpu = core->cpu;
325	do {
326		LR35902Tick(cpu);
327	} while (cpu->executionState != LR35902_CORE_FETCH);
328}
329
330static size_t _GBCoreStateSize(struct mCore* core) {
331	UNUSED(core);
332	return sizeof(struct GBSerializedState);
333}
334
335static bool _GBCoreLoadState(struct mCore* core, const void* state) {
336	return GBDeserialize(core->board, state);
337}
338
339static bool _GBCoreSaveState(struct mCore* core, void* state) {
340	struct LR35902Core* cpu = core->cpu;
341	while (cpu->executionState != LR35902_CORE_FETCH) {
342		LR35902Tick(cpu);
343	}
344	GBSerialize(core->board, state);
345	return true;
346}
347
348static void _GBCoreSetKeys(struct mCore* core, uint32_t keys) {
349	struct GBCore* gbcore = (struct GBCore*) core;
350	gbcore->keys = keys;
351}
352
353static void _GBCoreAddKeys(struct mCore* core, uint32_t keys) {
354	struct GBCore* gbcore = (struct GBCore*) core;
355	gbcore->keys |= keys;
356}
357
358static void _GBCoreClearKeys(struct mCore* core, uint32_t keys) {
359	struct GBCore* gbcore = (struct GBCore*) core;
360	gbcore->keys &= ~keys;
361}
362
363static int32_t _GBCoreFrameCounter(const struct mCore* core) {
364	const struct GB* gb = core->board;
365	return gb->video.frameCounter;
366}
367
368static int32_t _GBCoreFrameCycles(const  struct mCore* core) {
369	UNUSED(core);
370	return GB_VIDEO_TOTAL_LENGTH;
371}
372
373static int32_t _GBCoreFrequency(const struct mCore* core) {
374	UNUSED(core);
375	// TODO: GB differences
376	return DMG_LR35902_FREQUENCY;
377}
378
379static void _GBCoreGetGameTitle(const struct mCore* core, char* title) {
380	GBGetGameTitle(core->board, title);
381}
382
383static void _GBCoreGetGameCode(const struct mCore* core, char* title) {
384	GBGetGameCode(core->board, title);
385}
386
387static void _GBCoreSetRTC(struct mCore* core, struct mRTCSource* rtc) {
388	struct GB* gb = core->board;
389	gb->memory.rtc = rtc;
390}
391
392static void _GBCoreSetRotation(struct mCore* core, struct mRotationSource* rotation) {
393	struct GB* gb = core->board;
394	gb->memory.rotation = rotation;
395}
396
397static void _GBCoreSetRumble(struct mCore* core, struct mRumble* rumble) {
398	struct GB* gb = core->board;
399	gb->memory.rumble = rumble;
400}
401
402static uint32_t _GBCoreBusRead8(struct mCore* core, uint32_t address) {
403	struct LR35902Core* cpu = core->cpu;
404	return cpu->memory.load8(cpu, address);
405}
406
407static uint32_t _GBCoreBusRead16(struct mCore* core, uint32_t address) {
408	struct LR35902Core* cpu = core->cpu;
409	return cpu->memory.load8(cpu, address) | (cpu->memory.load8(cpu, address + 1) << 8);
410}
411
412static uint32_t _GBCoreBusRead32(struct mCore* core, uint32_t address) {
413	struct LR35902Core* cpu = core->cpu;
414	return cpu->memory.load8(cpu, address) | (cpu->memory.load8(cpu, address + 1) << 8) |
415	       (cpu->memory.load8(cpu, address + 2) << 16) | (cpu->memory.load8(cpu, address + 3) << 24);
416}
417
418static void _GBCoreBusWrite8(struct mCore* core, uint32_t address, uint8_t value) {
419	struct LR35902Core* cpu = core->cpu;
420	cpu->memory.store8(cpu, address, value);
421}
422
423static void _GBCoreBusWrite16(struct mCore* core, uint32_t address, uint16_t value) {
424	struct LR35902Core* cpu = core->cpu;
425	cpu->memory.store8(cpu, address, value);
426	cpu->memory.store8(cpu, address + 1, value >> 8);
427}
428
429static void _GBCoreBusWrite32(struct mCore* core, uint32_t address, uint32_t value) {
430	struct LR35902Core* cpu = core->cpu;
431	cpu->memory.store8(cpu, address, value);
432	cpu->memory.store8(cpu, address + 1, value >> 8);
433	cpu->memory.store8(cpu, address + 2, value >> 16);
434	cpu->memory.store8(cpu, address + 3, value >> 24);
435}
436
437static uint32_t _GBCoreRawRead8(struct mCore* core, uint32_t address, int segment) {
438	struct LR35902Core* cpu = core->cpu;
439	return GBView8(cpu, address, segment);
440}
441
442static uint32_t _GBCoreRawRead16(struct mCore* core, uint32_t address, int segment) {
443	struct LR35902Core* cpu = core->cpu;
444	return GBView8(cpu, address, segment) | (GBView8(cpu, address + 1, segment) << 8);
445}
446
447static uint32_t _GBCoreRawRead32(struct mCore* core, uint32_t address, int segment) {
448	struct LR35902Core* cpu = core->cpu;
449	return GBView8(cpu, address, segment) | (GBView8(cpu, address + 1, segment) << 8) |
450	       (GBView8(cpu, address + 2, segment) << 16) | (GBView8(cpu, address + 3, segment) << 24);
451}
452
453static void _GBCoreRawWrite8(struct mCore* core, uint32_t address, int segment, uint8_t value) {
454	struct LR35902Core* cpu = core->cpu;
455	GBPatch8(cpu, address, value, NULL, segment);
456}
457
458static void _GBCoreRawWrite16(struct mCore* core, uint32_t address, int segment, uint16_t value) {
459	struct LR35902Core* cpu = core->cpu;
460	GBPatch8(cpu, address, value, NULL, segment);
461	GBPatch8(cpu, address + 1, value >> 8, NULL, segment);
462}
463
464static void _GBCoreRawWrite32(struct mCore* core, uint32_t address, int segment, uint32_t value) {
465	struct LR35902Core* cpu = core->cpu;
466	GBPatch8(cpu, address, value, NULL, segment);
467	GBPatch8(cpu, address + 1, value >> 8, NULL, segment);
468	GBPatch8(cpu, address + 2, value >> 16, NULL, segment);
469	GBPatch8(cpu, address + 3, value >> 24, NULL, segment);
470}
471
472#ifdef USE_DEBUGGERS
473static bool _GBCoreSupportsDebuggerType(struct mCore* core, enum mDebuggerType type) {
474	UNUSED(core);
475	switch (type) {
476	case DEBUGGER_CLI:
477		return true;
478	default:
479		return false;
480	}
481}
482
483static struct mDebuggerPlatform* _GBCoreDebuggerPlatform(struct mCore* core) {
484	struct GBCore* gbcore = (struct GBCore*) core;
485	if (!gbcore->debuggerPlatform) {
486		gbcore->debuggerPlatform = LR35902DebuggerPlatformCreate();
487	}
488	return gbcore->debuggerPlatform;
489}
490
491static struct CLIDebuggerSystem* _GBCoreCliDebuggerSystem(struct mCore* core) {
492	return GBCLIDebuggerCreate(core);
493}
494
495static void _GBCoreAttachDebugger(struct mCore* core, struct mDebugger* debugger) {
496	struct LR35902Core* cpu = core->cpu;
497	if (core->debugger) {
498		LR35902HotplugDetach(cpu, CPU_COMPONENT_DEBUGGER);
499	}
500	cpu->components[CPU_COMPONENT_DEBUGGER] = &debugger->d;
501	LR35902HotplugAttach(cpu, CPU_COMPONENT_DEBUGGER);
502	core->debugger = debugger;
503}
504
505static void _GBCoreDetachDebugger(struct mCore* core) {
506	struct LR35902Core* cpu = core->cpu;
507	if (core->debugger) {
508		LR35902HotplugDetach(cpu, CPU_COMPONENT_DEBUGGER);
509	}
510	cpu->components[CPU_COMPONENT_DEBUGGER] = NULL;
511	core->debugger = NULL;
512}
513#endif
514
515static struct mCheatDevice* _GBCoreCheatDevice(struct mCore* core) {
516	struct GBCore* gbcore = (struct GBCore*) core;
517	if (!gbcore->cheatDevice) {
518		gbcore->cheatDevice = GBCheatDeviceCreate();
519		((struct LR35902Core*) core->cpu)->components[CPU_COMPONENT_CHEAT_DEVICE] = &gbcore->cheatDevice->d;
520		LR35902HotplugAttach(core->cpu, CPU_COMPONENT_CHEAT_DEVICE);
521		gbcore->cheatDevice->p = core;
522	}
523	return gbcore->cheatDevice;
524}
525
526static size_t _GBCoreSavedataClone(struct mCore* core, void** sram) {
527	struct GB* gb = core->board;
528	struct VFile* vf = gb->sramVf;
529	if (vf) {
530		*sram = malloc(vf->size(vf));
531		vf->seek(vf, 0, SEEK_SET);
532		return vf->read(vf, *sram, vf->size(vf));
533	}
534	*sram = malloc(gb->sramSize);
535	memcpy(*sram, gb->memory.sram, gb->sramSize);
536	return gb->sramSize;
537}
538
539static bool _GBCoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {
540	struct GB* gb = core->board;
541	if (!writeback) {
542		struct VFile* vf = VFileMemChunk(sram, size);
543		GBSavedataMask(gb, vf, true);
544		return true;
545	}
546	struct VFile* vf = gb->sramVf;
547	if (vf) {
548		vf->seek(vf, 0, SEEK_SET);
549		return vf->write(vf, sram, size) > 0;
550	}
551	if (size > 0x20000) {
552		size = 0x20000;
553	}
554	GBResizeSram(gb, size);
555	memcpy(gb->memory.sram, sram, size);
556	return true;
557}
558
559struct mCore* GBCoreCreate(void) {
560	struct GBCore* gbcore = malloc(sizeof(*gbcore));
561	struct mCore* core = &gbcore->d;
562	memset(&core->opts, 0, sizeof(core->opts));
563	core->cpu = NULL;
564	core->board = NULL;
565	core->debugger = NULL;
566	core->init = _GBCoreInit;
567	core->deinit = _GBCoreDeinit;
568	core->platform = _GBCorePlatform;
569	core->setSync = _GBCoreSetSync;
570	core->loadConfig = _GBCoreLoadConfig;
571	core->desiredVideoDimensions = _GBCoreDesiredVideoDimensions;
572	core->setVideoBuffer = _GBCoreSetVideoBuffer;
573	core->getPixels = _GBCoreGetPixels;
574	core->putPixels = _GBCorePutPixels;
575	core->getAudioChannel = _GBCoreGetAudioChannel;
576	core->setAudioBufferSize = _GBCoreSetAudioBufferSize;
577	core->getAudioBufferSize = _GBCoreGetAudioBufferSize;
578	core->setAVStream = _GBCoreSetAVStream;
579	core->setCoreCallbacks = _GBCoreSetCoreCallbacks;
580	core->isROM = GBIsROM;
581	core->loadROM = _GBCoreLoadROM;
582	core->loadBIOS = _GBCoreLoadBIOS;
583	core->loadSave = _GBCoreLoadSave;
584	core->loadTemporarySave = _GBCoreLoadTemporarySave;
585	core->loadPatch = _GBCoreLoadPatch;
586	core->unloadROM = _GBCoreUnloadROM;
587	core->checksum = _GBCoreChecksum;
588	core->reset = _GBCoreReset;
589	core->runFrame = _GBCoreRunFrame;
590	core->runLoop = _GBCoreRunLoop;
591	core->step = _GBCoreStep;
592	core->stateSize = _GBCoreStateSize;
593	core->loadState = _GBCoreLoadState;
594	core->saveState = _GBCoreSaveState;
595	core->setKeys = _GBCoreSetKeys;
596	core->addKeys = _GBCoreAddKeys;
597	core->clearKeys = _GBCoreClearKeys;
598	core->frameCounter = _GBCoreFrameCounter;
599	core->frameCycles = _GBCoreFrameCycles;
600	core->frequency = _GBCoreFrequency;
601	core->getGameTitle = _GBCoreGetGameTitle;
602	core->getGameCode = _GBCoreGetGameCode;
603	core->setRTC = _GBCoreSetRTC;
604	core->setRotation = _GBCoreSetRotation;
605	core->setRumble = _GBCoreSetRumble;
606	core->busRead8 = _GBCoreBusRead8;
607	core->busRead16 = _GBCoreBusRead16;
608	core->busRead32 = _GBCoreBusRead32;
609	core->busWrite8 = _GBCoreBusWrite8;
610	core->busWrite16 = _GBCoreBusWrite16;
611	core->busWrite32 = _GBCoreBusWrite32;
612	core->rawRead8 = _GBCoreRawRead8;
613	core->rawRead16 = _GBCoreRawRead16;
614	core->rawRead32 = _GBCoreRawRead32;
615	core->rawWrite8 = _GBCoreRawWrite8;
616	core->rawWrite16 = _GBCoreRawWrite16;
617	core->rawWrite32 = _GBCoreRawWrite32;
618#ifdef USE_DEBUGGERS
619	core->supportsDebuggerType = _GBCoreSupportsDebuggerType;
620	core->debuggerPlatform = _GBCoreDebuggerPlatform;
621	core->cliDebuggerSystem = _GBCoreCliDebuggerSystem;
622	core->attachDebugger = _GBCoreAttachDebugger;
623	core->detachDebugger = _GBCoreDetachDebugger;
624#endif
625	core->cheatDevice = _GBCoreCheatDevice;
626	core->savedataClone = _GBCoreSavedataClone;
627	core->savedataRestore = _GBCoreSavedataRestore;
628	return core;
629}