Scripting

From ZeldaHacking Wiki
Jump to: navigation, search

Opcodes

asm15 [parameter]

The "asm15" opcode calls an assembly function in bank 15 (or bank 0, which is always visible). It takes an optional parameter.

Unless the function you're calling is located in bank 0, the function should be in the "scriptHelp" namespace. By convention, in the disassembly, any code which could be used by the "asm15" opcode is located in this namespace. For example:

asm15 scriptHelp.carpenter_buildBridgeColumn, $52

Although bank 0 functions don't have a namespace, so this also works:

asm15 loseTreasure, TREASURE_TOKAY_EYEBALL

Useful functions

In addition to the standard scripting opcodes, you can use these functions with the "asm15" opcode for more useful effects.

Function name Address Description
loseTreasure $1733 Analogous to the "giveitem" opcode. See constants/treasure.s for what parameters to give.
removeRupeeValue $1778 Removes some rupees based on the parameter. See the Rupee value table.
blossom_checkHasRupees $4ffb Checks whether Link has a certain number of rupees. Writes 0 to var3c if he has at least that many, or 1 otherwise.

See the Rupee value table.

Example

This will cause Link to lose his seed shooter:

asm15 loseTreasure TREASURE_SHOOTER

If you're using ZOSE, you won't have the benefit of labels and constant definitions. This is equivalent:

asm15 1733 0f