Skip to content

Fix #1558: world map preview ignores map editor bpp setting - #2964

Open
joshgoebel wants to merge 1 commit into
nesbox:mainfrom
joshgoebel:fix-1558-world-map-bpp
Open

Fix #1558: world map preview ignores map editor bpp setting#2964
joshgoebel wants to merge 1 commit into
nesbox:mainfrom
joshgoebel:fix-1558-world-map-bpp

Conversation

@joshgoebel

Copy link
Copy Markdown
Collaborator

Closes #1558

What

The world map overview (Tab in the map editor) always rendered using 4bpp regardless of the bpp mode selected in the map editor toolbar. This caused incorrect colors for cartridges using 2bpp or 1bpp tiles.

Root cause

initWorld() used tic_tool_peek4() to read every tile's pixel data, hardcoding 4bpp interpretation:

tic_tile* tile = &getBankTiles(world->studio)->data[index];
for(s32 p = 0; p < TIC_SPRITESIZE * TIC_SPRITESIZE; p++)
{
    u8 color = tic_tool_peek4(tile, p);  // always 4bpp
    ...
}

Fix

Use tic_tilesheet_get with the segment derived from map->sheet.blit (the same blit state the map editor uses), then read pixels via tic_tilesheet_gettilepix which dispatches to the correct peek1/peek2/peek4 function for the active bpp mode. This mirrors the approach already used by the sprite and map editors.

initWorld() always used tic_tool_peek4() to read tile pixels, which
hardcodes 4bpp regardless of the bpp mode selected in the map editor.
This caused incorrect colors in the world map overview when using 2bpp
or 1bpp tiles.

Replace the hardcoded peek4 loop with a tic_tilesheet / tic_tileptr
lookup that uses the segment derived from map->sheet.blit, matching
the approach used by the sprite and map editors. tic_tilesheet_gettilepix
then reads pixel values correctly for the active bpp mode.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.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.

World map doesn't respect current bpp on map editor

2 participants