Repository navigation
fix(3D view): draw NPCs and objects across the whole 3D view, not just the old GBA screen area - #219
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.hNot in v0.9.5. It affects anyone on
masterusing the 3D view (Windows/Linux Vulkan builds).Change
Only while the 3D view drew the previous frame (new
Port_Voxel_IsDrawing()):DrawEntityuses a draw-onlyCheckOnScreenForDraw(): GBA bounds plus 256 px past the top and sides.CheckOnScreenis unchanged, since scripts and AI use it.RenderSpritePieceskeeps 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 newPortVoxelOamTagfields that the 3D view uses.Known limitations
Tested (Windows, Vulkan, USA)
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.