Difference between revisions of "Get Script Variable"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (Add duplicated link)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
  #  ROUTINE: GET SCRIPT VARIABLE
 
  #  ROUTINE: GET SCRIPT VARIABLE
 
  #      Parameters:
 
  #      Parameters:
  #          r4 = VariableID
+
  #          r4 = (VariableID) (https://ffhacktics.com/wiki/Variables)
 
  #      Returns:
 
  #      Returns:
 
  #          r2 = Value of Script Variable with specified ID
 
  #          r2 = Value of Script Variable with specified ID
Line 9: Line 9:
 
  8013b598: 00808821 addu r17,r4,r0              #  VariableID
 
  8013b598: 00808821 addu r17,r4,r0              #  VariableID
 
  8013b59c: 3c028016 lui r2,0x8016
 
  8013b59c: 3c028016 lui r2,0x8016
  8013b5a0: 8c425f9c lw r2,0x5f9c(r2)            #  *0x80165f9c
+
  8013b5a0: 8c425f9c lw r2,0x5f9c(r2)            #  Variable_0_Pointer = *0x80165f9c
 
  8013b5a4: 34030022 ori r3,r0,0x0022            #  0x22
 
  8013b5a4: 34030022 ori r3,r0,0x0022            #  0x22
 
  8013b5a8: afbf001c sw r31,0x001c(r29)
 
  8013b5a8: afbf001c sw r31,0x001c(r29)
 
  8013b5ac: afb20018 sw r18,0x0018(r29)
 
  8013b5ac: afb20018 sw r18,0x0018(r29)
 
  8013b5b0: afb00010 sw r16,0x0010(r29)
 
  8013b5b0: afb00010 sw r16,0x0010(r29)
  8013b5b4: 8c520000 lw r18,0x0000(r2)            #  originalValue = *(*0x80165f9c)
+
  8013b5b4: 8c520000 lw r18,0x0000(r2)            #  Old_Variable_0_Value = *Variable_0_Pointer
 
  8013b5b8: 1623000d bne r17,r3,0x8013b5f0         
 
  8013b5b8: 1623000d bne r17,r3,0x8013b5f0         
 
  8013b5bc: 340400be ori r4,r0,0x00be            #  0xbe
 
  8013b5bc: 340400be ori r4,r0,0x00be            #  0xbe
Line 33: Line 33:
 
  8013b5f0: 00002821 addu r5,r0,r0                #  0
 
  8013b5f0: 00002821 addu r5,r0,r0                #  0
 
  8013b5f4: 00003021 addu r6,r0,r0                #  0
 
  8013b5f4: 00003021 addu r6,r0,r0                #  0
  8013b5f8: 0c052806 jal 0x8014a018              #  ROUTINE: [[Run Script Variable Command]] (0xbe, 0, 0, 0)                 // ZERO (0)
+
  8013b5f8: 0c052806 jal 0x8014a018              #  ROUTINE: [[Run Script Variable Command]] (0xbe, 0, 0, 0)                   // ZERO (0)
 
  8013b5fc: 00003821 addu r7,r0,r0                #  0
 
  8013b5fc: 00003821 addu r7,r0,r0                #  0
 
  8013b600: 340400b1 ori r4,r0,0x00b1            #  0xb1
 
  8013b600: 340400b1 ori r4,r0,0x00b1            #  0xb1
 
  8013b604: 00002821 addu r5,r0,r0                #  0
 
  8013b604: 00002821 addu r5,r0,r0                #  0
 
  8013b608: 02203021 addu r6,r17,r0              #  Variable ID
 
  8013b608: 02203021 addu r6,r17,r0              #  Variable ID
  8013b60c: 0c052806 jal 0x8014a018              #  ROUTINE: [[Run Script Variable Command]] (0xb1, 0, VariableID, 0)       // ADDVAR (0, VariableID)
+
  8013b60c: 0c052806 jal 0x8014a018              #  ROUTINE: [[Run Script Variable Command]] (0xb1, 0, VariableID, 0)           // ADDVAR (0, VariableID)
 
  8013b610: 00003821 addu r7,r0,r0                #  0
 
  8013b610: 00003821 addu r7,r0,r0                #  0
 
  8013b614: 3c038016 lui r3,0x8016
 
  8013b614: 3c038016 lui r3,0x8016
  8013b618: 8c635f9c lw r3,0x5f9c(r3)            #  *0x80165f9c
+
  8013b618: 8c635f9c lw r3,0x5f9c(r3)            #  Variable_0_Pointer = *0x80165f9c
 
  8013b61c: 00000000 nop
 
  8013b61c: 00000000 nop
  8013b620: 8c620000 lw r2,0x0000(r3)            #  result = *(*0x80165f9c)
+
  8013b620: 8c620000 lw r2,0x0000(r3)            #  result = *(Variable_0_Pointer)
  8013b624: ac720000 sw r18,0x0000(r3)            #  *(*0x80165f9c) = originalValue
+
  8013b624: ac720000 sw r18,0x0000(r3)            #  *(Variable_0_Pointer) = Old_Variable_0_Value
 
  8013b628: 8fbf001c lw r31,0x001c(r29)          #  return result
 
  8013b628: 8fbf001c lw r31,0x001c(r29)          #  return result
 
  8013b62c: 8fb20018 lw r18,0x0018(r29)
 
  8013b62c: 8fb20018 lw r18,0x0018(r29)
Line 53: Line 53:
 
  8013b640: 00000000 nop
 
  8013b640: 00000000 nop
  
 +
=== Return location ===
 +
'''SCUS_942.21'''
 +
0005e69c: [[Increase_Casualties/Injured_Counters]]
 +
 +
'''Battle.bin'''
 +
00070d70:
 +
00079314:
 +
00079344:
 +
00081ea0:
 +
00081eac:
 +
00088880:
 +
0008e6ec:
 +
0008e93c:
 +
0008e948:
 +
0008e954:
 +
0008ebcc:
 +
0008edd4:
 +
0008ee80:
 +
00093674:
 +
000eeb80:
 +
000f35a8:
 +
000f35b4:
 +
000f35c8:
 +
000f3930:
 +
000f393c:
 +
000f3950:
 +
000f3b88:
 +
000f3b94:
 +
000f3ba8:
 +
000f3ffc:
 +
000f4008:
 +
000f401c:
 +
000f4bf4:
 +
000f4c00:
 +
000f4c14:
 +
0012da30:
 +
0012da40:
 +
0012db20:
 +
0012dc94:
 +
0012dfc4:
 +
0012fac8:
 +
0012fb0c:
 +
0012fcd0:
 +
00131428:
 +
00131d70:
 +
001322f0:
 +
0013332c:
 +
001333f8:
 +
00137c5c:
 +
0013b5c8:
 +
0013b5d4:
 +
0013cd8c:
 +
0013e82c:
 +
0013f420:
 +
0013f450:
 +
0014066c:
 +
001418b4:
 +
00141b90:
 +
00141c68:
 +
00141d18:
 +
00141d4c:
 +
00141d7c:
 +
001422d4:
 +
001426dc:
 +
001426f8:
 +
00142714:
 +
0014292c:
 +
00142948:
 +
00142964:
 +
00142978:
 +
00142988:
 +
001429a4:
 +
001429b8:
 +
001429c8:
 +
001429e4:
 +
00142a00:
 +
00142b78:
 +
00142c64:
 +
00142c7c:
 +
00142e74:
 +
00142eb4:
 +
001435f0:
 +
00143614:
 +
00143694:
 +
00143c94:
 +
00143dd8:
 +
00143e08:
 +
00143e20:
 +
00143e94:
 +
00144370:
 +
00145608:
 +
00145b9c:
 +
00145bb4:
 +
00145bc0:
 +
00145e7c:
 +
00145fc4:
 +
001461cc:
 +
001486d0:
 +
0014a1e4: [[Run_Script_Variable_Command]]
 +
0014a21c: [[Run_Script_Variable_Command]]
 +
0014a430:
 +
0014b588:
 +
0017f904:
 +
00180298:
 +
001803d8:
 +
00185780: [[Weather_effects_on_Bows]]
 +
0018578c: [[Weather_effects_on_Bows]]
 +
00186794: [[Steal_Gil]]
 +
0018e670:
 +
0018eb00:
 +
 +
  
 
Routine duplicated here : [[Unknown_1]]
 
Routine duplicated here : [[Unknown_1]]

Latest revision as of 20:23, 21 April 2022

#   ROUTINE: GET SCRIPT VARIABLE
#       Parameters:
#           r4 = (VariableID) (https://ffhacktics.com/wiki/Variables)
#       Returns:
#           r2 = Value of Script Variable with specified ID

8013b590: 27bdffe0 addiu r29,r29,-0x0020
8013b594: afb10014 sw r17,0x0014(r29)
8013b598: 00808821 addu r17,r4,r0               #   VariableID
8013b59c: 3c028016 lui r2,0x8016
8013b5a0: 8c425f9c lw r2,0x5f9c(r2)             #   Variable_0_Pointer = *0x80165f9c
8013b5a4: 34030022 ori r3,r0,0x0022             #   0x22
8013b5a8: afbf001c sw r31,0x001c(r29)
8013b5ac: afb20018 sw r18,0x0018(r29)
8013b5b0: afb00010 sw r16,0x0010(r29)
8013b5b4: 8c520000 lw r18,0x0000(r2)            #   Old_Variable_0_Value = *Variable_0_Pointer
8013b5b8: 1623000d bne r17,r3,0x8013b5f0        
8013b5bc: 340400be ori r4,r0,0x00be             #   0xbe
                                                #   if (Variable ID == 0x22) {
8013b5c0: 0c04ed64 jal 0x8013b590               #       ROUTINE: (Result_0x24) = Get Script Variable (0x24)   // Recursive call!
8013b5c4: 34040024 ori r4,r0,0x0024             #       0x24
8013b5c8: 30500001 andi r16,r2,0x0001           #       (Result_0x24) & 0x01
8013b5cc: 0c04ed64 jal 0x8013b590               #       ROUTINE: (Result_0x23) = Get Script Variable (0x23)   // Recursive call!
8013b5d0: 34040023 ori r4,r0,0x0023             #       0x23
8013b5d4: 30420007 andi r2,r2,0x0007            #       (Result_0x23) & 0x07
8013b5d8: 001083c0 sll r16,r16,0x0f             #       ((Result_0x24) & 0x01) << 15
8013b5dc: 00021300 sll r2,r2,0x0c               #       ((Result_0x23) & 0x07) << 12
8013b5e0: 34040022 ori r4,r0,0x0022             #       0x22
8013b5e4: 0c04ed91 jal 0x8013b644               #       ROUTINE: Set Script Variable (0x22, ((((Result_0x24) & 0x01) << 15) | (((Result_0x23) & 0x07) << 12)))
8013b5e8: 02022825 or r5,r16,r2                 #       ((((Result_0x24) & 0x01) << 15) | (((Result_0x23) & 0x07) << 12))
8013b5ec: 340400be ori r4,r0,0x00be             #       0xbe
                                                #   }
8013b5f0: 00002821 addu r5,r0,r0                #   0
8013b5f4: 00003021 addu r6,r0,r0                #   0
8013b5f8: 0c052806 jal 0x8014a018               #   ROUTINE: Run Script Variable Command (0xbe, 0, 0, 0)                    // ZERO (0)
8013b5fc: 00003821 addu r7,r0,r0                #   0
8013b600: 340400b1 ori r4,r0,0x00b1             #   0xb1
8013b604: 00002821 addu r5,r0,r0                #   0
8013b608: 02203021 addu r6,r17,r0               #   Variable ID
8013b60c: 0c052806 jal 0x8014a018               #   ROUTINE: Run Script Variable Command (0xb1, 0, VariableID, 0)           // ADDVAR (0, VariableID)
8013b610: 00003821 addu r7,r0,r0                #   0
8013b614: 3c038016 lui r3,0x8016
8013b618: 8c635f9c lw r3,0x5f9c(r3)             #   Variable_0_Pointer = *0x80165f9c
8013b61c: 00000000 nop
8013b620: 8c620000 lw r2,0x0000(r3)             #   result = *(Variable_0_Pointer)
8013b624: ac720000 sw r18,0x0000(r3)            #   *(Variable_0_Pointer) = Old_Variable_0_Value
8013b628: 8fbf001c lw r31,0x001c(r29)           #   return result
8013b62c: 8fb20018 lw r18,0x0018(r29)
8013b630: 8fb10014 lw r17,0x0014(r29)
8013b634: 8fb00010 lw r16,0x0010(r29)
8013b638: 27bd0020 addiu r29,r29,0x0020
8013b63c: 03e00008 jr r31
8013b640: 00000000 nop

Return location

SCUS_942.21
0005e69c: Increase_Casualties/Injured_Counters

Battle.bin
00070d70:
00079314:
00079344:
00081ea0:
00081eac:
00088880:
0008e6ec:
0008e93c:
0008e948:
0008e954:
0008ebcc:
0008edd4:
0008ee80:
00093674:
000eeb80:
000f35a8:
000f35b4:
000f35c8:
000f3930:
000f393c:
000f3950:
000f3b88:
000f3b94:
000f3ba8:
000f3ffc:
000f4008:
000f401c:
000f4bf4:
000f4c00:
000f4c14:
0012da30:
0012da40:
0012db20:
0012dc94:
0012dfc4:
0012fac8:
0012fb0c:
0012fcd0:
00131428:
00131d70:
001322f0:
0013332c:
001333f8:
00137c5c:
0013b5c8:
0013b5d4:
0013cd8c:
0013e82c:
0013f420:
0013f450:
0014066c:
001418b4:
00141b90:
00141c68:
00141d18:
00141d4c:
00141d7c:
001422d4:
001426dc:
001426f8:
00142714:
0014292c:
00142948:
00142964:
00142978:
00142988:
001429a4:
001429b8:
001429c8:
001429e4:
00142a00:
00142b78:
00142c64:
00142c7c:
00142e74:
00142eb4:
001435f0:
00143614:
00143694:
00143c94:
00143dd8:
00143e08:
00143e20:
00143e94:
00144370:
00145608:
00145b9c:
00145bb4:
00145bc0:
00145e7c:
00145fc4:
001461cc:
001486d0:
0014a1e4: Run_Script_Variable_Command
0014a21c: Run_Script_Variable_Command
0014a430:
0014b588:
0017f904:
00180298:
001803d8:
00185780: Weather_effects_on_Bows
0018578c: Weather_effects_on_Bows 
00186794: Steal_Gil
0018e670:
0018eb00:


Routine duplicated here : Unknown_1