Set Origin Height Data

From Final Fantasy Hacktics Wiki
Revision as of 10:54, 3 June 2023 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BATTLE.BIN : Set Origin Height Data
---------------------------------------------------------------------------------------------------------
Parameters : r4 - Preset value (some loop counter from previous routine) 
                   0x0 to 0x3 : Tile Path Height (4 directions) 
                   0x4 to 0x7 : Check Unit Path (if any)
                   Above 0x8 (until 0x24 when Acting Unit stop riding) - seems to increment height above unit (?)

Returns  : r2 = 0x00 if AoE of move is not finsihed
           r2 = 0x04 if AoE ended
           r2 = 0x01 when ? (Above 8 section)

Multiple Height Check to finaly set some Origin height data in S-Pad 0x180
(0x48 0x49 0x36 0x46 0x1d 0x10)
------------------------------------------------------------------------------------------------------------
0017567c: 27bdffe0 addiu r29,r29,-0x0020    |
00175680: afb20018 sw r18,0x0018(r29)       |
00175684: 3c128019 lui r18,0x8019           |
00175688: 8e52f4e0 lw r18,-0x0b20(r18)      |Pointer to scratch pad 0x1f800000
0017568c: afb10014 sw r17,0x0014(r29)       |
00175690: 3c118019 lui r17,0x8019           |
00175694: 8e31f4f0 lw r17,-0x0b10(r17)      |Pointer to Scratch Pad 0x1f800200
00175698: afb00010 sw r16,0x0010(r29)       |
0017569c: 3c108019 lui r16,0x8019           |
001756a0: 8e10f4e4 lw r16,-0x0b1c(r16)      |Pointer to Scratch Pad 0x1f800180
001756a4: 3c058019 lui r5,0x8019            |
001756a8: 8ca5f4e8 lw r5,-0x0b18(r5)        |Pointer to scratch pad 0x1f800080
001756ac: 28830008 slti r3,r4,0x0008        |
001756b0: 10600005 beq r3,r0,0x001756c8     #If Counter < 8
001756b4: afbf001c sw r31,0x001c(r29)           |
001756b8: 92020040 lbu r2,0x0040(r16)           |Load Tile/Unit Path flag
001756bc: 00000000 nop                          |
001756c0: 1040004a beq r2,r0,0x001757ec         #If Path flag = 0 then branch to   Tile section
001756c4: 00000000 nop                              |
001756c8: 8e020008 lw r2,0x0008(r16)        |Pointer : Tile's data in Targetable grid table 80192dd8
001756cc: 00000000 nop                      |
001756d0: 90420002 lbu r2,0x0002(r2)        |Unit ID on Tile
001756d4: 14600020 bne r3,r0,0x00175758     #If Value is between 4 and 7 Branch to  Unit section
001756d8: a2020041 sb r2,0x0041(r16)        |Store Unit ID 
                                        8 or Above
001756dc: 92030041 lbu r3,0x0041(r16)       |Unit ID
001756e0: 00000000 nop                      |
001756e4: 000310c0 sll r2,r3,0x03           |
001756e8: 00431023 subu r2,r2,r3            |Unit ID * 7
001756ec: 04810002 bgez r4,0x001756f8       #If Preset value < 0x00
001756f0: 00452821 addu r5,r2,r5            |Pointer to Unit data in S-Pad 0x80
001756f4: 24840003 addiu r4,r4,0x0003           |Value +3
001756f8: 92020058 lbu r2,0x0058(r16)       |Load Slope Type
001756fc: 92030044 lbu r3,0x0044(r16)       |Load Origin Slope Mod
00175700: 00000000 nop                      |
00175704: 00621007 srav r2,r2,r3            |Side slope
00175708: 92030056 lbu r3,0x0056(r16)       |Load Tile's Halves
0017570c: 30420003 andi r2,r2,0x0003        |
00175710: 00620018 mult r3,r2               |
00175714: 90a20005 lbu r2,0x0005(r5)        |Unit Height
00175718: 00041883 sra r3,r4,0x02           |Preset Value / 4
0017571c: 00431021 addu r2,r2,r3            |Unit Total Height + Preset Value/4
00175720: 2442fffe addiu r2,r2,-0x0002      |
00175724: a2020048 sb r2,0x0048(r16)        |Store Unit Height + PV/4 - 2
00175728: 9202004c lbu r2,0x004c(r16)       |Load Origin's Height*2
0017572c: 00001812 mflo r3                  |Slope Type * Halves
00175730: 00431021 addu r2,r2,r3            |
00175734: a2020050 sb r2,0x0050(r16)        |Store Origin exit side's Height
00175738: 92020048 lbu r2,0x0048(r16)       |Load Unit Total Height
0017573c: 92030050 lbu r3,0x0050(r16)       |Load Tile's Size height
00175740: 00000000 nop                      |
00175744: 0043102b sltu r2,r2,r3            |
00175748: 10400013 beq r2,r0,0x00175798     #If Unit Height + PV mod > Origin Exit Size  Branch in section below
0017574c: 34020001 ori r2,r0,0x0001             |
00175750: 0805d64f j 0x0017593c             >>If not Returns 0x1
00175754: 00000000 nop                      |
                                        --- Above Unit Path (Counter 4 to 7) ---
00175758: 8602001a lh r2,0x001a(r16)        |Load Tile ID
0017575c: 00000000 nop                      |
00175760: 02221021 addu r2,r17,r2           |Tile's data pointer in S-Pad 0x200
00175764: 90420000 lbu r2,0x0000(r2)        |Load Tile's flags
00175768: 00000000 nop                      |
0017576c: 30420008 andi r2,r2,0x0008        |Check 0x08 (Fly - Ally with stepping stone)
00175770: 10400072 beq r2,r0,0x0017593c     #If Flag 0x08 is ON Else returns 0x2
00175774: 34020002 ori r2,r0,0x0002         |0x2
00175778: 92020041 lbu r2,0x0041(r16)           |Load Unit ID
0017577c: 00000000 nop                          |
00175780: 000218c0 sll r3,r2,0x03               |ID*8
00175784: 00621823 subu r3,r3,r2                |ID*7
00175788: 00651821 addu r3,r3,r5                |Pointer to Unit data in S-Pad 0x80
0017578c: 90620006 lbu r2,0x0006(r3)            |Tile Height + unit Size
00175790: 00000000 nop                          |
00175794: a2020048 sb r2,0x0048(r16)            |Store Height + Size
                                        --- > 8 Section Branch here ---
00175798: 86040026 lh r4,0x0026(r16)            |Tile's X Coord (for Jal)
0017579c: 86050028 lh r5,0x0028(r16)            |Tile's Y Coord (for Jal)
001757a0: 92060044 lbu r6,0x0044(r16)           |Exit Side slope mod (for Jal)
001757a4: 92070048 lbu r7,0x0048(r16)           |Height + Size (for Jal)
001757a8: 92020048 lbu r2,0x0048(r16)           |Height + Size
001757ac: a6000036 sh r0,0x0036(r16)            |Reset 0x36
001757b0: 24e7ffff addiu r7,r7,-0x0001          |Height - 1
001757b4: 30e700ff andi r7,r7,0x00ff            |Byte only
001757b8: 0c05d859 jal 0x00176164               |-->Calculate_Tile_Ceiling returns r2 = Ceiling height or 0x7f (Height from unit head here)
001757bc: a2020049 sb r2,0x0049(r16)            |Store Height + Size
001757c0: 92030041 lbu r3,0x0041(r16)           |Unit ID
001757c4: a2020046 sb r2,0x0046(r16)            |Store Ceiling Height
001757c8: 24630200 addiu r3,r3,0x0200           |Unit ID + 0x200
001757cc: 00031080 sll r2,r3,0x02               |
001757d0: 00431021 addu r2,r2,r3                |Pointer to Unit data in Post-Grid Table  801937d8
001757d4: a603001e sh r3,0x001e(r16)            |Unit Offset in Post-Grid Table
001757d8: 3c038019 lui r3,0x8019                |
001757dc: 24632dd8 addiu r3,r3,0x2dd8           |Start of Targetable grid data
001757e0: 00431021 addu r2,r2,r3                |Unit Data (Offset 0x05) at 801937d8
001757e4: 0805d649 j 0x00175924                 >>End section
001757e8: ae020010 sw r2,0x0010(r16)            |Store pointer
                                        ---- Tile Section ---
001757ec: 92020058 lbu r2,0x0058(r16)           |Load Tile's Slope Type
001757f0: 92030044 lbu r3,0x0044(r16)           |Load Exit Side Slope Mod
001757f4: 00000000 nop                          |
001757f8: 00621007 srav r2,r2,r3                |
001757fc: 92030056 lbu r3,0x0056(r16)           |Load Tile's Halves
00175800: 30420003 andi r2,r2,0x0003            |Exit Side Slope mod
00175804: 00620018 mult r3,r2                   |
00175808: 92020058 lbu r2,0x0058(r16)           |Slope Type
0017580c: 92030045 lbu r3,0x0045(r16)           |Opposite Side Slope Mod
00175810: 00000000 nop                          |
00175814: 00621007 srav r2,r2,r3                |
00175818: 00003812 mflo r7                      |Exit Side slope mod * Halves
0017581c: 92030056 lbu r3,0x0056(r16)           |Tile's Halves
00175820: 30420003 andi r2,r2,0x0003            |
00175824: 00620018 mult r3,r2                   |
00175828: 86040026 lh r4,0x0026(r16)            |X Coord (for Jal)
0017582c: 86050028 lh r5,0x0028(r16)            |Y Coord  (for Jal)
00175830: 9202004c lbu r2,0x004c(r16)           |Tile's Height*2
00175834: 92060044 lbu r6,0x0044(r16)           |Exit Side Slope Mod (for Jal)
00175838: 00471021 addu r2,r2,r7                |
0017583c: a2020048 sb r2,0x0048(r16)            |Store Exit Side Height  Height * 2 + Halve * Exit Side slope mod (0,1 or 2)
00175840: 9202004c lbu r2,0x004c(r16)           |Tile's Height*2
00175844: 00001812 mflo r3                      |Opposite Side slope mod * Halves
00175848: 00431021 addu r2,r2,r3                |Opposite Side Height
0017584c: a2020049 sb r2,0x0049(r16)            |Store Opposite Side Height
00175850: 92020048 lbu r2,0x0048(r16)           |Exit Side Height
00175854: 92030049 lbu r3,0x0049(r16)           |Opposite Side Height
00175858: 92070048 lbu r7,0x0048(r16)           |Exit Side Height (for Jal)
0017585c: 00431023 subu r2,r2,r3                |Delta Height (2 Side)
00175860: 0c05d859 jal 0x00176164               |-->Calculate_Tile_Ceiling returns r2 = Ceiling height or 0x7f
00175864: a6020036 sh r2,0x0036(r16)            |Store Height diffences (of the 2 sides)
00175868: 86030036 lh r3,0x0036(r16)            |Load delta Height
0017586c: 00000000 nop                          |
00175870: 04600009 bltz r3,0x00175898           #If Delta height is Valid
00175874: a2020046 sb r2,0x0046(r16)            |Store ceiling height
00175878: 8602001a lh r2,0x001a(r16)                |Load Tile ID
0017587c: 00000000 nop                              |
00175880: 02221021 addu r2,r17,r2                   |Pointer to Tile S-Pad 0x200
00175884: 90420000 lbu r2,0x0000(r2)                |Load Flags
00175888: 00000000 nop                              |
0017588c: 30420040 andi r2,r2,0x0040                |Check Unwalkable
00175890: 1440002a bne r2,r0,0x0017593c             #If Tile is unWalkable (0x40 if ON) :   Exit and returns 0x03
00175894: 34020003 ori r2,r0,0x0003                     |
00175898: 8e030000 lw r3,0x0000(r16)            |Load Tile's data pointer ( 8019f8cc Table)
0017589c: 00000000 nop                          |
001758a0: 90620003 lbu r2,0x0003(r3)            |Halve + Depth
001758a4: 00000000 nop                          |
001758a8: 304200e0 andi r2,r2,0x00e0            |Depth only
001758ac: 10400012 beq r2,r0,0x001758f8         #If depht > 0x00
001758b0: 00000000 nop                              |
001758b4: 9242001c lbu r2,0x001c(r18)               |Load Unit's Movement 3
001758b8: 00000000 nop                              |
001758bc: 304200c0 andi r2,r2,0x00c0                |Check on/in Water
001758c0: 1040000d beq r2,r0,0x001758f8             #If Unit Can walk on/in water
001758c4: 00000000 nop                                  |
001758c8: 90620003 lbu r2,0x0003(r3)                    |Halve + Depth
001758cc: 92030048 lbu r3,0x0048(r16)                   |Exit Side Height
001758d0: 00021142 srl r2,r2,0x05                       |Depht only
001758d4: 00021040 sll r2,r2,0x01                       |Depht * 2
001758d8: 00621821 addu r3,r3,r2                        |
001758dc: a2030048 sb r3,0x0048(r16)                    |Add Depth*2 to Exit side height
001758e0: 9242001c lbu r2,0x001c(r18)                   |Load Unit's Movement 3
001758e4: 00000000 nop                                  |
001758e8: 30420040 andi r2,r2,0x0040                    |
001758ec: 10400002 beq r2,r0,0x001758f8                 #If Unit Uses Move in Water
001758f0: 246200fe addiu r2,r3,-0x0002                      |Path Heght - 2
001758f4: a2020048 sb r2,0x0048(r16)                        |Add Depth*2 - 2 to Exit side Height
001758f8: 9602001a lhu r2,0x001a(r16)           |Load Tile ID
001758fc: 00000000 nop                          |
00175900: a602001e sh r2,0x001e(r16)            |Store Tile's ID in 0x1e
00175904: 00021400 sll r2,r2,0x10               |
00175908: 00021403 sra r2,r2,0x10               |
0017590c: 00021880 sll r3,r2,0x02               |Tile ID *4
00175910: 00621821 addu r3,r3,r2                |Tile ID * 5
00175914: 3c028019 lui r2,0x8019                |
00175918: 24422dd8 addiu r2,r2,0x2dd8           |
0017591c: 00621821 addu r3,r3,r2                |Tile Offset in Targetable grid data ( 80192dd8 )
00175920: ae030010 sw r3,0x0010(r16)            |Store pointer
                                        --- End section --
00175924: 8e020010 lw r2,0x0010(r16)        |Load Grid Pointer / Unit post grid pointer
00175928: 00000000 nop                      |
0017592c: 90420000 lbu r2,0x0000(r2)        |Load Tile's AoE data
00175930: 00000000 nop                      |
00175934: 2c420002 sltiu r2,r2,0x0002       |1 if  AoE < 2
00175938: 00021080 sll r2,r2,0x02           |4 if AoE < 2 / Else 0x00
0017593c: 8fbf001c lw r31,0x001c(r29)       END
00175940: 8fb20018 lw r18,0x0018(r29)
00175944: 8fb10014 lw r17,0x0014(r29)
00175948: 8fb00010 lw r16,0x0010(r29)
0017594c: 27bd0020 addiu r29,r29,0x0020
00175950: 03e00008 jr r31
00175954: 00000000 nop

Return Location

BATTLE.BIN
00175f38: Check_and_Spread_Movement_One_Tile_Around
00176560: Spread_Horizontal_Jump