- Updated the gfx_optimizations_complete.md to streamline the overview and implementation details of graphics optimizations, removing completed status indicators and enhancing clarity on future recommendations. - Introduced imgui_widget_testing_guide.md, detailing the usage of YAZE's ImGui testing infrastructure for automated GUI testing, including architecture, integration steps, and best practices. - Created ollama_integration_status.md to document the current status of Ollama integration, highlighting completed tasks, ongoing issues, and next steps for improvement. - Revised developer_guide.md to reflect the latest updates in AI provider configuration and input methods for the z3ed agent, ensuring clarity on command-line flags and supported providers.
3.2 KiB
Dungeon Canvas Blank Screen - Fix Summary
Issue
The dungeon editor canvas was displaying only UI elements but the room graphics were blank, despite the rendering pipeline appearing to be set up correctly.
Root Cause
The background buffers (bg1 and bg2) were never being populated with tile indices from room objects before calling DrawBackground().
The Missing Step
-
Room::RenderRoomGraphics()would:- Copy graphics data to
current_gfx16_ - Draw floor pattern via
DrawFloor() - Call
DrawBackground()to render tiles to pixels
- Copy graphics data to
-
Problem:
DrawBackground()expects the buffer to contain tile indices, but only the floor pattern was in the buffer. Room objects were loaded but never converted to tile indices in the buffer!
How ZScream Does It
- ZScream's
Room.loadLayoutObjects()and object drawing methods populatetilesBg1Buffer/tilesBg2Bufferwith tile indices GraphicsManager.DrawBackground()then converts those buffer indices to pixels- Result: Complete room with floors, walls, and objects
Solution Implemented
Changes Made
File: src/app/zelda3/dungeon/room.cc
-
Enhanced
RenderRoomGraphics()(line 286-315)- Added call to
RenderObjectsToBackground()afterDrawFloor()but beforeDrawBackground()
- Added call to
-
Implemented
RenderObjectsToBackground()(line 317-383)- Iterates through all
tile_objects_ - Ensures each object has tiles loaded via
EnsureTilesLoaded() - For each object:
- Determines correct layer (BG1 vs BG2)
- Converts each
Tile16to 4TileInfosub-tiles - Converts each
TileInfoto word format usingTileInfoToWord() - Places tiles in background buffer using
SetTileAt()
- Iterates through all
Technical Details
Tile Structure:
Tile16= 16x16 pixel tile made of 4TileInfo(8x8) tiles- Arranged as:
[tile0_][tile1_](top row),[tile2_][tile3_](bottom row)
Word Format (per SNES specs):
Bit 15: Vertical flip
Bit 14: Horizontal flip
Bit 13: Priority/over
Bits 10-12: Palette (3 bits)
Bits 0-9: Tile ID (10 bits)
Buffer Layout:
- 64x64 tiles (512x512 pixels)
- Buffer index =
y * 64 + x - Each entry is a uint16_t word
Testing
To verify the fix:
- Build yaze with:
cmake --build build --target yaze - Run yaze and open the dungeon editor
- Select any room
- Canvas should now display:
- ✅ Floor pattern
- ✅ Wall structures
- ✅ Room objects
- ✅ Correct layer separation
Future Enhancements
- Add layout object rendering (walls from room layout data)
- Optimize tile placement algorithm for different object types
- Add support for animated tiles
- Implement object-specific draw routines (similar to ZScream's
DungeonObjectDraw.cs)
Related Files
- Implementation:
src/app/zelda3/dungeon/room.cc - Header:
src/app/zelda3/dungeon/room.h - Buffer:
src/app/gfx/background_buffer.cc - Tiles:
src/app/gfx/snes_tile.h - Reference:
ZeldaFullEditor/GraphicsManager.cs(ZScream) - Reference:
ZeldaFullEditor/Data/Types/DungeonObjectDraw.cs(ZScream)
Build Status
✅ Compilation: Success (0 errors) ⚠️ Warnings: 21 warnings (pre-existing, unrelated to this fix)