News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Poll

Patching Mysidian Tower Orbs Behavior: http://www.romhacking.net/forum/index.php?topic=29704.msg388989#msg388989

Leave it, flawed as it is; the remakes retained this behavior after all
3 (13.6%)
Keep the random single-character bonus, but remove the 4th character from the RNG
4 (18.2%)
Grant the bonus to all characters, giving them a much-earned buff at this point in the game.
15 (68.2%)

Total Members Voted: 22

Author Topic: Final Fantasy II Restored  (Read 54879 times)

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #60 on: January 14, 2020, 10:03:18 pm »
Interesting... seems that 7D43 is written to when closing the menu on the overworld...?
I've also noticed that some parts of RAM are used for different purposes in battle, e.g. the $7A48-$7B47 is only used for the RNG table during battle and gets overwritten with something else outside of battle, so it's possible the same thing might be happening with $7D43 etc.

In spite of being told to increment 7D3B, debugger says it's incrementing 7D43... what could be causing that?
If I'm reading the opcode manual properly, what's happening is that INC (FE) $7D3B is incrementing Absolute Indexed with X to increment the ADDRESS $7D3B by the value in X.
This. "INC foo,X" means "increment the address 'foo + X'", so in the case where X = #$08, INC $7D3B,X affects $7D43; the debugger's helpfully telling you the effective address.

So I chased the control flow around to the two addresses indicated, but it was A57B that got my attention.
Yeah, that call from $A75B does look suspicious. It looks like they wanted to set A to #$08 for the eventual STA ($44),Y (probably #$08 means target all?) but forgot about the intermediate TAX + INC $7D3B,X. For this specific item, I would also expect a loop that increments the entire party's counters for being magically attacked. On the other hand, this entire action counter system all seems to be happening in the wrong place - all the counters are updated when the actions are determined, not when they happen. So if you manage to kill both Sorcerers before they get a chance to act, you still get credit for having been hit by a magic spell even though you actually weren't.

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #61 on: January 14, 2020, 10:08:19 pm »
Yes, while the target/cancel exploit fix addresses that issue with the party, I somehow doubt it also corrects the same behavior on enemies. The current behavior is indeed that at the start of a turn before you issue orders to your party, the enemies have already decided their attacks and credit to your attacked counters is already incremented. I might suggest looking at that down the line once the more prominent bugs are fixed, and will add that to the first post. I've been busy today but also wracking my brain about how to possibly optimize the existing code so that a fix could be fit in the available space as outlined at the bottom of my previous post. We at least know what's causing the Firion Spirit bug now, it's just a matter of how to fix it.
« Last Edit: January 19, 2020, 04:57:24 pm by redmagejoe »

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #62 on: January 14, 2020, 11:31:51 pm »
Here's a hint: once you take out the completely useless BEQ $A55F at $0C:$A55B, the sections of code at $0C:$A54A-$0C:$A55E and $0C:$A582-$0C:$A594 are identical. If you extract that code to a separate function and JSR to it from the original places, you'll free up more than enough space to add a short INC loop.

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #63 on: January 15, 2020, 12:11:08 am »
Here's a hint: once you take out the completely useless BEQ $A55F at $0C:$A55B, the sections of code at $0C:$A54A-$0C:$A55E and $0C:$A582-$0C:$A594 are identical. If you extract that code to a separate function and JSR to it from the original places, you'll free up more than enough space to add a short INC loop.

You're certain it's absolutely useless? What is it supposed to be doing, or was supposed to do, do you think? I will, however, mock up a solution and post it here before I tamper with anything for review. I appreciate your patience while I try to work this out.

EDIT: Moved mock-up down to latest post.
« Last Edit: January 19, 2020, 04:57:31 pm by redmagejoe »

abw

  • Sr. Member
  • ****
  • Posts: 372
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #64 on: January 15, 2020, 09:23:07 am »
You're certain it's absolutely useless? What is it supposed to be doing, or was supposed to do, do you think?
Aside from cycle and byte counts, this:
Code: [Select]
BEQ +
BNE label
+
is functionally equivalent to this:
Code: [Select]
BNE label
Either way, you end up branching to label if Z is clear and executing the line after BNE otherwise. The same thing goes for combinations of BxC and BxS like this:
Code: [Select]
0x032574|$0C:$A564:90 02    BCC $A568 
0x032576|$0C:$A566:B0 E2    BCS $A54A 
; control flow target (from $A564)
0x032578|$0C:$A568:A5 9E    LDA $9E   
which is just a longer and slower way of saying:
Code: [Select]
0x032576|$0C:$A566:B0 E2    BCS $A54A 
0x032578|$0C:$A568:A5 9E    LDA $9E   

I will, however, mock up a solution and post it here before I tamper with anything for review. I appreciate your patience while I try to work this out.
[...]
Code: [Select]
0x0325A1|$0C:$A591:A2 00    LDX #$00
0x0325A3|$0C:$A593:FE 3B 7D INC $7D3B,X ; Character #1 counter for times magically attacked by enemy
0x0325A6|$0C:$A596:CA    INX
0x0325A7|$0C:$A597:E0 04    CPX #$04
OUT OF BYTES:$????:D0 F9    BNE $A593    <- need 2 more bytes somewhere, or to make this sub-routine optimized
It's often better to start high and count down to 0 than to start at 0 and count up since that lets you take advantage of the decrement instructions automatically doing a comparison to 0 and updating the Z flag for you. This:
Code: [Select]
LDX #$03
-
INC $7D3B,X ; Character #1 counter for times magically attacked by enemy
DEX
BNE - ; loop to increment all characters' counter
does the same thing but eliminates the CPX #$04 to save 2 bytes. Also, you've still got this part to deal with:
Code: [Select]
0x032578|$0C:$A568:A9 08    LDA #$08   
0x03257A|$0C:$A56A:4C 0C A6 JMP $A60C 
so you can combine the two sections into one and eliminate the CPX #$08 and BNE $A5?? to save 4 more bytes.

Here's the version I put together - try giving that a shot!
« Last Edit: January 16, 2020, 09:19:41 am by abw »

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #65 on: January 15, 2020, 10:11:26 am »
Done. This is actually the most extensively I've worked with ASM, not only finding what instructions I needed to do what, but reorganizing code and working out solutions. This is the fifth iteration of this workspace, but I think I've got it a point ready for review. Forgive my inexperience, but please point out any issues with my approach.

Oh... you had a post almost an hour ago while I was still touching this up and working through it. I'm going to take your advice on the DEX and try to move this around so it's closer to the original structure (for minimal address changes), and... if you could find any faults in my changes functionally (I'm still working on making it cleaner), I'd really like to try to use my fix. It's not that I don't appreciate you providing a change, but I'd really like to learn how to do this before I look at what you linked. I'd hate to feel like I was being spoonfed solutions. That said, I did not know that quality of DEX setting the Z flag, and until I looked it up, I did not realize that the way BEQ actually worked was ensuring the Z flag was 0. I'm learning more by the minute.

Completed Mock-up:
Code: [Select]
; control flow target (from $A525)
0x03254A|$0C:$A53A:A0 2A    LDY #$2A   
0x03254C|$0C:$A53C:B1 44    LDA ($44),Y
0x03254E|$0C:$A53E:D0 1F    BNE $A55F    <- changed reference address and 31 to 1F to account for changes
0x032550|$0C:$A540:A6 76    LDX $76   
0x032552|$0C:$A542:BD 5A 7B LDA $7B5A,X
0x032555|$0C:$A545:F0 03 BEQ $A54A
0x032557|$0C:$A547:20 20 A7 JSR $A720
0x03255A|$0C:$A54A:20 82 A5 JSR $A582   <- changed address to new sub-routine

0x03255D|$0C:$A54D:A0 35    LDY #$35    <- shifted this and all following code up, sub-routine comes later
0x03255F|$0C:$A54F:B1 7E    LDA ($7E),Y
0x032561|$0C:$A551:4A      LSR
0x032562|$0C:$A552:90 02    BCC $A556   <- changed reference address
0x032564|$0C:$A554:B0 F4    BCS $A54A

0x032566|$0C:$A556:A5 9E    LDA $9E   
0x032568|$0C:$A558:AA      TAX       
0x032569|$0C:$A559:FE 37 7D INC $7D37,X ; Character #1 counter for times physically attacked by enemy
0x03256C|$0C:$A55C:4C 10 A6 JMP $A610 

0x03256F|$0C:$A55F:A0 2B    LDY #$2B   
0x032571|$0C:$A561:B1 44    LDA ($44),Y
0x032573|$0C:$A563:C9 01    CMP #$01   
0x032575|$0C:$A565:D0 0F    BNE $A576     <- change opcode and reference address to point past the new loop
0x032577|$0C:$A567:A9 08    LDA #$08

;; New Increment Loop only used after LDA #$08
0x032579|$0C:$A569:A2 00    LDX #$00
0x03257B|$0C:$A56B:FE 3B 7D INC $7D3B,X ; Character #1 counter for times magically attacked by enemy
0x03257E|$0C:$A56E:E8    INX
0x03257F|$0C:$A56F:E0 04    CPX #$04
0x032581|$0C:$A571:D0 F8    BNE $A56B
0x032583|$0C:$A573:4C 10 A6    JMP $A610     <- changed to jump past the TAX and INC commands 

0x032586|$0C:$A576:C9 02    CMP #$02   
0x032588|$0C:$A578:D0 20    BNE $A59A    <- 18 increased to 20 due to code shift
0x03258A|$0C:$A57A:20 82 A5     JSR $A582    <- added JSR here
0x03258D|$0C:$A57D:A5 9E    LDA $9E 
0x03258F|$0C:$A57F:4C 0C A6 JMP $A60C

; control flow target (from $A54A and $A57A)         <- added control flow from new JSR sources
0x032592|$0C:$A582:A2 00    LDX #$00   
0x032594|$0C:$A584:A9 03    LDA #$03   
0x032596|$0C:$A586:20 11 FD JSR $FD11  ; given A and X, return a random value in A: X == #$FF => #$FF, A == #$00 or X => A, else X + the third byte of (A-X) * (#$80 + 256 * $7A48,$42) rounded based on its second byte
0x032599|$0C:$A589:85 9E    STA $9E   
0x03259B|$0C:$A58B:20 E1 96 JSR $96E1 
0x03259E|$0C:$A58E:20 6C AF JSR $AF6C 
0x0325A1|$0C:$A591:29 C0    AND #$C0   
0x0325A3|$0C:$A593:D0 ED    BNE $A582
0x0325A5|$0C:$A595:60    RTS

0x0325A6|$0C:$A596:EA    NOP
0x0325A7|$0C:$A597:EA    NOP
0x0325A8|$0C:$A598:EA    NOP
0x0325A9|$0C:$A599:EA    NOP

Ready for review. May have to fill $A595 to $A599 with $EA (NOP)s. Any opcodes I failed to change? Does this look ready for a test-run? I'm pretty pleased with what I learned from this process, and I'm feeling more confident about making other fix attempts once I narrow down the locations of the other bugs. Your input and assistance has been tremendously helpful, abw.

EDIT: Also tested it, had to change FB to FA (oops, didn't BNE back enough bytes and caused a crash), and no more white magic breaks! It seems to successfully cycle through the party, except Firion's getting skipped over, I guess I need to set LDX to 4 and set the DEX above the INC to avoid this. Well shit, that just made it jump back up to 7D3F (thought this might happen so set a break for it) and endlessly loop. Checking the debugger with breaks set for all the relevant addresses. Huh, in spite of the Z flag being cleared, the BNE is still branching. Isn't BNE supposed to fail if Z = 0? Seems I still have to have a CPX #$00. Maybe I misunderstood, but for some reason I thought you were suggesting that DEX would automatically do a CPX #$00. Adding in the CPX caused the BNE to be passed properly, and fortunately we have 5 bytes to spare (now 3). Updating my code above accordingly.
« Last Edit: January 19, 2020, 04:57:38 pm by redmagejoe »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 334
  • I am the baldest romhacker
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #66 on: January 15, 2020, 12:52:50 pm »
The problem is that INC also affects Z status.

You are correct, if you want to recieve Z status specifically from current X after executing INC instruction, then CPX #$00 is a way to go.

Next time watch flag status in Debugger when you do Step Into.

iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #67 on: January 15, 2020, 12:56:02 pm »
The problem is that INC also affects Z.

You are correct, if you want to recieve Z status specifically from X after INC instruction, then CPX #$00 is a way to go.

Next time watch flag status in Debugger when you do Step Into.
Yeah I noticed that upon second glance. ASM and flag status still makes my head spin. Also, thanks for checking in Cyne. As you can see, I'm trying my best to dive headfirst into the confusing world of ASM, but I feel like I'm making genuine progress, and being able to work a fix like this feels rewarding. :)
« Last Edit: January 19, 2020, 04:57:44 pm by redmagejoe »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 334
  • I am the baldest romhacker
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #68 on: January 15, 2020, 01:02:48 pm »
Yes, nice speed in code writing experience. It was longer in my case since there was no one around to give me some tips.

So, do you have any questions while abw is offline? I don't really care or paying attention about what exactly are you trying to accomplish in this game, I'm simply interested in coding details.
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #69 on: January 15, 2020, 01:07:04 pm »
Yes, nice speed in code writing experience. It was longer in my case since there was no one around to give me some tips.

So, do you have any questions while abw is offline? I don't really care or paying attention about what exactly are you trying to accomplish in this game, I'm simply interested in coding.

Well without getting to into the details of the game itself, as you'd said, my fix appears to have worked up to a point. However I'm now at the end of a turn and the game is softlocked. Battle music playing, menu won't come up, stuck in the transition between all orders finished and actions taken at the end of a turn, and the menu eventually appearing for the new turn. I did a step into, and it appears to be stuck on an RTS. Do you have an idea why code execution would hang on an RTS? Being pointed into the code not from a JSR is the only speculation I can come up with, so it doesn't know what to return to. But I don't think anything in my code changes had anything to do with this address.

Code: [Select]
  032723:A0 09     LDY #$09
  032725:B1 44     LDA ($44),Y @ $7E43 = #$00
> 032727:60        RTS -----------------------------------------

Maybe my opcodes are off? I was doing a lot of changing of instructions, addresses, etc, and it's possible that what I have in my test ROM right now is not equal to what I have written in that code block above, or I've got bad bytes somewhere.
« Last Edit: January 19, 2020, 04:57:53 pm by redmagejoe »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 334
  • I am the baldest romhacker
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #70 on: January 15, 2020, 01:12:20 pm »
Code being stuck at RTS is almost impossible, so I think you mean something else.

Show me a screenshot from Debugger while it's trying to execute RTS
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #71 on: January 15, 2020, 01:18:47 pm »
Oh I see what you mean. It only shows what instruction it's on the moment you hit Step Into. So it's soft-locked because it's continually looping through instructions. A screenshot would probably not help in that case? Should I put up a dump of the instructions it's stuck cycling through by going through Step Into?
« Last Edit: January 19, 2020, 04:58:00 pm by redmagejoe »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 334
  • I am the baldest romhacker
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #72 on: January 15, 2020, 01:21:31 pm »
Yes, show me that log, and also a screen of that code in debugger just in case

Quote
is almost impossible
Actually I take that back. It's just impossible
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #73 on: January 15, 2020, 01:52:54 pm »
https://drive.google.com/open?id=1LoHvh5q0NlFtosAA2IT_pDIbyiIJeYrL

Found the Tracelogger. Trimmed it down significantly, but this appears to be the loop it's stuck in.
« Last Edit: January 19, 2020, 04:58:08 pm by redmagejoe »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 334
  • I am the baldest romhacker
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #74 on: January 15, 2020, 02:00:16 pm »
My phone can't handle a text file this big

Set an execute breakpoint at the start of your routine. When it hits, start logging, then press 128 Lines button to make sure your loop was executed several times, then stop logging.

Or you can wait an hour until I get to my computer. 

January 15, 2020, 02:04:01 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Nevermind that, I was able to see a problem

January 15, 2020, 02:10:09 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Code loops because of BPL at $A525. You read a value from LDA ($44),Y. This value appears to be positive (#$00-#$7F range), so BPL branches to the same loop and starts over.

Looks like you wanted to create loop by using INY, but since you execute LDY #$09, it becomes infinite
« Last Edit: January 15, 2020, 02:13:19 pm by Cyneprepou4uk »
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #75 on: January 15, 2020, 02:15:41 pm »
Code loops because of BPL at $A525. You read a value from LDA ($44),Y. This value appears to be positive (#$00-#$7F range), so BPL branches to the same loop and starts over.
I wonder what caused that... Did I tamper with that in my code somehow? I'll take a closer look.
« Last Edit: January 19, 2020, 04:58:15 pm by redmagejoe »

Cyneprepou4uk

  • Sr. Member
  • ****
  • Posts: 334
  • I am the baldest romhacker
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #76 on: January 15, 2020, 02:16:11 pm »
Quote
Looks like you wanted to create loop by using INY, but since you execute LDY #$09, it becomes infinite

You need to watch registers values as well as flags when you Step Into
iromhacker.ru - NES ROM hacking tutorials for beginners. Please use Google Translate browser extension

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #77 on: January 15, 2020, 02:50:15 pm »
That's bizarre... The code I changed in the block above didn't involve Y in any way, I don't think. The instructions you've described are the original code. I must have done something that had an indirect effect on Y in some way. I'll sift through the code and see what I broke. Actually been poring over this for a while and it's making my head hurt for now. I'll come back to this, and hopefully abw will have a more contextual idea of why something I did was a bad idea.

EDIT: Oops... Yep, I have a D0 0F to a577 listed above, it was D0 0D in my ROM. Also the FE 37 7D was 70 in my ROM. I'm just going to go through and input the bytes again. Typos are probably the cause of all this trouble.

 :banghead:  :banghead:  :banghead:  :banghead:

God I feel like such an idiot. Sure enough that fixed the problem. Pretty sure I had JSRs to parts of memory that the game wasn't supposed to be accessing at that point. Two typos in the test ROM remedied, and now COMPLETELY reflect the assembly solution I posted above. Would just like to have abw give it a review and make sure there's no other surprises down the line, but otherwise, I believe we've fixed the Magic-All Spirit bug! :)

Completed Mock-up:
Code: [Select]
; control flow target (from $A525)
0x03254A|$0C:$A53A:A0 2A    LDY #$2A   
0x03254C|$0C:$A53C:B1 44    LDA ($44),Y
0x03254E|$0C:$A53E:D0 1F    BNE $A55F    <- changed reference address and 31 to 1F to account for changes
0x032550|$0C:$A540:A6 76    LDX $76   
0x032552|$0C:$A542:BD 5A 7B LDA $7B5A,X
0x032555|$0C:$A545:F0 03 BEQ $A54A
0x032557|$0C:$A547:20 20 A7 JSR $A720
0x03255A|$0C:$A54A:20 82 A5 JSR $A582   <- changed address to new sub-routine

0x03255D|$0C:$A54D:A0 35    LDY #$35    <- shifted this and all following code up, sub-routine comes later
0x03255F|$0C:$A54F:B1 7E    LDA ($7E),Y
0x032561|$0C:$A551:4A      LSR
0x032562|$0C:$A552:90 02    BCC $A556   <- changed reference address
0x032564|$0C:$A554:B0 F4    BCS $A54A

0x032566|$0C:$A556:A5 9E    LDA $9E   
0x032568|$0C:$A558:AA      TAX       
0x032569|$0C:$A559:FE 37 7D INC $7D37,X ; Character #1 counter for times physically attacked by enemy
0x03256C|$0C:$A55C:4C 10 A6 JMP $A610 

0x03256F|$0C:$A55F:A0 2B    LDY #$2B   
0x032571|$0C:$A561:B1 44    LDA ($44),Y
0x032573|$0C:$A563:C9 01    CMP #$01   
0x032575|$0C:$A565:D0 0F    BNE $A576     <- change opcode and reference address to point past the new loop
0x032577|$0C:$A567:A9 08    LDA #$08

;; New Increment Loop only used after LDA #$08
0x032579|$0C:$A569:A2 00    LDX #$00
0x03257B|$0C:$A56B:FE 3B 7D INC $7D3B,X ; Character #1 counter for times magically attacked by enemy
0x03257E|$0C:$A56E:E8    INX
0x03257F|$0C:$A56F:E0 04    CPX #$04
0x032581|$0C:$A571:D0 F8    BNE $A56B
0x032583|$0C:$A573:4C 10 A6    JMP $A610     <- changed to jump past the TAX and INC commands 

0x032586|$0C:$A576:C9 02    CMP #$02   
0x032588|$0C:$A578:D0 20    BNE $A59A    <- 18 increased to 20 due to code shift
0x03258A|$0C:$A57A:20 82 A5     JSR $A582    <- added JSR here
0x03258D|$0C:$A57D:A5 9E    LDA $9E 
0x03258F|$0C:$A57F:4C 0C A6 JMP $A60C

; control flow target (from $A54A and $A57A)         <- added control flow from new JSR sources
0x032592|$0C:$A582:A2 00    LDX #$00   
0x032594|$0C:$A584:A9 03    LDA #$03   
0x032596|$0C:$A586:20 11 FD JSR $FD11  ; given A and X, return a random value in A: X == #$FF => #$FF, A == #$00 or X => A, else X + the third byte of (A-X) * (#$80 + 256 * $7A48,$42) rounded based on its second byte
0x032599|$0C:$A589:85 9E    STA $9E   
0x03259B|$0C:$A58B:20 E1 96 JSR $96E1 
0x03259E|$0C:$A58E:20 6C AF JSR $AF6C 
0x0325A1|$0C:$A591:29 C0    AND #$C0   
0x0325A3|$0C:$A593:D0 ED    BNE $A582
0x0325A5|$0C:$A595:60    RTS

0x0325A6|$0C:$A596:EA    NOP
0x0325A7|$0C:$A597:EA    NOP
0x0325A8|$0C:$A598:EA    NOP
0x0325A9|$0C:$A599:EA    NOP

EDIT: I decided to revert (and thus swap the instructions) the DEX to an INX, since a CPX has to be used anyway. This also allows this patch to be in the appropriate order should we decide to try to fix the increment counters first, do battle actions last behavior down the line. After all, in party-wide enemy casts, it starts from the top character and works down, so we'd want the counters to increase in the same order.
« Last Edit: January 19, 2020, 04:58:22 pm by redmagejoe »

Leviathan Mist

  • Jr. Member
  • **
  • Posts: 50
    • View Profile
Re: Final Fantasy II Disassembly / Bug Fix Project
« Reply #78 on: January 15, 2020, 03:08:59 pm »
Hey there, nice work so far on this project. Not sure if you're aware but the Gil counter isn't capped properly either. It should be capped at 9999999, but instead goes all the way up to 16777215 before it rolls over.

redmagejoe

  • Full Member
  • ***
  • Posts: 218
    • View Profile
Re: Final Fantasy II Restored
« Reply #79 on: January 15, 2020, 03:10:29 pm »
Hey there, nice work so far on this project. Not sure if you're aware but the Gil counter isn't capped properly either. It should be capped at 9999999, but instead goes all the way up to 16777215 before it rolls over.

I'm not going to lie, after discovering the HP/MP thing, I wholly assumed this to be the case. I don't think it's reasonable to expect a person to get that much money, but I'd still prefer to cap it anyway. Thank you for confirming this, and I'll add it to the list. Thank you for the kind words, Leviathian. Means a lot to me coming from such an awesome dude behind Final Fantasy hacking. I love your RP2A03 demakes. :)
« Last Edit: January 19, 2020, 04:58:32 pm by redmagejoe »