Difference between revisions of "Load Ability From Skillset"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
  Load Ability From Skillset
+
  '''SCUS_942.21''' - Load Ability From Skillset                         DUPLICATED : [[Get_Ability_ID_From_Skillset]]
  0005a568: 288200b0 slti r2,r4,0x00b0
+
----------------------------------------------------------------------------------------------
  0005a56c: 10400017 beq r2,r0,0x0005a5cc Branch if using a monster skillset
+
Parameters : r4 - Skillset ID
  0005a570: 28a20016 slti r2,r5,0x0016
+
              r5 - Ability counter (position in the skillset)
  0005a574: 1040002d beq r2,r0,0x0005a62c Branch if Counter >= 0x16
+
  0005a578: 00a03021 addu r6,r5,r0 r6 = Counter
+
Returns : r2 = Ability ID (halfword)
  0005a57c: 3c038006 lui r3,0x8006
+
          r2 = 0x00 if Ability counter or skillset ID is invalid
  0005a580: 24634a94 addiu r3,r3,0x4a94
+
----------------------------------------------------------------------------------------------
  0005a584: 00041040 sll r2,r4,0x01 ID * 2
+
  0005a568: 288200b0 slti r2,r4,0x00b0       |{{f/std|Check if skillset is a monster skillset}}
  0005a588: 00441021 addu r2,r2,r4 ID * 3
+
  0005a56c: 10400017 beq r2,r0,0x0005a5cc     {{f/Cond|If Not a monster skillset}}
  0005a58c: 000210c0 sll r2,r2,0x03 ID * 24
+
  0005a570: 28a20016 slti r2,r5,0x0016           |{{f/std|Check if Ability counter is valid (max is 0x15 for skillset)}}
  0005a590: 00441021 addu r2,r2,r4 ID * 25
+
  0005a574: 1040002d beq r2,r0,0x0005a62c         {{f/Cond|Branch to }} {{f/loc|END}} '''if Ability counter is invalid'''
  0005a594: 04a10002 bgez r5,0x0005a5a0 Branch if Counter >= 0
+
  0005a578: 00a03021 addu r6,r5,r0               |{{f/std|<nowiki>r6 = Ability Counter</nowiki>}}
  0005a598: 00432021 addu r4,r2,r3 r4 = Pointer to Skillsets
+
  0005a57c: 3c038006 lui r3,0x8006               |
  0005a59c: 24a60007 addiu r6,r5,0x0007 r6 = Counter + 7
+
  0005a580: 24634a94 addiu r3,r3,0x4a94           |{{f/std|1st skillset data address}}
  0005a5a0: 000618c3 sra r3,r6,0x03 Counter / 8 (byte to load)
+
  0005a584: 00041040 sll r2,r4,0x01               |{{f/std|Skillset ID * 2}}
  0005a5a4: 00831021 addu r2,r4,r3
+
  0005a588: 00441021 addu r2,r2,r4               |{{f/std|ID * 3}}
  0005a5a8: 000318c0 sll r3,r3,0x03 Counter / 8 * 8
+
  0005a58c: 000210c0 sll r2,r2,0x03               |{{f/std|ID * 24}}
  0005a5ac: 00a31823 subu r3,r5,r3 r3 = Counter - Counter / 8 * 8
+
  0005a590: 00441021 addu r2,r2,r4               |{{f/std|ID * 25 (Size of each skillset data)}}
  0005a5b0: 90420000 lbu r2,0x0000(r2) Load Ability Flag s
+
  0005a594: 04a10002 bgez r5,0x0005a5a0           {{f/Cond|If counter < 0 }} ?
  0005a5b4: 24630001 addiu r3,r3,0x0001 C Mod = (Counter - Counter / 8 *  8) + 1
+
  0005a598: 00432021 addu r4,r2,r3               |{{f/adr|<nowiki>r4 = Pointer to Skillset's data</nowiki>}}
  0005a5b8: 00621004 sllv r2,r2,r3 Ability Flags * 2^(C Mod)
+
  0005a59c: 24a60007 addiu r6,r5,0x0007               |{{f/std|<nowiki>r6 = Counter + 7</nowiki>}}
  0005a5bc: 00851821 addu r3,r4,r5 r3 = Ability ID Pointer
+
  0005a5a0: 000618c3 sra r3,r6,0x03               |{{f/std|Ability Counter / 8}} {{f/std|0x00 or 0x01 (used to check the  [100h] flag of ability}}
  0005a5c0: 90630003 lbu r3,0x0003(r3) Load Ability ID
+
  0005a5a4: 00831021 addu r2,r4,r3               |{{f/std|Skillset pointer +0 or +1}}
  0005a5c4: 08016989 j 0x0005a624
+
  0005a5a8: 000318c0 sll r3,r3,0x03               |{{f/std|Counter / 8 * 8 - 0x00 or 0x08}} {{f/std| (prep bitmask for [100h] flag)}}
  0005a5c8: 30420100 andi r2,r2,0x0100 r2 = Ability ID +0x100 flag
+
  0005a5ac: 00a31823 subu r3,r5,r3               |{{f/std|r3 is between 0x00 and 0x07}} {{f/std| (prep bitmask for [100h] flag)}}
  0005a5cc: 288200e0 slti r2,r4,0x00e0
+
  0005a5b0: 90420000 lbu r2,0x0000(r2)           |{{f/load|Load Ability Flag 1 or 2 }} {{f/std|(based on counter being more than 8 or not)}}
  0005a5d0: 10400016 beq r2,r0,0x0005a62c Branch if not a monster skillset
+
  0005a5b4: 24630001 addiu r3,r3,0x0001           |{{f/std|Bitmask for [100h] flag }} {{f/std|between 0x1 and 0x8}}
  0005a5d4: 28a20004 slti r2,r5,0x0004
+
  0005a5b8: 00621004 sllv r2,r2,r3               |{{f/std|Shift ability flag so the ability [100h] becomes 0x100}}
  0005a5d8: 10400014 beq r2,r0,0x0005a62c Branch if Counter >= 4
+
  0005a5bc: 00851821 addu r3,r4,r5               |{{f/adr|Pointer to Ability ID byte in skillset data}}
  0005a5dc: 00a03021 addu r6,r5,r0 r6 = Counter
+
  0005a5c0: 90630003 lbu r3,0x0003(r3)           |{{f/load|Load Ability ID (Byte without [100h] flag}}
  0005a5e0: 3c038006 lui r3,0x8006
+
  0005a5c4: 08016989 j 0x0005a624                 |
  0005a5e4: 24635854 addiu r3,r3,0x5854 (start back some instead of subtracting)
+
  0005a5c8: 30420100 andi r2,r2,0x0100           |{{f/std|0x000 or 0x100 (will be added to r3 to gve the Ability ID)}}
  0005a5e8: 00041080 sll r2,r4,0x02 Skillset * 4
+
                                            {{f/Cond|Else : Monster section}}
  0005a5ec: 00441021 addu r2,r2,r4 Skillset * 5
+
  0005a5cc: 288200e0 slti r2,r4,0x00e0           |{{f/std|Check if skillset is valid (last ID if 0xDF)}}
  0005a5f0: 04a10002 bgez r5,0x0005a5fc Branch if Counter >= 0
+
  0005a5d0: 10400016 beq r2,r0,0x0005a62c         {{f/Cond|Branch to }} {{f/loc|END}} '''if skillset ID is invalid'''
  0005a5f4: 00432021 addu r4,r2,r3
+
  0005a5d4: 28a20004 slti r2,r5,0x0004           |{{f/std|Check if ability counter is valid (max is 0x3 for monsters)}}
  0005a5f8: 24a60007 addiu r6,r5,0x0007
+
  0005a5d8: 10400014 beq r2,r0,0x0005a62c         {{f/Cond|Branch to }} {{f/loc|END}} '''if ability counter is invalid'''
  0005a5fc: 000618c3 sra r3,r6,0x03 Counter / 8
+
  0005a5dc: 00a03021 addu r6,r5,r0               |{{f/std|<nowiki>r6 = Counter</nowiki>}}
  0005a600: 00831021 addu r2,r4,r3
+
  0005a5e0: 3c038006 lui r3,0x8006               |
  0005a604: 000318c0 sll r3,r3,0x03 Counter / 8 * 8
+
  0005a5e4: 24635854 addiu r3,r3,0x5854           |{{f/std|Fake pointer to monster skillset (Avoid substraction of 0xB0 to set the offset)}}
  0005a608: 00a31823 subu r3,r5,r3 Counter - Counter / 8 * 8
+
  0005a5e8: 00041080 sll r2,r4,0x02               |{{f/std|Skillset * 4}}
  0005a60c: 90420000 lbu r2,0x0000(r2) Load Ability Flags
+
  0005a5ec: 00441021 addu r2,r2,r4               |{{f/std|Skillset * 5}}
  0005a610: 24630001 addiu r3,r3,0x0001 C Mod = (Counter - Counter / 8 * 8) + 1
+
  0005a5f0: 04a10002 bgez r5,0x0005a5fc           {{f/Cond|If Ability counter < 0x00}}
  0005a614: 00621004 sllv r2,r2,r3 Ability Flags * 2^(C Mod)
+
  0005a5f4: 00432021 addu r4,r2,r3               |{{f/adr|Pointer to monster skillset data}}
  0005a618: 00851821 addu r3,r4,r5
+
  0005a5f8: 24a60007 addiu r6,r5,0x0007               |{{f/std|Ability Counter +7}}
  0005a61c: 90630001 lbu r3,0x0001(r3) Load Ability ID
+
  0005a5fc: 000618c3 sra r3,r6,0x03               |{{f/std|Always 0x00 (for monsters)}}
  0005a620: 30420100 andi r2,r2,0x0100 r2 = Ability ID's 0x100 Flag
+
  0005a600: 00831021 addu r2,r4,r3               |
  0005a624: 0801698c j 0x0005a630
+
  0005a604: 000318c0 sll r3,r3,0x03               |{{f/std|0x00}}
  0005a628: 00621025 or r2,r3,r2 r2 = Full Ability ID (Base ID +  0x100 flag)
+
  0005a608: 00a31823 subu r3,r5,r3               |{{f/std|<nowiki>r3 = Ability counter</nowiki>}}
  0005a62c: 00001021 addu r2,r0,r0 r2 = 0 (Attack)
+
  0005a60c: 90420000 lbu r2,0x0000(r2)           |{{f/load|Load Ability Flag 1}}
  0005a630: 03e00008 jr r31
+
  0005a610: 24630001 addiu r3,r3,0x0001           |{{f/std|Bitmask for [100h] flag }} {{f/std|between 0x1 and 0x4}}
  0005a634: 00000000 nop
+
  0005a614: 00621004 sllv r2,r2,r3               |{{f/std|Shift ability flag so the ability [100h] becomes 0x100}}
 
+
  0005a618: 00851821 addu r3,r4,r5               |{{f/adr|Pointer to Ability ID byte in skillset data}}
 
+
  0005a61c: 90630001 lbu r3,0x0001(r3)           |{{f/load|Load Ability ID (Byte without [100h] flag}}
== Return Locations ==
+
  0005a620: 30420100 andi r2,r2,0x0100           |{{f/std|0x000 or 0x100 (will be added to r3 to gve the Ability ID)}}
 
+
  0005a624: 0801698c j 0x0005a630             {{f/jump|Avoid Ability ID nullification and returns ability ID}}
 +
  0005a628: 00621025 or r2,r3,r2             |{{f/std|returns Full Ability ID (Base ID +  0x100 flag)}}
 +
{{f/sec|---- Invalid ID/Ability counter ----  }}
 +
  0005a62c: 00001021 addu r2,r0,r0           |{{f/std|<nowiki>r2 = 0 (Attack)</nowiki>}}
 +
 +
  0005a630: 03e00008 jr r31                  
 +
  0005a634: 00000000 nop  
 +
=== Return location ===
 +
'''SCUS_942.21'''
 
  0005a67c:  [[Store Skillset's Abilities]]
 
  0005a67c:  [[Store Skillset's Abilities]]
 
  0005cfac:  [[Calculate Learned Abilities]]
 
  0005cfac:  [[Calculate Learned Abilities]]
 
  0005d268:  [[Calculate Unit's R/S/M]]
 
  0005d268:  [[Calculate Unit's R/S/M]]
  001807bc:  [[Generate Crystal or Treasure]]
+
   
  00181994: 001817c0
+
'''Battle.bin'''
  00182378: 001822cc
+
001807c4:  [[Generate Crystal or Treasure]]
  0018e828: 0018e6b8
+
  0018199c: [[Load ability data for skillset]]
  0018e95c: 0018e8ac
+
  00182380: [[Monster skill, frog attack ability loading]]
 +
  0018e830: [[Learn on hit 1]]
 +
  0018e964: [[Learn on hit 2]]

Latest revision as of 18:24, 3 August 2023

SCUS_942.21 - Load Ability From Skillset                          DUPLICATED : Get_Ability_ID_From_Skillset
---------------------------------------------------------------------------------------------- 
Parameters : r4 - Skillset ID
             r5 - Ability counter (position in the skillset)

Returns : r2 = Ability ID (halfword)
          r2 = 0x00 if Ability counter or skillset ID is invalid
----------------------------------------------------------------------------------------------
0005a568: 288200b0 slti r2,r4,0x00b0        |Check if skillset is a monster skillset
0005a56c: 10400017 beq r2,r0,0x0005a5cc     #If Not a monster skillset
0005a570: 28a20016 slti r2,r5,0x0016            |Check if Ability counter is valid (max is 0x15 for skillset)
0005a574: 1040002d beq r2,r0,0x0005a62c         #Branch to  END if Ability counter is invalid
0005a578: 00a03021 addu r6,r5,r0                |r6 = Ability Counter
0005a57c: 3c038006 lui r3,0x8006                |
0005a580: 24634a94 addiu r3,r3,0x4a94           |1st skillset data address
0005a584: 00041040 sll r2,r4,0x01               |Skillset ID * 2
0005a588: 00441021 addu r2,r2,r4                |ID * 3
0005a58c: 000210c0 sll r2,r2,0x03               |ID * 24
0005a590: 00441021 addu r2,r2,r4                |ID * 25 (Size of each skillset data)
0005a594: 04a10002 bgez r5,0x0005a5a0           #If counter < 0  ?
0005a598: 00432021 addu r4,r2,r3                |r4 = Pointer to Skillset's data
0005a59c: 24a60007 addiu r6,r5,0x0007               |r6 = Counter + 7
0005a5a0: 000618c3 sra r3,r6,0x03               |Ability Counter / 8 0x00 or 0x01 (used to check the  [100h] flag of ability
0005a5a4: 00831021 addu r2,r4,r3                |Skillset pointer +0 or +1
0005a5a8: 000318c0 sll r3,r3,0x03               |Counter / 8 * 8 - 0x00 or 0x08  (prep bitmask for [100h] flag)
0005a5ac: 00a31823 subu r3,r5,r3                |r3 is between 0x00 and 0x07  (prep bitmask for [100h] flag)
0005a5b0: 90420000 lbu r2,0x0000(r2)            |Load Ability Flag 1 or 2  (based on counter being more than 8 or not)
0005a5b4: 24630001 addiu r3,r3,0x0001           |Bitmask for [100h] flag  between 0x1 and 0x8
0005a5b8: 00621004 sllv r2,r2,r3                |Shift ability flag so the ability [100h] becomes 0x100
0005a5bc: 00851821 addu r3,r4,r5                |Pointer to Ability ID byte in skillset data
0005a5c0: 90630003 lbu r3,0x0003(r3)            |Load Ability ID (Byte without [100h] flag
0005a5c4: 08016989 j 0x0005a624                 |
0005a5c8: 30420100 andi r2,r2,0x0100            |0x000 or 0x100 (will be added to r3 to gve the Ability ID)
                                            #Else : Monster section
0005a5cc: 288200e0 slti r2,r4,0x00e0            |Check if skillset is valid (last ID if 0xDF)
0005a5d0: 10400016 beq r2,r0,0x0005a62c         #Branch to  END if skillset ID is invalid
0005a5d4: 28a20004 slti r2,r5,0x0004            |Check if ability counter is valid (max is 0x3 for monsters)
0005a5d8: 10400014 beq r2,r0,0x0005a62c         #Branch to  END if ability counter is invalid
0005a5dc: 00a03021 addu r6,r5,r0                |r6 = Counter
0005a5e0: 3c038006 lui r3,0x8006                |
0005a5e4: 24635854 addiu r3,r3,0x5854           |Fake pointer to monster skillset (Avoid substraction of 0xB0 to set the offset)
0005a5e8: 00041080 sll r2,r4,0x02               |Skillset * 4
0005a5ec: 00441021 addu r2,r2,r4                |Skillset * 5
0005a5f0: 04a10002 bgez r5,0x0005a5fc           #If Ability counter < 0x00
0005a5f4: 00432021 addu r4,r2,r3                |Pointer to monster skillset data
0005a5f8: 24a60007 addiu r6,r5,0x0007               |Ability Counter +7
0005a5fc: 000618c3 sra r3,r6,0x03               |Always 0x00 (for monsters)
0005a600: 00831021 addu r2,r4,r3                |
0005a604: 000318c0 sll r3,r3,0x03               |0x00
0005a608: 00a31823 subu r3,r5,r3                |r3 = Ability counter
0005a60c: 90420000 lbu r2,0x0000(r2)            |Load Ability Flag 1
0005a610: 24630001 addiu r3,r3,0x0001           |Bitmask for [100h] flag  between 0x1 and 0x4
0005a614: 00621004 sllv r2,r2,r3                |Shift ability flag so the ability [100h] becomes 0x100
0005a618: 00851821 addu r3,r4,r5                |Pointer to Ability ID byte in skillset data
0005a61c: 90630001 lbu r3,0x0001(r3)            |Load Ability ID (Byte without [100h] flag
0005a620: 30420100 andi r2,r2,0x0100            |0x000 or 0x100 (will be added to r3 to gve the Ability ID)
0005a624: 0801698c j 0x0005a630             >>Avoid Ability ID nullification and returns ability ID
0005a628: 00621025 or r2,r3,r2              |returns Full Ability ID (Base ID +  0x100 flag)
---- Invalid ID/Ability counter ----   
0005a62c: 00001021 addu r2,r0,r0            |r2 = 0 (Attack)

0005a630: 03e00008 jr r31                   
0005a634: 00000000 nop 

Return location

SCUS_942.21
0005a67c:  Store Skillset's Abilities
0005cfac:  Calculate Learned Abilities
0005d268:  Calculate Unit's R/S/M

Battle.bin
001807c4:  Generate Crystal or Treasure
0018199c:  Load ability data for skillset
00182380:  Monster skill, frog attack ability loading
0018e830:  Learn on hit 1
0018e964:  Learn on hit 2