Math Skill targeting calculations
Jump to navigation
Jump to search
# BATTLE.BIN offset 0x114680 # this is the code that performs calculations for math skill targeting # prime numbers are located at SCUS_942.21 offset 0x56998 # check that it is a prime number 00114680: 32220008 andi r2,r17,0x0008 # r17 contains the flag of the current math skill operation 00114684: 1040000e beq r2,r0,0x001146c0 # proceed to "divisible by 5" section 00114688: 00003021 addu r6,r0,r0 0011468c: 00001821 addu r3,r0,r0 00114690: 00a02021 addu r4,r5,r0 00114694: 3c018006 lui r1,0x8006 00114698: 00230821 addu r1,r1,r3 0011469c: 90226198 lbu r2,0x6198(r1) # read prime numbers from memory address 0x66198 001146a0: 00000000 nop 001146a4: 10440026 beq r2,r4,0x00114740 # success! 001146a8: 24630001 addiu r3,r3,0x0001 001146ac: 28620036 slti r2,r3,0x0036 001146b0: 10400024 beq r2,r0,0x00114744 # failure... 001146b4: 00000000 nop 001146b8: 0805eda5 j 0x00114694 # try the next number in the prime number table 001146bc: 00000000 nop # check that it is divisible by 5 001146c0: 32220004 andi r2,r17,0x0004 001146c4: 1040000b beq r2,r0,0x001146f4 # proceed to "divisible by 4" section 001146c8: 3c02cccc lui r2,0xcccc 001146cc: 3442cccd ori r2,r2,0xcccd 001146d0: 00a20019 multu r5,r2 001146d4: 00001810 mfhi r3 001146d8: 00031882 srl r3,r3,0x02 001146dc: 00031080 sll r2,r3,0x02 001146e0: 00431021 addu r2,r2,r3 001146e4: 00a21023 subu r2,r5,r2 001146e8: 304200ff andi r2,r2,0x00ff 001146ec: 10400014 beq r2,r0,0x00114740 # success! 001146f0: 00000000 nop # check that it is divisible by 4 001146f4: 32220002 andi r2,r17,0x0002 001146f8: 10400003 beq r2,r0,0x00114708 # proceed to "divisible by 3" section 001146fc: 30820003 andi r2,r4,0x0003 00114700: 1040000f beq r2,r0,0x00114740 # success! 00114704: 00000000 nop # check that it is divisible by 3 00114708: 32220001 andi r2,r17,0x0001 0011470c: 1040000d beq r2,r0,0x00114744 # failure... 00114710: 3c02aaaa lui r2,0xaaaa 00114714: 3442aaab ori r2,r2,0xaaab 00114718: 308400ff andi r4,r4,0x00ff 0011471c: 00820019 multu r4,r2 00114720: 00001810 mfhi r3 00114724: 00031842 srl r3,r3,0x01 00114728: 00031040 sll r2,r3,0x01 0011472c: 00431021 addu r2,r2,r3 00114730: 00822023 subu r4,r4,r2 00114734: 308400ff andi r4,r4,0x00ff 00114738: 14800002 bne r4,r0,0x00114744 # failure... 0011473c: 00000000 nop 00114740: 34060001 ori r6,r0,0x0001 # success! 00114744: 10c0000b beq r6,r0,0x00114774 00114748: 00000000 nop 0011474c: 0c060428 jal 0x0011a0a0