User:Cassidymoen!2979/SRAM Map: Difference between revisions

From ALttPR Wiki
Jump to navigation Jump to search
(Some cleanup)
(No difference)

Revision as of 15:46, 26 March 2020

Overview

This document is intended to be an SRAM reference for the randomizer base ROM. The base ROM expands the SRAM size to 32k and removes the last two save files.

Warning

The SRAM save loading routing relies upon an inverse checksum. Additions to any byte in the .srm file, must be subtracted from that save game's checksum to maintain integrity. Failure to observe this precaution will cause the game to attempt to load the mirror copy. Should the mirror copy also fail the checksum verification, the save slot will be cleared. (TODO: add a quick explanation of the checksum algorithm somewhere)

SRAM Map

$000 to $24F - Room Data

There are 296 ($128) rooms in in the ROM. Each room's data occupies one word, or two bytes.

High Byte d d d d b k c/k c/r

Low Byte c c c c q q q q


  • c - chest, big key chest, or big key lock. Any combination of them totaling to 6 is valid.
  • q - quadrants visited:
  • k - key or item (such as a 300 rupee gift)
  • d - door opened (either unlocked, bombed or other means)
  • r - special rupee tiles, whether they've been obtained or not.
  • b - boss battle won

The quadrant bits corresponds to quadrants 4, 3, 2, and 1 in that order which is also how the quadrants are laid out on a tile from left to right (upper left, upper right, lower left, lower right), so if quadrants 4 and 1 have been "seen" by Link, then qqqq will look like 1001.

$250 to $27F - Unused

$280 to $2FF - Overworld Event Information

Each area occupies one byte.

? h o ? ? ? s ?

  • o - If set, the area will draw its designated overlay when you enter it. e.g. If you're triggered misery mire then the entrance shows up there the next time you enter that area. You can view overlays in the latest release of Hyrule Magic (v0.963). Other overlays include stairs leading underground, and the removal of the weather vane after it has exploded.
  • s - If set, the area will draw its secondary overlay when you enter it.
  • h - If set, heart piece has been collected in this area already. Also used for a handful of other sprites.
  • ? - Unknown, possibly unused.

$300 to $33F - Shop Purchase Counts

The randomizer ROM uses new shop code to handle loading and configuration of shops which allows the higher-level item and entrance randomizers to use clean, convenient abstractions for changing them. Through these abstractions, the randomizer can dictate a certain number of times that a shop item can be re-purchased (e.g. you can only buy capacity upgrades seven times.) The bytes here (except for $300 which is currently unknown) are used to count how many times a single item in a shop has been purchased. They are dynamically assigned at generation time, which is to say that any single byte should not be considered statically bound to a certain item in a shop. Take-Any caves as well as the old man with the sword in Retro world state are considered shops in this context.

Note 1: This is noted as a "temporary home" for the shop purchase counts in the base rom's source code

Note 2: Jumping into deep water without flippers and being placed back on land on the Hobo and Zora's Domain maps are known to overwrite $302 and $304 respectively. This has no effect if a shop item can always be repurchased, but will lead to unintended behavior if the item can only be purchased a limited amount of times.

Template:$ to Template:$ = Items & Equipment

Address Item Values Notes
Template:$ Bow 0 - Nothing 1 - Bow 2 - Bow & Arrows 3 - Silver Arrow Bow 4 - Bow & Silver Arrows Confirmed correct 4/19/16.
Template:$ Boomerang 0 - Nothing 1 - Blue Boomerang 2 - Red Boomerang
Template:$ Hookshot 0 - Nothing 1 - Hookshot
Template:$ How many bombs you have   Can exceed Template:0x (50), up to Template:0x (255).
Template:$ Magic Powder 0 - Nothing 1 - Mushroom 2 - Magic Powder
Template:$ Fire Rod 0 - Nothing 1 - Fire Rod
Template:$ Ice Rod 0 - Nothing 1 - Ice Rod
Template:$ Bombos Medallion 0 - Nothing 1 - Bombos Medallion
Template:$ Ether Medallion 0 - Nothing 1 - Ether Medallion
Template:$ Quake Medallion 0 - Nothing 1 - Quake Medallion
Template:$ Lamp 0 - Nothing 1 - Lamp
Template:$ Magic Hammer 0 - Nothing 1 - Magic Hammer
Template:$ Flute 0 - Nothing 1 - Shovel 2 - Flute 3 - Flute & Bird
Template:$ Bug Catching Net 0 - Nothing 1 - Bug Catching Net
Template:$ Book of Mudora 0 - Nothing 1 - Book of Mudora
Template:$ Bottles 0 - Nothing 1 - Bottle 1 (Template:$) 2 - Bottle 2 (Template:$) 3 - Bottle 3 (Template:$) 4 - Bottle 4 (Template:$)
Template:$ Cane of Somaria 0 - Nothing 1 - Cane of Somaria
Template:$ Cane of Byrna 0 - Nothing 1 - Cane of Byrna
Template:$ Magic Cape 0 - Nothing 1 - Magic Cape
Template:$ Magic Mirror 0 - Nothing 1 - Magic Scroll 2 - Magic Mirror
Template:$ Gloves 0 - Nothing 1 - Power Glove 2 - Titan's Mitt
Template:$ Pegasus Boots 0 - Nothing 1 - Pegasus Boots   Just having the boots isn't enough to dash. The player must have the "Run" ability flag set as well. See Template:$.
Template:$ Zora's Flippers 0 - Nothing 1 - Zora's Flippers   Having this allows you to swim, but doesn't make the swim ability text show up by itself. See Template:$. Unlike with the Pegasus Boots, the ability to swim is granted as long as the player has this item.
Template:$ Moon Pearl 0 - Nothing 1 - Moon Pearl
Template:$ Unused (See note)   Can be clobbered by fairy fountains.
Template:$ Sword 0 - No sword 1 - Fighter's Sword 2 - Master Sword 3 - Tempered Sword 4 - Golden Sword ***See Side Note 2***
Template:$ Shield 0 - No shield 1 - Blue Shield 2 - Hero's Shield 3 - Mirror Shield   ***See Side Note 2***
Template:$ Armor 0 - Green Jerkin 1 - Blue Mail 2 - Red Mail   ***See Side Note 2***
Template:$ to Template:$ Bottle Contents 0 - No bottle 1 - Mushroom 2 - Empty bottle 3 - Red Potion 4 - Green Potion
5 - Blue Potion 6 - Fairy 7 - Bee 8 - Good Bee
Template:$ to Template:$ Wallet Capacity   This number can be set above the 999 limit.
Template:$ to Template:$ Rupee Count

THE COMPASS, BIG KEY, AND DUNGEON MAP WORD LOCATIONS ARE ALL MAPPED OUT THE SAME WAY, AS YOU WILL OBSERVE.

Template:Note

Item Address Bit 0 Bit 1 Bit 2 Bit 3 Bit 4 Bit 5 Bit 6 Bit 7
Compass1 Template:$ Unused Unused Ganon's Tower Turtle Rock Gargoyle's domain Tower of Hera Ice Palace Skull Woods.
BigKey1 Template:$
Dungeon map1 Template:$
Compass2 Template:$ Misery Mire. Dark Palace Swamp Palace Hyrule Castle 2 (doesn't exist) Desert Palace Eastern Palace Hyrule Castle (doesn't exist) Sewer Passage (doesn't exist)
BigKey2 Template:$
Dungeon map2 Template:$

Wishing Pond Rupee Template:$

  • Number of rupees in the pond Count

Heart pieces collected:

  • Template:$. Number of heart pieces (out of four) you have earned

Health: Template:$

  • Goal (capacity) Health. Each increment of Template:$ is worth one heart.
  • Template:$ is a half heart. The max is generally Template:$. The game is coded to not accept health values beyond this.
  • Template:$. Actual Health. Same as above, but this reflects your current health status rather than potential.

Magic Power: Template:$

Keys: Template:$

  • Number of Keys you have in the dungeon you are currently in. You can earn keys on the overworld but they don't do anything. If you're in a non-keyed dungeon it will generally read Template:$.

Bomb Upgrades: Template:$

  • Number of upgrades your bomb capacity has received. Behavior varies after a while. Will probably need recoding to be consistent.

Arrow Upgrades: Template:$

  • Number of upgrades your arrow capacity has received. Same as above, more or less.

Hearts filler: Template:$

  • Write to this location to fill in a set number of hearts. Make sure to write in a multiple of Template:$ Otherwise, you will end up filling the whole life meter.

Magic filler: Template:$

  • Write to this location how much magic power you want filled up. The maximum effective value is Template:$.

Pendants: Template:$

  • Bit 0: Red/Wisdom/Hera
  • Bit 1: Blue/Power/Desert
  • Bit 2: Green/Courage/Eastern Palace

Bomb filler: Template:$

  • Write to this location to add X bombs to your arsenal. It will not exceed your maximum, as defined with Template:$.

Arrow filler: Template:$

  • Write to this location to add X arrows to your arsenal. It will not exceed your maximum, as defined with Template:$.

Arrows: Template:$

????: Template:$

  • ????

Ability Flags: Template:$

  • Bit 0:
  • Bit 1: Swim
  • Bit 2: Run / Dash
  • Bit 3: Pull
  • Bit 4: ----
  • Bit 5: Talk
  • Bit 6: Read
  • Bit 7: ----

Crystals: Template:$

  • Bit 0: Misery Mire
  • Bit 1: Dark Palace
  • Bit 2: Ice Palace
  • Bit 3: Turtle Rock
  • Bit 4: Swamp Palace
  • Bit 5: Gargoyle's Domain
  • Bit 6: Skull Woods

Magic usage: Template:$

Keys earned per dungeon:

Game Event Information

Progress Indicator Template:$ (value, not bitwise):

  • Template:$ = Unset, Will put Link in his bed state at the beginning of the game. (Also can't use sword or shield)
  • Template:$ = You have a sword and start in the castle on start up.
  • Template:$ = Indicates you have completed the first Hyrule Castle dungeon.
  • Template:$ = Indicates you have beaten Agahnim and are now searching for crystals.
  • Template:$ and above = meaningless. Though, you could write code using them to expand the event system perhaps.

Progress Flags (bitwise)Template:$:

  • Template:Hex = Set after your Uncle gives you his gear in the secret passage. Prevents him from showing up there again.
  • Template:Hex = Indicates that you've touched the dying priest in Sanctuary.
  • Template:Hex = Set after you bring Zelda to sanctuary?
  • Template:Hex = Unused? (98% certainty)
  • Template:Hex = Set after Link's Uncle leaves your house. It's used to prevent him from respawning there.
  • Template:Hex = Set after you obtain the Book of Mudora (this is a guess)
  • Template:Hex = Seems to be a persistent flag that toggles between two possible statements that a fortune teller can give you during your "reading". In other words, don't expect this to stay in one state if you're using fortune tellers. Has no other known purpose.
  • Template:Hex = Unused? (98% certainty)

Map Icons Indicator 2 (value, not bitwise) Template:$:

All values beyond 8 are invalid, it seems.

Starting Entrance to use: Template:$: Abbreviations:

  • LH = Link's House;
  • SA = Sanctuary;
  • MC = Mountain Cave;
  • PP = Pyramid of Power in DW;


Progress Indicator 3 (bitwise) Template:$:

Lightworld / Darkworld Template:$:

Unused? Template:$:

  • ?????

Template:$[[[:Template:0x]]] - (Tagalong)

  • Tagalong Indicator (who is following you, if anyone?) (value based)

Note: Don't use a value of Template:0x or larger here, as it will likely crash the game.

Template:$[[[:Template:0x]]] -

  • Cached Y coordinate of Tagalong after it has been lost by the player. Applies to the old man and to the super bomb, at the very least. This is intended to be used not as a save game variable, but rather as a means of picking the Tagalong back up by getting in contact with it.

Template:$[[[:Template:0x]]] -

  • Cached X coordinate of Tagalong after it has been lost by the player. Applies to the old man and to the super bomb, at the very least. This is intended to be used not as a save game variable, but rather as a means of picking the Tagalong back up by getting in contact with it.

Template:$:

  • ????

Template:$:

Template:$:

  • Set to 0 normally. Set to Template:$ if a Super Bomb is going off.

Template:$ to Template:$:

  • ????

Player's Name Template:$ to Template:$:

  • See appendix for listing of character codes. Note each of the six letters is represented by a 16-bit number.

Validity (Checksum) of the File: Template:$ to Template:$:

  • There is a subroutine in the ROM that checks to make sure this value is Template:0x. (Note the reverse byte order in the actual SRAM.) If you alter this your file is automatically tagged for deletion at startup. The game is designed to delete it, it's not a Super NES feature or anything. In short, Don't mess with it. Unused game slots have the value Template:0x here, and you will too if you mess with it - resulting in your save file(s) being wiped out.

Template:$ to Template:$ (?) = Deaths totals for each dungeon. Each number is 16 bit. Thanks to Euclid for helping verify this!

Life/Save Counter: Template:$ to Template:$

  • Counts the number of times your saved or died in the game, before you beat it.

PostGame Death Counter: Template:$ to Template:$

  • When you start the game this is written to with the value -1 (Template:0x). On the game select screen, it will only display a number if this is not Template:0x. The max displayable number is 999.

When you beat the game, the number of times you died gets recorded here.

Presumed to be unused: Template:$ to Template:$

  • ????

Inverse Checksum: Template:$ to Template:$

  • If you add numbers to the file, you need to subtract from this location. See Side Note 3 for more information.
===================================================================================

Appendix:

Template:Note

Template:Note

(edit later)


Character Codes:

Alpha-numeric

00 = A
01 = B
02 = C
03 = D
04 = E
05 = F
06 = G
07 = H
08 = I^
09 = J
0A = K
0B = L
0C = M
0D = N
OE = O
OF = P
10 = ??
20 = Q
21 = R
22 = S
23 = T
24 = U
25 = V
26 = W
27 = X
28 = Y
29 = Z
2A = a
2B = b
2C = c
2D = d
2E = e
2F = f
40 = g
41 = h
42 = k
43 = j
44 = i
45 = l
46 = m
47 = n
48 = o
49 = p
4A = q
4B = r
4C = s
4D = t
4E = u
4F = v
60 = w
61 = x
62 = y
63 = z
64 = 0
65 = 1
66 = 2
67 = 3
68 = 4
69 = 5
6A = 6
6B = 7
6C = 8
6D = 9
6E = "?"
6F = "!"
80 = " = "
81 = "."
82 = ","

85 = "("
86 = ")"

Special characters (not normally accessible. This is by far an incomplete listing)

Template:$ small right Arrow
Template:$ "'" (apostrophe)
Template:$ HPiece Again
Template:$ "empty right hand heart cont."
Template:$ see
Template:$
Template:$ Same As
Template:$
Template:$ "Quarter Heart piece, top right corner."
Template:$ "Heart piece,left half"
Template:$ "Heart piece, right half"
Template:$ blank
Template:$ "left Arrow"


SNES Button Alphabet:

Template:$ A
Template:$ B
Template:$ X
Template:$ Y
Template:$ I
Template:$ blank^

^This code is not the canon encoding of this character. ex. Template:Hex is the proper "I". 08 is not.

Template:Toc