Spread Horizontal Jump

From Final Fantasy Hacktics Wiki
Revision as of 19:40, 30 May 2023 by Orkney (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
BATTLE.BIN : Spread Horizontal Jump
----------------------------------------------------------------
Parameters : Nothing   
Returns  : Nothing

Spread Move around an Origin Tile. Uses Acting Unit Jump/2 as a range to reach some
additionnal Tiles.
------------------------------------------------------------------------------------------------------------
001764d8: 27bdffc8 addiu r29,r29,-0x0038    |
001764dc: afb40030 sw r20,0x0030(r29)       |
001764e0: 3c148019 lui r20,0x8019           |
001764e4: 8e94f4e0 lw r20,-0x0b20(r20)      |Pointer to Scratch Pad (0x1f800000)
001764e8: afb10024 sw r17,0x0024(r29)       |
001764ec: 3c118019 lui r17,0x8019           |
001764f0: 8e31f4e4 lw r17,-0x0b1c(r17)      |Pointer to Scratch Pad (0x1f800180)
001764f4: afbf0034 sw r31,0x0034(r29)       |
001764f8: afb3002c sw r19,0x002c(r29)       |
001764fc: afb20028 sw r18,0x0028(r29)       |
00176500: 0c05d56a jal 0x001755a8           |-->Transfer_Tiles_Height_Halves_and_Slope_in_Scratch_Pad Origin Tile
00176504: afb00020 sw r16,0x0020(r29)       |
00176508: 92220054 lbu r2,0x0054(r17)       |Spread Counter
0017650c: 00000000 nop                      |
00176510: 1840005f blez r2,0x00176690       #If Invalid :  Exit routine
00176514: 00009821 addu r19,r0,r0               |
00176518: 2a620004 slti r2,r19,0x0004           |
                                            @LOOP - 8 Times (Each direction - From Tile  and From Above Unit)
0017651c: 38420001 xori r2,r2,0x0001            |Tile Path / Unit Path flag  0x00 Until counter = 4 then 0x01
00176520: a2220040 sb r2,0x0040(r17)            |Store Tile/Unit Path Flag
00176524: 06610002 bgez r19,0x00176530          #If Counter < 0x00
00176528: 02601021 addu r2,r19,r0                   |
0017652c: 26620003 addiu r2,r19,0x0003              |Counter + 3
00176530: 00021083 sra r2,r2,0x02               |Counter/4
00176534: 00021080 sll r2,r2,0x02               |
00176538: 02621023 subu r2,r19,r2               |
0017653c: 00021080 sll r2,r2,0x02               |Counter Word Offset 
00176540: 3c018019 lui r1,0x8019                |
00176544: 00220821 addu r1,r1,r2                |
00176548: 8c22f500 lw r2,-0x0b00(r1)            |Load Routine Address (based on direction)
0017654c: 00000000 nop                          |
00176550: 0040f809 jalr r2,r31                  |-->Jal to spreading routine Set value at 3a 3c 44 45 in S-Pad 0x180
00176554: 00000000 nop                          |
00176558: 0c05d59f jal 0x0017567c               |-->Set Origin Height data returns r2 = 0 or 4 (Grid AoE tile)
0017655c: 02602021 addu r4,r19,r0               |Send Counter
00176560: 14400046 bne r2,r0,0x0017667c         #If There is no AoE to spread  Go to next iteration
00176564: 00000000 nop                              |
00176568: 0c05d57a jal 0x001755e8               |-->Set_spreading_Tile_X_and_Y_coordinates
0017656c: 34120001 ori r18,r0,0x0001            |
00176570: 92820005 lbu r2,0x0005(r20)           |Acting Unit Jump/2
00176574: 00000000 nop                          |
00176578: 10400040 beq r2,r0,0x0017667c         #If Acting Unit Jump = 0x00  Go to next iteration
0017657c: 00000000 nop                              |
                                                @LOOP - 1 time per Jump range 
00176580: 8e220010 lw r2,0x0010(r17)                |Pointer : Origin Tile Grid data
00176584: 00000000 nop                              |
00176588: 90420000 lbu r2,0x0000(r2)                |Origin AoE of Moves
0017658c: 00000000 nop                              |
00176590: 00521023 subu r2,r2,r18                   |AoE - Jump Counter
00176594: a6220024 sh r2,0x0024(r17)                |Store Decreased move's AoE
00176598: 00021400 sll r2,r2,0x10                   |
0017659c: 00021403 sra r2,r2,0x10                   |
001765a0: 28420002 slti r2,r2,0x0002                |
001765a4: 14400035 bne r2,r0,0x0017667c             #If Remaining AoE >=2
001765a8: 00000000 nop                                  |
001765ac: 0c05d586 jal 0x00175618                       |-->Check_Spreading_Tile_Coordinates
001765b0: 00000000 nop                                  |
001765b4: 14400031 bne r2,r0,0x0017667c                 #If Destination Coordinate are valid
001765b8: 00000000 nop                                      |
001765bc: 86230032 lh r3,0x0032(r17)                        |Destination Y
001765c0: 92820018 lbu r2,0x0018(r20)                       |Map Max X
001765c4: 00000000 nop                                      |
001765c8: 00620018 mult r3,r2                               |
001765cc: 92250044 lbu r5,0x0044(r17)                       |Origin Exit Side Slope Mod (Jal)
001765d0: 92260045 lbu r6,0x0045(r17)                       |Destination Entry Side Slope Mod
001765d4: 92270048 lbu r7,0x0048(r17)                       |Origin Exit Side Height
001765d8: 86220030 lh r2,0x0030(r17)                        |Destination X
001765dc: 00002012 mflo r4                                  |Max X * Destination Y
001765e0: 0c05d88b jal 0x0017622c                           |-->Check_Horizontal_Jump_option returns r2 = 0x00 if Unit can Jump
001765e4: 00822021 addu r4,r4,r2                            |Destination Tile ID (without elevation)
001765e8: 14400024 bne r2,r0,0x0017667c                     #If Cannot Jump in that direction  Go to next iteration
001765ec: 26430001 addiu r3,r18,0x0001                          |
001765f0: 8622003a lh r2,0x003a(r17)                        |Destination X direction
001765f4: 00000000 nop                                      |
001765f8: 00430018 mult r2,r3                               |
001765fc: 00002012 mflo r4                                  |X direction * Jump counter
00176600: 8622003c lh r2,0x003c(r17)                        |Destination Y direction
00176604: 00000000 nop                                      |
00176608: 00430018 mult r2,r3                               |
0017660c: 96220026 lhu r2,0x0026(r17)                       |X coordinates
00176610: 00000000 nop                                      |
00176614: 00441021 addu r2,r2,r4                            |X coordinates + Jump Mod
00176618: a6220030 sh r2,0x0030(r17)                        |Potential Jump destination X coordinates
0017661c: 96220028 lhu r2,0x0028(r17)                       |
00176620: 00001812 mflo r3                                  |Y direction * Jump counter
00176624: 00431021 addu r2,r2,r3                            |Y coordinates + Jump Mod
00176628: 0c05d586 jal 0x00175618                           |-->Check_Spreading_Tile_Coordinates
0017662c: a6220032 sh r2,0x0032(r17)                        |Potential Jump destination Y coordinates
00176630: 14400012 bne r2,r0,0x0017667c                     #If destination coordinates are valid
00176634: 00000000 nop                                          |
00176638: 92220055 lbu r2,0x0055(r17)                           |Load 2nd loop counter
0017663c: 00000000 nop                                          |
00176640: 18400009 blez r2,0x00176668                           #If this counter is invalid   Go to next iteration
00176644: 00008021 addu r16,r0,r0                                   |
00176648: 02002021 addu r4,r16,r0                               |
                                                                @LOOP 4 Times
0017664c: 0c05d656 jal 0x00175958                                   |-->Movement_routine Enable Flag on Jumpable Tiles (4 directions both elevation)
00176650: 02402821 addu r5,r18,r0                                   |
00176654: 92220055 lbu r2,0x0055(r17)                               |2nd loop counter
00176658: 26100001 addiu r16,r16,0x0001                             |Counter +1
0017665c: 0202102a slt r2,r16,r2                                    |
00176660: 1440fffa bne r2,r0,0x0017664c                         Λ Loop
00176664: 02002021 addu r4,r16,r0                                   |
00176668: 92820005 lbu r2,0x0005(r20)               |Acting Unit Jump/2
0017666c: 26520001 addiu r18,r18,0x0001             |Counter + 1
00176670: 0052102a slt r2,r2,r18                    |
00176674: 1040ffc2 beq r2,r0,0x00176580         Λ Loop While counter < Acting Unit Jump/2
00176678: 00000000 nop                              |
0017667c: 92220054 lbu r2,0x0054(r17)           |Loop counter
00176680: 26730001 addiu r19,r19,0x0001         |Counter + 1
00176684: 0262102a slt r2,r19,r2                |
00176688: 1440ffa4 bne r2,r0,0x0017651c     Λ Loop while counter < ScratchPad counter
0017668c: 2a620004 slti r2,r19,0x0004           |
00176690: 8fbf0034 lw r31,0x0034(r29)       END
00176694: 8fb40030 lw r20,0x0030(r29)
00176698: 8fb3002c lw r19,0x002c(r29)
0017669c: 8fb20028 lw r18,0x0028(r29)
001766a0: 8fb10024 lw r17,0x0024(r29)
001766a4: 8fb00020 lw r16,0x0020(r29)
001766a8: 27bd0038 addiu r29,r29,0x0038
001766ac: 03e00008 jr r31
001766b0: 00000000 nop

Notes

Table of Spreading routines - 8018f500 
   0x00 - 801754d0 Spread_Move_to_East_Preset
   0x04 - 801754f4 Spread_Move_to_North_Preset
   0x08 - 8017551c Spread_Move_to_West_Preset
   0x0c - 80175540 Spread_Move_to_South_Preset

Return Location

BATTLE.BIN
00174d24: 00174b8c_-_00174df4
00178804: Calculate_Pathing