Core: Minor preparatory work
Jeffrey Pfau jeffrey@endrift.com
Sun, 07 Feb 2016 20:07:08 -0800
4 files changed,
26 insertions(+),
11 deletions(-)
M
src/core/core.c
→
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); }
M
src/core/core.h
→
src/core/core.h
@@ -38,13 +38,15 @@ bool (*init)(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); void (*getVideoBuffer)(struct mCore*, color_t** buffer, size_t* stride); 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);@@ -91,5 +93,6 @@ #endif
void mCoreInitConfig(struct mCore* core, const char* port); void mCoreLoadConfig(struct mCore* core); +void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config); #endif
M
src/gb/core.c
→
src/gb/core.c
@@ -60,8 +60,9 @@ struct GB* gb = core->board;
gb->sync = sync; } -static void _GBCoreLoadConfig(struct mCore* core) { +static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) { UNUSED(core); + UNUSED(config); // TODO }
M
src/gba/core.c
→
src/gba/core.c
@@ -20,6 +20,7 @@ struct mCore d;
struct GBAVideoSoftwareRenderer renderer; int keys; struct mCPUComponent* components[GBA_COMPONENT_MAX]; + struct Configuration* overrides; }; static bool _GBACoreInit(struct mCore* core) {@@ -34,6 +35,7 @@ return false;
} core->cpu = cpu; core->board = gba; + gbacore->overrides = 0; GBACreate(gba); // TODO: Restore debugger and cheats@@ -67,10 +69,13 @@ struct GBA* gba = core->board;
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 @@ GBALoadBIOS(gba, bios);
} #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 @@ return NULL;
} } +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 @@
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 @@ core->desiredVideoDimensions = _GBACoreDesiredVideoDimensions;
core->setVideoBuffer = _GBACoreSetVideoBuffer; core->getVideoBuffer = _GBACoreGetVideoBuffer; core->getAudioChannel = _GBACoreGetAudioChannel; + core->setAVStream = _GBACoreSetAVStream; core->isROM = GBAIsROM; core->loadROM = _GBACoreLoadROM; core->loadBIOS = _GBACoreLoadBIOS;