Adding src/main example.
This commit is contained in:
commit
06ca4c695c
30
src/main.c
Normal file
30
src/main.c
Normal 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);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user