Checks map max X and Y

From Final Fantasy Hacktics Wiki
(Redirected from 00197c68 - 00197d08)
Jump to navigation Jump to search
BATTLE.BIN :  - Checks_map_max_X_and_Y
------------------------------------------------------------------------------------------
Parameter : r4 = Pointer to some AI Tile's Table (1 bit per tile)
Return : r2 = Nb of Tiles enabled in r4 Table
------------------------------------------------------------------------------------------
00197c68: 27bdfff0 addiu r29,r29,-0x0010     |
00197c6c: 00004821 addu r9,r0,r0             |
00197c70: 3c0c801a lui r12,0x801a            |
00197c74: 258cf3c4 addiu r12,r12,-0x0c3c     |0x8019f3c4
00197c78: 00005821 addu r11,r0,r0            |Initialize elevation counter
00197c7c: 3c0d801a lui r13,0x801a            |
00197c80: 91ad01ff lbu r13,0x01ff(r13)       |Map Max Y
                                            @LOOP - both elevation
00197c84: 00000000 nop                           |
00197c88: 11a00018 beq r13,r0,0x00197cec         #If Max Y is invalid : branch to next elevation
00197c8c: 00003021 addu r6,r0,r0                 |Initialize Y counter
00197c90: 918a0e3b lbu r10,0x0e3b(r12)           |Map Max Y
00197c94: 00803821 addu r7,r4,r0                 |Prepare Dynamic pointer to AI Table of Tiles flags
                                                @LOOP - All Y row (halfwords of flags)
00197c98: 94e20000 lhu r2,0x0000(r7)                 |This Y row Flags
00197c9c: 00000000 nop                               |
00197ca0: 1040000e beq r2,r0,0x00197cdc              #If All Tile's flags are off : branch to  Next Y row
00197ca4: 00000000 nop                               |
00197ca8: 91850e3a lbu r5,0x0e3a(r12)                |Load map max X
00197cac: 00000000 nop                               |
00197cb0: 18a0000a blez r5,0x00197cdc                #If Max X is invalid : branch to  Next Y row
00197cb4: 00001821 addu r3,r0,r0                     |Initialize X counter
00197cb8: 00404021 addu r8,r2,r0                     |Y row flags
00197cbc: 00681004 sllv r2,r8,r3                     |Shift flags so tile of interest flag is in 0x8000 position
                                                    @LOOP
00197cc0: 30428000 andi r2,r2,0x8000                     |
00197cc4: 10400002 beq r2,r0,0x00197cd0                  #If This Tile flag is ON
00197cc8: 24630001 addiu r3,r3,0x0001                    |X counter + 1
00197ccc: 25290001 addiu r9,r9,0x0001                        |Increase Tile ON counter
00197cd0: 0065102a slt r2,r3,r5                          |
00197cd4: 1440fffa bne r2,r0,0x00197cc0              #Loop while X < Max X
00197cd8: 00681004 sllv r2,r8,r3                         |Shift flags so tile of interest flag is in 0x8000 position
00197cdc: 24c60001 addiu r6,r6,0x0001                |Y counter +1
00197ce0: 00ca102a slt r2,r6,r10                     |
00197ce4: 1440ffec bne r2,r0,0x00197c98          #Branch while Y < Max Y
00197ce8: 24e70002 addiu r7,r7,0x0002                |Halfword offset
00197cec: 256b0001 addiu r11,r11,0x0001          |Elevation counter + 1
00197cf0: 29620002 slti r2,r11,0x0002            |Set if 0x1 < 2
00197cf4: 1440ffe3 bne r2,r0,0x00197c84      #Branch if so
00197cf8: 24840024 addiu r4,r4,0x0024            |Elevation offset
00197cfc: 01201021 addu r2,r9,r0             |Returns Number of Tiles enabled in considered Table
00197d00: 27bd0010 addiu r29,r29,0x0010
00197d04: 03e00008 jr r31
00197d08: 00000000 nop

Return locations

BATTLE.BIN
 0019771c: Store_ability/skillset_data,_set_AI_settings_for_ability?   r4 = AI 0x0b4c
 0019c8a8: Evaluate_Linear_Ability_Behaviors   r4 = AI 0x0bdc
 0019c8b4: Evaluate_Linear_Ability_Behaviors   r4 = AI 0x0b94