C1/516B (C1/516B to C1/51FB) S Text CC: [1C 14 XX] [1C 14 XX] If XX is 0x01, this stores the current attacker's gender in working memory. Gender values are as follows: 0x01 = Male 0x02 = Female 0x03 = Neutral If XX is not 0x01, this returns the number of living (not unconscious or diamondized) battlers that are fighting alongside the attacker, capped above at 0x03. This code does not read values from text system memory if XX is 0x00. C1/516B: C2 31 REP #$31 Flags and direct page manipulation C1/516D: 0B PHD C1/516E: 48 PHA C1/516F: 7B TDC C1/5170: 69 EC FF ADC #$FFEC C1/5173: 5B TCD C1/5174: 68 PLA C1/5175: 86 12 STX $12 $12 = arg C1/5177: AE 70 A9 LDX $A970 X = Pointer to current attacker C1/517A: BD 0E 00 LDA $000E,X C1/517D: 29 FF 00 AND #$00FF A = Ally/Opponent flag for current attacker C1/5180: C9 01 00 CMP #$0001 C1/5183: D0 37 BNE $51BC Here the code divides, depending on whether the attacker is an ally or opponent. C1/5185: A6 12 LDX $12 Opponent case C1/5187: E0 01 00 CPX #$0001 C1/518A: F0 15 BEQ $51A1 C1/518C: AD 8A 9F LDA $9F8A Opponent, arg != 0x01 case C1/518F: C9 03 00 CMP #$0003 A = Number of enemies in current battle C1/5192: 90 07 BCC $519B C1/5194: F0 05 BEQ $519B C1/5196: A2 03 00 LDX #$0003 If more than three, cap to three C1/5199: 80 03 BRA $519E C1/519B: AE 8A 9F LDX $9F8A C1/519E: 8A TXA A = Number of enemies in current battle (capped at 0x0003) C1/519F: 80 47 BRA $51E8 C1/51A1: AE 70 A9 LDX $A970 Opponent, arg == 0x01 case C1/51A4: BD 00 00 LDA $0000,X C1/51A7: A0 5E 00 LDY #$005E C1/51AA: 22 F7 8F C0 JSR $C08FF7 C1/51AE: 18 CLC C1/51AF: 69 1A 00 ADC #$001A C1/51B2: AA TAX C1/51B3: BF 89 95 D5 LDA $D59589,X C1/51B7: 29 FF 00 AND #$00FF A = Current attacker's gender (0x01 = Male, 0x02 = Female, 0x03 = Neutral) C1/51BA: 80 2C BRA $51E8 C1/51BC: A6 12 LDX $12 Ally case C1/51BE: E0 01 00 CPX #$0001 C1/51C1: F0 12 BEQ $51D5 C1/51C3: 22 2F 27 C2 JSR $C2272F Ally, arg != 0x01 case C1/51C7: AA TAX A = Number of living player-controlled party members C1/51C8: E0 03 00 CPX #$0003 C1/51CB: 90 05 BCC $51D2 C1/51CD: F0 03 BEQ $51D2 C1/51CF: A2 03 00 LDX #$0003 If more than three, cap to three C1/51D2: 8A TXA A = Number of allies in current battle (capped at 0x0003) C1/51D3: 80 13 BRA $51E8 C1/51D5: AE 70 A9 LDX $A970 Ally, arg == 0x01 case C1/51D8: BD 00 00 LDA $0000,X C1/51DB: C9 02 00 CMP #$0002 Is the ally Paula? C1/51DE: D0 05 BNE $51E5 C1/51E0: A9 02 00 LDA #$0002 If yes: A = 0x0002 (Female) C1/51E3: 80 03 BRA $51E8 C1/51E5: A9 01 00 LDA #$0001 If no: A = 0x0001 (Male) Both cases eventually reach this code. C1/51E8: 85 06 STA $06 C1/51EA: 64 08 STZ $08 C1/51EC: A5 06 LDA $06 C1/51EE: 85 0E STA $0E C1/51F0: A5 08 LDA $08 C1/51F2: 85 10 STA $10 C1/51F4: 20 5D 04 JSR $045D Store $0E+10 in working memory C1/51F7: A9 00 00 LDA #$0000 C1/51FA: 2B PLD C1/51FB: 60 RTS .