Skip to content

fix(3D view): draw NPCs and objects across the whole 3D view, not just the old GBA screen area - #219

Merged
999sian merged 2 commits into
999sian:masterfrom
Strikeborn:fix/voxel-offscreen-entities
Oct 20, 2026
Merged

999sian merged 2 commits into
999sian:masterfrom
Strikeborn:fix/voxel-offscreen-entities

Conversation

@Strikeborn

Copy link
Copy Markdown

Depends on #213 (stacked on it: until #213 merges, this diff also shows #213's commit). This PR's own changes are the second commit.

Result: characters stay visible everywhere the tilted 3D camera can see, instead of vanishing at the old GBA screen edge.

Background, OAM: the GBA draws sprites from OAM (Object Attribute Memory), a table of 128 slots. Each slot holds one sprite piece's screen position, size and tile. The game only fills it with pieces on or near the GBA screen, and the position fields are small: y is 8 bits (it can't express more than 96 px above the screen) and x is 9 bits. The 3D view reads the same OAM to place its standing sprites.

Before: that made the GBA screen an effective maximum draw distance. Entities more than 63 px outside it weren't drawn, pieces were clipped at its edges, and anything above −96 px couldn't be stored at all. Characters vanished at the old screen edge, sometimes leaving only their shadow (which sits lower, so it still fit).

Now: while the 3D view is drawing, entities are drawn up to 256 px past the top and sides. Pieces OAM can't hold are parked off the 2D screen, with their real position passed to the 3D view in a side table.

Files: port/port_draw.c, port/port_voxel.cpp, port/port_voxel.h

Not in v0.9.5. It affects anyone on master using the 3D view (Windows/Linux Vulkan builds).

Change

Only while the 3D view drew the previous frame (new Port_Voxel_IsDrawing()):

  • DrawEntity uses a draw-only CheckOnScreenForDraw(): GBA bounds plus 256 px past the top and sides. CheckOnScreen is unchanged, since scripts and AI use it.
  • RenderSpritePieces keeps pieces up to 256 px past the top and sides. Pieces OAM can't encode (y < −96, or x outside [viewW−512, viewW)) are parked at y=160, which the 2D PPU never shows, with their true x/y in new PortVoxelOamTag fields that the 3D view uses.
  • With 3D not drawing, the 2D path is the same code and OAM output as before. Menus, cutscenes and the software renderer spend no extra OAM.

Known limitations

  • Off-screen entities share the 128 OAM slots, so very busy rooms may overflow sooner with 3D on.
  • Entities in the margin play their pending SFX. That's arguably right, since they're visible.
  • Pieces taller than 96 rows outside OAM range still drop (large bosses).
  • NPCs that teleport once off the GBA screen (original script logic) now do so visibly.
  • Some NPCs (e.g. parts of the Picori Festival crowd) are only spawned or updated near the GBA screen, so they still appear late; that's spawning logic, not drawing.

Tested (Windows, Vulkan, USA)

  • Zelda stays visible to the top and past both side edges of the 3D view (before: shadow only, then nothing).
  • 3D off: same 2D code path. Smoke run reaches Entering AgbMain.... Play-tested to the Picori Festival (early game only).

Developed with assistance from Claude Code (Opus 5.5). I reviewed and tested the changes as described above.

Strikeborn and others added 2 commits October 7, 2026 18:17
MapShownPct compared gRoomControls.scroll against the latched BG registers, which can be a tile apart for a frame while scrolling. Score the camera tile and its 8 neighbours and keep the best. Adds opt-in TMC_VOXEL_DEBUG logging.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
While the 3D view is drawing, entities up to 256 px past the GBA screen's top and sides get sprites; pieces OAM can't encode are parked off the 2D screen with their true position in the voxel tag. CheckOnScreen (used by gameplay) is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

2 participants