dwt/loader/loader.lua had a completion check that only set done in the frames >= ENDF branch; the status block was a comment-only no-op. Every run
therefore continued to the fixed LOADER_END (default 2700) and called machine:exit(), even when the loader result had been final for hundreds of
frames. A slow client had no way to run longer, and a client still in startup
at LOADER_END was cut off with no diagnostic.
This replaces the empty block with a real completion rule and adds LOADER_END=0 / LOADER_MAX:
done is set exactly once, on the frame completion is detected.
Completion = RESULT_STATUS has been written (!= 0xFFFFFFFF) andPC
is outside [LOADER_BASE, LOADER_BASE+0x400)and the result block has
been unchanged for 10 frames.
On completion: LOADER: complete at frame <n> status=<hex>.
A fixedLOADER_END still exits at that frame, so the snapshot filename
and every existing fixed-frame capture are unchanged. Completion is
informational there and suppresses the startup warning.
LOADER_END=0 exits at completion, or at LOADER_MAX (default 6000) with LOADER: warning: app still in startup at LOADER_MAX=<n>.
A fixed LOADER_END reached before completion prints LOADER: warning: app still in startup at LOADER_END=<n>.
LOADER: result, LOADER: snapshot, the loader_frame<frames>.png filename,
and the default ENDF=2700 are unchanged.
Verification
M=/home/arti/code/k-space/mame0289/vt1200, run from the repo root. Every run
used private -cfg_directory / -nvram_directory and a private HOME:
No env; default LOADER_COFF=dwt/loader/build/marker.coff, default LOADER_END=2700:
$ grep -c "LOADER: complete" baseline.log
0
$ grep -n "LOADER: result\|LOADER: PC at inspection" baseline.log
225:LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
229:LOADER: PC at inspection = 018C0260
$ tail -1 baseline.log
Average speed: 122.15% (58 seconds)
No completion line; the result was only inspected at the fixed end frame. The
marker app had already been running for many frames before that (the old log
shows its counter climbing from frame 2500).
2. Default LOADER_END=2700, after the change
Same command plus LOADER_SNAP=1 LOADER_OUT=/tmp/opencode/issue3/evidence
(the snapshot filename is how the exit frame is pinned):
LOADER: complete at frame 2510 status=00000000
LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
LOADER: PC at inspection = 018C0260
LOADER: snapshot /tmp/opencode/issue3/evidence/loader_frame2700.png ok=true
Average speed: 117.37% (58 seconds)
Completion is detected at frame 2510, but the run still exits at 2700: loader_frame2700.png, same fixed-frame contract as before.
3. LOADER_END=0
$ HOME=... VT1200_SKIP_LEVEL1=1 LOADER_END=0 LOADER_SNAP=1 \
LOADER_OUT=/tmp/opencode/issue3/evidence $M vt1200 ...
LOADER: complete at frame 2510 status=00000000
LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
LOADER: PC at inspection = 018C0260
LOADER: snapshot /tmp/opencode/issue3/evidence/loader_frame2510.png ok=true
Average speed: 121.25% (54 seconds)
Exit at the completion frame (2510), well before LOADER_MAX=6000.
4. Warning paths
Fixed end reached before completion:
$ LOADER_END=2505 LOADER_SNAP=1 ...
LOADER: warning: app still in startup at LOADER_END=2505
LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
LOADER: snapshot /tmp/opencode/issue3/evidence/loader_frame2505.png ok=true
LOADER_END=0 with a short LOADER_MAX:
$ LOADER_END=0 LOADER_MAX=2505 LOADER_SNAP=1 ...
LOADER: warning: app still in startup at LOADER_MAX=2505
LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
LOADER: snapshot /tmp/opencode/issue3/evidence/loader_frame2505.png ok=true
5. Deliberately wrong LOADER_COFF
$ LOADER_COFF=/tmp/opencode/issue3/does-not-exist.coff $M vt1200 ... -seconds_to_run 5
Ignoring MAME exception: Error running autoboot script dwt/loader/loader.lua: runtime error
dwt/loader/loader.lua:62: cannot open /tmp/opencode/issue3/does-not-exist.coff: /tmp/opencode/issue3/does-not-exist.coff: No such file or directory
Fatal error: Error running autoboot script dwt/loader/loader.lua: runtime error
dwt/loader/loader.lua:62: cannot open /tmp/opencode/issue3/does-not-exist.coff: /tmp/opencode/issue3/does-not-exist.coff: No such file or directory
The error path still reports the missing file and exits non-zero (exit=3).
Notes
The logs above were produced on commit 0e36c3e before rebasing onto upstream/master (0b3db19). The rebase did not change either file: git rev-parse 0e36c3e:dwt/loader/loader.lua and git rev-parse HEAD:dwt/loader/loader.lua are both 57e8173927cbc08230d2df9a4165475a5a52bcf3, and the README blob is ba2b32ae82653f74ca7b8d6b217d85799fe834cb in both.
ROM untouched: md5sum vt1200_v22.bin = b46a3e442ccb86134d2356bd70d22fd2.
The termtris tests carry their own Lua copies and were not modified; their
fixed LOADER_END behaviour is unchanged.
Not verified here: a client whose startup exceeds LOADER_MAX, and the
actual slow-client retry timing in termtris. The rule was exercised with the
marker app (completes at frame 2510) and the two warning paths above.
## What this fixes
`dwt/loader/loader.lua` had a completion check that only set `done` in the
`frames >= ENDF` branch; the status block was a comment-only no-op. Every run
therefore continued to the fixed `LOADER_END` (default 2700) and called
`machine:exit()`, even when the loader result had been final for hundreds of
frames. A slow client had no way to run longer, and a client still in startup
at `LOADER_END` was cut off with no diagnostic.
This replaces the empty block with a real completion rule and adds
`LOADER_END=0` / `LOADER_MAX`:
* `done` is set exactly once, on the frame completion is detected.
* Completion = `RESULT_STATUS` has been written (`!= 0xFFFFFFFF`) **and** `PC`
is outside `[LOADER_BASE, LOADER_BASE+0x400)` **and** the result block has
been unchanged for 10 frames.
* On completion: `LOADER: complete at frame <n> status=<hex>`.
* A **fixed** `LOADER_END` still exits at that frame, so the snapshot filename
and every existing fixed-frame capture are unchanged. Completion is
informational there and suppresses the startup warning.
* `LOADER_END=0` exits at completion, or at `LOADER_MAX` (default 6000) with
`LOADER: warning: app still in startup at LOADER_MAX=<n>`.
* A fixed `LOADER_END` reached before completion prints
`LOADER: warning: app still in startup at LOADER_END=<n>`.
`LOADER: result`, `LOADER: snapshot`, the `loader_frame<frames>.png` filename,
and the default `ENDF=2700` are unchanged.
## Verification
`M=/home/arti/code/k-space/mame0289/vt1200`, run from the repo root. Every run
used private `-cfg_directory` / `-nvram_directory` and a private `HOME`:
```
VT1200_SKIP_LEVEL1=1 $M vt1200 -rompath harness/mame/roms \
-video none -sound none -nothrottle -skip_gameinfo \
-nvram_directory <private>/nvram -cfg_directory <private>/cfg \
-debug -debugger none -autoboot_script dwt/loader/loader.lua -autoboot_delay 0
```
### 1. Before the change (reproduction)
No env; default `LOADER_COFF=dwt/loader/build/marker.coff`, default
`LOADER_END=2700`:
```
$ grep -c "LOADER: complete" baseline.log
0
$ grep -n "LOADER: result\|LOADER: PC at inspection" baseline.log
225:LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
229:LOADER: PC at inspection = 018C0260
$ tail -1 baseline.log
Average speed: 122.15% (58 seconds)
```
No completion line; the result was only inspected at the fixed end frame. The
marker app had already been running for many frames before that (the old log
shows its counter climbing from frame 2500).
### 2. Default `LOADER_END=2700`, after the change
Same command plus `LOADER_SNAP=1 LOADER_OUT=/tmp/opencode/issue3/evidence`
(the snapshot filename is how the exit frame is pinned):
```
LOADER: complete at frame 2510 status=00000000
LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
LOADER: PC at inspection = 018C0260
LOADER: snapshot /tmp/opencode/issue3/evidence/loader_frame2700.png ok=true
Average speed: 117.37% (58 seconds)
```
Completion is detected at frame 2510, but the run still exits at **2700**:
`loader_frame2700.png`, same fixed-frame contract as before.
### 3. `LOADER_END=0`
```
$ HOME=... VT1200_SKIP_LEVEL1=1 LOADER_END=0 LOADER_SNAP=1 \
LOADER_OUT=/tmp/opencode/issue3/evidence $M vt1200 ...
LOADER: complete at frame 2510 status=00000000
LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
LOADER: PC at inspection = 018C0260
LOADER: snapshot /tmp/opencode/issue3/evidence/loader_frame2510.png ok=true
Average speed: 121.25% (54 seconds)
```
Exit at the completion frame (2510), well before `LOADER_MAX=6000`.
### 4. Warning paths
Fixed end reached before completion:
```
$ LOADER_END=2505 LOADER_SNAP=1 ...
LOADER: warning: app still in startup at LOADER_END=2505
LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
LOADER: snapshot /tmp/opencode/issue3/evidence/loader_frame2505.png ok=true
```
`LOADER_END=0` with a short `LOADER_MAX`:
```
$ LOADER_END=0 LOADER_MAX=2505 LOADER_SNAP=1 ...
LOADER: warning: app still in startup at LOADER_MAX=2505
LOADER: result status=0 (OK) entry=018C0000 text=018C0000/656 bits data=018D0000/64 bits bss=018D8000/64 bits relocs=0 pcb=003FEE50 nscns=3 len=510
LOADER: snapshot /tmp/opencode/issue3/evidence/loader_frame2505.png ok=true
```
### 5. Deliberately wrong `LOADER_COFF`
```
$ LOADER_COFF=/tmp/opencode/issue3/does-not-exist.coff $M vt1200 ... -seconds_to_run 5
Ignoring MAME exception: Error running autoboot script dwt/loader/loader.lua: runtime error
dwt/loader/loader.lua:62: cannot open /tmp/opencode/issue3/does-not-exist.coff: /tmp/opencode/issue3/does-not-exist.coff: No such file or directory
Fatal error: Error running autoboot script dwt/loader/loader.lua: runtime error
dwt/loader/loader.lua:62: cannot open /tmp/opencode/issue3/does-not-exist.coff: /tmp/opencode/issue3/does-not-exist.coff: No such file or directory
```
The error path still reports the missing file and exits non-zero (`exit=3`).
## Notes
* The logs above were produced on commit `0e36c3e` before rebasing onto
`upstream/master` (`0b3db19`). The rebase did not change either file:
`git rev-parse 0e36c3e:dwt/loader/loader.lua` and
`git rev-parse HEAD:dwt/loader/loader.lua` are both
`57e8173927cbc08230d2df9a4165475a5a52bcf3`, and the README blob is
`ba2b32ae82653f74ca7b8d6b217d85799fe834cb` in both.
* ROM untouched: `md5sum vt1200_v22.bin` =
`b46a3e442ccb86134d2356bd70d22fd2`.
* The termtris tests carry their own Lua copies and were not modified; their
fixed `LOADER_END` behaviour is unchanged.
* Not verified here: a client whose startup exceeds `LOADER_MAX`, and the
actual slow-client retry timing in termtris. The rule was exercised with the
marker app (completes at frame 2510) and the two warning paths above.
Closes #3
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What this fixes
dwt/loader/loader.luahad a completion check that only setdonein theframes >= ENDFbranch; the status block was a comment-only no-op. Every runtherefore continued to the fixed
LOADER_END(default 2700) and calledmachine:exit(), even when the loader result had been final for hundreds offrames. A slow client had no way to run longer, and a client still in startup
at
LOADER_ENDwas cut off with no diagnostic.This replaces the empty block with a real completion rule and adds
LOADER_END=0/LOADER_MAX:doneis set exactly once, on the frame completion is detected.RESULT_STATUShas been written (!= 0xFFFFFFFF) andPCis outside
[LOADER_BASE, LOADER_BASE+0x400)and the result block hasbeen unchanged for 10 frames.
LOADER: complete at frame <n> status=<hex>.LOADER_ENDstill exits at that frame, so the snapshot filenameand every existing fixed-frame capture are unchanged. Completion is
informational there and suppresses the startup warning.
LOADER_END=0exits at completion, or atLOADER_MAX(default 6000) withLOADER: warning: app still in startup at LOADER_MAX=<n>.LOADER_ENDreached before completion printsLOADER: warning: app still in startup at LOADER_END=<n>.LOADER: result,LOADER: snapshot, theloader_frame<frames>.pngfilename,and the default
ENDF=2700are unchanged.Verification
M=/home/arti/code/k-space/mame0289/vt1200, run from the repo root. Every runused private
-cfg_directory/-nvram_directoryand a privateHOME:1. Before the change (reproduction)
No env; default
LOADER_COFF=dwt/loader/build/marker.coff, defaultLOADER_END=2700:No completion line; the result was only inspected at the fixed end frame. The
marker app had already been running for many frames before that (the old log
shows its counter climbing from frame 2500).
2. Default
LOADER_END=2700, after the changeSame command plus
LOADER_SNAP=1 LOADER_OUT=/tmp/opencode/issue3/evidence(the snapshot filename is how the exit frame is pinned):
Completion is detected at frame 2510, but the run still exits at 2700:
loader_frame2700.png, same fixed-frame contract as before.3.
LOADER_END=0Exit at the completion frame (2510), well before
LOADER_MAX=6000.4. Warning paths
Fixed end reached before completion:
LOADER_END=0with a shortLOADER_MAX:5. Deliberately wrong
LOADER_COFFThe error path still reports the missing file and exits non-zero (
exit=3).Notes
0e36c3ebefore rebasing ontoupstream/master(0b3db19). The rebase did not change either file:git rev-parse 0e36c3e:dwt/loader/loader.luaandgit rev-parse HEAD:dwt/loader/loader.luaare both57e8173927cbc08230d2df9a4165475a5a52bcf3, and the README blob isba2b32ae82653f74ca7b8d6b217d85799fe834cbin both.md5sum vt1200_v22.bin=b46a3e442ccb86134d2356bd70d22fd2.fixed
LOADER_ENDbehaviour is unchanged.LOADER_MAX, and theactual slow-client retry timing in termtris. The rule was exercised with the
marker app (completes at frame 2510) and the two warning paths above.
Closes #3