Attack Preparation

From Final Fantasy Hacktics Wiki
Revision as of 03:51, 11 December 2012 by Choto (talk | contribs)
Jump to navigation Jump to search
r21 = Misc Unit Data
r20 = Preset Value (PV)
    0x00 - Charge

0017c45c: 27bdffb0 addiu r29,r29,0xffb0
0017c460: afb5003c sw r21,0x003c(r29)
0017c464: 00a0a821 addu r21,r5,r0
0017c468: afb40038 sw r20,0x0038(r29)
0017c46c: 00c0a021 addu r20,r6,r0
0017c470: 27a50010 addiu r5,r29,0x0010
0017c474: afbf0048 sw r31,0x0048(r29)
0017c478: afb70044 sw r23,0x0044(r29)
0017c47c: afb60040 sw r22,0x0040(r29)
0017c480: afb30034 sw r19,0x0034(r29)
0017c484: afb20030 sw r18,0x0030(r29)
0017c488: afb1002c sw r17,0x002c(r29)
0017c48c: 0c01788b jal 0x0005e22c		Transfer target ID routine
0017c490: afb00028 sw r16,0x0028(r29)
0017c494: 93a30010 lbu r3,0x0010(r29)		load target ID
0017c498: 00000000 nop
0017c49c: 2c620015 sltiu r2,r3,0x0015		set on less than 20 (party?)
0017c4a0: 104000dd beq r2,r0,0x 0017c818		jump to writes action taken if not in party
0017c4a4: 000310c0 sll r2,r3,0x03
0017c4a8: 00431023 subu r2,r2,r3
0017c4ac: 00021180 sll r2,r2,0x06
0017c4b0: 3c038019 lui r3,0x8019
0017c4b4: 246308cc addiu r3,r3,0x08cc		
0017c4b8: 00439821 addu r19,r2,r3		r19 = unit data
0017c4bc: 92620001 lbu r2,0x0001(r19)		load unit ID
0017c4c0: 340400ff ori r4,r0,0x00ff		
0017c4c4: 104400d4 beq r2,r4,0x 0017c818		branch if unitID doesn't exist
0017c4c8: 34020006 ori r2,r0,0x0006		
0017c4cc: 93a3001a lbu r3,0x001a(r29)		load 0x17c in unit data?
0017c4d0: 00000000 nop
0017c4d4: 1462000e bne r3,r2,0x 0017c510		branch if 0x17c in unit data isn't 0x06?
0017c4d8: 0000b021 addu r22,r0,r0		
0017c4dc: 93a3001b lbu r3,0x001b(r29)		load Target ID
0017c4e0: 00000000 nop
0017c4e4: 2c620015 sltiu r2,r3,0x0015
0017c4e8: 104000cb beq r2,r0,0x 0017c818		branch if unit not in party
0017c4ec: 000310c0 sll r2,r3,0x03
0017c4f0: 00431023 subu r2,r2,r3
0017c4f4: 00021180 sll r2,r2,0x06
0017c4f8: 3c018019 lui r1,0x8019
0017c4fc: 00220821 addu r1,r1,r2
0017c500: 902208cd lbu r2,0x08cd(r1)		load party ID?	
0017c504: 00000000 nop
0017c508: 104400f4 beq r2,r4,0x 0017c8dc		branch if party ID != 0xff?
0017c50c: 2402ffff addiu r2,r0,0xffff		r2 - 1
0017c510: 93a20011 lbu r2,0x0011(r29)		load skillset of last attack
0017c514: 3c018006 lui r1,0x8006
0017c518: 00220821 addu r1,r1,r2
0017c51c: 90235cb4 lbu r3,0x5cb4(r1)		action menu bytes
0017c520: 00000000 nop
0017c524: 2c62000d sltiu r2,r3,0x000d		set if less than 0d
0017c528: 104000bb beq r2,r0,0x 0017c818		branch if not
0017c52c: 00031080 sll r2,r3,0x02
0017c530: 3c018017 lui r1,0x8017
0017c534: 00220821 addu r1,r1,r2
0017c538: 8c2240e8 lw r2,0x40e8(r1)		load return address based on action menu byte
0017c53c: 00000000 nop
0017c540: 00400008 jr r2			jump to return address
0017c544: 00000000 nop
Item Inventory
0017c548: 93b10018 lbu r17,0x0018(r29)		load used item ID
0017c54c: 00000000 nop
0017c550: 323200ff andi r18,r17,0x00ff
0017c554: 00121040 sll r2,r18,0x01		item ID*2
0017c558: 00521021 addu r2,r2,r18		item ID*2 + Item ID
0017c55c: 00021080 sll r2,r2,0x02		(item ID*2 + Item ID)*4
0017c560: 3c018006 lui r1,0x8006
0017c564: 00220821 addu r1,r1,r2
0017c568: 90232ebd lbu r3,0x2ebd(r1)		load item type
0017c56c: 34020022 ori r2,r0,0x0022		
0017c570: 146200da bne r3,r2,0x 0017c8dc		skip to end if used item is not an item. not necessary?
0017c574: 2402ffff addiu r2,r0,0xffff		r2 = -1
0017c578: 27a40010 addiu r4,r29,0x0010
0017c57c: 0c01788b jal 0x0005e22c		transfer target ID
0017c580: 02a02821 addu r5,r21,r0		r5 = 0x182 in unit data (mount data)
0017c584: 26300080 addiu r16,r17,0x0080		r16 = used ability ID
0017c588: 12800067 beq r20,r0,0x 0017c728	branch if r20 is 0
0017c58c: a6b00002 sh r16,0x0002(r21)		store used ability ID
0017c590: 32820001 andi r2,r20,0x0001		
0017c594: 10400064 beq r2,r0,0x 0017c728		branch if r20 is not 01
0017c598: 02602021 addu r4,r19,r0		r4 = unit data
0017c59c: 02402821 addu r5,r18,r0		r5 = used item ID
0017c5a0: 0c05f255 jal 0x 0017c954		jump to decrement item quantity
0017c5a4: 34060001 ori r6,r0,0x0001		input value = 01
0017c5a8: 34020001 ori r2,r0,0x0001
0017c5ac: 0805f1ca j 0x 0017c728			jump to write action taken, return r2=01
0017c5b0: a2620188 sb r2,0x0188(r19)		store action taken
Weapon Inventory
0017c5b4: 341 0017e ori r16,r0,0x017e				
0017c5b8: 93b10018 lbu r17,0x0018(r29)		
0017c5bc: 3c048006 lui r4,0x8006		
0017c5c0: 24840ea2 addiu r4,r4,0x0ea2		load ability data 2 (@ ability 0x170)
0017c5c4: 00111040 sll r2,r17,0x01
0017c5c8: 00511021 addu r2,r2,r17
0017c5cc: 00021080 sll r2,r2,0x02
0017c5d0: 3c018006 lui r1,0x8006
0017c5d4: 00220821 addu r1,r1,r2
0017c5d8: 90232ebd lbu r3,0x2ebd(r1)		load item type?
0017c5dc: 00101400 sll r2,r16,0x10
0017c5e0: 00021403 sra r2,r2,0x10
0017c5e4: 00441021 addu r2,r2,r4
0017c5e8: 90420000 lbu r2,0x0000(r2)				
0017c5ec: 00000000 nop
0017c5f0: 10430007 beq r2,r3,0x 0017c610		
0017c5f4: 26020001 addiu r2,r16,0x0001
0017c5f8: 00408021 addu r16,r2,r0
0017c5fc: 00021400 sll r2,r2,0x10
0017c600: 00021403 sra r2,r2,0x10
0017c604: 2842018a slti r2,r2,0x018a
0017c608: 1440fff5 bne r2,r0,0x 0017c5e0
0017c60c: 00101400 sll r2,r16,0x10

<----1---->

0017c610: 00101400 sll r2,r16,0x10
0017c614: 00021403 sra r2,r2,0x10
0017c618: 3403018a ori r3,r0,0x018a
0017c61c: 1043007e beq r2,r3,0x 0017c818
0017c620: 27a40010 addiu r4,r29,0x0010
0017c624: 0c01788b jal 0x0005e22c		transfer target ID
0017c628: 02a02821 addu r5,r21,r0
0017c62c: 1280003e beq r20,r0,0x 0017c728		
0017c630: a6b00002 sh r16,0x0002(r21)
0017c634: 32820001 andi r2,r20,0x0001
0017c638: 1040003b beq r2,r0,0x 0017c728
0017c63c: 02602021 addu r4,r19,r0
0017c640: 02202821 addu r5,r17,r0
0017c644: 0c05f255 jal 0x 0017c954		item quantity decrement
0017c648: 34060001 ori r6,r0,0x0001
0017c64c: 34020001 ori r2,r0,0x0001
0017c650: 0805f1ca j 0x 0017c728
0017c654: a2620188 sb r2,0x0188(r19)
Math Skill
0017c658: 3404fe62 ori r4,r0,0xfe62
0017c65c: 97b00012 lhu r16,0x0012(r29)
0017c660: 97a20014 lhu r2,0x0014(r29)
0017c664: 97a30016 lhu r3,0x0016(r29)
0017c668: 00441021 addu r2,r2,r4		r2 - 19e
0017c66c: 3042ffff andi r2,r2,0xffff
0017c670: 2c420008 sltiu r2,r2,0x0008
0017c674: 10400068 beq r2,r0,0x 0017c818		branch if not using a math skill ability
0017c678: 00641021 addu r2,r3,r4
0017c67c: 3042ffff andi r2,r2,0xffff
0017c680: 2c420008 sltiu r2,r2,0x0008
0017c684: 10400064 beq r2,r0,0x 0017c818		same check for 2nd parameter?
0017c688: 3202ffff andi r2,r16,0xffff
0017c68c: 2c420170 sltiu r2,r2,0x0170
0017c690: 10400061 beq r2,r0,0x 0017c818		check if 3rd parameter is an active ability
0017c694: 27a40010 addiu r4,r29,0x0010
0017c698: 0c01788b jal 0x0005e22c		transfer target data
0017c69c: 02a02821 addu r5,r21,r0
0017c6a0: 12800021 beq r20,r0,0x 0017c728
0017c6a4: 32820001 andi r2,r20,0x0001
0017c6a8: 1040001f beq r2,r0,0x 0017c728
0017c6ac: 34020001 ori r2,r0,0x0001
0017c6b0: 0805f1ca j 0x 0017c728
0017c6b4: a2620188 sb r2,0x0188(r19)
Elemental
0017c6b8: 0c05fcb6 jal 0x 0017f2d8
0017c6bc: 02602021 addu r4,r19,r0
0017c6c0: 0805f1ff j 0x 0017c7fc
0017c6c4: a7a20012 sh r2,0x0012(r29)
Katana Inventory
0017c6c8: 93b10018 lbu r17,0x0018(r29)
0017c6cc: 00000000 nop
0017c6d0: 2622ffda addiu r2,r17,0xffda
0017c6d4: 2c42000a sltiu r2,r2,0x000a
0017c6d8: 1040004f beq r2,r0,0x 0017c818
0017c6dc: 26300026 addiu r16,r17,0x0026
0017c6e0: 32820001 andi r2,r20,0x0001
0017c6e4: 10400045 beq r2,r0,0x 0017c7fc
0017c6e8: a7b00012 sh r16,0x0012(r29)
0017c6ec: 02602021 addu r4,r19,r0
0017c6f0: 02202821 addu r5,r17,r0
0017c6f4: 0c05f255 jal 0x 0017c954
0017c6f8: 34060001 ori r6,r0,0x0001
0017c6fc: 0805f1ff j 0x 0017c7fc
0017c700: 00000000 nop
Attack
0017c704: 27a40010 addiu r4,r29,0x0010
0017c708: 0c01788b jal 0x0005e22c		transfer target ID
0017c70c: 02a02821 addu r5,r21,r0
0017c710: 12800004 beq r20,r0,0x 0017c724
0017c714: 32820001 andi r2,r20,0x0001
0017c718: 10400002 beq r2,r0,0x 0017c724
0017c71c: 34020001 ori r2,r0,0x0001
0017c720: a2620188 sb r2,0x0188(r19)
0017c724: a6a00002 sh r0,0x0002(r21)		store last attack used?
0017c728: 0805f237 j 0x 0017c8dc
0017c72c: 34020001 ori r2,r0,0x0001
Jump
0017c730: 27a40010 addiu r4,r29,0x0010
0017c734: 0c01788b jal 0x0005e22c		transfer target data
0017c738: 02a02821 addu r5,r21,r0
0017c73c: 12800013 beq r20,r0,0x 0017c78c
0017c740: 34030032 ori r3,r0,0x0032
0017c744: 92620038 lbu r2,0x0038(r19)		load speed
0017c748: 00000000 nop
0017c74c: 0062001a div r3,r2			0x32 / speed?
0017c750: 00001812 mflo r3
0017c754: 00000000 nop
0017c758: 00609021 addu r18,r3,r0
0017c75c: 16400002 bne r18,r0,0x 0017c768
0017c760: 02401021 addu r2,r18,r0
0017c764: 34020001 ori r2,r0,0x0001
0017c768: a262015d sb r2,0x015d(r19)		store current ability CT!!
0017c76c: 32820001 andi r2,r20,0x0001
0017c770: 10400006 beq r2,r0,0x 0017c78c
0017c774: 02602021 addu r4,r19,r0
0017c778: 34050006 ori r5,r0,0x0006
0017c77c: 34020001 ori r2,r0,0x0001
0017c780: a0820188 sb r2,0x0188(r4)
0017c784: 0c0179ea jal 0x0005e7a8		set status flags - jump
0017c788: a0820187 sb r2,0x0187(r4)
0017c78c: 3402018a ori r2,r0,0x018a
0017c790: a6a20002 sh r2,0x0002(r21)		store last attack used
0017c794: 0805f237 j 0x 0017c8dc
0017c798: 34020003 ori r2,r0,0x0003
Charge
0017c79c: 97b00012 lhu r16,0x0012(r29)
0017c7a0: 00000000 nop
0017c7a4: 2602fe6a addiu r2,r16,0xfe6a		ability ID - 196
0017c7a8: 2c420008 sltiu r2,r2,0x0008
0017c7ac: 1040001a beq r2,r0,0x 0017c818		check if ability is charge ability
0017c7b0: 27a40010 addiu r4,r29,0x0010
0017c7b4: 0c01788b jal 0x0005e22c		transfer target ID
0017c7b8: 02a02821 addu r5,r21,r0
0017c7bc: 00101400 sll r2,r16,0x10
0017c7c0: 000213c3 sra r2,r2,0x0f
0017c7c4: 3c018006 lui r1,0x8006
0017c7c8: 00220821 addu r1,r1,r2
0017c7cc: 90320d18 lbu r18,0x0d18(r1)		get charges power?
0017c7d0: 32820001 andi r2,r20,0x0001
0017c7d4: 10400003 beq r2,r0,0x 0017c7e4
0017c7d8: 34160001 ori r22,r0,0x0001
0017c7dc: 34020001 ori r2,r0,0x0001
0017c7e0: a2620187 sb r2,0x0187(r19)		store movement taken
0017c7e4: 0805f1ff j 0x 0017c7fc
0017c7e8: 0000b821 addu r23,r0,r0
Defend
0017c7ec: 0805f237 j 0x 0017c8dc
0017c7f0: 00001021 addu r2,r0,r0
Change Equipment
0017c7f4: 0805f237 j 0x 0017c8dc
0017c7f8: 34020002 ori r2,r0,0x0002
Default / Monster
0017c7fc: 16c00020 bne r22,r0,0x 0017c880
0017c800: 00000000 nop
0017c804: 97b00012 lhu r16,0x0012(r29)
0017c808: 00000000 nop
0017c80c: 2e020170 sltiu r2,r16,0x0170
0017c810: 14400003 bne r2,r0,0x 0017c820		jump to set ability CT
0017c814: 27a40010 addiu r4,r29,0x0010

Blank jumps to this address

0017c818: 0805f237 j 0x 0017c8dc			jump to write action taken
0017c81c: 2402ffff addiu r2,r0,0xffff

Sets ability CT from here

0017c820: 0c01788b jal 0x0005e22c
0017c824: 02a02821 addu r5,r21,r0
0017c828: 00101c00 sll r3,r16,0x10
0017c82c: 00031c03 sra r3,r3,0x10
0017c830: 000310c0 sll r2,r3,0x03
0017c834: 00431023 subu r2,r2,r3
0017c838: 00021040 sll r2,r2,0x01
0017c83c: 3c038006 lui r3,0x8006
0017c840: 2463fbf0 addiu r3,r3,0xfbf0		load ability data
0017c844: 00431021 addu r2,r2,r3
0017c848: 9043000c lbu r3,0x000c(r2)		load CT
0017c84c: 90420005 lbu r2,0x0005(r2)		load flags 3
0017c850: 3072007f andi r18,r3,0x007f		r18 = CT as signed?
0017c854: 30570004 andi r23,r2,0x0004		persevere check
0017c858: 92630092 lbu r3,0x0092(r19)		load support 4
0017c85c: 16e00008 bne r23,r0,0x 0017c880	branch if persevere checked
0017c860: 30620008 andi r2,r3,0x0008		
0017c864: 10400002 beq r2,r0,0x 0017c870		branch if short charge not equipped
0017c868: 26420001 addiu r2,r18,0x0001		CT + 1?
0017c86c: 00029042 srl r18,r2,0x01		CT / 2
0017c870: 30620004 andi r2,r3,0x0004		
0017c874: 10400002 beq r2,r0,0x 0017c880		branch if non-charge equipped
0017c878: 00000000 nop
0017c87c: 00009021 addu r18,r0,r0		CT = 0
0017c880: 12800014 beq r20,r0,0x 0017c8d4	control
0017c884: 32820001 andi r2,r20,0x0001
0017c888: 10400012 beq r2,r0,0x 0017c8d4		control?
0017c88c: a272015d sb r18,0x015d(r19)		store current ability CT
0017c890: 3c028019 lui r2,0x8019
0017c894: 8c42f5f0 lw r2,-0x0a10(r2)		load reaction check
0017c898: 00000000 nop
0017c89c: 1440000e bne r2,r0,0x 0017c8d8		branch if reaction exists?
0017c8a0: 324200ff andi r2,r18,0x00ff		r2 = CT
0017c8a4: 34020001 ori r2,r0,0x0001
0017c8a8: a2620188 sb r2,0x0188(r19)		store action taken
0017c8ac: 324200ff andi r2,r18,0x00ff		
0017c8b0: 10400008 beq r2,r0,0x 0017c8d4		
0017c8b4: 32e200ff andi r2,r23,0x00ff
0017c8b8: 10400003 beq r2,r0,0x 0017c8c8
0017c8bc: 02602021 addu r4,r19,r0
0017c8c0: 0805f233 j 0x 0017c8cc
0017c8c4: 34050008 ori r5,r0,0x0008		set status flags = charging
0017c8c8: 34050005 ori r5,r0,0x0005		set status flags = jump and performing?
0017c8cc: 0c0179ea jal 0x0005e7a8		set status flags
0017c8d0: 00000000 nop
0017c8d4: 324200ff andi r2,r18,0x00ff		r2 = CT
0017c8d8: 2c420001 sltiu r2,r2,0x0001		set if CT = 0
0017c8dc: 8fbf0048 lw r31,0x0048(r29)
0017c8e0: 8fb70044 lw r23,0x0044(r29)
0017c8e4: 8fb60040 lw r22,0x0040(r29)
0017c8e8: 8fb5003c lw r21,0x003c(r29)
0017c8ec: 8fb40038 lw r20,0x0038(r29)
0017c8f0: 8fb30034 lw r19,0x0034(r29)
0017c8f4: 8fb20030 lw r18,0x0030(r29)
0017c8f8: 8fb1002c lw r17,0x002c(r29)
0017c8fc: 8fb00028 lw r16,0x0028(r29)
0017c900: 27bd0050 addiu r29,r29,0x0050
0017c904: 03e00008 jr r31
0017c908: 00000000 nop