[EA] [WIP] A Guide To Inserting Everything Through EA

#Chapter 1 - Making a ROM Buildfile

The idea is to have one event file that #includes, assembles, and organizes all of your other files, so you can just load this file up into EA and click “Assemble” like it’s some kind of “Make Hack” button.

There’s not much to it, but I’ll offer some suggestions.

1) Include #ifdef guards for the game you’re assembling for.

  • This is shown in Example 1 in the Prologue. There’s no reason to waste some time and potentially breaking a ROM because your definitions were wrong or you were writing that assembly to the wrong location.
  • There’s just really no reason not to have this on your buildfile.

2) Follow a freespace convention.

  • Have your main ROM Buildfile ORG to some free space. Then in each #included file, assume it starts at some free space in the ROM. In return, have it return to the end of free space at the end of the file.
    • Consequentially, if you need to ORG away, that means PUSH the current offset before you do, and POP once you’re done. There’ll be more examples on this later.

3) #include a lot. A. Lot.

  • The purpose of your build file isn’t to do much actual eventing. It’s to organize everything else you’re written. So most of your lines should just be #includeing your other files. In fact, I would say labels and include statements should be about 80% of your installation file.

4) Organize things Into folders.

  • You don’t have to call your folders these, but to stay organized, keep data in relevantly named folders. Put your text data in a Text folder, then just say #include "Text/Text Install.txt". Put your chapter events into an Events folder. Put your graphics into a Graphics folder. Etc.

Let’s take a look at the buildfile (with file names changed) of a hack I’m working on (It’s also a WIP):

#ifdef _FE8_
    #include "Hack Definitions.txt"
    #include "EAstdlib.event"
    
    #define Free_Space 0xb2a610
    ORG Free_Space
    #define INLINE
    MESSAGE "Used free space starts at CURRENTOFFSET"

    //CSV tables
    #include "Table Installer.txt"
    #include "Tables/Table Data External.txt"
    
    //Install Hacks
    #include "Engine Hacks/_MasterHackInstaller.txt"

    //Graphics
    #include "Mugs and Graphics/Install Graphics Data.txt"

    //Chapter Events
    #define InlineEvents //Assemble events into this free space.
    #include "Events/Chapter Events Installer.txt"
    #include "Events/World Map Events Installer.txt"

    //Maps
    #include "Maps/Master Map Installer.txt"
    
    #undef InlineEvents

    //Music
    #include "Music and Sound/Music Installer.txt"

    //Text
    //MESSAGE Text data at currentOffset
    #include "Text/Install Text.txt"
    
    MESSAGE Used free space ends at currentOffset
   


#else
    ERROR You are not assembling FE8 events!
#endif

Let’s look at how I organized this and why, a few lines at a time.

#include "Hack Definitions.txt"
#include "EAstdlib.event"

This just brings all relevant definitions into scope, for all subsequent files to use them. Even if they #include them themselves, it’s safe since Hack Definitions has #ifndef guards.

#define Free_Space 0xb2a610
ORG Free_Space

From there, it mostly just #includes every sub-installer file to hand each part of the hack. Because we ORGed to free space, each installer may assume it has access to as much free space as it needs. All the repointing is handled automatically by EA since we’ll be using labels.

It’s a very simple structure.