Adding src/main example.

This commit is contained in:
sergiotarxz 2023-02-02 16:55:37 +01:00
commit 06ca4c695c

30
src/main.c Normal file
View File

@ -0,0 +1,30 @@
#include <libgen.h>
#include <stdio.h>
#include <mgba/core/core.h>
#include <mgba-util/vfs.h>
struct controller {
struct mCoreThread *thread;
color_t *videoOutputBuffer;
};
int main() {
unsigned width, height;
char *file = "/home/sergio/ruby.gba";
struct mCore* core = mCoreFind(file);
core->init(core);
core->desiredVideoDimensions(core, &width, &height);
ssize_t bufferSize = (width * height) * BYTES_PER_PIXEL;
color_t* videoOutputBuffer = calloc(width * height, bufferSize);
core->setVideoBuffer(core, videoOutputBuffer, width);
mCoreLoadFile(core, file);
mCoreInitConfig(core, NULL);
mCoreConfigSetDefaultValue(&core->config, "idleOptimization", "detect");
mCoreLoadConfig(core);
core->reset(core);
for (int i = 0; i < 50; i++) {
core->runFrame(core);
}
mCoreTakeScreenshot(core);
}