Memory layout

| 0x5B | B1 / B2 | B3 / B4 | T | AP | |——|———–|———–|—–|——|

Arguments

Description

Adds a new piece of materia to the materia inventory. This is either done by explicitly providing the materia type and AP value, in which case the first two bytes are zero, or by retrieving these values from memory. Both setting the values explicitly and retrieving from memory can be used together in one call by setting the correct bytes to zero; to see an example, please check below.

If B1 is non-zero, then T specifies the address to be used with B1 to find the value for materia type. If B2, B3 or B4 are non-zero, these three bytes specify the addresses to retrieve the values for this unit. B2 and the first AP byte specifies the lowest-unit (16^1) hex value to retrieve, corresponding to 0-16 gil; B3 and the second AP byte specifies the middle-unit (16^2) hex value to retrieve; B4 and the third AP byte the highest-unit (16^3) hex value.

Example

The following example adds a piece of Slash All materia (ID: 0xE) using the following parameters:

SETWORD(60,1B,1,0)
SETWORD(60,1D,E,0)
SMTRA(60,06,1D,3,2,1B)

This equates to: (3*16^1) + (2*16^2) + (1*16^3) == 0x010203 == 66051 AP.