Store movement stuff into scratch pad

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
BATTLE.BIN - Store movement stuff into scratch pad
-----------------------------------------------------------------
Parameters : nothing 

Returns : nothing

Set a lot of data in different scratchpad
0x1f800000 - Acting Unit data
0x1f800080 - Other Units data
0x1f800100 - Movement modifiers 
------------------------------------------------------------------
00174430: 27bdffb0 addiu r29,r29,-0x0050    |
00174434: afbe0048 sw r30,0x0048(r29)       |
00174438: 0080f021 addu r30,r4,r0           |Acting Unit ID (if Riding - ID of his mount)
0017443c: afb30034 sw r19,0x0034(r29)       |
00174440: 3c138019 lui r19,0x8019           |
00174444: 8e73f4e0 lw r19,-0x0b20(r19)      |Pointer to scratch pad at 0x1f800000 - refered as S-Pad 0x00 from 8018f4e0 - Used to store data on acting unit
00174448: 27a40018 addiu r4,r29,0x0018      |
0017444c: afb40038 sw r20,0x0038(r29)       |
00174450: 3c148019 lui r20,0x8019           |
00174454: 8e94f4e8 lw r20,-0x0b18(r20)      |Pointer to scratch pad at 0x1f800080 - refered as S-Pad 0x80  from 8018f4e8 - Used to store All unit data 
00174458: 03c02821 addu r5,r30,r0           |
0017445c: afbf004c sw r31,0x004c(r29)       |
00174460: afb70044 sw r23,0x0044(r29)       |
00174464: afb60040 sw r22,0x0040(r29)       |
00174468: afb5003c sw r21,0x003c(r29)       |
0017446c: afb20030 sw r18,0x0030(r29)       |
00174470: afb1002c sw r17,0x002c(r29)       |
00174474: 0c05f056 jal 0x0017c158           |-->Calculate_Height_Data Returns some coordinates on stack (r4)
00174478: afb00028 sw r16,0x0028(r29)       |
0017447c: 001e10c0 sll r2,r30,0x03          |
00174480: 005e1023 subu r2,r2,r30           |
00174484: 00021180 sll r2,r2,0x06           |
00174488: 3c038019 lui r3,0x8019            |
0017448c: 246308cc addiu r3,r3,0x08cc       |Start of Unit Battle data
00174490: 00438821 addu r17,r2,r3           |Acting Unit Battle data pointer
00174494: 00009021 addu r18,r0,r0           |
00174498: 27a30010 addiu r3,r29,0x0010      |Stack 0x10
                                            @LOOP though Acting Unit active movement skills
0017449c: 02321021 addu r2,r17,r18          |Unit Battle data pointer + loop offset
001744a0: 90420093 lbu r2,0x0093(r2)            |Load This iteration movement 
001744a4: 26520001 addiu r18,r18,0x0001         |Counter + 1
001744a8: a0620000 sb r2,0x0000(r3)             |Store Movement on Stack
001744ac: 2a420003 slti r2,r18,0x0003           |
001744b0: 1440fffa bne r2,r0,0x0017449c     Λ Loop 3 times
001744b4: 24630001 addiu r3,r3,0x0001           |Stack Offset (+1)
001744b8: a27e000d sb r30,0x000d(r19)       |store active unit ID
001744bc: 92220047 lbu r2,0x0047(r17)       |load X coordinate
001744c0: 00000000 nop                      |
001744c4: a2620007 sb r2,0x0007(r19)        |Store X
001744c8: 92220048 lbu r2,0x0048(r17)       |load Y coord
001744cc: 00000000 nop                      |
001744d0: a2620008 sb r2,0x0008(r19)        |Store Y
001744d4: 96220048 lhu r2,0x0048(r17)       |load Elevation
001744d8: 00000000 nop                      |
001744dc: 000213c2 srl r2,r2,0x0f           |
001744e0: a2620009 sb r2,0x0009(r19)        |Store Elevation
001744e4: 3c02800e lui r2,0x800e            |
001744e8: 90424e9c lbu r2,0x4e9c(r2)        |Map Max X
001744ec: 00000000 nop                      |
001744f0: a2620018 sb r2,0x0018(r19)        |Store Max X
001744f4: 3c02800e lui r2,0x800e            |
001744f8: 90424ea0 lbu r2,0x4ea0(r2)        |Map Max Y
001744fc: 34030001 ori r3,r0,0x0001         |
00174500: a2600011 sb r0,0x0011(r19)        |Initialize Cannot enter water flag
00174504: a2600014 sb r0,0x0014(r19)        |Initialize Cannot Stay on water flag
00174508: a2630012 sb r3,0x0012(r19)        |Enable Will drown flag
0017450c: a2630013 sb r3,0x0013(r19)        |Enable Will sink flag
00174510: a260001d sb r0,0x001d(r19)        |Initialize Fly/Teleport flag
00174514: a2620019 sb r2,0x0019(r19)        |Store Max Y
00174518: 96220048 lhu r2,0x0048(r17)       |Load Acting Unit Height + Elevation
0017451c: 00000000 nop                      |
00174520: 00021382 srl r2,r2,0x0e           |Shift
00174524: 30420001 andi r2,r2,0x0001        |Check Stepping Stone
00174528: a2620022 sb r2,0x0022(r19)        |Store Acting Unit Stepping stone flag
0017452c: 93a20012 lbu r2,0x0012(r29)       |Load 3rd set of Movement
00174530: 00000000 nop                      |
00174534: 30420028 andi r2,r2,0x0028        |
00174538: 10400003 beq r2,r0,0x00174548     #If Acting Unit uses [Float] or [Move on Lava]
0017453c: 00000000 nop                          |
00174540: 0805d153 j 0x0017454c                 >>Skip flag nullification
00174544: a2630025 sb r3,0x0025(r19)            |Store can Pass Lava flag
                                            Else : Acting Unit do not use Float nor Move on Lava
00174548: a2600025 sb r0,0x0025(r19)            |Nullify scratch pad 0x25
0017454c: 9230005a lbu r16,0x005a(r17)      |Load 3rd set of current status
00174550: 00000000 nop                      |
00174554: 32020006 andi r2,r16,0x0006       |
00174558: 10400008 beq r2,r0,0x0017457c     #If Unit has Frog or Chicken
0017455c: 34020006 ori r2,r0,0x0006         |Default Unit size is 0x6
00174560: 93a20011 lbu r2,0x0011(r29)           |Load 2nd set of Movement
00174564: 93a30012 lbu r3,0x0012(r29)           |Load 3rd set of Movement
00174568: 304200f3 andi r2,r2,0x00f3            |Remove Teleport and Teleport 2
0017456c: 306300fb andi r3,r3,0x00fb            |Remove Fly
00174570: a3a20011 sb r2,0x0011(r29)            |Set Teleport and Teleport2 flags  OFF (on stack)
00174574: 34020004 ori r2,r0,0x0004             |Frog and Chicken Size is 0x4
00174578: a3a30012 sb r3,0x0012(r29)            |Set Fly flag OFF (on Stack)
0017457c: a262001b sb r2,0x001b(r19)        |Store Unit size in Scratch Pad
00174580: 93a20012 lbu r2,0x0012(r29)       |Load 3rd set of Movement
00174584: 00000000 nop                      |
00174588: 30420088 andi r2,r2,0x0088        |Check [Float]and [Walk on water]
0017458c: 14400007 bne r2,r0,0x001745ac     #If Unit will not be above water
00174590: 00000000 nop                          |
00174594: 93a20011 lbu r2,0x0011(r29)           |Load 2nd set of Movement
00174598: 00000000 nop                          |
0017459c: 30420010 andi r2,r2,0x0010            |Check [Can not enter water]
001745a0: 10400002 beq r2,r0,0x001745ac         #If Unit cannot enter water
001745a4: 34020001 ori r2,r0,0x0001                 |
001745a8: a2620014 sb r2,0x0014(r19)                |store cannot Stay on water flag
001745ac: 93a30012 lbu r3,0x0012(r29)       |Load 3rd set of Movement
001745b0: 00000000 nop                      |
001745b4: 30620008 andi r2,r3,0x0008        |Check [Float]
001745b8: 1040000a beq r2,r0,0x001745e4     #If Unit uses Float
001745bc: 00000000 nop                          |
001745c0: 9262001b lbu r2,0x001b(r19)           |Load Unit Size
001745c4: 00000000 nop                          |
001745c8: 24420002 addiu r2,r2,0x0002           |
001745cc: a262001b sb r2,0x001b(r19)            |Size + 2 if Floating
001745d0: 93a20012 lbu r2,0x0012(r29)           |Load 3rd set of Movement
001745d4: 00000000 nop                          |
001745d8: 34420080 ori r2,r2,0x0080             |Enable [Move on Water]
001745dc: 0805d17a j 0x001745e8                 >>Avoid Not Floating section
001745e0: a262001c sb r2,0x001c(r19)            |Store 3rd Set of active movement + Move on Water in scratchpad
                                            Else : No Float
001745e4: a263001c sb r3,0x001c(r19)            |Store 3rd Set of active movement  in scratchpad
001745e8: 32020040 andi r2,r16,0x0040       |Check [Float] in current status
001745ec: 10400005 beq r2,r0,0x00174604     #If Unit has Float
001745f0: 00000000 nop                          |
001745f4: 93a20012 lbu r2,0x0012(r29)           |Load 3rd set of Movement
001745f8: 00000000 nop                          |
001745fc: 34420008 ori r2,r2,0x0008             |Enable [Float] in movement
00174600: a3a20012 sb r2,0x0012(r29)            |If float status, you get the float ability for free. (on stack)
00174604: 93a20011 lbu r2,0x0011(r29)       |Load 2nd set of Movement
00174608: 00000000 nop                      |
0017460c: 30420010 andi r2,r2,0x0010        |check [Can not Enter Water]
00174610: 10400005 beq r2,r0,0x00174628     #If Unit can't enter Water
00174614: 00000000 nop                          |
00174618: 93a20012 lbu r2,0x0012(r29)           |Load 3rd set of Movement
0017461c: 00000000 nop                          |
00174620: 304200af andi r2,r2,0x00af            |everything except move underwater, move in water
00174624: a3a20012 sb r2,0x0012(r29)            |Disable [Move underwater] and [Move in water]
00174628: 0c05d0dc jal 0x00174370           |-->00174370-001743c4   returns weather severity (1, 2, or 3)
0017462c: 00000000 nop                      |
00174630: 93a30012 lbu r3,0x0012(r29)       |Load 3rd set of Movement
00174634: 00403021 addu r6,r2,r0            |r6 = difficulty to move through weather affected tiles
00174638: 30620004 andi r2,r3,0x0004        |check [Fly]
0017463c: 10400005 beq r2,r0,0x00174654     #If the Unit uses Fly
00174640: 34020001 ori r2,r0,0x0001             |
00174644: a262000f sb r2,0x000f(r19)            |Store Unhindered movement in scratchpad
00174648: a260000e sb r0,0x000e(r19)            |Store Move Type is Fly (0)
0017464c: 0805d1c0 j 0x00174700                 >>Jump After Check move type section
00174650: a262001d sb r2,0x001d(r19)            |Fly/Teleport Flag
                                            Else : Unit is not Flying
00174654: 93a20011 lbu r2,0x0011(r29)           |Load 2nd set of Movement
00174658: 00000000 nop                          |
0017465c: 3042000c andi r2,r2,0x000c            |Check Teleport and Teleport2
00174660: 10400007 beq r2,r0,0x00174680         #If Unit uses Teleport
00174664: 34020001 ori r2,r0,0x0001                 |
00174668: a262000f sb r2,0x000f(r19)                |Store unhindered movement in scratchpad
0017466c: 93a30011 lbu r3,0x0011(r29)               |Load 2nd set of Movement
00174670: a262000e sb r2,0x000e(r19)                |Store Move Type is Teleport (1)
00174674: a262001d sb r2,0x001d(r19)                |Fly/Teleport Flag
00174678: 0805d1c0 j 0x00174700                     >>Jump After Check move type section
0017467c: a2630024 sb r3,0x0024(r19)                |Store 2nd set of movement
                                                Else : No Teleport
00174680: 30620008 andi r2,r3,0x0008                |Check [Float]
00174684: 10400003 beq r2,r0,0x00174694             #If Unit uses Float
00174688: 34020002 ori r2,r0,0x0002                     |
0017468c: 0805d1bf j 0x001746fc                         >>Jump to Store move type (0x2)
00174690: a262000f sb r2,0x000f(r19)                    |Float in Move Mod
                                                    Else : No Float
00174694: 30620020 andi r2,r3,0x0020                    |Check [Move on Lava]
00174698: 10400004 beq r2,r0,0x001746ac                 #If Unit uses Move on Lava
0017469c: 34020005 ori r2,r0,0x0005                         |
001746a0: a262000f sb r2,0x000f(r19)                        |Move on Lava in Move mod
001746a4: 0805d1bf j 0x001746fc                             >>Jump to Store move type (0x3)
001746a8: 34020003 ori r2,r0,0x0003                         |
                                                        Else : not moving on lava
001746ac: 30620080 andi r2,r3,0x0080                        |
001746b0: 10400004 beq r2,r0,0x001746c4                     #If Unit uses Walk on Water
001746b4: 34020003 ori r2,r0,0x0003                             |
001746b8: a262000f sb r2,0x000f(r19)                            |Walk on Water in move mod
001746bc: 0805d1bf j 0x001746fc                                 >>Jump to Store move type (0x4)
001746c0: 34020004 ori r2,r0,0x0004                             |

001746c4: 30620040 andi r2,r3,0x0040                            |
001746c8: 10400004 beq r2,r0,0x001746dc                         #If Unit moves in water
001746cc: 34020003 ori r2,r0,0x0003                                 |
001746d0: a262000f sb r2,0x000f(r19)                                |Move in water in Move mod
001746d4: 0805d1bf j 0x001746fc                                     >>Jump to Store move type (0x5)
001746d8: 34020005 ori r2,r0,0x0005                                 |

001746dc: 30620010 andi r2,r3,0x0010                                |
001746e0: 10400004 beq r2,r0,0x001746f4                             #If Unit Move under water
001746e4: 34020004 ori r2,r0,0x0004                                     |
001746e8: a262000f sb r2,0x000f(r19)                                    |Move underWater in move mod
001746ec: 0805d1bf j 0x001746fc                                         >>Jump to Store move type (0x6)
001746f0: 34020006 ori r2,r0,0x0006                                     |I just wanna know why these are counting up

001746f4: 34020007 ori r2,r0,0x0007                                     |r2 = 0x07
001746f8: a260000f sb r0,0x000f(r19)                                    |No Move mod
001746fc: a262000e sb r2,0x000e(r19)                |Store move Type
00174700: 9262001c lbu r2,0x001c(r19)       |Load 3rd Set of movement (scratchpad)
00174704: 00000000 nop                      |
00174708: 304200c0 andi r2,r2,0x00c0        |Check [Walk on Water] and [Move in water]
0017470c: 10400002 beq r2,r0,0x00174718     #If Acting unit uses [Walk on Water] or [Move in water]  Walk on water is ON if unit is Floating
00174710: 00000000 nop                          |
00174714: a2600013 sb r0,0x0013(r19)            |Nullify Will Sink flag
00174718: 9262001c lbu r2,0x001c(r19)       |Load 3rd Set of movement (scratchpad)
0017471c: 00000000 nop                      |
00174720: 304200d0 andi r2,r2,0x00d0        |Check [Walk on Water] [Move in water] and [Move underwater]
00174724: 10400002 beq r2,r0,0x00174730     #If Acting unit uses [Walk on Water]  [Move in water] or [Move underwater]
00174728: 00000000 nop                          |
0017472c: a2600012 sb r0,0x0012(r19)            |Nullify Will drawn flag
00174730: 93a20012 lbu r2,0x0012(r29)       |Load 3rd set of Movement (stack)
00174734: 00000000 nop                      |
00174738: 3042008c andi r2,r2,0x008c        |Walk on water, Float, Fly
0017473c: 14400007 bne r2,r0,0x0017475c     #If Unit don't uses [Walk on water] [Float] nor [Fly]
00174740: 00000000 nop                          |
00174744: 93a20011 lbu r2,0x0011(r29)           |Load 2nd set of Movement
00174748: 00000000 nop                          |
0017474c: 30420010 andi r2,r2,0x0010            |
00174750: 10400002 beq r2,r0,0x0017475c         #If Unit can't enter Water
00174754: 34020001 ori r2,r0,0x0001                 |
00174758: a2620011 sb r2,0x0011(r19)                |Enable Cannot enter  Water flag
0017475c: 93a20012 lbu r2,0x0012(r29)       |Load 3rd set of Movement (stack)
00174760: 00000000 nop                      |
00174764: a2620010 sb r2,0x0010(r19)        |Store 3rd set of movement
00174768: 93a30011 lbu r3,0x0011(r29)       |Load 2nd set of Movement (stack)
0017476c: 00000000 nop                      |
00174770: 30620002 andi r2,r3,0x0002        |
00174774: 10400002 beq r2,r0,0x00174780     #If Unit uses [Any Weather]
00174778: 30650001 andi r5,r3,0x0001        |r5 = any ground check (used in next loop)
0017477c: 34060001 ori r6,r0,0x0001             |if any weather, set cost to move through watery terrain = 1, even if heavy or extreme weather.
00174780: 00009021 addu r18,r0,r0           |Initialize loop counter
00174784: 340700ff ori r7,r0,0x00ff         |
00174788: 9262000f lbu r2,0x000f(r19)       |Load Move mod flag
0017478c: 3c038006 lui r3,0x8006            |
00174790: 2463ea50 addiu r3,r3,-0x15b0      |Default movement cost table pointer Movement modifiers Table at 8005ea50
00174794: 00021180 sll r2,r2,0x06           |movement ignorance type * 0x40
00174798: 00432021 addu r4,r2,r3            |This Unit Movement Cost Table
                                            @LOOP - All entries of Movement cost Table
0017479c: 90830000 lbu r3,0x0000(r4)            |Load this iteration movement cost
001747a0: 00000000 nop                          |
001747a4: 306200ff andi r2,r3,0x00ff            |
001747a8: 14400003 bne r2,r0,0x001747b8         #If Movement cost = 0x00
001747ac: 00000000 nop                              |
001747b0: 0805d1f3 j 0x001747cc                     >>Jump to next iteration Returns weather impact
001747b4: 00c01821 addu r3,r6,r0                    |Weather Impact
                                                Else movement cost <> 0x00
001747b8: 10a00004 beq r5,r0,0x001747cc             #If Unit uses [Any Ground] /  Else  Returns Movement cost
001747bc: 00000000 nop                                  |
001747c0: 10470002 beq r2,r7,0x001747cc                 #If Movement cost <> 0xff / Else  returns Movement cost
001747c4: 00000000 nop                                      |
001747c8: 34030001 ori r3,r0,0x0001                         |if any ground, set terrain move cost to 1
001747cc: 3c028019 lui r2,0x8019                |
001747d0: 8c42f4ec lw r2,-0x0b14(r2)            |Pointer to scratch pad at 0x1f800100 - refered as S-Pad 0x100  from 8018f4ec
001747d4: 00000000 nop                          |
001747d8: 00521021 addu r2,r2,r18               |S-Pad 0x100 + Iteration offset
001747dc: 26520001 addiu r18,r18,0x0001         |Counter + 1
001747e0: a0430000 sb r3,0x0000(r2)             |Store Movement cost in scratch 0x100
001747e4: 2a420040 slti r2,r18,0x0040           |
001747e8: 1440ffec bne r2,r0,0x0017479c     Λ Loop 0x40 Times
001747ec: 24840001 addiu r4,r4,0x0001           |Movement cost table offset
001747f0: 9230003b lbu r16,0x003b(r17)      |Load units jump
001747f4: 00000000 nop                      |
001747f8: 2e020008 sltiu r2,r16,0x0008      |
001747fc: 14400003 bne r2,r0,0x0017480c     #If Unit Jump > 7
00174800: 320200ff andi r2,r16,0x00ff           |
00174804: 34100007 ori r16,r0,0x0007            |Cap Jump at 0x7
00174808: 320200ff andi r2,r16,0x00ff           |
0017480c: 9263000e lbu r3,0x000e(r19)       |Load Move Type
00174810: 00021042 srl r2,r2,0x01           |jump / 2
00174814: 10600006 beq r3,r0,0x00174830     #If Move Type  <> 0x00 (not flying)
00174818: a2620005 sb r2,0x0005(r19)        |Store jump/2 (S-Pad 0x00)
0017481c: 93a20010 lbu r2,0x0010(r29)           |Load 1st set of Movement (stack)
00174820: 00000000 nop                          |
00174824: 30420002 andi r2,r2,0x0002            |Ignore Height check
00174828: 10400003 beq r2,r0,0x00174838         #If Unit uses [Ignore Height]
0017482c: 02202021 addu r4,r17,r0                   |
                                                    Fly or Ignore height
00174830: 3410001f ori r16,r0,0x001f        #E      |Forces unit height to 31 (Fly or ignore height)
00174834: 02202021 addu r4,r17,r0           |Acting Unit pointer to battle data (for Jal)
00174838: 320200ff andi r2,r16,0x00ff       |
0017483c: 00021040 sll r2,r2,0x01           |
00174840: a2620002 sb r2,0x0002(r19)        |Store Jump*2 in S-Pad 0x00
00174844: 0c05d0f2 jal 0x001743c8           |-->Chocobo_Check returns r2 (Unmountable / montable / Already ridden)
00174848: a2700004 sb r16,0x0004(r19)       |Store Jump in S-Pad 0x00
0017484c: 10400003 beq r2,r0,0x0017485c     #If Unit is a mountable Chocobo (ridden or not)
00174850: 34020001 ori r2,r0,0x0001             |
00174854: 0805d218 j 0x00174860                 >>Avoid not chocobo
00174858: a2620015 sb r2,0x0015(r19)            |Chocobo flag (S-Pad 0x00)
                                            Else : not a chocobo (or not mountable by statuses)
0017485c: a2600015 sb r0,0x0015(r19)            |No chocobo flag
00174860: 9230003a lbu r16,0x003a(r17)      |Load Unit move
00174864: 00000000 nop                      |
00174868: 2e02007d sltiu r2,r16,0x007d      |
0017486c: 14400002 bne r2,r0,0x00174878     #If Move > 0x7c
00174870: 00000000 nop                          |
00174874: 3410007c ori r16,r0,0x007c            |Cap move at 0x7c
00174878: a2700006 sb r16,0x0006(r19)       |Store unit move in S-Pad 0x00
0017487c: 92220006 lbu r2,0x0006(r17)       |Load Unit Gender
00174880: 00000000 nop                      |
00174884: 304200c0 andi r2,r2,0x00c0        |
00174888: 1040000d beq r2,r0,0x001748c0     #If Unit is not a monster
0017488c: 00000000 nop                          |
00174890: 9222005a lbu r2,0x005a(r17)           |Load Unit Current Status 3
00174894: 00000000 nop                          |
00174898: 30420006 andi r2,r2,0x0006            |
0017489c: 14400008 bne r2,r0,0x001748c0         #If Unit is not a Frog nor a Chicken
001748a0: 00000000 nop                              |
001748a4: 9222005c lbu r2,0x005c(r17)               |Load Unit Current Status 5
001748a8: 00000000 nop                              |
001748ac: 30420020 andi r2,r2,0x0020                |
001748b0: 14400003 bne r2,r0,0x001748c0             #If unit is not Charmed
001748b4: 34020001 ori r2,r0,0x0001                     |
001748b8: 0805d231 j 0x001748c4                         >>Avoid Normal section
001748bc: a2620016 sb r2,0x0016(r19)                    |Enable Can Ride Flag
                                            Else : Monster or Forg/Chicken/Charm
001748c0: a2600016 sb r0,0x0016(r19)            |Disable Can Ride flag
001748c4: 340400ff ori r4,r0,0x00ff         |
001748c8: 3412000f ori r18,r0,0x000f        |Initialize Counter
001748cc: 923101ba lbu r17,0x01ba(r17)      |Load Unit modified ENTD
001748d0: 3c028019 lui r2,0x8019            |
001748d4: 9042f4fc lbu r2,-0x0b04(r2)       |Load ?? 8018f4fc
001748d8: 26830069 addiu r3,r20,0x0069      |Scratch Pad 3 0x69
001748dc: a3b10020 sb r17,0x0020(r29)       |Store modified ENTD
001748e0: a262001a sb r2,0x001a(r19)        |Store [8018f4fc] on scratch pad
                                            @LOOP - Set all Units 0x03 Entry to 0xff
001748e4: a0640003 sb r4,0x0003(r3)             |Store 0xff on scratch pad
001748e8: 2652ffff addiu r18,r18,-0x0001        |Counter - 1
001748ec: 0641fffd bgez r18,0x001748e4      Λ Loop 16 times
001748f0: 2463fff9 addiu r3,r3,0xfff9           |Scratch Pad offet - 0x07
001748f4: 0000b821 addu r23,r0,r0           |Initialize Stored data counter
001748f8: 00009021 addu r18,r0,r0           |Loop counter (Used as Unit offset of battle data)
001748fc: 0000b021 addu r22,r0,r0           |Unit Offset (+0x1c0 each iteration)
                                            @LOOP - Other units data (0x15 times, but room for only 0x10 units)
00174900: 2ae20010 slti r2,r23,0x0010           |Check Size of Stored data
00174904: 10400094 beq r2,r0,0x00174b58         #If this loop has stored more than 0x10 Units :  Exit routine
00174908: 00000000 nop                              |
0017490c: 3c028019 lui r2,0x8019                    |
00174910: 244208cc addiu r2,r2,0x08cc               |
00174914: 02c28821 addu r17,r22,r2              |This iteration Unit Battle data pointer
00174918: 92230001 lbu r3,0x0001(r17)           |Load Unit Battle ID
0017491c: 340200ff ori r2,r0,0x00ff             |
00174920: 10620089 beq r3,r2,0x00174b48         #If Unit do not Exist : branch to   Next Unit iteration
00174924: 00000000 nop                              |
00174928: 92220058 lbu r2,0x0058(r17)           |Load This Unit current status 1
0017492c: 00000000 nop                          |
00174930: 30420064 andi r2,r2,0x0064            |
00174934: 14400084 bne r2,r0,0x00174b48         #If Unit is Dead or Crystal : branch to  Next Unit iteration
00174938: 00000000 nop                              |
0017493c: 92220059 lbu r2,0x0059(r17)           |Load This Unit current status 2
00174940: 00000000 nop                          |
00174944: 30420001 andi r2,r2,0x0001            |
00174948: 1440007f bne r2,r0,0x00174b48         #If Unit is a Treasure : branch to  Next Unit iteration
0017494c: 00000000 nop                              |
00174950: 125e007d beq r18,r30,0x00174b48       #If This Unit is the active Unit : branch to  Next Unit iteration
00174954: 00000000 nop                              |
00174958: 92240182 lbu r4,0x0182(r17)           |Load This unit Mount info
0017495c: 00000000 nop                          |
00174960: 30820080 andi r2,r4,0x0080            |
00174964: 1040000a beq r2,r0,0x00174990         #If This Unit is Riding
00174968: 3082001f andi r2,r4,0x001f                |Ridden Unit ID
0017496c: 9263000d lbu r3,0x000d(r19)               |Load Active Unit ID (Parameter of the routine)
00174970: 00000000 nop                              |
00174974: 14430007 bne r2,r3,0x00174994             #If This Unit is the rider of Active unit
00174978: 02408021 addu r16,r18,r0                      |
0017497c: 9262001b lbu r2,0x001b(r19)                   |Load Scratch pad 0x1b (Chicken Frog Float)
00174980: 00000000 nop                                  |
00174984: 24420002 addiu r2,r2,0x0002                   |Active Unit Height + 2
00174988: 0805d2d2 j 0x00174b48                         >>Jump to   Next Unit iteration
0017498c: a262001b sb r2,0x001b(r19)                    |Store Updated Height
00174990: 02408021 addu r16,r18,r0              |Add Unit ID (will be stored)
00174994: 0c05d0f2 jal 0x001743c8               |-->Chocobo Check Check This unit mount status
00174998: 02202021 addu r4,r17,r0               |This iteration Unit Data pointer (for Jal)
0017499c: 34030001 ori r3,r0,0x0001             |
001749a0: 10430007 beq r2,r3,0x001749c0         #If This Unit is not mountable (or already ridden)
001749a4: 00000000 nop                              |
001749a8: 9262000d lbu r2,0x000d(r19)               |Load Active unit ID
001749ac: 92230182 lbu r3,0x0182(r17)               |Load this Unit mount info
001749b0: 34420040 ori r2,r2,0x0040                 |Unit ID + 0x40 (so it will match r3)
001749b4: 10620002 beq r3,r2,0x001749c0             #If This unit is not ridden by active Unit
001749b8: 00000000 nop                                  |
001749bc: 36500020 ori r16,r18,0x0020                   |Update with not Mountable flag
001749c0: 92230005 lbu r3,0x0005(r17)           |Load This Unit Team
001749c4: 93a80020 lbu r8,0x0020(r29)           |Load active unit modified ENTD
001749c8: 00000000 nop                          |
001749cc: 01031026 xor r2,r8,r3                 |Keep Only the difference
001749d0: 30420030 andi r2,r2,0x0030            |Focus on team difference
001749d4: 10400002 beq r2,r0,0x001749e0         #If This unit is an enemy of Active Unit
001749d8: 0280a821 addu r21,r20,r0              |S-Pad 0x80
001749dc: 36100040 ori r16,r16,0x0040               |Add Enemy Flag
001749e0: a2900003 sb r16,0x0003(r20)           |Store r16 in S-Pad 0x80 (Unit ID/ 20 if Unmountable / 40 if enemy)
001749e4: 92220047 lbu r2,0x0047(r17)           |This unit X
001749e8: 92830002 lbu r3,0x0002(r20)           |Load this Unit 0x02 (dynamic scratch Pad)
001749ec: a2820000 sb r2,0x0000(r20)            |store X on S-Pad 0x80
001749f0: 92220048 lbu r2,0x0048(r17)           |This Unit Y
001749f4: 00000000 nop                          |
001749f8: a2820001 sb r2,0x0001(r20)            |store Y on S-Pad 0x80
001749fc: 96220048 lhu r2,0x0048(r17)           |Load Y + Elevation
00174a00: 30630080 andi r3,r3,0x0080            |
00174a04: 000213c2 srl r2,r2,0x0f               |1 if higher elevation
00174a08: 00621825 or r3,r3,r2                  |
00174a0c: a2830002 sb r3,0x0002(r20)            |Enable (or not) high elvation flag (S-Pad 0x80)
00174a10: 96220048 lhu r2,0x0048(r17)           |Load Y + Elevation
00174a14: 3063007f andi r3,r3,0x007f            |Disable 0x80
00174a18: 000211c2 srl r2,r2,0x07               |
00174a1c: 30420080 andi r2,r2,0x0080            |check [Stepping stone]
00174a20: 00621825 or r3,r3,r2                  |Enable 0x80 if stepping stone
00174a24: a2830002 sb r3,0x0002(r20)            |Store back 0x80 if stepping stone
00174a28: 9230005a lbu r16,0x005a(r17)          |This Unit Current Status 3
00174a2c: 00000000 nop                          |
00174a30: 32020006 andi r2,r16,0x0006           |
00174a34: 10400006 beq r2,r0,0x00174a50         #If Unit has Frog or Chicken
00174a38: 34020004 ori r2,r0,0x0004                 |
00174a3c: 92830002 lbu r3,0x0002(r20)               |
00174a40: a2820004 sb r2,0x0004(r20)                |Store 0x04 (height)
00174a44: 3063007f andi r3,r3,0x007f                |remove 80 flag
00174a48: 0805d296 j 0x00174a58                     >>Avoid Anti section
00174a4c: a2830002 sb r3,0x0002(r20)                |Disable stepping stone
                                                Else : if Unit hasn't Frog nor Chicken
00174a50: 34020006 ori r2,r0,0x0006                 |
00174a54: a2820004 sb r2,0x0004(r20)                |Store height = 0x06
00174a58: 92300182 lbu r16,0x0182(r17)          |Mount info byte
00174a5c: 00000000 nop                          |
00174a60: 32020040 andi r2,r16,0x0040           |
00174a64: 10400009 beq r2,r0,0x00174a8c         #If Unit is ridden
00174a68: 3202001f andi r2,r16,0x001f               |Rider ID
00174a6c: 9263000d lbu r3,0x000d(r19)               |Load Active Unit ID
00174a70: 00000000 nop                              |
00174a74: 10430005 beq r2,r3,0x00174a8c             #If This unit is not the active unit mount
00174a78: 00000000 nop                                  |
00174a7c: 92a20004 lbu r2,0x0004(r21)                   |Load Unit Size
00174a80: 00000000 nop                                  |
00174a84: 24420002 addiu r2,r2,0x0002                   |
00174a88: a2a20004 sb r2,0x0004(r21)                    |Size + 2 (rider height)
00174a8c: 92300095 lbu r16,0x0095(r17)          |This unit Movement 3
00174a90: 0c060428 jal 0x001810a0               |-->Map Location Calculation returns r2 = This unit Tile ID
00174a94: 02202021 addu r4,r17,r0               |This unit data pointer
00174a98: 000210c0 sll r2,r2,0x03               |Tile ID *8
00174a9c: 3c038019 lui r3,0x8019                |
00174aa0: 2463f8cc addiu r3,r3,0xf8cc           |
00174aa4: 00431021 addu r2,r2,r3                |This unit Tile's data pointer
00174aa8: 90440002 lbu r4,0x0002(r2)            |load height
00174aac: 90430003 lbu r3,0x0003(r2)            |load halves/depth
00174ab0: 90420003 lbu r2,0x0003(r2)            |load halves/depth
00174ab4: 00042040 sll r4,r4,0x01               |height*2
00174ab8: 3063001f andi r3,r3,0x001f            |r3 = height (halves)
00174abc: 00832021 addu r4,r4,r3                |height*2 + halves
00174ac0: 00022942 srl r5,r2,0x05               |Tile depth
00174ac4: 10a00014 beq r5,r0,0x00174b18         #If Depht <> 0x00
00174ac8: 00801821 addu r3,r4,r0                |r3 = Total Height (Height*2) + Halves
00174acc: 9222005a lbu r2,0x005a(r17)               |This unit Current Status 3
00174ad0: 00000000 nop                              |
00174ad4: 30420040 andi r2,r2,0x0040                |load float flag
00174ad8: 10400004 beq r2,r0,0x00174aec             #If this Unit has [Float]
00174adc: 00051040 sll r2,r5,0x01                       |depth*2
00174ae0: 24420002 addiu r2,r2,0x0002                   |depth*2+2
00174ae4: 0805d2cc j 0x00174b30                         >>Jump to next iteration
00174ae8: 00821821 addu r3,r4,r2                        |r3 = total height + depth*2 + 2
                                                    Else : This unit isn't Floating
00174aec: 32020080 andi r2,r16,0x0080                   |
00174af0: 10400003 beq r2,r0,0x00174b00                 #If Unit Walk on water
00174af4: 00051040 sll r2,r5,0x01                           |depht * 2
00174af8: 0805d2cc j 0x00174b30                             >>Jump to next iteration
00174afc: 00821821 addu r3,r4,r2                            |r3 = total height + depth*2 
                                                        Else : not walking on water
00174b00: 32020040 andi r2,r16,0x0040                       |
00174b04: 1040000a beq r2,r0,0x00174b30                     #If Unit Walk in water
00174b08: 00051040 sll r2,r5,0x01                               |depht * 2
00174b0c: 2442fffe addiu r2,r2,-0x0002                          |depht * 2 -2
00174b10: 0805d2cc j 0x00174b30                                 >>Jump to next iteration
00174b14: 00821821 addu r3,r4,r2                                |Total Height + depht*2 - 2
                                                Else : Depht  = 0x00
00174b18: 9222005a lbu r2,0x005a(r17)               |This unit Current Status 3
00174b1c: 00000000 nop                              |
00174b20: 30420040 andi r2,r2,0x0040                |
00174b24: 10400002 beq r2,r0,0x00174b30             #If This unit is Floating
00174b28: 00000000 nop                                  |
00174b2c: 24830002 addiu r3,r4,0x0002                   |Total height + 2
00174b30: 26940007 addiu r20,r20,0x0007         |Next Unit Offset in scratch pad
00174b34: 92a20004 lbu r2,0x0004(r21)           |Load Unit Height
00174b38: 26f70001 addiu r23,r23,0x0001         |Data stored counter
00174b3c: a2a30005 sb r3,0x0005(r21)            |Store Total Height on S-Pad 0x80
00174b40: 00621021 addu r2,r3,r2                |Unit Size + Map height
00174b44: a2a20006 sb r2,0x0006(r21)            |Store Size + Height 
00174b48: 26520001 addiu r18,r18,0x0001         |Unit Counter + 1
00174b4c: 2a420015 slti r2,r18,0x0015           |Check unit limit
00174b50: 1440ff6b bne r2,r0,0x00174900     Λ Loop 21 times (for each unit)
00174b54: 26d601c0 addiu r22,r22,0x01c0         |Offset for Battle data
00174b58: 8fbf004c lw r31,0x004c(r29)       END
00174b5c: 8fbe0048 lw r30,0x0048(r29)
00174b60: 8fb70044 lw r23,0x0044(r29)
00174b64: 8fb60040 lw r22,0x0040(r29)
00174b68: 8fb5003c lw r21,0x003c(r29)
00174b6c: 8fb40038 lw r20,0x0038(r29)
00174b70: 8fb30034 lw r19,0x0034(r29)
00174b74: 8fb20030 lw r18,0x0030(r29)
00174b78: 8fb1002c lw r17,0x002c(r29)
00174b7c: 8fb00028 lw r16,0x0028(r29)
00174b80: 27bd0050 addiu r29,r29,0x0050
00174b84: 03e00008 jr r31
00174b88: 00000000 nop

Return Location

BATTLE.BIN
00174be8: 00174b8c_-_00174df4
00176744: 001766b4_-_00176c0c
00178d44: Find_Tiles_for_the_AI_to_move_to_(00178ca4)