End of Turn

From Final Fantasy Hacktics Wiki
Jump to navigation Jump to search
BATTLE.BIN - End of Turn 
---------------------------------------------------------------------------------------
Parameters : r4 = Unit ID
Returns : r2 = 0x01 (always..)

This routine checks CT bonus at end of turn (AI simulation only ?)
---------------------------------------------------------------------------------------
00183c6c: 000410c0 sll r2,r4,0x03           |
00183c70: 00441023 subu r2,r2,r4            |
00183c74: 00021180 sll r2,r2,0x06           |Unit offset in battle data
00183c78: 3c038019 lui r3,0x8019            |
00183c7c: 246308cc addiu r3,r3,0x08cc       |
00183c80: 00433821 addu r7,r2,r3            |Pointer to Unit battle stats
00183c84: 3c018019 lui r1,0x8019            |
00183c88: 00220821 addu r1,r1,r2            |
00183c8c: 902308cd lbu r3,0x08cd(r1)        |Unit ID
00183c90: 340200ff ori r2,r0,0x00ff         |r2 = ff
00183c94: 1062001c beq r3,r2,0x00183d08     #If unit doesn't exist :   exit routine 
00183c98: 34020001 ori r2,r0,0x0001             |r2 = 0x01
00183c9c: 90e20186 lbu r2,0x0186(r7)        |Unit Turn flag
00183ca0: 00000000 nop                      |
00183ca4: 10400018 beq r2,r0,0x00183d08     #If this is not Unit turn   exit routine 
00183ca8: 34020001 ori r2,r0,0x0001             |r2 = 0x01
00183cac: 90e60039 lbu r6,0x0039(r7)        |Unit CT
00183cb0: 90e3005c lbu r3,0x005c(r7)        |Unit Current status 5
00183cb4: 90e50187 lbu r5,0x0187(r7)        |Load movement taken
00183cb8: 90e40188 lbu r4,0x0188(r7)        |Load action taken
00183cbc: 30620008 andi r2,r3,0x0008        |Don't move check
00183cc0: 00a22825 or r5,r5,r2              |r5 = Movement taken or disallowed
00183cc4: 30630004 andi r3,r3,0x0004        |don't act check
00183cc8: 90e20058 lbu r2,0x0058(r7)        |Unit Current status 1
00183ccc: 00641825 or r3,r3,r4              |r3 = Action taken or disallowed
00183cd0: 30420001 andi r2,r2,0x0001        |Check [Performing]
00183cd4: 14a00002 bne r5,r0,0x00183ce0     #If Movement is not taken
00183cd8: 00621825 or r3,r3,r2                  |
00183cdc: 24c60014 addiu r6,r6,0x0014           |20 CT bonus
00183ce0: 14600003 bne r3,r0,0x00183cf0     #If Action not taken nor perfoming
00183ce4: 30c2ffff andi r2,r6,0xffff            |
00183ce8: 24c60014 addiu r6,r6,0x0014           |20 CT bonus
00183cec: 30c2ffff andi r2,r6,0xffff            |
00183cf0: 2c42003d sltiu r2,r2,0x003d       |
00183cf4: 14400002 bne r2,r0,0x00183d00     #If CT is more than 60
00183cf8: 34020001 ori r2,r0,0x0001             |
00183cfc: 3406003c ori r6,r0,0x003c             |Cap CT at 60
00183d00: a0e60039 sb r6,0x0039(r7)         |store r6 as CT
00183d04: a0e00186 sb r0,0x0186(r7)         |store store turn over
00183d08: 03e00008 jr r31
00183d0c: 00000000 nop

Return location

Battle.bin
000755dc: Set_move/act_based_on_skillset
00076504: 00076430_-_00076654
00076630: 00076430_-_00076654
00182e4c: In_between_turn_control_routine
00183c58: Set_move/act_flags
0019d530: AI_End_of_turn,_in_between_turn,_etc.