Skip to content

arm64: playable Dam, mission select, HUD and 64-bit audio fixes - #1

Merged
sergiomanzur merged 2 commits into
mainfrom
arm64-64bit-port
Oct 25, 2026
Merged

sergiomanzur merged 2 commits into
mainfrom
arm64-64bit-port

Conversation

@sergiomanzur

Copy link
Copy Markdown
Owner

Goal

Make the 64-bit (arm64-v8a) engine playable on the Galaxy S24 Ultra: Dam renders correctly, guards patrol, see and shoot Bond, the mission-select screen draws properly, and sound works. 32-bit builds (Windows, Retroid Pocket 6) must stay as they were.

Description

Two commits, all 64-bit fixes guarded by PORT_LP64 or behaviour-identical on 32-bit:

  • Gameplay (first commit): host-sized player/hand/watch models, guard weapon records rebuilt from the N64 setup layout (guards could not fire), anim-callback restored (floating guards), pad/path tables, several crashes.
  • Mission select: Vertex was 24 bytes on LP64; it is 16 again (collision related-node moves to a side table). vtxstore entry size no longer hard-coded.
  • HUD triangles: gunDrawSight kept a Gfx* in an s32 and passed &s32 as Gfx**; HUD gauge display lists overran their vertex data; ~50 implicitly declared pointer-returning functions are now declared (port_lp64_protos.h).
  • Audio: new port/src/bank64.c converts the big-endian banks and music table to host structs; sample tables, music heap and frame buffer live in the low arena (mixer takes 32-bit addresses); reverb delay offsets are signed; ALParam padded so voice starts no longer corrupt the free list.
  • Tooling: x86_64 added as a developer-only ABI (same LP64 engine) so these bugs reproduce on the Android emulator. It is never part of the universal APK.

Fixes # n/a

Type of Change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • armeabi-v7a, arm64-v8a and x86_64 debug builds compile.
  • x86_64 emulator: mission-select film strip renders correctly (was black wedges); ~100 s of rendered PCM analysed offline: tonal stereo music, no crashes.
  • Not run on a physical S24 yet; yellow-triangle fixes are untested (could not reproduce).
  • 32-bit builds were only compiled, not run on a Retroid Pocket 6 / Windows. gunDrawSight, the reverb offset type and Vertex changes touch shared code.
  • Known: LOD textures streak on the emulator (looks emulator-specific); debug logging added in earlier work remains in arm64 builds.

Checklist

  • I have performed a self-review of my code
  • My Code is AI-Generated or AI-assisted (Claude Sonnet 5.5)
  • My PR contains no AI-generated images, textures, models, sound or music
  • I am an AI
  • I have reviewed my PR to make sure the above is truthful and accurate.

sergiomanzur and others added 2 commits October 24, 2026 11:22
Fixes the LP64 port so the S24 Ultra build renders Dam correctly and
guards patrol on the ground, see Bond and shoot him.

- PORT_LP64 (platform_info.h) guards 64-bit-only fixes so the 32-bit
  builds compile what they always did.
- Player/hand/watch/gait models get host-sized storage instead of
  overlaying N64 offsets (fixes sky-only terrain, garbage start pos,
  missing gun).
- Guard weapons: the setup record is the N64 0x88-byte layout, so
  rebuild a host WeaponObjRecord from the wire fields (weaponnum read
  as 0 and every attack try failed).
- Restore the chr anim callback (ground height / stand tile) with a
  pointer sanity check; widen truncating (s32) animation pointer casts.
- Pad-name tables, patrol paths, anim flip func and bg portals kept
  full-width; skip cleanupObjects on unload (wire-layout objects) and
  harden sndGetPlayingState.

Setup objects other than weapons are still read as host structs on
64-bit; converting them at load is the proper follow-up. The 32-bit
build compiles but has not been run on device.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Found by reproducing the S24 bugs on an x86_64 emulator build (a new
developer-only ABI: same LP64 engine, never in the release APK).

Rendering
- Vertex was 24 bytes on a 64-bit host (pointer union), so every Vertex[]
  walk disagreed with the 16-byte display-list vertices: the film strip
  drew black wedges. Vertex is 16 bytes again; the collision-only related
  node moves to a side table built in model64.c.
- vtxstore sized its entry table with a hard-coded 0x14 (0x18 on LP64) and
  overflowed into neighbouring allocations.
- gunDrawSight kept a Gfx* in an s32 and passed &s32 as Gfx**, so the callee
  read 4 bytes of stack as the pointer's upper half (garbage display list,
  and a crash). Same for portDrawTargetPlus.
- HUD armor/health gauge display lists were built in place in the player
  struct in room for 8-byte commands and ran over their own vertex data;
  they get separate buffers on LP64.
- ~50 functions called without a declaration had pointer results truncated
  to int; declared in port/include/port_lp64_protos.h (fixes a boot crash
  in set_mt_tex_alloc on x86_64 and strchr in the options parser).
- wiredl: purge cached expansions when a buffer is (un)registered.

Audio (was muted on arm64)
- port/src/bank64.c converts the big-endian bank files and Rare sequence
  table into host structs; sample tables, the music heap and the frame
  buffer are placed in the low arena because the mixer takes 32-bit
  addresses.
- ALDelay input/output are signed: r->input[-d->input] with u32 made the
  reverb delay lines read and write before their buffer, corrupting the
  synth.
- ALParam is padded so the 40-byte voice-start record fits (it overran its
  slot and corrupted the free list on every voice start).
- Verified on the emulator by rendering ~100 s of PCM: tonal, stereo, ~-15
  dBFS music, no crashes.

Not verified on a real phone. The emulator's texture streaking on LOD
textures looks emulator-specific and is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sergiomanzur
sergiomanzur merged commit 96609b1 into main Oct 25, 2026
0 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant