This is in reference to @CaptainMuscles:' dynamic actions patch:http://www.romhacking.net/hacks/1769/
I ran into the same problem as @dudejo: in this thread:http://www.romhacking.net/forum/index.php?topic=17295.0
I crashed after casting HEL3 while battling Kary.
Admittedly, I'm new to rom hacking and ASM, in fact the problem with this patch spurred me to go to nesdev and learn about the 6502. I like this patch and want to fix it, but if I can't then hopefully this info helps someone else who can.
Alright, enough rambling...
The reported behavior is that the game freezes whenever a physical attack (player or enemy) happens any time after an L5-8 spell is cast.
The actual problem is a bit more subtle. It's not a problem with combining patches, as it happens when the patch is applied to a clean FF1 image. I don't think it's a problem with how Cap coded the patch; I two different variations and got the same results.
Steps to reproduce:
It can be reproduced from a clean state as follows:
1) apply the patch to a clean FF1 NES image;
2) New Game, create a part with 4 mages of any type - this guarantees that your first action can access the MAGIC menu;
3) on your first turn, select MAGIC, and scroll down to the second page, then press B to cancel;
4) with that same character, select FIGHT, pick an enemy, press A to attack;
-> the attack lands, but the game freezes, including the music.
Attempting to run after viewing the L5-8 page also locked up the game.
Notice that the game crashes without having to cast the spell; invoking the menu is enough to produce the effect. This also happened when I manually implemented this with Disch's Disassembly.
Furthermore, I noticed this behavior, picking up from after step 3) of the previous steps:
4) with that same character, select MAGIC again, but this time immediately cancel with B while the L1-4 page is showing;
5) with the same character, select FIGHT, pick an enemy, press A;
-> the attack lands, the game DOES NOT freeze, combat continues normally.
Just DISPLAYING the L5-8 page freezes after physical attacks or running, but display the L1-4 page again will prevent the freeze from occurring.
I used FCEUX to debug the game and discovered that it's entering an infinite loop while attempting to display a battle message. Using Disch's Disassembly as a reference, this is what I found:
The loop is in the DrawBattleString routine, bank 0F at $F9AB (ROM address 0x3F9BB).
The loop happens between bank addresses $F9D6 and F9E0 (at the @BottomLoop label in bank_0F.asm).
The loop is trying to draw the battle row of tiles of an interleaved null terminate string of tiles, stored in the buffer btl_stringoutputbuf starting $6CD4+1).
The loop can't end because the buffer is filled with space tiles (value $FF), not null tiles ($00), so the BEQ $F9F3 test fails (the Z flag is never set).
I'm not quite sure what's causing it, my conjecture is that moving the turn selection to occur when the character's turn order happens is allowing one or more variables to retain the wrong value, and that in turn is messing with the routines that undraw and redraw the message boxes. The L1-4 spell correcting it points to a possible difference in registers, the stack, temporary memory, something that isn't happening when changing to the L5-8 page.
I'm now examining the routine that handles the magic pages, BattleSubMenu_Magic at bank 0C:$94F5 (ROM address 0x31505).
That's a guess though, I've been at it for 2 weeks now, that's as far as I've gotten.
If anyone has any additional info, please post it to this thread (or link to this one). Hopefully one (or more) of us can crack the code on this one, because I absolutely love the way this patch makes the game flow!
If I find anything else on this, I'll update this thread.