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