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 matchandmake testpass with every port change. - Port-only code lives under
port/. It mirrors IOI's platform split: where the engine hassystem/_ps2/sysinterfaceps2.cpp, the port addsport/engine/system/_sdl/sysinterfacesdl.cpp. The matching tools never seeport/. - Edits to shared
src/files are portability fixes that do not change PS2 code generation, verified bymake match. Platform conditionals use one macro,OPENBLOOD_TARGET_PS2, whichtools/config/toolchain.jsonpasses to every matching compile.OPENBLOOD_HOST_TESTkeeps 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_ps2code does. - Port translation units that include engine headers include no C++ standard library headers. The engine's own containers (
src/common/zstl) definenamespace stdthemselves, 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¶
- 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.
- Renderer boundary. New
ZRenderSDL,ZRenderDllSDL,ZOldDrawSDL,ZOldViewSDL,ZPostFilterSDLandZ2DFunctionsSDLclasses 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. - 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-bitREFs. - Audio. An in-process synthesizer replaces the IOP.
ZDllSoundkeeps producing its per-frameSYNTH_CMD_*frame, and a newZDllSoundSDLhands that frame to a synth on the SDL audio thread instead of DMAing it to the IOP. The synth's behaviour comes from analysingSYNTHCD.IRX, which is IOI code. - Shaders. Shaders are written in HLSL under
port/shaders/and compiled offline with SDL_shadercross to SPIR-V (Vulkan) and MSL (Metal). - Movies. FFmpeg decodes the MPEG-2 streams;
make port-setupbuilds a pinned minimal FFmpeg and links it statically (sound-and-movies.md). - Build. CMake builds the port only.
tools/port/port_units.pyreadstools/config/source-tree.jsonand lists the game translation units, excluding the_ps2units the port replaces and the.sunits. 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.jsonholds the flags and the pinned dependencies. - Overrides. The port's behaviour (mod hooks, launcher settings, diagnostics) lives in
port/. A game function the port changes is markedOBM_FNinsrc/(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.jsonlists 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 bytools/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_TESTkeeps only the host unit test's layout fakes.- GCC's
<?and>?areZMINandZMAX(engine/system/minmaxoperator.h). openblood/crt.hreplaces about 550 hand-written C library declarations. Game units compile with-nostdinc++, because the game brings its ownnamespace std.- Explicit specializations carry
template<>, dependent-base members are named,Header,ActiveAnimationandScriptEngineeach have one declaration, and read-onlystrchrresults areconst char *. fast_asin,fast_cos,fast_mod,qpul,mrot,vpuland the MMI intrinsics have native C versions next to the EE assembly.- Release builds pass
-fno-delete-null-pointer-checks: engine methods testthisagainst null (ZEventBase::Delete), and clang removed those tests. - Plain
charis signed on the EE and unsigned on Linux arm64, so the port always builds with-fsigned-char.
Pointer width and loaders¶
REFisuintptr:unsigned inton the PS2 and pointer-sized natively, because REFTABs, message data and CCom carry raw pointers in REF storage throughout the engine.intptrsits 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
Inforecords, 2,680 nodes, enum descriptors and load/save tables) is generated bytools/property_records.pyfrom the ELF and the debug record, with member pointers named so native builds store native offsets. openbloodmoney <disc> [Option=Value ...]applies options aftermain.ini.OPENBLOOD_SYSTEM_HEAP=1routes the game allocators tocalloc, so ASan reports heap overflows at the faulting write.- 32-bit assumptions the first boot found, all fixed with
make matchstill exact: pools and inline blocks sized with PS2 element sizes (ZMalloc,REFTAB32), a>> 3header count inZPoolAllocator, alignment masks that negated a 32-bit operand, an over-read inCGlobalCom::Append, duplicate class definitions that only agree on the PS2 because padding stands in for pointers (ZScene,ZBaseVideo/ZPS2Video, thehm3properties.hcopies, two globalParticlestructs sharing a constructor symbol), sprite arrays used in place from primitive data,SRoomTreeBoxREFs (nowendian_REF, the original's 32-bit file REF), static geom REFs (byte offsets in units of the PS2ZBaseGeom, 0x70), and texture buffers installed withoutCompactTextureBuffer. 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
ZPoolAllocatorbuffers 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 overuintptrkeys,ZHFlow::ExtendVisibleMap'spMap[b - lModulo](it wrapped to the previous row only on 32-bit addresses),RoomFreereturning 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 withmemset(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::OpenDoorsnow sends azmsg_dooropenlike the original, not anint32. - The particle box prefetch into scratchpad (an SPR1 DMA) only runs on the PS2.
- The CUTS chunk holds PlayStation 2
SCutrecords (0x34 bytes). The native build copies them with that stride into an owned array instead of indexing the native 0x38-byte struct.
Renderer¶
ZRenderSDLowns 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).Flipdraws the list, composites the target into the window at 4:3, andOPENBLOOD_CAPTURE_DIRwrites PNG captures. Shaders are HLSL inport/shaders, compiled to SPIR-V at build time by the DXC thatmake port-setupinstalls (port/port.jsonpins 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::CalcCameraToViewwith 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_lResolutionis set to 512x448 asZPS2Setupdoes. Textures use a placeholder decoder until the PS2 texture decoder is in. - On Linux the executable keeps the game's
operator new/deletelocal (port/openbloodmoney.map), because Vulkan drivers load C++ code that must not allocate from the game heap. macOS coalescesoperator newacross images, so the Mac build needs its own answer. The platform sources build as C++14 with-fno-sized-deallocation, so adeletethere calls the game's unsizedoperator delete; the sized one would come from libstdc++ and free a game block withfree(). - 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 theVColClipcolour 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_cookiefalse positives when the game'soperator delete[]hands a block back toZMalloc; the boot script setspoison_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.
ZOldDrawSDLruns the PS2 bone update (IK,MatToParentandMatMulMatas C++) and the direct-light update inUpdateDynamic;zoldviewbonessdl.cppskins bone strips, bone variants and bone arrays on the CPU and lights them asVColClipBonedoes, and poses and lights rigid-bone (pack type 8) and owned strips asVColClipdoes. Cutscene characters get the HQ "Prettylights" pass (see "Lights"). The view draws with the root matrices, deform bones and lights of the previous frame'sUpdateDynamic, one frame behind the PS2, which runs it before its chain executes. - Crowds (
ZHFlow, M06's Mardi Gras) draw as bone arrays.ZAnimBufferControler::GetBoneshands each animation a bone buffer from a shared pool every frame during visibility, andZHFlow::UpdateBones, a flip callback, fills those buffers and places the attached accessories.ZRenderPS2::Flipruns the callbacks before it sends the chain, so the port runs them at the same point, right afterUpdateDynamicBeforeDraw. Run atPresent, 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
VUStaticShadowDrawVIF 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
ComputeDot3Lightingdoes 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)^16specular pass. Omni, spot and square spot lights from the geom's light list are added; seedocs/internals/formats/vu-programs.md. - Particles, snow and rain follow the
SnowDrawmicroprogram (settled against a small VU1 interpreter);ParticleCalcis 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_DETERMINISTICandOPENBLOOD_FRAMESgive runs that repeat exactly (docs/internals/scripts/scene-scripts.md).OPENBLOOD_TRACE_FRAMERATE=1logs 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::UpdateLightfollowsZOldDrawPS2::UpdateLight: for each geom whoseBASEGEOM_LightDirtyis set (and owned bone geoms every frame) it fixes and updates the light list, gathers up to 12 lights fromCListUserwith the PS2's filters, and keeps them with the environment light per geom (lightssdl.cpp).PrimInstanceCreatesets the bit for light-enabled strips as the PS2 does.- Static strips with lighting enabled (
CheckPrimLightEnabledor geom control 0x8000) get the per-vertex light coloursVLightTestcomputes: environment (directional or two-sided), omni, cone and square spot lights, clamped to 255 and used asLinL·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 whiteg_WhiteChunklight. - Dot3 surfaces add omni, cone and square spot lights to the environment term as
ComputeDot3Lightingand thenewlightsegments do, with the direction weighted by luminance. - Characters created during a cut sequence (
GEOMCONTROL_HQLIGHTS) get thePrettylightspass:CreatePrettyLightsBufferfills 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 ofVLightTestand 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::PrimInstanceCreateallocates theSWaterPatchInstasPrimInstanceCreateWaterPatchdoes andUpdateDynamicrunsZWaterManager::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 ofVUWaterRender; 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 plusnormal.xz * fRefractScaleand blendslerp(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'sWaterSurface.fxterms (DrawWaterPc, thewaterpcprogram; 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, asVColClip'sInitPODRegsdoes (PlaneAlignedMatrix), and strips with an angle-blend header (0x40) fade by their distance from the eye (StripsAngleBlendFade, read bygeneral.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 ofPrimInstanceCreateScatterare walked asVU_GrassDrawdoes: 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_ONLYis 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 asDrawMirrordoes. 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 fromZOldDrawIdListMirror::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 aClipPlaneuniform for this. Mirror prims in the main list are skipped: on the PS2 theirDATEtest fails onceEndMirrorresets 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
VLineClipsends a GIF tag per strip. The only line prims on the disc belong to geoms that never reach a draw list (M02'sSoundSpline_01, the title scene's camera pathsLine01toLine07, chunkless wire strips in the premission scenes), so there is no capture; the decoder gives 2 x (vertices - strips) indices for them. FadeScreenblends the fade colour over the shown frame forfTime * m_fFramesPerSecondframes withALPHA0x44 and the PS2's quadratic alpha, then fills the screen.ZRenderDllSDLsets a one-second black fade, so everyPopScenefades.- The loading bar:
ZRenderSDL::ProgressBardrawsm_v4ProgressBarRectindwColor1 & 0xffffffover the shown frame and presents it.LoaderSequenceRegisterSDLinstalls a loader sequence player that forwardsSet_Progressto it, which is whatZLoader_Sequence_PS2does 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 ofLOADER_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_01to03,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. VLightTestruns only for primsCheckPrimLightEnabledaccepts (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
CalcGSRegsuses 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 (lAlphaFailin 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=1logs every 50th frame's draw list size (calls, vertices, uniforms, passes, overflow) fromDrawListSubmit.-
OPENBLOOD_TRACE_DROPS=1counts sort entries per material every 300 frames and the reasons for entries that emit no draw (2also 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=TEXTleaves 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=1leaves out the static shadows;OPENBLOOD_TRACE_MATERIAL=TEXTlogs the PC material and the converted draw mode, destination and colour of every object whose material name contains TEXT (MakeDrawSetup);OPENBLOOD_TRACE_SCATTER=1logs 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) followsZPostFilterPS2::Updatepass 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 asZOldViewPS2does.- The draw list takes pass entries:
DrawListSubmitends 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 ofshaders.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=0crashes natively inZHM3LevelControl::SetupPostFilters(ZPostFilterSetEvent::SetiPrimuses an event that already removed itself); this predates the SDL post filter.OPENBLOOD_TRACE_POSTFILTER=1logs the parameters every 50 frames;OPENBLOOD_NO_POSTFILTER=1draws 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'sZPostFilterWintelD3Ddoes (PC rendering). It also lists the bloom list's geoms (material, destination, texture, draw mode, colour and position), andOPENBLOOD_BLOOM_DEBUG=1shows the bloom list's picture in place of the frame (2its blurred picture).
Scene scripts¶
- The engine side is the matched
scriptc.cppandzscriptc.cpp. Natively the shared script structs hold host pointers,m_rThisstays 32 bits, andAttachSceneScriptsloads the level's library throughScriptLevelAttach(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.cppandscriptmessagesrecovered.cpphold the field layouts, andscriptfunctionssdl.cppconverts a payload each way when a script sends or receives it. - Script save state: the save walk and
PostSaveare the matched code; nativelyPrepareDataandFixupDatawalk pointer-width slots and store controllers as offsets into the level library's image.OPENBLOOD_SAVE_TEST_FRAME=Nsaves throughZEngineDataBase::SaveGameintomc0/savetest.*and loads it back throughZLoadGameInfoPS2;OPENBLOOD_SAVE_TEST_RESAVE=1saves again on the next frame. Under the offscreen SDL driver the load crashes inDrawListSubmitwhile 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::WriteandIInputStream::Readtake and returnsize_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::DePackVectorandDePackBlocksign-extend each delta with(delta << (32 - bits)) >> (32 - bits), and a delta band of 0 bits gives a shift of 32. The EE'ssllv/sravuse 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,StateFitbuilt 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.SIGNEXTENDinstreampacker.cppmasks the shift to five bits natively and expands to the original expression on the PS2 (make matchexact). A differential test of the decoder at -O2 against -O0 on 200,000 random streams now agrees, and UBSan reports nothing.