Difference between revisions of "Randomly Transfer Data"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (Dokurider moved page 001970bc - 001971b4 to Randomly Transfer Data: Renaming and adding new documentation)
m
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<font face='Courier New'>
+
'''BATTLE.BIN''' :  - Randomly_Transfer_Data
 +
Test Saved Action Outcomes. Begin by better score, simulate Hit% and store the first action that do not miss at AI 0x17fc
 +
------------------------------------------------------------------------------------------
 +
Parameter : Nothing
 +
Return : r2 = 0x01 if an action has been selected
 +
          r2 = 0x00 if No Action passed the test
 +
------------------------------------------------------------------------------------------
 +
001970bc: 27bdffd0 addiu r29,r29,-0x0030    |
 +
001970c0: afb3001c sw r19,0x001c(r29)        |
 +
001970c4: 00009821 addu r19,r0,r0            |{{f/std|Initialize Valid action flag}}
 +
001970c8: afb00010 sw r16,0x0010(r29)        |
 +
001970cc: 00008021 addu r16,r0,r0            |{{f/std|Initialize Action counter}}
 +
001970d0: afb60028 sw r22,0x0028(r29)        |
 +
001970d4: 3c1651eb lui r22,0x51eb            |
 +
001970d8: 36d6851f ori r22,r22,0x851f        |{{f/std|0,32*2^32}}
 +
001970dc: afb40020 sw r20,0x0020(r29)        |
 +
001970e0: 3c14801a lui r20,0x801a            |
 +
001970e4: 2694f3c4 addiu r20,r20,-0x0c3c    |{{f/adr|0x8019f3c4}}
 +
001970e8: afb20018 sw r18,0x0018(r29)        |
 +
001970ec: 02809021 addu r18,r20,r0          |{{f/adr|0x8019f3c4 - Used as pointer to Saved Action data (AI 0x54 -> AI 0x154)}}
 +
001970f0: afbf002c sw r31,0x002c(r29)        |
 +
001970f4: afb50024 sw r21,0x0024(r29)        |
 +
001970f8: afb10014 sw r17,0x0014(r29)        |
 
   
 
   
  00196fc4: 27bdffd8 addiu r29,r29,0xffd8
+
  {{f/sec|<nowiki>=== TEST all stored action hit% - Transfer the first that succeed ===</nowiki>}}
  00196fc8: afb40020 sw r20,0x0020(r29)
+
                                            {{f/bloop|LOOP - Test Action average Hit% vs Rdm}}
  00196fcc: 3c14801a lui r20,0x801a
+
  001970fc: 92510071 lbu r17,0x0071(r18)           |{{f/load|This Action Average Hit %}}
  00196fd0: 2694f3c4 addiu r20,r20,0xf3c4
+
  00197100: 00000000 nop                          |
  00196fd4: 26840050 addiu r4,r20,0x0050
+
  00197104: 12200002 beq r17,r0,0x00197110        {{f/Cond|If Average Hit% > 0}}
  00196fd8: 26850170 addiu r5,r20,0x0170
+
  00197108: 0010a940 sll r21,r16,0x05              |{{f/std|Counter * 0x20}}
  00196fdc: afbf0024 sw r31,0x0024(r29)
+
  0019710c: 34130001 ori r19,r0,0x0001                |{{f/std|Enable valid action flag}}
  00196fe0: afb3001c sw r19,0x001c(r29)
+
  00197110: 0c0088c3 jal 0x0002230c                |{{f/jal|Random_Number_Generator|Random_Number_Generator}} {{f/std|return rdm {0…0x7fff}}}
  00196fe4: afb20018 sw r18,0x0018(r29)
+
  00197114: 00000000 nop                          |
  00196fe8: afb10014 sw r17,0x0014(r29)
+
  00197118: 00560018 mult r2,r22                  |{{f/std|Rdm * 0,32 * 2^32}}
00196fec: 0c065b6c jal 0x00196db0 [[00196db0 - 00196e1c]]
+
  0019711c: 00021fc3 sra r3,r2,0x1f                |
00196ff0: afb00010 sw r16,0x0010(r29)
+
  00197120: 00002010 mfhi r4                      |{{f/std|Rdm * 0,32}}
  00196ff4: 34030002 ori r3,r0,0x0002
+
  00197124: 00042143 sra r4,r4,0x05                |{{f/std|Rdm/100}}
  00196ff8: 14430025 bne r2,r3,0x00197090
+
  00197128: 00832023 subu r4,r4,r3                |
  00196ffc: 26840034 addiu r4,r20,0x0034
+
  0019712c: 00041840 sll r3,r4,0x01                |{{f/std|2*Rdm%}}
  00197000: 0c065b88 jal 0x00196e20 [[00196e20 - 00196ef0]]
+
  00197130: 00641821 addu r3,r3,r4                |{{f/std|3*Rdm%}}
00197004: 26850134 addiu r5,r20,0x0134
+
  00197134: 000318c0 sll r3,r3,0x03                |{{f/std|24*Rdm%}}
  00197008: 10400021 beq r2,r0,0x00197090
+
  00197138: 00641821 addu r3,r3,r4                |{{f/std|25*Rdm%}}
  0019700c: 34100054 ori r16,r0,0x0054
+
  0019713c: 00031880 sll r3,r3,0x02                |{{f/std|100*Rdm%}}
  00197010: 00009821 addu r19,r0,r0
+
  00197140: 00431023 subu r2,r2,r3                |{{f/std|Rdm{0…99            Since Rdm/100 do not have decimals}}
  00197014: 26840034 addiu r4,r20,0x0034
+
  00197144: 0051102a slt r2,r2,r17                |{{f/std|0x1 if Rdm < Average Hit%}}
  00197018: 0c065b88 jal 0x00196e20 [[00196e20 - 00196ef0]]
+
  00197148: 14400008 bne r2,r0,0x0019716c          {{f/Cond|If Rdm < Hit%}} {{f/loc|Select this action}}
0019701c: 02902821 addu r5,r20,r16
+
  0019714c: 26100001 addiu r16,r16,0x0001         |{{f/std|Action counter +1}}
  00197020: 14400006 bne r2,r0,0x0019703c
+
  00197150: 2a020008 slti r2,r16,0x0008           |
  00197024: 34020008 ori r2,r0,0x0008
+
  00197154: 1440ffe9 bne r2,r0,0x001970fc      {{f/Cond|loop 8 times or RNG breaks out}}
  00197028: 26730001 addiu r19,r19,0x0001
+
  00197158: 26520020 addiu r18,r18,0x0020         |{{f/std|AI Action Outcome offset (+0x20 each iteration)}}
  0019702c: 2a620008 slti r2,r19,0x0008
+
   
  00197030: 1440fff8 bne r2,r0,0x00197014
+
  {{f/sec|<nowiki>=== No valid action in list ===</nowiki>}}
  00197034: 26100020 addiu r16,r16,0x0020
+
  0019715c: 1260000a beq r19,r0,0x00197188    {{f/Cond|If there was no action with hit > 0%}} {{f/loc|Exit}} {{f/Returns|Return 0x00}}
  00197038: 34020008 ori r2,r0,0x0008
+
   
  0019703c: 12620014 beq r19,r2,0x00197090
+
  {{f/sec|<nowiki>=== There is some valid action but they all failed the test : Force AI 0x54 ===</nowiki>}}
  00197040: 2a620007 slti r2,r19,0x0007
+
  00197160: 268417fc addiu r4,r20,0x17fc      |{{f/std|Destination pointer }}
  00197044: 1040000c beq r2,r0,0x00197078
+
  00197164: 08065c5e j 0x00197178              {{f/jump|If there was an Action with Hit > 0% but all rdm test fails}} {{f/loc|Tranfer best score data}}
  00197048: 34100007 ori r16,r0,0x0007
+
  00197168: 26850054 addiu r5,r20,0x0054      |{{f/std|Force origin pointer to best-scoring action (AI 0x54)}}
  0019704c: 34120114 ori r18,r0,0x0114
+
   
  00197050: 34110134 ori r17,r0,0x0134
+
  {{f/sec|<nowiki>=== Select the first action to pass the test ===</nowiki>}}
  00197054: 02912021 addu r4,r20,r17
+
  0019716c: 268417fc addiu r4,r20,0x17fc      |{{f/std|Destination pointer}}
  00197058: 02922821 addu r5,r20,r18
+
  00197170: 26a50054 addiu r5,r21,0x0054      |{{f/std|Action counter offset (0x20) + 0x54 (start of action data)}}
  0019705c: 0c066ac2 jal 0x0019ab08 [[Transfer Halfword Values]]
+
  00197174: 02852821 addu r5,r20,r5            |{{f/std|Pointer to 0x8019f3c4 + 0x54 + selected action offset}}
  00197060: 34060020 ori r6,r0,0x0020
+
   
  00197064: 2652ffe0 addiu r18,r18,0xffe0
+
  {{f/sec|<nowiki>=== Transfer data to AI 0x17fc ===</nowiki>}}
  00197068: 2610ffff addiu r16,r16,0xffff
+
  00197178: 0c066ac2 jal 0x0019ab08            |{{f/jal|Transfer_Halfword_Values|Transfer_Halfword_Values}} {{f/std|Transfer selected action data to AI 0x17fc}}
  0019706c: 0270102a slt r2,r19,r16
+
  0019717c: 34060020 ori r6,r0,0x0020          |{{f/std|Transfer 0x20 bytes}}
  00197070: 1440fff8 bne r2,r0,0x00197054
+
  00197180: 08065c63 j 0x0019718c              |{{f/loc|Exit }} {{f/Returns|return 0x01}}
  00197074: 2631ffe0 addiu r17,r17,0xffe0
+
  00197184: 34020001 ori r2,r0,0x0001          |
  00197078: 00102140 sll r4,r16,0x05
+
  00197188: 00001021 addu r2,r0,r0
  0019707c: 24840054 addiu r4,r4,0x0054
+
  0019718c: 8fbf002c lw r31,0x002c(r29)
  00197080: 02842021 addu r4,r20,r4
+
  00197190: 8fb60028 lw r22,0x0028(r29)
  00197084: 26850034 addiu r5,r20,0x0034
+
  00197194: 8fb50024 lw r21,0x0024(r29)
  00197088: 0c066ac2 jal 0x0019ab08 [[Transfer Halfword Values]]
+
  00197198: 8fb40020 lw r20,0x0020(r29)
0019708c: 34060020 ori r6,r0,0x0020
+
  0019719c: 8fb3001c lw r19,0x001c(r29)
  00197090: 0c0657db jal 0x00195f6c [[Initialize some AI Data (mount, base hit %)]]
+
  001971a0: 8fb20018 lw r18,0x0018(r29)
  00197094: 26840034 addiu r4,r20,0x0034
+
  001971a4: 8fb10014 lw r17,0x0014(r29)
  00197098: 8fbf0024 lw r31,0x0024(r29)
+
  001971a8: 8fb00010 lw r16,0x0010(r29)
  0019709c: 8fb40020 lw r20,0x0020(r29)
+
  001971ac: 27bd0030 addiu r29,r29,0x0030
  001970a0: 8fb3001c lw r19,0x001c(r29)
+
  001971b0: 03e00008 jr r31
  001970a4: 8fb20018 lw r18,0x0018(r29)
+
  001971b4: 00000000 nop
  001970a8: 8fb10014 lw r17,0x0014(r29)
+
===Return locations===
  001970ac: 8fb00010 lw r16,0x0010(r29)
+
'''BATTLE.BIN'''
  001970b0: 27bd0028 addiu r29,r29,0x0028
+
  00196278: [[Non-Specific_AI_AutoBattle_(Enemies)]]
  001970b4: 03e00008 jr r31
+
  0019825c: [[Fight_for_Life_-_Auto_Battle_(00197ff4)]]
  001970b8: 00000000 nop
+
  001982a8: [[Fight_for_Life_-_Auto_Battle_(00197ff4)]]
</font>
+
  00198764: [[Protect_Allies_-_Auto_Battle_(001984ec)]]
 +
  001987a4: [[Protect_Allies_-_Auto_Battle_(001984ec)]]
 +
  001987dc: [[Protect_Allies_-_Auto_Battle_(001984ec)]]
 +
  00198f3c: [[AI_Critical_or_Run_Like_Rabbit]]
 +
  00199024: [[AI_Critical_or_Run_Like_Rabbit]]

Latest revision as of 20:02, 22 June 2024

BATTLE.BIN :  - Randomly_Transfer_Data
Test Saved Action Outcomes. Begin by better score, simulate Hit% and store the first action that do not miss at AI 0x17fc
------------------------------------------------------------------------------------------
Parameter : Nothing
Return : r2 = 0x01 if an action has been selected
         r2 = 0x00 if No Action passed the test
------------------------------------------------------------------------------------------
001970bc: 27bdffd0 addiu r29,r29,-0x0030     |
001970c0: afb3001c sw r19,0x001c(r29)        |
001970c4: 00009821 addu r19,r0,r0            |Initialize Valid action flag
001970c8: afb00010 sw r16,0x0010(r29)        |
001970cc: 00008021 addu r16,r0,r0            |Initialize Action counter
001970d0: afb60028 sw r22,0x0028(r29)        |
001970d4: 3c1651eb lui r22,0x51eb            |
001970d8: 36d6851f ori r22,r22,0x851f        |0,32*2^32
001970dc: afb40020 sw r20,0x0020(r29)        |
001970e0: 3c14801a lui r20,0x801a            |
001970e4: 2694f3c4 addiu r20,r20,-0x0c3c     |0x8019f3c4
001970e8: afb20018 sw r18,0x0018(r29)        |
001970ec: 02809021 addu r18,r20,r0           |0x8019f3c4 - Used as pointer to Saved Action data (AI 0x54 -> AI 0x154)
001970f0: afbf002c sw r31,0x002c(r29)        |
001970f4: afb50024 sw r21,0x0024(r29)        |
001970f8: afb10014 sw r17,0x0014(r29)        |

=== TEST all stored action hit% - Transfer the first that succeed ===
                                            @LOOP - Test Action average Hit% vs Rdm
001970fc: 92510071 lbu r17,0x0071(r18)           |This Action Average Hit %
00197100: 00000000 nop                           |
00197104: 12200002 beq r17,r0,0x00197110         #If Average Hit% > 0
00197108: 0010a940 sll r21,r16,0x05              |Counter * 0x20
0019710c: 34130001 ori r19,r0,0x0001                 |Enable valid action flag
00197110: 0c0088c3 jal 0x0002230c                |-->Random_Number_Generator return rdm {0…0x7fff}
00197114: 00000000 nop                           |
00197118: 00560018 mult r2,r22                   |Rdm * 0,32 * 2^32
0019711c: 00021fc3 sra r3,r2,0x1f                |
00197120: 00002010 mfhi r4                       |Rdm * 0,32
00197124: 00042143 sra r4,r4,0x05                |Rdm/100
00197128: 00832023 subu r4,r4,r3                 |
0019712c: 00041840 sll r3,r4,0x01                |2*Rdm%
00197130: 00641821 addu r3,r3,r4                 |3*Rdm%
00197134: 000318c0 sll r3,r3,0x03                |24*Rdm%
00197138: 00641821 addu r3,r3,r4                 |25*Rdm%
0019713c: 00031880 sll r3,r3,0x02                |100*Rdm%
00197140: 00431023 subu r2,r2,r3                 |Rdm{0…99             Since Rdm/100 do not have decimals
00197144: 0051102a slt r2,r2,r17                 |0x1 if Rdm < Average Hit%
00197148: 14400008 bne r2,r0,0x0019716c          #If Rdm < Hit% Select this action
0019714c: 26100001 addiu r16,r16,0x0001          |Action counter +1
00197150: 2a020008 slti r2,r16,0x0008            |
00197154: 1440ffe9 bne r2,r0,0x001970fc      #loop 8 times or RNG breaks out
00197158: 26520020 addiu r18,r18,0x0020          |AI Action Outcome offset (+0x20 each iteration)

=== No valid action in list  ===
0019715c: 1260000a beq r19,r0,0x00197188     #If there was no action with hit > 0% Exit Return 0x00

=== There is some valid action but they all failed the test : Force AI 0x54 ===
00197160: 268417fc addiu r4,r20,0x17fc       |Destination pointer 
00197164: 08065c5e j 0x00197178              >>If there was an Action with Hit > 0% but all rdm test fails Tranfer best score data
00197168: 26850054 addiu r5,r20,0x0054       |Force origin pointer to best-scoring action (AI 0x54)

=== Select the first action to pass the test ===
0019716c: 268417fc addiu r4,r20,0x17fc       |Destination pointer
00197170: 26a50054 addiu r5,r21,0x0054       |Action counter offset (0x20) + 0x54 (start of action data)
00197174: 02852821 addu r5,r20,r5            |Pointer to 0x8019f3c4 + 0x54 + selected action offset

=== Transfer data to AI 0x17fc ===
00197178: 0c066ac2 jal 0x0019ab08            |-->Transfer_Halfword_Values Transfer selected action data to AI 0x17fc
0019717c: 34060020 ori r6,r0,0x0020          |Transfer 0x20 bytes
00197180: 08065c63 j 0x0019718c              |Exit  return 0x01
00197184: 34020001 ori r2,r0,0x0001          |
00197188: 00001021 addu r2,r0,r0
0019718c: 8fbf002c lw r31,0x002c(r29)
00197190: 8fb60028 lw r22,0x0028(r29)
00197194: 8fb50024 lw r21,0x0024(r29)
00197198: 8fb40020 lw r20,0x0020(r29)
0019719c: 8fb3001c lw r19,0x001c(r29)
001971a0: 8fb20018 lw r18,0x0018(r29)
001971a4: 8fb10014 lw r17,0x0014(r29)
001971a8: 8fb00010 lw r16,0x0010(r29)
001971ac: 27bd0030 addiu r29,r29,0x0030
001971b0: 03e00008 jr r31
001971b4: 00000000 nop

Return locations

BATTLE.BIN
 00196278: Non-Specific_AI_AutoBattle_(Enemies)
 0019825c: Fight_for_Life_-_Auto_Battle_(00197ff4)
 001982a8: Fight_for_Life_-_Auto_Battle_(00197ff4)
 00198764: Protect_Allies_-_Auto_Battle_(001984ec)
 001987a4: Protect_Allies_-_Auto_Battle_(001984ec)
 001987dc: Protect_Allies_-_Auto_Battle_(001984ec)
 00198f3c: AI_Critical_or_Run_Like_Rabbit
 00199024: AI_Critical_or_Run_Like_Rabbit