From eb896f7b8c23256bbb944d04311df4d2c7168bdf Mon Sep 17 00:00:00 2001 From: "opencode.energia.arti.ee" Date: Tue, 3 Nov 2026 20:11:57 +0000 Subject: [PATCH] test(termtris): assert the play acceptance results; drop the dead drain hook --- apps/termtris/build/termtris.coff | Bin 15157 -> 15118 bytes apps/termtris/build/termtris.map | 63 +++++++++++++++--------------- apps/termtris/src/vt1200/x11.c | 9 +++-- apps/termtris/src/vt1200/x11.h | 1 - apps/termtris/tests/play_keys.sh | 11 ++++++ apps/termtris/tests/render.c | 1 - 6 files changed, 47 insertions(+), 38 deletions(-) diff --git a/apps/termtris/build/termtris.coff b/apps/termtris/build/termtris.coff index 5046cde4e5cb1b04a47d6c59684af759117219af..6c515d9717a183721e60d921df7d5405f808769b 100644 GIT binary patch delta 829 zcmY*XUr1A76#u@v>2~+WK&`o};k6+;HrnReT1jvX7YZ2^fe#U`XoM}5Z0(^S>>((m zr5>UOUkr&61FbINLkNSQLWu=MLQvi}S(;#f-ime3T~oUc=lh-Cckb{0&N+83l}PZxJ&lZIRCW^lInEM8+hm z?G*{mbC9VFR?Ar85woTome8p!!g}Q}UiO)u@SG}|R|U>s(=usgx>$a?>SGQbTJv0i zi?+RZciR@lxMb_VXt$#Ywbvf!m@HJC!=!Onv;yVgwI?yo*S^K$h7`zNGN6GrX%4B?aAU>EH*SFvh}jBh+2p&aCmX}`dN&CuWNpS@iY8uoZfAr(daKv0rT5AMRETSkz zAM+&&{Ns=qG0@^7{t|@1Ad5vogFw3fmLWo4{|bB0ow+(c-t)ZAdEe(e=RNn*^J&)u zq9r%xzKosjAVemFG!r*9(4SQ7ryTls>XsC#Lq(z`KP(2H`n zE>5Weg}NXt+v>GNEP(a8BvO+8DOF_NP~oTmUyV~HVXL+Ng949CB^rTq<~?|J(;UXQ zV(!6cvGh|x9=1d&CX4kWm^gQYbto6Lp2E0beXr`Y^Q9T4^Ke&I&0DIu?AiSi?a1F7 zJv+rFT^EH9n$an8_ipVOUhLsAV{!;%9n>GqR_p zLBo;PAhx|dNY+`$_{rs-n8ce7`%n*=wjslT+a{9P+??ZyF~Z;Ht>n#6aY5P4; ENTRY POINT SYMBOL: "_start" address: 018a0000 @@ -43,15 +43,15 @@ section page origin length input sections 018b5b70 00000050 X11.obj (.cinit) 018b5bc0 00000050 rts.lib (.cinit) -.bss 0 01a00000 0001ec20 UNINITIALIZED +.bss 0 01a00000 0001ec00 UNINITIALIZED 01a00000 00008000 ENTRY.obj (.bss) 01a08000 00000400 MAIN.obj (.bss) 01a08400 00004a40 GAME.obj (.bss) 01a0ce40 00000b80 SCOREDB.obj (.bss) - 01a0d9c0 0000f220 X11.obj (.bss) - 01a1cbe0 00000020 COMPAT.obj (.bss) - 01a1cc00 00002000 XGFIX.obj (.bss) - 01a1ec00 00000020 rts.lib (.bss) + 01a0d9c0 0000f200 X11.obj (.bss) + 01a1cbc0 00000020 COMPAT.obj (.bss) + 01a1cbe0 00002000 XGFIX.obj (.bss) + 01a1ebe0 00000020 rts.lib (.bss) .data 0 018a0000 00000000 UNINITIALIZED @@ -92,23 +92,23 @@ address name address name 018b2c10 _sprintf 018b2390 _fflush 018b4330 _srand 018b2400 _putchar 018a0000 _start 018b2c10 _sprintf -01a1cbe0 _stdout 018b39d0 _vt_install_xg +01a1cbc0 _stdout 018b39d0 _vt_install_xg 018b4400 _strcmp 018b3be0 _memcpy 018b4550 _strcpy 018b3d80 _memmove 018b4670 _strlen 018b4030 _memset 018b4780 _strncpy 018b41d0 _rand -01a1cb00 _term_clearscr 018b4330 _srand -01a1cb40 _term_cursor 018b4400 _strcmp +01a1cae0 _term_clearscr 018b4330 _srand +01a1cb20 _term_cursor 018b4400 _strcmp 01a08a60 _term_height 018b4550 _strcpy -01a1cb80 _term_ibmchar 018b4670 _strlen +01a1cb60 _term_ibmchar 018b4670 _strlen 018b2320 _term_init 018b4780 _strncpy 018b0c30 _term_putstr 018b4940 cinit -01a1cae0 _term_reset 018b4940 etext -01a1cb60 _term_setcolor 01a00000 .bss -01a1cb20 _term_setcursor 01a08360 _dbg_loops -01a1cbc0 _term_type 01a08380 _dbg_events +01a1cac0 _term_reset 018b4940 etext +01a1cb40 _term_setcolor 01a00000 .bss +01a1cb00 _term_setcursor 01a08360 _dbg_loops +01a1cba0 _term_type 01a08380 _dbg_events 01a08a40 _term_width 01a083a0 _dbg_last -01a1cba0 _termenv 01a083c0 _dbg_focus +01a1cb80 _termenv 01a083c0 _dbg_focus 01a08960 _tick_interval 01a083e0 _dbg_rev 018a3130 _update 01a08940 _quit 01a08980 _use_bell 01a08960 _tick_interval @@ -121,21 +121,20 @@ address name address name 018a0530 _vt_poll_event 01a08a40 _term_width 018af950 _vt_root_window 01a08a60 _term_height 01a1ca60 _vt_win 01a08a80 _scr -01a1cac0 _vt_x11_drain_events 01a0ce40 _username -018b0dd0 _vt_x11_flush 01a1ca40 _vt_dpy -018afa30 _vt_x11_init 01a1ca60 _vt_win -01a1caa0 _vt_x11_progress 01a1ca80 _vt_gc -018b2000 _vt_x11_term_init 01a1caa0 _vt_x11_progress -018a1700 _wait_display 01a1cac0 _vt_x11_drain_events -018b01e0 _x11_clearscr 01a1cae0 _term_reset -018b03e0 _x11_cursor 01a1cb00 _term_clearscr -018b07b0 _x11_ibmchar 01a1cb20 _term_setcursor -018b03a0 _x11_reset 01a1cb40 _term_cursor -018b0440 _x11_setcolor 01a1cb60 _term_setcolor -018b0560 _x11_setcursor 01a1cb80 _term_ibmchar -018b4940 cinit 01a1cba0 _termenv -018a0000 edata 01a1cbc0 _term_type -01a1ec20 end 01a1cbe0 _stdout -018b4940 etext 01a1ec20 end +018b0dd0 _vt_x11_flush 01a0ce40 _username +018afa30 _vt_x11_init 01a1ca40 _vt_dpy +01a1caa0 _vt_x11_progress 01a1ca60 _vt_win +018b2000 _vt_x11_term_init 01a1ca80 _vt_gc +018a1700 _wait_display 01a1caa0 _vt_x11_progress +018b01e0 _x11_clearscr 01a1cac0 _term_reset +018b03e0 _x11_cursor 01a1cae0 _term_clearscr +018b07b0 _x11_ibmchar 01a1cb00 _term_setcursor +018b03a0 _x11_reset 01a1cb20 _term_cursor +018b0440 _x11_setcolor 01a1cb40 _term_setcolor +018b0560 _x11_setcursor 01a1cb60 _term_ibmchar +018b4940 cinit 01a1cb80 _termenv +018a0000 edata 01a1cba0 _term_type +01a1ec00 end 01a1cbc0 _stdout +018b4940 etext 01a1ec00 end -[77 symbols] +[76 symbols] diff --git a/apps/termtris/src/vt1200/x11.c b/apps/termtris/src/vt1200/x11.c index a79053e..9d89af5 100644 --- a/apps/termtris/src/vt1200/x11.c +++ b/apps/termtris/src/vt1200/x11.c @@ -1,7 +1,9 @@ /* * x11.c -- a small character-cell terminal that draws through the VT1200 ROM - * Xlib. The game's term_* callbacks feed an 80x24 grid; vt_x11_flush() paints - * only the dirty cells with XFillRectangle (background) + XDrawString (glyph). + * Xlib. The game's term_* callbacks feed an 80x24 grid; vt_x11_flush() repaints + * each dirty row with one XFillRectangle (background) and one XDrawString (the + * row's 80 characters), which keeps the request stream small enough for the + * in-machine X server to drain. * * Geometry is the default GC's font, measured on the real server: 6x13 cells, * baseline +10. Do not change the cell metrics without re-measuring. @@ -29,8 +31,7 @@ static int cur_fg, cur_bg; void *vt_dpy; vt_u32 vt_win; vt_u32 vt_gc; -volatile vt_u32 vt_x11_progress; -int vt_x11_drain_events; +volatile vt_u32 vt_x11_progress; /* debug: 0xFFFFFF when a flush finished */ /* term.h's callback objects (term.c is not compiled for the VT1200). */ void (*term_reset)(void); diff --git a/apps/termtris/src/vt1200/x11.h b/apps/termtris/src/vt1200/x11.h index 6ac8351..023512f 100644 --- a/apps/termtris/src/vt1200/x11.h +++ b/apps/termtris/src/vt1200/x11.h @@ -9,7 +9,6 @@ extern void *vt_dpy; extern vt_u32 vt_win; extern vt_u32 vt_gc; -extern int vt_x11_drain_events; int vt_x11_init(void); void vt_x11_flush(void); diff --git a/apps/termtris/tests/play_keys.sh b/apps/termtris/tests/play_keys.sh index 4d396b9..e39565e 100755 --- a/apps/termtris/tests/play_keys.sh +++ b/apps/termtris/tests/play_keys.sh @@ -29,6 +29,17 @@ for mode in ${MODES:-move panels quit}; do -autoboot_script "$DIR/play_keys.lua" -autoboot_delay 0 \ >"$LOG" 2>&1 || true grep -E 'PLAYKEYS:|LOADER: result|LOADER: snapshot' "$LOG" | tail -5 + DIAG=$(grep -a 'DIAG: loops' "$LOG" | sed -n 's/.*loops=\([0-9]*\) events=\([0-9]*\).*quit=\([0-9]*\)/\1 \2 \3/p' | head -1) + [ -n "$DIAG" ] || { echo "play_keys.sh: no DIAG line for $mode (see $LOG)" >&2; exit 1; } + set -- $DIAG + LOOPS=$1; EVENTS=$2; QUIT=$3 + echo "play_keys: $mode loops=$LOOPS events=$EVENTS quit=$QUIT" + [ "$LOOPS" -ge 100 ] || { echo "play_keys.sh: $mode main loop barely ran ($LOOPS)" >&2; exit 1; } + [ "$EVENTS" -ge 6 ] || { echo "play_keys.sh: $mode got $EVENTS events, expected the click and keys" >&2; exit 1; } + case $mode in + move|panels) [ "$QUIT" = 0 ] || { echo "play_keys.sh: $mode quit unexpectedly" >&2; exit 1; } ;; + quit) [ "$QUIT" = 1 ] || { echo "play_keys.sh: q did not reach the game (quit=$QUIT)" >&2; exit 1; } ;; + esac [ -s "$EV/loader_frame3200.png" ] || { echo "play_keys.sh: no $mode snapshot" >&2; exit 1; } cp "$EV/loader_frame3200.png" "$EV/termtris_${mode}_3200.png" done diff --git a/apps/termtris/tests/render.c b/apps/termtris/tests/render.c index ccb4e2c..1302a8c 100644 --- a/apps/termtris/tests/render.c +++ b/apps/termtris/tests/render.c @@ -48,7 +48,6 @@ int main(void) put(1, 20, word, 0x70); put(21, 20, "0123456789", 0x70); put(22, 20, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 0x70); - vt_x11_drain_events = 1; vt_x11_flush(); mark[4] = 0x464C5553UL; /* FLUS */