split code_8073CF0 code_8075708 files

This commit is contained in:
DizzyEggg
2025-03-31 11:22:46 +02:00
parent 9cdb4e5982
commit 65ac31cdc6
5 changed files with 316 additions and 280 deletions

View File

@@ -2,9 +2,6 @@
.align 2
.string "pksdir0\0"
.string "pksdir0\0"
.string "pksdir0\0"
.string "pksdir0\0"
.string "pksdir0\0"

View File

@@ -583,6 +583,8 @@ SECTIONS {
src/code_80718D8.o(.rodata);
src/dungeon_ai_leader.o(.rodata);
src/dungeon_8072CF4.o(.rodata);
src/code_8073CF0.o(.rodata);
src/code_8075708.o(.rodata);
src/dungeon_ai_items.o(.rodata);
data/data_8107010.o(.rodata);
src/dungeon_serializer.o(.rodata);

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "globaldata.h"
#include "dungeon_util.h"
#include "items.h"
#include "status.h"
@@ -31,6 +32,7 @@
#include "dungeon_logic.h"
#include "math.h"
#include "dungeon_config.h"
#include "dungeon_strings.h"
extern bool8 sub_8044B28(void);
extern void sub_8075708(Entity *entity);
@@ -56,31 +58,7 @@ extern void sub_8075900(Entity *pokemon, u8 r1);
extern void sub_806A5B8(Entity *);
extern void sub_807EC28(bool8);
extern u8 gUnknown_202F32D;
extern const u8 *gMonTerrifiedCouldntPickUpItem;
extern const u8 *gMonPickedUpItem;
extern const u8 *gMonPickedUpItem2;
extern const u8 *gMonPickedUpItemToolbox;
extern const u8 *gMonSteppedOnItem;
extern const u8 *gMonCouldntPickUpItem;
extern const u8 *gUnknown_80FD594;
extern const u8 *gUnknown_80FD5B8;
extern const u8 *gUnknown_80FD5DC;
extern const u8 *gUnknown_80FD608;
extern const u8 *gUnknown_80FD628;
extern const u8 *gUnknown_80FEB30;
extern const u8 *gUnknown_80FABD8;
extern const u8 *gPtrProtectSavedItMessage;
extern const u8 *gPtrStenchWavedOffMessage;
extern const u8 *gUnknown_80FA124[];
extern const DungeonPos gUnknown_80F4D44[];
bool8 UseAttack(Entity *a0);
void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr);
static EWRAM_DATA s32 gUnknown_202F378 = 0;
void sub_8074094(Entity *entity)
{
@@ -602,254 +580,3 @@ void TickStatusHeal(Entity *entity)
}
}
void sub_8074FB0(Entity *entity, s32 a1, DungeonPos *pos)
{
Unk_Entity_x184 *strPtr;
EntityInfo *entityInfo = GetEntInfo(entity);
if (entityInfo->numMoveTiles > 3) {
entityInfo->action.action = 0;
return;
}
if (gGameOptionsRef->dungeonSpeed != 0)
gUnknown_202F378 = 2;
else
gUnknown_202F378 = 1;
strPtr = &entityInfo->unk184[entityInfo->numMoveTiles];
strPtr->unk1A = 0;
strPtr->lastMoveDirection = a1;
strPtr->previousTargetMovePosition1.x = entity->pos.x;
strPtr->previousTargetMovePosition1.y = entity->pos.y;
strPtr->previousTargetMovePosition2.x = pos->x;
strPtr->previousTargetMovePosition2.y = pos->y;
strPtr->lastMoveIncrement.x = gUnknown_80F4D44[a1].x * gUnknown_202F378;
strPtr->lastMoveIncrement.y = gUnknown_80F4D44[a1].y * gUnknown_202F378;
sub_8075050(entityInfo, strPtr);
}
void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr)
{
s32 savedX, savedY;
if (gGameOptionsRef->dungeonSpeed != 0)
gUnknown_202F378 = 2;
else
gUnknown_202F378 = 1;
info->numMoveTiles++;
if (info->numMoveTiles == 2) {
info->unk184[0].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 2);
info->unk184[0].lastMoveIncrement.x *= 2;
info->unk184[0].lastMoveIncrement.y *= 2;
strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 2);
strPtr->lastMoveIncrement.x *= 2;
strPtr->lastMoveIncrement.y *= 2;
}
else if (info->numMoveTiles == 3) {
s32 i;
savedX = strPtr->lastMoveIncrement.x;
savedY = strPtr->lastMoveIncrement.y;
for (i = 0; i < 2; i++) {
info->unk184[i].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 3);
info->unk184[i].lastMoveIncrement.x *= 3;
info->unk184[i].lastMoveIncrement.y *= 3;
info->unk184[i].lastMoveIncrement.x /= 2;
info->unk184[i].lastMoveIncrement.y /= 2;
}
strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 3);
strPtr->lastMoveIncrement.x = savedX * 3;
strPtr->lastMoveIncrement.y = savedY * 3;
}
else if (info->numMoveTiles == 4) {
s32 i;
savedX = strPtr->lastMoveIncrement.x;
savedY = strPtr->lastMoveIncrement.y;
for (i = 0; i < 3; i++) {
info->unk184[i].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 4);
info->unk184[i].lastMoveIncrement.x *= 4;
info->unk184[i].lastMoveIncrement.y *= 4;
info->unk184[i].lastMoveIncrement.x /= 3;
info->unk184[i].lastMoveIncrement.y /= 3;
}
strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 4);
strPtr->lastMoveIncrement.x = savedX * 4;
strPtr->lastMoveIncrement.y = savedY * 4;
}
else {
strPtr->walkAnimFramesLeft = 24 / gUnknown_202F378;
}
}
bool8 UseAttack(Entity *a0)
{
s32 i, j, loop;
Entity *savedEntityPtr;
bool32 r7 = FALSE;
bool32 r9 = FALSE;
gUnknown_202F32D = 0;
if (gGameOptionsRef->dungeonSpeed != 0)
gUnknown_202F378 = 2;
else
gUnknown_202F378 = 1;
for (i = 0; i < DUNGEON_MAX_POKEMON; i++) {
Entity *mon = gDungeon->activePokemon[i];
if (EntityIsValid(mon)) {
EntityInfo *monInfo = GetEntInfo(mon);
if (monInfo->numMoveTiles == 0) {
if (monInfo->waiting) {
monInfo->waiting = FALSE;
if ((monInfo->targetPos.x != 0 || monInfo->targetPos.y != 0)
&& (monInfo->targetPos.x != mon->pos.x || monInfo->targetPos.y != mon->pos.y)
&& (!CheckVariousStatuses2(mon, TRUE) || !CheckVariousStatuses(mon)))
{
s32 direction = GetDirectionTowardsPosition(&mon->pos, &monInfo->targetPos);
if (direction != monInfo->action.direction)
sub_806CE68(mon, direction);
}
}
}
else {
PixelPos pos;
monInfo->flags |= 0x2000;
pos.x = X_POS_TO_PIXELPOS(monInfo->unk184[0].previousTargetMovePosition2.x);
pos.y = Y_POS_TO_PIXELPOS(monInfo->unk184[0].previousTargetMovePosition2.y);
sub_804535C(mon, &pos);
sub_806CDFC(mon, 0, monInfo->unk184[0].lastMoveDirection);
monInfo->notMoving = 0;
r7 = TRUE;
if (sub_8045888(mon))
r9 = TRUE;
}
}
}
if (!r7)
return FALSE;
savedEntityPtr = gDungeon->unkB8;
gDungeon->unkB8 = a0;
if (gDungeon->unk644.unk28 == 0 && r9) {
sub_80526D0(0x35);
for (loop = 0; loop < 24 / gUnknown_202F378; loop++) {
DungeonRunFrameActions(7);
for (i = 0; i < DUNGEON_MAX_POKEMON; i++) {
Entity *mon = gDungeon->activePokemon[i];
if (EntityIsValid(mon)) {
EntityInfo *monInfo = GetEntInfo(mon);
Unk_Entity_x184 *strPtr = &monInfo->unk184[monInfo->notMoving];
ASM_MATCH_TRICK(i);
if (monInfo->numMoveTiles != 0) {
IncreaseEntityPixelPos(mon, strPtr->lastMoveIncrement.x, strPtr->lastMoveIncrement.y);
if (--strPtr->walkAnimFramesLeft == 0) {
if (++monInfo->notMoving == monInfo->numMoveTiles) {
monInfo->numMoveTiles = 0;
}
else {
PixelPos pos;
pos.x = X_POS_TO_PIXELPOS(monInfo->unk184[monInfo->notMoving].previousTargetMovePosition2.x);
pos.y = Y_POS_TO_PIXELPOS(monInfo->unk184[monInfo->notMoving].previousTargetMovePosition2.y);
sub_804535C(mon, &pos);
sub_806CDFC(mon, 0, monInfo->unk184[monInfo->notMoving].lastMoveDirection);
}
}
}
}
}
}
}
for (i = 0; i < DUNGEON_MAX_POKEMON; i++) {
Entity *mon = gDungeon->activePokemon[i];
if (EntityIsValid(mon)) {
EntityInfo *monInfo = GetEntInfo(mon);
monInfo->numMoveTiles = 0;
nullsub_97(mon);
if (monInfo->flags & 0x2000) {
sub_804535C(mon, NULL);
}
}
}
sub_807AA30();
for (j = 0; j < 2; j++) {
for (loop = 0; loop < DUNGEON_MAX_POKEMON; loop++) {
DungeonPos monPosBefore;
EntityInfo *monInfo;
Entity *mon = gDungeon->activePokemon[loop];
if (!EntityIsValid(mon))
continue;
if (sub_8044B28())
break;
monInfo = GetEntInfo(mon);
if ((j == 0 && !monInfo->isTeamLeader) || (j != 0 && monInfo->isTeamLeader))
continue;
monPosBefore = mon->pos;
// Statement with no effect needed to match.
GetEntInfo(mon)->isTeamLeader = GetEntInfo(mon)->isTeamLeader;
if (monInfo->flags & 0x2000) {
monInfo->flags &= ~(0x2000);
if (monInfo->isTeamLeader) {
sub_804AC20(&mon->pos);
sub_807EC28(FALSE);
sub_805EE30();
}
else {
sub_8075708(mon);
}
if (!EntityIsValid(mon))
continue;
if (sub_8044B28())
break;
sub_8043ED0(0);
sub_8074094(mon);
if (!EntityIsValid(mon))
continue;
if (sub_8044B28())
break;
sub_8071DA4(mon);
sub_8046D20();
sub_8075900(mon, gDungeon->forceMonsterHouse);
}
if (!EntityIsValid(mon))
continue;
if (sub_8044B28())
break;
if (monPosBefore.x != mon->pos.x || monPosBefore.y != mon->pos.y)
gUnknown_202F32D = 1;
sub_806A5B8(mon);
if (sub_80706A4(mon, &mon->pos)) {
WarpTarget(mon, mon, 0, NULL);
}
}
}
sub_8086AC0();
if (!sub_8044B28()) {
sub_8085140();
gDungeon->unkB8 = savedEntityPtr;
}
else {
gDungeon->unkB8 = savedEntityPtr;
}
return TRUE;
}

View File

@@ -1,4 +1,5 @@
#include "global.h"
#include "globaldata.h"
#include "dungeon_ai.h"
#include "constants/iq_skill.h"
#include "constants/item.h"
@@ -12,9 +13,317 @@
#include "structs/str_dungeon.h"
#include "position_util.h"
#include "trap.h"
#include "dungeon_logic.h"
#include "items.h"
#include "status.h"
#include "weather.h"
#include "structs/dungeon_entity.h"
#include "structs/map.h"
#include "structs/str_moves.h"
#include "position_util.h"
#include "dungeon_music.h"
#include "dungeon_map_access.h"
#include "code_803E46C.h"
#include "code_806CD90.h"
#include "game_options.h"
#include "dungeon_items.h"
#include "moves.h"
#include "dungeon_random.h"
#include "code_803E668.h"
#include "constants/dungeon.h"
#include "constants/iq_skill.h"
#include "constants/ability.h"
#include "constants/type.h"
#include "constants/move_id.h"
#include "constants/weather.h"
#include "number_util.h"
#include "dungeon_message.h"
#include "code_8077274_1.h"
#include "math.h"
#include "dungeon_config.h"
extern void sub_8073D14(Entity *);
extern bool8 sub_8044B28(void);
extern void sub_8075708(Entity *entity);
extern void DealDamageToEntity(Entity *, s32, u32, u32);
extern void sub_805229C(void);
extern void sub_807E8F0(Entity *);
extern void sub_80444F4(Entity *pokemon);
extern void WarpTarget(Entity *pokemon, Entity *r1, u32 r2, DungeonPos *r3);
extern void sub_80420B8(Entity *pokemon);
extern void sub_8041C4C(Entity *pokemon, u32 r1);
extern void sub_805E804(void);
extern void sub_80838EC(u8 *a);
extern bool8 TryUseChosenMove(struct Entity *, u32, u32, u32, u32, struct Move *);
extern bool8 sub_8045888(Entity *);
extern void nullsub_97(Entity *entity);
extern void sub_805EE30(void);
extern void sub_8086AC0(void);
extern void sub_8085140(void);
extern void sub_8075708(Entity *entity);
extern void sub_8043ED0(u32);
extern void sub_8071DA4(Entity *);
extern void sub_8075900(Entity *pokemon, u8 r1);
extern void sub_806A5B8(Entity *);
extern void sub_807EC28(bool8);
extern void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr);
extern void sub_8074094(Entity *entity);
extern u8 gUnknown_202F32D;
extern const DungeonPos gUnknown_80F4D44[];
static EWRAM_DATA s32 gUnknown_202F378 = 0;
void sub_8074FB0(Entity *entity, s32 a1, DungeonPos *pos)
{
Unk_Entity_x184 *strPtr;
EntityInfo *entityInfo = GetEntInfo(entity);
if (entityInfo->numMoveTiles > 3) {
entityInfo->action.action = 0;
return;
}
if (gGameOptionsRef->dungeonSpeed != 0)
gUnknown_202F378 = 2;
else
gUnknown_202F378 = 1;
strPtr = &entityInfo->unk184[entityInfo->numMoveTiles];
strPtr->unk1A = 0;
strPtr->lastMoveDirection = a1;
strPtr->previousTargetMovePosition1.x = entity->pos.x;
strPtr->previousTargetMovePosition1.y = entity->pos.y;
strPtr->previousTargetMovePosition2.x = pos->x;
strPtr->previousTargetMovePosition2.y = pos->y;
strPtr->lastMoveIncrement.x = gUnknown_80F4D44[a1].x * gUnknown_202F378;
strPtr->lastMoveIncrement.y = gUnknown_80F4D44[a1].y * gUnknown_202F378;
sub_8075050(entityInfo, strPtr);
}
void sub_8075050(EntityInfo *info, Unk_Entity_x184 *strPtr)
{
s32 savedX, savedY;
if (gGameOptionsRef->dungeonSpeed != 0)
gUnknown_202F378 = 2;
else
gUnknown_202F378 = 1;
info->numMoveTiles++;
if (info->numMoveTiles == 2) {
info->unk184[0].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 2);
info->unk184[0].lastMoveIncrement.x *= 2;
info->unk184[0].lastMoveIncrement.y *= 2;
strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 2);
strPtr->lastMoveIncrement.x *= 2;
strPtr->lastMoveIncrement.y *= 2;
}
else if (info->numMoveTiles == 3) {
s32 i;
savedX = strPtr->lastMoveIncrement.x;
savedY = strPtr->lastMoveIncrement.y;
for (i = 0; i < 2; i++) {
info->unk184[i].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 3);
info->unk184[i].lastMoveIncrement.x *= 3;
info->unk184[i].lastMoveIncrement.y *= 3;
info->unk184[i].lastMoveIncrement.x /= 2;
info->unk184[i].lastMoveIncrement.y /= 2;
}
strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 3);
strPtr->lastMoveIncrement.x = savedX * 3;
strPtr->lastMoveIncrement.y = savedY * 3;
}
else if (info->numMoveTiles == 4) {
s32 i;
savedX = strPtr->lastMoveIncrement.x;
savedY = strPtr->lastMoveIncrement.y;
for (i = 0; i < 3; i++) {
info->unk184[i].walkAnimFramesLeft = 24 / (gUnknown_202F378 * 4);
info->unk184[i].lastMoveIncrement.x *= 4;
info->unk184[i].lastMoveIncrement.y *= 4;
info->unk184[i].lastMoveIncrement.x /= 3;
info->unk184[i].lastMoveIncrement.y /= 3;
}
strPtr->walkAnimFramesLeft = 24 / (gUnknown_202F378 * 4);
strPtr->lastMoveIncrement.x = savedX * 4;
strPtr->lastMoveIncrement.y = savedY * 4;
}
else {
strPtr->walkAnimFramesLeft = 24 / gUnknown_202F378;
}
}
bool8 UseAttack(Entity *a0)
{
s32 i, j, loop;
Entity *savedEntityPtr;
bool32 r7 = FALSE;
bool32 r9 = FALSE;
gUnknown_202F32D = 0;
if (gGameOptionsRef->dungeonSpeed != 0)
gUnknown_202F378 = 2;
else
gUnknown_202F378 = 1;
for (i = 0; i < DUNGEON_MAX_POKEMON; i++) {
Entity *mon = gDungeon->activePokemon[i];
if (EntityIsValid(mon)) {
EntityInfo *monInfo = GetEntInfo(mon);
if (monInfo->numMoveTiles == 0) {
if (monInfo->waiting) {
monInfo->waiting = FALSE;
if ((monInfo->targetPos.x != 0 || monInfo->targetPos.y != 0)
&& (monInfo->targetPos.x != mon->pos.x || monInfo->targetPos.y != mon->pos.y)
&& (!CheckVariousStatuses2(mon, TRUE) || !CheckVariousStatuses(mon)))
{
s32 direction = GetDirectionTowardsPosition(&mon->pos, &monInfo->targetPos);
if (direction != monInfo->action.direction)
sub_806CE68(mon, direction);
}
}
}
else {
PixelPos pos;
monInfo->flags |= 0x2000;
pos.x = X_POS_TO_PIXELPOS(monInfo->unk184[0].previousTargetMovePosition2.x);
pos.y = Y_POS_TO_PIXELPOS(monInfo->unk184[0].previousTargetMovePosition2.y);
sub_804535C(mon, &pos);
sub_806CDFC(mon, 0, monInfo->unk184[0].lastMoveDirection);
monInfo->notMoving = 0;
r7 = TRUE;
if (sub_8045888(mon))
r9 = TRUE;
}
}
}
if (!r7)
return FALSE;
savedEntityPtr = gDungeon->unkB8;
gDungeon->unkB8 = a0;
if (gDungeon->unk644.unk28 == 0 && r9) {
sub_80526D0(0x35);
for (loop = 0; loop < 24 / gUnknown_202F378; loop++) {
DungeonRunFrameActions(7);
for (i = 0; i < DUNGEON_MAX_POKEMON; i++) {
Entity *mon = gDungeon->activePokemon[i];
if (EntityIsValid(mon)) {
EntityInfo *monInfo = GetEntInfo(mon);
Unk_Entity_x184 *strPtr = &monInfo->unk184[monInfo->notMoving];
ASM_MATCH_TRICK(i);
if (monInfo->numMoveTiles != 0) {
IncreaseEntityPixelPos(mon, strPtr->lastMoveIncrement.x, strPtr->lastMoveIncrement.y);
if (--strPtr->walkAnimFramesLeft == 0) {
if (++monInfo->notMoving == monInfo->numMoveTiles) {
monInfo->numMoveTiles = 0;
}
else {
PixelPos pos;
pos.x = X_POS_TO_PIXELPOS(monInfo->unk184[monInfo->notMoving].previousTargetMovePosition2.x);
pos.y = Y_POS_TO_PIXELPOS(monInfo->unk184[monInfo->notMoving].previousTargetMovePosition2.y);
sub_804535C(mon, &pos);
sub_806CDFC(mon, 0, monInfo->unk184[monInfo->notMoving].lastMoveDirection);
}
}
}
}
}
}
}
for (i = 0; i < DUNGEON_MAX_POKEMON; i++) {
Entity *mon = gDungeon->activePokemon[i];
if (EntityIsValid(mon)) {
EntityInfo *monInfo = GetEntInfo(mon);
monInfo->numMoveTiles = 0;
nullsub_97(mon);
if (monInfo->flags & 0x2000) {
sub_804535C(mon, NULL);
}
}
}
sub_807AA30();
for (j = 0; j < 2; j++) {
for (loop = 0; loop < DUNGEON_MAX_POKEMON; loop++) {
DungeonPos monPosBefore;
EntityInfo *monInfo;
Entity *mon = gDungeon->activePokemon[loop];
if (!EntityIsValid(mon))
continue;
if (sub_8044B28())
break;
monInfo = GetEntInfo(mon);
if ((j == 0 && !monInfo->isTeamLeader) || (j != 0 && monInfo->isTeamLeader))
continue;
monPosBefore = mon->pos;
// Statement with no effect needed to match.
GetEntInfo(mon)->isTeamLeader = GetEntInfo(mon)->isTeamLeader;
if (monInfo->flags & 0x2000) {
monInfo->flags &= ~(0x2000);
if (monInfo->isTeamLeader) {
sub_804AC20(&mon->pos);
sub_807EC28(FALSE);
sub_805EE30();
}
else {
sub_8075708(mon);
}
if (!EntityIsValid(mon))
continue;
if (sub_8044B28())
break;
sub_8043ED0(0);
sub_8074094(mon);
if (!EntityIsValid(mon))
continue;
if (sub_8044B28())
break;
sub_8071DA4(mon);
sub_8046D20();
sub_8075900(mon, gDungeon->forceMonsterHouse);
}
if (!EntityIsValid(mon))
continue;
if (sub_8044B28())
break;
if (monPosBefore.x != mon->pos.x || monPosBefore.y != mon->pos.y)
gUnknown_202F32D = 1;
sub_806A5B8(mon);
if (sub_80706A4(mon, &mon->pos)) {
WarpTarget(mon, mon, 0, NULL);
}
}
}
sub_8086AC0();
if (!sub_8044B28()) {
sub_8085140();
gDungeon->unkB8 = savedEntityPtr;
}
else {
gDungeon->unkB8 = savedEntityPtr;
}
return TRUE;
}
void sub_8075680(void)
{
@@ -122,7 +431,7 @@ u32 sub_8075818(Entity *entity)
EntityInfo *entityInfo;
Entity *subEntity;
Item *item;
Trap *trapData; // TODO: turn into struct when more research is done..
Trap *trapData;
u8 r1;
entityInfo = GetEntInfo(entity);

View File

@@ -162,6 +162,7 @@ gUnknown_202F32D: /* 202F32D (sub_8072CF4 - UseAttack) */
.include "src/dungeon_ai_items.o"
.include "src/code_8073CF0.o"
.include "src/code_8075708.o"
.space 0x4
.include "src/dungeon_ai_attack.o"
.include "src/code_80869E4.o"