Check Vert Tolerance and if Tiles can be Chosen

From Final Fantasy Hacktics Wiki
Revision as of 20:23, 8 February 2022 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
001792a4 - 001793fc

Parameters : r4 = Target Tile Height (height * 2 + halves + depht *2)
             r5 = Ability vetical tolerance (Vertical in pacher)
             r6 = 0x01 if Ability has the top-down flag
 
Nullify some targetable panels AoE flag and targetd flag is they don't match the ability vertical tolerance.
If both elevation are in the AoE, the nearest tile only will be checked (the other one is "discarded")
-----------------------------------------------------------------------------------------------------------
001792a4: 30a500ff andi r5,r5,0x00ff        |r5 = Ability Vertical
001792a8: 00052840 sll r5,r5,0x01           |r5 = Ability Vertical * 2
001792ac: 308a00ff andi r10,r4,0x00ff       |r10 = Origin Height
001792b0: 00005821 addu r11,r0,r0           |r11 = 0x00
001792b4: 3c0e8019 lui r14,0x8019           |r4 = 0x80190000
001792b8: 25cef8cc addiu r14,r14,-0x0734    |r14 = Tile Data Pointer  ( 0x8018f8cc )
001792bc: 3c098019 lui r9,0x8019            |r9 = 0x80190000
001792c0: 25292dd8 addiu r9,r9,0x2dd8       |r9 = 0x80192dd8 (Targetable panel grid data pointer)
001792c4: 01207821 addu r15,r9,r0           |r15 = Targetable panel grid data pointer
001792c8: 340d0500 ori r13,r0,0x0500        |r13 = 0x500 (offset of higher elevation tile in Targetable panel grid)
001792cc: 340c0800 ori r12,r0,0x0800        |r12 = 0x800 (offset of higher elevation tile in Tiles data)
001792d0: 000b10c0 sll r2,r11,0x03          @LOOP r2 = Counter * 8 (size of tiles data)
001792d4: 004e1821 addu r3,r2,r14                |r3 = This iteration Tile data pointer
001792d8: 90620006 lbu r2,0x0006(r3)             |r2 = Tile [0x06] byte
001792dc: 00000000 nop                           |
001792e0: 30420001 andi r2,r2,0x0001             |r2 = 0x01 if Tile is unselectable
001792e4: 1440000a bne r2,r0,0x00179310          #If this Tile is selectable
001792e8: 2407ff01 addiu r7,r0,-0x00ff           |r7 = -0x00ff
001792ec: 90640002 lbu r4,0x0002(r3)                 |r4 = Tile Height
001792f0: 90630003 lbu r3,0x0003(r3)                 |r3 = Tile depht + halves
001792f4: 00042040 sll r4,r4,0x01                    |r4 = Tile Height*2
001792f8: 3062001f andi r2,r3,0x001f                 |r2 = Tile halves
001792fc: 00822021 addu r4,r4,r2                     |r4 = Tile's (Height*2 + halves)
00179300: 00031942 srl r3,r3,0x05                    |r3 = Tile effective depht
00179304: 00031840 sll r3,r3,0x01                    |r3 = Tile effective depht *2
00179308: 0805e4c6 j 0x00179318                      >>jump avoiding nullification section
0017930c: 00833821 addu r7,r4,r3                     |r7 = Tile's total height
00179310: a1200000 sb r0,0x0000(r9)              #Else (unselectable tile) Store This iteration Targetable panel AoE = 0x00
00179314: a1200001 sb r0,0x0001(r9)                  |Store This iteration Targetable panel targeted flag = 0x00
00179318: 018e1821 addu r3,r12,r14               |r3 = This iteration Higher elevation Tile data pointer
0017931c: 90620006 lbu r2,0x0006(r3)             |r2 = Higher elevatio Tile [0x06] byte
00179320: 00000000 nop                           |
00179324: 30420001 andi r2,r2,0x0001             |r2 = 0x01 if Tile is unselectable
00179328: 1440000a bne r2,r0,0x00179354          #If higher Tile is selectable
0017932c: 01af4021 addu r8,r13,r15               |r8 = Higher Elevation targetable panel Pointer
00179330: 90640002 lbu r4,0x0002(r3)                 |r4 = Higher Tile Height
00179334: 90630003 lbu r3,0x0003(r3)                 |r3 = Higher Tile depht + halves
00179338: 00042040 sll r4,r4,0x01                    |r4 = Higher Tile Height*2
0017933c: 3062001f andi r2,r3,0x001f                 |r2 = Higher Tile halves
00179340: 00822021 addu r4,r4,r2                     |r4 = Higher Tile's (Height*2 + halves)
00179344: 00031942 srl r3,r3,0x05                    |r3 = Higher Tile effective depht
00179348: 00031840 sll r3,r3,0x01                    |r3 = Higher Tile effective depht *2
0017934c: 0805e4d8 j 0x00179360                      >>jump avoiding nullification section
00179350: 00832021 addu r4,r4,r3                     |r4 = Higher Tile total height
00179354: 2404ff01 addiu r4,r0,0xff01            #Else (unselectable tile) r4 = -0x00ff
00179358: a1000000 sb r0,0x0000(r8)                  |Store Higher Targetable panel AoE = 0x00
0017935c: a1000001 sb r0,0x0001(r8)                  |Store Higher Targetable panel targeted flag = 0x00
00179360: 10c00006 beq r6,r0,0x0017937c          #If Used Ability has the Top-Down flag ON
00179364: 00e4102a slt r2,r7,r4                  |r2 = 0x01 if lower Tile height < Higher elevation height (?? Only true if there is no elevated tile ?)
00179368: 14400003 bne r2,r0,0x00179378              #If There's no elevated tile 
0017936c: 00000000 nop                                   |(basically target from top down)
00179370: 0805e4df j 0x0017937c                          >>jump keeping low tile height unchanged disqualify  higher elevation tile height (redundant ?)
00179374: 2404ff01 addiu r4,r0,-0x00ff                   |r4 = -0x00ff
00179378: 2407ff01 addiu r7,r0,0xff01                #Else (There's an elevated tile) r7 = -0x00ff (disqualify lower tile for vertical tolerance) (keep r4 unchanged)
0017937c: 00ea102a slt r2,r7,r10                 |r2 = 0x01 if Lower tile Height < Origin Height
00179380: 14400002 bne r2,r0,0x0017938c          #If Low Height > Origin Height /Else  Branch with r3 > 0x00
00179384: 01471823 subu r3,r10,r7                |r3 = Delta Height (Origin - This tile height)
00179388: 00ea1823 subu r3,r7,r10                    |r3 = Delta Height (This Tile - Origin)
0017938c: 008a102a slt r2,r4,r10                 |r2 = 0x01 if Higher elevation tile < Origin Height
00179390: 14400003 bne r2,r0,0x001793a0          #if Higher elevation tile > origin height
00179394: 00000000 nop                               | 
00179398: 0805e4e9 j 0x001793a4                      >>jump after delta height section
0017939c: 008a2023 subu r4,r4,r10                    |r4 = Higher Delta Height (Higher Tile - Origin Tile)
001793a0: 01442023 subu r4,r10,r4                #Else r4 =Higher Height ( Origin Tile - higher tile)
001793a4: 0083102a slt r2,r4,r3                  |r2 = 0x01 if Higher Delta height  < Delta Height
001793a8: 10400007 beq r2,r0,0x001793c8          #if Higher Delta height  < Delta Height
001793ac: 00a4102a slt r2,r5,r4                      |r2 = 0x01 if Vertical Tolerance < Higher delta height
001793b0: a1200000 sb r0,0x0000(r9)                  |Nullify AoE of This iteration lower panel
001793b4: 1040000a beq r2,r0,0x001793e0              #If Vertical Tolerance < Higher delta height #\Else branch to next iteration keeping flag and Aoe
001793b8: a1200001 sb r0,0x0001(r9)                  |Nullify this iteration lower panel "targeted" flag
001793bc: a1000000 sb r0,0x0000(r8)                      |Nullify this iteration higher panel AoE
001793c0: 0805e4f8 j 0x001793e0                          >>Jump to next tile
001793c4: a1000001 sb r0,0x0001(r8)                      |Nullify this iteration higher panel "targeted" flag
001793c8: 00a3102a slt r2,r5,r3                  #Else (Lower delta height < higher one) r2 = 0x01 if vertical tolerance < delta height
001793cc: a1000000 sb r0,0x0000(r8)                  |Nullify this iteration higher panel AoE
001793d0: 10400003 beq r2,r0,0x001793e0              #If Vertical Tolerance < lower delta height #\Else branch to next iteration keeping flag and Aoe
001793d4: a1000001 sb r0,0x0001(r8)                  |Nullify this iteration higher panel "targeted" flag
001793d8: a1200000 sb r0,0x0000(r9)                      |Nullify AoE of This iteration lower panel
001793dc: a1200001 sb r0,0x0001(r9)                      |Nullify this iteration lower panel "targeted" flag
001793e0: 25290005 addiu r9,r9,0x0005            |r9 = Lower Panel data pointer + 5 (5 is the size of panel data)
001793e4: 25ad0005 addiu r13,r13,0x0005          |r13 = Higher Panel data pointer + 5
001793e8: 256b0001 addiu r11,r11,0x0001          |r11 = tile counter +1
001793ec: 29620100 slti r2,r11,0x0100            |r2 = 0x01 if Tile counter < 0x100 (all lower elevation tiles)
001793f0: 1440ffb7 bne r2,r0,0x001792d0     Λ Loop until tile 0x100
001793f4: 258c0008 addiu r12,r12,0x0008          |r12 = Higher elevation tile pointer + 0x08 (size of tile data)
001793f8: 03e00008 jr r31                        
001793fc: 00000000 nop

Notes

In thoses notes Tile refers to data stored at 0x8018f8cc, panel refers to data stored at 0x80192dd8

Loop through all XY coordinates (0x100 iteration), lower and higher elevation Tiles are checked in each iteration.
The flags of lower and higher targetable panels are nullified if necessary (matching the tile ID during each iteration)
 
- Check if tile is selectable (via Tile [0x06] byte), if not matching panel AoE and targeted flags are nullified
- If the ability has the top down flag, and the higher elevation tile is selectable, the lower panel is nullified
- Check the Height distance between lower and higher elevation tiles and the targeted tile, discard the more distant one
- Check of Height distance is greater than vertical tolerance, if so, nullify AoE and Targeted flag of the panel
 

Return locations

Battle.bin
0017a480: Set_panels_affected_by_ability?
0017baf0: Targeting_routine