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 three demos play in sync with Chocolate Doom, tic for tic
Mason3631e3e08a95f06
diff --git a/games/doom/src/doom/g_game.c b/games/doom/src/doom/g_game.cindex 48e27047..22565d5e 100644--- a/games/doom/src/doom/g_game.c+++ b/games/doom/src/doom/g_game.c@@ -1182,6 +1182,9 @@ void G_Ticker (void)D_PageTicker ();break;}+#if HOST+ { extern void host_tic(void); host_tic(); }+#endif}@@ -2637,6 +2640,9 @@ boolean G_CheckDemoStatus (void)#endif}+#if HOST+ if (demoplayback) { extern void host_demo_end(void); host_demo_end(); }+#endifif (demoplayback){W_ReleaseLumpName(defdemoname);diff --git a/games/doom/src/doom/p_map.c b/games/doom/src/doom/p_map.cindex 96b41d30..9fbe53aa 100644--- a/games/doom/src/doom/p_map.c+++ b/games/doom/src/doom/p_map.c@@ -570,9 +570,19 @@ boolean P_ThingHeightClip (mobj_t* thing)mobj_full(thing)->floorz = tmfloorz;mobj_full(thing)->ceilingz = tmceilingz;} else {+#if NUMWORKS+ // a static thing keeps no floorz of its own: in vanilla it is always on its floor, which is the+ // highest floor under its whole radius (tmfloorz), not just its sector's (an item next to a rising+ // floor rides up with it, and can be picked up from it)+ if (!(thing->flags & MF_FLOAT))+ {+ thing->z = tmfloorz;+ return tmceilingz - tmfloorz >= mobj_height(thing);+ }+#endifonfloor = !(thing->flags & MF_FLOAT);}-+if (onfloor){// walking monsters rise and fall with the floordiff --git a/games/doom/src/doom/s_sound.c b/games/doom/src/doom/s_sound.cindex f262ab63..5b4b6494 100644--- a/games/doom/src/doom/s_sound.c+++ b/games/doom/src/doom/s_sound.c@@ -462,9 +462,6 @@ void S_StartSound(xy_positioned_t *origin, int sfx_id)int cnum;int volume;-#if NO_USE_SOUND- return; // (the calculator has no speaker)-#endifvolume = snd_SfxVolume;// check for bogus sound #@@ -530,6 +527,11 @@ void S_StartSound(xy_positioned_t *origin, int sfx_id)pitch += 16 - (M_Random()&31);}pitch = Clamp(pitch);+#if NO_USE_SOUND+ // the calculator has no speaker; but the sound got this far, as in vanilla, so M_Random is called the+ // same times (the status bar's face looks the same way)+ return;+#endif// kill old soundS_StopSound(origin);diff --git a/games/doom/src/nw/i_video.c b/games/doom/src/nw/i_video.cindex a4b6d4a7..69af8d90 100644--- a/games/doom/src/nw/i_video.c+++ b/games/doom/src/nw/i_video.c@@ -104,7 +104,14 @@ void nw_band_begin(uint8_t *band, int y0, int y1) {}/* the band to the screen: Doom's rows 5k to 5k + 4 are the screen's 6k to 6k + 5 (the last one twice) */+#ifdef HOST+uint8_t host_doom_screen[SCREENWIDTH * SCREENHEIGHT]; /* (tests: the frame in Doom's own pixels) */+#endif+void nw_band_end(void) {+#ifdef HOST+ memcpy(host_doom_screen + nw_band_y0 * SCREENWIDTH, nw_band, (nw_band_y1 - nw_band_y0) * SCREENWIDTH);+#endifuint16_t lines[SCREENWIDTH * 6];for (int y = nw_band_y0; y < nw_band_y1; y += 5) {const uint8_t *src = nw_band + (y - nw_band_y0) * SCREENWIDTH;diff --git a/games/doom/tests/check.py b/games/doom/tests/check.pyindex 438add48..3af87281 100644--- a/games/doom/tests/check.py+++ b/games/doom/tests/check.py@@ -40,7 +40,7 @@ def run(args, saves=None, what=""):return Noneend = dict(zip(("time", "quit", "state", "episode", "map", "leveltime", "health", "kills"), map(int, m.groups())))end.update(zone_free=int(s.group(1)), columns=int(s.group(2)), overflows=int(s.group(3)), zone=int(s.group(4)),- files=files)+ files=files, demos=[line.split(" ", 2)[2] for line in p.stdout.splitlines() if line.startswith("DEMOEND")])return end@@ -50,11 +50,22 @@ def check(cond, what):print(("ok " if cond else "FAIL"), what, flush=True)-# the title, the credits and the three demos, which must play as they were recorded (they end in their-# levels at the same moment as on a PC: the title loop comes back around)-e = run(["--ms", "120000"], what="the demos")+# the title, the credits and the three demos, which must play exactly as in Chocolate Doom 3.1.0 (vanilla Doom+# 1.9): where each ends, the player there and both random number generators are Chocolate Doom's, tic for tic+CHOCOLATE = [+ "leveltime=5026 map=E1M5 x=87385351 y=84364146 z=5767168 angle=2514731840 health=0 armor=36 kills=61 items=7 "+ "secrets=1 ammo=103,0,0,0 weapon=1 prnd=181 rnd=108",+ "leveltime=3836 map=E1M3 x=-9362093 y=-84944896 z=3145728 angle=2688383391 health=0 armor=0 kills=41 items=14 "+ "secrets=0 ammo=140,34,0,0 weapon=2 prnd=75 rnd=152",+ "leveltime=2134 map=E1M7 x=-91417116 y=-164628508 z=7340032 angle=2593932736 health=0 armor=68 kills=20 items=9 "+ "secrets=0 ammo=70,14,0,0 weapon=2 prnd=207 rnd=107",+]+e = run(["--ms", "340000"], what="the demos")if e:- check(e["quit"] == 1, "the title and the demos play for two minutes and quit on Home")+ check(e["quit"] == 1, "the title loop plays its three demos and quits on Home")+ for n, want in enumerate(CHOCOLATE):+ got = e["demos"][n] if n < len(e["demos"]) else "(did not end)"+ check(got == want, f"demo {n + 1} ends as in Chocolate Doom: {got}")# every level, walking, turning and firing on Ultra-Violencewalk = ",".join(f"{t}-{t + 900}:up,{t + 900}-{t + 1300}:right,{t + 300}-{t + 400}:ok" for t in range(1500, 20000, 1500))diff --git a/games/doom/tests/play.c b/games/doom/tests/play.cindex 5560a7a5..35b41356 100644--- a/games/doom/tests/play.c+++ b/games/doom/tests/play.c@@ -16,6 +16,7 @@#include "doomtype.h"#include "z_zone.h"#include "doom/doomstat.h"+#include "doom/p_local.h"#include "nw.h"#include "plat.h"@@ -85,8 +86,52 @@ void host_tick(void) {host_keys = k;}+/* checks against Chocolate Doom: the state at the end of each demo, the player at each tic (--trace), and+ * the frame of the level in Doom's own pixels at given tics of the level (--dump-tics, DIR/frame_<tic>.raw) */+extern int rndindex, prndindex;+static FILE *trace_file;+static int dump_tics[256], ndump;+static uint8_t dumped[256];+extern uint8_t host_doom_screen[SCREENWIDTH * SCREENHEIGHT];++void host_demo_end(void) {+ player_t *p = &players[consoleplayer];+ mobj_t *mo = p->mo;+ printf("DEMOEND gametic=%d leveltime=%d map=E%dM%d x=%d y=%d z=%d angle=%u health=%d armor=%d kills=%d items=%d "+ "secrets=%d ammo=%d,%d,%d,%d weapon=%d prnd=%d rnd=%d\n",+ gametic, leveltime, gameepisode, gamemap, mo ? mo->xy.x : 0, mo ? mo->xy.y : 0, mo ? mo->z : 0,+ mo ? (unsigned)mobj_full(mo)->angle : 0u, p->health, p->armorpoints, p->killcount, p->itemcount,+ p->secretcount, p->ammo[0], p->ammo[1], p->ammo[2], p->ammo[3], (int)p->readyweapon, prndindex, rndindex);+ fflush(stdout);+}++void host_tic(void) {+ if (!trace_file || gamestate != GS_LEVEL || !players[consoleplayer].mo) return;+ player_t *p = &players[consoleplayer];+ mobj_t *mo = p->mo;+ fprintf(trace_file, "T %d %d %d %d %d %u %d %d %d %d %d %d %d %d\n", gametic, leveltime, mo->xy.x, mo->xy.y, mo->z,+ (unsigned)mobj_full(mo)->angle, p->health, prndindex, p->ammo[0], p->ammo[1], p->ammo[2], p->ammo[3],+ p->armorpoints, p->killcount);+}++static void dump_frame(void) {+ if (gamestate != GS_LEVEL) return;+ for (int i = 0; i < ndump; i++) {+ if (dumped[i] || dump_tics[i] != leveltime) continue;+ dumped[i] = 1;+ char path[512];+ snprintf(path, sizeof path, "%s/frame_%d.raw", out, leveltime);+ FILE *f = fopen(path, "wb");+ if (f) {+ fwrite(host_doom_screen, 1, sizeof host_doom_screen, f);+ fclose(f);+ }+ }+}+/* each frame drawn: 1/35 s goes by, and screenshots are taken */void host_frame(void) {+ dump_frame();while (next_shot < nshots && host_time >= shots[next_shot]) shot(shots[next_shot++]);if (every && host_time >= next_every) {shot(host_time);@@ -115,6 +160,13 @@ int main(int argc, char **argv) {else if (!strcmp(argv[i], "--saves") && i + 1 < argc) saves = argv[++i];else if (!strcmp(argv[i], "--stats")) stats = 1;else if (!strcmp(argv[i], "--warp") && i + 1 < argc) nw_warp = atoi(argv[++i]);+ else if (!strcmp(argv[i], "--trace") && i + 1 < argc) trace_file = fopen(argv[++i], "w");+ else if (!strcmp(argv[i], "--dump-tics") && i + 1 < argc) {+ for (char *s = argv[++i]; *s && ndump < 256;) {+ dump_tics[ndump++] = (int)strtol(s, &s, 10);+ if (*s == ',') s++;+ }+ }else if (!strcmp(argv[i], "--exit-at") && i + 1 < argc) {for (char *s = argv[++i]; *s && nexits < 16;) {exit_at[nexits++] = (uint32_t)strtoul(s, &s, 10);