From ca3050d76be99f4d635f4c45d790a199befc2f6c Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Thu, 14 Jan 2021 00:06:59 -0800 Subject: [PATCH] Core: Add mCoreCreate function for making a core based on platform type --- include/mgba/core/core.h | 1 + src/core/core.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/mgba/core/core.h b/include/mgba/core/core.h index fcd302279..3475c393d 100644 --- a/include/mgba/core/core.h +++ b/include/mgba/core/core.h @@ -186,6 +186,7 @@ void mCoreTakeScreenshot(struct mCore* core); 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); diff --git a/src/core/core.c b/src/core/core.c index 082d547e2..fb706eb02 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -73,6 +73,19 @@ enum mPlatform mCoreIsCompatible(struct VFile* vf) { 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