phy tdc lda $3dfd,y ; Statuses to Clear, byte 1 sta backupStatus1 ; save them for possible cancelling of Image lifting lda $fe ; any Golem/Dog block occurred? beq doEvasion ; branch if not CLC ; ensure below BCC passes IF imminent BNE does LDA $11A4 BIT #$20 ; Check for Can't be Dodged BNE preloadGolemDog ; if set, we would've had a guaranteed hit without ; C2/22FB ever running, so miss credit goes ; squarely to Esper/Interceptor. ; (i could toss the "CLC" above if we branched to ; the final "LDA $FE" here. however, i don't want ; to rely on an instruction instance that i ; recommend chucking in various combinations or ; intepretations of this patch.) ; Or: ; LDA $11A4 ; ASL ; ASL ; ASL ; Carry Flag = Can't be Dodged ; lda $fe ; any Golem/Dog block occurred? ; beq doEvasion ; branch if not ; BCS chooseEligAnim ; if unblockable, we would've had a guaranteed hit ; without C2/22FB ever running, so miss credit ; goes squarely to Esper/Interceptor. jsr fictional_sanitized_22FB ; simulate normal attack hit determination ; Carry Flag: 0 = hit, 1 = miss preloadGolemDog: lda $fe ; Golem/Dog blockage flags bcc chooseEligAnim ; branch if attack would've otherwise hit, if not ; for Golem/Dog ;beq doEqu ; we reached here with no guardian blocking this ; ; strike, so always choose equipment. ; both Golem/Dog and our usual evasion check would have caused a block, ; so split credit between the two categories. normally, that'd just be ; a 50/50 split. however, the tweak to give more equal footing between ; the Esper and Interceptor lets their flags coexist, so handle a 3-WAY ; split if need be. PHX PHA JSR $520E ; X = number of bits set in A, so # of guardians ; trying to activate. CPX #$02 PLA PLX bcs threeWay ; Alternatively: ; bit #$20 ; is Golem block flagged? ; beq twoWay ; do normal, 2-way selection if not ; bit #$40 ; is Dog block flagged? ; bne threeWay ; TWO guardians are marked alongside a normal, ; evasion/etc.-based miss, so do special 3-way ; selection. ; ; or "cmp #$60 / bcs threeWay" is smaller yet, but depends on no ; hack putting a flag in Bit 7 of Variable $FE. twoWay: JSR $4B53 ; random: 0 or 1 in Carry flag. both Golem OR Dog ; and our usual evasion check would have caused a ; block, so split credit evenly between the two ; categories. ;bcc chooseEligAnim ; use Esper/Interceptor half the time bra chooseCategory ; will use Esper/Interceptor half the time, and ; equipment (when eligible) the other. threeWay: pha lda #$03 JSR $4B65 ; A = random #: 0 to 2 cmp #$02 ; treat 2 as representing evasion/gear, 0 to 1 as ; guardians pla chooseCategory: bcc chooseEligAnim ; depending on how we reached this: ; - use Esper/Interceptor half of the time ; - use Esper/Interceptor two thirds of the time doEvasion: LDA $11A2 LSR BCC chkClrMTekZomb ; Branch if magical attack LDA $3EE5,Y ; Check for Image status BIT #$04 BNE skip ; branch if possessed. attack would've otherwise ; missed, but sans an equipment animation. chkClrMTekZomb: LDA $3EE4,Y BIT #$1A ; Check target for Clear, M-Tek, or Zombie BNE skip ; no equipment dodge animation if any possessed BCS loadEquAnims ; Branch if physical attack INY ; if it was magical, read from 3CE5,old_Y instead loadEquAnims: lda $3ce4,y ; load equipment miss animation flags bne chooseEligAnim ; if we actually have 1+, go pick amongst them ; Now we're trying to detect and handle a special case of: ; 1) Golem/Dog block was flagged. ; 2) The 50/50 coin flip chose evasion blockage. ; 3) But target's equipment has no miss animation flags. ; 4) And there's no Image/Clear/M-Tek/Zombie status that'd give a ; plain "Miss" as on vanilla. ; Following vanilla's system, Golem/Dog would arguably be the only ; valid animation to choose, so we'd want to fall back to that. lda $fe ; Golem/Dog blockage flags ; we know conditions #3 and #4 above were met. ; result of the "beq" right below will tell us ; whether #1 and #2 had been as well. ; If combining with a patch that actually lets animation-less gear ; (and character base Evade/MBlock) be represented (by a plain ; "Miss") alongside animation-having gear, it definitely gets a ; seat at the table here as well. Thus, we don't care about this ; special case, and should chuck the past 2 instructions. ; They can also be tossed if our interpretation/philosophy: ; - Sees the 50/50 fork between guardian and gear crediting as ; fixed, and not contingent on options within the latter. ; - Sees the plain "Miss" animation as simply a default _within_ ; the gear category, and not purely an absolute-last-resort ; default. beq skip ; branch if no active/relevant dodge flags in A chooseEligAnim: jsr $522a ; Pick a random bit that is set cmp #$20 bcc proceed ; branch if Dog/Golem not chosen pha ; but if one of those WAS chosen, undo any Image removal flagging done by ; our simulated hit determination call, because we're not considering ; Image status as responsible for the dodge in the first place! ; ; (maybe for purity, i should also be testing whether ; fictional_sanitized_22FB was called in the first place and that it ; produced a Miss, as the following code is unnecessary otherwise. ; however, it should also be harmless, and adding the proposed test(s) ; would need RAM storage.) lda backupStatus1 ora #$FB and $3dfd,y ; A = $3DFD,Y AND (backupStatus1 OR FBh). simplification of ; ($3DFD,Y AND FBh) OR (backupStatus1 AND 04h AND $3DFD,Y). ; that is, deduct Image from Statuses to Clear unless it was ; set before our above simulated hit determination call. sta $3dfd,y ; save Statuses to Clear, byte 1 pla proceed: ... skip: