Difference between revisions of "Find Unit at Coordinates (Special) (0x7a2b8)"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with " # ROUTINE: FIND UNIT AT COORDINATES (SPECIAL) (0x7a2b8) # Finds a unit at the specified coordinates. # Units that are in Jumping, Crystal, or Treasure status are ignore...")
 
(Blanked the page)
 
Line 1: Line 1:
# ROUTINE: FIND UNIT AT COORDINATES (SPECIAL) (0x7a2b8)
+
 
#  Finds a unit at the specified coordinates.
 
#  Units that are in Jumping, Crystal, or Treasure status are ignored.
 
#  Favors unit pointer in memory at 0x80096118, if it exists.
 
#  Favors mounted units?
 
#
 
#  Parameters:
 
#      r4 = X Coordinate
 
#      r5 = Y Coordinate
 
#      r6 = Higher Elevation bit
 
#  Returns:
 
#      r2 = [Unit misc data pointer] of appropriate unit, or null if no unit found
 
 
0007a2b8: 27bdffb0 addiu r29,r29,-0x0050
 
0007a2bc: 3c03800a lui r3,0x800a
 
0007a2c0: 8c638a54 lw r3,-0x75ac(r3)                    #  [Unit misc data pointer]
 
0007a2c4: 00000000 nop
 
0007a2c8: 10600023 beq r3,r0,0x0007a358                #  Check if ([Unit misc data pointer] != null)
 
0007a2cc: 00003821 addu r7,r0,r0                        #  index = 0
 
                                                        #  if ([Unit misc data pointer] != null) {
 
0007a2d0: 340900ff ori r9,r0,0x00ff
 
0007a2d4: 03a04021 addu r8,r29,r0                      #      declare stackArray, 80 bytes (20 words)
 
                                                        #      (Points to initial element of stack array)
 
                                                        #      do {
 
0007a2d8: 9062007c lbu r2,0x007c(r3)                    #          Unit's X Coordinate
 
0007a2dc: 00000000 nop
 
0007a2e0: 14440019 bne r2,r4,0x0007a348                #          if ([Unit's X Coordinate] != [Input X Coordinate]), continue (skip this iteration)
 
0007a2e4: 00000000 nop
 
0007a2e8: 9062007d lbu r2,0x007d(r3)                    #          Unit's Y Coordinate
 
0007a2ec: 00000000 nop
 
0007a2f0: 14450015 bne r2,r5,0x0007a348                #          if ([Unit's Y Coordinate] != [Input Y Coordinate]), continue (skip this iteration)
 
0007a2f4: 00000000 nop
 
0007a2f8: 9062007e lbu r2,0x007e(r3)                    #          Unit's Higher Elevation bit
 
0007a2fc: 00000000 nop
 
0007a300: 14460011 bne r2,r6,0x0007a348                #          if ([Unit's Higher Elevation bit] != [Input Higher Elevation bit]), continue (skip this iteration)
 
0007a304: 00000000 nop
 
0007a308: 8c620134 lw r2,0x0134(r3)                    #          Unit in-battle data pointer
 
0007a30c: 00000000 nop
 
0007a310: 1040000d beq r2,r0,0x0007a348                #          If ([Unit in-battle data pointer] == null), continue (skip this iteration)
 
0007a314: 00000000 nop
 
0007a318: 90420001 lbu r2,0x0001(r2)                    #          Does unit exist?
 
0007a31c: 00000000 nop
 
0007a320: 10490009 beq r2,r9,0x0007a348                #          If not, update [Unit misc data pointer], continue (skip this iteration)
 
0007a324: 00000000 nop
 
0007a328: 8c620144 lw r2,0x0144(r3)                    #          Unit's Current Status Flags 5
 
0007a32c: 00000000 nop
 
0007a330: 30420049 andi r2,r2,0x0049                    #          Check for Jumping, Crystal or Treasure
 
0007a334: 14400004 bne r2,r0,0x0007a348                #          if (Unit is Jumping, Crystal or Treasure), continue (skip this iteration)
 
0007a338: 00000000 nop
 
0007a33c: ad030000 sw r3,0x0000(r8)                    #          stackArray[index] = [Unit misc data pointer]
 
0007a340: 25080004 addiu r8,r8,0x0004                  #          (Points to next element of stack array) 
 
0007a344: 24e70001 addiu r7,r7,0x0001                  #          index = index + 1
 
 
0007a348: 8c630000 lw r3,0x0000(r3)                    #          [Unit misc data pointer] = (Previous unit misc data pointer) (Updates even if skipping iteration)
 
0007a34c: 00000000 nop
 
0007a350: 1460ffe1 bne r3,r0,0x0007a2d8                #      } while ([Unit misc data pointer] != null)
 
0007a354: 00000000 nop
 
                                                        #  }
 
                                                       
 
0007a358: 10e00023 beq r7,r0,0x0007a3e8                #  if (index == 0), return 0 (null)
 
0007a35c: 34020001 ori r2,r0,0x0001
 
0007a360: 10e2001c beq r7,r2,0x0007a3d4                #  if (index == 1), return stackArray[0]
 
0007a364: 00000000 nop
 
                                                       
 
0007a368: 18e0000d blez r7,0x0007a3a0                  #  Check if (index > 0)    (How could it not be?)
 
0007a36c: 00001821 addu r3,r0,r0                        #  innerIndex = 0
 
                                                        #  if (index > 0) {
 
0007a370: 3c068009 lui r6,0x8009
 
0007a374: 8cc66118 lw r6,0x6118(r6)                    #      [Global unit misc ID]
 
0007a378: 03a02821 addu r5,r29,r0                      #      (Points to initial element of stack array)
 
                                                        #      do {
 
0007a37c: 8ca40000 lw r4,0x0000(r5)                    #          stackArray[innerIndex]
 
0007a380: 00000000 nop
 
0007a384: 90820004 lbu r2,0x0004(r4)                    #          [Unit misc ID] from stackArray[innerIndex]
 
0007a388: 00000000 nop
 
0007a38c: 10460014 beq r2,r6,0x0007a3e0                #          if ([Unit misc ID] == [Global unit misc ID]), return stackArray[innerIndex]
 
0007a390: 24630001 addiu r3,r3,0x0001                  #          innerIndex = innerIndex + 1
 
0007a394: 0067102a slt r2,r3,r7                        #          Check (innerIndex < index)
 
0007a398: 1440fff8 bne r2,r0,0x0007a37c                           
 
0007a39c: 24a50004 addiu r5,r5,0x0004                  #          (Points to next element of stack array)
 
                                                        #      } while (innerIndex < index)
 
                                                        #  }
 
 
0007a3a0: 18e0000c blez r7,0x0007a3d4                  #  Check if (index > 0)    (How could it not be?)
 
0007a3a4: 00001821 addu r3,r0,r0                        #  innerIndex = 0
 
                                                        #  if (index > 0) {
 
0007a3a8: 34060001 ori r6,r0,0x0001
 
0007a3ac: 03a02821 addu r5,r29,r0                      #      (Points to first element of stack array)
 
                                                        #      do {
 
0007a3b0: 8ca40000 lw r4,0x0000(r5)                    #          stackArray[innerIndex]
 
0007a3b4: 00000000 nop
 
0007a3b8: 90820130 lbu r2,0x0130(r4)                    #          Mount/Rider Value of stackArray[innerIndex]
 
0007a3bc: 00000000 nop
 
0007a3c0: 10460007 beq r2,r6,0x0007a3e0                #          if (Mount/Rider Value == 1), return stackArray[innerIndex]
 
0007a3c4: 24630001 addiu r3,r3,0x0001                  #          innerIndex = innerIndex + 1
 
0007a3c8: 0067102a slt r2,r3,r7                        #          Check if (innerIndex < index)
 
0007a3cc: 1440fff8 bne r2,r0,0x0007a3b0
 
0007a3d0: 24a50004 addiu r5,r5,0x0004
 
                                                        #      } while (innerIndex < index)
 
                                                        #  }
 
 
0007a3d4: 8fa20000 lw r2,0x0000(r29)                    #  Return stackArray[0]
 
0007a3d8: 0801e8fb j 0x0007a3ec
 
0007a3dc: 00000000 nop
 
 
0007a3e0: 0801e8fb j 0x0007a3ec
 
0007a3e4: 00801021 addu r2,r4,r0
 
 
0007a3e8: 00001021 addu r2,r0,r0
 
 
0007a3ec: 27bd0050 addiu r29,r29,0x0050
 
0007a3f0: 03e00008 jr r31
 
0007a3f4: 00000000 nop
 

Latest revision as of 19:50, 11 September 2016