Difference between revisions of "Calculate Possible AoE Tiles"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
m (Add duplicated link)
 
Line 1: Line 1:
  DUPLICATED [[Generate_Range_Around_Tile_Routine]]
+
  '''0017963c - 001797b0''' : This routine will spread the AoE out of the center, storing the original AoE value - 1 in the surrounding tiles (see [[#Notes|Notes]])
 
+
   
  Calculate Possible AoE Tiles
+
  '''Parameters''' : r4 = AoE Origin Y
  0017963c: 3c02800e lui r2,0x800e
+
              r5 = AoE Origin X
00179640: 90424e9c lbu r2,0x4e9c(r2) r2 = Map Max X
+
   
  00179644: 00000000 nop
+
  '''Returns''' : r2 = 0x01 if AoE is not ended yet
  00179648: 00820018 mult r4,r2 Max X * YC
+
          r2 = 0x00 if AoE has ended to spread out
0017964c: 00007021 addu r14,r0,r0 Tiles Left? = 0
+
  ------------------------------------------------------------------------------------------------------
  00179650: 00004821 addu r9,r0,r0 Tile Check = 0
+
  0017963c: 3c02800e lui r2,0x800e            |{{f/std|<nowiki>r2 = 0x800e</nowiki>}}
00179654: 00001812 mflo r3
+
  00179640: 90424e9c lbu r2,0x4e9c(r2)       |{{f/load|<nowiki>r2 = Map Max X</nowiki>}}
00179658: 00651821 addu r3,r3,r5 Max X * YC + XC
+
  00179644: 00000000 nop                      |
0017965c: 00031080 sll r2,r3,0x02 (Max X * YC + XC) * 4
+
  00179648: 00820018 mult r4,r2              |{{f/std|<nowiki>Max X * Y coord</nowiki>}}
00179660: 00431021 addu r2,r2,r3 Tile ID = (Max X * YC + XC) * 4
+
  0017964c: 00007021 addu r14,r0,r0          |{{f/std|<nowiki>r14 = 0x00 (will be set to 0x01 and returned via r2 if AoE is not finished)</nowiki>}}
00179664: 3c018019 lui r1,0x8019 (Tile ID was calculated before jumping here, and this is only
+
  00179650: 00004821 addu r9,r0,r0           |{{f/std|<nowiki>r9 = 0x00 (Loop counter)</nowiki>}}
  00179668: 00220821 addu r1,r1,r2 ever called form that routine)
+
  00179654: 00001812 mflo r3                  |{{f/std|<nowiki>r3 = Max X * Y coord</nowiki>}}
  0017966c: 902c2dd8 lbu r12,0x2dd8(r1) Load Tile's AoE?
+
  00179658: 00651821 addu r3,r3,r5            |{{f/std|<nowiki>(Max X * Y coord) + X coord  (Tile ID without elevation)</nowiki>}}
  00179670: 340f0001 ori r15,r0,0x0001 r15 = 1
+
  0017965c: 00031080 sll r2,r3,0x02          |{{f/std|<nowiki>r2 = Tile ID *4</nowiki>}}
  00179674: 258dffff addiu r13,r12,0xffff r13 = AoE - 1
+
  00179660: 00431021 addu r2,r2,r3            |{{f/std|<nowiki>r2 = Tile ID * 5 (offset of data on targetable grid)</nowiki>}}
  00179678: 112f0011 beq r9,r15,0x 001796c0 Branch if Tile Check = 1
+
  00179664: 3c018019 lui r1,0x8019            |{{f/std|<nowiki>r1 = 0x80190000</nowiki>}}
  0017967c: 29220002 slti r2,r9,0x0002
+
  00179668: 00220821 addu r1,r1,r2           |{{f/std|<nowiki>r1 = 0x80190000 + Tile offset</nowiki>}}
00179680: 10400005 beq r2,r0,0x 00179698 Branch if Tile Check >= 2
+
  0017966c: 902c2dd8 lbu r12,0x2dd8(r1)      |{{f/load|<nowiki>r12 = AoE of targetable pannel matching Tile coordinates (will spread from here = Origin Panel)</nowiki>}}
  00179684: 00000000 nop
+
  00179670: 340f0001 ori r15,r0,0x0001        |{{f/std|<nowiki>r15 = 0x01 (will be stored at panel 0x01 while looping)</nowiki>}}
  00179688: 1120000a beq r9,r0,0x 001796b4 Branch if Tile Check = 0
+
  00179674: 258dffff addiu r13,r12,-0x0001    |{{f/std|<nowiki>r13 = AoE from Origin Panel - 0x01</nowiki>}}
  0017968c: 00ab4021 addu r8,r5,r11 AoE X = X Counter + X Mod
+
  00179678: 112f0011 beq r9,r15,0x001796c0    {{f/bloop|<nowiki>LOOP 4 times (4 panels around origin)</nowiki>}} {{f/Cond|<nowiki>If r9 <> 0x01</nowiki>}} {{f/std|<nowiki>(Start of the loop is a mess, just to check counter value)</nowiki>}}
  00179690: 0805e5b9 j 0x 001796e4
+
  0017967c: 29220002 slti r2,r9,0x0002            |{{f/std|<nowiki>r2 = 0x01 if r9 < 0x02</nowiki>}}
00179694: 00000000 nop
+
  00179680: 10400005 beq r2,r0,0x00179698              {{f/Cond|<nowiki>If r9 <0x02 (=< 0x00)</nowiki>}}
00179698: 34020002 ori r2,r0,0x0002 r2 = 2
+
  00179684: 00000000 nop                              |
  0017969c: 1122000b beq r9,r2,0x 001796cc Branch if Tile Check = 2
+
  00179688: 1120000a beq r9,r0,0x001796b4                  {{f/Cond|<nowiki>if r9<> 0x00 (not 0x00 not 0x01 and <0x02) ? < 0x00 ? Never met ? (resolution is strange)</nowiki>}}
  001796a0: 34020003 ori r2,r0,0x0003 r2 = 3
+
  0017968c: 00ab4021 addu r8,r5,r11                            |{{f/std|<nowiki>r8 = Origin X + r11 (not set yet or = 0x00)</nowiki>}}
  001796a4: 1122000c beq r9,r2,0x 001796d8 Branch if Tile Check = 3
+
  00179690: 0805e5b9 j 0x001796e4                              {{f/jump|<nowiki>jump to offset attribution ( X already done)</nowiki>}}
  001796a8: 00ab4021 addu r8,r5,r11 AoE X = X Counter + X Mod
+
  00179694: 00000000 nop                                      |
  001796ac: 0805e5b9 j 0x 001796e4
+
00179698: 34020002 ori r2,r0,0x0002                  {{f/Cond|<nowiki>Else (r9 >=0x02) </nowiki>}} {{f/std|<nowiki>r2 = 0x02</nowiki>}}
001796b0: 00000000 nop
+
  0017969c: 1122000b beq r9,r2,0x001796cc                      {{f/Cond|<nowiki>if r9 <> 0x02</nowiki>}}
  001796b4: 340b0001 ori r11,r0,0x0001 X Mod = 1
+
  001796a0: 34020003 ori r2,r0,0x0003                              |{{f/std|<nowiki>r2 = 0x03</nowiki>}}
  001796b8: 0805e5b8 j 0x 001796e0
+
  001796a4: 1122000c beq r9,r2,0x001796d8                          {{f/Cond|<nowiki>if r9 <> 0x03</nowiki>}}
001796bc: 00005021 addu r10,r0,r0 Y Mod = 0
+
  001796a8: 00ab4021 addu r8,r5,r11                                    |{{f/std|<nowiki>r8 = Origin X + r11 (not set yet or = 0x00)</nowiki>}}
  001796c0: 00005821 addu r11,r0,r0 X Mod = 0
+
  001796ac: 0805e5b9 j 0x001796e4                                      {{f/jump|<nowiki>jump</nowiki>}}
  001796c4: 0805e5b8 j 0x 001796e0
+
  001796b0: 00000000 nop                                              |
  001796c8: 340a0001 ori r10,r0,0x0001 Y Mod = 1
+
  001796b4: 340b0001 ori r11,r0,0x0001            {{f/Cond|<nowiki>>jump here if r9 = 0x00</nowiki>}} {{f/std|<nowiki>X offset = 0x01</nowiki>}}
001796cc: 240bffff addiu r11,r0,0xffff X Mod = -1
+
  001796b8: 0805e5b8 j 0x001796e0                      {{f/jump|<nowiki>jump to offset attribution (X+1)</nowiki>}}
  001796d0: 0805e5b8 j 0x 001796e0
+
  001796bc: 00005021 addu r10,r0,r0                    |{{f/std|<nowiki>Y offset = 0x00</nowiki>}}
001796d4: 00005021 addu r10,r0,r0 Y Mod = 0
+
  001796c0: 00005821 addu r11,r0,r0                {{f/Cond|<nowiki>>jump here if r9 = 0x01</nowiki>}} {{f/std|<nowiki>X offset = 0</nowiki>}}
  001796d8: 00005821 addu r11,r0,r0 X Mod = 0
+
001796c4: 0805e5b8 j 0x001796e0                      {{f/jump|<nowiki>jump to offset attribution (Y+1)</nowiki>}}
  001796dc: 240affff addiu r10,r0,0xffff Y Mod = -1
+
  001796c8: 340a0001 ori r10,r0,0x0001                |{{f/std|<nowiki>Y offset= 0x01</nowiki>}}
  001796e0: 00ab4021 addu r8,r5,r11 AoE X = X Counter + X Mod
+
  001796cc: 240bffff addiu r11,r0,0xffff          {{f/Cond|<nowiki>>jump here if r9 = 0x02</nowiki>}} {{f/std|<nowiki>X offset = -0x01</nowiki>}}
  001796e4: 0500002d bltz r8,0x 0017979c Branch if AoE X < 0
+
  001796d0: 0805e5b8 j 0x001796e0                      {{f/jump|<nowiki>jump to offset attribution X-1)</nowiki>}}
  001796e8: 008a3821 addu r7,r4,r10 AoE Y = Y Counter + Y Mod
+
  001796d4: 00005021 addu r10,r0,r0                    |{{f/std|<nowiki>Y offset = 0x00</nowiki>}}
  001796ec: 04e0002b bltz r7,0x 0017979c Branch if AoE Y < 0
+
  001796d8: 00005821 addu r11,r0,r0                {{f/Cond|<nowiki>>jump here if r9 = 0x03 (Y-1)</nowiki>}} {{f/std|<nowiki>X offset = 0</nowiki>}}
  001796f0: 00000000 nop
+
  001796dc: 240affff addiu r10,r0,0xffff              |{{f/std|<nowiki>Y offset = -0x01</nowiki>}}
  001796f4: 3c03800e lui r3,0x800e
+
   
  001796f8: 90634e9c lbu r3,0x4e9c(r3) Load Map Max X
+
                              {{f/com|<nowiki>---  Coordinates checking and AoE attribution ---</nowiki>}}
  001796fc: 00000000 nop
+
  001796e0: 00ab4021 addu r8,r5,r11                |{{f/std|<nowiki>r8 = Origin X + X offset</nowiki>}}
00179700: 0103102a slt r2,r8,r3
+
  001796e4: 0500002d bltz r8,0x0017979c            {{f/Cond|<nowiki>if Xcoord is valid (>= 0x00)</nowiki>}} /Else branch to next loop iteration
  00179704: 10400025 beq r2,r0,0x 0017979c Branch if AoE X >= Max X
+
  001796e8: 008a3821 addu r7,r4,r10                |{{f/std|<nowiki>r7 = Origin Y + Y offset</nowiki>}}
  00179708: 00000000 nop
+
  001796ec: 04e0002b bltz r7,0x0017979c                {{f/Cond|<nowiki>if Y coord is valid (>= 0x00)</nowiki>}} /Else branch to next loop iteration
0017970c: 3c02800e lui r2,0x800e
+
  001796f0: 00000000 nop                                   |
00179710: 90424ea0 lbu r2,0x4ea0(r2) Load Map Max Y
+
  001796f4: 3c03800e lui r3,0x800e                        |{{f/std|<nowiki>r3 = 0x800e0000</nowiki>}}
  00179714: 00000000 nop
+
  001796f8: 90634e9c lbu r3,0x4e9c(r3)                     |{{f/load|<nowiki>r3 = Map Max X</nowiki>}}
00179718: 00e2102a slt r2,r7,r2
+
  001796fc: 00000000 nop                                   |
  0017971c: 1040001f beq r2,r0,0x 0017979c Branch if AoE Y >= Max Y
+
  00179700: 0103102a slt r2,r8,r3                          |{{f/std|<nowiki>r2 = 0x01 if r8 < Map Max X</nowiki>}}
00179720: 00e30018 mult r7,r3 AoE Y * Max X
+
  00179704: 10400025 beq r2,r0,0x0017979c                  {{f/Cond|<nowiki>If X coord is valid (< Map Max X)</nowiki>}} /Else branch to next loop iteration
  00179724: 00001012 mflo r2
+
  00179708: 00000000 nop                                      |
  00179728: 00481021 addu r2,r2,r8 AoE Y * Max X + AoE X
+
  0017970c: 3c02800e lui r2,0x800e                            |{{f/std|<nowiki>r2 = 0x800e0000</nowiki>}}
  0017972c: 00021880 sll r3,r2,0x02 (AoE Y * Max X + AoE X) * 4
+
  00179710: 90424ea0 lbu r2,0x4ea0(r2)                        |{{f/load|<nowiki>r2 = Map Max Y</nowiki>}}
  00179730: 00621821 addu r3,r3,r2 Tile ID = (AoE Y * Max X + AoE X) * 5
+
  00179714: 00000000 nop                                      |
  00179734: 3c028019 lui r2,0x8019
+
00179718: 00e2102a slt r2,r7,r2                             |{{f/std|<nowiki>r2 = 0x01 if r7 < Map Max Y</nowiki>}}
  00179738: 24422dd8 addiu r2,r2,0x2dd8
+
  0017971c: 1040001f beq r2,r0,0x0017979c                      {{f/Cond|<nowiki>If Y coord is valid (< Map Max Y)</nowiki>}}
  0017973c: 00623021 addu r6,r3,r2
+
  00179720: 00e30018 mult r7,r3                                    |{{f/std|<nowiki>Y coord * Max X</nowiki>}}
00179740: 90c20000 lbu r2,0x0000(r6) Load Tile's AoE
+
  00179724: 00001012 mflo r2                                      |{{f/std|<nowiki>r2 = Y coord * Max X</nowiki>}}
  00179744: 00000000 nop
+
  00179728: 00481021 addu r2,r2,r8                                |{{f/std|<nowiki>r2 =(Y * Max X) + X = Tile ID (with elevation 0)</nowiki>}}
00179748: 004c102a slt r2,r2,r12
+
  0017972c: 00021880 sll r3,r2,0x02                                |{{f/std|<nowiki>r3 = Tile ID * 4</nowiki>}}
  0017974c: 10400013 beq r2,r0,0x 0017979c Branch if New Tile AoE > Starting AoE
+
  00179730: 00621821 addu r3,r3,r2                                |{{f/std|<nowiki>r3 = Tile ID * 5 (offset of panel data in targetable grid)</nowiki>}}
  00179750: 00000000 nop
+
  00179734: 3c028019 lui r2,0x8019                                |
  00179754: a0cd0000 sb r13,0x0000(r6) Store AoE = AoE - 1
+
  00179738: 24422dd8 addiu r2,r2,0x2dd8                            |{{f/std|<nowiki>r2 = 0x80192dd8</nowiki>}}
  00179758: 3c02800e lui r2,0x800e
+
  0017973c: 00623021 addu r6,r3,r2                                |{{f/std|<nowiki>r6 = Targetable grid panel data pointer</nowiki>}}
0017975c: 90424e9c lbu r2,0x4e9c(r2) Load Map Max X
+
  00179740: 90c20000 lbu r2,0x0000(r6)                            |{{f/load|<nowiki>r2 = AoE from this panel</nowiki>}}
  00179760: 00000000 nop
+
  00179744: 00000000 nop                                          |
  00179764: 00e20018 mult r7,r2 Max X * AoE Y
+
  00179748: 004c102a slt r2,r2,r12                                |{{f/std|<nowiki>r2 =0x01 if AoE is < origin panel AoE</nowiki>}}
  00179768: 25020100 addiu r2,r8,0x0100 r2 = AoE X + 0x100 (higher elevation)
+
0017974c: 10400013 beq r2,r0,0x0017979c                          {{f/Cond|<nowiki>if AoE is < Origin Panel AoE (AoE spread out, this is for not overwriting data toward the center of large AoE)</nowiki>}} /Else next loop iteration
  0017976c: 00001812 mflo r3
+
00179750: 00000000 nop                                              |
  00179770: 00621821 addu r3,r3,r2 Max X * AoE Y + AoE X + 0x100
+
00179754: a0cd0000 sb r13,0x0000(r6)                                |{{f/store|<nowiki>Store AoE = Origin AoE - 1</nowiki>}}
  00179774: 00031080 sll r2,r3,0x02 (Max X * AoE Y + AoE X + 0x100) * 4
+
00179758: 3c02800e lui r2,0x800e                                    |{{f/std|<nowiki>r2 = 0x800e</nowiki>}}
  00179778: 00431021 addu r2,r2,r3 (Max X * AoE Y + AoE X + 0x100) * 5
+
0017975c: 90424e9c lbu r2,0x4e9c(r2)                                |{{f/load|<nowiki>r2 = Map Max X</nowiki>}}
  0017977c: 3c018019 lui r1,0x8019
+
00179760: 00000000 nop                                              |
00179780: 00220821 addu r1,r1,r2
+
00179764: 00e20018 mult r7,r2                                        |{{f/std|<nowiki>Y coord * Max X</nowiki>}}
  00179784: a02d2dd8 sb r13,0x2dd8(r1) Store Tile's reduced AoE (slowly spread out from origin)
+
00179768: 25020100 addiu r2,r8,0x0100                                |{{f/std|<nowiki>r2 =  X coord+ 0x100 (higher elevation offset)</nowiki>}}
  00179788: 29820003 slti r2,r12,0x0003
+
0017976c: 00001812 mflo r3                                          |{{f/std|<nowiki>r3 = Y coord * Max X</nowiki>}}
  0017978c: 14400003 bne r2,r0,0x 0017979c Branch if Starting AoE <= 3
+
00179770: 00621821 addu r3,r3,r2                                    |{{f/std|<nowiki>r3 = (Y coord * Max X) + X coord+ 0x100 = Tile ID (with elevation 1)</nowiki>}}
00179790: 00000000 nop
+
00179774: 00031080 sll r2,r3,0x02                                    |{{f/std|<nowiki>Higher Tile ID * 4</nowiki>}}
  00179794: a0cf0001 sb r15,0x0001(r6) Store Tile Targeted Flag? = 1
+
00179778: 00431021 addu r2,r2,r3                                    |{{f/std|<nowiki>Higher Tile ID * 5 (offset of panel data in targetable grid)</nowiki>}}
  00179798: 340e0001 ori r14,r0,0x0001 Tiles Left? = 1
+
0017977c: 3c018019 lui r1,0x8019                                    |{{f/std|<nowiki>r1 = 0x80190000</nowiki>}}
  0017979c: 25290001 addiu r9,r9,0x0001 Tile Check += 1
+
00179780: 00220821 addu r1,r1,r2                                    |{{f/std|<nowiki>r1 = 0x80190000 + offset of panel data in targetable grid</nowiki>}}
  001797a0: 29220004 slti r2,r9,0x0004
+
00179784: a02d2dd8 sb r13,0x2dd8(r1)                                |{{f/store|<nowiki>Store AoE = Origin AoE - 1</nowiki>}}
  001797a4: 1440ffb4 bne r2,r0,0x 00179678 Branch if Tile Check < 4
+
00179788: 29820003 slti r2,r12,0x0003                                |{{f/std|<nowiki>r2 = 0x01 if Origin AoE is < 0x03</nowiki>}}
  001797a8: 00000000 nop
+
0017978c: 14400003 bne r2,r0,0x0017979c                              {{f/Cond|<nowiki>If Origin AoE is > 0x02</nowiki>}} /Else AoE has ended spreading
  001797ac: 03e00008 jr r31
+
00179790: 00000000 nop                                                  |
  001797b0: 01c01021 addu r2,r14,r0 r2 = Tiles Left Check
+
00179794: a0cf0001 sb r15,0x0001(r6)                                    |{{f/store|<nowiki>Store lower panel Targeted Flag = 0x01</nowiki>}}
 +
00179798: 340e0001 ori r14,r0,0x0001                                    |{{f/std|<nowiki>r14 = 0x01 (will be returned, AoE is not ended yet)</nowiki>}}
 +
0017979c: 25290001 addiu r9,r9,0x0001            |{{f/std|<nowiki>Counter +1</nowiki>}}
 +
001797a0: 29220004 slti r2,r9,0x0004            |{{f/std|<nowiki>r2 = 0x01 while r9 < 0x04</nowiki>}}
 +
001797a4: 1440ffb4 bne r2,r0,0x00179678    {{f/eloop|<nowiki>LOOP while counter < 0x04</nowiki>}}
 +
001797a8: 00000000 nop                      |
 +
001797ac: 03e00008 jr r31                  |
 +
001797b0: 01c01021 addu r2,r14,r0          |{{f/std|<nowiki>r2 = 0x01 (not ended) or 0x00 (ended)</nowiki>}}
 +
=== Notes ===
 +
Loop 4 times (4 surrounding tiles)
 +
The first part seems messy, and check the loop counter, then determine X and Y offset arround the original tile
 +
Second part check if the surrounding tiles are valid (in the map)
 +
If Tile is in the map, the AoE (- 0x01) will be stored in the panel 0x00 byte (lower and higher elevation)
 +
 +
If Aoe is not finished, the target flag of the panel (panel 0x01) will be set to 0x01 and r2 will be set to 0x01
 +
If AoE is finished, r2 is set to 0x00
 +
=== Return location ===
 +
001795cc: [[Calculate_Tiles_Hit_by_Ability]]

Latest revision as of 22:10, 5 February 2022

0017963c - 001797b0 : This routine will spread the AoE out of the center, storing the original AoE value - 1 in the surrounding tiles (see Notes)

Parameters : r4 = AoE Origin Y
             r5 = AoE Origin X

Returns : r2 = 0x01 if AoE is not ended yet
          r2 = 0x00 if AoE has ended to spread out
------------------------------------------------------------------------------------------------------
0017963c: 3c02800e lui r2,0x800e            |r2 = 0x800e
00179640: 90424e9c lbu r2,0x4e9c(r2)        |r2 = Map Max X
00179644: 00000000 nop                      |
00179648: 00820018 mult r4,r2               |Max X * Y coord
0017964c: 00007021 addu r14,r0,r0           |r14 = 0x00 (will be set to 0x01 and returned via r2 if AoE is not finished)
00179650: 00004821 addu r9,r0,r0            |r9 = 0x00 (Loop counter)
00179654: 00001812 mflo r3                  |r3 = Max X * Y coord
00179658: 00651821 addu r3,r3,r5            |(Max X * Y coord) + X coord   (Tile ID without elevation)
0017965c: 00031080 sll r2,r3,0x02           |r2 = Tile ID *4
00179660: 00431021 addu r2,r2,r3            |r2 = Tile ID * 5 (offset of data on targetable grid)
00179664: 3c018019 lui r1,0x8019            |r1 = 0x80190000
00179668: 00220821 addu r1,r1,r2            |r1 = 0x80190000 + Tile offset
0017966c: 902c2dd8 lbu r12,0x2dd8(r1)       |r12 = AoE of targetable pannel matching Tile coordinates (will spread from here = Origin Panel)
00179670: 340f0001 ori r15,r0,0x0001        |r15 = 0x01 (will be stored at panel 0x01 while looping)
00179674: 258dffff addiu r13,r12,-0x0001    |r13 = AoE from Origin Panel - 0x01
00179678: 112f0011 beq r9,r15,0x001796c0    @LOOP 4 times (4 panels around origin) #If r9 <> 0x01 (Start of the loop is a mess, just to check counter value)
0017967c: 29220002 slti r2,r9,0x0002             |r2 = 0x01 if r9 < 0x02
00179680: 10400005 beq r2,r0,0x00179698              #If r9 <0x02 (=< 0x00)
00179684: 00000000 nop                               |
00179688: 1120000a beq r9,r0,0x001796b4                  #if r9<> 0x00 (not 0x00 not 0x01 and <0x02) ? < 0x00 ? Never met ? (resolution is strange)
0017968c: 00ab4021 addu r8,r5,r11                            |r8 = Origin X + r11 (not set yet or = 0x00)
00179690: 0805e5b9 j 0x001796e4                              >>jump to offset attribution ( X already done)
00179694: 00000000 nop                                       |
00179698: 34020002 ori r2,r0,0x0002                  #Else (r9 >=0x02)  r2 = 0x02
0017969c: 1122000b beq r9,r2,0x001796cc                      #if r9 <> 0x02
001796a0: 34020003 ori r2,r0,0x0003                              |r2 = 0x03
001796a4: 1122000c beq r9,r2,0x001796d8                          #if r9 <> 0x03
001796a8: 00ab4021 addu r8,r5,r11                                    |r8 = Origin X + r11 (not set yet or = 0x00)
001796ac: 0805e5b9 j 0x001796e4                                      >>jump
001796b0: 00000000 nop                                               |
001796b4: 340b0001 ori r11,r0,0x0001             #>jump here if r9 = 0x00 X offset = 0x01
001796b8: 0805e5b8 j 0x001796e0                      >>jump to offset attribution (X+1)
001796bc: 00005021 addu r10,r0,r0                    |Y offset = 0x00
001796c0: 00005821 addu r11,r0,r0                #>jump here if r9 = 0x01 X offset = 0
001796c4: 0805e5b8 j 0x001796e0                      >>jump to offset attribution (Y+1)
001796c8: 340a0001 ori r10,r0,0x0001                 |Y offset= 0x01
001796cc: 240bffff addiu r11,r0,0xffff           #>jump here if r9 = 0x02 X offset = -0x01
001796d0: 0805e5b8 j 0x001796e0                      >>jump to offset attribution X-1)
001796d4: 00005021 addu r10,r0,r0                    |Y offset = 0x00
001796d8: 00005821 addu r11,r0,r0                #>jump here if r9 = 0x03 (Y-1) X offset = 0
001796dc: 240affff addiu r10,r0,0xffff               |Y offset = -0x01

                              ---  Coordinates checking and AoE attribution ---
001796e0: 00ab4021 addu r8,r5,r11                |r8 = Origin X + X offset
001796e4: 0500002d bltz r8,0x0017979c            #if Xcoord is valid (>= 0x00) /Else branch to next loop iteration
001796e8: 008a3821 addu r7,r4,r10                |r7 = Origin Y + Y offset
001796ec: 04e0002b bltz r7,0x0017979c                #if Y coord is valid (>= 0x00) /Else branch to next loop iteration
001796f0: 00000000 nop                                   |
001796f4: 3c03800e lui r3,0x800e                         |r3 = 0x800e0000
001796f8: 90634e9c lbu r3,0x4e9c(r3)                     |r3 = Map Max X
001796fc: 00000000 nop                                   |
00179700: 0103102a slt r2,r8,r3                          |r2 = 0x01 if r8 < Map Max X
00179704: 10400025 beq r2,r0,0x0017979c                  #If X coord is valid (< Map Max X) /Else branch to next loop iteration
00179708: 00000000 nop                                       |
0017970c: 3c02800e lui r2,0x800e                             |r2 = 0x800e0000
00179710: 90424ea0 lbu r2,0x4ea0(r2)                         |r2 = Map Max Y
00179714: 00000000 nop                                       |
00179718: 00e2102a slt r2,r7,r2                              |r2 = 0x01 if r7 < Map Max Y
0017971c: 1040001f beq r2,r0,0x0017979c                      #If Y coord is valid (< Map Max Y)
00179720: 00e30018 mult r7,r3                                    |Y coord * Max X
00179724: 00001012 mflo r2                                       |r2 = Y coord * Max X
00179728: 00481021 addu r2,r2,r8                                 |r2 =(Y * Max X) + X = Tile ID (with elevation 0)
0017972c: 00021880 sll r3,r2,0x02                                |r3 = Tile ID * 4
00179730: 00621821 addu r3,r3,r2                                 |r3 = Tile ID * 5 (offset of panel data in targetable grid)
00179734: 3c028019 lui r2,0x8019                                 |
00179738: 24422dd8 addiu r2,r2,0x2dd8                            |r2 = 0x80192dd8
0017973c: 00623021 addu r6,r3,r2                                 |r6 = Targetable grid panel data pointer
00179740: 90c20000 lbu r2,0x0000(r6)                             |r2 = AoE from this panel
00179744: 00000000 nop                                           |
00179748: 004c102a slt r2,r2,r12                                 |r2 =0x01 if AoE is < origin panel AoE
0017974c: 10400013 beq r2,r0,0x0017979c                          #if AoE is < Origin Panel AoE (AoE spread out, this is for not overwriting data toward the center of large AoE) /Else next loop iteration
00179750: 00000000 nop                                               |
00179754: a0cd0000 sb r13,0x0000(r6)                                 |Store AoE = Origin AoE - 1
00179758: 3c02800e lui r2,0x800e                                     |r2 = 0x800e
0017975c: 90424e9c lbu r2,0x4e9c(r2)                                 |r2 = Map Max X
00179760: 00000000 nop                                               |
00179764: 00e20018 mult r7,r2                                        |Y coord * Max X
00179768: 25020100 addiu r2,r8,0x0100                                |r2 =  X coord+ 0x100 (higher elevation offset)
0017976c: 00001812 mflo r3                                           |r3 = Y coord * Max X
00179770: 00621821 addu r3,r3,r2                                     |r3 = (Y coord * Max X) + X coord+ 0x100 = Tile ID (with elevation 1)
00179774: 00031080 sll r2,r3,0x02                                    |Higher Tile ID * 4
00179778: 00431021 addu r2,r2,r3                                     |Higher Tile ID * 5 (offset of panel data in targetable grid)
0017977c: 3c018019 lui r1,0x8019                                     |r1 = 0x80190000
00179780: 00220821 addu r1,r1,r2                                     |r1 = 0x80190000 + offset of panel data in targetable grid
00179784: a02d2dd8 sb r13,0x2dd8(r1)                                 |Store AoE = Origin AoE - 1
00179788: 29820003 slti r2,r12,0x0003                                |r2 = 0x01 if Origin AoE is < 0x03
0017978c: 14400003 bne r2,r0,0x0017979c                              #If Origin AoE is > 0x02 /Else AoE has ended spreading
00179790: 00000000 nop                                                   |
00179794: a0cf0001 sb r15,0x0001(r6)                                     |Store lower panel Targeted Flag = 0x01
00179798: 340e0001 ori r14,r0,0x0001                                     |r14 = 0x01 (will be returned, AoE is not ended yet)
0017979c: 25290001 addiu r9,r9,0x0001            |Counter +1
001797a0: 29220004 slti r2,r9,0x0004             |r2 = 0x01 while r9 < 0x04
001797a4: 1440ffb4 bne r2,r0,0x00179678     Λ LOOP while counter < 0x04
001797a8: 00000000 nop                      |
001797ac: 03e00008 jr r31                   |
001797b0: 01c01021 addu r2,r14,r0           |r2 = 0x01 (not ended) or 0x00 (ended)

Notes

Loop 4 times (4 surrounding tiles)
The first part seems messy, and check the loop counter, then determine X and Y offset arround the original tile
Second part check if the surrounding tiles are valid (in the map)
If Tile is in the map, the AoE (- 0x01) will be stored in the panel 0x00 byte (lower and higher elevation)

If Aoe is not finished, the target flag of the panel (panel 0x01) will be set to 0x01 and r2 will be set to 0x01
If AoE is finished, r2 is set to 0x00

Return location

001795cc: Calculate_Tiles_Hit_by_Ability