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