more Blue based clean-up

This commit is contained in:
DizzyEggg
2025-11-07 12:57:35 +01:00
parent 275b3e59f6
commit 4932b1a78b
3 changed files with 42 additions and 55 deletions

View File

@@ -37,7 +37,6 @@ typedef struct MenuInputStruct
/* 0x20 */ s16 pagesCount;
/* 0x22 */ s16 totalEntriesCount;
/* 0x24 */ u16 unk24;
/* 0x26 */ u16 unk26;
/* 0x28 */ TouchScreenMenuInput touchScreen; // For obvious reason unused on GBA
} MenuInputStruct;

View File

@@ -53,14 +53,13 @@ void AIMovement(Entity *pokemon, bool8 showRunAwayEffect)
pokemonInfo->aiTarget.aiTurningAround = FALSE;
if (IsTacticSet(pokemon, TACTIC_BE_PATIENT))
{
u32 maxHPStat = pokemonInfo->maxHPStat;
maxHPStat += maxHPStat >> 0x1f;
if (pokemonInfo->HP <= (s16) (maxHPStat / 2))
if (pokemonInfo->HP <= pokemonInfo->maxHPStat / 2)
{
pokemonInfo->action.action = ACTION_NOTHING;
return;
}
}
if (IsTacticSet(pokemon, TACTIC_WAIT_THERE))
{
pokemonInfo->action.action = ACTION_NOTHING;
@@ -92,6 +91,7 @@ void AIMovement(Entity *pokemon, bool8 showRunAwayEffect)
{
hasAction = ChooseTargetPosition(pokemon);
}
if (!hasAction)
{
pokemonInfo->action.action = ACTION_NOTHING;
@@ -444,6 +444,8 @@ static void DecideMovement(Entity *pokemon, bool8 showRunAwayEffect)
}
}
// This function is nowhere near close to matching in Blue https://decomp.me/scratch/QNmaT. I suspect abs macros/static inlines or s16 changing the way we need to write code for agbcc.
// Sky's version is not matched either, but I believe it's closer to this one. To revisit later.
static bool8 AvoidEnemies(Entity *pokemon)
{
bool8 pokemonInFront;
@@ -546,16 +548,8 @@ static bool8 AvoidEnemies(Entity *pokemon)
naturalJunctionListCounts = gDungeon->naturalJunctionListCounts[room];
furthestTargetToExitDistance = -INFINITY_2;
furthestTargetExitIndex = 0;
distanceX = closestTarget->pos.x - pokemon->pos.x;
if (distanceX < 0)
{
distanceX = -distanceX;
}
pokemonToTargetDistance = closestTarget->pos.y - pokemon->pos.y;
if (pokemonToTargetDistance < 0)
{
pokemonToTargetDistance = -pokemonToTargetDistance;
}
distanceX = abs(closestTarget->pos.x - pokemon->pos.x);
pokemonToTargetDistance = abs(closestTarget->pos.y - pokemon->pos.y);
if (pokemonToTargetDistance < distanceX)
{
pokemonToTargetDistance = distanceX;
@@ -565,48 +559,31 @@ static bool8 AvoidEnemies(Entity *pokemon)
s32 targetToExitDistance;
s32 pokemonToExitSignX, pokemonToExitSignY;
s32 adjacentToTargetDistanceX, adjacentToTargetDistance;
s32 distanceX = closestTarget->pos.x - naturalJunctionList[i].x;
if (distanceX < 0)
{
distanceX = -distanceX;
}
targetToExitDistance = closestTarget->pos.y - naturalJunctionList[i].y;
if (targetToExitDistance < 0)
{
targetToExitDistance = -targetToExitDistance;
}
s32 distanceX = abs(closestTarget->pos.x - naturalJunctionList[i].x);
targetToExitDistance = abs(closestTarget->pos.y - naturalJunctionList[i].y);
if (targetToExitDistance < distanceX)
{
targetToExitDistance = distanceX;
}
pokemonToExitSignX = naturalJunctionList[i].x - pokemon->pos.x;
pokemonToExitSignY = naturalJunctionList[i].y - pokemon->pos.y;
if (pokemonToExitSignX < -1)
{
pokemonToExitSignX = -1;
}
if (pokemonToExitSignY < -1)
{
pokemonToExitSignY = -1;
}
if (pokemonToExitSignX > 1)
{
pokemonToExitSignX = 1;
}
if (pokemonToExitSignY > 1)
{
pokemonToExitSignY = 1;
}
adjacentToTargetDistanceX = closestTarget->pos.x - (pokemon->pos.x + pokemonToExitSignX);
if (adjacentToTargetDistanceX < 0)
{
adjacentToTargetDistanceX = -adjacentToTargetDistanceX;
}
adjacentToTargetDistance = closestTarget->pos.y - (pokemon->pos.y + pokemonToExitSignY);
if (adjacentToTargetDistance < 0)
{
adjacentToTargetDistance = -adjacentToTargetDistance;
}
adjacentToTargetDistanceX = abs(closestTarget->pos.x - (pokemon->pos.x + pokemonToExitSignX));
adjacentToTargetDistance = abs(closestTarget->pos.y - (pokemon->pos.y + pokemonToExitSignY));
if (adjacentToTargetDistance < adjacentToTargetDistanceX)
{
adjacentToTargetDistance = adjacentToTargetDistanceX;

View File

@@ -1107,18 +1107,23 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1)
s32 r10;
bool8 printAll = fromBPress;
s32 chosenOption;
s32 var_24;
struct UnkMenuBitsStruct var_30;
struct UnkMenuBitsStruct var_34;
bool8 var_24;
r10 = gDungeon->unk5C0;
chosenOption = 0;
var_24 = (gDungeon->unk5C0 > - 1);
var_24 = (gDungeon->unk5C0 >= 0);
gDungeon->unk5C0 = -1;
if (r10 >= 0) {
chosenOption = r10;
}
// Blue/DS only fields?
#if GAME_VERSION == VERSION_BLUE
gDungeon->unk17C = -1;
gDungeon->unk17E = -1;
#endif
if (a1) {
PlayFanfareSE(0x137, 0x100);
}
@@ -1143,7 +1148,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1)
PlayDungeonCursorSE(1);
MoveMenuCursorUpWrapAround(&gDungeonMenu, TRUE);
}
if ((gRealInputs.pressed & A_BUTTON || gDungeonMenu.touchScreen.a_button)) {
if ((gRealInputs.pressed & A_BUTTON /* || (gRealInputs.pressed & 0x400) */ || gDungeonMenu.touchScreen.a_button)) {
if (gUnknown_202749A[gDungeonMenu.menuIndex + 1] == 7) {
PlayDungeonConfirmationSE();
chosenOption = gDungeonMenu.menuIndex;
@@ -1165,6 +1170,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1)
r10 = chosenOption;
if (chosenOption == MAIN_MENU_ITEMS) {
u16 action;
struct UnkMenuBitsStruct var_34;
SetLeaderActionToNothing(TRUE);
var_34.a0_8 = 0;
@@ -1269,7 +1275,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1)
break;
}
else if (chosenOption == MAIN_MENU_MOVES) {
s32 i, currMonId, teamMonsCount, r9;
s32 i, currMonId;
Entity *currEntity;
currMonId = 0;
@@ -1285,8 +1291,10 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1)
}
while (1) {
s32 r9, teamMonsCount;
SetLeaderActionToNothing(0);
LOOP_START_NO_CALL: // Actions 6 and 7 don't call SetLeaderActionToNothing
LOOP_START_NO_CALL: // Actions 6 and 7 don't call SetLeaderActionToNothing. Goto is real here.
currEntity = NULL;
r9 = 0;
teamMonsCount = 0;
@@ -1347,7 +1355,10 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1)
else if (GetLeaderActionId() == ACTION_MOVE_INFO) {
ActionShowMoveInfo(GetLeaderActionContainer());
}
else if (GetLeaderActionId() == ACTION_SET_MOVE || GetLeaderActionId() == ACTION_UNSET_MOVE) {
else if (GetLeaderActionId() == ACTION_SET_MOVE) {
ActionSetOrUnsetMove(GetLeaderActionContainer(), FALSE);
}
else if (GetLeaderActionId() == ACTION_UNSET_MOVE) {
ActionSetOrUnsetMove(GetLeaderActionContainer(), FALSE);
}
else if (GetLeaderActionId() == ACTION_SWITCH_AI_MOVE) {
@@ -1375,6 +1386,7 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1)
if (tileObject != NULL) {
if (GetEntityType(tileObject) == ENTITY_ITEM) {
u16 action;
struct UnkMenuBitsStruct var_30;
SetLeaderActionToNothing(TRUE);
var_30.a0_8 = 0;
@@ -1449,14 +1461,13 @@ static void ShowMainMenu(bool8 fromBPress, bool8 a1)
if (chosenOption < 0)
break;
if (var_24 == 0) {
ResetRepeatTimers();
ResetUnusedInputStruct();
}
else {
if (var_24) {
TryPointCameraToMonster(GetLeader(), 0);
break;
}
ResetRepeatTimers();
ResetUnusedInputStruct();
}
sub_803EAF0(0, NULL);