Skip to content

Free games for graphing calculators: NumWorks, TI-Nspire CX, Casio fx-CG50 and soon TI-84 Plus CE. Balatro, Celeste, Hollow Knight, Minecraft and more.

Ports: Doom, Crossy Road, NumDrive, Suika and Paperclips on a computer

Mason3632afccaa8cf83
diff --git a/games/crossyroad/Makefile b/games/crossyroad/Makefile
index d552e377..6f7b06f8 100644
--- a/games/crossyroad/Makefile
+++ b/games/crossyroad/Makefile
@@ -68,3 +68,10 @@ $(BUILD)/sim-module.o: src/crossy.c | $(BUILD)
cc -std=c11 -O2 -fno-math-errno -fPIC -DPLATFORM_SIM=1 -I$(EADK_INC) -Dmain=np_crossyroad_main \
-c src/crossy.c -o $(BUILD)/sim.o
ld -r $(BUILD)/sim.o -exported_symbol _np_crossyroad_main -o $@
+
+# the other targets (platform/port.mk): make port TARGET=sdl, web, nspire, ti84ce. (Not PLATFORM_DEVICE: the
+# calculator's register for the game's state and its own memset stay out.)
+PORT_ID = crossyroad
+PORT_NAME = Crossy Road
+PORT_SRC = src/crossy.c
+include ../../platform/port.mk
diff --git a/games/crossyroad/src/crossy.c b/games/crossyroad/src/crossy.c
index f66606d1..0fad0745 100644
--- a/games/crossyroad/src/crossy.c
+++ b/games/crossyroad/src/crossy.c
@@ -2021,7 +2021,7 @@ static void render(void) {
// firmware slot tells where. Top score, coins, the characters won and the one played go in a
// tiny record named "crossyroad.sav", written only after the whole file system checks out
// (one from before the characters, top score and coins, is read and replaced).
-#if (PLATFORM_DEVICE && !defined(HOST)) || defined(SAVE_TEST)
+#if (PLATFORM_DEVICE && !defined(HOST)) || defined(SAVE_TEST) || defined(NP_PORT)
#define FS_MAGIC 0xEE0BDDBAu
#define SAVE_LEN 20
#define SAVE_LEN1 12
@@ -2110,6 +2110,9 @@ static NOINLINE void write_save(void) {
uint8_t *d = f + 2 + sizeof(save_name);
for (int i = 0; i < 5; i++)
for (int j = 0; j < 4; j++) d[4 * i + j] = (uint8_t)(v[i] >> (8 * j));
+#ifdef NP_PORT
+ np_storage_changed();
+#endif
}
#elif defined(HOST)
// (on a computer: coins and characters to start with, for trying the prize machine)
diff --git a/games/doom/Makefile b/games/doom/Makefile
index dc3aa3c2..f4c26c5a 100644
--- a/games/doom/Makefile
+++ b/games/doom/Makefile
@@ -167,5 +167,7 @@ PORT_ID = doom
PORT_NAME = Doom
PORT_SRC = src/d_event.c src/d_iwad.c src/d_loop.c src/d_mode.c src/deh_str.c src/image_decoder.c src/m_argv.c src/m_bbox.c src/m_cheat.c src/m_config.c src/m_controls.c src/m_fixed.c src/m_misc.c src/memio.c src/tables.c src/tiny_huff.c src/v_diskicon.c src/v_video.c src/w_checksum.c src/w_file.c src/w_file_memory.c src/w_main.c src/w_merge.c src/w_wad.c src/z_zone.c src/doom/am_map.c src/doom/d_items.c src/doom/d_main.c src/doom/d_net.c src/doom/doomdef.c src/doom/doomstat.c src/doom/dstrings.c src/doom/f_finale.c src/doom/f_wipe.c src/doom/g_game.c src/doom/hu_lib.c src/doom/hu_stuff.c src/doom/info.c src/doom/m_menu.c src/doom/m_random.c src/doom/p_ceilng.c src/doom/p_doors.c src/doom/p_enemy.c src/doom/p_floor.c src/doom/p_inter.c src/doom/p_lights.c src/doom/p_map.c src/doom/p_maputl.c src/doom/p_mobj.c src/doom/p_plats.c src/doom/p_pspr.c src/doom/p_saveg.c src/doom/p_setup.c src/doom/p_sight.c src/doom/p_spec.c src/doom/p_switch.c src/doom/p_telept.c src/doom/p_tick.c src/doom/p_user.c src/doom/r_bsp.c src/doom/r_data.c src/doom/r_data_whd.c src/doom/r_draw.c src/doom/r_main.c src/doom/r_plane.c src/doom/r_segs.c src/doom/r_sky.c src/doom/r_things.c src/doom/s_sound.c src/doom/sounds.c src/doom/st_lib.c src/doom/st_stuff.c src/doom/statdump.c src/doom/wi_stuff.c src/nw/i_system.c src/nw/i_video.c src/nw/i_input.c src/nw/i_sound.c src/nw/saves.c src/nw/main.c src/nw/scan.c src/nw/plat_eadk.c
PORT_ASM = src/nw/data.S
-PORT_FLAGS = -DEPSILON_XL=1 -Isrc -Isrc/doom -Isrc/compat -Isrc/nw -DNDEBUG -DDOOM_WHX='"src/doom1.whx"' -DDOOM_MIP='"src/doom1.mip"'
+PORT_CXX = src/pd_render.cpp
+PORT_CXXFLAGS = -std=gnu++17
+PORT_FLAGS = -DEPSILON_XL=1 $(INC) -fwrapv -DNDEBUG -DDOOM_WHX='"$(WHX)"' -DDOOM_MIP='"$(MIP)"' -w
include ../../platform/port.mk
diff --git a/games/doom/src/nw/doomconf.h b/games/doom/src/nw/doomconf.h
index 076910a5..43ee25cd 100644
--- a/games/doom/src/nw/doomconf.h
+++ b/games/doom/src/nw/doomconf.h
@@ -110,13 +110,13 @@
#define NO_USE_SOUND 1
#define NO_USE_MUSIC 1
#define NO_USE_MOUSE 1
-#if !defined(HOST)
+#if !defined(HOST) && !defined(NP_PORT) /* (another target, a computer's 64-bit pointers: as the tests') */
#define NW_SHORTPTR 1 /* pointers into RAM in 16 bits, as on the RP2040 (doomtype.h) */
#endif
#ifndef __ASSEMBLER__
#include <stdint.h>
-#if !defined(HOST)
+#if !defined(HOST) && !defined(NP_PORT)
/* the calculator has no console and no files but Epsilon's: what the engine prints goes nowhere */
#include <stdio.h>
#define printf(...) ((void)0)
@@ -131,5 +131,9 @@ typedef unsigned int uint;
#define __fast_mul(a, b) ((a) * (b))
#define panic_unsupported() I_Error("unsupported")
#endif
+#if defined(NP_PORT) && defined(__EMSCRIPTEN__) /* (the web's C library has no sys/cdefs.h) */
+#define __CONCAT(x, y) x##y
+#define __STRING(x) #x
+#endif
#endif
diff --git a/games/doom/src/nw/i_system.c b/games/doom/src/nw/i_system.c
index d0e956df..c3ab00c1 100644
--- a/games/doom/src/nw/i_system.c
+++ b/games/doom/src/nw/i_system.c
@@ -86,7 +86,7 @@ uint64_t time_us_64(void) { return (uint64_t)plat_millis() * 1000; }
/* ------------------------------------------------------------------ the end */
boolean nw_quit;
-#if defined(HOST) && defined(__APPLE__)
+#if (defined(HOST) && defined(__APPLE__)) || defined(NP_PORT)
jmp_buf nw_exit;
#else
void *nw_exit[5];
diff --git a/games/doom/src/nw/main.c b/games/doom/src/nw/main.c
index 42d07565..147d380c 100644
--- a/games/doom/src/nw/main.c
+++ b/games/doom/src/nw/main.c
@@ -34,6 +34,8 @@ int main(void) {
if (nw_home) nw_resume_save();
}
nw_settings_save();
+#ifndef NP_PORT
while (plat_keys()) plat_sleep(10); /* (the key that quit is not given to the calculator) */
+#endif
return plat_end();
}
diff --git a/games/doom/src/nw/nw.h b/games/doom/src/nw/nw.h
index e31d47f8..8c1c9107 100644
--- a/games/doom/src/nw/nw.h
+++ b/games/doom/src/nw/nw.h
@@ -13,7 +13,7 @@ extern int nw_warp;
/* i_system.c: Home, On/Off and Quit end the main loop; I_Error and I_Quit jump back to main
* (__builtin_setjmp and __builtin_longjmp on nw_exit) */
extern boolean nw_quit;
-#if defined(HOST) && defined(__APPLE__) /* (a Mac's compiler has no __builtin_setjmp on arm64) */
+#if (defined(HOST) && defined(__APPLE__)) || defined(NP_PORT) /* (no __builtin_setjmp on arm64) */
#include <setjmp.h>
extern jmp_buf nw_exit;
#define __builtin_setjmp setjmp
diff --git a/games/numdrive/Makefile b/games/numdrive/Makefile
index fb4f58dd..93ec5235 100644
--- a/games/numdrive/Makefile
+++ b/games/numdrive/Makefile
@@ -88,4 +88,6 @@ PORT_ID = numdrive
PORT_NAME = NumDrive
PORT_SRC = src/main.c src/world.c src/vm.c src/physics.c src/render.c src/inflate.c src/gfx.c src/ui.c src/save.c src/font.c src/platform_eadk.c
PORT_ASM = src/pack_data.S
+# (pack.bin found next to pack_data.S; a computer's 64-bit pointers: the host tests' arena)
+PORT_FLAGS = -Wa,-Isrc $(if $(filter sdl,$(TARGET)),-DARENA_SIZE=600000)
include ../../platform/port.mk
diff --git a/games/paperclips/Makefile b/games/paperclips/Makefile
index 268772b1..dec2ef54 100644
--- a/games/paperclips/Makefile
+++ b/games/paperclips/Makefile
@@ -78,6 +78,8 @@ clean:
# the other targets (platform/port.mk): make port TARGET=sdl, web, nspire, ti84ce
PORT_ID = paperclips
PORT_NAME = Universal Paperclips
-PORT_SRC = src/main.c src/sim.c src/projects.c src/num.c src/ui.c src/save.c src/plat_eadk.c src/font_data.c ../../launcher/src/gfx.c ../../launcher/src/xfont.c $(BUILD_DIR)/fr/main.c $(BUILD_DIR)/fr/sim.c $(BUILD_DIR)/fr/projects.c $(BUILD_DIR)/fr/num.c $(BUILD_DIR)/fr/ui.c $(BUILD_DIR)/fr/save.c $(BUILD_DIR)/fr/plat_eadk.c $(BUILD_DIR)/fr/font_data.c
-PORT_FLAGS = -DEPSILON_XL=1 -I../../launcher/src -Isrc -DPC_FR=1
+PORT_SRC = src/main.c src/sim.c src/projects.c src/num.c src/ui.c src/save.c src/plat_eadk.c ../../launcher/src/gfx.c \
+ ../../launcher/src/xfont.c
+PORT_FONT = src/font_data.c
+PORT_FLAGS = -DEPSILON_XL=1 -I../../launcher/src -Isrc -ffp-contract=off
include ../../platform/port.mk
diff --git a/games/suika/Makefile b/games/suika/Makefile
index 272e9117..faa0f5e3 100644
--- a/games/suika/Makefile
+++ b/games/suika/Makefile
@@ -86,5 +86,5 @@ test: build/play
# the other targets (platform/port.mk): make port TARGET=sdl, web, nspire, ti84ce
PORT_ID = suika
PORT_NAME = Suika Game
-PORT_SRC = src/main.c ../../launcher/src/gfx.c ../../launcher/src/xfont.c
+PORT_SRC = src/main.c ../../launcher/src/gfx.c ../../launcher/src/icons.c ../../launcher/src/xfont.c
include ../../platform/port.mk