Core: Add mCoreCreate function for making a core based on platform type
Vicki Pfau vi@endrift.com
Thu, 14 Jan 2021 00:06:59 -0800
2 files changed,
14 insertions(+),
0 deletions(-)
M
include/mgba/core/core.h
→
include/mgba/core/core.h
@@ -186,6 +186,7 @@ #endif
struct mCore* mCoreFindVF(struct VFile* vf); enum mPlatform mCoreIsCompatible(struct VFile* vf); +struct mCore* mCoreCreate(enum mPlatform); bool mCoreSaveStateNamed(struct mCore* core, struct VFile* vf, int flags); bool mCoreLoadStateNamed(struct mCore* core, struct VFile* vf, int flags);
M
src/core/core.c
→
src/core/core.c
@@ -73,6 +73,19 @@ }
return mPLATFORM_NONE; } +struct mCore* mCoreCreate(enum mPlatform platform) { + const struct mCoreFilter* filter; + for (filter = &_filters[0]; filter->filter; ++filter) { + if (filter->platform == platform) { + break; + } + } + if (filter->open) { + return filter->open(); + } + return NULL; +} + #if !defined(MINIMAL_CORE) || MINIMAL_CORE < 2 #include <mgba-util/png-io.h>