Items

From ZeldaHacking Wiki
Jump to: navigation, search

Items are a class of objects which represent "allied" objects. Technically speaking, their main distinguishing property is that they are part of a collision system with enemies. It would be difficult, for instance, to make an interaction which damages enemies in the same way that items do.

Item objects include swords, bombs, the seed shooter, seeds (when being fired), etc. They do not include animal companions (those are special objects).

Not to be confused with treasure, which represent collectables (but which can also be called items in a colloquial sense).

Item list

See constants/itemTypes.s.

Memory layout

Each item slot uses bytes $dx00-$dx3f in WRAM bank 1, ie. $d700-$d73f. This is the same region used for special objects. Special objects only occupy $d000-$d03f (link) and $d100-$d13f (companion / maple), and items use the rest ($d2-$df).

Object slot Usage
$d2 Parent item 2 (for weapons that Link holds, ie. sword)
$d3 Parent item 3 (for projectile-based items)
$d4 Parent item 4 (for projectile-based items)
$d5 Parent item 5 (for flute, harp, and shield)
$d6 Weapon being held by Link (ie. sword, seed shooter)
$d7-$db Dynamically allocated item slots (used mostly for projectiles)
$dc Reserved for objects that Link holds and throws, ie. pots
$dd Reserved for something?
$de Reserved for something? (doesn't have collisions)
$df Used for drawing the "puffs" at Link's feet while using pegasus seeds

Parent items

Slots $d2-$d5 are very different from $d6-$df. The former are "parent item" slots, which don't get drawn to the screen, but perform behind-the-scenes tasks. (Items $d6-$df will be called "physical items" just to differentiate the two.)

When an item button is pressed, first, a parent item object is created. The parent item code will be run each frame, which may be responsible for determining whether to create a physical item. It is also responsible for setting Link's animation.

For example, when you press the bomb button, a parent item object will be created. It will make sure that you have at least one bomb, and that there isn't already a bomb on-screen. If both conditions are satisfied, it will proceed to create a physical bomb object, tell Link to stop moving for a moment, etc.

Data structures

itemUsageParameterTable (06:55be)

Search for this in main.s. This table is checked before creating the "parent item" object in order to determine which parent item slot to use.

In effect, this determines how using different items simultaneously will work; sometimes you can, sometimes you can't, sometimes one will take precedence over the other, etc. It achieves this by reserving each of the 4 parent item slots for specific purposes.

linkItemAnimationTable (06:55fe)

Search for this in main.s. This determines what animation Link will have when using an item, although the parent item code can override this if it wants.

data/itemAttributes.s (07:65b3)

Determines the item's collision radius, probably some other things. Needs more documentation.

data/itemData.s (3f:63a5)

Determines the graphics the item uses, including which palette to use.

(Note: this only applies to the item when in object form. To change its appearance in the inventory, see treasure.)