Difference between revisions of "Facing Evade Calculation"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
  Facing Evade Calculation
+
  No Parameters - Returns Nothing
  001854fc: 3c058019 lui r5,0x8019
+
   
  00185500: 8ca52d98 lw r5,0x2d98(r5) Load Target's Data Pointer
+
  Compare X and Y coordinates difference to determine which direction is the more relevant
  00185504: 3c048019 lui r4,0x8019
+
If X = Y Facing is Front or Side (back only if Same coordinates (?))
  00185508: 8c842d94 lw r4,0x2d94(r4) Load Attacker's Data Pointer
+
   
  0018550c: 90a30047 lbu r3,0x0047(r5) Load Target's X Coordinate
+
  If Attacked from side : Class Evade is nullified (0x801938e1)
00185510: 90820047 lbu r2,0x0047(r4) Load Attacker's X Coordinate
+
  If Attacked from back : Class Evade, Right and Left Hands Evade are nullified (0x801938e1, 0x801938df, 0x801938e0)
  00185514: 00000000 nop
+
  ------------------------------------------------------------------------------------------------------------------------
00185518: 00624023 subu r8,r3,r2 r8 = TX - AX
+
  001854fc: 3c058019 lui r5,0x8019            |
0018551c: 90820048 lbu r2,0x0048(r4) Load Attacker's Y Coordinate
+
00185500: 8ca52d98 lw r5,0x2d98(r5)        |{{f/adr|<nowiki>r5 = Target data pointer</nowiki>}}
00185520: 05010002 bgez r8,0x0018552c Branch if TX >= AX
+
  00185504: 3c048019 lui r4,0x8019            |
00185524: 01002021 addu r4,r8,r0 r4 = TX - AX
+
  00185508: 8c842d94 lw r4,0x2d94(r4)        |{{f/adr|<nowiki>r4 = Attacker data pointer</nowiki>}}
00185528: 00042023 subu r4,r0,r4 r4 = AX - TX
+
  0018550c: 90a30047 lbu r3,0x0047(r5)       |{{f/load|<nowiki>r3 = Target X coordinate</nowiki>}}
0018552c: 90a30048 lbu r3,0x0048(r5) Load Target's Y Coordinate
+
  00185510: 90820047 lbu r2,0x0047(r4)        |{{f/load|<nowiki>r2 = Attacker X coordinate</nowiki>}}
00185530: 308400ff andi r4,r4,0x00ff r4 = X Difference
+
00185514: 00000000 nop                     |
00185534: 00623823 subu r7,r3,r2 r7 = TY - AY
+
  00185518: 00624023 subu r8,r3,r2           |{{f/std|<nowiki>r8 = Delta X (Target - Attacker)</nowiki>}}
00185538: 04e10002 bgez r7,0x00185544 Branch if TY > AY
+
  0018551c: 90820048 lbu r2,0x0048(r4)        |{{f/load|<nowiki>r2 = Attacker Y coordinate</nowiki>}}
0018553c: 00e01021 addu r2,r7,r0 r2 = TY - AY
+
  00185520: 05010002 bgez r8,0x0018552c      {{f/Cond|If Delta X < 0x00 }}
00185540: 00021023 subu r2,r0,r2 r2 = AY - TY
+
  00185524: 01002021 addu r4,r8,r0           |{{f/std|<nowiki>r4 = Delta X</nowiki>}}
00185544: 304300ff andi r3,r2,0x00ff r3 = Y Difference
+
  00185528: 00042023 subu r4,r0,r4                |{{f/std|<nowiki>r4 = Delta X (positive value)</nowiki>}}
00185548: 0064102b sltu r2,r3,r4
+
  0018552c: 90a30048 lbu r3,0x0048(r5)        |{{f/load|<nowiki>r3 = Target Y Coordinate</nowiki>}}
  0018554c: 1040001d beq r2,r0,0x001855c4 Branch if Y Difference >= X  Difference
+
  00185530: 308400ff andi r4,r4,0x00ff        |{{f/std|<nowiki>r4 = Delta X (positive byte)</nowiki>}}
  00185550: 34060001 ori r6,r0,0x0001 r6 = 1 (Side)
+
  00185534: 00623823 subu r7,r3,r2            |{{f/std|<nowiki>r7 = Delta Y (Target - Attacker)</nowiki>}}
  00185554: 1900000c blez r8,0x00185588 Branch if TX <= AX
+
  00185538: 04e10002 bgez r7,0x00185544      {{f/Cond|If Delta Y < 0x00}}
  00185558: 00000000 nop
+
  0018553c: 00e01021 addu r2,r7,r0            |{{f/std|<nowiki>r2 = Delta Y</nowiki>}}
0018555c: 94a20048 lhu r2,0x0048(r5) Load Target's Y + Facing
+
  00185540: 00021023 subu r2,r0,r2                |{{f/std|<nowiki>r2 = Positive value of Delta Y</nowiki>}}
  00185560: 00000000 nop
+
  00185544: 304300ff andi r3,r2,0x00ff        |{{f/std|<nowiki>r3 = Delta Y (positive byte)</nowiki>}}
  00185564: 30430f00 andi r3,r2,0x0f00 Leave only Target's Facing
+
  00185548: 0064102b sltu r2,r3,r4            |{{f/std|<nowiki>r2 = 0x01 if Delta Y < Delta X</nowiki>}}
  00185568: 34020100 ori r2,r0,0x0100
+
  0018554c: 1040001d beq r2,r0,0x001855c4    {{f/Cond|If Delta X > Delta Y (delta X has more weight to determine facing)}}
0018556c: 14620003 bne r3,r2,0x0018557c Branch if Target isn't facing West
+
  00185550: 34060001 ori r6,r0,0x0001        |{{f/std|<nowiki>r6 = 0x01 (default is side attack)</nowiki>}}
  00185570: 34020300 ori r2,r0,0x0300
+
   
  00185574: 08061562 j 0x00185588 Jump past remaining direction  checks
+
  {{f/loc|---  Delta X  has more weight --- }}
00185578: 00003021 addu r6,r0,r0 r6 = 0 (Front)
+
  00185554: 1900000c blez r8,0x00185588          {{f/Cond|If raw Delta X > 0x00 (Target is eastward)}} /Else branch to Westward check)
  0018557c: 14620002 bne r3,r2,0x00185588 Branch if Target isn't facing East
+
  00185558: 00000000 nop                              |
  00185580: 00000000 nop
+
  0018555c: 94a20048 lhu r2,0x0048(r5)                |{{f/load|<nowiki>r2 = Target Y + Facing/Elevation</nowiki>}}
  00185584: 34060002 ori r6,r0,0x0002 r6 = 2 (Back)
+
  00185560: 00000000 nop                             |
  00185588: 05010058 bgez r8,0x001856ec Branch if TX >= AX (TX = AX)
+
  00185564: 30430f00 andi r3,r2,0x0f00                |{{f/std|<nowiki>r3 = Target facing</nowiki>}}
  0018558c: 00000000 nop
+
  00185568: 34020100 ori r2,r0,0x0100                |{{f/std|<nowiki>r2 = 0x0100 (Facing West)</nowiki>}}
  00185590: 3c028019 lui r2,0x8019
+
  0018556c: 14620003 bne r3,r2,0x0018557c            {{f/Cond|If Target is facing West}}
  00185594: 8c422d98 lw r2,0x2d98(r2) Load Target's Data Pointer
+
  00185570: 34020300 ori r2,r0,0x0300                |{{f/std|<nowiki>r2 = 0x0300 (Facing East)</nowiki>}}
  00185598: 00000000 nop
+
  00185574: 08061562 j 0x00185588                        {{f/jump|Jump to Westward check (will branch to evade calculation)}}
0018559c: 94420048 lhu r2,0x0048(r2) Load Target's Y + Facing
+
  00185578: 00003021 addu r6,r0,r0                       |{{f/std|<nowiki>r6 = 0x00 (Frontal Attack)</nowiki>}}
  001855a0: 00000000 nop
+
  0018557c: 14620002 bne r3,r2,0x00185588            {{f/Cond|If Target is facing East}}
001855a4: 30430f00 andi r3,r2,0x0f00 Leave only Facing
+
  00185580: 00000000 nop                                 |
  001855a8: 34020300 ori r2,r0,0x0300
+
  00185584: 34060002 ori r6,r0,0x0002                     |{{f/std|<nowiki>r6 = 0x02 (Attack from Back)</nowiki>}}
  001855ac: 10620048 beq r3,r2,0x001856d0 Branch if Target is facing East
+
  00185588: 05010058 bgez r8,0x001856ec           {{f/Cond|If raw Delta X < 0x00 (Target is Westward)}} /Else branch to {{f/loc|Evade Calculation}}
  001855b0: 34020100 ori r2,r0,0x0100
+
  0018558c: 00000000 nop                             |{{f/std|}}
001855b4: 1462004d bne r3,r2,0x001856ec Branch if Target is not facing West
+
  00185590: 3c028019 lui r2,0x8019                   |{{f/std|}}
  001855b8: 00000000 nop
+
  00185594: 8c422d98 lw r2,0x2d98(r2)                 |{{f/adr|<nowiki>r2 = Target data pointer</nowiki>}}
  001855bc: 080615bb j 0x001856ec Jump past Y direction checks
+
  00185598: 00000000 nop                             |
  001855c0: 34060002 ori r6,r0,0x0002 r6 = 2 (Back)
+
  0018559c: 94420048 lhu r2,0x0048(r2)               |{{f/load|<nowiki>r2 = Target Y + Facing/Elevation</nowiki>}}
  001855c4: 0083102b sltu r2,r4,r 3
+
  001855a0: 00000000 nop                             |
  001855c8: 1040001c beq r2,r0,0x0018563c Branch if X Difference >= Y Difference (X = Y)
+
  001855a4: 30430f00 andi r3,r2,0x0f00               |{{f/std|<nowiki>r3 = Target facing only</nowiki>}}
  001855cc: 00000000 nop
+
  001855a8: 34020300 ori r2,r0,0x0300                |{{f/std|<nowiki>r2 = 0x0300 (Facing East)</nowiki>}}
  001855d0: 18e0000b blez r7,0x00185600 Branch if TY <= AY
+
  001855ac: 10620048 beq r3,r2,0x001856d0             {{f/Cond|If Target is not facing East}} /If Facing East branch - r6 will be set to 0x00 and jump to {{f/loc|Evade Calculation}}
  001855d4: 00000000 nop
+
  001855b0: 34020100 ori r2,r0,0x0100                    |{{f/std|<nowiki>r2 = 0x0100 (Facing West)</nowiki>}}
001855d8: 94a20048 lhu r2,0x0048(r5) Load Target's Y + Facing
+
001855b4: 1462004d bne r3,r2,0x001856ec                {{f/Cond|If Target is facing West}}
  001855dc: 00000000 nop
+
  001855b8: 00000000 nop                                     |
001855e0: 30430f00 andi r3,r2,0x0f00 Leave only Facin g
+
  001855bc: 080615bb j 0x001856ec                             {{f/jump|Jump to }} {{f/loc|Evade Calculation}} r6 = 0x02 (Attack from Back)
  001855e4: 14600003 bne r3,r0,0x001855f4 Branch if Target is not facing  South
+
001855c0: 34060002 ori r6,r0,0x0002                         |{{f/std|<nowiki>r6 = 0x02 (Attack from Back)</nowiki>}}
  001855e8: 34020200 ori r2,r0,0x0200
+
  001855c4: 0083102b sltu r2,r4,r3            |{{f/std|<nowiki>r2 = 0x01 if Delta X < Delta Y</nowiki>}}
  001855ec: 08061580 j 0x00185600 Jump past remaining facing checks
+
  001855c8: 1040001c beq r2,r0,0x0018563c    {{f/Cond|If Delta Y > Delta X (delta Y has more weight to determine facing)}}
001855f0: 00003021 addu r6,r0,r0 r6 = 0 (Front)
+
  001855cc: 00000000 nop                          |
  001855f4: 14620002 bne r3,r2,0x00185600 Branch if Target is not facing North
+
  001855f8: 00000000 nop
+
{{f/loc|--- Delta has more weight ---}}
  001855fc: 34060002 ori r6,r0,0x0002 r6 = 2 (Back)
+
  001855d0: 18e0000b blez r7,0x00185600          {{f/Cond|If Raw Delta Y > 0x00 (Target is to the North)}}
  00185600: 04e1003a bgez r7,0x001856ec Branch if TY >= AY (TY = AY)
+
  001855d4: 00000000 nop                             |
  00185604: 00000000 nop
+
  001855d8: 94a20048 lhu r2,0x0048(r5)                |{{f/load|<nowiki>r2 = Target Y + Facing/Elevation</nowiki>}}
  00185608: 3c028019 lui r2,0x8019
+
  001855dc: 00000000 nop                              |
  0018560c: 8c422d98 lw r2,0x2d98(r2) Load Target's Data Pointer
+
001855e0: 30430f00 andi r3,r2,0x0f00                |{{f/std|<nowiki>r3 = Target facing</nowiki>}}
  00185610: 00000000 nop
+
  001855e4: 14600003 bne r3,r0,0x001855f4            {{f/Cond|If Target is facing South}}
  00185614: 94420048 lhu r2,0x0048(r2) Load Target's Y + Facing
+
001855e8: 34020200 ori r2,r0,0x0200                |{{f/std|<nowiki>r2 = 0x200 (Facing North ?)</nowiki>}}
  00185618: 00000000 nop
+
  001855ec: 08061580 j 0x00185600                        {{f/jump|Jump to Southward check (will branch to Evade calculation)}}
  0018561c: 30430f00 andi r3,r2,0x0f00 Leave only Facing
+
  001855f0: 00003021 addu r6,r0,r0                        |{{f/std|<nowiki>r6 = 0x00 (front)</nowiki>}}
  00185620: 34020200 ori r2,r0,0x0200
+
001855f4: 14620002 bne r3,r2,0x00185600            {{f/Cond|If Target is facing North}}
  00185624: 1062002a beq r3,r2,0x001856d0 Branch if Target is facing North
+
  001855f8: 00000000 nop                                 |
  00185628: 00000000 nop
+
  001855fc: 34060002 ori r6,r0,0x0002                    |{{f/std|<nowiki>r6 = 0x02 (Attack from Back)</nowiki>}}
  0018562c: 1460002f bne r3,r0,0x001856ec Branch if Target is not facing South
+
  00185600: 04e1003a bgez r7,0x001856ec          {{f/Cond|If Raw Delta Y < 0x00 (Target is Southward)}}
  00185630: 00000000 nop
+
  00185604: 00000000 nop                             |{{f/std|}}
  00185634: 080615bb j 0x001856ec
+
  00185608: 3c028019 lui r2,0x8019                   |{{f/std|}}
  00185638: 34060002 ori r6,r0,0x0002 r6 = 2 (Back)
+
  0018560c: 8c422d98 lw r2,0x2d98(r2)                 |{{f/adr|<nowiki>r2 = Target data pointer</nowiki>}}
  0018563c: 19000006 blez r8,0x00185658 Branch if TX <= AX
+
  00185610: 00000000 nop                             |
  00185640: 34030100 ori r3,r0,0x0100
+
  00185614: 94420048 lhu r2,0x0048(r2)               |{{f/load|<nowiki>r2 = Target Y + Facing/Elevation</nowiki>}}
  00185644: 94a20048 lhu r2,0x0048(r5) Load Target's Y + Facing
+
  00185618: 00000000 nop                             |
  00185648: 00000000 nop
+
  0018561c: 30430f00 andi r3,r2,0x0f00               |{{f/std|<nowiki>r3 = Target facing</nowiki>}}
  0018564c: 30420f00 andi r2,r2,0x0f00 Leave only Facing
+
  00185620: 34020200 ori r2,r0,0x0200                |{{f/std|<nowiki>r2 = 0x200 (Facing North)</nowiki>}}
00185650: 1043001f beq r2,r3,0x001856d0 Branch if Target is facing West
+
  00185624: 1062002a beq r3,r2,0x001856d0            {{f/Cond|If Target is not Facing North}} /If Facing North branch - r6 will be set to 0x00 and jump to  {{f/loc|Evade Calculation}}
  00185654: 00000000 nop
+
  00185628: 00000000 nop                                  |
  00185658: 05010009 bgez r8,0x00185680 Branch if TX >= AX
+
0018562c: 1460002f bne r3,r0,0x001856ec                {{f/Cond|If Target is Facing South}}
  0018565c: 34030300 ori r3,r0,0x0300
+
  00185630: 00000000 nop                                      |
  00185660: 3c028019 lui r2,0x8019
+
  00185634: 080615bb j 0x001856ec                            {{f/jump|Jump to }} {{f/loc|Evade Calculation}}  r6 = 0x02 (Attack from Back)
00185664: 8c422d98 lw r2,0x2d98(r2) Load Target Pointer
+
  00185638: 34060002 ori r6,r0,0x0002                        |{{f/std|<nowiki>r6 = 0x02 (Attack from Back)</nowiki>}}
  00185668: 00000000 nop
+
   
  0018566c: 94420048 lhu r2,0x0048(r2) Load Target's Y + Facing
+
{{f/loc|<nowiki>--- Delta X = Delta Y (45° Attack) --- </nowiki>}}
  00185670: 00000000 nop
+
  0018563c: 19000006 blez r8,0x00185658      {{f/Cond|If raw delta X >0x00 (Target is Eastward)}}
  00185674: 30420f00 andi r2,r2,0x0f00 Leave only Facing
+
  00185640: 34030100 ori r3,r0,0x0100            |{{f/std|<nowiki>r3 = 0x100 (Facing West)</nowiki>}}
  00185678: 10430015 beq r2,r3,0x001856d0 Branch if Target is facing East
+
  00185644: 94a20048 lhu r2,0x0048(r5)            |{{f/load|<nowiki>r2 = Target Y + Facing/Elevation</nowiki>}}
  0018567c: 00000000 nop
+
00185648: 00000000 nop                          |
  00185680: 18e00009 blez r7,0x001856a8 Branch if TY <= AY
+
  0018564c: 30420f00 andi r2,r2,0x0f00            |{{f/std|<nowiki>r2 = Target facing only</nowiki>}}
00185684: 00000000 nop
+
  00185650: 1043001f beq r2,r3,0x001856d0        {{f/Cond|If Target is not facing West}} /Branch if facing West (r6 will be set to 0x00 - front Attack)
00185688: 3c028019 lui r2,0x8019
+
  00185654: 00000000 nop                             |
  0018568c: 8c422d98 lw r2,0x2d98(r2) Load Target Pointer
+
  00185658: 05010009 bgez r8,0x00185680              {{f/Cond|If raw delta X < 0x00 (Target is Westward)}}
  00185690: 00000000 nop
+
  0018565c: 34030300 ori r3,r0,0x0300                    |{{f/std|<nowiki>r3 = 0x300 (facing East)</nowiki>}}
  00185694: 94420048 lhu r2,0x0048(r2) Load Target's Y + Facing
+
  00185660: 3c028019 lui r2,0x8019                       |
  00185698: 00000000 nop
+
  00185664: 8c422d98 lw r2,0x2d98(r2)                    |{{f/adr|<nowiki>r2 = Target data pointer</nowiki>}}
  0018569c: 30420f00 andi r2,r2,0x0f00 Leave only Facing
+
  00185668: 00000000 nop                                  |
  001856a0: 1040000b beq r2,r0,0x001856d0 Branch if Facing South
+
  0018566c: 94420048 lhu r2,0x0048(r2)                   |{{f/load|<nowiki>r2 = Target Y + Facing/Elevation</nowiki>}}
  001856a4: 00000000 nop
+
  00185670: 00000000 nop                                 |
001856a8: 04e1000b bgez r7,0x001856d8 Branch if TY >= AY
+
  00185674: 30420f00 andi r2,r2,0x0f00                    |{{f/std|<nowiki>r2 = Target facing only</nowiki>}}
  001856ac: 34030200 ori r3,r0,0x0200
+
00185678: 10430015 beq r2,r3,0x001856d0                {{f/Cond|If Target is not facing East}} /Branch if facing East (r6 will be set to 0x00 - front Attack)
  001856b0: 3c028019 lui r2,0x8019
+
  0018567c: 00000000 nop                                     |
  001856b4: 8c422d98 lw r2,0x2d98(r2) Load Target Pointer
+
  00185680: 18e00009 blez r7,0x001856a8                      {{f/Cond|If Raw delta Y > 0x00 (Target is Northward)}}
  001856b8: 00000000 nop
+
00185684: 00000000 nop                                          |{{f/std|}}
  001856bc: 94420048 lh u r2,0x0048(r2) Load Target's Y + Facing
+
00185688: 3c028019 lui r2,0x8019                               |{{f/std|}}
  001856c0: 00000000 no p
+
  0018568c: 8c422d98 lw r2,0x2d98(r2)                             |{{f/adr|<nowiki>r2 = Target data pointer</nowiki>}}
001856c4: 30420f00 andi r2,r2,0x0f00 Leave only Facin g
+
  00185690: 00000000 nop                                          |
  001856c8: 14430003 bne r2,r3,0x001856d8 Branch if Target is not facing  North
+
  00185694: 94420048 lhu r2,0x0048(r2)                            |{{f/load|<nowiki>r2 = Target Y + Facing/Elevation</nowiki>}}
  001856cc: 00000000 nop
+
  00185698: 00000000 nop                                          |
001856d0: 080615bb j 0x001856ec
+
0018569c: 30420f00 andi r2,r2,0x0f00                            |{{f/std|<nowiki>r2 = Target facing only</nowiki>}}
  001856d4: 00003021 addu r6,r0,r0 r6 = 0 (Front)
+
  001856a0: 1040000b beq r2,r0,0x001856d0                        {{f/Cond|If Target is not facing South}} /Branch if facing South (r6 will be set to 0x00 - front Attack)
  001856d8: 15000004 bne r8,r0,0x001856ec Branch if TX - AX is not 0
+
  001856a4: 00000000 nop                                              |
  001856dc: 00000000 nop
+
  001856a8: 04e1000b bgez r7,0x001856d8                      {{f/Cond|E  }}    {{f/Cond|If Delta Y < 0x00 (Target is Southward)}}
  001856e0: 14e00002 bne r7,r0,0x001856ec Branch if TY - AY is not 0
+
001856ac: 34030200 ori r3,r0,0x0200                                    |{{f/std|<nowiki>r3 = 0x200 (Facing North)</nowiki>}}
  001856e4: 00000000 nop
+
001856b0: 3c028019 lui r2,0x8019                                        |
001856e8: 34060002 ori r6,r0,0x0002 r6 = 2 (Back)
+
001856b4: 8c422d98 lw r2,0x2d98(r2)                                    |{{f/adr|<nowiki>r2 = Target data pointer</nowiki>}}
  001856ec: 3c038019 lui r3,0x8019
+
001856b8: 00000000 nop                                                  |
  001856f0: 246338e2 addiu r3,r3,0x38e2
+
001856bc: 94420048 lhu r2,0x0048(r2)                                    |{{f/load|<nowiki>r2 = Target Y + Facing/Elevation</nowiki>}}
  001856f4: a0660000 sb r6,0x0000(r3) Store Facing Mod
+
001856c0: 00000000 nop                                                  |
  001856f8: 90620000 lbu r2,0x0000(r3) Load Facing Mod >_>
+
001856c4: 30420f00 andi r2,r2,0x0f00                                    |{{f/std|<nowiki>r2 = Target facing only</nowiki>}}
  001856fc: 00000000 nop
+
001856c8: 14430003 bne r2,r3,0x001856d8                                {{f/Cond|If Target is facing North}}
  00185700: 10400003 beq r2,r0,0x00185710 Branch if Facing Mod = 0 (Facing Front)
+
001856cc: 00000000 nop                                                      |
  00185704: 00000000 nop
+
001856d0: 080615bb j 0x001856ec                        {{f/Cond|E  }}  {{f/Cond|E  }}        {{f/jump|Jump to }} {{f/loc|Evade Calculation}}  r6 = 0x00 (Attack from Front)
  00185708: 3c018019 lui r1,0x8019
+
001856d4: 00003021 addu r6,r0,r0                                            |{{f/std|<nowiki>r6 = 0x00</nowiki>}}
  0018570c: a02038e1 sb r0,0x38e1(r1) Class Evade = 0
+
001856d8: 15000004 bne r8,r0,0x001856ec                            {{f/Cond|<nowiki>If Delta X = 0x00</nowiki>}} /Else Branch to Evade calculation (Side Attack)
  00185710: 90630000 lbu r3,0x0000(r3) Load Facing Mod
+
001856dc: 00000000 nop                                                  |
  00185714: 34020002 ori r2,r0,0x0002
+
001856e0: 14e00002 bne r7,r0,0x001856ec                                {{f/Cond|<nowiki>If Delta Y = 0x00</nowiki>}} /Else Branch to Evade calculation (Side Attack)
  00185718: 14620005 bne r3,r2,0x00185730 Branch if Facing Mod != 2 (not facing Back)
+
001856e4: 00000000 nop                                                      |
  0018571c: 00000000 nop
+
001856e8: 34060002 ori r6,r0,0x0002                                        |{{f/std|<nowiki>r6 = 0x02 (Never true ? Delta X = Delta Y = 0 ? - Attack from same tile different elevation ??)</nowiki>}}
  00185720: 3c018019 lui r1,0x8019
+
  00185724: a02038df sb r0,0x38df(r1) Weapon Evade = 0
+
{{f/loc|--- Evasion Calculation --- }}
00185728: 3c018019 lui r1,0x8019
+
001856ec: 3c038019 lui r3,0x8019                                            |
  0018572c: a02038e0 sb r0,0x38e0(r1) Shield Evade = 0
+
001856f0: 246338e2 addiu r3,r3,0x38e2      |{{f/adr|<nowiki>r3 = 0x801938e2 (Current ability Facing mod pointer)</nowiki>}}
  00185730: 03e00008 jr r31
+
001856f4: a0660000 sb r6,0x0000(r3)        |{{f/store|Store r6 as Current ability facing modifier}}
  00185734: 00000000 nop
+
001856f8: 90620000 lbu r2,0x0000(r3)        |{{f/load|<nowiki>r2 = Facing modifier</nowiki>}}
 +
001856fc: 00000000 nop                      |
 +
00185700: 10400003 beq r2,r0,0x00185710    {{f/Cond|If Facing modifier <> 0x00 (not frontal attack)}}
 +
00185704: 00000000 nop                          |{{f/std|}}
 +
00185708: 3c018019 lui r1,0x8019                |{{f/std|}}
 +
0018570c: a02038e1 sb r0,0x38e1(r1)            |{{f/store|Nullify Current Ability Class Evade ( 0x801938e1 )}}
 +
00185710: 90630000 lbu r3,0x0000(r3)        |{{f/load|<nowiki>r3 =  Facing Mod</nowiki>}}
 +
00185714: 34020002 ori r2,r0,0x0002        |
 +
00185718: 14620005 bne r3,r2,0x00185730    {{f/Cond|<nowiki>If Facing modifier = 0x02 (Back Attack)</nowiki>}}
 +
0018571c: 00000000 nop                          |
 +
00185720: 3c018019 lui r1,0x8019                |
 +
00185724: a02038df sb r0,0x38df(r1)            |{{f/store|Nullify Current Ability Weapon Evade ( 0x801938df )}}
 +
00185728: 3c018019 lui r1,0x8019                |
 +
0018572c: a02038e0 sb r0,0x38e0(r1)            |{{f/store|Nullify Current Ability Shield Evade  ( 0x801938e0 )}}
 +
  00185730: 03e00008 jr r31                       |
 +
  00185734: 00000000 nop                         |
  
  
== Return Locations ==
 
  
*Battle.bin
+
=== Return Locations ===
 
+
'''Battle.bin'''
  00188548: [[Physical Evade Calculation]]
+
  00188550: [[Physical Evade Calculation]]
  00188598: [[Physical Evade Calculation(Charge)]]
+
  001885A0: [[Physical Evade Calculation(Charge)]]

Latest revision as of 20:58, 23 March 2022

No Parameters - Returns Nothing

Compare X and Y coordinates difference to determine which direction is the more relevant
If X = Y Facing is Front or Side (back only if Same coordinates (?))

If Attacked from side : Class Evade is nullified (0x801938e1)
If Attacked from back : Class Evade, Right and Left Hands Evade are nullified (0x801938e1, 0x801938df, 0x801938e0)
------------------------------------------------------------------------------------------------------------------------
001854fc: 3c058019 lui r5,0x8019            |
00185500: 8ca52d98 lw r5,0x2d98(r5)         |r5 = Target data pointer
00185504: 3c048019 lui r4,0x8019            |
00185508: 8c842d94 lw r4,0x2d94(r4)         |r4 = Attacker data pointer
0018550c: 90a30047 lbu r3,0x0047(r5)        |r3 = Target X coordinate
00185510: 90820047 lbu r2,0x0047(r4)        |r2 = Attacker X coordinate
00185514: 00000000 nop                      |
00185518: 00624023 subu r8,r3,r2            |r8 = Delta X (Target - Attacker)
0018551c: 90820048 lbu r2,0x0048(r4)        |r2 = Attacker Y coordinate
00185520: 05010002 bgez r8,0x0018552c       #If Delta X < 0x00 
00185524: 01002021 addu r4,r8,r0            |r4 = Delta X
00185528: 00042023 subu r4,r0,r4                |r4 = Delta X (positive value)
0018552c: 90a30048 lbu r3,0x0048(r5)        |r3 = Target Y Coordinate
00185530: 308400ff andi r4,r4,0x00ff        |r4 = Delta X (positive byte)
00185534: 00623823 subu r7,r3,r2            |r7 = Delta Y (Target - Attacker)
00185538: 04e10002 bgez r7,0x00185544       #If Delta Y < 0x00
0018553c: 00e01021 addu r2,r7,r0            |r2 = Delta Y
00185540: 00021023 subu r2,r0,r2                |r2 = Positive value of Delta Y
00185544: 304300ff andi r3,r2,0x00ff        |r3 = Delta Y (positive byte)
00185548: 0064102b sltu r2,r3,r4            |r2 = 0x01 if Delta Y < Delta X
0018554c: 1040001d beq r2,r0,0x001855c4     #If Delta X > Delta Y  (delta X has more weight to determine facing)
00185550: 34060001 ori r6,r0,0x0001         |r6 = 0x01 (default is side attack)

---  Delta X  has more weight --- 
00185554: 1900000c blez r8,0x00185588           #If raw Delta X > 0x00 (Target is eastward) /Else branch to Westward check)
00185558: 00000000 nop                              |
0018555c: 94a20048 lhu r2,0x0048(r5)                |r2 = Target Y + Facing/Elevation
00185560: 00000000 nop                              |
00185564: 30430f00 andi r3,r2,0x0f00                |r3 = Target facing
00185568: 34020100 ori r2,r0,0x0100                 |r2 = 0x0100 (Facing West)
0018556c: 14620003 bne r3,r2,0x0018557c             #If Target is facing West
00185570: 34020300 ori r2,r0,0x0300                 |r2 = 0x0300 (Facing East)
00185574: 08061562 j 0x00185588                         >>Jump to Westward check (will branch to evade calculation)
00185578: 00003021 addu r6,r0,r0                        |r6 = 0x00 (Frontal Attack)
0018557c: 14620002 bne r3,r2,0x00185588             #If Target is facing East
00185580: 00000000 nop                                  |
00185584: 34060002 ori r6,r0,0x0002                     |r6 = 0x02 (Attack from Back)
00185588: 05010058 bgez r8,0x001856ec           #If raw Delta X < 0x00 (Target is Westward) /Else branch to Evade Calculation
0018558c: 00000000 nop                              |
00185590: 3c028019 lui r2,0x8019                    |
00185594: 8c422d98 lw r2,0x2d98(r2)                 |r2 = Target data pointer
00185598: 00000000 nop                              |
0018559c: 94420048 lhu r2,0x0048(r2)                |r2 = Target Y + Facing/Elevation
001855a0: 00000000 nop                              |
001855a4: 30430f00 andi r3,r2,0x0f00                |r3 = Target facing only
001855a8: 34020300 ori r2,r0,0x0300                 |r2 = 0x0300 (Facing East)
001855ac: 10620048 beq r3,r2,0x001856d0             #If Target is not facing East /If Facing East branch - r6 will be set to 0x00 and jump to  Evade Calculation
001855b0: 34020100 ori r2,r0,0x0100                     |r2 = 0x0100 (Facing West)
001855b4: 1462004d bne r3,r2,0x001856ec                 #If Target is facing West
001855b8: 00000000 nop                                      |
001855bc: 080615bb j 0x001856ec                             >>Jump to  Evade Calculation  r6 = 0x02 (Attack from Back)
001855c0: 34060002 ori r6,r0,0x0002                         |r6 = 0x02 (Attack from Back)
001855c4: 0083102b sltu r2,r4,r3            |r2 = 0x01 if Delta X < Delta Y
001855c8: 1040001c beq r2,r0,0x0018563c     #If Delta Y > Delta X (delta Y has more weight to determine facing)
001855cc: 00000000 nop                          |

--- Delta Y  has more weight ---
001855d0: 18e0000b blez r7,0x00185600           #If Raw Delta Y > 0x00 (Target is to the North)
001855d4: 00000000 nop                              |
001855d8: 94a20048 lhu r2,0x0048(r5)                |r2 = Target Y + Facing/Elevation
001855dc: 00000000 nop                              |
001855e0: 30430f00 andi r3,r2,0x0f00                |r3 = Target facing
001855e4: 14600003 bne r3,r0,0x001855f4             #If Target is facing South
001855e8: 34020200 ori r2,r0,0x0200                 |r2 = 0x200 (Facing North ?)
001855ec: 08061580 j 0x00185600                         >>Jump to Southward check (will branch to Evade calculation)
001855f0: 00003021 addu r6,r0,r0                        |r6 = 0x00 (front)
001855f4: 14620002 bne r3,r2,0x00185600             #If Target is facing North
001855f8: 00000000 nop                                  |
001855fc: 34060002 ori r6,r0,0x0002                     |r6 = 0x02 (Attack from Back)
00185600: 04e1003a bgez r7,0x001856ec           #If Raw Delta Y < 0x00 (Target is Southward)
00185604: 00000000 nop                              |
00185608: 3c028019 lui r2,0x8019                    |
0018560c: 8c422d98 lw r2,0x2d98(r2)                 |r2 = Target data pointer
00185610: 00000000 nop                              |
00185614: 94420048 lhu r2,0x0048(r2)                |r2 = Target Y + Facing/Elevation
00185618: 00000000 nop                              |
0018561c: 30430f00 andi r3,r2,0x0f00                |r3 = Target facing
00185620: 34020200 ori r2,r0,0x0200                 |r2 = 0x200 (Facing North)
00185624: 1062002a beq r3,r2,0x001856d0             #If Target is not Facing North /If Facing North branch - r6 will be set to 0x00 and jump to  Evade Calculation
00185628: 00000000 nop                                  |
0018562c: 1460002f bne r3,r0,0x001856ec                 #If Target is Facing South
00185630: 00000000 nop                                      |
00185634: 080615bb j 0x001856ec                             >>Jump to  Evade Calculation  r6 = 0x02 (Attack from Back)
00185638: 34060002 ori r6,r0,0x0002                         |r6 = 0x02 (Attack from Back)

--- Delta X = Delta Y (45° Attack) --- 
0018563c: 19000006 blez r8,0x00185658       #If raw delta X >0x00 (Target is Eastward)
00185640: 34030100 ori r3,r0,0x0100             |r3 = 0x100 (Facing West)
00185644: 94a20048 lhu r2,0x0048(r5)            |r2 = Target Y + Facing/Elevation
00185648: 00000000 nop                          |
0018564c: 30420f00 andi r2,r2,0x0f00            |r2 = Target facing only
00185650: 1043001f beq r2,r3,0x001856d0         #If Target is not facing West /Branch if facing West (r6 will be set to 0x00 - front Attack)
00185654: 00000000 nop                              |
00185658: 05010009 bgez r8,0x00185680               #If raw delta X < 0x00 (Target is Westward)
0018565c: 34030300 ori r3,r0,0x0300                     |r3 = 0x300 (facing East)
00185660: 3c028019 lui r2,0x8019                        |
00185664: 8c422d98 lw r2,0x2d98(r2)                     |r2 = Target data pointer
00185668: 00000000 nop                                  |
0018566c: 94420048 lhu r2,0x0048(r2)                    |r2 = Target Y + Facing/Elevation
00185670: 00000000 nop                                  |
00185674: 30420f00 andi r2,r2,0x0f00                    |r2 = Target facing only
00185678: 10430015 beq r2,r3,0x001856d0                 #If Target is not facing East /Branch if facing East (r6 will be set to 0x00 - front Attack)
0018567c: 00000000 nop                                      |
00185680: 18e00009 blez r7,0x001856a8                       #If Raw delta Y > 0x00 (Target is Northward)
00185684: 00000000 nop                                          |
00185688: 3c028019 lui r2,0x8019                                |
0018568c: 8c422d98 lw r2,0x2d98(r2)                             |r2 = Target data pointer
00185690: 00000000 nop                                          |
00185694: 94420048 lhu r2,0x0048(r2)                            |r2 = Target Y + Facing/Elevation
00185698: 00000000 nop                                          |
0018569c: 30420f00 andi r2,r2,0x0f00                            |r2 = Target facing only
001856a0: 1040000b beq r2,r0,0x001856d0                         #If Target is not facing South /Branch if facing South (r6 will be set to 0x00 - front Attack)
001856a4: 00000000 nop                                              |
001856a8: 04e1000b bgez r7,0x001856d8                       #E      #If Delta Y < 0x00 (Target is Southward)
001856ac: 34030200 ori r3,r0,0x0200                                     |r3 = 0x200 (Facing North)
001856b0: 3c028019 lui r2,0x8019                                        |
001856b4: 8c422d98 lw r2,0x2d98(r2)                                     |r2 = Target data pointer
001856b8: 00000000 nop                                                  |
001856bc: 94420048 lhu r2,0x0048(r2)                                    |r2 = Target Y + Facing/Elevation
001856c0: 00000000 nop                                                  |
001856c4: 30420f00 andi r2,r2,0x0f00                                    |r2 = Target facing only
001856c8: 14430003 bne r2,r3,0x001856d8                                 #If Target is facing North
001856cc: 00000000 nop                                                      |
001856d0: 080615bb j 0x001856ec                         #E     #E           >>Jump to  Evade Calculation  r6 = 0x00 (Attack from Front)
001856d4: 00003021 addu r6,r0,r0                                            |r6 = 0x00
001856d8: 15000004 bne r8,r0,0x001856ec                             #If Delta X = 0x00 /Else Branch to Evade calculation (Side Attack)
001856dc: 00000000 nop                                                  |
001856e0: 14e00002 bne r7,r0,0x001856ec                                 #If Delta Y = 0x00 /Else Branch to Evade calculation (Side Attack)
001856e4: 00000000 nop                                                      |
001856e8: 34060002 ori r6,r0,0x0002                                         |r6 = 0x02 (Never true ? Delta X = Delta Y = 0 ? - Attack from same tile different elevation ??)

--- Evasion Calculation --- 
001856ec: 3c038019 lui r3,0x8019                                            |
001856f0: 246338e2 addiu r3,r3,0x38e2       |r3 = 0x801938e2 (Current ability Facing mod pointer)
001856f4: a0660000 sb r6,0x0000(r3)         |Store r6 as Current ability facing modifier
001856f8: 90620000 lbu r2,0x0000(r3)        |r2 = Facing modifier
001856fc: 00000000 nop                      |
00185700: 10400003 beq r2,r0,0x00185710     #If Facing modifier <> 0x00 (not frontal attack)
00185704: 00000000 nop                          |
00185708: 3c018019 lui r1,0x8019                |
0018570c: a02038e1 sb r0,0x38e1(r1)             |Nullify Current Ability Class Evade ( 0x801938e1 )
00185710: 90630000 lbu r3,0x0000(r3)        |r3 =  Facing Mod
00185714: 34020002 ori r2,r0,0x0002         |
00185718: 14620005 bne r3,r2,0x00185730     #If Facing modifier = 0x02 (Back Attack)
0018571c: 00000000 nop                          |
00185720: 3c018019 lui r1,0x8019                |
00185724: a02038df sb r0,0x38df(r1)             |Nullify Current Ability Weapon Evade ( 0x801938df )
00185728: 3c018019 lui r1,0x8019                |
0018572c: a02038e0 sb r0,0x38e0(r1)             |Nullify Current Ability Shield Evade  ( 0x801938e0 )
00185730: 03e00008 jr r31                       |
00185734: 00000000 nop                          |


Return Locations

Battle.bin
00188550: Physical Evade Calculation
001885A0: Physical Evade Calculation(Charge)