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