finish out ai_targeting and move data

This commit is contained in:
Seth Barberee
2022-11-18 16:54:10 -08:00
parent bfde61cee6
commit 29c9956bf6
8 changed files with 178 additions and 450 deletions

View File

@@ -1,397 +0,0 @@
#include "asm/constants/gba_constants.inc"
#include "asm/macros.inc"
.syntax unified
.text
thumb_func_start sub_8070E3C
sub_8070E3C:
push {r4-r7,lr}
adds r4, r0, 0
adds r6, r1, 0
adds r7, r2, 0
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r5, r0, 24
movs r2, 0
ldrsh r0, [r6, r2]
ldr r1, _08070EB0
lsls r2, r7, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x2
ldrsh r1, [r6, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTile_1
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08070F0C
ldr r0, [r2, 0x10]
cmp r0, 0
beq _08070E8A
bl GetEntityType
cmp r0, 0x1
bne _08070F0C
_08070E8A:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08070EDC
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070EAC
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
beq _08070EB4
_08070EAC:
movs r5, 0x3
b _08070EDC
.align 2, 0
_08070EB0: .4byte gAdjacentTileOffsets
_08070EB4:
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _08070EDA
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08070EDC
movs r0, 0x1
ands r0, r7
movs r5, 0x3
cmp r0, 0
beq _08070EDC
_08070EDA:
movs r5, 0x2
_08070EDC:
movs r1, 0
ldrsh r0, [r6, r1]
movs r2, 0x2
ldrsh r1, [r6, r2]
bl GetMapTile_1
adds r2, r0, 0
adds r1, r2, 0
adds r1, 0xA
adds r1, r5
ldr r2, _08070F08
movs r0, 0x7
ands r0, r7
adds r0, r2
ldrb r1, [r1]
ldrb r0, [r0]
ands r0, r1
cmp r0, 0
beq _08070F0C
movs r0, 0x1
b _08070F0E
.align 2, 0
_08070F08: .4byte gUnknown_8106FB5
_08070F0C:
movs r0, 0
_08070F0E:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_8070E3C
thumb_func_start sub_8070F14
sub_8070F14:
push {r4,r5,lr}
adds r4, r0, 0
adds r5, r1, 0
movs r1, 0x4
ldrsh r0, [r4, r1]
ldr r1, _08070F70
lsls r2, r5, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r4, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTile_1
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08070F78
ldr r0, [r2, 0x10]
cmp r0, 0
bne _08070F78
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTile_1
adds r2, r0, 0
ldr r1, _08070F74
movs r0, 0x7
ands r0, r5
adds r0, r1
ldrb r1, [r2, 0xA]
ldrb r0, [r0]
ands r0, r1
cmp r0, 0
beq _08070F78
movs r0, 0x1
b _08070F7A
.align 2, 0
_08070F70: .4byte gAdjacentTileOffsets
_08070F74: .4byte gUnknown_8106FBD
_08070F78:
movs r0, 0
_08070F7A:
pop {r4,r5}
pop {r1}
bx r1
thumb_func_end sub_8070F14
thumb_func_start sub_8070F80
sub_8070F80:
push {r4-r6,lr}
adds r4, r0, 0
adds r6, r1, 0
ldr r0, [r4, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r5, r0, 24
movs r2, 0x4
ldrsh r0, [r4, r2]
ldr r1, _08070FF4
lsls r2, r6, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r4, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTile_1
adds r2, r0, 0
ldrh r1, [r2]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08071050
ldr r0, [r2, 0x10]
cmp r0, 0
beq _08070FCC
bl GetEntityType
cmp r0, 0x1
bne _08071050
_08070FCC:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08071020
ldr r0, [r4, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _08070FEE
adds r0, r4, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
beq _08070FF8
_08070FEE:
movs r5, 0x3
b _08071020
.align 2, 0
_08070FF4: .4byte gAdjacentTileOffsets
_08070FF8:
adds r0, r4, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _0807101E
adds r0, r4, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071020
movs r0, 0x1
ands r0, r6
movs r5, 0x3
cmp r0, 0
beq _08071020
_0807101E:
movs r5, 0x2
_08071020:
movs r1, 0x4
ldrsh r0, [r4, r1]
movs r2, 0x6
ldrsh r1, [r4, r2]
bl GetMapTile_1
adds r2, r0, 0
adds r1, r2, 0
adds r1, 0xA
adds r1, r5
ldr r2, _0807104C
movs r0, 0x7
ands r0, r6
adds r0, r2
ldrb r1, [r1]
ldrb r0, [r0]
ands r0, r1
cmp r0, 0
beq _08071050
movs r0, 0x1
b _08071052
.align 2, 0
_0807104C: .4byte gUnknown_8106FC5
_08071050:
movs r0, 0
_08071052:
pop {r4-r6}
pop {r1}
bx r1
thumb_func_end sub_8070F80
thumb_func_start sub_8071058
sub_8071058:
push {r4-r7,lr}
adds r5, r0, 0
adds r7, r1, 0
ldr r0, [r5, 0x70]
movs r1, 0x2
ldrsh r0, [r0, r1]
bl GetCrossableTerrain
lsls r0, 24
lsrs r6, r0, 24
movs r2, 0x4
ldrsh r0, [r5, r2]
ldr r1, _080710D4
lsls r2, r7, 2
adds r2, r1
movs r3, 0
ldrsh r1, [r2, r3]
adds r0, r1
movs r3, 0x6
ldrsh r1, [r5, r3]
movs r3, 0x2
ldrsh r2, [r2, r3]
adds r1, r2
bl GetMapTile_1
adds r4, r0, 0
ldrh r1, [r4]
movs r0, 0x10
ands r0, r1
cmp r0, 0
bne _08071130
ldr r0, [r4, 0x10]
cmp r0, 0
beq _080710AE
bl GetEntityType
cmp r0, 0x1
beq _080710AE
ldr r0, [r4, 0x10]
ldr r0, [r0, 0x70]
ldrb r0, [r0, 0x6]
cmp r0, 0
bne _08071130
_080710AE:
bl IsFixedDungeon
lsls r0, 24
cmp r0, 0
bne _08071100
ldr r0, [r5, 0x70]
adds r0, 0xE4
ldrb r0, [r0]
cmp r0, 0x3
beq _080710D0
adds r0, r5, 0
movs r1, 0x9
bl HasItem
lsls r0, 24
cmp r0, 0
beq _080710D8
_080710D0:
movs r6, 0x3
b _08071100
.align 2, 0
_080710D4: .4byte gAdjacentTileOffsets
_080710D8:
adds r0, r5, 0
movs r1, 0xC
bl HasIQSkill
lsls r0, 24
cmp r0, 0
bne _080710FE
adds r0, r5, 0
movs r1, 0xD
bl HasIQSkill
lsls r0, 24
cmp r0, 0
beq _08071100
movs r0, 0x1
ands r0, r7
movs r6, 0x3
cmp r0, 0
beq _08071100
_080710FE:
movs r6, 0x2
_08071100:
movs r1, 0x4
ldrsh r0, [r5, r1]
movs r2, 0x6
ldrsh r1, [r5, r2]
bl GetMapTile_1
adds r4, r0, 0
adds r1, r4, 0
adds r1, 0xA
adds r1, r6
ldr r2, _0807112C
movs r0, 0x7
ands r0, r7
adds r0, r2
ldrb r1, [r1]
ldrb r0, [r0]
ands r0, r1
cmp r0, 0
beq _08071130
movs r0, 0x1
b _08071132
.align 2, 0
_0807112C: .4byte gUnknown_8106FCD
_08071130:
movs r0, 0
_08071132:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_8071058
.align 2, 0

View File

@@ -5,28 +5,6 @@
.text
thumb_func_start sub_8097DD0
sub_8097DD0:
push {lr}
adds r2, r0, 0
adds r3, r1, 0
ldr r1, [r2]
ldr r0, [r3]
cmp r1, r0
bne _08097DEA
ldr r1, [r2, 0x4]
ldr r0, [r3, 0x4]
cmp r1, r0
bne _08097DEA
movs r0, 0x1
b _08097DEC
_08097DEA:
movs r0, 0
_08097DEC:
pop {r1}
bx r1
thumb_func_end sub_8097DD0
thumb_func_start sub_8097DF0
sub_8097DF0:
push {r4-r7,lr}

View File

@@ -1,21 +0,0 @@
.section .rodata
.global gUnknown_8106FB5
gUnknown_8106FB5: @ 8106FB5
@ replacing .incbin "baserom.gba", 0x00106fb5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FBD
gUnknown_8106FBD: @ 8106FBD
@ replacing .incbin "baserom.gba", 0x00106fbd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FC5
gUnknown_8106FC5: @ 8106FC5
@ replacing .incbin "baserom.gba", 0x00106fc5, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80
.global gUnknown_8106FCD
gUnknown_8106FCD: @ 8106FCD
@ replacing .incbin "baserom.gba", 0x00106fcd, 0x8
.byte 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80

View File

@@ -1,6 +1,9 @@
#ifndef GUARD_EXCLUSIVE_POKEMON_H
#define GUARD_EXCLUSIVE_POKEMON_H
#include "code_8092334.h"
#define NUM_EXCLUSIVE_POKEMON 12
struct ExclusivePokemon
@@ -36,6 +39,9 @@ extern struct ExclusivePokemonData *gUnknown_203B498;
void LoadExclusivePokemon(void);
struct ExclusivePokemonData *GetExclusivePokemon(void);
void InitializeExclusivePokemon(void);
bool8 IsExclusivePokemonUnlocked(s16 pokeID);
void UnlockExclusivePokemon(s16 pokeID);
void WriteExclusivePokemon(struct unkStruct_8094924 *r0);
void ReadExclusivePokemon(struct unkStruct_8094924 *r0);
#endif // GUARD_EXCLUSIVE_POKEMON_H

View File

@@ -238,7 +238,6 @@ SECTIONS {
src/dungeon_capabilities.o(.text);
asm/code_8070BC0.o(.text);
src/dungeon_capabilities_1.o(.text);
asm/code_8070E3C.o(.text);
src/dungeon_ai_targeting.o(.text);
src/dungeon_pokemon_attributes.o(.text);
asm/code_80718D8.o(.text);
@@ -465,7 +464,6 @@ SECTIONS {
src/type_effectiveness.o(.data);
data/data_8106F7C.o(.rodata);
src/dungeon_capabilities_1.o(.rodata);
data/data_8106FB5.o(.rodata);
src/dungeon_ai_targeting.o(.rodata);
data/data_8107010.o(.rodata);
src/friend_area.o(.rodata);

View File

@@ -1,6 +1,7 @@
#include "global.h"
#include "code_8092334.h"
#include "pokemon.h"
#include "exclusive_pokemon.h"
struct unkStruct_203B494
{
@@ -23,10 +24,8 @@ extern struct unkStruct_203B494 *gUnknown_203B494;
extern void SaveDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*);
extern void RestoreDungeonLocation(struct unkStruct_8094924*, struct DungeonLocation*);
void ReadExclusivePokemon(struct unkStruct_8094924 *r0);
void ReadGameOptions(struct unkStruct_8094924 *param_1);
void ReadPlayTime(struct unkStruct_8094924 *r0);
void WriteExclusivePokemon(struct unkStruct_8094924 *r0);
void WriteGameOptions(struct unkStruct_8094924 *param_1);
void WritePlayTime(struct unkStruct_8094924 *r0);
@@ -88,3 +87,13 @@ u32 sub_8097D98(u8 *r0, u32 size)
nullsub_102(&backup);
return backup.unk8;
}
bool8 sub_8097DD0(s32 *param_1, s32 *param_2)
{
if ((param_1[0] == param_2[0]) && (param_1[1] == param_2[1])) {
return TRUE;
}
else {
return FALSE;
}
}

View File

@@ -22,6 +22,10 @@
extern void ShowVisualFlags(struct DungeonEntity *r0);
const u8 gUnknown_8106FB5[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gUnknown_8106FBD[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gUnknown_8106FC5[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gUnknown_8106FCD[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gDirectionBitMasks_2[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
const u8 gDirectionBitMasks_3[] = {0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80};
@@ -58,6 +62,159 @@ const u8 gTargetingData[3][2][2][2] = {
}
};
bool8 sub_8070F3C(struct DungeonEntity * pokemon, struct Position *pos, s32 direction)
{
u8 terrain;
struct MapTile *tile;
terrain = GetCrossableTerrain(pokemon->entityData->entityID);
tile = GetMapTile_1(pos->x + gAdjacentTileOffsets[direction].x, pos->y + gAdjacentTileOffsets[direction].y);
if ((!(tile->tileType & TILE_TYPE_MAP_EDGE)) &&
(((tile->pokemon == NULL || (GetEntityType(tile->pokemon) == ENTITY_POKEMON))))) {
if (!IsFixedDungeon())
{
if (pokemon->entityData->transformStatus == TRANSFORM_STATUS_MOBILE ||
HasItem(pokemon, ITEM_ID_MOBILE_SCARF))
{
terrain = CROSSABLE_TERRAIN_WALL;
}
else if (HasIQSkill(pokemon, IQ_SKILL_ALL_TERRAIN_HIKER))
{
// BUG: If the Pokémon is a Ghost type that can normally attack through walls,
// All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls.
terrain = CROSSABLE_TERRAIN_CREVICE;
}
else if (HasIQSkill(pokemon, IQ_SKILL_SUPER_MOBILE))
{
if ((direction & 1) != 0)
{
terrain = CROSSABLE_TERRAIN_CREVICE;
}
else
{
terrain = CROSSABLE_TERRAIN_WALL;
}
}
}
tile = GetMapTile_1(pos->x, pos->y);
if (((tile->canMoveAdjacent[terrain] & gUnknown_8106FB5[direction & DIRECTION_MASK]))) {
return TRUE;
}
}
return FALSE;
}
bool8 sub_8070F14(struct DungeonEntity * pokemon, s32 direction)
{
struct MapTile *tile;
tile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[direction].x, pokemon->posWorld.y + gAdjacentTileOffsets[direction].y);
if ((!(tile->tileType & TILE_TYPE_MAP_EDGE)) &&
(((tile->pokemon == NULL)))) {
tile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
if (((tile->canMoveAdjacent[0] & gUnknown_8106FBD[direction & DIRECTION_MASK]))) {
return TRUE;
}
}
return FALSE;
}
bool8 sub_8070F80(struct DungeonEntity * pokemon, s32 direction)
{
u8 terrain;
struct MapTile *tile;
terrain = GetCrossableTerrain(pokemon->entityData->entityID);
tile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[direction].x, pokemon->posWorld.y + gAdjacentTileOffsets[direction].y);
if ((!(tile->tileType & TILE_TYPE_MAP_EDGE)) &&
(((tile->pokemon == NULL || (GetEntityType(tile->pokemon) == ENTITY_POKEMON))))) {
if (!IsFixedDungeon())
{
if (pokemon->entityData->transformStatus == TRANSFORM_STATUS_MOBILE ||
HasItem(pokemon, ITEM_ID_MOBILE_SCARF))
{
terrain = CROSSABLE_TERRAIN_WALL;
}
else if (HasIQSkill(pokemon, IQ_SKILL_ALL_TERRAIN_HIKER))
{
// BUG: If the Pokémon is a Ghost type that can normally attack through walls,
// All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls.
terrain = CROSSABLE_TERRAIN_CREVICE;
}
else if (HasIQSkill(pokemon, IQ_SKILL_SUPER_MOBILE))
{
if ((direction & 1) != 0)
{
terrain = CROSSABLE_TERRAIN_CREVICE;
}
else
{
terrain = CROSSABLE_TERRAIN_WALL;
}
}
}
tile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
if (((tile->canMoveAdjacent[terrain] & gUnknown_8106FC5[direction & DIRECTION_MASK]))) {
return TRUE;
}
}
return FALSE;
}
bool8 sub_8071058(struct DungeonEntity * pokemon, s32 direction)
{
u8 terrain;
struct MapTile *tile;
terrain = GetCrossableTerrain(pokemon->entityData->entityID);
tile = GetMapTile_1(pokemon->posWorld.x + gAdjacentTileOffsets[direction].x, pokemon->posWorld.y + gAdjacentTileOffsets[direction].y);
if ((!(tile->tileType & TILE_TYPE_MAP_EDGE)) &&
(((tile->pokemon == NULL || (GetEntityType(tile->pokemon) == ENTITY_POKEMON)) ||
(!tile->pokemon->entityData->isEnemy)))) {
if (!IsFixedDungeon())
{
if (pokemon->entityData->transformStatus == TRANSFORM_STATUS_MOBILE ||
HasItem(pokemon, ITEM_ID_MOBILE_SCARF))
{
terrain = CROSSABLE_TERRAIN_WALL;
}
else if (HasIQSkill(pokemon, IQ_SKILL_ALL_TERRAIN_HIKER))
{
// BUG: If the Pokémon is a Ghost type that can normally attack through walls,
// All-Terrain Hiker/Super Mobile may make the AI think it can't attack through walls.
terrain = CROSSABLE_TERRAIN_CREVICE;
}
else if (HasIQSkill(pokemon, IQ_SKILL_SUPER_MOBILE))
{
if ((direction & 1) != 0)
{
terrain = CROSSABLE_TERRAIN_CREVICE;
}
else
{
terrain = CROSSABLE_TERRAIN_WALL;
}
}
}
tile = GetMapTile_1(pokemon->posWorld.x, pokemon->posWorld.y);
if (((tile->canMoveAdjacent[terrain] & gUnknown_8106FCD[direction & DIRECTION_MASK]))) {
return TRUE;
}
}
return FALSE;
}
bool8 CanAttackInFront(struct DungeonEntity *pokemon, s32 direction)
{
u8 crossableTerrain = GetCrossableTerrain(pokemon->entityData->entityID);

View File

@@ -4,7 +4,6 @@
extern struct ExclusivePokemonData *gUnknown_203B498;
extern struct ExclusivePokemon gExclusivePokemon[NUM_EXCLUSIVE_POKEMON];
void RestoreIntegerBits(u32 *, void *, u32);
void sub_80980B4(s16);
void sub_8097FA8(u8);
void sub_8098170(s32);
@@ -13,7 +12,6 @@ void sub_8097FF8(void);
u8 sub_8098100(u8);
u8 sub_8098134(s16);
u8 sub_80981A0(s32);
void SaveIntegerBits(u32 *, void *, s32);
bool8 IsExclusivePokemonUnlocked(s16 pokeID)
{
@@ -40,11 +38,11 @@ void UnlockExclusivePokemon(s16 pokeID)
for(iVar2 = 0; iVar2 < NUM_EXCLUSIVE_POKEMON; iVar2++)
{
if(gExclusivePokemon[iVar2].poke_id == pokeID_s32)
gUnknown_203B498->Exclusives[iVar2] = 1;
gUnknown_203B498->Exclusives[iVar2] = TRUE;
}
}
void WriteExclusivePokemon(u32 *r0)
void WriteExclusivePokemon(struct unkStruct_8094924 *r0)
{
s32 iVar2;
u8 *puVar2;
@@ -59,7 +57,7 @@ void WriteExclusivePokemon(u32 *r0)
zero = 0;
SaveIntegerBits(r0, (u8 *)gUnknown_203B498, 1);
SaveIntegerBits(r0, gUnknown_203B498, 1);
for(iVar2 = 0; iVar2 < 424; iVar2++)
{
stack_0 = sub_8098134(iVar2);
@@ -85,7 +83,7 @@ void WriteExclusivePokemon(u32 *r0)
}
}
void ReadExclusivePokemon(u32 *r0)
void ReadExclusivePokemon(struct unkStruct_8094924 *r0)
{
s32 iVar2;
u8 stack_0;