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.
C calculatorcalculator-gamescasiochesscrossy-roaddrive-madfx-cg50gamesgeometry-dashgraphing-calculatorndlessnumworksnumworks-appsnumworks-calculatornumworks-gamenumworks-gamestetristi-84-plus-ceti-nspire
NumDash: its drawing strip on main's stack, 15 KB less RAM
Mason Chen432cc14493b0
diff --git a/games/numdash/src/gfx.c b/games/numdash/src/gfx.cindex 964beff3..ed070a7a 100644--- a/games/numdash/src/gfx.c+++ b/games/numdash/src/gfx.c@@ -3,7 +3,12 @@#include <string.h>#include "../../common/np_text.h"-uint16_t gfx_strip[GFX_W * STRIP_H] __attribute__((aligned(8)));+#if PLATFORM_DEVICE+uint16_t *gfx_strip; /* main() points it at a strip on its stack */+#else+static uint16_t host_strip[GFX_W * STRIP_H] __attribute__((aligned(8)));+uint16_t *gfx_strip = host_strip;+#endifint gfx_y0 = 0, gfx_y1 = STRIP_H;static int clip_x0 = 0, clip_y0 = 0, clip_x1 = GFX_W, clip_y1 = GFX_H;diff --git a/games/numdash/src/gfx.h b/games/numdash/src/gfx.hindex 5f446553..5cd1ec87 100644--- a/games/numdash/src/gfx.h+++ b/games/numdash/src/gfx.h@@ -8,7 +8,7 @@/* The screen is rendered in horizontal strips: every primitive clips to the* current strip, so a full frame needs only one strip of RGB565 memory. */enum { GFX_W = 320, GFX_H = 240, STRIP_H = 24, STRIPS = GFX_H / STRIP_H };-extern uint16_t gfx_strip[GFX_W * STRIP_H];+extern uint16_t *gfx_strip; /* (on main's stack: the RAM apps get is smaller on some calculator software) */extern int gfx_y0, gfx_y1;void gfx_begin_strip(int index);void gfx_clip(int x0, int y0, int x1, int y1);diff --git a/games/numdash/src/main.c b/games/numdash/src/main.cindex 5f04a5af..9174f782 100644--- a/games/numdash/src/main.c+++ b/games/numdash/src/main.c@@ -13,6 +13,10 @@ __attribute__((used)) volatile uint32_t perf_frames;int main(int argc, char **argv) {(void)argc;(void)argv;+#if PLATFORM_DEVICE+ uint16_t strip[GFX_W * STRIP_H] __attribute__((aligned(8)));+ gfx_strip = strip;+#endifif (!platform_init()) return 1;#if PLATFORM_DEVICEplatform_begin();diff --git a/games/numdash/tools/dev/icon.c b/games/numdash/tools/dev/icon.cindex dea6efd0..214aef11 100644--- a/games/numdash/tools/dev/icon.c+++ b/games/numdash/tools/dev/icon.c@@ -15,7 +15,7 @@ int main(int argc, char **argv) {float cx = x0 + 27.5f, cy = y0 + 42 - 14;gfx_sprite_ex(SPR_CUBE1_S, (int)(cx * 16), (int)(cy * 16), 0, 360, 0, rgb(0, 255, 255), 256, BLEND_NORMAL);gfx_sprite_ex(SPR_CUBE1_P, (int)(cx * 16), (int)(cy * 16), 0, 360, 0, rgb(125, 255, 0), 256, BLEND_NORMAL);- memcpy(fb + s * STRIP_H * GFX_W, gfx_strip, sizeof(gfx_strip));+ memcpy(fb + s * STRIP_H * GFX_W, gfx_strip, GFX_W * STRIP_H * sizeof(uint16_t));}FILE *f = fopen(argv[1], "wb");if (!f) return 1;diff --git a/games/numdash/tools/dev/shot.c b/games/numdash/tools/dev/shot.cindex 98f499fb..c526e491 100644--- a/games/numdash/tools/dev/shot.c+++ b/games/numdash/tools/dev/shot.c@@ -9,7 +9,7 @@ static void render(void) {for (int s = 0; s < STRIPS; s++) {gfx_begin_strip(s);scene_draw();- memcpy(fb + s * STRIP_H * GFX_W, gfx_strip, sizeof(gfx_strip));+ memcpy(fb + s * STRIP_H * GFX_W, gfx_strip, GFX_W * STRIP_H * sizeof(uint16_t));}}static void save(const char *path) {