Special Status Flag Enabling

From Final Fantasy Hacktics Wiki
Revision as of 20:44, 18 June 2021 by Orkney (talk | contribs) (Notes link return link color summary)
Jump to navigation Jump to search

Special Status Flag Enabling? summary

----------------------------------------
r4 = Status X number + 1 ? (Become r17 in this routine) - When this routine is called, it's for one specific status
r6 = Target ID           (Become r18 in this routine)
r5 = 0x00 (removal section) (Become r16 in this routine) or 0x01 (any other value drive to the end of the routine) 0x02 if treasure
Returns r2 = 0x00 if there's no unit pointer / 0x01 in every other situation )
------------------------------------------
00068e80: 27bdffe0 addiu r29,r29,0xffe0
00068e84: afb10014 sw r17,0x0014(r29)
00068e88: 00808821 addu r17,r4,r0            r17 = Counter2 (Status number + 1)
00068e8c: afb00010 sw r16,0x0010(r29)
00068e90: 00a08021 addu r16,r5,r0            r16 = 1 = status present, 0 = not present?
00068e94: afb20018 sw r18,0x0018(r29)
00068e98: 00c09021 addu r18,r6,r0            r18 = Unit's ID
00068e9c: afbf001c sw r31,0x001c(r29)
00068ea0: 0c01e9c9 jal 0x0007a724            Get_unit_misc_data_that_matches_r4_ID - use r4 to find unit's misc data pointer
00068ea4: 3244ffff andi r4,r18,0xffff        r4 = Unit's ID
00068ea8: 00402821 addu r5,r2,r0             r5 = r4 Unit misc data pointer (inherited from jal))
00068eac: 14a00003 bne r5,r0,0x00068ebc      #If r5 = 0x00 (no pointer) // Else Branch if Pointer exists
00068eb0: 34020001 ori r2,r0,0x0001          |r2 = 1
00068eb4: 0801a437 j 0x000690dc                  >> Jump to END  (with r2 = 0x00)
00068eb8: 00001021 addu r2,r0,r0                 |r2 = 0
00068ebc: 1202003f beq r16,r2,0x00068fbc     #If r16 <> r2 (r16 <> 0x01 (= r5 from calling routine))/ Else Branch to enabling section (r16 = 0x01)
00068ec0: 2a020002 slti r2,r16,0x0002            |r2 = 0x01 if r16 <0x02
00068ec4: 10400084 beq r2,r0,0x000690d8          #If r2 = 0x01 / Else Branch to almost- END set r2 = 0x01 and exit if r16 > 0x01 (error check?)
00068ec8: 00000000 nop                              |
00068ecc: 16000083 bne r16,r0,0x000690dc            #If r16 = 0x00 / Else Branch to end if value is negative (error check) 
00068ed0: 34020001 ori r2,r0,0x0001                 |r2 = 1
*Status Flag Removal*
00068ed4: 2623ffff addiu r3,r17,0xffff                 |r3 = Counter2 - 1 (C2 starts at 1) = status number (in patcher list)
00068ed8: 2c620020 sltiu r2,r3,0x0020                  |r2 = 0x01 if status number < 0x20  Else 0x00(wall faith ?)
00068edc: 10400028 beq r2,r0,0x 00068f80               #If r2 = 0x01 (counter < 0x20) / Branch o others statuses section if Counter2 >= 20
00068ee0: 00031080 sll r2,r3,0x02                         |r2 = (Counter2 - 1) * 4 (status 4 bytes offset)
00068ee4: 3c018006 lui r1,0x8006                          |
00068ee8: 00220821 addu r1,r1,r2                          |r1 = 8006XXXX (XXXX )
00068eec: 8c227038 lw r2,0x7038(r1)                       |r2 = status jump address Load Code Pointer
00068ef0: 00000000 nop                                    |
00068ef4: 00400008 jr r2                                  >> jump to r2 value
00068ef8: 00000000 nop
Crystal/Chicken
00068efc: 8ca20154 lw r2,0x0154(r5)                       |r2 = unit's Statuses to Remove 5 (misc data 0x0154 )
00068f00: 00000000 nop                                    |
00068f04: 34420002 ori r2,r2,0x0002                       |r2 = r2 + Enable Crystal/chicken 
00068f08: aca20154 sw r2,0x0154(r5)                       | Store updated r2 Statuses to Remove 5 
00068f0c: 8ca2014c lw r2,0x014c(r5)                       |r2 = unit's Statuses to add 5 (misc data 0x014c )
00068f10: 0801a3dd j 0x 00068f74                          >> Jump to end of Jump/Float/Transparent (r3 will be updated and stored)
00068f14: 2403fffd addiu r3,r0,0xfffd                     |r3 = everything but 0x0002 (while be processed after jump)
Frog
00068f18: 8ca20154 lw r2,0x0154(r5)                       |r2 = Unit's Statuses to Remove 5 (misc data 0x0154 )
00068f1c: 02402021 addu r4,r18,r0                         |r4 = Unit's ID
00068f20: 34420004 ori r2,r2,0x0004                       |r2 = r2 updated with Frog enabled
00068f24: aca20154 sw r2,0x0154(r5)                       | Store r2 updated Statuses to Remove 5 
00068f28: 8ca2014c lw r2,0x014c(r5)                       |r2 = unit's Statuses to add 5 (misc data 0x014c )
00068f2c: 2403fffb addiu r3,r0,0xfffb                     |r3 = everything but 0x0004 
00068f30: 00431024 and r2,r2,r3                           |update r2 without frog flag
00068f34: 0c0667b2 jal 0x00199ec8        JAL              --> Usable_Ability_Setting/ENTD_AI_Calculations
00068f38: aca2014c sw r2,0x014c(r5)                       | Store filtered Statuses to Add 5 
00068f3c: 0801a437 j 0x 000690dc                          >> Jump to END
00068f40: 34020001 ori r2,r0,0x0001                       |r2 = 1
Jump/Float/Transparent
00068f44: 3c028009 lui r2,0x8009 
00068f48: 24424a40 addiu r2,r2,0x4a40                     |r2 = 0x80094a40 (Status Flags table)
00068f4c: 00112080 sll r4,r17,0x02                        |r4 = (status X number +1) * 4
00068f50: 00822021 addu r4,r4,r2                          |r4 = 0x80094a40 + status offset (4 bytes for each status)
00068f54: 8ca20154 lw r2,0x0154(r5)                       |r2 = Unit's Statuses to Remove 5 (misc data 0x0154 )
00068f58: 8c830000 lw r3,0x0000(r4)                       |r3 = Status X Flags
00068f5c: 00000000 nop
00068f60: 00431025 or r2,r2,r3                            |Update r2 with Status X Flag enabled
00068f64: aca20154 sw r2,0x0154(r5)                       | Store updated Statuses to Remove 5 
00068f68: 8c820000 lw r2,0x0000(r4)                       |r2 = Status X Flags
00068f6c: 8ca3014c lw r3,0x014c(r5)                       |r3 = unit's Statuses to add 5 (misc data 0x014c )
00068f70: 00021027 nor r2,r0,r2                           |r2 updated with everything but status X flag 
00068f74: 00431024 and r2,r2,r3                          W|r2 filtered with unit's status to add 5 // W - landing of crystal chicken jump
00068f78: 0801a436 j 0x 000690d8                          >> Jump to pre-END (set r2 to 0x01 and end)
00068f7c: aca2014c sw r2,0x014c(r5)                       | Store filtered Statuses to Add 5 
Other statuses
00068f80: 3c028009 lui r2,0x8009                   
00068f84: 24424a40 addiu r2,r2,0x4a40                 E# r2 = 0x80094a40  (Status Flags table)  - (Landing line of branch if counter >= 20)           
00068f88: 00112080 sll r4,r17,0x02                    |r4 = (status X number +1) * 4
00068f8c: 00822021 addu r4,r4,r2                      |r4 = 0x80094a40 + status offset (4 bytes for each status)
00068f90: 8ca20150 lw r2,0x0150(r5)                   | r2 = Unit's Statuses to Remove 1 (misc data 0x0150 )
00068f94: 8c830000 lw r3,0x0000(r4)                   | r3 = Status X Flags 
00068f98: 00000000 nop
00068f9c: 00431025 or r2,r2,r3                        |r2 = Updated Unit's Statuses to remove 1 with Status X flag
00068fa0: aca20150 sw r2,0x0150(r5)                   | Store updated Statuses to Remove 1 
00068fa4: 8c820000 lw r2,0x0000(r4)                   | r2 = Status X Flags 
00068fa8: 8ca30148 lw r3,0x0148(r5)                   | r3 = unit's Statuses to add 1 (misc data 0x0148 ) 
00068fac: 00021027 nor r2,r0,r2                       |r2 updated with everything but status X flag
00068fb0: 00431024 and r2,r2,r3                       |r2 filtered with unit's status to add 1
00068fb4: 0801a436 j 0x 000690d8                      >> Jump to pre-END (set r2 to 0x01 and end)
00068fb8: aca20148 sw r2,0x0148(r5)                   | Store filtered Statuses to Add 1 
*Status Flag Enabling*
00068fbc: 2623ffff addiu r3,r17,0xffff	       E# r3 = Counter2 - 1 (C2 starts at 1) = status number (in patcher list)
00068fc0: 2c620020 sltiu r2,r3,0x0020             |r2 = 0x01 if status number < 0x20  Else 0x00(wall faith ?)
00068fc4: 10400036 beq r2,r0,0x 000690a0          #If r2 = 0x01 (counter < 0x20) / Branch o others statuses section if Counter2 >= 20
00068fc8: 00031080 sll r2,r3,0x02                     |r2 = (Counter2 - 1) * 4 (status 4 bytes offset)		                
00068fcc: 3c018006 lui r1,0x8006                      |
00068fd0: 00220821 addu r1,r1,r2                      |r1 = 8006XXXX 
00068fd4: 8c2270b8 lw r2,0x70b8(r1)		           | r2 = status jump address Load Code Pointer 
00068fd8: 00000000 nop                                |
00068fdc: 00400008 jr r2                              >>Jump to r2
00068fe0: 00000000 nop
Crystal
00068fe4: 8ca2014c lw r2,0x014c(r5)                   | r2 = unit's Statuses to add 5 (misc data 0x014c ) 
00068fe8: 00000000 nop                                |
00068fec: 34420001 ori r2,r2,0x0001                   |r2 = r2 updated with Crystal flag
00068ff0: aca2014c sw r2,0x014c(r5)                   | Store updated Statuses to Add 5  
00068ff4: 8ca20154 lw r2,0x0154(r5)                   | r2 = Unit's Statuses to Remove 5 (misc data 0x0154 ) 
00068ff8: 0801a425 j 0x 00069094                      >>Jump to end of jump section (will update status to remove there)
00068ffc: 2403fffe addiu r3,r0,0xfffe                 |r3 = everything but Crystal flag
Chicken
00069000: 8ca2014c lw r2,0x014c(r5)                   | r2 = unit's Statuses to add 5 (misc data 0x014c ) 
00069004: 00000000 nop                                |
00069008: 34420002 ori r2,r2,0x0002                   |r2 = r2 updated with chicken flag
0006900c: aca2014c sw r2,0x014c(r5)                   | Store updated Statuses to Add 5 
00069010: 8ca20154 lw r2,0x0154(r5)                   | r2 = Unit's Statuses to Remove 5 (misc data 0x0154 ) 
00069014: 0801a425 j 0x 00069094                      >>Jump to end of jump section (will update status to remove there)
00069018: 2403fffd addiu r3,r0,0xfffd                 |r3 = everything but chicken flag
Frog
0006901c: 8ca2014c lw r2,0x014c(r5)                   | r2 = unit's Statuses to add 5 (misc data 0x014c ) 
00069020: 02402021 addu r4,r18,r0                     |r4 = Unit's ID
00069024: 34420004 ori r2,r2,0x0004                   |r2 = r2 updated with frog flag
00069028: aca2014c sw r2,0x014c(r5)                   | Store updated Statuses to Add 5  
0006902c: 8ca20154 lw r2,0x0154(r5)                   | r2 = Unit's Statuses to Remove 5 (misc data 0x0154 ) 
00069030: 2403fffb addiu r3,r0,0xfffb                 |r3 = everything but 0x04 (frog)
00069034: 00431024 and r2,r2,r3                       |r2 = r2 filtered without frog
00069038: 0c0667b2 jal 0x00199ec8                     --> Usable_Ability_Setting/ENTD_AI_Calculations
0006903c: aca20154 sw r2,0x0154(r5)                   | Store filtered Statuses to Remove 5 
00069040: 0801a437 j 0x 000690dc                      >> Jump to END 
00069044: 34020001 ori r2,r0,0x0001
Treasure
00069048: 8ca2014c lw r2,0x014c(r5)                   | r2 = unit's Statuses to add 5 (misc data 0x014c ) 
0006904c: 00000000 nop                                |
00069050: 34420008 ori r2,r2,0x0008                   |r2 = r2 updated with Treasure flag
00069054: aca2014c sw r2,0x014c(r5)                   | Store updated Statuses to Add 5  
00069058: 8ca20154 lw r2,0x0154(r5)                   | r2 = Unit's Statuses to Remove 5 (misc data 0x0154 ) 
0006905c: 0801a425 j 0x 00069094                      >>Jump to end of jump section (will update status to remove there)               
00069060: 2403fff7 addiu r3,r0,0xfff7                 |r3 = Everything but Treasure flag
Jump/Float/Transparent
00069064: 3c028009 lui r2,0x8009                      |
00069068: 24424a40 addiu r2,r2,0x4a40                 |r2 = 0x80094a40 (Status Flags table)
0006906c: 00112080 sll r4,r17,0x02                    |r4 = (status X number +1) * 4
00069070: 00822021 addu r4,r4,r2                      |r4 = 0x80094a40 + status offset (4 bytes for each status)
00069074: 8ca2014c lw r2,0x014c(r5)		           | r2 = unit's Statuses to add 5 (misc data 0x014c ) 
00069078: 8c830000 lw r3,0x0000(r4)                   | r3 = Status X Flags 
0006907c: 00000000 nop                                |
00069080: 00431025 or r2,r2,r3                        |r2 = r2 updated with status flag
00069084: aca2014c sw r2,0x014c(r5)                   | Store new Statuses to Add 5 
00069088: 8c820000 lw r2,0x0000(r4)                   | r2 = Status X Flags 
0006908c: 8ca30154 lw r3,0x0154(r5)                   | r2 = Unit's Statuses to Remove 5 (misc data 0x0154 ) 
00069090: 00021027 nor r2,r0,r2                       |r2 = Everything but status X flag
00069094: 00431024 and r2,r2,r3                      W|r2 = Unit's status to remove 5 without status X flag (landing line of other section jump)
00069098: 0801a436 j 0x 000690d8                      >> Jump to pre-END (set r2 to 0x01 and end)
0006909c: aca20154 sw r2,0x0154(r5)                   | Store updated Statuses to Remove 5 
Other statuses
000690a0: 3c028009 lui r2,0x8009                  E# (Branch if Status number >= 20)
000690a4: 24424a40 addiu r2,r2,0x4a40             |r2 = 0x80094a40 (Status Flags table)                
000690a8: 00112080 sll r4,r17,0x02                |r4 = (status X number +1) * 4
000690ac: 00822021 addu r4,r4,r2                  |r4 = 0x80094a40 + status offset (4 bytes for each status)
000690b0: 8ca20148 lw r2,0x0148(r5)               | r2 = unit's Statuses to add 1 (misc data 0x0148 ) 
000690b4: 8c830000 lw r3,0x0000(r4)               | r3 = Status X Flag  
000690b8: 00000000 nop                            |
000690bc: 00431025 or r2,r2,r3                    |r2 updated with Status X Flags
000690c0: aca20148 sw r2,0x0148(r5)               | Store updated Statuses to Add 1 
000690c4: 8c820000 lw r2,0x0000(r4)               | r2 = Status X Flag  
000690c8: 8ca30150 lw r3,0x0150(r5)               | r3 = Unit's Statuses to Remove 1 (misc data 0x0150 ) 
000690cc: 00021027 nor r2,r0,r2                   |r2 = everything but status X flag
000690d0: 00431024 and r2,r2,r3                   |r2 = Unit's Statuses to Remove 1 without status X flag
000690d4: aca20150 sw r2,0x0150(r5)               | Store filtered Statuses to Remove 1 
Unused/Invite/Treasure (disabling)/Wall
000690d8: 34020001 ori r2,r0,0x0001		r2 = 1
000690dc: 8fbf001c lw r31,0x001c(r29)
000690e0: 8fb20018 lw r18,0x0018(r29)
000690e4: 8fb10014 lw r17,0x0014(r29)
000690e8: 8fb00010 lw r16,0x0010(r29)
000690ec: 27bd0020 addiu r29,r29,0x0020
000690f0: 03e00008 jr r31
000690f4: 00000000 nop

Return location

0018e9d8: Determine_if_Status_Flags_can_be_Enabled

Summary

Find unit misc data by target ID 
Update Unit X misc data 0x148 0x14C 0x150 0x154 with status Y flag enabled/disabled