mirror of https://github.com/mgba-emu/mgba.git
Core: Minor preparatory work
This commit is contained in:
parent
2eaaaa8491
commit
fc905657ad
|
@ -113,9 +113,13 @@ void mCoreLoadConfig(struct mCore* core) {
|
||||||
#ifndef MINIMAL_CORE
|
#ifndef MINIMAL_CORE
|
||||||
mCoreConfigLoad(&core->config);
|
mCoreConfigLoad(&core->config);
|
||||||
#endif
|
#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
|
#ifndef MINIMAL_CORE
|
||||||
mDirectorySetMapOptions(&core->dirs, &core->opts);
|
mDirectorySetMapOptions(&core->dirs, &core->opts);
|
||||||
#endif
|
#endif
|
||||||
core->loadConfig(core);
|
core->loadConfig(core, config);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ struct mCore {
|
||||||
void (*deinit)(struct mCore*);
|
void (*deinit)(struct mCore*);
|
||||||
|
|
||||||
void (*setSync)(struct mCore*, struct mCoreSync*);
|
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 (*desiredVideoDimensions)(struct mCore*, unsigned* width, unsigned* height);
|
||||||
void (*setVideoBuffer)(struct mCore*, color_t* buffer, size_t stride);
|
void (*setVideoBuffer)(struct mCore*, color_t* buffer, size_t stride);
|
||||||
|
@ -46,6 +46,8 @@ struct mCore {
|
||||||
|
|
||||||
struct blip_t* (*getAudioChannel)(struct mCore*, int ch);
|
struct blip_t* (*getAudioChannel)(struct mCore*, int ch);
|
||||||
|
|
||||||
|
void (*setAVStream)(struct mCore*, struct mAVStream*);
|
||||||
|
|
||||||
bool (*isROM)(struct VFile* vf);
|
bool (*isROM)(struct VFile* vf);
|
||||||
bool (*loadROM)(struct mCore*, struct VFile* vf);
|
bool (*loadROM)(struct mCore*, struct VFile* vf);
|
||||||
bool (*loadSave)(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 mCoreInitConfig(struct mCore* core, const char* port);
|
||||||
void mCoreLoadConfig(struct mCore* core);
|
void mCoreLoadConfig(struct mCore* core);
|
||||||
|
void mCoreLoadForeignConfig(struct mCore* core, const struct mCoreConfig* config);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -60,8 +60,9 @@ static void _GBCoreSetSync(struct mCore* core, struct mCoreSync* sync) {
|
||||||
gb->sync = sync;
|
gb->sync = sync;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _GBCoreLoadConfig(struct mCore* core) {
|
static void _GBCoreLoadConfig(struct mCore* core, const struct mCoreConfig* config) {
|
||||||
UNUSED(core);
|
UNUSED(core);
|
||||||
|
UNUSED(config);
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ struct GBACore {
|
||||||
struct GBAVideoSoftwareRenderer renderer;
|
struct GBAVideoSoftwareRenderer renderer;
|
||||||
int keys;
|
int keys;
|
||||||
struct mCPUComponent* components[GBA_COMPONENT_MAX];
|
struct mCPUComponent* components[GBA_COMPONENT_MAX];
|
||||||
|
struct Configuration* overrides;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool _GBACoreInit(struct mCore* core) {
|
static bool _GBACoreInit(struct mCore* core) {
|
||||||
|
@ -34,6 +35,7 @@ static bool _GBACoreInit(struct mCore* core) {
|
||||||
}
|
}
|
||||||
core->cpu = cpu;
|
core->cpu = cpu;
|
||||||
core->board = gba;
|
core->board = gba;
|
||||||
|
gbacore->overrides = 0;
|
||||||
|
|
||||||
GBACreate(gba);
|
GBACreate(gba);
|
||||||
// TODO: Restore debugger and cheats
|
// TODO: Restore debugger and cheats
|
||||||
|
@ -67,10 +69,13 @@ static void _GBACoreSetSync(struct mCore* core, struct mCoreSync* sync) {
|
||||||
gba->sync = 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;
|
struct GBA* gba = core->board;
|
||||||
|
|
||||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
||||||
|
struct GBACore* gbacore = (struct GBACore*) core;
|
||||||
|
gbacore->overrides = mCoreConfigGetOverrides(&core->config);
|
||||||
|
|
||||||
struct VFile* bios = 0;
|
struct VFile* bios = 0;
|
||||||
if (core->opts.useBios) {
|
if (core->opts.useBios) {
|
||||||
bios = VFileOpen(core->opts.bios, O_RDONLY);
|
bios = VFileOpen(core->opts.bios, O_RDONLY);
|
||||||
|
@ -80,7 +85,7 @@ static void _GBACoreLoadConfig(struct mCore* core) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const char* idleOptimization = mCoreConfigGetValue(&core->config, "idleOptimization");
|
const char* idleOptimization = mCoreConfigGetValue(config, "idleOptimization");
|
||||||
if (idleOptimization) {
|
if (idleOptimization) {
|
||||||
if (strcasecmp(idleOptimization, "ignore") == 0) {
|
if (strcasecmp(idleOptimization, "ignore") == 0) {
|
||||||
gba->idleOptimization = IDLE_LOOP_IGNORE;
|
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) {
|
static bool _GBACoreLoadROM(struct mCore* core, struct VFile* vf) {
|
||||||
return GBALoadROM2(core->board, vf);
|
return GBALoadROM2(core->board, vf);
|
||||||
}
|
}
|
||||||
|
@ -169,11 +179,7 @@ static void _GBACoreReset(struct mCore* core) {
|
||||||
struct GBACartridgeOverride override;
|
struct GBACartridgeOverride override;
|
||||||
const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom;
|
const struct GBACartridge* cart = (const struct GBACartridge*) gba->memory.rom;
|
||||||
memcpy(override.id, &cart->id, sizeof(override.id));
|
memcpy(override.id, &cart->id, sizeof(override.id));
|
||||||
struct Configuration* overrides = 0;
|
if (GBAOverrideFind(gbacore->overrides, &override)) {
|
||||||
#if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2
|
|
||||||
overrides = mCoreConfigGetOverrides(&core->config);
|
|
||||||
#endif
|
|
||||||
if (GBAOverrideFind(overrides, &override)) {
|
|
||||||
GBAOverrideApply(gba, &override);
|
GBAOverrideApply(gba, &override);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,6 +257,7 @@ struct mCore* GBACoreCreate(void) {
|
||||||
core->setVideoBuffer = _GBACoreSetVideoBuffer;
|
core->setVideoBuffer = _GBACoreSetVideoBuffer;
|
||||||
core->getVideoBuffer = _GBACoreGetVideoBuffer;
|
core->getVideoBuffer = _GBACoreGetVideoBuffer;
|
||||||
core->getAudioChannel = _GBACoreGetAudioChannel;
|
core->getAudioChannel = _GBACoreGetAudioChannel;
|
||||||
|
core->setAVStream = _GBACoreSetAVStream;
|
||||||
core->isROM = GBAIsROM;
|
core->isROM = GBAIsROM;
|
||||||
core->loadROM = _GBACoreLoadROM;
|
core->loadROM = _GBACoreLoadROM;
|
||||||
core->loadBIOS = _GBACoreLoadBIOS;
|
core->loadBIOS = _GBACoreLoadBIOS;
|
||||||
|
|
Loading…
Reference in New Issue