Difference between revisions of "Check for good units to target (based on distance,status,coordinate)"

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
(Updated Documentation)
Line 20: Line 20:
 
   0019975c: 0c066632 jal 0x001998c8 [[Check if Regen/Charm/DM/Reraise/DA Can be Inflicted]]
 
   0019975c: 0c066632 jal 0x001998c8 [[Check if Regen/Charm/DM/Reraise/DA Can be Inflicted]]
 
   00199760: 02002021 addu r4,r16,r0
 
   00199760: 02002021 addu r4,r16,r0
   00199764: 14400002 bne r2,r0,0x00199770 branch if not?
+
   00199764: 14400002 bne r2,r0,0x00199770 Next Unit if Unit has Stop/Don't Act/Sleep/Chicken/Charm or spell can't go off in time
 
   00199768: 00000000 nop
 
   00199768: 00000000 nop
   0019976c: a2330c8d sb r19,0x0c8d(r17) store good unit to target?
+
   0019976c: a2330c8d sb r19,0x0c8d(r17) Unit Targetable = True
 
    
 
    
 
   00199770: 26100001 addiu r16,r16,0x0001
 
   00199770: 26100001 addiu r16,r16,0x0001
Line 35: Line 35:
 
   00199790: 02406821 addu r13,r18,r0
 
   00199790: 02406821 addu r13,r18,r0
 
   00199794: 02406021 addu r12,r18,r0
 
   00199794: 02406021 addu r12,r18,r0
 +
 
   00199798: 92420e3b lbu r2,0x0e3b(r18) load map max X?
 
   00199798: 92420e3b lbu r2,0x0e3b(r18) load map max X?
 
   0019979c: 00000000 nop
 
   0019979c: 00000000 nop
Line 41: Line 42:
 
   001997a8: 25ab0174 addiu r11,r13,0x0174
 
   001997a8: 25ab0174 addiu r11,r13,0x0174
 
   001997ac: 258a0a74 addiu r10,r12,0x0a74 load ?? data
 
   001997ac: 258a0a74 addiu r10,r12,0x0a74 load ?? data
   001997b0: 95490000 lhu r9,0x0000(r10) load coordinate?
+
   001997b0: 95490000 lhu r9,0x0000(r10) Load Highest Target Priority
 
   001997b4: 00000000 nop
 
   001997b4: 00000000 nop
   001997b8: 11200030 beq r9,r0,0x0019987c
+
   001997b8: 11200030 beq r9,r0,0x0019987c               Branch if Highest Target Priority hasn't been set yet
 
   001997bc: 00000000 nop
 
   001997bc: 00000000 nop
 
   001997c0: 92420e3a lbu r2,0x0e3a(r18) load map max y?
 
   001997c0: 92420e3a lbu r2,0x0e3a(r18) load map max y?
Line 51: Line 52:
 
   001997d0: 01603021 addu r6,r11,r0
 
   001997d0: 01603021 addu r6,r11,r0
 
   001997d4: 00a91004 sllv r2,r9,r5
 
   001997d4: 00a91004 sllv r2,r9,r5
   001997d8: 30428000 andi r2,r2,0x8000 check some flag
+
   001997d8: 30428000 andi r2,r2,0x8000
   001997dc: 10400022 beq r2,r0,0x00199868 branch if not
+
   001997dc: 10400022 beq r2,r0,0x00199868         Next X if Targeted Unit is not in that Targeting Matrix Coordinate
 
   001997e0: 00000000 nop
 
   001997e0: 00000000 nop
   001997e4: a0c00000 sb r0,0x0000(r6)
+
   001997e4: a0c00000 sb r0,0x0000(r6)                   Empty part of Target Priority
 
   001997e8: 00008021 addu r16,r0,r0
 
   001997e8: 00008021 addu r16,r0,r0
 
   001997ec: 00c03821 addu r7,r6,r0
 
   001997ec: 00c03821 addu r7,r6,r0
 
   001997f0: 02202021 addu r4,r17,r0
 
   001997f0: 02202021 addu r4,r17,r0
 
   001997f4: 02501021 addu r2,r18,r16
 
   001997f4: 02501021 addu r2,r18,r16
   001997f8: 90420c8d lbu r2,0x0c8d(r2) load good unit to targeT
+
   001997f8: 90420c8d lbu r2,0x0c8d(r2) Load Can Target List
 
   001997fc: 00000000 nop
 
   001997fc: 00000000 nop
   00199800: 10400015 beq r2,r0,0x00199858 go to next unit if not
+
   00199800: 10400015 beq r2,r0,0x00199858 Next Unit if unit cannot/should not be targeted
 
   00199804: 00000000 nop
 
   00199804: 00000000 nop
 
   00199808: 90820047 lbu r2,0x0047(r4) load coordinate
 
   00199808: 90820047 lbu r2,0x0047(r4) load coordinate
Line 76: Line 77:
 
   00199834: 00021023 subu r2,r0,r2 make positive
 
   00199834: 00021023 subu r2,r0,r2 make positive
 
   00199838: 00621821 addu r3,r3,r2 r3 = distance
 
   00199838: 00621821 addu r3,r3,r2 r3 = distance
   0019983c: 2862000b slti r2,r3,0x000b set if distance < 11
+
   0019983c: 2862000b slti r2,r3,0x000b Next Unit if distance < 11 (more than 5 Panels away)
 
   00199840: 10400005 beq r2,r0,0x00199858 branch if not
 
   00199840: 10400005 beq r2,r0,0x00199858 branch if not
   00199844: 01e31823 subu r3,r15,r3 distance - 10?
+
   00199844: 01e31823 subu r3,r15,r3 10 - Distance (5 Panels away)
 
   00199848: 90e20000 lbu r2,0x0000(r7) load ??
 
   00199848: 90e20000 lbu r2,0x0000(r7) load ??
 
   0019984c: 00000000 nop
 
   0019984c: 00000000 nop
 
   00199850: 00431021 addu r2,r2,r3 add amounts
 
   00199850: 00431021 addu r2,r2,r3 add amounts
   00199854: a0e20000 sb r2,0x0000(r7) store new
+
   00199854: a0e20000 sb r2,0x0000(r7) Save Distance
 
   00199858: 26100001 addiu r16,r16,0x0001
 
   00199858: 26100001 addiu r16,r16,0x0001
 
   0019985c: 2a020015 slti r2,r16,0x0015
 
   0019985c: 2a020015 slti r2,r16,0x0015

Revision as of 02:08, 29 March 2017

Check for good units to target (based on distance,status,coordinate)

 0019971c: 27bdffc8 addiu r29,r29,0xffc8
 00199720: afb20028 sw r18,0x0028(r29)
 00199724: 3c12801a lui r18,0x801a
 00199728: 2652f3c4 addiu r18,r18,0xf3c4
 0019972c: afb00020 sw r16,0x0020(r29)
 00199730: 00008021 addu r16,r0,r0
 00199734: afb3002c sw r19,0x002c(r29)
 00199738: 34130001 ori r19,r0,0x0001
 0019973c: afbf0030 sw r31,0x0030(r29)
 00199740: afb10024 sw r17,0x0024(r29)
 00199744: 02508821 addu r17,r18,r16
 00199748: a2200c8d sb r0,0x0c8d(r17)
 0019974c: 0c065b23 jal 0x00196c8c			Check target type
 00199750: 02002021 addu r4,r16,r0
 00199754: 14400006 bne r2,r0,0x00199770		branch if not targetable
 00199758: 00000000 nop
 0019975c: 0c066632 jal 0x001998c8			Check if Regen/Charm/DM/Reraise/DA Can be Inflicted
 00199760: 02002021 addu r4,r16,r0
 00199764: 14400002 bne r2,r0,0x00199770		Next Unit if Unit has Stop/Don't Act/Sleep/Chicken/Charm or spell can't go off in time
 00199768: 00000000 nop
 0019976c: a2330c8d sb r19,0x0c8d(r17)			Unit Targetable = True
 
 00199770: 26100001 addiu r16,r16,0x0001
 00199774: 2a020015 slti r2,r16,0x0015
 00199778: 1440fff3 bne r2,r0,0x00199748		do for all units
 0019977c: 02508821 addu r17,r18,r16
 
 00199780: 00007021 addu r14,r0,r0
 00199784: 3c118019 lui r17,0x8019
 00199788: 263108cc addiu r17,r17,0x08cc
 0019978c: 340f000a ori r15,r0,0x000a
 00199790: 02406821 addu r13,r18,r0
 00199794: 02406021 addu r12,r18,r0
 00199798: 92420e3b lbu r2,0x0e3b(r18)			load map max X?
 0019979c: 00000000 nop
 001997a0: 1840003c blez r2,0x00199894
 001997a4: 00004021 addu r8,r0,r0
 001997a8: 25ab0174 addiu r11,r13,0x0174		
 001997ac: 258a0a74 addiu r10,r12,0x0a74		load ?? data
 001997b0: 95490000 lhu r9,0x0000(r10)			Load Highest Target Priority
 001997b4: 00000000 nop
 001997b8: 11200030 beq r9,r0,0x0019987c               Branch if Highest Target Priority hasn't been set yet
 001997bc: 00000000 nop
 001997c0: 92420e3a lbu r2,0x0e3a(r18)			load map max y?
 001997c4: 00000000 nop
 001997c8: 1840002c blez r2,0x0019987c
 001997cc: 00002821 addu r5,r0,r0
 001997d0: 01603021 addu r6,r11,r0
 001997d4: 00a91004 sllv r2,r9,r5
 001997d8: 30428000 andi r2,r2,0x8000			
 001997dc: 10400022 beq r2,r0,0x00199868	        Next X if Targeted Unit is not in that Targeting Matrix Coordinate
 001997e0: 00000000 nop
 001997e4: a0c00000 sb r0,0x0000(r6)                   Empty part of Target Priority
 001997e8: 00008021 addu r16,r0,r0
 001997ec: 00c03821 addu r7,r6,r0
 001997f0: 02202021 addu r4,r17,r0
 001997f4: 02501021 addu r2,r18,r16
 001997f8: 90420c8d lbu r2,0x0c8d(r2)			Load Can Target List
 001997fc: 00000000 nop
 00199800: 10400015 beq r2,r0,0x00199858		Next Unit if unit cannot/should not be targeted
 00199804: 00000000 nop
 00199808: 90820047 lbu r2,0x0047(r4)			load coordinate
 0019980c: 00000000 nop
 00199810: 00451823 subu r3,r2,r5			coordinate - ??
 00199814: 04610002 bgez r3,0x00199820			branch if out in range?
 00199818: 00000000 nop
 0019981c: 00031823 subu r3,r0,r3			make positive
 00199820: 90820048 lbu r2,0x0048(r4)			load coordinate
 00199824: 00000000 nop
 00199828: 00481023 subu r2,r2,r8
 0019982c: 04410002 bgez r2,0x00199838
 00199830: 00000000 nop
 00199834: 00021023 subu r2,r0,r2			make positive
 00199838: 00621821 addu r3,r3,r2			r3 = distance
 0019983c: 2862000b slti r2,r3,0x000b			Next Unit if distance < 11 (more than 5 Panels away)
 00199840: 10400005 beq r2,r0,0x00199858		branch if not
 00199844: 01e31823 subu r3,r15,r3			10 - Distance (5 Panels away)
 00199848: 90e20000 lbu r2,0x0000(r7)			load ??
 0019984c: 00000000 nop
 00199850: 00431021 addu r2,r2,r3			add amounts
 00199854: a0e20000 sb r2,0x0000(r7)			Save Distance
 00199858: 26100001 addiu r16,r16,0x0001
 0019985c: 2a020015 slti r2,r16,0x0015
 00199860: 1440ffe4 bne r2,r0,0x001997f4
 00199864: 248401c0 addiu r4,r4,0x01c0
 
 00199868: 92420e3a lbu r2,0x0e3a(r18)			load map max x
 0019986c: 24a50001 addiu r5,r5,0x0001			go to next coordinate
 00199870: 00a2102a slt r2,r5,r2			set if < max coordinate
 00199874: 1440ffd7 bne r2,r0,0x001997d4		do for each X coordinate
 00199878: 24c60001 addiu r6,r6,0x0001			increment coordinate array
 0019987c: 256b0010 addiu r11,r11,0x0010		increment unit coordinate array by row
 
 00199880: 92420e3b lbu r2,0x0e3b(r18)
 00199884: 25080001 addiu r8,r8,0x0001
 00199888: 0102102a slt r2,r8,r2
 0019988c: 1440ffc8 bne r2,r0,0x001997b0		do for each y coordinate
 00199890: 254a0002 addiu r10,r10,0x0002
  
 00199894: 25ad0120 addiu r13,r13,0x0120
 00199898: 25ce0001 addiu r14,r14,0x0001
 0019989c: 29c20002 slti r2,r14,0x0002
 001998a0: 1440ffbd bne r2,r0,0x00199798		do for each map level
 001998a4: 258c0024 addiu r12,r12,0x0024
 
 001998a8: 8fbf0030 lw r31,0x0030(r29)
 001998ac: 8fb3002c lw r19,0x002c(r29)
 001998b0: 8fb20028 lw r18,0x0028(r29)
 001998b4: 8fb10024 lw r17,0x0024(r29)
 001998b8: 8fb00020 lw r16,0x0020(r29)
 001998bc: 27bd0038 addiu r29,r29,0x0038
 001998c0: 03e00008 jr r31
 001998c4: 00000000 nop