I figure I’d drop this for posterity and if anybody needed it. I was looking through ASM for FE4 earlier since there was a request for some enhancements for Yune, and I stumbled on the code for determining follow-up attacks. I’ve tweaked it a bit try and mirror FEBinary’s system where Pursuit just makes follow-up attacks easier.

All addresses are assuming a headered ROM.

**The short version:**

At 0x4E567:

Change `90 12 BD 24 00 89 00 40 F0 0A B9 30 00 DD 30 00 10 02 38 60 18 60`

to `20 10 FF 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00`

. (The zeros are actually just me stubbing out the old code and are technically not necessary.)

At 0x50110:

Replace the 00s with `90 2C B9 30 00 DD 30 00 10 24 BD 24 00 89 00 40 F0 0E BD 30 00 38 F9 30 00 C9 03 00 90 10 80 0C BD 30 00 38 F9 30 00 C9 06 00 90 02 38 60 18 60`

There are two bytes in the second chunk that can be customized. After each of the 0xC9 bytes, there’s a value. The first one (0x03 above) is the AS threshold needed to follow-up if you have Pursuit. The second one (0x06 above) is the AS threshold needed to follow-up if you don’t have Pursuit.

**The long version:**

The second chunk is my own subroutine that is written in empty space at the end of the same data bank. The first chunk simply replaces the old routine to check for Pursuit to jump to my own subroutine, since I needed more space to do this.

The original routine ASM:

$84/E367 90 12 BCC $12 [$E37B] <-- Some kind of check that bypasses this entire sequence if the result of the previous function (see above) has the carry flag cleared.

$84/E369 BD 24 00 LDA $0024,x[$7E:4ED9] <-- Loads Attacker Skills into Accumulator.

$84/E36C 89 00 40 BIT #$4000 <-- Check if the Pursuit bit is set. If it is, clears the zero flag.

$84/E36F F0 0A BEQ $0A [$E37B] <-- Branches if zero flag was set.

$84/E371 B9 30 00 LDA $0030,y[$7E:4F45] <-- Loads the defender’s AS into the Accumulator

$84/E374 DD 30 00 CMP $0030,x[$7E:4EE5] <-- Compares it with the attacker’s AS. Sets the negative flag if necessary (i.e. Defender AS - Attacker AS)

$84/E377 10 02 BPL $02 [$E37B] <-- Branches to skip the double attack if the negative flag was not set. (i.e. Defender AS > Attacker AS)

$84/E379 38 SEC <-- Sets the Carry to indicate a follow up attack is needed.

$84/E37A 60 RTS <-- Return

$84/E37B 18 CLC <-- The Branch Destination if there is no double attack. Clears the Carry flag to indicate no double attack.

$84/E37C 60 RTS <-- Return

The new subroutine:

$84/FF10 90 2C BCC $2C [$FF3E]

$84/FF12 B9 30 00 LDA $0030,y[$7E:4F45] <-- Loads the defender’s AS.

$84/FF15 DD 30 00 CMP $0030,x[$7E:4EE5] <-- Compares the defender AS with the attacker AS.

$84/FF18 10 24 BPL $24 [$FF3E] <-- If the defender is faster, skip the rest and return no follow-up.$84/FF1A BD 24 00 LDA $0024,x[$7E:4ED9] <-- Load the attacker’s skills.

$84/FF1D 89 00 40 BIT #$4000 <-- Does the attacker have Pursuit?

$84/FF20 F0 0E BEQ $0E [$FF30] <-- If he doesn’t, skip to the logic for checking doubling threshold without Pursuit.$84/FF22 BD 30 00 LDA $0030,x[$7E:4EE5] <-- If we get here, the attacker has Pursuit. Load the attacker AS.

$84/FF25 38 SEC <-- 65816 CPU quirk for subtraction.

$84/FF26 F9 30 00 SBC $0030,y[$7E:4F45] <-- Subtract the defender’s AS from the attacker’s.

$84/FF29 C9 03 00 CMP #$0003 <-- Compare it to the Pursuit threshold (3 in this case). Sets the carry flag if AS difference > threshold.

$84/FF2C 90 10 BCC $10 [$FF3E] <-- If carry flag is not set, skip to the end. No follow-up needed.

$84/FF2E 80 0C BRA $0C [$FF3C] <-- Otherwise, we have a follow-up. Always jump to the follow-up routine.$84/FF30 BD 30 00 LDA $0030,x[$7E:4EE5] <-- If we get here, the attacker does not have Pursuit. Same as above, load the attacker AS.

$84/FF33 38 SEC <-- 65816 CPU quirk for subtraction.

$84/FF34 F9 30 00 SBC $0030,y[$7E:4F45] <-- Subtract the defender’s AS from the attacker’s.

$84/FF37 C9 06 00 CMP #$0006 <-- Compare it to the non-Pursuit threshold (6 in this case). Sets the carry flag if AS difference > threshold.

$84/FF3A 90 02 BCC $02 [$FF3E] <-- If carry flag is not set, skip to the end. No follow-up needed.$84/FF3C 38 SEC <-- If we get here, we have a follow-up attack. Set the carry flag to indicate this.

$84/FF3D 60 RTS <-- Return.

$84/FF3E 18 CLC <-- If we get here, we don’t have a follow-up attack. Clear the carry flag to indicate this.

$84/FF3F 60 RTS <-- Return.

And the jump ASM:

$84/E367 20 10 FF JSR $FF10 [$84:FF10] <-- Jump to our new subroutine.

$84/E36A 60 RTS <-- Return the result from our new subroutine.

$84/E36B 00 00 BRK #$00 <-- Stubbed out to 00s.

$84/E36D 00 00 BRK #$00

$84/E36F 00 00 BRK #$00

$84/E371 00 00 BRK #$00

$84/E373 00 00 BRK #$00

$84/E375 00 00 BRK #$00

$84/E377 00 00 BRK #$00

$84/E379 00 00 BRK #$00

$84/E37B 00 00 BRK #$00

Edit: Formatting