Help modifying Unique Battle Music Per Unit patch to work on enemy phase

I want to enable some units to have unique battle music that plays regardless of whether they’re the one initiating combat, which is not an option with the patch included in FEBuilder.

I have no experience with ASM, but in preparation for this question I did figure out how to install the existing patch via buildfile at least, since I assume that will be necessary. Now I’m just stuck on the part where I have to actually understand the code.

Any help would be much appreciated

You want to look at the part of the code where it checks for enemy phase. Enemy phase is 0x80. So if you see it checking for that then it’s checking for enemy phase. Simply removing the check might work. You could try commenting out the branch after the compare to 0x80.

Before I can even attempt that, an upstream issue is that most of the logic of the patch, including multiple instances of 0x80, are all contained in a .s assembler source file which isn’t responsive to changes at all. Even deleting it does nothing. Which is odd because I don’t recall this being the case when I was first messing with it a month ago.

There’s also a .event file that is responsive but it just has the controls that are present in the patch’s editor panel in febuilder, not what I want for my purposes

Well you need to assemble the .s file after editing it, is the corresponding binary file being updated? You’d have to assemble it yourself if not.

Okay I went and got that figured out. From the looks of it the reason this patch is one phase only is because it always uses the attacking unit to determine the music. If the specific enemy has no bgm assigned to them it will default to the current map theme. The best I could do with my tinkering so far is change what that default theme is, which isn’t exactly what I want

Essentially I need to modify it so it checks attacker on player phase and defender on enemy phase

Could you tell me the version of the patch you’re working on? There’s multiple versions for different games.

its Unique Battle Music Per Unit 20200603 (for fe8)

I think if you comment out this branch:

cmp     r1,#0x80
@beq		CHECKUNIT_CHECK_LEFT

Then it won’t check the left unit in the combat and won’t try to look them up in the data table, so it should just look for the player unit regardless of phase.

There’s also this branch:

cmp     r1,#0x80
@beq		CHECK_EQU_ITEM_LEFT

I’m not sure what that does but it looks like a check for the left unit, and we don’t want to look them up in the table, so it would make sense to skip this check too.

That appears to be how it works just looking at the source code anyway. Even without these checks it should still play the default enemy phase music if the player unit is not found in the data table.

Okay damn that solved it instantly. Somehow I didn’t pick up on check unit left literally meaning check the unit on the left.

Of course the caveat to disabling this is that it also prevents enemies from having unique battle music (boss themes aside) which is completely fine for me, I just figured I should point that out in case that’s somehow a dealbreaker for someone else looking to implement this in the future

But yeah I would assume that second branch is checking the defending unit’s weapon then, since unique music based on equipment is also a feature of the patch

Anyways thanks for the the help