diff --git a/src/app/editor/dungeon/dungeon_editor.cc b/src/app/editor/dungeon/dungeon_editor.cc index a91b01ac..8b7e9907 100644 --- a/src/app/editor/dungeon/dungeon_editor.cc +++ b/src/app/editor/dungeon/dungeon_editor.cc @@ -301,11 +301,22 @@ void DungeonEditor::DrawCanvasAndPropertiesPanel() { static std::vector empty_gfx; const auto& gfx_buffer = rom()->graphics_buffer(); + // Get the actual palette being used by this room + const auto& dungeon_pal_group = rom()->palette_group().dungeon_main; + int room_palette_id = rooms_[room_id].palette; + + // Validate and clamp palette ID + if (room_palette_id < 0 || room_palette_id >= static_cast(dungeon_pal_group.size())) { + room_palette_id = 0; + } + + auto room_palette = dungeon_pal_group[room_palette_id]; + zelda3::dungeon::RoomVisualDiagnostic::DrawDiagnosticWindow( &show_visual_diagnostic_, gfx::Arena::Get().bg1(), gfx::Arena::Get().bg2(), - current_palette_, + room_palette, gfx_buffer.empty() ? empty_gfx : gfx_buffer); } } else { diff --git a/src/app/zelda3/dungeon/room.cc b/src/app/zelda3/dungeon/room.cc index efb3897f..404a0e50 100644 --- a/src/app/zelda3/dungeon/room.cc +++ b/src/app/zelda3/dungeon/room.cc @@ -312,7 +312,7 @@ void Room::RenderRoomGraphics() { // Get the palette for this room - just use the 90-color palette as-is // The SNES will index into this palette correctly without needing expansion - auto& dungeon_pal_group = rom()->mutable_palette_group()->get_group("dungeon_main")[0]; + auto& dungeon_pal_group = rom()->mutable_palette_group()->dungeon_main; int num_palettes = dungeon_pal_group.size(); int palette_id = palette;