aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


commit 8bb15991195a051024575fb64d31fe74a5bf7dbf
parent 3cb4a235af36c3251637359c088cc75651815e1f
Author: anon <anon@example.com>
Date:   Tue, 13 Oct 2026 06:26:29 +0000

Load client-target preferences and enumerate DirectX 7 interfaces

Diffstat:
Mdocs/browser-porting.md | 76++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 72 insertions(+), 4 deletions(-)

diff --git a/docs/browser-porting.md b/docs/browser-porting.md @@ -700,7 +700,75 @@ conversion's used-default-character output is a 32-bit BOOL. The verified environment conversion covers CP_ACP/Windows-1252 with flags zero, directly representable characters and default-character replacement. UTF-8, composition and Windows best-fit transliteration remain unsupported. -On 2026-10-12 native Rust and browser WASM runs completed the observed -diagnostic initialization and directory creation without low-page warnings, -then both stopped at BR's imported `_chmod` call (RVA `0x2257`). This is -further startup progress, not successful world loading or rendering. +Native Rust and browser WASM runs complete the observed diagnostic +initialization and directory creation without low-page warnings. Reaching +these paths does not establish successful world loading or rendering. + +### Main preference loading + +OOR Preferences::LoadMainPrefs (RVA `0x20b0`) enters LR's +IndependentPrefs::Load (RVA `0x1490`). A native trace observed +`_chmod("Prefs\\Main.cfg", 0x180)`: `_S_IREAD | _S_IWRITE`. +On Windows this controls the readonly attribute; it does not supply Unix +read/write/execute access control. The writable profile can live in an +overlay while original source assets remain immutable. + +The following file-existence call uses BR's `_stat` import at RVA `0x20fe`. +Its legacy output occupies 36 bytes, including a 16-bit mode at +6, +link count at +8 and signed 32-bit size at +20. The caller checks the +regular-file bit `0x8000`. BR opens the profile in binary mode (`rb`, +RVA `0x2204`), measures it with ftell/fseek to EOF and back, then reads +the whole file with `fread(destination, 1, file_size, stream)` at RVA +`0x2387`. This path does not require fgetc or fgets. + +Parsing then uses native Buffer_t::ReadText (BR RVA `0x1ab0`), which drops +CR and splits at LF. LR scans keys/values with `%399s %399s` (RVA `0x176a`) +and skips comment lines plus username/password keys. It handles quoted +values itself. Nonquoted values containing a decimal point use `%f` +(RVA `0x18be`), writing a 32-bit float; other numeric values use `%i` +(RVA `0x188b`), including sign and decimal/octal/hex autodetection. +The `_stricmp` comparisons occur at RVAs `0x17a1`/`0x17be`. +The relevant BR SetPermissions analysis is REA evidence +`ev_764c41f92a1d8425b09738c4f42af06e6cd8d31c65e04e3e5e2d851cf5fa70b0`; +the other call sites were checked in bounded PE/disassembly inspection of +the pinned OOR/LR/BR images. + +### Graphics discovery callbacks + +BBR EnumeratingSystem_t's constructor (RVA `0x879e0`) probes DirectDraw +and queries `IID_IDirectDraw7`. This is distinct from its later +`IID_IDirect3D7` query. The GUIDs and COM method order are defined in +[the DirectDraw header](https://github.com/wine-mirror/wine/blob/master/include/ddraw.h) +and [the Direct3D header](https://github.com/wine-mirror/wine/blob/master/include/d3d.h). +An interface handoff must preserve the original pointer and share object +lifetime; changing its vtable in place can leave callers using the wrong ABI. + +Randy::GetDevices (BBR RVA `0xbbd10`) calls DirectDrawEnumerateExA with +flags 7 and an adapter callback at RVA `0xbb7d0`. Its five stdcall +arguments are GUID pointer, description, name, context and monitor handle. +The default adapter has a null GUID. The callback creates DirectDraw7, +reads DDCAPS of size `0x17c` and tests `DDCAPS2_CANRENDERWINDOWED` +(`0x80000`) at offset +8. Null optional capability outputs must be skipped. + +The adapter then enumerates display modes through BBR RVA `0xbbca0`: +stdcall `(DDSURFACEDESC2*, context)`. It reads width at +12, height at +8 +and RGB bit count at +84. Later selection keeps resolutions at least +640 by 480 with compatible color depth. A 32-bit 800 by 600 descriptor +survives these observed checks. DDSURFACEDESC2 is 124 bytes in this ABI. + +After querying Direct3D7, the adapter invokes EnumDevices at vtable slot 3. +BBR's device callback (RVA `0xbbb60`) takes description, name, +`D3DDEVICEDESC7*` and context, cleaning 16 stack bytes. The descriptor is +236 bytes. It reads deviceGUID at +196 to classify HAL versus T&L HAL and +the W-buffer capability bit `0x40000` at +68. These are different from +DirectDraw's adapter GUID and windowed-rendering flag. A missing W-buffer +bit does not exclude the device here. Capability layouts are defined in +[d3dcaps.h](https://github.com/wine-mirror/wine/blob/master/include/d3dcaps.h). +Discovery alone does not establish that device creation or rendering works. + +These call sites were checked in the pinned BBR image, SHA-256 +`0c61958075bb39a1848736aa515d81fd0830dfab706c2896d99d5d6ded45823d`, +with bounded PE/disassembly inspection. REA constructor evidence is +`ev_f3344e489870c04edd133c7facf5dd39c9d80bd240a65f63ff86b6d1a2fa06e6`. +Callback addresses passed as arguments must be explicit translation seeds; +following only direct calls does not discover these functions.