Get Variable's Word Pointer from Variable's ID

From Final Fantasy Hacktics Wiki
Revision as of 20:06, 29 October 2021 by Orkney (talk | contribs) (correcting notes)
Jump to navigation Jump to search
#Input r4 (0x00 from Run script variable) - keep r4 unchanged
#Return r2 
    as 0x0005771c + r4 * 4 if r4 < 0x80   (steal gil leads here)
    as 0x0005771c + 0x200 + ((r4-0x80) /32)*4 if r4 is between 0x80 and 0x359
    as 0x0005771c + 0x25c + ((r4 - 0x360)/8)*4 if r4 is between 0x360 and 0x3FF
    as ? If r4>= 0x400 (via 0014c958_-_0014c990 - not investigated)
------------------------------------------------------------------------------------
0014a2ec: 27bdffe8 addiu r29,r29,-0x0018          
0014a2f0: 28820080 slti r2,r4,0x0080             |r2 = 1 if Input < 0x80 
0014a2f4: afbf0014 sw r31,0x0014(r29)            |
0014a2f8: 10400006 beq r2,r0,0x0014a314          #Input < 0x80 (r2=1)
0014a2fc: afb00010 sw r16,0x0010(r29)            
0014a300: 3c038016 lui r3,0x8016                 
0014a304: 8c635f9c lw r3,0x5f9c(r3)                  |r3 = 0x80165f9c (host 0005771c - start of main (map?) data?)
0014a308: 00041080 sll r2,r4,0x02                    |r2 = r4 * 4 
0014a30c: 080528e1 j 0x0014a384                      >>jump to almost end
0014a310: 00438021 addu r16,r2,r3                    |r16 = Main (map ?)  data start + offset (r4*4)
0014a314: 28820360 slti r2,r4,0x0360             |r2 = 1 if input < 0x360 
0014a318: 1040000b beq r2,r0,0x0014a348          #If r2 = 1 (r4 between 0x80 and 0x35F) branch if r2 = 0
0014a31c: 2482ff80 addiu r2,r4,-0x0080               |r2 = input - 0x80  (0x00 to 2DF)
0014a320: 04410003 bgez r2,0x0014a330                #If r2 < 0 never true ? 
0014a324: 00021143 sra r2,r2,0x05                    |r2 = r2 /32 any value under 0x20 is 0x00 (for input = 0x80 to 0xA0)
0014a328: 2482ff9f addiu r2,r4,-0x0061                   |r2 = input-0x61
0014a32c: 00021143 sra r2,r2,0x05                        |r2 = r2/32
0014a330: 00021080 sll r2,r2,0x02                    |r2 = r2*4
0014a334: 3c038016 lui r3,0x8016                     |
0014a338: 8c635f9c lw r3,0x5f9c(r3)                  |r3 = 0x80165f9c (host 0005771c - start of main (map?) data?)
0014a33c: 24420200 addiu r2,r2,0x0200                |r2 = r2 + 0x200
0014a340: 080528e1 j 0x0014a384                      >>jump to almost end
0014a344: 00438021 addu r16,r2,r3                    |r16 = Main (map ?)  data start + offset
0014a348: 28820400 slti r2,r4,0x0400             |r2 = 1 if input < 0x400
0014a34c: 1040000b beq r2,r0,0x0014a37c          #If input < 0x400 and >= 0x360 
0014a350: 2482fca0 addiu r2,r4,-0x0360               |r2 = input - 0x360)
0014a354: 04410003 bgez r2,0x0014a364                #If r2<0 (never true ?)
0014a358: 000210c3 sra r2,r2,0x03                    |r2 = r2/8
0014a35c: 2482fca7 addiu r2,r4,-0x0359                   |r2 = input - 0x359
0014a360: 000210c3 sra r2,r2,0x03                        |r2 = r2/8
0014a364: 00021080 sll r2,r2,0x02                    |r2 = r2 * 4 
0014a368: 3c038016 lui r3,0x8016                     |
0014a36c: 8c635f9c lw r3,0x5f9c(r3)                  |r3 = 0x80165f9c (host 0005771c - start of main (map?) data?)
0014a370: 2442025c addiu r2,r2,0x025c                |r2 = r2 + 0x25c
0014a374: 080528e1 j 0x0014a384                      >>jump to almost end
0014a378: 00438021 addu r16,r2,r3                    |r16 = Main (map ?)  data + offset ?
0014a37c: 0c053256 jal 0x0014c958                |-->jal 0x0014c958 (input > 0x400)  
0014a380: 00000000 nop                           |
0014a384: 02001021 addu r2,r16,r0                |r2 = r16 (jumps landing site)
0014a388: 8fbf0014 lw r31,0x0014(r29)            
0014a38c: 8fb00010 lw r16,0x0010(r29)            
0014a390: 27bd0018 addiu r29,r29,0x0018          
0014a394: 03e00008 jr r31                        
0014a398: 00000000 nop

Returns location

0014a0cc: Run_Script_Variable_Command