Zane's Hack Rewrites

This is a set of rewritten/redone/replacement code for FE8. It’s intended that these get used in part of a larger buildfile, preferably something like Stan’s make-ea template or some such method.

Oftentimes when looking at code written by other people, I think about how I would do it. This is especially true when looking at older code that was released or ported in the early days of the buildfile method. I hope that these are clearer and cleaner than the things that inspired them, and I’m always hoping to improve. If you’ve got suggestions for ways I can improve this code (or this thread, or the GitHub repository, or whatever) please let me know.

Also, if you’ve got any suggestions for code I could rewrite, I’d love to hear them as long as the hack is:

  1. (relatively) short
  2. self-contained
  3. for FE8
  4. easy to test

I’m not going to rewrite the skill system.

Hack List

Skip Huffman Decompression

Source

This hack serves the same purpose as the ubiquitous ‘Antihuffman’ patch that hacks use to circumvent the normal text (de)compression that the game uses. The Antihuffman patch was written by Hextator and Nintenlord, and was adapted for use with the buildfile method by CrazyColorz5 and distributed as part of the ‘FE8 Essential fixes’.

Some notes about the Antihuffman patch

The function at 0x800A240 (GetStringFromIndex in the decomp) is smart and will avoid decompressing a passed-in text ID if it’s already in the text buffer. The Antihuffman patch hooks into the middle of this function, just after the the check for the current ID and return, and tries to preserve this functionality. It fails, however, because it destroys the function’s original literal pool and doesn’t add the pointer to the text buffer into its new one, leading to:

https://i.imgur.com/MvIkzso.png

The third line, address 0800A244, normally loads a pointer to the current text ID in the text buffer. Now, it’s a garbage read to an address outside of the GBA memory map and the result is open bus. Definitely worth changing.

The Antihuffman patch also can’t fit all of its code inline, and jumps out to some mysterious offset with no explanation to lay down the rest of its code. The original picks a block of zeroes in one of the DirectSound instruments in the Demon King’s sound effects, according to FEBuilderGBA, and the Essential Fixes version picks a different offset in that same block of zeroes.

This hack is backwards compatible with the Antihuffman patch’s method for flagging text pointers as uncompressed (i.e. setting the uppermost bit in the pointer).

Moving Sounds

Source

This is a rewrite of Tequila’s FE8 Walking Sounds Fix done in C and making use of some updated buildfile techniques. It includes some helpers for changing class movement sounds and demonstrates how you could add a moving sound. See the installer for usage examples.

Like the original, this one also fits without needing any extra free space, although you’ll probably need to put any custom moving sounds into free space.

Allegiance Palettes

Source

This is a rewrite of Vesly’s Allegiance Palette done in C.

The original hack had entries that checked whether it was a specific chapter and if an event flag was set. This rewritten hack allows you to specify a function that returns whether or not to use the palette based on whatever conditions you want. Included by default is a check that mimics the behavior of the original hack (along with some helper macros to make it easy to use).

17 Likes

EXP by Action

Source

This is a rewrite of Contro’s EXP by Action done in C.

Dance, Steal, Summon, and Summon (DK) all share an experience value in vanilla, this breaks them out so that you can specify experience values individually.

8 Likes