Effect particles (particle01, particle02; element update and draw in PDUWP.exe)
Our reading of the machine code (addresses as
leads; the update functions are found through
the RTTI names
alfn_FunctionPARTICLE01/02 and the
particle objects pdEftParticle1/2).
Played by pd_effect.gd
(spawn_particles,
tick_particles,
_step_emitters).
- Pool. The element function
(PARTICLE01 at 0x1401119c0, PARTICLE02 at
0x140111fc0, same code) creates one particle
object per element: a pool of
raw_m[14]×raw_m[15]particles (+2 for particle01), 0x40 bytes each. - Per tick inside the window
(start ≤ frame ≤ end,
raw_f[2..3]), it reads the matrix sourceraw_m[3]and the emitter typeraw_m[12]:- source 0: the particles live in the effect’s frame (the effect’s matrix is copied as the draw matrix on every spawning tick; after the window the last one stays); 1: spawned at the effect’s world position, drawn in the world; 2: as 1, and the acceleration is turned by the effect’s matrix; 3: as 1, the acceleration turned by a matrix of the exe’s view context (the per-context table at 0x1405bb2e0, +0xA0; not followed). Counts: source 1 on 1797 particle elements, 2 on 86, 0 on 66, 3 on 13.
- type 0 (0x1401a2050; 1856 of 1962 particle elements) spawns; types 1 (106 elements, 0x1401a2bc0) and 2 (none in the data, 0x1401a34a0) are other spawners, not decoded.
- Type-0 spawn: walks the
pool; each free slot gets a particle, and the
count is compared with
raw_m[14]after every slot (so a rate of 0 fills every free slot when the first one is free). The game’srand()(15-bit) is drawn in this order: a blink phase bit (state 1 or 3); three values each mapped to rand / 32767 − 0.5, normalized, as the direction; one more for the speed =raw_f[7]− rand / 32767 ×raw_m[8]. The acceleration israw_f[8..10](through the source matrix for sources 2 and 3) plus a global vector ×raw_m[10]× 0.01 (the vector is 0.3 × a per-frame vector of an object whose pointer the exe keeps at 0x140533308; 524 elements haveraw_m[10]≠ 0; not followed). Size: startraw_m[0], endraw_m[1]; whenraw_m[2](as an integer) is not 0, a fixed sizeraw_m[0]+ rand / 32767 ×raw_m[1]instead. Colors byraw_m[13]: 0 and 2 take the element’s start/end colors; 1 draws each byte between the blink color and the color (byte k = blink[k] + (rand × (color[k] − blink[k])) >> 15 in 32-bit unsigned math, bytes 3 to 0, start and end pair each); 3 the same with one weight (rand × 255 >> 15) / 255 for all bytes of a color. A negative difference wraps and spills into the next byte, as the exe packs it. Life =raw_m[15]ticks, age 0. - Per draw tick (pdEftParticle1 0x1401a1c00, vertices 0x1401a2880; pdEftParticle2 0x1401a4110, 0x1401a4530): age + 1, a particle older than its life is freed; then velocity += acceleration, position += velocity; t = age / life; color = start + (end − start) × t per byte, truncated, or the element’s blink pair on ticks where the particle’s phase bit is set and the color mode is 2 (the bit flips every tick, so mode 2 blinks per particle with a random phase); size = start + (end − start) × t, or the fixed size.
- particle01 draw: one point
per particle (position, size, color), drawn with
Part1V/Part1P: the four corners are pushed out in clip space by size × (1/853, 1/480) before the divide by w, the depth in game units (so a dot shrinks with distance: size / (2 w) of the 853 × 480 view each side, as for the capsule dust). The draw (0x1401a1c00) uploads cPROJEC (VS registers 20..23, setter 0x14001e540) as the transposed product of the particle object’s matrix (+0x80), the view matrix (0x1405a5ca0, the player camera’s +0x40, copied at 0x14012c159) and the projection (0x1405a5c60, the fixed 75° 853:480 matrix of “Camera”), with no scale of its own (bof3). Since the projection’s y scale is 853/480 times its x scale, the push is the same fraction of both: a square in view space of half-size size / (853 · cot 37.5°) ≈ size × 0.0009 units at any depth. We work in metres, where w is ten times smaller, so the push is size × 0.1 for the same on-screen size, and we scale it by our own projection’s x and y scales (a window that is not 16:9 keeps the quads square; at 16:9 this is exactly (1/853, 1/480)); the texture (bound to stage 3) times the clamped vertex color, no premultiply. The corner/UV table is theQuadMapconstant buffer (VS slot 2), filled once when the device is set up (0x14001c680, bound at 0x14001c7bf): the six vertices of a point use corners 0, 3, 1, 0, 2, 3 (two triangles); corner k sits at (2 (k & 1) − 1, 2 (k >> 1) − 1) in the push with UV (k & 1, k >> 1). So UV (0, 0) is the corner pushed to (−1, −1): the texture’s first row is drawn at the bottom of the quad. The vertex shader passes only this UV on (no flipbook cell for particle01) (bof2). - particle02 draw: four
vertices per particle built on the CPU: position
± right ± up of the view matrix (its first two
columns, i.e. the camera’s axes in the world,
added in the emitter’s frame) × size × 0.001;
UVs from a flipbook of
raw_f[0]×raw_f[1]cells: cell = whole part of cols × rows × t, column = cell mod cols, row = floor(cell / cols), stored as signed 16-bit × 32767.Part2Vonly transforms;Part2Pis Part1P on stage 0. - Blend (corrected, bof4): both draws set their own blend, as the trails do: the particle01/02 draw (0x1401a1c00, through its helper 0x1401a1fd0) and the second particle draw (0x1401a4110) call the blend setter 0x14028e4e0 with the fixed mode word 0x1101 just before the draw call, so every particle is drawn one / one, add, whatever its material’s blend bit and mode say (the setter caches the word at 0x14054ca10; the only direct write of the source-blend state 0x3E is inside the setter, so the cache cannot go stale). The material gives the texture only; its shader name is not used. The pack has over two hundred particle elements whose materials say something else (zero / inverse source colour, source colour / one, source alpha / inverse source alpha, blending off …): none of those reach the screen. The earlier note (“the material gives the blend state”) was wrong.