hirom header org $C22675 LDA $3EBB AND #$04 ; are we in Phunbaba battle #4? (iow, Terra's ; second Phunbaba meeting) ASL ASL ; get that into Bit 4, for now PHA LDA $3C6D,X ; monster/equip status byte 3 LSR ; put perm-Float (aka Dance) into Carry PLA ROR ; Bit 7 = 1 if perm-Float (aka Dance) was set, ; 0 otherwise. ; Bit 3 = 1 if in Phunbaba battle #4, 0 if not AND $3EF9,X ; only try to lock in indicated Morph or Float ; statuses if they're actually possessed. EOR #$FF AND $3331,X ; add statuses that passed both tests to blockages. STA $3331,X ; update blocked status byte 4. note that blocked ; statuses = 0, susceptible ones = 1 ; 25 bytes versus 29 bytes original, despite added possessed ; statuses check. not bad. lda $3ef8,x ; status byte 3 pha lda $3ee5,x ; status byte 2 pha LDA $3330,X XBA LDA $331D,X ; A.top=blocked status byte 3, A.btm=blocked status #2 REP #$20 ; Set 16-bit Accumulator EOR #$FFFF ; make it so blocked statuses = 1, and vulnerable statuses = 0. ; i find this more intuitive to work with, and it doesn't take ; any more bytes overall. will toggle back later. STA $EE ; starting list of intended blocked statuses, bytes 2 and 3. LDA $3C6C,X ; monster/equip status bytes 2-3 AND #$EE78 ; Dance, Stop, Sleep, Condemned, Near Fatal, Image will all be 0 sta $eb ; save would-be permanent statuses and $01,s ; if any of these are also possessed... tsb $ee ; ...add them to list of intended blockages pla ; retrieve possessed statuses, bytes 2 and 3 and $ee ; ((would_be_perm AND had) OR blocked) AND had ; = (would_be_perm AND had) OR (blocked AND had) tsb $eb ; ((would_be_perm AND had) OR (blocked AND had)) OR would_be_perm ; = would_be_perm OR (blocked AND had) ; this variable is our mirror-status-immunity inducers ; 39 bytes for this chunk jsr add_mirrors lda $ee ; get list of intended blocked statuses (bytes 2 and 3) eor #$FFFF ; go back to game's format of blocked statuses = 0 and ; susceptible statuses = 1 sep #$20 sta $331d,x ; update blocked status byte #2 xba sta $3330,x ; update blocked status byte #3 rts ; this little chunk is 18 bytes nop rts ; ------------------ org $C2???? add_mirrors: lda $eb ; get our list of mirror-status-immunity inducers, ; would_be_perm OR (blocked AND had) and #$0c00 beq skip_it ; branch if neither Haste nor Slow in there toggle: eor #$0c00 beq toggle ; if our AND produced 0C00h, make it so again tsb $ee ; for either status present in the mirror-status-immunity ; inducers, add its mirror to intended blocked statuses skip_it: ; above 14 bytes equivalent to following 16 bytes of code: ; lda $eb ; and #$0400 ; asl ; tsb $ee ; ; lda $eb ; and #$0800 ; lsr ; tsb $ee lda $eb ; get our list of mirror-status-immunity inducers, ; would_be_perm OR (blocked AND had) and #$0240 beq skip_it2 ; branch if neither Regen nor Seizure in there toggle2: eor #$0240 beq toggle2 ; if our AND produced 0240h, make it so again tsb $ee ; for either status present in the mirror-status-immunity ; inducers, add its mirror to intended blocked statuses skip_it2: ; above 14 bytes equivalent to following 20 bytes of code: ; lda $eb ; and #$0200 ; lsr ; lsr ; lsr ; tsb $ee ; ; lda $eb ; and #$0040 ; asl ; asl ; asl ; tsb $ee rts ; total for function = 29 bytes ; ------------------ ; (grand total = 25 + 39 + 3 + 15 + 29 = 111 bytes . ; compare to 84 bytes original.)