Fix alloc.c as per #386, define INVALID_ constants and rename malloc to alloc as per #325

Some of the INVALID_ are likely erroneously placed, due to lack of documentation
This commit is contained in:
nullableVoidPtr 2018-11-29 19:24:28 +08:00
parent 1b33ad6c26
commit 3909b6408c
148 changed files with 1116 additions and 1108 deletions

View File

@ -1,5 +1,5 @@
#ifndef GUARD_MALLOC_H #ifndef GUARD_ALLOC_H
#define GUARD_MALLOC_H #define GUARD_ALLOC_H
#define HEAP_SIZE 0x1C000 #define HEAP_SIZE 0x1C000
#define malloc Alloc #define malloc Alloc
@ -19,4 +19,4 @@ void *AllocZeroed(u32 size);
void Free(void *pointer); void Free(void *pointer);
void InitHeap(void *pointer, u32 size); void InitHeap(void *pointer, u32 size);
#endif // GUARD_MALLOC_H #endif // GUARD_ALLOC_H

View File

@ -25,6 +25,14 @@
#define INCBIN_S32 {0} #define INCBIN_S32 {0}
#endif // IDE support #endif // IDE support
// Invalid / Out of Bound Placeholder values
#define INVALID_U8 0xFF
#define INVALID_U16 0xFFFF
#define INVALID_U32 0xFFFFFFFF
#define INVALID_S8 -1
#define INVALID_S16 -1
#define INVALID_S32 -1
#define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0])) #define ARRAY_COUNT(array) (size_t)(sizeof(array) / sizeof((array)[0]))
#define SWAP(a, b, temp) \ #define SWAP(a, b, temp) \

View File

@ -43,7 +43,7 @@ SECTIONS {
{ {
asm/crt0.o(.text); asm/crt0.o(.text);
src/main.o(.text); src/main.o(.text);
src/malloc.o(.text); src/alloc.o(.text);
src/dma3_manager.o(.text); src/dma3_manager.o(.text);
src/gpu_regs.o(.text); src/gpu_regs.o(.text);
src/bg.o(.text); src/bg.o(.text);

210
src/alloc.c Normal file
View File

@ -0,0 +1,210 @@
#include "global.h"
static void *sHeapStart;
static u32 sHeapSize;
static u32 malloc_c_unused_0300000c; // needed to align dma3_manager.o(.bss)
#define MALLOC_SYSTEM_ID 0xA3A3
struct MemBlock {
// Whether this block is currently allocated.
bool16 flag;
// Magic number used for error checking. Should equal MALLOC_SYSTEM_ID.
u16 magic;
// Size of the block (not including this header struct).
u32 size;
// Previous block pointer. Equals sHeapStart if this is the first block.
struct MemBlock *prev;
// Next block pointer. Equals sHeapStart if this is the last block.
struct MemBlock *next;
// Data in the memory block. (Arrays of length 0 are a GNU extension.)
u8 data[0];
};
void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next, u32 size)
{
struct MemBlock *header = (struct MemBlock *)block;
header->flag = FALSE;
header->magic = MALLOC_SYSTEM_ID;
header->size = size;
header->prev = prev;
header->next = next;
}
void PutFirstMemBlockHeader(void *block, u32 size)
{
PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock));
}
void *AllocInternal(void *heapStart, u32 size)
{
struct MemBlock *pos = (struct MemBlock *)heapStart;
struct MemBlock *head = pos;
struct MemBlock *splitBlock;
u32 foundBlockSize;
// Alignment
if (size & 3)
size = 4 * ((size / 4) + 1);
for (;;) {
// Loop through the blocks looking for unused block that's big enough.
if (!pos->flag) {
foundBlockSize = pos->size;
if (foundBlockSize >= size) {
if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) {
// The block isn't much bigger than the requested size,
// so just use it.
pos->flag = TRUE;
} else {
// The block is significantly bigger than the requested
// size, so split the rest into a separate block.
foundBlockSize -= sizeof(struct MemBlock);
foundBlockSize -= size;
splitBlock = (struct MemBlock *)(pos->data + size);
pos->flag = TRUE;
pos->size = size;
PutMemBlockHeader(splitBlock, pos, pos->next, foundBlockSize);
pos->next = splitBlock;
if (splitBlock->next != head)
splitBlock->next->prev = splitBlock;
}
return pos->data;
}
}
if (pos->next == head)
return NULL;
pos = pos->next;
}
}
void FreeInternal(void *heapStart, void *pointer)
{
if (pointer) {
struct MemBlock *head = (struct MemBlock *)heapStart;
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
block->flag = FALSE;
// If the freed block isn't the last one, merge with the next block
// if it's not in use.
if (block->next != head) {
if (!block->next->flag) {
block->size += sizeof(struct MemBlock) + block->next->size;
block->next->magic = 0;
block->next = block->next->next;
if (block->next != head)
block->next->prev = block;
}
}
// If the freed block isn't the first one, merge with the previous block
// if it's not in use.
if (block != head) {
if (!block->prev->flag) {
block->prev->next = block->next;
if (block->next != head)
block->next->prev = block->prev;
block->magic = 0;
block->prev->size += sizeof(struct MemBlock) + block->size;
}
}
}
}
void *AllocZeroedInternal(void *heapStart, u32 size)
{
void *mem = AllocInternal(heapStart, size);
if (mem != NULL) {
if (size & 3)
size = 4 * ((size / 4) + 1);
CpuFill32(0, mem, size);
}
return mem;
}
bool32 CheckMemBlockInternal(void *heapStart, void *pointer)
{
struct MemBlock *head = (struct MemBlock *)heapStart;
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
if (block->magic != MALLOC_SYSTEM_ID)
return FALSE;
if (block->next->magic != MALLOC_SYSTEM_ID)
return FALSE;
if (block->next != head && block->next->prev != block)
return FALSE;
if (block->prev->magic != MALLOC_SYSTEM_ID)
return FALSE;
if (block->prev != head && block->prev->next != block)
return FALSE;
if (block->next != head && block->next != (struct MemBlock *)(block->data + block->size))
return FALSE;
return TRUE;
}
void InitHeap(void *heapStart, u32 heapSize)
{
sHeapStart = heapStart;
sHeapSize = heapSize;
PutFirstMemBlockHeader(heapStart, heapSize);
}
void *Alloc(u32 size)
{
AllocInternal(sHeapStart, size);
}
void *AllocZeroed(u32 size)
{
AllocZeroedInternal(sHeapStart, size);
}
void Free(void *pointer)
{
FreeInternal(sHeapStart, pointer);
}
bool32 CheckMemBlock(void *pointer)
{
return CheckMemBlockInternal(sHeapStart, pointer);
}
bool32 CheckHeap()
{
struct MemBlock *pos = (struct MemBlock *)sHeapStart;
do {
if (!CheckMemBlockInternal(sHeapStart, pos->data))
return FALSE;
pos = pos->next;
} while (pos != (struct MemBlock *)sHeapStart);
return TRUE;
}

View File

@ -9,7 +9,7 @@
#include "item.h" #include "item.h"
#include "item_menu.h" #include "item_menu.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "menu.h" #include "menu.h"
#include "new_game.h" #include "new_game.h"
#include "party_menu.h" #include "party_menu.h"
@ -1079,7 +1079,7 @@ void ResetApprenticeStruct(struct Apprentice *apprentice)
u8 i; u8 i;
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
apprentice->easyChatWords[i] |= 0xFFFF; apprentice->easyChatWords[i] |= INVALID_U16;
apprentice->playerName[0] = EOS; apprentice->playerName[0] = EOS;
apprentice->id = 16; apprentice->id = 16;
@ -1093,7 +1093,7 @@ void ResetAllApprenticeData(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
for (j = 0; j < 6; j++) for (j = 0; j < 6; j++)
gSaveBlock2Ptr->apprentices[i].easyChatWords[j] |= 0xFFFF; gSaveBlock2Ptr->apprentices[i].easyChatWords[j] |= INVALID_U16;
gSaveBlock2Ptr->apprentices[i].id = 16; gSaveBlock2Ptr->apprentices[i].id = 16;
gSaveBlock2Ptr->apprentices[i].playerName[0] = EOS; gSaveBlock2Ptr->apprentices[i].playerName[0] = EOS;
gSaveBlock2Ptr->apprentices[i].lvlMode = 0; gSaveBlock2Ptr->apprentices[i].lvlMode = 0;
@ -1290,7 +1290,7 @@ static u16 sub_819FF98(u8 arg0)
else else
level = 60; level = 60;
for (j = 0; learnset[j] != 0xFFFF; j++) for (j = 0; learnset[j] != INVALID_U16; j++)
{ {
if ((learnset[j] & 0xFE00) > (level << 9)) if ((learnset[j] & 0xFE00) > (level << 9))
break; break;
@ -1393,7 +1393,7 @@ static void GetLatestLearnedMoves(u16 species, u16 *moves)
level = 60; level = 60;
learnset = gLevelUpLearnsets[species]; learnset = gLevelUpLearnsets[species];
for (i = 0; learnset[i] != 0xFFFF; i++) for (i = 0; learnset[i] != INVALID_U16; i++)
{ {
if ((learnset[i] & 0xFE00) > (level << 9)) if ((learnset[i] & 0xFE00) > (level << 9))
break; break;
@ -2236,7 +2236,7 @@ static void sub_81A1370(void)
} }
r10 = 0xFFFF; r10 = 0xFFFF;
r9 = -1; r9 = INVALID_S32;
for (i = 1; i < 4; i++) for (i = 1; i < 4; i++)
{ {
if (GetTrainerId(gSaveBlock2Ptr->apprentices[i].playerId) == GetTrainerId(gSaveBlock2Ptr->playerTrainerId) if (GetTrainerId(gSaveBlock2Ptr->apprentices[i].playerId) == GetTrainerId(gSaveBlock2Ptr->playerTrainerId)

View File

@ -54,7 +54,7 @@ void GetWordPhonemes(struct BardSong *song, u16 word)
for (i = 0; i < 6; i ++) for (i = 0; i < 6; i ++)
{ {
sound = &song->sound[i]; sound = &song->sound[i];
if (sound->var00 != 0xFF) if (sound->var00 != INVALID_U8)
{ {
song->phonemes[i].length = sound->var01 + gBardSoundLengthTable[sound->var00]; song->phonemes[i].length = sound->var01 + gBardSoundLengthTable[sound->var00];
song->phonemes[i].pitch = CalcWordPitch(word + 30, i); song->phonemes[i].pitch = CalcWordPitch(word + 30, i);

View File

@ -276,7 +276,7 @@ static const u16 sDiscouragedPowerfulMoveEffects[] =
EFFECT_SUPERPOWER, EFFECT_SUPERPOWER,
EFFECT_ERUPTION, EFFECT_ERUPTION,
EFFECT_OVERHEAT, EFFECT_OVERHEAT,
0xFFFF INVALID_U16
}; };
// code // code
@ -463,8 +463,8 @@ static u8 ChooseMoveOrAction_Doubles(void)
{ {
if (i == sBattler_AI || gBattleMons[i].hp == 0) if (i == sBattler_AI || gBattleMons[i].hp == 0)
{ {
actionOrMoveIndex[i] = -1; actionOrMoveIndex[i] = INVALID_U8;
bestMovePointsForTarget[i] = -1; bestMovePointsForTarget[i] = INVALID_S16 ;
} }
else else
{ {
@ -530,7 +530,7 @@ static u8 ChooseMoveOrAction_Doubles(void)
// Don't use a move against ally if it has less than 100 points. // Don't use a move against ally if it has less than 100 points.
if (i == (sBattler_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100) if (i == (sBattler_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100)
{ {
bestMovePointsForTarget[i] = -1; bestMovePointsForTarget[i] = INVALID_S16;
mostViableMovesScores[0] = mostViableMovesScores[0]; // Needed to match. mostViableMovesScores[0] = mostViableMovesScores[0]; // Needed to match.
} }
} }
@ -1003,7 +1003,7 @@ static void BattleAICmd_if_in_bytes(void)
{ {
const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1); const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFF) while (*ptr != INVALID_U8)
{ {
if (AI_THINKING_STRUCT->funcResult == *ptr) if (AI_THINKING_STRUCT->funcResult == *ptr)
{ {
@ -1019,7 +1019,7 @@ static void BattleAICmd_if_not_in_bytes(void)
{ {
const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1); const u8 *ptr = T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFF) while (*ptr != INVALID_U8)
{ {
if (AI_THINKING_STRUCT->funcResult == *ptr) if (AI_THINKING_STRUCT->funcResult == *ptr)
{ {
@ -1035,7 +1035,7 @@ static void BattleAICmd_if_in_hwords(void)
{ {
const u16 *ptr = (const u16 *)T1_READ_PTR(gAIScriptPtr + 1); const u16 *ptr = (const u16 *)T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFFFF) while (*ptr != INVALID_U16)
{ {
if (AI_THINKING_STRUCT->funcResult == *ptr) if (AI_THINKING_STRUCT->funcResult == *ptr)
{ {
@ -1051,7 +1051,7 @@ static void BattleAICmd_if_not_in_hwords(void)
{ {
const u16 *ptr = (const u16 *)T1_READ_PTR(gAIScriptPtr + 1); const u16 *ptr = (const u16 *)T1_READ_PTR(gAIScriptPtr + 1);
while (*ptr != 0xFFFF) while (*ptr != INVALID_U16)
{ {
if (AI_THINKING_STRUCT->funcResult == *ptr) if (AI_THINKING_STRUCT->funcResult == *ptr)
{ {
@ -1167,14 +1167,14 @@ static void BattleAICmd_get_how_powerful_move_is(void)
s32 i, checkedMove; s32 i, checkedMove;
s32 moveDmgs[4]; s32 moveDmgs[4];
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++) for (i = 0; sDiscouragedPowerfulMoveEffects[i] != INVALID_U16; i++)
{ {
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == sDiscouragedPowerfulMoveEffects[i]) if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].effect == sDiscouragedPowerfulMoveEffects[i])
break; break;
} }
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power > 1 if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power > 1
&& sDiscouragedPowerfulMoveEffects[i] == 0xFFFF) && sDiscouragedPowerfulMoveEffects[i] == INVALID_U16)
{ {
gDynamicBasePower = 0; gDynamicBasePower = 0;
*(&gBattleStruct->dynamicMoveType) = 0; *(&gBattleStruct->dynamicMoveType) = 0;
@ -1184,14 +1184,14 @@ static void BattleAICmd_get_how_powerful_move_is(void)
for (checkedMove = 0; checkedMove < 4; checkedMove++) for (checkedMove = 0; checkedMove < 4; checkedMove++)
{ {
for (i = 0; sDiscouragedPowerfulMoveEffects[i] != 0xFFFF; i++) for (i = 0; sDiscouragedPowerfulMoveEffects[i] != INVALID_U16; i++)
{ {
if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i]) if (gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].effect == sDiscouragedPowerfulMoveEffects[i])
break; break;
} }
if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE
&& sDiscouragedPowerfulMoveEffects[i] == 0xFFFF && sDiscouragedPowerfulMoveEffects[i] == INVALID_U16
&& gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1) && gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1)
{ {
gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove]; gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove];

View File

@ -126,7 +126,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
return FALSE; return FALSE;
if (gLastLandedMoves[gActiveBattler] == 0) if (gLastLandedMoves[gActiveBattler] == 0)
return FALSE; return FALSE;
if (gLastLandedMoves[gActiveBattler] == 0xFFFF) if (gLastLandedMoves[gActiveBattler] == INVALID_U16)
return FALSE; return FALSE;
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0) if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
return FALSE; return FALSE;
@ -221,7 +221,7 @@ static bool8 ShouldSwitchIfNaturalCure(void)
if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2) if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2)
return FALSE; return FALSE;
if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == 0xFFFF) && Random() & 1) if ((gLastLandedMoves[gActiveBattler] == 0 || gLastLandedMoves[gActiveBattler] == INVALID_U16) && Random() & 1)
{ {
*(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE; *(gBattleStruct->AI_monToSwitchIntoId + gActiveBattler) = PARTY_SIZE;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0); BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
@ -331,9 +331,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
if (gLastLandedMoves[gActiveBattler] == 0) if (gLastLandedMoves[gActiveBattler] == 0)
return FALSE; return FALSE;
if (gLastLandedMoves[gActiveBattler] == 0xFFFF) if (gLastLandedMoves[gActiveBattler] == INVALID_U16)
return FALSE; return FALSE;
if (gLastHitBy[gActiveBattler] == 0xFF) if (gLastHitBy[gActiveBattler] == INVALID_U8)
return FALSE; return FALSE;
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0) if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
return FALSE; return FALSE;

View File

@ -1452,14 +1452,14 @@ void ClearBattleAnimationVars(void)
// Clear index array. // Clear index array.
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
sAnimSpriteIndexArray[i] |= 0xFFFF; sAnimSpriteIndexArray[i] |= INVALID_U16;
// Clear anim args. // Clear anim args.
for (i = 0; i < ANIM_ARGS_COUNT; i++) for (i = 0; i < ANIM_ARGS_COUNT; i++)
gBattleAnimArgs[i] = 0; gBattleAnimArgs[i] = 0;
sMonAnimTaskIdArray[0] = 0xFF; sMonAnimTaskIdArray[0] = INVALID_U8;
sMonAnimTaskIdArray[1] = 0xFF; sMonAnimTaskIdArray[1] = INVALID_U8;
gAnimMoveTurn = 0; gAnimMoveTurn = 0;
sAnimBackgroundFadeState = 0; sAnimBackgroundFadeState = 0;
sAnimMoveIndex = 0; sAnimMoveIndex = 0;
@ -1505,19 +1505,19 @@ void LaunchBattleAnimation(const u8 *const animsTable[], u16 tableId, bool8 isMo
for (i = 0; i < ANIM_ARGS_COUNT; i++) for (i = 0; i < ANIM_ARGS_COUNT; i++)
gBattleAnimArgs[i] = 0; gBattleAnimArgs[i] = 0;
sMonAnimTaskIdArray[0] = 0xFF; sMonAnimTaskIdArray[0] = INVALID_U8;
sMonAnimTaskIdArray[1] = 0xFF; sMonAnimTaskIdArray[1] = INVALID_U8;
sBattleAnimScriptPtr = animsTable[tableId]; sBattleAnimScriptPtr = animsTable[tableId];
gAnimScriptActive = TRUE; gAnimScriptActive = TRUE;
gAnimFramesToWait = 0; gAnimFramesToWait = 0;
gAnimScriptCallback = RunAnimScriptCommand; gAnimScriptCallback = RunAnimScriptCommand;
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
sAnimSpriteIndexArray[i] |= 0xFFFF; sAnimSpriteIndexArray[i] |= INVALID_U16;
if (isMoveAnim) if (isMoveAnim)
{ {
for (i = 0; gMovesWithQuietBGM[i] != 0xFFFF; i++) for (i = 0; gMovesWithQuietBGM[i] != INVALID_U16; i++)
{ {
if (tableId == gMovesWithQuietBGM[i]) if (tableId == gMovesWithQuietBGM[i])
{ {
@ -1558,7 +1558,7 @@ static void AddSpriteIndex(u16 index)
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
{ {
if (sAnimSpriteIndexArray[i] == 0xFFFF) if (sAnimSpriteIndexArray[i] == INVALID_U16)
{ {
sAnimSpriteIndexArray[i] = index; sAnimSpriteIndexArray[i] = index;
return; return;
@ -1574,7 +1574,7 @@ static void ClearSpriteIndex(u16 index)
{ {
if (sAnimSpriteIndexArray[i] == index) if (sAnimSpriteIndexArray[i] == index)
{ {
sAnimSpriteIndexArray[i] |= 0xFFFF; sAnimSpriteIndexArray[i] |= INVALID_U16;
return; return;
} }
} }
@ -1712,7 +1712,7 @@ static void ScriptCmd_delay(void)
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimFramesToWait = sBattleAnimScriptPtr[0]; gAnimFramesToWait = sBattleAnimScriptPtr[0];
if (gAnimFramesToWait == 0) if (gAnimFramesToWait == 0)
gAnimFramesToWait = -1; gAnimFramesToWait = INVALID_S8;
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
gAnimScriptCallback = WaitAnimFrameCount; gAnimScriptCallback = WaitAnimFrameCount;
} }
@ -1746,7 +1746,7 @@ static void ScriptCmd_end(void)
// Keep waiting as long as there are animations to be done. // Keep waiting as long as there are animations to be done.
if (gAnimVisualTaskCount != 0 || gAnimSoundTaskCount != 0 if (gAnimVisualTaskCount != 0 || gAnimSoundTaskCount != 0
|| sMonAnimTaskIdArray[0] != 0xFF || sMonAnimTaskIdArray[1] != 0xFF) || sMonAnimTaskIdArray[0] != INVALID_U8 || sMonAnimTaskIdArray[1] != INVALID_U8)
{ {
sSoundAnimFramesToWait = 0; sSoundAnimFramesToWait = 0;
gAnimFramesToWait = 1; gAnimFramesToWait = 1;
@ -1773,11 +1773,11 @@ static void ScriptCmd_end(void)
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++) for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
{ {
if (sAnimSpriteIndexArray[i] != 0xFFFF) if (sAnimSpriteIndexArray[i] != INVALID_U16)
{ {
FreeSpriteTilesByTag(gBattleAnimPicTable[sAnimSpriteIndexArray[i]].tag); FreeSpriteTilesByTag(gBattleAnimPicTable[sAnimSpriteIndexArray[i]].tag);
FreeSpritePaletteByTag(gBattleAnimPicTable[sAnimSpriteIndexArray[i]].tag); FreeSpritePaletteByTag(gBattleAnimPicTable[sAnimSpriteIndexArray[i]].tag);
sAnimSpriteIndexArray[i] |= 0xFFFF; // set terminator. sAnimSpriteIndexArray[i] |= INVALID_U16; // set terminator.
} }
} }
@ -2122,9 +2122,9 @@ static void ScriptCmd_clearmonbg(void)
else else
battlerId = gBattleAnimTarget; battlerId = gBattleAnimTarget;
if (sMonAnimTaskIdArray[0] != 0xFF) if (sMonAnimTaskIdArray[0] != INVALID_U8)
gSprites[gBattlerSpriteIds[battlerId]].invisible = FALSE; gSprites[gBattlerSpriteIds[battlerId]].invisible = FALSE;
if (animBattlerId > 1 && sMonAnimTaskIdArray[1] != 0xFF) if (animBattlerId > 1 && sMonAnimTaskIdArray[1] != INVALID_U8)
gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = FALSE; gSprites[gBattlerSpriteIds[battlerId ^ BIT_FLANK]].invisible = FALSE;
else else
animBattlerId = 0; animBattlerId = 0;
@ -2148,17 +2148,17 @@ static void sub_80A4980(u8 taskId)
else else
to_BG2 = TRUE; to_BG2 = TRUE;
if (sMonAnimTaskIdArray[0] != 0xFF) if (sMonAnimTaskIdArray[0] != INVALID_U8)
{ {
sub_80A477C(to_BG2); sub_80A477C(to_BG2);
DestroyTask(sMonAnimTaskIdArray[0]); DestroyTask(sMonAnimTaskIdArray[0]);
sMonAnimTaskIdArray[0] = 0xFF; sMonAnimTaskIdArray[0] = INVALID_U8;
} }
if (gTasks[taskId].data[0] > 1) if (gTasks[taskId].data[0] > 1)
{ {
sub_80A477C(to_BG2 ^ 1); sub_80A477C(to_BG2 ^ 1);
DestroyTask(sMonAnimTaskIdArray[1]); DestroyTask(sMonAnimTaskIdArray[1]);
sMonAnimTaskIdArray[1] = 0xFF; sMonAnimTaskIdArray[1] = INVALID_U8;
} }
DestroyTask(taskId); DestroyTask(taskId);
} }
@ -2421,7 +2421,7 @@ static void Task_FadeToBg(u8 taskId)
{ {
s16 bgId = gTasks[taskId].tBackgroundId; s16 bgId = gTasks[taskId].tBackgroundId;
if (bgId == -1) if (bgId == INVALID_S16)
LoadDefaultBg(); LoadDefaultBg();
else else
LoadMoveBg(bgId); LoadMoveBg(bgId);
@ -2477,7 +2477,7 @@ static void ScriptCmd_restorebg(void)
sBattleAnimScriptPtr++; sBattleAnimScriptPtr++;
taskId = CreateTask(Task_FadeToBg, 5); taskId = CreateTask(Task_FadeToBg, 5);
gTasks[taskId].tBackgroundId = -1; gTasks[taskId].tBackgroundId = INVALID_S16;
sAnimBackgroundFadeState = 1; sAnimBackgroundFadeState = 1;
} }
@ -3001,7 +3001,7 @@ static void ScriptCmd_invisible(void)
u8 spriteId; u8 spriteId;
spriteId = GetAnimBattlerSpriteId(sBattleAnimScriptPtr[1]); spriteId = GetAnimBattlerSpriteId(sBattleAnimScriptPtr[1]);
if (spriteId != 0xFF) if (spriteId != INVALID_U8)
gSprites[spriteId].invisible = TRUE; gSprites[spriteId].invisible = TRUE;
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
@ -3012,7 +3012,7 @@ static void ScriptCmd_visible(void)
u8 spriteId; u8 spriteId;
spriteId = GetAnimBattlerSpriteId(sBattleAnimScriptPtr[1]); spriteId = GetAnimBattlerSpriteId(sBattleAnimScriptPtr[1]);
if (spriteId != 0xFF) if (spriteId != INVALID_U8)
gSprites[spriteId].invisible = FALSE; gSprites[spriteId].invisible = FALSE;
sBattleAnimScriptPtr += 2; sBattleAnimScriptPtr += 2;
@ -3039,7 +3039,7 @@ static void ScriptCmd_doublebattle_2D(void)
r4 = sub_80A8364(gBattleAnimTarget); r4 = sub_80A8364(gBattleAnimTarget);
spriteId = GetAnimBattlerSpriteId(ANIM_TARGET); spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
} }
if (spriteId != 0xFF) if (spriteId != INVALID_U8)
{ {
gSprites[spriteId].invisible = FALSE; gSprites[spriteId].invisible = FALSE;
if (r4 == 2) if (r4 == 2)
@ -3075,7 +3075,7 @@ static void ScriptCmd_doublebattle_2E(void)
spriteId = GetAnimBattlerSpriteId(ANIM_TARGET); spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
} }
if (spriteId != 0xFF && r4 == 2) if (spriteId != INVALID_U8 && r4 == 2)
gSprites[spriteId].oam.priority = 2; gSprites[spriteId].oam.priority = 2;
} }
} }

View File

@ -7,7 +7,7 @@
#include "decompress.h" #include "decompress.h"
#include "dma3.h" #include "dma3.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "malloc.h" #include "alloc.h"
#include "palette.h" #include "palette.h"
#include "pokemon_icon.h" #include "pokemon_icon.h"
#include "sprite.h" #include "sprite.h"
@ -1590,7 +1590,7 @@ s16 duplicate_obj_of_side_rel2move_in_transparent_mode(u8 whichBattler)
} }
} }
} }
return -1; return INVALID_S16;
} }
void obj_delete_but_dont_free_vram(struct Sprite *sprite) void obj_delete_but_dont_free_vram(struct Sprite *sprite)

View File

@ -183,7 +183,7 @@ void sub_80A9EF4(u8 taskId)
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
spriteId = CreateSprite(&gUnknown_0853EF48, x, y, 4); spriteId = CreateSprite(&gUnknown_0853EF48, x, y, 4);
if (GetSpriteTileStartByTag(ANIM_TAG_ICE_CUBE) == 0xFFFF) if (GetSpriteTileStartByTag(ANIM_TAG_ICE_CUBE) == INVALID_U16)
gSprites[spriteId].invisible = TRUE; gSprites[spriteId].invisible = TRUE;
SetSubspriteTables(&gSprites[spriteId], gUnknown_0853EF40); SetSubspriteTables(&gSprites[spriteId], gUnknown_0853EF40);
gTasks[taskId].data[15] = spriteId; gTasks[taskId].data[15] = spriteId;
@ -315,10 +315,10 @@ void AnimTask_StatsChange(u8 taskId)
CASE(MINUS2, STAT_ACC): goesDown = TRUE; animStatId = 2; sharply = TRUE; break; CASE(MINUS2, STAT_ACC): goesDown = TRUE; animStatId = 2; sharply = TRUE; break;
CASE(MINUS2, STAT_EVASION): goesDown = TRUE; animStatId = 4; sharply = TRUE; break; CASE(MINUS2, STAT_EVASION): goesDown = TRUE; animStatId = 4; sharply = TRUE; break;
case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = 0xFF; sharply = FALSE; break; case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = INVALID_U8; sharply = FALSE; break;
case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = 0xFF; sharply = TRUE; break; case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = INVALID_U8; sharply = TRUE; break;
case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = 0xFF; sharply = FALSE; break; case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = INVALID_U8; sharply = FALSE; break;
case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = 0xFF; sharply = TRUE; break; case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = INVALID_U8; sharply = TRUE; break;
default: default:
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);

View File

@ -214,7 +214,7 @@ void sub_8158E9C(u8 taskId)
if (species != SPECIES_NONE) if (species != SPECIES_NONE)
{ {
if (gBattleAnimArgs[1] == 0xFF) if (gBattleAnimArgs[1] == INVALID_U8)
PlayCry3(species, pan, 9); PlayCry3(species, pan, 9);
else else
PlayCry3(species, pan, 7); PlayCry3(species, pan, 7);
@ -238,7 +238,7 @@ static void sub_8158FF4(u8 taskId)
} }
else else
{ {
if (gTasks[taskId].data[0] == 0xFF) if (gTasks[taskId].data[0] == INVALID_U8)
{ {
if (!IsCryPlaying()) if (!IsCryPlaying())
{ {

View File

@ -3,7 +3,7 @@
#include "contest.h" #include "contest.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "graphics.h" #include "graphics.h"
#include "malloc.h" #include "alloc.h"
#include "palette.h" #include "palette.h"
#include "sound.h" #include "sound.h"
#include "sprite.h" #include "sprite.h"
@ -82,7 +82,7 @@ void sub_8116664(u8 taskId)
animBattlers[1] = gBattleAnimTarget; animBattlers[1] = gBattleAnimTarget;
break; break;
case 5: case 5:
animBattlers[0] = 0xFF; animBattlers[0] = INVALID_U8;
break; break;
case 6: case 6:
selectedPalettes = 0; selectedPalettes = 0;

View File

@ -449,7 +449,7 @@ static const union AnimCmd *const sSpriteAnimTable_8611F4C[] =
static const struct SpriteTemplate sSpriteTemplate_JudgmentIcon = static const struct SpriteTemplate sSpriteTemplate_JudgmentIcon =
{ {
.tileTag = 0x3E8, .tileTag = 0x3E8,
.paletteTag = 0xFFFF, .paletteTag = INVALID_U16,
.oam = &sOamData_8611F24, .oam = &sOamData_8611F24,
.anims = sSpriteAnimTable_8611F4C, .anims = sSpriteAnimTable_8611F4C,
.images = NULL, .images = NULL,

View File

@ -212,7 +212,7 @@ static void sub_8064470(void)
static void sub_80644D8(void) static void sub_80644D8(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == INVALID_U8)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
LinkOpponentBufferExecCompleted(); LinkOpponentBufferExecCompleted();
@ -395,7 +395,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != INVALID_S16)
{ {
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }

View File

@ -203,7 +203,7 @@ static void sub_814AF54(void)
static void sub_814AFBC(void) static void sub_814AFBC(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == INVALID_U8)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
LinkPartnerBufferExecCompleted(); LinkPartnerBufferExecCompleted();
@ -279,7 +279,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != INVALID_S16)
{ {
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }

View File

@ -220,7 +220,7 @@ static void sub_805F240(void)
static void sub_805F2A8(void) static void sub_805F2A8(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == INVALID_U8)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
OpponentBufferExecCompleted(); OpponentBufferExecCompleted();
@ -389,7 +389,7 @@ static void CompleteOnHealthbarDone(void)
{ {
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0); s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != INVALID_S16)
{ {
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }

View File

@ -635,7 +635,7 @@ u32 sub_8057FBC(void) // unused
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
gBattle_BG0_X = 0; gBattle_BG0_X = 0;
gBattle_BG0_Y = 0x140; gBattle_BG0_Y = 0x140;
var = 0xFF; var = INVALID_U8;
} }
if (gMain.newKeys & DPAD_LEFT && gMoveSelectionCursor[gActiveBattler] & 1) if (gMain.newKeys & DPAD_LEFT && gMoveSelectionCursor[gActiveBattler] & 1)
{ {
@ -936,7 +936,7 @@ static void sub_80588B4(void)
static void sub_8058924(void) static void sub_8058924(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == INVALID_U8)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
PlayerBufferExecCompleted(); PlayerBufferExecCompleted();
@ -1119,7 +1119,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != INVALID_S16)
{ {
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
@ -1221,7 +1221,7 @@ static void sub_8059400(u8 taskId)
newExpPoints = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0); newExpPoints = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
if (newExpPoints == -1) // The bar has been filled with given exp points. if (newExpPoints == INVALID_S16) // The bar has been filled with given exp points.
{ {
u8 level; u8 level;
s32 currExp; s32 currExp;

View File

@ -218,7 +218,7 @@ static void sub_81BAE98(void)
static void sub_81BAF00(void) static void sub_81BAF00(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == INVALID_U8)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
PlayerPartnerBufferExecCompleted(); PlayerPartnerBufferExecCompleted();
@ -294,7 +294,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != INVALID_S16)
{ {
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }
@ -397,7 +397,7 @@ static void sub_81BB4E4(u8 taskId)
r4 = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0); r4 = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
if (r4 == -1) if (r4 == INVALID_S16)
{ {
u8 level; u8 level;
s32 currExp; s32 currExp;

View File

@ -213,7 +213,7 @@ static void sub_81865C8(void)
static void sub_8186630(void) static void sub_8186630(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == INVALID_U8)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
RecordedOpponentBufferExecCompleted(); RecordedOpponentBufferExecCompleted();
@ -377,7 +377,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != INVALID_S16)
{ {
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }

View File

@ -202,7 +202,7 @@ static void sub_81899F0(void)
static void sub_8189A58(void) static void sub_8189A58(void)
{ {
if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == 0xFF) if (--gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 == INVALID_U8)
{ {
gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0; gBattleSpritesDataPtr->healthBoxesData[gActiveBattler].field_9 = 0;
RecordedPlayerBufferExecCompleted(); RecordedPlayerBufferExecCompleted();
@ -360,7 +360,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != INVALID_S16)
{ {
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }

View File

@ -348,7 +348,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]); SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
if (hpValue != -1) if (hpValue != INVALID_S16)
{ {
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT); UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
} }

View File

@ -51,7 +51,7 @@ void SetUpBattleVarsAndBirchZigzagoon(void)
for (i = 0; i < MAX_BATTLERS_COUNT; i++) for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{ {
gBattlerControllerFuncs[i] = nullsub_21; gBattlerControllerFuncs[i] = nullsub_21;
gBattlerPositions[i] = 0xFF; gBattlerPositions[i] = INVALID_U8;
gActionSelectionCursor[i] = 0; gActionSelectionCursor[i] = 0;
gMoveSelectionCursor[i] = 0; gMoveSelectionCursor[i] = 0;
} }

View File

@ -8,7 +8,7 @@
#include "event_data.h" #include "event_data.h"
#include "overworld.h" #include "overworld.h"
#include "util.h" #include "util.h"
#include "malloc.h" #include "alloc.h"
#include "string_util.h" #include "string_util.h"
#include "random.h" #include "random.h"
#include "task.h" #include "task.h"
@ -3032,7 +3032,7 @@ static s32 GetTypeEffectivenessPoints(s32 move, s32 targetSpecies, s32 arg2)
s32 i = 0; s32 i = 0;
s32 typePower = TYPE_x1; s32 typePower = TYPE_x1;
if (move == MOVE_NONE || move == 0xFFFF || gBattleMoves[move].power == 0) if (move == MOVE_NONE || move == INVALID_U16 || gBattleMoves[move].power == 0)
return 0; return 0;
defType1 = gBaseStats[targetSpecies].type1; defType1 = gBaseStats[targetSpecies].type1;
@ -3434,14 +3434,14 @@ static s32 TournamentIdOfOpponent(s32 roundId, s32 trainerId)
if (j != val) if (j != val)
return gUnknown_0860D14C[j]; return gUnknown_0860D14C[j];
else else
return 0xFF; return INVALID_U8;
} }
else else
{ {
if (!gSaveBlock2Ptr->frontier.domeTrainers[sIdToOpponentId[i][roundId]].isEliminated) if (!gSaveBlock2Ptr->frontier.domeTrainers[sIdToOpponentId[i][roundId]].isEliminated)
return sIdToOpponentId[i][roundId]; return sIdToOpponentId[i][roundId];
else else
return 0xFF; return INVALID_U8;
} }
} }
@ -3562,7 +3562,7 @@ static void sub_8190400(u8 taskId)
SetVBlankCallback(VblankCb0_BattleDome); SetVBlankCallback(VblankCb0_BattleDome);
sBattleDomeStruct = AllocZeroed(sizeof(*sBattleDomeStruct)); sBattleDomeStruct = AllocZeroed(sizeof(*sBattleDomeStruct));
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++) for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
sBattleDomeStruct->arr[i] |= 0xFF; sBattleDomeStruct->arr[i] |= INVALID_U8;
LoadMonIconPalettes(); LoadMonIconPalettes();
i = CreateTask(sub_8190CD4, 0); i = CreateTask(sub_8190CD4, 0);
gTasks[i].data[0] = 0; gTasks[i].data[0] = 0;
@ -3624,7 +3624,7 @@ static void SpriteCb_TrainerIconCardScrollUp(struct Sprite *sprite)
{ {
if (sprite->pos1.y >= 192) if (sprite->pos1.y >= 192)
{ {
sBattleDomeStruct->arr[sprite->data[2]] = 0xFF; sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
FreeAndDestroyTrainerPicSprite(sprite->data[3]); FreeAndDestroyTrainerPicSprite(sprite->data[3]);
} }
} }
@ -3644,7 +3644,7 @@ static void SpriteCb_TrainerIconCardScrollDown(struct Sprite *sprite)
{ {
if (sprite->pos1.y <= -32) if (sprite->pos1.y <= -32)
{ {
sBattleDomeStruct->arr[sprite->data[2]] = 0xFF; sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
FreeAndDestroyTrainerPicSprite(sprite->data[3]); FreeAndDestroyTrainerPicSprite(sprite->data[3]);
} }
} }
@ -3664,7 +3664,7 @@ static void SpriteCb_TrainerIconCardScrollLeft(struct Sprite *sprite)
{ {
if (sprite->pos1.x >= 272) if (sprite->pos1.x >= 272)
{ {
sBattleDomeStruct->arr[sprite->data[2]] = 0xFF; sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
FreeAndDestroyTrainerPicSprite(sprite->data[3]); FreeAndDestroyTrainerPicSprite(sprite->data[3]);
} }
} }
@ -3684,7 +3684,7 @@ static void SpriteCb_TrainerIconCardScrollRight(struct Sprite *sprite)
{ {
if (sprite->pos1.x <= -32) if (sprite->pos1.x <= -32)
{ {
sBattleDomeStruct->arr[sprite->data[2]] = 0xFF; sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
FreeAndDestroyTrainerPicSprite(sprite->data[3]); FreeAndDestroyTrainerPicSprite(sprite->data[3]);
} }
} }
@ -3714,7 +3714,7 @@ static void SpriteCb_MonIconCardScrollUp(struct Sprite *sprite)
{ {
if (sprite->pos1.y >= 176) if (sprite->pos1.y >= 176)
{ {
sBattleDomeStruct->arr[sprite->data[2]] = 0xFF; sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
sub_80D2EF8(sprite); sub_80D2EF8(sprite);
} }
} }
@ -3736,7 +3736,7 @@ static void SpriteCb_MonIconCardScrollDown(struct Sprite *sprite)
{ {
if (sprite->pos1.y <= -16) if (sprite->pos1.y <= -16)
{ {
sBattleDomeStruct->arr[sprite->data[2]] = 0xFF; sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
sub_80D2EF8(sprite); sub_80D2EF8(sprite);
} }
} }
@ -3758,7 +3758,7 @@ static void SpriteCb_MonIconCardScrollLeft(struct Sprite *sprite)
{ {
if (sprite->pos1.x >= 256) if (sprite->pos1.x >= 256)
{ {
sBattleDomeStruct->arr[sprite->data[2]] = 0xFF; sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
sub_80D2EF8(sprite); sub_80D2EF8(sprite);
} }
} }
@ -3780,7 +3780,7 @@ static void SpriteCb_MonIconCardScrollRight(struct Sprite *sprite)
{ {
if (sprite->pos1.x <= -16) if (sprite->pos1.x <= -16)
{ {
sBattleDomeStruct->arr[sprite->data[2]] = 0xFF; sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
sub_80D2EF8(sprite); sub_80D2EF8(sprite);
} }
} }
@ -4005,7 +4005,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 2) if (i < 2)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4016,7 +4016,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollUp; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollUp;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4029,7 +4029,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 10) if (i < 10)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4040,7 +4040,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollUp; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollUp;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4121,7 +4121,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 2) if (i < 2)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4132,7 +4132,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollDown; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollDown;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4145,7 +4145,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 10) if (i < 10)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4156,7 +4156,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollDown; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollDown;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4204,7 +4204,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 2) if (i < 2)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4215,7 +4215,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4228,7 +4228,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 10) if (i < 10)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4239,7 +4239,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4287,7 +4287,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 2) if (i < 2)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4298,7 +4298,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4311,7 +4311,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 10) if (i < 10)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4322,7 +4322,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4368,7 +4368,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 2) if (i < 2)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4379,7 +4379,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4392,7 +4392,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 10) if (i < 10)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4403,7 +4403,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4451,7 +4451,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 2) if (i < 2)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4462,7 +4462,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2] ^ 1;
@ -4475,7 +4475,7 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 10) if (i < 10)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4486,7 +4486,7 @@ static void sub_8190CD4(u8 taskId)
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
{ {
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight; gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2]; gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@ -4556,12 +4556,12 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 2) if (i < 2)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
FreeAndDestroyTrainerPicSprite(sBattleDomeStruct->arr[i]); FreeAndDestroyTrainerPicSprite(sBattleDomeStruct->arr[i]);
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
sub_80D2EF8(&gSprites[sBattleDomeStruct->arr[i]]); sub_80D2EF8(&gSprites[sBattleDomeStruct->arr[i]]);
} }
} }
@ -4569,12 +4569,12 @@ static void sub_8190CD4(u8 taskId)
{ {
if (i < 10) if (i < 10)
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
FreeAndDestroyTrainerPicSprite(sBattleDomeStruct->arr[i]); FreeAndDestroyTrainerPicSprite(sBattleDomeStruct->arr[i]);
} }
else else
{ {
if (sBattleDomeStruct->arr[i] != 0xFF) if (sBattleDomeStruct->arr[i] != INVALID_U8)
sub_80D2EF8(&gSprites[sBattleDomeStruct->arr[i]]); sub_80D2EF8(&gSprites[sBattleDomeStruct->arr[i]]);
} }
} }
@ -5483,13 +5483,13 @@ static u8 sub_8193BDC(u8 taskId)
} }
else else
{ {
if (gMain.newKeys == DPAD_UP && gUnknown_0860CBF1[spriteId][roundId][0] != 0xFF) if (gMain.newKeys == DPAD_UP && gUnknown_0860CBF1[spriteId][roundId][0] != INVALID_U8)
arrId = 0; arrId = 0;
else if (gMain.newKeys == DPAD_DOWN && gUnknown_0860CBF1[spriteId][roundId][1] != 0xFF) else if (gMain.newKeys == DPAD_DOWN && gUnknown_0860CBF1[spriteId][roundId][1] != INVALID_U8)
arrId = 1; arrId = 1;
else if (gMain.newKeys == DPAD_LEFT && gUnknown_0860CBF1[spriteId][roundId][2] != 0xFF) else if (gMain.newKeys == DPAD_LEFT && gUnknown_0860CBF1[spriteId][roundId][2] != INVALID_U8)
arrId = 2; arrId = 2;
else if (gMain.newKeys == DPAD_RIGHT && gUnknown_0860CBF1[spriteId][roundId][3] != 0xFF) else if (gMain.newKeys == DPAD_RIGHT && gUnknown_0860CBF1[spriteId][roundId][3] != INVALID_U8)
arrId = 3; arrId = 3;
} }
@ -6314,21 +6314,21 @@ static void DecideRoundWinners(u8 roundId)
tournamentId1 = i; tournamentId1 = i;
tournamentId2 = TournamentIdOfOpponent(roundId, gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].trainerId); tournamentId2 = TournamentIdOfOpponent(roundId, gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].trainerId);
// Frontier Brain always wins, check tournamentId1. // Frontier Brain always wins, check tournamentId1.
if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].trainerId == TRAINER_FRONTIER_BRAIN && tournamentId2 != 0xFF) if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].trainerId == TRAINER_FRONTIER_BRAIN && tournamentId2 != INVALID_U8)
{ {
gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].isEliminated = 1; gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].isEliminated = 1;
gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].eliminatedAt = roundId; gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].eliminatedAt = roundId;
gSaveBlock2Ptr->frontier.field_EC0[tournamentId2] = GetWinningMove(tournamentId1, tournamentId2, roundId); gSaveBlock2Ptr->frontier.field_EC0[tournamentId2] = GetWinningMove(tournamentId1, tournamentId2, roundId);
} }
// Frontier Brain always wins, check tournamentId2. // Frontier Brain always wins, check tournamentId2.
else if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].trainerId == TRAINER_FRONTIER_BRAIN && tournamentId1 != 0xFF) else if (gSaveBlock2Ptr->frontier.domeTrainers[tournamentId2].trainerId == TRAINER_FRONTIER_BRAIN && tournamentId1 != INVALID_U8)
{ {
gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].isEliminated = 1; gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].isEliminated = 1;
gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].eliminatedAt = roundId; gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].eliminatedAt = roundId;
gSaveBlock2Ptr->frontier.field_EC0[tournamentId1] = GetWinningMove(tournamentId2, tournamentId1, roundId); gSaveBlock2Ptr->frontier.field_EC0[tournamentId1] = GetWinningMove(tournamentId2, tournamentId1, roundId);
} }
// Decide which one of two trainers wins! // Decide which one of two trainers wins!
else if (tournamentId2 != 0xFF) else if (tournamentId2 != INVALID_U8)
{ {
// BUG: points1 and points2 are not cleared at the beginning of the loop resulting in not fair results. // BUG: points1 and points2 are not cleared at the beginning of the loop resulting in not fair results.

View File

@ -202,9 +202,9 @@ static void sub_81A5E94(void)
gUnknown_03001288 = FALSE; gUnknown_03001288 = FALSE;
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
gSaveBlock2Ptr->frontier.field_E70[i].monId |= 0xFFFF; gSaveBlock2Ptr->frontier.field_E70[i].monId |= INVALID_U16;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
gUnknown_03006298[i] |= 0xFFFF; gUnknown_03006298[i] |= INVALID_U16;
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1); saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
gTrainerBattleOpponent_A = 0; gTrainerBattleOpponent_A = 0;

View File

@ -10,7 +10,7 @@
#include "palette.h" #include "palette.h"
#include "task.h" #include "task.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "bg.h" #include "bg.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "string_util.h" #include "string_util.h"

View File

@ -6,7 +6,7 @@
#include "constants/battle_anim.h" #include "constants/battle_anim.h"
#include "battle_interface.h" #include "battle_interface.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "graphics.h" #include "graphics.h"
#include "random.h" #include "random.h"
#include "util.h" #include "util.h"
@ -122,7 +122,7 @@ void FreeBattleSpritesData(void)
u16 ChooseMoveAndTargetInBattlePalace(void) u16 ChooseMoveAndTargetInBattlePalace(void)
{ {
s32 i, var1, var2; s32 i, var1, var2;
s32 chosenMoveId = -1; s32 chosenMoveId = INVALID_S32;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, 0xFF); u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, 0xFF);
s32 percent = Random() % 100; s32 percent = Random() % 100;

View File

@ -589,17 +589,17 @@ static void sub_8072308(s16 arg0, u16 *arg1, u8 arg2)
for (; i > -1; i--) for (; i > -1; i--)
{ {
array[i] = 0xFF; array[i] = INVALID_U8;
} }
if (arrayPtr[3] == 0xFF) if (arrayPtr[3] == INVALID_U8)
arrayPtr[3] = 0; arrayPtr[3] = 0;
if (arg2 == 0) if (arg2 == 0)
{ {
for (i = 0, j = 0; i < 4; i++) for (i = 0, j = 0; i < 4; i++)
{ {
if (array[j] == 0xFF) if (array[j] == INVALID_U8)
{ {
arg1[j] &= 0xFC00; arg1[j] &= 0xFC00;
arg1[j] |= 0x1E; arg1[j] |= 0x1E;
@ -622,7 +622,7 @@ static void sub_8072308(s16 arg0, u16 *arg1, u8 arg2)
{ {
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
if (array[i] == 0xFF) if (array[i] == INVALID_U8)
{ {
arg1[i] &= 0xFC00; arg1[i] &= 0xFC00;
arg1[i] |= 0x1E; arg1[i] |= 0x1E;
@ -1580,7 +1580,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{ {
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (partyInfo[i].hp == 0xFFFF) // empty slot or an egg if (partyInfo[i].hp == INVALID_U16) // empty slot or an egg
{ {
gSprites[ballIconSpritesIds[i]].oam.tileNum += 1; gSprites[ballIconSpritesIds[i]].oam.tileNum += 1;
gSprites[ballIconSpritesIds[i]].data[7] = 1; gSprites[ballIconSpritesIds[i]].data[7] = 1;
@ -1599,7 +1599,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{ {
for (i = 0, var = 5, j = 0; j < PARTY_SIZE; j++) for (i = 0, var = 5, j = 0; j < PARTY_SIZE; j++)
{ {
if (partyInfo[j].hp == 0xFFFF) // empty slot or an egg if (partyInfo[j].hp == INVALID_U16) // empty slot or an egg
{ {
gSprites[ballIconSpritesIds[var]].oam.tileNum += 1; gSprites[ballIconSpritesIds[var]].oam.tileNum += 1;
gSprites[ballIconSpritesIds[var]].data[7] = 1; gSprites[ballIconSpritesIds[var]].data[7] = 1;
@ -1628,7 +1628,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{ {
for (var = 5, i = 0; i < PARTY_SIZE; i++) for (var = 5, i = 0; i < PARTY_SIZE; i++)
{ {
if (partyInfo[i].hp == 0xFFFF) // empty slot or an egg if (partyInfo[i].hp == INVALID_U16) // empty slot or an egg
{ {
gSprites[ballIconSpritesIds[var]].oam.tileNum += 1; gSprites[ballIconSpritesIds[var]].oam.tileNum += 1;
gSprites[ballIconSpritesIds[var]].data[7] = 1; gSprites[ballIconSpritesIds[var]].data[7] = 1;
@ -1648,7 +1648,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{ {
for (var = 0, i = 0, j = 0; j < PARTY_SIZE; j++) for (var = 0, i = 0, j = 0; j < PARTY_SIZE; j++)
{ {
if (partyInfo[j].hp == 0xFFFF) // empty slot or an egg if (partyInfo[j].hp == INVALID_U16) // empty slot or an egg
{ {
gSprites[ballIconSpritesIds[i]].oam.tileNum += 1; gSprites[ballIconSpritesIds[i]].oam.tileNum += 1;
gSprites[ballIconSpritesIds[i]].data[7] = 1; gSprites[ballIconSpritesIds[i]].data[7] = 1;
@ -1765,7 +1765,7 @@ static void sub_8073E64(u8 taskId)
s32 i; s32 i;
u8 battlerId = gTasks[taskId].tBattler; u8 battlerId = gTasks[taskId].tBattler;
if (--gTasks[taskId].tData15 == -1) if (--gTasks[taskId].tData15 == INVALID_S16)
{ {
u8 summaryBarSpriteId = gTasks[taskId].tSummaryBarSpriteId; u8 summaryBarSpriteId = gTasks[taskId].tSummaryBarSpriteId;
@ -1808,7 +1808,7 @@ static void sub_8073F98(u8 taskId)
{ {
SetGpuReg(REG_OFFSET_BLDALPHA, (gTasks[taskId].tData15) | ((16 - gTasks[taskId].tData15) << 8)); SetGpuReg(REG_OFFSET_BLDALPHA, (gTasks[taskId].tData15) | ((16 - gTasks[taskId].tData15) << 8));
} }
else if (gTasks[taskId].tData15 == -1) else if (gTasks[taskId].tData15 == INVALID_S16)
{ {
u8 summaryBarSpriteId = gTasks[taskId].tSummaryBarSpriteId; u8 summaryBarSpriteId = gTasks[taskId].tSummaryBarSpriteId;
@ -2289,7 +2289,7 @@ s32 MoveBattleBar(u8 battlerId, u8 healthboxSpriteId, u8 whichBar, u8 unused)
if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars)) if (whichBar == EXP_BAR || (whichBar == HEALTH_BAR && !gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars))
MoveBattleBarGraphically(battlerId, whichBar); MoveBattleBarGraphically(battlerId, whichBar);
if (currentBarValue == -1) if (currentBarValue == INVALID_S32)
gBattleSpritesDataPtr->battleBars[battlerId].currValue = 0; gBattleSpritesDataPtr->battleBars[battlerId].currValue = 0;
return currentBarValue; return currentBarValue;
@ -2376,12 +2376,12 @@ static s32 CalcNewBarValue(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *c
if (maxValue < scale) if (maxValue < scale)
{ {
if (newValue == Q_24_8_TO_INT(*currValue) && (*currValue & 0xFF) == 0) if (newValue == Q_24_8_TO_INT(*currValue) && (*currValue & 0xFF) == 0)
return -1; return INVALID_S32;
} }
else else
{ {
if (newValue == *currValue) // we're done, the bar's value has been updated if (newValue == *currValue) // we're done, the bar's value has been updated
return -1; return INVALID_S32;
} }
if (maxValue < scale) // handle cases of max var having less pixels than the whole bar if (maxValue < scale) // handle cases of max var having less pixels than the whole bar
@ -2403,7 +2403,7 @@ static s32 CalcNewBarValue(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *c
*currValue -= toAdd; *currValue -= toAdd;
ret = Q_24_8_TO_INT(*currValue); ret = Q_24_8_TO_INT(*currValue);
// try round up // try round up
if ((*currValue & 0xFF) > 0) if ((*currValue & INVALID_U8) > 0)
ret++; ret++;
if (ret <= newValue) if (ret <= newValue)
{ {

View File

@ -23,7 +23,7 @@
#include "link_rfu.h" #include "link_rfu.h"
#include "load_save.h" #include "load_save.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "m4a.h" #include "m4a.h"
#include "palette.h" #include "palette.h"
#include "party_menu.h" #include "party_menu.h"
@ -500,7 +500,7 @@ const struct TrainerMoney gTrainerMoneyTable[] =
{TRAINER_CLASS_HIKER, 10}, {TRAINER_CLASS_HIKER, 10},
{TRAINER_CLASS_YOUNG_COUPLE, 8}, {TRAINER_CLASS_YOUNG_COUPLE, 8},
{TRAINER_CLASS_WINSTRATE, 10}, {TRAINER_CLASS_WINSTRATE, 10},
{0xFF, 5}, {INVALID_U8, 5},
}; };
#include "data/text/abilities.h" #include "data/text/abilities.h"
@ -2251,7 +2251,7 @@ static void sub_8038F34(void)
ShowBg(0); ShowBg(0);
ShowBg(1); ShowBg(1);
ShowBg(2); ShowBg(2);
gBattleCommunication[1] = 0xFF; gBattleCommunication[1] = INVALID_U8;
gBattleCommunication[MULTIUSE_STATE]++; gBattleCommunication[MULTIUSE_STATE]++;
break; break;
case 1: case 1:
@ -2993,7 +2993,7 @@ static void BattleStartClearSetData(void)
gLastLandedMoves[i] = 0; gLastLandedMoves[i] = 0;
gLastHitByType[i] = 0; gLastHitByType[i] = 0;
gLastResultingMoves[i] = 0; gLastResultingMoves[i] = 0;
gLastHitBy[i] = 0xFF; gLastHitBy[i] = INVALID_U8;
gLockedMoves[i] = 0; gLockedMoves[i] = 0;
gLastPrintedMoves[i] = 0; gLastPrintedMoves[i] = 0;
gBattleResources->flags->flags[i] = 0; gBattleResources->flags->flags[i] = 0;
@ -3161,7 +3161,7 @@ void SwitchInClearSetData(void)
gLastHitByType[gActiveBattler] = 0; gLastHitByType[gActiveBattler] = 0;
gLastResultingMoves[gActiveBattler] = 0; gLastResultingMoves[gActiveBattler] = 0;
gLastPrintedMoves[gActiveBattler] = 0; gLastPrintedMoves[gActiveBattler] = 0;
gLastHitBy[gActiveBattler] = 0xFF; gLastHitBy[gActiveBattler] = INVALID_U8;
*(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 0) = 0; *(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 0) = 0;
*(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 1) = 0; *(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 1) = 0;
@ -3192,7 +3192,7 @@ void SwitchInClearSetData(void)
gBattleResources->flags->flags[gActiveBattler] = 0; gBattleResources->flags->flags[gActiveBattler] = 0;
gCurrentMove = 0; gCurrentMove = 0;
gBattleStruct->field_DA = 0xFF; gBattleStruct->field_DA = INVALID_U8;
ClearBattlerMoveHistory(gActiveBattler); ClearBattlerMoveHistory(gActiveBattler);
ClearBattlerAbilityHistory(gActiveBattler); ClearBattlerAbilityHistory(gActiveBattler);
@ -3253,7 +3253,7 @@ void FaintClearSetData(void)
gLastHitByType[gActiveBattler] = 0; gLastHitByType[gActiveBattler] = 0;
gLastResultingMoves[gActiveBattler] = 0; gLastResultingMoves[gActiveBattler] = 0;
gLastPrintedMoves[gActiveBattler] = 0; gLastPrintedMoves[gActiveBattler] = 0;
gLastHitBy[gActiveBattler] = 0xFF; gLastHitBy[gActiveBattler] = INVALID_U8;
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 0; *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 0;
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 1) = 0; *(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 1) = 0;
@ -3440,7 +3440,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE if (GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) || GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{ {
hpStatus[i].hp = 0xFFFF; hpStatus[i].hp = INVALID_U16;
hpStatus[i].status = 0; hpStatus[i].status = 0;
} }
else else
@ -3458,7 +3458,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{ {
hpStatus[i].hp = 0xFFFF; hpStatus[i].hp = INVALID_U16;
hpStatus[i].status = 0; hpStatus[i].status = 0;
} }
else else
@ -3484,7 +3484,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG) || GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{ {
hpStatus[i].hp = 0xFFFF; hpStatus[i].hp = INVALID_U16;
hpStatus[i].status = 0; hpStatus[i].status = 0;
} }
else else
@ -3991,7 +3991,7 @@ void BattleTurnPassed(void)
return; return;
} }
if (gBattleResults.battleTurnCounter < 0xFF) if (gBattleResults.battleTurnCounter < INVALID_U8)
{ {
gBattleResults.battleTurnCounter++; gBattleResults.battleTurnCounter++;
gBattleStruct->field_DA++; gBattleStruct->field_DA++;
@ -4375,7 +4375,7 @@ static void HandleTurnActionSelectionState(void)
return; return;
default: default:
sub_818603C(2); sub_818603C(2);
if ((gBattleBufferB[gActiveBattler][2] | (gBattleBufferB[gActiveBattler][3] << 8)) == 0xFFFF) if ((gBattleBufferB[gActiveBattler][2] | (gBattleBufferB[gActiveBattler][3] << 8)) == INVALID_U16)
{ {
gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN; gBattleCommunication[gActiveBattler] = STATE_BEFORE_ACTION_CHOSEN;
RecordedBattle_ClearBattlerAction(gActiveBattler, 1); RecordedBattle_ClearBattlerAction(gActiveBattler, 1);
@ -5740,7 +5740,7 @@ static void HandleAction_ThrowPokeblock(void)
gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBattlerAttacker][1] - 1; gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBattlerAttacker][1] - 1;
gLastUsedItem = gBattleBufferB[gBattlerAttacker][2]; gLastUsedItem = gBattleBufferB[gBattlerAttacker][2];
if (gBattleResults.pokeblockThrows < 0xFF) if (gBattleResults.pokeblockThrows < INVALID_U8)
gBattleResults.pokeblockThrows++; gBattleResults.pokeblockThrows++;
if (gBattleStruct->safariPkblThrowCounter < 3) if (gBattleStruct->safariPkblThrowCounter < 3)
gBattleStruct->safariPkblThrowCounter++; gBattleStruct->safariPkblThrowCounter++;

View File

@ -1156,7 +1156,7 @@ const u16 gCaughtMonStringIds[] =
const u16 gTrappingMoves[] = const u16 gTrappingMoves[] =
{ {
MOVE_BIND, MOVE_WRAP, MOVE_FIRE_SPIN, MOVE_CLAMP, MOVE_WHIRLPOOL, MOVE_SAND_TOMB, 0xFFFF MOVE_BIND, MOVE_WRAP, MOVE_FIRE_SPIN, MOVE_CLAMP, MOVE_WHIRLPOOL, MOVE_SAND_TOMB, INVALID_U16
}; };
const u8 gText_PkmnIsEvolving[] = _("What?\n{STR_VAR_1} is evolving!"); const u8 gText_PkmnIsEvolving[] = _("What?\n{STR_VAR_1} is evolving!");
@ -2967,7 +2967,7 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId)
printerTemplate.bgColor = textInfo[windowId].bgColor; printerTemplate.bgColor = textInfo[windowId].bgColor;
printerTemplate.shadowColor = textInfo[windowId].shadowColor; printerTemplate.shadowColor = textInfo[windowId].shadowColor;
if (printerTemplate.x == 0xFF) if (printerTemplate.x == INVALID_U8)
{ {
u32 width = sub_80397C4(gBattleScripting.windowsType, windowId); u32 width = sub_80397C4(gBattleScripting.windowsType, windowId);
s32 alignX = GetStringCenterAlignXOffsetWithLetterSpacing(printerTemplate.fontId, printerTemplate.currentChar, width, printerTemplate.letterSpacing); s32 alignX = GetStringCenterAlignXOffsetWithLetterSpacing(printerTemplate.fontId, printerTemplate.currentChar, width, printerTemplate.letterSpacing);

View File

@ -9,7 +9,7 @@
#include "task.h" #include "task.h"
#include "battle_tower.h" #include "battle_tower.h"
#include "party_menu.h" #include "party_menu.h"
#include "malloc.h" #include "alloc.h"
#include "palette.h" #include "palette.h"
#include "script.h" #include "script.h"
#include "battle_setup.h" #include "battle_setup.h"
@ -1228,7 +1228,7 @@ static void sub_81A7E60(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4)
static bool8 sub_81A7EC4(void) static bool8 sub_81A7EC4(void)
{ {
if (FindTaskIdByFunc(sub_81A7D54) == 0xFF) if (FindTaskIdByFunc(sub_81A7D54) == INVALID_U8)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -1448,7 +1448,7 @@ static void sub_81A84B4(void)
u8 i; u8 i;
for (i = 0; i < 14; i++) for (i = 0; i < 14; i++)
gSaveBlock2Ptr->frontier.field_CB4[i] |= 0xFFFF; gSaveBlock2Ptr->frontier.field_CB4[i] |= INVALID_U16;
} }
static void sub_81A84EC(void) static void sub_81A84EC(void)

View File

@ -21,7 +21,7 @@
#include "main.h" #include "main.h"
#include "load_save.h" #include "load_save.h"
#include "script.h" #include "script.h"
#include "malloc.h" #include "alloc.h"
#include "overworld.h" #include "overworld.h"
#include "event_scripts.h" #include "event_scripts.h"
#include "constants/battle_frontier.h" #include "constants/battle_frontier.h"
@ -1541,7 +1541,7 @@ void sub_81AA1D8(void)
u8 var0, var1; u8 var0, var1;
for (i = 0; i < 8; i++) for (i = 0; i < 8; i++)
gSaveBlock2Ptr->frontier.field_CB4[i] |= 0xFFFF; gSaveBlock2Ptr->frontier.field_CB4[i] |= INVALID_U16;
id = sub_81AA9E4(); id = sub_81AA9E4();
sub_81AA33C(&var0, &var1); sub_81AA33C(&var0, &var1);

View File

@ -17,7 +17,7 @@
#include "list_menu.h" #include "list_menu.h"
#include "mail.h" #include "mail.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "menu.h" #include "menu.h"
#include "menu_helpers.h" #include "menu_helpers.h"
#include "overworld.h" #include "overworld.h"
@ -388,11 +388,11 @@ void sub_81C4F98(u8 a0, void (*callback)(void))
gPyramidBagCursorData.callback = callback; gPyramidBagCursorData.callback = callback;
gPyramidBagResources->callback2 = NULL; gPyramidBagResources->callback2 = NULL;
gPyramidBagResources->unk814 = 0xFF; gPyramidBagResources->unk814 = INVALID_U8;
gPyramidBagResources->scrollIndicatorsTaskId = 0xFF; gPyramidBagResources->scrollIndicatorsTaskId = INVALID_U8;
memset(gPyramidBagResources->itemsSpriteIds, 0xFF, sizeof(gPyramidBagResources->itemsSpriteIds)); memset(gPyramidBagResources->itemsSpriteIds, INVALID_U8, sizeof(gPyramidBagResources->itemsSpriteIds));
memset(gPyramidBagResources->windowIds, 0xFF, sizeof(gPyramidBagResources->windowIds)); memset(gPyramidBagResources->windowIds, INVALID_U8, sizeof(gPyramidBagResources->windowIds));
SetMainCallback2(sub_81C504C); SetMainCallback2(sub_81C504C);
} }
@ -604,7 +604,7 @@ static void PyramidBagMoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMen
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
sub_81C6F20(); sub_81C6F20();
} }
if (gPyramidBagResources->unk814 == 0xFF) if (gPyramidBagResources->unk814 == INVALID_U8)
{ {
sub_81C6FF8(gPyramidBagResources->unk815 ^ 1); sub_81C6FF8(gPyramidBagResources->unk815 ^ 1);
if (itemIndex != LIST_B_PRESSED) if (itemIndex != LIST_B_PRESSED)
@ -622,7 +622,7 @@ static void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y)
if (itemIndex == LIST_B_PRESSED) if (itemIndex == LIST_B_PRESSED)
return; return;
if (gPyramidBagResources->unk814 != 0xFF) if (gPyramidBagResources->unk814 != INVALID_U8)
{ {
if (gPyramidBagResources->unk814 == (u8)(itemIndex)) if (gPyramidBagResources->unk814 == (u8)(itemIndex))
sub_81C5AB8(y, 1); sub_81C5AB8(y, 1);
@ -657,16 +657,16 @@ static void PrintItemDescription(s32 listMenuId)
static void AddScrollArrow(void) static void AddScrollArrow(void)
{ {
if (gPyramidBagResources->scrollIndicatorsTaskId == 0xFF) if (gPyramidBagResources->scrollIndicatorsTaskId == INVALID_U8)
gPyramidBagResources->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(2, 172, 12, 148, gPyramidBagResources->listMenuCount - gPyramidBagResources->listMenuMaxShown, 0xB5E, 0xB5E, &gPyramidBagCursorData.scrollPosition); gPyramidBagResources->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(2, 172, 12, 148, gPyramidBagResources->listMenuCount - gPyramidBagResources->listMenuMaxShown, 0xB5E, 0xB5E, &gPyramidBagCursorData.scrollPosition);
} }
static void RemoveScrollArrow(void) static void RemoveScrollArrow(void)
{ {
if (gPyramidBagResources->scrollIndicatorsTaskId != 0xFF) if (gPyramidBagResources->scrollIndicatorsTaskId != INVALID_U8)
{ {
RemoveScrollIndicatorArrowPair(gPyramidBagResources->scrollIndicatorsTaskId); RemoveScrollIndicatorArrowPair(gPyramidBagResources->scrollIndicatorsTaskId);
gPyramidBagResources->scrollIndicatorsTaskId = 0xFF; gPyramidBagResources->scrollIndicatorsTaskId = INVALID_U8;
} }
} }
@ -803,7 +803,7 @@ static void sub_81C5A98(u8 listMenuTaskId, u8 arg1)
static void sub_81C5AB8(u8 y, u8 arg1) static void sub_81C5AB8(u8 y, u8 arg1)
{ {
if (arg1 == 0xFF) if (arg1 == INVALID_U8)
FillWindowPixelRect(0, 0, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); FillWindowPixelRect(0, 0, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
else else
PrintOnWindow_Font1(0, gText_SelectorArrow2, 0, y, 0, 0, 0, arg1); PrintOnWindow_Font1(0, gText_SelectorArrow2, 0, y, 0, 0, 0, arg1);
@ -1323,7 +1323,7 @@ static void PerformItemSwap(u8 taskId)
else else
{ {
MovePyramidBagItemSlotInList(data[1], var); MovePyramidBagItemSlotInList(data[1], var);
gPyramidBagResources->unk814 = 0xFF; gPyramidBagResources->unk814 = INVALID_U8;
sub_81C7028(TRUE); sub_81C7028(TRUE);
DestroyListMenuTask(data[0], scrollOffset, selectedRow); DestroyListMenuTask(data[0], scrollOffset, selectedRow);
if (data[1] < var) if (data[1] < var)
@ -1340,7 +1340,7 @@ static void sub_81C6A14(u8 taskId)
u16 *scrollOffset = &gPyramidBagCursorData.scrollPosition; u16 *scrollOffset = &gPyramidBagCursorData.scrollPosition;
u16 *selectedRow = &gPyramidBagCursorData.cursorPosition; u16 *selectedRow = &gPyramidBagCursorData.cursorPosition;
gPyramidBagResources->unk814 = 0xFF; gPyramidBagResources->unk814 = INVALID_U8;
sub_81C7028(TRUE); sub_81C7028(TRUE);
DestroyListMenuTask(data[0], scrollOffset, selectedRow); DestroyListMenuTask(data[0], scrollOffset, selectedRow);
if (data[1] < *scrollOffset + *selectedRow) if (data[1] < *scrollOffset + *selectedRow)
@ -1427,7 +1427,7 @@ static u8 sub_81C6D08(u8 windowArrayId)
static u8 sub_81C6D24(u8 windowArrayId) static u8 sub_81C6D24(u8 windowArrayId)
{ {
u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId]; u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId];
if (*windowId == 0xFF) if (*windowId == INVALID_U8)
{ {
*windowId = AddWindow(&gUnknown_0861F350[windowArrayId]); *windowId = AddWindow(&gUnknown_0861F350[windowArrayId]);
SetWindowBorderStyle(*windowId, FALSE, 1, 0xE); SetWindowBorderStyle(*windowId, FALSE, 1, 0xE);
@ -1439,13 +1439,13 @@ static u8 sub_81C6D24(u8 windowArrayId)
static void sub_81C6D6C(u8 windowArrayId) static void sub_81C6D6C(u8 windowArrayId)
{ {
u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId]; u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId];
if (*windowId != 0xFF) if (*windowId != INVALID_U8)
{ {
sub_8198070(*windowId, FALSE); sub_8198070(*windowId, FALSE);
ClearWindowTilemap(*windowId); ClearWindowTilemap(*windowId);
RemoveWindow(*windowId); RemoveWindow(*windowId);
schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(1);
*windowId = 0xFF; *windowId = INVALID_U8;
} }
} }
@ -1473,13 +1473,13 @@ static void sub_81C6E1C(void)
static void sub_81C6E38(u8 itemSpriteArrayId) static void sub_81C6E38(u8 itemSpriteArrayId)
{ {
u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[itemSpriteArrayId]; u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[itemSpriteArrayId];
if (*spriteId != 0xFF) if (*spriteId != INVALID_U8)
{ {
FreeSpriteTilesByTag(ITEM_IMAGE_TAG + itemSpriteArrayId); FreeSpriteTilesByTag(ITEM_IMAGE_TAG + itemSpriteArrayId);
FreeSpritePaletteByTag(ITEM_IMAGE_TAG + itemSpriteArrayId); FreeSpritePaletteByTag(ITEM_IMAGE_TAG + itemSpriteArrayId);
FreeSpriteOamMatrix(&gSprites[*spriteId]); FreeSpriteOamMatrix(&gSprites[*spriteId]);
DestroySprite(&gSprites[*spriteId]); DestroySprite(&gSprites[*spriteId]);
*spriteId = 0xFF; *spriteId = INVALID_U8;
} }
} }
@ -1524,7 +1524,7 @@ static void ShowItemImage(u16 itemId, u8 itemSpriteArrayId)
{ {
u8 itemSpriteId; u8 itemSpriteId;
u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[itemSpriteArrayId + 1]; u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[itemSpriteArrayId + 1];
if (*spriteId == 0xFF) if (*spriteId == INVALID_U8)
{ {
FreeSpriteTilesByTag(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId); FreeSpriteTilesByTag(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId);
FreeSpritePaletteByTag(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId); FreeSpritePaletteByTag(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId);

View File

@ -18,7 +18,7 @@
#include "international_string_util.h" #include "international_string_util.h"
#include "sound.h" #include "sound.h"
#include "constants/songs.h" #include "constants/songs.h"
#include "malloc.h" #include "alloc.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "constants/game_stat.h" #include "constants/game_stat.h"

View File

@ -763,8 +763,8 @@ static const struct SpriteTemplate sSpriteTemplate_MonIconOnLvlUpBox =
static const u16 sProtectSuccessRates[] = {USHRT_MAX, USHRT_MAX / 2, USHRT_MAX / 4, USHRT_MAX / 8}; static const u16 sProtectSuccessRates[] = {USHRT_MAX, USHRT_MAX / 2, USHRT_MAX / 4, USHRT_MAX / 8};
#define MIMIC_FORBIDDEN_END 0xFFFE #define MIMIC_FORBIDDEN_END 0xFFFE
#define METRONOME_FORBIDDEN_END 0xFFFF #define METRONOME_FORBIDDEN_END INVALID_U16
#define ASSIST_FORBIDDEN_END 0xFFFF #define ASSIST_FORBIDDEN_END INVALID_U16
static const u16 sMovesForbiddenToCopy[] = static const u16 sMovesForbiddenToCopy[] =
{ {
@ -822,7 +822,7 @@ static const u16 sWeightToDamageTable[] =
500, 60, 500, 60,
1000, 80, 1000, 80,
2000, 100, 2000, 100,
0xFFFF, 0xFFFF INVALID_U16, INVALID_U16
}; };
static const u16 sPickupItems[] = static const u16 sPickupItems[] =
@ -1976,7 +1976,7 @@ static void atk0C_datahpupdate(void)
{ {
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]); gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
if (gSpecialStatuses[gActiveBattler].dmg == 0) if (gSpecialStatuses[gActiveBattler].dmg == 0)
gSpecialStatuses[gActiveBattler].dmg = 0xFFFF; gSpecialStatuses[gActiveBattler].dmg = INVALID_U16;
} }
gBattlescriptCurrInstr += 2; gBattlescriptCurrInstr += 2;
} }
@ -2579,7 +2579,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
u16 PayDay = gPaydayMoney; u16 PayDay = gPaydayMoney;
gPaydayMoney += (gBattleMons[gBattlerAttacker].level * 5); gPaydayMoney += (gBattleMons[gBattlerAttacker].level * 5);
if (PayDay > gPaydayMoney) if (PayDay > gPaydayMoney)
gPaydayMoney = 0xFFFF; gPaydayMoney = INVALID_U16;
} }
BattleScriptPush(gBattlescriptCurrInstr + 1); BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]]; gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
@ -4520,7 +4520,7 @@ static void atk49_moveend(void)
u8 arg1, arg2; u8 arg1, arg2;
u16 originallyUsedMove; u16 originallyUsedMove;
if (gChosenMove == 0xFFFF) if (gChosenMove == INVALID_U16)
originallyUsedMove = 0; originallyUsedMove = 0;
else else
originallyUsedMove = gChosenMove; originallyUsedMove = gChosenMove;
@ -4593,7 +4593,7 @@ static void atk49_moveend(void)
break; break;
case ATK49_CHOICE_MOVE: // update choice band move case ATK49_CHOICE_MOVE: // update choice band move
if (!(gHitMarker & HITMARKER_OBEYS) || holdEffectAtk != HOLD_EFFECT_CHOICE_BAND if (!(gHitMarker & HITMARKER_OBEYS) || holdEffectAtk != HOLD_EFFECT_CHOICE_BAND
|| gChosenMove == MOVE_STRUGGLE || (*choicedMoveAtk != 0 && *choicedMoveAtk != 0xFFFF)) || gChosenMove == MOVE_STRUGGLE || (*choicedMoveAtk != 0 && *choicedMoveAtk != INVALID_U16))
goto LOOP; goto LOOP;
if (gChosenMove == MOVE_BATON_PASS && !(gMoveResultFlags & MOVE_RESULT_FAILED)) if (gChosenMove == MOVE_BATON_PASS && !(gMoveResultFlags & MOVE_RESULT_FAILED))
{ {
@ -4708,8 +4708,8 @@ static void atk49_moveend(void)
} }
else else
{ {
gLastMoves[gBattlerAttacker] = 0xFFFF; gLastMoves[gBattlerAttacker] = INVALID_U16;
gLastResultingMoves[gBattlerAttacker] = 0xFFFF; gLastResultingMoves[gBattlerAttacker] = INVALID_U16;
} }
if (!(gHitMarker & HITMARKER_FAINTED(gBattlerTarget))) if (!(gHitMarker & HITMARKER_FAINTED(gBattlerTarget)))
@ -4717,7 +4717,7 @@ static void atk49_moveend(void)
if (gHitMarker & HITMARKER_OBEYS && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)) if (gHitMarker & HITMARKER_OBEYS && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{ {
if (gChosenMove == 0xFFFF) if (gChosenMove == INVALID_U16)
{ {
gLastLandedMoves[gBattlerTarget] = gChosenMove; gLastLandedMoves[gBattlerTarget] = gChosenMove;
} }
@ -4729,7 +4729,7 @@ static void atk49_moveend(void)
} }
else else
{ {
gLastLandedMoves[gBattlerTarget] = 0xFFFF; gLastLandedMoves[gBattlerTarget] = INVALID_U16;
} }
} }
gBattleScripting.atk49_state++; gBattleScripting.atk49_state++;
@ -5662,7 +5662,7 @@ static void atk59_handlelearnnewmove(void)
{ {
gBattlescriptCurrInstr = jumpPtr2; gBattlescriptCurrInstr = jumpPtr2;
} }
else if (ret == 0xFFFF) else if (ret == INVALID_U16)
{ {
gBattlescriptCurrInstr += 10; gBattlescriptCurrInstr += 10;
} }
@ -6015,7 +6015,7 @@ static void atk61_drawpartystatussummary(void)
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG) || GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{ {
hpStatuses[i].hp = 0xFFFF; hpStatuses[i].hp = INVALID_U16;
hpStatuses[i].status = 0; hpStatuses[i].status = 0;
} }
else else
@ -6930,7 +6930,7 @@ static void atk7C_trymirrormove(void)
move = *(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0) move = *(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0)
| (*(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) << 8); | (*(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) << 8);
if (move != 0 && move != 0xFFFF) if (move != 0 && move != INVALID_U16)
{ {
movesArray[validMovesCount] = move; movesArray[validMovesCount] = move;
validMovesCount++; validMovesCount++;
@ -6941,7 +6941,7 @@ static void atk7C_trymirrormove(void)
move = *(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 0) move = *(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 0)
| (*(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 1) << 8); | (*(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 1) << 8);
if (move != 0 && move != 0xFFFF) if (move != 0 && move != INVALID_U16)
{ {
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED); gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
gCurrentMove = move; gCurrentMove = move;
@ -7094,7 +7094,7 @@ bool8 UproarWakeUpCheck(u8 battlerId)
gBattleScripting.battler = i; gBattleScripting.battler = i;
if (gBattlerTarget == 0xFF) if (gBattlerTarget == INVALID_U8)
gBattlerTarget = i; gBattlerTarget = i;
else if (gBattlerTarget == i) else if (gBattlerTarget == i)
gBattleCommunication[MULTISTRING_CHOOSER] = 0; gBattleCommunication[MULTISTRING_CHOOSER] = 0;
@ -8008,7 +8008,7 @@ static void atk9A_setfocusenergy(void)
static void atk9B_transformdataexecution(void) static void atk9B_transformdataexecution(void)
{ {
gChosenMove = 0xFFFF; gChosenMove = INVALID_U16;
gBattlescriptCurrInstr++; gBattlescriptCurrInstr++;
if (gBattleMons[gBattlerTarget].status2 & STATUS2_TRANSFORMED if (gBattleMons[gBattlerTarget].status2 & STATUS2_TRANSFORMED
|| gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE) || gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE)
@ -8088,12 +8088,12 @@ static bool8 IsMoveUncopyableByMimic(u16 move)
static void atk9D_mimicattackcopy(void) static void atk9D_mimicattackcopy(void)
{ {
gChosenMove = 0xFFFF; gChosenMove = INVALID_U16;
if (IsMoveUncopyableByMimic(gLastMoves[gBattlerTarget]) if (IsMoveUncopyableByMimic(gLastMoves[gBattlerTarget])
|| gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED || gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED
|| gLastMoves[gBattlerTarget] == 0 || gLastMoves[gBattlerTarget] == 0
|| gLastMoves[gBattlerTarget] == 0xFFFF) || gLastMoves[gBattlerTarget] == INVALID_U16)
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
@ -8296,7 +8296,7 @@ static void atkA5_painsplitdmgcalc(void)
storeLoc[3] = (painSplitHp & 0xFF000000) >> 24; storeLoc[3] = (painSplitHp & 0xFF000000) >> 24;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp - hpDiff; gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp - hpDiff;
gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF; gSpecialStatuses[gBattlerTarget].dmg = INVALID_U16;
gBattlescriptCurrInstr += 5; gBattlescriptCurrInstr += 5;
} }
@ -8309,7 +8309,7 @@ static void atkA5_painsplitdmgcalc(void)
static void atkA6_settypetorandomresistance(void) // conversion 2 static void atkA6_settypetorandomresistance(void) // conversion 2
{ {
if (gLastLandedMoves[gBattlerAttacker] == 0 if (gLastLandedMoves[gBattlerAttacker] == 0
|| gLastLandedMoves[gBattlerAttacker] == 0xFFFF) || gLastLandedMoves[gBattlerAttacker] == INVALID_U16)
{ {
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1); gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
} }
@ -8376,12 +8376,12 @@ static void atkA7_setalwayshitflag(void)
static void atkA8_copymovepermanently(void) // sketch static void atkA8_copymovepermanently(void) // sketch
{ {
gChosenMove = 0xFFFF; gChosenMove = INVALID_U16;
if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED) if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED)
&& gLastPrintedMoves[gBattlerTarget] != MOVE_STRUGGLE && gLastPrintedMoves[gBattlerTarget] != MOVE_STRUGGLE
&& gLastPrintedMoves[gBattlerTarget] != 0 && gLastPrintedMoves[gBattlerTarget] != 0
&& gLastPrintedMoves[gBattlerTarget] != 0xFFFF && gLastPrintedMoves[gBattlerTarget] != INVALID_U16
&& gLastPrintedMoves[gBattlerTarget] != MOVE_SKETCH) && gLastPrintedMoves[gBattlerTarget] != MOVE_SKETCH)
{ {
s32 i; s32 i;
@ -8550,7 +8550,7 @@ static void atkAC_remaininghptopower(void)
static void atkAD_tryspiteppreduce(void) static void atkAD_tryspiteppreduce(void)
{ {
if (gLastMoves[gBattlerTarget] != 0 if (gLastMoves[gBattlerTarget] != 0
&& gLastMoves[gBattlerTarget] != 0xFFFF) && gLastMoves[gBattlerTarget] != INVALID_U16)
{ {
s32 i; s32 i;
@ -9671,13 +9671,13 @@ static void atkDC_trysetgrudge(void)
static void atkDD_weightdamagecalculation(void) static void atkDD_weightdamagecalculation(void)
{ {
s32 i; s32 i;
for (i = 0; sWeightToDamageTable[i] != 0xFFFF; i += 2) for (i = 0; sWeightToDamageTable[i] != INVALID_U16; i += 2)
{ {
if (sWeightToDamageTable[i] > GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), 1)) if (sWeightToDamageTable[i] > GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), 1))
break; break;
} }
if (sWeightToDamageTable[i] != 0xFFFF) if (sWeightToDamageTable[i] != INVALID_U16)
gDynamicBasePower = sWeightToDamageTable[i + 1]; gDynamicBasePower = sWeightToDamageTable[i + 1];
else else
gDynamicBasePower = 120; gDynamicBasePower = 120;

View File

@ -1530,7 +1530,7 @@ static s32 FirstBattleTrainerIdToRematchTableId(const struct RematchTrainer *tab
return i; return i;
} }
return -1; return INVALID_S32;
} }
static s32 TrainerIdToRematchTableId(const struct RematchTrainer *table, u16 trainerId) static s32 TrainerIdToRematchTableId(const struct RematchTrainer *table, u16 trainerId)
@ -1548,7 +1548,7 @@ static s32 TrainerIdToRematchTableId(const struct RematchTrainer *table, u16 tra
} }
} }
return -1; return INVALID_S32;
} }
static bool32 sub_80B1D94(s32 rematchTableId) static bool32 sub_80B1D94(s32 rematchTableId)
@ -1640,7 +1640,7 @@ static bool8 IsFirstTrainerIdReadyForRematch(const struct RematchTrainer *table,
{ {
s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId); s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId);
if (tableId == -1) if (tableId == INVALID_S32)
return FALSE; return FALSE;
if (tableId >= 100) if (tableId >= 100)
return FALSE; return FALSE;
@ -1654,7 +1654,7 @@ static bool8 IsTrainerReadyForRematch_(const struct RematchTrainer *table, u16 t
{ {
s32 tableId = TrainerIdToRematchTableId(table, trainerId); s32 tableId = TrainerIdToRematchTableId(table, trainerId);
if (tableId == -1) if (tableId == INVALID_S32)
return FALSE; return FALSE;
if (tableId >= 100) if (tableId >= 100)
return FALSE; return FALSE;
@ -1670,7 +1670,7 @@ static u16 GetRematchTrainerIdFromTable(const struct RematchTrainer *table, u16
s32 i; s32 i;
s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId); s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId);
if (tableId == -1) if (tableId == INVALID_S32)
return FALSE; return FALSE;
trainerEntry = &table[tableId]; trainerEntry = &table[tableId];
@ -1691,7 +1691,7 @@ static u16 GetLastBeatenRematchTrainerIdFromTable(const struct RematchTrainer *t
s32 i; s32 i;
s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId); s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId);
if (tableId == -1) if (tableId == INVALID_S32)
return FALSE; return FALSE;
trainerEntry = &table[tableId]; trainerEntry = &table[tableId];
@ -1710,7 +1710,7 @@ static void ClearTrainerWantRematchState(const struct RematchTrainer *table, u16
{ {
s32 tableId = TrainerIdToRematchTableId(table, firstBattleTrainerId); s32 tableId = TrainerIdToRematchTableId(table, firstBattleTrainerId);
if (tableId != -1) if (tableId != INVALID_S32)
gSaveBlock1Ptr->trainerRematches[tableId] = 0; gSaveBlock1Ptr->trainerRematches[tableId] = 0;
} }
@ -1724,7 +1724,7 @@ static u32 GetTrainerMatchCallFlag(u32 trainerId)
return FLAG_MATCH_CALL_REGISTERED + i; return FLAG_MATCH_CALL_REGISTERED + i;
} }
return 0xFFFF; return INVALID_U16;
} }
static void RegisterTrainerInMatchCall(void) static void RegisterTrainerInMatchCall(void)
@ -1732,7 +1732,7 @@ static void RegisterTrainerInMatchCall(void)
if (FlagGet(FLAG_HAS_MATCH_CALL)) if (FlagGet(FLAG_HAS_MATCH_CALL))
{ {
u32 matchCallFlagId = GetTrainerMatchCallFlag(gTrainerBattleOpponent_A); u32 matchCallFlagId = GetTrainerMatchCallFlag(gTrainerBattleOpponent_A);
if (matchCallFlagId != 0xFFFF) if (matchCallFlagId != INVALID_U16)
FlagSet(matchCallFlagId); FlagSet(matchCallFlagId);
} }
} }
@ -1741,7 +1741,7 @@ static bool8 WasSecondRematchWon(const struct RematchTrainer *table, u16 firstBa
{ {
s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId); s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId);
if (tableId == -1) if (tableId == INVALID_S32)
return FALSE; return FALSE;
if (!HasTrainerBeenFought(table[tableId].trainerIds[1])) if (!HasTrainerBeenFought(table[tableId].trainerIds[1]))
return FALSE; return FALSE;

View File

@ -364,7 +364,7 @@ static void sub_81BA040(void)
} while (i != gSaveBlock2Ptr->frontier.curChallengeBattleNum); } while (i != gSaveBlock2Ptr->frontier.curChallengeBattleNum);
gTrainerBattleOpponent_A = trainerId; gTrainerBattleOpponent_A = trainerId;
while (gFacilityTrainers[gTrainerBattleOpponent_A].monSets[setsCount] != 0xFFFF) while (gFacilityTrainers[gTrainerBattleOpponent_A].monSets[setsCount] != INVALID_U16)
setsCount++; setsCount++;
if (setsCount > 8) if (setsCount > 8)
break; break;

View File

@ -973,7 +973,7 @@ static void FillTrainerParty(u16 trainerId, u8 firstMonId, u8 monCount)
// Attempt to fill the trainer's party with random Pokemon until 3 have been // Attempt to fill the trainer's party with random Pokemon until 3 have been
// successfully chosen. The trainer's party may not have duplicate pokemon species // successfully chosen. The trainer's party may not have duplicate pokemon species
// or duplicate held items. // or duplicate held items.
for (bfMonCount = 0; monSets[bfMonCount] != 0xFFFF; bfMonCount++) for (bfMonCount = 0; monSets[bfMonCount] != INVALID_U16; bfMonCount++)
; ;
i = 0; i = 0;
otID = Random32(); otID = Random32();
@ -1081,11 +1081,11 @@ u16 RandomizeFacilityTrainerMonSet(u16 trainerId)
u8 bfMonCount = 0; u8 bfMonCount = 0;
u32 monSetId = monSets[bfMonCount]; u32 monSetId = monSets[bfMonCount];
while (monSetId != 0xFFFF) while (monSetId != INVALID_U16)
{ {
bfMonCount++; bfMonCount++;
monSetId = monSets[bfMonCount]; monSetId = monSets[bfMonCount];
if (monSetId == 0xFFFF) if (monSetId == INVALID_U16)
break; break;
} }
@ -2641,11 +2641,11 @@ static void FillTentTrainerParty_(u16 trainerId, u8 firstMonId, u8 monCount)
bfMonCount = 0; bfMonCount = 0;
monSetId = monSets[bfMonCount]; monSetId = monSets[bfMonCount];
while (monSetId != 0xFFFF) while (monSetId != INVALID_U16)
{ {
bfMonCount++; bfMonCount++;
monSetId = monSets[bfMonCount]; monSetId = monSets[bfMonCount];
if (monSetId == 0xFFFF) if (monSetId == INVALID_U16)
break; break;
} }

View File

@ -7,7 +7,7 @@
#include "field_effect.h" #include "field_effect.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "overworld.h" #include "overworld.h"
#include "palette.h" #include "palette.h"
#include "random.h" #include "random.h"
@ -749,7 +749,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_85C8E60[] =
static const struct SpriteTemplate gUnknown_085C8E68 = static const struct SpriteTemplate gUnknown_085C8E68 =
{ {
.tileTag = 0xFFFF, .tileTag = INVALID_U16,
.paletteTag = 4105, .paletteTag = 4105,
.oam = &gEventObjectBaseOam_32x32, .oam = &gEventObjectBaseOam_32x32,
.anims = sSpriteAnimTable_85C8E3C, .anims = sSpriteAnimTable_85C8E3C,
@ -798,7 +798,7 @@ static const union AnimCmd *const sSpriteAnimTable_85C8EA0[] =
static const struct SpriteTemplate sSpriteTemplate_85C8EA4 = static const struct SpriteTemplate sSpriteTemplate_85C8EA4 =
{ {
.tileTag = 0xFFFF, .tileTag = INVALID_U16,
.paletteTag = 4106, .paletteTag = 4106,
.oam = &gOamData_85C8E80, .oam = &gOamData_85C8E80,
.anims = sSpriteAnimTable_85C8EA0, .anims = sSpriteAnimTable_85C8EA0,
@ -809,7 +809,7 @@ static const struct SpriteTemplate sSpriteTemplate_85C8EA4 =
static const struct SpriteTemplate sSpriteTemplate_85C8EBC = static const struct SpriteTemplate sSpriteTemplate_85C8EBC =
{ {
.tileTag = 0xFFFF, .tileTag = INVALID_U16,
.paletteTag = 4106, .paletteTag = 4106,
.oam = &gOamData_85C8E80, .oam = &gOamData_85C8E80,
.anims = sSpriteAnimTable_85C8EA0, .anims = sSpriteAnimTable_85C8EA0,
@ -998,7 +998,7 @@ static bool8 Transition_Phase1(struct Task *task)
static bool8 Transition_WaitForPhase1(struct Task *task) static bool8 Transition_WaitForPhase1(struct Task *task)
{ {
if (FindTaskIdByFunc(sPhase1_Tasks[task->tTransitionId]) == 0xFF) if (FindTaskIdByFunc(sPhase1_Tasks[task->tTransitionId]) == INVALID_U8)
{ {
task->tState++; task->tState++;
return TRUE; return TRUE;
@ -1019,7 +1019,7 @@ static bool8 Transition_Phase2(struct Task *task)
static bool8 Transition_WaitForPhase2(struct Task *task) static bool8 Transition_WaitForPhase2(struct Task *task)
{ {
task->tTransitionDone = FALSE; task->tTransitionDone = FALSE;
if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionId]) == 0xFF) if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionId]) == INVALID_U8)
task->tTransitionDone = TRUE; task->tTransitionDone = TRUE;
return FALSE; return FALSE;
} }
@ -3605,7 +3605,7 @@ static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4)
static bool8 IsPhase1Done(void) static bool8 IsPhase1Done(void)
{ {
if (FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) == 0xFF) if (FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) == INVALID_U8)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;

View File

@ -26,9 +26,9 @@ static const u16 sVariableDmgMoves[] =
MOVE_WATER_SPOUT, MOVE_DREAM_EATER, MOVE_WEATHER_BALL, MOVE_WATER_SPOUT, MOVE_DREAM_EATER, MOVE_WEATHER_BALL,
MOVE_SNORE, MOVE_PAIN_SPLIT, MOVE_GUILLOTINE, MOVE_SNORE, MOVE_PAIN_SPLIT, MOVE_GUILLOTINE,
MOVE_FRUSTRATION, MOVE_RETURN, MOVE_ENDEAVOR, MOVE_FRUSTRATION, MOVE_RETURN, MOVE_ENDEAVOR,
MOVE_PRESENT, MOVE_REVENGE, 0xFFFF, MOVE_PRESENT, MOVE_REVENGE, INVALID_U16,
// those are handled by the function itself // those are handled by the function itself
MOVE_MAGNITUDE, MOVE_PSYWAVE, 0xFFFF MOVE_MAGNITUDE, MOVE_PSYWAVE, INVALID_U16
}; };
static const u16 sUnknown_0860A4E0[] = static const u16 sUnknown_0860A4E0[] =
@ -199,7 +199,7 @@ static const u16 sUnknown_0860A8A4[] =
STRINGID_PKMNAFFLICTEDBYCURSE, STRINGID_PKMNSAPPEDBYLEECHSEED, STRINGID_PKMNLOCKEDINNIGHTMARE, STRINGID_PKMNAFFLICTEDBYCURSE, STRINGID_PKMNSAPPEDBYLEECHSEED, STRINGID_PKMNLOCKEDINNIGHTMARE,
STRINGID_PKMNHURTBY, STRINGID_PKMNHURTBYBURN, STRINGID_PKMNHURTBYPOISON, STRINGID_PKMNHURTBY, STRINGID_PKMNHURTBYBURN, STRINGID_PKMNHURTBYPOISON,
STRINGID_PKMNHURTBYSPIKES, STRINGID_ATTACKERFAINTED, STRINGID_TARGETFAINTED, STRINGID_PKMNHURTBYSPIKES, STRINGID_ATTACKERFAINTED, STRINGID_TARGETFAINTED,
STRINGID_PKMNHITWITHRECOIL, STRINGID_PKMNCRASHED, 0xFFFF STRINGID_PKMNHITWITHRECOIL, STRINGID_PKMNCRASHED, INVALID_U16
}; };
// code // code
@ -625,9 +625,9 @@ static bool8 sub_817E0B8(u16 stringId)
if (sUnknown_0860A8A4[i] == stringId) if (sUnknown_0860A8A4[i] == stringId)
break; break;
i++; i++;
} while (sUnknown_0860A8A4[i] != 0xFFFF); } while (sUnknown_0860A8A4[i] != INVALID_U16);
if (sUnknown_0860A8A4[i] == 0xFFFF) if (sUnknown_0860A8A4[i] == INVALID_U16)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -1164,7 +1164,7 @@ static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3)
break; break;
} }
i += 2; i += 2;
} while (ptr[i] != 0xFFFF); } while (ptr[i] != INVALID_U16);
break; break;
case 19: case 19:
tvPtr->side[arg2 ^ 1].faintCause = 0; tvPtr->side[arg2 ^ 1].faintCause = 0;
@ -1415,9 +1415,9 @@ static void TrySetBattleSeminarShow(void)
if (currMoveSaved == sVariableDmgMoves[i]) if (currMoveSaved == sVariableDmgMoves[i])
break; break;
i++; i++;
} while (sVariableDmgMoves[i] != 0xFFFF); } while (sVariableDmgMoves[i] != INVALID_U16);
if (sVariableDmgMoves[i] != 0xFFFF) if (sVariableDmgMoves[i] != INVALID_U16)
return; return;
dmgByMove[gMoveSelectionCursor[gBattlerAttacker]] = gBattleMoveDamage; dmgByMove[gMoveSelectionCursor[gBattlerAttacker]] = gBattleMoveDamage;
@ -1490,9 +1490,9 @@ static bool8 ShouldCalculateDamage(u16 moveId, s32 *dmg, u16 *powerOverride)
if (moveId == sVariableDmgMoves[i]) if (moveId == sVariableDmgMoves[i])
break; break;
i++; i++;
} while (sVariableDmgMoves[i] != 0xFFFF); } while (sVariableDmgMoves[i] != INVALID_U16);
if (sVariableDmgMoves[i] != 0xFFFF) if (sVariableDmgMoves[i] != INVALID_U16)
{ {
*dmg = 0; *dmg = 0;
return FALSE; return FALSE;

View File

@ -29,7 +29,7 @@ extern u8 weather_get_current(void);
static const u16 sSoundMovesTable[] = static const u16 sSoundMovesTable[] =
{ {
MOVE_GROWL, MOVE_ROAR, MOVE_SING, MOVE_SUPERSONIC, MOVE_SCREECH, MOVE_SNORE, MOVE_GROWL, MOVE_ROAR, MOVE_SING, MOVE_SUPERSONIC, MOVE_SCREECH, MOVE_SNORE,
MOVE_UPROAR, MOVE_METAL_SOUND, MOVE_GRASS_WHISTLE, MOVE_HYPER_VOICE, 0xFFFF MOVE_UPROAR, MOVE_METAL_SOUND, MOVE_GRASS_WHISTLE, MOVE_HYPER_VOICE, INVALID_U16
}; };
u8 GetBattlerForBattleScript(u8 caseId) u8 GetBattlerForBattleScript(u8 caseId)
@ -382,7 +382,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
gPotentialItemEffectBattler = gActiveBattler; gPotentialItemEffectBattler = gActiveBattler;
if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != move) if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != INVALID_U16 && *choicedMove != move)
{ {
gCurrentMove = *choicedMove; gCurrentMove = *choicedMove;
gLastUsedItem = gBattleMons[gActiveBattler].item; gLastUsedItem = gBattleMons[gActiveBattler].item;
@ -442,7 +442,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check)
unusableMoves |= gBitTable[i]; unusableMoves |= gBitTable[i];
if (gDisableStructs[battlerId].encoreTimer && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[i]) if (gDisableStructs[battlerId].encoreTimer && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[i])
unusableMoves |= gBitTable[i]; unusableMoves |= gBitTable[i];
if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != 0xFFFF && *choicedMove != gBattleMons[battlerId].moves[i]) if (holdEffect == HOLD_EFFECT_CHOICE_BAND && *choicedMove != 0 && *choicedMove != INVALID_U16 && *choicedMove != gBattleMons[battlerId].moves[i])
unusableMoves |= gBitTable[i]; unusableMoves |= gBitTable[i];
} }
return unusableMoves; return unusableMoves;
@ -451,7 +451,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check)
bool8 AreAllMovesUnusable(void) bool8 AreAllMovesUnusable(void)
{ {
u8 unusable; u8 unusable;
unusable = CheckMoveLimitations(gActiveBattler, 0, 0xFF); unusable = CheckMoveLimitations(gActiveBattler, 0, INVALID_U8);
if (unusable == 0xF) // All moves are unusable. if (unusable == 0xF) // All moves are unusable.
{ {
@ -1137,7 +1137,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void)
gBattlerTarget = gActiveBattler; gBattlerTarget = gActiveBattler;
gBattlerAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler]; gBattlerAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler];
gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBattler]; gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBattler];
gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF; gSpecialStatuses[gBattlerTarget].dmg = INVALID_U16;
BattleScriptExecute(BattleScript_MonTookFutureAttack); BattleScriptExecute(BattleScript_MonTookFutureAttack);
if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0 if (gWishFutureKnock.futureSightCounter[gActiveBattler] == 0
@ -1996,12 +1996,12 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
case ABILITYEFFECT_MOVES_BLOCK: // 2 case ABILITYEFFECT_MOVES_BLOCK: // 2
if (gLastUsedAbility == ABILITY_SOUNDPROOF) if (gLastUsedAbility == ABILITY_SOUNDPROOF)
{ {
for (i = 0; sSoundMovesTable[i] != 0xFFFF; i++) for (i = 0; sSoundMovesTable[i] != INVALID_U16; i++)
{ {
if (sSoundMovesTable[i] == move) if (sSoundMovesTable[i] == move)
break; break;
} }
if (sSoundMovesTable[i] != 0xFFFF) if (sSoundMovesTable[i] != INVALID_U16)
{ {
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS) if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)
gHitMarker |= HITMARKER_NO_PPDEDUCT; gHitMarker |= HITMARKER_NO_PPDEDUCT;
@ -2527,7 +2527,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
break; break;
} }
if (effect && caseID < ABILITYEFFECT_CHECK_OTHER_SIDE && gLastUsedAbility != 0xFF) if (effect && caseID < ABILITYEFFECT_CHECK_OTHER_SIDE && gLastUsedAbility != INVALID_U8)
RecordAbilityBattle(battler, gLastUsedAbility); RecordAbilityBattle(battler, gLastUsedAbility);
} }
@ -3213,7 +3213,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
case HOLD_EFFECT_SHELL_BELL: case HOLD_EFFECT_SHELL_BELL:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT) if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gSpecialStatuses[gBattlerTarget].dmg != 0 && gSpecialStatuses[gBattlerTarget].dmg != 0
&& gSpecialStatuses[gBattlerTarget].dmg != 0xFFFF && gSpecialStatuses[gBattlerTarget].dmg != INVALID_U16
&& gBattlerAttacker != gBattlerTarget && gBattlerAttacker != gBattlerTarget
&& gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP && gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP
&& gBattleMons[gBattlerAttacker].hp != 0) && gBattleMons[gBattlerAttacker].hp != 0)
@ -3394,7 +3394,7 @@ u8 IsMonDisobedient(void)
calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8; calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8;
if (calc < obedienceLevel) if (calc < obedienceLevel)
{ {
calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], 0xFF); calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], INVALID_U8);
if (calc == 0xF) // all moves cannot be used if (calc == 0xF) // all moves cannot be used
{ {
gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3; gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3;

View File

@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
#include "battle.h" #include "battle.h"
#include "battle_controllers.h" #include "battle_controllers.h"
#include "malloc.h" #include "alloc.h"
#include "pokemon.h" #include "pokemon.h"
#include "event_data.h" #include "event_data.h"
#include "constants/abilities.h" #include "constants/abilities.h"

View File

@ -12,7 +12,7 @@
#include "bg.h" #include "bg.h"
#include "palette.h" #include "palette.h"
#include "decompress.h" #include "decompress.h"
#include "malloc.h" #include "alloc.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "text.h" #include "text.h"
#include "text_window.h" #include "text_window.h"
@ -1455,7 +1455,7 @@ static void sub_808074C(void)
for (i = 0; i < BLENDER_MAX_PLAYERS; i++) for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{ {
sBerryBlenderData->field_96[i] = 0xFF; sBerryBlenderData->field_96[i] = INVALID_U8;
sBerryBlenderData->field_8E[i] = sUnknown_083399D0[sBerryBlenderData->playersNo - 2][i]; sBerryBlenderData->field_8E[i] = sUnknown_083399D0[sBerryBlenderData->playersNo - 2][i];
} }
for (j = 0; j < BLENDER_MAX_PLAYERS; j++) for (j = 0; j < BLENDER_MAX_PLAYERS; j++)
@ -1479,7 +1479,7 @@ static void Blender_PrintPlayerNames(void)
for (i = 0; i < BLENDER_MAX_PLAYERS; i++) for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{ {
if (sBerryBlenderData->field_8E[i] != 0xFF) if (sBerryBlenderData->field_8E[i] != INVALID_U8)
{ {
sBerryBlenderData->syncArrowSpriteIds[sBerryBlenderData->field_8E[i]] = sBerryBlenderData->syncArrowSprite2Ids[i]; sBerryBlenderData->syncArrowSpriteIds[sBerryBlenderData->field_8E[i]] = sBerryBlenderData->syncArrowSprite2Ids[i];
StartSpriteAnim(&gSprites[sBerryBlenderData->syncArrowSpriteIds[sBerryBlenderData->field_8E[i]]], i); StartSpriteAnim(&gSprites[sBerryBlenderData->syncArrowSpriteIds[sBerryBlenderData->field_8E[i]]], i);

View File

@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "multiboot.h" #include "multiboot.h"
#include "malloc.h" #include "alloc.h"
#include "bg.h" #include "bg.h"
#include "graphics.h" #include "graphics.h"
#include "main.h" #include "main.h"

View File

@ -21,7 +21,7 @@
#include "string_util.h" #include "string_util.h"
#include "strings.h" #include "strings.h"
#include "bg.h" #include "bg.h"
#include "malloc.h" #include "alloc.h"
#include "scanline_effect.h" #include "scanline_effect.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "graphics.h" #include "graphics.h"

View File

@ -87,37 +87,37 @@ void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenS
{ {
if (IsInvalidBg(bg) == FALSE) if (IsInvalidBg(bg) == FALSE)
{ {
if (charBaseIndex != 0xFF) if (charBaseIndex != INVALID_U8)
{ {
sGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex & 0x3; sGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex & 0x3;
} }
if (mapBaseIndex != 0xFF) if (mapBaseIndex != INVALID_U8)
{ {
sGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex & 0x1F; sGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex & 0x1F;
} }
if (screenSize != 0xFF) if (screenSize != INVALID_U8)
{ {
sGpuBgConfigs.configs[bg].screenSize = screenSize & 0x3; sGpuBgConfigs.configs[bg].screenSize = screenSize & 0x3;
} }
if (paletteMode != 0xFF) if (paletteMode != INVALID_U8)
{ {
sGpuBgConfigs.configs[bg].paletteMode = paletteMode; sGpuBgConfigs.configs[bg].paletteMode = paletteMode;
} }
if (priority != 0xFF) if (priority != INVALID_U8)
{ {
sGpuBgConfigs.configs[bg].priority = priority & 0x3; sGpuBgConfigs.configs[bg].priority = priority & 0x3;
} }
if (mosaic != 0xFF) if (mosaic != INVALID_U8)
{ {
sGpuBgConfigs.configs[bg].mosaic = mosaic & 0x1; sGpuBgConfigs.configs[bg].mosaic = mosaic & 0x1;
} }
if (wraparound != 0xFF) if (wraparound != INVALID_U8)
{ {
sGpuBgConfigs.configs[bg].wraparound = wraparound; sGpuBgConfigs.configs[bg].wraparound = wraparound;
} }
@ -154,7 +154,7 @@ u16 GetBgControlAttribute(u8 bg, u8 attributeId)
} }
} }
return 0xFF; return INVALID_U8;
} }
u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode) u8 LoadBgVram(u8 bg, const void *src, u16 size, u16 destOffset, u8 mode)
@ -379,7 +379,7 @@ u16 LoadBgTiles(u8 bg, const void* src, u16 size, u16 destOffset)
cursor = LoadBgVram(bg, src, size, tileOffset, DISPCNT_MODE_1); cursor = LoadBgVram(bg, src, size, tileOffset, DISPCNT_MODE_1);
if (cursor == 0xFF) if (cursor == INVALID_U8)
{ {
return -1; return -1;
} }
@ -400,7 +400,7 @@ u16 LoadBgTilemap(u8 bg, const void *src, u16 size, u16 destOffset)
cursor = LoadBgVram(bg, src, size, destOffset * 2, DISPCNT_MODE_2); cursor = LoadBgVram(bg, src, size, destOffset * 2, DISPCNT_MODE_2);
if (cursor == 0xFF) if (cursor == INVALID_U8)
{ {
return -1; return -1;
} }
@ -480,25 +480,25 @@ void SetBgAttribute(u8 bg, u8 attributeId, u8 value)
switch (attributeId) switch (attributeId)
{ {
case 1: case 1:
SetBgControlAttributes(bg, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); SetBgControlAttributes(bg, value, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8);
break; break;
case 2: case 2:
SetBgControlAttributes(bg, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF); SetBgControlAttributes(bg, INVALID_U8, value, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8);
break; break;
case 3: case 3:
SetBgControlAttributes(bg, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF, 0xFF); SetBgControlAttributes(bg, INVALID_U8, INVALID_U8, value, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8);
break; break;
case 4: case 4:
SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF, 0xFF); SetBgControlAttributes(bg, INVALID_U8, INVALID_U8, INVALID_U8, value, INVALID_U8, INVALID_U8, INVALID_U8);
break; break;
case 7: case 7:
SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF, 0xFF); SetBgControlAttributes(bg, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, value, INVALID_U8, INVALID_U8);
break; break;
case 5: case 5:
SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value, 0xFF); SetBgControlAttributes(bg, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, value, INVALID_U8);
break; break;
case 6: case 6:
SetBgControlAttributes(bg, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, value); SetBgControlAttributes(bg, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, INVALID_U8, value);
break; break;
} }
} }
@ -1284,7 +1284,7 @@ u32 GetBgType(u8 bg)
break; break;
} }
return 0xFFFF; return INVALID_U16;
} }
bool32 IsInvalidBg32(u8 bg) bool32 IsInvalidBg32(u8 bg)

View File

@ -3,7 +3,7 @@
void BlitBitmapRect4BitWithoutColorKey(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height) void BlitBitmapRect4BitWithoutColorKey(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height)
{ {
BlitBitmapRect4Bit(src, dst, srcX, srcY, dstX, dstY, width, height, 0xFF); BlitBitmapRect4Bit(src, dst, srcX, srcY, dstX, dstY, width, height, INVALID_U8);
} }
void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey) void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height, u8 colorKey)
@ -33,7 +33,7 @@ void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 sr
multiplierSrcY = (src->width + (src->width & 7)) >> 3; multiplierSrcY = (src->width + (src->width & 7)) >> 3;
multiplierDstY = (dst->width + (dst->width & 7)) >> 3; multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
if (colorKey == 0xFF) if (colorKey == INVALID_U8)
{ {
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++) for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
{ {
@ -132,7 +132,7 @@ void BlitBitmapRect4BitTo8Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX,
multiplierSrcY = (src->width + (src->width & 7)) >> 3; multiplierSrcY = (src->width + (src->width & 7)) >> 3;
multiplierDstY = (dst->width + (dst->width & 7)) >> 3; multiplierDstY = (dst->width + (dst->width & 7)) >> 3;
if (colorKey == 0xFF) if (colorKey == INVALID_U8)
{ {
for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++) for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++)
{ {

View File

@ -465,7 +465,7 @@ bool8 ShouldDoBrailleRegicePuzzle(void)
} }
varValue = VarGet(0x403B); varValue = VarGet(0x403B);
if (varValue != 0xFFFF || VarGet(0x403C) != varValue || VarGet(0x403D) != 0xF) if (varValue != INVALID_U16 || VarGet(0x403C) != varValue || VarGet(0x403D) != 0xF)
return FALSE; return FALSE;
if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 21) if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 21)

View File

@ -70,7 +70,7 @@ static void sub_80B3220(u8 taskId);
static void sub_80B236C(u8 arg0, u8 arg1) static void sub_80B236C(u8 arg0, u8 arg1)
{ {
if (FindTaskIdByFunc(sub_80B2634) == 0xFF) if (FindTaskIdByFunc(sub_80B2634) == INVALID_U8)
{ {
u8 taskId1; u8 taskId1;
@ -604,7 +604,7 @@ void sub_80B2EA8(void)
{ {
u32 taskId = FindTaskIdByFunc(sub_80B2EE4); u32 taskId = FindTaskIdByFunc(sub_80B2EE4);
if (taskId == 0xFF) if (taskId == INVALID_U8)
{ {
taskId = CreateTask(sub_80B2EE4, 80); taskId = CreateTask(sub_80B2EE4, 80);
gTasks[taskId].data[0] = 0; gTasks[taskId].data[0] = 0;
@ -702,7 +702,7 @@ void sub_80B3028(void)
u8 sub_80B3050(void) u8 sub_80B3050(void)
{ {
if (FuncIsActiveTask(sub_80B3144) != FALSE) if (FuncIsActiveTask(sub_80B3144) != FALSE)
return 0xFF; return INVALID_U8;
switch (gSpecialVar_0x8004) switch (gSpecialVar_0x8004)
{ {

View File

@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "bg.h" #include "bg.h"
#include "malloc.h" #include "alloc.h"
#include "constants/items.h" #include "constants/items.h"
#include "constants/event_objects.h" #include "constants/event_objects.h"
#include "constants/moves.h" #include "constants/moves.h"
@ -324,7 +324,7 @@ void sub_80D787C(void)
*gContestResources->field_0 = (struct Contest){}; *gContestResources->field_0 = (struct Contest){};
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
gContestResources->field_0->unk19206[i] = 0xFF; gContestResources->field_0->unk19206[i] = INVALID_U8;
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
@ -344,7 +344,7 @@ void sub_80D787C(void)
sub_80DCE58(0); sub_80DCE58(0);
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
gContestResources->field_4[i].nextTurnOrder = 0xFF; gContestResources->field_4[i].nextTurnOrder = INVALID_U8;
gContestResources->field_0->unk19218[i] = gUnknown_02039F26[i]; gContestResources->field_0->unk19218[i] = gUnknown_02039F26[i];
} }
sub_80DD590(); sub_80DD590();
@ -2097,7 +2097,7 @@ void sub_80DAB8C(u8 contestType, u8 rank)
opponents[opponentsCount++] = i; opponents[opponentsCount++] = i;
} }
} }
opponents[opponentsCount] = 0xFF; opponents[opponentsCount] = INVALID_U8;
// Choose three random opponents from the list // Choose three random opponents from the list
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
@ -2106,7 +2106,7 @@ void sub_80DAB8C(u8 contestType, u8 rank)
s32 j; s32 j;
gContestMons[i] = gContestOpponents[opponents[rnd]]; gContestMons[i] = gContestOpponents[opponents[rnd]];
for (j = rnd; opponents[j] != 0xFF; j++) for (j = rnd; opponents[j] != INVALID_U8; j++)
opponents[j] = opponents[j + 1]; opponents[j] = opponents[j + 1];
opponentsCount--; opponentsCount--;
} }
@ -2151,7 +2151,7 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame)
else if (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough) else if (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough)
opponents[opponentsCount++] = i; opponents[opponentsCount++] = i;
} }
opponents[opponentsCount] = 0xFF; opponents[opponentsCount] = INVALID_U8;
for (i = 0; i < 4 - gUnknown_02039F30; i++) for (i = 0; i < 4 - gUnknown_02039F30; i++)
{ {
u16 rnd = sub_80F903C() % opponentsCount; u16 rnd = sub_80F903C() % opponentsCount;
@ -2160,7 +2160,7 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame)
gContestMons[gUnknown_02039F30 + i] = gContestOpponents[opponents[rnd]]; gContestMons[gUnknown_02039F30 + i] = gContestOpponents[opponents[rnd]];
sub_80DF9D4(gContestMons[gUnknown_02039F30 + i].trainerName); sub_80DF9D4(gContestMons[gUnknown_02039F30 + i].trainerName);
sub_80DF9E0(gContestMons[gUnknown_02039F30 + i].nickname, GAME_LANGUAGE); sub_80DF9E0(gContestMons[gUnknown_02039F30 + i].nickname, GAME_LANGUAGE);
for (j = rnd; opponents[j] != 0xFF; j++) for (j = rnd; opponents[j] != INVALID_U8; j++)
opponents[j] = opponents[j + 1]; opponents[j] = opponents[j + 1];
opponentsCount--; opponentsCount--;
} }
@ -2591,7 +2591,7 @@ void prints_contest_move_description(u16 a)
ContestBG_FillBoxWithIncrementingTile(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01); ContestBG_FillBoxWithIncrementingTile(0, categoryTile, 0x0b, 0x1f, 0x05, 0x01, 0x11, 0x01);
ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01); ContestBG_FillBoxWithIncrementingTile(0, categoryTile + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01);
if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF) if (gContestEffects[gContestMoves[a].effect].appeal == INVALID_U8)
numHearts = 0; numHearts = 0;
else else
numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10; numHearts = gContestEffects[gContestMoves[a].effect].appeal / 10;
@ -2600,7 +2600,7 @@ void prints_contest_move_description(u16 a)
ContestBG_FillBoxWithTile(0, 0x5035, 0x15, 0x1f, 0x08, 0x01, 0x11); ContestBG_FillBoxWithTile(0, 0x5035, 0x15, 0x1f, 0x08, 0x01, 0x11);
ContestBG_FillBoxWithTile(0, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11); ContestBG_FillBoxWithTile(0, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11);
if (gContestEffects[gContestMoves[a].effect].jam == 0xFF) if (gContestEffects[gContestMoves[a].effect].jam == INVALID_U8)
numHearts = 0; numHearts = 0;
else else
numHearts = gContestEffects[gContestMoves[a].effect].jam / 10; numHearts = gContestEffects[gContestMoves[a].effect].jam / 10;

View File

@ -144,7 +144,7 @@ static void ContestEffect_StartleFrontMon(void)
break; break;
} }
shared192D0.jamQueue[0] = i; shared192D0.jamQueue[0] = i;
shared192D0.jamQueue[1] = 0xFF; shared192D0.jamQueue[1] = INVALID_U8;
idx = WasAtLeastOneOpponentJammed(); idx = WasAtLeastOneOpponentJammed();
} }
if (idx == 0) if (idx == 0)
@ -168,7 +168,7 @@ static void ContestEffect_StartlePrevMons(void)
shared192D0.jamQueue[j++] = i; shared192D0.jamQueue[j++] = i;
} }
shared192D0.jamQueue[j] = 0xFF; shared192D0.jamQueue[j] = INVALID_U8;
idx = WasAtLeastOneOpponentJammed(); idx = WasAtLeastOneOpponentJammed();
} }
if (idx == 0) if (idx == 0)
@ -211,7 +211,7 @@ static void ContestEffect_StartlePrevMons2(void)
u8 rval, jam; u8 rval, jam;
shared192D0.jamQueue[0] = i; shared192D0.jamQueue[0] = i;
shared192D0.jamQueue[1] = 0xFF; shared192D0.jamQueue[1] = INVALID_U8;
rval = Random() % 10; rval = Random() % 10;
if (rval == 0) if (rval == 0)
@ -288,7 +288,7 @@ static void ContestEffect_StartleMonWithJudgesAttention(void)
else else
shared192D0.jam = 10; shared192D0.jam = 10;
shared192D0.jamQueue[0] = i; shared192D0.jamQueue[0] = i;
shared192D0.jamQueue[1] = 0xFF; shared192D0.jamQueue[1] = INVALID_U8;
if (WasAtLeastOneOpponentJammed()) if (WasAtLeastOneOpponentJammed())
numStartled++; numStartled++;
} }
@ -393,7 +393,7 @@ static void ContestEffect_MakeFollowingMonsNervous(void)
s16 oddsMod[4]; s16 oddsMod[4];
s16 odds[4]; s16 odds[4];
memset(contestantIds, 0xFF, ARRAY_COUNT(contestantIds)); memset(contestantIds, INVALID_U8, ARRAY_COUNT(contestantIds));
for (i = 0, numAfter = 0; i < 4; i++) for (i = 0, numAfter = 0; i < 4; i++)
{ {
if (shared192D0.turnOrder[shared192D0.contestant] < shared192D0.turnOrder[i] && if (shared192D0.turnOrder[shared192D0.contestant] < shared192D0.turnOrder[i] &&
@ -431,7 +431,7 @@ static void ContestEffect_MakeFollowingMonsNervous(void)
} }
if (odds[0] != 0) if (odds[0] != 0)
{ {
for (i = 0; contestantIds[i] != 0xFF; i++) for (i = 0; contestantIds[i] != INVALID_U8; i++)
{ {
if (Random() % 100 < odds[i] + oddsMod[contestantIds[i]]) if (Random() % 100 < odds[i] + oddsMod[contestantIds[i]])
{ {
@ -504,7 +504,7 @@ static void ContestEffect_BadlyStartlesMonsInGoodCondition(void)
else else
shared192D0.jam = 10; shared192D0.jam = 10;
shared192D0.jamQueue[0] = i; shared192D0.jamQueue[0] = i;
shared192D0.jamQueue[1] = 0xFF; shared192D0.jamQueue[1] = INVALID_U8;
if (WasAtLeastOneOpponentJammed()) if (WasAtLeastOneOpponentJammed())
numHit++; numHit++;
} }
@ -755,7 +755,7 @@ static void ContestEffect_NextAppealEarlier(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
turnOrder[i] = sContestantStatus[i].nextTurnOrder; turnOrder[i] = sContestantStatus[i].nextTurnOrder;
turnOrder[shared192D0.contestant] = 0xFF; turnOrder[shared192D0.contestant] = INVALID_U8;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
@ -797,7 +797,7 @@ static void ContestEffect_NextAppealLater(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
turnOrder[i] = sContestantStatus[i].nextTurnOrder; turnOrder[i] = sContestantStatus[i].nextTurnOrder;
turnOrder[shared192D0.contestant] = 0xFF; turnOrder[shared192D0.contestant] = INVALID_U8;
for (i = 3; i > -1; i--) for (i = 3; i > -1; i--)
{ {
@ -855,12 +855,12 @@ static void ContestEffect_ScrambleNextTurnOrder(void)
for (j = 0; j < 4; j++) for (j = 0; j < 4; j++)
{ {
if (unselectedContestants[j] != 0xFF) if (unselectedContestants[j] != INVALID_U8)
{ {
if (rval == 0) if (rval == 0)
{ {
turnOrder[j] = i; turnOrder[j] = i;
unselectedContestants[j] = 0xFF; unselectedContestants[j] = INVALID_U8;
break; break;
} }
else else
@ -906,7 +906,7 @@ static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void)
else else
shared192D0.jam = 10; shared192D0.jam = 10;
shared192D0.jamQueue[0] = i; shared192D0.jamQueue[0] = i;
shared192D0.jamQueue[1] = 0xFF; shared192D0.jamQueue[1] = INVALID_U8;
if (WasAtLeastOneOpponentJammed()) if (WasAtLeastOneOpponentJammed())
numJammed++; numJammed++;
} }
@ -974,7 +974,7 @@ static void JamByMoveCategory(u8 category)
else else
shared192D0.jam = 10; shared192D0.jam = 10;
shared192D0.jamQueue[0] = i; shared192D0.jamQueue[0] = i;
shared192D0.jamQueue[1] = 0xFF; shared192D0.jamQueue[1] = INVALID_U8;
if (WasAtLeastOneOpponentJammed()) if (WasAtLeastOneOpponentJammed())
numJammed++; numJammed++;
} }
@ -1013,7 +1013,7 @@ static bool8 WasAtLeastOneOpponentJammed(void)
s16 jamBuffer[4] = {0}; s16 jamBuffer[4] = {0};
int i; int i;
for (i = 0; shared192D0.jamQueue[i] != 0xFF; i++) for (i = 0; shared192D0.jamQueue[i] != INVALID_U8; i++)
{ {
u8 contestant = shared192D0.jamQueue[i]; u8 contestant = shared192D0.jamQueue[i];
if (CanUnnerveContestant(contestant)) if (CanUnnerveContestant(contestant))

View File

@ -3,7 +3,7 @@
#include "main.h" #include "main.h"
#include "task.h" #include "task.h"
#include "bg.h" #include "bg.h"
#include "malloc.h" #include "alloc.h"
#include "window.h" #include "window.h"
#include "text.h" #include "text.h"
#include "menu.h" #include "menu.h"

View File

@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
#include "data2.h" #include "data2.h"
#include "graphics.h" #include "graphics.h"
#include "malloc.h" #include "alloc.h"
#include "constants/species.h" #include "constants/species.h"
const u16 gUnknown_082FF1D8[] = INCBIN_U16("graphics/link/minigame_digits.gbapal"); const u16 gUnknown_082FF1D8[] = INCBIN_U16("graphics/link/minigame_digits.gbapal");

View File

@ -251,7 +251,7 @@ static void ApplyDaycareExperience(struct Pokemon *mon)
while ((learnedMove = MonTryLearningNewMove(mon, firstMove)) != 0) while ((learnedMove = MonTryLearningNewMove(mon, firstMove)) != 0)
{ {
firstMove = FALSE; firstMove = FALSE;
if (learnedMove == 0xFFFF) if (learnedMove == INVALID_U16)
{ {
// Mon already knows 4 moves. // Mon already knows 4 moves.
DeleteFirstMoveAndGiveMoveToMon(mon, gMoveToLearn); DeleteFirstMoveAndGiveMoveToMon(mon, gMoveToLearn);
@ -535,7 +535,7 @@ static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv)
s32 i, j; s32 i, j;
u8 temp[NUM_STATS]; u8 temp[NUM_STATS];
ivs[selectedIv] = 0xff; ivs[selectedIv] = INVALID_U8;
for (i = 0; i < NUM_STATS; i++) for (i = 0; i < NUM_STATS; i++)
{ {
temp[i] = ivs[i]; temp[i] = ivs[i];
@ -544,7 +544,7 @@ static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv)
j = 0; j = 0;
for (i = 0; i < NUM_STATS; i++) for (i = 0; i < NUM_STATS; i++)
{ {
if (temp[i] != 0xff) if (temp[i] != INVALID_U8)
ivs[j++] = temp[i]; ivs[j++] = temp[i];
} }
} }
@ -684,7 +684,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru
{ {
if (sHatchedEggFatherMoves[i] == sHatchedEggEggMoves[j]) if (sHatchedEggFatherMoves[i] == sHatchedEggEggMoves[j])
{ {
if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == 0xffff) if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == INVALID_U16)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]); DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]);
break; break;
} }
@ -703,7 +703,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru
{ {
if (sHatchedEggFatherMoves[i] == ItemIdToBattleMoveId(ITEM_TM01_FOCUS_PUNCH + j) && CanMonLearnTMHM(egg, j)) if (sHatchedEggFatherMoves[i] == ItemIdToBattleMoveId(ITEM_TM01_FOCUS_PUNCH + j) && CanMonLearnTMHM(egg, j))
{ {
if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == 0xffff) if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == INVALID_U16)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]); DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]);
} }
} }
@ -728,7 +728,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru
{ {
if (sHatchedEggLevelUpMoves[j] != MOVE_NONE && sHatchedEggFinalMoves[i] == sHatchedEggLevelUpMoves[j]) if (sHatchedEggLevelUpMoves[j] != MOVE_NONE && sHatchedEggFinalMoves[i] == sHatchedEggLevelUpMoves[j])
{ {
if (GiveMoveToMon(egg, sHatchedEggFinalMoves[i]) == 0xffff) if (GiveMoveToMon(egg, sHatchedEggFinalMoves[i]) == INVALID_U16)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFinalMoves[i]); DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFinalMoves[i]);
break; break;
} }
@ -773,7 +773,7 @@ static void GiveVoltTackleIfLightBall(struct Pokemon *mon, struct DayCare *dayca
if (motherItem == ITEM_LIGHT_BALL || fatherItem == ITEM_LIGHT_BALL) if (motherItem == ITEM_LIGHT_BALL || fatherItem == ITEM_LIGHT_BALL)
{ {
if (GiveMoveToMon(mon, MOVE_VOLT_TACKLE) == 0xFFFF) if (GiveMoveToMon(mon, MOVE_VOLT_TACKLE) == INVALID_U16)
DeleteFirstMoveAndGiveMoveToMon(mon, MOVE_VOLT_TACKLE); DeleteFirstMoveAndGiveMoveToMon(mon, MOVE_VOLT_TACKLE);
} }
} }
@ -909,7 +909,7 @@ static bool8 _DoEggActions_CheckHatch(struct DayCare *daycare)
} }
// try to trigger poke sex // try to trigger poke sex
if (daycare->offspringPersonality == 0 && validEggs == 2 && (daycare->mons[1].steps & 0xFF) == 0xFF) if (daycare->offspringPersonality == 0 && validEggs == 2 && (daycare->mons[1].steps & 0xFF) == INVALID_U8)
{ {
u8 loveScore = GetDaycareCompatibilityScore(daycare); u8 loveScore = GetDaycareCompatibilityScore(daycare);
if (loveScore > (Random() * 100u) / USHRT_MAX) if (loveScore > (Random() * 100u) / USHRT_MAX)

View File

@ -2,7 +2,7 @@
#include "decompress.h" #include "decompress.h"
#include "constants/species.h" #include "constants/species.h"
#include "text.h" #include "text.h"
#include "malloc.h" #include "alloc.h"
#include "pokemon.h" #include "pokemon.h"
EWRAM_DATA ALIGNED(4) u8 gDecompressionBuffer[0x4000] = {0}; EWRAM_DATA ALIGNED(4) u8 gDecompressionBuffer[0x4000] = {0};

View File

@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
#include "constants/decorations.h" #include "constants/decorations.h"
#include "decompress.h" #include "decompress.h"
#include "malloc.h" #include "alloc.h"
#include "text.h" #include "text.h"
#include "string_util.h" #include "string_util.h"
#include "international_string_util.h" #include "international_string_util.h"
@ -312,7 +312,7 @@ const struct SpriteFrameImage sDecorSelectorSpriteFrameImages = {
}; };
const struct SpriteTemplate sDecorSelectorSpriteTemplate = { const struct SpriteTemplate sDecorSelectorSpriteTemplate = {
0xffff, INVALID_U16,
OVERWORLD_PLACE_DECOR_SELECTOR_PAL_TAG, OVERWORLD_PLACE_DECOR_SELECTOR_PAL_TAG,
&sDecorSelectorOam, &sDecorSelectorOam,
sDecorSelectorAnims, sDecorSelectorAnims,
@ -409,7 +409,7 @@ const struct SpriteFrameImage Unknown_085A73FC = {
}; };
const struct SpriteTemplate gUnknown_085A7404 = { const struct SpriteTemplate gUnknown_085A7404 = {
0xFFFF, INVALID_U16,
OVERWORLD_PLACE_DECOR_PLAYER_PAL_TAG, OVERWORLD_PLACE_DECOR_PLAYER_PAL_TAG,
&Unknown_085A73E8, &Unknown_085A73E8,
Unknown_085A73F8, Unknown_085A73F8,
@ -881,7 +881,7 @@ void sub_81274A0(u8 a0, s32 a1, u8 a2)
void sub_8127500(void) void sub_8127500(void)
{ {
if (sDecorPCBuffer->unk_522 == 0xFF) if (sDecorPCBuffer->unk_522 == INVALID_U8)
{ {
sDecorPCBuffer->unk_522 = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0x3c, 0x0c, 0x94, sDecorPCBuffer->unk_520 - sDecorPCBuffer->unk_521, 0x6e, 0x6e, &sSecretBasePCSelectDecorPageNo); sDecorPCBuffer->unk_522 = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0x3c, 0x0c, 0x94, sDecorPCBuffer->unk_520 - sDecorPCBuffer->unk_521, 0x6e, 0x6e, &sSecretBasePCSelectDecorPageNo);
} }
@ -889,10 +889,10 @@ void sub_8127500(void)
void sub_8127554(void) void sub_8127554(void)
{ {
if (sDecorPCBuffer->unk_522 != 0xFF) if (sDecorPCBuffer->unk_522 != INVALID_U8)
{ {
RemoveScrollIndicatorArrowPair(sDecorPCBuffer->unk_522); RemoveScrollIndicatorArrowPair(sDecorPCBuffer->unk_522);
sDecorPCBuffer->unk_522 = 0xFF; sDecorPCBuffer->unk_522 = INVALID_U8;
} }
} }
@ -910,7 +910,7 @@ void sub_812759C(u8 taskId)
sub_81269D4(3); sub_81269D4(3);
sub_8127718(sCurDecorationCategory); sub_8127718(sCurDecorationCategory);
sDecorPCBuffer = calloc(1, sizeof(struct DecorPCBuffer)); sDecorPCBuffer = calloc(1, sizeof(struct DecorPCBuffer));
sDecorPCBuffer->unk_522 = 0xFF; sDecorPCBuffer->unk_522 = INVALID_U8;
sub_8127284(); sub_8127284();
sub_81272C8(); sub_81272C8();
sub_81272F8(); sub_81272F8();
@ -1188,7 +1188,7 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
v0 = 0; v0 = 0;
} }
v1 = sub_8127B54(gDecorations[decor].id, i * decWidth + j); v1 = sub_8127B54(gDecorations[decor].id, i * decWidth + j);
if (v1 != 0xFFFF) if (v1 != INVALID_U16)
{ {
MapGridSetMetatileEntryAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | flags | v1); MapGridSetMetatileEntryAt(decLeft, decBottom, (gDecorations[decor].tiles[i * decWidth + j] + (0x200 | v0)) | flags | v1);
} }

View File

@ -3,7 +3,7 @@
#include "easy_chat.h" #include "easy_chat.h"
#include "event_data.h" #include "event_data.h"
#include "link.h" #include "link.h"
#include "malloc.h" #include "alloc.h"
#include "random.h" #include "random.h"
#include "text.h" #include "text.h"
#include "tv.h" #include "tv.h"

View File

@ -5,7 +5,7 @@
#include "gpu_regs.h" #include "gpu_regs.h"
#include "scanline_effect.h" #include "scanline_effect.h"
#include "task.h" #include "task.h"
#include "malloc.h" #include "alloc.h"
#include "decompress.h" #include "decompress.h"
#include "bg.h" #include "bg.h"
#include "window.h" #include "window.h"

View File

@ -1,7 +1,7 @@
// Includes // Includes
#include "global.h" #include "global.h"
#include "malloc.h" #include "alloc.h"
#include "constants/songs.h" #include "constants/songs.h"
#include "sound.h" #include "sound.h"
#include "overworld.h" #include "overworld.h"

View File

@ -17,7 +17,7 @@
#include "menu.h" #include "menu.h"
#include "trig.h" #include "trig.h"
#include "random.h" #include "random.h"
#include "malloc.h" #include "alloc.h"
#include "dma3.h" #include "dma3.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "bg.h" #include "bg.h"

View File

@ -9,7 +9,7 @@
#include "field_effect_helpers.h" #include "field_effect_helpers.h"
#include "field_player_avatar.h" #include "field_player_avatar.h"
#include "fieldmap.h" #include "fieldmap.h"
#include "malloc.h" #include "alloc.h"
#include "mauville_old_man.h" #include "mauville_old_man.h"
#include "metatile_behavior.h" #include "metatile_behavior.h"
#include "overworld.h" #include "overworld.h"
@ -129,7 +129,7 @@ static void UpdateEventObjectSpriteSubpriorityAndVisibility(struct Sprite *);
const u8 gReflectionEffectPaletteMap[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0}; const u8 gReflectionEffectPaletteMap[] = {1, 1, 6, 7, 8, 9, 6, 7, 8, 9, 11, 11, 0, 0, 0, 0};
const struct SpriteTemplate gCameraSpriteTemplate = {0, 0xFFFF, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, ObjectCB_CameraObject}; const struct SpriteTemplate gCameraSpriteTemplate = {0, INVALID_U16, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, ObjectCB_CameraObject};
void (*const gCameraObjectFuncs[])(struct Sprite *) = { void (*const gCameraObjectFuncs[])(struct Sprite *) = {
CameraObject_0, CameraObject_0,
@ -1093,10 +1093,10 @@ const u8 gUnknown_0850DC3F[][4] = {
static void ClearEventObject(struct EventObject *eventObject) static void ClearEventObject(struct EventObject *eventObject)
{ {
*eventObject = (struct EventObject){}; *eventObject = (struct EventObject){};
eventObject->localId = 0xFF; eventObject->localId = INVALID_U8;
eventObject->mapNum = 0xFF; eventObject->mapNum = INVALID_U8;
eventObject->mapGroup = 0xFF; eventObject->mapGroup = INVALID_U8;
eventObject->movementActionId = 0xFF; eventObject->movementActionId = INVALID_U8;
} }
static void ClearAllEventObjects(void) static void ClearAllEventObjects(void)
@ -1537,7 +1537,7 @@ static u8 TrySetupEventObjectSprite(struct EventObjectTemplate *eventObjectTempl
{ {
eventObject->invisible = TRUE; eventObject->invisible = TRUE;
} }
*(u16 *)&spriteTemplate->paletteTag = 0xFFFF; *(u16 *)&spriteTemplate->paletteTag = INVALID_U16;
spriteId = CreateSprite(spriteTemplate, 0, 0, 0); spriteId = CreateSprite(spriteTemplate, 0, 0, 0);
if (spriteId == MAX_SPRITES) if (spriteId == MAX_SPRITES)
{ {
@ -1666,7 +1666,7 @@ u8 AddPseudoEventObject(u16 graphicsId, void (*callback)(struct Sprite *), s16 x
spriteTemplate = malloc(sizeof(struct SpriteTemplate)); spriteTemplate = malloc(sizeof(struct SpriteTemplate));
MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, callback, spriteTemplate, &subspriteTables); MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, callback, spriteTemplate, &subspriteTables);
if (spriteTemplate->paletteTag != 0xFFFF) if (spriteTemplate->paletteTag != INVALID_U16)
{ {
LoadEventObjectPalette(spriteTemplate->paletteTag); LoadEventObjectPalette(spriteTemplate->paletteTag);
} }
@ -1692,7 +1692,7 @@ u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction)
graphicsInfo = GetEventObjectGraphicsInfo(graphicsId); graphicsInfo = GetEventObjectGraphicsInfo(graphicsId);
MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, UpdateEventObjectSpriteSubpriorityAndVisibility, &spriteTemplate, &subspriteTables); MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, UpdateEventObjectSpriteSubpriorityAndVisibility, &spriteTemplate, &subspriteTables);
*(u16 *)&spriteTemplate.paletteTag = 0xFFFF; *(u16 *)&spriteTemplate.paletteTag = INVALID_U16;
x += 7; x += 7;
y += 7; y += 7;
sub_80930E0(&x, &y, 8, 16); sub_80930E0(&x, &y, 8, 16);
@ -1849,7 +1849,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y)
spriteFrameImage.size = graphicsInfo->size; spriteFrameImage.size = graphicsInfo->size;
MakeObjectTemplateFromEventObjectGraphicsInfoWithCallbackIndex(eventObject->graphicsId, eventObject->movementType, &spriteTemplate, &subspriteTables); MakeObjectTemplateFromEventObjectGraphicsInfoWithCallbackIndex(eventObject->graphicsId, eventObject->movementType, &spriteTemplate, &subspriteTables);
spriteTemplate.images = &spriteFrameImage; spriteTemplate.images = &spriteFrameImage;
*(u16 *)&spriteTemplate.paletteTag = 0xFFFF; *(u16 *)&spriteTemplate.paletteTag = INVALID_U16;
paletteSlot = graphicsInfo->paletteSlot; paletteSlot = graphicsInfo->paletteSlot;
if (paletteSlot == 0) if (paletteSlot == 0)
{ {
@ -1864,7 +1864,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y)
paletteSlot -= 16; paletteSlot -= 16;
sub_808EAB0(graphicsInfo->paletteTag1, paletteSlot); sub_808EAB0(graphicsInfo->paletteTag1, paletteSlot);
} }
*(u16 *)&spriteTemplate.paletteTag = 0xFFFF; *(u16 *)&spriteTemplate.paletteTag = INVALID_U16;
spriteId = CreateSprite(&spriteTemplate, 0, 0, 0); spriteId = CreateSprite(&spriteTemplate, 0, 0, 0);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
{ {
@ -2146,9 +2146,9 @@ void Unused_LoadEventObjectPaletteSet(u16 *paletteTags)
static u8 sub_808E8F4(const struct SpritePalette *spritePalette) static u8 sub_808E8F4(const struct SpritePalette *spritePalette)
{ {
if (IndexOfSpritePaletteTag(spritePalette->tag) != 0xFF) if (IndexOfSpritePaletteTag(spritePalette->tag) != INVALID_U8)
{ {
return 0xFF; return INVALID_U8;
} }
return LoadSpritePalette(spritePalette); return LoadSpritePalette(spritePalette);
} }
@ -2181,7 +2181,7 @@ static u8 FindEventObjectPaletteIndexByTag(u16 tag)
return i; return i;
} }
} }
return 0xFF; return INVALID_U8;
} }
void LoadPlayerObjectReflectionPalette(u16 tag, u8 slot) void LoadPlayerObjectReflectionPalette(u16 tag, u8 slot)
@ -2513,7 +2513,7 @@ u8 sub_808F080(u8 localId, u8 mapNum, u8 mapGroup)
if (TryGetEventObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &eventObjectId)) if (TryGetEventObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &eventObjectId))
{ {
return 0xFF; return INVALID_U8;
} }
return gEventObjects[eventObjectId].trainerType; return gEventObjects[eventObjectId].trainerType;
} }
@ -2529,7 +2529,7 @@ u8 sub_808F0D4(u8 localId, u8 mapNum, u8 mapGroup)
if (TryGetEventObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &eventObjectId)) if (TryGetEventObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &eventObjectId))
{ {
return 0xFF; return INVALID_U8;
} }
return gEventObjects[eventObjectId].trainerRange_berryTreeId; return gEventObjects[eventObjectId].trainerRange_berryTreeId;
} }
@ -4374,7 +4374,7 @@ bool8 MovementType_CopyPlayer_Step0(struct EventObject *eventObject, struct Spri
bool8 MovementType_CopyPlayer_Step1(struct EventObject *eventObject, struct Sprite *sprite) bool8 MovementType_CopyPlayer_Step1(struct EventObject *eventObject, struct Sprite *sprite)
{ {
if (gEventObjects[gPlayerAvatar.eventObjectId].movementActionId == 0xFF || gPlayerAvatar.tileTransitionState == T_TILE_CENTER) if (gEventObjects[gPlayerAvatar.eventObjectId].movementActionId == INVALID_U8 || gPlayerAvatar.tileTransitionState == T_TILE_CENTER)
{ {
return FALSE; return FALSE;
} }
@ -4553,7 +4553,7 @@ movement_type_def(MovementType_CopyPlayerInGrass, gMovementTypeFuncs_CopyPlayerI
bool8 MovementType_CopyPlayerInGrass_Step1(struct EventObject *eventObject, struct Sprite *sprite) bool8 MovementType_CopyPlayerInGrass_Step1(struct EventObject *eventObject, struct Sprite *sprite)
{ {
if (gEventObjects[gPlayerAvatar.eventObjectId].movementActionId == 0xFF || gPlayerAvatar.tileTransitionState == T_TILE_CENTER) if (gEventObjects[gPlayerAvatar.eventObjectId].movementActionId == INVALID_U8 || gPlayerAvatar.tileTransitionState == T_TILE_CENTER)
{ {
return FALSE; return FALSE;
} }
@ -4699,7 +4699,7 @@ static void ClearEventObjectMovement(struct EventObject *eventObject, struct Spr
eventObject->singleMovementActive = 0; eventObject->singleMovementActive = 0;
eventObject->heldMovementActive = FALSE; eventObject->heldMovementActive = FALSE;
eventObject->heldMovementFinished = FALSE; eventObject->heldMovementFinished = FALSE;
eventObject->movementActionId = 0xFF; eventObject->movementActionId = INVALID_U8;
sprite->data[1] = 0; sprite->data[1] = 0;
} }
@ -5105,7 +5105,7 @@ bool8 EventObjectIsMovementOverridden(struct EventObject *eventObject)
bool8 EventObjectIsHeldMovementActive(struct EventObject *eventObject) bool8 EventObjectIsHeldMovementActive(struct EventObject *eventObject)
{ {
if (eventObject->heldMovementActive && eventObject->movementActionId != 0xFF) if (eventObject->heldMovementActive && eventObject->movementActionId != INVALID_U8)
return TRUE; return TRUE;
return FALSE; return FALSE;
@ -5138,7 +5138,7 @@ void EventObjectClearHeldMovementIfActive(struct EventObject *eventObject)
void EventObjectClearHeldMovement(struct EventObject *eventObject) void EventObjectClearHeldMovement(struct EventObject *eventObject)
{ {
eventObject->movementActionId = 0xFF; eventObject->movementActionId = INVALID_U8;
eventObject->heldMovementActive = FALSE; eventObject->heldMovementActive = FALSE;
eventObject->heldMovementFinished = FALSE; eventObject->heldMovementFinished = FALSE;
gSprites[eventObject->spriteId].data[1] = 0; gSprites[eventObject->spriteId].data[1] = 0;
@ -5167,7 +5167,7 @@ u8 EventObjectGetHeldMovementActionId(struct EventObject *eventObject)
if (eventObject->heldMovementActive) if (eventObject->heldMovementActive)
return eventObject->movementActionId; return eventObject->movementActionId;
return 0xFF; return INVALID_U8;
} }
void UpdateEventObjectCurrentMovement(struct EventObject *eventObject, struct Sprite *sprite, bool8 (*callback)(struct EventObject *, struct Sprite *)) void UpdateEventObjectCurrentMovement(struct EventObject *eventObject, struct Sprite *sprite, bool8 (*callback)(struct EventObject *, struct Sprite *))
@ -5279,7 +5279,7 @@ static bool8 EventObjectExecSingleMovementAction(struct EventObject *eventObject
{ {
if (gMovementActionFuncs[eventObject->movementActionId][sprite->data[2]](eventObject, sprite)) if (gMovementActionFuncs[eventObject->movementActionId][sprite->data[2]](eventObject, sprite))
{ {
eventObject->movementActionId = 0xFF; eventObject->movementActionId = INVALID_U8;
sprite->data[2] = 0; sprite->data[2] = 0;
return TRUE; return TRUE;
} }
@ -5706,7 +5706,7 @@ u8 sub_80940C4(struct EventObject *eventObject, struct Sprite *sprite, u8 callba
eventObject->triggerGroundEffectsOnMove = TRUE; eventObject->triggerGroundEffectsOnMove = TRUE;
eventObject->disableCoveringGroundEffects = TRUE; eventObject->disableCoveringGroundEffects = TRUE;
} }
else if (result == 0xFF) else if (result == INVALID_U8)
{ {
ShiftStillEventObjectCoords(eventObject); ShiftStillEventObjectCoords(eventObject);
eventObject->triggerGroundEffectsOnStop = TRUE; eventObject->triggerGroundEffectsOnStop = TRUE;
@ -5728,7 +5728,7 @@ u8 sub_809419C(struct EventObject *eventObject, struct Sprite *sprite)
bool8 sub_80941B0(struct EventObject *eventObject, struct Sprite *sprite) bool8 sub_80941B0(struct EventObject *eventObject, struct Sprite *sprite)
{ {
if (sub_8094188(eventObject, sprite) == 0xFF) if (sub_8094188(eventObject, sprite) == INVALID_U8)
{ {
return TRUE; return TRUE;
} }
@ -5737,7 +5737,7 @@ bool8 sub_80941B0(struct EventObject *eventObject, struct Sprite *sprite)
bool8 sub_80941C8(struct EventObject *eventObject, struct Sprite *sprite) bool8 sub_80941C8(struct EventObject *eventObject, struct Sprite *sprite)
{ {
if (sub_809419C(eventObject, sprite) == 0xFF) if (sub_809419C(eventObject, sprite) == INVALID_U8)
{ {
return TRUE; return TRUE;
} }
@ -9122,7 +9122,7 @@ void CreateLevitateMovementTask(struct EventObject *eventObject)
StoreWordInTwoHalfwords(&task->data[0], (u32)eventObject); StoreWordInTwoHalfwords(&task->data[0], (u32)eventObject);
eventObject->warpArrowSpriteId = taskId; eventObject->warpArrowSpriteId = taskId;
task->data[3] = 0xFFFF; task->data[3] = INVALID_U16;
} }
static void ApplyLevitateMovement(u8 taskId) static void ApplyLevitateMovement(u8 taskId)

View File

@ -2,7 +2,7 @@
#include "evolution_scene.h" #include "evolution_scene.h"
#include "evolution_graphics.h" #include "evolution_graphics.h"
#include "sprite.h" #include "sprite.h"
#include "malloc.h" #include "alloc.h"
#include "task.h" #include "task.h"
#include "palette.h" #include "palette.h"
#include "main.h" #include "main.h"
@ -748,7 +748,7 @@ static void Task_EvolutionScene(u8 taskID)
GetMonData(mon, MON_DATA_NICKNAME, text); GetMonData(mon, MON_DATA_NICKNAME, text);
StringCopy10(gBattleTextBuff1, text); StringCopy10(gBattleTextBuff1, text);
if (var == 0xFFFF) // no place to learn it if (var == INVALID_U16) // no place to learn it
gTasks[taskID].tState = 22; gTasks[taskID].tState = 22;
else if (var == 0xFFFE) // it already knows that move else if (var == 0xFFFE) // it already knows that move
break; break;
@ -1105,7 +1105,7 @@ static void Task_TradeEvolutionScene(u8 taskID)
GetMonData(mon, MON_DATA_NICKNAME, text); GetMonData(mon, MON_DATA_NICKNAME, text);
StringCopy10(gBattleTextBuff1, text); StringCopy10(gBattleTextBuff1, text);
if (var == 0xFFFF) if (var == INVALID_U16)
gTasks[taskID].tState = 20; gTasks[taskID].tState = 20;
else if (var == 0xFFFE) else if (var == 0xFFFE)
break; break;

View File

@ -266,7 +266,7 @@ const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatil
else else
eventObjectId = GetEventObjectIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height); eventObjectId = GetEventObjectIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF) if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == INVALID_U8)
return NULL; return NULL;
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
@ -287,14 +287,14 @@ static const u8 *GetInteractedEventObjectScript(struct MapPosition *position, u8
const u8 *script; const u8 *script;
eventObjectId = GetEventObjectIdByXYZ(position->x, position->y, position->height); eventObjectId = GetEventObjectIdByXYZ(position->x, position->y, position->height);
if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF) if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == INVALID_U8)
{ {
if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE) if (MetatileBehavior_IsCounter(metatileBehavior) != TRUE)
return NULL; return NULL;
// Look for an event object on the other side of the counter. // Look for an event object on the other side of the counter.
eventObjectId = GetEventObjectIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height); eventObjectId = GetEventObjectIdByXYZ(position->x + gDirectionToVectors[direction].x, position->y + gDirectionToVectors[direction].y, position->height);
if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF) if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == INVALID_U8)
return NULL; return NULL;
} }

View File

@ -695,7 +695,7 @@ static void DrawClosedDoorTiles(const struct DoorGraphics *gfx, u32 x, u32 y)
static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame *frame, u32 x, u32 y) static void DrawDoor(const struct DoorGraphics *gfx, const struct DoorAnimFrame *frame, u32 x, u32 y)
{ {
if (frame->offset == 0xFFFF) if (frame->offset == INVALID_U16)
{ {
DrawClosedDoorTiles(gfx, x, y); DrawClosedDoorTiles(gfx, x, y);
if (sub_808A964()) if (sub_808A964())

View File

@ -305,7 +305,7 @@ const union AnimCmd *const gNewGameBirchImageAnimTable[] = {
}; };
const struct SpriteTemplate gNewGameBirchObjectTemplate = { const struct SpriteTemplate gNewGameBirchObjectTemplate = {
.tileTag = 0xffff, .tileTag = INVALID_U16,
.paletteTag = 4102, .paletteTag = 4102,
.oam = &gNewGameBirchOamAttributes, .oam = &gNewGameBirchOamAttributes,
.anims = gNewGameBirchImageAnimTable, .anims = gNewGameBirchImageAnimTable,
@ -383,7 +383,7 @@ const union AnimCmd *const gSpriteAnimTable_855C300[] = {
}; };
const struct SpriteTemplate gSpriteTemplate_855C304 = { const struct SpriteTemplate gSpriteTemplate_855C304 = {
.tileTag = 0xffff, .tileTag = INVALID_U16,
.paletteTag = 4103, .paletteTag = 4103,
.oam = &gOamData_855C218, .oam = &gOamData_855C218,
.anims = gSpriteAnimTable_855C2F8, .anims = gSpriteAnimTable_855C2F8,
@ -393,7 +393,7 @@ const struct SpriteTemplate gSpriteTemplate_855C304 = {
}; };
const struct SpriteTemplate gSpriteTemplate_855C31C = { const struct SpriteTemplate gSpriteTemplate_855C31C = {
.tileTag = 0xffff, .tileTag = INVALID_U16,
.paletteTag = 4100, .paletteTag = 4100,
.oam = &gOamData_855C220, .oam = &gOamData_855C220,
.anims = gSpriteAnimTable_855C2F8, .anims = gSpriteAnimTable_855C2F8,
@ -403,7 +403,7 @@ const struct SpriteTemplate gSpriteTemplate_855C31C = {
}; };
const struct SpriteTemplate gSpriteTemplate_855C334 = { const struct SpriteTemplate gSpriteTemplate_855C334 = {
.tileTag = 0xffff, .tileTag = INVALID_U16,
.paletteTag = 4112, .paletteTag = 4112,
.oam = &gOamData_855C220, .oam = &gOamData_855C220,
.anims = gSpriteAnimTable_855C300, .anims = gSpriteAnimTable_855C300,
@ -413,7 +413,7 @@ const struct SpriteTemplate gSpriteTemplate_855C334 = {
}; };
const struct SpriteTemplate gSpriteTemplate_855C34C = { const struct SpriteTemplate gSpriteTemplate_855C34C = {
.tileTag = 0xffff, .tileTag = INVALID_U16,
.paletteTag = 4112, .paletteTag = 4112,
.oam = &gOamData_855C26C, .oam = &gOamData_855C26C,
.anims = gSpriteAnimTable_855C300, .anims = gSpriteAnimTable_855C300,
@ -618,7 +618,7 @@ u32 FieldEffectScript_ReadWord(u8 **script)
void FieldEffectScript_LoadTiles(u8 **script) void FieldEffectScript_LoadTiles(u8 **script)
{ {
struct SpriteSheet *sheet = (struct SpriteSheet *)FieldEffectScript_ReadWord(script); struct SpriteSheet *sheet = (struct SpriteSheet *)FieldEffectScript_ReadWord(script);
if (GetSpriteTileStartByTag(sheet->tag) == 0xFFFF) if (GetSpriteTileStartByTag(sheet->tag) == INVALID_U16)
LoadSpriteSheet(sheet); LoadSpriteSheet(sheet);
(*script) += 4; (*script) += 4;
} }
@ -665,7 +665,7 @@ void FieldEffectFreeTilesIfUnused(u16 tileStart)
u8 i; u8 i;
u16 tag = GetSpriteTileTagByTileStart(tileStart); u16 tag = GetSpriteTileTagByTileStart(tileStart);
if (tag != 0xFFFF) if (tag != INVALID_U16)
{ {
for (i = 0; i < MAX_SPRITES; i++) for (i = 0; i < MAX_SPRITES; i++)
if (gSprites[i].inUse && gSprites[i].usingSheet && tileStart == gSprites[i].sheetTileStart) if (gSprites[i].inUse && gSprites[i].usingSheet && tileStart == gSprites[i].sheetTileStart)
@ -679,7 +679,7 @@ void FieldEffectFreePaletteIfUnused(u8 paletteNum)
u8 i; u8 i;
u16 tag = GetSpritePaletteTagByPaletteNum(paletteNum); u16 tag = GetSpritePaletteTagByPaletteNum(paletteNum);
if (tag != 0xFFFF) if (tag != INVALID_U16)
{ {
for (i = 0; i < MAX_SPRITES; i++) for (i = 0; i < MAX_SPRITES; i++)
if (gSprites[i].inUse && gSprites[i].oam.paletteNum == paletteNum) if (gSprites[i].inUse && gSprites[i].oam.paletteNum == paletteNum)
@ -761,7 +761,7 @@ u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority)
{ {
s32 spriteId = CreateMonPicSprite_HandleDeoxys(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag); s32 spriteId = CreateMonPicSprite_HandleDeoxys(species, 0, 0x8000, 1, x, y, 0, gMonPaletteTable[species].tag);
PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[species].tag) + 0x10); PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[species].tag) + 0x10);
if (spriteId == 0xFFFF) if (spriteId == INVALID_U16)
return MAX_SPRITES; return MAX_SPRITES;
else else
return spriteId; return spriteId;
@ -772,7 +772,7 @@ u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subprio
const struct CompressedSpritePalette *spritePalette = GetMonSpritePalStructFromOtIdPersonality(species, d, g); const struct CompressedSpritePalette *spritePalette = GetMonSpritePalStructFromOtIdPersonality(species, d, g);
u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, d, g, 1, x, y, 0, spritePalette->tag); u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, d, g, 1, x, y, 0, spritePalette->tag);
PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10); PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10);
if (spriteId == 0xFFFF) if (spriteId == INVALID_U16)
return MAX_SPRITES; return MAX_SPRITES;
else else
return spriteId; return spriteId;
@ -3591,7 +3591,7 @@ const union AnimCmd *const gSpriteAnimTable_855C5DC[] = {
}; };
const struct SpriteTemplate gUnknown_0855C5EC = { const struct SpriteTemplate gUnknown_0855C5EC = {
.tileTag = 0xffff, .tileTag = INVALID_U16,
.paletteTag = 4378, .paletteTag = 4378,
.oam = &gOamData_855C218, .oam = &gOamData_855C218,
.anims = gSpriteAnimTable_855C5DC, .anims = gSpriteAnimTable_855C5DC,

View File

@ -53,7 +53,7 @@ void task_add_textbox(void)
void task_del_textbox(void) void task_del_textbox(void)
{ {
u8 taskId = FindTaskIdByFunc(sub_8098154); u8 taskId = FindTaskIdByFunc(sub_8098154);
if (taskId != 0xFF) if (taskId != INVALID_U8)
DestroyTask(taskId); DestroyTask(taskId);
} }

View File

@ -1389,7 +1389,7 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender)
u8 eventObjectId; u8 eventObjectId;
struct EventObject *eventObject; struct EventObject *eventObject;
playerEventObjTemplate.localId = 0xFF; playerEventObjTemplate.localId = INVALID_U8;
playerEventObjTemplate.graphicsId = GetPlayerAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, gender); playerEventObjTemplate.graphicsId = GetPlayerAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, gender);
playerEventObjTemplate.x = x - 7; playerEventObjTemplate.x = x - 7;
playerEventObjTemplate.y = y - 7; playerEventObjTemplate.y = y - 7;

View File

@ -3,7 +3,7 @@
#include "gpu_regs.h" #include "gpu_regs.h"
#include "international_string_util.h" #include "international_string_util.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "menu.h" #include "menu.h"
#include "palette.h" #include "palette.h"
#include "region_map.h" #include "region_map.h"

View File

@ -20,7 +20,7 @@
#include "link.h" #include "link.h"
#include "list_menu.h" #include "list_menu.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "match_call.h" #include "match_call.h"
#include "menu.h" #include "menu.h"
#include "overworld.h" #include "overworld.h"
@ -1957,12 +1957,12 @@ void sub_8139D98(void)
bool32 warp0_in_pokecenter(void) bool32 warp0_in_pokecenter(void)
{ {
static const u16 gUnknown_085B2C2A[] = { 0x0202, 0x0301, 0x0405, 0x0504, 0x0604, 0x0700, 0x0804, 0x090b, 0x0a05, 0x0b05, 0x0c02, 0x0d06, 0x0e03, 0x0f02, 0x100c, 0x100a, 0x1a35, 0x193c, 0xffff }; static const u16 gUnknown_085B2C2A[] = { 0x0202, 0x0301, 0x0405, 0x0504, 0x0604, 0x0700, 0x0804, 0x090b, 0x0a05, 0x0b05, 0x0c02, 0x0d06, 0x0e03, 0x0f02, 0x100c, 0x100a, 0x1a35, 0x193c, INVALID_U16 };
int i; int i;
u16 map = (gLastUsedWarp.mapGroup << 8) + gLastUsedWarp.mapNum; u16 map = (gLastUsedWarp.mapGroup << 8) + gLastUsedWarp.mapNum;
for (i = 0; gUnknown_085B2C2A[i] != 0xFFFF; i++) for (i = 0; gUnknown_085B2C2A[i] != INVALID_U16; i++)
{ {
if (gUnknown_085B2C2A[i] == map) if (gUnknown_085B2C2A[i] == map)
return TRUE; return TRUE;
@ -2946,10 +2946,10 @@ void sub_813AA44(void)
static void sub_813AA60(u16 a0, u16 a1) static void sub_813AA60(u16 a0, u16 a1)
{ {
static const u16 gUnknown_085B312C[] = { 0x004b, 0x0067, 0x0057, 0x004f, 0x0054, 0x0055, 0x0056, 0x0050, 0x0051, 0x0052, 0xffff }; static const u16 gUnknown_085B312C[] = { 0x004b, 0x0067, 0x0057, 0x004f, 0x0054, 0x0055, 0x0056, 0x0050, 0x0051, 0x0052, INVALID_U16 };
static const u16 gUnknown_085B3142[] = { 0x0071, 0x006f, 0x0072, 0x0073, 0x0074, 0xffff }; static const u16 gUnknown_085B3142[] = { 0x0071, 0x006f, 0x0072, 0x0073, 0x0074, INVALID_U16 };
static const u16 gUnknown_085B314E[] = { 0x0040, 0x0043, 0x0041, 0x0046, 0x0042, 0x003f, 0xffff }; static const u16 gUnknown_085B314E[] = { 0x0040, 0x0043, 0x0041, 0x0046, 0x0042, 0x003f, INVALID_U16 };
static const u16 gUnknown_085B315C[] = { 0x00c8, 0x00b4, 0x00b7, 0x00b9, 0x00b3, 0x00ba, 0x00bb, 0x00c4, 0x00c6, 0xffff }; static const u16 gUnknown_085B315C[] = { 0x00c8, 0x00b4, 0x00b7, 0x00b9, 0x00b3, 0x00ba, 0x00bb, 0x00c4, 0x00c6, INVALID_U16 };
static const u8 *const gUnknown_085B3170[] = { static const u8 *const gUnknown_085B3170[] = {
BattleFrontier_BattlePointExchangeServiceCorner_Text_2601AA, BattleFrontier_BattlePointExchangeServiceCorner_Text_2601AA,
@ -3004,7 +3004,7 @@ static void sub_813AA60(u16 a0, u16 a1)
{ {
case 3: case 3:
AddTextPrinterParameterized2(0, 1, gUnknown_085B3170[a1], 0, NULL, 2, 1, 3); AddTextPrinterParameterized2(0, 1, gUnknown_085B3170[a1], 0, NULL, 2, 1, 3);
if (gUnknown_085B312C[a1] == 0xFFFF) if (gUnknown_085B312C[a1] == INVALID_U16)
{ {
sub_813ABD4(gUnknown_085B312C[a1]); sub_813ABD4(gUnknown_085B312C[a1]);
} }
@ -3017,7 +3017,7 @@ static void sub_813AA60(u16 a0, u16 a1)
break; break;
case 4: case 4:
AddTextPrinterParameterized2(0, 1, gUnknown_085B319C[a1], 0, NULL, 2, 1, 3); AddTextPrinterParameterized2(0, 1, gUnknown_085B319C[a1], 0, NULL, 2, 1, 3);
if (gUnknown_085B3142[a1] == 0xFFFF) if (gUnknown_085B3142[a1] == INVALID_U16)
{ {
sub_813ABD4(gUnknown_085B3142[a1]); sub_813ABD4(gUnknown_085B3142[a1]);
} }
@ -3841,13 +3841,13 @@ bool32 sub_813B9C0(void)
MAP_TRADE_CENTER, MAP_TRADE_CENTER,
MAP_RECORD_CORNER, MAP_RECORD_CORNER,
MAP_DOUBLE_BATTLE_COLOSSEUM, MAP_DOUBLE_BATTLE_COLOSSEUM,
0xffff INVALID_U16
}; };
int i; int i;
u16 map = (gSaveBlock1Ptr->location.mapGroup << 8) + gSaveBlock1Ptr->location.mapNum; u16 map = (gSaveBlock1Ptr->location.mapGroup << 8) + gSaveBlock1Ptr->location.mapNum;
for (i = 0; gUnknown_085B3444[i] != 0xFFFF; i++) for (i = 0; gUnknown_085B3444[i] != INVALID_U16; i++)
{ {
if (gUnknown_085B3444[i] == map) if (gUnknown_085B3444[i] == map)
{ {

View File

@ -496,7 +496,7 @@ u16 GetBehaviorByMetatileId(u16 metatile)
} }
else else
{ {
return 0xff; return INVALID_U8;
} }
} }
@ -922,7 +922,7 @@ void sub_8088B94(int x, int y, int a2)
bool8 sub_8088BF0(u16* a0, u16 a1, u8 a2) bool8 sub_8088BF0(u16* a0, u16 a1, u8 a2)
{ {
if (a2 == 0xFF) if (a2 == INVALID_U8)
return FALSE; return FALSE;
if (a2 == 0) if (a2 == 0)

View File

@ -6,7 +6,7 @@
#include "field_player_avatar.h" #include "field_player_avatar.h"
#include "fieldmap.h" #include "fieldmap.h"
#include "fldeff_cut.h" #include "fldeff_cut.h"
#include "malloc.h" #include "alloc.h"
#include "metatile_behavior.h" #include "metatile_behavior.h"
#include "overworld.h" #include "overworld.h"
#include "party_menu.h" #include "party_menu.h"
@ -164,7 +164,7 @@ const struct SpritePalette gFieldEffectObjectPaletteInfo6 = {gFieldEffectObjectP
static const struct SpriteTemplate sSpriteTemplate_CutGrass = static const struct SpriteTemplate sSpriteTemplate_CutGrass =
{ {
.tileTag = 0xFFFF, .tileTag = INVALID_U16,
.paletteTag = 0x1000, .paletteTag = 0x1000,
.oam = &sOamData_CutGrass, .oam = &sOamData_CutGrass,
.anims = sSpriteAnimTable_CutGrass, .anims = sSpriteAnimTable_CutGrass,

View File

@ -2,7 +2,7 @@
#include "event_data.h" #include "event_data.h"
#include "event_object_movement.h" #include "event_object_movement.h"
#include "field_camera.h" #include "field_camera.h"
#include "malloc.h" #include "alloc.h"
#include "random.h" #include "random.h"
#include "roulette_util.h" #include "roulette_util.h"
#include "script.h" #include "script.h"
@ -236,7 +236,7 @@ static void sub_81BE968(void)
u8 taskId; u8 taskId;
taskId = FindTaskIdByFunc(sub_81BE9C0); taskId = FindTaskIdByFunc(sub_81BE9C0);
if(taskId != 0xFF) if(taskId != INVALID_U8)
gTasks[taskId].data[0]++; gTasks[taskId].data[0]++;
} }

View File

@ -8,7 +8,7 @@
#include "fieldmap.h" #include "fieldmap.h"
#include "global.fieldmap.h" #include "global.fieldmap.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "malloc.h" #include "alloc.h"
#include "menu.h" #include "menu.h"
#include "random.h" #include "random.h"
#include "script.h" #include "script.h"
@ -302,7 +302,7 @@ static void sub_81BED50(u8 taskId)
case 4: case 4:
UnsetBgTilemapBuffer(0); UnsetBgTilemapBuffer(0);
anotherTaskId = FindTaskIdByFunc(sub_81BEBB4); anotherTaskId = FindTaskIdByFunc(sub_81BEBB4);
if (anotherTaskId != 0xFF) if (anotherTaskId != INVALID_U8)
DestroyTask(anotherTaskId); DestroyTask(anotherTaskId);
sUnknown_0203CF14[1] = sUnknown_0203CF14[0] = 0; sUnknown_0203CF14[1] = sUnknown_0203CF14[0] = 0;
sub_81BEB90(); sub_81BEB90();

View File

@ -24,7 +24,7 @@
#include "data2.h" #include "data2.h"
#include "record_mixing.h" #include "record_mixing.h"
#include "strings.h" #include "strings.h"
#include "malloc.h" #include "alloc.h"
#include "save.h" #include "save.h"
#include "load_save.h" #include "load_save.h"
#include "battle_dome.h" #include "battle_dome.h"
@ -681,7 +681,7 @@ static const u8 sFacilityToBrainEventObjGfx[][2] =
const u16 gFrontierBannedSpecies[] = const u16 gFrontierBannedSpecies[] =
{ {
SPECIES_MEW, SPECIES_MEWTWO, SPECIES_HO_OH, SPECIES_LUGIA, SPECIES_CELEBI, SPECIES_MEW, SPECIES_MEWTWO, SPECIES_HO_OH, SPECIES_LUGIA, SPECIES_CELEBI,
SPECIES_KYOGRE, SPECIES_GROUDON, SPECIES_RAYQUAZA, SPECIES_JIRACHI, SPECIES_DEOXYS, 0xFFFF SPECIES_KYOGRE, SPECIES_GROUDON, SPECIES_RAYQUAZA, SPECIES_JIRACHI, SPECIES_DEOXYS, INVALID_U16
}; };
static const u8 *const gUnknown_08611CB0[][2] = static const u8 *const gUnknown_08611CB0[][2] =
@ -1829,7 +1829,7 @@ void sub_81A3ACC(void)
s32 i; s32 i;
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++)
gSaveBlock2Ptr->frontier.field_CB4[i] |= 0xFFFF; gSaveBlock2Ptr->frontier.field_CB4[i] |= INVALID_U16;
} }
static void sub_81A3B00(void) static void sub_81A3B00(void)
@ -1974,10 +1974,10 @@ static void AppendIfValid(u16 species, u16 heldItem, u16 hp, u8 lvlMode, u8 monL
if (species == SPECIES_EGG || species == SPECIES_NONE) if (species == SPECIES_EGG || species == SPECIES_NONE)
return; return;
for (i = 0; gFrontierBannedSpecies[i] != 0xFFFF && gFrontierBannedSpecies[i] != species; i++) for (i = 0; gFrontierBannedSpecies[i] != INVALID_U16 && gFrontierBannedSpecies[i] != species; i++)
; ;
if (gFrontierBannedSpecies[i] != 0xFFFF) if (gFrontierBannedSpecies[i] != INVALID_U16)
return; return;
if (lvlMode == FRONTIER_LVL_50 && monLevel > 50) if (lvlMode == FRONTIER_LVL_50 && monLevel > 50)
return; return;
@ -2060,7 +2060,7 @@ static void sub_81A3FD4(void)
s32 i; s32 i;
s32 caughtBannedMons = 0; s32 caughtBannedMons = 0;
s32 species = gFrontierBannedSpecies[0]; s32 species = gFrontierBannedSpecies[0];
for (i = 0; species != 0xFFFF; i++, species = gFrontierBannedSpecies[i]) for (i = 0; species != INVALID_U16; i++, species = gFrontierBannedSpecies[i])
{ {
if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT)) if (GetSetPokedexFlag(SpeciesToNationalPokedexNum(species), FLAG_GET_CAUGHT))
caughtBannedMons++; caughtBannedMons++;
@ -2068,7 +2068,7 @@ static void sub_81A3FD4(void)
gStringVar1[0] = EOS; gStringVar1[0] = EOS;
gSpecialVar_0x8004 = 1; gSpecialVar_0x8004 = 1;
count = 0; count = 0;
for (i = 0; gFrontierBannedSpecies[i] != 0xFFFF; i++) for (i = 0; gFrontierBannedSpecies[i] != INVALID_U16; i++)
count = sub_81A3DD0(gFrontierBannedSpecies[i], count, caughtBannedMons); count = sub_81A3DD0(gFrontierBannedSpecies[i], count, caughtBannedMons);
if (count == 0) if (count == 0)

View File

@ -588,7 +588,7 @@ void sub_81152DC(u8 taskId)
break; break;
default: default:
task->data[9] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]); task->data[9] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]);
if (task->data[9] == 0xFF) if (task->data[9] == INVALID_U8)
{ {
DestroyAnimVisualTask(taskId); DestroyAnimVisualTask(taskId);
} }

View File

@ -6,7 +6,7 @@
#include "pokemon.h" #include "pokemon.h"
#include "text.h" #include "text.h"
#include "text_window.h" #include "text_window.h"
#include "malloc.h" #include "alloc.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "graphics.h" #include "graphics.h"
#include "main.h" #include "main.h"
@ -467,11 +467,11 @@ static void Task_Hof_InitMonData(u8 taskId)
sUnknown_0203BCD4 = 0; sUnknown_0203BCD4 = 0;
gTasks[taskId].tDisplayedMonId = 0; gTasks[taskId].tDisplayedMonId = 0;
gTasks[taskId].tPlayerSpriteID = 0xFF; gTasks[taskId].tPlayerSpriteID = INVALID_U8;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
gTasks[taskId].tMonSpriteId(i) = 0xFF; gTasks[taskId].tMonSpriteId(i) = INVALID_U8;
} }
if (gTasks[taskId].tDontSaveData) if (gTasks[taskId].tDontSaveData)
@ -522,7 +522,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId)
static void Task_Hof_TrySaveData(u8 taskId) static void Task_Hof_TrySaveData(u8 taskId)
{ {
gGameContinueCallback = CB2_DoHallOfFameScreenDontSaveData; gGameContinueCallback = CB2_DoHallOfFameScreenDontSaveData;
if (TrySavingData(SAVE_HALL_OF_FAME) == 0xFF && gDamagedSaveSectors != 0) if (TrySavingData(SAVE_HALL_OF_FAME) == INVALID_U8 && gDamagedSaveSectors != 0)
{ {
UnsetBgTilemapBuffer(1); UnsetBgTilemapBuffer(1);
UnsetBgTilemapBuffer(3); UnsetBgTilemapBuffer(3);
@ -645,7 +645,7 @@ static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId)
BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, RGB_BLACK); BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, RGB_BLACK);
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (gTasks[taskId].tMonSpriteId(i) != 0xFF) if (gTasks[taskId].tMonSpriteId(i) != INVALID_U8)
gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 0; gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 0;
} }
@ -668,7 +668,7 @@ static void sub_8173DC0(u8 taskId)
u16 i; u16 i;
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
if (gTasks[taskId].tMonSpriteId(i) != 0xFF) if (gTasks[taskId].tMonSpriteId(i) != INVALID_U8)
gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1; gSprites[gTasks[taskId].tMonSpriteId(i)].oam.priority = 1;
} }
BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24)); BeginNormalPaletteFade(sUnknown_0203BCD4, 0, 12, 12, RGB(16, 29, 24));
@ -752,7 +752,7 @@ static void Task_Hof_HandleExit(u8 taskId)
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u8 spriteId = gTasks[taskId].tMonSpriteId(i); u8 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF) if (spriteId != INVALID_U8)
{ {
FreeOamMatrix(gSprites[spriteId].oam.matrixNum); FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
FreeAndDestroyMonPicSprite(spriteId); FreeAndDestroyMonPicSprite(spriteId);
@ -847,7 +847,7 @@ void CB2_DoHallOfFamePC(void)
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
gTasks[taskId].tMonSpriteId(i) = 0xFF; gTasks[taskId].tMonSpriteId(i) = INVALID_U8;
} }
sHofMonPtr = AllocZeroed(0x2000); sHofMonPtr = AllocZeroed(0x2000);
@ -937,7 +937,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
} }
else else
{ {
gTasks[taskId].tMonSpriteId(i) = 0xFF; gTasks[taskId].tMonSpriteId(i) = INVALID_U8;
} }
} }
@ -967,7 +967,7 @@ static void Task_HofPC_PrintMonInfo(u8 taskId)
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u16 spriteId = gTasks[taskId].tMonSpriteId(i); u16 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF) if (spriteId != INVALID_U8)
gSprites[spriteId].oam.priority = 1; gSprites[spriteId].oam.priority = 1;
} }
@ -999,10 +999,10 @@ static void Task_HofPC_HandleInput(u8 taskId)
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
{ {
u8 spriteId = gTasks[taskId].tMonSpriteId(i); u8 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF) if (spriteId != INVALID_U8)
{ {
FreeAndDestroyMonPicSprite(spriteId); FreeAndDestroyMonPicSprite(spriteId);
gTasks[taskId].tMonSpriteId(i) = 0xFF; gTasks[taskId].tMonSpriteId(i) = INVALID_U8;
} }
} }
if (gTasks[taskId].tCurrPageNo != 0) if (gTasks[taskId].tCurrPageNo != 0)
@ -1060,10 +1060,10 @@ static void Task_HofPC_HandleExit(u8 taskId)
for (i = 0; i < PARTY_SIZE; i++) for (i = 0; i < PARTY_SIZE; i++)
{ {
u16 spriteId = gTasks[taskId].tMonSpriteId(i); u16 spriteId = gTasks[taskId].tMonSpriteId(i);
if (spriteId != 0xFF) if (spriteId != INVALID_U8)
{ {
FreeAndDestroyMonPicSprite(spriteId); FreeAndDestroyMonPicSprite(spriteId);
gTasks[taskId].tMonSpriteId(i) = 0xFF; gTasks[taskId].tMonSpriteId(i) = INVALID_U8;
} }
} }
@ -1130,7 +1130,7 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u
{ {
stringPtr = StringCopy(text, gText_Number); stringPtr = StringCopy(text, gText_Number);
dexNumber = SpeciesToPokedexNum(currMon->species); dexNumber = SpeciesToPokedexNum(currMon->species);
if (dexNumber != 0xFFFF) if (dexNumber != INVALID_U16)
{ {
stringPtr[0] = (dexNumber / 100) + CHAR_0; stringPtr[0] = (dexNumber / 100) + CHAR_0;
stringPtr++; stringPtr++;
@ -1417,7 +1417,7 @@ void sub_8175280(void)
gSpecialVar_0x8004 = 180; gSpecialVar_0x8004 = 180;
taskId = CreateTask(sub_8175364, 0); taskId = CreateTask(sub_8175364, 0);
if (taskId != 0xFF) if (taskId != INVALID_U8)
{ {
gTasks[taskId].data[1] = gSpecialVar_0x8004; gTasks[taskId].data[1] = gSpecialVar_0x8004;
gSpecialVar_0x8005 = taskId; gSpecialVar_0x8005 = taskId;
@ -1428,7 +1428,7 @@ static void sub_81752C0(void)
{ {
u8 taskId; u8 taskId;
if ((taskId = FindTaskIdByFunc(sub_8175364)) != 0xFF) if ((taskId = FindTaskIdByFunc(sub_8175364)) != INVALID_U8)
DestroyTask(taskId); DestroyTask(taskId);
sub_8152254(); sub_8152254();
@ -1473,7 +1473,7 @@ static void sub_8175364(u8 taskId)
{ {
DestroyTask(taskId); DestroyTask(taskId);
gSpecialVar_0x8004 = var; gSpecialVar_0x8004 = var;
gSpecialVar_0x8005 = 0xFFFF; gSpecialVar_0x8005 = INVALID_U16;
} }
LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet); LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet);
LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette); LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette);
@ -1483,7 +1483,7 @@ static void sub_8175364(u8 taskId)
if (data[1] != 0 && data[1] % 3 == 0) if (data[1] != 0 && data[1] % 3 == 0)
{ {
var = sub_81524C4(&sOamData_85E53FC, 0x3E9, 0x3E9, Random() % 240, -(Random() % 8), Random() % 0x11, var); var = sub_81524C4(&sOamData_85E53FC, 0x3E9, 0x3E9, Random() % 240, -(Random() % 8), Random() % 0x11, var);
if (var != 0xFF) if (var != INVALID_U8)
{ {
sub_8152438(var, sub_81752F4); sub_8152438(var, sub_81752F4);
if ((Random() & 3) == 0) if ((Random() & 3) == 0)
@ -1496,12 +1496,12 @@ static void sub_8175364(u8 taskId)
if (data[1] != 0) if (data[1] != 0)
data[1]--; data[1]--;
else if (data[15] == 0) else if (data[15] == 0)
data[0] = 0xFF; data[0] = INVALID_U8;
break; break;
case 0xFF: case INVALID_U8:
sub_81752C0(); sub_81752C0();
gSpecialVar_0x8004 = var; gSpecialVar_0x8004 = var;
gSpecialVar_0x8005 = 0xFFFF; gSpecialVar_0x8005 = INVALID_U16;
break; break;
} }
} }

View File

@ -5,7 +5,7 @@
#include "task.h" #include "task.h"
#include "title_screen.h" #include "title_screen.h"
#include "libgcnmultiboot.h" #include "libgcnmultiboot.h"
#include "malloc.h" #include "alloc.h"
#include "gpu_regs.h" #include "gpu_regs.h"
#include "link.h" #include "link.h"
#include "multiboot_pokemon_colosseum.h" #include "multiboot_pokemon_colosseum.h"

View File

@ -58,7 +58,7 @@ static void sub_817B7C4(struct Sprite *sprite);
static void nullsub_66(struct Sprite *sprite); static void nullsub_66(struct Sprite *sprite);
static const struct SpriteTemplate gUnknown_085F504C = { static const struct SpriteTemplate gUnknown_085F504C = {
2000, 0xFFFF, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_817B62C 2000, INVALID_U16, &gDummyOamData, gDummySpriteAnimTable, NULL, gDummySpriteAffineAnimTable, sub_817B62C
}; };
static const struct CompressedSpriteSheet gUnknown_085F5064[] = { static const struct CompressedSpriteSheet gUnknown_085F5064[] = {

View File

@ -4,7 +4,7 @@
#include "string_util.h" #include "string_util.h"
#include "text.h" #include "text.h"
#include "event_data.h" #include "event_data.h"
#include "malloc.h" #include "alloc.h"
#include "secret_base.h" #include "secret_base.h"
#include "item_menu.h" #include "item_menu.h"
#include "strings.h" #include "strings.h"

View File

@ -2,7 +2,7 @@
#include "decompress.h" #include "decompress.h"
#include "graphics.h" #include "graphics.h"
#include "item_icon.h" #include "item_icon.h"
#include "malloc.h" #include "alloc.h"
#include "sprite.h" #include "sprite.h"
#include "constants/items.h" #include "constants/items.h"
@ -161,7 +161,7 @@ u8 AddCustomItemIconSprite(struct SpriteTemplate *customSpriteTemplate, u16 tile
const void *GetItemIconPicOrPalette(u16 itemId, u8 which) const void *GetItemIconPicOrPalette(u16 itemId, u8 which)
{ {
if (itemId == 0xFFFF) if (itemId == INVALID_U16)
itemId = ITEM_FIELD_ARROW; itemId = ITEM_FIELD_ARROW;
else if (itemId >= ITEMS_COUNT) else if (itemId >= ITEMS_COUNT)
itemId = 0; itemId = 0;

View File

@ -23,7 +23,7 @@
#include "link.h" #include "link.h"
#include "mail.h" #include "mail.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "map_name_popup.h" #include "map_name_popup.h"
#include "menu.h" #include "menu.h"
#include "money.h" #include "money.h"
@ -532,11 +532,11 @@ void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)
if (temp <= 1) if (temp <= 1)
gUnknown_0203CE54->unk81B = 1; gUnknown_0203CE54->unk81B = 1;
gUnknown_0203CE54->unk0 = 0; gUnknown_0203CE54->unk0 = 0;
gUnknown_0203CE54->unk81A = 0xFF; gUnknown_0203CE54->unk81A = INVALID_U8;
gUnknown_0203CE54->unk81E = -1; gUnknown_0203CE54->unk81E = -1;
gUnknown_0203CE54->unk81F = -1; gUnknown_0203CE54->unk81F = -1;
memset(gUnknown_0203CE54->unk804, 0xFF, sizeof(gUnknown_0203CE54->unk804)); memset(gUnknown_0203CE54->unk804, INVALID_U8, sizeof(gUnknown_0203CE54->unk804));
memset(gUnknown_0203CE54->unk810, 0xFF, 10); memset(gUnknown_0203CE54->unk810, INVALID_U8, 10);
SetMainCallback2(CB2_Bag); SetMainCallback2(CB2_Bag);
} }
} }
@ -819,7 +819,7 @@ void bag_menu_change_item_callback(s32 a, bool8 b, struct ListMenu *unused)
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ShakeBagVisual(); ShakeBagVisual();
} }
if (gUnknown_0203CE54->unk81A == 0xFF) if (gUnknown_0203CE54->unk81A == INVALID_U8)
{ {
RemoveBagItemIconSprite(1 ^ gUnknown_0203CE54->unk81B_1); RemoveBagItemIconSprite(1 ^ gUnknown_0203CE54->unk81B_1);
if (a != -2) if (a != -2)
@ -840,7 +840,7 @@ void sub_81AB520(u8 rboxId, int item_index_in_pocket, u8 a)
int offset; int offset;
if (item_index_in_pocket != -2) if (item_index_in_pocket != -2)
{ {
if (gUnknown_0203CE54->unk81A != 0xFF) if (gUnknown_0203CE54->unk81A != INVALID_U8)
{ {
if (gUnknown_0203CE54->unk81A == (u8)item_index_in_pocket) if (gUnknown_0203CE54->unk81A == (u8)item_index_in_pocket)
bag_menu_print_cursor(a, 2); bag_menu_print_cursor(a, 2);
@ -897,7 +897,7 @@ void bag_menu_print_cursor_(u8 a, u8 b)
void bag_menu_print_cursor(u8 a, u8 b) void bag_menu_print_cursor(u8 a, u8 b)
{ {
if (b == 0xFF) if (b == INVALID_U8)
FillWindowPixelRect(0, 0, 0, a, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); FillWindowPixelRect(0, 0, 0, a, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
else else
bag_menu_print(0, 1, gText_SelectorArrow2, 0, a, 0, 0, 0, b); bag_menu_print(0, 1, gText_SelectorArrow2, 0, a, 0, 0, 0, b);
@ -906,32 +906,32 @@ void bag_menu_print_cursor(u8 a, u8 b)
void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void) void bag_menu_add_pocket_scroll_arrow_indicators_maybe(void)
{ {
if (gUnknown_0203CE54->unk81E == 0xFF) if (gUnknown_0203CE54->unk81E == INVALID_U8)
gUnknown_0203CE54->unk81E = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0xAC, 12, 0x94, gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - gUnknown_0203CE54->unk82E[gUnknown_0203CE58.pocket], 0x6E, 0x6E, &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]); gUnknown_0203CE54->unk81E = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0xAC, 12, 0x94, gUnknown_0203CE54->unk829[gUnknown_0203CE58.pocket] - gUnknown_0203CE54->unk82E[gUnknown_0203CE58.pocket], 0x6E, 0x6E, &gUnknown_0203CE58.scrollPosition[gUnknown_0203CE58.pocket]);
} }
void sub_81AB824(void) void sub_81AB824(void)
{ {
if (gUnknown_0203CE54->unk81E != 0xFF) if (gUnknown_0203CE54->unk81E != INVALID_U8)
{ {
RemoveScrollIndicatorArrowPair(gUnknown_0203CE54->unk81E); RemoveScrollIndicatorArrowPair(gUnknown_0203CE54->unk81E);
gUnknown_0203CE54->unk81E = 0xFF; gUnknown_0203CE54->unk81E = INVALID_U8;
} }
sub_81AB89C(); sub_81AB89C();
} }
void bag_menu_add_list_scroll_arrow_indicators_maybe(void) void bag_menu_add_list_scroll_arrow_indicators_maybe(void)
{ {
if (gUnknown_0203CE54->unk81B != 1 && gUnknown_0203CE54->unk81F == 0xFF) if (gUnknown_0203CE54->unk81B != 1 && gUnknown_0203CE54->unk81F == INVALID_U8)
gUnknown_0203CE54->unk81F = AddScrollIndicatorArrowPair(&gUnknown_08614094, &gUnknown_0203CE58.unk6); gUnknown_0203CE54->unk81F = AddScrollIndicatorArrowPair(&gUnknown_08614094, &gUnknown_0203CE58.unk6);
} }
void sub_81AB89C(void) void sub_81AB89C(void)
{ {
if (gUnknown_0203CE54->unk81F != 0xFF) if (gUnknown_0203CE54->unk81F != INVALID_U8)
{ {
RemoveScrollIndicatorArrowPair(gUnknown_0203CE54->unk81F); RemoveScrollIndicatorArrowPair(gUnknown_0203CE54->unk81F);
gUnknown_0203CE54->unk81F = 0xFF; gUnknown_0203CE54->unk81F = INVALID_U8;
} }
} }
@ -2303,7 +2303,7 @@ u8 sub_81AE124(u8 a)
u8 bag_menu_add_window(u8 a) u8 bag_menu_add_window(u8 a)
{ {
u8 *ptr = &gUnknown_0203CE54->unk810[a]; u8 *ptr = &gUnknown_0203CE54->unk810[a];
if (*ptr == 0xFF) if (*ptr == INVALID_U8)
{ {
*ptr = AddWindow(&gUnknown_086141AC[a]); *ptr = AddWindow(&gUnknown_086141AC[a]);
SetWindowBorderStyle(*ptr, 0, 1, 14); SetWindowBorderStyle(*ptr, 0, 1, 14);
@ -2315,20 +2315,20 @@ u8 bag_menu_add_window(u8 a)
void bag_menu_remove_window(u8 a) void bag_menu_remove_window(u8 a)
{ {
u8 *ptr = &gUnknown_0203CE54->unk810[a]; u8 *ptr = &gUnknown_0203CE54->unk810[a];
if (*ptr != 0xFF) if (*ptr != INVALID_U8)
{ {
sub_8198070(*ptr, 0); sub_8198070(*ptr, 0);
ClearWindowTilemap(*ptr); ClearWindowTilemap(*ptr);
RemoveWindow(*ptr); RemoveWindow(*ptr);
schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(1);
*ptr = 0xFF; *ptr = INVALID_U8;
} }
} }
u8 AddItemMessageWindow(u8 a) u8 AddItemMessageWindow(u8 a)
{ {
u8 *ptr = &gUnknown_0203CE54->unk810[a]; u8 *ptr = &gUnknown_0203CE54->unk810[a];
if (*ptr == 0xFF) if (*ptr == INVALID_U8)
*ptr = AddWindow(&gUnknown_086141AC[a]); *ptr = AddWindow(&gUnknown_086141AC[a]);
return *ptr; return *ptr;
} }
@ -2336,13 +2336,13 @@ u8 AddItemMessageWindow(u8 a)
void bag_menu_RemoveBagItem_message_window(u8 a) void bag_menu_RemoveBagItem_message_window(u8 a)
{ {
u8 *ptr = &gUnknown_0203CE54->unk810[a]; u8 *ptr = &gUnknown_0203CE54->unk810[a];
if (*ptr != 0xFF) if (*ptr != INVALID_U8)
{ {
sub_8197DF8(*ptr, 0); sub_8197DF8(*ptr, 0);
ClearWindowTilemap(*ptr); ClearWindowTilemap(*ptr);
RemoveWindow(*ptr); RemoveWindow(*ptr);
schedule_bg_copy_tilemap_to_vram(1); schedule_bg_copy_tilemap_to_vram(1);
*ptr = 0xFF; *ptr = INVALID_U8;
} }
} }

View File

@ -301,7 +301,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FC74[] =
static const struct SpriteTemplate gUnknown_0857FC7C = static const struct SpriteTemplate gUnknown_0857FC7C =
{ {
.tileTag = 0xFFFF, .tileTag = INVALID_U16,
.paletteTag = 0x7544, .paletteTag = 0x7544,
.oam = &sOamData_857FBD0, .oam = &sOamData_857FBD0,
.anims = sSpriteAnimTable_857FBE0, .anims = sSpriteAnimTable_857FBE0,
@ -410,13 +410,13 @@ static const struct SpriteTemplate gUnknown_0857FE10 =
void RemoveBagSprite(u8 id) void RemoveBagSprite(u8 id)
{ {
u8 *spriteId = &gUnknown_0203CE54->unk804[id]; u8 *spriteId = &gUnknown_0203CE54->unk804[id];
if (*spriteId != 0xFF) if (*spriteId != INVALID_U8)
{ {
FreeSpriteTilesByTag(id + 100); FreeSpriteTilesByTag(id + 100);
FreeSpritePaletteByTag(id + 100); FreeSpritePaletteByTag(id + 100);
FreeSpriteOamMatrix(&gSprites[*spriteId]); FreeSpriteOamMatrix(&gSprites[*spriteId]);
DestroySprite(&gSprites[*spriteId]); DestroySprite(&gSprites[*spriteId]);
*spriteId = 0xFF; *spriteId = INVALID_U8;
} }
} }
@ -516,7 +516,7 @@ static void SpriteCB_SwitchPocketRotatingBallContinue(struct Sprite *sprite)
void AddBagItemIconSprite(u16 itemId, u8 id) void AddBagItemIconSprite(u16 itemId, u8 id)
{ {
u8 *spriteId = &gUnknown_0203CE54->unk804[id + 2]; u8 *spriteId = &gUnknown_0203CE54->unk804[id + 2];
if (*spriteId == 0xFF) if (*spriteId == INVALID_U8)
{ {
u8 iconSpriteId; u8 iconSpriteId;

View File

@ -9,7 +9,7 @@
#include "gpu_regs.h" #include "gpu_regs.h"
#include "learn_move.h" #include "learn_move.h"
#include "list_menu.h" #include "list_menu.h"
#include "malloc.h" #include "alloc.h"
#include "menu.h" #include "menu.h"
#include "menu_helpers.h" #include "menu_helpers.h"
#include "overworld.h" #include "overworld.h"
@ -381,7 +381,7 @@ static void LearnMoveMain(void)
if (selection == 0) if (selection == 0)
{ {
if (GiveMoveToMon(&gPlayerParty[sLearnMoveStruct->partyMon], GetCurrentItemId()) != 0xFFFF) if (GiveMoveToMon(&gPlayerParty[sLearnMoveStruct->partyMon], GetCurrentItemId()) != INVALID_U16)
{ {
sub_816084C(gText_PkmnLearnedMove4); sub_816084C(gText_PkmnLearnedMove4);
gSpecialVar_0x8004 = 1; gSpecialVar_0x8004 = 1;
@ -727,12 +727,12 @@ static void CreateHearts(void)
static void AddScrollArrows(void) static void AddScrollArrows(void)
{ {
if (sLearnMoveStruct->scrollArrowTaskId2 == 0xFF) if (sLearnMoveStruct->scrollArrowTaskId2 == INVALID_U8)
{ {
sLearnMoveStruct->scrollArrowTaskId2 = AddScrollIndicatorArrowPair(&gUnknown_085CEBC0, &sLearnMoveStruct->scrollOffset); sLearnMoveStruct->scrollArrowTaskId2 = AddScrollIndicatorArrowPair(&gUnknown_085CEBC0, &sLearnMoveStruct->scrollOffset);
} }
if (sLearnMoveStruct->scrollArrowTaskId1 == 0xFF) if (sLearnMoveStruct->scrollArrowTaskId1 == INVALID_U8)
{ {
gTempScrollArrowTemplate = gUnknown_085CEBD0; gTempScrollArrowTemplate = gUnknown_085CEBD0;
gTempScrollArrowTemplate.fullyDownThreshold = sLearnMoveStruct->numMenuChoices - sLearnMoveStruct->numToShowAtOnce; gTempScrollArrowTemplate.fullyDownThreshold = sLearnMoveStruct->numMenuChoices - sLearnMoveStruct->numToShowAtOnce;
@ -742,16 +742,16 @@ static void AddScrollArrows(void)
static void RemoveScrollArrows(void) static void RemoveScrollArrows(void)
{ {
if (sLearnMoveStruct->scrollArrowTaskId2 != 0xFF) if (sLearnMoveStruct->scrollArrowTaskId2 != INVALID_U8)
{ {
RemoveScrollIndicatorArrowPair(sLearnMoveStruct->scrollArrowTaskId2); RemoveScrollIndicatorArrowPair(sLearnMoveStruct->scrollArrowTaskId2);
sLearnMoveStruct->scrollArrowTaskId2 = 0xFF; sLearnMoveStruct->scrollArrowTaskId2 = INVALID_U8;
} }
if (sLearnMoveStruct->scrollArrowTaskId1 != 0xFF) if (sLearnMoveStruct->scrollArrowTaskId1 != INVALID_U8)
{ {
RemoveScrollIndicatorArrowPair(sLearnMoveStruct->scrollArrowTaskId1); RemoveScrollIndicatorArrowPair(sLearnMoveStruct->scrollArrowTaskId1);
sLearnMoveStruct->scrollArrowTaskId1 = 0xFF; sLearnMoveStruct->scrollArrowTaskId1 = INVALID_U8;
} }
} }
@ -792,7 +792,7 @@ void ShowHideHearts(s32 item)
{ {
numHearts = (u8)(gContestEffects[gContestMoves[item].effect].appeal / 10); numHearts = (u8)(gContestEffects[gContestMoves[item].effect].appeal / 10);
if (numHearts == 0xFF) if (numHearts == INVALID_U8)
{ {
numHearts = 0; numHearts = 0;
} }
@ -812,7 +812,7 @@ void ShowHideHearts(s32 item)
numHearts = (u8)(gContestEffects[gContestMoves[item].effect].jam / 10); numHearts = (u8)(gContestEffects[gContestMoves[item].effect].jam / 10);
if (numHearts == 0xFF) if (numHearts == INVALID_U8)
{ {
numHearts = 0; numHearts = 0;
} }

View File

@ -64,7 +64,7 @@
v12 = (u16*)((u32)&sub_82E53F4 & ~1); v12 = (u16*)((u32)&sub_82E53F4 & ~1);
v13 = (u16*)gUnknown_03007898->unk_8; v13 = (u16*)gUnknown_03007898->unk_8;
for (i = 47; i != 0xFFFF; i--) for (i = 47; i != INVALID_U16; i--)
{ {
*v13 = *v12; *v13 = *v12;
++v12; ++v12;

View File

@ -116,7 +116,7 @@ u16 STWI_read_status(u8 index)
case 3: case 3:
return gRfuState->activeCommand; return gRfuState->activeCommand;
default: default:
return 0xFFFF; return INVALID_U16;
} }
} }

View File

@ -2,7 +2,7 @@
// Includes // Includes
#include "global.h" #include "global.h"
#include "m4a.h" #include "m4a.h"
#include "malloc.h" #include "alloc.h"
#include "reset_save_heap.h" #include "reset_save_heap.h"
#include "save.h" #include "save.h"
#include "bg.h" #include "bg.h"
@ -2250,7 +2250,7 @@ static bool8 DoHandshake(void)
u16 minRecv; u16 minRecv;
playerCount = 0; playerCount = 0;
minRecv = 0xFFFF; minRecv = INVALID_U16;
if (gLink.handshakeAsMaster == TRUE) if (gLink.handshakeAsMaster == TRUE)
{ {
REG_SIOMLT_SEND = MASTER_HANDSHAKE; REG_SIOMLT_SEND = MASTER_HANDSHAKE;
@ -2274,7 +2274,7 @@ static bool8 DoHandshake(void)
} }
else else
{ {
if (gLink.tempRecvBuffer[i] != 0xFFFF) if (gLink.tempRecvBuffer[i] != INVALID_U16)
{ {
playerCount = 0; playerCount = 0;
} }

View File

@ -1,4 +1,5 @@
#include "global.h" #include "global.h"
#include "alloc.h"
#include "battle.h" #include "battle.h"
#include "berry_blender.h" #include "berry_blender.h"
#include "decompress.h" #include "decompress.h"
@ -7,7 +8,6 @@
#include "librfu.h" #include "librfu.h"
#include "link.h" #include "link.h"
#include "link_rfu.h" #include "link_rfu.h"
#include "malloc.h"
#include "overworld.h" #include "overworld.h"
#include "random.h" #include "random.h"
#include "palette.h" #include "palette.h"
@ -276,7 +276,7 @@ const struct {
{ gBlockSendBuffer, 40 } { gBlockSendBuffer, 40 }
}; };
const u16 gUnknown_082ED6E0[] = { const u16 gUnknown_082ED6E0[] = {
0x0002, 0x7f7d, 0x0000, 0xffff 0x0002, 0x7f7d, 0x0000, INVALID_U16
}; };
const char sUnref_082ED6E8[][15] = { const char sUnref_082ED6E8[][15] = {
@ -436,7 +436,7 @@ u8 sub_800C054(u8 r5, u16 r7, u16 r8, const u16 *r6)
} }
for (i = 0, buffer = r6; i < 16; i++) for (i = 0, buffer = r6; i < 16; i++)
{ {
if (*buffer++ == 0xFFFF) if (*buffer++ == INVALID_U16)
{ {
break; break;
} }
@ -754,7 +754,7 @@ void sub_800C54C(u32 a0)
switch (gUnknown_03004140.unk_04) switch (gUnknown_03004140.unk_04)
{ {
case 23: case 23:
r2 = sub_800BEC0() == 0x8001 ? 0x44 : 0xFF; r2 = sub_800BEC0() == 0x8001 ? 0x44 : INVALID_U8;
gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0; gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0;
sub_800D30C(r2, 0); sub_800D30C(r2, 0);
break; break;
@ -1168,7 +1168,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
gUnknown_03004140.unk_00 &= ~gUnknown_03004140.unk_14; gUnknown_03004140.unk_00 &= ~gUnknown_03004140.unk_14;
if (gUnknown_03004140.unk_07) if (gUnknown_03004140.unk_07)
{ {
if (gUnknown_03007890->unk_00 == 0xFF) if (gUnknown_03007890->unk_00 == INVALID_U8)
{ {
if (gUnknown_03004140.unk_07 == 8) if (gUnknown_03004140.unk_07 == 8)
{ {
@ -1183,7 +1183,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
} }
} }
} }
if (gUnknown_03007890->unk_00 == 0xFF) if (gUnknown_03007890->unk_00 == INVALID_U8)
{ {
if (gUnknown_03004140.unk_04 == 0) if (gUnknown_03004140.unk_04 == 0)
{ {
@ -1198,7 +1198,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
break; break;
case 38: case 38:
sub_800D20C(); sub_800D20C();
if (gUnknown_03007890->unk_00 != 0xFF) if (gUnknown_03007890->unk_00 != INVALID_U8)
{ {
sub_800D30C(0x50, 0x00); sub_800D30C(0x50, 0x00);
} }
@ -1241,7 +1241,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
sub_800D610(); sub_800D610();
} }
} }
if (r8 == 0xFF) if (r8 == INVALID_U8)
{ {
sub_800D30C(0xf2, 0x00); sub_800D30C(0xf2, 0x00);
sub_800D610(); sub_800D610();
@ -1322,7 +1322,7 @@ static void sub_800CF34(void)
if (gUnknown_03007880[i]->unk_61 == 1) if (gUnknown_03007880[i]->unk_61 == 1)
{ {
r5 = 0x02; r5 = 0x02;
for (ptr = gUnknown_03004140.unk_20; *ptr != 0xFFFF; ptr++) for (ptr = gUnknown_03004140.unk_20; *ptr != INVALID_U16; ptr++)
{ {
if (gUnknown_03007890->unk_14[i].unk_04 == *ptr) if (gUnknown_03007890->unk_14[i].unk_04 == *ptr)
{ {
@ -1469,7 +1469,7 @@ static u8 sub_800D294(void)
for (i = 0; i < gUnknown_03007890->unk_08; i++) for (i = 0; i < gUnknown_03007890->unk_08; i++)
{ {
for (ptr = gUnknown_03004140.unk_20; *ptr != 0xffff; ptr++) for (ptr = gUnknown_03004140.unk_20; *ptr != INVALID_U16; ptr++)
{ {
if (gUnknown_03007890->unk_14[i].unk_04 == *ptr) if (gUnknown_03007890->unk_14[i].unk_04 == *ptr)
{ {
@ -2242,12 +2242,12 @@ void sub_800E084(void)
void sub_800E0E8(void) void sub_800E0E8(void)
{ {
if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF) if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == INVALID_U16)
{ {
LoadCompressedObjectPic(&sWirelessStatusIndicatorSpriteSheet); LoadCompressedObjectPic(&sWirelessStatusIndicatorSpriteSheet);
} }
LoadSpritePalette(&sWirelessStatusIndicatorSpritePalette); LoadSpritePalette(&sWirelessStatusIndicatorSpritePalette);
gWirelessStatusIndicatorSpriteId = 0xFF; gWirelessStatusIndicatorSpriteId = INVALID_U8;
} }
u8 sub_800E124(void) u8 sub_800E124(void)
@ -2277,7 +2277,7 @@ void sub_800E15C(struct Sprite *sprite, s32 signalStrengthAnimNum)
void sub_800E174(void) void sub_800E174(void)
{ {
if (gWirelessStatusIndicatorSpriteId != 0xFF && gSprites[gWirelessStatusIndicatorSpriteId].data[7] == 0x1234) if (gWirelessStatusIndicatorSpriteId != INVALID_U8 && gSprites[gWirelessStatusIndicatorSpriteId].data[7] == 0x1234)
{ {
struct Sprite *sprite = &gSprites[gWirelessStatusIndicatorSpriteId]; struct Sprite *sprite = &gSprites[gWirelessStatusIndicatorSpriteId];
u8 signalStrength = 255; u8 signalStrength = 255;
@ -2461,7 +2461,7 @@ void sub_800E604(void)
u8 unk_ee_bak = gUnknown_03005000.unk_ee; u8 unk_ee_bak = gUnknown_03005000.unk_ee;
CpuFill16(0, &gUnknown_03005000, sizeof gUnknown_03005000); CpuFill16(0, &gUnknown_03005000, sizeof gUnknown_03005000);
gUnknown_03005000.unk_ee = unk_ee_bak; gUnknown_03005000.unk_ee = unk_ee_bak;
gUnknown_03005000.unk_0c = 0xFF; gUnknown_03005000.unk_0c = INVALID_U8;
if (gUnknown_03005000.unk_ee != 4) if (gUnknown_03005000.unk_ee != 4)
{ {
gUnknown_03005000.unk_ee = 0; gUnknown_03005000.unk_ee = 0;
@ -3077,7 +3077,7 @@ bool32 sub_800F1E0(void)
{ {
if (gUnknown_03005000.unk_14[i][1]) if (gUnknown_03005000.unk_14[i][1])
{ {
if (gUnknown_03005000.unk_cee[i] != 0xff && (gUnknown_03005000.unk_14[i][0] >> 5) != ((gUnknown_03005000.unk_cee[i] + 1) & 7)) if (gUnknown_03005000.unk_cee[i] != INVALID_U8 && (gUnknown_03005000.unk_14[i][0] >> 5) != ((gUnknown_03005000.unk_cee[i] + 1) & 7))
{ {
if (++gUnknown_03005000.unk_cea[i] > 4) if (++gUnknown_03005000.unk_cea[i] > 4)
sub_8011170(0x8100); sub_8011170(0x8100);
@ -3778,7 +3778,7 @@ bool32 sub_8010454(u32 a0)
s32 i; s32 i;
for (i = 0; gUnknown_082ED6E0[i] != a0; i++) for (i = 0; gUnknown_082ED6E0[i] != a0; i++)
{ {
if (gUnknown_082ED6E0[i] == 0xffff) if (gUnknown_082ED6E0[i] == INVALID_U16)
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
@ -3881,7 +3881,7 @@ bool32 sub_80105EC(void)
bool32 sub_801064C(u16 a0, const u8 *a1) bool32 sub_801064C(u16 a0, const u8 *a1)
{ {
u8 r1 = sub_8011CE4(a1, a0); u8 r1 = sub_8011CE4(a1, a0);
if (r1 == 0xFF) if (r1 == INVALID_U8)
return TRUE; return TRUE;
if (gUnknown_03005000.unk_cd1[r1] == 9) if (gUnknown_03005000.unk_cd1[r1] == 9)
return TRUE; return TRUE;
@ -3906,7 +3906,7 @@ void sub_80106D4(void)
u32 sub_8010714(u16 a0, const u8 *a1) u32 sub_8010714(u16 a0, const u8 *a1)
{ {
u8 r0 = sub_8011CE4(a1, a0); u8 r0 = sub_8011CE4(a1, a0);
if (r0 == 0xff) if (r0 == INVALID_U8)
return 2; return 2;
if (gUnknown_03007880[r0]->unk_0 == 0) if (gUnknown_03007880[r0]->unk_0 == 0)
return 1; return 1;

View File

@ -8,7 +8,7 @@
#include "trig.h" #include "trig.h"
#include "decompress.h" #include "decompress.h"
#include "palette.h" #include "palette.h"
#include "malloc.h" #include "alloc.h"
#include "strings.h" #include "strings.h"
#include "sound.h" #include "sound.h"
#include "constants/songs.h" #include "constants/songs.h"
@ -392,7 +392,7 @@ u8 ListMenuInitInRect(struct ListMenuTemplate *listMenuTemplate, struct ListMenu
s32 i; s32 i;
u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow); u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow);
for (i = 0; rect[i].palNum != 0xFF; i++) for (i = 0; rect[i].palNum != INVALID_U8; i++)
{ {
PutWindowRectTilemapOverridePalette(listMenuTemplate->windowId, PutWindowRectTilemapOverridePalette(listMenuTemplate->windowId,
rect[i].x, rect[i].x,
@ -465,7 +465,7 @@ s32 ListMenuHandleInputGetItemId(u8 listTaskId)
} }
} }
#define TASK_NONE 0xFF #define TASK_NONE INVALID_U8
void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow) void DestroyListMenuTask(u8 listTaskId, u16 *scrollOffset, u16 *selectedRow)
{ {
@ -1143,7 +1143,7 @@ static void Task_ScrollIndicatorArrowPair(u8 taskId)
struct ScrollIndicatorPair *data = (void*) gTasks[taskId].data; struct ScrollIndicatorPair *data = (void*) gTasks[taskId].data;
u16 currItem = (*data->scrollOffset); u16 currItem = (*data->scrollOffset);
if (currItem == data->fullyUpThreshold && currItem != 0xFFFF) if (currItem == data->fullyUpThreshold && currItem != INVALID_U16)
gSprites[data->topSpriteId].invisible = TRUE; gSprites[data->topSpriteId].invisible = TRUE;
else else
gSprites[data->topSpriteId].invisible = FALSE; gSprites[data->topSpriteId].invisible = FALSE;

View File

@ -4,7 +4,7 @@
#include "main.h" #include "main.h"
#include "pokemon.h" #include "pokemon.h"
#include "random.h" #include "random.h"
#include "malloc.h" #include "alloc.h"
#include "item.h" #include "item.h"
#include "overworld.h" #include "overworld.h"
#include "decoration_inventory.h" #include "decoration_inventory.h"

View File

@ -17,7 +17,7 @@
#include "bg.h" #include "bg.h"
#include "pokemon_icon.h" #include "pokemon_icon.h"
#include "constants/species.h" #include "constants/species.h"
#include "malloc.h" #include "alloc.h"
#include "easy_chat.h" #include "easy_chat.h"
extern const u16 gMailPalette_Orange[]; extern const u16 gMailPalette_Orange[];

View File

@ -20,7 +20,7 @@ void ClearMailStruct(struct MailStruct *mail)
s32 i; s32 i;
for (i = 0; i < MAIL_WORDS_COUNT; i++) for (i = 0; i < MAIL_WORDS_COUNT; i++)
mail->words[i] = 0xFFFF; mail->words[i] = INVALID_U16;
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
mail->playerName[i] = EOS; mail->playerName[i] = EOS;
@ -35,7 +35,7 @@ void ClearMailStruct(struct MailStruct *mail)
bool8 MonHasMail(struct Pokemon *mon) bool8 MonHasMail(struct Pokemon *mon)
{ {
u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM); u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM);
if (ItemIsMail(heldItem) && GetMonData(mon, MON_DATA_MAIL) != 0xFF) if (ItemIsMail(heldItem) && GetMonData(mon, MON_DATA_MAIL) != INVALID_U8)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -56,7 +56,7 @@ u8 GiveMailToMon(struct Pokemon *mon, u16 itemId)
if (gSaveBlock1Ptr->mail[id].itemId == 0) if (gSaveBlock1Ptr->mail[id].itemId == 0)
{ {
for (i = 0; i < MAIL_WORDS_COUNT; i++) for (i = 0; i < MAIL_WORDS_COUNT; i++)
gSaveBlock1Ptr->mail[id].words[i] = 0xFFFF; gSaveBlock1Ptr->mail[id].words[i] = INVALID_U16;
for (i = 0; i < PLAYER_NAME_LENGTH + 1 - 1; i++) for (i = 0; i < PLAYER_NAME_LENGTH + 1 - 1; i++)
gSaveBlock1Ptr->mail[id].playerName[i] = gSaveBlock2Ptr->playerName[i]; gSaveBlock1Ptr->mail[id].playerName[i] = gSaveBlock2Ptr->playerName[i];
@ -76,7 +76,7 @@ u8 GiveMailToMon(struct Pokemon *mon, u16 itemId)
} }
} }
return 0xFF; return INVALID_U8;
} }
u16 SpeciesToMailSpecies(u16 species, u32 personality) u16 SpeciesToMailSpecies(u16 species, u32 personality)
@ -113,8 +113,8 @@ u8 GiveMailToMon2(struct Pokemon *mon, struct MailStruct *mail)
u16 itemId = mail->itemId; u16 itemId = mail->itemId;
u8 mailId = GiveMailToMon(mon, itemId); u8 mailId = GiveMailToMon(mon, itemId);
if (mailId == 0xFF) if (mailId == INVALID_U8)
return 0xFF; return INVALID_U8;
gSaveBlock1Ptr->mail[mailId] = *mail; gSaveBlock1Ptr->mail[mailId] = *mail;
@ -142,7 +142,7 @@ void TakeMailFromMon(struct Pokemon *mon)
{ {
mailId = GetMonData(mon, MON_DATA_MAIL); mailId = GetMonData(mon, MON_DATA_MAIL);
gSaveBlock1Ptr->mail[mailId].itemId = ITEM_NONE; gSaveBlock1Ptr->mail[mailId].itemId = ITEM_NONE;
mailId = 0xFF; mailId = INVALID_U8;
heldItem[0] = ITEM_NONE; heldItem[0] = ITEM_NONE;
heldItem[1] = ITEM_NONE << 8; heldItem[1] = ITEM_NONE << 8;
SetMonData(mon, MON_DATA_MAIL, &mailId); SetMonData(mon, MON_DATA_MAIL, &mailId);
@ -163,7 +163,7 @@ u8 TakeMailFromMon2(struct Pokemon *mon)
newHeldItem[0] = ITEM_NONE; newHeldItem[0] = ITEM_NONE;
newHeldItem[1] = ITEM_NONE << 8; newHeldItem[1] = ITEM_NONE << 8;
newMailId = 0xFF; newMailId = INVALID_U8;
for (i = PARTY_SIZE; i < MAIL_COUNT; i++) for (i = PARTY_SIZE; i < MAIL_COUNT; i++)
{ {
@ -177,7 +177,7 @@ u8 TakeMailFromMon2(struct Pokemon *mon)
} }
} }
return 0xFF; return INVALID_U8;
} }
bool8 ItemIsMail(u16 itemId) bool8 ItemIsMail(u16 itemId)

View File

@ -1,6 +1,6 @@
#include "global.h" #include "global.h"
#include "crt0.h" #include "crt0.h"
#include "malloc.h" #include "alloc.h"
#include "link.h" #include "link.h"
#include "link_rfu.h" #include "link_rfu.h"
#include "librfu.h" #include "librfu.h"

View File

@ -1,210 +0,0 @@
#include "global.h"
static void *sHeapStart;
static u32 sHeapSize;
static u32 malloc_c_unused_0300000c; // needed to align dma3_manager.o(.bss)
#define MALLOC_SYSTEM_ID 0xA3A3
struct MemBlock {
// Whether this block is currently allocated.
bool16 flag;
// Magic number used for error checking. Should equal MALLOC_SYSTEM_ID.
u16 magic;
// Size of the block (not including this header struct).
u32 size;
// Previous block pointer. Equals sHeapStart if this is the first block.
struct MemBlock *prev;
// Next block pointer. Equals sHeapStart if this is the last block.
struct MemBlock *next;
// Data in the memory block. (Arrays of length 0 are a GNU extension.)
u8 data[0];
};
void PutMemBlockHeader(void *block, struct MemBlock *prev, struct MemBlock *next, u32 size)
{
struct MemBlock *header = (struct MemBlock *)block;
header->flag = FALSE;
header->magic = MALLOC_SYSTEM_ID;
header->size = size;
header->prev = prev;
header->next = next;
}
void PutFirstMemBlockHeader(void *block, u32 size)
{
PutMemBlockHeader(block, (struct MemBlock *)block, (struct MemBlock *)block, size - sizeof(struct MemBlock));
}
void *AllocInternal(void *heapStart, u32 size)
{
struct MemBlock *pos = (struct MemBlock *)heapStart;
struct MemBlock *head = pos;
struct MemBlock *splitBlock;
u32 foundBlockSize;
// Alignment
if (size & 3)
size = 4 * ((size / 4) + 1);
for (;;) {
// Loop through the blocks looking for unused block that's big enough.
if (!pos->flag) {
foundBlockSize = pos->size;
if (foundBlockSize >= size) {
if (foundBlockSize - size < 2 * sizeof(struct MemBlock)) {
// The block isn't much bigger than the requested size,
// so just use it.
pos->flag = TRUE;
} else {
// The block is significantly bigger than the requested
// size, so split the rest into a separate block.
foundBlockSize -= sizeof(struct MemBlock);
foundBlockSize -= size;
splitBlock = (struct MemBlock *)(pos->data + size);
pos->flag = TRUE;
pos->size = size;
PutMemBlockHeader(splitBlock, pos, pos->next, foundBlockSize);
pos->next = splitBlock;
if (splitBlock->next != head)
splitBlock->next->prev = splitBlock;
}
return pos->data;
}
}
if (pos->next == head)
return NULL;
pos = pos->next;
}
}
void FreeInternal(void *heapStart, void *pointer)
{
if (pointer) {
struct MemBlock *head = (struct MemBlock *)heapStart;
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
block->flag = FALSE;
// If the freed block isn't the last one, merge with the next block
// if it's not in use.
if (block->next != head) {
if (!block->next->flag) {
block->size += sizeof(struct MemBlock) + block->next->size;
block->next->magic = 0;
block->next = block->next->next;
if (block->next != head)
block->next->prev = block;
}
}
// If the freed block isn't the first one, merge with the previous block
// if it's not in use.
if (block != head) {
if (!block->prev->flag) {
block->prev->next = block->next;
if (block->next != head)
block->next->prev = block->prev;
block->magic = 0;
block->prev->size += sizeof(struct MemBlock) + block->size;
}
}
}
}
void *AllocZeroedInternal(void *heapStart, u32 size)
{
void *mem = AllocInternal(heapStart, size);
if (mem != NULL) {
if (size & 3)
size = 4 * ((size / 4) + 1);
CpuFill32(0, mem, size);
}
return mem;
}
bool32 CheckMemBlockInternal(void *heapStart, void *pointer)
{
struct MemBlock *head = (struct MemBlock *)heapStart;
struct MemBlock *block = (struct MemBlock *)((u8 *)pointer - sizeof(struct MemBlock));
if (block->magic != MALLOC_SYSTEM_ID)
return FALSE;
if (block->next->magic != MALLOC_SYSTEM_ID)
return FALSE;
if (block->next != head && block->next->prev != block)
return FALSE;
if (block->prev->magic != MALLOC_SYSTEM_ID)
return FALSE;
if (block->prev != head && block->prev->next != block)
return FALSE;
if (block->next != head && block->next != (struct MemBlock *)(block->data + block->size))
return FALSE;
return TRUE;
}
void InitHeap(void *heapStart, u32 heapSize)
{
sHeapStart = heapStart;
sHeapSize = heapSize;
PutFirstMemBlockHeader(heapStart, heapSize);
}
void *Alloc(u32 size)
{
AllocInternal(sHeapStart, size);
}
void *AllocZeroed(u32 size)
{
AllocZeroedInternal(sHeapStart, size);
}
void Free(void *pointer)
{
FreeInternal(sHeapStart, pointer);
}
bool32 CheckMemBlock(void *pointer)
{
return CheckMemBlockInternal(sHeapStart, pointer);
}
bool32 CheckHeap()
{
struct MemBlock *pos = (struct MemBlock *)sHeapStart;
do {
if (!CheckMemBlockInternal(sHeapStart, pos->data))
return FALSE;
pos = pos->next;
} while (pos != (struct MemBlock *)sHeapStart);
return TRUE;
}

View File

@ -250,7 +250,7 @@ void ScrSpecial_HipsterTeachWord(void)
{ {
u16 var = sub_811F01C(); u16 var = sub_811F01C();
if (var == 0xFFFF) if (var == INVALID_U16)
{ {
gSpecialVar_Result = FALSE; gSpecialVar_Result = FALSE;
} }
@ -283,7 +283,7 @@ void ScrSpecial_GenerateGiddyLine(void)
if (giddy->taleCounter == 0) if (giddy->taleCounter == 0)
InitGiddyTaleList(); InitGiddyTaleList();
if (giddy->randomWords[giddy->taleCounter] != 0xFFFF) // is not the last element of the array? if (giddy->randomWords[giddy->taleCounter] != INVALID_U16) // is not the last element of the array?
{ {
u8 *stringPtr; u8 *stringPtr;
u32 adjective = Random(); u32 adjective = Random();
@ -348,7 +348,7 @@ static void InitGiddyTaleList(void)
r1 = Random() % 10; r1 = Random() % 10;
if (r1 < 3 && r7 < 8) if (r1 < 3 && r7 < 8)
{ {
giddy->randomWords[i] = 0xFFFF; giddy->randomWords[i] = INVALID_U16;
r7++; r7++;
} }
else else

View File

@ -7,7 +7,7 @@
#include "main.h" #include "main.h"
#include "sound.h" #include "sound.h"
#include "menu_helpers.h" #include "menu_helpers.h"
#include "malloc.h" #include "alloc.h"
#include "task.h" #include "task.h"
#include "dma3.h" #include "dma3.h"
#include "string_util.h" #include "string_util.h"
@ -140,8 +140,8 @@ extern void task_free_buf_after_copying_tile_data_to_vram(u8 taskId);
void sub_81971D0(void) void sub_81971D0(void)
{ {
InitWindows(gUnknown_0860F098); InitWindows(gUnknown_0860F098);
gStartMenuWindowId = 0xFF; gStartMenuWindowId = INVALID_U8;
gUnknown_0203CD8D = 0xFF; gUnknown_0203CD8D = INVALID_U8;
} }
void sub_81971F4(void) void sub_81971F4(void)
@ -486,7 +486,7 @@ u8 GetPlayerTextSpeedDelay(void)
u8 sub_81979C4(u8 a1) u8 sub_81979C4(u8 a1)
{ {
if (gStartMenuWindowId == 0xFF) if (gStartMenuWindowId == INVALID_U8)
gStartMenuWindowId = sub_8198AA4(0, 0x16, 1, 7, (a1 * 2) + 2, 0xF, 0x139); gStartMenuWindowId = sub_8198AA4(0, 0x16, 1, 7, (a1 * 2) + 2, 0xF, 0x139);
return gStartMenuWindowId; return gStartMenuWindowId;
} }
@ -498,10 +498,10 @@ u8 GetStartMenuWindowId(void)
void RemoveStartMenuWindow(void) void RemoveStartMenuWindow(void)
{ {
if (gStartMenuWindowId != 0xFF) if (gStartMenuWindowId != INVALID_U8)
{ {
RemoveWindow(gStartMenuWindowId); RemoveWindow(gStartMenuWindowId);
gStartMenuWindowId = 0xFF; gStartMenuWindowId = INVALID_U8;
} }
} }
@ -517,7 +517,7 @@ u16 sub_8197A38(void)
u8 AddMapNamePopUpWindow(void) u8 AddMapNamePopUpWindow(void)
{ {
if (gUnknown_0203CD8D == 0xFF) if (gUnknown_0203CD8D == INVALID_U8)
gUnknown_0203CD8D = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107); gUnknown_0203CD8D = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107);
return gUnknown_0203CD8D; return gUnknown_0203CD8D;
} }
@ -529,10 +529,10 @@ u8 GetMapNamePopUpWindowId(void)
void RemoveMapNamePopUpWindow(void) void RemoveMapNamePopUpWindow(void)
{ {
if (gUnknown_0203CD8D != 0xFF) if (gUnknown_0203CD8D != INVALID_U8)
{ {
RemoveWindow(gUnknown_0203CD8D); RemoveWindow(gUnknown_0203CD8D);
gUnknown_0203CD8D = 0xFF; gUnknown_0203CD8D = INVALID_U8;
} }
} }
@ -808,7 +808,7 @@ void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram)
{ {
u16 width = 0; u16 width = 0;
if (gUnknown_0203CDA0 != 0xFF) if (gUnknown_0203CDA0 != INVALID_U8)
{ {
PutWindowTilemap(gUnknown_0203CDA0); PutWindowTilemap(gUnknown_0203CDA0);
FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF); FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF);
@ -830,7 +830,7 @@ void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyTo
u8 color[3]; u8 color[3];
u16 width = 0; u16 width = 0;
if (gUnknown_0203CDA0 != 0xFF) if (gUnknown_0203CDA0 != INVALID_U8)
{ {
if (a3 != 0) if (a3 != 0)
{ {
@ -865,13 +865,13 @@ void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyTo
void sub_81982D8(void) void sub_81982D8(void)
{ {
if (gUnknown_0203CDA0 != 0xFF) if (gUnknown_0203CDA0 != INVALID_U8)
CopyWindowToVram(gUnknown_0203CDA0, 3); CopyWindowToVram(gUnknown_0203CDA0, 3);
} }
void sub_81982F0(void) void sub_81982F0(void)
{ {
if (gUnknown_0203CDA0 != 0xFF) if (gUnknown_0203CDA0 != INVALID_U8)
{ {
FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF); FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF);
CopyWindowToVram(gUnknown_0203CDA0, 3); CopyWindowToVram(gUnknown_0203CDA0, 3);
@ -880,13 +880,13 @@ void sub_81982F0(void)
void sub_8198314(void) void sub_8198314(void)
{ {
if (gUnknown_0203CDA0 != 0xFF) if (gUnknown_0203CDA0 != INVALID_U8)
{ {
FillWindowPixelBuffer(gUnknown_0203CDA0, 0); FillWindowPixelBuffer(gUnknown_0203CDA0, 0);
ClearWindowTilemap(gUnknown_0203CDA0); ClearWindowTilemap(gUnknown_0203CDA0);
CopyWindowToVram(gUnknown_0203CDA0, 3); CopyWindowToVram(gUnknown_0203CDA0, 3);
RemoveWindow(gUnknown_0203CDA0); RemoveWindow(gUnknown_0203CDA0);
gUnknown_0203CDA0 = 0xFF; gUnknown_0203CDA0 = INVALID_U8;
} }
} }

View File

@ -1,7 +1,7 @@
#include "global.h" #include "global.h"
#include "event_object_movement.h" #include "event_object_movement.h"
#include "fieldmap.h" #include "fieldmap.h"
#include "malloc.h" #include "alloc.h"
#include "mossdeep_gym.h" #include "mossdeep_gym.h"
#include "script_movement.h" #include "script_movement.h"
#include "constants/event_object_movement_constants.h" #include "constants/event_object_movement_constants.h"

View File

@ -1,6 +1,6 @@
#include "global.h" #include "global.h"
#include "naming_screen.h" #include "naming_screen.h"
#include "malloc.h" #include "alloc.h"
#include "palette.h" #include "palette.h"
#include "task.h" #include "task.h"
#include "sprite.h" #include "sprite.h"
@ -2141,7 +2141,7 @@ static const struct SpriteTemplate sSpriteTemplate_Underscore =
static const struct SpriteTemplate gUnknown_0858C180 = static const struct SpriteTemplate gUnknown_0858C180 =
{ {
.tileTag = 0xFFFF, .tileTag = INVALID_U16,
.paletteTag = 0x0000, .paletteTag = 0x0000,
.oam = &gOamData_858BFEC, .oam = &gOamData_858BFEC,
.anims = gSpriteAnimTable_858C0BC, .anims = gSpriteAnimTable_858C0BC,

View File

@ -27,7 +27,7 @@
#include "link_rfu.h" #include "link_rfu.h"
#include "load_save.h" #include "load_save.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "m4a.h" #include "m4a.h"
#include "map_name_popup.h" #include "map_name_popup.h"
#include "menu.h" #include "menu.h"
@ -1110,7 +1110,7 @@ static bool16 IsInflitratedSpaceCenter(struct WarpData *warp)
u16 GetLocationMusic(struct WarpData *warp) u16 GetLocationMusic(struct WarpData *warp)
{ {
if (NoMusicInSotopolisWithLegendaries(warp) == TRUE) if (NoMusicInSotopolisWithLegendaries(warp) == TRUE)
return 0xFFFF; return INVALID_U16;
else if (ShouldLegendaryMusicPlayAtLocation(warp) == TRUE) else if (ShouldLegendaryMusicPlayAtLocation(warp) == TRUE)
return MUS_OOAME; return MUS_OOAME;
else if (IsInflitratedSpaceCenter(warp) == TRUE) else if (IsInflitratedSpaceCenter(warp) == TRUE)
@ -1171,7 +1171,7 @@ void Overworld_PlaySpecialMapMusic(void)
{ {
u16 music = GetCurrLocationDefaultMusic(); u16 music = GetCurrLocationDefaultMusic();
if (music != MUS_OOAME && music != 0xFFFF) if (music != MUS_OOAME && music != INVALID_U16)
{ {
if (gSaveBlock1Ptr->savedMusic) if (gSaveBlock1Ptr->savedMusic)
music = gSaveBlock1Ptr->savedMusic; music = gSaveBlock1Ptr->savedMusic;
@ -1201,7 +1201,7 @@ static void sub_8085810(void)
{ {
u16 newMusic = GetWarpDestinationMusic(); u16 newMusic = GetWarpDestinationMusic();
u16 currentMusic = GetCurrentMapMusic(); u16 currentMusic = GetCurrentMapMusic();
if (newMusic != MUS_OOAME && newMusic != 0xFFFF) if (newMusic != MUS_OOAME && newMusic != INVALID_U16)
{ {
if (currentMusic == MUS_DEEPDEEP || currentMusic == MUS_NAMINORI) if (currentMusic == MUS_DEEPDEEP || currentMusic == MUS_NAMINORI)
return; return;

View File

@ -63,7 +63,7 @@ static EWRAM_DATA u32 sPlttBufferTransferPending = 0;
EWRAM_DATA u8 gPaletteDecompressionBuffer[PLTT_DECOMP_BUFFER_SIZE] = {0}; EWRAM_DATA u8 gPaletteDecompressionBuffer[PLTT_DECOMP_BUFFER_SIZE] = {0};
static const struct PaletteStructTemplate gDummyPaletteStructTemplate = { static const struct PaletteStructTemplate gDummyPaletteStructTemplate = {
.uid = 0xFFFF, .uid = INVALID_U16,
.pst_field_B_5 = 1 .pst_field_B_5 = 1
}; };

View File

@ -15,7 +15,7 @@
#include "list_menu.h" #include "list_menu.h"
#include "mail.h" #include "mail.h"
#include "main.h" #include "main.h"
#include "malloc.h" #include "alloc.h"
#include "menu.h" #include "menu.h"
#include "menu_helpers.h" #include "menu_helpers.h"
#include "overworld.h" #include "overworld.h"

Some files were not shown because too many files have changed in this diff Show More