Calculator Routine
Jump to navigation
Jump to search
Calculator Routine 0017b4d0: 27bdffb0 addiu r29,r29,0xffb0 0017b4d4: afb50044 sw r21,0x0044(r29) 0017b4d8: 0000a821 addu r21,r0,r0 0017b4dc: 27a50018 addiu r5,r29,0x0018 0017b4e0: afbf004c sw r31,0x004c(r29) 0017b4e4: afb60048 sw r22,0x0048(r29) 0017b4e8: afb40040 sw r20,0x0040(r29) 0017b4ec: afb3003c sw r19,0x003c(r29) 0017b4f0: afb20038 sw r18,0x0038(r29) 0017b4f4: afb10034 sw r17,0x0034(r29) 0017b4f8: 0c01788b jal 0x0005e22c 0017b4fc: afb00030 sw r16,0x0030(r29) 0017b500: 3407fe62 ori r7,r0,0xfe62 0017b504: 97a6001c lhu r6,0x001c(r29) 0017b508: 93a30018 lbu r3,0x0018(r29) 0017b50c: 97a5001e lhu r5,0x001e(r29 ) 0017b510: 00c72021 addu r4,r6,r7 r4 = 00-07 if calculator skills, r6 = CT/Height /LVL/EXP Parameter? 0017b514: 000310c0 sll r2,r3,0x03 0017b518: 00431023 subu r2,r2,r3 0017b51c: 00021180 sll r2,r2,0x06 0017b520: 3c038019 lui r3,0x8019 0017b524: 246308cc addiu r3,r3,0x08cc 0017b528: 3084ffff andi r4,r4,0xffff 0017b52c: 2c840008 sltiu r4,r4,0x0008 0017b530: 10800019 beq r4,r0,0x0017b598 if r4 isn't 00-07, GOTO END and r2 = 0xFFFF 0017b534: 0043b021 addu r22,r2,r3 0017b538: 00a71021 addu r2,r5,r7 r2 = 00-07 if calculator skills, r5 = Prime/5/4/3 Parameter? 0017b53c: 3042ffff andi r2,r2,0xffff 0017b540: 2c420008 sltiu r2,r2,0x0008 0017b544: 10400014 beq r2,r0,0x0017b598 if r2 isn't 00-07, GOTO END and r2 = 0xFFFF 0017b548: 00061c00 sll r3,r6,0x10 0017b54c: 00031c03 sra r3,r3,0x10 0017b550: 3c048006 lui r4,0x8006 0017b554: 24840eb6 addiu r4,r4,0x0eb6 0017b558: 00641821 addu r3,r3,r4 0017b55c: 00051400 sll r2,r5,0x10 0017b560: 00021403 sra r2,r2,0x10 0017b564: 00441021 addu r2,r2,r4 0017b568: 90730000 lbu r19,0x0000(r3) 0017b56c: 90510000 lbu r17,0x0000(r2) 0017b570: 326300f0 andi r3,r19,0x00f0 0017b574: 10600008 beq r3,r0,0x0017b598 0017b578: 3222000f andi r2,r17,0x000f 0017b57c: 10400006 beq r2,r0,0x0017b598 0017b580: 3262000f andi r2,r19,0x000f 0017b584: 14400080 bne r2,r0,0x0017b788 0017b588: 2402ffff addiu r2,r0,0xffff 0017b58c: 322200f0 andi r2,r17,0x00f0 0017b590: 10400003 beq r2,r0,0x0017b5a0 0017b594: 00000000 nop 0017b598: 0805ede2 j 0x0017b788 If there aren't 4 Grid Params or 4 Num Params, GOTO END 0017b59c: 2402ffff addiu r2,r0,0xffff 0017b5a0: 0c05ed28 jal 0x0017b4a0 //Initialize Grid 0017b5a4: 00009021 addu r18,r0,r0 0017b5a8: 0000a021 addu r20,r0,r0 0017b5ac: 3c028019 lui r2,0x8019 0017b5b0: 244208cc addiu r2,r2,0x08cc 0017b5b4: 02828021 addu r16,r20,r2 0017b5b8: 92030001 lbu r3,0x0001(r16) 0017b5bc: 340200ff ori r2,r0,0x00ff 0017b5c0: 1062006c beq r3,r2,0x0017b774 If unit doesn't exist, Check NEXT UNIT 0017b5c4: 00000000 nop 0017b5c8: 92020058 lbu r2,0x0058(r16) 0017b5cc: 00000000 nop 0017b5d0: 30420044 andi r2,r2,0x0044 0017b5d4: 14400067 bne r2,r0,0x0017b774 If unit is jumping or crystallized, Check NEXT UNIT 0017b5d8: 00000000 nop 0017b5dc: 92020059 lbu r2,0x0059(r16) 0017b5e0: 00000000 nop 0017b5e4: 30420001 andi r2,r2,0x0001 0017b5e8: 14400062 bne r2,r0,0x0017b774 If unit is treasure boxed, Check NEXT UNIT. 0017b5ec: 00000000 nop 0017b5f0: 92020182 lbu r2,0x0182(r16) 0017b5f4: 00000000 nop 0017b5f8: 30420040 andi r2,r2,0x0040 0017b5fc: 1440005d bne r2,r0,0x0017b774 If unit is riding a chocobo, Check NEXT UNIT 0017b600: 32620080 andi r2,r19,0x0080 0017b604: 1040000a beq r2,r0,0x0017b630 If not CT, GOTO check LEVEL 0017b608: 32620040 andi r2,r19,0x0040 0017b60c: 92040039 lbu r4,0x0039(r16) 0017b610: 00000000 nop 0017b614: 2c820065 sltiu r2,r4,0x0065 0017b618: 10400003 beq r2,r0,0x0017b628 If CT > 100, treat CT as 100. 0017b61c: 00000000 nop 0017b620: 16160016 bne r16,r22,0x0017b67c If Target isn't Self, r5 = CT. 0017b624: 308500ff andi r5,r4,0x00ff 0017b628: 0805ed9e j 0x0017b678 If CT > 100 or Target is Self, CT = 100 0017b62c: 34040064 ori r4,r0,0x0064 0017b630: 10400004 beq r2,r0,0x0017b644 If not LVL, GOTO EXP 0017b634: 32620020 andi r2,r19,0x0020 0017b638: 92040022 lbu r4,0x0022(r16) 0017b63c: 0805ed9f j 0x0017b67c 0017b640: 308500ff andi r5,r4,0x00ff ELSE, r5 = LVL 0017b644: 10400004 beq r2,r0,0x0017b658 If not EXP, GOTO HEight 0017b648: 27a40010 addiu r4,r29,0x0010 0017b64c: 92040021 lbu r4,0x0021(r16) 0017b650: 0805ed9f j 0x0017b67c 0017b654: 308500ff andi r5,r4,0x00ff ELSE, r5 = EXP 0017b658: 0c05f056 jal 0x0017c158 If Height, r5 = Height 0017b65c: 02402821 addu r5,r18,r0 0017b660: 93a40015 lbu r4,0x0015(r29) 0017b664: 00000000 nop 0017b668: 30820001 andi r2,r4,0x0001 0017b66c: 14400041 bne r2,r0,0x0017b774 If ??? is 1, GOTO Check NExt Unit 0017b670: 00000000 nop 0017b674: 00042042 srl r4,r4,0x0 1 0017b678: 308500ff andi r5,r4,0x00ff r5 = r4 / 2, so r4 = ??? = Height in half tiles? If that's the case, then why even run jal 0x17c158? 0017b67c: 10a0003d beq r5,r0,0x0017b774 If ??? = 0 or 1, GOTO Check Next Unit 0017b680: 32220008 andi r2,r17,0x0008 0017b684: 1040000e beq r2,r0,0x0017b6c0 If not Prime, GOTO Check 5 0017b688: 00003021 addu r6,r0,r0 0017b68c: 00001821 addu r3,r0,r0 0017b690: 00a02021 addu r4,r5,r0 0017b694: 3c018006 lui r1,0x8006 0017b698: 00230821 addu r1,r1,r3 0017b69c: 90226198 lbu r2,0x6198(r1) 0017b6a0: 00000000 nop 0017b6a4: 10440026 beq r2,r4,0x0017b740 If Prime = Above Param, Unit = Hit 0017b6a8: 24630001 addiu r3,r3,0x0001 0017b6ac: 28620036 slti r2,r3,0x0036 0017b6b0: 10400024 beq r2,r0,0x0017b744 If no prime = Above Param, Check Next Unit 0017b6b4: 00000000 nop 0017b6b8: 0805eda5 j 0x0017b694 0017b6bc: 00000000 nop 0017b6c0: 32220004 andi r2,r17,0x0004 0017b6c4: 1040000b beq r2,r0,0x0017b6f4 If not 5, GOTO Check 4 0017b6c8: 3c02cccc lui r2,0xcccc 0017b6cc: 3442cccd ori r2,r2,0xcccd 0017b6d0: 00a20019 multu r5,r2 0017b6d4: 00001810 mfhi r3 0017b6d8: 00031882 srl r3,r3,0x02 0017b6dc: 00031080 sll r2,r3,0x02 0017b6e0: 00431021 addu r2,r2,r3 0017b6e4: 00a21023 subu r2,r5,r2 0017b6e8: 304200ff andi r2,r2,0x00ff 0017b6ec: 10400014 beq r2,r0,0x0017b740 If x MOD 5 = 0, Unit = HIT 0017b6f0: 00000000 nop 0017b6f4: 32220002 andi r2,r17,0x0002 0017b6f8: 10400003 beq r2,r0,0x0017b708 If NOT 4, Check 3 0017b6fc: 30820003 andi r2,r4,0x0003 0017b700: 1040000f beq r2,r0,0x0017b740 If X MOD 4 = 0, Check Next unit 0017b704: 00000000 nop 0017b708: 32220001 andi r2,r17,0x0001 0017b70c: 1040000d beq r2,r0,0x0017b744 0017b710: 3c02aaaa lui r2,0xaaaa 0017b714: 3442aaab ori r2,r2,0xaaab 0017b718: 308400ff andi r4,r4,0x00ff 0017b71c: 00820019 multu r4,r2 0017b720: 00001810 mfhi r3 0017b724: 00031842 srl r3,r3,0x01 0017b728: 00031040 sll r2,r3,0x01 0017b72c: 00431021 addu r2,r2,r3 0017b730: 00822023 subu r4,r4,r2 0017b734: 308400ff andi r4,r4,0x00ff 0017b738: 14800002 bne r4,r0,0x0017b744 If X MOD 3 != 0, Check NExt Unit 0017b73c: 00000000 nop 0017b740: 34060001 ori r6,r0,0x0001 0017b744: 10c0000b beq r6,r0,0x0017b774 0017b748: 00000000 nop 0017b74c: 0c060428 jal 0x001810a0 Find X/Y coordinate of target 0017b750: 02002021 addu r4,r16,r0 0017b754: 000210c0 sll r2,r2,0x03 0017b758: 3c038019 lui r3,0x8019 0017b75c: 2463f8cc addiu r3,r3,0xf8cc 0017b760: 00431021 addu r2,r2,r3 0017b764: 90430005 lbu r3,0x0005(r2) 0017b768: 26b50001 addiu r21,r21,0x0001 0017b76c: 34630080 ori r3,r3,0x0080 0017b770: a0430005 sb r3,0x0005(r2) Flag X/Y coordinate as green = target. 0017b774: 26520001 addiu r18,r18,0x0001 0017b778: 2a420015 slti r2,r18,0x0015 0017b77c: 1440ff8b bne r2,r0,0x0017b5ac 0017b780: 269401c0 addiu r20,r20,0x01c0 Pointer = next unit's data. 0017b784: 02a01021 addu r2,r21,r0 RETURN (r2) = # of units hit 0017b788: 8fbf004c lw r31,0x004c(r29) 0017b78c: 8fb60048 lw r22,0x0048(r29) 0017b790: 8fb50044 lw r21,0x0044(r29) 0017b794: 8fb40040 lw r20,0x0040(r29) 0017b798: 8fb3003c lw r19,0x003c(r29) 0017b79c: 8fb20038 lw r18,0x0038(r29) 0017b7a0: 8fb10034 lw r17,0x0034(r29) 0017b7a4: 8fb00030 lw r16,0x0030(r29) 0017b7a8: 27bd0050 addiu r29,r29,0x0050 0017b7ac: 03e00008 jr r31 0017b7b0: 00000000 nop