The Final Fantasy Legend/RAM map

From Data Crystal
Jump to navigation Jump to search

Chip tiny.png The following article is a RAM map for The Final Fantasy Legend.

The following article is a RAM map for The Final Fantasy Legend. Addresses below are CPU addresses (4-digit hex). VRAM (8000–9FFF), OAM (FE00–FE9F), I/O (FF00–FF7F), and HRAM (FF80–FFFE) follow the standard Game Boy layout; see Pan Docs for the full memory map.

Sources: saga1dx (wram0.asm, wram1.asm), Fledermaus formffl.txt, TASVideos (RNG semantics), Pan Docs. Save layout from save dumps (docs/saves). Feel free to add any locations you have found that aren't on this document.

Overview

Range Description
8000–9FFF Video RAM (VRAM) — tiles, tile maps
A000–BFFF External RAM — cartridge save data (8 KiB)
C000–CFFF Work RAM bank 0 (WRAM0)
D000–DFFF Work RAM bank 1 (WRAM1); scene-dependent
E000–FDFF Echo RAM — mirror of C000–DDFF (prohibited)
FE00–FE9F OAM — sprite attributes (160 bytes)
FF00–FF7F I/O registers
FF80–FFFE High RAM (HRAM) — 127 bytes
FFFF Interrupt Enable (IE)

External RAM (A000–BFFF)

Save data; battery-backed. One save slot; layout from save dump.

Range Description
A000–BFFF Save slot — 8192 bytes total; four party blocks of 64 bytes each. HP at +0x0C/+0x0D per block; gold at save offsets +0x11C (high) and +0x11E (low), packed BCD; bytes at 0x1FC–0x1FF checksum or tail. Runtime gold in WRAM at CC8E/CC8F.

Work RAM (C000–DFFF)

Labels from saga1dx vanilla wram0.asm and wram1.asm.

Range Description
C000–C09F wOAM1 — OAM copy / metasprite buffer, 160 bytes
C100–C19F wOAM2 — OAM copy / character animation, 160 bytes
C300–C37F wRandSeeds — RNG seeds, 128 bytes; each address used for a specific RNG (see RNG table below)
C380–C389 wC380 — Undocumented
C38A–C399 wFarCall — Far-call template; init copies code from ROM
C39A–C39C wVBlank — VBlank call stub, 3 bytes
C39D–C424 Code / data — Undocumented
C425–C426 wSoftResetSentinel — Sentinel 0xE41B to detect soft reset
C427 wBooted — Set to 1 on first boot
C428–CAFF Code / data — Undocumented
CB00–CBFF wRandTable — RNG lookup table, 256-byte period; two-byte index → rolled value (TASVideos semantics)
CC00–CFFF Code / data — Undocumented. Notable: CC0B Strength (current mutant in post-battle effect); CC8E/CC8F runtime gold (packed BCD); CFF7 significance TBD
D000–DFFF WRAM1 — Scene-dependent. Overworld: wTilemap (4 KiB). Battle: wBattleStates ($3E9), wBattleEnemyID (6 bytes), wBattleStatesUnknown (rest to E000)

Notable WRAM addresses

Text buffers: C600 = textbox buffer (copied to VRAM $9900); DE00 = message source buffer (message built here, then copied to C600).

RNG (TASVideos): Selected wRandSeeds addresses — one roll per use, then increment.

Address Description
C309 Mutant HP growth
C30B Mutant bonus type (ability / HP / Mana / Agl / Str / Def / shuffle / none)
C30E Mutant ability-uses shuffler
C31B HP potion recovery RNG
C323 Run away (0–126 can't run, 127–255 can run)
C33B Random battle trigger (terrain)
C343 Encounter monster group
C34B Mutant ability gained / growth (index into wRandTable)
C358 POTION / X-POTION recovery amount
C36F Mutant ability slot (1–4) — which slot overwritten when learning ability

Party block (current mutant), base CC00: CC0B Strength, CC0C Defense, CC0D Agility, CC0E Mana, CC08/CC09/CC0A HP; CC0F–CC16 ability slots (ID + uses). CC8E/CC8F gold (packed BCD).

GBC WRAM (patch-only)

saga1dx colorization patch only; original DMG has single WRAM bank at D000–DFFF.

Location Description
WRAM0 $C0A0 wFarCall2 — patch far-call stub
WRAMX bank 2 (D000) wMetatileAttr ($500), wMetatileBuffer ($300)
WRAMX bank 3 (D000) wPalettes (BG/OBJ/Battle/Title, $40 each), wPaletteLookup (256 B at D300), wRequestedPalette / wLastFadeValue / wIsTitle (3 B at DFFD)
WRAMX bank 5 (D000) wSpriteIDs (512 B), wSpriteAttr (576 B)

Hardware registers

Key I/O ranges; full listing in Pan Docs.

Range Description
FF00–FF02 Joypad / Serial — input and link cable
FF04–FF07 Timer / Divider
FF0F Interrupt Flag (IF)
FF10–FF26 Sound — audio registers
FF30–FF3F Wave pattern RAM — audio wave
FF40–FF4B LCD / Scroll / Palettes — display control
FF46 OAM DMA — OAM DMA transfer
FFFF Interrupt Enable (IE)