; ---- everything before this same as first variety. as is ------- ; ---- everything through next dotted line, but just shown for context. -------- 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 ; ------- changes start here ---------- lda $ee trb $eb ; would_be_perm AND NOT(blocked) AND NOT(would_be_perm AND had) 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 NOT(blocked) AND NOT(would_be_perm AND had)) ; OR ((blocked AND had) OR (would_be_perm AND had)) ; wtf is that?! it actually simplifies to the intended: ; (had AND blocked) OR (would_be_perm AND NOT(blocked)) ; i can't prove that without a ton of lines, so verify with a ; truth table. okay, two tips for the curious. show that: ; 1. (a AND NOT(b) AND NOT(c)) OR (x OR c) = ; (a AND NOT(b)) OR (x OR c) ; 2. (would_be_perm AND NOT(blocked)) OR (blocked AND had) ; already contains a (would_be_perm AND had). ; more straightforward yet longer code would have a "STA $F0" ; (or whatever free variable) right after the above "STA $EE", ; then use $F0 instead of $EE for the two modifications to $EB. ; anyway, Variable $EB is our mirror-status-immunity inducers ; 43 bytes for this chunk jsr add_mirrors ; need to move the below or above instruction into this function ; for space reasons. move the one with the one-line comment! lda $ee ; get list of intended blocked statuses (bytes 2 and 3) ; ------- everything after this same as in first variety, but likely -------- ; ------- shifted forward 2 bytes. ------------