WiiDuktape/source/quickjs/quickjs_engine.c

35 lines
919 B
C
Raw Normal View History

#include <quickjs.h>
#include <ogc/lwp_watchdog.h>
#include <quickjs_engine.h>
#include <microsecond.h>
#include <wii_qjs.h>
static float deltatime = 1.0f/60;
static unsigned int green = RGBA(0, 255, 0, 255);
static GRRLIB_ttfFont * font;
void quickjs(GRRLIB_ttfFont * global_font, bool * running) {
font = global_font;
JSRuntime * rt = JS_NewRuntime();
JSContext * ctx = JS_NewContext(rt);
JSValue wii_obj = qjs_define_wii_object(ctx, font, running, &deltatime);
JSValue global_obj = JS_GetGlobalObject(ctx);
JS_SetPropertyStr(ctx, global_obj, "wii", wii_obj);
while (*running) {
const unsigned int beginningOfFrame = ticks_to_microsecs(gettime());
PAD_ScanPads();
// fun
JS_Eval(ctx, "wii.print('hi')", strlen("wii.print('hi')"), "file", 0);
GRRLIB_Render();
const unsigned int endOfFrame = ticks_to_microsecs(gettime());
deltatime = (endOfFrame - beginningOfFrame) * MICROSECOND;
}
}