Adds an env-gated (GE_DETERM=1, default OFF), test-only deterministic-clock mode to port/src/libultra.c per the design in docs/dev/findings.md section D117: osGetCount() returns a virtual clock advanced synchronously in osRecvMesg() when __scMain (the sole consumer of the scheduler's retrace queue) asks for the next message, instead of tracking real elapsed time. Goal: two runs of the same build take the same simulation path, for exact frame-diff regression testing and reproducible crash repro. Four passes this session, each is a real, verified result, not a guess: 1. Fixed the predicted pre-first-frame deadlock (a poll-driven fallback caused it in the first cut). 2. Replaced the poll-driven fallback with synchronous per-ask generation in osRecvMesg -- fixed the deadlock cleanly, but two-run divergence was still 33-38%. 3. Capped the pre-first-task tick backlog to a fixed constant -- divergence dropped to 17-20%, still not the ~0% target. 4. Added GE_DETERM_TRACE=1 instrumented tracing and diffed two runs' clock event logs directly. Proved the tick mechanism is now fully deterministic (byte-identical clock values through the first real task). Root-caused the actual remaining divergence: every synthesized retrace increments the scheduler's frameCount, which gates a half-rate client (the audio client) by parity -- since the pre-task spin count is still real-time-scheduling-dependent, that parity isn't guaranteed to match between runs. GE_DETERM is NOT achieving its determinism goal yet and is not meant to be used for anything today -- it ships here purely as a well-documented, zero-risk-when-off checkpoint (verify.sh bunker1 PASS, worst_cell unchanged, confirmed after every change this session) so the next attempt starts from proof instead of re-deriving four sessions of dead ends. Full trace numbers, exact line citations, and the mechanism: docs/dev/findings.md section D117 (four M-52 addenda). Claude-Session: https://claude.ai/code/session_01P3WrUHAFQZUuhrHhiJgTUr
GoldenEye 007 — PC port layer
This directory contains the PC port layer: the code that lets the (unmodified) GoldenEye game sources run on a modern host instead of N64 hardware.
It mirrors the layout of the Perfect Dark PC
port, which ports the
same Rare engine family. See docs/internals.md (repo root) for the full
research write-up and phased plan.
Layout
port/
├── fast3d/ # Software RSP: interprets GBI display lists -> OpenGL
│ ├── gfx_pc.cpp # RSP interpreter (matrices, lights, tris, fog)
│ ├── gfx_opengl.cpp # OpenGL rendering backend (shaders, textures, zbuf)
│ ├── gfx_sdl2.cpp # SDL2 window-manager backend
│ ├── gfx_cc.cpp # color-combiner -> GLSL shader compiler
│ └── ...
├── include/ # port-facing headers
│ ├── audio.h config.h fs.h input.h mixer.h
│ ├── platform.h romdata.h system.h video.h utils.h
│ └── versioninfo.h.in
└── src/
├── main.c # PC entry point (replaces boot.s / init())
├── libultra.c # shims for the libultra OS API
├── video.c # SDL2 window + GL context + frame pacing
├── audio.c # SDL audio device, buffer queueing
├── mixer.c # audio mixing
├── input.c # SDL2 keyboard/mouse/gamepad -> N64 controller structs
├── fs.c # filesystem abstraction over the ROM + data dir
├── romdata.c # loads the .z64 ROM from disk, sets up segments
├── config.c # INI config (ge007.ini)
├── system.c # platform primitives (time, logging, paths)
├── crash.c # crash handler / stack traces
├── gesched.c # replacement RCP scheduler that drives the software RSP
└── utils.c
How it works (short version)
- The R4300 game code (
src/game,src) is compiled unmodified. - The RSP is emulated in software (
fast3d/): it interprets the Gfx display list the game builds and emits OpenGL calls, bypassing the RDP. - The RCP scheduler (
gesched.c) replacessrc/sched.c's hardware task submission: instead of writing RSP registers it callsgfx_run(). - libultra OS functions are shimmed in
libultra.c(single-threaded, host clock, VI/PI/SI/AI mapped onto the video/audio/fs/input layers). - Saves (Memory Pak / EEPROM) are backed by files in the data dir.
GE-specific RSP work
The PD fast3d already handles G_TRI4 (GE's 4-triangle command). The new
work for GE is:
G_SETTEX— GE's custom texture-bank command (include/gbi_extension.h,gsSPUseTexture). Must be added to the RSP interpreter + GL backend.- Verify GE's custom color-combiner modes (
G_CC_*FADE*) and render mode (G_RM_CUSTOM_AA_ZB_XLU_SURF) produce correct GLSL / GL state.
Use rsp/graphics/gmain.s (the real GE RSP ucode) as the ground truth for the
exact command encodings.
Status
Scaffolding only. The files in src/ and fast3d/ are stubs that define
the interfaces and mark the work to be done. The actual implementation is
brought in phase by phase (see docs/internals.md §8), largely by
adapting the PD port's port/ layer.