Files
goldeneye-pc-port/port/include/gimgfixup.h
T
James Dansereau 8f631462f3 PC port: phase 2 — D59-D68 milestone: full intro renders; blocker is D69 (BG-file BE headers)
D59/D64: the 'external GL DLL' crash was an unbounded blood-RLE write
(sentinel die_blood_image_end lost its N64 section adjacency on PC)
clobbering the gun-barrel sub-DL at ptr_logo_and_walletbond_DL+0x200.
D60: osPiStartDma DMA-target validation (VirtualQuery-based) in libultra.c.
D61/D63: TEMP env-gated ROM-read / VTX-pool / menu probes (strip list in
HANDOFF Task 3). D62: OSMesgQueue/OSScMsg PC layout verification.
D65/D65b: enum HEADS/BODIES signed sentinels under PORT (PC GCC picks
unsigned underlying types; N64 semantics were signed).
D66: romCopyAligned + ramrom replay 64-bit pointer width (s32 truncation
of .bss targets > 4 GiB). D67: struct image_entry N64 layout
reconstruction (dataoffset:24 first, all-u32 bitfields, sizeof==8).
D68: Globalimagetable BE->LE fixup (port/src/gimgfixup.c): bswap the
IMAGESEG-marked Gfx w1 words in the 17 ROM-copied DLs + sImageTableEntry.
index in the 32 tables after texReset's romCopy; marker scan moved to
bytes 6..7 under PORT; compiled globalDL shadows synced post-texLoad for
explosion.c's g_ExplosionDisplayLists.

Result: game boots, plays intro music, and renders the entire ~3.5-minute
intro (logo -> gun barrel with Brosnan -> cast screen) at ~59 fps. New
blocker D69: load_bg_file faults on first stage load - BG-file headers are
N64 big-endian segment-0x0F offsets read LE on PC. Full analysis + strategy
in PCPortResearch.md §F/D69; HANDOFF rewritten for the D69 session.
2026-08-24 03:27:29 -04:00

37 lines
1.6 KiB
C

#ifndef GIMG_FIXUP_H
#define GIMG_FIXUP_H
#include <PR/ultratypes.h>
/* D68 (docs/PCPortResearch.md): endianness fixup for the Globalimagetable
* segment after texReset()'s romCopy(). The N64 CPU is big-endian, so every
* u32 in the ROM copy is BE-encoded; PC consumers read them natively (LE).
*
* Two kinds of CPU-interpreted u32 live in the segment:
* - Gfx w1 words of IMAGESEG-marked G_SETTIMG commands (IMAGESEG(id) =
* 0xABCD0000 | id, see bondconstants.h). texLoadFromDisplayList() scans
* for the AB CD marker bytes and texLoad() reads the word back as
* `*updateword & 0xffff` to get the image id.
* - sImageTableEntry.index (first u32 of each 12-byte entry) in the 32
* table arrays; read both as a raw word by texLoad() and as a struct
* field by texSelect()/explosion.c.
*
* Everything else in the segment is byte-level (Gfx opcodes, single-byte
* table fields, raw pixel blocks referenced via 0x02xxxxxx segmented
* addresses) and needs no transform.
*
* After the fixup the marker bytes sit at offsets 6..7 of each Gfx (LE
* encoding of 0xABCDxxxx), so texLoadFromDisplayList() checks them there
* under PORT.
*/
void gimgFixupGlobalimagetable(u8 *base);
/* Copy the IMAGESEG w1 words patched by texLoad() in the ROM copy back into
* the compiled globalDL_0xNNN arrays (oddtextures.o), which explosion.c
* executes via g_ExplosionDisplayLists[] on PC. The ROM copy and the
* compiled arrays are byte-identical per D39, so command j of the ROM DL
* maps to Gfx slot j of the compiled array (16-byte stride on PC). */
void gimgSyncCompiledGlobalDLs(u8 *base);
#endif