Final Fantasy VI:ROM map/Assembly C25: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
mNo edit summary
Line 1: Line 1:
{{subpage|game=Final Fantasy VI:ROM map}}
==C2/500B set regen,poison,seizure or phantasm damage==
==C2/500B set regen,poison,seizure or phantasm damage==
:check if monsters are alive
:check if monsters are alive

Latest revision as of 19:12, 21 June 2016

C2/500B set regen,poison,seizure or phantasm damage

check if monsters are alive
C2/500B AD 77 3A       LDA $3A77       number of monsters alive
C2/500E F0 CF          BEQ $4FDF       exit if no monsters are alive
allows new queue for this entity
C2/5010 B9 A1 3A       LDA $3AA1,Y     
C2/5013 29 EF          AND #$EF        clear bit 4
C2/5015 99 A1 3A       STA $3AA1,Y
check if enemies are present?
C2/5018 B9 A0 3A       LDA $3AA0,Y
C2/501B 89 10          BIT #$10
C2/501D D0 C0          BNE $4FDF       exit
setup attack data
C2/501F 20 8A 29       JSR $298A       init attack data
C2/5022 A9 90          LDA #$90
C2/5024 14 B3          TRB $B3         set ignore clear and allow damage increment
C2/5026 A9 12          LDA #$12        mimic command
C2/5028 85 B5          STA $B5         set command
C2/502A A9 68          LDA #$68
C2/502C 8D A2 11       STA $11A2       set: ignore defense, no split damage, reverse damage on undead
adjust attack data for regen attack or poison,seizure,phantasm attack
C2/502F 4E A4 11       LSR $11A4       shift bits for later addition
C2/5032 A5 B6          LDA $B6         (#$02=regen, #$04=poison,#$40=seizure or phantasm)
C2/5034 4A             LSR
C2/5035 4A             LSR             is it poison?
C2/5036 2E A4 11       ROL $11A4       set to heal for regen; damage for poison, seizure, phantasm
C2/5039 4A             LSR
C2/503A 90 15          BCC $5051       Branch if not poison
calculate damage increment for poison
C2/503C B9 24 3E       LDA $3E24,Y     amount to increment damage
C2/503F 85 BD          STA $BD
C2/5041 1A             INC
C2/5042 1A             INC
C2/5043 C9 0F          CMP #$0F        maximum damage increment
C2/5045 90 02          BCC $5049       don't cap if under 15
C2/5047 A9 0E          LDA #$0E
C2/5049 99 24 3E       STA $3E24,Y     cap to 15
set damage as poison type
C2/504C A9 08          LDA #$08
C2/504E 8D A1 11       STA $11A1       set element as poison
calculate damage
C2/5051 B9 40 3B       LDA $3B40,Y     stamina
C2/5054 85 E8          STA $E8
C2/5056 C2 20          REP #$20        set 16-bit A
C2/5058 B9 1C 3C       LDA $3C1C,Y     max HP
C2/505B 20 B7 47       JSR $47B7       A = (max HP * stamina / 256)
C2/505E 4A             LSR
C2/505F 4A             LSR             A = A / 4
C2/5060 C9 FE          CMP #$00FE      is damage under 254?
C2/5063 E2 20          SEP #$20        set 8-bit A
C2/5065 90 02          BCC $5069       don't cap if under 254
C2/5067 A9 FC          LDA #$FC        cap damage to 253
C2/5069 69 02          ADC #$02
C2/506B 8D A6 11       STA $11A6       store damage
C2/506E BB             TYX
C2/506F 4C 67 31       JMP $3167       execute regen,poison,seizure,phantasm hit

C2/5072 monster script #$F2

Monster command script command #$F2
($B8 and bottom 7 bits of $B9 = new formation to change to)
C2/5072: A5 B8        LDA $B8     (Byte 2)
C2/5074: 8D E0 11     STA $11E0   (Monster formation, byte 1)
C2/5077: 0E 47 3A     ASL $3A47
C2/507A: A5 B9        LDA $B9     (Byte 3.  top bit: 0 = monsters get Max HP.  1 = retain HP and
                                   Max HP from current formation.)
C2/507C: 49 80        EOR #$80
C2/507E: 0A           ASL 
C2/507F: 6E 47 3A     ROR $3A47
C2/5082: 4A           LSR 
C2/5083: 8D E1 11     STA $11E1   (Monster formation, byte 2)
C2/5086: 20 E8 30     JSR $30E8
C2/5089: C2 20        REP #$20    (Set 16-bit Accumulator)
C2/508B: A2 0A        LDX #$0A
C2/508D: 9E A8 3A     STZ $3AA8,X  (clear enemy presence flag)
C2/5090: 9E 54 3E     STZ $3E54,X
C2/5093: 7B           TDC 
C2/5094: 3A           DEC 
C2/5095: 9D 01 20     STA $2001,X  (save FFFFh [null] as enemy #)
C2/5098: A9 BC FF     LDA #$FFBC
C2/509A: 9D 0C 32     STA $320C,X  (aka $3204,X)
C2/509E: CA           DEX 
C2/509F: CA           DEX 
C2/50A0: 10 EB        BPL $508D    (loop for all 6 enemies)
C2/50A2: E2 20        SEP #$20     (Set 8-bit Accumulator)
C2/50A4: 20 E1 2E     JSR $2EE1
C2/50A7: 20 91 43     JSR $4391
C2/50AA: 20 9B 06     JSR $069B
C2/50AD: 20 3F 08     JSR $083F
C2/50B0: 20 B9 4A     JSR $4AB9
C2/50B3: 20 C9 26     JSR $26C9
C2/50B6: 20 3A 2E     JSR $2E3A
C2/50B9: AD 75 3A     LDA $3A75
C2/50BC: 8D 2B 3A     STA $3A2B
C2/50BF: AD 1E 20     LDA $201E
C2/50C2: 8D 2A 3A     STA $3A2A
C2/50C5: A5 B6        LDA $B6
C2/50C7: EB           XBA 
C2/50C8: A9 12        LDA #$12
C2/50CA: 4C BF 62     JMP $62BF

C2/50CD command #$25

C2/50CD: A9 02        LDA #$02
C2/50CF: 80 02        BRA $50D3
C2/50D1: A9 10        LDA #$10    (Command #$21 - F3 Command script enters here)
C2/50D3: EB           XBA 
C2/50D4: A5 B6        LDA $B6
C2/50D6: EB           XBA 
C2/50D7: 9C 2A 3A     STZ $3A2A   (Sets final damage to 0)
C2/50DA: 4C BF 62     JMP $62BF

C2/50DD command 27: display scan info

C2/50DD: A6 B6        LDX $B6
C2/50DF: A9 FF        LDA #$FF
C2/50E1: 8D 72 2D     STA $2D72
C2/50E4: A9 02        LDA #$02
C2/50E6: 8D 6E 2D     STA $2D6E
C2/50E9: 9C 36 2F     STZ $2F36
C2/50EC: 9C 37 2F     STZ $2F37
C2/50EF: 9C 3A 2F     STZ $2F3A
C2/50F2: BD 18 3B     LDA $3B18,X  (Level)
C2/50F5: 8D 35 2F     STA $2F35
C2/50F8: A9 34        LDA #$34
C2/50FA: 8D 6F 2D     STA $2D6F
C2/50FD: A9 04        LDA #$04
C2/50FF: 20 11 64     JSR $6411
C2/5102: C2 20        REP #$20
C2/5104: BD F4 3B     LDA $3BF4,X  (Current HP)
C2/5107: 8D 35 2F     STA $2F35
C2/510A: BD 1C 3C     LDA $3C1C,X  (Max HP)
C2/510D: 8D 38 2F     STA $2F38
C2/5110: E2 20        SEP #$20
C2/5112: A9 30        LDA #$30
C2/5114: 8D 6F 2D     STA $2D6F
C2/5117: A9 04        LDA #$04
C2/5119: 20 11 64     JSR $6411
C2/511C: C2 20        REP #$20
C2/511E: BD 08 3C     LDA $3C08,X  (Current MP)
C2/5121: 8D 35 2F     STA $2F35
C2/5124: BD 30 3C     LDA $3C30,X  (Max MP)
C2/5127: 8D 38 2F     STA $2F38
C2/512A: E2 20        SEP #$20
C2/512C: F0 0A        BEQ $5138
C2/512E: A9 31        LDA #$31
C2/5130: 8D 6F 2D     STA $2D6F
C2/5133: A9 04        LDA #$04
C2/5135: 20 11 64     JSR $6411
C2/5138: A9 15        LDA #$15
C2/513A: 8D 6F 2D     STA $2D6F
C2/513D: BD E0 3B     LDA $3BE0,X   
C2/5140: 85 EE        STA $EE      (Weak elements)
C2/5142: BD E1 3B     LDA $3BE1,X
C2/5145: 1D CC 3B     ORA $3BCC,X
C2/5148: 1D CD 3B     ORA $3BCD,X   
C2/514B: 14 EE        TRB $EE      (subtract Absorbed, Nullified, and Resisted
                                    elements, because those supercede weaknesses)
C2/514D: A9 01        LDA #$01
C2/514F: 24 EE        BIT $EE
C2/5151: F0 07        BEQ $515A    (branch if not weak to current element)
C2/5153: 48           PHA 
C2/5154: A9 04        LDA #$04
C2/5156: 20 11 64     JSR $6411
C2/5159: 68           PLA 
C2/515A: EE 6F 2D     INC $2D6F    (point to next element name)
C2/515D: 0A           ASL          (look at next elemental bit)
C2/515E: 90 EF        BCC $514F    (loop 8 times, as there's 8 elements)
C2/5160: 60           RTS 

C2/5161 check and remove status based on time

Remove Stop, Reflect, Freeze, or Sleep when time is up
C2/5161: AE 7D 3A     LDX $3A7D
C2/5164: 20 8A 29     JSR $298A   (Clear special effect, magic power, etc.)
C2/5167: A9 12        LDA #$12
C2/5169: 85 B5        STA $B5     (Set command to Mimic)
C2/516B: A9 10        LDA #$10
C2/516D: 14 B0        TRB $B0
C2/516F: 46 B8        LSR $B8
C2/5171: 90 05        BCC $5178   (Branch if bit 0 of $B8 is 0)
C2/5173: A9 10        LDA #$10
C2/5175: 0C AC 11     TSB $11AC   (Attack clears Stop)
C2/5178: 46 B8        LSR $B8
C2/517A: 90 05        BCC $5181   (Branch if bit 1 of $B8 is 0)
C2/517C: A9 80        LDA #$80
C2/517E: 0C AC 11     TSB $11AC   (Attack clears Reflect)
C2/5181: 46 B8        LSR $B8
C2/5183: 90 05        BCC $518A   (Branch if bit 2 of $B8 is 0)
C2/5185: A9 02        LDA #$02
C2/5187: 0C AD 11     TSB $11AD   (Attack clears Freeze)
C2/518A: 46 B8        LSR $B8
C2/518C: 90 12        BCC $51A0   (Branch if bit 3 of $B8 is 0)
C2/518E: A9 80        LDA #$80
C2/5190: 3D E5 3E     AND $3EE5,X
C2/5193: F0 0B        BEQ $51A0   (Branch if not sleeping)
C2/5195: 0C AB 11     TSB $11AB   (Attack clears Sleep)
C2/5198: A9 02        LDA #$02
C2/519A: 85 B5        STA $B5     (Set command to Magic)
C2/519C: A9 78        LDA #$78
C2/519E: 85 B6        STA $B6     (Set spell to Tapir.  Note this does *not*
                                   use the spell _data_ of the Tapir from Mog's
                                   dance, so it won't have the same effect)
C2/51A0: A9 04        LDA #$04
C2/51A2: 0C A4 11     TSB $11A4   (Set to lift statuses)
C2/51A5: 4C 67 31     JMP $3167

C2/51A8 command 2C

C2/51A8: AD 7D 3A     LDA $3A7D    
C2/51AB: 4A           LSR 
C2/51AC: EB           XBA 
C2/51AD: A9 0E        LDA #$0E
C2/51AF: 4C BF 62     JMP $62BF

C2/51B2 command 2D: drain from being seized

C2/51B2: B9 A1 3A     LDA $3AA1,Y
C2/51B5: 29 EF        AND #$EF
C2/51B7: 99 A1 3A     STA $3AA1,Y (Clear bit 4 of $3AA1,Y)
C2/51BA: BB           TYX 
C2/51BB: 20 8A 29     JSR $298A   (Clear special effect, magic power, etc.)
C2/51BE: 9C AE 11     STZ $11AE   (Set Magic Power to 0)
C2/51C1: A9 10        LDA #$10
C2/51C3: 8D AF 11     STA $11AF   (Set Level to 16)
C2/51C6: 8D A6 11     STA $11A6   (Set Spell Power to 16)
C2/51C9: A9 28        LDA #$28
C2/51CB: 8D A2 11     STA $11A2   (Sets to only ignore defense, heal undead)
C2/51CE: A9 02        LDA #$02
C2/51D0: 8D A3 11     STA $11A3   (Sets to Not reflectable only)
C2/51D3: 0C A4 11     TSB $11A4   (Sets Redirection)
C2/51D6: 0C 46 3A     TSB $3A46   (set flag to let this attack target a Seized
                                   entity, who is normally untargetable)
C2/51D9: A9 80        LDA #$80
C2/51DB: 14 B2        TRB $B2     (Indicate a special type of drainage.  Normal drain
                                   is capped at the lowest of: drainee's Current HP/MP
                                   and drainer's Max - Current HP/MP.  This one will
                                   ignore the latter, meaning it's effectively just a
                                   damage attack if the drainer's [or undead target's]
                                   HP/MP is full.)
C2/51DD: A9 12        LDA #$12
C2/51DF: 85 B5        STA $B5     (Sets command to Mimic)
C2/51E1: 4C 7B 31     JMP $317B

C2/51E4 pointers: command F5

C2/51E4: E0 4F
C2/51E6: CB 4F
C2/51E8: EC 4F
C2/51EA: CE 4F
C2/51EC: C2 4F
C2/51EE: FF 4F

C2/51F0 unknow

X = Highest bit in A that is 1 (bit 0 = 0, 1 = 1, etc.)
C2/51F0: A2 00        LDX #$00
C2/51F2: 4A           LSR
C2/51F3: F0 03        BEQ $51F8   (Exit if all bits are 0)
C2/51F5: E8           INX 
C2/51F6: 80 FA        BRA $51F2
C2/51F8: 60           RTS 

C2/51F9 unknow

Y = (Number of highest target set in A) * 2
    (0, 2, 4, or 6 for characters.  8, 10, 12, 14, 16, or 18 for monsters.)

    (Remember that
     $3018 : Holds $01 for character 1, $02 for character 2, $04 for character 3,
             $08 for character 4
     $3019 : Holds $01 for monster 1, $02 for monster 2, etc.  )
C2/51F9: DA           PHX
C2/51FA: 08           PHP 
C2/51FB: C2 20        REP #$20    (Set 16-bit Accumulator)
C2/51FD: E2 10        SEP #$10    (Set 8-bit Index Registers)
C2/51FF: A2 12        LDX #$12
C2/5201: 3C 18 30     BIT $3018,X
C2/5204: D0 04        BNE $520A   (Exit loop if bit set)
C2/5206: CA           DEX 
C2/5207: CA           DEX 
C2/5208: 10 F7        BPL $5201   (loop through all 10 targets if necessary)
C2/520A: 9B           TXY 
C2/520B: 28           PLP 
C2/520C: FA           PLX 
C2/520D: 60           RTS 

C2/520E math: X = number of bits of A

Sets X to number of bits set in A
C2/520E: A2 00        LDX #$00
C2/5210: 4A           LSR 
C2/5211: 90 01        BCC $5214
C2/5213: E8           INX 
C2/5214: D0 FA        BNE $5210
C2/5216: 60           RTS 

C2/5217 math: division by 8

X = A / 8  (including carry, so A is effectively 9 bits)
A = 1 if (A % 8) = 0, 2 if (A % 8) = 1, 4 if (A % 8) = 2,
    8 if (A % 8) = 3, 16 if (A % 8) = 4, etc.
Carry flag = cleared

C2/5217: 5A           PHY
C2/5218: 48           PHA 
C2/5219: 6A           ROR 
C2/521A: 4A           LSR 
C2/521B: 4A           LSR 
C2/521C: AA           TAX 
C2/521D: 68           PLA 
C2/521E: 29 07        AND #$07
C2/5220: A8           TAY 
C2/5221: A9 00        LDA #$00
C2/5223: 38           SEC 
C2/5224: 2A           ROL 
C2/5225: 88           DEY 
C2/5226: 10 FC        BPL $5224
C2/5228: 7A           PLY 
C2/5229: 60           RTS 

C2/522A randomly picks a bit set in A

C2/522A: 5A           PHY
C2/522B: 08           PHP 
C2/522C: C2 20        REP #$20    (Set 16-bit Accumulator)
C2/522E: 85 EE        STA $EE
C2/5230: 20 0E 52     JSR $520E   (X = number of bits set in A)
C2/5233: 8A           TXA 
C2/5234: F0 0E        BEQ $5244   (Exit if no bits set)
C2/5236: 20 65 4B     JSR $4B65   (0 to A - 1)
C2/5239: AA           TAX 
C2/523A: 38           SEC 
C2/523B: 7B           TDC 
C2/523C: 2A           ROL 
C2/523D: 24 EE        BIT $EE
C2/523F: F0 FB        BEQ $523C
C2/5241: CA           DEX 
C2/5242: 10 F8        BPL $523C
C2/5244: 28           PLP 
C2/5245: 7A           PLY 
C2/5246: 60           RTS 

C2/5247 set front, back, pincer or side attack

(Determine if front, back, pincer, or side attack)
 (X = #$10 when called for choosing type of attack formation)
 (A = Which types to allow, bit 7 = side, 6 = pincer, 5 = back, 4 = normal/front)
 (Returns attack formation in X: 0 = Front/Normal, 1 = Back, 2 = Pincer, 3 = Side)
(Also used for determining which attack Umaro should use)
 (X = #$00 for no Rage Ring or Blizzard Orb, #$04 for Rage Ring, #$08 for Blizzard Orb,
      #$0C for both)
 (A = Which attacks to allow, bit 7 = Normal attack, 6 = Charge/Tackle, 5 = Storm,
      4 = Throw character.  Bits 6 and 7 are always set by caller.  Note that masking
      in A is unneeded [it could very well have all bits set] because the 4 different
      data structures at C2/5269 will exclude certain attacks by having FFh
      [read: 00h] for them.)
 (Returns Umaro attack type in X: 0 = Throw character, 1 = Storm, 2 = Charge/Tackle,
  3 = Normal attack)
C2/5247: 5A           PHY
C2/5248: EB           XBA 
C2/5249: A9 00        LDA #$00
C2/524B: A0 03        LDY #$03
C2/524D: EB           XBA 
C2/524E: 0A           ASL 
C2/524F: EB           XBA 
C2/5250: 90 04        BCC $5256     (Branch if type not allowed)
C2/5252: 7F 69 52 C2  ADC $C25269,X (Add chance to get that type.  note
                                     that Carry is always set going into
                                     this instruction.)
C2/5256: 99 FC 00     STA $00FC,Y  (build an array that determines which ranges
                                    of random numbers will result in which
                                    Umaro attacks or Battle formations)
C2/5259: E8           INX 
C2/525A: 88           DEY 
C2/525B: 10 F0        BPL $524D   (Check for all 4 types)
C2/525D: 20 65 4B     JSR $4B65   (random #: 0 to A - 1 , where A is
                                   the denominator of our probabilities,
                                   as explained in the data below.)
C2/5260: A2 04        LDX #$04
C2/5262: CA           DEX 
C2/5263: D5 FC        CMP $FC,X
C2/5265: B0 FB        BCS $5262   (Check next type if A >= $FC,X)
C2/5267: 7A           PLY 
C2/5268: 60           RTS         (Return X = Battle type / Attack to use)

C2/5269 data: chance of Umaro's attacks

(NOTE: Carry is always set when accessing the data at C2/5269 through
 C2/527C, so effective values are all 1 greater than those listed below
 [with FFh wrapping to 00h].  This is quite deliberate, as the sum of
 the values must fit in a single byte.)
(Each effective value is the Numerator of the probability of getting a
 certain type of Umaro attack, in the order: Normal attack, Charge/Tackle,
 Storm, Throw character)
(Denominator of the probability is the sum of the effective values.)
C2/5269: 9E 5F FF FF    (No Rage Ring or Blizzard Orb)
C2/526D: 5E 3F FF 5F    (Rage Ring)
C2/5271: 5E 3F 5F FF    (Blizzard Orb)
C2/5275: 3E 3F 3F 3F    (Both)

C2/5279 data: chance of type of encounter

(Each effective value is the Numerator of probability of getting a
 certain type of attack formation, in the order: Side, Pincer,
 Back, Normal/Front)
(Denominator of the probability is the sum of the effective values,
 excluding those of formations that were skipped at C2/5250 due
 to not being allowed.)
C2/5279: 1E 07 07 CF    (For choosing type of battle)

C2/527D enable or disable commands

(Gray out or enable character commands based on various criteria, such as: whether
 current equipment supports them, whether the character is inflicted with Imp or
 Mute, and whether they've accumulated enough Magic Points to Morph.
 This function also enables Offering to change the aiming of Fight and Capture.)
C2/527D: DA           PHX
C2/527E: 08           PHP
C2/527F: C2 30        REP #$30       (Set 16-bit A, X and Y)
C2/5281: 9B           TXY
C2/5282: BF 4A 54 C2  LDA $C2544A,X  (Get address of character's menu)
C2/5286: AA           TAX 
C2/5287: E2 20        SEP #$20       (Set 8-bit Accumulator)
C2/5289: B9 18 30     LDA $3018,Y
C2/528C: 0C 58 3A     TSB $3A58      (flag this character's main menu to be redrawn
                                      right away)
C2/528F: B9 E4 3E     LDA $3EE4,Y
C2/5292: 29 20        AND #$20
C2/5294: 85 EF        STA $EF        (if Imp status possessed, turn on Bit 5 of $EF.
                                      if not, the variable is set to 0.)
C2/5296: B9 A4 3B     LDA $3BA4,Y    (weapon properties, right hand)
C2/5299: 19 A5 3B     ORA $3BA5,Y    (merge with weapon properties, left hand)
C2/529C: 49 FF        EOR #$FF       (invert)
C2/529E: 29 82        AND #$82
C2/52A0: 04 EF        TSB $EF        (if neither hand supports Runic, set Bit 7.
                                      if neither hand supports SwdTech, set Bit 1.)
C2/52A2: A9 04        LDA #$04
C2/52A4: 85 EE        STA $EE        (counter variable.. we're going to check
                                      4 menu slots in all)
C2/52A6: DA           PHX            (push address of character's current menu slot)
C2/52A7: 38           SEC            (mark menu slot to be disabled)
C2/52A8: 7B           TDC            (clear 16-bit A)
C2/52A9: BD 00 00     LDA $0000,X    (get command # in current menu slot)
C2/52AC: 30 2D        BMI $52DB      (branch if slot empty)
C2/52AE: 48           PHA            (push command #)
C2/52AF: 18           CLC            (mark menu slot to be enabled)
C2/52B0: A5 EF        LDA $EF
C2/52B2: 89 20        BIT #$20       (are they an Imp?)
C2/52B4: F0 0D        BEQ $52C3      (branch if not)
C2/52B6: A3 01        LDA $01,S    
C2/52B8: 0A           ASL            (command # * 2)
C2/52B9: AA           TAX  
C2/52BA: BF 00 FE CF  LDA $CFFE00,X  (table of command info)
C2/52BE: 89 04        BIT #$04       (is command supported while Imped?)
C2/52C0: D0 01        BNE $52C3      (branch if so)
C2/52C2: 38           SEC            (mark menu slot to be disabled)
C2/52C3: 68           PLA            (fetch command #)
C2/52C4: B0 15        BCS $52DB      (if menu slot is disabled at this point,
                                      don't bother with our next checks)

(This next loop sees if our current command is one that needs special code to assess
 its menu availability -- graying it if unavailable -- or another property, such as
 its aiming.  If so, a special function is called for the command.)

C2/52C6: A2 07 00     LDX #$0007
C2/52C9: DF E9 52 C2  CMP $C252E9,X  (does our current command match one whose menu
                                      availability or aiming can vary?)
C2/52CD: D0 08        BNE $52D7      (if not, compare it to next command in table)
C2/52CF: 8A           TXA 
C2/52D0: 0A           ASL 
C2/52D1: AA           TAX 
C2/52D2: FC F1 52     JSR ($52F1,X)  (call special function for command)
C2/52D5: 80 04        BRA $52DB      (we've gotten a match, so there's no need to
                                      compare our current command against rest of list)
C2/52D7: CA           DEX 
C2/52D8: 10 EF        BPL $52C9      (there are 8 possible commands that need
                                      special checks)
C2/52DA: 18           CLC            (if there was no match, default to enabling the
                                      menu slot)
C2/52DB: FA           PLX 
C2/52DC: 7E 01 00     ROR $0001,X    (2nd byte of current menu slot will have Bit 7 set
                                      if the slot should be grayed out and unavailable.
                                      iow, Carry = 1 -> grayed.  Carry = 0 -> enabled.)

C2/52DF: E8           INX 
C2/52E0: E8           INX 
C2/52E1: E8           INX            (point to next slot in character's menu)
C2/52E2: C6 EE        DEC $EE
C2/52E4: D0 C0        BNE $52A6      (repeat process for all 4 menu slots)
C2/52E6: 28           PLP 
C2/52E7: FA           PLX 
C2/52E8: 60           RTS 

C2/52E9 data: commands to check for disabling

(Data - commands that can potentially get grayed out on the menu in battle,
 or have a property like their aiming altered.)
C2/52E9: 03    (Morph)
C2/52EA: 0B    (Runic)
C2/52EB: 07    (SwdTech)
C2/52EC: 0C    (Lore)
C2/52ED: 17    (X-Magic)
C2/52EE: 02    (Magic)
C2/52EF: 06    (Capture)
C2/52F0: 00    (Fight)

C2/52F1 data: commands to check for alteration

(Data - addresses of functions to check whether above command should be
 enabled, disabled, or otherwise modified on battle menu)
C2/52F1: 26 53   (Morph)
C2/52F3: 22 53   (Runic)
C2/52F5: 1D 53   (SwdTech)
C2/52F7: 14 53   (Lore)
C2/52F9: 14 53   (X-Magic)
C2/52FB: 14 53   (Magic)
C2/52FD: 01 53   (Capture)
C2/52FF: 01 53   (Fight)

C2/5301 capture and fight adjustments

(For Capture and Fight menu slots)
C2/5301: B9 58 3C     LDA $3C58,Y (Check for offering)
C2/5304: 4A           LSR 
C2/5305: 90 0C        BCC $5313   (Exit if no Offering)
C2/5307: C2 21        REP #$21    (Set 16-bit Accumulator.  Clear Carry to enable
                                   menu slot.)
C2/5309: A3 03        LDA $03,S   
C2/530B: AA           TAX         (get address of character's current menu slot)
C2/530C: E2 20        SEP #$20    (Set 8-bit Accumulator)
C2/530E: A9 4E        LDA #$4E
C2/5310: 9D 02 00     STA $0002,X (update aiming byte: Cursor start on enemy,
                                   Auto select one party, Auto select both parties
                                   [in this case, that means you'll target both enemy
                                    clumps in a Pincer], and One side only.)
C2/5313: 60           RTS 

C2/5314 lore, magic and x-magic adjustments

(For Lore, X-Magic, and Magic menu slots)
C2/5314: B9 E5 3E     LDA $3EE5,Y
C2/5317: 89 08        BIT #$08     (is character Muted?)
C2/5319: F0 01        BEQ $531C    (branch if not)
C2/531B: 38           SEC          (if they are, mark menu slot to be disabled?)
C2/531C: 60           RTS 

C2/531D sword tech adjustments

(For SwdTech menu slot)
C2/531D: A5 EF        LDA $EF
C2/531F: 4A           LSR 
C2/5320: 4A           LSR          (Carry = Bit 1, which was set in function C2/527D)
C2/5321: 60           RTS          (if it was set, menu slot will be disabled..
                                    if it wasn't, slot is enabled)

C2/5322 runic adjustments

(For Runic menu slot)
C2/5322: A5 EF        LDA $EF
C2/5324: 0A           ASL          (Carry = Bit 7, which was set in function C2/527D)
C2/5325: 60           RTS          (if it was set, menu slot will be disabled..
                                    if it wasn't, slot is enabled)

C2/5326 morph adjustments

(For Morph menu slot)
C2/5326: A9 0F        LDA #$0F
C2/5328: CD F6 1C     CMP $1CF6    (compare to Morph supply)
C2/532B: 60           RTS          (if Morph supply isn't at least 16, menu slot will
                                    be disabled..  if it's >=16, slot is enabled)

C2/532C change commands before battle

(Change character commands when wearing MagiTek armor or visiting Fanatics' Tower.
 Change commands based on relics, such as Fight becoming Jump, or Steal becoming Capture.
 Blank or retain certain commands, depending on whether they should be available -- e.g.
   no known dances means no Dance command.)
(Zero character MP if they have no Lore command, no Magic/X-Magic with at least one spell
   learned, and no Magic/X-Magic with an Esper equipped.)
C2/532C: DA           PHX
C2/532D: 08           PHP 
C2/532E: C2 30        REP #$30       (Set 16-bit A, X, and Y)
C2/5330: BC 10 30     LDY $3010,X    (get offset to character info block)
C2/5333: BF 4A 54 C2  LDA $C2544A,X  (get address of character's menu)
C2/5337: 8F 81 21 00  STA $002181    (this means that future writes to $00218n in this function
                                      will modify that character's menu?)
C2/533B: B9 16 16     LDA $1616,Y   (1st and 2nd menu slots)
C2/533E: 85 FC        STA $FC
C2/5340: B9 18 16     LDA $1618,Y   (3rd and 4th menu slots)
C2/5343: 85 FE        STA $FE
C2/5345: B9 14 16     LDA $1614,Y   (out of battle Status Bytes 1 and 2; correspond
                                     to in-battle Status Bytes 1 and 4)
C2/5348: E2 30        SEP #$30      (Set 8-bit A, X, and Y)
C2/534A: 89 08        BIT #$08      (does character have MagiTek?)
C2/534C: D0 06        BNE $5354     (branch if so)
C2/534E: AD BB 3E     LDA $3EBB     (Fanatics' Tower?  must verify this.)
C2/5351: 4A           LSR 
C2/5352: 90 49        BCC $539D     (branch if neither MagiTek nor Fanatics' Tower)
C2/5354: BD D8 3E     LDA $3ED8,X   (get character index)
C2/5357: EB           XBA 
C2/5358: A2 03        LDX #$03      (point to 4th menu slot)
C2/535A: B5 FC        LDA $FC,X     (get command in menu slot)
C2/535C: C9 01        CMP #$01
C2/535E: F0 3A        BEQ $539A     (if Item, skip to next slot)
C2/5360: C9 12        CMP #$12
C2/5362: F0 36        BEQ $539A     (if Mimic, skip to next slot)
C2/5364: EB           XBA           (retrieve character index)
C2/5365: C9 0B        CMP #$0B
C2/5367: D0 08        BNE $5371     (branch if not Gau)
C2/5369: EB           XBA           (get command again)
C2/536A: C9 10        CMP #$10
C2/536C: D0 02        BNE $5370     (branch if not Rage)
C2/536E: A9 00        LDA #$00      (load Fight command into A so that Gau's Rage will get replaced
                                     by MagiTek too.  why not just replace "BNE $5370 / LDA #$00"
                                     with "BEQ formerly_$5376" ??  you got me..)
C2/5370: EB           XBA 
C2/5371: EB           XBA           (once more, command is in bottom of A, character index in top)
C2/5372: C9 00        CMP #$00      (Fight?)
C2/5374: D0 04        BNE $537A     (branch if not.  if it is Fight, we'll replace it with MagiTek)
C2/5376: A9 1D        LDA #$1D       
C2/5378: 80 06        BRA $5380     (go store MagiTek command in menu slot)
C2/537A: C9 02        CMP #$02
C2/537C: F0 02        BEQ $5380     (if Magic, branch..  which just keeps Magic as command?
                                     rewriting it seems inefficient, unless i'm missing
C2/537E: A9 FF        LDA #$FF      (empty command)
C2/5380: 95 FC        STA $FC,X     (update this menu slot)
C2/5382: AD BB 3E     LDA $3EBB     (Fanatics' Tower?  must verify this.)
C2/5385: 4A           LSR 
C2/5386: 90 12        BCC $539A     (branch if not in the tower)
C2/5388: B5 FC        LDA $FC,X     (get menu slot again)
C2/538A: C9 02        CMP #$02
C2/538C: F0 08        BEQ $5396     (branch if Magic command, emptying slot.)
C2/538E: C9 1D        CMP #$1D      (MagiTek?  actually, this is former Fight or Gau+Rage.)
C2/5390: D0 06        BNE $5398     (branch if not)
C2/5392: A9 02        LDA #$02      
C2/5394: 80 02        BRA $5398     (save Magic as command)
C2/5396: A9 FF        LDA #$FF      (empty command)
C2/5398: 95 FC        STA $FC,X     (update menu slot)
C2/539A: CA           DEX 
C2/539B: 10 BD        BPL $535A     (loop for all 4 slots)

C2/539D: 7B           TDC           (clear 16-bit A)
C2/539E: 85 F8        STA $F8
C2/53A0: 8F 83 21 00  STA $002183
C2/53A4: A8           TAY           (Y = 0)

C2/53A5: B9 FC 00     LDA $00FC,Y   (get command from menu slot)
C2/53A8: A2 04        LDX #$04
C2/53AA: 48           PHA 
C2/53AB: A9 04        LDA #$04
C2/53AD: 85 EE        STA $EE        (start checking Bit 2 of variable $11D6)
C2/53AF: BF 52 54 C2  LDA $C25452,X  (commands that can be changed FROM)
C2/53B3: C3 01        CMP $01,S      (is current command one of those commands?)
C2/53B5: D0 0D        BNE $53C4      (branch if not)
C2/53B7: AD D6 11     LDA $11D6     (check Battle Effects 1 byte.
                                     Bit 2 = Fight -> Jump, Bit 3 = Magic -> X-Magic,
                                     Bit 4 = Sketch -> Control, Bit 5 = Slot -> GP Rain,
                                     Bit 6 = Steal -> Capture)
C2/53BA: 24 EE        BIT $EE
C2/53BC: F0 06        BEQ $53C4
C2/53BE: BF 57 54 C2  LDA $C25457,X   (commands to change TO)
C2/53C2: 83 01        STA $01,S       (replace command on stack)
C2/53C4: 06 EE        ASL $EE         (will check the next highest bit of $11D6
                                       in our next iteration)
C2/53C6: CA           DEX 
C2/53C7: 10 E6        BPL $53AF       (loop for all 5 possible commands that can be

(This next loop sees if our current command is one that needs special code to assess
 its menu availability -- blanking it if unavailable -- or do some other tests.  If so,
 a special function is called for the command.)

C2/53C9: A3 01        LDA $01,S       (get current command)
C2/53CB: A2 05        LDX #$05
C2/53CD: DF 68 54 C2  CMP $C25468,X   (is it one of the commands that can be blanked from menu
                                       or have other miscellaneous crap done?)
C2/53D1: D0 08        BNE $53DB       (branch if not)
C2/53D3: 8A           TXA 
C2/53D4: 0A           ASL 
C2/53D5: AA           TAX             (X = X * 2)
C2/53D6: FC 5C 54     JSR ($545C,X)   (call special function for command)
C2/53D9: 80 03        BRA $53DE       (we've gotten a match, so there's no need to
                                       compare our current command against rest of list)
C2/53DB: CA           DEX 
C2/53DC: 10 EF        BPL $53CD       (there are 6 possible commands that need
                                       special checks)
C2/53DE: 68           PLA             (restore command #, which may've been nulled by our
                                       C2/545C special function)
C2/53DF: 8F 80 21 00  STA $002180     (save command # in first menu byte)
C2/53E3: 8F 80 21 00  STA $002180     (save command # again in second menu byte..  all i know
                                       about this byte is that the top bit will be set if the
                                       menu option is unavailable [blank or gray] )
C2/53E7: 0A           ASL 
C2/53E8: AA           TAX             (X = command * 2, will let us index a command table)
C2/53E9: 7B           TDC             (clear 16-bit A)
C2/53EA: B0 04        BCS $53F0       (branch if command # was negative.  this will put
                                       zero into the menu aiming)
C2/53EC: BF 01 FE CF  LDA $CFFE01,X   (get command's aiming)
C2/53F0: 8F 80 21 00  STA $002180     (store it in a third menu byte)
C2/53F4: C8           INY 
C2/53F5: C0 04        CPY #$04      (loop for all 4 menu slots)
C2/53F7: D0 AC        BNE $53A5
C2/53F9: 46 F8        LSR $F8       (Carry gets set if character has Magic/X-Magic command
                                     and at least one spell known, Magic/X-Magic and an
                                     Esper equipped, or if they simply have Lore.)
C2/53FB: B0 0B        BCS $5408
C2/53FD: A3 02        LDA $02,S     (retrieve the X value originally passed to the function.
                                     iow, the index of the party member whose menu is being
C2/53FF: AA           TAX 
C2/5400: C2 20        REP #$20      (Set 16-bit A)
C2/5402: 9E 08 3C     STZ $3C08,X   (zero MP)
C2/5405: 9E 30 3C     STZ $3C30,X   (zero max MP)
C2/5408: 28           PLP 
C2/5409: FA           PLX 
C2/540A: 60           RTS 

C2/540B morph command before battle

C2/540B: A9 04        LDA #$04
C2/540D: 2C BC 3E     BIT $3EBC    (set after retrieving Terra from Zozo --
                                    allows Morph command)
C2/5410: F0 22        BEQ $5434    (if not set, go null out command)
C2/5412: 2C BB 3E     BIT $3EBB    (set only for Phunbaba battle #4 [i.e. Terra's second
                                    Phunbaba encounter])
C2/5415: F0 21        BEQ $5438    (if not Phunbaba, just keep command enabled)
C2/5417: A3 05        LDA $05,S    (get the X value originally passed to function C2/532C.
                                    iow, the index of the party member whose menu is being
C2/5419: AA           TAX 
C2/541A: BD E9 3D     LDA $3DE9,X
C2/541D: 09 08        ORA #$08
C2/541F: 9D E9 3D     STA $3DE9,X  (Cause attack to set Morph)
C2/5422: A9 FF        LDA #$FF
C2/5424: 8D F6 1C     STA $1CF6    (set Morph supply to maximum)
C2/5427: 80 0B        BRA $5434    (by nulling Morph command in menu, we'll stop Terra from
                                    Morphing again and from Reverting?)

C2/5429 magic and x-magic command before battle

(Magic and X-Magic menu entry)
(Blank out Magic/X-Magic menu if no spells are known and no Esper is equipped)
C2/5429: A5 F6        LDA $F6      (# of spells learnt?)
C2/542B: D0 18        BNE $5445    (if some are, branch and set a flag)
C2/542D: A5 F7        LDA $F7      (index of Esper equipped.  this value starts with 0
                                    for Ramuh, and the order matches the Espers' order in
                                    the spell list.  FFh means nothing's equipped)
C2/542F: 1A           INC 
C2/5430: D0 13        BNE $5445    (branch if an Esper equipped)
C2/5432: D0 04        BNE $5438    (Dance and Leap jump here.  obviously, this branch
                                    is never taken if we called this function for Magic
                                    or X-Magic.)
C2/5434: A9 FF        LDA #$FF
C2/5436: 83 03        STA $03,S    (replace current command with empty)
C2/5438: 60           RTS 

C2/5439 dance entry

(Dance menu entry)
C2/5439: AD 4C 1D     LDA $1D4C  (bitfield of known Dances)
C2/543C: 80 F4        BRA $5432  (if none are, menu entry will be nulled after branch)

C2/543E leap entry

(Leap menu entry)
C2/543E: AD E4 11     LDA $11E4
C2/5441: 89 02        BIT #$02   (is Leap available?)
C2/5443: 80 ED        BRA $5432  (if it's not, menu entry will be nulled after branch)

C2/5445 lore entry

(Lore menu entry)
C2/5445: A9 01        LDA #$01
C2/5447: 04 F8        TSB $F8    (this will stop character's Current MP and Max MP from
                                  getting zeroed in calling function.  Lore always does
                                  this, whereas Magic and X-Magic have conditions..
                                  Also note that Lore never checks whether the menu command
                                  should be available, as Strago knows 3 Lores at startup)
C2/5449: 60           RTS 

C2/544A data: menu related

(Data - addressed by index of character onscreen -- 0,2,4, or 6)
(Points to each of their menus, which are 4 entries, 3 bytes per entry.)
C2/544A: 2E 20
C2/544C: 3A 20
C2/544E: 46 20
C2/5450: 52 20

C2/5452 data: commands to be replaced by relics

(Data - commands that can be replaced with other commands thanks to Relics)
C2/5452: 05   (Steal)
C2/5453: 0F   (Slot)
C2/5454: 0D   (Sketch)
C2/5455: 02   (Magic)
C2/5456: 00   (Fight)

C2/5457 data: commands to replace commands at C2/5452

(Data - commands that can replace above commands due to Relics)
C2/5457: 06   (Capture)
C2/5458: 18   (GP Rain)
C2/5459: 0E   (Control)
C2/545A: 17   (X-Magic)
C2/545B: 16   (Jump)

C2/545C pointers: adjust commands

(Pointers - functions to remove commands from in-battle menu, or to make
 miscellaneous adjustments)
C2/545C: 0B 54   (Morph)
C2/545E: 3E 54   (Leap)
C2/5460: 39 54   (Dance)
C2/5462: 29 54   (Magic)
C2/5464: 29 54   (X-Magic)
C2/5466: 45 54   (Lore)

C2/5468 data: commands related

(Data - commands that can be removed from menu in some circumstances, or otherwise
 need special functions.)
C2/5468: 03   (Morph)
C2/5469: 11   (Leap)
C2/546A: 13   (Dance)
C2/546B: 02   (Magic)
C2/546C: 17   (X-Magic)
C2/546D: 0C   (Lore)

C2/546E unknow

C2/546E: 08           PHP
C2/546F: C2 30        REP #$30     (Set 16-bit Accumulator, 16-bit X and Y)
C2/5471: A0 AD 2B     LDY #$2BAD
C2/5474: A9 01 00     LDA #$0001
C2/5477: 8D 75 2E     STA $2E75
C2/547A: A2 06 00     LDX #$0006
C2/547D: 5A           PHY
C2/547E: BC 10 30     LDY $3010,X  (get offset to character info block)
C2/5481: B9 20 16     LDA $1620,Y  (get 2nd Arm equipment)
C2/5484: 7A           PLY 
C2/5485: 20 CD 54     JSR $54CD    
C2/5488: CA           DEX 
C2/5489: CA           DEX 
C2/548A: 10 F1        BPL $547D    (loop for all 4 characters)
C2/548C: A2 06 00     LDX #$0006
C2/548F: 5A           PHY
C2/5490: BC 10 30     LDY $3010,X  (get offset to character info block)
C2/5493: B9 1F 16     LDA $161F,Y  (get 1st Arm equipment)
C2/5496: 7A           PLY 
C2/5497: 20 CD 54     JSR $54CD
C2/549A: CA           DEX 
C2/549B: CA           DEX 
C2/549C: 10 F1        BPL $548F    (loop for all 4 characters)
C2/549E: A2 FF 00     LDX #$00FF
C2/54A1: BD 69 19     LDA $1969,X  (get item quantity)
C2/54A4: 8D 75 2E     STA $2E75    
C2/54A7: BD 69 18     LDA $1869,X  (get item)
C2/54AA: 20 CD 54     JSR $54CD
C2/54AD: CA           DEX 
C2/54AE: 10 F1        BPL $54A1    (loop for all 256 items)
C2/54B0: E2 30        SEP #$30     (Set 8-bit Accumulator, 8-bit X and Y)
C2/54B2: 7B           TDC 
C2/54B3: A8           TAY 
C2/54B4: B9 69 18     LDA $1869,Y  (get item in first slot)
C2/54B7: C9 A3        CMP #$A3
C2/54B9: 90 0D        BCC $54C8    (if it's < 163 [NoiseBlaster], branch)
C2/54BB: E9 A3        SBC #$A3     (get a Tool index, where NoiseBlaster = 0, etc)     
C2/54BD: C9 08        CMP #$08
C2/54BF: B0 07        BCS $54C8    (if it's >= 171 [iow, not a tool], branch)
C2/54C1: AA           TAX 
C2/54C2: 20 57 1E     JSR $1E57
C2/54C5: 0C 9B 3A     TSB $3A9B    (Set bit N for Tool N)
C2/54C8: C8           INY 
C2/54C9: D0 E9        BNE $54B4    (loop for all 256 item slots)
C2/54CB: 28           PLP 
C2/54CC: 60           RTS 

C2/54CD unknow

C2/54CD: DA           PHX 
C2/54CE: 20 DC 54     JSR $54DC
C2/54D1: A2 76 2E     LDX #$2E76
C2/54D4: A9 04 00     LDA #$0004
C2/54D7: 44 7E 7E     MVP $7E,$7E
C2/54DA: FA           PLX
C2/54DB: 60           RTS 

C2/54DC unknow

C2/54DC: DA           PHX
C2/54DD: 08           PHP 
C2/54DE: C2 10        REP #$10      (Set 16-bit X and Y)
C2/54E0: E2 20        SEP #$20      (set 8-bit Accumulator)
C2/54E2: 48           PHA 
C2/54E3: A9 80        LDA #$80
C2/54E5: 8D 73 2E     STA $2E73     (assume item is unusable/unselectable (?) in battle)
C2/54E8: A9 FF        LDA #$FF
C2/54EA: 8D 76 2E     STA $2E76     (assume item can't be equipped by any onscreen characters)
C2/54ED: 68           PLA 
C2/54EE: 8D 72 2E     STA $2E72     (save the Item #)
C2/54F1: C9 FF        CMP #$FF      (is it item #255, aka Empty?)
C2/54F3: F0 51        BEQ $5546     (if so, Exit function)
C2/54F5: EB           XBA 
C2/54F6: A9 1E        LDA #$1E    
C2/54F8: 20 81 47     JSR $4781     (Multiply by 30, size of item block)
C2/54FB: AA           TAX 
C2/54FC: BF 0E 50 D8  LDA $D8500E,X (Get Item targeting)
C2/5500: 8D 74 2E     STA $2E74
C2/5503: BF 00 50 D8  LDA $D85000,X (Get Item type)
	 			(	            Item Type:
				00: Tool       04: Hat    |   10: Can be thrown
				01: Weapon     05: Relic  |   20: Usable as an item in battle
				02: Armor      06: Item   |   40: Usable on the field (Items only)
				03: Shield  )

C2/5507: 48           PHA 
C2/5508: 48           PHA 
C2/5509: 0A           ASL 
C2/550A: 0A           ASL           (item type * 4)
C2/550B: 29 80        AND #$80      (isolate whether Usable as item in battle)
C2/550D: 1C 73 2E     TRB $2E73     (clear corresponding bit)
C2/5510: 68           PLA           (get unshifted item type)
C2/5511: 0A           ASL 
C2/5512: 29 20        AND #$20      (isolate can be thrown)
C2/5514: 0C 73 2E     TSB $2E73     (set corresponding bit)
C2/5517: 7B           TDC 
C2/5518: 68           PLA           (get unshifted item type)
C2/5519: 29 07        AND #$07      (isolate classification)
C2/551B: DA           PHX 
C2/551C: AA           TAX 
C2/551D: BF 49 55 C2  LDA $C25549,X (get a value indexed by item type)
C2/5521: FA           PLX           
C2/5522: 0A           ASL           (multiply by 2)
C2/5523: 0C 73 2E     TSB $2E73     (turn on corresponding bits)
C2/5526: B0 1E        BCS $5546     (if top bit was set, branch to end of function.
                                     only Weapon, Shield and Item classifications have
                                     it unset.)
                                    (maybe this controls whether an Item is selectable
                                     under a given character's Item menu?)

(!? why should items of Classification Item ever reach here?! )

C2/5528: C2 21        REP #$21      (Set 16-bit Accumulator, clear carry)
C2/552A: 64 EE        STZ $EE
C2/552C: BF 01 50 D8  LDA $D85001,X (Get Item's equippable characters)
C2/5530: A2 06 00     LDX #$0006
C2/5533: 3C 20 3A     BIT $3A20,X   ($3A20,X has bit Z set, where Z is the actual Character #
                                     of the current onscreen character indexed by X.  don't
                                     think $3A20 is defined for characters >= 0Eh)

C2/5536: D0 01        BNE $5539     (branch if character can equip the item)
C2/5538: 38           SEC           (the current onscreen character can't equip the item)
C2/5539: 26 EE        ROL $EE      
C2/553B: CA           DEX 
C2/553C: CA           DEX 
C2/553D: 10 F4        BPL $5533     (loop for all 4 onscreen characters)
C2/553F: E2 20        SEP #$20      (Set 8-bit Accumulator)
C2/5541: A5 EE        LDA $EE       
C2/5543: 8D 76 2E     STA $2E76     (so $2E76 should look like:
				       Bit 0 = 1, if onscreen character 0 can't equip item
     				       Bit 1 = 1, if onscreen character 1 can't equip item
				       Bit 2 = 1, if onscreen character 2 can't equip item
				       Bit 3 = 1, if onscreen character 3 can't equip item  )

C2/5546: 28           PLP 
C2/5547: FA           PLX 
C2/5548: 60           RTS 

C2/5549 data: item type related

C2/5549: A0  (Tool)
C2/554A: 08  (Weapon)
C2/554B: 80  (Armor)
C2/554C: 04  (Shield)
C2/554D: 80  (Hat)
C2/554E: 80  (Relic)
C2/554F: 00  (Item)
C2/5550: 00  (extra?)

C2/5551 unknow

C2/5551: 08           PHP 
C2/5552: A2 1A        LDX #$1A
C2/5554: 9E BA 30     STZ $30BA,X
C2/5557: CA           DEX 
C2/5558: 10 FA        BPL $5554
C2/555A: A9 FF        LDA #$FF
C2/555C: A2 35        LDX #$35
C2/555E: 9D A0 11     STA $11A0,X
C2/5561: CA           DEX 
C2/5562: 10 FA        BPL $555E
C2/5564: A0 17        LDY #$17
C2/5566: A2 02        LDX #$02
C2/5568: 7B           TDC 
C2/5569: 38           SEC 
C2/556A: 6A           ROR 
C2/556B: 90 02        BCC $556F
C2/556D: 6A           ROR 
C2/556E: CA           DEX 
C2/556F: 3C 29 1D     BIT $1D29,X
C2/5572: F0 10        BEQ $5584
C2/5574: EE 87 3A     INC $3A87
C2/5577: 48           PHA 
C2/5578: 98           TYA 
C2/5579: 69 37        ADC #$37
C2/557B: 99 0F 31     STA $310F,Y
C2/557E: 69 54        ADC #$54
C2/5580: 99 6A 30     STA $306A,Y
C2/5583: 68           PLA 
C2/5584: 88           DEY 
C2/5585: 10 E3        BPL $556A
C2/5587: A2 06        LDX #$06
C2/5589: BD D8 3E     LDA $3ED8,X
C2/558C: C9 0C        CMP #$0C
C2/558E: B0 1E        BCS $55AE
C2/5590: EB           XBA 
C2/5591: A9 36        LDA #$36
C2/5593: 20 81 47     JSR $4781
C2/5596: C2 21        REP #$21
C2/5598: 69 6E        ADC #$6E
C2/559A: 1A           INC 
C2/559B: F0           STA $F0
C2/559D: E2 20        SEP #$20
C2/559F: A0 35        LDY #$35
C2/55A1: B1 F0        LDA ($F0),Y
C2/55A3: C9 FF        CMP #$FF
C2/55A5: D0 04        BNE $55AB
C2/55A7: 98           TYA 
C2/55A8: 99 34 30     STA $3034,Y
C2/55AB: 88           DEY 
C2/55AC: 10 F3        BPL $55A1
C2/55AE: CA           DEX 
C2/55AF: CA           DEX 
C2/55B0: 10 D7        BPL $5589
C2/55B2: AD 54 1D     LDA $1D54    (info from Config screen)
                                   (Bit 7 = Controller: 0 = Single, 1 = Multiple
                                    Bit 6 = ???
                                    Bits 3-5 = Window Color adjustment cursor:
                                      000b = Font, 001b = 1st Window component,
                                      010b = 2nd Window component, 011b = 3rd ' ' ,
                                      100b = 4th ' ' , 101b = 5th ' ' ,
                                      110b = 6th ' ' , 111b = 6th ' '
                                    Bits 0-2 = Magic Order:
                                      000b = Healing, Attack, Effect (HAE) ,
                                      001b = HEA , 010b = AEH, 011b = AHE ,
                                      100b = EHA , 101b = EAH )
C2/55B5: 29 07        AND #$07     (isolate Magic Order)
C2/55B7: AA           TAX 
C2/55B8: A0 35        LDY #$35
C2/55BA: B9 34 30     LDA $3034,Y    (get spell #)
C2/55BD: C9 18        CMP #$18       (compare to 24.  if it's 0-23, it's Attack
                                      magic [Black].)
C2/55BF: B0 06        BCS $55C7      (branch if it's 24 or higher)
C2/55C1: 7F 4B 57 C2  ADC $C2574B,X  (add spell # to amount to adjust Attack
                                      spells positioning based on current
                                      Magic Order)
C2/55C5: 80 12        BRA $55D9
C2/55C7: C9 2D        CMP #$2D       (compare to 45.  if it's 24-44, it's Effect
                                      magic [Gray].)
C2/55C9: B0 06        BCS $55D1      (branch if it's 45 or higher)
C2/55CB: 7F 51 57 C2  ADC $C25751,X  (add spell # to amount to adjust Effect
                                      spells positioning based on current
                                      Magic Order)
C2/55CF: 80 08        BRA $55D9
C2/55D1: C9 36        CMP #$36       (compare to 54.  if it's 45-53, it's Healing
                                      magic [White].)
C2/55D3: B0 0B        BCS $55E0      (branch if it's 54 or higher, which apparently
                                      means it's not a Magic spell at all.)
C2/55D5: 7F 57 57 C2  ADC $C25757,X  (add spell # to amount to adjust Healing
                                      spells positioning based on current
                                      Magic Order)
C2/55D9: DA           PHX 
C2/55DA: AA           TAX 
C2/55DB: 98           TYA 
C2/55DC: 9D A0 11     STA $11A0,X
C2/55DF: FA           PLX 
C2/55E0: 88           DEY 
C2/55E1: 10 D7        BPL $55BA
C2/55E3: A9 FF        LDA #$FF
C2/55E5: A2 35        LDX #$35
C2/55E7: 9D 34 30     STA $3034,X
C2/55EA: CA           DEX 
C2/55EB: 10 FA        BPL $55E7
C2/55ED: 7B           TDC 
C2/55EE: AA           TAX 
C2/55EF: A8           TAY 
C2/55F0: BD A0 11     LDA $11A0,X
C2/55F3: 1A           INC 
C2/55F4: D0 0C        BNE $5602
C2/55F6: BD A1 11     LDA $11A1,X
C2/55F9: 1A           INC 
C2/55FA: D0 06        BNE $5602
C2/55FC: BD A2 11     LDA $11A2,X
C2/55FF: 1A           INC 
C2/5600: F0 15        BEQ $5617
C2/5602: BD A0 11     LDA $11A0,X
C2/5605: 99 34 30     STA $3034,Y
C2/5608: BD A1 11     LDA $11A1,X
C2/560B: 99 35 30     STA $3035,Y
C2/560E: BD A2 11     LDA $11A2,X
C2/5611: 99 36 30     STA $3036,Y
C2/5614: C8           INY 
C2/5615: C8           INY 
C2/5616: C8           INY 
C2/5617: E8           INX 
C2/5618: E8           INX 
C2/5619: E8           INX 
C2/561A: E0 36        CPX #$36
C2/561C: 90 D2        BCC $55F0
C2/561E: A2 35        LDX #$35
C2/5620: BD 34 30     LDA $3034,X
C2/5623: C9 FF        CMP #$FF
C2/5625: F0 06        BEQ $562D
C2/5627: A8           TAY 
C2/5628: 8A           TXA 
C2/5629: 1A           INC 
C2/562A: 99 84 30     STA $3084,Y
C2/562D: CA           DEX 
C2/562E: 10 F0        BPL $5620
C2/5630: C2 10        REP #$10
C2/5632: A2 4D 00     LDX #$004D
C2/5635: 7B           TDC
C2/5636: BD 34 30     LDA $3034,X
C2/5639: C9 FF        CMP #$FF
C2/563B: F0 4B        BEQ $5688
C2/563D: 48           PHA 
C2/563E: A8           TAY 
C2/563F: B9 84 30     LDA $3084,Y
C2/5642: C2 20        REP #$20
C2/5644: 0A           ASL 
C2/5645: 0A           ASL 
C2/5646: E2 20        SEP #$20
C2/5648: A8           TAY 
C2/5649: A3 01        LDA $01,S
C2/564B: C9 8B        CMP #$8B
C2/564D: 90 02        BCC $5651
C2/564F: E9 8B        SBC #$8B
C2/5651: 99 8E 20     STA $208E,Y
C2/5654: 99 CA 21     STA $21CA,Y
C2/5657: 99 06 23     STA $2306,Y
C2/565A: 99 42 24     STA $2442,Y
C2/565D: 68           PLA 
C2/565E: 20 23 57     JSR $5723
C2/5661: 99 90 20     STA $2090,Y
C2/5664: 99 CC 21     STA $21CC,Y
C2/5667: 99 08 23     STA $2308,Y
C2/566A: 99 44 24     STA $2444,Y
C2/566D: EB           XBA 
C2/566E: E0 44 00     CPX #$0044   (are we pointing at Step Mine's menu slot?)
C2/5671: D0 09        BNE $567C    (branch if not)
C2/5673: AD 64 18     LDA $1864    (minutes portion of time played)
C2/5676: C9 1E        CMP #$1E     (set Carry if >=30 minutes)
C2/5678: AD 63 18     LDA $1863    (hours portion of time played)
C2/567B: 2A           ROL          (MP Cost = [hours * 2] + [minutes DIV 30])
C2/567C: 99 91 20     STA $2091,Y
C2/567F: 99 CD 21     STA $21CD,Y
C2/5682: 99 09 23     STA $2309,Y
C2/5685: 99 45 24     STA $2445,Y
C2/5688: CA           DEX 
C2/5689: 10 AA        BPL $5635
C2/568B: 28           PLP 
C2/568C: 60           RTS 

C2/568D unknow

C2/568D: DA           PHX 
C2/568E: 08           PHP 
C2/568F: C2 10        REP #$10
C2/5691: BD 45 3C     LDA $3C45,X
C2/5694: 85 F8        STA $F8       (copy "Relic Effects 2" byte)
C2/5696: 64 F6        STZ $F6
C2/5698: BC 2C 30     LDY $302C,X
C2/569B: 84 F2        STY $F2       (save starting address of character's Magic menu?)
C2/569D: C8           INY 
C2/569E: C8           INY 
C2/569F: C8           INY 
C2/56A0: 84 F4        STY $F4       (save address of MP cost of first spell)
C2/56A2: BC 10 30     LDY $3010,X   (get offset to character info block)
C2/56A5: B9 1E 16     LDA $161E,Y
C2/56A8: 85 F7        STA $F7
C2/56AA: 30 1B        BMI $56C7
C2/56AC: 9D 44 33     STA $3344,X
C2/56AF: A4 F2        LDY $F2
C2/56B1: 99 00 00     STA $0000,Y
C2/56B4: 18           CLC 
C2/56B5: 69 36        ADC #$36
C2/56B7: 20 23 57     JSR $5723    (put spell aiming byte in bottom half of A,
                                    MP cost in top)
C2/56BA: 99 02 00     STA $0002,Y  (save aiming byte in menu data)
C2/56BD: 9D 45 33     STA $3345,X
C2/56C0: EB           XBA          (get spell MP cost)
C2/56C1: 20 36 57     JSR $5736    (change it if Gold Hairpin or Economizer equipped)
C2/56C4: 99 03 00     STA $0003,Y  (save updated MP cost)
C2/56C7: 7B           TDC 
C2/56C8: A8           TAY          (A = 0, Y = 0)
C2/56C9: BD D8 3E     LDA $3ED8,X
C2/56CC: C9 0C        CMP #$0C
C2/56CE: F0 15        BEQ $56E5    (branch if the character is Gogo)
C2/56D0: C8           INY 
C2/56D1: C8           INY          (Y = 2)
C2/56D2: B0 11        BCS $56E5    (branch if Umaro)
C2/56D4: C8           INY 
C2/56D5: C8           INY          (Y = 4)
C2/56D6: EB           XBA 
C2/56D7: A9 36        LDA #$36
C2/56D9: 20 81 47     JSR $4781
C2/56DC: C2 21        REP #$21     (Set 16-bit A, clear Carry)
C2/56DE: 69 6E 1A     ADC #$1A6E
C2/56E1: 85 F0        STA $F0
C2/56E3: E2 20        SEP #$20     (Set 8-bit A)
C2/56E5: BB           TYX 
C2/56E6: A0 38 01     LDY #$0138   (we can loop through 78 spell menu entries [each taking
                                    4 bytes].  54 Magic spells + 24 Lores = 78)
C2/56E9: 7B           TDC
C2/56EA: B1 F2        LDA ($F2),Y
C2/56EC: C9 FF        CMP #$FF
C2/56EE: F0 1E        BEQ $570E     (branch if no spell available in this menu slot)
C2/56F0: C0 DC 00     CPY #$00DC    (are we pointing to the first slot on the Lore menu
                                     [our 55th slot overall]?)
C2/56F3: 7C 5D 57     JMP ($575D,X) (jump out of the loop..  but the other places can actually
                                     jump back into it.  Square is crazy like that. :P )
C2/56F6: 88           DEY
C2/56F7: 88           DEY 
C2/56F8: 88           DEY 
C2/56F9: 88           DEY   
C2/56FA: D0 ED        BNE $56E9     (point to next menu slot, and loop)
C2/56FC: 28           PLP 
C2/56FD: FA           PLX 
C2/56FE: A5 F6        LDA $F6
C2/5700: 9D F8 3C     STA $3CF8,X
C2/5703: 60           RTS 

C2/5704: B0 10        BCS $5716     (branch if we're pointing to a Lore slot.  otherwise,
                                     we're pointing to a Magic spell slot.)
C2/5706: 5A           PHY 
C2/5707: A8           TAY 
C2/5708: B1 F0        LDA ($F0),Y
C2/570A: 7A           PLY 
C2/570B: 1A           INC 
C2/570C: F0 08        BEQ $5716

C2/570E: 7B           TDC 
C2/570F: 91 F4        STA ($F4),Y   (save 0 as MP cost)
C2/5711: 3A           DEC 
C2/5712: 91 F2        STA ($F2),Y   (save FFh [null] as spell #)
C2/5714: 80 E0        BRA $56F6     (reenter our 78-slot loop)

C2/5716: B0 02        BCS $571A     (branch if we're pointing to a Lore slot.  otherwise,
                                     we're pointing to a Magic spell slot.)
C2/5718: E6 F6        INC $F6
C2/571A: B1 F4        LDA ($F4),Y   (get spell's MP cost from menu)
C2/571C: 20 36 57     JSR $5736     (change it if Gold Hairpin or Economizer equipped)
C2/571F: 91 F4        STA ($F4),Y   (save updated MP cost)
C2/5721: 80 D3        BRA $56F6     (reenter our 78-slot loop)

C2/5723 unknow

C2/5723: DA           PHX 
C2/5724: EB           XBA 
C2/5725: A9 0E        LDA #$0E
C2/5727: 20 81 47     JSR $4781      (spell # * 14)
C2/572A: AA           TAX 
C2/572B: BF C5 6A C4  LDA $C46AC5,X  (read MP cost from spell data)
C2/572F: EB           XBA
C2/5730: BF C0 6A C4  LDA $C46AC0,X  (read aiming byte from spell data)
C2/5734: FA           PLX 
C2/5735: 60           RTS 

C2/5736 adjust MP cost based on relics

(Adjust MP cost for Gold Hairpin and/or Economizer.  obviously, the latter supercedes
 the former.)
C2/5736: EB           XBA           (put MP cost in top of A)
C2/5737: A5 F8        LDA $F8       (read our copy of "Relic Effects 2" byte)
C2/5739: 89 20        BIT #$20
C2/573B: F0 04        BEQ $5741     (branch if no Gold Hairpin)
C2/573D: EB           XBA           (get MP cost)
C2/573E: 1A           INC 
C2/573F: 4A           LSR           (MP cost = [MP cost + 1] / 2)
C2/5740: EB           XBA           (look at relics byte again)
C2/5741: 89 40        BIT #$40
C2/5743: F0 04        BEQ $5749     (branch if no Economizer)
C2/5745: EB           XBA 
C2/5746: A9 01        LDA #$01      (MP cost = 1)
C2/5748: EB           XBA 
C2/5749: EB           XBA           (return MP cost in bottom of A)
C2/574A: 60           RTS 

C2/574B adjustments for magic order at magic menu

(Data - amount to shift menu position of certain Magic spells,
 depending on the "Magic Order" chosen in Config menu.
 These values are signed, so anything 80h and above means to
 subtract, i.e. move the spell backwards.)
(For Spells 0 - 23 : Attack, Black)
C2/574B: 09  (Healing, Attack, Effect (HAE))
C2/574C: 1E  (Healing, Effect, Attack (HEA))
C2/574D: 00  (Attack, Effect, Healing (AEH))
C2/574E: 00  (Attack, Healing, Effect (AHE))
C2/574F: 1E  (Effect, Healing, Attack (EHA))
C2/5750: 15  (Effect, Attack, Healing (EAH))

(For Spells 24 - 44 : Effect, Gray)
C2/5751: 09  (Healing, Attack, Effect (HAE))
C2/5752: F1  (Healing, Effect, Attack (HEA))
C2/5753: 00  (Attack, Effect, Healing (AEH))
C2/5754: 09  (Attack, Healing, Effect (AHE))
C2/5755: E8  (Effect, Healing, Attack (EHA))
C2/5756: E8  (Effect, Attack, Healing (EAH))

(For Spells 45 - 53 : White, Healing)
C2/5757: D3  (Healing, Attack, Effect (HAE))
C2/5758: D3  (Healing, Effect, Attack (HEA))
C2/5759: 00  (Attack, Effect, Healing (AEH))
C2/575A: EB  (Attack, Healing, Effect (AHE))
C2/575B: E8  (Effect, Healing, Attack (EHA))
C2/575C: 00  (Effect, Attack, Healing (EAH))

C2/575D pointers

(Pointer table)
C2/575D: 16 57
C2/575F: 0E 57
C2/5761: 04 57

C2/5763 check availability for esper, magic and lore

(Make entries on Esper, Magic, and Lore menus available and lit up or unavailable
 and grayed, depending on whether: the spell is learned [or for the Esper menu,
 an Esper is equipped], the character has enough MP to cast the spell, the
 character is an Imp trying to cast a spell other than Imp)

C2/5763: E0 08        CPX #$08
C2/5765: B0 42        BCS $57A9    (Exit function if monster)
C2/5767: DA           PHX 
C2/5768: 5A           PHY 
C2/5769: 08           PHP 
C2/576A: BD 09 3C     LDA $3C09,X  (MP, top byte)
C2/576D: D0 06        BNE $5775    (branch if MP >= 256)
C2/576F: BD 08 3C     LDA $3C08,X  (MP, bottom byte)
C2/5772: 1A           INC 
C2/5773: D0 02        BNE $5777    (if MP < 255, branch and save MP cost
                                    as character MP + 1)
C2/5775: A9 FF        LDA #$FF     (otherwise, set it to 255)
C2/5777: 8D 4C 3A     STA $3A4C    (save Caster MP + 1.  capped at 255)
C2/577A: BD E4 3E     LDA $3EE4,X  (Status byte 1)
C2/577D: 0A           ASL 
C2/577E: 0A           ASL 
C2/577F: 85 EF        STA $EF      (Imp is saved in Bit 7)
C2/5781: C2 10        REP #$10     (16-bit X and Y registers)
C2/5783: BD 18 30     LDA $3018,X  (Holds $01 for character 1, $02 for character 2,
                                    $04 for character 3, $08 for character 4
C2/5786: BC 2C 30     LDY $302C,X  (get starting address of character's Magic menu?)
C2/5789: BB           TYX 
C2/578A: 38           SEC 
C2/578B: 2C 2E 3F     BIT $3F2E    (bit is set for characters who don't have Espers
C2/578E: D0 03        BNE $5793    (if no Esper equipped, branch with Carry Set)
C2/5790: 20 AA 57     JSR $57AA    (Set Carry if spell's unavailable due to Impage or
                                    insufficient MP.  Clear Carry otherwise.)
C2/5793: 7E 01 00     ROR $0001,X  (put Carry into bit 7 of 2nd byte of menu data.
                                    if set, it makes spell unavailable on menu.)
C2/5796: A0 4D 00     LDY #$004D
C2/5799: E8           INX
C2/579A: E8           INX
C2/579B: E8           INX 
C2/579C: E8           INX          (point to next spell in menu)
C2/579D: 20 AA 57     JSR $57AA    (Set Carry if spell's unavailable due to absence,
                                    Impage, or insufficient MP.  Clear Carry otherwise.)
C2/57A0: 7E 01 00     ROR $0001,X  (put Carry into bit 7 of 2nd byte of menu data.
                                    if set, it makes spell unavailable on menu.)
C2/57A3: 88           DEY 
C2/57A4: 10 F3        BPL $5799    (loop 78 times: 54 spells plus 24 lores)
C2/57A6: 28           PLP 
C2/57A7: 7A           PLY 
C2/57A8: FA           PLX 
C2/57A9: 60           RTS 

C2/57AA check if spell can be cast

(Set Carry if spell should be disabled due to unavailability, or because
 caster is an Imp and the spell isn't Imp.  If none of these factors
 disable the spell, check the MP cost.)

C2/57AA: BD 00 00     LDA $0000,X   (get spell # from menu)
C2/57AD: 30 0A        BMI $57B9     (branch if undefined)
C2/57AF: EB           XBA 
C2/57B0: A5 EF        LDA $EF
C2/57B2: 10 07        BPL $57BB     (branch if character not an Imp)
C2/57B4: EB           XBA 
C2/57B5: C9 23        CMP #$23    
C2/57B7: F0 02        BEQ $57BB     (branch if spell is Imp)
C2/57B9: 38           SEC           (spell will be unavailable)
C2/57BA: 60           RTS 

C2/57BB check if caster lacks MP to cast spell

(Set Carry if caster lacks MP to cast spell.
 Clear it if they have sufficient MP.)
C2/57BB: BD 03 00     LDA $0003,X  (get spell's MP cost from menu data)
C2/57BE: CD 4C 3A     CMP $3A4C    (compare to Caster MP + 1, capped at 255)
C2/57C1: 60           RTS 

C2/57C2 jump animation

(Sets up attack animation, including making all Jump but the last in a Dragon Horn
 sequence send the attacker airborne again.
 Randomizes targets for all jumps but the first with Dragon Horn.)

C2/57C2: 08           PHP
C2/57C3: E2 30        SEP #$30    (set 8-bit A, X, Y)
C2/57C5: 64 A0        STZ $A0
C2/57C7: 8A           TXA         (get attacker index)
C2/57C8: 4A           LSR         (divide by 2.  now we have 0, 1, 2, and 3 for characters,
                                   and 4, 5, 6, 7, 8, 9 for monsters)
C2/57C9: 85 A1        STA $A1     (save attacker for animation purposes)
C2/57CB: C9 04        CMP #$04
C2/57CD: 90 02        BCC $57D1   (branch if character is attacker)
C2/57CF: 66 A0        ROR $A0     (Bit 7 is set if monster attacker)
C2/57D1: A5 B9        LDA $B9     (get monster targets)
C2/57D3: 85 A3        STA $A3
C2/57D5: 85 A5        STA $A5
C2/57D7: A5 B8        LDA $B8     (get character targets)
C2/57D9: 85 A2        STA $A2
C2/57DB: 85 A4        STA $A4
C2/57DD: D0 04        BNE $57E3   (branch if there are character targets)
C2/57DF: A9 40        LDA #$40    
C2/57E1: 04 A0        TSB $A0     (Bit 6 set if there are no character targets)
C2/57E3: A5 A0        LDA $A0
C2/57E5: 0A           ASL 
C2/57E6: 90 02        BCC $57EA   (branch if not monster attacker)
C2/57E8: 49 80        EOR #$80    (flip "no character targets" bit)
C2/57EA: 10 04        BPL $57F0   (next two lines are only executed if:
                                   - character attacker and no character (i.e. just monster) targets
                                   OR  - monster attacker and character targets)
C2/57EC: A9 02        LDA #$02
C2/57EE: 04 BA        TSB $BA     (Set "attacking opposition" bit.  Used for criticals
                                   and reflections.)
C2/57F0: A9 10        LDA #$10
C2/57F2: 14 B0        TRB $B0
C2/57F4: D0 02        BNE $57F8
C2/57F6: 04 A0        TSB $A0
C2/57F8: AD 70 3A     LDA $3A70   (# of attacks left for Dragon Horn / Offering / Quadra Slam)
C2/57FB: F0 0D        BEQ $580A   (if no more after the current one, exit)
C2/57FD: AD 8E 3A     LDA $3A8E   (set to FFh by Dragon Horn's "jump continuously" attribute;
                                   should be zero otherwise)
C2/5800: F0 08        BEQ $580A   (exit if zero)
C2/5802: A9 02        LDA #$02
C2/5804: 04 A0        TSB $A0     (animation to send jumper bouncing skyward again)
C2/5806: A9 60        LDA #$60
C2/5808: 04 BA        TSB $BA     (set Can Beat on Corpses if no Valid Targets Left and
                                   Randomize Target.  the latter explains why all jumps
                                   after the first one are random.)
C2/580A: 28           PLP 
C2/580B: 60           RTS 

C2/580C unknow

C2/580C: 7B           TDC         (16-bit A = 0)
C2/580D: AD F7 1C     LDA $1CF7   (Known SwdTechs)
C2/5810: 20 0E 52     JSR $520E   (X = # of known SwdTechs)
C2/5813: CA           DEX 
C2/5814: 8E 20 20     STX $2020   (index of the highest SwdTech acquired.  useful
                                   to represent it this way because SwdTechs are
                                   on a continuum.)  
C2/5817: 7B           TDC 
C2/5818: AD 28 1D     LDA $1D28   (Known Blitzes)
C2/581B: 20 0E 52     JSR $520E   (X = # of known Blitzes)
C2/581E: 8E 80 3A     STX $3A80
C2/5821: AD 4C 1D     LDA $1D4C   (Known Dances)
C2/5824: 85 EE        STA $EE
C2/5826: A2 07        LDX #$07    (start looking at 8th dance)
C2/5828: 06 EE        ASL $EE     (Carry will be set if current dance is known)
C2/582A: A9 FF        LDA #$FF    (default to storing null in Dance menu?)
C2/582C: 90 01        BCC $582F   (branch if dance unknown)
C2/582E: 8A           TXA         (if current dance is known, store its number
                                   in the menu instead.)
C2/582F: 9D 7E 26     STA $267E,X
C2/5832: CA           DEX 
C2/5833: 10 F3        BPL $5828    (loop for all 8 Dances)
C2/5835: C2 20        REP #$20     (Set 16-bit Accumulator)
C2/5837: A9 7E 25     LDA #$257E
C2/583A: 8F 81 21 00  STA $002181
C2/583E: E2 20        SEP #$20     (Set 8-bit Accumulator)
C2/5840: 7B           TDC
C2/5841: A8           TAY
C2/5842: AA           TAX           (Clear A, Y, X)
C2/5843: 8F 83 21 00  STA $002183
C2/5847: 89 07        BIT #$07
C2/5849: D0 08        BNE $5853     (if none of bottom 3 bits set, we're on enemy #
                                     0,8,16,etc.  in which case we need to read a new
                                     rage byte)
C2/584B: 48           PHA 
C2/584C: BD 2C 1D     LDA $1D2C,X   (load current rage byte - 32 bytes total, 8 rages
                                     per byte)
C2/584F: 85 EE        STA $EE
C2/5851: E8           INX           (point to next rage byte)
C2/5852: 68           PLA 
C2/5853: 46 EE        LSR $EE       (get bottom bit of current rage byte)
C2/5855: 90 07        BCC $585E     (if bit wasn't set, rage wasn't found, so don't
                                     display it)
C2/5857: EE 9A 3A     INC $3A9A     (# of rages possessed.  used to randomly pick a rage
                                     in situations like Muddle)
C2/585A: 8F 80 21 00  STA $002180   (store rage in menu)
C2/585E: 1A           INC           (advance to next enemy #)
C2/585F: C9 FF        CMP #$FF      
C2/5861: D0 E4        BNE $5847     (loop for all eligible enemies, 0 to 254.  we don't loop
                                     a 256th time for Pugs, which is inaccessible regardless,
                                     because that would overflow our $3A9A counter)
C2/5863: 60           RTS 

C2/5864 check for statuses

Doesn't set carry if any are set
Carry clear = one or more set
Carry set = none set

C2/5864: C2 21        REP #$21    (Set 16-bit Accumulator)
C2/5866: B9 E4 3E     LDA $3EE4,Y (Target status byte 1 & 2)
C2/5869: 23 05        AND $05,S
C2/586B: D0 08        BNE $5875
C2/586D: B9 F8 3E     LDA $3EF8,Y (Target status byte 3 & 4)
C2/5870: 23 03        AND $03,S
C2/5872: D0 01        BNE $5875
C2/5874: 38           SEC 
C2/5875: A3 01        LDA $01,S
C2/5877: 83 05        STA $05,S
C2/5879: 68           PLA 
C2/587A: 68           PLA 
C2/587B: E2 20        SEP #$20    (Set 8-bit Accumulator)
C2/587D: 60           RTS

C2/587E targeting function

(Big ass targeting function.  It's not used to choose targets with the cursor, but
 it can choose targets randomly (for all sorts of reasons), or refine ones previously
 chosen [e.g. with the cursor].  This routine's so important, it uses several
 helper functions.)
C2/587E: DA           PHX
C2/587F: 5A           PHY 
C2/5880: 08           PHP 
C2/5881: E2 30        SEP #$30    (set 8-bit A, X and Y)
C2/5883: A5 BB        LDA $BB     (targeting byte)
C2/5885: C9 02        CMP #$02    (does the aiming consist of JUST "one side only?"
                                   if so, that means we can't do spread-aim, start the
                                   cursor on the enemy, or move it)

C2/5887: D0 0C        BNE $5895   (if not, branch)
C2/5889: BD 18 30     LDA $3018,X
C2/588C: 85 B8        STA $B8
C2/588E: BD 19 30     LDA $3019,X
C2/5891: 85 B9        STA $B9     (save attacker as lone target?)
C2/5893: 80 61        BRA $58F6   (then exit function)
C2/5895: 20 FA 58     JSR $58FA
C2/5898: A5 BA        LDA $BA
C2/589A: 89 40        BIT #$40
C2/589C: D0 1B        BNE $58B9   (Branch if randomize targets)
C2/589E: 89 08        BIT #$08
C2/58A0: D0 03        BNE $58A5   (Branch if Can target dead/hidden entities)
C2/58A2: 20 4D 5A     JSR $5A4D   (Remove dead and hidden targets)
C2/58A5: A5 B8        LDA $B8
C2/58A7: 05 B9        ORA $B9
C2/58A9: F0 08        BEQ $58B3   (Branch if no targets)
C2/58AB: A5 BB        LDA $BB     (targeting byte)
C2/58AD: 89 2C        BIT #$2C    (is "manual party select", "autoselect one party", or
                                   "autoselect both parties" set?  in other words,
                                   we're checking to see if the spell can be spread)
C2/58AF: F0 3C        BEQ $58ED   (if not, branch)
C2/58B1: 80 43        BRA $58F6   (if so, exit function)

                          (So if there were multiple targets and the targeting byte
                           allows that, keep our multiple targets.  If there were
                           somehow multiple targets despite the targeting byte
                           [I can't think of a cause for this], just choose a
                           random one at $58ED.  If there was only a single target,
                           the branch to either $58ED or $58F6 will retain it.)

C2/58B3: A5 BA        LDA $BA
C2/58B5: 89 04        BIT #$04    (Don't retarget if target dead/invalid?)
C2/58B7: D0 0F        BNE $58C8   (if we don't retarget, branch)
C2/58B9: 20 37 59     JSR $5937   (Randomize Targets jumps here)
C2/58BC: 20 FA 58     JSR $58FA
C2/58BF: A5 BA        LDA $BA
C2/58C1: 89 08        BIT #$08
C2/58C3: D0 03        BNE $58C8   (Branch if can target dead/hidden entities)
C2/58C5: 20 4D 5A     JSR $5A4D   (Remove dead and hidden targets)
C2/58C8: 20 AC 59     JSR $59AC
C2/58CB: A5 BA        LDA $BA
C2/58CD: 89 20        BIT #$20
C2/58CF: F0 0D        BEQ $58DE   (branch if attack doesn't allow us to beat on corpses)
C2/58D1: C2 20        REP #$20    (Set 16-bit Accumulator)
C2/58D3: A5 B8        LDA $B8
C2/58D5: D0 05        BNE $58DC   (branch if there are some targets set)
C2/58D7: AD 4E 3A     LDA $3A4E
C2/58DA: 85 B8        STA $B8     (if there are no targets left, copy them from a
                                   "backup targets byte".  this will let Offering and
                                   Genji Glove and friends beat on corpses once all
                                   targets have been killed during the attacker's turn.

                                   i dunno if this variable is used in any other cases.)

C2/58DC: E2 20        SEP #$20    (Set 8-bit Accumulator)

(note: if we're at this point, we never did the BIT #$2C target byte check above..
 and we've most likely retargeted thanks to "Randomize targets", or to there being
 no valid targets initially selected)

C2/58DE: A5 BB        LDA $BB     (targeting byte)
C2/58E0: 89 0C        BIT #$0C    (is "autoselect one party" or "autoselect both parties" set?
                                   in another words, we're checking for some auto-spread aim)
C2/58E2: D0 12        BNE $58F6   (if so, exit function)
C2/58E4: 89 20        BIT #$20    (is "manual party select" set?  i.e. can the spell be spread
                                   via L/R button?)
C2/58E6: F0 05        BEQ $58ED   (if not, branch)
C2/58E8: 20 53 4B     JSR $4B53   (if so, do random coinflip)
C2/58EB: B0 09        BCS $58F6   (50% of the time, we'll pretend it was spread, so exit)
                                  (50% of the time, we'll pretend it kept one target)
C2/58ED: C2 20        REP #$20    (Set 16-bit Accumulator)
C2/58EF: A5 B8        LDA $B8
C2/58F1: 20 2A 52     JSR $522A   (Randomly picks a bit set in A)
C2/58F4: 85 B8        STA $B8     (so we pick one random target)
C2/58F6: 28           PLP 
C2/58F7: 7A           PLY 
C2/58F8: FA           PLX 
C2/58F9: 60           RTS 

C2/58FA unknow

C2/58FA: 08           PHP
C2/58FB: A9 02        LDA #$02
C2/58FD: 1C 46 3A     TRB $3A46    (clear flag)
C2/5900: D0 13        BNE $5915    (if it was set [as is the case with the Joker
                                    Dooms and the Tentacles' Seize drain], branch
                                    and don't remove any targets)
C2/5902: 20 17 59     JSR $5917
C2/5905: A5 BA        LDA $BA
C2/5907: 10 02        BPL $590B    (branch if not abort on characters)
C2/5909: 64 B8        STZ $B8      (clear character targets)
C2/590B: 4A           LSR 
C2/590C: 90 07        BCC $5915    (branch if not "Exclude Attacker from targets")
C2/590E: C2 20        REP #$20     (set 16-bit accumulator)
C2/5910: BD 18 30     LDA $3018,X
C2/5913: 14 B8        TRB $B8      (clear caster from targets)
C2/5915: 28           PLP 
C2/5916: 60           RTS 

C2/5917 unknow

C2/5917: 08           PHP
C2/5918: AD 46 2F     LDA $2F46
C2/591B: EB           XBA 
C2/591C: AD 03 34     LDA $3403    (Seized entities: bit clear for those who are,
                                    set for those who aren't.)
C2/591F: C2 20        REP #$20
C2/5921: 2D 78 3A     AND $3A78
C2/5924: 2D 08 34     AND $3408
C2/5927: 25 B8        AND $B8
C2/5929: 85 B8        STA $B8
C2/592B: AD 1A 34     LDA $341A    (check top bit of $341B)
C2/592E: 10 05        BPL $5935    (branch if not set)
C2/5930: AD 2C 3F     LDA $3F2C    (get Jumpers)
C2/5933: 14 B8        TRB $B8      (remove them from targets)
C2/5935: 28           PLP 
C2/5936: 60           RTS 

C2/5937 randomize targets

(Randomize Targets function.  selects entire monster or character parties (or both) at a time.
 calling function will later refine the targeting.)

(calling the character side 0 and the monster side 1, it looks like this up through C2/598A:
  side chosen = (monster caster) XOR Charmed XOR "Cursor start on opposition" XOR Muddled )

(values DURING function -- not coming in or leaving it:
 bit 7 of $B8 = side to target. characters = 0, monsters = 1, special/opposing(?) characters = 1
 bit 6 of $B8 = 1: make both sides eligible to target)

C2/5937: 64 B9        STZ $B9      (clear enemy targets)
C2/5939: 7B           TDC          (Accumulator = 0)
C2/593A: E0 08        CPX #$08     (carry set if caster is monster?  note that "caster" can
                                    also mean "reflectee", in which cases a good part of
                                    this function will be skipped..)
C2/593C: 6A           ROR 
C2/593D: 85 B8        STA $B8      (Bits 0-6 = 0.  Bit 7 = 1 if monster caster, 0 if character)
C2/593F: A5 BA        LDA $BA
C2/5941: 89 10        BIT #$10     (this bit only seems to be set by Reflection)
C2/5943: D0 41        BNE $5986    (if it's set, branch.  once the spell's already hit the
                                    Wall Ring, we [generally] don't care about the reflector's
                                    status, and they're not necessarily the caster anyway)

                           (after this branch, there'll be just the one flip of $B8's
                            top bit..  as a reflected spell always bounces at the
                            party opposing the reflectee)

C2/5945: BD 95 33     LDA $3395,X
C2/5948: 30 06        BMI $5950    (Branch if charmed)
C2/594A: A9 80        LDA #$80
C2/594C: 45 B8        EOR $B8
C2/594E: 85 B8        STA $B8      (toggle top bit of $B8)
C2/5950: BD 18 30     LDA $3018,X
C2/5953: 2C 40 3A     BIT $3A40    (is caster a special type of character?
                                    from all i've seen, this means a character acting as
                                    an enemy, like Gau returning from a Veldt leap, or
                                    Shadow in the Colosseum)
C2/5956: F0 06        BEQ $595E    (if not, branch)
C2/5958: A9 80        LDA #$80     (if so.. here comes another toggle!)
C2/595A: 45 B8        EOR $B8
C2/595C: 85 B8        STA $B8      (toggle top bit of $B8)
C2/595E: A5 BB        LDA $BB      (targeting byte)
C2/5960: 29 0C        AND #$0C     (isolate "Autoselect both parties" and "Autoselect one party")
C2/5962: C9 04        CMP #$04     (is "autoselect both parties" the only bit of these two set?)
C2/5964: D0 04        BNE $596A    (if not, branch)
C2/5966: A9 40        LDA #$40
C2/5968: 04 B8        TSB $B8      (make both monsters and characters targetable?)
C2/596A: A5 BB        LDA $BB      (targeting byte)
C2/596C: 29 40        AND #$40     (isolate "cursor start on enemy" [read OPPOSITION: not monster])
C2/596E: 0A           ASL          (put into top bit of A)
C2/596F: 45 B8        EOR $B8
C2/5971: 85 B8        STA $B8      (toggle top bit yet again)
C2/5973: BD E4 3E     LDA $3EE4,X  (Status byte 1)
C2/5976: 4A           LSR 
C2/5977: 4A           LSR 
C2/5978: 90 04        BCC $597E    (Branch if not Zombie)
C2/597A: A9 40        LDA #$40
C2/597C: 04 B8        TSB $B8      (make both monsters and characters targetable?)
C2/597E: BD E5 3E     LDA $3EE5,X  (Status byte 2)
C2/5981: 0A           ASL 
C2/5982: 0A           ASL 
C2/5983: 0A           ASL 
C2/5984: 90 06        BCC $598C    (Branch if not Muddled)
C2/5986: A9 80        LDA #$80
C2/5988: 45 B8        EOR $B8
C2/598A: 85 B8        STA $B8      (toggle top bit)
C2/598C: A5 B8        LDA $B8
C2/598E: 0A           ASL          
C2/598F: 64 B8        STZ $B8      (clear character targets; monsters were cleared at start
                                    of function)
C2/5991: 30 02        BMI $5995    (if target anybody bit is set, branch, as we don't care
                                    whether monsters or characters were indicated by top bit)
C2/5993: 90 0B        BCC $59A0    (if target monsters bit was not set, branch)
C2/5995: 08           PHP          (save Carry and Negative flags)
C2/5996: A9 3F        LDA #$3F     
C2/5998: 04 B9        TSB $B9      (target all monsters)
C2/599A: AD 40 3A     LDA $3A40
C2/599D: 04 B8        TSB $B8      (only target certain characters?  like not typically playable ones?
                                    or ones acting as enemies in some event?  at any rate, $3A40
                                    has been 0 the few times i checked in normal battles..)

C2/599F: 28           PLP          (restore Carry and Negative flags)
C2/59A0: 30 02        BMI $59A4    (if target anybody bit is set, branch, as we don't care
                                    whether monsters or characters were indicated by top bit)
C2/59A2: B0 07        BCS $59AB    (if target monsters bit was set, exit function)
C2/59A4: A9 0F        LDA #$0F     (mark all characters)
C2/59A6: 4D 40 3A     EOR $3A40    (exclude characters acting as enemies, like Colosseum Shadow
                                    and Gau returning from Veldt leap)
C2/59A9: 04 B8        TSB $B8      (turn on just normal characters' bits)

(bits 7 and 6 |  Results
    0     0      normal characters (?)
    1     0      all monsters, special/enemy characters
    0     1      all monsters, special/enemy characters + normal characters
    1     1      all monsters, special/enemy characters + normal characters
C2/59AB: 60           RTS 

C2/59AC unknow

(If a reflection has occurred AND the initial spellcast had one party aiming at another
 AND the reflector isn't Muddled, then there's a 50% chance the initial caster will
 become the sole target, provided he/she is in the party that's about to be hit by the
 bounce.  The other 50% of the time, the final target is randomly chosen by the end of
 function C2/587E; each member of the party opposing the reflector has the same chance
 of getting hit.)

C2/59AC: A5 BA        LDA $BA
C2/59AE: 89 10        BIT #$10     
C2/59B0: F0 28        BEQ $59DA    (branch if not Reflected)
C2/59B2: 89 02        BIT #$02
C2/59B4: F0 23        BEQ $59D9    (branch if not attacking opposition..  iow,
                                    is reflectOR an opponent?)
C2/59B6: BD E5 3E     LDA $3EE5,X  (Status byte 2)
C2/59B9: 89 20        BIT #$20     
C2/59BB: D0 1C        BNE $59D9    (if this reflector is Muddled, exit function)
C2/59BD: 20 53 4B     JSR $4B53
C2/59C0: B0 17        BCS $59D9    (50% chance of exit function)
C2/59C2: DA           PHX 
C2/59C3: AE 32 3A     LDX $3A32
C2/59C6: BD 5F 2C     LDA $2C5F,X  (get unique index of ORIGINAL spell caster
                                    [from animation data]?)
C2/59C9: 0A           ASL 
C2/59CA: AA           TAX          (multiply by 2 to access their data block)
C2/59CB: C2 20        REP #$20     (set 16-bit accumulator)
C2/59CD: BD 18 30     LDA $3018,X
C2/59D0: 24 B8        BIT $B8      (is original caster a member of the party about
                                    to be hit by the bounce?)
C2/59D2: F0 02        BEQ $59D6    
C2/59D4: 85 B8        STA $B8      (if they are, save them as the sole target of
                                    this bounce)
C2/59D6: E2 20        SEP #$20     (set 8-bit accumulator)
C2/59D8: FA           PLX 
C2/59D9: 60           RTS 

C2/59DA targeting for different encounter formations

(NOTE: I reuse the "Autoselect both parties" description from FF3usME, but
 it really seems to be more like "Autoselect both/all CLUSTERS".  spread-aim
 spells without this bit set [Haste 2, Slow 2, X-Zone] will only be able
 to target one cluster of your party at a time when it's split by a Side
 attack or one cluster of the monster party when it's split by a Pincer.
 Whereas spells WITH it set [Meteor, Quake] can hit both/all clumps)

C2/59DA: A5 BB        LDA $BB     (targeting byte)
C2/59DC: 29 0C        AND #$0C    (isolate "Autoselect both parties" and "Autoselect one party")
C2/59DE: 48           PHA         (save these bits of targeting byte)
C2/59DF: 89 04        BIT #$04    (is "Autoselect both parties" set?)
C2/59E1: D0 52        BNE $5A35   (if yes, branch)
                                  (if not, we'll be unable to hit more than one cluster of
                                   targets at a time, so take special steps for formations
                                   like Pincer and Side, which divide targets into these clusters)

C2/59E3: AD 1F 20     LDA $201F   (get encounter type: 0 = front, 1 = back, 2 = pincer, 3 = side)
C2/59E6: C9 02        CMP #$02    
C2/59E8: D0 23        BNE $5A0D   (branch if not pincer)
C2/59EA: AD AD 2E     LDA $2EAD   (bitfield of enemies in right "clump".
                                   set in function C1/1588.)
C2/59ED: EB           XBA 
C2/59EE: AD AC 2E     LDA $2EAC   (bitfield of enemies in left "clump".
                                   set in function C1/1588.)
C2/59F1: E0 08        CPX #$08
C2/59F3: 90 07        BCC $59FC   (branch if attacker is not a monster)
C2/59F5: 3C 19 30     BIT $3019,X (is this attacker among enemies on left side
                                   of pincer?)
C2/59F8: F0 11        BEQ $5A0B   (branch if not, and clear left side enemies from targets)
C2/59FA: 80 0E        BRA $5A0A   (otherwise, branch, and clear right side enemies from
C2/59FC: 24 B9        BIT $B9     (are left side enemies among targets?)
C2/59FE: F0 0D        BEQ $5A0D   (if they aren't, we don't have to choose a side for
                                   attack, so branch and dont' alter anything.)
C2/5A00: EB           XBA 
C2/5A01: 24 B9        BIT $B9
C2/5A03: F0 08        BEQ $5A0D   (if right side enemies aren't among targets, we don't have
                                   to choose a side, so branch and don't alter anything.)
C2/5A05: 20 53 4B     JSR $4B53
C2/5A08: 90 01        BCC $5A0B  (50% branch.  half the time, we clear left side enemies.
                                  the other half, right side.)
C2/5A0A: EB           XBA 
C2/5A0B: 14 B9        TRB $B9    (clear some enemy targets)
C2/5A0D: AD 1F 20     LDA $201F  (get encounter type: 0 = front, 1 = back, 2 = pincer, 3 = side)
C2/5A10: C9 03        CMP #$03
C2/5A12: D0 21        BNE $5A35  (branch if not side)
C2/5A14: A9 0C        LDA #$0C   (characters 2 and 3, who are on left side)
C2/5A16: EB           XBA 
C2/5A17: A9 03        LDA #$03   (characters 0 and 1, who are on right side)
C2/5A19: E0 08        CPX #$08   
C2/5A1B: B0 07        BCS $5A24    (branch if monster attacker)
C2/5A1D: 3C 18 30     BIT $3018,X
C2/5A20: F0 11        BEQ $5A33    (branch if it's a character, and they're not on right side.
                                    this will clear right side characters from targets.)
C2/5A22: 80 0E        BRA $5A32    (otherwise, branch and clear left side characters from
C2/5A24: 24 B8        BIT $B8
C2/5A26: F0 0D        BEQ $5A35    (if right side characters aren't among targets, we don't
                                    have to choose a side, so branch and don't alter anything)
C2/5A28: EB           XBA 
C2/5A29: 24 B8        BIT $B8
C2/5A2B: F0 08        BEQ $5A35    (if left side characters aren't among targets, we don't
                                    have to choose a side, so branch and don't alter anything)
C2/5A2D: 20 53 4B     JSR $4B53  
C2/5A30: 90 01        BCC $5A33  (50% branch.  half the time, we clear right side characters.
                                  the other half, left side.)
C2/5A32: EB           XBA 
C2/5A33: 14 B8        TRB $B8    (clear some character targets)
C2/5A35: 68           PLA        (retrieve "Autoselect both parties" and "Autoselect one party"
                                  bits of targeting byte)
C2/5A36: C9 04        CMP #$04   (was only "Autoselect both parties" set?)
C2/5A38: F0 12        BEQ $5A4C  (if so, exit function)
C2/5A3A: A5 B8        LDA $B8
C2/5A3C: F0 0E        BEQ $5A4C  (if no characters targeted, exit function)
C2/5A3E: A5 B9        LDA $B9
C2/5A40: F0 0A        BEQ $5A4C  (or if no monsters targeted, exit function)

                         (if we reached here, both monsters and characters are targeted, even
                          though attack's aiming byte didn't indicate that.)
C2/5A42: 20 5A 4B     JSR $4B5A  (random # [0..255])
C2/5A45: DA           PHX 
C2/5A46: 29 01        AND #$01   (reduce random number to 0 or 1)
C2/5A48: AA           TAX 
C2/5A49: 74 B8        STZ $B8,X  (clear $B8 [character targets] or $B9 [monster targets] .
                                  i THINK the only case where C2/5937 would have both characters
                                  and monsters targeted with "Autoselect both parties" unset
                                  or "Autoselect one party" set along with it is that of a
                                  Zombie caster)
C2/5A4B: FA           PLX 
C2/5A4C: 60           RTS 

C2/5A4D removes dead and hidden targets

C2/5A4D: DA           PHX
C2/5A4E: 08           PHP 
C2/5A4F: C2 20        REP #$20
C2/5A51: A2 12        LDX #$12
C2/5A53: BD 18 30     LDA $3018,X
C2/5A56: 24 B8        BIT $B8
C2/5A58: F0 22        BEQ $5A7C   (Branch if not a target)
C2/5A5A: BD A0 3A     LDA $3AA0,X
C2/5A5D: 4A           LSR 
C2/5A5E: 90 17        BCC $5A77   (? is target still valid?)
C2/5A60: A9 C2 00     LDA #$00C2
C2/5A63: E0 08        CPX #$08
C2/5A65: B0 03        BCS $5A6A   (Branch if monster)
C2/5A67: A9 80 00     LDA #$0080
C2/5A6A: 3C E4 3E     BIT $3EE4,X
C2/5A6D: D0 08        BNE $5A77   (Branch if death status, and zombie and Petrify for
C2/5A6F: BD F8 3E     LDA $3EF8,X
C2/5A72: 89 00 20     BIT #$2000
C2/5A75: F0 05        BEQ $5A7C   (Branch if not hidden)
C2/5A77: BD 18 30     LDA $3018,X
C2/5A7A: 14 B8        TRB $B8     (clear current target)
C2/5A7C: CA           DEX 
C2/5A7D: CA           DEX 
C2/5A7E: 10 D3        BPL $5A53   (loop for all monsters and characters)
C2/5A80: 28           PLP 
C2/5A81: FA           PLX 
C2/5A82: 60           RTS 

C2/5A83 unknow

(???  called whenever battle timer is incremented)
C2/5A83: AD 91 3A     LDA $3A91   (Lower byte of time counter)
C2/5A86: EE 91 3A     INC $3A91   (increment that counter)
C2/5A89: 29 0F        AND #$0F    
C2/5A8B: C9 0A        CMP #$0A    
C2/5A8D: B0 52        BCS $5AE1   (Branch if lower nibble of time counter was >= #$0A)
                                  (otherwise, A now corresponds to one of the 10
                                   onscreen entities.)
C2/5A8F: 0A           ASL 
C2/5A90: AA           TAX 
C2/5A91: BD A0 3A     LDA $3AA0,X
C2/5A94: 4A           LSR 
C2/5A95: 90 52        BCC $5AE9   (Exit if bit 0 of $3AA0,X is clear)
C2/5A97: 18           CLC 
C2/5A98: BD DC 3A     LDA $3ADC,X
C2/5A9B: 7D DD 3A     ADC $3ADD,X  (Add ATB multiplier (set at C2/09D2))
C2/5A9E: 9D DC 3A     STA $3ADC,X
C2/5AA1: 90 46        BCC $5AE9    (Exit if no carry set from addition)
C2/5AA3: BD F1 3A     LDA $3AF1,X  (Get Stop timer, originally set to #$12
                                    at C2/467D)
C2/5AA6: F0 09        BEQ $5AB1    (Branch if it's 0, as that *should* mean the
                                    entity is not stopped.)
C2/5AA8: DE F1 3A     DEC $3AF1,X  (Decrement Stop timer)
C2/5AAB: D0 3C        BNE $5AE9    (did it JUST run down on this tick?  if not, exit)
C2/5AAD: A9 01        LDA #$01
C2/5AAF: 80 55        BRA $5B06    (Set Stop to wear off)
                                   (Also decrement Reflect, Freeze, and Sleep timers if
                                    applicable, and check if any have worn off.  That
                                    makes no sense, as these timers are stalled on
                                    all of the Stop timer's preceding ticks; they should
                                    be stalled during the last one as well.  To contrast, 
                                    an entity's Condemned countdown and Regen/Seizure/etc
                                    resume on the tick following the one where its Stop
                                    timer hits zero -- that's much more consistent with
                                    the simple concept of time unfreezing *after* Stop
                                    wears off.)

C2/5AB1: BD A0 3A     LDA $3AA0,X
C2/5AB4: 89 10        BIT #$10
C2/5AB6: D0 31        BNE $5AE9    (Exit if bit 4 of $3AA0,X is set)
C2/5AB8: BD 05 3B     LDA $3B05,X  (Condemned counter - originally set at C2/09B4.
                                    To be clear, this counter is "one off" from the
                                    actual numerals you'll see onscreen:
                                      00 value = numerals disabled
                                      01 value = numerals at "00"
                                      02 value = numerals at "01"
                                      03 value = numerals at "02" , etc.)
C2/5ABB: C9 02        CMP #$02
C2/5ABD: 90 0A        BCC $5AC9    (Branch if counter < 2.  [i.e. numerals < "01",
                                    meaning they're "00" or disabled.])
C2/5ABF: 3A           DEC 
C2/5AC0: 9D 05 3B     STA $3B05,X  (decrement counter)
C2/5AC3: 3A           DEC          (just think of this second "DEC" as an optimized
                                    "CMP #$01", as we're not altering the counter.)
C2/5AC4: D0 03        BNE $5AC9    (Branch if counter now != 1  [i.e. numerals != "00"])
C2/5AC6: 20 C7 5B     JSR $5BC7    (Cast Doom when countdown numerals reach 0)
C2/5AC9: 20 1B 5C     JSR $5C1B    (Check if runs from combat)
C2/5ACC: 20 4F 5B     JSR $5B4F    (Trigger Poison, Seizure, Regen, Phantasm, or
                                    Tentacle Drain damage)
C2/5ACF: 7B           TDC 
C2/5AD0: 20 06 5B     JSR $5B06    (Decrement Reflect, Freeze, and Sleep timers if
                                    applicable, and check if any have worn off)
C2/5AD3: FE F0 3A     INC $3AF0,X  (advance this entity's pointer to the next entry
                                    in the C2/5AEA function table)
C2/5AD6: BD F0 3A     LDA $3AF0,X
C2/5AD9: 9B           TXY 
C2/5ADA: 29 07        AND #$07     (convert it to 0-7, wrapping as necessary)
C2/5ADC: 0A           ASL 
C2/5ADD: AA           TAX 
C2/5ADE: 7C EA 5A     JMP ($5AEA,X) (determine which periodic/damage healing type
                                     will be checked on this entity's next tick.)
C2/5AE1: E9 0A        SBC #$0A      (should only be reached if ($3A91 AND 15) was >= 10
                                     at start of function.  now subtract 10)
C2/5AE3: 0A           ASL 
C2/5AE4: AA           TAX 
C2/5AE5: 7C FA 5A     JMP ($5AFA,X)
C2/5AE8: BB           TYX 
C2/5AE9: 60           RTS 

C2/5AEA pointers

(Note: choosing RTS will default to the (monster) entity draining anybody
 it has Seized on its next tick.)
C2/5AEA: 45 5B     (Set bit 3 of $3E4C,X - check regen, seizure, phantasm)
C2/5AEC: E8 5A     (RTS)
C2/5AEE: 3B 5B     (Set bit 4 of $3E4C,X - check poison)
C2/5AF0: E8 5A     (RTS)
C2/5AF2: 45 5B     (Set bit 3 of $3E4C,X - check regen, seizure, phantasm)
C2/5AF4: E8 5A     (RTS)
C2/5AF6: E8 5A     (RTS)
C2/5AF8: E8 5A     (RTS)

C2/5AFA pointers

C2/5AFA: B2 5B     (Enemy Roulette completion)
C2/5AFC: FC 5B     (Increment time counters)
C2/5AFE: E9 5A     (RTS)
C2/5B00: E9 5A     (RTS)
C2/5B02: E9 5A     (RTS)
C2/5B04: D0 5B     (Check if characters run?)

C2/5B06 decrement status counters based on time

(Decrement Reflect, Freeze, and Sleep timers if applicable, and if any
 have worn off, mark them to be removed.  If A was 1 (rather than 0) going
 into this function, which means Stop just ran out, mark it to be removed.)

C2/5B06: 85 B8        STA $B8
C2/5B08: BD 0C 3F     LDA $3F0C,X  (Time until Reflect wears off)
                                   (Originally set to #$1A at C2/4687)
C2/5B0B: F0 09        BEQ $5B16    (branch if timer not active)
C2/5B0D: DE 0C 3F     DEC $3F0C,X  (Decrement Reflect timer)
C2/5B10: D0 04        BNE $5B16    
C2/5B12: A9 02        LDA #$02
C2/5B14: 04 B8        TSB $B8      (If Reflect timer reached 0 on this tick,
                                    set to remove Reflect)
C2/5B16: BD 0D 3F     LDA $3F0D,X  (Time until Freeze wears off)
                                   (Originally set to #$22 at C2/4691)
C2/5B19: F0 09        BEQ $5B24    (branch if timer not active)
C2/5B1B: DE 0D 3F     DEC $3F0D,X  (Decrement Freeze timer)
C2/5B1E: D0 04        BNE $5B24    
C2/5B20: A9 04        LDA #$04
C2/5B22: 04 B8        TSB $B8      (If Freeze timer reached 0 on this tick,
                                    set to remove Freeze)
C2/5B24: BD F9 3C     LDA $3CF9,X  (Time until Sleep wears off)
                                   (Originally set to #$12 at C2/4633)
C2/5B27: F0 09        BEQ $5B32    (branch if timer not active)
C2/5B29: DE F9 3C     DEC $3CF9,X  (Decrement Sleep timer)
C2/5B2C: D0 04        BNE $5B32
C2/5B2E: A9 08        LDA #$08
C2/5B30: 04 B8        TSB $B8      (If Sleep timer reached 0 on this tick,
                                    set to remove Sleep)
C2/5B32: A5 B8        LDA $B8
C2/5B34: F0 B3        BEQ $5AE9    (Exit if we haven't marked any of the
                                    statuses to be auto-removed)
C2/5B36: A9 29        LDA #$29
C2/5B38: 4C 91 4E     JMP $4E91

C2/5B3B queue to check for poison

Set to check for Poison on this entity's next tick
C2/5B3B: BB           TYX 
C2/5B3C: BD 4C 3E     LDA $3E4C,X
C2/5B3F: 09 10        ORA #$10
C2/5B41: 9D 4C 3E     STA $3E4C,X  (Set bit 4 of $3E4C,X)
C2/5B44: 60           RTS 

C2/5B45 queue to check for regen, seizure and phantasm

Set to check for Regen, Seizure, Phantasm on this entity's next tick

C2/5B45: BB           TYX
C2/5B46: BD 4C 3E     LDA $3E4C,X
C2/5B49: 09 08        ORA #$08
C2/5B4B: 9D 4C 3E     STA $3E4C,X  (Set bit 3 of $3E4C,X)
C2/5B4E: 60           RTS 

C2/5B4F trigger poison, regen, seizure, phantasm or drain attack

Trigger Poison, Regen, Seizure, Phantasm, or Tentacle Drain attack

C2/5B4F: A9 10        LDA #$10
C2/5B51: 3C A1 3A     BIT $3AA1,X
C2/5B54: D0 F8        BNE $5B4E   (Exit if bit 4 of $3AA1 is set.  we already
                                   have some periodic damage/healing queued for
                                   this entity, so don't queue any more yet.)
C2/5B56: BD 4C 3E     LDA $3E4C,X
C2/5B59: 89 10        BIT #$10
C2/5B5B: F0 0E        BEQ $5B6B   (Branch if bit 4 of $3E4C,X is not set)
                                  (Check Regen and Seizure and Phantasm if not set,
                                   Poison if set)
C2/5B5D: 29 EF        AND #$EF
C2/5B5F: 9D 4C 3E     STA $3E4C,X (Clear bit 4 of $3E4C,X)
C2/5B62: BD E4 3E     LDA $3EE4,X (Status byte 1)
C2/5B65: 29 04        AND #$04    
C2/5B67: F0 E5        BEQ $5B4E   (Exit if not poisoned)
C2/5B69: 80 1A        BRA $5B85

C2/5B6B check seizure, phantasm and regen

Check Seizure, Phantasm, and Regen
C2/5B6B: 89 08        BIT #$08
C2/5B6D: F0 23        BEQ $5B92     (Branch if bit 3 of $3E4C,X is not set)
                                    (Check Tentacle Drain if not set, Seizure and Phantasm
                                     and Regen if set)
C2/5B6F: 29 F7        AND #$F7
C2/5B71: 9D 4C 3E     STA $3E4C,X   (Clear bit 3 of $3E4C,X)
C2/5B74: BD E5 3E     LDA $3EE5,X
C2/5B77: 1D 4D 3E     ORA $3E4D,X   (are Seizure or Phantasm set?)
C2/5B7A: 29 40        AND #$40
C2/5B7C: D0 07        BNE $5B85     (if at least one is, branch)
C2/5B7E: BD F8 3E     LDA $3EF8,X   
C2/5B81: 29 02        AND #$02      (is Regen set?)
C2/5B83: F0 C9        BEQ $5B4E     (if not, exit function)
C2/5B85: 8D 7B 3A     STA $3A7B     (Set spell) (02 = Regen, 04 = Poison, 40 = Seizure/Phantasm)
C2/5B88: A9 22        LDA #$22
C2/5B8A: 8D 7A 3A     STA $3A7A     (Set command to #$22 - Poison, Regen, Seizure, Phantasm)
C2/5B8D: 20 B2 4E     JSR $4EB2
C2/5B90: 80 17        BRA $5BA9

C2/5B92 check drain from being seized

C2/5B92: BC 58 33     LDY $3358,X
C2/5B95: 30 B7        BMI $5B4E    (Exit if monster doesn't have a character seized)
C2/5B97: C2 20        REP #$20     (Set 16-bit A)
C2/5B99: B9 18 30     LDA $3018,Y
C2/5B9C: 85 B8        STA $B8      (Set target to character monster has seized)
C2/5B9E: A9 2D 00     LDA #$002D
C2/5BA1: 8D 7A 3A     STA $3A7A    (Set command to #$2D - drain from being seized) 
C2/5BA4: E2 20        SEP #$20     (Set 8-bit A)
C2/5BA6: 20 B2 4E     JSR $4EB2
C2/5BA9: A9 10        LDA #$10
C2/5BAB: 1D A1 3A     ORA $3AA1,X
C2/5BAE: 9D A1 3A     STA $3AA1,X  (Set bit 4 of $3AA1,X.  This bit will prevent us from
                                    queueing up more than one instance of periodic
                                    damage/healing (i.e. Poison, Seizure/Phantasm, Regen,
                                    or Tentacle Drain) at a time for a given entity.)
C2/5BB1: 60           RTS 

C2/5BB2 enemy roulette completion

(Enemy Roulette completion)
C2/5BB2: AD 43 2F     LDA $2F43   (top byte of Enemy Roulette target bitfield, which
                                   is set at C1/B41A when the cursor winds down.)
C2/5BB5: 30 97        BMI $5B4E   (Exit if no targets are defined)
C2/5BB7: C2 20        REP #$20    (Set 16-bit A)
C2/5BB9: AD 42 2F     LDA $2F42   (get our chosen target)
C2/5BBC: 20 F9 51     JSR $51F9   (Y = bit number of highest bit set in A (0 for bit 0,
                                   2 for bit 1, 4 for bit 2, etc.))
C2/5BBF: 7B           TDC 
C2/5BC0: 3A           DEC 
C2/5BC1: 8D 42 2F     STA $2F42   (Set $2F42 to #$FFFF)
C2/5BC4: E2 20        SEP #$20    (Set 8-bit A)
C2/5BC6: BB           TYX 
C2/5BC7: A9 0D        LDA #$0D    (Condemned expiration enters here)
C2/5BC9: 85 B8        STA $B8     (spell = Doom)
C2/5BCB: A9 26        LDA #$26
C2/5BCD: 4C 91 4E     JMP $4E91

C2/5BD0 unknow

C2/5BD0: AD 45 2F     LDA $2F45   (characters trying to run)
C2/5BD3: F0 45        BEQ $5C1A   (exit if not trying to run)
C2/5BD5: A5 B1        LDA $B1
C2/5BD7: 89 02        BIT #$02    (is Can't Run set?)
C2/5BD9: D0 16        BNE $5BF1   (branch if so)
C2/5BDB: AD 91 3A     LDA $3A91   (get bottom byte of battle time counter equiv.)
C2/5BDE: 29 70        AND #$70
C2/5BE0: D0 38        BNE $5C1A   (7/8 chance of exit)
C2/5BE2: AD 45 2F     LDA $2F45   (characters trying to run.  yes, a duplicate
                                   check.  it's done because C2/5C1B and C2/11BB
                                   can branch here.)
C2/5BE5: F0 33        BEQ $5C1A   (exit if not trying to run)
C2/5BE7: AD 38 3A     LDA $3A38   (characters who are successfully running)
C2/5BEA: F0 2E        BEQ $5C1A   (branch if none)
C2/5BEC: AD 97 3A     LDA $3A97
C2/5BEF: D0 29        BNE $5C1A   (exit if in Colosseum)
C2/5BF1: A9 04        LDA #$04
C2/5BF3: 04 B0        TSB $B0
C2/5BF5: D0 23        BNE $5C1A
C2/5BF7: A9 2A        LDA #$2A
C2/5BF9: 4C 91 4E     JMP $4E91

C2/5BFC increment time counters

C2/5BFC: 08           PHP 
C2/5BFD: C2 20        REP #$20     (set 16-bit A)
C2/5BFF: EE 44 3A     INC $3A44    (increment Global battle time counter)
C2/5C02: A2 12        LDX #$12     (point to last enemy)
C2/5C04: BD A0 3A     LDA $3AA0,X
C2/5C07: 4A           LSR 
C2/5C08: 90 0B        BCC $5C15    (Skip if bit 0 of $3AA0,X is not set)
C2/5C0A: BD E4 3E     LDA $3EE4,X  (status byte 1)
C2/5C0D: 89 C0 00     BIT #$00C0   
C2/5C10: D0 03        BNE $5C15    (branch if petrified or dead)
C2/5C12: FE C0 3D     INC $3DC0,X  (Increment monster time counter)
C2/5C15: CA           DEX 
C2/5C16: CA           DEX 
C2/5C17: 10 EB        BPL $5C04    (loop for all monsters and characters)
C2/5C19: 28           PLP 
C2/5C1A: 60           RTS 

C2/5C1B check if character runs from combat

C2/5C1B: E0 08        CPX #$08
C2/5C1D: B0 34        BCS $5C53    (Exit if monster)
C2/5C1F: AD 45 2F     LDA $2F45    (Characters trying to run)
C2/5C22: F0 2F        BEQ $5C53    (Exit if not trying to run)
C2/5C24: AD 39 3A     LDA $3A39    (Load characters who've escaped)
C2/5C27: 0D 40 3A     ORA $3A40    (Or with characters acting as enemies)
C2/5C2A: 3C 18 30     BIT $3018,X  (Does the character we're currently checking
                                    fall into one of those categories (escaped
                                    or enemy)?)
C2/5C2D: D0 24        BNE $5C53    (Exit if so)
C2/5C2F: AD 3B 3A     LDA $3A3B    (Get the Run Difficulty)
C2/5C32: D0 06        BNE $5C3A    (Branch if it's nonzero)
C2/5C34: 20 4D 5C     JSR $5C4D
C2/5C37: 4C E2 5B     JMP $5BE2

C2/5C3A chance to run from combat

(Figure character's "Run Success" variable and attempt to run)
C2/5C3A: BD 71 3D     LDA $3D71,X  (Amount to add to "run success" variable.
                                    varies by character.)
C2/5C3D: 20 65 4B     JSR $4B65    (random: 0 to A - 1)
C2/5C40: 1A           INC          (1 to A)
C2/5C41: 18           CLC 
C2/5C42: 7D 70 3D     ADC $3D70,X
C2/5C45: 9D 70 3D     STA $3D70,X  (add to Run Success variable)
C2/5C48: CD 3B 3A     CMP $3A3B    (compare to Run Difficulty)
C2/5C4B: 90 06        BCC $5C53    (if it's less, the character's not running yet)
C2/5C4D: BD 18 30     LDA $3018,X
C2/5C50: 0C 38 3A     TSB $3A38    (mark character as successfully running)
C2/5C53: 60           RTS 

C2/5C54 unknow

C2/5C54: E2 30        SEP #$30
C2/5C56: A2 06        LDX #$06
C2/5C58: A0 03        LDY #$03
C2/5C5A: BD 19 32     LDA $3219,X  (ATB timer, top byte)
C2/5C5D: 3A           DEC 
C2/5C5E: 99 22 20     STA $2022,Y  (visual ATB gauge?)
C2/5C61: BD 04 3B     LDA $3B04,X  (Morph gauge)
C2/5C64: 99 26 20     STA $2026,Y
C2/5C67: BD 05 3B     LDA $3B05,X  (Condemned counter)
C2/5C6A: 99 2A 20     STA $202A,Y
C2/5C6D: CA           DEX 
C2/5C6E: CA           DEX 
C2/5C6F: 88           DEY 
C2/5C70: 10 E8        BPL $5C5A    (loop for all 4 characters)
C2/5C72: 60           RTS 

C2/5C73 unknow

C2/5C73: C2 20        REP #$20     (Set 16-bit Accumulator)
C2/5C75: A0 08        LDY #$08     (the following loop nulls the list of enemy
                                    names [and quantities, shown in FF6j but not FF3us]
                                    that appears on the bottom left corner of the
                                    screen in battle?)
C2/5C77: 7B           TDC          (A = 0000h)
C2/5C78: 99 13 20     STA $2013,Y  (store to $2015 - $201B, each having a 16-bit
                                    monster quantity)
C2/5C7B: 3A           DEC          (A = FFFFh)
C2/5C7C: 99 0B 20     STA $200B,Y  (store to $200D - $2013, each having a 16-bit
                                    monster ID)
C2/5C7F: 88           DEY 
C2/5C80: 88           DEY 
C2/5C81: D0 F4        BNE $5C77    (loop 4 times, as there are 4 list entries)
C2/5C83: E2 20        SEP #$20     (Set 8-bit Accumulator)
C2/5C85: A9 06        LDA #$06
C2/5C87: 14 B1        TRB $B1      (clear Can't Run and Can't Escape)
C2/5C89: AD 1F 20     LDA $201F    (get encounter type.  0 = front, 1 = back,
                                    2 = pincer, 3 = side)
C2/5C8C: C9 02        CMP #$02
C2/5C8E: D0 14        BNE $5CA4    (branch if not pincer)
C2/5C90: AD AC 2E     LDA $2EAC    (bitfield of enemies in left "clump".
                                    set in function C1/1588.)
C2/5C93: 2D 2F 2F     AND $2F2F    (compare to bitfield of remaining enemies?)
C2/5C96: F0 0C        BEQ $5CA4    (branch if no enemy on left side remaining)
C2/5C98: AD AD 2E     LDA $2EAD    (bitfield of enemies in right "clump".
                                    set in function C1/1588.)
C2/5C9B: 2D 2F 2F     AND $2F2F    (compare to bitfield of remaining enemies?)
C2/5C9E: F0 04        BEQ $5CA4    (branch if no enemy on right side remaining)
C2/5CA0: A9 02        LDA #$02
C2/5CA2: 04 B1        TSB $B1      (set Can't Run)
C2/5CA4: 9C 3B 3A     STZ $3A3B    (set Run Difficulty to zero)
C2/5CA7: 9C CA 3E     STZ $3ECA    (set Number of Unique enemy names who are currently
                                    active to zero?  this variable will have a max
                                    of 4, even though the actual number of unique
                                    enemy names can go to 6.)
C2/5CAA: B9 A8 3A     LDA $3AA8,Y
C2/5CAD: 4A           LSR 
C2/5CAE: 90 54        BCC $5D04
C2/5CB0: B9 21 30     LDA $3021,Y
C2/5CB3: 2C 3A 3A     BIT $3A3A
C2/5CB6: D0 4C        BNE $5D04
C2/5CB8: 2C 09 34     BIT $3409
C2/5CBB: F0 47        BEQ $5D04
C2/5CBD: B9 EC 3E     LDA $3EEC,Y  (get monster's status byte 1)
C2/5CC0: 89 C2        BIT #$C2
C2/5CC2: D0 40        BNE $5D04    (branch if Zombie, Petrify, or Wound is set)
C2/5CC4: B9 88 3C     LDA $3C88,Y  (normally accessed as "$3C80,Y" , but we're only looking at
                                    enemies here)
C2/5CC7: 4A           LSR          (put "Harder to Run From" bit in Carry flag)
C2/5CC8: 89 04        BIT #$04     (is "Can't Run" bit set?)
C2/5CCA: F0 04        BEQ $5CD0  
C2/5CCC: A9 06        LDA #$06
C2/5CCE: 04 B1        TSB $B1      (if so, set both Can't Run and Can't Escape.  the latter
                                    will stop Warp, Warp Stones, and Smoke Bombs.  even though
                                    a failed Smoke Bomb gives a "Can't run away!!" rather than
                                    a "Can't escape!!" message, it just looks at the
                                    Can't Escape bit. )

C2/5CD0: 7B           TDC 
C2/5CD1: 2A           ROL 
C2/5CD2: 38           SEC 
C2/5CD3: 2A           ROL 
C2/5CD4: 0A           ASL          (if "Harder to Run From" was set, A = 6.  if not, A = 2.)
C2/5CD5: 6D 3B 3A     ADC $3A3B
C2/5CD8: 8D 3B 3A     STA $3A3B    (add to Run Difficulty)
C2/5CDB: B9 9D 3C     LDA $3C9D,Y  (normally accessed as $3C95,Y , but we're only looking
                                    at enemies here.)
C2/5CDE: 89 04        BIT #$04     (is "Name Hidden" property set?)
C2/5CE0: D0 22        BNE $5D04    (branch if so)
C2/5CE2: C2 20        REP #$20
C2/5CE4: A2 00        LDX #$00
C2/5CE6: BD 0D 20     LDA $200D,X  (entry in list of enemy names you see on bottom left
                                    of screen in battle?)
C2/5CE9: 10 09        BPL $5CF4    (branch if this entry has already been assigned an
                                    enemy ID)
C2/5CEB: B9 88 33     LDA $3388,Y  (get entry from Enemy Name structure, initialized
                                    in function C2/2C30 [using $3380], for our current
                                    monster pointed to by Y.  this structure has a list
                                    of enemy IDs for the up to 6 enemies in a battle,
                                    but it's normalized so enemies with matching names have
                                    matching IDs.)
C2/5CEE: 9D 0D 20     STA $200D,X  (save it in list of names?)
C2/5CF1: EE CA 3E     INC $3ECA    (increment the number of unique names of active enemies?
                                    this counter will max out at 4, because the in-battle
                                    list shows a maximum of 4 names, even though the actual
                                    # of unique enemy names goes up to 6.
                                    this variable is used by the FC 10 monster script
C2/5CF4: D9 88 33     CMP $3388,Y  (compare enemy ID previously in this screen list entry
                                    to one in the Name Structure entry.  they'll match for
                                    sure if we didn't follow the branch at C2/5CE9.)
C2/5CF7: D0 05        BNE $5CFE    (if they don't match, skip to next screen list entry)
C2/5CF9: FE 15 20     INC $2015,X  (they did match, so increase the quantity of enemies
                                    who have this name.  FF6j displayed a quantity in
                                    battle.  FF3us increased enemy names from 8 to 10
                                    characters, so it never shows the quantity.)
C2/5CFC: 80 06        BRA $5D04    (exit this loop, as our enemy ID [as indexed by Y] is
                                    already in the screen list.)
C2/5CFE: E8           INX 
C2/5CFF: E8           INX 
C2/5D00: E0 08        CPX #$08
C2/5D02: 90 E2        BCC $5CE6    (loop 4 times, as the battle enemy name list has
                                    4 entries.)
C2/5D04: E2 20        SEP #$20
C2/5D06: C8           INY 
C2/5D07: C8           INY 
C2/5D08: C0 0C        CPY #$0C
C2/5D0A: 90 9E        BCC $5CAA
C2/5D0C: AD 1F 20     LDA $201F    (get encounter type.  0 = front, 1 = back,
                                    2 = pincer, 3 = side)
C2/5D0F: C9 03        CMP #$03
C2/5D11: F0 06        BEQ $5D19    (branch if side attack)
C2/5D13: A5 B0        LDA $B0
C2/5D15: 89 40        BIT #$40
C2/5D17: F0 03        BEQ $5D1C    (branch if not Preemptive attack)
C2/5D19: 9C 3B 3A     STZ $3A3B    (set Run Difficulty to zero)
C2/5D1C: AD 42 3A     LDA $3A42
C2/5D1F: F0 04        BEQ $5D25
C2/5D21: A9 02        LDA #$02
C2/5D23: 04 B1        TSB $B1      (set Can't Run)
C2/5D25: 60           RTS 

C2/5D26 switch combat status to permanent status

C2/5D26: 08           PHP
C2/5D27: C2 20        REP #$20
C2/5D29: E2 10        SEP #$10
C2/5D2B: A0 06        LDY #$06
C2/5D2D: B9 F4 3B     LDA $3BF4,Y
C2/5D30: 99 78 2E     STA $2E78,Y
C2/5D33: B9 1C 3C     LDA $3C1C,Y
C2/5D36: 99 80 2E     STA $2E80,Y
C2/5D39: B9 08 3C     LDA $3C08,Y
C2/5D3C: 99 88 2E     STA $2E88,Y
C2/5D3F: B9 30 3C     LDA $3C30,Y
C2/5D42: 99 90 2E     STA $2E90,Y
C2/5D45: B9 E4 3E     LDA $3EE4,Y
C2/5D48: 99 98 2E     STA $2E98,Y
C2/5D4B: B9 F8 3E     LDA $3EF8,Y
C2/5D4E: 99 A0 2E     STA $2EA0,Y
C2/5D51: 88           DEY 
C2/5D52: 88           DEY 
C2/5D53: 10 D8        BPL $5D2D
C2/5D55: 28           PLP 
C2/5D56: 60           RTS 

C2/5D57 unknow

C2/5D57: 08           PHP
C2/5D58: 20 67 02     JSR $0267
C2/5D5B: A2 06        LDX #$06
C2/5D5D: 9E 99 2E     STZ $2E99,X
C2/5D60: CA           DEX 
C2/5D61: CA           DEX 
C2/5D62: 10 F9        BPL $5D5D
C2/5D64: A2 0B        LDX #$0B
C2/5D66: 9E 35 2F     STZ $2F35,X
C2/5D69: CA           DEX 
C2/5D6A: 10 FA        BPL $5D66
C2/5D6C: A9 08        LDA #$08
C2/5D6E: 20 11 64     JSR $6411
C2/5D71: 20 03 49     JSR $4903
C2/5D74: AD 97 3A     LDA $3A97
C2/5D77: F0 18        BEQ $5D91  (branch if not in Colosseum)
C2/5D79: A9 01        LDA #$01
C2/5D7B: 8D 75 2E     STA $2E75
C2/5D7E: AD 07 02     LDA $0207
C2/5D81: 8D 35 2F     STA $2F35
C2/5D84: 20 DC 54     JSR $54DC
C2/5D87: 20 79 62     JSR $6279
C2/5D8A: A9 20        LDA #$20
C2/5D8C: 20 D4 5F     JSR $5FD4
C2/5D8F: 28           PLP 
C2/5D90: 60           RTS 

C2/5D91 end of battle routine

(Displays all messages at end of victorious combat)
C2/5D91: C2 10        REP #$10     (Set 16-bit X and Y)
C2/5D93: 7B           TDC          (clear accumulator)
C2/5D94: AE D4 3E     LDX $3ED4    (get battle formation #)
C2/5D97: E0 00 02     CPX #$0200   
C2/5D9A: B0 04        BCS $5DA0     (if it's >=512, there's no magic points, so branch)
C2/5D9C: BF 00 B4 DF  LDA $DFB400,X  (magic points given by that enemy formation)
C2/5DA0: 85 FB        STA $FB
C2/5DA2: 64           STZ $F0
C2/5DA4: AD BC 3E     LDA $3EBC
C2/5DA7: 29 08        AND #$08      (set after getting any of four Magicites in Zozo --
                                     allows Magic Point display)
C2/5DA9: 85 F1        STA $F1       (save that bit)
C2/5DAB: C2 20        REP #$20      (Set 16-bit Accumulator)
C2/5DAD: A2 0A 00     LDX #$000A
C2/5DB0: BD EC 3E     LDA $3EEC,X   (check enemy's 1st status byte)
C2/5DB3: 89 C2 00     BIT #$00C2    (Petrify, death, or zombie?)
C2/5DB6: F0 26        BEQ $5DDE     (if not, skip this enemy)
C2/5DB8: AD E4 11     LDA $11E4		Leap flag?
C2/5DBB: 89 02 00     BIT #$0002
C2/5DBE: D0 0F        BNE $5DD0
C2/5DC0: 18           CLC
C2/5DC2: BD 8C 3D     LDA $3D8C,X  (get enemy's XP -- base offset 3D84 is used earlier,
                                    but that's because the function was indexing everybody
                                    on screen, not just enemies)
C2/5DC4: 6D 35 2F     ADC $2F35
C2/5DC7: 8D 35 2F     STA $2F35    (add it to the XP from other enemies)
C2/5DCA: 90 03        BCC $5DCF
C2/5DCC: EE 37 2F     INC $2F37    (if it flowed out of bottom word, increment top word)
C2/5DCF: 18           CLC 
C2/5DD0: BD A0 3D     LDA $3DA0,X  (get enemy's GP)
C2/5DD3: 6D 3E 2F     ADC $2F3E
C2/5DD6: 8D 3E 2F     STA $2F3E    (add it to GP from other enemies)
C2/5DD9: 90 03        BCC $5DDE
C2/5DDB: EE 40 2F     INC $2F40    (if it flowed out of bottom word, increment top word)
C2/5DDE: CA           DEX 
C2/5DDF: CA           DEX 
C2/5DE0: 10 CE        BPL $5DB0    (loop for all 6 enemies)

(Following code divides 24-bit XP gained from battle by 8-bit character quantity.
 Just long divide a 3-digit number by a 1-digit # to better follow the steps)

C2/5DE2: AD 35 2F     LDA $2F35   (bottom 2 bytes of 24-bit(?) XP) 
C2/5DE5: 85 E8        STA $E8
C2/5DE7: AD 36 2F     LDA $2F36   (top 2 bytes of XP)
C2/5DEA: AE 76 3A     LDX $3A76   (Number of characters in party)
C2/5DED: DA           PHX 
C2/5DEE: 20 92 47     JSR $4792  (Divides 16-bit A / 8-bit X
                                  Stores quotient in 16-bit A. Stores remainder in 8-bit X)
C2/5DF1: 85 EC        STA $EC    (save quotient)
C2/5DF3: 86 E9        STX $E9    (save remainder)
C2/5DF5: A5 E8        LDA $E8    ( $E8 = (remainder * 256) + bottom byte of original XP )
C2/5DF7: FA           PLX 
C2/5DF8: 20 92 47     JSR $4792  (divide that by # of characters again)
C2/5DFB: 8D 35 2F     STA $2F35  (save bottom byte of final quotient)
C2/5DFE: A5 EC        LDA $EC    (retrieve top 2 bytes of final quotient)
C2/5E00: 8D 36 2F     STA $2F36  
C2/5E03: 0D 35 2F     ORA $2F35
C2/5E06: F0 06        BEQ $5E0E  (if the XP per character is zero, branch)
C2/5E08: A9 27 00     LDA #$0027
C2/5E0B: 20 D4 5F     JSR $5FD4
C2/5E0E: E2 20        SEP #$20    (set 8-bit Accumulator)
C2/5E10: A0 06 00     LDY #$0006
C2/5E13: B9 18 30     LDA $3018,Y 
C2/5E16: 2C 74 3A     BIT $3A74
C2/5E19: F0 58        BEQ $5E73   (Branch if character dead)
C2/5E1B: B9 59 3C     LDA $3C59,Y
C2/5E1E: 29 10        AND #$10    
C2/5E20: F0 0D        BEQ $5E2F   (Branch if not x2 Gold)
C2/5E22: 04 F0        TSB $F0
C2/5E24: D0 09        BNE $5E2F   (Branch if gold has already been doubled by another
C2/5E26: 0E 3E 2F     ASL $2F3E
C2/5E29: 2E 3F 2F     ROL $2F3F
C2/5E2C: 2E 40 2F     ROL $2F40  
C2/5E2F: B9 D8 3E     LDA $3ED8,Y (Which character it is)
C2/5E32: C9 00        CMP #$00
C2/5E34: D0 13        BNE $5E49   (Branch if not Terra)
C2/5E36: A5 F1        LDA $F1
C2/5E38: F0 0F        BEQ $5E49
C2/5E3A: 04 F0        TSB $F0
C2/5E3C: A5 FB        LDA $FB     (Number of Magic Points gained from battle)
C2/5E3E: 0A           ASL         (* 2)
C2/5E3F: 6D F6 1C     ADC $1CF6   (Add to Morph supply)
C2/5E42: 90 02        BCC $5E46   (If it didn't overflow, branch)
C2/5E44: A9 FF        LDA #$FF    (Since it DID overflow, just set it to maximum)
C2/5E46: 8D F6 1C     STA $1CF6   (Set Morph supply)
C2/5E49: BE 10 30     LDX $3010,Y (get offset to character info block)
C2/5E4C: 20 35 62     JSR $6235   (Add XP for battle)
C2/5E4F: B9 59 3C     LDA $3C59,Y
C2/5E52: 89 08        BIT #$08
C2/5E54: F0 03        BEQ $5E59   (Branch if not x2 XP)
C2/5E56: 20 35 62     JSR $6235   (Add XP for battle)
C2/5E59: B9 D8 3E     LDA $3ED8,Y (Which character it is)
C2/5E5C: C9 0C        CMP #$0C
C2/5E5E: B0 13        BCS $5E73   (Branch if Gogo or Umaro)
C2/5E60: 20 83 62     JSR $6283   (Stores address for spells known by character in $F4)
C2/5E63: BE 10 30     LDX $3010,Y (get offset to character info block)
C2/5E66: 5A           PHY 
C2/5E67: 20 EF 5F     JSR $5FEF   (Cursed Shield check)
C2/5E6A: BD 1E 16     LDA $161E,X (Esper equipped)
C2/5E6D: 30 03        BMI $5E72   (Branch if no esper equipped)
C2/5E6F: 20 2A 60     JSR $602A   (Learn spells taught by esper)
C2/5E72: 7A           PLY 
C2/5E73: 88           DEY 
C2/5E74: 88           DEY 
C2/5E75: 10 9C        BPL $5E13   (Check next character)
C2/5E77: A5 F1        LDA $F1
C2/5E79: 25 F0        AND $F0
C2/5E7B: F0 12        BEQ $5E8F
C2/5E7D: A5 FB        LDA $FB     (Magic points gained from battle)
C2/5E7F: F0 0E        BEQ $5E8F
C2/5E81: 8D 35 2F     STA $2F35
C2/5E84: 9C 36 2F     STZ $2F36
C2/5E87: 9C 37 2F     STZ $2F37
C2/5E8A: A9 35        LDA #$35
C2/5E8C: 20 D4 5F     JSR $5FD4
C2/5E8F: A0 06 00     LDY #$0006
C2/5E92: B9 18 30     LDA $3018,Y
C2/5E95: 2C 74 3A     BIT $3A74
C2/5E98: F0 1F        BEQ $5EB9
C2/5E9A: B9 D8 3E     LDA $3ED8,Y
C2/5E9D: 20 83 62     JSR $6283
C2/5EA0: BE 10 30     LDX $3010,Y  (get offset to character info block)
C2/5EA3: 98           TYA 
C2/5EA4: 4A           LSR 
C2/5EA5: 8D 38 2F     STA $2F38
C2/5EA8: A9 2E        LDA #$2E
C2/5EAA: 85 F2        STA $F2
C2/5EAC: 20 6D 60     JSR $606D
C2/5EAF: B9 D8 3E     LDA $3ED8,Y
C2/5EB2: C9 0C        CMP #$0C
C2/5EB4: B0 03        BCS $5EB9
C2/5EB6: 20 33 61     JSR $6133
C2/5EB9: 88           DEY 
C2/5EBA: 88           DEY 
C2/5EBB: 10 D5        BPL $5E92
C2/5EBD: E2 10        SEP #$10
C2/5EBF: 7B           TDC 
C2/5EC0: 38           SEC 
C2/5EC1: A2 02        LDX #$02
C2/5EC3: A0 17        LDY #$17
C2/5EC5: 6A           ROR 
C2/5EC6: 90 02        BCC $5ECA
C2/5EC8: 6A           ROR 
C2/5EC9: CA           DEX 
C2/5ECA: 3C 84 3A     BIT $3A84,X
C2/5ECD: F0 13        BEQ $5EE2
C2/5ECF: 48           PHA 
C2/5ED0: 1D 29 1D     ORA $1D29,X
C2/5ED3: 9D 29 1D     STA $1D29,X
C2/5ED6: 98           TYA 
C2/5ED7: 69 8B        ADC #$8B
C2/5ED9: 8D 35 2F     STA $2F35
C2/5EDC: A9 2D        LDA #$2D
C2/5EDE: 20 D4 5F     JSR $5FD4
C2/5EE1: 68           PLA 
C2/5EE2: 88           DEY 
C2/5EE3: 10 E0        BPL $5EC5
C2/5EE5: AD 0A 30     LDA $300A     (which character is Mog)
C2/5EE8: 30 16        BMI $5F00     (branch if not present in party)
C2/5EEA: AE E2 11     LDX $11E2     (get combat background)
C2/5EED: BF 5B 8E ED  LDA $ED8E5B,X (get corresponding dance #)
C2/5EF1: 30 0D        BMI $5F00     (branch if it's negative - presumably FF)
C2/5EF3: 20 17 52     JSR $5217
C2/5EF6: 0C 4C 1D     TSB $1D4C     (turn on dance in known dances)
C2/5EF9: D0 05        BNE $5F00     (if it was already on, don't display the
                                     "Learned Dance!" message)
C2/5EFB: A9 40        LDA #$40
C2/5EFD: 20 D4 5F     JSR $5FD4
C2/5F00: A5 F0        LDA $F0
C2/5F02: 4A           LSR
C2/5F03: 90 05        BCC $5F0A
C2/5F05: A9 2A        LDA #$2A
C2/5F07: 20 D4 5F     JSR $5FD4 
C2/5F0A: A2 05        LDX #$05    (with up to 6 different enemies, you can win up to
                                   6 different types of items)
C2/5F0C: 7B           TDC         (clear A)
C2/5F0D: 3A           DEC         (set A to FF)
C2/5F0E: 95 F0        STA $F0,X   (item type)
C2/5F10: 74 F6        STZ $F6,X   (quantity of that item)
C2/5F12: CA           DEX
C2/5F13: 10 F7        BPL $5F0C   (loop. so in all 6 item slots, we'll have 0 of item #255)
C2/5F15: A0 0A        LDY #$0A    (point to last enemy)
C2/5F17: B9 EC 3E     LDA $3EEC,Y (check enemy's 1st status byte)
C2/5F1A: 89 C2        BIT #$C2    (Petrify, Wound, or Zombied?)
C2/5F1C: F0 30        BEQ $5F4E   (if not, skip this enemy)
C2/5F1E: 20 5A 4B     JSR $4B5A   (random #, 0 to 255)
C2/5F21: C9 20        CMP #$20    (Carry clear if A < 20h, set otherwise.
                                   this means we'll use the Rare dropped item slot 1/8 of
                                   the time, and the Common 7/8 of the time)
C2/5F23: C2 30        REP #$30    (Acc and Index regs 16-bit)
C2/5F25: 7B           TDC         (clear A)
C2/5F26: 6A           ROR         (put Carry in highest bit of A)
C2/5F27: 79 01 20     ADC $2001,Y (enemy number?  $2001 is filled by code handling F2 script
                                   command, which handles enemy formation)
C2/5F2A: 0A           ASL
C2/5F2B: 2A           ROL         (multiply enemy # by 4, as Stolen+Dropped Item block is 4 bytes)
                                  (and put Carry into lowest bit.  Rare when bit is 0, Common for 1)
C2/5F2C: AA           TAX         (updated index with enemy num and rare/common slot)
C2/5F2D: BF 02 30 CF  LDA $CF3002,X  (item dropped - CF3002 is rare, CF3003 is common)
C2/5F31: E2 30        SEP #$30    (Acc and index regs 8-bit)
C2/5F33: C9 FF        CMP #$FF    (does chosen enemy slot have empty FF item?)
C2/5F35: F0 17        BEQ $5F4E   (if so, skip to next enemy)
C2/5F37: A2 05        LDX #$05
C2/5F39: D5 F0        CMP $F0,X   (is Item # the same as any of the others won?)
C2/5F3B: F0 0F        BEQ $5F4C   (if so, branch to increment its quantity)
C2/5F3D: EB           XBA
C2/5F3E: B5 F0        LDA $F0,X   (if not, check if current battle slot is empty)
C2/5F40: 1A           INC
C2/5F41: D0 05        BNE $5F48   (if it wasn't empty, branch to check another battle slot)
C2/5F43: EB           XBA
C2/5F44: 95 F0        STA $F0,X   (if it was, we can store our item there)
C2/5F46: 80 04        BRA $5F4C
C2/5F48: EB           XBA
C2/5F49: CA           DEX
C2/5F4A: 10 ED        BPL $5F39   (compare item won to next slot)
C2/5F4C: F6 F6        INC $F6,X   (increment the quantity of the item won)
C2/5F4E: 88           DEY
C2/5F4F: 88           DEY         (move down to next enemy)
C2/5F50: 10 C5        BPL $5F17   (loop for all the critters)
C2/5F52: A2 05        LDX #$05
C2/5F54: B5 F0        LDA $F0,X
C2/5F56: C9 FF        CMP #$FF
C2/5F58: F0 1B        BEQ $5F75
C2/5F5A: 8D 35 2F     STA $2F35
C2/5F5D: 20 DC 54     JSR $54DC
C2/5F60: B5 F6        LDA $F6,X
C2/5F62: 8D 38 2F     STA $2F38
C2/5F65: 8D 75 2E     STA $2E75
C2/5F68: 20 79 62     JSR $6279
C2/5F6B: A9 20        LDA #$20
C2/5F6D: D6 F6        DEC $F6,X
C2/5F6F: F0 01        BEQ $5F72
C2/5F71: 1A           INC 
C2/5F72: 20 D4 5F     JSR $5FD4
C2/5F75: CA           DEX 
C2/5F76: 10 DC        BPL $5F54
C2/5F78: AD 3E 2F     LDA $2F3E
C2/5F7B: 0D 3F 2F     ORA $2F3F
C2/5F7E: 0D 40 2F     ORA $2F40
C2/5F81: F0 42        BEQ $5FC5
C2/5F83: AD 3E 2F     LDA $2F3E
C2/5F86: 8D 38 2F     STA $2F38
C2/5F89: AD 3F 2F     LDA $2F3F
C2/5F8C: 8D 39 2F     STA $2F39
C2/5F8F: AD 40 2F     LDA $2F40
C2/5F92: 8D 3A 2F     STA $2F3A
C2/5F95: A9 26        LDA #$26
C2/5F97: 20 D4 5F     JSR $5FD4
C2/5F9A: 18           CLC 
C2/5F9B: A2 FD        LDX #$FD
C2/5F9D: BD 63 17     LDA $1763,X
C2/5FA0: 7D 41 2E     ADC $2E41,X
C2/5FA3: 9D 63 17     STA $1763,X
C2/5FA6: E8           INX 
C2/5FA7: D0 F4        BNE $5F9D

(The following loops will compare the party's GP (held in $1860 - $1862) to
 9999999, and if it exceeds that amount, cap it at 9999999.)
C2/5FA9: A2 02        LDX #$02        (start pointing to topmost bytes of party GP
                                       and GP limit)                              
C2/5FAB: BF C7 5F C2  LDA $C25FC7,X   (get current byte of GP limit)
C2/5FAF: DD 60 18     CMP $1860,X     (compare to corresponding byte of party GP)
C2/5FB2: F0 0E        BEQ $5FC2       (if the byte values match, we don't know how
                                       the overall 24-bit values compare yet, so
                                       go check the next lowest byte)
C2/5FB4: B0 0F        BCS $5FC5       (if this byte of the GP limit exceeds the
                                       corresponding byte of the party GP, we know
                                       the overall value is also higher, so there's
                                       no need to alter anything or compare further)
C2/5FB6: A2 02        LDX #$02        (if we reached here, we know party GP must
                                       exceed the 9999999 limit, so cap it.)
C2/5FB8: BF C7 5F C2  LDA $C25FC7,X
C2/5FBC: 9D 60 18     STA $1860,X
C2/5FBF: CA           DEX 
C2/5FC0: 10 F6        BPL $5FB8       (update all 3 bytes of the party's GP)
C2/5FC2: CA           DEX 
C2/5FC3: 10 E6        BPL $5FAB
C2/5FC5: 28           PLP 
C2/5FC6: 60           RTS 

C2/5FC7 data

C2/5FC7: 7F 96 98  (GP cap: 9999999)

C2/5FCA unknow

C2/5FCA: 48           PHA
C2/5FCB: A9 01        LDA #$01
C2/5FCD: 0C BC 3E     TSB $3EBC
C2/5FD0: 20 03 49     JSR $4903
C2/5FD3: 68           PLA 
C2/5FD4: 08           PHP 
C2/5FD5: E2 20        SEP #$20
C2/5FD7: C9 FF        CMP #$FF
C2/5FD9: F0 12        BEQ $5FED
C2/5FDB: 8D 6F 2D     STA $2D6F
C2/5FDE: A9 02        LDA #$02
C2/5FE0: 8D 6E 2D     STA $2D6E
C2/5FE3: A9 FF        LDA #$FF
C2/5FE5: 8D 72 2D     STA $2D72
C2/5FE8: A9 04        LDA #$04
C2/5FEA: 20 11 64     JSR $6411
C2/5FED: 28           PLP 
C2/5FEE: 60           RTS 

C2/5FEF unknow

C2/5FEF: DA           PHX
C2/5FF0: A0 06 00     LDY #$0006  (Check all equipment and relic slots)
C2/5FF3: BD 1F 16     LDA $161F,X (Item equipped, X determines slot to check)
C2/5FF6: C9 FF        CMP #$FF
C2/5FF8: F0 2A        BEQ $6024   (Branch if no item equipped)
C2/5FFA: C9 66        CMP #$66
C2/5FFC: D0 0E        BNE $600C   (Branch if no cursed shield equipped)
C2/5FFE: EE C0 3E     INC $3EC0   (Increment number of battles fought with cursed shield)
C2/6001: D0 09        BNE $600C   (Branch if not 256 battles)
C2/6003: A9 01        LDA #$01
C2/6005: 04 F0        TSB $F0
C2/6007: A9 67        LDA #$67
C2/6009: 9D 1F 16     STA $161F,X (Change to Paladin Shield)
C2/600C: EB           XBA 
C2/600D: A9 1E        LDA #$1E
C2/600F: 20 81 47     JSR $4781
C2/6012: DA           PHX 
C2/6013: 5A           PHY 
C2/6014: AA           TAX 
C2/6015: 7B           TDC 
C2/6016: BF 04 50 D8  LDA $D85004,X (Spell item teaches)
C2/601A: A8           TAY 
C2/601B: BF 03 50 D8  LDA $D85003,X (Rate spell is learned)
C2/601F: 20 4B 60     JSR $604B     (Learn spell for equipped item)
C2/6022: 7A           PLY 
C2/6023: FA           PLX 
C2/6024: E8           INX         (Check next equipment slot)
C2/6025: 88           DEY 
C2/6026: D0 CB        BNE $5FF3   (Branch if not last slot to check)
C2/6028: FA           PLX 
C2/6029: 60           RTS