Files
isaac-port/notes/items/parity_player_parts.md
T

3.9 KiB

Player parts: head and body as separately transformed layer groups (parity sweep, player_parts)

How Repentance+ draws Isaac

  • One player sprite (Entity_Player +0x48, gfx/001.000_player.anm2) with 15 layers: 0 glow, 1 body, 2 body0, 3 body1, 4 head, 5-10 head0-head5, 11 top0, 12 extra, 13 ghost, 14 back. Costumes are separate sprites (_costumeSpriteDescs, stride 0x130) mapped onto those layers by _playerCostumeMap[15] (+0x122c, stride 0x10: _index, _layerID, _priority, _isBodyLayer +0xc).
  • _isBodyLayer is set by Entity_Player::UpdateCostumes 0x75bf00 (at 0x75c37x): layers 1, 2, 3 and 11 (body, body0, body1, top0) are body layers; every other layer is a "head" layer (glow and back included).
  • Entity_Player::Update 0x782af0, near the end (0x786a7a..0x787b70), builds two scale pairs and a head lift, then sets every player layer's LayerState _color (+0x48), _size (+0x34) and _pos (+0x40):
    • starts: body scale [EBP-0x144]/[EBP-0x124] = (1,1), head scale [EBP-0x184]/[EBP-0x188] = (1,1), head lift [EBP-0x150] = 0, x offset [EBP-0x12c] = 0 (0x78745a).
    • body layers (0x7879a4): colour local_98, size = _bodyScale (+0x14f8) * body scale pair; pos.x = x offset.
    • head layers (0x787a5a): colour local_f0, pos = HeadTransform null pos (from the costume on map entry 1, the body layer: +0x123c) * _bodyScale, size = HeadTransform scale * _headScale (+0x1500) * the head costume's own head-layer frame scale (local_16c: map entry 4, +0x126c, skipped for Pluto 598 / Inner Child 688 costumes) * head scale pair; pos.y += (_headScale.y - _bodyScale.y) * 2.5 (0xbaa6bc) + head lift * 8 (0xbaa7e8); then pos.x = x offset (0x787b47: the HeadTransform x is overwritten).
    • a second loop (0x787b81..) copies each player layer's _size and _pos (and colour) onto the matching layer of the costume sprite that owns it, so costumes follow their layer group.
  • render_build_sprite_quad 0x409cb0: a frame draws at frame pos + layer _pos + anm2 offset, its scale frame scale * layer _size about that point (the frame's pivot), then the sprite's scale about the sprite origin. Rotation adds layer _rotation.
  • _headScale/_bodyScale: Entity_Player::EvaluateItems 0x763570 (CACHE_SIZE 0x800) sets _headScale to 2^(0.152 * (Odd Mushroom Large 121 - Odd Mushroom Thin 120 counts and effects) + 1.585 in timed set 0x23 - 1 in 0x24) (linear past 2) and _bodyScale to (1,1); saved in GameStatePlayer (0x3d..0x40).

Effects that shape the parts in Update 0x782af0

  • Adrenaline (493, 0x1ed), 0x786a9f: pulsing head and body scales and head lift from missing hearts.
  • Tainted Magdalene's hug (_hugCountdown +0x1ef8), 0x7870a0: f = table DAT_00b6bc98[clamp(8 - t, 0, 6)]; body and head x * (2 - f), y * f; head lift + (f - 1) * 4.
  • Jelly Belly (690, _jellyBellyBounceTimer +0x1efc), 0x787178..0x7872da: t = max(t - speedMultiplier, 0); s(x) = 1 - (x / 20) * sin(2 pi x / 10) * 0.4 (0xbaa87c 20, 0xbaa708 pi, 0xbaa81c 10, 0xbaa280 0.4); body x * (2 - s(t)), y * s(t); head x * (2 - s(t + 1)), y * s(t + 1); head lift + (s(t + 1) - 1) * 3 (0xbaa6fc). TakeDamage 0x7729d0 sets the timer 14 (shot) or 20 (enemy).
  • Reverse Chariot (_reverseChariotMoveCooldown +0x1ed0 > 1), 0x787444: x offset = {0, -0.5, -1, 0.5, 2, 1, 0}[min(6, ..)] (both groups' pos.x).
  • Berserk effect (704, 0x2c0), 0x7874a9: head HeadTransform x + sin(updateClock * pi/2) (but see pos.x overwrite above; read the asm before porting) and a colour pulse on both groups.
  • Mars (593, 0x251): head colour (local_f0) flash every 30 frames while the dash is ready.
  • Player type 0x23 (+0x1f88) and challenge 0x2a: head offsets / HeadAnim null.
  • Many colour effects multiply local_f0 (head) and local_98 (body) together.

Port (isaac-classic, items/player_parts)

  • PlayerPart {scale, offset, colour} for head and body on PlayerAnimation, reset every animation step (player_parts_step), applied by anm2_look_draws's walk to the layers of each group, about each frame's pivot.