Find Formation Palette Index (REQUIRE.OUT)

From Final Fantasy Hacktics Wiki
(Redirected from 001c5458 - 001c58cc)
Jump to navigation Jump to search

< REQUIRE.OUT

# WORLD.BIN: Find Formation Palette Index
# ATTACK.OUT: Find Formation Palette Index (ATTACK.OUT)

001c5458: 27bdffb8 addiu r29,r29,0xffb8
001c545c: 3c040002 lui r4,0x0002
001c5460: afbf0040 sw r31,0x0040(r29)
001c5464: afb7003c sw r23,0x003c(r29)
001c5468: afb60038 sw r22,0x0038(r29)
001c546c: afb50034 sw r21,0x0034(r29)
001c5470: afb40030 sw r20,0x0030(r29)
001c5474: afb3002c sw r19,0x002c(r29)
001c5478: afb20028 sw r18,0x0028(r29)
001c547c: afb10024 sw r17,0x0024(r29)
001c5480: 0c011105 jal 0x00044414			00044414 - 000444d8
001c5484: afb00020 sw r16,0x0020(r29)
001c5488: 3c038016 lui r3,0x8016
001c548c: 94635fda lhu r3,0x5fda(r3)
001c5490: 00000000 nop
001c5494: 1060000b beq r3,r0,0x001c54c4
001c5498: 00409021 addu r18,r2,r0
001c549c: 3c028004 lui r2,0x8004
001c54a0: 24424954 addiu r2,r2,0x4954
001c54a4: 3c018017 lui r1,0x8017
001c54a8: ac223ca8 sw r2,0x3ca8(r1)
001c54ac: 340418ba ori r4,r0,0x18ba
001c54b0: 3c050002 lui r5,0x0002
001c54b4: 0c0533ad jal 0x0014ceb4			Call Inner Subroutine
001c54b8: 02403021 addu r6,r18,r0
001c54bc: 08071548 j 0x001c5520
001c54c0: 00008821 addu r17,r0,r0
001c54c4: 3c04801d lui r4,0x801d
001c54c8: 24840cf4 addiu r4,r4,0x0cf4
001c54cc: 0c009258 jal 0x00024960			00024960 - 000249c0
001c54d0: 02402821 addu r5,r18,r0
001c54d4: 3c04801d lui r4,0x801d
001c54d8: 24840cfc addiu r4,r4,0x0cfc
001c54dc: 34058000 ori r5,r0,0x8000
001c54e0: 0c009258 jal 0x00024960			00024960 - 000249c0
001c54e4: 02452821 addu r5,r18,r5
001c54e8: 3c04801d lui r4,0x801d
001c54ec: 24840d04 addiu r4,r4,0x0d04
001c54f0: 3c050001 lui r5,0x0001
001c54f4: 0c009258 jal 0x00024960			00024960 - 000249c0
001c54f8: 02452821 addu r5,r18,r5
001c54fc: 3c050001 lui r5,0x0001
001c5500: 34a58000 ori r5,r5,0x8000
001c5504: 3c04801d lui r4,0x801d
001c5508: 24840d0c addiu r4,r4,0x0d0c
001c550c: 0c009258 jal 0x00024960			00024960 - 000249c0
001c5510: 02452821 addu r5,r18,r5
001c5514: 0c0091b5 jal 0x000246d4			000246d4 - 0002473c
001c5518: 00002021 addu r4,r0,r0
001c551c: 00008821 addu r17,r0,r0
001c5520: 34160014 ori r22,r0,0x0014
001c5524: 3c15801d lui r21,0x801d
001c5528: 26b57db4 addiu r21,r21,0x7db4
001c552c: 3c17801d lui r23,0x801d
001c5530: 26f77dc4 addiu r23,r23,0x7dc4
001c5534: 3c14801d lui r20,0x801d
001c5538: 26947dbc addiu r20,r20,0x7dbc
001c553c: 123600d6 beq r17,r22,0x001c5898
001c5540: 00000000 nop
001c5544: 0c0166bc jal 0x00059af0			Get Party Data Pointer
001c5548: 02202021 addu r4,r17,r0
001c554c: 00408021 addu r16,r2,r0
001c5550: 92030000 lbu r3,0x0000(r16)
001c5554: 00000000 nop
001c5558: 2c620080 sltiu r2,r3,0x0080
001c555c: 14400026 bne r2,r0,0x001c55f8
001c5560: 00603821 addu r7,r3,r0
001c5564: 34020080 ori r2,r0,0x0080
001c5568: 1462000a bne r3,r2,0x001c5594
001c556c: 34020081 ori r2,r0,0x0081
001c5570: 92020002 lbu r2,0x0002(r16)
001c5574: 00000000 nop
001c5578: 2443ffb6 addiu r3,r2,0xffb6
001c557c: 00032040 sll r4,r3,0x01
001c5580: 3403005d ori r3,r0,0x005d
001c5584: 14430014 bne r2,r3,0x001c55d8
001c5588: 24870060 addiu r7,r4,0x0060
001c558c: 08071576 j 0x001c55d8
001c5590: 2487005e addiu r7,r4,0x005e
001c5594: 1462000a bne r3,r2,0x001c55c0
001c5598: 00000000 nop
001c559c: 92020002 lbu r2,0x0002(r16)
001c55a0: 00000000 nop
001c55a4: 2443ffb6 addiu r3,r2,0xffb6
001c55a8: 00032040 sll r4,r3,0x01
001c55ac: 3403005d ori r3,r0,0x005d
001c55b0: 14430009 bne r2,r3,0x001c55d8
001c55b4: 24870061 addiu r7,r4,0x0061
001c55b8: 08071576 j 0x001c55d8
001c55bc: 2487005f addiu r7,r4,0x005f
001c55c0: 92040002 lbu r4,0x0002(r16)
001c55c4: 0c016a29 jal 0x0005a8a4			Get Job Data Pointer
001c55c8: 00000000 nop
001c55cc: 3c01801d lui r1,0x801d
001c55d0: ac227db0 sw r2,0x7db0(r1)
001c55d4: 9047002d lbu r7,0x002d(r2)
001c55d8: 92030002 lbu r3,0x0002(r16)
001c55dc: 3402005b ori r2,r0,0x005b
001c55e0: 14620002 bne r3,r2,0x001c55ec
001c55e4: 3402005c ori r2,r0,0x005c
001c55e8: 34070082 ori r7,r0,0x0082
001c55ec: 14620003 bne r3,r2,0x001c55fc
001c55f0: 00071040 sll r2,r7,0x01
001c55f4: 34070083 ori r7,r0,0x0083
001c55f8: 00071040 sll r2,r7,0x01
001c55fc: 92030000 lbu r3,0x0000(r16)
001c5600: 3c01801d lui r1,0x801d
001c5604: 00220821 addu r1,r1,r2
001c5608: 94270b3c lhu r7,0x0b3c(r1)              # r7 = Formation Sprite value
001c560c: 14600002 bne r3,r0,0x001c5618
001c5610: 34020082 ori r2,r0,0x0082
001c5614: 00003821 addu r7,r0,r0
001c5618: 14620009 bne r3,r2,0x001c5640
001c561c: 3c026666 lui r2,0x6666
001c5620: 3c02801d lui r2,0x801d
001c5624: 8c427db0 lw r2,0x7db0(r2)
001c5628: 00000000 nop
001c562c: 9042002e lbu r2,0x002e(r2)              # r2 = monster palette?
001c5630: 00000000 nop
001c5634: 00021280 sll r2,r2,0x0a                 # r2 = Monster palette * 0x400
001c5638: 00e23825 or r7,r7,r2                    # r7 = Formation Sprite & Monster palette * 0x400
001c563c: 3c026666 lui r2,0x6666
001c5640: 34426667 ori r2,r2,0x6667
001c5644: 30f000ff andi r16,r7,0x00ff             # r16 = Formation Sprite
001c5648: 02020018 mult r16,r2                    # Formation Sprite * (6/15) ?
001c564c: 00101fc3 sra r3,r16,0x1f                # r3 = Formation Sprite / 0x80000000 ?? Looking for a negative bit for rounding due to compiler shenanigans?
001c5650: 00001010 mfhi r2                        # r2 = Formation Sprite * (6/15)
001c5654: 00021103 sra r2,r2,0x04                 # r2 = WLDFACE set. (WLDFACE portraits are in sets of 40. Formation Sprite * (6/15) / 16 = / 40.)
001c5658: 00432823 subu r5,r2,r3                  # r5 = WLDFACE set, rounded with the negative bit... IF ONE EXISTED. Which it can't, ever.
001c565c: 30e30c00 andi r3,r7,0x0c00              # r3 = Monster palette * 0x400
001c5660: 00051080 sll r2,r5,0x02                 # r2 = Formation Sprite / 40 * 4 = / 10
001c5664: 00451021 addu r2,r2,r5                  # r2 = WLDFACE row. (WLDFACE have eight portraits per row. Formation Sprite / 40 * 5 = / 8)
001c5668: 000210c0 sll r2,r2,0x03                 # r2 = WLDFACE row * 8
001c566c: 02023823 subu r7,r16,r2                 # r7 = WLDFACE entry within set (WLDFACE value - row = entry).
001c5670: 00e01021 addu r2,r7,r0                  # r2 = WLDFACE entry within set
001c5674: 04e10002 bgez r7,0x001c5680             # Branch if original - recalculated was not negative
001c5678: 00039a83 sra r19,r3,0x0a                # r19 = Monster palette * 0x400 / 0x400 (??????????)
001c567c: 24e20007 addiu r2,r7,0x0007             # If r7 was negative, add 7 to r2
001c5680: 000230c3 sra r6,r2,0x03                 # r6 = WLDFACE entry / 8
001c5684: 00c02021 addu r4,r6,r0                  # r4 = WLDFACE row (Formation sprite / 8)
001c5688: 000410c0 sll r2,r4,0x03                 # r2 = WLDFACE row * 8
001c568c: 00e23023 subu r6,r7,r2                  # r6 = WLDFACE column
001c5690: 3c029249 lui r2,0x9249
001c5694: 34422493 ori r2,r2,0x2493
001c5698: 00003821 addu r7,r0,r0
001c569c: 00041840 sll r3,r4,0x01                 # r3 = Formation sprite / 8 * 2 = / 4
001c56a0: 00641821 addu r3,r3,r4                  # r3 = Formation sprite / 4 + Formation Sprite / 8 = * 3/8
001c56a4: 00031b00 sll r3,r3,0x0c                 # r3 = Formation sprite * 3/8 * 0x1000
001c56a8: 02220018 mult r17,r2
001c56ac: 00061140 sll r2,r6,0x05                 # Even more modified formation sprite * 0x20 (either I'm missing something or this is way above my head, I'm done here)
001c56b0: 00621821 addu r3,r3,r2
001c56b4: 00031843 sra r3,r3,0x01
001c56b8: 000513c0 sll r2,r5,0x0f
001c56bc: 00521021 addu r2,r2,r18
001c56c0: 00434021 addu r8,r2,r3
001c56c4: 34020008 ori r2,r0,0x0008
001c56c8: a6a20004 sh r2,0x0004(r21)
001c56cc: 34020030 ori r2,r0,0x0030
001c56d0: a6a20006 sh r2,0x0006(r21)
001c56d4: 001117c3 sra r2,r17,0x1f
001c56d8: 00001810 mfhi r3
001c56dc: 00711821 addu r3,r3,r17
001c56e0: 00031883 sra r3,r3,0x02
001c56e4: 00621823 subu r3,r3,r2
001c56e8: 000310c0 sll r2,r3,0x03
001c56ec: 00431023 subu r2,r2,r3
001c56f0: 02221023 subu r2,r17,r2
001c56f4: 000210c0 sll r2,r2,0x03
001c56f8: 24420100 addiu r2,r2,0x0100
001c56fc: a6a20000 sh r2,0x0000(r21)
001c5700: 00031040 sll r2,r3,0x01
001c5704: 00431021 addu r2,r2,r3
001c5708: 00021100 sll r2,r2,0x04
001c570c: 24420028 addiu r2,r2,0x0028
001c5710: a6a20002 sh r2,0x0002(r21)
001c5714: 00003021 addu r6,r0,r0
001c5718: 00072900 sll r5,r7,0x04
001c571c: 01002021 addu r4,r8,r0
001c5720: 90830000 lbu r3,0x0000(r4)
001c5724: 00a61021 addu r2,r5,r6
001c5728: 24c60001 addiu r6,r6,0x0001
001c572c: 00571021 addu r2,r2,r23
001c5730: a0430000 sb r3,0x0000(r2)
001c5734: 28c20010 slti r2,r6,0x0010
001c5738: 1440fff9 bne r2,r0,0x001c5720
001c573c: 24840001 addiu r4,r4,0x0001
001c5740: 24e70001 addiu r7,r7,0x0001
001c5744: 28e20030 slti r2,r7,0x0030
001c5748: 1440fff2 bne r2,r0,0x001c5714
001c574c: 25080080 addiu r8,r8,0x0080
001c5750: 3c04801d lui r4,0x801d
001c5754: 24847db4 addiu r4,r4,0x7db4
001c5758: 16360003 bne r17,r22,0x001c5768
001c575c: 00000000 nop
001c5760: 3c04801d lui r4,0x801d
001c5764: 24840ce4 addiu r4,r4,0x0ce4
001c5768: 3c05801d lui r5,0x801d
001c576c: 24a57dc4 addiu r5,r5,0x7dc4
001c5770: 0c00923f jal 0x000248fc			? 0x248fc
001c5774: 00000000 nop
001c5778: 3c025555 lui r2,0x5555
001c577c: 34425556 ori r2,r2,0x5556
001c5780: 02220018 mult r17,r2
001c5784: 3c046666 lui r4,0x6666
001c5788: 34846667 ori r4,r4,0x6667
001c578c: 34020010 ori r2,r0,0x0010
001c5790: 00001810 mfhi r3
001c5794: a6820004 sh r2,0x0004(r20)
001c5798: 34020001 ori r2,r0,0x0001
001c579c: 02040018 mult r16,r4
001c57a0: a6820006 sh r2,0x0006(r20)
001c57a4: 001117c3 sra r2,r17,0x1f
001c57a8: 00621823 subu r3,r3,r2
001c57ac: 00031040 sll r2,r3,0x01
001c57b0: 00431021 addu r2,r2,r3
001c57b4: 02221023 subu r2,r17,r2
001c57b8: 00021100 sll r2,r2,0x04
001c57bc: 24420100 addiu r2,r2,0x0100
001c57c0: a6830002 sh r3,0x0002(r20)
001c57c4: 00101fc3 sra r3,r16,0x1f
001c57c8: a6820000 sh r2,0x0000(r20)
001c57cc: 00001010 mfhi r2
001c57d0: 00021103 sra r2,r2,0x04
001c57d4: 00432823 subu r5,r2,r3
001c57d8: 00051080 sll r2,r5,0x02
001c57dc: 00451021 addu r2,r2,r5
001c57e0: 000210c0 sll r2,r2,0x03
001c57e4: 02023823 subu r7,r16,r2
001c57e8: 04e10002 bgez r7,0x001c57f4
001c57ec: 00e01021 addu r2,r7,r0
001c57f0: 24e20003 addiu r2,r7,0x0003
001c57f4: 00023083 sra r6,r2,0x02
001c57f8: 00c02021 addu r4,r6,r0
001c57fc: 00041080 sll r2,r4,0x02
001c5800: 00e23023 subu r6,r7,r2
001c5804: 1260000e beq r19,r0,0x001c5840
001c5808: 00803821 addu r7,r4,r0
001c580c: 3c022aaa lui r2,0x2aaa
001c5810: 3442aaab ori r2,r2,0xaaab
001c5814: 2604ffc1 addiu r4,r16,0xffc1
001c5818: 00820018 mult r4,r2
001c581c: 02603021 addu r6,r19,r0
001c5820: 00041fc3 sra r3,r4,0x1f
001c5824: 00001010 mfhi r2
001c5828: 00432823 subu r5,r2,r3
001c582c: 00051040 sll r2,r5,0x01
001c5830: 00451021 addu r2,r2,r5
001c5834: 00021040 sll r2,r2,0x01
001c5838: 00822023 subu r4,r4,r2
001c583c: 2487000a addiu r7,r4,0x000a
001c5840: 00071200 sll r2,r7,0x08
001c5844: 00061980 sll r3,r6,0x06
001c5848: 3404f000 ori r4,r0,0xf000
001c584c: 00641821 addu r3,r3,r4
001c5850: 00431021 addu r2,r2,r3
001c5854: 16360005 bne r17,r22,0x001c586c
001c5858: 00021043 sra r2,r2,0x01
001c585c: 3c04801d lui r4,0x801d
001c5860: 24840cec addiu r4,r4,0x0cec
001c5864: 0807161d j 0x001c5874
001c5868: 00052bc0 sll r5,r5,0x0f
001c586c: 02802021 addu r4,r20,r0
001c5870: 00052bc0 sll r5,r5,0x0f
001c5874: 02452821 addu r5,r18,r5
001c5878: 0c00923f jal 0x000248fc			? 0x248fc
001c587c: 00a22821 addu r5,r5,r2
001c5880: 0c0091b5 jal 0x000246d4			000246d4 - 0002473c
001c5884: 00002021 addu r4,r0,r0
001c5888: 26310001 addiu r17,r17,0x0001
001c588c: 2a220015 slti r2,r17,0x0015
001c5890: 1440ff2a bne r2,r0,0x001c553c
001c5894: 00000000 nop
001c5898: 0c011273 jal 0x000449cc			000449cc - 000449e8
001c589c: 02402021 addu r4,r18,r0
001c58a0: 8fbf0040 lw r31,0x0040(r29)
001c58a4: 8fb7003c lw r23,0x003c(r29)
001c58a8: 8fb60038 lw r22,0x0038(r29)
001c58ac: 8fb50034 lw r21,0x0034(r29)
001c58b0: 8fb40030 lw r20,0x0030(r29)
001c58b4: 8fb3002c lw r19,0x002c(r29)
001c58b8: 8fb20028 lw r18,0x0028(r29)
001c58bc: 8fb10024 lw r17,0x0024(r29)
001c58c0: 8fb00020 lw r16,0x0020(r29)
001c58c4: 27bd0048 addiu r29,r29,0x0048
001c58c8: 03e00008 jr r31
001c58cc: 00000000 nop