In between turn control routine

From Final Fantasy Hacktics Wiki
Revision as of 23:25, 17 March 2021 by Talcall (talk | contribs) (there i put in the stupid 2)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Starting routine

001827f0: 27bdffc0 addiu r29,r29,0xffc0
001827f4: afb5002c sw r21,0x002c(r29)
001827f8: 0000a821 addu r21,r0,r0
001827fc: 34020001 ori r2,r0,0x0001
00182800: afbf003c sw r31,0x003c(r29)
00182804: afbe0038 sw r30,0x0038(r29)
00182808: afb70034 sw r23,0x0034(r29)
0018280c: afb60030 sw r22,0x0030(r29)
00182810: afb40028 sw r20,0x0028(r29)
00182814: afb30024 sw r19,0x0024(r29)
00182818: afb20020 sw r18,0x0020(r29)
0018281c: afb1001c sw r17,0x001c(r29)
00182820: afb0 0018 sw r16,0x0018(r29)
00182824: 1482001f bne r4,r2,0x001828a4		; branch if preset value isn't 01
00182828: afa00010 sw r0,0x0010(r29)

*PV = 1 (initialize data?)

0018282c: 34120003 ori r18,r0,0x0003
00182830: 3c038019 lui r3,0x8019
00182834: 2463f5fa addiu r3,r3,0xf5fa		; Ai data?
00182838: 2402ffff addiu r2,r0,0xffff
0018283c: 3c018019 lui r1,0x8019
00182840: ac20f518 sw r0,-0x0ae8(r1)		; go to next clocktick
00182844: 3c018019 lui r1,0x8019
00182848: ac22f520 sw r2,-0x0ae0(r1)		; active unit = 0xff
0018284c: a4600000 sh r0,0x0000(r3)		; clear team golem amount
00182850: 2652ffff addiu r18,r18,0xffff		; perform 4 times
00182854: 0641fffd bgez r18,0x0018284c
00182858: 2463fffe addiu r3,r3,0xfffe		; address decrement
0018285c: 3c018019 lui r1,0x8019
00182860: a020389d sb r0,0x389d(r1)		; clear mimicable action occurred byte
00182864: 00009021 addu r18,r0,r0
00182868: 340400ff ori r4,r0,0x00ff
0018286c: 3c038019 lui r3,0x8019
00182870: 246308cc addiu r3,r3,0x08cc		; load unit data
00182874: a0600039 sb r0,0x0039(r3)		; store 0 CT
00182878: a0600186 sb r0,0x0186(r3)		; Clear characters turn
0018287c: a0600189 sb r0,0x0189(r3)		; clear unknown byte
00182880: a064015d sb r4,0x015d(r3)		; Store Current ability CT = ff
00182884: 26520001 addiu r18,r18,0x0001
00182888: 2a420015 slti r2,r18,0x0015
0018288c: 1440fff9 bne r2,r0,0x00182874		; clear above data in all unts?
00182890: 246301c0 addiu r3,r3,0x01c0
00182894: 0c06398a jal 0x0018e628		; Store current attack data into AI?
00182898: 00000000 nop
0018289c: 08060c11 j 0x00183044			; jump to end, return r2 = 0xe000
001828a0: 3402e000 ori r2,r0,0xe000
001828a4: 34020002 ori r2,r0,0x0002
001828a8: 14820034 bne r4,r2,0x0018297c		; branch if preset value isn't 02
001828ac: 341e0001 ori r30,r0,0x0001

*PV = 2 : Find unit that is not crystal/dead/jumping/treasure/petrify

001828b0: 00009021 addu r18,r0,r0
001828b4: 340400ff ori r4,r0,0x00ff
001828b8: 3c038019 lui r3,0x8019
001828bc: 246308cc addiu r3,r3,0x08cc		; unit data
001828c0: 90620001 lbu r2,0x0001(r3)		;
001828c4: 00000000 nop
001828c8: 1044000b beq r2,r4,0x001828f8		; unit exists check
001828cc: 00000000 nop
001828d0: 90620058 lbu r2,0x0058(r3)
001828d4: 00000000 nop
001828d8: 30420064 andi r2,r2,0x0064
001828dc: 14400006 bne r2,r0,0x001828f8		; branch if crystal, dead, jumping
001828e0: 00000000 nop
001828e4: 90620059 lbu r2,0x0059(r3)
001828e8: 00000000 nop
001828ec: 30420081 andi r2,r2,0x0081
001828f0: 104001d4 beq r2,r0,0x00183044		; branch to end if not treasure, petrify - should be bne??
001828f4: 3642d000 ori r2,r18,0xd000		; return r2 = unit counter + 0xd000

if crystal dead jumping

001828f8: 26520001 addiu r18,r18,0x0001
001828fc: 2a420015 slti r2,r18,0x0015
00182900: 1440ffef bne r2,r0,0x001828c0		; do for each unit
00182904: 246301c0 addiu r3,r3,0x01c0
00182908: 08060c11 j 0x00183044			; jump to end, return r2 = 0xdf00
0018290c: 3402df00 ori r2,r0,0xdf00

mimic stuff?

00182910: 3c018019 lui r1,0x8019
00182914: 00320821 addu r1,r1,r18
00182918: a020f8b0 sb r0,-0x0750(r1)		; clear ?? active turn byte?
0018291c: 08060c11 j 0x00183044
00182920: 36420300 ori r2,r18,0x0300		; jump to end, return r2 = r18 + 0x0300

Set unit active

00182924: 001410c0 sll r2,r20,0x03
00182928: 00541023 subu r2,r2,r20
0018292c: 00021180 sll r2,r2,0x06
00182930: 3c038019 lui r3,0x8019
00182934: 246308cc addiu r3,r3,0x08cc
00182938: 00438821 addu r17,r2,r3
0018293c: 34030001 ori r3,r0,0x0001
00182940: a2230186 sb r3,0x0186(r17)		; set character turn = true
00182944: a2230027 sb r3,0x0027(r17)		; set character turn = true
00182948: 34030009 ori r3,r0,0x0009
0018294c: a2200039 sb r0,0x0039(r17)		; clear CT
00182950: a2200187 sb r0,0x0187(r17)		; store move available
00182954: a2200188 sb r0,0x0188(r17)		; store action available
00182958: 3c018019 lui r1,0x8019
0018295c: ac23f51c sw r3,-0x0ae4(r1)		; control variable = 0x09
00182960: 3403000a ori r3,r0,0x000a
00182964: 3c018019 lui r1,0x8019
00182968: ac34f520 sw r20,-0x0ae0(r1)		; store unit ID
0018296c: 3c018019 lui r1,0x8019
00182970: ac23f518 sw r3,-0x0ae8(r1)		; go to validate turn
00182974: 08060c11 j 0x00183044			; jump to end
00182978: 36820100 ori r2,r20,0x0100

*PV != 1 or 2

0018297c: 3c168019 lui r22,0x8019
00182980: 26d608cc addiu r22,r22,0x08cc		; load unit data
00182984: 341700ff ori r23,r0,0x00ff
00182988: 3c038019 lui r3,0x8019
0018298c: 8c63f518 lw r3,-0x0ae8(r3)		; load this routine control variable
00182990: 00000000 nop
00182994: 2c620014 sltiu r2,r3,0x0014		; set if less than 20
00182998: 104001a1 beq r2,r0,0x00183020		; branch if not
0018299c: 00031080 sll r2,r3,0x02		;
001829a0: 3c018017 lui r1,0x8017
001829a4: 00220821 addu r1,r1,r2
001829a8: 8c224174 lw r2,0x4174(r1)		; Get return address* (See: jump lookup table)
001829ac: 00000000 nop
001829b0: 00400008 jr r2
001829b4: 00000000 nop

0x00 *next clocktick - increment CT
001829b8: 00009021 addu r18,r0,r0
001829bc: 00008021 addu r16,r0,r0
001829c0: 02168821 addu r17,r16,r22
001829c4: 0c060cb3 jal 0x001832cc		; Status checks
001829c8: 02202021 addu r4,r17,r0		; r17, r4 = unit data
001829cc: 00401821 addu r3,r2,r0
001829d0: 30620001 andi r2,r3,0x0001		;
001829d4: 14400013 bne r2,r0,0x00182a24		; branch if return value is 0x01 = true (being ridden?)
001829d8: 30620020 andi r2,r3,0x0020
001829dc: 92240038 lbu r4,0x0038(r17)		; load speed
001829e0: 10400003 beq r2,r0,0x001829f0		; branch if return value doesn't have slow = true
001829e4: 30620010 andi r2,r3,0x0010
001829e8: 08060a80 j 0x00182a00
001829ec: 00042042 srl r4,r4,0x01		; spd / 2
001829f0: 10400003 beq r2,r0,0x00182a00		; branch if return value doesn't have haste = true
001829f4: 3082ffff andi r2,r4,0xffff		; r2 = spd
001829f8: 00021042 srl r2,r2,0x01		; spd / 2
001829fc: 00822021 addu r4,r4,r			; spd + spd/2
00182a00: 92220039 lbu r2,0x0039(r17)		; load CT		;
00182a04: 00000000 nop
00182a08: 00821821 addu r3,r4,r			; add CT
00182a0c: 3062ffff andi r2,r3,0xffff		; r2 = new CT
00182a10: 2c4200ff sltiu r2,r2,0x00ff		; set if new CT < 0xff
00182a14: 14400002 bne r2,r0,0x00182a20		; branch if so
00182a18: 00000000 nop
00182a1c: 340300fe ori r3,r0,0x00fe
00182a20: a2230039 sb r3,0x0039(r17)		; store CT = 0xfe
00182a24: 26520001 addiu r18,r18,0x0001
00182a28: 2a420015 slti r2,r18,0x0015
00182a2c: 1440ffe4 bne r2,r0,0x001829c0
00182a30: 261001c0 addiu r16,r16,0x01c0		; perform above for all units
00182a34: 3c018019 lui r1,0x8019
00182a38: ac3ef518 sw r30,-0x0ae8(r1)		; go to dead processing and get next turn
00182a3c: 08060c08 j 0x00183020
00182a40: 00000000 nop

0x01 *Delay turn while jumping, dead/crystal/treasure processing, next turn if 100 CT found
00182a44: 34130063 ori r19,r0,0x0063
00182a48: 341400ff ori r20,r0,0x00ff
00182a4c: 00009021 addu r18,r0,r0
00182a50: 02c08021 addu r16,r22,r		; r16 = unit data

loop - Get highest CT Dead unit

00182a54: 0c060cb3 jal 0x001832cc		; Status checks

; 0x01 if being ridden ; 0x01 if some status found ; 0x06 if dead ; 0x0a if slept ; 0x10 if haste ; 0x20 if slow ; 0xff - unit doesn't exist

00182a58: 02002021 addu r4,r16,r0
00182a5c: 30420001 andi r2,r2,0x0001
00182a60: 14400008 bne r2,r0,0x00182a84		; branch if not dead
00182a64: 00000000 nop

if dead

00182a68: 92030039 lbu r3,0x0039(r16)		; load CT
00182a6c: 00000000 nop
00182a70: 0263102b sltu r2,r19,r3		; set if less than 99
00182a74: 10400003 beq r2,r0,0x00182a84		; branch if CT = 100
00182a78: 00000000 nop
00182a7c: 0240a021 addu r20,r18,r		; r20 = battle ID of dead unit
00182a80: 00609821 addu r19,r3,r0		; r19 = CT
00182a84: 26520001 addiu r18,r18,0x0001
00182a88: 2a420015 slti r2,r18,0x0015
00182a8c: 1440fff1 bne r2,r0,0x00182a54		; Do for each unit
00182a90: 261001c0 addiu r16,r16,0x01c0		;
00182a94: 12970043 beq r20,r23,0x00182ba4	; branch if no dead unit found
00182a98: 001410c0 sll r2,r20,0x03
00182a9c: 00541023 subu r2,r2,r20
00182aa0: 00021180 sll r2,r2,0x06
00182aa4: 00568821 addu r17,r2,r22
00182aa8: 92220058 lbu r2,0x0058(r17)		; load status
00182aac: 00000000 nop
00182ab0: 30420004 andi r2,r2,0x0004
00182ab4: 10400003 beq r2,r0,0x00182ac4		; branch if not jumping
00182ab8: 34020063 ori r2,r0,0x0063		;

if jumping

00182abc: 08060c0e j 0x00183038
00182ac0: a2220039 sb r2,0x0039(r17)		; store 99 CT
00182ac4: 92220039 lbu r2,0x0039(r17)		; load CT
00182ac8: 00000000 nop
00182acc: 14570003 bne r2,r23,0x00182adc	; branch if CT != 0xff
00182ad0: 3c0251eb lui r2,0x51eb
00182ad4: 08060ac3 j 0x00182b0c
00182ad8: a2200039 sb r0,0x0039(r17)		; clear CT
00182adc: 3442851f ori r2,r2,0x851f
00182ae0: 3264ffff andi r4,r19,0xffff		; r4 = current CT
00182ae4: 00820019 multu r4,r2			; CT*0x51eb851f?
00182ae8: 00001810 mfhi r3
00182aec: 00031942 srl r3,r3,0x05
00182af0: 00031040 sll r2,r3,0x01
00182af4: 00431021 addu r2,r2,r3
00182af8: 000210c0 sll r2,r2,0x03
00182afc: 00431021 addu r2,r2,r3
00182b00: 00021080 sll r2,r2,0x02
00182b04: 00822023 subu r4,r4,r2
00182b08: a2240039 sb r4,0x0039(r17)		; store new CT
00182b0c: 02802021 addu r4,r20,r0
00182b10: 0c060c1e jal 0x00183078		; Death sentence, crystalization, treasurization, etc
00182b14: 02202821 addu r5,r17,r0
00182b18: 00408021 addu r16,r2,r0
00182b1c: 12000009 beq r16,r0,0x00182b44	; branch if return value = 0 (knocked out, death counter incrememnt)
00182b20: 32020001 andi r2,r16,0x0001		;
00182b24: 10400007 beq r2,r0,0x00182b44		; branch if return value != treasuring, crystaling
00182b28: 36950300 ori r21,r20,0x0300		;
00182b2c: 161e0145 bne r16,r30,0x00183044	; jump
00182b30: 02a01021 addu r2,r21,r0		; return 0x0300 (reraise? Death sentence?)

If crystal/treasure

00182b34: 0c01799c jal 0x0005e670		; Increase Casualties/Injured Counters
00182b38: 02202021 addu r4,r17,r0
00182b3c: 08060c11 j 0x00183044			; jump to end
00182b40: 02a01021 addu r2,r21,r0		;

knocked out, death counter increment

00182b44: 0c060cb3 jal 0x001832cc		; Status checks
00182b48: 02202021 addu r4,r17,r0
00182b4c: 30420007 andi r2,r2,0x0007
00182b50: 10400003 beq r2,r0,0x00182b60		; branch if ??
00182b54: 34020002 ori r2,r0,0x0002
00182b58: 16020137 bne r16,r2,0x00183038	; branch to next directive
00182b5c: 00000000 nop

if no disabling status found?

00182b60: a23e0186 sb r30,0x0186(r17)		; store units turn = active
00182b64: a2200187 sb r0,0x0187(r17)		; store move available
00182b68: a2200188 sb r0,0x0188(r17)		; store act available
00182b6c: 16000002 bne r16,r0,0x00182b78
00182b70: a23e0027 sb r30,0x0027(r17)		; set units turn = active
00182b74: 36950100 ori r21,r20,0x0100		; r21 = return code (0x0100) next turn?
00182b78: 3c048019 lui r4,0x8019
00182b7c: 8c84f518 lw r4,-0x0ae8(r4)
00182b80: 3403000a ori r3,r0,0x000a
00182b84: 3c018019 lui r1,0x8019
00182b88: ac34f520 sw r20,-0x0ae0(r1)		; store active turn ID
00182b8c: 3c018019 lui r1,0x8019
00182b90: ac23f518 sw r3,-0x0ae8(r1)		; go to validate units turn
00182b94: 3c018019 lui r1,0x8019
00182b98: ac24f51c sw r4,-0x0ae4(r1)		; store previous value = 01
00182b9c: 08060c11 j 0x00183044
00182ba0: 02a01021 addu r2,r21,r0
00182ba4: 08060c06 j 0x00183018			; go to dead processing, next turn processing
00182ba8: 34020002 ori r2,r0,0x0002

*Ability CT decrement

00182bac: 00009021 addu r18,r0,r0
00182bb0: 02c08021 addu r16,r22,r0
00182bb4: 0c060cb3 jal 0x001832cc		; Status checks
00182bb8: 02002021 addu r4,r16,r0
00182bbc: 3042000f andi r2,r2,0x000f
00182bc0: 14400009 bne r2,r0,0x00182be8
00182bc4: 26520001 addiu r18,r18,0x0001
00182bc8: 9203015d lbu r3,0x015d(r16)		; load current ability CT
00182bcc: 00000000 nop
00182bd0: 306200ff andi r2,r3,0x00ff
00182bd4: 10570004 beq r2,r23,0x00182be8	; branch if no ability charging
00182bd8: 00000000 nop
00182bdc: 10400002 beq r2,r0,0x00182be8		; branch if CT = 0
00182be0: 2463ffff addiu r3,r3,0xffff		; ability CT decrement
00182be4: a203015d sb r3,0x015d(r16)		; store current ability CT
00182be8: 2a420015 slti r2,r18,0x0015
00182bec: 1440fff1 bne r2,r0,0x00182bb4
00182bf0: 261001c0 addiu r16,r16,0x01c0
00182bf4: 34060003 ori r6,r0,0x0003
00182bf8: 3c018019 lui r1,0x8019
00182bfc: ac26f518 sw r6,-0x0ae8(r1)		; go to post ability ability CT setting
00182c00: 08060c08 j 0x00183020
00182c04: 00000000 nop

*Post ability - persevere/clear ability CT after ability used

00182c08: 00009021 addu r18,r0,r0
00182c0c: 00008021 addu r16,r0,r0
00182c10: 02168821 addu r17,r16,r22
00182c14: 0c060cb3 jal 0x001832cc		; Status checks
00182c18: 02202021 addu r4,r17,r0
00182c1c: 3042000f andi r2,r2,0x000f
00182c20: 14400015 bne r2,r0,0x00182c78
00182c24: 00000000 nop
00182c28: 9222015d lbu r2,0x015d(r17)		; load current ability CT
00182c2c: 00000000 nop
00182c30: 14400011 bne r2,r0,0x00182c78		; branch if not 0
00182c34: 00000000 nop
00182c38: 92220058 lbu r2,0x0058(r17)
00182c3c: 00000000 nop
00182c40: 30420001 andi r2,r2,0x0001
00182c44: 10400006 beq r2,r0,0x00182c60		; branch if not performing
00182c48: 00000000 nop
00182c4c: 0c0179de jal 0x0005e778		; Transfer Last Ability Used CT
00182c50: 02202021 addu r4,r17,r0
00182c54: 9222018b lbu r2,0x018b(r17)		; load ability CT
00182c58: 08060b19 j 0x00182c64
00182c5c: a222015d sb r2,0x015d(r17)		; store current ability CT
00182c60: a237015d sb r23,0x015d(r17)		; store ability CT = 0xff?
00182c64: 34020009 ori r2,r0,0x0009
00182c68: 3c018019 lui r1,0x8019
00182c6c: ac22f518 sw r2,-0x0ae8(r1)		; go to find highest CT
00182c70: 08060c11 j 0x00183044			; jump to end, return r18 + 0x0200
00182c74: 36420200 ori r2,r18,0x0200
00182c78: 26520001 addiu r18,r18,0x0001
00182c7c: 2a420015 slti r2,r18,0x0015
00182c80: 1440ffe3 bne r2,r0,0x00182c10		; cycle through units
00182c84: 261001c0 addiu r16,r16,0x01c0
00182c88: 08060c06 j 0x00183018			; go to status CT decrement
00182c8c: 34020004 ori r2,r0,0x0004

*Status CT decrement

00182c90: 00009021 addu r18,r0,r0
00182c94: 02c08021 addu r16,r22,r0
00182c98: 92020001 lbu r2,0x0001(r16)
00182c9c: 00000000 nop
00182ca0: 10570008 beq r2,r23,0x00182cc4	; branch if unit ID = 0xff?
00182ca4: 00000000 nop
00182ca8: 92020058 lbu r2,0x0058(r16)
00182cac: 00000000 nop
00182cb0: 30420004 andi r2,r2,0x0004
00182cb4: 14400003 bne r2,r0,0x00182cc4		; branch if jumping
00182cb8: 00000000 nop
00182cbc: 0c063644 jal 0x0018d910		; Status CT decrement and innate statuses?
00182cc0: 02402021 addu r4,r18,r0
00182cc4: 26520001 addiu r18,r18,0x0001
00182cc8: 2a420015 slti r2,r18,0x0015
00182ccc: 1440fff2 bne r2,r0,0x00182c98		; Cycles through each unit
00182cd0: 261001c0 addiu r16,r16,0x01c0 	;
00182cd4: 34060005 ori r6,r0,0x0005
00182cd8: 3c018019 lui r1,0x8019
00182cdc: ac26f518 sw r6,-0x0ae8(r1)		; go to set action enabling
00182ce0: 08060c08 j 0x00183020
00182ce4: 00000000 nop

*Set Mime bytes

00182ce8: 00009021 addu r18,r0,r0
00182cec: 3c048019 lui r4,0x8019
00182cf0: 2484f8b0 addiu r4,r4,0xf8b0		; Mime bytes address
00182cf4: 02c01821 addu r3,r22,r0
00182cf8: a0800000 sb r0,0x0000(r4)		; clear Mime bytes
00182cfc: 90620001 lbu r2,0x0001(r3)		; load unit ID?
00182d00: 00000000 nop
00182d04: 10570009 beq r2,r23,0x00182d2c	; branch if = 0xff
00182d08: 26520001 addiu r18,r18,0x0001
00182d0c: 90620058 lbu r2,0x0058(r3)
00182d10: 00000000 nop
00182d14: 30420004 andi r2,r2,0x0004
00182d18: 14400004 bne r2,r0,0x00182d2c		; branch if jumping
00182d1c: 00000000 nop
00182d20: 906201b1 lbu r2,0x01b1(r3)		; load attack type?
00182d24: 00000000 nop
00182d28: a0820000 sb r2,0x0000(r4)		; store attack type in mime byte?
00182d2c: 24840001 addiu r4,r4,0x0001
00182d30: 2a420015 slti r2,r18,0x0015
00182d34: 1440fff0 bne r2,r0,0x00182cf8
00182d38: 246301c0 addiu r3,r3,0x01c0
00182d3c: 34060006 ori r6,r0,0x0006
00182d40: 3c018019 lui r1,0x8019
00182d44: ac26f518 sw r6,-0x0ae8(r1)		; go to clear action enabling bytes
00182d48: 08060c08 j 0x00183020
00182d4c: 00000000 nop

*Clear mime bytes?

00182d50: 00009021 addu r18,r0,r0
00182d54: 3c018019 lui r1,0x8019
00182d58: 00320821 addu r1,r1,r18
00182d5c: 9022f8b0 lbu r2,-0x0750(r1)		; load mime byte
00182d60: 00000000 nop
00182d64: 1440feea bne r2,r0,0x00182910		; clear above byte and jump to end
00182d68: 00000000 nop
00182d6c: 26520001 addiu r18,r18,0x0001
00182d70: 2a420015 slti r2,r18,0x0015
00182d74: 1440fff7 bne r2,r0,0x00182d54
00182d78: 00000000 nop
00182d7c: 3c018019 lui r1,0x8019
00182d80: ac20f518 sw r0,-0x0ae8(r1)		; go to next clocktick
00182d84: 08060c08 j 0x00183020
00182d88: 00000000 nop

*find highest CT

00182d8c: 341300fe ori r19,r0,0x00fe
00182d90: 341400ff ori r20,r0,0x00ff
00182d94: 00009021 addu r18,r0,r0
00182d98: 02c08821 addu r17,r22,r0
00182d9c: 00008021 addu r16,r0,r0
00182da0: 0c060cb3 jal 0x001832cc		; Status checks
00182da4: 02202021 addu r4,r17,r0
00182da8: 30420001 andi r2,r2,0x0001
00182dac: 1440000a bne r2,r0,0x00182dd8
00182db0: 263101c0 addiu r17,r17,0x01c0
00182db4: 3c018019 lui r1,0x8019
00182db8: 00300821 addu r1,r1,r16
00182dbc: 90230905 lbu r3,0x0905(r1)		; load CT
00182dc0: 00000000 nop
00182dc4: 0263102b sltu r2,r19,r3		; set if CT < previous units CT
00182dc8: 10400003 beq r2,r0,0x00182dd8		; branch if not
00182dcc: 00000000 nop
00182dd0: 0240a021 addu r20,r18,r		; r20 = battle ID
00182dd4: 00609821 addu r19,r3,r0		; r19 = CT
00182dd8: 26520001 addiu r18,r18,0x0001
00182ddc: 2a420015 slti r2,r18,0x0015
00182de0: 1440ffef bne r2,r0,0x00182da0
00182de4: 261001c0 addiu r16,r16,0x01c0
00182de8: 1697fece bne r20,r23,0x00182924	; Branch to set active turn if Battle ID is valid
00182dec: 34060003 ori r6,r0,0x0003
00182df0: 3c018019 lui r1,0x8019
00182df4: ac26f51c sw r6,-0x0ae4(r1)		; store control variable = 0x03
00182df8: 08060c06 j 0x00183018
00182dfc: 3402000d ori r2,r0,0x000d		; go to set some AI weapon data

*Validate units turn

00182e00: 00009021 addu r18,r0,r0
00182e04: 02c09821 addu r19,r22,r0
00182e08: 02608821 addu r17,r19,r0
00182e0c: 92220186 lbu r2,0x0186(r17)		; Characters turn byte
00182e10: 00000000 nop
00182e14: 1040000f beq r2,r0,0x00182e54		; branch if not units turn
00182e18: 00000000 nop
00182e1c: 0c060cb3 jal 0x001832cc		; Status checks
00182e20: 02202021 addu r4,r17,r0
00182e24: 02202021 addu r4,r17,r0
00182e28: 0c060f44 jal 0x00183d10		; Able to move/act checks (Menu?)
00182e2c: 00408021 addu r16,r2,r0
00182e30: 32100001 andi r16,r16,0x0001
00182e34: 16000003 bne r16,r0,0x00182e44
00182e38: 267301c0 addiu r19,r19,0x01c0
00182e3c: 10400081 beq r2,r0,0x00183044
00182e40: 36420100 ori r2,r18,0x0100
00182e44: 0c060f1b jal 0x00183c6c		; End of Turn
00182e48: 02402021 addu r4,r18,r0
00182e4c: 08060b96 j 0x00182e58
00182e50: a2200186 sb r0,0x0186(r17)		; clear characters turn byte
00182e54: 267301c0 addiu r19,r19,0x01c0
00182e58: 26520001 addiu r18,r18,0x0001
00182e5c: 2a420015 slti r2,r18,0x0015
00182e60: 1440ffea bne r2,r0,0x00182e0c
00182e64: 02608821 addu r17,r19,r0
00182e68: 08060c06 j 0x00183018			; go to poison/regen
00182e6c: 34020013 ori r2,r0,0x0013

*Poison and Regen

00182e70: 3c038019 lui r3,0x8019
00182e74: 8c63f520 lw r3,-0x0ae0(r3)		; load active units ID?
00182e78: 3402000f ori r2,r0,0x000f
00182e7c: 3c018019 lui r1,0x8019
00182e80: ac22f518 sw r2,-0x0ae8(r1)		; go to transparent removal
00182e84: 2402ffff addiu r2,r0,0xffff
00182e88: 10620065 beq r3,r2,0x00183020		; branch if active unit ID = 0xff
00182e8c: 00000000 nop
00182e90: 000320c0 sll r4,r3,0x03		; ID*8
00182e94: 00832023 subu r4,r4,r3
00182e98: 00042180 sll r4,r4,0x06
00182e9c: 0c0635f2 jal 0x0018d7c8		; Poison and Regen
00182ea0: 00962021 addu r4,r4,r22		; r4 = unit data?
00182ea4: 08060bc7 j 0x00182f1c
00182ea8: 00000000 nop

*Poison Marsh

00182eac: 3c038019 lui r3,0x8019
00182eb0: 8c63f520 lw r3,-0x0ae0(r3)		; load active units ID again
00182eb4: 34020011 ori r2,r0,0x0011
00182eb8: 3c018019 lui r1,0x8019
00182ebc: ac22f518 sw r2,-0x0ae8(r1)		; go to poison marsh?
00182ec0: 2402ffff addiu r2,r0,0xffff
00182ec4: 10620056 beq r3,r2,0x00183020		; branch if unit ID = 0xff
00182ec8: 00000000 nop
00182ecc: 000320c0 sll r4,r3,0x03
00182ed0: 00832023 subu r4,r4,r3
00182ed4: 00042180 sll r4,r4,0x06
00182ed8: 0c0636a2 jal 0x0018da88		; Poison Marsh Routine
00182edc: 00962021 addu r4,r4,r22
00182ee0: 08060bc7 j 0x00182f1c
00182ee4: 00000000 nop

*Transparent removal

00182ee8: 3c038019 lui r3,0x8019
00182eec: 8c63f520 lw r3,-0x0ae0(r3)		; load active unit ID
00182ef0: 3402000d ori r2,r0,0x000d
00182ef4: 3c018019 lui r1,0x8019
00182ef8: ac22f518 sw r2,-0x0ae8(r1)		; go to set some AI weapon data
00182efc: 2402ffff addiu r2,r0,0xffff
00182f00: 10620047 beq r3,r2,0x00183020
00182f04: 00000000 nop
00182f08: 000320c0 sll r4,r3,0x03
00182f0c: 00832023 subu r4,r4,r3
00182f10: 00042180 sll r4,r4,0x06
00182f14: 0c06361a jal 0x0018d868		; Transparent removal routine
00182f18: 00962021 addu r4,r4,r22
00182f1c: 10400040 beq r2,r0,0x00183020
00182f20: 00000000 nop
00182f24: 3c028019 lui r2,0x8019
00182f28: 8c42f520 lw r2,-0x0ae0(r2)
00182f2c: 08060c11 j 0x00183044
00182f30: 34420300 ori r2,r2,0x0300

*Check if mimicable ability occurred

00182f34: 3c028019 lui r2,0x8019
00182f38: 9042389d lbu r2,0x389d(r2)		; 01 if action taken?
00182f3c: 00000000 nop
00182f40: 10400033 beq r2,r0,0x00183010		; branch if = 0 (go to 01, dead processing,next turn)
00182f44: 3405005d ori r5,r0,0x005d		; if action taken, go to below loop
00182f48: 00009021 addu r18,r0,r0
00182f4c: 3c048019 lui r4,0x8019
00182f50: 2484f8b0 addiu r4,r4,0xf8b0		; 0x8018f8b0
00182f54: 02c01821 addu r3,r22,r0
00182f58: a0800000 sb r0,0x0000(r4)		; clear action enabling byte?
00182f5c: 90620003 lbu r2,0x0003(r3)		; load job ID
00182f60: 00000000 nop
00182f64: 14450006 bne r2,r5,0x00182f80		; branch if job is not mime
00182f68: 26520001 addiu r18,r18,0x0001
00182f6c: 90620001 lbu r2,0x0001(r3)
00182f70: 00000000 nop
00182f74: 10570002 beq r2,r23,0x00182f80	; unit exists check
00182f78: 00000000 nop
00182f7c: a09e0000 sb r30,0x0000(r4)		; store mimic ability
00182f80: 24840001 addiu r4,r4,0x0001
00182f84: 2a420015 slti r2,r18,0x0015
00182f88: 1440fff3 bne r2,r0,0x00182f58
00182f8c: 246301c0 addiu r3,r3,0x01c0
00182f90: 3406000e ori r6,r0,0x000e
00182f94: 3c018019 lui r1,0x8019
00182f98: ac26f518 sw r6,-0x0ae8(r1)		; go to mimic ability setting
00182f9c: 08060c08 j 0x00183020
00182fa0: 00000000 nop

*Mimic ability setting

00182fa4: 3c018019 lui r1,0x8019
00182fa8: a020389d sb r0,0x389d(r1)		; clear action occurred byte
00182fac: 00009021 addu r18,r0,r0
00182fb0: 3c138019 lui r19,0x8019
00182fb4: 2673f8b0 addiu r19,r19,0xf8b0		; load mimic bytes
00182fb8: 02c08821 addu r17,r22,r0
00182fbc: 92620000 lbu r2,0x0000(r19)
00182fc0: 00000000 nop
00182fc4: 1040000d beq r2,r0,0x00182ffc		; branch if not miming ability
00182fc8: 00000000 nop
00182fcc: 92220001 lbu r2,0x0001(r17)
00182fd0: 00000000 nop
00182fd4: 10570009 beq r2,r23,0x00182ffc	; branch if unit doesn't exist
00182fd8: 00000000 nop
00182fdc: a2600000 sb r0,0x0000(r19)		; clear AI byte
00182fe0: 0c063c0e jal 0x0018f038		; Mimic ability setting
00182fe4: 02202021 addu r4,r17,r0
00182fe8: 00408021 addu r16,r2,r0
00182fec: 121eff20 beq r16,r30,0x00182c70
00182ff0: 2402ffff addiu r2,r0,0xffff
00182ff4: 12020013 beq r16,r2,0x00183044	; jump to end, return values
00182ff8: 36420500 ori r2,r18,0x0500
00182ffc: 26730001 addiu r19,r19,0x0001
00183000: 26520001 addiu r18,r18,0x0001
00183004: 2a420015 slti r2,r18,0x0015
00183008: 1440ffec bne r2,r0,0x00182fbc
0018300c: 263101c0 addiu r17,r17,0x01c0
00183010: 3c028019 lui r2,0x8019
00183014: 8c42f51c lw r2,-0x0ae4(r2)		; load control variable
00183018: 3c018019 lui r1,0x8019
0018301c: ac22f518 sw r2,-0x0ae8(r1)		; store control variable

*End

00183020: 8fa60010 lw r6,0x0010(r29)
00183024: 00000000 nop
00183028: 24c60001 addiu r6,r6,0x0001
0018302c: 28c204b1 slti r2,r6,0x04b1
00183030: 10400003 beq r2,r0,0x00183040
00183034: afa60010 sw r6,0x0010(r29)
00183038: 12a0fe53 beq r21,r0,0x00182988
0018303c: 00000000 nop
00183040: 3402ff00 ori r2,r0,0xff00		; return r2 = 0xff00 (type of event occurring?)
00183044: 8fbf003c lw r31,0x003c(r29)
00183048: 8fbe0038 lw r30,0x0038(r29)
0018304c: 8fb70034 lw r23,0x0034(r29)
00183050: 8fb60030 lw r22,0x0030(r29)
00183054: 8fb5002c lw r21,0x002c(r29)
00183058: 8fb40028 lw r20,0x0028(r29)
0018305c: 8fb30024 lw r19,0x0024(r29)
00183060: 8fb20020 lw r18,0x0020(r29)
00183064: 8fb1001c lw r17,0x001c(r29)
00183068: 8fb00018 lw r16,0x0018(r29)
0018306c: 27bd0040 addiu r29,r29,0x0040
00183070: 03e00008 jr r31
00183074: 00000000 nop

Jump Lookup table

00174174: 801829b8 lb r24,0x29b8(r0) - 00 - next clocktick
00174178: 80182a44 lb r24,0x2a44(r0) - 01 - dead processing, next turn processing
0017417c: 80182bac lb r24,0x2bac(r0) - 02 - ability CT decrement
00174180: 80182c08 lb r24,0x2c08(r0) - 03 - Post ability - persevere/clear ability CT after ability used
00174184: 80182c90 lb r24,0x2c90(r0) - 04 - Status CT decrement
00174188: 80182ce8 lb r24,0x2ce8(r0) - 05 - Set Mime bytes
0017418c: 80182d50 lb r24,0x2d50(r0) - 06 - Clear mime bytes
00174190: 80183020 lb r24,0x3020(r0) - 07 -
00174194: 80183020 lb r24,0x3020(r0) - 08 -
00174198: 80182d8c lb r24,0x2d8c(r0) - 09 - find highest CT
0017419c: 80182e00 lb r24,0x2e00(r0) - 0a - Validate units turn
001741a0: 80183020 lb r24,0x3020(r0) - 0b -
001741a4: 80183020 lb r24,0x3020(r0) - 0c
001741a8: 80182f34 lb r24,0x2f34(r0) - 0d - Check if mimickable ability occurred
001741ac: 80182fa4 lb r24,0x2fa4(r0) - 0e - Mimic ability setting
001741b0: 80182eac lb r24,0x2eac(r0) - 0f - transparent removal
001741b4: 80183020 lb r24,0x3020(r0) - 10
001741b8: 80182ee8 lb r24,0x2ee8(r0) - 11 - poison marsh
001741bc: 80183020 lb r24,0x3020(r0) - 12
001741c0: 80182e70 lb r24,0x2e70(r0) - 13 - poison/regen
001741c4: 80184070 lb r24,0x4070(r0) - 14 - get tile type