Player Control Routine?

From Final Fantasy Hacktics Wiki
Revision as of 19:57, 21 April 2024 by Nyzer (talk | contribs) (Added some notes about how the branches work. Seems to have some extra redundancy with can't act/can't move checks...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Player Control Routine? 
001811f8: 27bdffe0 addiu r29,r29,0xffe0
001811fc: afb10014 sw r17,0x0014(r29)
00181200: 00808821 addu r17,r4,r0
00181204: afb00010 sw r16,0x0010(r29)
00181208: 00008021 addu r16,r0,r0
0018120c: afbf001c sw r31,0x001c(r29)
00181210: 0c060445 jal 0x00181114		check whose turn it is
00181214: afb20018 sw r18,0x0018(r29)
00181218: 00401821 addu r3,r2,r0
0018121c: 1060000b beq r3,r0,0x0018124c
00181220: 00000000 nop
00181224: 90620005 lbu r2,0x0005(r3)		load ENTD flags
00181228: 00000000 nop
0018122c: 30420008 andi r2,r2,0x0008		
00181230: 10400005 beq r2,r0,0x00181248		branch if control not  checked
00181234: 00000000 nop
00181238: 906201b8 lbu r2,0x01b8(r3)		load AI setting?
0018123c: 00000000 nop
00181240: 10400002 beq r2,r0,0x0018124c		branch if not auto-battle  or AI
00181244: 00000000 nop
00181248: 34100001 ori r16,r0,0x0001		r16 = 1
0018124c: 92220005 lbu r2,0x0005(r17)		load ENTD flags?
00181250: 00000000 nop
00181254: 30420008 andi r2,r2,0x0008		control flag check
00181258: 0002182b sltu r3,r0,r2		set if controllable unit
0018125c: 12000005 beq r16,r0,0x00181274	branch if not auto battle/ai
00181260: 00609021 addu r18,r3,r0
00181264: 10600022 beq r3,r0,0x001812f0		
00181268: 34020012 ori r2,r0,0x0012		r2 = 12
0018126c: 080604bc j 0x001812f0			jump to end
00181270: 34020011 ori r2,r0,0x0011
00181274: 9230005c lbu r16,0x005c(r17)		load status
00181278: 0c0604c3 jal 0x0018130c		Weapon Guard usability. Returns r2 = 0x00 if unit can evade, 0x01 if not, 0x02 if underwater. Includes Don't Act and "being ridden" check. 
0018127c: 02202021 addu r4,r17,r0
00181280: 92230187 lbu r3,0x0187(r17)		load movement taken
00181284: 32100008 andi r16,r16,0x0008		don't move check
00181288: 00702825 or r5,r3,r16                r5 = 0x01 if unit moved, 0x08 if Don't Moved/immobilized
0018128c: 92230188 lbu r3,0x0188(r17)		load action taken
00181290: 92240186 lbu r4,0x0186(r17)		load turn setting
00181294: 00000000 nop
00181298: 10800012 beq r4,r0,0x001812e4		branch if not units turn
0018129c: 00621825 or r3,r3,r2			        r3 = Action Taken + Weapon Guard Usability output. 0x01 or 0x02 if unit can't act.
001812a0: 14a00005 bne r5,r0,0x001812b8		Branch if unit can't move
001812a4: 306200ff andi r2,r3,0x00ff                   r2 = r3 (can act). Waste of a line? r3 should never be bigger than one byte anyway...
001812a8: 14400007 bne r2,r0,0x001812c8		Branch if can't act/evade, but can move
001812ac: 00000000 nop
001812b0: 080604bc j 0x001812f0                        Can both act and move. Jump to end with r2 = 0
001812b4: 00001021 addu r2,r0,r0
001812b8: 14400003 bne r2,r0,0x001812c8		Branch if can't act/evade or move
001812bc: 00000000 nop
001812c0: 080604bc j 0x001812f0                        Can't move, but can attack. Jump to end with r2 = 0x0E
001812c4: 3402000e ori r2,r0,0x000e
001812c8: 14a00009 bne r5,r0,0x001812f0		Branch to end with r2 = 0x14 if can't move or act
001812cc: 34020014 ori r2,r0,0x0014                    r2 = 0x14 if can't act
001812d0: 306300ff andi r3,r3,0x00ff                   r3 = still shouldn't be bigger than one byte but sure whatever
001812d4: 10600006 beq r3,r0,0x001812f0		Branch to end if user can act (redundant, this was already ruled out?)
001812d8: 00000000 nop
001812dc: 080604bc j 0x001812f0                        Jump to end with r2 = 0x13 if can't act but can move
001812e0: 34020013 ori r2,r0,0x0013
001812e4: 16400002 bne r18,r0,0x001812f0               Branch to end with r2 = 0x0F if r18 has a value? Can only get here if not unit's turn
001812e8: 3402000f ori r2,r0,0x000f
001812ec: 34020010 ori r2,r0,0x0010
001812f0: 8fbf001c lw r31,0x001c(r29)
001812f4: 8fb20018 lw r18,0x0018(r29)
001812f8: 8fb10014 lw r17,0x0014(r29)
001812fc: 8fb00010 lw r16,0x0010(r29)
00181300: 27bd0020 addiu r29,r29,0x0020
00181304: 03e00008 jr r31
00181308: 00000000 nop