hl1-ps2-gui-sdk

Half-Life PS2 (Gearbox) UI Reverse Engineering SDK ๐Ÿ•น๏ธ

A toolkit for reverse-engineering, documenting, and recompiling the User Interface system used by Gearbox Software in the PlayStation 2 port of Half-Life.


๐Ÿ“š Table of Contents


This project targets the proprietary guidef.txt (GUI Definition) pipeline and its compiled binary counterparts, enabling reconstruction of original menus, layout behavior, and runtime state logic.


๐Ÿ” Reverse Engineering Scope

The Gearbox PS2 UI system is not a conventional retained-mode UI. It is a state-driven renderer designed around the constraints of the Emotion Engine (MIPS R5900) and the PS2 Graphics Synthesizer (GS).

This SDK reproduces:


โœจ Features


๐Ÿ› ๏ธ Project Structure


๐Ÿ“„ Binary Format (Current Understanding)

Each UI element compiles into a fixed 32-byte structure:

Offset Type Description
0x00 uint16 Element Type ID
0x02 int16 X Position
0x04 int16 Y Position
0x06 int16 Width
0x08 int16 Height
0x0A uint32 Color (Packed, likely ABGR)
0x0E uint32 Hover Color
0x12 int16 Z-Plane
0x14 int16 Dependency Index (-1 = none)
0x16 uint16 Blend Mode ID
0x18 uint16 Fade In (ms)
0x1A uint16 Fade Out (ms)
0x1C uint32 Padding (DMA alignment)

Notes


๐Ÿ“ฆ Container Formats

The engine uses multiple compression wrappers:

1. .MPC (Standard)

[4] Magic ".MPC"
[4] Decompressed Size
[4] Compressed Size
[Zlib stream]

2. CMP. (Canonical Gearbox TXT)

[4] "CMP."
[4] Decompressed Size
[4] Compressed Size
[4] Unknown/flags
[Zlib stream]

3. "COMPRESSED" (String Header)

[10] ASCII "COMPRESSED"
[Zlib stream]

All variants rely on Zlib (DEFLATE) streams.


๐Ÿ“ Usage

  1. Place a guidef (or any other Gearbox Text) file in the workspace
  2. Parse โ†’ simulate โ†’ export
  3. Output binary is ready for:

    • emulator testing
    • asset injection
    • engine-side validation

๐Ÿงช Validation Strategy

To ensure correctness:

  1. Load original asset
  2. Decompress โ†’ parse
  3. Re-export
  4. Compare decompressed buffers

Differences usually indicate:


โš ๏ธ Disclaimer

This project is a reverse-engineering effort for research and preservation.

All original assets and IP belong to Valve Corporation and Gearbox Software.


๐Ÿง  Project Status

The current project status is available on the Project Board.

For more information about the GUI system, see the GUI Specification.