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 _GBCoreSetCursorLocation(struct mCore* core, int x, int y) {
372 UNUSED(core);
373 UNUSED(x);
374 UNUSED(y);
375}
376
377static void _GBCoreSetCursorDown(struct mCore* core, bool down) {
378 UNUSED(core);
379 UNUSED(down);
380}
381
382static int32_t _GBCoreFrameCounter(const struct mCore* core) {
383 const struct GB* gb = core->board;
384 return gb->video.frameCounter;
385}
386
387static int32_t _GBCoreFrameCycles(const struct mCore* core) {
388 UNUSED(core);
389 return GB_VIDEO_TOTAL_LENGTH;
390}
391
392static int32_t _GBCoreFrequency(const struct mCore* core) {
393 UNUSED(core);
394 // TODO: GB differences
395 return DMG_LR35902_FREQUENCY;
396}
397
398static void _GBCoreGetGameTitle(const struct mCore* core, char* title) {
399 GBGetGameTitle(core->board, title);
400}
401
402static void _GBCoreGetGameCode(const struct mCore* core, char* title) {
403 GBGetGameCode(core->board, title);
404}
405
406static void _GBCoreSetRTC(struct mCore* core, struct mRTCSource* rtc) {
407 struct GB* gb = core->board;
408 gb->memory.rtc = rtc;
409}
410
411static void _GBCoreSetRotation(struct mCore* core, struct mRotationSource* rotation) {
412 struct GB* gb = core->board;
413 gb->memory.rotation = rotation;
414}
415
416static void _GBCoreSetRumble(struct mCore* core, struct mRumble* rumble) {
417 struct GB* gb = core->board;
418 gb->memory.rumble = rumble;
419}
420
421static uint32_t _GBCoreBusRead8(struct mCore* core, uint32_t address) {
422 struct LR35902Core* cpu = core->cpu;
423 return cpu->memory.load8(cpu, address);
424}
425
426static uint32_t _GBCoreBusRead16(struct mCore* core, uint32_t address) {
427 struct LR35902Core* cpu = core->cpu;
428 return cpu->memory.load8(cpu, address) | (cpu->memory.load8(cpu, address + 1) << 8);
429}
430
431static uint32_t _GBCoreBusRead32(struct mCore* core, uint32_t address) {
432 struct LR35902Core* cpu = core->cpu;
433 return cpu->memory.load8(cpu, address) | (cpu->memory.load8(cpu, address + 1) << 8) |
434 (cpu->memory.load8(cpu, address + 2) << 16) | (cpu->memory.load8(cpu, address + 3) << 24);
435}
436
437static void _GBCoreBusWrite8(struct mCore* core, uint32_t address, uint8_t value) {
438 struct LR35902Core* cpu = core->cpu;
439 cpu->memory.store8(cpu, address, value);
440}
441
442static void _GBCoreBusWrite16(struct mCore* core, uint32_t address, uint16_t value) {
443 struct LR35902Core* cpu = core->cpu;
444 cpu->memory.store8(cpu, address, value);
445 cpu->memory.store8(cpu, address + 1, value >> 8);
446}
447
448static void _GBCoreBusWrite32(struct mCore* core, uint32_t address, uint32_t value) {
449 struct LR35902Core* cpu = core->cpu;
450 cpu->memory.store8(cpu, address, value);
451 cpu->memory.store8(cpu, address + 1, value >> 8);
452 cpu->memory.store8(cpu, address + 2, value >> 16);
453 cpu->memory.store8(cpu, address + 3, value >> 24);
454}
455
456static uint32_t _GBCoreRawRead8(struct mCore* core, uint32_t address, int segment) {
457 struct LR35902Core* cpu = core->cpu;
458 return GBView8(cpu, address, segment);
459}
460
461static uint32_t _GBCoreRawRead16(struct mCore* core, uint32_t address, int segment) {
462 struct LR35902Core* cpu = core->cpu;
463 return GBView8(cpu, address, segment) | (GBView8(cpu, address + 1, segment) << 8);
464}
465
466static uint32_t _GBCoreRawRead32(struct mCore* core, uint32_t address, int segment) {
467 struct LR35902Core* cpu = core->cpu;
468 return GBView8(cpu, address, segment) | (GBView8(cpu, address + 1, segment) << 8) |
469 (GBView8(cpu, address + 2, segment) << 16) | (GBView8(cpu, address + 3, segment) << 24);
470}
471
472static void _GBCoreRawWrite8(struct mCore* core, uint32_t address, int segment, uint8_t value) {
473 struct LR35902Core* cpu = core->cpu;
474 GBPatch8(cpu, address, value, NULL, segment);
475}
476
477static void _GBCoreRawWrite16(struct mCore* core, uint32_t address, int segment, uint16_t value) {
478 struct LR35902Core* cpu = core->cpu;
479 GBPatch8(cpu, address, value, NULL, segment);
480 GBPatch8(cpu, address + 1, value >> 8, NULL, segment);
481}
482
483static void _GBCoreRawWrite32(struct mCore* core, uint32_t address, int segment, uint32_t value) {
484 struct LR35902Core* cpu = core->cpu;
485 GBPatch8(cpu, address, value, NULL, segment);
486 GBPatch8(cpu, address + 1, value >> 8, NULL, segment);
487 GBPatch8(cpu, address + 2, value >> 16, NULL, segment);
488 GBPatch8(cpu, address + 3, value >> 24, NULL, segment);
489}
490
491#ifdef USE_DEBUGGERS
492static bool _GBCoreSupportsDebuggerType(struct mCore* core, enum mDebuggerType type) {
493 UNUSED(core);
494 switch (type) {
495 case DEBUGGER_CLI:
496 return true;
497 default:
498 return false;
499 }
500}
501
502static struct mDebuggerPlatform* _GBCoreDebuggerPlatform(struct mCore* core) {
503 struct GBCore* gbcore = (struct GBCore*) core;
504 if (!gbcore->debuggerPlatform) {
505 gbcore->debuggerPlatform = LR35902DebuggerPlatformCreate();
506 }
507 return gbcore->debuggerPlatform;
508}
509
510static struct CLIDebuggerSystem* _GBCoreCliDebuggerSystem(struct mCore* core) {
511 return GBCLIDebuggerCreate(core);
512}
513
514static void _GBCoreAttachDebugger(struct mCore* core, struct mDebugger* debugger) {
515 struct LR35902Core* cpu = core->cpu;
516 if (core->debugger) {
517 LR35902HotplugDetach(cpu, CPU_COMPONENT_DEBUGGER);
518 }
519 cpu->components[CPU_COMPONENT_DEBUGGER] = &debugger->d;
520 LR35902HotplugAttach(cpu, CPU_COMPONENT_DEBUGGER);
521 core->debugger = debugger;
522}
523
524static void _GBCoreDetachDebugger(struct mCore* core) {
525 struct LR35902Core* cpu = core->cpu;
526 if (core->debugger) {
527 LR35902HotplugDetach(cpu, CPU_COMPONENT_DEBUGGER);
528 }
529 cpu->components[CPU_COMPONENT_DEBUGGER] = NULL;
530 core->debugger = NULL;
531}
532#endif
533
534static struct mCheatDevice* _GBCoreCheatDevice(struct mCore* core) {
535 struct GBCore* gbcore = (struct GBCore*) core;
536 if (!gbcore->cheatDevice) {
537 gbcore->cheatDevice = GBCheatDeviceCreate();
538 ((struct LR35902Core*) core->cpu)->components[CPU_COMPONENT_CHEAT_DEVICE] = &gbcore->cheatDevice->d;
539 LR35902HotplugAttach(core->cpu, CPU_COMPONENT_CHEAT_DEVICE);
540 gbcore->cheatDevice->p = core;
541 }
542 return gbcore->cheatDevice;
543}
544
545static size_t _GBCoreSavedataClone(struct mCore* core, void** sram) {
546 struct GB* gb = core->board;
547 struct VFile* vf = gb->sramVf;
548 if (vf) {
549 *sram = malloc(vf->size(vf));
550 vf->seek(vf, 0, SEEK_SET);
551 return vf->read(vf, *sram, vf->size(vf));
552 }
553 *sram = malloc(gb->sramSize);
554 memcpy(*sram, gb->memory.sram, gb->sramSize);
555 return gb->sramSize;
556}
557
558static bool _GBCoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {
559 struct GB* gb = core->board;
560 if (!writeback) {
561 struct VFile* vf = VFileMemChunk(sram, size);
562 GBSavedataMask(gb, vf, true);
563 return true;
564 }
565 struct VFile* vf = gb->sramVf;
566 if (vf) {
567 vf->seek(vf, 0, SEEK_SET);
568 return vf->write(vf, sram, size) > 0;
569 }
570 if (size > 0x20000) {
571 size = 0x20000;
572 }
573 GBResizeSram(gb, size);
574 memcpy(gb->memory.sram, sram, size);
575 return true;
576}
577
578struct mCore* GBCoreCreate(void) {
579 struct GBCore* gbcore = malloc(sizeof(*gbcore));
580 struct mCore* core = &gbcore->d;
581 memset(&core->opts, 0, sizeof(core->opts));
582 core->cpu = NULL;
583 core->board = NULL;
584 core->debugger = NULL;
585 core->init = _GBCoreInit;
586 core->deinit = _GBCoreDeinit;
587 core->platform = _GBCorePlatform;
588 core->setSync = _GBCoreSetSync;
589 core->loadConfig = _GBCoreLoadConfig;
590 core->desiredVideoDimensions = _GBCoreDesiredVideoDimensions;
591 core->setVideoBuffer = _GBCoreSetVideoBuffer;
592 core->getPixels = _GBCoreGetPixels;
593 core->putPixels = _GBCorePutPixels;
594 core->getAudioChannel = _GBCoreGetAudioChannel;
595 core->setAudioBufferSize = _GBCoreSetAudioBufferSize;
596 core->getAudioBufferSize = _GBCoreGetAudioBufferSize;
597 core->setAVStream = _GBCoreSetAVStream;
598 core->setCoreCallbacks = _GBCoreSetCoreCallbacks;
599 core->isROM = GBIsROM;
600 core->loadROM = _GBCoreLoadROM;
601 core->loadBIOS = _GBCoreLoadBIOS;
602 core->loadSave = _GBCoreLoadSave;
603 core->loadTemporarySave = _GBCoreLoadTemporarySave;
604 core->loadPatch = _GBCoreLoadPatch;
605 core->unloadROM = _GBCoreUnloadROM;
606 core->checksum = _GBCoreChecksum;
607 core->reset = _GBCoreReset;
608 core->runFrame = _GBCoreRunFrame;
609 core->runLoop = _GBCoreRunLoop;
610 core->step = _GBCoreStep;
611 core->stateSize = _GBCoreStateSize;
612 core->loadState = _GBCoreLoadState;
613 core->saveState = _GBCoreSaveState;
614 core->setKeys = _GBCoreSetKeys;
615 core->addKeys = _GBCoreAddKeys;
616 core->clearKeys = _GBCoreClearKeys;
617 core->setCursorLocation = _GBCoreSetCursorLocation;
618 core->setCursorDown = _GBCoreSetCursorDown;
619 core->frameCounter = _GBCoreFrameCounter;
620 core->frameCycles = _GBCoreFrameCycles;
621 core->frequency = _GBCoreFrequency;
622 core->getGameTitle = _GBCoreGetGameTitle;
623 core->getGameCode = _GBCoreGetGameCode;
624 core->setRTC = _GBCoreSetRTC;
625 core->setRotation = _GBCoreSetRotation;
626 core->setRumble = _GBCoreSetRumble;
627 core->busRead8 = _GBCoreBusRead8;
628 core->busRead16 = _GBCoreBusRead16;
629 core->busRead32 = _GBCoreBusRead32;
630 core->busWrite8 = _GBCoreBusWrite8;
631 core->busWrite16 = _GBCoreBusWrite16;
632 core->busWrite32 = _GBCoreBusWrite32;
633 core->rawRead8 = _GBCoreRawRead8;
634 core->rawRead16 = _GBCoreRawRead16;
635 core->rawRead32 = _GBCoreRawRead32;
636 core->rawWrite8 = _GBCoreRawWrite8;
637 core->rawWrite16 = _GBCoreRawWrite16;
638 core->rawWrite32 = _GBCoreRawWrite32;
639#ifdef USE_DEBUGGERS
640 core->supportsDebuggerType = _GBCoreSupportsDebuggerType;
641 core->debuggerPlatform = _GBCoreDebuggerPlatform;
642 core->cliDebuggerSystem = _GBCoreCliDebuggerSystem;
643 core->attachDebugger = _GBCoreAttachDebugger;
644 core->detachDebugger = _GBCoreDetachDebugger;
645#endif
646 core->cheatDevice = _GBCoreCheatDevice;
647 core->savedataClone = _GBCoreSavedataClone;
648 core->savedataRestore = _GBCoreSavedataRestore;
649 return core;
650}