Skip to content

Commit c0806af

Browse files
committed
Movies play: answer the CPU ~MHz registry value, turn movies on by default
The game decodes VP6 itself. The first movie hung because the movie timer (sub_006f625d) reads HKLM\...\CentralProcessor\0 "~MHz" and, without it, calibrates RDTSC against QueryPerformanceCounter until two measurements agree. QPC is our virtual clock and RDTSC real time, so they never agreed. Answering 3000 (rdtsc_shim's rate) skips the calibration; the logos, the PSA and the opening movie play with sound on the original and HD engines. The app and run.sh now default to NOMOVIES=0; tools/check.sh keeps NOMOVIES=1 for repeatable runs.
1 parent b4e7abf commit c0806af

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

‎run.sh‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ BIN="$ROOT/out/nfsu2${NA}_boot"
4545
# rows 2 and 3 written, 0-1 zero) -> every vertex collapses to
4646
# (1,1). MODE=3 injects the correct identity matrix; the raw
4747
# positions are already in clip space.
48-
# NOMOVIES : no VP6 video decoder; if the video files aren't ignored the
49-
# game waits forever at the first video.
48+
# NOMOVIES : 1 skips the videos (they play by default: the game decodes VP6
49+
# itself; the old hang at the first video was the movie timer's
50+
# CPU calibration, fixed with the "~MHz" registry value).
5051
# Don't let the diagnostic synthetic input/forcing variables leak in from the
5152
# shell: an old "export AUTOKEY=..." made the game look like it clicked by itself.
5253
unset AUTOKEY AUTOCLICK FORCESWITCH FETICK GAMELOG DUMPFRAME BOOTFLOW \
@@ -62,7 +63,7 @@ unset AUTOKEY AUTOCLICK FORCESWITCH FETICK GAMELOG DUMPFRAME BOOTFLOW \
6263
STALL MEMDUMP REGFIRST ADAPTERID FPSCAP BGFPS FBONLY
6364

6465
export FIXMAT="${FIXMAT:-1}"
65-
export NOMOVIES="${NOMOVIES:-1}"
66+
export NOMOVIES="${NOMOVIES:-0}"
6667
export FIXMAT_MODE="${FIXMAT_MODE:-3}"
6768
# SNDSYNC : tie the playback rate to the ratio of the game's virtual clock to
6869
# real time. Since the clock now advances with real elapsed time the

‎runtime/bundle.m‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ void app_set_defaults(void){
5858
setdef("ALARM", "0");
5959
setdef("FIXMAT", "1");
6060
setdef("FIXMAT_MODE", "3");
61-
setdef("NOMOVIES", "1");
61+
/* Movies play (the game decodes VP6 itself; the first movie used to hang in the
62+
* movie timer's CPU calibration, see win32_ext.c "~MHz"). NOMOVIES=1 skips them. */
63+
setdef("NOMOVIES", "0");
6264
setdef("SNDSYNC", "1");
6365
setdef("GPUVS", "1");
6466
}

‎runtime/win32_ext.c‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,12 @@ int win32_ext_call(CPU *c, const char *n, uint32_t *out){
617617
else if (!strcasecmp(vn,"StreamingInstall")){ dval=0; have_d=1; }
618618
else if (!strcasecmp(vn,"VERSION")) sval="1.2.0.0";
619619
else if (!strcasecmp(vn,"SIZE")){ dval=0; have_d=1; }
620+
/* HKLM\HARDWARE\DESCRIPTION\System\CentralProcessor\0 "~MHz". The movie
621+
* player's timer (sub_006f625d) reads it; without it the timer calibrates
622+
* RDTSC against QueryPerformanceCounter, waiting for two measurements that
623+
* agree. Our QPC is the virtual clock and RDTSC is real time, so they never
624+
* agree and the first movie hung for ever. 3000 matches rdtsc_shim (3 GHz). */
625+
else if (!strcasecmp(vn,"~MHz")){ dval=3000; have_d=1; }
620626

621627
if (sval){
622628
uint32_t need = (uint32_t)strlen(sval) + 1u;

0 commit comments

Comments
 (0)