Users browsing this thread: 1 Guest(s)
Psycho Cyan Bug Fix

#1
Posts: 18
Threads: 3
Thanks Received: 0
Thanks Given: 0
Joined: Nov 2019
Reputation: 0
Status
None
Psycho Cyan bugs have been impacting WC players recently which caused me to look into fixes. Most places online point to:
http://www.rpglegion.com/ff6/hack/psycho.htm

The bug fixed by this patch seems caused by death/petrify/zombie calling c246a9 which sets the entity's bit at 0x3a56. If those status effects are later removed the entity's bit is still set. This causes Retort to skip checking if the attack is a normal attack at c24c95 and skip checking if the user is the target of the attack and not attacking themselves at c24c9b.

From the C2 disassembly:
Code:
C2/4C8B: 2C 56 3A     BIT $3A56      (has entity died since last executing Command 1Fh,
                                     "Run Monster Script", counterattack variant?)
C2/4C8E: E2 20        SEP #$20       (Set 8-bit accumulator)
C2/4C90: D0 0B        BNE $4C9D      (Branch if so.  this is a "catch-all" to allow
                                     counters when not normally permitted.)
C2/4C92: A5 B1        LDA $B1
C2/4C94: 4A           LSR
C2/4C95: B0 27        BCS $4CBE      (Branch if it's a counterattack, periodic
                                     damage/healing, or a special command like a
                                     status expiring or an equipment auto-spell.
                                     iow, No counter if not a normal attack.)
C2/4C97: A5 B8        LDA $B8
C2/4C99: 05 B9        ORA $B9
C2/4C9B: F0 21        BEQ $4CBE      (No counter if not target of attack, or if
                                     targeting yourself)

The existing fix clears the entity's bit at 0x3a56 when death/petrify are removed but it does not fix the bug for zombie. This can be verified on a rom with the patch applied by inflicting zombie on Cyan, using a Revivify on him, then using retort. He will counter even if not targeted by the next attack. As a result, the full psycho cyan bug can still be achieved by inflicting Cyan with zombie, removing it, using Retort, and then turning Cyan into an Imp.

All three statuses can be fixed with the following:
Code:
 0265ba: 0x20 0x9c 0x46                | JSR $469c
 0265bd: 0xb9 0x18 0x30                | LDA $3018
 0265c0: 0x1c 0x56 0x3a                | TRB $3a56
 0265c3: 0x60                          | RTS

# petrify/death:
 0245f2: 0x20 0xba 0x65                | JSR $65ba

# zombie:
 0245ae: 0x20 0xba 0x65                | JSR $65ba

The addresses are for an unheadered rom and 0x65ba is any free space in C2. These changes require 10 bytes of free space (2 bytes less than the existing fix).

The second part of the bug is using retort and then inflicting Cyan with imp. This will cause the next attack targeting Cyan to counter with a normal attack which will not clear the retort bit. As a result, Cyan will counter every attack with a normal attack.

As a fix, I clear the retort bit when a character has imp set (or cleared) which will also prevent the first normal counter attack after turning into an imp:
Code:
 0265c4: 0xfe 0x30 0x2f                | INC $2f30, X
 0265c7: 0xbb                          | TYX
 0265c8: 0x5e 0x4c 0x3e                | LSR $3e4c, X
 0265cb: 0x1e 0x4c 0x3e                | ASL $3e4c, X
 0265ce: 0x60                          | RTS

# imp set/clear:
 0245ed: 0x20 0xc4 0x65                | JSR $65c4

The addresses are for an unheadered rom and 0x65c4 is any free space in C2. These changes require 11 bytes of free space.
  Find
Quote  
[-] The following 4 users say Thank You to AtmaTek for this post:
  • Gi Nattak (05-22-2021), kjinn22 (05-30-2021), madsiur (05-24-2021), Warrax (05-23-2021)

#2
Posts: 200
Threads: 1
Thanks Received: 10
Thanks Given: 0
Joined: Oct 2015
Reputation: 18
Status
None
note that there's already a fix for the 2nd part of the bug, which takes a somewhat different approach:
http://slickproductions.org/forum/index....pic=2050.0
(warning: that forum often takes about 30 seconds to load.)

good catch on Zombie.
Quote  

#3
Posts: 208
Threads: 3
Thanks Received: 0
Thanks Given: 8
Joined: May 2013
Reputation: 0
Status
None
Found a bug so far.

If a monster has Vanish (clear) status, casting SwrdTech -> Retort will put it out of clear status (but not always).



  Find
Quote  

#4
Posts: 281
Threads: 18
Thanks Received: 12
Thanks Given: 8
Joined: Mar 2014
Reputation: 8
Status
None
(05-24-2021, 03:50 PM)Warrax Wrote: Found a bug so far.

If a monster has Vanish (clear) status, casting SwrdTech -> Retort will put it out of clear status (but not always).

That happens in vanilla as well, and is oddly working as intended, I think. Even though Retort (the preparation) doesn't actually do anything except set Cyan's Retort flag, it's still a spell, with a (random) target. If it targets an enemy with Clear status, everything proceeds as normal.
I agree it's probably an oversight though - setting the "ignore clear" flag for Retort should fix it.
  Find
Quote  

#5
Posts: 208
Threads: 3
Thanks Received: 0
Thanks Given: 8
Joined: May 2013
Reputation: 0
Status
None
(05-24-2021, 07:21 PM)seibaby Wrote:
(05-24-2021, 03:50 PM)Warrax Wrote: Found a bug so far.

If a monster has Vanish (clear) status, casting SwrdTech -> Retort will put it out of clear status (but not always).

That happens in vanilla as well, and is oddly working as intended, I think. Even though Retort (the preparation) doesn't actually do anything except set Cyan's Retort flag, it's still a spell, with a (random) target. If it targets an enemy with Clear status, everything proceeds as normal.
I agree it's probably an oversight though - setting the "ignore clear" flag for Retort should fix it.

Interesting, I added LDA #$80 + TRB $B3 (Set ignore vanish) to retort preparation, I had some issues at first but now it seem to work, thanks!



  Find
Quote  



Forum Jump:

Users browsing this thread: 1 Guest(s)


Theme by Madsiur2017Custom Graphics by JamesWhite