AT List Sorting

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
00183acc: 00805821 addu r11,r4,r0		r11 = Unit ID
00183ad0: 00a07021 addu r14,r5,r0		r14 = Preset Value
00183ad4: 000b10c0 sll r2,r11,0x03		ID * 8
00183ad8: 004b1023 subu r2,r2,r11		ID * 7
00183adc: 00021180 sll r2,r2,0x06		ID * 448
00183ae0: 3c038019 lui r3,0x8019
00183ae4: 246308cc addiu r3,r3,0x08cc
00183ae8: 00436021 addu r12,r2,r3		r12 = Unit's Data Pointer
00183aec: 00005021 addu r10,r0,r0		Counter = 0
00183af0: 30c3ffff andi r3,r6,0xffff		r3 = Current CTs
00183af4: 256d0040 addiu r13,r11,0x0040		r13 = Unit ID + 0x40
00183af8: 340f0012 ori r15,r0,0x0012		r15 = 0x12
00183afc: 00e04821 addu r9,r7,r0		r9 = Stack Pointer
00183b00: 95220002 lhu r2,0x0002(r9)		Load CTs
00183b04: 00000000 nop
00183b08: 0062102b sltu r2,r3,r2
00183b0c: 1040001f beq r2,r0,0x00183b8c		Branch if Current CTs >= CTs
00183b10: 29420027 slti r2,r10,0x0027
00183b14: 1040000b beq r2,r0,0x00183b44		Branch if Counter >= 0x27
00183b18: 34080027 ori r8,r0,0x0027		Sort Counter = 0x27
00183b1c: 24e7009c addiu r7,r7,0x009c		Stack Pointer += 0x9c (last entry)
00183b20: 88e2ffff lwl r2,-0x0001(r7)		Load AT data (Sort for AT list)
00183b24: 98e2fffc lwr r2,-0x0004(r7)
00183b28: 00000000 nop
00183b2c: a8e20003 swl r2,0x0003(r7)		Store AT data
00183b30: b8e20000 swr r2,0x0000(r7)
00183b34: 2508ffff addiu r8,r8,0xffff		Sort Counter --
00183b38: 0148102a slt r2,r10,r8
00183b3c: 1440fff8 bne r2,r0,0x00183b20		Branch if Counter < Sort Counter (farther in, sort less)
00183b40: 24e7fffc addiu r7,r7,0xfffc		Stack Pointer -= 4
00183b44: 01601821 addu r3,r11,r0		r3 = Unit ID
00183b48: 11c0000e beq r14,r0,0x00183b84	Branch if PV = 0 (skip skillset check)
00183b4c: a5260002 sh r6,0x0002(r9)		Store CTs = Current CTs
00183b50: 9182016f lbu r2,0x016f(r12)		Load Skillset of Last Attack
00183b54: 00000000 nop
00183b58: 144f0003 bne r2,r15,0x00183b68	Branch if Skillset != 0x12 (Jump)
00183b5c: 01a01821 addu r3,r13,r0		r3 = Unit ID + 0x40
00183b60: 08060ee1 j 0x00183b84
00183b64: 25630060 addiu r3,r11,0x0060		r3 = Unit ID + 0x60
00183b68: 85820170 lh r2,0x0170(r12)		Load Unit's Last Attack ID
00183b6c: 00000000 nop
00183b70: a1220001 sb r2,0x0001(r9)		Store Last Attack ID
00183b74: 28420100 slti r2,r2,0x0100
00183b78: 14400002 bne r2,r0,0x00183b84		Branch if Last Attack < 0x100
00183b7c: 00000000 nop
00183b80: 2563ffc0 addiu r3,r11,0xffc0		r3 = Unit ID - 0x40
00183b84: 08060ee7 j 0x00183b9c
00183b88: a1230000 sb r3,0x0000(r9)		Store Unit ID + Flags
00183b8c: 254a0001 addiu r10,r10,0x0001		Counter ++
00183b90: 29420028 slti r2,r10,0x0028
00183b94: 1440ffda bne r2,r0,0x00183b00		Branch if Counter < 0x28
00183b98: 25290004 addiu r9,r9,0x0004		Stack Pointer += 4
00183b9c: 39420028 xori r2,r10,0x0028
00183ba0: 03e00008 jr r31
00183ba4: 0002102b sltu r2,r0,r2		r2 = 0 if Counter = 0x28 (everything was sorted)