Mother 3/Extended codes (04)

From Data Crystal
Jump to navigation Jump to search

This is a sub-page of Mother 3.

Extended codes

[04 00 YY ZZ] = Call extended code ZZYY

The value ZZYY must be between 0 and 0xFF, inclusive. Each code has a fixed number of stack parameters that must be pushed with either [01 XX YY ZZ] or [00 XX YY ZZ] codes before executing the [04] code. The ROM has a table at 0xD2D658 (256 entries, 4 bytes per entry) indicating exactly how many stack parameters each [04] code has.

The ROM has a jump table at 0xD2DA58 (256 entries, 4 bytes per entry), one jump address for each [04] code.

Known codes

(SRAM_BASE is $2004860 in WRAM, $4008/$A008 in SRAM)

  • [04 00 00 00] = Delay parsing
    • 01 = Number of frames to delay
  • [04 00 01 00] = Changes the sprite's movement speed
    • 01 = Index in the current active sprites table
  • [04 00 02 00] = UNUSED
  • [04 00 03 00] = Loads a game logic script in the pointer table. Used by cutscenes and/or the first 5 scripts
    • 01 = Script # to use. 5 has to be added to $1
  • [04 00 04 00] =
  • [04 00 05 00] =
    • 01 =
  • [04 00 06 00] =
    • 01 =
  • [04 00 07 00] =
  • [04 00 08 00] = Reloads current room
  • [04 00 09 00] = UNUSED
  • [04 00 0A 00] = Set event flag
    • 02 = Event flag number. Must be between 0 and 0x7FF, inclusive
    • 01 = Value
  • [04 00 0B 00] = Store byte to (SRAM_BASE + 0x380 + $2)
    • 02 = Must be between 0 and 0x3F, inclusive
    • 01 = Value to store, only lowest 8 bits used
  • [04 00 0C 00] = Store halfword to (SRAM_BASE + 0x3C0 + ($2 * 2))
    • 02 = Must be between 0 and 0x1F, inclusive
    • 01 = Value to store, only lowest 16 bits used
  • [04 00 0D 00] = Push event flag value
    • 01 = Event flag number. Must be between 0 and 0x7FF, inclusive
  • [04 00 0E 00] = Load byte from (SRAM_BASE + 0x380 + $1), push to stack
    • 01 = Must be between 0 and 0x3F, inclusive
  • [04 00 0F 00] = Load halfword from (SRAM_BASE + 0x3C0 + ($1 * 2)), push to stack
    • 01 = Must be between 0 and 0x1F, inclusive
  • [04 00 10 00] = Compare event flag value to $1, push 1 if equal, 0 otherwise
    • 02 = Event flag to check. Must be between 0 and 0x7FF, inclusive
    • 01 = Value to compare with
  • [04 00 11 00] = Compare byte at (SRAM_BASE + 0x380 + $2) to $1, push 1 if equal, 0 otherwise
    • 02 = Must be between 0 and 0x3F, inclusive
    • 01 = Value to compare with
  • [04 00 12 00] = Compare halfword at (SRAM_BASE + 0x3C0 + ($2 * 2)), push 1 if equal, 0 otherwise
    • 02 = Must be between 0 and 0x1F, inclusive
    • 01 = Value to compare with
  • [04 00 13 00] = UNUSED
  • [04 00 14 00] = Map-related
    • 01 = Must be between 0 and 999 (0x3E7), inclusive
  • [04 00 15 00] = Push the current map number
  • [04 00 16 00] = Add to money on hand (capped at 999,999)
    • 01 = Amount to add
  • [04 00 17 00] = Push current money on hand
  • [04 00 18 00] = Set key item value
    • 02 = Item number. Must be between 0 and 0xFF, inclusive
    • 01 = Value to set
  • [04 00 19 00] = Pushes how many of the $1 item are in the inventory
    • 01 = Item to check existence of
  • [04 00 1A 00] = Push number of characters in party
  • [04 00 1B 00] = Check if character is in current party: push 1 if true, 0 if false
    • 01 = Character to check
  • [04 00 1C 00] = Check if character is in current party: push 0 if true, -1 if false
    • 01 = Character to check
  • [04 00 1D 00] = Restores the whole party's HPs and PPs based on $1 and then updates the overworld sprites to match that
    • 01 = 0 fully restores both the PPs and the HPs, 1 fully restores the HPs, 2 fully restores the PPs and 3 makes it so all party members have at least 1 HP.
  • [04 00 1E 00] = Add character to party
    • 01 = Character number
  • [04 00 1F 00] = Remove character from party
    • 01 = Character number
  • [04 00 20 00] = Set a flag at 200DEB6:01
    • 01 = Complement of flag value. Must be 0 or 1
  • [04 00 21 00] = Set giftbox flag
    • 02 = Giftbox flag number. Must be between 0 and 0x3FF, inclusive
    • 01 = Value to set (only lowest bit is used)
  • [04 00 22 00] = Push giftbox flag value
    • 01 = Giftbox flag number. Must be between 0 and 0x3FF, inclusive
  • [04 00 23 00] = Restore HP and PP of one character, and clear status ailments
    • 01 = Character number
  • [04 00 24 00] =
    • 01 =
  • [04 00 25 00] = Add to money in bank (capped at 999,999)
    • 01 = Amount to add
  • [04 00 26 00] = Push money in bank
  • [04 00 27 00] =
    • 01 =
  • [04 00 28 00] =
  • [04 00 29 00] = Add character to party (Identical to 1E)
    • 01 = Character number
  • [04 00 2A 00] =
    • 01 =
  • [04 00 2B 00] = Set character's level and sprite
    • 03 = Character number
    • 02 = Level
    • 01 = Sprite number
  • [04 00 2C 00] = Adds/Removes an item to a party character's inventory a certain amount of times (Removing more than 1 item is bugged in terms of equipment positions)
    • 03 = Party character number, -1 is first one possible
    • 02 = Item number
    • 01 = Amount of times to add/remove
  • [04 00 2D 00] = Copy party character's HP and PP to stack
    • 05 = Party character number
    • 04 = Stack slot for current HP
    • 03 = Stack slot for max HP
    • 02 = Stack slot for current PP
    • 01 = Stack slot for max PP
  • [04 00 2E 00] = Store word to (SRAM_BASE + 0x744)
    • 01 = Value to store
  • [04 00 2F 00] = Push word from (SRAM_BASE + 0x744)
  • [04 00 30 00] = Change status ailment for a party character
    • 03 = Party character number
    • 02 = Ailment number. Must be between 0 and 8, inclusive. The ailment listing for this is a bit odd:
      • 00 = Poison
      • 01 = Numbness
      • 02 = Sleep (glitchy out of battle)
      • 03 = Strange
      • 04 = Crying (glitchy out of battle)
      • 05 = Forgetful
      • 06 = Nauseated
      • 07 = All ailments
      • 08 = Fleas
    • 01 = Ailment value (should be 0 or 1)
  • [04 00 31 00] = Party related
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 32 00] = Displays text entry from current bank. If the current bank is 0, then it displays text from the caller bank
    • 03 = Speaker (-1 for interacted npc/object, -2 for first party member, -3 is for speaker with no grey bar, positive values < 100 are for characters in the screen, a value >= 100 for $3 – 100)
    • 02 = Unused
    • 01 = Text entry
  • [04 00 33 00] = Displays text entry from zero bank
    • 03 = Speaker (-1 for interacted npc/object, -2 for first party member, -3 for no speaker, positive values < 100 are for characters in the screen, a value >= 100 for $3 – 100)
    • 02 = Unused
    • 01 = Text entry
  • [04 00 34 00] =
  • [04 00 35 00] =
  • [04 00 36 00] = Push menu selection
  • [04 00 37 00] =
    • 01 =
  • [04 00 38 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 39 00] = Load name index into writeable memory
    • 02 = Writing stack slot to load this into. F0 + $2
    • 01 = Index of the name to load
  • [04 00 3A 00] =
  • [04 00 3B 00] =
  • [04 00 3C 00] = Load another room and place character in a certain position
    • 04 = Room to load
    • 03 = X
    • 02 = Y
    • 01 = Unknown, 0 usually
  • [04 00 3D 00] =
    • 01 =
  • [04 00 3E 00] =
    • 01 =
  • [04 00 3F 00] = Screen panning
    • 03 =
    • 02 =
    • 01 =
  • [04 00 40 00] = Pan camera to absolute coords
    • 03 = X
    • 02 = Y
    • 01 = Speed
  • [04 00 41 00] =
    • 02 =
    • 01 =
  • [04 00 42 00] = Position the camera to a location on the map
    • 03 = Unknown, -1 is the usual value
    • 02 = X position on the map in pixels
    • 01 = Y position on the map in pixels
  • [04 00 43 00] =
    • 02 =
    • 01 =
  • [04 00 44 00] =
    • 02 =
    • 01 =
  • [04 00 45 00] =
    • 01 =
  • [04 00 46 00] =
    • 01 =
  • [04 00 47 00] =
    • 02 =
    • 01 =
  • [04 00 48 00] =
    • 08 =
    • 07 =
    • 06 =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 49 00] = Make the camera follow a particular sprite
    • 01 = Index in the current active sprites table
  • [04 00 4A 00] =
    • 02 =
    • 01 =
  • [04 00 4B 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 4C 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 4D 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 4E 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 4F 00] =
    • 01 =
  • [04 00 50 00] = Animates a sprite?
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 51 00] = Play sprite animation
    • 03 = Index in the current active sprites table
    • 02 = Animation index
    • 01 = Loop flag (0 = no loop, 1 = loop)
  • [04 00 52 00] = Move sprite for $1 frames in $3 direction
    • 04 = Index in the current active sprites table
    • 03 = Direction the sprite needs to move into
    • 02 = Flags
    • 01 = Frames of movement
  • [04 00 53 00] =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 54 00] =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 55 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 56 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 57 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 58 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 59 00] =
  • [04 00 5A 00] = Do sprite related stuff
    • 02 = Index in the sprite memory of the sprite
    • 01 = Index into the switch to determine what to do
  • [04 00 5B 00] = Move an object.
    • 03 = Object
    • 02 = X coordinate
    • 01 = Y coordinate
  • [04 00 5C 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 5D 00] = Sets sprite $1 for party member $2
    • 02 = Number of the party member whose sprite must be set
    • 01 = Sprite to set
  • [04 00 5E 00] =
    • 02 =
    • 01 =
  • [04 00 5F 00] =
    • 01 =
  • [04 00 60 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 61 00] =
    • 01 =
  • [04 00 62 00] =
    • 02 =
    • 01 =
  • [04 00 63 00] =
    • 02 =
    • 01 =
  • [04 00 64 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 65 00] =
    • 02 =
    • 01 =
  • [04 00 66 00] =
    • 02 =
    • 01 =
  • [04 00 67 00] =
  • [04 00 68 00] = Set an object's sprite until the room reloads
    • 02 = Sprite to be used by the object
    • 01 = Object
  • [04 00 69 00] =
  • [04 00 6A 00] =
  • [04 00 6B 00] = Move sprite
    • 04 = Sprite index in the curretn active sprites table
    • 03 = Direction to move the sprite in
    • 02 = Speed (values are 0 to 5, 0 being the slowest while 5 is the fastest)
    • 01 = Distance (measured in frames of movement)
  • [04 00 6C 00] = Sets animation override flag of a sprite
    • 02 =
    • 01 =
  • [04 00 6D 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 6E 00] = Set screen fade to play
    • 02 = Unknown, maybe stack number of the screen fade?
    • 01 = Screen fade to set
  • [04 00 6F 00] = Fade in
    • 01 = Frames for fading in
  • [04 00 70 00] = Play screen fade
    • 01 = Frames to play the screen fade
  • [04 00 71 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 72 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 73 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 74 00] = Changes palettes to a specific colour
    • 03 =
    • 02 =
    • 01 =
  • [04 00 75 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 76 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 77 00] = Stops screen shaking
  • [04 00 78 00] = Display animation on top of a sprite
    • 03 = Sprite number in the active sprites index
    • 02 = Animation to play on top of the sprite
    • 01 = Permanent flag
  • [04 00 79 00] =
    • 01 =
  • [04 00 7A 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 7B 00] =
  • [04 00 7C 00] =
  • [04 00 7D 00] =
    • 02 =
    • 01 =
  • [04 00 7E 00] =
    • 01 =
  • [04 00 7F 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 80 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 81 00] =
    • 01 =
  • [04 00 82 00] = Plays sound, complex
    • 02 = Sound to play, -1 plays the song that should be playing in the loaded room
    • 01 = Volume, -1 keeps the current volume
  • [04 00 83 00] = Play generic sound
    • 02 = Sound to play
    • 01 = Volume, -1 keeps the current volume
  • [04 00 84 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 85 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 86 00] =
    • 01 =
  • [04 00 87 00] =
    • 01 =
  • [04 00 88 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 89 00] = Sets up the first song for area $2
    • 02 = Area number
    • 01 = Song number (Between 0 and 0xFF)
  • [04 00 8A 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 8B 00] = Sets up the second song for area $2
    • 02 = Area number
    • 01 = Song number (Between 0 and 0xFF)
  • [04 00 8C 00] = Start battle
  • [04 00 8D 00] =
  • [04 00 8E 00] =
  • [04 00 8F 00] =
  • [04 00 90 00] =
    • 01 =
  • [04 00 91 00] =
  • [04 00 92 00] = Game over
  • [04 00 93 00] =
    • 01 =
  • [04 00 94 00] = UNUSED
  • [04 00 95 00] = UNUSED
  • [04 00 96 00] =
    • 01 =
  • [04 00 97 00] = UNUSED
  • [04 00 98 00] = UNUSED
  • [04 00 99 00] = UNUSED
  • [04 00 9A 00] = UNUSED
  • [04 00 9B 00] = UNUSED
  • [04 00 9C 00] = UNUSED
  • [04 00 9D 00] = UNUSED
  • [04 00 9E 00] = UNUSED
  • [04 00 9F 00] = UNUSED
  • [04 00 A0 00] = Opens up shop menu
    • 02 = Shop to open
    • 01 = Unknown, seems always 1
  • [04 00 A1 00] = Opens up save menu
  • [04 00 A2 00] = Opens up naming menu
    • 01 = Naming menu to open up
  • [04 00 A3 00] = Compares input's name to another predetermined name. Returns true if they're the same and false if not.
    • 01 = Character whose name must be compared. 00 = Duster. 02 = Kumatora. Any other value returns false.
  • [04 00 A4 00] = Opens up Item Guy's menu
  • [04 00 A5 00] = Opens up money withdrawing/depositing menu
  • [04 00 A6 00] =
  • [04 00 A7 00] = UNUSED
  • [04 00 A8 00] = UNUSED
  • [04 00 A9 00] = UNUSED
  • [04 00 AA 00] = Restarts the game
  • [04 00 AB 00] = Changes the party's movement properties
    • 04 = Collision check
    • 03 = Battle Vulnerability
    • 02 = Sliding off walls check
    • 01 = Unknown. Seems always 1
  • [04 00 AC 00] =
    • 01 =
  • [04 00 AD 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 AE 00] =
    • 01 =
  • [04 00 AF 00] =
  • [04 00 B0 00] =
  • [04 00 B1 00] =
  • [04 00 B2 00] = UNUSED
  • [04 00 B3 00] = UNUSED
  • [04 00 B4 00] =
    • 06 =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 B5 00] = Load a different sprite table
    • 01 = Number of the sprite table to load. If <= 0 or >= 5 defaults to 0
  • [04 00 B6 00] = Display text entry 0-$1 using display mode $2
    • 02 = Display mode: 0 = Scrolling text; 1 = Centered text; 2 = Notebook text
    • 01 = Text entry
  • [04 00 B7 00] =
  • [04 00 B8 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 B9 00] =
    • 01 =
  • [04 00 BA 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 BB 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 BC 00] =
    • 02 =
    • 01 =
  • [04 00 BD 00] =
    • 01 =
  • [04 00 BE 00] =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 BF 00] =
  • [04 00 C0 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 C1 00] = Return sprite number of talker
    • 01 = Number of the entity whose sprite number it wants to return. 0 is party leader. -1 is speaker.
  • [04 00 C2 00] =
    • 02 =
    • 01 =
  • [04 00 C3 00] =
    • 02 =
    • 01 =
  • [04 00 C4 00] =
    • 02 =
    • 01 =
  • [04 00 C5 00] =
    • 02 =
    • 01 =
  • [04 00 C6 00] =
    • 01 =
  • [04 00 C7 00] =
    • 02 =
    • 01 =
  • [04 00 C8 00] =
  • [04 00 C9 00] =
  • [04 00 CA 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 CB 00] =
    • 02 =
    • 01 =
  • [04 00 CC 00] =
    • 01 =
  • [04 00 CD 00] =
    • 01 =
  • [04 00 CE 00] =
    • 02 =
    • 01 =
  • [04 00 CF 00] =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 D0 00] =
    • 01 =
  • [04 00 D1 00] =
    • 01 =
  • [04 00 D2 00] =
    • 02 =
    • 01 =
  • [04 00 D3 00] =
    • 02 =
    • 01 =
  • [04 00 D4 00] = Sets up the volume for area $2
    • 02 = Area number
    • 01 = Volume (-1 = 100%)
  • [04 00 D5 00] =
    • 02 =
    • 01 =
  • [04 00 D6 00] = Move sprite to party leader
    • 01 = Index in the current active sprites table
  • [04 00 D7 00] =
    • 06 =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 D8 00] = Calls the logo sequence
  • [04 00 D9 00] =
    • 07 =
    • 06 =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 DA 00] =
    • 02 =
    • 01 =
  • [04 00 DB 00] =
    • 01 =
  • [04 00 DC 00] =
    • 01 =
  • [04 00 DD 00] = Store nybble $1 at SRAM_BASE + 0x340 + ($2/2)
    • 02 = First bit is whether to store $1 as the upper nybble or the lower nybble. The rest is the address (Between 0 and 0x7F)
    • 01 = Nybble to store
  • [04 00 DE 00] = Load nybble at SRAM_BASE + 0x340 + ($1/2)
    • 01 = Nybble to load
  • [04 00 DF 00] =
    • 02 =
    • 01 =
  • [04 00 E0 00] =
    • 02 =
    • 01 =
  • [04 00 E1 00] =
    • 01 =
  • [04 00 E2 00] = Plays sfx
    • 01 = Number of the sfx to play, not the sound's number in the normal sound's table
  • [04 00 E3 00] =
    • 01 =
  • [04 00 E4 00] =
    • 02 =
    • 01 =
  • [04 00 E5 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 E6 00] =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 E7 00] =
    • 02 =
    • 01 =
  • [04 00 E8 00] =
    • 01 =
  • [04 00 E9 00] =
    • 01 =
  • [04 00 EA 00] =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 EB 00] =
    • 01 =
  • [04 00 EC 00] = Push Character's Level
    • 01 = Character's Identifier
  • [04 00 ED 00] = Restore $1 HPs to party member $2
    • 02 = Number of the party member
    • 01 = Number of HPs to restore
  • [04 00 EE 00] = Restore $1 PPs to party member $2
    • 02 = Number of the party member
    • 01 = Number of PPs to restore
  • [04 00 EF 00] = Set/Unset single PSI of a character
    • 03 = Character whose flag must be set
    • 02 = PSI to set/unset, -1 and -2 are both used in order to set to $1 all the PSI which can be leart up to a certain level
    • 01 = Value to set the PSI to
  • [04 00 F0 00] =
    • 01 =
  • [04 00 F1 00] =
    • 01 =
  • [04 00 F2 00] =
    • 05 =
    • 04 =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 F3 00] =
    • 02 =
    • 01 =
  • [04 00 F4 00] =
    • 03 =
    • 02 =
    • 01 =
  • [04 00 F5 00] =
    • 02 =
    • 01 =
  • [04 00 F6 00] = Starts the game's staff roll - Needs to have a wait after it in order to start the sequence
  • [04 00 F7 00] =
    • 02 =
    • 01 =
  • [04 00 F8 00] =
  • [04 00 F9 00] =
  • [04 00 FA 00] =
  • [04 00 FB 00] = Stores the party's inventory in Ocho's inventory and wipes it, with the exception of equipped items.
  • [04 00 FC 00] = Tries to put Ocho's items back into the party's inventory. If Ocho's inventory can't be fully emptied, it returns 0. If there are no items, it returns 1. If Ocho fully empties its inventory, it returns 2.
  • [04 00 FD 00] =
    • 01 =
  • [04 00 FE 00] =
    • 02 =
    • 01 =
  • [04 00 FF 00] =
    • 02 =
    • 01 =