From fc905657adeba406a2c280bbb94b09533a89e3f8 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Sun, 7 Feb 2016 20:07:08 -0800 Subject: [PATCH] Core: Minor preparatory work --- src/core/core.c | 8 ++++++-- src/core/core.h | 5 ++++- src/gb/core.c | 3 ++- src/gba/core.c | 21 ++++++++++++++------- 4 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/core/core.c b/src/core/core.c index 460997432..d4be5fd7f 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -113,9 +113,13 @@ void mCoreLoadConfig(struct mCore* core) { #ifndef MINIMAL_CORE mCoreConfigLoad(&core->config); #endif - mCoreConfigMap(&core->config, &core->opts); + mCoreLoadForeignConfig(core, &core->config); +} + +void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config) { + mCoreConfigMap(config, &core->opts); #ifndef MINIMAL_CORE mDirectorySetMapOptions(&core->dirs, &core->opts); #endif - core->loadConfig(core); + core->loadConfig(core, config); } diff --git a/src/core/core.h b/src/core/core.h index 987482b22..891918daf 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -38,7 +38,7 @@ struct mCore { void (*deinit)(struct mCore*); void (*setSync)(struct mCore*, struct mCoreSync*); - void (*loadConfig)(struct mCore*); + void (*loadConfig)(struct mCore*, const struct mCoreConfig*); void (*desiredVideoDimensions)(struct mCore*, unsigned* width, unsigned* height); void (*setVideoBuffer)(struct mCore*, color_t* buffer, size_t stride); @@ -46,6 +46,8 @@ struct mCore { struct blip_t* (*getAudioChannel)(struct mCore*, int ch); + void (*setAVStream)(struct mCore*, struct mAVStream*); + bool (*isROM)(struct VFile* vf); bool (*loadROM)(struct mCore*, struct VFile* vf); bool (*loadSave)(struct mCore*, struct VFile* vf); @@ -91,5 +93,6 @@ void mCoreTakeScreenshot(struct mCore* core); void mCoreInitConfig(struct mCore* core, const char* port); void mCoreLoadConfig(struct mCore* core); +void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config); #endif diff --git a/src/gb/core.c b/src/gb/core.c index b38f74e89..07af91ce8 100644 --- a/src/gb/core.c +++ b/src/gb/core.c @@ -60,8 +60,9 @@ static void _GBCoreSetSync(struct mCore* core, struct mCoreSync* sync) { gb->sync = sync; } -static void _GBCoreLoadConfig(struct mCore* core) { +static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) { UNUSED(core); + UNUSED(config); // TODO } diff --git a/src/gba/core.c b/src/gba/core.c index aed881f5a..ea0d349aa 100644 --- a/src/gba/core.c +++ b/src/gba/core.c @@ -20,6 +20,7 @@ struct GBACore { struct GBAVideoSoftwareRenderer renderer; int keys; struct mCPUComponent* components[GBA_COMPONENT_MAX]; + struct Configuration* overrides; }; static bool _GBACoreInit(struct mCore* core) { @@ -34,6 +35,7 @@ static bool _GBACoreInit(struct mCore* core) { } core->cpu = cpu; core->board = gba; + gbacore->overrides = 0; GBACreate(gba); // TODO: Restore debugger and cheats @@ -67,10 +69,13 @@ static void _GBACoreSetSync(struct mCore* core, struct mCoreSync* sync) { gba->sync = sync; } -static void _GBACoreLoadConfig(struct mCore* core) { +static void _GBACoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) { struct GBA* gba = core->board; #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 + struct GBACore* gbacore = (struct GBACore*) core; + gbacore->overrides = mCoreConfigGetOverrides(&core->config); + struct VFile* bios = 0; if (core->opts.useBios) { bios = VFileOpen(core->opts.bios, O_RDONLY); @@ -80,7 +85,7 @@ static void _GBACoreLoadConfig(struct mCore* core) { } #endif - const char* idleOptimization = mCoreConfigGetValue(&core->config, "idleOptimization"); + const char* idleOptimization = mCoreConfigGetValue(config, "idleOptimization"); if (idleOptimization) { if (strcasecmp(idleOptimization, "ignore") == 0) { gba->idleOptimization = IDLE_LOOP_IGNORE; @@ -122,6 +127,11 @@ static struct blip_t* _GBACoreGetAudioChannel(struct mCore* core, int ch) { } } +static void _GBACoreSetAVStream(struct mCore* core, struct mAVStream* stream) { + struct GBA* gba = core->board; + gba->stream = stream; +} + static bool _GBACoreLoadROM(struct mCore* core, struct VFile* vf) { return GBALoadROM2(core->board, vf); } @@ -169,11 +179,7 @@ static void _GBACoreReset(struct mCore* core) { struct GBACartridgeOverride override; const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom; memcpy(override.id, &cart->id, sizeof(override.id)); - struct Configuration* overrides = 0; -#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 - overrides = mCoreConfigGetOverrides(&core->config); -#endif - if (GBAOverrideFind(overrides, &override)) { + if (GBAOverrideFind(gbacore->overrides, &override)) { GBAOverrideApply(gba, &override); } } @@ -251,6 +257,7 @@ struct mCore* GBACoreCreate(void) { core->setVideoBuffer = _GBACoreSetVideoBuffer; core->getVideoBuffer = _GBACoreGetVideoBuffer; core->getAudioChannel = _GBACoreGetAudioChannel; + core->setAVStream = _GBACoreSetAVStream; core->isROM = GBAIsROM; core->loadROM = _GBACoreLoadROM; core->loadBIOS = _GBACoreLoadBIOS;