Eventing for Dummies

Macros & Definitions

I’d like to cover one of the Event Assembler’s handiest features. Although the Event Assembler gives us a way to compile code for chapter events, what we see as the writers is different from what the game sees in pure code. In the last chapter I mentioned the Event Assembler Standard Library. The “EAstdlib” is a compilation of various macros and definitions. What are macros and definitions?

Macro: A more user-friendly feature, which translates strings of raw code into easy-to-understand text. This is the above raw code with macros added:

Text(0815)
ENDA

Defined Variable: Defined variables are another part of the user-friendliness of the Event Assembler. Instead of memorizing hex-values for information (Lyn_t, Lyn’s tutorial mode, is hex-value 0x03), you can define words to substitute for hex values.

MOVE Lyn_t [10,1]

Lyn_t is used to substitute for 0x03 in any instance. The Event Assembler will know that Lyn_t = 0x03 when writing the events to the ROM. There’s no difference between Lyn_t and 0x03 to the EA, but using defined variables is a convenience for users.

Event Assembler Standard Library: The library of macros that comes with every EA download. Contains macros, labels, and numerous helpful things.

They're what allow me to turn code that looks like this:
CHES 0x00 0x6C [2,4] 0x14

Into code that looks like this:
Chest(Elixir,2,4)

The latter seems a lot simpler, right? It’s more intuitive to write this way because it’s closer to what we see in the game itself. We don’t see 0x6C, we see an Elixir given to us by a treasure chest.

The EAstdlib comes bundled with every download of the Event Assembler. It contains a plethora of macros and definitions for you to use (I will be covering a lot of those macros in this tutorial). However, most people would like to make their own custom sets of definitions to match their hack. You can define Character IDs with your hack’s character names, you can pretty much define anything. What’s important is a definitions file. Notice in the template it has the line “#include EAstdlib.event”? Below that, in your own event files, you can put “#include yourdefinitions.txt” (obviously the file name is changeable) to tell the Event Assembler to read your own set of definitions!

Make a new .txt file, name it whatever you desire.Open up your newly created text file, it is (hopefully) blank.

The to make the definitions we need to write the following code.

#define (name) (value)

The name is the word you want to define and the value is the value in hex. Here’s a screenshot from my ‘BSFE7_Definitions.txt’ file (used for Elibian Nights).

Remember, the file can be named whatever you like so long as it matches the name in the “#include filename.txt” part of your events. Have fun defining! It makes the life of an event-crafter’s life much much easier.