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;
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 bios = VFileOpen(configPath, O_RDONLY);
287 if (bios && GBIsBIOS(bios)) {
288 found = true;
289 } else if (bios) {
290 bios->close(bios);
291 bios = NULL;
292 }
293 }
294 if (!found) {
295 char path[PATH_MAX];
296 mCoreConfigDirectory(path, PATH_MAX);
297 switch (gb->model) {
298 case GB_MODEL_DMG:
299 case GB_MODEL_SGB: // TODO
300 strncat(path, PATH_SEP "gb_bios.bin", PATH_MAX - strlen(path));
301 break;
302 case GB_MODEL_CGB:
303 case GB_MODEL_AGB:
304 strncat(path, PATH_SEP "gbc_bios.bin", PATH_MAX - strlen(path));
305 break;
306 default:
307 break;
308 };
309 bios = VFileOpen(path, O_RDONLY);
310 if (bios && GBIsBIOS(bios)) {
311 found = true;
312 } else if (bios) {
313 bios->close(bios);
314 bios = NULL;
315 }
316 }
317 if (bios) {
318 GBLoadBIOS(gb, bios);
319 }
320 }
321#endif
322
323 LR35902Reset(core->cpu);
324}
325
326static void _GBCoreRunFrame(struct mCore* core) {
327 struct GB* gb = core->board;
328 int32_t frameCounter = gb->video.frameCounter;
329 while (gb->video.frameCounter == frameCounter) {
330 LR35902Run(core->cpu);
331 }
332}
333
334static void _GBCoreRunLoop(struct mCore* core) {
335 LR35902Run(core->cpu);
336}
337
338static void _GBCoreStep(struct mCore* core) {
339 struct LR35902Core* cpu = core->cpu;
340 do {
341 LR35902Tick(cpu);
342 } while (cpu->executionState != LR35902_CORE_FETCH);
343}
344
345static size_t _GBCoreStateSize(struct mCore* core) {
346 UNUSED(core);
347 return sizeof(struct GBSerializedState);
348}
349
350static bool _GBCoreLoadState(struct mCore* core, const void* state) {
351 return GBDeserialize(core->board, state);
352}
353
354static bool _GBCoreSaveState(struct mCore* core, void* state) {
355 struct LR35902Core* cpu = core->cpu;
356 while (cpu->executionState != LR35902_CORE_FETCH) {
357 LR35902Tick(cpu);
358 }
359 GBSerialize(core->board, state);
360 return true;
361}
362
363static void _GBCoreSetKeys(struct mCore* core, uint32_t keys) {
364 struct GBCore* gbcore = (struct GBCore*) core;
365 gbcore->keys = keys;
366}
367
368static void _GBCoreAddKeys(struct mCore* core, uint32_t keys) {
369 struct GBCore* gbcore = (struct GBCore*) core;
370 gbcore->keys |= keys;
371}
372
373static void _GBCoreClearKeys(struct mCore* core, uint32_t keys) {
374 struct GBCore* gbcore = (struct GBCore*) core;
375 gbcore->keys &= ~keys;
376}
377
378static void _GBCoreSetCursorLocation(struct mCore* core, int x, int y) {
379 UNUSED(core);
380 UNUSED(x);
381 UNUSED(y);
382}
383
384static void _GBCoreSetCursorDown(struct mCore* core, bool down) {
385 UNUSED(core);
386 UNUSED(down);
387}
388
389static int32_t _GBCoreFrameCounter(const struct mCore* core) {
390 const struct GB* gb = core->board;
391 return gb->video.frameCounter;
392}
393
394static int32_t _GBCoreFrameCycles(const struct mCore* core) {
395 UNUSED(core);
396 return GB_VIDEO_TOTAL_LENGTH;
397}
398
399static int32_t _GBCoreFrequency(const struct mCore* core) {
400 UNUSED(core);
401 // TODO: GB differences
402 return DMG_LR35902_FREQUENCY;
403}
404
405static void _GBCoreGetGameTitle(const struct mCore* core, char* title) {
406 GBGetGameTitle(core->board, title);
407}
408
409static void _GBCoreGetGameCode(const struct mCore* core, char* title) {
410 GBGetGameCode(core->board, title);
411}
412
413static void _GBCoreSetRotation(struct mCore* core, struct mRotationSource* rotation) {
414 struct GB* gb = core->board;
415 gb->memory.rotation = rotation;
416}
417
418static void _GBCoreSetRumble(struct mCore* core, struct mRumble* rumble) {
419 struct GB* gb = core->board;
420 gb->memory.rumble = rumble;
421}
422
423static uint32_t _GBCoreBusRead8(struct mCore* core, uint32_t address) {
424 struct LR35902Core* cpu = core->cpu;
425 return cpu->memory.load8(cpu, address);
426}
427
428static uint32_t _GBCoreBusRead16(struct mCore* core, uint32_t address) {
429 struct LR35902Core* cpu = core->cpu;
430 return cpu->memory.load8(cpu, address) | (cpu->memory.load8(cpu, address + 1) << 8);
431}
432
433static uint32_t _GBCoreBusRead32(struct mCore* core, uint32_t address) {
434 struct LR35902Core* cpu = core->cpu;
435 return cpu->memory.load8(cpu, address) | (cpu->memory.load8(cpu, address + 1) << 8) |
436 (cpu->memory.load8(cpu, address + 2) << 16) | (cpu->memory.load8(cpu, address + 3) << 24);
437}
438
439static void _GBCoreBusWrite8(struct mCore* core, uint32_t address, uint8_t value) {
440 struct LR35902Core* cpu = core->cpu;
441 cpu->memory.store8(cpu, address, value);
442}
443
444static void _GBCoreBusWrite16(struct mCore* core, uint32_t address, uint16_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}
449
450static void _GBCoreBusWrite32(struct mCore* core, uint32_t address, uint32_t value) {
451 struct LR35902Core* cpu = core->cpu;
452 cpu->memory.store8(cpu, address, value);
453 cpu->memory.store8(cpu, address + 1, value >> 8);
454 cpu->memory.store8(cpu, address + 2, value >> 16);
455 cpu->memory.store8(cpu, address + 3, value >> 24);
456}
457
458static uint32_t _GBCoreRawRead8(struct mCore* core, uint32_t address, int segment) {
459 struct LR35902Core* cpu = core->cpu;
460 return GBView8(cpu, address, segment);
461}
462
463static uint32_t _GBCoreRawRead16(struct mCore* core, uint32_t address, int segment) {
464 struct LR35902Core* cpu = core->cpu;
465 return GBView8(cpu, address, segment) | (GBView8(cpu, address + 1, segment) << 8);
466}
467
468static uint32_t _GBCoreRawRead32(struct mCore* core, uint32_t address, int segment) {
469 struct LR35902Core* cpu = core->cpu;
470 return GBView8(cpu, address, segment) | (GBView8(cpu, address + 1, segment) << 8) |
471 (GBView8(cpu, address + 2, segment) << 16) | (GBView8(cpu, address + 3, segment) << 24);
472}
473
474static void _GBCoreRawWrite8(struct mCore* core, uint32_t address, int segment, uint8_t value) {
475 struct LR35902Core* cpu = core->cpu;
476 GBPatch8(cpu, address, value, NULL, segment);
477}
478
479static void _GBCoreRawWrite16(struct mCore* core, uint32_t address, int segment, uint16_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}
484
485static void _GBCoreRawWrite32(struct mCore* core, uint32_t address, int segment, uint32_t value) {
486 struct LR35902Core* cpu = core->cpu;
487 GBPatch8(cpu, address, value, NULL, segment);
488 GBPatch8(cpu, address + 1, value >> 8, NULL, segment);
489 GBPatch8(cpu, address + 2, value >> 16, NULL, segment);
490 GBPatch8(cpu, address + 3, value >> 24, NULL, segment);
491}
492
493#ifdef USE_DEBUGGERS
494static bool _GBCoreSupportsDebuggerType(struct mCore* core, enum mDebuggerType type) {
495 UNUSED(core);
496 switch (type) {
497 case DEBUGGER_CLI:
498 return true;
499 default:
500 return false;
501 }
502}
503
504static struct mDebuggerPlatform* _GBCoreDebuggerPlatform(struct mCore* core) {
505 struct GBCore* gbcore = (struct GBCore*) core;
506 if (!gbcore->debuggerPlatform) {
507 gbcore->debuggerPlatform = LR35902DebuggerPlatformCreate();
508 }
509 return gbcore->debuggerPlatform;
510}
511
512static struct CLIDebuggerSystem* _GBCoreCliDebuggerSystem(struct mCore* core) {
513 return GBCLIDebuggerCreate(core);
514}
515
516static void _GBCoreAttachDebugger(struct mCore* core, struct mDebugger* debugger) {
517 struct LR35902Core* cpu = core->cpu;
518 if (core->debugger) {
519 LR35902HotplugDetach(cpu, CPU_COMPONENT_DEBUGGER);
520 }
521 cpu->components[CPU_COMPONENT_DEBUGGER] = &debugger->d;
522 LR35902HotplugAttach(cpu, CPU_COMPONENT_DEBUGGER);
523 core->debugger = debugger;
524}
525
526static void _GBCoreDetachDebugger(struct mCore* core) {
527 struct LR35902Core* cpu = core->cpu;
528 if (core->debugger) {
529 LR35902HotplugDetach(cpu, CPU_COMPONENT_DEBUGGER);
530 }
531 cpu->components[CPU_COMPONENT_DEBUGGER] = NULL;
532 core->debugger = NULL;
533}
534#endif
535
536static struct mCheatDevice* _GBCoreCheatDevice(struct mCore* core) {
537 struct GBCore* gbcore = (struct GBCore*) core;
538 if (!gbcore->cheatDevice) {
539 gbcore->cheatDevice = GBCheatDeviceCreate();
540 ((struct LR35902Core*) core->cpu)->components[CPU_COMPONENT_CHEAT_DEVICE] = &gbcore->cheatDevice->d;
541 LR35902HotplugAttach(core->cpu, CPU_COMPONENT_CHEAT_DEVICE);
542 gbcore->cheatDevice->p = core;
543 }
544 return gbcore->cheatDevice;
545}
546
547static size_t _GBCoreSavedataClone(struct mCore* core, void** sram) {
548 struct GB* gb = core->board;
549 struct VFile* vf = gb->sramVf;
550 if (vf) {
551 *sram = malloc(vf->size(vf));
552 vf->seek(vf, 0, SEEK_SET);
553 return vf->read(vf, *sram, vf->size(vf));
554 }
555 *sram = malloc(gb->sramSize);
556 memcpy(*sram, gb->memory.sram, gb->sramSize);
557 return gb->sramSize;
558}
559
560static bool _GBCoreSavedataRestore(struct mCore* core, const void* sram, size_t size, bool writeback) {
561 struct GB* gb = core->board;
562 if (!writeback) {
563 struct VFile* vf = VFileMemChunk(sram, size);
564 GBSavedataMask(gb, vf, true);
565 return true;
566 }
567 struct VFile* vf = gb->sramVf;
568 if (vf) {
569 vf->seek(vf, 0, SEEK_SET);
570 return vf->write(vf, sram, size) > 0;
571 }
572 if (size > 0x20000) {
573 size = 0x20000;
574 }
575 GBResizeSram(gb, size);
576 memcpy(gb->memory.sram, sram, size);
577 return true;
578}
579
580struct mCore* GBCoreCreate(void) {
581 struct GBCore* gbcore = malloc(sizeof(*gbcore));
582 struct mCore* core = &gbcore->d;
583 memset(&core->opts, 0, sizeof(core->opts));
584 core->cpu = NULL;
585 core->board = NULL;
586 core->debugger = NULL;
587 core->init = _GBCoreInit;
588 core->deinit = _GBCoreDeinit;
589 core->platform = _GBCorePlatform;
590 core->setSync = _GBCoreSetSync;
591 core->loadConfig = _GBCoreLoadConfig;
592 core->desiredVideoDimensions = _GBCoreDesiredVideoDimensions;
593 core->setVideoBuffer = _GBCoreSetVideoBuffer;
594 core->getPixels = _GBCoreGetPixels;
595 core->putPixels = _GBCorePutPixels;
596 core->getAudioChannel = _GBCoreGetAudioChannel;
597 core->setAudioBufferSize = _GBCoreSetAudioBufferSize;
598 core->getAudioBufferSize = _GBCoreGetAudioBufferSize;
599 core->setAVStream = _GBCoreSetAVStream;
600 core->addCoreCallbacks = _GBCoreAddCoreCallbacks;
601 core->clearCoreCallbacks = _GBCoreClearCoreCallbacks;
602 core->isROM = GBIsROM;
603 core->loadROM = _GBCoreLoadROM;
604 core->loadBIOS = _GBCoreLoadBIOS;
605 core->loadSave = _GBCoreLoadSave;
606 core->loadTemporarySave = _GBCoreLoadTemporarySave;
607 core->loadPatch = _GBCoreLoadPatch;
608 core->unloadROM = _GBCoreUnloadROM;
609 core->checksum = _GBCoreChecksum;
610 core->reset = _GBCoreReset;
611 core->runFrame = _GBCoreRunFrame;
612 core->runLoop = _GBCoreRunLoop;
613 core->step = _GBCoreStep;
614 core->stateSize = _GBCoreStateSize;
615 core->loadState = _GBCoreLoadState;
616 core->saveState = _GBCoreSaveState;
617 core->setKeys = _GBCoreSetKeys;
618 core->addKeys = _GBCoreAddKeys;
619 core->clearKeys = _GBCoreClearKeys;
620 core->setCursorLocation = _GBCoreSetCursorLocation;
621 core->setCursorDown = _GBCoreSetCursorDown;
622 core->frameCounter = _GBCoreFrameCounter;
623 core->frameCycles = _GBCoreFrameCycles;
624 core->frequency = _GBCoreFrequency;
625 core->getGameTitle = _GBCoreGetGameTitle;
626 core->getGameCode = _GBCoreGetGameCode;
627 core->setRotation = _GBCoreSetRotation;
628 core->setRumble = _GBCoreSetRumble;
629 core->busRead8 = _GBCoreBusRead8;
630 core->busRead16 = _GBCoreBusRead16;
631 core->busRead32 = _GBCoreBusRead32;
632 core->busWrite8 = _GBCoreBusWrite8;
633 core->busWrite16 = _GBCoreBusWrite16;
634 core->busWrite32 = _GBCoreBusWrite32;
635 core->rawRead8 = _GBCoreRawRead8;
636 core->rawRead16 = _GBCoreRawRead16;
637 core->rawRead32 = _GBCoreRawRead32;
638 core->rawWrite8 = _GBCoreRawWrite8;
639 core->rawWrite16 = _GBCoreRawWrite16;
640 core->rawWrite32 = _GBCoreRawWrite32;
641#ifdef USE_DEBUGGERS
642 core->supportsDebuggerType = _GBCoreSupportsDebuggerType;
643 core->debuggerPlatform = _GBCoreDebuggerPlatform;
644 core->cliDebuggerSystem = _GBCoreCliDebuggerSystem;
645 core->attachDebugger = _GBCoreAttachDebugger;
646 core->detachDebugger = _GBCoreDetachDebugger;
647#endif
648 core->cheatDevice = _GBCoreCheatDevice;
649 core->savedataClone = _GBCoreSavedataClone;
650 core->savedataRestore = _GBCoreSavedataRestore;
651 return core;
652}