The Control Code Chrestomathy

chres•tom•a•thy (kres•tom•'e•the) n.   pl. •thies  A collection of choice extracts; especially, one compiled for instruction in a language.
                                   [<Gk. chrestos useful + manthanein learn>] ... aren't I helpful? :)

Okay, so this is it.  You've figured out how to use the EarthBound Text Editor,  its basic functions, and the main text control codes.  Now you're ready to spice up your text!  The following is a listing of control codes used by the EarthBound game engine.  As compared to other ROMs, the EB engine is incredibly more flexible, and it allows for a great deal more actual creativity in plot development.  I've built this chrestomathy with different sections to focus on the different control codes, fitting each one into different categories based on what they do.  Codes are also listed alphanumerically with no variable numbers filled in, with one exception - codes that start with 1F are quite diverse and not all that well-documented or understood, so some have the variable numbers filled. Go ahead, have at it!

Remember, a text block always ends with [02], which signifies... duh, the end of the block.  All control codes are isolated by [ ] brackets, so when you want to use one of these, put them around it.  If two blocks are next to each other, you don't have to put in closing and opening brackets for them - but it won't matter if you do.

@Luna is a goddess![03 00]@You go squish now![1F 02 54][13 02]
is the same as
@Luna is a goddess![03 00]@You go squish now![1F 02 54 13 02]

One more thing to keep in mind is arguments.  Some codes will accept a range of values as part of them.  I have these indicated as "."  Don't worry, your font isn't screwing up, I meant to use the  character.  I have also color coded them to make them stand out.  Good luck to you!

Difficulty Classes (DC)

Monkey Butt Easy
Monkey Butt Easy - Just follow the mouse to the exit.
Simple
Simple - Has a little more to it than the above.
Average
Average - Not too hard, but not as obvious as a simple code.
Tricky
Tricky - You may need a little illumination on various aspects of it.
Difficult
Difficult - Requires plenty of experience, or simply may be experimental.
Extreme
Extreme - If you have a noose lying around, stay away!  L33t h4X0rZ only.

Basic Text Manipulation and Window Management

Code
DC
Description
[00]
Monkey Butt Easy
Drop down to the next line.  It's like pressing ENTER in your word processor.
[01]
Monkey Butt Easy
Clear the text box out.
[02]
Simple
End of the text block.  Only use it when you mean to.  Also, the EBTE will sometimes see these in unlisted codes.
[03]
Monkey Butt Easy
Wait for player to push "A," with a blinking arrow.  Use this to show the player that there's more text to come.
[13]
Monkey Butt Easy
Wait for player to push "A," without the blinking arrow.
[14]
Monkey Butt Easy
Wait for player to push "A," with a blinking arrow in battle.  If you use [03] in battle it only pauses for a moment.
[10 ]
Simple
Brief Pause.  Fill in the  with any hex number from 00 to FF to indicate length.  Experiment to get a feel for how long values are.
[18 ]
 
Base window control code.  You should have some experience before you play with these.  Here are the various options:
Tricky   [18 00]: Close text windows in battle.
Average   [18 01 01]: Open up a square text window.
Average   [18 01 0E]: Open up a rectangular battle text window.
Difficult   [18 05]: Center text vertically?
Difficult   [18 07]: Don't display text?
Average   [18 04]: Close text windows out of battle
Average   [18 0A]: Open the "amount of money" window
Tricky   [18 0B]: Close window (I'm not sure which one - maybe the status window. - Tomato)
Average   [18 0D]: Status screen (You can write text in this window.)
Average   [18 02 1C 04 18 0A 18 01 02]: Opens a MASSIVE window.  It's not really that hard, but it may be a bit intimidating for some.
[1A 0A]
Average
This code opens the phone list.
[1C 01 ]
Simple
Display stats and stuff.
[1C 01 00]: Current Character - This is mostly used with battle statements and If-Then codes.
[1C 01 01]: Player name 1 (Input when Tony calls you in Toto)
[1C 01 02]: Player name 2 (Input when you free the Tenda of shyness)
[1C 01 03]: Your dog
[1C 01 04]: Favorite food
[1C 01 05]: Favorite thing
[1C 01 06]: Money on hand
[1C 01 07]: Money in ATM
[1C 01 08]: Char 1
[1C 01 09]: Char 1 level
[1C 01 0A]: Char 1 Exp. Points
[1C 01 0B]: Char 1 Current HP?
[1C 01 0C]: Char 1 Roll HP?
[1C 01 0D]: Char 1 Max HP?
[1C 01 0E]: Char 1 Current PP?
[1C 01 0F]: Char 1 Roll PP?
[1C 01 10]: Char 1 Max PP?
[1C 01 11]: Char 1 Offense
[1C 01 12]: Char 1 Defense
[1C 02 ]
Simple
Display Names
@Hi, my name is [1C 02 0A].[13 02]
•Hi, my name is Dungeon Man.

[1C 02 00]: Current Character.  (Use it in attack text, when using an item, or such things)
[1C 02 01]: Ness
[1C 02 02]: Paula
[1C 02 03]: Jeff
[1C 02 04]: Poo
[1C 02 05]: Pokey*
[1C 02 06]: Picky*
[1C 02 07]: King
[1C 02 08]: Tony*
[1C 02 09]: Bubble Monkey*
[1C 02 0A]: Dungeon Man*
[1C 02 0B] - [1C 02 0F]: Flying Man*
[1C 02 10]: Teddy Bear*
[1C 02 11]: Super Plush Bear*
* Uses the name in the PK Hack enemy listing

[1C 04]
Average
Opens the character HP/PP windows.
[1C 05 ]
Average
Display item names.  This one gets an average because it requires you to know the Hex number of the item you want to use.  To find that, select the item in PK Hack, put the list number into the Windows calculator, and hit Hex.  [1C 05 00] indicates an item currently being used.
[1C 06 ]
Simple
Town names (used in the teleportation menu in PK Hack.)  You could use the empy slots as a shortcut for phrases you often use!
[1C 06 01]: Onett
[1C 06 02]: Twoson
[1C 06 03]: Threed
[1C 06 04]: Saturn Valley
[1C 06 05]: Fourside
[1C 06 06]: Winters
[1C 06 07]: Summers
[1C 06 08]: Scaraba
[1C 06 09]: Dalaam
[1C 06 0A]: Deep Darkness
[1C 06 0B]: Tenda Village
[1C 06 0C]: Underworld
[1C 06 0D]: (Blank)
[1C 06 0E]: Dusty Dunes
[1C 06 0F]: (Blank)
[1C 06 10]: (Blank)
[1C 08 ]
Simple
Uses special text images.
[1C 08 01]: SMAAASH!
[1C 08 02]: You Won!
[1C 0D]
Average
In a nutshell, the character or enemy performing the action.  This is for the user of an item, the performer of an attack, the character defeating an enemy (good for death quotes) and possibly the enemy speaking a specific start quote.  Versatile, isn't it?
Use it like: @[1C 0D] used the [1C 05 CB].[13 02]
•Jeff used the Video relaxant.
[1C 0E]
Average
Like the reverse of 1C 0D, the target of the action.  This is for the target of an item, the recipient of an attack, and the enemy being defeated...  Use it like @[1C 0D] used the [1C 05 CB].[03 00]  [1C 0E] said, <Argle bargle morble woosh?>
•Jeff used the Video relaxant.
  Ness said, "Argle bargle morble woosh?"
[1F 30]
Monkey Butt Easy
Change to the normal font.  Why would you want to do that, you say?  Well, because...
[1F 31]
Monkey Butt Easy
Change to the Mr. Saturn font!

The Chosen Four - Changing Stats, Status, and Inventory

CC DC Description
[1D 0E  ]
Tricky
Gives character # item # .  The item # is in hex, of course, and the character # is the same as the one in the [1C 02 ] list.  Also keep in mind you can use character # FF, which indicates either all characters or the first available one.  You can also use the byte 00, but I'll explain that later in the conditional modifiers section.
[1D 01  ]
Tricky
Takes an item away from a character in the same form as above.  Read the conditional modifiers section for information on how you might make EB check to see if someone has an item.
[1D 08  ]
Tricky
Give money to the party in the amount specified by the two-byte number represented by  .  Remember, like pointers, you do this backwards.  To take 2 dollars away, use 02 00, not 00 02.
[1D 09  ]
Tricky
Take money from the party in the same form as above.
[1E 00 00 64]
Monkey Butt Easy
Heal the entire party's HP.
[1E 04 00 64]
Monkey Butt Easy
Restore the entire party's PP.
[1E 08  ]
Average
Sets character # 's (Remember, you can use FF) level as level .  It automatically calculates all stats and PSI.
[1F 11 ]
Average
Adds a character to your party.  Again, use the [1C 02 ] list.  Anything out of that range can lead to buggy shit.
[1F 12 ]
Average
Removes a character from your party as in [1F 11 ].  You probably shouldn't remove people who aren't there.
[1F 71  ]
Average
Give player  a PSI power.  01 is Teleport a, 02 is Teleport b, 03 is Starstorm a, 04 is Starstorm W.  Using characters other than Ness and Poo for these powers (and then only Poo for the Starstorms) does nothing.
[1F F0 02]
Difficult
Make Ness ride a bike.  This will only work correctly if nobody is following him, and if he's in his normal street clothes.
[See Right]
Tricky
[0E 01 0D 01 1B 04 1B 00 1B 01 19 05 00  ]:  Afflict somebody with status state  .  An explanation on how to use this correctly can be found here.

Events, Event Flags, and Teleportation

CC DC Description
[04  ]
Simple
This is the basic event flag code.  It marks event   as having happened.  We assume that all event flags are unset at the beginning, but as the game progresses things happen and various flags are set.  Most event flags are undocumented; thus, if you come across one and you know without a doubt what it does, TELL US at the PK Hack forum.  Here is a list of known ones.
[05  ]
Simple
This unsets an event flag.
[1F 21 ]
Average
This is the base teleport code.  Bow down and praise Falcon24 for documenting all the arguments...  You should probably close the text window before you do this.
[1F 23  ]
Tricky This triggers a battle.  You should probably close the text window before you do this.  A list of battle arguments has been prepared by ROFISH, MrRoboto2040, Tomato, and myself.
[1F 41 ]
Tricky
Call a special event.
[1F 41 01]: Coffee Scene 1
[1F 41 02]: Coffee Scene 2
[1F 41 03]: Register your name (1)
[1F 41 04]: Register your name (2)
[1F 41 05]: Place after a teleport code to make it fade to white?  Sometimes it doesn't work though.
[1F 41 07]: Display town map
[1F 41 09]: Sound stone
[1F 41 0A]: Show the title screen
[1F 41 0B]: Show cast of characters
[1F 41 0C]: Show credits
[1F 41 10]: Sound stone

Tomato: "Note that after some of these end, the game won’t know what to do next, so if you just do something like [1F 41 0C 02], the game will hang after the credits end.  So be careful.  I know I’m missing some stuff in this list, but when I tried them, nothing happened.  I think certain event flags need to be set before they work."

[1F E5 FF]
Tricky
Putting this after a teleport code makes it do the Phase Distorter back-in-time teleport.

If-Thens, Pointers, and Conditional Modifiers

CC DC Description
[08    00]
Average
Link to address    and return to the location of this code once that block resolves itself.  Look in the EBTE section for a thorough explanation on how to use this and the next two codes.
[0A    00]
Average
Link to address   .  The text will stop once that block resolves itself.
[06      00]
Tricky
If event flag   is set, link to the address   .  The [06] link works like a [0A] link, in that it does not return to the original text block once the linked block finishes.
[1B 03    00]
Difficult
This code is the True/False Pointer.  This code, discovered in Summer 2001, is a very important bit of hex.  If you have another code that sets a true/false flag (they'll all be identified hereafter), put this there.  If that true/false flag is set to FALSE, it will go to address   . Here's an example:

[1D 14 0A 00 00 00 1B 03 00 00 C5 00]@You're rich, kid![03 02] would check to see if you have $10, if you don't, it'll branch to $C50000, if you do, it'll tell you that you're rich.

[1D 05  ]
Tricky
This checks to see if character  has item .  As always, you can use FF in the character slot to check to see if ANYBODY in the party has one.  If you have the item, a "false" flag is set, so the link location in the following [1B 03] needs to go to a location that assumes that you have it.
[1D 14    ]
Tricky
Looks to see if you have the specified amount of money.  If it's false, a true/false flag totally separate from everything we've known about 'till about is set.  Use the T/F Selector above with it.
[1C 10 ]
Average
This code "selects" the person in position #  in your party.  What I mean by that is codes following it that take a character argument can be given a 00, and they will use whatever character is selected - like this:
[1C 10 01]@Hi, [1C 02 00].[13 02]  If Ness is in the front of the group, it says
•Hi, Ness.

But if Ness fainted, and Paula's in front, it says
•Hi, Paula.

This trick applies to a lot of other codes as well.

[0B ]
Tricky
This allows for customization based on which party position a specific character is in.
Let's say we use the same example.
[1C 10 01]@Hi, [1C 02 00].[03 0B 01]  That's a nice hat.[0B 02]  That hairbow is pretty.[13 02]
If Ness is in the front of the group, it says 
•Hi, Ness.  That's a nice hat.

But if Ness fainted, and Paula's in front, it says
•Hi, Paula.  That hairbow is pretty.

Another example would be,
[1C 10 03]@Hi, [1C 02 00].[03 0B 04]  Where's [1C 02 03]?[13 02]
If the party is Ness, Paula, then Poo, it would say, 
•Hi, Poo.  Where's Jeff?

[0E     00]
Average
If character  is in the party, link to address   .  Pretty basic compared to these others.
[1F 52  1B 04]
Extreme
This is the number chooser code.  The  indicates how many digits you can select with - though anything over 6 or 7 will not work or something.  If the next code uses a 00 argument, they'll use the number you input.  Like, [1F 52 03 1B 04 1C 05 00 03 02] will print the name of the item you choose.  It's three digits long because of the number you input is in decimal form, not Hex.
[1D 20 1B 03    00]
Difficult
This link goes to address    if a character or monster performing an action is also the target of the same action.  This is used in food like so:
[1D 20 1B 03 AB 7B C9 00 01]@[1C 0D] took[00]  the [1C 05 00] out and[03 00]@[1C 0E] ate it.[03 02]
That translates to two different possibilities:

Let's say Ness just gave Poo a bowl of rice gruel.
•Ness took the Bowl of rice gruel out and
•Poo ate it.
But if Ness eats it himself...
•Ness ate the Bowl of rice gruel.

[See Right]
Difficult
[03 18 04 1C 04 1A 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 1D 0D 00 01 02 1B 01 1B 04] This will open a party window like you see in the hospital, showing the names of all living party members.  As before, you can use the 00 argument for following character codes to do all sorts of groovy stuff!

Sprite Manipulation & Movement

CC DC Description
[1F EB  06]
Tricky
This makes the character selected disappear.  It will remain invisible until...
[1F EC  01]
Tricky
...you use this code to make a character reappear.
[1F E4   ]
Average
This code makes the selected character or sprite face in the direction indicated by .  The if you use a character and not a sprite, make the second byte in the code a 00.  Here is a list of acceptable numbers.
[1F E4   01]: Up
[1F E4   03]: right
[1F E4   05]: down
[1F E4   07]: left
[1F E4   09]: diagonal up right
[1F E4   0A]: diagonal down left
[1F E4   0B]: diagonal down left
[1F E4   0C]: diagonal up left
There are other values but they just repeat.  Thanks to flynman for this info!
[1F F3   02]
Average
Using this makes Captain Strong's walkie talkie appear in sprite/character 's   hand.  It's best if they face down.
[1F F4  ]
Average
This gets rid of the walkie talkie - otherwise it floats there with a hand attached to it.  Use the same sprite # as before.
[1F E1   3C]
Average
Change to pallet  .  This is cool, but sometime's it's just wrong.
[1F 17    00 01]
Extreme
Cause sprite # to appear.  Byte  is believed to be movement #, but it's unconfirmed.  It's unlikely that the sprites will be documented anytime soon, because there's just so many...  :p
[1F 15    00 ]
Extreme
Basic movement code.  This makes a sprite appear (not one using the pointer table, mind you, but simply an image.) and move around the screen.    is a two byte sprite number. This is not the same as the other set of two byte sprite numbers. Here is a list of the sprites.   is movement number. The movement numbers are mostly undocumened, but we know that some of them have to do with the coordinate system.  See, the EB map is one giant map, and the coordinates dictate not only teleports but certain movement codes as well.  So if you were to use a particular code that made a walking cow, it might end up 'mooving' right through a wall on its way to Dalaam from Saturn Valley...
[1F 1E   ]
Extreme
Cause sprite #   to disappear.  Byte  seems to be the method of disappearing (06 just vanishes, 08 does horizontal lines, and 09 does vertical lines.)
[1F 1A  ]
Difficult
Causes sprite  to appear around sprite # .  A list for this code and [1F 1C] has been compiled by flynman, take a look!
[1F 1B 02]
Simple
Makes a sprite generated by [1F 1A] to vanish.
[1F 1C  ]
Difficult
Causes sprite  to appear around character #.
[1F 1D 02]
Simple
Makes a sprite generated by [1F 1C] to vanish.
[19 22    ]
Tricky
  looks at  , simply.  This is a cool little code!
[1F 13  ]
Tricky
An addendum to the above code, I think this might lock  's view on the previously selected sprite.

Assorted Crap

CC DC Description
[Sound]
Simple
This is a seperate page on sounds and music.
[Stores]
Average
MrAccident figured out a way to access stores from the text! Here is an explanation of how to do it.
[Phones]
Average
[1D 09   18  1F 02 0B 08 33 30 C6 00 02]: Phone call!  This will take $  from you and open the phone menu.   is either 0A or 0B, the former indicating dictation wallet window will open and the latter indicating it won't.  You'd probably want to add a [1D 14    ] money checker with a [1B 03    00] true/false pointer to make sure they actually have that money. (The pointer links to a place that says you don't have enough.)
[Animations]
Tricky
I discovered a control code that allows you to display battle animations during battle!  And again, flynman has risen to the occasion and mapped out the arguments (at least, a practical set of them.)  Check it out.