Seems like the current popular vote is for giving the bonus to all 4 characters. I'll leave the poll going until all the bugs are fixed and work on that down the line.
I'm stumped regarding the Evasion/MDef delay again though. I just don't know what address is being referenced by STA ($7E),Y, but it's clearly neither of the addresses that SHOULD be holding Evasion or MDef level. Stats should be refreshed, I think, the moment that a character's stat window is opened, rather than when something forces it to update. I'll have to look into what routine is running to refresh stats when you change equipment or anything of that nature.
So watching the relevant addresses in RAM for MDef in the case I'm testing (7D7D for Firion's MDef in combat and 612C for what appears in stat window), it appears to break upon leaving combat here,
03D3C8:91 82 STA ($82),Y @ $7D7D = #$07
in what looks like combat stats are being stored before it returns to the overworld with no further breaks. So it doesn't actually store the new value in 612C until something prompts it. Strangely though, stats are not handled in this way, as they immediately write to the relevant permanent stat addresses the moment they increase. As such rather than tampering with that routine and causing potentially harmful side-effects, I should see if I can't simply insert a JSR to the routine that refreshes stats. I'll see what I can do about either putting that at the end of a battle, or having it run the moment the menu screen opens.
I think 0x0018B2 is what I want to JSR to when the menu screen opens, as it is run everytime one tries to change equipment, enters a battle (when these stats get refreshed), and appears to be what's in charge of refreshing stats. I just have to figure out where in code the menu screen opening is handled...
So I just spent the last hour or two chasing down control flow and setting breakpoints, and FINALLY found the routine that handles going to the pause menu. It's at 0x03ACD4
in the disassembly, fortuitously right below the routine that handles spell levels off of which I shaved 3 bytes (just enough for a JSR!) with the Spell Max Level Fix. I also determined precisely where to point a JSR if I want stats to be refreshed, 0x001890
. Alas, likely again due to fixed bank, I cannot use JSR $9880, as it points to 0x039890
instead of 0x001890
. How frustrating... Anyone can think of a workaround? Also, more specifically, the very beginning of this entire rabbit hole starts the moment the Start button is hit at
0x03C175|$0F:$C165:A9 00 LDA #$00
Another solution I'm looking at is if I could have this stat refresh apply immediately at the end of a battle, or at least where there's stat gains. I'll see if I made enough room with changes to the stat ups to fit a JSR in, or if it will even be able to point to the correct bank. I tried moving my first fix, which had some blank space inside it, around a bit, and stick a JSR inside the evasion/mdef up code. Alas, still limited by banks. I'm stumped on how or where to stick this stat refreshing function call currently, so I'm going to start looking into some of the other bugs on the list.
- Investigate possible overflow on Evasion % when Agility/Evasion level and Shield equipped modifier add up.
I believe that the issue here is that the code does not take two shields into account, and it is simply setting the character's Evasion to whatever bonus the second shield gives, rather than attempting to ADC it to current evasion and then comparing the new value to 99.
; control flow target (from $9A19)
0x001A4C|$00:$9A3C:A5 56 LDA $56
0x001A4E|$00:$9A3E:65 6F ADC $6F
0x001A50|$00:$9A40:85 56 STA $56
0x001A52|$00:$9A42:A5 57 LDA $57
0x001A54|$00:$9A44:69 00 ADC #$00
0x001A56|$00:$9A46:85 57 STA $57
0x001A58|$00:$9A48:A0 01 LDY #$01
0x001A5B|$00:$9A4B:B1 44 LDA ($44),Y
0x001A5D|$00:$9A4D:71 46 ADC ($46),Y
0x001A5F|$00:$9A4F:71 48 ADC ($48),Y
0x001A61|$00:$9A51:85 58 STA $58
0x001A63|$00:$9A53:A9 00 LDA #$00
0x001A65|$00:$9A55:69 00 ADC #$00
0x001A67|$00:$9A57:85 59 STA $59
0x001A6A|$00:$9A5A:A5 56 LDA $56
0x001A6C|$00:$9A5C:E5 58 SBC $58
0x001A6E|$00:$9A5E:85 56 STA $56
0x001A70|$00:$9A60:A5 57 LDA $57
0x001A72|$00:$9A62:E5 59 SBC $59
0x001A74|$00:$9A64:85 57 STA $57
0x001A76|$00:$9A66:B0 04 BCS $9A6C
0x001A78|$00:$9A68:A9 00 LDA #$00
0x001A7A|$00:$9A6A:85 56 STA $56
; control flow target (from $9A66)
0x001A7C|$00:$9A6C:A0 2B LDY #$2B
0x001A7E|$00:$9A6E:A5 56 LDA $56
0x001A80|$00:$9A70:20 84 9B JSR $9B84 ; cap A at 99
0x001A83|$00:$9A73:91 7A STA ($7A),Y <<< Evasion is being set here, rather than added and capped
; cap A at 99
; control flow target (from $9949, $995E, $9A70, $9AC1)
0x001B94|$00:$9B84:C9 64 CMP #$64
0x001B96|$00:$9B86:90 02 BCC $9B8A
0x001B98|$00:$9B88:A9 63 LDA #$63
; control flow target (from $9B86)