The Overworld Editor is the primary tool for editing the Legend of Zelda: A Link to the Past overworld maps. It provides visual editing capabilities for tiles, entities, and map properties across the Light World, Dark World, and Special World areas.
src/app/editor/overworld/)| File | Lines | Purpose |
|---|---|---|
overworld_editor.h/cc | ~3,750 | Main editor class, coordinates all subsystems |
tile16_editor.h/cc | ~3,400 | Tile16 editing with pending changes workflow |
map_properties.h/cc | ~1,900 | Toolbar, context menus, property panels |
entity.h/cc | ~820 | Entity popup rendering and editing |
entity_operations.h/cc | ~370 | Entity insertion helper functions |
overworld_entity_interaction.h/cc | ~200 | Entity drag/drop and click handling |
overworld_entity_renderer.h/cc | ~200 | Entity drawing delegation |
overworld_sidebar.h/cc | ~420 | Sidebar property tabs |
overworld_toolbar.h/cc | ~210 | Mode toggle toolbar |
scratch_space.cc | ~420 | Tile layout scratch space |
automation.cc | ~230 | Canvas automation API |
ui_constants.h | ~75 | Shared UI constants and enums |
usage_statistics_card.h/cc | ~130 | Tile usage tracking |
debug_window_card.h/cc | ~100 | Debug information display |
panels/)Thin wrappers implementing EditorPanel interface that delegate to main editor methods:
| Panel | Purpose |
|---|---|
overworld_canvas_panel | Main map canvas display |
tile16_selector_panel | Tile palette for painting |
tile8_selector_panel | Individual tile8 selector |
area_graphics_panel | Current area graphics display |
map_properties_panel | Map property editing |
scratch_space_panel | Tile layout workspace |
gfx_groups_panel | Graphics group editor |
usage_statistics_panel | Tile usage analytics |
v3_settings_panel | ZScustom v3 feature settings |
debug_window_panel | Debug information |
src/zelda3/overworld/)| File | Purpose |
|---|---|
overworld.h/cc | Core data management for 160+ maps |
overworld_map.h/cc | Individual map data and bitmap generation |
overworld_entrance.h/cc | Entrance entity data structures |
overworld_exit.h/cc | Exit entity data structures |
overworld_item.h/cc | Overworld item data |
overworld_version_helper.h | ROM version detection for ZScustom features |
diggable_tiles.h/cc | Diggable tile management |
The tile16 editing system uses a pending changes pattern to prevent accidental ROM modifications:
Key Files:
tile16_editor.cc - Main editing logicoverworld_editor.cc - Integration with overworldPending Changes System:
Palette Coordination (Critical for Color Fixes):
The overworld uses a 256-color palette organized as 16 rows of 16 colors. Different graphics sheets map to different palette regions:
| Sheet Index | Palette Region | Purpose |
|---|---|---|
| 0, 3, 4 | AUX1 (rows 10-15) | Main blockset graphics |
| 1, 2 | MAIN (rows 2-6) | Main area graphics |
| 5, 6 | AUX2 (rows 10-15) | Secondary blockset |
| 7 | ANIMATED (row 7) | Animated tiles |
Key palette methods in tile16_editor.cc:
ZScustom is an ASM patch system that extends overworld capabilities. Version detection is centralized in overworld_version_helper.h:
Feature Detection:
Version-Specific Features:
| Version | Features |
|---|---|
| Vanilla | Standard 64 Light World + 64 Dark World + 32 Special World maps |
| v1 | Expanded pointers, map data overflow space |
| v2 | + Custom BG colors per area, Main palette selection |
| v3 | + Area size enum (Wide 2x1, Tall 1x2), Mosaic, Animated GFX, Subscreen overlays, Tile GFX groups |
The overworld uses a parent-child system to manage multi-area maps (Large 2x2, Wide 2x1, Tall 1x2).
Version-Specific Parent ID Loading:
| Version | Parent ID Source | Area Size Source |
|---|---|---|
| Vanilla | kOverworldMapParentId (0x125EC) | kOverworldScreenSize + (index & 0x3F) |
| v1 | kOverworldMapParentId (0x125EC) | kOverworldScreenSize + (index & 0x3F) |
| v2 | kOverworldMapParentId (0x125EC) | kOverworldScreenSize + (index & 0x3F) |
| v3+ | kOverworldMapParentIdExpanded (0x140998) | kOverworldScreenSize + index |
Area Size Enum (v3+ only):
Sibling Map Calculation:
For a parent at index P:
Parent ID Loading (Version-Specific):
The vanilla parent table at 0x125EC (kOverworldMapParentId) only contains 64 entries for Light World maps. Different worlds require different handling:
| Version | Light World (0x00-0x3F) | Dark World (0x40-0x7F) | Special World (0x80-0x9F) |
|---|---|---|---|
| v3+ | Expanded table (0x140998) with 160 entries | Same expanded table | Same expanded table |
| Vanilla/v1/v2 | Direct lookup from 64-entry table | Mirror LW parent + 0x40 offset | Hardcoded (Zora's Domain = 0x81, others = self) |
Example: DW map 0x43's parent = LW map 0x03's parent (0x03) + 0x40 = 0x43
Graphics Cache Hash:
The tileset cache uses a comprehensive hash that includes:
static_graphics[0-11] - Main blockset sheet IDs (excluding sprite sheets 12-15)game_state - Game state (Beginning=0, Zelda=1, Master Sword=2, Agahnim=3) - affects sprite sheetssprite_graphics[game_state] - Sprite graphics config for current game statearea_graphics - Area-specific graphics group IDmain_gfx_id - World-specific graphics group (LW=0x20, DW=0x21, SW=0x20/0x24)parent - Parent map ID for sibling coordinationmap_index - Critical for SW: Unique hardcoded configs per map (0x80 Master Sword, 0x88/0x93 Triforce, 0x95 DM clone, etc.)main_palette - World palette (LW=0, DW=1, Death Mountain=2/3, Triforce=4)animated_gfx - Death Mountain (0x59) vs normal water/clouds (0x5B)area_palette - Area-specific palette configurationsubscreen_overlay - Visual effects (fog, curtains, sky, lava)Important: static_graphics[12-15] (sprite sheets) are loaded using sprite_graphics_[game_state_], which may be stale at hash computation time. The hash includes game_state and sprite_graphics directly to avoid collisions.
Refresh Coordination:
When any map in a multi-area group is modified, all siblings must be refreshed to maintain visual consistency. Key methods:
RefreshMultiAreaMapsSafely() - Coordinates refresh from parent perspectiveInvalidateSiblingMapCaches() - Clears graphics cache for all siblingsRefreshSiblingMapGraphics() - Forces immediate refresh of sibling bitmapsWorld Boundary Protection:
Sibling calculations in FetchLargeMaps() verify that siblings stay within the same world (LW: 0-63, DW: 64-127, SW: 128-159) to prevent cross-world corruption.
Upgrade Workflow (in overworld_editor.cc):
Saving is controlled by feature flags in core::FeatureFlags. Each component saves independently:
Save Order Dependencies:
Feature Flags (in core/features.h):
GetPaletteSlotForSheet() for correct sheet-to-palette mappingApplyPaletteToCurrentTile16Bitmap() is called after palette changesset_palette() callback from overworld editor is workinghas_pending_changes() returns true after editingCommitAllChanges() is called before expecting ROM changeson_changes_committed_ callback is properly setRefreshTile16Blockset() is called after commitRefreshOverworldMap() is triggeredDefined in ui_constants.h:
The overworld editor has its own undo/redo stack for tile painting operations:
Paint operations within 500ms are batched together to avoid creating too many undo points for drag operations.
ProcessDeferredTextures() handles background texture creationEnsureMapBuilt()ComputeGraphicsConfigHash() identifies identical configsInvalidateSiblingMapCaches() clears cache for all maps in a multi-area group