implemented emu_framecount, scrapped python lib struct

This commit is contained in:
gfp34 2022-10-12 03:04:53 -04:00
parent e01f0977cb
commit 974601ae71
2 changed files with 9 additions and 13 deletions

View File

@ -1,5 +1,5 @@
import emu
while True:
print("PY: Frame")
print(f"PY: Frame {emu.framecount()}")
emu.frameadvance()

View File

@ -3,13 +3,14 @@
#include <mutex>
#include <condition_variable>
#include <iostream>
#include <functional>
#include <pybind11/embed.h>
namespace py = pybind11;
#include "fceupython.h"
#include "movie.h"
// Are we running any code right now?
static char* pythonScriptName = NULL;
bool pythonRunning = false;
@ -24,11 +25,6 @@ std::mutex mtx;
std::condition_variable cv;
typedef struct pythonL_Reg {
const char* name;
void (*func)();
} pythonL_Reg;
static void emu_frameadvance()
{
// Can't call if a frameAdvance is already waiting
@ -46,15 +42,15 @@ static void emu_frameadvance()
cv.wait(lock, [] { return bool(inFrameBoundry); });
}
static const struct pythonL_Reg emulib [] = {
{"frameadvance", &emu_frameadvance}
};
static int emu_framecount()
{
return FCEUMOV_GetFrame();
}
PYBIND11_EMBEDDED_MODULE(emu, m)
{
for (pythonL_Reg libReg : emulib) {
m.def(libReg.name, libReg.func);
}
m.def("frameadvance", emu_frameadvance);
m.def("framecount", emu_framecount);
}
void FCEU_PythonFrameBoundary()