Core: Add mVideoLogIsCompatible function

This commit is contained in:
Vicki Pfau 2020-06-23 22:59:00 -07:00
parent 386b788956
commit b8e9f50c92
2 changed files with 23 additions and 2 deletions

View File

@ -10,6 +10,8 @@
CXX_GUARD_START
#include <mgba/core/core.h>
#include <mgba-util/circle-buffer.h>
#define mVL_MAX_CHANNELS 32
@ -128,6 +130,7 @@ void mVideoLoggerInjectVideoRegister(struct mVideoLogger* logger, uint32_t addre
void mVideoLoggerInjectPalette(struct mVideoLogger* logger, uint32_t address, uint16_t value);
void mVideoLoggerInjectOAM(struct mVideoLogger* logger, uint32_t address, uint16_t value);
enum mPlatform mVideoLogIsCompatible(struct VFile*);
struct mCore* mVideoLogCoreFind(struct VFile*);
CXX_GUARD_END

View File

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include <mgba/feature/video-logger.h>
#include <mgba/core/core.h>
#include <mgba-util/memory.h>
#include <mgba-util/vfs.h>
#include <mgba-util/math.h>
@ -1033,7 +1032,7 @@ static ssize_t mVideoLoggerWriteChannel(struct mVideoLogChannel* channel, const
return read;
}
struct mCore* mVideoLogCoreFind(struct VFile* vf) {
static const struct mVLDescriptor* _mVideoLogDescriptor(struct VFile* vf) {
if (!vf) {
return NULL;
}
@ -1055,6 +1054,25 @@ struct mCore* mVideoLogCoreFind(struct VFile* vf) {
break;
}
}
if (descriptor->platform == PLATFORM_NONE) {
return NULL;
}
return descriptor;
}
enum mPlatform mVideoLogIsCompatible(struct VFile* vf) {
const struct mVLDescriptor* descriptor = _mVideoLogDescriptor(vf);
if (descriptor) {
return descriptor->platform;
}
return PLATFORM_NONE;
}
struct mCore* mVideoLogCoreFind(struct VFile* vf) {
const struct mVLDescriptor* descriptor = _mVideoLogDescriptor(vf);
if (!descriptor) {
return NULL;
}
struct mCore* core = NULL;
if (descriptor->open) {
core = descriptor->open();