Compiles and working

This commit is contained in:
John Alanbrook 2023-04-19 20:16:35 +00:00
parent 86211aecb8
commit 879ab0fc05
12 changed files with 147 additions and 191 deletions

View file

@ -679,8 +679,8 @@ static cpBool handle_collision(cpArbiter *arb, int type)
cpBody *body1; cpBody *body1;
cpBody *body2; cpBody *body2;
cpArbiterGetBodies(arb, &body1, &body2); cpArbiterGetBodies(arb, &body1, &body2);
int g1 = cpBodyGetUserData(body1); int g1 = (int)cpBodyGetUserData(body1);
int g2 = cpBodyGetUserData(body2); int g2 = (int)cpBodyGetUserData(body2);
struct gameobject *go = id2go(g1); struct gameobject *go = id2go(g1);
struct gameobject *go2 = id2go(g2); struct gameobject *go2 = id2go(g2);
@ -736,7 +736,7 @@ void phys2d_rm_go_handlers(int go)
void phys2d_setup_handlers(int go) void phys2d_setup_handlers(int go)
{ {
cpCollisionHandler *handler = cpSpaceAddWildcardHandler(space, go); cpCollisionHandler *handler = cpSpaceAddWildcardHandler(space, go);
handler->userData = go; handler->userData = (void*)go;
handler->beginFunc = script_phys_cb_begin; handler->beginFunc = script_phys_cb_begin;
handler->separateFunc = script_phys_cb_separate; handler->separateFunc = script_phys_cb_separate;
} }

View file

@ -99,26 +99,26 @@ void setupmesh(struct mesh *mesh)
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), NULL); glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), NULL);
// vertex normals // vertex normals
glEnableVertexAttribArray(1); glEnableVertexAttribArray(1);
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Normal[3])); // glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Normal[3]));
// vertex texture coords // vertex texture coords
glEnableVertexAttribArray(2); glEnableVertexAttribArray(2);
glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, TexCoords[2])); // glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, TexCoords[2]));
// vertex tangent // vertex tangent
glEnableVertexAttribArray(3); glEnableVertexAttribArray(3);
glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Tangent[3])); // glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Tangent[3]));
// vertex bitangent // vertex bitangent
glEnableVertexAttribArray(4); glEnableVertexAttribArray(4);
glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Bitangent[3])); // glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, Bitangent[3]));
// Bone ids // Bone ids
glEnableVertexAttribArray(5); glEnableVertexAttribArray(5);
glVertexAttribPointer(5, 4, GL_INT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, /* glVertexAttribPointer(5, 4, GL_INT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex,
m_BoneIDs m_BoneIDs
[MAX_BONE_INFLUENCE])); [MAX_BONE_INFLUENCE]));
*/
// Weights // Weights
glEnableVertexAttribArray(6); glEnableVertexAttribArray(6);
glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, m_Weights)); // glVertexAttribPointer(6, 4, GL_FLOAT, GL_FALSE, sizeof(struct Vertex), offsetof(struct Vertex, m_Weights));
glBindVertexArray(0); glBindVertexArray(0);
} }

View file

@ -42,7 +42,7 @@
int js2int(JSValue v) int js2int(JSValue v)
{ {
int i; int32_t i;
JS_ToInt32(js,&i,v); JS_ToInt32(js,&i,v);
return i; return i;
} }
@ -63,6 +63,7 @@ JSValue float2js(double g)
{ {
return JS_NewFloat64(js,g); return JS_NewFloat64(js,g);
} }
JSValue num2js(double g) JSValue num2js(double g)
{ {
return float2js(g); return float2js(g);
@ -82,7 +83,7 @@ void *js2ptr(JSValue v)
JSValue ptr2js(void *ptr) JSValue ptr2js(void *ptr)
{ {
return JS_NewInt64(js,ptr); return JS_NewInt64(js,(long)ptr);
} }
struct timer *js2timer(JSValue v) struct timer *js2timer(JSValue v)
@ -90,20 +91,10 @@ struct timer *js2timer(JSValue v)
return id2timer(js2int(v)); return id2timer(js2int(v));
} }
struct color js2color(JSValue v)
double js_get_prop_number(JSValue v, const char *p)
{ {
struct color color; double num;
JS_ToInt64(js, &color.r, JS_GetPropertyUint32(js,v,0));
JS_ToInt64(js, &color.g, JS_GetPropertyUint32(js,v,1));
JS_ToInt64(js, &color.b, JS_GetPropertyUint32(js,v,2));
return color;
}
float js_get_prop_number(JSValue v, const char *p)
{
float num;
JS_ToFloat64(js, &num, JS_GetPropertyStr(js, v, p)); JS_ToFloat64(js, &num, JS_GetPropertyStr(js, v, p));
return num; return num;
} }
@ -118,18 +109,31 @@ struct glrect js2glrect(JSValue v)
return rect; return rect;
} }
JSValue js_arridx(JSValue v, int idx)
{
return JS_GetPropertyUint32(js,v,idx);
}
int js_arrlen(JSValue v) int js_arrlen(JSValue v)
{ {
int len; int len;
JS_ToInt32(js, &len, JS_GetProperty(js, v, JS_PROP_LENGTH)); JS_ToInt32(js, &len, JS_GetPropertyStr(js, v, "length"));
return len; return len;
} }
struct color js2color(JSValue v)
{
struct color color = {0,0,0};
color.r = js2int(js_arridx(v,0));
color.g = js2int(js_arridx(v,1));
color.b = js2int(js_arridx(v,2));
return color;
}
cpVect js2vec2(JSValue v) cpVect js2vec2(JSValue v)
{ {
cpVect vect; cpVect vect;
JS_ToInt64(js, &vect.x, JS_GetPropertyUint32(js, v, 0)); vect.x = js2number(js_arridx(v,0));
JS_ToInt64(js, &vect.y, JS_GetPropertyUint32(js,v,1)); vect.y = js2number(js_arridx(v,1));
return vect; return vect;
} }
@ -178,7 +182,7 @@ void vec2float(cpVect v, float *f)
JSValue vec2js(cpVect v) JSValue vec2js(cpVect v)
{ {
JSValue array = JS_NewObject(js); JSValue array = JS_NewArray(js);
JS_SetPropertyInt64(js, array, 0, JS_NewFloat64(js,v.x)); JS_SetPropertyInt64(js, array, 0, JS_NewFloat64(js,v.x));
JS_SetPropertyInt64(js, array, 1, JS_NewFloat64(js,v.y)); JS_SetPropertyInt64(js, array, 1, JS_NewFloat64(js,v.y));
return array; return array;
@ -853,13 +857,10 @@ JSValue duk_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
JSValue duk_register(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) JSValue duk_register(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
{ {
int cmd = js2int(argv[0]); int cmd = js2int(argv[0]);
YughWarn("Registration is all handled script side now.");
return JS_NULL;
/*
void *fn = duk_get_heapptr(duk, 1);
void *obj = duk_get_heapptr(duk, 2);
struct callee c = {fn, obj}; struct callee c;
c.fn = argv[1];
c.obj = argv[2];
switch(cmd) { switch(cmd) {
case 0: case 0:
@ -879,20 +880,23 @@ JSValue duk_register(JSContext *js, JSValueConst this, int argc, JSValueConst *a
break; break;
case 4: case 4:
unregister_obj(obj); // unregister_obj(obj);
break; break;
case 5: case 5:
unregister_gui(c); // unregister_gui(c);
break; break;
case 6: case 6:
register_debug(c); register_debug(c);
break; break;
case 7:
register_pawn(c);
break;
} }
return JS_NULL; return JS_NULL;
*/
} }
void gameobject_add_shape_collider(int go, struct callee c, struct phys2d_shape *shape) void gameobject_add_shape_collider(int go, struct callee c, struct phys2d_shape *shape)
@ -905,14 +909,9 @@ void gameobject_add_shape_collider(int go, struct callee c, struct phys2d_shape
JSValue duk_register_collide(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) JSValue duk_register_collide(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
{ {
YughWarn("Registration is all handled script side now.");
return JS_NULL;
/*
int cmd = js2int(argv[0]); int cmd = js2int(argv[0]);
void *fn = duk_get_heapptr(duk, 1);
void *obj = duk_get_heapptr(duk, 2);
int go = js2int(argv[3]); int go = js2int(argv[3]);
struct callee c = {fn, obj}; struct callee c = {argv[1], argv[2]};
switch(cmd) { switch(cmd) {
case 0: case 0:
@ -920,7 +919,7 @@ JSValue duk_register_collide(JSContext *js, JSValueConst this, int argc, JSValue
break; break;
case 1: case 1:
gameobject_add_shape_collider(go, c, duk_get_pointer(duk,4)); gameobject_add_shape_collider(go, c, js2ptr(argv[4]));
break; break;
case 2: case 2:
@ -933,7 +932,6 @@ JSValue duk_register_collide(JSContext *js, JSValueConst this, int argc, JSValue
} }
return JS_NULL; return JS_NULL;
*/
} }
JSValue duk_sys_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv) JSValue duk_sys_cmd(JSContext *js, JSValueConst this, int argc, JSValueConst *argv)
@ -1362,11 +1360,10 @@ JSValue duk_make_timer(JSContext *js, JSValueConst this, int argc, JSValueConst
return JS_NewInt64(js, id); return JS_NewInt64(js, id);
} }
#define DUK_FUNC(NAME, ARGS) JS_CFUNC_DEF(#NAME, ARGS, duk_##NAME), #define DUK_FUNC(NAME, ARGS) JS_SetPropertyStr(js, JS_GetGlobalObject(js), #NAME, JS_NewCFunction(js, duk_##NAME, #NAME, ARGS));
void ffi_load() void ffi_load()
{ {
JSCFunctionListEntry yugh_funcs[] = {
DUK_FUNC(yughlog, 4) DUK_FUNC(yughlog, 4)
DUK_FUNC(nuke, 6) DUK_FUNC(nuke, 6)
DUK_FUNC(make_gameobject, 7) DUK_FUNC(make_gameobject, 7)
@ -1402,5 +1399,4 @@ void ffi_load()
DUK_FUNC(inflate_cpv, 3) DUK_FUNC(inflate_cpv, 3)
DUK_FUNC(anim, 2) DUK_FUNC(anim, 2)
};
} }

View file

@ -6,16 +6,14 @@
void ffi_load(); void ffi_load();
void duk_dump_stack(JSContext *js);
JSValue vec2js(cpVect v); JSValue vec2js(cpVect v);
cpVect js2vec2(JSValue v); cpVect js2vec2(JSValue v);
JSValue bitmask2js(cpBitmask mask); JSValue bitmask2js(cpBitmask mask);
cpBitmask js2bitmask(JSValue v); cpBitmask js2bitmask(JSValue v);
struct color duk2color(JSValue v); struct color js2color(JSValue v);
double js2number(JSValue v);
JSValue num2js(double g); JSValue num2js(double g);
JSValue int2js(int i); JSValue int2js(int i);

View file

@ -35,7 +35,7 @@ struct gameobject *id2go(int id)
int body2id(cpBody *body) int body2id(cpBody *body)
{ {
return cpBodyGetUserData(body); return (int)cpBodyGetUserData(body);
} }
cpBody *id2body(int id) cpBody *id2body(int id)
@ -174,7 +174,7 @@ int MakeGameobject()
*id2go(retid) = go; *id2go(retid) = go;
} }
cpBodySetUserData(go.body, (int)retid); cpBodySetUserData(go.body, (void*)retid);
phys2d_setup_handlers(retid); phys2d_setup_handlers(retid);
return retid; return retid;
} }

View file

@ -17,19 +17,11 @@ static int *downkeys = NULL;
static int mquit = 0; static int mquit = 0;
static void **pawns = NULL; static struct callee pawn_callee;
void set_pawn(void *pawn) { void register_pawn(struct callee c)
arrput(pawns, pawn); {
} pawn_callee = c;
void remove_pawn(void *pawn) {
for (int i = 0; i < arrlen(pawns); i++) {
if (pawns[i] == pawn) {
arrdel(pawns, i);
return;
}
}
} }
void add_downkey(int key) { void add_downkey(int key) {
@ -55,20 +47,22 @@ static void cursor_pos_cb(GLFWwindow *w, double xpos, double ypos)
mouse_pos.x = xpos; mouse_pos.x = xpos;
mouse_pos.y = ypos; mouse_pos.y = ypos;
for (int i = 0; i < arrlen(pawns); i++) { JSValue argv[2];
if (!pawns[i]) continue; argv[0] = JS_NewString(js, "input_mouse_pos");
JSValue v = vec2js(mouse_pos); argv[1] = vec2js(mouse_pos);
} script_callee(pawn_callee, 2, argv);
JS_FreeValue(js, argv[0]);
JS_FreeValue(js, argv[1]);
} }
static void pawn_call_keydown(int key) static void pawn_call_keydown(int key)
{ {
for (int i = 0; i < arrlen(pawns); i++) { JSValue argv[2];
// if (!pawns[i] || script_eval_setup("input_num_pressed", pawns[i])) continue; argv[0] = JS_NewString(js, "input_num_pressed");
//TODO duk_push_int(duk, key); argv[1] = JS_NewInt32(js, key);
// script_eval_exec(1); script_callee(pawn_callee, 2, argv);
} JS_FreeValue(js, argv[0]);
JS_FreeValue(js, argv[1]);
} }
static void scroll_cb(GLFWwindow *w, double xoffset, double yoffset) static void scroll_cb(GLFWwindow *w, double xoffset, double yoffset)
@ -117,14 +111,16 @@ void set_mouse_mode(int mousemode)
void char_cb(GLFWwindow *w, unsigned int codepoint) void char_cb(GLFWwindow *w, unsigned int codepoint)
{ {
for (int i = 0; i < arrlen(pawns); i++) { static char out[2] = {0};
// if (!pawns[i] || script_eval_setup("input_text", pawns[i])) continue; static JSValue argv[2];
char out[2];
out[0] = (char)codepoint; out[0] = (char)codepoint;
out[1] = 0; argv[0] = JS_NewString(js, "input_text");
//TODO duk_push_string(duk, out); argv[1] = JS_NewString(js, out);
// script_eval_exec(1); script_callee(pawn_callee, 2, argv);
}
JS_FreeValue(js, argv[0]);
JS_FreeValue(js, argv[1]);
} }
static GLFWcharfun nukechar; static GLFWcharfun nukechar;
@ -148,19 +144,11 @@ void input_to_game()
} }
void call_input_signal(char *signal) { void call_input_signal(char *signal) {
for (int i = arrlen(pawns)-1; i >= 0; i--) { JSValue s = JS_NewString(js, signal);
if (pawns[i] == NULL) arrdel(pawns, i); JS_Call(js, pawn_callee.fn, pawn_callee.obj, 1, &s);
} JS_FreeValue(js, s);
int len = arrlen(pawns);
void *framepawns[len];
memcpy(framepawns, pawns, len*sizeof(*pawns));
for (int i = 0; i < len; i++) {
// script_eval_w_env(signal, framepawns[i]);
}
} }
const char *keyname_extd(int key, int scancode) { const char *keyname_extd(int key, int scancode) {
char keybuf[50]; char keybuf[50];
const char *kkey = NULL; const char *kkey = NULL;

View file

@ -25,6 +25,8 @@ void call_input_signal(char *signal);
const char *keyname_extd(int key, int scancode); const char *keyname_extd(int key, int scancode);
int action_down(int scancode); int action_down(int scancode);
void register_pawn(struct callee c);
int want_quit(); int want_quit();
void quit(); void quit();
@ -35,9 +37,6 @@ struct inputaction
int scancode; int scancode;
}; };
void set_pawn(void *pawn);
void remove_pawn(void *pawn);
void input_to_nuke(); void input_to_nuke();
void input_to_game(); void input_to_game();

View file

@ -39,7 +39,7 @@ void script_init() {
} }
void script_run(const char *script) { void script_run(const char *script) {
JS_Eval(js, script, strlen(script), "script", 0); JS_FreeValue(js, JS_Eval(js, script, strlen(script), "script", 0));
} }
time_t file_mod_secs(const char *file) { time_t file_mod_secs(const char *file) {
@ -48,13 +48,34 @@ time_t file_mod_secs(const char *file) {
return attr.st_mtime; return attr.st_mtime;
} }
int js_print_exception(JSValue v)
{
if (JS_IsException(v)) {
JSValue exception = JS_GetException(js);
JSValue val = JS_GetPropertyStr(js, exception, "stack");
if (!JS_IsUndefined(val)) {
const char *name = JS_ToCString(js, JS_GetPropertyStr(js, exception, "name"));
const char *msg = JS_ToCString(js, JS_GetPropertyStr(js, exception, "message"));
const char *stack = JS_ToCString(js, val);
YughError("%s :: %s\n%s", name, msg, stack);
JS_FreeCString(js, name);
JS_FreeCString(js, msg);
JS_FreeCString(js, stack);
}
}
}
int script_dofile(const char *file) { int script_dofile(const char *file) {
YughInfo("Doing script %s", file);
const char *script = slurp_text(file); const char *script = slurp_text(file);
if (!script) { if (!script) {
YughError("Can't find file %s.", file); YughError("Can't find file %s.", file);
return 1; return 1;
} }
JS_Eval(js, script, strlen(script), file, 0); JSValue obj = JS_Eval(js, script, strlen(script), file, 0);
js_print_exception(obj);
JS_FreeValue(js, obj);
return file_mod_secs(file); return file_mod_secs(file);
} }
@ -63,123 +84,76 @@ int script_dofile(const char *file) {
s is the function to call on that object s is the function to call on that object
*/ */
void script_eval_w_env(const char *s, JSValue env) { void script_eval_w_env(const char *s, JSValue env) {
JS_EvalThis(js, env, s, strlen(s), "internal", 0); JSValue v = JS_EvalThis(js, env, s, strlen(s), "internal", 0);
js_print_exception(v);
JS_FreeValue(js, v);
} }
void script_call_sym(JSValue sym) void script_call_sym(JSValue sym)
{ {
JS_Call(js, sym, JS_GetGlobalObject(js), 0, NULL); JSValue v = JS_Call(js, sym, JS_GetGlobalObject(js), 0, NULL);
js_print_exception(v);
JS_FreeValue(js, v);
} }
struct callee *updates = NULL;
struct callee *physics = NULL;
struct callee *guis = NULL;
struct callee *debugs = NULL;
struct callee *nk_guis = NULL;
void unregister_obj(JSValue obj)
{
/* for (int i = arrlen(updates)-1; i >= 0; i--)
if (updates[i].obj == obj) arrdel(updates, i);
for (int i = arrlen(physics)-1; i >= 0; i--)
if (physics[i].obj == obj) arrdel(physics,i);
for (int i = arrlen(guis)-1; i >= 0; i--)
if (guis[i].obj == obj) arrdel(guis,i);
for (int i = arrlen(nk_guis)-1; i >= 0; i--)
if (nk_guis[i].obj == obj) arrdel(nk_guis,i);
for (int i = arrlen(debugs)-1; i >= 0; i--)
if (debugs[i].obj == obj) arrdel(debugs,i);
*/
}
void register_debug(struct callee c) {
arrput(debugs, c);
}
void unregister_gui(struct callee c)
{
for (int i = arrlen(guis)-1; i >= 0; i--) {
/*
if (guis[i].obj == c.obj && guis[i].fn == c.fn) {
arrdel(guis, i);
return;
}
*/
}
}
void register_update(struct callee c) {
arrput(updates, c);
}
void register_gui(struct callee c) {
arrput(guis, c);
}
void register_nk_gui(struct callee c) { arrput(nk_guis, c); }
void register_physics(struct callee c) {
arrput(physics, c);
}
JSValue js_callee_exec(struct callee *c, int argc, JSValue *argv) JSValue js_callee_exec(struct callee *c, int argc, JSValue *argv)
{ {
JS_Call(js, c->obj, c->fn, argc, argv); JSValue ret = JS_Call(js, c->fn, c->obj, argc, argv);
js_print_exception(ret);
JS_FreeValue(js, ret);
} }
void call_callee(struct callee *c) { void call_callee(struct callee *c) {
JS_Call(js, c->obj, c->fn, 0, NULL); js_callee_exec(c, 0, NULL);
} }
void callee_dbl(struct callee c, double d) void callee_dbl(struct callee c, double d)
{ {
JSValue v = num2js(d); JSValue v = num2js(d);
js_callee_exec(&c, 1, &v); js_callee_exec(&c, 1, &v);
JS_FreeValue(js, v);
} }
void callee_int(struct callee c, int i) void callee_int(struct callee c, int i)
{ {
JSValue v = int2js(i); JSValue v = int2js(i);
js_callee_exec(&c, 1, &v); js_callee_exec(&c, 1, &v);
JS_FreeValue(js, v);
} }
void callee_vec2(struct callee c, cpVect vec) void callee_vec2(struct callee c, cpVect vec)
{ {
JSValue v = vec2js(vec); JSValue v = vec2js(vec);
js_callee_exec(&c, 1, &v); js_callee_exec(&c, 1, &v);
JS_FreeValue(js, v);
} }
void call_updates(double dt) { void script_callee(struct callee c, int argc, JSValue *argv)
for (int i = 0; i < arrlen(updates); i++)
callee_dbl(updates[i], dt);
}
void call_gui() {
for (int i = 0; i < arrlen(guis); i++)
call_callee(&guis[i]);
}
void call_debug() {
for (int i = 0; i < arrlen(debugs); i++)
call_callee(&debugs[i]);
}
void call_nk_gui() {
for (int i = 0; i < arrlen(nk_guis); i++)
call_callee(&nk_guis[i]);
}
void call_physics(double dt) {
for (int i = 0; i < arrlen(physics); i++)
callee_dbl(physics[i], dt);
}
void call_debugs()
{ {
for (int i = 0; i < arrlen(debugs); i++) js_callee_exec(&c, argc, argv);
call_callee(&debugs[i]);
} }
static struct callee update_callee;
void register_update(struct callee c) {
update_callee = c;
}
void call_updates(double dt) {
callee_dbl(update_callee, dt);
}
static struct callee gui_callee;
void register_gui(struct callee c) { gui_callee = c; }
void call_gui() { js_callee_exec(&gui_callee, 0, NULL); }
static struct callee nk_gui_callee;
void register_nk_gui(struct callee c) { nk_gui_callee = c; }
void call_nk_gui() { js_callee_exec(&nk_gui_callee, 0, NULL); }
static struct callee physupdate_callee;
void register_physics(struct callee c) { physupdate_callee = c;}
void call_physics(double dt) { callee_dbl(physupdate_callee, dt); }
struct callee debug_callee;
void register_debug(struct callee c) { debug_callee = c; }
void call_debugs() { JS_Call(js, debug_callee.fn, debug_callee.obj, 0, NULL); }

View file

@ -24,6 +24,7 @@ void script_editor();
void script_call(const char *f); void script_call(const char *f);
void script_call_sym(JSValue sym); void script_call_sym(JSValue sym);
void call_callee(struct callee *c); void call_callee(struct callee *c);
void script_callee(struct callee c, int argc, JSValue *argv);
int script_has_sym(void *sym); int script_has_sym(void *sym);
void script_eval_w_env(const char *s, JSValue env); void script_eval_w_env(const char *s, JSValue env);

View file

@ -121,7 +121,7 @@ struct wav *make_sound(const char *wav)
if (index != -1) return wavhash[index].value; if (index != -1) return wavhash[index].value;
struct wav mwav; struct wav mwav;
mwav.data = drwav_open_file_and_read_pcm_frames_s16(wav, &mwav.ch, &mwav.samplerate, &mwav.frames, NULL); // mwav.data = drwav_open_file_and_read_pcm_frames_s16(wav, &mwav.ch, &mwav.samplerate, &mwav.frames, NULL);
if (mwav.samplerate != SAMPLERATE) { if (mwav.samplerate != SAMPLERATE) {
YughInfo("Changing samplerate of %s from %d to %d.", wav, mwav.samplerate, SAMPLERATE); YughInfo("Changing samplerate of %s from %d to %d.", wav, mwav.samplerate, SAMPLERATE);

View file

@ -258,7 +258,7 @@ void anim_play(struct anim2d *anim)
anim->playing = 1; anim->playing = 1;
if (anim->timer == NULL) if (anim->timer == NULL)
anim->timer = timer_make(1.f / anim->anim->ms, anim_incr, anim, 0); anim->timer = id2timer(timer_make(1.f / anim->anim->ms, anim_incr, anim, 0));
else else
timerr_settime(anim->timer, 1.f/anim->anim->ms); timerr_settime(anim->timer, 1.f/anim->anim->ms);

View file

@ -140,13 +140,13 @@ int main(int argc, char **args) {
YughInfo("Starting yugine version %s.", VER); YughInfo("Starting yugine version %s.", VER);
FILE *sysinfo = NULL; FILE *sysinfo = NULL;
sysinfo = popen("uname -a", "r"); /* sysinfo = popen("uname -a", "r");
if (!sysinfo) { if (!sysinfo) {
YughWarn("Failed to get sys info."); YughWarn("Failed to get sys info.");
} else { } else {
log_cat(sysinfo); log_cat(sysinfo);
pclose(sysinfo); pclose(sysinfo);
} }*/
signal(SIGSEGV, seghandle); signal(SIGSEGV, seghandle);
signal(SIGABRT, seghandle); signal(SIGABRT, seghandle);
signal(SIGFPE, seghandle); signal(SIGFPE, seghandle);