Effect Palette Setup

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
#   ROUTINE: EFFECT PALETTE SETUP
#       Parameters:
#           r4 = (effectID) Effect ID

801a0e80: 27bdffe0 addiu r29,r29,-0x0020
801a0e84: 3405000c ori r5,r0,0x000c                 #   12
801a0e88: 00042400 sll r4,r4,0x10
801a0e8c: 00042383 sra r4,r4,0x0e                   #   effectID * 4
801a0e90: afbf001c sw r31,0x001c(r29)
801a0e94: afb00018 sw r16,0x0018(r29)
801a0e98: 3c01801b lui r1,0x801b
801a0e9c: 00240821 addu r1,r1,r4
801a0ea0: 8c2348d0 lw r3,0x48d0(r1)                 #   effect = 0x801b48d0 + (effectID * 4)
801a0ea4: 00003021 addu r6,r0,r0                    #   0
801a0ea8: 8c620024 lw r2,0x0024(r3)                 #   effect.paletteOffset
801a0eac: 34070001 ori r7,r0,0x0001                 #   1
801a0eb0: 00628021 addu r16,r3,r2                   #   effectPalette = effect + effect.paletteOffset
801a0eb4: 3c01801c lui r1,0x801c
801a0eb8: ac30bf80 sw r16,-0x4080(r1)               #   *0x801bbf80 = effectPalette
801a0ebc: 0c0249b6 jal 0x800926d8                   #   Extract Palette Data (effectPalette, 12, 0, 1);
801a0ec0: 02002021 addu r4,r16,r0                   #   effectPalette
801a0ec4: 26040200 addiu r4,r16,0x0200              #   effectPalette2 = effectPalette + 0x200  // 0x200 = sizeof(Palette)
801a0ec8: 3405000d ori r5,r0,0x000d                 #   13
801a0ecc: 00003021 addu r6,r0,r0                    #   0
801a0ed0: 0c0249b6 jal 0x800926d8                   #   Extract Palette Data (effectPalette2, 13, 0, 1);
801a0ed4: 34070001 ori r7,r0,0x0001                 #   1
801a0ed8: 92020401 lbu r2,0x0401(r16)               #   byte2 = *(effectPalette + 0x0401)
801a0edc: 92040400 lbu r4,0x0400(r16)               #   byte1 = *(effectPalette + 0x0400)
801a0ee0: 92030402 lbu r3,0x0402(r16)               #   byte3 = *(effectPalette + 0x0402)
801a0ee4: 00021200 sll r2,r2,0x08                   #   byte2 << 8
801a0ee8: 00822021 addu r4,r4,r2                    #   byte1 + (byte2 << 8)
801a0eec: 00031c00 sll r3,r3,0x10                   #   byte3 << 16
801a0ef0: 92020403 lbu r2,0x0403(r16)               #   byte4 = *(effectPalette + 0x0403)
801a0ef4: 00000000 nop
801a0ef8: 1040000b beq r2,r0,0x801a0f28             
801a0efc: 00831821 addu r3,r4,r3                    #   byteValue = byte1 + (byte2 << 8) + (byte3 << 16)        // 3-byte little endian value
                                                    #   if (byte4 != 0) {
801a0f00: 04610002 bgez r3,0x801a0f0c
801a0f04: 00601021 addu r2,r3,r0                    #       v2 = byteValue
                                                    #       if (byteValue < 0) {
801a0f08: 246200ff addiu r2,r3,0x00ff               #           v2 = byteValue + 255
                                                    #       }
801a0f0c: 00021a03 sra r3,r2,0x08                   #       v3 = v2 >> 8
801a0f10: 27a40010 addiu r4,r29,0x0010              #       valueArray = sp + 0x10
801a0f14: 26050404 addiu r5,r16,0x0404              #       graphics = effectPalette + 0x0404
801a0f18: 34020180 ori r2,r0,0x0180
801a0f1c: a7a20010 sh r2,0x0010(r29)                #       valueArray[0] = 0x0180
801a0f20: 080683d3 j 0x801a0f4c
801a0f24: 34020080 ori r2,r0,0x0080                 #       v2 = 0x80
                                                    #   } else {
801a0f28: 04610002 bgez r3,0x801a0f34
801a0f2c: 00601021 addu r2,r3,r0                    #       v2 = byteValue
                                                    #       if (byteValue < 0) {
801a0f30: 2462007f addiu r2,r3,0x007f               #           v2 = byteValue + 127
                                                    #       }
801a0f34: 000219c3 sra r3,r2,0x07                   #       v3 = v2 >> 7
801a0f38: 27a40010 addiu r4,r29,0x0010              #       valueArray = sp + 0x10
801a0f3c: 26050404 addiu r5,r16,0x0404              #       graphics = effectPalette + 0x0404
801a0f40: 34020180 ori r2,r0,0x0180                 
801a0f44: a7a20010 sh r2,0x0010(r29)                #       valueArray[0] = 0x0180
801a0f48: 34020040 ori r2,r0,0x0040                 #       v2 = 0x40
                                                    #   }
801a0f4c: a7a00012 sh r0,0x0012(r29)                #   valueArray[1] = 0
801a0f50: a7a20014 sh r2,0x0014(r29)                #   valueArray[2] = v2
801a0f54: 0c00923f jal 0x800248fc                   #   ? 0x248fc (valueArray, graphics);
801a0f58: a7a30016 sh r3,0x0016(r29)                #   valueArray[3] = v3
801a0f5c: 8fbf001c lw r31,0x001c(r29)
801a0f60: 8fb00018 lw r16,0x0018(r29)
801a0f64: 27bd0020 addiu r29,r29,0x0020
801a0f68: 03e00008 jr r31
801a0f6c: 00000000 nop