Skip to content

The SDL3 port

A native build of Hitman: Blood Money that runs the C++ directly, renders through SDL3's GPU API (Vulkan, Metal), plays sound through SDL3 audio, and reads the game data from the user's own PC installation at run time. No game data files are in the repository, with the stated exception of the Silverballer renders used for the app icons and header image and the comparison screenshots under docs/development/port/images/ (Legal and Licensing).

make port-setup     # cmake, ninja, SDL3, FFmpeg, Dear ImGui, DXC, SPIRV-Cross under tools/third_party/port/
make port           # CMake build, including native scene scripts: build/port/cmake/openbloodmoney
make port-status    # compile every game unit with the host clang and report failures
make port-windows-setup   # zig, a CMake toolchain and static SDL3, zlib and FFmpeg for x86_64-windows-gnu
make port-windows         # cross-compile build/port/windows/openbloodmoney.exe from Linux
openbloodmoney                       # the launcher
openbloodmoney DISC.iso [Option=Value ...]   # straight into the game, as the test scripts start it

The mobile builds produce unsigned arm64 packages under build/release/. Run python3 tools/port/build_mobile.py ios with Xcode and Ninja, or python3 tools/port/build_mobile.py android with JDK 17, CMake, Ninja, Android SDK 36 and NDK r28c. Android uses ANDROID_HOME to locate the SDK. The same script runs on GitHub Actions on v* tag pushes.

Documents

Document Subject
launcher.md The launcher, settings, input bindings
overrides.md How the port replaces game functions: definitions marked OBM_FN in src/ (weak outside the PS2 build), listed in port/overrides.json
scene-scripts.md, native-scripts.md The level scripts as C, and how the port runs them as native code
script-sdk.md, script-thunks.md, payload-layouts.md Script headers, the engine interfaces, message payloads across the script boundary
textures.md, prim-decode.md, ../formats/vu-programs.md Texture and mesh decoding, the PS2 vertex programs the renderer follows
sound-and-movies.md The synthesizer, streams and movie playback
pc-data.md, pc-assets.md Playing a PC installation alone; which PC assets a disc run can use, with the measurements
PC rendering Water, shadows and PC material shaders
Frame timing, display and projection, graphics and gameplay implementation Renderer measurements and version-specific behavior
frame-rate.md, resolution-and-widescreen.md Frame rates above 30, resolutions and aspect ratios
enhancements.md Optional graphics and gameplay enhancements (mipmaps, FXAA, SSAO, field of view, quick save, photo mode and more)
modding.md Lua mods, their manifest and the obm API, and the built-in mods the port ships (rating, cheat menu, photo mode, Instinct, slow aim, HUD styles and the Randomiser)
randomiser.md The built-in Randomiser gamemode: presets, what each layer changes, how rules are checked, seed codes, and curating a level's data
debug-ui.md, stability.md The debug overlay, the stress harness, crash reports and what they found
native-width-audit.md, platform-symbols.md, ../elf-only-data.md 64-bit layouts, platform symbols, data defined in source

Ground rules

  • The matching build stays green. make match and make test pass with every port change.
  • Port-only code lives under port/. It mirrors IOI's platform split: where the engine has system/_ps2/sysinterfaceps2.cpp, the port adds port/engine/system/_sdl/sysinterfacesdl.cpp. The matching tools never see port/.
  • Edits to shared src/ files are portability fixes that do not change PS2 code generation, verified by make match. Platform conditionals use one macro, OPENBLOOD_TARGET_PS2, which tools/config/toolchain.json passes to every matching compile. OPENBLOOD_HOST_TEST keeps its one job, the faked 32-bit layouts of the host unit test.
  • Where the engine exposes a virtual platform class (ZSysInterface, ZSysFile, ZDllSound, ZSysInput, ZOldDrawBase, ZOldViewBase, ZRender), the port adds one subclass, as the _ps2 code does.
  • Port translation units that include engine headers include no C++ standard library headers. The engine's own containers (src/common/zstl) define namespace std themselves, and mixing them with libc++ in one translation unit will not compile. Port code uses C headers and SDL.
  • Build steps that need game data read it from the user's ISO or PC installation. The app icon contains a flattened render of the Silverballers. Its source mesh and textures are loaded from the user's game files when capturing the artwork.

App icons

The app icons in port/launcher/icons share the launcher’s render of the Dual Silverballers. The Apple packages compile the layered AppIcon.icon with Xcode 26 or later. Older Xcode versions use the iOS asset catalog or the macOS ICNS. Android uses adaptive layers and a monochrome layer for themed icons. The Windows executable embeds a multi-size ICO. The Linux archive includes a desktop entry and a hicolor icon, and SDL supplies an icon to desktop windows.

To update the artwork, use the desktop launcher to capture the transparent model from your PC installation and regenerate the icon sizes with Pillow installed.

mkdir -p build/app-icons
OPENBLOOD_LAUNCHER_MODEL_ONLY=1 build/port/cmake/openbloodmoney --set game.version=pc \
    --pc-install "/path/to/Hitman Blood Money.zip" --launcher-capture build/app-icons/Silverballers.png
python3 tools/port/make_app_icons.py --model build/app-icons/Silverballers.png

Architecture

  1. Pointer width. The port is a true 64-bit build. Engine code keeps native pointers. Every loader that patches file offsets into pointers in place gets a port path: either it resolves offsets at use, or it copies into a host-layout struct. File layouts are declared as separate fixed-width structs used only by loaders. A 32-bit build is impossible on current macOS, and a low-4 GB arena does not help because native pointer fields stay 8 bytes wide.
  2. Renderer boundary. New ZRenderSDL, ZRenderDllSDL, ZOldDrawSDL, ZOldViewSDL, ZPostFilterSDL and Z2DFunctionsSDL classes sit beside the PS2 ones. Rooms, portals, sorting, decals, shadow lists and the post-filter API stay engine code. Emulating the GS, VIF and VU1 is rejected; it would make a PS2 emulator, and the result would not be a native renderer.
  3. Scripts. The decompiled sources in src/scripts/ compile for the host into the port's executable and run as native 64-bit code (native-scripts.md). The engine's script core uses real pointers; interface adapters and payload tables convert the scripts' 32-bit REFs.
  4. Audio. An in-process synthesizer replaces the IOP. ZDllSound keeps producing its per-frame SYNTH_CMD_* frame, and a new ZDllSoundSDL hands that frame to a synth on the SDL audio thread instead of DMAing it to the IOP. The synth's behaviour comes from analysing SYNTHCD.IRX, which is IOI code.
  5. Shaders. Shaders are written in HLSL under port/shaders/ and compiled offline with SDL_shadercross to SPIR-V (Vulkan) and MSL (Metal).
  6. Movies. FFmpeg decodes the MPEG-2 streams; make port-setup builds a pinned minimal FFmpeg and links it statically (sound-and-movies.md).
  7. Build. CMake builds the port only. tools/port/port_units.py reads tools/config/source-tree.json and lists the game translation units, excluding the _ps2 units the port replaces and the .s units. Linked SDK, runtime and library code has no unit; the port uses the host's C library, SDL3 and zlib instead. Game units compile as -std=gnu++98 -fsigned-char -fno-exceptions -fno-rtti -fno-strict-aliasing -DNON_MATCHING; port/port.json holds the flags and the pinned dependencies.
  8. Overrides. The port's behaviour (mod hooks, launcher settings, diagnostics) lives in port/. A game function the port changes is marked OBM_FN in src/ (src/openblood/replaceable.h): empty on the PS2, a weak definition elsewhere, so the port's own definition of the function takes its place. port/overrides.json lists them (overrides.md).

Implementation notes

These record how each part was built and what it approximates. They were written as the work was done in November 2026.

Shared source

  • OPENBLOOD_TARGET_PS2, passed by tools/config/toolchain.json, guards PS2-only code. The 32-bit layout checks and inline assembly sit behind it; native fallbacks test its absence; OPENBLOOD_HOST_TEST keeps only the host unit test's layout fakes.
  • GCC's <? and >? are ZMIN and ZMAX (engine/system/minmaxoperator.h).
  • openblood/crt.h replaces about 550 hand-written C library declarations. Game units compile with -nostdinc++, because the game brings its own namespace std.
  • Explicit specializations carry template<>, dependent-base members are named, Header, ActiveAnimation and ScriptEngine each have one declaration, and read-only strchr results are const char *.
  • fast_asin, fast_cos, fast_mod, qpul, mrot, vpul and the MMI intrinsics have native C versions next to the EE assembly.
  • Release builds pass -fno-delete-null-pointer-checks: engine methods test this against null (ZEventBase::Delete), and clang removed those tests.
  • Plain char is signed on the EE and unsigned on Linux arm64, so the port always builds with -fsigned-char.

Pointer width and loaders

  • REF is uintptr: unsigned int on the PS2 and pointer-sized natively, because REFTABs, message data and CCom carry raw pointers in REF storage throughout the engine. intptr sits beside it.
  • Storage that held addresses in 32 bits is pointer-sized: CListUser light lists (the scene block is widened at load), geom-list IDs and entries, decal handles, ZValTree and CFastLookup2 values, the zip cache, and the CCom-passed cut-sequence queue and item table.
  • The property graph (402 Info records, 2,680 nodes, enum descriptors and load/save tables) is generated by tools/property_records.py from the ELF and the debug record, with member pointers named so native builds store native offsets.
  • openbloodmoney <disc> [Option=Value ...] applies options after main.ini. OPENBLOOD_SYSTEM_HEAP=1 routes the game allocators to calloc, so ASan reports heap overflows at the faulting write.
  • 32-bit assumptions the first boot found, all fixed with make match still exact: pools and inline blocks sized with PS2 element sizes (ZMalloc, REFTAB32), a >> 3 header count in ZPoolAllocator, alignment masks that negated a 32-bit operand, an over-read in CGlobalCom::Append, duplicate class definitions that only agree on the PS2 because padding stands in for pointers (ZScene, ZBaseVideo/ZPS2Video, the hm3properties.h copies, two global Particle structs sharing a constructor symbol), sprite arrays used in place from primitive data, SRoomTreeBox REFs (now endian_REF, the original's 32-bit file REF), static geom REFs (byte offsets in units of the PS2 ZBaseGeom, 0x70), and texture buffers installed without CompactTextureBuffer.
  • tools/duplicate_classes.py [--sources] [--layouts] lists classes defined more than once and compares their native layouts.
  • Arenas sized in PS2 bytes now account for native sizes. The event arena and the draw arena get twice their PS2 size. The geom list buffer and the five static ZPoolAllocator buffers are sized in pointer-sized words. Extra geoms are 16-byte aligned natively, because clang uses aligned SSE stores on classes with 16-byte members.
  • Further 32-bit assumptions: QuickSort's pivot over uintptr keys, ZHFlow::ExtendVisibleMap's pMap[b - lModulo] (it wrapped to the previous row only on 32-bit addresses), RoomFree returning 4 bytes per geom pointer, which left a hole on every free until the draw allocator's 1024 free links overflowed, and a draft that cleared three pointers with memset(this, 0, 0xc).
  • Further file records: post-filter collection indices are endian_REF, and editor spline waypoints are widened from their 24-byte records. CElevatorHouse::OpenDoors now sends a zmsg_dooropen like the original, not an int32.
  • The particle box prefetch into scratchpad (an SPR1 DMA) only runs on the PS2.
  • The CUTS chunk holds PlayStation 2 SCut records (0x34 bytes). The native build copies them with that stride into an owned array instead of indexing the native 0x38-byte struct.

Renderer

  • ZRenderSDL owns an SDL_GPU device, a 512x448 colour and reversed-depth target and a per-frame draw list (transient vertices, per-draw uniforms, pipelines keyed by GS state). Flip draws the list, composites the target into the window at 4:3, and OPENBLOOD_CAPTURE_DIR writes PNG captures. Shaders are HLSL in port/shaders, compiled to SPIR-V at build time by the DXC that make port-setup installs (port/port.json pins it).
  • Material state is a port of ZOldDrawPS2::CalcGSRegs: each draw keeps the GS TEST/ALPHA/ZBUF values, and one function maps any GS ALPHA equation to GPU blend factors.
  • Camera view entries use the engine's own ZCameraViewEntry::CalcCameraToView with a 0..1 depth range (near maps to 1), then a fixed GS-screen-to-clip matrix.
  • The boot menu draws: sprite arrays (plain, UV, raw), camera clears and scissors, and the memory card warning laid out correctly once m_lResolution is set to 512x448 as ZPS2Setup does. Textures use a placeholder decoder until the PS2 texture decoder is in.
  • On Linux the executable keeps the game's operator new/delete local (port/openbloodmoney.map), because Vulkan drivers load C++ code that must not allocate from the game heap. macOS coalesces operator new across images, so the Mac build needs its own answer. The platform sources build as C++14 with -fno-sized-deallocation, so a delete there calls the game's unsized operator delete; the sized one would come from libstdc++ and free a game block with free().
  • The PS2 texture decoder (texturedecodesdl.cpp, cross-checked against a Python reference on all 26,471 mip levels of the disc), the PRM mesh decoder (primdecodesdl.cpp, 71,655 submeshes cross-checked) and the VU program documentation (docs/internals/formats/vu-programs.md, tools/vu_disasm.py) were cross-checked against the disc. Sprites follow the general sprite microprogram (object-space corners from the camera axes, shared W, screen-aligned rectangles); static strips draw from decoded meshes with the VColClip colour rule and depth bias. The boot menu, the copyright screen and the title screen (HitmanBloodMoney.gms) render correctly. Further loader fixes: draw-list block capacity, pool REFTAB blocks, the prim handle flag bit, overlapping prim compaction and post-filter boxes.
  • ASan reports poison_array_cookie false positives when the game's operator delete[] hands a block back to ZMalloc; the boot script sets poison_array_cookie=0.
  • Known leaks to fix with a per-scene arena: widened sprite arrays, room exits and neighbour lists, and animation headers are never freed.
  • Skinned prims draw. ZOldDrawSDL runs the PS2 bone update (IK, MatToParent and MatMulMat as C++) and the direct-light update in UpdateDynamic; zoldviewbonessdl.cpp skins bone strips, bone variants and bone arrays on the CPU and lights them as VColClipBone does, and poses and lights rigid-bone (pack type 8) and owned strips as VColClip does. Cutscene characters get the HQ "Prettylights" pass (see "Lights"). The view draws with the root matrices, deform bones and lights of the previous frame's UpdateDynamic, one frame behind the PS2, which runs it before its chain executes.
  • Crowds (ZHFlow, M06's Mardi Gras) draw as bone arrays. ZAnimBufferControler::GetBones hands each animation a bone buffer from a shared pool every frame during visibility, and ZHFlow::UpdateBones, a flip callback, fills those buffers and places the attached accessories. ZRenderPS2::Flip runs the callbacks before it sends the chain, so the port runs them at the same point, right after UpdateDynamicBeforeDraw. Run at Present, they left each crowd member skinned with whatever animation had its buffer the frame before, so the crowd changed outfits every frame. Particle boxes register the same kind of callback.
  • Static shadows (layer 6, material 10) draw as on the PS2: shadow meshes decode from their VUStaticShadowDraw VIF streams (shadowdecodesdl.cpp, checked on all 1,726 meshes), lerp shadows accumulate per colour in a byte of the temp target (DRAW_TARGET_TEMP, a second render pass) and merge into the frame through the same blend equations; additive and textured (projected) shadows follow the VU program. The seams fixup (PS2_EnableStaticShadowSeamsFixup) is not ported; M00 does not use it.
  • Normal-mapped strips (material 6) follow the PS2's dot3 passes with one texture per pass: per-vertex lighting from the geom's environment light as ComputeDot3Lighting does it, max(0, N·L) from the normal map written to the frame's alpha, the diffuse texture blended by destination alpha, and a (N·H)^16 specular pass. Omni, spot and square spot lights from the geom's light list are added; see docs/internals/formats/vu-programs.md.
  • Particles, snow and rain follow the SnowDraw microprogram (settled against a small VU1 interpreter); ParticleCalc is native C++. From a PC installation the snow and rain are drawn the PC release's way (PC data: Snow and rain). The title screen survives the attract-mode restart: the GPU device, window, targets and draw list live outside the game heap and are opened once.
  • Headless test tools: OPENBLOOD_CAPTURE_DIR (PNG captures), OPENBLOOD_INPUT_SCRIPT (scripted pad, key and mouse input, launcher.md), OPENBLOOD_DEBUG_COLORS (colour by prim), OPENBLOOD_DEPTH_CLIP (clip at the far plane like a GPU without depth clamping, PC rendering), and a crash backtrace handler in builds without ASan. OPENBLOOD_DETERMINISTIC and OPENBLOOD_FRAMES give runs that repeat exactly (docs/internals/scripts/scene-scripts.md). OPENBLOOD_TRACE_FRAMERATE=1 logs once a second how often ragdolls, rigid bodies and cloth stepped and what they cost, and how fast the pad pans the map (frame-rate.md).

Lights

  • ZOldDrawSDL::UpdateLight follows ZOldDrawPS2::UpdateLight: for each geom whose BASEGEOM_LightDirty is set (and owned bone geoms every frame) it fixes and updates the light list, gathers up to 12 lights from CListUser with the PS2's filters, and keeps them with the environment light per geom (lightssdl.cpp). PrimInstanceCreate sets the bit for light-enabled strips as the PS2 does.
  • Static strips with lighting enabled (CheckPrimLightEnabled or geom control 0x8000) get the per-vertex light colours VLightTest computes: environment (directional or two-sided), omni, cone and square spot lights, clamped to 255 and used as L in L·C·D/32768. The colours are computed on the CPU when the PS2 would recompute them and baked into a per-instance vertex buffer that reuses the mesh's index buffer (litmeshsdl.cpp); other strips keep the white g_WhiteChunk light.
  • Dot3 surfaces add omni, cone and square spot lights to the environment term as ComputeDot3Lighting and the newlight segments do, with the direction weighted by luminance.
  • Characters created during a cut sequence (GEOMCONTROL_HQLIGHTS) get the Prettylights pass: CreatePrettyLightsBuffer fills the HQ block as on the PS2 and the bone draw evaluates it per vertex in place of the three directional lights.
  • The formulas were settled by simulating the VU programs (docs/internals/formats/vu-programs.md); all terms are exact except the square spot of VLightTest and of the dot3 path, which use a per-axis model (297 of 300 random samples exact, edges within 14/255).
  • Interiors change most: the winery walls of M02 (normal-mapped) were close to black with only the environment light and are now lit by their lamps, and static props in the hideout and M00 show the environment light's shading instead of flat white. M00's Plane_Seabottom_PS2 (draw mode 0x390) is light-enabled and its geom's environment light has multiplier 0.2, so its light colours are 18 to 79 out of 0x80; it is a lerp-blended layer with vertex alpha up to 0x40 over the underwater ground and caustics, which makes the murky sea. M00 has no water patches.

Surfaces and screen effects

  • Water (material 11, zoldviewwatersdl.cpp, water.hlsl): ZOldDrawSDL::PrimInstanceCreate allocates the SWaterPatchInst as PrimInstanceCreateWaterPatch does and UpdateDynamic runs ZWaterManager::FrameUpdate, so waves and Hitman's ripples advance as on the PS2. Each patch is a grid with the four sine waves, the ripples, the Fresnel alpha and the environment UVs of VUWaterRender; pass 1 draws the patch texture with colour 0 (ALPHA_1 = Cs, depth written), pass 2 samples a copy of the frame at the screen position plus normal.xz * fRefractScale and blends lerp(refraction * colour 1, pass 1, Fresnel) (ALPHA_2 = 1). Every water patch on the disc is textured with flags 2, so the disc never uses the projective and mirror-group reflection paths (g_bUseTrueReflections, untextured patches). Patches converted from a PC installation do: in PC-data mode the port renders the reflected view to a texture that covers the view and draws the patch with the PC's WaterSurface.fx terms (DrawWaterPc, the waterpc program; PC rendering). Approximations: the refraction copy is full resolution where the PS2 squashes the frame into half of the temp buffer, and colours interpolate perspective-correctly in pass 1. In M10 the water sits under the pool floor's depth-biased strips, as the same code does on the PS2.
  • Plane align and angle blend (zoldviewsdl.cpp): strips with draw mode 0x10000000 take the camera's rotation, as VColClip's InitPODRegs does (PlaneAlignedMatrix), and strips with an angle-blend header (0x40) fade by their distance from the eye (StripsAngleBlendFade, read by general.hlsl); the angle ramp between two different angles is not drawn. See pc-data.md: Plane align.
  • Grass (material 9, zoldviewgrasssdl.cpp): the tile grids of PrimInstanceCreateScatter are walked as VU_GrassDraw does: per-vertex colour from the vertex RGB and up to four scatter lights, the distance fade (fDrawDist, 0.0025), two triangles per cell with object counts from the master tile, barycentric placement, the VU random generator seeded with the tile's first vertex, a tint between colour A and B, and screen-aligned billboards picked from the texture strip (distribution values 4 to 7 are mirrored). AFAIL FB_ONLY is two passes (alpha above the reference with depth, the rest without). Approximations: campos.w, the base colour scale, is never initialised by the PS2 C++ and is taken as 1.0, the value the program's "tweak" path writes; tiles are culled against the view frustum in camera space, not with the program's four root planes.
  • Mirrors (zoldviewmirrorsdl.cpp): mirror sub-lists draw as DrawMirror does. The glass prims (lDrawMode & 0x10000) write the mirror fog colour and a stencil mask where they pass the depth test, then clear depth to far inside the mask; the sub-list is drawn with the camera from ZOldDrawIdListMirror::UpdateCameraSpace, the stencil test, a clip distance at the mirror plane and dest-alpha blends drawn opaque (MIRROR_ALPHA_1_VALUE); the glass depth is restored and the stencil cleared. The general shader has a ClipPlane uniform for this. Mirror prims in the main list are skipped: on the PS2 their DATE test fails once EndMirror resets the alpha. Mirror groups (water reflections) are recorded and drawn with their water (WaterRecordMirrorGroup, DrawWaterMirrorGroup), which only PC-data patches make.
  • Lines (material types 3 and 4): the mesh decoder emits line lists, one line strip per strip, as VLineClip sends a GIF tag per strip. The only line prims on the disc belong to geoms that never reach a draw list (M02's SoundSpline_01, the title scene's camera paths Line01 to Line07, chunkless wire strips in the premission scenes), so there is no capture; the decoder gives 2 x (vertices - strips) indices for them.
  • FadeScreen blends the fade colour over the shown frame for fTime * m_fFramesPerSecond frames with ALPHA 0x44 and the PS2's quadratic alpha, then fills the screen. ZRenderDllSDL sets a one-second black fade, so every PopScene fades.
  • The loading bar: ZRenderSDL::ProgressBar draws m_v4ProgressBarRect in dwColor1 & 0xffffff over the shown frame and presents it. LoaderSequenceRegisterSDL installs a loader sequence player that forwards Set_Progress to it, which is what ZLoader_Sequence_PS2 does when no picture sequence is installed; boot menu and attract mode start at 10% as on the PS2. Mission main scenes and the hideout play the picture sequence of LOADER_S.ZIP (loadersequencesdl.cpp).
  • OPENBLOOD_CAMERA="x,y,z,tx,ty,tz" places the main camera before the visibility pass (it must stay inside a room to see anything).

Geometry the port dropped

  • Meshes upload to the GPU through a per-frame queue. It held 1,024 buffers and a mesh whose upload found it full was marked failed for good, so it never drew again. Lit strips added one vertex buffer upload per instance, and M00's first frame went over the limit: 70 geoms never drew, among them the sea (Plane_Seabottom_PS2, So00G_Underwater_GroundA_14, PS2_Caustics_01 to 03, WaterDarkness_01), railings, street lights, ropes, the theatre sign and walls, roofs and corners of the palace. That was the "dark fog" under the pier and the missing objects. The queue now grows.
  • VLightTest runs only for prims CheckPrimLightEnabled accepts (draw mode 0x80 set, 0x8 clear). A prim that gets a light buffer only through its geom's control bit 0x8000 keeps the 0x7f7f7f the buffer is filled with on the PS2 (PrimInstanceCreate); the port had lit those too (chain-link fences and street lights in M00).
  • Pixels that fail the GS alpha test were discarded. On the GS the test's AFAIL field decides what a failing pixel still writes, and CalcGSRegs uses AFAIL RGB_ONLY for every alpha cutoff (draw modes with blending and a cutoff below 0x80, and draw mode 0x8), so on the PS2 those pixels still blend into the frame without writing Z or alpha. M00 has 15 such material setups with cutoffs up to 0x79, which lost almost all of their semi-transparent pixels, and the hideout's subtractive detail layers (DetailTexture_*, detail_Wall_*, draw mode 0x2291, cutoff 0x3f) darkened the walls only where their alpha passed. Draw calls whose test can fail now draw a second time with the inverted test and the AFAIL write mask (lAlphaFail in the draw state); grass and dot3, which handle alpha themselves, opt out. Within one mesh the failing pixels draw after the passing ones, where the GS interleaves them.
  • OPENBLOOD_TRACE_DRAWLIST=1 logs every 50th frame's draw list size (calls, vertices, uniforms, passes, overflow) from DrawListSubmit.
  • OPENBLOOD_TRACE_DROPS=1 counts sort entries per material every 300 frames and the reasons for entries that emit no draw (2 also logs each geom and reason once). With these fixes, M00 at the pier, the palace front and back, the roller coaster and below the pier shows no dropped strips, bones, dot3 or shadows. What remains is what the PS2 drops as well: sprites outside the PS2's near and far constants (hidden briefing and map items), culled or empty particle arrays, and bone geoms whose lights the PS2 has not computed yet (the port draws one frame behind, so such a geom appears one frame late).

  • OPENBLOOD_HIDE_ENTRY=TEXT leaves out every draw entry of the geoms whose name contains TEXT, from the frame and from the bloom and other lists (ZOldViewSDL::Draw); OPENBLOOD_NO_STATIC_SHADOWS=1 leaves out the static shadows; OPENBLOOD_TRACE_MATERIAL=TEXT logs the PC material and the converted draw mode, destination and colour of every object whose material name contains TEXT (MakeDrawSetup); OPENBLOOD_TRACE_SCATTER=1 logs each scatter field as it is converted and first drawn. In Git Bash a value starting with / is turned into a Windows path, so pass a plain text.

Post filters

  • ZPostFilterSDL (postfiltersdl.cpp, postfilter.hlsl) follows ZPostFilterPS2::Update pass by pass: bloom, the first-person layer, the depth key or z-blur list, depth blend with heat shimmer, curves, last-frame blend with rotate and zoom, finish blend and noise. The view adds the material-13 sort entry (layer 23, priority 9) and fills the camera border as ZOldViewPS2 does.
  • The draw list takes pass entries: DrawListSubmit ends the render pass, runs the entry's callback outside any pass and continues on the entry's colour target. Calls still carry their own target, so the static shadows' temp target works inside any pass. Shaders are created by manifest position for the draw list and looked up by name for the post filter, so new shaders go at the end of shaders.json.
  • M00 gameplay shows its sepia grade (curves palettes as a 3x3 channel mix), sun bloom and glow. The title's 3D scene is filtered too, but the full-screen title art drawn after it covers it, as on the PS2.
  • Approximations: the blur is a separable Gaussian modelled on the PS2's down/up-sampling pyramid; the bloom target is 8-bit RGBA, not 16-bit; the noise and shimmer random generator is a standard LFSR model. The first-person paths and Metal's depth sampling are untested.
  • The M00 briefing keeps a camera-effect filter at full strength (black palette) until it closes, so a run that never closes the briefing is black behind it. PostFilterLOD=0 crashes natively in ZHM3LevelControl::SetupPostFilters (ZPostFilterSetEvent::SetiPrim uses an event that already removed itself); this predates the SDL post filter. OPENBLOOD_TRACE_POSTFILTER=1 logs the parameters every 50 frames; OPENBLOOD_NO_POSTFILTER=1 draws the frame without the bloom and the grade (to see the picture the grade starts from). From a PC installation the finish keys and blends as the PC's ZPostFilterWintelD3D does (PC rendering). It also lists the bloom list's geoms (material, destination, texture, draw mode, colour and position), and OPENBLOOD_BLOOM_DEBUG=1 shows the bloom list's picture in place of the frame (2 its blurred picture).

Scene scripts

  • The engine side is the matched scriptc.cpp and zscriptc.cpp. Natively the shared script structs hold host pointers, m_rThis stays 32 bits, and AttachSceneScripts loads the level's library through ScriptLevelAttach (scriptlevelsdl.cpp).
  • Message payloads: scripts see the PS2 field order with 32-bit REFs and the 64-bit script layout; the engine sees the native one. scriptmessagessdl.cpp and scriptmessagesrecovered.cpp hold the field layouts, and scriptfunctionssdl.cpp converts a payload each way when a script sends or receives it.
  • Script save state: the save walk and PostSave are the matched code; natively PrepareData and FixupData walk pointer-width slots and store controllers as offsets into the level library's image. OPENBLOOD_SAVE_TEST_FRAME=N saves through ZEngineDataBase::SaveGame into mc0/savetest.* and loads it back through ZLoadGameInfoPS2; OPENBLOOD_SAVE_TEST_RESAVE=1 saves again on the next frame. Under the offscreen SDL driver the load crashes in DrawListSubmit while the scene unloads, in the emulator build as well, so native loads are untested on a headless host.
  • The stream interface follows the debug record: IOutputStream::Write and IInputStream::Read take and return size_t, so the memory-card streams override them natively.

Animation streams

  • The dark upright shape on Hitman, and characters or birds that vanish for a few frames, came from the animation decoder, not the renderer. StreamPacker::DePackVector and DePackBlock sign-extend each delta with (delta << (32 - bits)) >> (32 - bits), and a delta band of 0 bits gives a shift of 32. The EE's sllv/srav use the shift modulo 32, so the PS2 adds 0; in C++ the shift is undefined, and clang -O2 turns it into garbage. The decoded human state then carried pelvis positions that grew by thousands of units per frame and wrong arm states, StateFit built the skeleton from them, and the deform bones placed the jacket's shoulder vertices above the head or moved the whole body out of view. SIGNEXTEND in streampacker.cpp masks the shift to five bits natively and expands to the original expression on the PS2 (make match exact). A differential test of the decoder at -O2 against -O0 on 200,000 random streams now agrees, and UBSan reports nothing.