Skip to content

Hardware Memory Limits#6609

Draft
unreference wants to merge 56 commits into
HarbourMasters:developfrom
unreference:feat/hardware-memory-limits
Draft

Hardware Memory Limits#6609
unreference wants to merge 56 commits into
HarbourMasters:developfrom
unreference:feat/hardware-memory-limits

Conversation

@unreference
Copy link
Copy Markdown

@unreference unreference commented May 11, 2026

Part 3/3 of Hardware Memory Limits, blocked on OTRExporter #47. Requires a compatible OTR generated with the updated OTRExporter to test.

SoH uses larger structs and a doubled THA budget which eliminates the pressure needed for heap manipulation glitches such as unloading Darunia's statue in Goron City, unloading the Royal Family's tomb in Graveyard, and unloading the barrier in Ganon's Castle. This feature aims to restore those glitches by emulating the original hardware memory constraints. A shadow heap mirrors every ZeldaArena allocation at original platform sizes.

  • Calculates the original ZeldaArena size from ROM-extracted data. This includes scene files, room buffers, skybox textures, kaleido overlays, BgCheck memory, elf_message, and parameter_static.
  • Every ZELDA_ARENA_MALLOC is mirrored into a shadow arena at original struct sizes, extracted from the ROM's overlay tables.
  • When the shadow cannot fit an allocation, the real spawn is blocked.
  • When enemy randomizer swaps an actor, the shadow charges the original actor's overlay and instance sizes, preserving the authentic heap regardless of the enemy that is spawned.
  • ShadowArena can be visualized with the heap viewer. Shows block types, actor names, allocated/free regions, and allows pinning rows for tracking its allocation. Base SoH is rather barebones comparatively. I didn't imagine it would be used much at all outside Hardware Memory Limits.

I tested the three heap manipulations mentioned above on NTSC 1.0, NTSC 1.1, NTSC 1.2, PAL 1.1, and PAL GC Debug. I cross-referenced allocations to verify the arena emulation. In all instances tested, they all lined up with how it would perform on hardware.

Unrelated fix: Old format saves with a randomizer section but no sohStats crash on JSON deserialization after the randomizer data is erased. Addressed by guarding the access with contains() checks and falling back to zeroed version info. The bug exists in upstream and is included here because it blocks testing.

unreference added 30 commits May 6, 2026 21:04
unreference added 20 commits May 9, 2026 19:19
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