0x6aed0

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: ? 0x6aed0
#       Parameters:
#           r4 = (p1) Struct data
#               First 8 entries are 4-byte values, and final 3 are 1-byte values.
#               Example (from call at 0x6c040): { 1, month + 0x1f, 4, 0, 0, 0, *0x800bb38c, *0x800bb390, output_0x69718.0x00, output_0x69718.0x01, output_0x69718.0x02 }
#           r5 = (p2) ?

8006aed0: 27bdff78 addiu r29,r29,-0x0088
8006aed4: afb10064 sw r17,0x0064(r29)
8006aed8: 00808821 addu r17,r4,r0                       #   p1
8006aedc: afbf0084 sw r31,0x0084(r29)
8006aee0: afbe0080 sw r30,0x0080(r29)
8006aee4: afb7007c sw r23,0x007c(r29)
8006aee8: afb60078 sw r22,0x0078(r29)
8006aeec: afb50074 sw r21,0x0074(r29)
8006aef0: afb40070 sw r20,0x0070(r29)
8006aef4: afb3006c sw r19,0x006c(r29)
8006aef8: afb20068 sw r18,0x0068(r29)
8006aefc: afb00060 sw r16,0x0060(r29)
8006af00: afa50040 sw r5,0x0040(r29)                    #   p2
8006af04: 8e220004 lw r2,0x0004(r17)                    #   p1.0x04 (entry?)
8006af08: 3c038009 lui r3,0x8009
8006af0c: 8c632b2c lw r3,0x2b2c(r3)                     #   *0x80092b2c (= 0x80092b38)
8006af10: 00021080 sll r2,r2,0x02                       #   p1.0x04 * 4
8006af14: 00431021 addu r2,r2,r3                        #   *0x80092b2c + (p1.0x04 * 4)
8006af18: 8c500000 lw r16,0x0000(r2)                    #   ptrBase = *(*0x80092b2c + (p1.0x04 * 4))
8006af1c: 34021000 ori r2,r0,0x1000                     #   0x1000
8006af20: a7a0002a sh r0,0x002a(r29)                    #   sp.0x2a = 0
8006af24: a7a00028 sh r0,0x0028(r29)                    #   sp.0x28 = 0
8006af28: a7a2002e sh r2,0x002e(r29)                    #   sp.0x2e = 0x1000
8006af2c: a7a2002c sh r2,0x002c(r29)                    #   sp.0x2c = 0x1000
8006af30: afa00030 sw r0,0x0030(r29)                    #   sp.0x30 = 0
8006af34: 8e220000 lw r2,0x0000(r17)                    #   p1.0x00
8006af38: 3c128009 lui r18,0x8009
8006af3c: 8e522b30 lw r18,0x2b30(r18)                   #   *0x80092b30 (= 0x8009324c)
8006af40: 30420400 andi r2,r2,0x0400                    #   p1.0x00 & 0x0400
8006af44: 10400008 beq r2,r0,0x8006af68
8006af48: 26240020 addiu r4,r17,0x0020                  #   (p1 + 0x20)
                                                        #   if ((p1.0x00 & 0x0400) != 0) {
8006af4c: 8a220023 lwl r2,0x0023(r17)
8006af50: 9a220020 lwr r2,0x0020(r17)                   #       p1.0x20
8006af54: 00000000 nop
8006af58: aba2003b swl r2,0x003b(r29)
8006af5c: bba20038 swr r2,0x0038(r29)                   #       sp.0x38 = p1.0x20
8006af60: 0801abdc j 0x8006af70
8006af64: 00000000 nop
                                                        #   } else {
8006af68: 0c01a5c6 jal 0x80069718                       #       0x69718 ((p1 + 0x20), (p1 + 0x38));
8006af6c: 27a50038 addiu r5,r29,0x0038
                                                        #   }
8006af70: 93a20038 lbu r2,0x0038(r29)                   #   sp.0x38
8006af74: 93a30039 lbu r3,0x0039(r29)                   #   sp.0x39
8006af78: 93a4003a lbu r4,0x003a(r29)                   #   sp.0x3a
8006af7c: a3a20024 sb r2,0x0024(r29)                    #   sp.0x24 = sp.0x38
8006af80: a3a30025 sb r3,0x0025(r29)                    #   sp.0x25 = sp.0x39
8006af84: a3a40026 sb r4,0x0026(r29)                    #   sp.0x26 = sp.0x3a
8006af88: 8e220000 lw r2,0x0000(r17)                    #   p1.0x00
8006af8c: 00000000 nop
8006af90: 30420800 andi r2,r2,0x0800                    #   p1.0x00 & 0x0800
8006af94: 14400007 bne r2,r0,0x8006afb4
8006af98: 3c030800 lui r3,0x0800
                                                        #   if (((p1.0x00 & 0x0800) != 0)
8006af9c: 3c028005 lui r2,0x8005
8006afa0: 8c42d950 lw r2,-0x26b0(r2)
8006afa4: 00000000 nop
8006afa8: 00431024 and r2,r2,r3
8006afac: 14400005 bne r2,r0,0x8006afc4
8006afb0: 00000000 nop                                  #       || (*0x8004d950 & 0x0800 == 0)) {
8006afb4: 8e220010 lw r2,0x0010(r17)
8006afb8: 00000000 nop
8006afbc: 24420001 addiu r2,r2,0x0001
8006afc0: ae220010 sw r2,0x0010(r17)                    #       p1.0x10++
                                                        #   }
                                                        #   while (true) {
8006afc4: 8e22000c lw r2,0x000c(r17)                    #       p1.0x0c
8006afc8: 00000000 nop
8006afcc: 00021080 sll r2,r2,0x02                       #       p1.0x0c * 4
8006afd0: 00501021 addu r2,r2,r16                       #       ptrBase + (p1.0x0c * 4)
8006afd4: 94460006 lhu r6,0x0006(r2)                    #       value = *(ptrBase + (p1.0x0c * 4) + 6)
8006afd8: 8e220010 lw r2,0x0010(r17)                    #       p1.0x10
8006afdc: 00000000 nop
8006afe0: 14c2000d bne r6,r2,0x8006b018
8006afe4: 3402ffff ori r2,r0,0xffff
8006afe8: 10c2000b beq r6,r2,0x8006b018
8006afec: 00000000 nop                                  #       if ((value != p1.0x10) || (value == -1)) break;
8006aff0: 8e22000c lw r2,0x000c(r17)                    #       p1.0x0c
8006aff4: ae200010 sw r0,0x0010(r17)                    #       p1.0x10 = 0
8006aff8: 24420001 addiu r2,r2,0x0001                   #       p1.0x0c + 1
8006affc: ae22000c sw r2,0x000c(r17)                    #       p1.0x0c = p1.0x0c + 1
8006b000: 8e060000 lw r6,0x0000(r16)                    #       *ptrBase
8006b004: 00000000 nop
8006b008: 14c2ffee bne r6,r2,0x8006afc4                 #       if (*ptrBase == p1.0x0c) {
8006b00c: 00000000 nop
8006b010: 0801abf1 j 0x8006afc4
8006b014: ae20000c sw r0,0x000c(r17)                    #           p1.0x0c = 0
                                                        #       }
                                                        #   }
8006b018: 8e22000c lw r2,0x000c(r17)                    #   p1.0x0c
8006b01c: 00000000 nop
8006b020: 00021080 sll r2,r2,0x02                       #   p1.0x0c * 4
8006b024: 00501021 addu r2,r2,r16                       #   ptrBase + (p1.0x0c * 4)
8006b028: 94460004 lhu r6,0x0004(r2)                    #   value = *(ptrBase + (p1.0x0c * 4) + 4)
8006b02c: 00000000 nop
8006b030: 00061080 sll r2,r6,0x02                       #   value * 4
8006b034: 00521021 addu r2,r2,r18                       #   *0x80092b30 + (value * 4)
8006b038: 8c530000 lw r19,0x0000(r2)                    #   data = *(*0x80092b30 + (value * 4))
8006b03c: 00000000 nop
8006b040: 8e620004 lw r2,0x0004(r19)                    #   data.0x04
8006b044: 00009021 addu r18,r0,r0                       #   count = 0
8006b048: 3048ffff andi r8,r2,0xffff                    #   data.0x04 & 0xffff      // Low 2 bytes
8006b04c: 0002f402 srl r30,r2,0x10                      #   data.0x04 >> 16         // High 2 bytes
8006b050: afa80048 sw r8,0x0048(r29)                    #   sp.0x48 = data.0x04 & 0xffff
8006b054: 8e630008 lw r3,0x0008(r19)                    #   data.0x08
8006b058: 8e740000 lw r20,0x0000(r19)                   #   data.0x00
8006b05c: 3075ffff andi r21,r3,0xffff                   #   data.0x08 & 0xffff
8006b060: 1a800075 blez r20,0x8006b238                  #   if (data.0x00 <= 0) return;
8006b064: 0003bc02 srl r23,r3,0x10                      #   data.0x08 >> 16
8006b068: 3c1600ff lui r22,0x00ff                       #   0x00ff0000
8006b06c: 02921023 subu r2,r20,r18                      #   data.0x00 - count
                                                        #   do {
8006b070: 00021040 sll r2,r2,0x01                       #       (data.0x00 - count) * 2
8006b074: 34460001 ori r6,r2,0x0001                     #       ((data.0x00 - count) * 2) + 1
8006b078: 00061080 sll r2,r6,0x02                       #       (((data.0x00 - count) * 2) + 1) * 4
8006b07c: 00532821 addu r5,r2,r19                       #       ptr5 = ((((data.0x00 - count) * 2) + 1) * 4) + data     // 12 bytes per entry?
8006b080: 8ca30000 lw r3,0x0000(r5)                     #       value = *(ptr5)
8006b084: 3c028000 lui r2,0x8000
8006b088: 00622024 and r4,r3,r2                         #       value & 0x80000000
8006b08c: afa40010 sw r4,0x0010(r29)                    #       sp.0x10 = value & 0x80000000
8006b090: 8e220000 lw r2,0x0000(r17)                    #       p1.0x00
8006b094: 00000000 nop
8006b098: 30420020 andi r2,r2,0x0020                    #       p1.0x00 & 0x0020
8006b09c: 1040000e beq r2,r0,0x8006b0d8
8006b0a0: 3c024000 lui r2,0x4000                        #       0x40000000
                                                        #       if ((p1.0x00 & 0x0020) != 0) {

8006b0a4: 00821025 or r2,r4,r2                          #           (value & 0x80000000) | 0x40000000
8006b0a8: afa20010 sw r2,0x0010(r29)                    #           sp.0x10 = (value & 0x80000000) | 0x40000000
8006b0ac: 8e230000 lw r3,0x0000(r17)                    #           p1.0x00
8006b0b0: 00000000 nop
8006b0b4: 306300c0 andi r3,r3,0x00c0                    #           p1.0x00 & 0x00c0
8006b0b8: 00031d80 sll r3,r3,0x16                       #           (p1.0x00 & 0x00c0) << 24
8006b0bc: 00431025 or r2,r2,r3                          #           ((value & 0x80000000) | 0x40000000) | ((p1.0x00 & 0x00c0) << 24)
8006b0c0: afa20010 sw r2,0x0010(r29)                    #           sp.0x10 = ((value & 0x80000000) | 0x40000000) | ((p1.0x00 & 0x00c0) << 24)
8006b0c4: 8e220000 lw r2,0x0000(r17)                    #           p1.0x00
8006b0c8: 00000000 nop
8006b0cc: 304200c0 andi r2,r2,0x00c0                    #           p1.0x00 & 0x00c0
8006b0d0: 0801ac3f j 0x8006b0fc
8006b0d4: 00022983 sra r5,r2,0x06                       #           paramValue = (p1.0x00 & 0x00c0) >> 6
                                                        #       } else {
8006b0d8: 8ca20000 lw r2,0x0000(r5)                     #           *(ptr5)
8006b0dc: 3c037000 lui r3,0x7000                        #           0x70000000
8006b0e0: 00431024 and r2,r2,r3                         #           *(ptr5) & 0x70000000
8006b0e4: 00821025 or r2,r4,r2                          #           (value & 0x80000000) | (*(ptr5) & 0x70000000)
8006b0e8: afa20010 sw r2,0x0010(r29)                    #           sp.0x10 = (value & 0x80000000) | (*(ptr5) & 0x70000000)
8006b0ec: 8ca20000 lw r2,0x0000(r5)                     #           *(ptr5)
8006b0f0: 00000000 nop
8006b0f4: 00021702 srl r2,r2,0x1c                       #           *(ptr5) >> 28
8006b0f8: 30450003 andi r5,r2,0x0003                    #           paramValue = (*(ptr5) >> 28) & 0x0003
                                                        #       }
8006b0fc: 00061080 sll r2,r6,0x02                       #       (((data.0x00 - count) * 2) + 1) * 4
8006b100: 00538021 addu r16,r2,r19                      #       ptr16 = ((((data.0x00 - count) * 2) + 1) * 4) + data
8006b104: 3c020700 lui r2,0x0700                        #       0x07000000
8006b108: 8e030000 lw r3,0x0000(r16)                    #       ptr16.0x00
8006b10c: 8fa60048 lw r6,0x0048(r29)                    #       sp.0x48
8006b110: 00621824 and r3,r3,r2                         #       ptr16.0x00 & 0x07000000
8006b114: 8fa20010 lw r2,0x0010(r29)                    #       sp.0x10
8006b118: 00031882 srl r3,r3,0x02                       #       (ptr16.0x00 & 0x07000000) >> 2
8006b11c: 00431025 or r2,r2,r3                          #       sp.0x10 | ((ptr16.0x00 & 0x07000000) >> 2)
8006b120: afa20010 sw r2,0x0010(r29)                    #       sp.0x10 = sp.0x10 | ((ptr16.0x00 & 0x07000000) >> 2)
8006b124: 92030000 lbu r3,0x0000(r16)                   #       ptr16.0x00      // Only low-order byte
8006b128: 8e220018 lw r2,0x0018(r17)                    #       p1.0x18
8006b12c: 2463ff80 addiu r3,r3,-0x0080                  #       ptr16.0x00 - 128
8006b130: 00431021 addu r2,r2,r3                        #       p1.0x18 + ptr16.0x00 - 128
8006b134: a7a20014 sh r2,0x0014(r29)                    #       sp.0x14 = p1.0x18 + ptr16.0x00 - 128
8006b138: 92030001 lbu r3,0x0001(r16)                   #       ptr16.0x01
8006b13c: 8e22001c lw r2,0x001c(r17)                    #       p1.0x1c
8006b140: 2463ff80 addiu r3,r3,-0x0080                  #       ptr16.0x01 - 128
8006b144: 00431021 addu r2,r2,r3                        #       p1.0x1c + ptr16.0x01 - 128
8006b148: a7a20016 sh r2,0x0016(r29)                    #       sp.0x16 = p1.0x1c + ptr16.0x01 - 128
8006b14c: 92020005 lbu r2,0x0005(r16)                   #       ptr16.0x05
8006b150: 00002021 addu r4,r0,r0                        #       0
8006b154: a7a20018 sh r2,0x0018(r29)                    #       sp.0x18 = ptr16.0x05
8006b158: 92020004 lbu r2,0x0004(r16)                   #       ptr16.0x04
8006b15c: 03c03821 addu r7,r30,r0                       #       data.0x04 >> 16
8006b160: 0c008e63 jal 0x8002398c                       #       calcResult = P00 GetTpage (0, paramValue, sp.0x48, data.0x04 >> 16);  // (4 bit texture compression, transparency mode, tpage x address, tpage y address)
8006b164: a7a2001a sh r2,0x001a(r29)                    #       sp.0x1a = ptr16.0x04
8006b168: a7a2001c sh r2,0x001c(r29)                    #       sp.0x1c = calcResult
8006b16c: 92020007 lbu r2,0x0007(r16)                   #       ptr16.0x07
8006b170: 00000000 nop
8006b174: a3a2001e sb r2,0x001e(r29)                    #       sp.0x1e = ptr16.0x07
8006b178: 8e020004 lw r2,0x0004(r16)                    #       ptr16.0x04
8006b17c: 00000000 nop
8006b180: 00561024 and r2,r2,r22                        #       ptr16.0x04 & 0x00ff0000
8006b184: 00021402 srl r2,r2,0x10                       #       (ptr16.0x04 & 0x00ff0000) >> 10
8006b188: a3a2001f sb r2,0x001f(r29)                    #       sp.0x1f
8006b18c: 8e240014 lw r4,0x0014(r17)                    #       p1.0x14
8006b190: 00000000 nop
8006b194: 10800006 beq r4,r0,0x8006b1b0             
8006b198: 3c030800 lui r3,0x0800                        #       0x08000000
                                                        #       if ((p1.0x14 != 0)
8006b19c: 8e020000 lw r2,0x0000(r16)
8006b1a0: 00000000 nop
8006b1a4: 00431024 and r2,r2,r3
8006b1a8: 10400007 beq r2,r0,0x8006b1c8                 #           || ((ptr16.0x00 & 0x08000000) != 0)) {
8006b1ac: 00000000 nop
8006b1b0: 8e020000 lw r2,0x0000(r16)                    #           ptr16.0x00
8006b1b4: 00000000 nop
8006b1b8: 00561024 and r2,r2,r22                        #           ptr16.0x00 & 0x00ff0000
8006b1bc: 02a21021 addu r2,r21,r2                       #           (data.0x08 & 0xffff) + (ptr16.0x00 & 0x00ff0000)
8006b1c0: 0801ac75 j 0x8006b1d4
8006b1c4: 00021302 srl r2,r2,0x0c                       #           value20 = ((data.0x08 & 0xffff) + (ptr16.0x00 & 0x00ff0000)) >> 12
                                                        #       } else {
8006b1c8: 2482ffff addiu r2,r4,-0x0001                  #           p1.0x14 - 1
8006b1cc: 00021100 sll r2,r2,0x04                       #           (p1.0x14 - 1) * 16
8006b1d0: 02a21021 addu r2,r21,r2                       #           value20 = (data.0x08 & 0xffff) + ((p1.0x14 - 1) * 16)
                                                        #       }
8006b1d4: a7a20020 sh r2,0x0020(r29)                    #       sp.0x20 = value20
8006b1d8: 8fa30010 lw r3,0x0010(r29)                    #       sp.0x10
8006b1dc: 3c020080 lui r2,0x0080                        #       0x00800000
8006b1e0: 00621024 and r2,r3,r2                         #       sp.0x10 & 0x00800000
8006b1e4: 10400005 beq r2,r0,0x8006b1fc
8006b1e8: a7b70022 sh r23,0x0022(r29)                   #       sp.0x22 = data.0x08 >> 16
8006b1ec: 93a2001e lbu r2,0x001e(r29)                   #       sp.0x1e
8006b1f0: 00000000 nop
8006b1f4: 24420001 addiu r2,r2,0x0001                   #       sp.0x1e + 1
8006b1f8: a3a2001e sb r2,0x001e(r29)                    #       sp.0x1e = sp.0x1e + 1
8006b1fc: 3c020040 lui r2,0x0040                        #       0x00400000
8006b200: 00621024 and r2,r3,r2                         #       sp.0x10 & 0x00400000
8006b204: 10400005 beq r2,r0,0x8006b21c
8006b208: 27a40010 addiu r4,r29,0x0010                  #       sp + 0x10
                                                        #       if ((sp.0x10 & 0x00400000) != 0) {
8006b20c: 93a2001f lbu r2,0x001f(r29)                   #           sp.0x1f
8006b210: 00000000 nop
8006b214: 24420001 addiu r2,r2,0x0001                   #           sp.0x1f + 1
8006b218: a3a2001f sb r2,0x001f(r29)                    #           sp.0x1f = sp.0x1f + 1
                                                        #       }
8006b21c: 8fa50040 lw r5,0x0040(r29)                    #       sp.0x40
8006b220: 96260008 lhu r6,0x0008(r17)                   #       p1.0x08
8006b224: 0c0382be jal 0x800e0af8                       #       0xe0af8 (sp + 0x10, sp.0x40, p1.0x08);
8006b228: 26520001 addiu r18,r18,0x0001                 #       count++
8006b22c: 0254102a slt r2,r18,r20
8006b230: 1440ff8f bne r2,r0,0x8006b070
8006b234: 02921023 subu r2,r20,r18                      #       data.0x00 - count
                                                        #   } while (count < data.0x00);
8006b238: 8fbf0084 lw r31,0x0084(r29)
8006b23c: 8fbe0080 lw r30,0x0080(r29)
8006b240: 8fb7007c lw r23,0x007c(r29)
8006b244: 8fb60078 lw r22,0x0078(r29)
8006b248: 8fb50074 lw r21,0x0074(r29)
8006b24c: 8fb40070 lw r20,0x0070(r29)
8006b250: 8fb3006c lw r19,0x006c(r29)
8006b254: 8fb20068 lw r18,0x0068(r29)
8006b258: 8fb10064 lw r17,0x0064(r29)
8006b25c: 8fb00060 lw r16,0x0060(r29)
8006b260: 27bd0088 addiu r29,r29,0x0088
8006b264: 03e00008 jr r31
8006b268: 00000000 nop