Difference between revisions of "Get Tile Data Pointer"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Created page with " # ROUTINE: GET TILE DATA POINTER # Parameters: # r4 = X Coordinate # r5 = Y Coordinate # r6 = Higher Elevation bit # Returns:...")
 
m
Line 17: Line 17:
 
  00183fd4: 04a00005 bltz r5,0x00183fec          #      or (Y Coordinate < 0)
 
  00183fd4: 04a00005 bltz r5,0x00183fec          #      or (Y Coordinate < 0)
 
  00183fd8: 00a3102a slt r2,r5,r3
 
  00183fd8: 00a3102a slt r2,r5,r3
  00183fdc: 10400003 beq r2,r0,0x00183fec        #      or (Y Coordiante >= Map Max Y Coordinate)
+
  00183fdc: 10400003 beq r2,r0,0x00183fec        #      or (Y Coordinate >= Map Max Y Coordinate)
 
  00183fe0: 2cc20002 sltiu r2,r6,0x0002
 
  00183fe0: 2cc20002 sltiu r2,r6,0x0002
 
  00183fe4: 14400003 bne r2,r0,0x00183ff4        #      or (Higher Elevation bit >= 2)
 
  00183fe4: 14400003 bne r2,r0,0x00183ff4        #      or (Higher Elevation bit >= 2)

Revision as of 22:24, 3 November 2016

#   ROUTINE: GET TILE DATA POINTER
#       Parameters:
#           r4 = X Coordinate
#           r5 = Y Coordinate
#           r6 = Higher Elevation bit
#       Returns:
#           r2 = Pointer to Tile Data for specified coordinates

00183fb4: 3c07800e lui r7,0x800e
00183fb8: 90e74e9c lbu r7,0x4e9c(r7)            #   Map Max X Coordinate
00183fbc: 3c03800e lui r3,0x800e
00183fc0: 90634ea0 lbu r3,0x4ea0(r3)            #   Map Max Y Coordinate
00183fc4: 04800009 bltz r4,0x00183fec           #   if ((X Coordinate < 0) 
00183fc8: 0087102a slt r2,r4,r7
00183fcc: 10400007 beq r2,r0,0x00183fec         #       or (X Coordinate >= Map Max X Coordinate)
00183fd0: 00000000 nop
00183fd4: 04a00005 bltz r5,0x00183fec           #       or (Y Coordinate < 0)
00183fd8: 00a3102a slt r2,r5,r3
00183fdc: 10400003 beq r2,r0,0x00183fec         #       or (Y Coordinate >= Map Max Y Coordinate)
00183fe0: 2cc20002 sltiu r2,r6,0x0002
00183fe4: 14400003 bne r2,r0,0x00183ff4         #       or (Higher Elevation bit >= 2)
00183fe8: 00a70018 mult r5,r7
                                                #   ) {

00183fec: 08061005 j 0x00184014                         Return 0 (null)
00183ff0: 00001021 addu r2,r0,r0
                                                #   }
00183ff4: 00061200 sll r2,r6,0x08               #   [Higher Elevation bit] * 256
00183ff8: 00001812 mflo r3                      #   (Y Coordinate * Map Max X Coordinate)
00183ffc: 00431021 addu r2,r2,r3                #   [Higher Elevation bit] * 256 + (Y Coordinate * Map Max X Coordinate) 
00184000: 00441021 addu r2,r2,r4                #   [Higher Elevation bit] * 256 + (Y Coordinate * Map Max X Coordinate) + X Coordinate
00184004: 000210c0 sll r2,r2,0x03               #   Offset for tile at coordinates: ([Higher Elevation bit] * 256 + (Y Coordinate * Map Max X Coordinate) + X Coordinate) * 8
00184008: 3c038019 lui r3,0x8019
0018400c: 2463f8cc addiu r3,r3,-0x0734          #   Tile data base pointer (0x8018f8cc)
00184010: 00431021 addu r2,r2,r3                #   Pointer to Tile data for this tile

00184014: 03e00008 jr r31                       #   Return Tile data pointer
00184018: 00000000 nop