diff --git a/.gitignore b/.gitignore index 1f32abe..184bbc5 100644 --- a/.gitignore +++ b/.gitignore @@ -27,6 +27,6 @@ primum* Prosperon* prosperon* *.icns -game.cdb +game.zip icon.ico steam/ \ No newline at end of file diff --git a/Makefile b/Makefile index c94c269..aa46658 100755 --- a/Makefile +++ b/Makefile @@ -17,6 +17,15 @@ LD = $(CC) STEAM = steam/sdk STEAMAPI = + +ifeq ($(CC), emcc) + LDFLAGS += --preload-file game.zip --preload-file config.js --preload-file game.js + CPPFLAGS += -Wbad-function-cast -Wcast-function-type -sSTACK_SIZE=5MB -sALLOW_MEMORY_GROWTH + OPT = 0 + NDEBUG = 1 + AR = emar +endif + CCC != $(CC) -v ifneq ($(findstring clangcc , $(CCC)),) LDFLAGS += -Wl,-rpath=./ @@ -42,14 +51,6 @@ ifdef NQOA CPPFLAGS += -DNQOA endif -ifeq ($(CC), emcc) - LDFLAGS += --emrun --preload-file game.cdb --preload-file config.js -sNO_EXIT_RUNTIME - CPPFLAGS += -g -Wbad-function-cast -Wcast-function-type -sALLOW_MEMORY_GROWTH - OPT = 0 - NDEBUG = 1 - AR = emar -endif - ifdef NDEBUG CPPFLAGS += -DNDEBUG else @@ -119,7 +120,7 @@ else ifeq ($(OS), IOS) INFO :=$(INFO)_ios else ifeq ($(CC), emcc) # Then WEB OS := Web - LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 -sTOTAL_MEMORY=128MB -sSTACK_SIZE=5MB + LDFLAGS += -sMIN_WEBGL_VERSION=2 -sMAX_WEBGL_VERSION=2 CPPFLAGS += -DNSTEAM LDLIBS += GL openal c m dl STEAMAPI := @@ -270,11 +271,6 @@ crossmac: Prosperon.icns crossweb: make CC=emcc - mv $(APP)_$(ARCH).html index.html - -playweb: - make crossweb - emrun index.html clean: @echo Cleaning project diff --git a/scripts/engine.js b/scripts/engine.js index eb89d50..5760a17 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -277,7 +277,6 @@ var gggstart = game.engine_start; game.engine_start = function(s) { game.startengine = 1; gggstart(function() { - say(`start of gggstart`); global.mixin("scripts/sound.js"); world_start(); go_init(); diff --git a/scripts/std.js b/scripts/std.js index 25189e0..fbde31a 100644 --- a/scripts/std.js +++ b/scripts/std.js @@ -85,7 +85,6 @@ io.chmod = function(file,mode) { var tmpslurp = io.slurp; io.slurp = function(path) { - say(`SLURPING ${path}`); path = Resources.replpath(path); return tmpslurp(path); } @@ -229,34 +228,25 @@ Cmdline.register_order("debug", function() { }, "Play the game with debugging enabled."); Cmdline.register_order("play", function(argv) { - say("SELECTED PLAY"); if (argv[0]) io.chdir(argv[0]); game.loadurs(); - say("AFTER LOADURS"); if (!io.exists(projectfile)) { say("No game to play. Try making one with 'prosperon init'."); return; } - say("AFTER EXIST CHECK"); var project = json.decode(io.slurp(projectfile)); - say(`project title is ${project.title}`); - say(json.encode(project)); game.title = project.title; window.mode = window.modetypes.expand; - say("BEFORE CONFIG"); global.mixin("config.js"); - say("AFTER CONFIG"); - //if (project.title) window.title = project.title; + if (project.title) window.title = project.title; + -/* if (window.rendersize.equal([0,0])) window.rendersize = window.size; console.info(`Starting game with window size ${window.size} and render ${window.rendersize}.`); -*/ - say("NOW ENGINESTART"); game.engine_start(function() { render.set_font("fonts/c64.ttf", 8); @@ -264,13 +254,12 @@ Cmdline.register_order("play", function(argv) { if (project.icon) window.set_icon(game.texture(project.icon)); game.camera = world.spawn("scripts/camera2d"); }); - say("FINISHED ENGINESTART"); }, "Play the game present in this folder."); Cmdline.register_order("pack", function(str) { var packname; if (str.length === 0) - packname = "game.cdb"; + packname = "game.zip"; else if (str.length > 1) { console.warn("Give me a single filename for the pack."); return; @@ -284,9 +273,9 @@ Cmdline.register_order("pack", function(str) { }, "Pack the game into the given name.", "NAME"); Cmdline.register_order("cdb", function(argv) { - var cdb = "game.cdb"; + var cdb = "game.zip"; if (!io.exists(cdb)) { - say(`No 'game.cdb' present.`); + say(`No 'game.zip' present.`); return; } if (argv.length === 0) { @@ -450,7 +439,6 @@ Cmdline.register_order("version", function() { function cmd_args(cmdargs) { - say("HERE COME THE CMD ARGS"); var play = false; var cmds = cmdargs.split(/\s+/).slice(1); diff --git a/source/engine/config.c b/source/engine/config.c index c420ab9..665da42 100644 --- a/source/engine/config.c +++ b/source/engine/config.c @@ -2,7 +2,6 @@ #define SOKOL_TRACE_HOOKS #define SOKOL_IMPL -#define SOKOL_NO_ENTRY #include "sokol/sokol_audio.h" #include "sokol/sokol_time.h" #include "sokol/sokol_args.h" diff --git a/source/engine/debug/log.c b/source/engine/debug/log.c index 5e0206a..096554b 100644 --- a/source/engine/debug/log.c +++ b/source/engine/debug/log.c @@ -97,21 +97,20 @@ void mYughLog(int category, int priority, int line, const char *file, const char raise(SIGTRAP); #endif } - #endif } /* print to stdout and console */ void log_print(const char *str) { - #ifndef NDEBUG fprintf(stdout, str); fprintf(writeout, str); + fflush(stdout); #else printf(str); -#endif fflush(stdout); +#endif } void sg_logging(const char *tag, uint32_t lvl, uint32_t id, const char *msg, uint32_t line, const char *file, void *data) { diff --git a/source/engine/jsffi.c b/source/engine/jsffi.c index 65e9936..c953920 100644 --- a/source/engine/jsffi.c +++ b/source/engine/jsffi.c @@ -1062,14 +1062,14 @@ static JSValue js_window_get_rendersize(JSContext *js, JSValue this) { } static JSValue js_window_set_rendersize(JSContext *js, JSValue this, JSValue v) { js2window(this)->rendersize = js2vec2(v); + return JS_UNDEFINED; } JSC_GETSET(window, mode, number) static JSValue js_window_get_fullscreen(JSContext *js, JSValue this) { return boolean2js(js2window(this)->fullscreen); } -static JSValue js_window_set_fullscreen(JSContext *js, JSValue this, JSValue v) { window_setfullscreen(js2window(this), js2boolean(v)); } +static JSValue js_window_set_fullscreen(JSContext *js, JSValue this, JSValue v) { window_setfullscreen(js2window(this), js2boolean(v)); return JS_UNDEFINED; } static JSValue js_window_set_title(JSContext *js, JSValue this, JSValue v) { - return JS_UNDEFINED; window *w = js2window(this); if (w->title) JS_FreeCString(js, w->title); w->title = js2str(v); @@ -1077,9 +1077,7 @@ static JSValue js_window_set_title(JSContext *js, JSValue this, JSValue v) sapp_set_window_title(w->title); return JS_UNDEFINED; } -JSC_CCALL(window_get_title, - return JS_UNDEFINED; -return str2js(js2window(this)->title)) +JSC_CCALL(window_get_title, return str2js(js2window(this)->title)) JSC_CCALL(window_set_icon, window_seticon(&mainwin, js2texture(argv[0]))) JSC_GETSET(window, vsync, boolean) JSC_GETSET(window, enable_clipboard, boolean) @@ -1109,12 +1107,12 @@ JSValue js_gameobject_set_rpos(JSContext *js, JSValue this, JSValue val) { return JS_UNDEFINED; } JSValue js_gameobject_get_rpos(JSContext *js, JSValue this) { return cvec22js(cpBodyGetPosition(js2gameobject(this)->body)); } -JSValue js_gameobject_set_rangle (JSContext *js, JSValue this, JSValue val) { cpBodySetAngle(js2gameobject(this)->body, HMM_TurnToRad*js2number(val)); } +JSValue js_gameobject_set_rangle (JSContext *js, JSValue this, JSValue val) { cpBodySetAngle(js2gameobject(this)->body, HMM_TurnToRad*js2number(val)); return JS_UNDEFINED; } JSValue js_gameobject_get_rangle (JSContext *js, JSValue this) { return number2js(HMM_RadToTurn*cpBodyGetAngle(js2gameobject(this)->body)); } JSValue js_gameobject_get_rscale(JSContext *js, JSValue this) { return vec32js(js2gameobject(this)->scale); } -JSValue js_gameobject_set_rscale(JSContext *js, JSValue this, JSValue val) { js2gameobject(this)->scale = js2vec3(val); } +JSValue js_gameobject_set_rscale(JSContext *js, JSValue this, JSValue val) { js2gameobject(this)->scale = js2vec3(val); return JS_UNDEFINED; } JSC_GETSET_BODY(velocity, Velocity, cvec2) -JSValue js_gameobject_set_angularvelocity (JSContext *js, JSValue this, JSValue val) { cpBodySetAngularVelocity(js2gameobject(this)->body, HMM_TurnToRad*js2number(val)); } +JSValue js_gameobject_set_angularvelocity (JSContext *js, JSValue this, JSValue val) { cpBodySetAngularVelocity(js2gameobject(this)->body, HMM_TurnToRad*js2number(val)); return JS_UNDEFINED;} JSValue js_gameobject_get_angularvelocity (JSContext *js, JSValue this) { return number2js(HMM_RadToTurn*cpBodyGetAngularVelocity(js2gameobject(this)->body)); } //JSC_GETSET_BODY(moi, Moment, number) JSC_GETSET_BODY(torque, Torque, number) diff --git a/source/engine/render.c b/source/engine/render.c index 73a05dd..2e1782a 100644 --- a/source/engine/render.c +++ b/source/engine/render.c @@ -121,7 +121,8 @@ void capture_screen(int x, int y, int w, int h, const char *path) #include "HandmadeMath.h" -struct rgba editorClearColor = {35,60,92,255}; +//struct rgba editorClearColor = {35,60,92,255}; +struct rgba editorClearColor = {0,0,0,255}; sg_pass_action pass_action = {0}; diff --git a/source/engine/resources.c b/source/engine/resources.c index 407ea29..32309e9 100644 --- a/source/engine/resources.c +++ b/source/engine/resources.c @@ -63,7 +63,6 @@ static void response_cb(const sfetch_response_t *r) void *gamedata; void resources_init() { - printf("INIT RESOURCES\n"); /* sfetch_setup(&(sfetch_desc_t){ .max_requests = 1024, @@ -74,7 +73,7 @@ void resources_init() { gamebuf = malloc(64*1024*1024); sfetch_handle_t h = sfetch_send(&(sfetch_request_t){ - .path="game.cdb", + .path="game.zip", .callback = response_cb, .buffer = { .ptr = gamebuf, @@ -83,9 +82,8 @@ void resources_init() { }); */ mz_zip_reader_init_mem(&corecdb, core_cdb, core_cdb_len, 0); - printf("SLURP GAME\n"); size_t gamesize; - gamedata = slurp_file("game.cdb", &gamesize); + gamedata = slurp_file("game.zip", &gamesize); mz_zip_reader_init_mem(&game_cdb, gamedata, gamesize, 0); } @@ -193,7 +191,6 @@ int fexists(const char *path) void *os_slurp(const char *file, size_t *size) { - printf("SLURPING %s FROM OS\n", file); FILE *f; jump: diff --git a/source/engine/script.c b/source/engine/script.c index 62b664c..c9720f1 100644 --- a/source/engine/script.c +++ b/source/engine/script.c @@ -34,10 +34,8 @@ void script_stop() #ifndef LEAK return; #endif - printf("FREEING CONTEXT\n"); script_gc(); - JS_FreeContext(js); js = NULL; JS_FreeRuntime(rt); diff --git a/source/engine/yugine.c b/source/engine/yugine.c index 65babb9..6dd47ed 100644 --- a/source/engine/yugine.c +++ b/source/engine/yugine.c @@ -57,19 +57,16 @@ static JSValue c_start; static JSValue c_process_fn; void c_init() { - printf("C INIT\n"); mainwin.start = 1; window_resize(sapp_width(), sapp_height()); phys2d_init(); render_init(); particle_init(); - printf("RUNNING START\n"); script_call_sym(c_start,0,NULL); JS_FreeValue(js, c_start); } void c_frame() { - printf("FRAME\n"); script_call_sym(c_process_fn,0,NULL); fflush(stdout); } @@ -203,11 +200,11 @@ static sapp_desc start_desc = { .frame_cb = c_frame, .cleanup_cb = c_clean, .event_cb = c_event, + .win32_console_create = false, .logger.func = sg_logging }; -void main(int argc, char **argv) { - printf("ENTERED MAIN\n"); +sapp_desc sokol_main(int argc, char **argv) { #ifndef NDEBUG log_init(); signal(SIGSEGV, seghandle); @@ -216,7 +213,6 @@ void main(int argc, char **argv) { #endif resources_init(); - printf("SETUP TIME\n"); stm_setup(); /* time */ script_startup(); @@ -237,16 +233,9 @@ void main(int argc, char **argv) { //while (!LOADED_GAME) // sfetch_dowork(); - printf("NOW SEND CMD ARGS\n"); - script_evalf("cmd_args('%s');", cmdstr); - printf("AND SETUP START DESC\n"); - start_desc.logger.func = NULL; - start_desc.enable_dragndrop = false; - printf("NOW SAPPRUN\n"); - sapp_run(&start_desc); -// return start_desc; + return start_desc; } void engine_start(JSValue start, JSValue procfn) @@ -255,7 +244,7 @@ void engine_start(JSValue start, JSValue procfn) c_process_fn = JS_DupValue(js,procfn); sound_init(); - return; + start_desc.width = mainwin.size.x; start_desc.height = mainwin.size.y; start_desc.window_title = mainwin.title; @@ -265,8 +254,6 @@ void engine_start(JSValue start, JSValue procfn) start_desc.enable_clipboard = mainwin.enable_clipboard; start_desc.high_dpi = mainwin.high_dpi; start_desc.sample_count = mainwin.sample_count; - - printf("END OF ENGINESTART\n"); } double apptime() { return stm_sec(stm_now()); }