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
Doom: the status bar is sent to the panel again only when it changes
Mason3631d8d2f938d91
diff --git a/games/doom/src/nw/i_video.c b/games/doom/src/nw/i_video.cindex cf4668f4..db796473 100644--- a/games/doom/src/nw/i_video.c+++ b/games/doom/src/nw/i_video.c@@ -96,6 +96,9 @@ static void make_palette(int num) {}}+/* (a new palette for this frame: everything is sent again) */+int nw_palette_changing(void) { return next_pal >= 0 || last_gamma != usegamma; }+void nw_frame_begin(void) {nw_band_index = 0;/* (the refresh measured again now and then: the panel's clock is not the processor's) */@@ -251,7 +254,7 @@ static void nw_melt_band(int x0, int x1) {void nw_band_end(int x0, int x1) {int w = x1 - x0;#ifdef HOST- for (int y = 0; y < SCREENHEIGHT; y++)+ for (int y = 0; y < nw_band_rows; y++)memcpy(host_doom_screen + y * SCREENWIDTH + x0, nw_band + y * NW_BAND_W, w);#endifint j = nw_band_index++;@@ -265,16 +268,17 @@ void nw_band_end(int x0, int x1) {return;}uint16_t lines[NW_BAND_W * 24];- for (int y = 0; y < SCREENHEIGHT; y += 20) {+ for (int y = 0; y < nw_band_rows; y += 20) {const uint8_t *src = nw_band + y * NW_BAND_W;uint16_t *d = lines;- for (int k = 0; k < 4; k++) {+ int n = nw_band_rows - y < 20 ? nw_band_rows - y : 20; /* (Doom's rows, and the screen's for them) */+ for (int k = 0; k < (n + 4) / 5; k++) {for (int r = 0; r < 5; r++, src += NW_BAND_W, d += w)for (int i = 0; i < w; i++) d[i] = palette[src[i]];memcpy(d, d - w, w * sizeof *d);d += w;}- plat_push(x0, y / 5 * 6, w, 24, lines);+ plat_push(x0, y / 5 * 6, w, n / 5 * 6 + n % 5, lines);}int32_t pushed = (int32_t)(plat_millis() - t) * 256;nw_push_ms += (pushed - nw_push_ms) / 4;diff --git a/games/doom/src/nw/nw_back.inc b/games/doom/src/nw/nw_back.incindex 8c71bfbf..15b34ce4 100644--- a/games/doom/src/nw/nw_back.inc+++ b/games/doom/src/nw/nw_back.inc@@ -10,6 +10,9 @@ uint32_t nw_last_walls, nw_last_planes; // (and the records of the last frame)#endifint nw_strip_x0 = 0, nw_strip_x1 = SCREENWIDTH;int nw_band_x0 = 0, nw_band_x1 = SCREENWIDTH;+int nw_band_rows = SCREENHEIGHT;+int nw_palette_changing(void);+extern int nw_melting;int nw_tmid_cur;fixed_t nw_masked_texturemid;int nw_fuzz_at;@@ -559,7 +562,7 @@ static void nw_draw_band(uint8_t *band, int x0, int x1, bool view, int help, boo}}int below = scaledviewwidth == SCREENWIDTH ? viewheight : SCREENHEIGHT - ST_HEIGHT;- for (int y = below; y < SCREENHEIGHT; y++) memset(render_frame_buffer + y * NW_STRIDE + x0, 0, x1 - x0);+ for (int y = below; y < nw_band_rows; y++) memset(render_frame_buffer + y * NW_STRIDE + x0, 0, x1 - x0);} else {nw_draw_background(x0, x1, help);if (gamestate == GS_FINALE && finalestage == F_STAGE_TEXT && !help) {@@ -582,11 +585,16 @@ static void nw_draw_band(uint8_t *band, int x0, int x1, bool view, int help, boo// the frame's bands, in the order the panel refreshes themstatic bool nw_frame_view, nw_frame_strips;static int nw_frame_help;+// the status bar's rows are drawn and sent again only when what is drawn there changes (the panel keeps them):+// what was drawn there last (0: not known), and whether this frame leaves them+static uint32_t nw_bar_last;+static bool nw_bar_kept;static void nw_draw_frame() {bool view = nw_frame_view, strips = nw_frame_strips;int help = nw_frame_help;nw_frame_begin();+ nw_band_rows = nw_bar_kept && !nw_melting ? SCREENHEIGHT - ST_HEIGHT : SCREENHEIGHT;uint8_t __aligned(8) band[NW_BAND_W * SCREENHEIGHT];const int bands = SCREENWIDTH / NW_BAND_W;if (nw_scan_right_to_left) {@@ -609,6 +617,7 @@ static void nw_draw_frame() {}nw_band_x0 = 0;nw_band_x1 = SCREENWIDTH;+ nw_band_rows = SCREENHEIGHT;nw_frame_end();}@@ -659,6 +668,7 @@ extern "C" int nw_melt(int tics) {}for (int i = 0; i < SCREENWIDTH / 2; i++) nw_melt_to[i] = nw_melt_y[i] > 0 ? nw_melt_y[i] : 0;nw_melting = 1;+ nw_bar_last = 0;nw_draw_frame();nw_melting = 0;if (done) nw_melt_going = false;@@ -727,6 +737,25 @@ void pd_end_frame(int wipe_start) {}M_Drawer();+ // (in a level, the view above the status bar: what is drawn over its rows, the patches reaching them, and the+ // palette, are as last frame's, or not)+ uint32_t bar = 0;+ if (view && viewwindowy + viewheight <= SCREENHEIGHT - ST_HEIGHT && !wipe_start && !nw_palette_changing()) {+ bar = 2166136261u;+ for (int l = 1; l < nw_patches[0].header.size; l++) {+ const vpatchlist_t &e = nw_patches[l];+ if (e.entry.y + vpatch_height(resolve_vpatch_handle(e.entry.patch_handle)) <= SCREENHEIGHT - ST_HEIGHT)+ continue;+ bar = (bar ^ e.entry.patch_handle) * 16777619u;+ bar = (bar ^ (uint16_t) e.entry.x) * 16777619u;+ bar = (bar ^ (uint16_t) e.entry.y) * 16777619u;+ bar = (bar ^ e.entry.repeat) * 16777619u;+ }+ bar |= 1;+ }+ nw_bar_kept = bar && bar == nw_bar_last;+ nw_bar_last = bar;+nw_frame_view = view;nw_frame_strips = strips;nw_frame_help = help;diff --git a/games/doom/src/nw/nw_render.h b/games/doom/src/nw/nw_render.hindex fa831afe..1ebc2026 100644--- a/games/doom/src/nw/nw_render.h+++ b/games/doom/src/nw/nw_render.h@@ -21,8 +21,10 @@ extern "C" {/* the columns this pass records (the whole view, or one band when a frame is drawn band by band: the BSP* still goes over the whole view, so that everything is as vanilla has it, but only the band is kept) */extern int nw_strip_x0, nw_strip_x1;-/* the band being drawn */+/* the band being drawn, and the rows of it drawn and sent (the status bar's are not when they have not changed:+ * the panel keeps them) */extern int nw_band_x0, nw_band_x1;+extern int nw_band_rows;/* the frame's table of wall texture heights (dc_texturemid), shared by the columns of a wall's tier */int nw_add_tmid(fixed_t texturemid);diff --git a/games/doom/src/v_video.c b/games/doom/src/v_video.cindex 12984042..1d99068b 100644--- a/games/doom/src/v_video.c+++ b/games/doom/src/v_video.c@@ -412,7 +412,7 @@ static void nw_vpatch_cols(const patch_t *patch, int x, int y, int c0, int c1) {if (c1 > nw_band_x1) c1 = nw_band_x1;if (c0 < 0) c0 = 0;if (c1 > SCREENWIDTH) c1 = SCREENWIDTH;- if (x >= c1 || x + w <= c0 || y >= SCREENHEIGHT) return;+ if (x >= c1 || x + w <= c0 || y >= nw_band_rows) return;nw_shared_palettes();const uint8_t *pal = vpatch_has_shared_palette(patch) ? shared_palette8[vpatch_shared_palette(patch)]: vpatch_palette(patch);@@ -421,7 +421,7 @@ static void nw_vpatch_cols(const patch_t *patch, int x, int y, int c0, int c1) {#define PUT(px, c) do { int px_ = (px); if ((unsigned)(px_ - c0) < cw) row[px_] = (c); } while (0)for (int r = 0; r < h; r++) {int sy = y + r;- if (sy >= SCREENHEIGHT) break;+ if (sy >= nw_band_rows) break;uint8_t *row = sy >= 0 ? nw_band - nw_band_x0 + sy * NW_BAND_W : NULL;switch (vpatch_type(patch)) {case vp4_runs: {