Map movement decision/data setting

From Final Fantasy Hacktics Wiki
Revision as of 19:14, 28 July 2020 by Dokurider (talk | contribs) (Updated Documentation)
Jump to navigation Jump to search

Non-Specific/True Default AI Movement Routine

0019638c: 34020001 ori r2,r0,0x0001
00196390: 3c01801a lui r1,0x801a
00196394: a02201f1 sb r2,0x01f1(r1)
00196398: 3c02801a lui r2,0x801a
0019639c: 90420d7b lbu r2,0x0d7b(r2)			Action = Decided byte
001963a0: 27bdffe0 addiu r29,r29,0xffe0
001963a4: afb10014 sw r17,0x0014(r29)
001963a8: 3c11801a lui r17,0x801a
001963ac: 8e3101f8 lw r17,0x01f8(r17)			Acting Unit's AI Decision Pointer
001963b0: afb00010 sw r16,0x0010(r29)
001963b4: 3c10801a lui r16,0x801a
001963b8: 2610f3c4 addiu r16,r16,0xf3c4
001963bc: afbf001c sw r31,0x001c(r29)
001963c0: 10400008 beq r2,r0,0x001963e4			Branch if an Action has been decided on
001963c4: afb20018 sw r18,0x0018(r29)


001963c8: 3c02801a lui r2,0x801a
001963cc: 90420035 lbu r2,0x0035(r2)			
001963d0: 00000000 nop
001963d4: 1040001a beq r2,r0,0x00196440		Skip targeting if False
001963d8: 00000000 nop
001963dc: 080659a0 j 0x00196680				Skip to Panel Priority	
001963e0: 00000000 nop

001963e4: 92220004 lbu r2,0x0004(r17)		Load Targeting Flag 1
001963e8: 00000000 nop
001963ec: 30420040 andi r2,r2,0x0040
001963f0: 10400013 beq r2,r0,0x00196440			branch if not focus on target
001963f4: 00000000 nop
001963f8: 92230005 lbu r3,0x0005(r17)			load main target ID
001963fc: 3c02801a lui r2,0x801a
00196400: 904201f2 lbu r2,0x01f2(r2)			load acting units ID
00196404: 00000000 nop
00196408: 10620009 beq r3,r2,0x00196430			branch if self
0019640c: 260403b4 addiu r4,r16,0x03b4
00196410: 00031100 sll r2,r3,0x04
00196414: 00501021 addu r2,r2,r16
00196418: 90421833 lbu r2,0x1833(r2)			load target type
0019641c: 00000000 nop
00196420: 00021102 srl r2,r2,0x04
00196424: 30420001 andi r2,r2,0x0001
00196428: 10400005 beq r2,r0,0x00196440			branch if able to be targeted
0019642c: 00000000 nop
00196430: 0c066ade jal 0x0019ab78				word nulling
00196434: 34050240 ori r5,r0,0x0240
00196438: 0806594e j 0x00196538					Jump to Longest Ability/Move
0019643c: 00000000 nop

00196440: 0c06653e jal 0x001994f8				see if able to move to target
00196444: 02202021 addu r4,r17,r0
00196448: 2403ffff addiu r3,r0,0xffff
0019644c: 14430003 bne r2,r3,0x0019645c
00196450: 2402ffff addiu r2,r0,0xffff
00196454: 08065a20 j 0x00196880					Frame Timer Exit
00196458: a2000c71 sb r0,0x0c71(r16)			0x1a0035 = False

0019645c: 92220007 lbu r2,0x0007(r17)			load type of target flags
00196460: 00000000 nop
00196464: 30420003 andi r2,r2,0x0003
00196468: 10400033 beq r2,r0,0x00196538			branch if not low hp/mp unit
0019646c: 00000000 nop
00196470: 8e0217f8 lw r2,0x17f8(r16)			load acting units data
00196474: 00000000 nop
00196478: 9042005c lbu r2,0x005c(r2)			load status
0019647c: 00000000 nop
00196480: 30420001 andi r2,r2,0x0001
00196484: 1440002c bne r2,r0,0x00196538			branch if death sentence
00196488: 00000000 nop
0019648c: 3c01801a lui r1,0x801a
00196490: ac20f370 sw r0,-0x0c90(r1)			Initialize Unit Counter

Search for Crystals
00196494: 3c04801a lui r4,0x801a
00196498: 8c84f370 lw r4,-0x0c90(r4)			Load Unit Counter
0019649c: 3c038019 lui r3,0x8019
001964a0: 246308cc addiu r3,r3,0x08cc
001964a4: 000410c0 sll r2,r4,0x03
001964a8: 00441023 subu r2,r2,r4
001964ac: 00021180 sll r2,r2,0x06
001964b0: 00432821 addu r5,r2,r3
001964b4: 90a30001 lbu r3,0x0001(r5)			load unit ID
001964b8: 340200ff ori r2,r0,0x00ff
001964bc: 10620015 beq r3,r2,0x00196514			branch if Unit doesn't exist
001964c0: 00000000 nop
001964c4: 90a20058 lbu r2,0x0058(r5)			
001964c8: 00000000 nop
001964cc: 30420040 andi r2,r2,0x0040
001964d0: 10400010 beq r2,r0,0x00196514			branch if not crystal
001964d4: 00000000 nop
001964d8: 0c067ca9 jal 0x0019f2a4				transfer unit coordinates to AI
001964dc: 26050c74 addiu r5,r16,0x0c74
001964e0: 92030c75 lbu r3,0x0c75(r16)                Load map level
001964e4: 92040c74 lbu r4,0x0c74(r16)                Load X coordinate
001964e8: 000310c0 sll r2,r3,0x03                    *8
001964ec: 00431021 addu r2,r2,r3                     *9
001964f0: 00021140 sll r2,r2,0x05                    *120
001964f4: 00501021 addu r2,r2,r16                    
001964f8: 92030c76 lbu r3,0x0c76(r16)                Load Y coordinate
001964fc: 244203b4 addiu r2,r2,0x03b4
00196500: 00031900 sll r3,r3,0x04                    Y coordinate*16
00196504: 00621821 addu r3,r3,r2                     
00196508: 00641821 addu r3,r3,r4                     +X coordinate
0019650c: 34020001 ori r2,r0,0x0001
00196510: a0620000 sb r2,0x0000(r3)                  Store 0x01 in panel data
00196514: 3c02801a lui r2,0x801a
00196518: 8c42f370 lw r2,-0x0c90(r2)			Load Unit Counter
0019651c: 00000000 nop
00196520: 24420001 addiu r2,r2,0x0001
00196524: 3c01801a lui r1,0x801a
00196528: ac22f370 sw r2,-0x0c90(r1)			Unit Counter++
0019652c: 28420015 slti r2,r2,0x0015
00196530: 1440ffd8 bne r2,r0,0x00196494         Do for each unit
00196534: 00000000 nop

00196538: 92020e31 lbu r2,0x0e31(r16)           load map level
0019653c: 92040e30 lbu r4,0x0e30(r16)           load x coordinate
00196540: 000218c0 sll r3,r2,0x03
00196544: 00621821 addu r3,r3,r2
00196548: 00031940 sll r3,r3,0x05
0019654c: 00701821 addu r3,r3,r16
00196550: 92020e32 lbu r2,0x0e32(r16)           load Y coordinate
00196554: 246303b4 addiu r3,r3,0x03b4
00196558: 00021100 sll r2,r2,0x04
0019655c: 00431021 addu r2,r2,r3
00196560: 00441021 addu r2,r2,r4
00196564: 90420000 lbu r2,0x0000(r2)            load panel value
00196568: 3c01801a lui r1,0x801a
0019656c: ac22f374 sw r2,-0x0c8c(r1)            store panel value
00196570: 0c0658a8 jal 0x001962a0				Get Longest Range Ability or Move
00196574: 00000000 nop
00196578: 3c04801a lui r4,0x801a
0019657c: 8c84f374 lw r4,-0x0c8c(r4)            load panel value
00196580: 3c01801a lui r1,0x801a
00196584: ac22f36c sw r2,-0x0c94(r1)            19f36c
00196588: 3c01801a lui r1,0x801a
0019658c: ac20f378 sw r0,-0x0c88(r1)           
00196590: 0044102a slt r2,r2,r4
00196594: 10400006 beq r2,r0,0x001965b0         branch if New Panel Value > Old Value
00196598: 34120001 ori r18,r0,0x0001
0019659c: 92220006 lbu r2,0x0006(r17)
001965a0: 00000000 nop
001965a4: 30420008 andi r2,r2,0x0008
001965a8: 10400030 beq r2,r0,0x0019666c         branch if not charging ability
001965ac: 00000000 nop
001965b0: 3c01801a lui r1,0x801a
001965b4: ac32f368 sw r18,-0x0c98(r1)			Target is in range = True

001965b8: 92220004 lbu r2,0x0004(r17)
001965bc: 00000000 nop
001965c0: 30420020 andi r2,r2,0x0020
001965c4: 10400024 beq r2,r0,0x00196658         branch if stay near X/Y location AI
001965c8: 00000000 nop
001965cc: 0c0674a5 jal 0x0019d294				Get unit that matches coordinates
001965d0: 02202021 addu r4,r17,r0
001965d4: 92030e2e lbu r3,0x0e2e(r16)           load acting unit id
001965d8: 00402021 addu r4,r2,r0
001965dc: 3c01801a lui r1,0x801a
001965e0: ac24f370 sw r4,-0x0c90(r1)            store unit ID
001965e4: 10830003 beq r4,r3,0x001965f4         branch if calculated ID is acting unit
001965e8: 34020015 ori r2,r0,0x0015
001965ec: 1482001a bne r4,r2,0x00196658         branch if not end of unit counter?
001965f0: 00000000 nop

001965f4: 92230001 lbu r3,0x0001(r17)           load map level flag
001965f8: 92240000 lbu r4,0x0000(r17)           load X coordinate
001965fc: 000310c0 sll r2,r3,0x03
00196600: 00431021 addu r2,r2,r3
00196604: 00021080 sll r2,r2,0x02
00196608: 92230002 lbu r3,0x0002(r17)           load Y coordinate
0019660c: 00501021 addu r2,r2,r16
00196610: 00031840 sll r3,r3,0x01
00196614: 00431021 addu r2,r2,r3
00196618: 34038000 ori r3,r0,0x8000
0019661c: 94420a74 lhu r2,0x0a74(r2)
00196620: 00831807 srav r3,r3,r4
00196624: 00431024 and r2,r2,r3
00196628: 1040000b beq r2,r0,0x00196658			Branch if acting unit is not in range?
0019662c: 00000000 nop
00196630: 92020e2d lbu r2,0x0e2d(r16)
00196634: 8e230000 lw r3,0x0000(r17)
00196638: 00021080 sll r2,r2,0x02
0019663c: 00501021 addu r2,r2,r16
00196640: 0c0664e8 jal 0x001993a0				Save new coordinates
00196644: ac430cc4 sw r3,0x0cc4(r2)
00196648: 3c01801a lui r1,0x801a
0019664c: ac32f378 sw r18,-0x0c88(r1)
00196650: 080659a0 j 0x00196680					Jump to Movement Priority Routine
00196654: 00000000 nop

00196658: 92020e38 lbu r2,0x0e38(r16)
0019665c: 3c04801a lui r4,0x801a
00196660: 8c84f374 lw r4,-0x0c8c(r4)
00196664: 0806599e j 0x00196678
00196668: 00442021 addu r4,r2,r4

0019666c: 3c01801a lui r1,0x801a
00196670: ac20f368 sw r0,-0x0c98(r1)
00196674: 2484ffff addiu r4,r4,0xffff
00196678: 0c065ab7 jal 0x00196adc			Find Panel in Range
0019667c: 00000000 nop
00196680: 0c066672 jal 0x001999c8			AI Target Priority Super Routine
00196684: 00000000 nop
00196688: 2403ffff addiu r3,r0,0xffff
0019668c: 14430004 bne r2,r3,0x001966a0
00196690: 34020001 ori r2,r0,0x0001
00196694: a2020c71 sb r2,0x0c71(r16)		Save to 0x1a0035
00196698: 08065a20 j 0x00196880				Exit and return -1
0019669c: 2402ffff addiu r2,r0,0xffff

001966a0: 3c02801a lui r2,0x801a
001966a4: 8c42f378 lw r2,-0x0c88(r2)
001966a8: 00000000 nop
001966ac: 14400029 bne r2,r0,0x00196754		Branch to Move Range stuff if Distance already Set?
001966b0: 00000000 nop
001966b4: 3c02801a lui r2,0x801a
001966b8: 8c42f368 lw r2,-0x0c98(r2)		Target is in range?
001966bc: 00000000 nop
001966c0: 10400006 beq r2,r0,0x001966dc		Randomize Target Distance if false
001966c4: 3c047fff lui r4,0x7fff
001966c8: 3484ffff ori r4,r4,0xffff
001966cc: 0c065a4f jal 0x0019693c			AI Post Action Movement Decision Routine
001966d0: 00002821 addu r5,r0,r0			Move Away from Enemy
001966d4: 080659d5 j 0x00196754				Jump to Move Range stuff
001966d8: 00000000 nop

Randomize coordinate values
001966dc: 92020e39 lbu r2,0x0e39(r16)		load acting units team
001966e0: 00000000 nop
001966e4: 10400017 beq r2,r0,0x00196744		branch if uncontrolled Blue player team
001966e8: 00000000 nop
001966ec: 0c0088c3 jal 0x0002230c			Random
001966f0: 00000000 nop
001966f4: 3c039249 lui r3,0x9249
001966f8: 34632493 ori r3,r3,0x2493
001966fc: 00430018 mult r2,r3
00196700: 000227c3 sra r4,r2,0x1f
00196704: 00001810 mfhi r3
00196708: 00621821 addu r3,r3,r2
0019670c: 00031883 sra r3,r3,0x02
00196710: 00641823 subu r3,r3,r4
00196714: 000320c0 sll r4,r3,0x03
00196718: 00832023 subu r4,r4,r3
0019671c: 14440009 bne r2,r4,0x00196744		Branch Randomly
00196720: 00000000 nop
00196724: 3c02801a lui r2,0x801a
00196728: 8c42f36c lw r2,-0x0c94(r2)		Load Target Distance
0019672c: 00000000 nop
00196730: 00021fc2 srl r3,r2,0x1f
00196734: 00431021 addu r2,r2,r3
00196738: 00021043 sra r2,r2,0x01
0019673c: 3c01801a lui r1,0x801a
00196740: ac22f36c sw r2,-0x0c94(r1)		Save new Target Distance

00196744: 3c04801a lui r4,0x801a
00196748: 8c84f36c lw r4,-0x0c94(r4)		Load Target Distance
0019674c: 0c065a42 jal 0x00196908			Find Best Panel to move to
00196750: 00000000 nop
00196754: 92030e3b lbu r3,0x0e3b(r16)			map max y
00196758: 34020002 ori r2,r0,0x0002
0019675c: a2020e2d sb r2,0x0e2d(r16)			??
00196760: 3c01801a lui r1,0x801a
00196764: ac20f370 sw r0,-0x0c90(r1)
00196768: 10600015 beq r3,r0,0x001967c0
0019676c: 00000000 nop
00196770: 3c05801a lui r5,0x801a
00196774: 8ca5f370 lw r5,-0x0c90(r5)
00196778: 00000000 nop
0019677c: 00051040 sll r2,r5,0x01
00196780: 00501021 addu r2,r2,r16
00196784: 94430a74 lhu r3,0x0a74(r2)
00196788: 94460abc lhu r6,0x0abc(r2)
0019678c: 94440a98 lhu r4,0x0a98(r2)
00196790: 94470ae0 lhu r7,0x0ae0(r2)
00196794: 00661826 xor r3,r3,r6
00196798: 00872026 xor r4,r4,r7
0019679c: a4430b04 sh r3,0x0b04(r2)
001967a0: a4440b28 sh r4,0x0b28(r2)
001967a4: 92020e3b lbu r2,0x0e3b(r16)
001967a8: 24a50001 addiu r5,r5,0x0001
001967ac: 3c01801a lui r1,0x801a
001967b0: ac25f370 sw r5,-0x0c90(r1)
001967b4: 00a2282a slt r5,r5,r2
001967b8: 14a0ffed bne r5,r0,0x00196770
001967bc: 00000000 nop
001967c0: 8e020cc8 lw r2,0x0cc8(r16)
001967c4: 8e0317f8 lw r3,0x17f8(r16)
001967c8: a2000e2d sb r0,0x0e2d(r16)
001967cc: ae020ccc sw r2,0x0ccc(r16)
001967d0: 90620188 lbu r2,0x0188(r3)			act flag?
001967d4: 00000000 nop
001967d8: 14400016 bne r2,r0,0x00196834			branch if able to act
001967dc: 00000000 nop
001967e0: 92220004 lbu r2,0x0004(r17) 
001967e4: 00000000 nop
001967e8: 30420040 andi r2,r2,0x0040
001967ec: 10400011 beq r2,r0,0x00196834                    branch if not focus on unit
001967f0: 00000000 nop
001967f4: 3c02801a lui r2,0x801a
001967f8: 8c42f368 lw r2,-0x0c98(r2)
001967fc: 00000000 nop
00196800: 1040000c beq r2,r0,0x00196834        
00196804: 00000000 nop
00196808: 92220006 lbu r2,0x0006(r17)
0019680c: 00000000 nop
00196810: 30420008 andi r2,r2,0x0008
00196814: 14400007 bne r2,r0,0x00196834                   branch if charging ability
00196818: 00000000 nop
0019681c: 3c04801a lui r4,0x801a
00196820: 8c84f374 lw r4,-0x0c8c(r4)
00196824: 0c065a27 jal 0x0019689c					Arcing Weapon Pathfinding
00196828: 2484ffff addiu r4,r4,0xffff
0019682c: 08065a11 j 0x00196844
00196830: 00001021 addu r2,r0,r0

00196834: 8e020cc8 lw r2,0x0cc8(r16)
00196838: 00000000 nop
0019683c: ae020cc4 sw r2,0x0cc4(r16)			Save as new coordinates
00196840: 00001021 addu r2,r0,r0
00196844: 92040e31 lbu r4,0x0e31(r16)
00196848: 92050e32 lbu r5,0x0e32(r16)
0019684c: 92060e30 lbu r6,0x0e30(r16)
00196850: 000418c0 sll r3,r4,0x03
00196854: 00641821 addu r3,r3,r4
00196858: 00031880 sll r3,r3,0x02
0019685c: 00701821 addu r3,r3,r16
00196860: 24630abc addiu r3,r3,0x0abc
00196864: 00052840 sll r5,r5,0x01
00196868: 00a32821 addu r5,r5,r3
0019686c: 34048000 ori r4,r0,0x8000
00196870: 94a30000 lhu r3,0x0000(r5)			
00196874: 00c42007 srav r4,r4,r6
00196878: 00641825 or r3,r3,r4
0019687c: a4a30000 sh r3,0x0000(r5)				
00196880: 8fbf001c lw r31,0x001c(r29)
00196884: 8fb20018 lw r18,0x0018(r29)
00196888: 8fb10014 lw r17,0x0014(r29)
0019688c: 8fb00010 lw r16,0x0010(r29)
00196890: 27bd0020 addiu r29,r29,0x0020
00196894: 03e00008 jr r31
00196898: 00000000 nop