Difference between revisions of "Randomly Transfer Data"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
  001970bc: 27bdffd0 addiu r29,r29,0xffd0
+
'''BATTLE.BIN''' :  - Randomly_Transfer_Data
  001970c0: afb3001c sw r19,0x001c(r29)
+
Test Saved Action Outcomes. Begin by better score, simulate Hit% and store the first action that do not miss at AI 0x17fc
  001970c4: 00009821 addu r19,r0,r0
+
------------------------------------------------------------------------------------------
  001970c8: afb00010 sw r16,0x0010(r29)
+
Parameter : Nothing
  001970cc: 00008021 addu r16,r0,r0 r16 = ? Counter
+
Return : r2 = 0x01 if an action has been selected
  001970d0: afb60028 sw r22,0x0028(r29)
+
          r2 = 0x00 if No Action passed the test
  001970d4: 3c1651eb lui r22,0x51eb
+
------------------------------------------------------------------------------------------
  001970d8: 36d6851f ori r22,r22,0x851f
+
  001970bc: 27bdffd0 addiu r29,r29,-0x0030    |
  001970dc: afb40020 sw r20,0x0020(r29)
+
  001970c0: afb3001c sw r19,0x001c(r29)       |
  001970e0: 3c14801a lui r20,0x801a
+
  001970c4: 00009821 addu r19,r0,r0           |{{f/std|Initialize Valid action flag}}
  001970e4: 2694f3c4 addiu r20,r20,0xf3c4
+
  001970c8: afb00010 sw r16,0x0010(r29)       |
  001970e8: afb20018 sw r18,0x0018(r29)
+
  001970cc: 00008021 addu r16,r0,r0           |{{f/std|Initialize Action counter}}
  001970ec: 02809021 addu r18,r20,r0
+
  001970d0: afb60028 sw r22,0x0028(r29)       |
  001970f0: afbf002c sw r31,0x002c(r29)
+
  001970d4: 3c1651eb lui r22,0x51eb           |
  001970f4: afb50024 sw r21,0x0024(r29)
+
  001970d8: 36d6851f ori r22,r22,0x851f       |{{f/std|0,32*2^32}}
  001970f8: afb10014 sw r17,0x0014(r29)
+
  001970dc: afb40020 sw r20,0x0020(r29)       |
 
+
  001970e0: 3c14801a lui r20,0x801a           |
  <RNG Loop>
+
  001970e4: 2694f3c4 addiu r20,r20,-0x0c3c    |{{f/adr|0x8019f3c4}}
  001970fc: 92510071 lbu r17,0x0071(r18)
+
  001970e8: afb20018 sw r18,0x0018(r29)       |
  00197100: 00000000 nop
+
  001970ec: 02809021 addu r18,r20,r0           |{{f/adr|0x8019f3c4 - Used as pointer to Saved Action data (AI 0x54 -> AI 0x154)}}
  00197104: 12200002 beq r17,r0,0x00197110 Branch to RNG if false
+
  001970f0: afbf002c sw r31,0x002c(r29)       |
  00197108: 0010a940 sll r21,r16,0x05
+
  001970f4: afb50024 sw r21,0x0024(r29)       |
  0019710c: 34130001 ori r19,r0,0x0001 r19 = True
+
  001970f8: afb10014 sw r17,0x0014(r29)       |
 
+
  00197110: 0c0088c3 jal 0x0002230c Load RNG
+
  {{f/sec|<nowiki>=== TEST all stored action hit% - Transfer the first that succeed ===</nowiki>}}
  00197114: 00000000 nop
+
                                            {{f/bloop|LOOP - Test Action average Hit% vs Rdm}}
  00197118: 00560018 mult r2,r22 RNG * 0x51eb851f
+
  001970fc: 92510071 lbu r17,0x0071(r18)           |{{f/load|This Action Average Hit %}}
  0019711c: 00021fc3 sra r3,r2,0x1f RNG / 0x1f
+
  00197100: 00000000 nop                           |
  00197120: 00002010 mfhi r4 r4 = Upper bits (Get positive value?)
+
  00197104: 12200002 beq r17,r0,0x00197110         {{f/Cond|If Average Hit% > 0}}
  00197124: 00042143 sra r4,r4,0x05
+
  00197108: 0010a940 sll r21,r16,0x05             |{{f/std|Counter * 0x20}}
  00197128: 00832023 subu r4,r4,r3
+
  0019710c: 34130001 ori r19,r0,0x0001                 |{{f/std|Enable valid action flag}}
  0019712c: 00041840 sll r3,r4,0x01
+
  00197110: 0c0088c3 jal 0x0002230c               |{{f/jal|Random_Number_Generator|Random_Number_Generator}} {{f/std|return rdm {0…0x7fff}}}
  00197130: 00641821 addu r3,r3,r4
+
  00197114: 00000000 nop                           |
  00197134: 000318c0 sll r3,r3,0x03
+
  00197118: 00560018 mult r2,r22                   |{{f/std|Rdm * 0,32 * 2^32}}
  00197138: 00641821 addu r3,r3,r4
+
  0019711c: 00021fc3 sra r3,r2,0x1f               |
  0019713c: 00031880 sll r3,r3,0x02
+
  00197120: 00002010 mfhi r4                       |{{f/std|Rdm * 0,32}}
  00197140: 00431023 subu r2,r2,r3
+
  00197124: 00042143 sra r4,r4,0x05               |{{f/std|Rdm/100}}
 
+
  00197128: 00832023 subu r4,r4,r3                 |
  00197144: 0051102a slt r2,r2,r17
+
  0019712c: 00041840 sll r3,r4,0x01               |{{f/std|2*Rdm%}}
  00197148: 14400008 bne r2,r0,0x0019716c Transfer if RNG is greater than r17
+
  00197130: 00641821 addu r3,r3,r4                 |{{f/std|3*Rdm%}}
  0019714c: 26100001 addiu r16,r16,0x0001 r16++
+
  00197134: 000318c0 sll r3,r3,0x03               |{{f/std|24*Rdm%}}
  00197150: 2a020008 slti r2,r16,0x0008
+
  00197138: 00641821 addu r3,r3,r4                 |{{f/std|25*Rdm%}}
  00197154: 1440ffe9 bne r2,r0,0x001970fc loop 20 times or RNG breaks out
+
  0019713c: 00031880 sll r3,r3,0x02               |{{f/std|100*Rdm%}}
  00197158: 26520020 addiu r18,r18,0x0020
+
  00197140: 00431023 subu r2,r2,r3                 |{{f/std|Rdm{0…99            Since Rdm/100 do not have decimals}}
  </RNG Loop>
+
  00197144: 0051102a slt r2,r2,r17                 |{{f/std|0x1 if Rdm < Average Hit%}}
 
+
  00197148: 14400008 bne r2,r0,0x0019716c         {{f/Cond|If Rdm < Hit%}} {{f/loc|Select this action}}
  0019715c: 1260000a beq r19,r0,0x00197188 Exit and return 0 if 0x71 = true
+
  0019714c: 26100001 addiu r16,r16,0x0001         |{{f/std|Action counter +1}}
  00197160: 268417fc addiu r4,r20,0x17fc
+
  00197150: 2a020008 slti r2,r16,0x0008           |
  00197164: 08065c5e j 0x00197178 Jump to Transfer
+
  00197154: 1440ffe9 bne r2,r0,0x001970fc     {{f/Cond|loop 8 times or RNG breaks out}}
  00197168: 26850054 addiu r5,r20,0x0054
+
  00197158: 26520020 addiu r18,r18,0x0020         |{{f/std|AI Action Outcome offset (+0x20 each iteration)}}
  <Tranfer ?>
+
   
  0019716c: 268417fc addiu r4,r20,0x17fc
+
{{f/sec|<nowiki>=== No valid action in list  ===</nowiki>}}
  00197170: 26a50054 addiu r5,r21,0x0054
+
  0019715c: 1260000a beq r19,r0,0x00197188     {{f/Cond|If there was no action with hit > 0%}} {{f/loc|Exit}} {{f/Returns|Return 0x00}}
  00197174: 02852821 addu r5,r20,r5
+
  00197178: 0c066ac2 jal 0x0019ab08 Transfer Halfword Values
+
{{f/sec|<nowiki>=== There is some valid action but they all failed the test : Force AI 0x54 ===</nowiki>}}
  0019717c: 34060020 ori r6,r0,0x0020
+
  00197160: 268417fc addiu r4,r20,0x17fc       |{{f/std|Destination pointer }}
  00197180: 08065c63 j 0x0019718c Exit and Return 1
+
  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}}
  00197184: 34020001 ori r2,r0,0x0001
+
  00197168: 26850054 addiu r5,r20,0x0054       |{{f/std|Force origin pointer to best-scoring action (AI 0x54)}}
 
+
 +
  {{f/sec|<nowiki>=== Select the first action to pass the test ===</nowiki>}}
 +
  0019716c: 268417fc addiu r4,r20,0x17fc       |{{f/std|Destination pointer}}
 +
  00197170: 26a50054 addiu r5,r21,0x0054       |{{f/std|Action counter offset (0x20) + 0x54 (start of action data)}}
 +
  00197174: 02852821 addu r5,r20,r5           |{{f/std|Pointer to 0x8019f3c4 + 0x54 + selected action offset}}
 +
 +
{{f/sec|<nowiki>=== Transfer data to AI 0x17fc ===</nowiki>}}
 +
  00197178: 0c066ac2 jal 0x0019ab08           |{{f/jal|Transfer_Halfword_Values|Transfer_Halfword_Values}} {{f/std|Transfer selected action data to AI 0x17fc}}
 +
  0019717c: 34060020 ori r6,r0,0x0020         |{{f/std|Transfer 0x20 bytes}}
 +
  00197180: 08065c63 j 0x0019718c             |{{f/loc|Exit }} {{f/Returns|return 0x01}}
 +
  00197184: 34020001 ori r2,r0,0x0001         |
 
  00197188: 00001021 addu r2,r0,r0
 
  00197188: 00001021 addu r2,r0,r0
 
  0019718c: 8fbf002c lw r31,0x002c(r29)
 
  0019718c: 8fbf002c lw r31,0x002c(r29)
Line 70: Line 80:
 
  001971b0: 03e00008 jr r31
 
  001971b0: 03e00008 jr r31
 
  001971b4: 00000000 nop
 
  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]]

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