yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze Namespace Reference

Namespaces

namespace  agent
 
namespace  anonymous_namespace{font_loader.cc}
 
namespace  anonymous_namespace{rom.cc}
 
namespace  anonymous_namespace{rom_old.cc}
 
namespace  app
 
namespace  cli
 Namespace for the command line interface.
 
namespace  core
 
namespace  editor
 Editors are the view controllers for the application.
 
namespace  emu
 SNES Emulation and debugging tools.
 
namespace  gfx
 Contains classes for handling graphical data.
 
namespace  gui
 Graphical User Interface (GUI) components for the application.
 
namespace  net
 
namespace  platform
 
namespace  project
 
namespace  rom
 
namespace  test
 
namespace  util
 
namespace  zelda3
 Zelda 3 specific classes and functions.
 

Classes

struct  AppConfig
 Configuration options for the application startup. More...
 
class  Application
 Main application singleton managing lifecycle and global state. More...
 
class  AssetLoader
 Cross-platform asset file loading utility. More...
 
class  Controller
 Main controller for the application. More...
 
struct  Event
 
class  EventBus
 
struct  FontConfig
 
struct  FontState
 
struct  GraphicsLoadDiagnostics
 
class  Json
 
class  Rom
 The Rom class is used to load, save, and modify Rom data. This is a generic SNES ROM container and does not contain game-specific logic. More...
 
struct  RomLoadOptions
 
struct  SheetDiagnostics
 
class  TimingManager
 Provides accurate timing for animations and frame pacing. More...
 
class  Transaction
 

Enumerations

enum class  StartupVisibility { kAuto , kShow , kHide }
 Tri-state toggle used for startup UI visibility controls. More...
 

Functions

absl::Status LoadPackageFonts ()
 
absl::Status ReloadPackageFont (const FontConfig &config)
 
absl::Status LoadFontFromMemory (const std::string &name, const std::string &data, float size_pixels)
 
void LoadSystemFonts ()
 
StartupVisibility StartupVisibilityFromString (absl::string_view value)
 
std::string StartupVisibilityToString (StartupVisibility value)
 
uint32_t GetGraphicsAddress (const uint8_t *data, uint8_t addr, uint32_t ptr1, uint32_t ptr2, uint32_t ptr3, size_t rom_size)
 Calculates ROM offset for a graphics sheet using pointer tables.
 
absl::StatusOr< std::vector< uint8_t > > Load2BppGraphics (const Rom &rom)
 Loads 2bpp graphics from Rom data.
 
absl::StatusOr< std::array< gfx::Bitmap, kNumLinkSheets > > LoadLinkGraphics (const Rom &rom)
 Loads the players 4bpp graphics sheet from Rom data.
 
absl::StatusOr< gfx::BitmapLoadFontGraphics (const Rom &rom)
 
absl::StatusOr< std::array< gfx::Bitmap, kNumGfxSheets > > LoadAllGraphicsData (Rom &rom, bool defer_render=false)
 This function iterates over all graphics sheets in the Rom and loads them into memory. Depending on the sheet's index, it may be uncompressed or compressed using the LC-LZ2 algorithm. The uncompressed sheets are 3 bits per pixel (BPP), while the compressed sheets are 4 BPP. The loaded graphics data is converted to 8 BPP and stored in a bitmap.
 
absl::Status SaveAllGraphicsData (Rom &rom, std::array< gfx::Bitmap, kNumGfxSheets > &gfx_sheets)
 
uint32_t SnesToPc (uint32_t addr) noexcept
 
uint32_t PcToSnes (uint32_t addr)
 
uint32_t Get24LocalFromPC (uint8_t *data, int addr, bool pc=true)
 
int AddressFromBytes (uint8_t bank, uint8_t high, uint8_t low) noexcept
 
uint32_t MapBankToWordAddress (uint8_t bank, uint16_t addr) noexcept
 

Variables

constexpr int Uncompressed3BPPSize = 0x0600
 
constexpr uint32_t kNumGfxSheets = 223
 
constexpr uint32_t kNumLinkSheets = 14
 
constexpr uint32_t kTile16Ptr = 0x78000
 
constexpr uint32_t kNormalGfxSpaceStart = 0x87000
 
constexpr uint32_t kNormalGfxSpaceEnd = 0xC4200
 
constexpr uint32_t kFontSpriteLocation = 0x70000
 
constexpr uint32_t kGfxGroupsPointer = 0x6237
 
constexpr uint32_t kUncompressedSheetSize = 0x0800
 
constexpr uint32_t kNumMainBlocksets = 37
 
constexpr uint32_t kNumRoomBlocksets = 82
 
constexpr uint32_t kNumSpritesets = 144
 
constexpr uint32_t kNumPalettesets = 72
 
constexpr uint32_t kEntranceGfxGroup = 0x5D97
 
constexpr uint32_t kMaxGraphics = 0x0C3FFF
 

Enumeration Type Documentation

◆ StartupVisibility

enum class yaze::StartupVisibility
strong

Tri-state toggle used for startup UI visibility controls.

kAuto - Use existing runtime logic (legacy behavior) kShow - Force the element to be shown on startup kHide - Force the element to be hidden on startup

Enumerator
kAuto 
kShow 
kHide 

Definition at line 18 of file startup_flags.h.

Function Documentation

◆ LoadPackageFonts()

absl::Status yaze::LoadPackageFonts ( )

◆ ReloadPackageFont()

absl::Status yaze::ReloadPackageFont ( const FontConfig & config)

◆ LoadFontFromMemory()

absl::Status yaze::LoadFontFromMemory ( const std::string & name,
const std::string & data,
float size_pixels )

Definition at line 133 of file font_loader.cc.

◆ LoadSystemFonts()

void yaze::LoadSystemFonts ( )

◆ StartupVisibilityFromString()

StartupVisibility yaze::StartupVisibilityFromString ( absl::string_view value)
inline

Definition at line 24 of file startup_flags.h.

References kAuto, kHide, and kShow.

Referenced by main().

◆ StartupVisibilityToString()

std::string yaze::StartupVisibilityToString ( StartupVisibility value)
inline

Definition at line 36 of file startup_flags.h.

References kAuto, kHide, and kShow.

◆ GetGraphicsAddress()

uint32_t yaze::GetGraphicsAddress ( const uint8_t * data,
uint8_t addr,
uint32_t ptr1,
uint32_t ptr2,
uint32_t ptr3,
size_t rom_size )

Calculates ROM offset for a graphics sheet using pointer tables.

Resolves a graphics sheet index to its PC (file) offset in the ROM.

ALTTP stores graphics sheet addresses using three separate pointer tables, where each table contains one byte of the 24-bit SNES address:

  • ptr1 table: Low byte of address (bits 0-7)
  • ptr2 table: High byte of address (bits 8-15)
  • ptr3 table: Bank byte of address (bits 16-23)

For US ROMs, these tables are located at:

  • kOverworldGfxPtr1 = 0x4F80 (low bytes)
  • kOverworldGfxPtr2 = 0x505F (high bytes)
  • kOverworldGfxPtr3 = 0x513E (bank bytes)

Example for sheet index 0: SNES addr = (data[0x513E] << 16) | (data[0x505F] << 8) | data[0x4F80] PC offset = SnesToPc(SNES addr)

Parameters
dataPointer to ROM data buffer
addrGraphics sheet index (0-222)
ptr1Offset of low-byte pointer table in ROM
ptr2Offset of high-byte pointer table in ROM
ptr3Offset of bank-byte pointer table in ROM
rom_sizeROM size for bounds checking
Returns
PC offset where the graphics sheet data begins, or rom_size if out of bounds
Warning
Callers must verify the returned offset is within ROM bounds before attempting to read or decompress data at that location.
Parameters
dataROM data buffer
addrSheet index (0-222)
ptr1Bank byte pointer table offset
ptr2High byte pointer table offset
ptr3Low byte pointer table offset
rom_sizeROM size for bounds checking (unused)
Returns
PC address (offset from start of ROM)

Definition at line 175 of file rom_old.cc.

References AddressFromBytes(), and SnesToPc().

Referenced by Load2BppGraphics(), LoadAllGraphicsData(), and SaveAllGraphicsData().

Here is the call graph for this function:

◆ Load2BppGraphics()

absl::StatusOr< std::vector< uint8_t > > yaze::Load2BppGraphics ( const Rom & rom)

Loads 2bpp graphics from Rom data.

Loads and decompresses 2-bit-per-pixel graphics sheets.

These sheets are used for fonts and certain UI elements that only need 4 colors (2^2 = 4). The specific sheet IDs loaded are:

  • 0x71, 0x72: Font graphics
  • 0xDA-0xDE: Additional 2BPP assets
Parameters
romThe loaded ROM to read graphics from
Returns
Combined 8BPP pixel data for all 2BPP sheets, or error status
Note
The decompressed 2BPP data is converted to 8BPP format for consistent handling in the graphics pipeline.

This function loads 2bpp graphics from Rom data by iterating over a list of sheet IDs, decompressing the sheet data, converting it to 8bpp format, and appending the converted sheet data to a byte vector.

Definition at line 206 of file rom_old.cc.

References ASSIGN_OR_RETURN, yaze::Rom::data(), yaze::gfx::lc_lz2::DecompressV2(), GetGraphicsAddress(), zelda3_version_pointers::kOverworldGfxPtr1, zelda3_version_pointers::kOverworldGfxPtr2, zelda3_version_pointers::kOverworldGfxPtr3, yaze::Rom::size(), yaze::gfx::SnesTo8bppSheet(), and yaze::Rom::version_constants().

◆ LoadLinkGraphics()

absl::StatusOr< std::array< gfx::Bitmap, kNumLinkSheets > > yaze::LoadLinkGraphics ( const Rom & rom)

Loads the players 4bpp graphics sheet from Rom data.

Definition at line 235 of file rom_old.cc.

References ASSIGN_OR_RETURN, kNumLinkSheets, yaze::gfx::kTilesheetDepth, yaze::gfx::kTilesheetHeight, yaze::gfx::kTilesheetWidth, yaze::Rom::palette_group(), yaze::Rom::ReadByteVector(), and yaze::gfx::SnesTo8bppSheet().

Here is the call graph for this function:

◆ LoadFontGraphics()

absl::StatusOr< gfx::Bitmap > yaze::LoadFontGraphics ( const Rom & rom)

Definition at line 256 of file rom_old.cc.

References yaze::gfx::Bitmap::Create(), yaze::Rom::data(), and yaze::Rom::size().

Here is the call graph for this function:

◆ LoadAllGraphicsData()

absl::StatusOr< std::array< gfx::Bitmap, kNumGfxSheets > > yaze::LoadAllGraphicsData ( Rom & rom,
bool defer_render )

This function iterates over all graphics sheets in the Rom and loads them into memory. Depending on the sheet's index, it may be uncompressed or compressed using the LC-LZ2 algorithm. The uncompressed sheets are 3 bits per pixel (BPP), while the compressed sheets are 4 BPP. The loaded graphics data is converted to 8 BPP and stored in a bitmap.

Loads all 223 graphics sheets from the ROM into bitmap format.

ALTTP uses 223 graphics sheets (kNumGfxSheets) stored in three formats:

Sheet Categories:

  • Sheets 0-112: Compressed 3BPP (overworld, dungeons, sprites)
  • Sheets 113-114: 2BPP sheets (skipped here, loaded separately)
  • Sheets 115-126: Uncompressed 3BPP (special graphics)
  • Sheets 127-217: Compressed 3BPP (additional graphics)
  • Sheets 218+: 2BPP sheets (skipped here)

Compression Format: Graphics data is compressed using Nintendo's LC-LZ2 algorithm. Each sheet is decompressed to a 0x800 (2048) byte buffer, then converted from SNES planar format to linear 8BPP for easier manipulation.

Graphics Buffer: All sheet data is also appended to rom.graphics_buffer() for legacy compatibility. Sheets that fail to load are filled with 0xFF bytes to maintain correct indexing.

Parameters
romThe loaded ROM (modified: graphics_buffer populated)
defer_renderIf true, defer texture creation for progressive loading
Returns
Array of 223 Bitmap objects, or error status
Warning
The DecompressV2 size parameter MUST be 0x800, not 0. Passing size=0 causes immediate return of empty data, which was a regression bug that caused all graphics to appear as solid purple/brown (0xFF fill).

The graphics sheets are divided into the following ranges:

Range Compression Type Decompressed Size Number of Chars
0-112 Compressed 3bpp BGR 0x600 chars Decompressed each
113-114 Compressed 2bpp 0x800 chars Decompressed each
115-126 Uncompressed 3bpp sprites 0x600 chars Each
127-217 Compressed 3bpp sprites 0x600 chars Decompressed each
218-222 Compressed 2bpp 0x800 chars Decompressed each

Definition at line 352 of file rom_old.cc.

References AddressFromBytes(), yaze::Rom::data(), yaze::gfx::lc_lz2::DecompressV2(), yaze::gfx::SnesPalette::empty(), GetGraphicsAddress(), yaze::Rom::GetMutableDiagnostics(), kNumGfxSheets, zelda3_version_pointers::kOverworldGfxPtr1, zelda3_version_pointers::kOverworldGfxPtr2, zelda3_version_pointers::kOverworldGfxPtr3, yaze::gfx::kTilesheetDepth, yaze::gfx::kTilesheetHeight, yaze::gfx::kTilesheetWidth, LOG_DEBUG, LOG_INFO, LOG_WARN, yaze::Rom::mutable_graphics_buffer(), yaze::Rom::palette_group(), PcToSnes(), yaze::GraphicsLoadDiagnostics::rom_size, yaze::Rom::size(), yaze::gfx::SnesTo8bppSheet(), SnesToPc(), Uncompressed3BPPSize, and yaze::Rom::version_constants().

◆ SaveAllGraphicsData()

◆ SnesToPc()

uint32_t yaze::SnesToPc ( uint32_t addr)
inlinenoexcept

Definition at line 8 of file snes.h.

Referenced by yaze::editor::BuildDictionaryEntries(), yaze::zelda3::TitleScreen::BuildTileset(), yaze::zelda3::Overworld::DecompressAllMapTilesParallel(), Get24LocalFromPC(), GetGraphicsAddress(), yaze::zelda3::GetGraphicsAddress(), yaze::zelda3::RoomLayout::GetLayoutAddress(), LoadAllGraphicsData(), yaze::zelda3::Room::LoadAnimatedGraphics(), yaze::zelda3::Room::LoadChests(), yaze::zelda3::LoadDungeonMaps(), yaze::Rom::LoadGfxGroups(), yaze::zelda3::LoadGfxGroups(), yaze::zelda3::Inventory::LoadItemIcons(), yaze::zelda3::LoadItems(), yaze::zelda3::Room::LoadObjects(), yaze::zelda3::Room::LoadPits(), yaze::zelda3::Room::LoadPotItems(), yaze::zelda3::LoadRoomFromRom(), yaze::zelda3::LoadRoomHeaderFromRom(), yaze::zelda3::Room::LoadSprites(), yaze::zelda3::Overworld::LoadSpritesFromMap(), yaze::zelda3::TitleScreen::LoadTitleScreen(), yaze::zelda3::TitleScreen::Save(), yaze::zelda3::SaveDungeonMaps(), yaze::Rom::SaveGfxGroups(), yaze::zelda3::SaveGfxGroups(), yaze::zelda3::Overworld::SaveMap16Expanded(), yaze::zelda3::Room::SaveObjects(), yaze::zelda3::Room::SaveSprites(), yaze::editor::PolyhedralEditorPanel::TablePc(), yaze::editor::anonymous_namespace{polyhedral_editor_panel.cc}::ToPc(), yaze::gui::DungeonObjectEmulatorPreview::TriggerEmulatedRender(), yaze::gui::DungeonObjectEmulatorPreview::TriggerStaticRender(), yaze::editor::MemoryEditor::Update(), and yaze::cli::anonymous_namespace{overworld_doctor_commands.cc}::ValidateMapPointers().

◆ PcToSnes()

◆ Get24LocalFromPC()

uint32_t yaze::Get24LocalFromPC ( uint8_t * data,
int addr,
bool pc = true )
inline

Definition at line 30 of file snes.h.

References PcToSnes(), and SnesToPc().

Referenced by yaze::editor::ParseSingleMessage(), and yaze::editor::ReadAllTextData().

Here is the call graph for this function:

◆ AddressFromBytes()

int yaze::AddressFromBytes ( uint8_t bank,
uint8_t high,
uint8_t low )
inlinenoexcept

◆ MapBankToWordAddress()

uint32_t yaze::MapBankToWordAddress ( uint8_t bank,
uint16_t addr )
inlinenoexcept

Definition at line 43 of file snes.h.

Variable Documentation

◆ Uncompressed3BPPSize

constexpr int yaze::Uncompressed3BPPSize = 0x0600
constexpr

Size of uncompressed 3BPP graphics sheet data (1536 bytes = 0x600) Used for graphics sheets 115-126 which are stored uncompressed in the ROM.

Definition at line 51 of file rom_old.cc.

Referenced by LoadAllGraphicsData().

◆ kNumGfxSheets

◆ kNumLinkSheets

constexpr uint32_t yaze::kNumLinkSheets = 14
constexpr

Definition at line 33 of file rom_old.h.

Referenced by LoadLinkGraphics().

◆ kTile16Ptr

constexpr uint32_t yaze::kTile16Ptr = 0x78000
constexpr

Definition at line 34 of file rom_old.h.

Referenced by yaze::Rom::ReadTile16(), and yaze::Rom::WriteTile16().

◆ kNormalGfxSpaceStart

constexpr uint32_t yaze::kNormalGfxSpaceStart = 0x87000
constexpr

Definition at line 35 of file rom_old.h.

◆ kNormalGfxSpaceEnd

constexpr uint32_t yaze::kNormalGfxSpaceEnd = 0xC4200
constexpr

Definition at line 36 of file rom_old.h.

◆ kFontSpriteLocation

constexpr uint32_t yaze::kFontSpriteLocation = 0x70000
constexpr

Definition at line 49 of file rom_old.h.

◆ kGfxGroupsPointer

constexpr uint32_t yaze::kGfxGroupsPointer = 0x6237
constexpr

Definition at line 50 of file rom_old.h.

Referenced by yaze::Rom::LoadGfxGroups(), and yaze::Rom::SaveGfxGroups().

◆ kUncompressedSheetSize

◆ kNumMainBlocksets

constexpr uint32_t yaze::kNumMainBlocksets = 37
constexpr

Definition at line 52 of file rom_old.h.

Referenced by yaze::Rom::LoadGfxGroups(), and yaze::Rom::SaveGfxGroups().

◆ kNumRoomBlocksets

constexpr uint32_t yaze::kNumRoomBlocksets = 82
constexpr

◆ kNumSpritesets

constexpr uint32_t yaze::kNumSpritesets = 144
constexpr

◆ kNumPalettesets

constexpr uint32_t yaze::kNumPalettesets = 72
constexpr

Definition at line 55 of file rom_old.h.

Referenced by yaze::Rom::LoadGfxGroups(), and yaze::Rom::SaveGfxGroups().

◆ kEntranceGfxGroup

constexpr uint32_t yaze::kEntranceGfxGroup = 0x5D97
constexpr

Definition at line 56 of file rom_old.h.

Referenced by yaze::Rom::LoadGfxGroups(), and yaze::Rom::SaveGfxGroups().

◆ kMaxGraphics

constexpr uint32_t yaze::kMaxGraphics = 0x0C3FFF
constexpr

Definition at line 57 of file rom_old.h.