Portrait loading routine (ATTACK.OUT)

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search

< ATTACK.OUT Routines

# WORLD.BIN: Portrait loading routine
001c80d0: 27bdffb8 addiu r29,r29,0xffb8
001c80d4: 3c040002 lui r4,0x0002
001c80d8: afbf0040 sw r31,0x0040(r29)
001c80dc: afb7003c sw r23,0x003c(r29)
001c80e0: afb60038 sw r22,0x0038(r29)
001c80e4: afb50034 sw r21,0x0034(r29)
001c80e8: afb40030 sw r20,0x0030(r29)
001c80ec: afb3002c sw r19,0x002c(r29)
001c80f0: afb20028 sw r18,0x0028(r29)
001c80f4: afb10024 sw r17,0x0024(r29)
001c80f8: 0c011105 jal 0x00044414
001c80fc: afb00020 sw r16,0x0020(r29)
001c8100: 3c038016 lui r3,0x8016
001c8104: 94635fda lhu r3,0x5fda(r3)
001c8108: 00000000 nop
001c810c: 10600012 beq r3,r0,0x001c8158
001c8110: 00409021 addu r18,r2,r0
001c8114: 34020002 ori r2,r0,0x0002
001c8118: 14620006 bne r3,r2,0x001c8134
001c811c: 340418ba ori r4,r0,0x18ba
001c8120: 3c050002 lui r5,0x0002
001c8124: 0c072009 jal 0x001c8024
001c8128: 02403021 addu r6,r18,r0
001c812c: 0807206d j 0x001c81b4
001c8130: 00008821 addu r17,r0,r0
001c8134: 3c028004 lui r2,0x8004
001c8138: 24424954 addiu r2,r2,0x4954
001c813c: 3c018017 lui r1,0x8017
001c8140: ac223ca8 sw r2,0x3ca8(r1)
001c8144: 3c050002 lui r5,0x0002
001c8148: 0c0533ad jal 0x0014ceb4
001c814c: 02403021 addu r6,r18,r0
001c8150: 0807206d j 0x001c81b4
001c8154: 00008821 addu r17,r0,r0
001c8158: 3c04801d lui r4,0x801d
001c815c: 24845d68 addiu r4,r4,0x5d68
001c8160: 0c009258 jal 0x00024960
001c8164: 02402821 addu r5,r18,r0
001c8168: 3c04801d lui r4,0x801d
001c816c: 24845d70 addiu r4,r4,0x5d70
001c8170: 34058000 ori r5,r0,0x8000
001c8174: 0c009258 jal 0x00024960
001c8178: 02452821 addu r5,r18,r5
001c817c: 3c04801d lui r4,0x801d
001c8180: 24845d78 addiu r4,r4,0x5d78
001c8184: 3c050001 lui r5,0x0001
001c8188: 0c009258 jal 0x00024960
001c818c: 02452821 addu r5,r18,r5
001c8190: 3c050001 lui r5,0x0001
001c8194: 34a58000 ori r5,r5,0x8000
001c8198: 3c04801d lui r4,0x801d
001c819c: 24845d80 addiu r4,r4,0x5d80
001c81a0: 0c009258 jal 0x00024960
001c81a4: 02452821 addu r5,r18,r5
001c81a8: 0c0091b5 jal 0x000246d4
001c81ac: 00002021 addu r4,r0,r0
001c81b0: 00008821 addu r17,r0,r0
001c81b4: 34160014 ori r22,r0,0x0014
001c81b8: 3c15801e lui r21,0x801e
001c81bc: 26b5d2d4 addiu r21,r21,0xd2d4
001c81c0: 3c17801e lui r23,0x801e
001c81c4: 26f7d2e4 addiu r23,r23,0xd2e4
001c81c8: 3c14801e lui r20,0x801e
001c81cc: 2694d2dc addiu r20,r20,0xd2dc
001c81d0: 16360005 bne r17,r22,0x001c81e8      # Branch if r17 and r22 aren't equal
001c81d4: 02203821 addu r7,r17,r0
001c81d8: 3c078005 lui r7,0x8005
001c81dc: 90e7d9ac lbu r7,-0x2654(r7)          # Load Special Portrait WLDFACE ID
001c81e0: 12360040 beq r17,r22,0x001c82e4      # Branch if r17 and r22 are equal
001c81e4: 3c026666 lui r2,0x6666
001c81e8: 0c0166bc jal 0x00059af0              # Get Party Data Pointer
001c81ec: 00e02021 addu r4,r7,r0
001c81f0: 00408021 addu r16,r2,r0              # r16 = Party Data Pointer
001c81f4: 92040000 lbu r4,0x0000(r16)          # r4 = Sprite Set
001c81f8: 00000000 nop
001c81fc: 2c820080 sltiu r2,r4,0x0080          # r2 = 0x01 if not a generic? (0x80 Generic Male, 0x81 Generic Female, 0x82 Monster)
001c8200: 14400026 bne r2,r0,0x001c829c        # Branch if not a generic
001c8204: 00803821 addu r7,r4,r0               # Replace Special Portrait WLDFACE ID with World Stats Sprite Set
001c8208: 34020080 ori r2,r0,0x0080            # r2 = 0x80 - Generic Male
001c820c: 1482000a bne r4,r2,0x001c8238        # Branch if not generic male
001c8210: 34020081 ori r2,r0,0x0081            # r2 = 0x81 - Generic Female
001c8214: 92020002 lbu r2,0x0002(r16)          # Generic male: load job ID
001c8218: 00000000 nop
001c821c: 2443ffb6 addiu r3,r2,0xffb6          # r3 = Job offset: ID - 0x4A (Squire)
001c8220: 00032040 sll r4,r3,0x01              # r4 = Job offset * 2
001c8224: 3403005d ori r3,r0,0x005d            # r3 = 0x5D (Mime)
001c8228: 14430014 bne r2,r3,0x001c827c        # Branch if not Mime
001c822c: 24870060 addiu r7,r4,0x0060          # r7 = Job offset + 0x60 if not mime
001c8230: 0807209f j 0x001c827c                # Jump past female/monster code
001c8234: 2487005e addiu r7,r4,0x005e          # r7 = Job offset + 0x5e if mime
001c8238: 1482000a bne r4,r2,0x001c8264        # Branch if not generic female
001c823c: 00000000 nop
001c8240: 92020002 lbu r2,0x0002(r16)          # Generic female: load job ID
001c8244: 00000000 nop
001c8248: 2443ffb6 addiu r3,r2,0xffb6          # r3 = Job offset: ID - 0x4A (Squire)
001c824c: 00032040 sll r4,r3,0x01              # r4 = Job offset * 2
001c8250: 3403005d ori r3,r0,0x005d            # r3 = 0x5D (Mime)
001c8254: 14430009 bne r2,r3,0x001c827c        # Branch if not Mime
001c8258: 24870061 addiu r7,r4,0x0061          # r7 = Job offset + 0x61 if not mime
001c825c: 0807209f j 0x001c827c                # Jump past monster code
001c8260: 2487005f addiu r7,r4,0x005f          # r7 = Job offset + 0x5f if mime
001c8264: 92040002 lbu r4,0x0002(r16)          # Generic monster: load job ID
001c8268: 0c016a29 jal 0x0005a8a4              # Get Job Data Pointer
001c826c: 00000000 nop
001c8270: 3c01801e lui r1,0x801e
001c8274: ac22caa8 sw r2,-0x3558(r1)           # Save Job Data Pointer to 0x801DCAA8
001c8278: 9047002d lbu r7,0x002d(r2)           # Load Monster Portrait
001c827c: 92030002 lbu r3,0x0002(r16)          # Load Current Job
001c8280: 3402005b ori r2,r0,0x005b            # r2 = 0x5B: Bard
001c8284: 14620002 bne r3,r2,0x001c8290        # Branch if not Bard
001c8288: 3402005c ori r2,r0,0x005c            # r2 = 0x5C: Dancer
001c828c: 34070082 ori r7,r0,0x0082            # If Bard, set lookup index to 0x82
001c8290: 14620003 bne r3,r2,0x001c82a0        # Branch if not Dancer
001c8294: 00071040 sll r2,r7,0x01              # r2 = Lookup index * 2
001c8298: 34070083 ori r7,r0,0x0083            # If Dancer, set lookup index to 0x83
001c829c: 00071040 sll r2,r7,0x01              # r2 = Lookup index * 2, again
001c82a0: 92030000 lbu r3,0x0000(r16)
001c82a4: 3c01801d lui r1,0x801d
001c82a8: 00220821 addu r1,r1,r2
001c82ac: 94275bb0 lhu r7,0x5bb0(r1)          # Load the index for the WLDFACE portrait.
001c82b0: 14600002 bne r3,r0,0x001c82bc
001c82b4: 34020082 ori r2,r0,0x0082
001c82b8: 00003821 addu r7,r0,r0
001c82bc: 14620009 bne r3,r2,0x001c82e4
001c82c0: 3c026666 lui r2,0x6666
001c82c4: 3c02801e lui r2,0x801e
001c82c8: 8c42caa8 lw r2,-0x3558(r2)
001c82cc: 00000000 nop
001c82d0: 9042002e lbu r2,0x002e(r2)
001c82d4: 00000000 nop
001c82d8: 00021280 sll r2,r2,0x0a
001c82dc: 00e23825 or r7,r7,r2
001c82e0: 3c026666 lui r2,0x6666
001c82e4: 34426667 ori r2,r2,0x6667
001c82e8: 30f000ff andi r16,r7,0x00ff
001c82ec: 02020018 mult r16,r2
001c82f0: 00101fc3 sra r3,r16,0x1f
001c82f4: 00001010 mfhi r2
001c82f8: 00021103 sra r2,r2,0x04
001c82fc: 00432823 subu r5,r2,r3
001c8300: 30e30c00 andi r3,r7,0x0c00
001c8304: 00051080 sll r2,r5,0x02
001c8308: 00451021 addu r2,r2,r5
001c830c: 000210c0 sll r2,r2,0x03
001c8310: 02023823 subu r7,r16,r2
001c8314: 00e01021 addu r2,r7,r0
001c8318: 04e10002 bgez r7,0x001c8324
001c831c: 00039a83 sra r19,r3,0x0a
001c8320: 24e20007 addiu r2,r7,0x0007
001c8324: 000230c3 sra r6,r2,0x03
001c8328: 00c02021 addu r4,r6,r0
001c832c: 000410c0 sll r2,r4,0x03
001c8330: 00e23023 subu r6,r7,r2
001c8334: 3c029249 lui r2,0x9249
001c8338: 34422493 ori r2,r2,0x2493
001c833c: 00003821 addu r7,r0,r0
001c8340: 00041840 sll r3,r4,0x01
001c8344: 00641821 addu r3,r3,r4
001c8348: 00031b00 sll r3,r3,0x0c
001c834c: 02220018 mult r17,r2
001c8350: 00061140 sll r2,r6,0x05
001c8354: 00621821 addu r3,r3,r2
001c8358: 00031843 sra r3,r3,0x01
001c835c: 000513c0 sll r2,r5,0x0f
001c8360: 00521021 addu r2,r2,r18
001c8364: 00434021 addu r8,r2,r3
001c8368: 34020008 ori r2,r0,0x0008
001c836c: a6a20004 sh r2,0x0004(r21)
001c8370: 34020030 ori r2,r0,0x0030
001c8374: a6a20006 sh r2,0x0006(r21)
001c8378: 001117c3 sra r2,r17,0x1f
001c837c: 00001810 mfhi r3
001c8380: 00711821 addu r3,r3,r17
001c8384: 00031883 sra r3,r3,0x02
001c8388: 00621823 subu r3,r3,r2
001c838c: 000310c0 sll r2,r3,0x03
001c8390: 00431023 subu r2,r2,r3
001c8394: 02221023 subu r2,r17,r2
001c8398: 000210c0 sll r2,r2,0x03
001c839c: 24420100 addiu r2,r2,0x0100
001c83a0: a6a20000 sh r2,0x0000(r21)
001c83a4: 00031040 sll r2,r3,0x01
001c83a8: 00431021 addu r2,r2,r3
001c83ac: 00021100 sll r2,r2,0x04
001c83b0: 24420028 addiu r2,r2,0x0028
001c83b4: a6a20002 sh r2,0x0002(r21)
001c83b8: 00003021 addu r6,r0,r0
001c83bc: 00072900 sll r5,r7,0x04
001c83c0: 01002021 addu r4,r8,r0
001c83c4: 90830000 lbu r3,0x0000(r4)
001c83c8: 00a61021 addu r2,r5,r6
001c83cc: 24c60001 addiu r6,r6,0x0001
001c83d0: 00571021 addu r2,r2,r23
001c83d4: a0430000 sb r3,0x0000(r2)
001c83d8: 28c20010 slti r2,r6,0x0010
001c83dc: 1440fff9 bne r2,r0,0x001c83c4
001c83e0: 24840001 addiu r4,r4,0x0001
001c83e4: 24e70001 addiu r7,r7,0x0001
001c83e8: 28e20030 slti r2,r7,0x0030
001c83ec: 1440fff2 bne r2,r0,0x001c83b8
001c83f0: 25080080 addiu r8,r8,0x0080
001c83f4: 3c04801e lui r4,0x801e
001c83f8: 2484d2d4 addiu r4,r4,0xd2d4
001c83fc: 16360003 bne r17,r22,0x001c840c
001c8400: 00000000 nop
001c8404: 3c04801d lui r4,0x801d
001c8408: 24845d58 addiu r4,r4,0x5d58
001c840c: 3c05801e lui r5,0x801e
001c8410: 24a5d2e4 addiu r5,r5,0xd2e4
001c8414: 0c00923f jal 0x000248fc
001c8418: 00000000 nop
001c841c: 3c025555 lui r2,0x5555
001c8420: 34425556 ori r2,r2,0x5556
001c8424: 02220018 mult r17,r2
001c8428: 3c046666 lui r4,0x6666
001c842c: 34846667 ori r4,r4,0x6667
001c8430: 34020010 ori r2,r0,0x0010
001c8434: 00001810 mfhi r3
001c8438: a6820004 sh r2,0x0004(r20)
001c843c: 34020001 ori r2,r0,0x0001
001c8440: 02040018 mult r16,r4
001c8444: a6820006 sh r2,0x0006(r20)
001c8448: 001117c3 sra r2,r17,0x1f
001c844c: 00621823 subu r3,r3,r2
001c8450: 00031040 sll r2,r3,0x01
001c8454: 00431021 addu r2,r2,r3
001c8458: 02221023 subu r2,r17,r2
001c845c: 00021100 sll r2,r2,0x04
001c8460: 24420100 addiu r2,r2,0x0100
001c8464: a6830002 sh r3,0x0002(r20)
001c8468: 00101fc3 sra r3,r16,0x1f
001c846c: a6820000 sh r2,0x0000(r20)
001c8470: 00001010 mfhi r2
001c8474: 00021103 sra r2,r2,0x04
001c8478: 00432823 subu r5,r2,r3
001c847c: 00051080 sll r2,r5,0x02
001c8480: 00451021 addu r2,r2,r5
001c8484: 000210c0 sll r2,r2,0x03
001c8488: 02023823 subu r7,r16,r2
001c848c: 04e10002 bgez r7,0x001c8498
001c8490: 00e01021 addu r2,r7,r0
001c8494: 24e20003 addiu r2,r7,0x0003
001c8498: 00023083 sra r6,r2,0x02
001c849c: 00c02021 addu r4,r6,r0
001c84a0: 00041080 sll r2,r4,0x02
001c84a4: 00e23023 subu r6,r7,r2
001c84a8: 1260000e beq r19,r0,0x001c84e4
001c84ac: 00803821 addu r7,r4,r0
001c84b0: 3c022aaa lui r2,0x2aaa
001c84b4: 3442aaab ori r2,r2,0xaaab
001c84b8: 2604ffc1 addiu r4,r16,0xffc1
001c84bc: 00820018 mult r4,r2
001c84c0: 02603021 addu r6,r19,r0
001c84c4: 00041fc3 sra r3,r4,0x1f
001c84c8: 00001010 mfhi r2
001c84cc: 00432823 subu r5,r2,r3
001c84d0: 00051040 sll r2,r5,0x01
001c84d4: 00451021 addu r2,r2,r5
001c84d8: 00021040 sll r2,r2,0x01
001c84dc: 00822023 subu r4,r4,r2
001c84e0: 2487000a addiu r7,r4,0x000a
001c84e4: 00071200 sll r2,r7,0x08
001c84e8: 00061980 sll r3,r6,0x06
001c84ec: 3404f000 ori r4,r0,0xf000
001c84f0: 00641821 addu r3,r3,r4
001c84f4: 00431021 addu r2,r2,r3
001c84f8: 16360005 bne r17,r22,0x001c8510
001c84fc: 00021043 sra r2,r2,0x01
001c8500: 3c04801d lui r4,0x801d
001c8504: 24845d60 addiu r4,r4,0x5d60
001c8508: 08072146 j 0x001c8518
001c850c: 00052bc0 sll r5,r5,0x0f
001c8510: 02802021 addu r4,r20,r0
001c8514: 00052bc0 sll r5,r5,0x0f
001c8518: 02452821 addu r5,r18,r5
001c851c: 0c00923f jal 0x000248fc
001c8520: 00a22821 addu r5,r5,r2
001c8524: 3c038016 lui r3,0x8016
001c8528: 94635fda lhu r3,0x5fda(r3)
001c852c: 34020002 ori r2,r0,0x0002
001c8530: 14620005 bne r3,r2,0x001c8548
001c8534: 00000000 nop
001c8538: 0c0532a0 jal 0x0014ca80
001c853c: 26310001 addiu r17,r17,0x0001
001c8540: 08072156 j 0x001c8558
001c8544: 2a220015 slti r2,r17,0x0015
001c8548: 0c0091b5 jal 0x000246d4
001c854c: 00002021 addu r4,r0,r0
001c8550: 26310001 addiu r17,r17,0x0001
001c8554: 2a220015 slti r2,r17,0x0015
001c8558: 1440ff1d bne r2,r0,0x001c81d0
001c855c: 00000000 nop
001c8560: 0c011273 jal 0x000449cc
001c8564: 02402021 addu r4,r18,r0
001c8568: 8fbf0040 lw r31,0x0040(r29)
001c856c: 8fb7003c lw r23,0x003c(r29)
001c8570: 8fb60038 lw r22,0x0038(r29)
001c8574: 8fb50034 lw r21,0x0034(r29)
001c8578: 8fb40030 lw r20,0x0030(r29)
001c857c: 8fb3002c lw r19,0x002c(r29)
001c8580: 8fb20028 lw r18,0x0028(r29)
001c8584: 8fb10024 lw r17,0x0024(r29)
001c8588: 8fb00020 lw r16,0x0020(r29)
001c858c: 27bd0048 addiu r29,r29,0x0048
001c8590: 03e00008 jr r31
001c8594: 00000000 nop