Find Formation Palette Index
(Redirected from 001090c8 - 00109244)
Jump to navigation
Jump to search
# ATTACK.OUT: Find Formation Palette Index (ATTACK.OUT) # REQUIRE.OUT: Find Formation Palette Index (REQUIRE.OUT)
# ROUTINE: FIND FORMATION PALETTE INDEX # Parameters: # r4 = (partyIndex) Party unit index # Returns: # r2 = Formation palette index
# Despite having code for generic human units, this code is not run for generic human units. 801090c8: 27bdffe0 addiu r29,r29,-0x0020 801090cc: afbf0018 sw r31,0x0018(r29) 801090d0: afb10014 sw r17,0x0014(r29) 801090d4: 0c0166bc jal 0x80059af0 # partyUnit = Get Party Data Pointer (partyIndex) 801090d8: afb00010 sw r16,0x0010(r29) 801090dc: 00408021 addu r16,r2,r0 # partyUnit 801090e0: 92030000 lbu r3,0x0000(r16) # partyUnit.BaseClass 801090e4: 00000000 nop 801090e8: 2c620080 sltiu r2,r3,0x0080 801090ec: 14400025 bne r2,r0,0x80109184 801090f0: 00602021 addu r4,r3,r0 # partyUnit.BaseClass # if (partyUnit.BaseClass >= 0x80) { // Is generic unit 801090f4: 34020080 ori r2,r0,0x0080 801090f8: 1462000a bne r3,r2,0x80109124 # if (partyUnit.BaseClass == 0x80) { // Is Generic Male unit 801090fc: 34020081 ori r2,r0,0x0081 80109100: 92020002 lbu r2,0x0002(r16) # partyUnit.JobID 80109104: 00000000 nop 80109108: 2443ffb6 addiu r3,r2,-0x004a # jobOffset = partyUnit.JobID - 0x4A // (Job 0x4A is Squire) 8010910c: 00032840 sll r5,r3,0x01 # jobOffset * 2 80109110: 3403005d ori r3,r0,0x005d 80109114: 14430013 bne r2,r3,0x80109164 # if (partyUnit.JobID != 0x5D) // (Job 0x5D is Mime) 80109118: 24a40060 addiu r4,r5,0x0060 # lookupIndex = (jobOffset * 2) + 0x60 8010911c: 08042459 j 0x80109164 # else 80109120: 24a4005e addiu r4,r5,0x005e # lookupIndex = (jobOffset * 2) + 0x5E 80109124: 1462000a bne r3,r2,0x80109150 # } else if (partyUnit.BaseClass == 0x81) { // Is Generic Female unit 80109128: 00000000 nop 8010912c: 92020002 lbu r2,0x0002(r16) # partyUnit.JobID 80109130: 00000000 nop 80109134: 2443ffb6 addiu r3,r2,-0x004a # jobOffset = partyUnit.JobID - 0x4A // (Job 0x4A is Squire) 80109138: 00032840 sll r5,r3,0x01 # jobOffset * 2 8010913c: 3403005d ori r3,r0,0x005d 80109140: 14430008 bne r2,r3,0x80109164 # if (partyUnit.JobID != 0x5D) // (Job 0x5D is Mime) 80109144: 24a40061 addiu r4,r5,0x0061 # lookupIndex = (jobOffset * 2) + 0x61 80109148: 08042459 j 0x80109164 # else 8010914c: 24a4005f addiu r4,r5,0x005f # lookupIndex = (jobOffset * 2) + 0x5F # } else { 80109150: 92040002 lbu r4,0x0002(r16) # partyUnit.JobID 80109154: 0c016a29 jal 0x8005a8a4 # job = Get Job Data Pointer (partyUnit.JobID) 80109158: 00000000 nop 8010915c: 00408821 addu r17,r2,r0 # job 80109160: 9044002d lbu r4,0x002d(r2) # lookupIndex = job.MonsterPortrait # } 80109164: 92030002 lbu r3,0x0002(r16) # partyUnit.JobID 80109168: 3402005b ori r2,r0,0x005b 8010916c: 14620002 bne r3,r2,0x80109178 80109170: 3402005c ori r2,r0,0x005c # if (partyUnit.JobID == 0x5B) { // (Job 0x5B is Bard) 80109174: 34040082 ori r4,r0,0x0082 # lookupIndex = 0x82 # } 80109178: 14620003 bne r3,r2,0x80109188 # if (partyUnit.JobID == 0x5C) { // (Job 0x5C is Dancer) 8010917c: 00041040 sll r2,r4,0x01 80109180: 34040083 ori r4,r0,0x0083 # lookupIndex = 0x83 # } # } 80109184: 00041040 sll r2,r4,0x01 # lookupIndex * 2 80109188: 92030000 lbu r3,0x0000(r16) # partyUnit.BaseClass 8010918c: 3c018019 lui r1,0x8019 80109190: 00220821 addu r1,r1,r2 80109194: 9424a168 lhu r4,-0x5e98(r1) # formationSpriteValue = *(0x8018a168 + (lookupIndex * 2)) 80109198: 14600002 bne r3,r0,0x801091a4 8010919c: 34020082 ori r2,r0,0x0082 # if (partyUnit.BaseClass == 0) { 801091a0: 00002021 addu r4,r0,r0 # formationSpriteValue = 0 # } 801091a4: 14620005 bne r3,r2,0x801091bc # if (partyUnit.BaseClass == 0x82) { // Generic Monster 801091a8: 00000000 nop 801091ac: 9222002e lbu r2,0x002e(r17) # job.MonsterPalette 801091b0: 00000000 nop 801091b4: 00021280 sll r2,r2,0x0a # job.MonsterPalette << 10 801091b8: 00822025 or r4,r4,r2 # formationSpriteValue = formationSpriteValue | (job.MonsterPalette << 10) // Appears to be irrelevant because following line truncates high bytes! # } 801091bc: 308400ff andi r4,r4,0x00ff # formationSpriteValue = formationSpriteValue & 0xff 801091c0: 34020018 ori r2,r0,0x0018 801091c4: 14820003 bne r4,r2,0x801091d4 801091c8: 2882003f slti r2,r4,0x003f # if (formationSpriteValue == 0x18) { // Holy Dragon 801091cc: 0804248c j 0x80109230 # return 0x7a; // Holy Dragon palette index (122) 801091d0: 3402007a ori r2,r0,0x007a # } 801091d4: 14400006 bne r2,r0,0x801091f0 # if (formationSpriteValue >= 0x3f) { // Monster 801091d8: 00000000 nop 801091dc: 3c018019 lui r1,0x8019 801091e0: 00240821 addu r1,r1,r4 801091e4: 9024a2d1 lbu r4,-0x5d2f(r1) # formationSpriteValue = *(0x8018a2d1 + formationSpriteValue) 801091e8: 08042483 j 0x8010920c 801091ec: 2882003e slti r2,r4,0x003e # } else { 801091f0: 92020000 lbu r2,0x0000(r16) # partyUnit.BaseClass 801091f4: 00000000 nop 801091f8: 30420080 andi r2,r2,0x0080 801091fc: 10400003 beq r2,r0,0x8010920c # if (partyUnit.BaseClass & 0x80) { // Is generic? 80109200: 2882003e slti r2,r4,0x003e 80109204: 2484ffff addiu r4,r4,-0x0001 # formationSpriteValue = formationSpriteValue - 1 // Generics offset by 1 for unit palette (correct for portrait palette) 80109208: 2882003e slti r2,r4,0x003e # } # } # formationSpriteIndex = formationSpriteValue 8010920c: 14400008 bne r2,r0,0x80109230 # if (formationSpriteIndex < 0x3e) 80109210: 00801021 addu r2,r4,r0 # return formationSpriteIndex; 80109214: 2484ffc2 addiu r4,r4,-0x003e # monsterOffset = formationSpriteIndex - 0x3e 80109218: 00041840 sll r3,r4,0x01 # monsterOffset * 2 8010921c: 9222002e lbu r2,0x002e(r17) # job.MonsterPalette 80109220: 00641821 addu r3,r3,r4 # monsterOffset * 3 80109224: 2442003e addiu r2,r2,0x003e # job.MonsterPalette + 0x3e 80109228: 00622021 addu r4,r3,r2 # (monsterOffset * 3) + (job.MonsterPalette + 0x3e) 8010922c: 00801021 addu r2,r4,r0 # return (monsterOffset * 3) + (job.MonsterPalette + 0x3e); 80109230: 8fbf0018 lw r31,0x0018(r29) 80109234: 8fb10014 lw r17,0x0014(r29) 80109238: 8fb00010 lw r16,0x0010(r29) 8010923c: 27bd0020 addiu r29,r29,0x0020 80109240: 03e00008 jr r31 80109244: 00000000 nop