0x35A9C0 - 0x35AB18 - Attack / Defense / Critical Hit manipulation for Damage Calculation

LBU T6, $0046 (V0) // Load Move Power to T6

LUI V1, $843C

ADDIU V1, V1, $4DC6 // V1 = 0x801E8126

ANDI T7, T6, $FFFF // Copy Move Power to T7

BEQ T7, R0, $0035AB18 // If Move Power = 0, get out of this function

SH T6, $0000 (V1) // Store Move Power at 0x801E8126

LBU T8, $0047 (V0) // Load Move Type to T8

LUI V1, $843C

LUI A0, $843C

SLTI AT, T8, $0014 // If Physical Move, set AT to 1

BEQ AT, R0, $0035AA58 // If Special Move, jump to 0x35AA58 (LUI V1, $843C)

NOP

LW V1, $523C (V1)

LUI A2, $843C

ADDIU A2, A2, $4DCA // A2 = 0x801E812A

LHU T9, $002C (V1) // Load Defense stat to T9

LUI A3, $843C

SH T9, $0000 (A2)

LBU T0, $004E (V1) // Load "Is Reflect up ?" to T0

SLL T3, T9, $1 // T3 = Defense stat × 2

ANDI T1, T0, $0004

BEQ T1, R0, $0035AA20 // If Reflect is not up, jump to 0x35AA20 (LBU A0, $4DA5 (A0))

NOP

SH T3, $0000 (A2) // Store Defense × 2 in 0x801E812A

(0x35AA20) LBU A0, $4DA5 (A0) // Load Critical Hit to A0

BEQL A0, R0, $0035AA4C // If not a Critical Hit, jump to 0x35AA4C

LHU T6, $002A (V0)

LHU T4, $003A (V1)

LUI A3, $843C

ADDIU A3, A3, $4DC8

SH T4, $0000 (A2)

LHU T5, $0038 (V0)

BEQ R0, R0, $0035AAC0 // Jump to 0x35AAC0 (LHU A1, $0000 (A3))

SH T5, $0000 (A3)

LHU T6, $002A (V0)

(0x35AA4C) ADDIU A3, A3, $4DC8

BEQ R0, R0, $0035AAC0 // Jump to 0x35AAC0 (LHU A1, $0000 (A3))

SH T6, $0000 (A3)

(0x35AA58) LUI V1, $843C

LW V1, $523C (V1)

LUI A2, $843C

ADDIU A2, A2, $4DCA

LHU T7, $0030 (V1) // Load Special stat to T7

LUI A0, $843C

SH T7, $0000 (A2)

LBU T8, $004E (V1) // Light Screen

ANDI T9, T8, $0002

BEQ T9, R0, $0035AA88

SLL T1, T7, $1 // T1 = Special stat × 2

SH T1, $0000 (A2) // Store Special × 2

LBU A0, $4DA5 (A0) // Load Critical Hit to A0

BEQL A0, R0, $0035AAB4 // If not a Critical Hit, jump to 0x35AAB4

LHU T4, $0030 (V0)

LHU T2, $003E (V1)

LUI A3, $843C

ADDIU A3, A3, $4DC8

SH T2, $0000 (A2)

LHU T3, $003E (V0)

BEQ R0, R0, $0035AAC0 // Jump to 0x35AAC0 (LHU A1, $0000 (A3))

SH T3, $0000 (A3)

LHU T4, $0030 (V0)

(0x35AAB4) LUI A3, $843C

ADDIU A3, A3, $4DC8

SH T4, $0000 (A3)

(0x35AAC0) LHU A1, $0000 (A3) // Load Attack stat to A1

ANDI T5, A1, $FF00

BEQL T5, R0, $0035AB00 // If Attack stat < 256, jump to 0x35AAFC (LBU T1, $0026 (V0))

LBU T1, $0026 (V0) // Load Level to T1

LHU V1, $0000 (A2) // Load Defense Stat to V1

SRL T7, A1, $2 // T7 = Attack stat >> 2

ANDI T9, T7, $FFFF

ANDI T6, V1, $FF00

BEQ T6, R0, $0035AAFC // If Defense stat < 256, jump to 0x35AAFC (LBU T1, $0026 (V0))

SRL T8, V1, $2 // T8 = Defense stat >> 2

SH T7, $0000 (A3) // Store T7 to 0x801E8128

BNEZ T9, $0035AAFC // If T9 > 0, jump to 0x35AAFC

SH T8, $0000 (A2) // Store T8 in 0x801E812A

ADDIU T0, R0, $0001

SH T0, $0000 (A3) // Set 0x801E8128 to 1

(0x35AAFC) LBU T1, $0026 (V0) // Load Level to T1

LUI V1, $843C

ADDIU V1, V1, $4DCC // V1 = 0x801E812C

BEQ A0, R0, $0035AB18 // If not a Critical Hit, get out of the function

SH T1, $0000 (V1)

SLL T3, T1, $1 // T3 = Level × 2

SH T3, $0000 (V1) // Store Level × 2 in 0x801E812C

JR RA

Click to expand...