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