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.

TI-84 CE: more games draw only what changed

Mason363b366d1ec7114
diff --git a/games/breakout/src/main.c b/games/breakout/src/main.c
index 69014673..5d9fcfc4 100644
--- a/games/breakout/src/main.c
+++ b/games/breakout/src/main.c
@@ -62,10 +62,18 @@ static uint32_t rnd(void) {
static int rndi(int n) { return (int)(rnd() % (uint32_t)n); }
/* f over b; a from 0 (all b) to 32 (all f) */
+#ifdef __TICE__ /* the TI-84 Plus CE: its own mixing (the same colours) */
+#include "../../../platform/ti84ce/ce_draw.h"
+__attribute__((naked)) static color ce_mix(color a, color b, unsigned t) { __asm__(CE_MIX_ASM); }
+#endif
static color mix(color f, color b, int a) {
+#ifdef __TICE__
+ return ce_mix(b, f, (unsigned)a);
+#else
uint32_t x = (f | (uint32_t)f << 16) & 0x07E0F81F, y = (b | (uint32_t)b << 16) & 0x07E0F81F;
y = (y + ((x - y) * (uint32_t)a >> 5)) & 0x07E0F81F;
return (color)(y | y >> 16);
+#endif
}
/* ------------------------------------------------------------------ bricks */
diff --git a/games/chess/src/main.c b/games/chess/src/main.c
index 4fcde682..ed197b50 100644
--- a/games/chess/src/main.c
+++ b/games/chess/src/main.c
@@ -37,11 +37,17 @@ static C buf[900];
/* ------------------------------------------------------------ Drawing */
+#ifdef __TICE__ /* the TI-84 Plus CE: its own mixing (the same colours, without a 24-bit int's overflow) */
+#include "../../../platform/ti84ce/ce_draw.h"
+__attribute__((naked)) static C ce_mix(C a, C b, unsigned t) { __asm__(CE_MIX_ASM); }
+static C mix(C a, C b, int t) { return ce_mix(a, b, (unsigned)t); }
+#else
static C mix(C a, C b, int t) {
uint32_t A = (a | a << 16) & 0x07E0F81F, B = (b | b << 16) & 0x07E0F81F;
uint32_t M = ((A * (32 - t) + B * t) >> 5) & 0x07E0F81F;
return M | M >> 16;
}
+#endif
static void fill(int x, int y, int w, int h, C c) {
eadk_display_push_rect_uniform((eadk_rect_t){x, y, w, h}, c);
diff --git a/games/connectfour/src/main.c b/games/connectfour/src/main.c
index e2a7f61c..543d2468 100644
--- a/games/connectfour/src/main.c
+++ b/games/connectfour/src/main.c
@@ -41,10 +41,18 @@ static const color THEME[2][4] = {
{RGB(0x1F2740), RGB(0x080B14), RGB(0xE9EEF8), RGB(0x8C98B4)},
};
+#ifdef __TICE__ /* the TI-84 Plus CE: its own mixing (the same colours) */
+#include "../../../platform/ti84ce/ce_draw.h"
+__attribute__((naked)) static color ce_mix(color a, color b, unsigned t) { __asm__(CE_MIX_ASM); }
+#endif
static color mix(color f, color b, int a) { /* f over b, a from 0 to 32 */
+#ifdef __TICE__
+ return ce_mix(b, f, (unsigned)a);
+#else
uint32_t x = (f | (uint32_t)f << 16) & 0x07E0F81F, y = (b | (uint32_t)b << 16) & 0x07E0F81F;
y = (y + ((x - y) * (uint32_t)a >> 5)) & 0x07E0F81F;
return (color)(y | y >> 16);
+#endif
}
static int clamp(int v, int a, int b) { return v < a ? a : v > b ? b : v; }
static int iabs(int v) { return v < 0 ? -v : v; }
diff --git a/games/coreball/src/main.c b/games/coreball/src/main.c
index 1ed904d5..69dca982 100644
--- a/games/coreball/src/main.c
+++ b/games/coreball/src/main.c
@@ -191,6 +191,12 @@ static float sin10(int a) { /* the sine of a in tenths of a degree */
}
static void put(int x, int y, color_t c, int a32) {
if ((unsigned)x < SCREEN_W && y >= gfx_y0 && y < gfx_y1 && a32 > 0) {
+#ifdef __TICE__
+ if (gfx_listing) { /* (its strip is drawn every time) */
+ gfx_list_rows(y, y + 1);
+ return;
+ }
+#endif
color_t *p = gfx_buf + (y - gfx_y0) * SCREEN_W + x;
*p = gfx_mix(*p, c, a32 > 32 ? 32 : a32);
}
diff --git a/games/dinorun/src/main.c b/games/dinorun/src/main.c
index ad5669bc..65771609 100644
--- a/games/dinorun/src/main.c
+++ b/games/dinorun/src/main.c
@@ -667,12 +667,39 @@ static uint8_t bg, ink, soft;
static int clip_x0, clip_x1, clip_y0, clip_y1; /* what may be drawn on (the canvas, or the screen) */
static uint8_t inv(float e, int v) { return (uint8_t)(v + (255 - 2 * v) * e + 0.5f); }
+#ifdef __TICE__
+/* The TI-84 Plus CE: a band's tiles are drawn only where what draws them changed. The band's calls run once to
+ sign what they would draw (their arguments, hashed into each tile they cover); then only the tiles whose
+ signature changed are drawn (ce_x0 to ce_x1) and sent. */
+#include <string.h>
+static bool signing;
+static uint32_t tsig[TILES_X];
+static int ce_x0, ce_x1 = W;
+static void sign(const int *v, int n, int x0, int x1) {
+ uint32_t h = 2166136261u;
+ for (int i = 0; i < n; i++) h = (h ^ (uint32_t)v[i]) * 16777619u;
+ for (int c = x0 / TILE_W; c <= (x1 - 1) / TILE_W && c < TILES_X; c++) tsig[c] = (tsig[c] ^ h) * 16777619u;
+}
+#endif
static void clip_screen(void) { clip_x0 = 0, clip_x1 = W, clip_y0 = 0, clip_y1 = H; }
static void fill(int x, int y, int w, int h, uint8_t c) {
int x0 = x < clip_x0 ? clip_x0 : x, x1 = x + w > clip_x1 ? clip_x1 : x + w;
int y0 = y < clip_y0 ? clip_y0 : y, y1 = y + h > clip_y1 ? clip_y1 : y + h;
if (y0 < band_y) y0 = band_y;
if (y1 > band_y + BAND) y1 = band_y + BAND;
+#ifdef __TICE__
+ if (x0 >= x1 || y0 >= y1) return;
+ if (signing) {
+ const int v[] = {1, x0, x1, y0, y1, c};
+ sign(v, 6, x0, x1);
+ return;
+ }
+ if (x0 < ce_x0) x0 = ce_x0;
+ if (x1 > ce_x1) x1 = ce_x1;
+ if (x0 >= x1) return;
+ for (int r = y0; r < y1; r++) memset(band + (r - band_y) * W + x0, c, (size_t)(x1 - x0));
+ return;
+#endif
for (int r = y0; r < y1; r++)
for (int c2 = x0; c2 < x1; c2++) band[(r - band_y) * W + c2] = c;
}
@@ -684,6 +711,38 @@ static void blit(int region, int sx, int sy, int w, int h, int dx, int dy, int a
int y0 = dy < clip_y0 ? clip_y0 : dy, y1 = dy + h > clip_y1 ? clip_y1 : dy + h;
if (y0 < band_y) y0 = band_y;
if (y1 > band_y + BAND) y1 = band_y + BAND;
+#ifdef __TICE__
+ if (signing) {
+ if (x0 < x1 && y0 < y1) {
+ const int v[] = {2, region, sx, sy, dx, dy, x0, x1, y0, y1, a};
+ sign(v, 11, x0, x1);
+ }
+ return;
+ }
+ if (x0 < ce_x0) x0 = ce_x0;
+ if (x1 > ce_x1) x1 = ce_x1;
+#endif
+#ifdef __TICE__ /* (the sheet's 2-bit pixels a byte at a time, no shifts) */
+ if (x0 < x1) {
+ static uint8_t px4[256][4];
+ if (!px4[255][0])
+ for (int v = 0; v < 256; v++)
+ for (int k = 0; k < 4; k++) px4[v][k] = (uint8_t)(v >> (2 * k) & 3);
+ for (int y = y0; y < y1; y++) {
+ int u = sx + x0 - dx;
+ const uint8_t *src = sheet + rg->off + (sy + y - dy) * rg->stride + (u >> 2);
+ uint8_t *d = band + (y - band_y) * W, k = (uint8_t)(u & 3);
+ for (int x = x0; x < x1; x++) {
+ uint8_t t = px4[*src][k];
+ if (++k == 4) k = 0, src++;
+ if (!t) continue;
+ if (a >= 256) d[x] = tone[t];
+ else d[x] = (uint8_t)(d[x] + ((tone[t] - d[x]) * a >> 8));
+ }
+ }
+ }
+ return;
+#endif
for (int y = y0; y < y1; y++) {
const uint8_t *src = sheet + rg->off + (sy + y - dy) * rg->stride;
uint8_t *d = band + (y - band_y) * W;
@@ -869,7 +928,45 @@ static uint32_t tile_hash(int x) {
}
return h;
}
+#ifdef __TICE__
+static uint8_t grey_mem[512 + 255];
+/* n (1..255) greys from s as colours at d, through the tables at t (256-aligned) */
+__attribute__((naked)) static void grey_row(uint16_t *d, const uint8_t *s, unsigned n, const uint8_t *t) {
+ __asm__(
+ "ld iy, 0\n"
+ "add iy, sp\n"
+ "push ix\n"
+ "ld ix, (iy + 3)\n"
+ "ld de, (iy + 6)\n"
+ "ld b, (iy + 9)\n"
+ "ld hl, (iy + 12)\n"
+ "1:\n"
+ "ld a, (de)\n"
+ "ld l, a\n"
+ "ld a, (hl)\n"
+ "ld (ix + 0), a\n"
+ "inc h\n"
+ "ld a, (hl)\n"
+ "ld (ix + 1), a\n"
+ "dec h\n"
+ "inc de\n"
+ "lea ix, ix + 2\n"
+ "djnz 1b\n"
+ "pop ix\n"
+ "ret\n");
+}
+#endif
static void send_band(int b) {
+#ifdef __TICE__ /* (the TI-84 Plus CE: the tiles that changed, ce_x0 to ce_x1, not hashed) */
+ uint8_t *t = (uint8_t *)(((unsigned)grey_mem + 255) & ~255u); /* the colours' low bytes, then their high bytes */
+ if (!t[256 + 255])
+ for (int v = 0; v < 256; v++) t[v] = (uint8_t)rgb((uint8_t)v), t[256 + v] = (uint8_t)(rgb((uint8_t)v) >> 8);
+ int w = ce_x1 - ce_x0;
+ for (int y = 0; y < BAND; y++)
+ for (int i = 0; i < w; i += 160) grey_row(upload + y * w + i, band + y * W + ce_x0 + i, (unsigned)(w - i < 160 ? w - i : 160), t);
+ eadk_display_push_rect((eadk_rect_t){(uint16_t)ce_x0, (uint16_t)(b * BAND), (uint16_t)w, BAND}, upload);
+ return;
+#endif
int run = -1;
for (int c = 0; c <= TILES_X; c++) {
bool changed = false;
@@ -881,6 +978,19 @@ static void send_band(int b) {
if (changed && run < 0) run = c;
if (!changed && run >= 0) {
int x = run * TILE_W, w = (c - run) * TILE_W;
+#ifdef __TICE__ /* (a table of the 256 greys) */
+ {
+ static uint16_t grey[256];
+ if (!grey[255])
+ for (int v = 0; v < 256; v++) grey[v] = rgb((uint8_t)v);
+ for (int y = 0; y < BAND; y++) {
+ const uint8_t *q = band + y * W + x;
+ uint16_t *u = upload + y * w;
+ for (int i = 0; i < w; i++) u[i] = grey[q[i]];
+ }
+ }
+ if (0)
+#endif
for (int y = 0; y < BAND; y++)
for (int i = 0; i < w; i++) upload[y * w + i] = rgb(band[y * W + x + i]);
eadk_display_push_rect((eadk_rect_t){(uint16_t)x, (uint16_t)(b * BAND), (uint16_t)w, BAND}, upload);
@@ -897,6 +1007,31 @@ static void frame(void) {
int cw = container_w();
for (int b = 0; b < BANDS; b++) {
band_y = b * BAND;
+#ifdef __TICE__
+ signing = true, ce_x0 = 0, ce_x1 = W;
+ for (int c = 0; c < TILES_X; c++) tsig[c] = 2166136261u;
+ const int v[] = {bg, tone[1], tone[2], tone[3], soft, ink, cw, menu, menu_sel};
+ sign(v, 9, 0, W);
+ draw_canvas(cw);
+ if (menu) draw_menu();
+ draw_hints();
+ signing = false;
+ int first = -1, last = -1;
+ for (int c = 0; c < TILES_X; c++)
+ if (!hashes_valid || tsig[c] != hashes[b][c]) {
+ if (first < 0) first = c;
+ last = c, hashes[b][c] = tsig[c];
+ }
+ if (first < 0) continue;
+ ce_x0 = first * TILE_W, ce_x1 = (last + 1) * TILE_W;
+ for (int y = 0; y < BAND; y++) memset(band + y * W + ce_x0, bg, (size_t)(ce_x1 - ce_x0));
+ draw_canvas(cw);
+ if (menu) draw_menu();
+ draw_hints();
+ send_band(b);
+ ce_x0 = 0, ce_x1 = W;
+ continue;
+#endif
for (int i = 0; i < W * BAND; i++) band[i] = bg;
draw_canvas(cw);
if (menu) draw_menu();
diff --git a/games/flappybird/src/main.c b/games/flappybird/src/main.c
index 05947a07..6c739c23 100644
--- a/games/flappybird/src/main.c
+++ b/games/flappybird/src/main.c
@@ -60,10 +60,18 @@ static int16_t sn[256]; /* sine, -256..256 */
#define COS(a) sn[((a) + 64) & 255]
/* f over b; a from 0 (all b) to 32 (all f) */
+#ifdef __TICE__ /* the TI-84 Plus CE: its own mixing (the same colours) */
+#include "../../../platform/ti84ce/ce_draw.h"
+__attribute__((naked)) static color ce_mix(color a, color b, unsigned t) { __asm__(CE_MIX_ASM); }
+#endif
static color mix(color f, color b, int a) {
+#ifdef __TICE__
+ return ce_mix(b, f, (unsigned)a);
+#else
uint32_t x = (f | (uint32_t)f << 16) & 0x07E0F81F, y = (b | (uint32_t)b << 16) & 0x07E0F81F;
y = (y + ((x - y) * (uint32_t)a >> 5)) & 0x07E0F81F;
return (color)(y | y >> 16);
+#endif
}
/* ------------------------------------------------------------------ drawing */
diff --git a/games/flappydunk/src/main.c b/games/flappydunk/src/main.c
index 380a9151..1cf0f09c 100644
--- a/games/flappydunk/src/main.c
+++ b/games/flappydunk/src/main.c
@@ -276,11 +276,27 @@ static void step(void) {
/* ------------------------------------------------------------ drawing */
static inline void px(int x, int y, color_t c) {
- if ((unsigned)x < SCREEN_W && y >= gfx_y0 && y < gfx_y1) gfx_buf[(y - gfx_y0) * SCREEN_W + x] = c;
+ if ((unsigned)x < SCREEN_W && y >= gfx_y0 && y < gfx_y1) {
+#ifdef __TICE__
+ if (gfx_listing) { /* (its strip is drawn every time) */
+ gfx_list_rows(y, y + 1);
+ return;
+ }
+#endif
+ gfx_buf[(y - gfx_y0) * SCREEN_W + x] = c;
+ }
}
static void line(float x0, float y0, float x1, float y1, color_t c) {
float dx = x1 - x0, dy = y1 - y0, n = fabs_(dx) > fabs_(dy) ? fabs_(dx) : fabs_(dy);
if ((y0 < gfx_y0 - 1 && y1 < gfx_y0 - 1) || (y0 > gfx_y1 && y1 > gfx_y1)) return;
+#ifdef __TICE__ /* (the TI-84 Plus CE: the same points, stepping in 65536ths of a pixel) */
+ {
+ int32_t fx = (int32_t)(x0 * 65536), fy = (int32_t)(y0 * 65536), m = (int)n;
+ int32_t sx = (int32_t)(dx / (n + 0.01f) * 65536), sy = (int32_t)(dy / (n + 0.01f) * 65536);
+ for (int i = 0; i <= m; i++, fx += sx, fy += sy) px((int)(fx >> 16), (int)(fy >> 16), c);
+ return;
+ }
+#endif
for (int i = 0; i <= (int)n; i++) px((int)(x0 + dx * i / (n + 0.01f)), (int)(y0 + dy * i / (n + 0.01f)), c);
}
@@ -356,6 +372,34 @@ static void ball_at(int cx, int cy, float rad, int skin, float rc, float rs) {
col[4] = HEX(0x111111);
int n = (int)rad + 2;
float inv = 1.0f / rad;
+#ifdef __TICE__ /* (the TI-84 Plus CE: in 32nds of a pixel, the same tests squared: no float, no square root) */
+ {
+ int RC = (int)(rc * 32), RS = (int)(rs * 32), r32 = (int)(rad * 32), w = 16; /* (w: half a pixel) */
+ int in2 = (r32 - 32) * (r32 - 32), out2 = r32 * r32, cx1 = (int)(1.1f * r32), ar = (int)(0.78f * r32);
+ int lo = (ar - w) * (ar - w), hi = (ar + w) * (ar + w), l1 = (int)(0.35f * rad * 160), l2 = (int)(-0.3f * rad * 160);
+ for (int y = -n; y <= n; y++) {
+ int sy = cy + y;
+ if (sy < gfx_y0 || sy >= gfx_y1) continue;
+ for (int x = -n; x <= n; x++) {
+ int d2 = (x * x + y * y) * 1024;
+ if (d2 > out2) continue;
+ color_t c;
+ if (d2 > in2) c = col[4];
+ else {
+ int u = x * RC + y * RS, v = y * RC - x * RS, v2 = v * v;
+ int q1 = (u - cx1) * (u - cx1) + v2, q2 = (u + cx1) * (u + cx1) + v2;
+ if ((u < w && u > -w) || (v < w && v > -w) || (q1 > lo && q1 < hi) || (q2 > lo && q2 < hi)) c = col[3];
+ else {
+ int l = -96 * x - 112 * y; /* (-0.6 and -0.7, times 160) */
+ c = l > l1 ? col[0] : l > l2 ? col[1] : col[2];
+ }
+ }
+ px(cx + x, sy, c);
+ }
+ }
+ return;
+ }
+#endif
for (int y = -n; y <= n; y++) {
int sy = cy + y;
if (sy < gfx_y0 || sy >= gfx_y1) continue;
@@ -385,6 +429,39 @@ static void wing(int jx, int jy, float c, float s, bool back) {
static const float fe[3][4] = {{6.2f, 2.0f, 6.6f, 2.2f}, {4.8f, -0.4f, 5.0f, 1.8f}, {3.4f, -2.5f, 3.6f, 1.5f}};
color_t ink = HEX(0x111111), col[3] = {0xFFFF, HEX(0xEBEBEB), HEX(0xDEDEDE)};
if (back) col[0] = col[1] = col[2] = HEX(0xC8C8C8);
+#ifdef __TICE__ /* (the TI-84 Plus CE: each way the wing turns worked out once, its pixels' colours) */
+ static struct {
+ float c, s;
+ uint8_t k[27 * 27]; /* 0 none, 1-3 a feather, 4 the ink */
+ } shapes[6];
+ static int nshapes;
+ int i = 0;
+ while (i < nshapes && (shapes[i].c != c || shapes[i].s != s)) i++;
+ if (i == nshapes) {
+ if (i == 6) i = 0, nshapes = 0;
+ shapes[i].c = c, shapes[i].s = s, nshapes++;
+ for (int y = -13, n = 0; y <= 13; y++)
+ for (int x = -13; x <= 13; x++, n++) {
+ float wx = -(x * c + y * s), wy = -(y * c - x * s);
+ shapes[i].k[n] = 0;
+ for (int k = 0; k < 3; k++) {
+ float dx = (wx - fe[k][0]) / (fe[k][2] + 1), dy = (wy - fe[k][1]) / (fe[k][3] + 1), e = dx * dx + dy * dy;
+ if (e >= 1) continue;
+ dx = (wx - fe[k][0]) / fe[k][2], dy = (wy - fe[k][1]) / fe[k][3];
+ shapes[i].k[n] = (uint8_t)(dx * dx + dy * dy < 1 ? k + 1 : 4);
+ break;
+ }
+ }
+ }
+ const uint8_t *m = shapes[i].k;
+ for (int y = -13; y <= 13; y++, m += 27) {
+ int sy = jy + y;
+ if (sy < gfx_y0 || sy >= gfx_y1) continue;
+ for (int x = 0; x < 27; x++)
+ if (m[x]) px(jx - 13 + x, sy, m[x] == 4 ? ink : col[m[x] - 1]);
+ }
+ return;
+#endif
for (int y = -13; y <= 13; y++) {
int sy = jy + y;
if (sy < gfx_y0 || sy >= gfx_y1) continue;
@@ -524,6 +601,9 @@ int main(void) {
np_app_begin();
color_t *their_strip = gfx_buf;
gfx_buf = strip;
+#ifdef __TICE__
+ gfx_pure = true; /* (its own pixels make their strips drawn every time) */
+#endif
now = (uint32_t)eadk_timing_millis();
load();
if (sv.flags & 1) ready = true, best0 = sv.best, cam = RUN.x - BALL_SX / PX;
diff --git a/games/imposter/src/ui.c b/games/imposter/src/ui.c
index b2640227..11e8f781 100644
--- a/games/imposter/src/ui.c
+++ b/games/imposter/src/ui.c
@@ -97,6 +97,14 @@ static void cubic(int t, int32_t *w) {
/* n letters of s, s256/256 times the font's size, from x on the baseline: each pixel the font's coverage
* between its pixels (bicubic), sharpened as much as the letters grow */
static void big_run(const char *s, int n, int x, int base, int s256, color_t c) {
+#ifdef __TICE__
+ if (gfx_listing) { /* (what it depends on, in the strips' lists) */
+ const int v[] = {n, x, base, s256, c};
+ gfx_list(v, sizeof v);
+ gfx_list(s, (unsigned)n);
+ return;
+ }
+#endif
int32_t pen = (int32_t)x * 256; /* in 1/256 pixels */
int32_t du = (int32_t)(((uint32_t)1 << 24) / (uint32_t)s256); /* the font's 1/65536 pixels a screen pixel */
int sharp = 16 + (s256 - 256) * BIG_SHARP / 64; /* (in 1/16) */
diff --git a/games/invaders/src/main.c b/games/invaders/src/main.c
index 30dc82a8..b20b6aeb 100644
--- a/games/invaders/src/main.c
+++ b/games/invaders/src/main.c
@@ -255,6 +255,25 @@ static void overlay(void) {
/* the picture's rows in the strip, through the cabinet's film */
static void scene(void *ctx) {
gfx_fill(0, gfx_y0, SCREEN_W, gfx_y1 - gfx_y0, 0);
+#ifdef __TICE__ /* (the TI-84 Plus CE: the picture's rows in the strips' lists; drawn a byte at a time, no shifts) */
+ if (gfx_listing) {
+ gfx_list(vram[gfx_y0], (unsigned)(gfx_y1 - gfx_y0) * sizeof vram[0]);
+ } else {
+ static const uint8_t bit[8] = {0x80, 0x40, 0x20, 0x10, 8, 4, 2, 1};
+ for (int y = gfx_y0; y < gfx_y1; y++) {
+ int py = y + OFF;
+ color_t c = py >= TOPY && py < 64 ? RED : py >= 184 ? GREEN : WHITE, *o = gfx_buf + (y - gfx_y0) * SCREEN_W + X0;
+ bool low = py >= LY;
+ for (int i = 0, x = 0; i < 28; i++, x += 8) {
+ uint8_t b = vram[y][i];
+ if (b)
+ for (int k = 0; k < 8; k++)
+ if (b & bit[k]) o[x + k] = low && (x + k < 16 || x + k >= 134) ? WHITE : c;
+ }
+ }
+ }
+ if (0)
+#endif
for (int y = gfx_y0; y < gfx_y1; y++) {
int py = y + OFF;
color_t c = py >= TOPY && py < 64 ? RED : py >= 184 ? GREEN : WHITE, *o = gfx_buf + (y - gfx_y0) * SCREEN_W + X0;
diff --git a/games/mahjong/src/main.c b/games/mahjong/src/main.c
index 87b45202..49628f40 100644
--- a/games/mahjong/src/main.c
+++ b/games/mahjong/src/main.c
@@ -391,6 +391,14 @@ static char *cat(char *o, const char *s) {
}
static void face_art(int k, int x, int y) {
+#ifdef __TICE__
+ if (gfx_listing) { /* (what it depends on, in the strips' lists) */
+ const int v[] = {k, x, y};
+ gfx_list(v, sizeof v);
+ gfx_list(pal, sizeof pal);
+ return;
+ }
+#endif
const uint8_t *a = art + k * (ART_W / 2 * ART_H);
int r0 = y < gfx_y0 ? gfx_y0 - y : 0, r1 = y + ART_H > gfx_y1 ? gfx_y1 - y : ART_H;
for (int r = r0; r < r1; r++) {
diff --git a/games/meowdoku/src/main.c b/games/meowdoku/src/main.c
index 589f8ca5..0c32d98b 100644
--- a/games/meowdoku/src/main.c
+++ b/games/meowdoku/src/main.c
@@ -514,6 +514,12 @@ static int cat_w, cat_h, cell_w;
static inline void blend(int x, int y, color_t c, int a) {
if (a > 0 && x >= 0 && x < SCREEN_W && y >= gfx_y0 && y < gfx_y1) {
+#ifdef __TICE__
+ if (gfx_listing) { /* (its strip is drawn every time) */
+ gfx_list_rows(y, y + 1);
+ return;
+ }
+#endif
color_t *p = gfx_buf + (y - gfx_y0) * SCREEN_W + x;
*p = a >= 32 ? c : gfx_mix(*p, c, a);
}
diff --git a/games/sokoban/src/main.c b/games/sokoban/src/main.c
index f49ea592..be438a4d 100644
--- a/games/sokoban/src/main.c
+++ b/games/sokoban/src/main.c
@@ -278,6 +278,9 @@ int main(void) {
np_app_begin();
color_t *their_strip = gfx_buf;
gfx_buf = strip;
+#ifdef __TICE__
+ gfx_pure = true; /* (draws only with gfx_*) */
+#endif
uint32_t len = 0;
const uint8_t *d = np_file_read(SAVE_NAME, &len);
if (d && len == sizeof sv && d[0] == 'S' && d[1] == 1) memcpy(&sv, d, len);
diff --git a/games/solitaire/src/main.c b/games/solitaire/src/main.c
index 394074b4..22abd531 100644
--- a/games/solitaire/src/main.c
+++ b/games/solitaire/src/main.c
@@ -91,10 +91,18 @@ static int min(int a, int b) { return a < b ? a : b; }
static int max(int a, int b) { return a > b ? a : b; }
/* f over b; a from 0 (all b) to 32 (all f) */
+#ifdef __TICE__ /* the TI-84 Plus CE: its own mixing (the same colours) */
+#include "../../../platform/ti84ce/ce_draw.h"
+__attribute__((naked)) static color ce_mix(color a, color b, unsigned t) { __asm__(CE_MIX_ASM); }
+#endif
static color mix(color f, color b, int a) {
+#ifdef __TICE__
+ return ce_mix(b, f, (unsigned)a);
+#else
uint32_t x = (f | (uint32_t)f << 16) & 0x07E0F81F, y = (b | (uint32_t)b << 16) & 0x07E0F81F;
y = (y + ((x - y) * (uint32_t)a >> 5)) & 0x07E0F81F;
return (color)(y | y >> 16);
+#endif
}
static void fill(int x, int y, int w, int h, color c) {
int x0 = max(x, rx), x1 = min(x + w, rx + rw), y0 = max(y, ry), y1 = min(y + h, ry + rh);
diff --git a/games/sudoku/src/main.c b/games/sudoku/src/main.c
index f4247da9..916aa527 100644
--- a/games/sudoku/src/main.c
+++ b/games/sudoku/src/main.c
@@ -374,6 +374,9 @@ int main(void) {
np_app_begin();
color_t *their_strip = gfx_buf;
gfx_buf = strip;
+#ifdef __TICE__
+ gfx_pure = true; /* (draws only with gfx_*) */
+#endif
units();
uint32_t now = (uint32_t)eadk_timing_millis(), tick = now, repeat_at = 0, shown = ~0u, len = 0;
seed = eadk_random() ^ now;
diff --git a/games/towerblock/src/main.c b/games/towerblock/src/main.c
index 6ab601a8..2d94c1e7 100644
--- a/games/towerblock/src/main.c
+++ b/games/towerblock/src/main.c
@@ -341,6 +341,9 @@ int main(void) {
np_app_begin();
color_t *their_strip = gfx_buf;
gfx_buf = strip;
+#ifdef __TICE__
+ gfx_pure = true; /* (draws only with gfx_*) */
+#endif
now = (uint32_t)eadk_timing_millis();
seed = eadk_random() ^ now;
if (!seed) seed = 1;
diff --git a/games/twoplayer/src/main.c b/games/twoplayer/src/main.c
index d39c4857..c1fe1437 100644
--- a/games/twoplayer/src/main.c
+++ b/games/twoplayer/src/main.c
@@ -911,6 +911,9 @@ int main(void) {
np_app_begin();
color_t *their_strip = gfx_buf;
gfx_buf = strip;
+#ifdef __TICE__
+ gfx_pure = true; /* (draws only with gfx_*) */
+#endif
static const uint32_t TEAM[2] = {0xEF4136, 0x2E7CF6};
for (int p = 0; p < 2; p++)
team[p] = gfx_rgb(TEAM[p]), light[p] = gfx_rgb(gfx_lerp888(TEAM[p], 0xFFFFFF, 120)), dark[p] = gfx_rgb(gfx_lerp888(TEAM[p], 0, 110));
diff --git a/games/uno/src/draw.c b/games/uno/src/draw.c
index 0cce8614..9a968473 100644
--- a/games/uno/src/draw.c
+++ b/games/uno/src/draw.c
@@ -48,6 +48,12 @@ void uno_card_name(int c, char *out) {
/* ------------------------------------------------------------------ shapes, smoothed */
static inline void put32(int x, int y, color_t c, int t) {
if (t <= 0 || x < 0 || x >= SCREEN_W || y < gfx_y0 || y >= gfx_y1) return;
+#ifdef __TICE__
+ if (gfx_listing) { /* (its strip is drawn every time) */
+ gfx_list_rows(y, y + 1);
+ return;
+ }
+#endif
color_t *d = &gfx_buf[(y - gfx_y0) * SCREEN_W + x];
*d = t >= 32 ? c : gfx_mix(*d, c, t);
}
@@ -68,6 +74,15 @@ static void oval(float cx, float cy, float a, float b, color_t c, const color_t
float ey = __builtin_sqrtf(a * a * ay * ay + b * b * by * by);
int r0, r1;
if (!rows(cy - ey, cy + ey, &r0, &r1)) return;
+#ifdef __TICE__
+ if (gfx_listing) { /* (what it depends on, in the strips' lists) */
+ const float v[] = {cx, cy, a, b};
+ gfx_list(v, sizeof v);
+ gfx_list(&c, sizeof c);
+ if (quarters) gfx_list(quarters, 4 * sizeof *quarters);
+ return;
+ }
+#endif
/* u^2 + v^2 = 1 as A x^2 + B x y + C y^2 = 1, for the ellipse grown and shrunk by 0.75 pixel */
float Ao[2], Bo[2], Co[2];
for (int k = 0; k < 2; k++) {
diff --git a/games/uttt/src/main.c b/games/uttt/src/main.c
index d04f9382..ff4f43c1 100644
--- a/games/uttt/src/main.c
+++ b/games/uttt/src/main.c
@@ -236,6 +236,9 @@ int main(void) {
np_app_begin();
color_t *their_strip = gfx_buf;
gfx_buf = strip;
+#ifdef __TICE__
+ gfx_pure = true; /* (draws only with gfx_*) */
+#endif
team[0] = HEX(0xFF4D6D), team[1] = HEX(0x3EC5FF);
now = (uint32_t)eadk_timing_millis();
seed = eadk_random() | 1;
diff --git a/launcher/src/gfx.h b/launcher/src/gfx.h
index 2b0e1cee..b257150f 100644
--- a/launcher/src/gfx.h
+++ b/launcher/src/gfx.h
@@ -20,6 +20,7 @@ void gfx_render(gfx_scene_t scene, void *ctx, int y0, int y1);
extern bool gfx_listing, gfx_pure;
void gfx_list(const void *p, unsigned bytes);
void gfx_list_always(void);
+void gfx_list_rows(int top, int bottom); /* the strips over these rows: drawn every time */
/* fn(a) draws (with gfx_*) in the box x, y, w, h what a[0..n) say (8 at most): one call in the strips' lists */
void gfx_call(void (*fn)(const int *a), const int *a, int n, int x, int y, int w, int h);
#endif
diff --git a/platform/ti84ce/gfx_ce.c b/platform/ti84ce/gfx_ce.c
index 9dd1c012..a3348bd2 100644
--- a/platform/ti84ce/gfx_ce.c
+++ b/platform/ti84ce/gfx_ce.c
@@ -160,11 +160,13 @@ void gfx_list(const void *p, unsigned bytes) {
bytes -= n;
}
}
-void gfx_list_always(void) {
+void gfx_list_rows(int top, int bottom) {
if (!gfx_listing) return;
- for (cursor_t *k = strip_of[gfx_y0], *e = strip_of[gfx_y1 - 1]; k <= e; k++)
- k->whole = false, k->changed = k->full = true;
+ top = NP_MAX(top, gfx_y0), bottom = NP_MIN(bottom, gfx_y1);
+ if (top >= bottom) return;
+ for (cursor_t *k = strip_of[top], *e = strip_of[bottom - 1]; k <= e; k++) k->whole = false, k->changed = k->full = true;
}
+void gfx_list_always(void) { gfx_list_rows(gfx_y0, gfx_y1); }
#define LIST(top, bottom, kind, ...) \
do { \
if (gfx_listing) { \