yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::anonymous_namespace{rom_old.cc} Namespace Reference

Functions

void MaybeStripSmcHeader (std::vector< uint8_t > &rom_data, unsigned long &size)
 

Variables

constexpr size_t kBaseRomSize = 1048576
 Standard SNES ROM size for The Legend of Zelda: A Link to the Past (1MB)
 
constexpr size_t kHeaderSize = 0x200
 

Function Documentation

◆ MaybeStripSmcHeader()

void yaze::anonymous_namespace{rom_old.cc}::MaybeStripSmcHeader ( std::vector< uint8_t > & rom_data,
unsigned long & size )

Detects and removes the 512-byte SMC copier header if present.

SMC headers were added by SNES game copier devices (Super Magicom, Pro Fighter, etc.) to store metadata about the ROM. Modern emulators and tools expect headerless ROM images, so this header must be stripped for correct operation.

Detection Logic:

  • A standard ALTTP ROM is exactly 1MB (1,048,576 bytes)
  • With an SMC header, it becomes 1MB + 512 bytes (1,049,088 bytes)
  • We check: (file_size % 1MB) == 512 bytes

This modulo-based approach correctly identifies:

  • 1MB ROM + 512-byte header = 1,049,088 bytes (✓ strips header)
  • 1MB ROM without header = 1,048,576 bytes (✓ no change)
  • 2MB expanded ROM + header = 2,097,664 bytes (✓ strips header)
  • 1.5MB expanded ROM + header = 1,573,376 bytes (✗ won't detect - rare case)
Parameters
rom_dataThe ROM data buffer (modified in-place if header found)
sizeThe file size (updated if header stripped)
Note
Do NOT change the modulo base from kBaseRomSize (1MB) to 0x8000 (32KB). The 32KB check caused false positives and broke graphics loading. See git history for details on this regression.

Definition at line 95 of file rom_old.cc.

References LOG_INFO.

Variable Documentation

◆ kBaseRomSize

constexpr size_t yaze::anonymous_namespace{rom_old.cc}::kBaseRomSize = 1048576
constexpr

Standard SNES ROM size for The Legend of Zelda: A Link to the Past (1MB)

Definition at line 60 of file rom_old.cc.

◆ kHeaderSize

constexpr size_t yaze::anonymous_namespace{rom_old.cc}::kHeaderSize = 0x200
constexpr

Size of the optional SMC/SFC copier header that some ROM dumps include. This 512-byte header was added by SNES copier devices (Super Magicom, etc.) and contains metadata about the ROM. It must be stripped for correct address calculations since all ROM offsets assume a headerless image.

Definition at line 66 of file rom_old.cc.