Difference between revisions of "Get Variable's Word Pointer from Variable's ID"
Jump to navigation
Jump to search
m |
m (Orkney moved page 0014a2ec - 0014a398 to Get Variable's Word Pointer from Variable's ID) |
(No difference)
|
Latest revision as of 12:46, 6 March 2022
Parameters : r4 = Variable ID Returns: r2 = Pointer to the word containing the variable (if variable ID < 0x400) r2 = Some data from a new thread of Variable ID >= 0x400 (events ?) ------------------------------------------------------------------------------------------------- 0014a2ec: 27bdffe8 addiu r29,r29,-0x0018 | 0014a2f0: 28820080 slti r2,r4,0x0080 |r2 = 0x01 if Variable ID < 0x80 0014a2f4: afbf0014 sw r31,0x0014(r29) | 0014a2f8: 10400006 beq r2,r0,0x0014a314 #If Variable ID < 0x80 #(Miscellaneous_Words from 0x00 to 0x7f are words) 0014a2fc: afb00010 sw r16,0x0010(r29) | 0014a300: 3c038016 lui r3,0x8016 | 0014a304: 8c635f9c lw r3,0x5f9c(r3) |£r3 = 0x0005771c - start of variables data 0014a308: 00041080 sll r2,r4,0x02 |r2 = Variable ID Value * 4 0014a30c: 080528e1 j 0x0014a384 >>Jump to END (return r2 = r16) 0014a310: 00438021 addu r16,r2,r3 |r16 = Miscellaneous word pointer #Else Variable ID >= 0x80 0014a314: 28820360 slti r2,r4,0x0360 |r2 = 0x01 if Variable ID value < 0x360 0014a318: 1040000b beq r2,r0,0x0014a348 #If Variable ID is between 0x80 and 0x35f (From miscellaneous Bytes to unexplored land) 0014a31c: 2482ff80 addiu r2,r4,-0x0080 |r2 = Variable ID - 0x80 0014a320: 04410003 bgez r2,0x0014a330 #If r2 < 0 (never true ?) 0014a324: 00021143 sra r2,r2,0x05 |r2 = r2 /32 32 variables per words in this section 0014a328: 2482ff9f addiu r2,r4,-0x0061 |r2 = Variable ID-0x61 0014a32c: 00021143 sra r2,r2,0x05 |r2 = r2/32 0014a330: 00021080 sll r2,r2,0x02 |r2 = r2*4 Offset of the word with the desired flag (from 0x80) 0014a334: 3c038016 lui r3,0x8016 | 0014a338: 8c635f9c lw r3,0x5f9c(r3) |£r3 = 0x0005771c - start of main data 0014a33c: 24420200 addiu r2,r2,0x0200 |r2 = r2 + 0x200 *0x5771c + 0x200 = 0x5791c (start of Variable from 0x80) 0014a340: 080528e1 j 0x0014a384 >>Jump to END (return r2 = r16) 0014a344: 00438021 addu r16,r2,r3 |r16 = Pointer to the word containing the Variable (from r4) #Else Variable ID >= 0x360 0014a348: 28820400 slti r2,r4,0x0400 |r2 = 1 if Variable ID < 0x400 0014a34c: 1040000b beq r2,r0,0x0014a37c #If Variable ID < 0x400 and >= 0x360 0014a350: 2482fca0 addiu r2,r4,-0x0360 |r2 = Variable ID - 0x360 0014a354: 04410003 bgez r2,0x0014a364 #If r2<0 (never true ?) 0014a358: 000210c3 sra r2,r2,0x03 |r2 = r2/8 8 Variables per words in this section 0014a35c: 2482fca7 addiu r2,r4,-0x0359 |r2 = Variable ID - 0x359 0014a360: 000210c3 sra r2,r2,0x03 |r2 = r2/8 0014a364: 00021080 sll r2,r2,0x02 |r2 = r2 * 4 Offset of the word with the desired flag (from 0x360) 0014a368: 3c038016 lui r3,0x8016 | 0014a36c: 8c635f9c lw r3,0x5f9c(r3) |£r3 = 0x0005771c - start of main data 0014a370: 2442025c addiu r2,r2,0x025c |r2 = r2 + 0x25c *0x5771c + 0x25c = 0x57978 (start of Variable from 0x360) 0014a374: 080528e1 j 0x0014a384 >>Jump to END (return r2 = r16) 0014a378: 00438021 addu r16,r2,r3 |r16 = Pointer to the word containing the Variable (from r4) #Else Variable ID >= 0x400 Events new instruction 0014a37c: 0c053256 jal 0x0014c958 |-->0014c958_-_0014c990 Close running thread and seek a new one - r16 is loaded from new thread (0x10) 0014a380: 00000000 nop | 0014a384: 02001021 addu r2,r16,r0 Returns r2 = r16 (Variable ID word data pointer) 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
Return locations
Battle.bin 0014a084: Run_Script_Variable_Command 0014a0cc: Run_Script_Variable_Command