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
TI-84 CE: Block Blast, Space Invaders, Sudoku, Ultimate Tic-Tac-Toe and Sokoban
Mason363ef9923d32a94
diff --git a/games/blockblast/src/main.c b/games/blockblast/src/main.cindex bdc700a5..841af7bd 100644--- a/games/blockblast/src/main.c+++ b/games/blockblast/src/main.c@@ -42,7 +42,8 @@ void np_push(int x, int y, int w, int h, const color_t *px) {/* The blocks, as five rows of five cells (the first one leftmost), and how often each comes(in the top 7 bits): every way a block faces is a block of its own. */-#define B(w, a, b, c, d, e) ((uint32_t)(w) << 25 | (a) << 20 | (b) << 15 | (c) << 10 | (d) << 5 | (e))+#define B(w, a, b, c, d, e) \+ ((uint32_t)(w) << 25 | (uint32_t)(a) << 20 | (uint32_t)(b) << 15 | (uint32_t)(c) << 10 | (uint32_t)(d) << 5 | (uint32_t)(e))#define I 0x10static const uint32_t pieces[] = {B(9, I, 0, 0, 0, 0), /* one */@@ -119,7 +120,7 @@ static uint32_t ago(uint32_t t) { return now - t; }/* ------------------------------------------------------------ the rules */static void measure(int p) { /* w and h: the columns any of its rows reach, the rows down to its last cell */uint32_t m = pieces[p] << 7, cols = (m | m << 5 | m << 10 | m << 15 | m << 20) >> 27;- w = 5 - __builtin_ctz(cols), h = (31 - __builtin_ctz(m)) / 5 + 1;+ w = 5 - __builtin_ctzl(cols), h = (31 - __builtin_ctzl(m)) / 5 + 1;}static bool fits(int p, int x, int y) {EACH(p) if (x + c >= N || y + r >= N || sv.board[(y + r) * N + x + c]) return false;@@ -323,7 +324,7 @@ static void scene(void *ctx) {else gfx_fill(x, y, P - 1, P - 1, HEX(0x242C53));if (fx[k]) { /* bursting: flashes, then shrinks away, from where the block went outwards */int ax = 2 * (k % N) + 1 - fx_x, ay = 2 * (k / N) + 1 - fx_y;- int t = (int)ago(fx_t) - ((ax < 0 ? -ax : ax) + (ay < 0 ? -ay : ay)) * 14;+ int32_t t = (int32_t)ago(fx_t) - ((ax < 0 ? -ax : ax) + (ay < 0 ? -ay : ay)) * 14;if (t < 0) t = 0;if (t < 240) {int z = (P - 1) * (240 - t) / 240, o = (P - 1 - z) / 2;diff --git a/games/invaders/src/main.c b/games/invaders/src/main.cindex 5b2a03d6..30dc82a8 100644--- a/games/invaders/src/main.c+++ b/games/invaders/src/main.c@@ -41,7 +41,7 @@ void np_push(int x, int y, int w, int h, const color_t *px) {#endif/* the keys used, in 32 bits: 4, 5, 6, 2 and EXE come down from the high word */-#define KEY(k) (1u << ((k) - ((k) >= 32) * 24))+#define KEY(k) ((uint32_t)1 << ((k) - ((k) >= 32) * 24))#define X0 48 /* the arcade's 224 columns, in the middle of the screen */#define OFF 7 /* and its rows from row 7 on */#define TOPY 32 /* the cannon's shots burst here, at the top of the red film */@@ -191,7 +191,7 @@ static void hud(void) {}}static void screen(void) { /* a clean picture: the scores and the credits */- for (uint8_t *p = vram[0]; p < vram[240]; p++) *p = 0;+ for (uint8_t *p = vram[0]; p < vram[0] + sizeof vram; p++) *p = 0;text(8, 8, "SCORE<1> HI-SCORE SCORE<2>", 26), text(168, 24, "0000", 4), text(136, LY, "CREDIT 00", 9);dirty = ALL;hud();diff --git a/games/sokoban/Makefile b/games/sokoban/Makefileindex f3998eb0..95696153 100644--- a/games/sokoban/Makefile+++ b/games/sokoban/Makefile@@ -104,4 +104,5 @@ PORT_ID = sokobanPORT_NAME = SokobanPORT_SRC = src/main.c ../../launcher/src/gfx.c ../../launcher/src/xfont.c ../../launcher/src/inflate.cPORT_FLAGS = -I$(BUILD_DIR)+PORT_DEPS = $(LEVELS)include ../../platform/port.mkdiff --git a/games/sokoban/src/main.c b/games/sokoban/src/main.cindex 8cd47db5..f49ea592 100644--- a/games/sokoban/src/main.c+++ b/games/sokoban/src/main.c@@ -38,7 +38,7 @@ void np_push(int x, int y, int w, int h, const color_t *px) {#include "levels.inc" /* levels_z, LEVELS (inside NumPlay, fewer: see the Makefile), ALL_LEVELS, TEXT_BYTES, MAXW, MAXH *//* the keys used, in 32 bits: those past the 32nd (4 5 6 2 EXE) come down by 22 */-#define KEY(k) (1u << ((k) - ((k) >= 32) * 22))+#define KEY(k) ((uint32_t)1 << ((k) - ((k) >= 32) * 22))static uint32_t keys(void) {uint64_t s = eadk_keyboard_scan();return ((uint32_t)s & 0x800201FFu) | ((uint32_t)(s >> 32) & 0x00100870u) << 10;@@ -116,6 +116,9 @@ static void mark_cell(int i) { mark(oy + (i / MAXW - 1) * size, oy + (i / MAXW +/* ------------------------------------------------------------ the level */static void open_level(int n) {+#ifdef __TICE__+ static /* (not on the TI-84 CE's 4 KB stack) */+#endifuint32_t tables[816]; /* np_inflate's two Huffman tables, 2 x 1632 bytes */const uint8_t *t = (const uint8_t *)strip;np_inflate((uint8_t *)strip, TEXT_BYTES, levels_z, sizeof levels_z, (np_inflate_tables_t *)(void *)tables);diff --git a/games/sudoku/src/main.c b/games/sudoku/src/main.cindex 383379af..f4247da9 100644--- a/games/sudoku/src/main.c+++ b/games/sudoku/src/main.c@@ -37,7 +37,7 @@ void np_push(int x, int y, int w, int h, const color_t *px) {#endif/* the keys used, in 32 bits: the number pad's 9, 4 to 6, 1 to 3, 0 and EXE come down from the high word */-#define KEY(k) (1u << ((k) < 32 ? (k) : (k) - 23))+#define KEY(k) ((uint32_t)1 << ((k) < 32 ? (k) : (k) - 23))static uint32_t keys(void) {uint64_t s = eadk_keyboard_scan();return ((uint32_t)s & 0xC00211FFu) | ((uint32_t)(s >> 32) & 0x00111C71u) << 9;diff --git a/games/uttt/src/main.c b/games/uttt/src/main.cindex 63eb8831..d04f9382 100644--- a/games/uttt/src/main.c+++ b/games/uttt/src/main.c@@ -34,7 +34,7 @@ static uint32_t keys(void) {uint64_t s = eadk_keyboard_scan();return ((uint32_t)s & 0xC000017Fu) | ((uint32_t)(s >> 32) & 0x00101C71u) << 9;}-#define KEY(k) (1u << ((k) < 32 ? (k) : (k) - 23))+#define KEY(k) ((uint32_t)1 << ((k) < 32 ? (k) : (k) - 23))/* the number pad as a small board, 7 at the top left: where each key's bit is in keys() */static const uint8_t DIGIT[9] = {30, 31, 9, 13, 14, 15, 19, 20, 21};#define QUIT (KEY(eadk_key_home) | KEY(eadk_key_on_off))