Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use miscellaneous missing constants #1910

Merged
merged 2 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/constants/contest.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#define CONTEST_LAST_APPEAL (CONTEST_NUM_APPEALS - 1)
#define MAX_CONTEST_MOVE_HEARTS 8

#define CONTESTANT_NONE 0xFF

#define LINK_CONTEST_FLAG_IS_LINK (1 << 0)
#define LINK_CONTEST_FLAG_IS_WIRELESS (1 << 1)
#define LINK_CONTEST_FLAG_HAS_RS_PLAYER (1 << 2)
Expand Down
16 changes: 6 additions & 10 deletions src/battle_ai_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,13 @@
#include "constants/abilities.h"
#include "constants/battle_ai.h"
#include "constants/battle_move_effects.h"
#include "constants/items.h"
#include "constants/moves.h"

#define AI_ACTION_DONE 0x0001
#define AI_ACTION_FLEE 0x0002
#define AI_ACTION_WATCH 0x0004
#define AI_ACTION_DO_NOT_ATTACK 0x0008
#define AI_ACTION_UNK5 0x0010
#define AI_ACTION_UNK6 0x0020
#define AI_ACTION_UNK7 0x0040
#define AI_ACTION_UNK8 0x0080
#define AI_ACTION_DONE (1 << 0)
#define AI_ACTION_FLEE (1 << 1)
#define AI_ACTION_WATCH (1 << 2)
#define AI_ACTION_DO_NOT_ATTACK (1 << 3)

#define AI_THINKING_STRUCT ((struct AI_ThinkingStruct *)(gBattleResources->ai))
#define BATTLE_HISTORY ((struct BattleHistory *)(gBattleResources->battleHistory))
Expand Down Expand Up @@ -283,7 +280,6 @@ static const u16 sIgnoredPowerfulMoveEffects[] =
IGNORED_MOVES_END
};

// code
void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves)
{
s32 i;
Expand All @@ -302,7 +298,7 @@ void BattleAI_HandleItemUseBeforeAISetup(u8 defaultScoreMoves)
{
for (i = 0; i < MAX_TRAINER_ITEMS; i++)
{
if (gTrainers[gTrainerBattleOpponent_A].items[i] != 0)
if (gTrainers[gTrainerBattleOpponent_A].items[i] != ITEM_NONE)
{
BATTLE_HISTORY->trainerItems[BATTLE_HISTORY->itemsNo] = gTrainers[gTrainerBattleOpponent_A].items[i];
BATTLE_HISTORY->itemsNo++;
Expand Down
8 changes: 4 additions & 4 deletions src/battle_ai_switch_items.c
Original file line number Diff line number Diff line change
Expand Up @@ -687,7 +687,7 @@ u8 GetMostSuitableMonToSwitchInto(void)

invalidMons = 0;

while (invalidMons != 0x3F) // All mons are invalid.
while (invalidMons != (1 << PARTY_SIZE) - 1) // All mons are invalid.
{
bestDmg = TYPE_MUL_NO_EFFECT;
bestMonId = PARTY_SIZE;
Expand Down Expand Up @@ -741,7 +741,7 @@ u8 GetMostSuitableMonToSwitchInto(void)
}
else
{
invalidMons = 0x3F; // No viable mon to switch.
invalidMons = (1 << PARTY_SIZE) - 1; // No viable mon to switch.
}
}

Expand Down Expand Up @@ -862,7 +862,7 @@ static bool8 ShouldUseItem(void)
shouldUse = TRUE;
break;
case AI_ITEM_HEAL_HP:
paramOffset = GetItemEffectParamOffset(item, 4, 4);
paramOffset = GetItemEffectParamOffset(item, 4, ITEM4_HEAL_HP);
if (paramOffset == 0)
break;
if (gBattleMons[gActiveBattler].hp == 0)
Expand Down Expand Up @@ -935,7 +935,7 @@ static bool8 ShouldUseItem(void)
{
BtlController_EmitTwoReturnValues(BUFFER_B, B_ACTION_USE_ITEM, 0);
*(gBattleStruct->chosenItem + (gActiveBattler / 2) * 2) = item;
gBattleResources->battleHistory->trainerItems[i] = 0;
gBattleResources->battleHistory->trainerItems[i] = ITEM_NONE;
return shouldUse;
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/battle_anim_effects_1.c
Original file line number Diff line number Diff line change
Expand Up @@ -3578,13 +3578,13 @@ static void AnimFlyingParticle(struct Sprite *sprite)
{
sprite->data[4] = 0;
sprite->data[2] = gBattleAnimArgs[3];
sprite->x = 0xFFF0;
sprite->x = -16;
}
else
{
sprite->data[4] = 1;
sprite->data[2] = -gBattleAnimArgs[3];
sprite->x = 0x100;
sprite->x = DISPLAY_WIDTH + 16;
}

sprite->data[1] = gBattleAnimArgs[1];
Expand Down Expand Up @@ -3623,7 +3623,7 @@ static void AnimFlyingParticle_Step(struct Sprite *sprite)
sprite->data[0] = (sprite->data[3] * a) & 0xFF;
if (!sprite->data[4])
{
if (sprite->x2 + sprite->x <= 0xF7)
if (sprite->x2 + sprite->x < DISPLAY_WIDTH + 8)
return;
}
else
Expand Down
6 changes: 3 additions & 3 deletions src/battle_anim_effects_3.c
Original file line number Diff line number Diff line change
Expand Up @@ -3056,7 +3056,7 @@ static void AnimFlatterConfetti(struct Sprite *sprite)
if (sprite->data[2] == ANIM_ATTACKER)
sprite->x = -8;
else
sprite->x = 248;
sprite->x = DISPLAY_WIDTH + 8;

sprite->y = 104;
sprite->callback = AnimFlatterConfetti_Step;
Expand Down Expand Up @@ -3414,8 +3414,8 @@ static void AnimTask_AcidArmor_Step(u8 taskId)
var0 *= 2;
while (var0 >= 0)
{
gScanlineEffectRegBuffers[0][var0] = bgX + 240;
gScanlineEffectRegBuffers[1][var0] = bgX + 240;
gScanlineEffectRegBuffers[0][var0] = bgX + DISPLAY_WIDTH;
gScanlineEffectRegBuffers[1][var0] = bgX + DISPLAY_WIDTH;
var0 -= 2;
}

Expand Down
6 changes: 3 additions & 3 deletions src/battle_anim_ground.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,10 @@ static void SetDigScanlineEffect(u8 useBG1, s16 y, s16 endY)
y++;
}

while (y < 160)
while (y < DISPLAY_HEIGHT)
{
gScanlineEffectRegBuffers[0][y] = bgX + 240;
gScanlineEffectRegBuffers[1][y] = bgX + 240;
gScanlineEffectRegBuffers[0][y] = bgX + DISPLAY_WIDTH;
gScanlineEffectRegBuffers[1][y] = bgX + DISPLAY_WIDTH;
y++;
}

Expand Down
6 changes: 3 additions & 3 deletions src/battle_anim_ice.c
Original file line number Diff line number Diff line change
Expand Up @@ -1305,11 +1305,11 @@ static void MovePoisonGasCloud(struct Sprite *sprite)
sprite->data[3] = sprite->y += sprite->y2;
sprite->data[4] = sprite->y + 4;
if (IsContest())
sprite->data[2] = -0x10;
sprite->data[2] = -16;
else if (GET_BATTLER_SIDE2(gBattleAnimTarget) != B_SIDE_PLAYER)
sprite->data[2] = 0x100;
sprite->data[2] = DISPLAY_WIDTH + 16;
else
sprite->data[2] = -0x10;
sprite->data[2] = -16;

sprite->data[7]++;
sprite->x2 = sprite->y2 = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/battle_anim_throw.c
Original file line number Diff line number Diff line change
Expand Up @@ -2117,7 +2117,7 @@ void AnimTask_SwapMonSpriteToFromSubstitute(u8 taskId)

gTasks[taskId].data[0] &= 0xFF;
x = gSprites[spriteId].x + gSprites[spriteId].x2 + 32;
if (x > 304)
if (x > DISPLAY_WIDTH + 64)
gTasks[taskId].data[10]++;
break;
case 1:
Expand Down
36 changes: 18 additions & 18 deletions src/battle_intro.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ static void BattleIntroSlide1(u8 taskId)
if ((gBattle_WIN0V & 0xFF00) == 0x3000)
{
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[2] = DISPLAY_WIDTH;
gTasks[taskId].data[3] = 32;
gIntroSlideFlags &= ~1;
}
Expand Down Expand Up @@ -213,13 +213,13 @@ static void BattleIntroSlide1(u8 taskId)
gTasks[taskId].data[2] -= 2;

// Scanline settings have already been set in CB2_InitBattleInternal()
for (i = 0; i < 80; i++)
for (i = 0; i < DISPLAY_HEIGHT / 2; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2];

for (; i < 160; i++)
for (; i < DISPLAY_HEIGHT; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2];

if (!gTasks[taskId].data[2])
if (gTasks[taskId].data[2] == 0)
{
gScanlineEffect.state = 3;
gTasks[taskId].tState++;
Expand Down Expand Up @@ -290,7 +290,7 @@ static void BattleIntroSlide2(u8 taskId)
if ((gBattle_WIN0V & 0xFF00) == 0x3000)
{
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[2] = DISPLAY_WIDTH;
gTasks[taskId].data[3] = 32;
gTasks[taskId].data[5] = 1;
gIntroSlideFlags &= ~1;
Expand Down Expand Up @@ -322,13 +322,13 @@ static void BattleIntroSlide2(u8 taskId)
gTasks[taskId].data[2] -= 2;

// Scanline settings have already been set in CB2_InitBattleInternal()
for (i = 0; i < 80; i++)
for (i = 0; i < DISPLAY_HEIGHT / 2; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2];

for (; i < 160; i++)
for (; i < DISPLAY_HEIGHT; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2];

if (!gTasks[taskId].data[2])
if (gTasks[taskId].data[2] == 0)
{
gScanlineEffect.state = 3;
gTasks[taskId].tState++;
Expand Down Expand Up @@ -383,7 +383,7 @@ static void BattleIntroSlide3(u8 taskId)
if ((gBattle_WIN0V & 0xFF00) == 0x3000)
{
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[2] = DISPLAY_WIDTH;
gTasks[taskId].data[3] = 32;
gTasks[taskId].data[5] = 1;
gIntroSlideFlags &= ~1;
Expand All @@ -410,13 +410,13 @@ static void BattleIntroSlide3(u8 taskId)
gTasks[taskId].data[2] -= 2;

// Scanline settings have already been set in CB2_InitBattleInternal()
for (i = 0; i < 80; i++)
for (i = 0; i < DISPLAY_HEIGHT / 2; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2];

for (; i < 160; i++)
for (; i < DISPLAY_HEIGHT; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2];

if (!gTasks[taskId].data[2])
if (gTasks[taskId].data[2] == 0)
{
gScanlineEffect.state = 3;
gTasks[taskId].tState++;
Expand Down Expand Up @@ -479,7 +479,7 @@ static void BattleIntroSlideLink(u8 taskId)
if ((gBattle_WIN0V & 0xFF00) == 0x3000)
{
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[2] = DISPLAY_WIDTH;
gTasks[taskId].data[3] = 32;
gIntroSlideFlags &= ~1;
}
Expand All @@ -492,13 +492,13 @@ static void BattleIntroSlideLink(u8 taskId)
gTasks[taskId].data[2] -= 2;

// Scanline settings have already been set in CB2_InitBattleInternal()
for (i = 0; i < 80; i++)
for (i = 0; i < DISPLAY_HEIGHT / 2; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gTasks[taskId].data[2];

for (; i < 160; i++)
for (; i < DISPLAY_HEIGHT; i++)
gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = -gTasks[taskId].data[2];

if (!gTasks[taskId].data[2])
if (gTasks[taskId].data[2] == 0)
{
gScanlineEffect.state = 3;
gTasks[taskId].tState++;
Expand Down Expand Up @@ -544,7 +544,7 @@ static void BattleIntroSlidePartner(u8 taskId)
if ((gBattle_WIN0V & 0xFF00) == 0x2000)
{
gTasks[taskId].tState++;
gTasks[taskId].data[2] = 240;
gTasks[taskId].data[2] = DISPLAY_WIDTH;
gIntroSlideFlags &= ~1;
}
break;
Expand All @@ -557,7 +557,7 @@ static void BattleIntroSlidePartner(u8 taskId)

gBattle_BG1_X = gTasks[taskId].data[2];
gBattle_BG2_X = -gTasks[taskId].data[2];
if (!gTasks[taskId].data[2])
if (gTasks[taskId].data[2] == 0)
gTasks[taskId].tState++;
break;
case 4:
Expand Down
7 changes: 2 additions & 5 deletions src/battle_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,19 +644,16 @@ static void CB2_InitBattleInternal(void)
gBattle_WIN0V = WIN_RANGE(DISPLAY_HEIGHT / 2, DISPLAY_HEIGHT / 2 + 1);
ScanlineEffect_Clear();

i = 0;
while (i < 80)
for (i = 0; i < DISPLAY_HEIGHT / 2; i++)
{
gScanlineEffectRegBuffers[0][i] = 0xF0;
gScanlineEffectRegBuffers[1][i] = 0xF0;
i++;
}

while (i < 160)
for (; i < DISPLAY_HEIGHT; i++)
{
gScanlineEffectRegBuffers[0][i] = 0xFF10;
gScanlineEffectRegBuffers[1][i] = 0xFF10;
i++;
}

ScanlineEffect_SetParams(sIntroScanlineParams16Bit);
Expand Down
9 changes: 9 additions & 0 deletions src/battle_script_commands.c
Original file line number Diff line number Diff line change
Expand Up @@ -7812,9 +7812,18 @@ static void Cmd_metronome(void)
{
s32 i;

#if MOVES_COUNT < 512
// Original GF method of move selection is to pick a random
// number between 1-511. 355-511 are not valid moves, so if it
// picks in this range it retries. If MOVES_COUNT exceeds 511 we
// instead use a simpler solution.
gCurrentMove = (Random() & 0x1FF) + 1;
if (gCurrentMove >= MOVES_COUNT)
continue;
#else
// Just pick a valid move value (between 1 and MOVES_COUNT-1)
gCurrentMove = (Random() % (MOVES_COUNT - 1)) + 1;
#endif

for (i = 0; i < MAX_MON_MOVES; i++); // ?

Expand Down
6 changes: 5 additions & 1 deletion src/battle_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,11 @@ void HandleAction_UseItem(void)
gBattleCommunication[MULTISTRING_CHOOSER] = AI_HEAL_CONFUSION;
if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & (1 << AI_HEAL_CONFUSION))
{
if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & 0x3E)
if (*(gBattleStruct->AI_itemFlags + gBattlerAttacker / 2) & ((1 << AI_HEAL_PARALYSIS)
| (1 << AI_HEAL_FREEZE)
| (1 << AI_HEAL_BURN)
| (1 << AI_HEAL_POISON)
| (1 << AI_HEAL_SLEEP)))
gBattleCommunication[MULTISTRING_CHOOSER] = AI_HEAL_SLEEP;
}
else
Expand Down
8 changes: 4 additions & 4 deletions src/berry_blender.c
Original file line number Diff line number Diff line change
Expand Up @@ -3109,10 +3109,10 @@ static void DrawBlenderCenter(struct BgAffineSrcData *dest)
{
struct BgAffineSrcData affineSrc;

affineSrc.texX = 0x7800;
affineSrc.texY = 0x5000;
affineSrc.scrX = 0x78 - sBerryBlender->bg_X;
affineSrc.scrY = 0x50 - sBerryBlender->bg_Y;
affineSrc.texX = (DISPLAY_WIDTH / 2) << 8;
affineSrc.texY = (DISPLAY_HEIGHT / 2) << 8;
affineSrc.scrX = DISPLAY_WIDTH / 2 - sBerryBlender->bg_X;
affineSrc.scrY = DISPLAY_HEIGHT / 2 - sBerryBlender->bg_Y;
affineSrc.sx = sBerryBlender->centerScale;
affineSrc.sy = sBerryBlender->centerScale;
affineSrc.alpha = sBerryBlender->arrowPos;
Expand Down
Loading