summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c210
-rw-r--r--src/apprentice.c12
-rw-r--r--src/bard_music.c2
-rw-r--r--src/battle_ai_script_commands.c24
-rw-r--r--src/battle_ai_switch_items.c8
-rw-r--r--src/battle_anim.c48
-rw-r--r--src/battle_anim_80A5C6C.c4
-rw-r--r--src/battle_anim_80A9C70.c10
-rw-r--r--src/battle_anim_sound_tasks.c4
-rw-r--r--src/battle_anim_utility_funcs.c4
-rw-r--r--src/battle_arena.c2
-rw-r--r--src/battle_controller_link_opponent.c4
-rw-r--r--src/battle_controller_link_partner.c4
-rw-r--r--src/battle_controller_opponent.c4
-rw-r--r--src/battle_controller_player.c8
-rw-r--r--src/battle_controller_player_partner.c6
-rw-r--r--src/battle_controller_recorded_opponent.c4
-rw-r--r--src/battle_controller_recorded_player.c4
-rw-r--r--src/battle_controller_wally.c2
-rw-r--r--src/battle_controllers.c2
-rw-r--r--src/battle_dome.c96
-rw-r--r--src/battle_factory.c4
-rw-r--r--src/battle_factory_screen.c2
-rw-r--r--src/battle_gfx_sfx_util.c4
-rw-r--r--src/battle_interface.c28
-rw-r--r--src/battle_main.c26
-rw-r--r--src/battle_message.c4
-rw-r--r--src/battle_pike.c6
-rw-r--r--src/battle_pyramid.c4
-rw-r--r--src/battle_pyramid_bag.c38
-rw-r--r--src/battle_records.c2
-rw-r--r--src/battle_script_commands.c52
-rw-r--r--src/battle_setup.c20
-rw-r--r--src/battle_tent.c2
-rw-r--r--src/battle_tower.c10
-rw-r--r--src/battle_transition.c14
-rw-r--r--src/battle_tv.c20
-rw-r--r--src/battle_util.c20
-rw-r--r--src/battle_util2.c2
-rw-r--r--src/berry_blender.c6
-rw-r--r--src/berry_fix_program.c2
-rw-r--r--src/berry_tag_screen.c2
-rw-r--r--src/bg.c36
-rw-r--r--src/blit.c6
-rw-r--r--src/braille_puzzles.c2
-rw-r--r--src/cable_club.c6
-rw-r--r--src/contest.c18
-rw-r--r--src/contest_effect.c28
-rw-r--r--src/credits.c2
-rw-r--r--src/data2b.c2
-rw-r--r--src/daycare.c16
-rw-r--r--src/decompress.c2
-rw-r--r--src/decoration.c16
-rw-r--r--src/dewford_trend.c2
-rw-r--r--src/diploma.c2
-rw-r--r--src/easy_chat.c2
-rw-r--r--src/egg_hatch.c2
-rw-r--r--src/event_object_movement.c54
-rw-r--r--src/evolution_scene.c6
-rw-r--r--src/field_control_avatar.c6
-rw-r--r--src/field_door.c2
-rw-r--r--src/field_effect.c22
-rwxr-xr-xsrc/field_message_box.c2
-rw-r--r--src/field_player_avatar.c2
-rw-r--r--src/field_region_map.c2
-rw-r--r--src/field_specials.c22
-rw-r--r--src/fieldmap.c4
-rw-r--r--src/fldeff_cut.c4
-rw-r--r--src/fldeff_groundshake.c4
-rw-r--r--src/fossil_specials.c4
-rw-r--r--src/frontier_util.c14
-rw-r--r--src/ground.c2
-rw-r--r--src/hall_of_fame.c44
-rw-r--r--src/intro.c2
-rw-r--r--src/intro_credits_graphics.c2
-rw-r--r--src/item.c2
-rw-r--r--src/item_icon.c4
-rwxr-xr-xsrc/item_menu.c38
-rw-r--r--src/item_menu_icons.c8
-rw-r--r--src/learn_move.c20
-rw-r--r--src/librfu_rfu.c2
-rw-r--r--src/librfu_stwi.c2
-rw-r--r--src/link.c6
-rw-r--r--src/link_rfu.c36
-rw-r--r--src/list_menu.c8
-rw-r--r--src/load_save.c2
-rw-r--r--src/mail.c2
-rw-r--r--src/mail_data.c18
-rw-r--r--src/main.c2
-rw-r--r--src/malloc.c210
-rw-r--r--src/mauville_old_man.c6
-rw-r--r--src/menu.c30
-rw-r--r--src/mossdeep_gym.c2
-rw-r--r--src/naming_screen.c4
-rw-r--r--src/overworld.c8
-rw-r--r--src/palette.c2
-rw-r--r--src/player_pc.c2
-rw-r--r--src/pokeblock.c12
-rw-r--r--src/pokeblock_feed.c2
-rw-r--r--src/pokedex.c38
-rwxr-xr-xsrc/pokedex_cry_screen.c2
-rw-r--r--src/pokemon.c48
-rw-r--r--src/pokemon_animation.c20
-rw-r--r--src/pokemon_icon.c6
-rw-r--r--src/pokemon_size_record.c2
-rw-r--r--src/pokemon_storage_system.c4
-rw-r--r--src/pokemon_summary_screen.c60
-rw-r--r--src/rayquaza_scene.c2
-rw-r--r--src/record_mixing.c6
-rw-r--r--src/recorded_battle.c4
-rw-r--r--src/region_map.c2
-rw-r--r--src/reset_rtc_screen.c2
-rw-r--r--src/reset_save_heap.c2
-rw-r--r--src/rock.c2
-rw-r--r--src/rom_8011DC0.c18
-rw-r--r--src/rom_8034C54.c8
-rw-r--r--src/rom_81520A8.c2
-rw-r--r--src/rotating_gate.c4
-rw-r--r--src/rtc.c10
-rw-r--r--src/safari_zone.c6
-rw-r--r--src/save.c50
-rw-r--r--src/save_location.c8
-rw-r--r--src/scanline_effect.c8
-rw-r--r--src/scrcmd.c4
-rw-r--r--src/script.c12
-rw-r--r--src/script_menu.c28
-rw-r--r--src/script_movement.c8
-rwxr-xr-xsrc/script_pokemon_util_80F87D8.c4
-rw-r--r--src/secret_base.c8
-rwxr-xr-xsrc/shop.c22
-rw-r--r--src/slot_machine.c12
-rw-r--r--src/smokescreen.c2
-rw-r--r--src/sound.c4
-rw-r--r--src/sprite.c64
-rw-r--r--src/task.c4
-rw-r--r--src/text.c4
-rw-r--r--src/trader.c2
-rw-r--r--src/trainer_pokemon_sprites.c42
-rw-r--r--src/tv.c112
-rw-r--r--src/unk_pokedex_area_screen_helper.c2
-rw-r--r--src/use_pokeblock.c2
-rw-r--r--src/walda_phrase.c2
-rw-r--r--src/wild_encounter.c16
-rw-r--r--src/window.c40
144 files changed, 1103 insertions, 1103 deletions
diff --git a/src/alloc.c b/src/alloc.c
new file mode 100644
index 000000000..2944bc1c6
--- /dev/null
+++ b/src/alloc.c
@@ -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;
+}
diff --git a/src/apprentice.c b/src/apprentice.c
index 499f85094..faed3756c 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -9,7 +9,7 @@
#include "item.h"
#include "item_menu.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "new_game.h"
#include "party_menu.h"
@@ -1079,7 +1079,7 @@ void ResetApprenticeStruct(struct Apprentice *apprentice)
u8 i;
for (i = 0; i < 6; i++)
- apprentice->easyChatWords[i] |= 0xFFFF;
+ apprentice->easyChatWords[i] |= INVALID_U16;
apprentice->playerName[0] = EOS;
apprentice->id = 16;
@@ -1093,7 +1093,7 @@ void ResetAllApprenticeData(void)
for (i = 0; i < 4; i++)
{
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].playerName[0] = EOS;
gSaveBlock2Ptr->apprentices[i].lvlMode = 0;
@@ -1290,7 +1290,7 @@ static u16 sub_819FF98(u8 arg0)
else
level = 60;
- for (j = 0; learnset[j] != 0xFFFF; j++)
+ for (j = 0; learnset[j] != INVALID_U16; j++)
{
if ((learnset[j] & 0xFE00) > (level << 9))
break;
@@ -1393,7 +1393,7 @@ static void GetLatestLearnedMoves(u16 species, u16 *moves)
level = 60;
learnset = gLevelUpLearnsets[species];
- for (i = 0; learnset[i] != 0xFFFF; i++)
+ for (i = 0; learnset[i] != INVALID_U16; i++)
{
if ((learnset[i] & 0xFE00) > (level << 9))
break;
@@ -2236,7 +2236,7 @@ static void sub_81A1370(void)
}
r10 = 0xFFFF;
- r9 = -1;
+ r9 = INVALID_S32;
for (i = 1; i < 4; i++)
{
if (GetTrainerId(gSaveBlock2Ptr->apprentices[i].playerId) == GetTrainerId(gSaveBlock2Ptr->playerTrainerId)
diff --git a/src/bard_music.c b/src/bard_music.c
index 6c2578071..4c28233c2 100644
--- a/src/bard_music.c
+++ b/src/bard_music.c
@@ -54,7 +54,7 @@ void GetWordPhonemes(struct BardSong *song, u16 word)
for (i = 0; i < 6; 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].pitch = CalcWordPitch(word + 30, i);
diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c
index 3e7064eb5..e6c089b1b 100644
--- a/src/battle_ai_script_commands.c
+++ b/src/battle_ai_script_commands.c
@@ -276,7 +276,7 @@ static const u16 sDiscouragedPowerfulMoveEffects[] =
EFFECT_SUPERPOWER,
EFFECT_ERUPTION,
EFFECT_OVERHEAT,
- 0xFFFF
+ INVALID_U16
};
// code
@@ -463,8 +463,8 @@ static u8 ChooseMoveOrAction_Doubles(void)
{
if (i == sBattler_AI || gBattleMons[i].hp == 0)
{
- actionOrMoveIndex[i] = -1;
- bestMovePointsForTarget[i] = -1;
+ actionOrMoveIndex[i] = INVALID_U8;
+ bestMovePointsForTarget[i] = INVALID_S16 ;
}
else
{
@@ -530,7 +530,7 @@ static u8 ChooseMoveOrAction_Doubles(void)
// Don't use a move against ally if it has less than 100 points.
if (i == (sBattler_AI ^ BIT_FLANK) && bestMovePointsForTarget[i] < 100)
{
- bestMovePointsForTarget[i] = -1;
+ bestMovePointsForTarget[i] = INVALID_S16;
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);
- while (*ptr != 0xFF)
+ while (*ptr != INVALID_U8)
{
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);
- while (*ptr != 0xFF)
+ while (*ptr != INVALID_U8)
{
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);
- while (*ptr != 0xFFFF)
+ while (*ptr != INVALID_U16)
{
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);
- while (*ptr != 0xFFFF)
+ while (*ptr != INVALID_U16)
{
if (AI_THINKING_STRUCT->funcResult == *ptr)
{
@@ -1167,14 +1167,14 @@ static void BattleAICmd_get_how_powerful_move_is(void)
s32 i, checkedMove;
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])
break;
}
if (gBattleMoves[AI_THINKING_STRUCT->moveConsidered].power > 1
- && sDiscouragedPowerfulMoveEffects[i] == 0xFFFF)
+ && sDiscouragedPowerfulMoveEffects[i] == INVALID_U16)
{
gDynamicBasePower = 0;
*(&gBattleStruct->dynamicMoveType) = 0;
@@ -1184,14 +1184,14 @@ static void BattleAICmd_get_how_powerful_move_is(void)
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])
break;
}
if (gBattleMons[sBattler_AI].moves[checkedMove] != MOVE_NONE
- && sDiscouragedPowerfulMoveEffects[i] == 0xFFFF
+ && sDiscouragedPowerfulMoveEffects[i] == INVALID_U16
&& gBattleMoves[gBattleMons[sBattler_AI].moves[checkedMove]].power > 1)
{
gCurrentMove = gBattleMons[sBattler_AI].moves[checkedMove];
diff --git a/src/battle_ai_switch_items.c b/src/battle_ai_switch_items.c
index ad25b483c..d6a8e1336 100644
--- a/src/battle_ai_switch_items.c
+++ b/src/battle_ai_switch_items.c
@@ -126,7 +126,7 @@ static bool8 FindMonThatAbsorbsOpponentsMove(void)
return FALSE;
if (gLastLandedMoves[gActiveBattler] == 0)
return FALSE;
- if (gLastLandedMoves[gActiveBattler] == 0xFFFF)
+ if (gLastLandedMoves[gActiveBattler] == INVALID_U16)
return FALSE;
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
return FALSE;
@@ -221,7 +221,7 @@ static bool8 ShouldSwitchIfNaturalCure(void)
if (gBattleMons[gActiveBattler].hp < gBattleMons[gActiveBattler].maxHP / 2)
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;
BtlController_EmitTwoReturnValues(1, B_ACTION_SWITCH, 0);
@@ -331,9 +331,9 @@ static bool8 FindMonWithFlagsAndSuperEffective(u8 flags, u8 moduloPercent)
if (gLastLandedMoves[gActiveBattler] == 0)
return FALSE;
- if (gLastLandedMoves[gActiveBattler] == 0xFFFF)
+ if (gLastLandedMoves[gActiveBattler] == INVALID_U16)
return FALSE;
- if (gLastHitBy[gActiveBattler] == 0xFF)
+ if (gLastHitBy[gActiveBattler] == INVALID_U8)
return FALSE;
if (gBattleMoves[gLastLandedMoves[gActiveBattler]].power == 0)
return FALSE;
diff --git a/src/battle_anim.c b/src/battle_anim.c
index e8720fcfb..68ffed834 100644
--- a/src/battle_anim.c
+++ b/src/battle_anim.c
@@ -1452,14 +1452,14 @@ void ClearBattleAnimationVars(void)
// Clear index array.
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
- sAnimSpriteIndexArray[i] |= 0xFFFF;
+ sAnimSpriteIndexArray[i] |= INVALID_U16;
// Clear anim args.
for (i = 0; i < ANIM_ARGS_COUNT; i++)
gBattleAnimArgs[i] = 0;
- sMonAnimTaskIdArray[0] = 0xFF;
- sMonAnimTaskIdArray[1] = 0xFF;
+ sMonAnimTaskIdArray[0] = INVALID_U8;
+ sMonAnimTaskIdArray[1] = INVALID_U8;
gAnimMoveTurn = 0;
sAnimBackgroundFadeState = 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++)
gBattleAnimArgs[i] = 0;
- sMonAnimTaskIdArray[0] = 0xFF;
- sMonAnimTaskIdArray[1] = 0xFF;
+ sMonAnimTaskIdArray[0] = INVALID_U8;
+ sMonAnimTaskIdArray[1] = INVALID_U8;
sBattleAnimScriptPtr = animsTable[tableId];
gAnimScriptActive = TRUE;
gAnimFramesToWait = 0;
gAnimScriptCallback = RunAnimScriptCommand;
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
- sAnimSpriteIndexArray[i] |= 0xFFFF;
+ sAnimSpriteIndexArray[i] |= INVALID_U16;
if (isMoveAnim)
{
- for (i = 0; gMovesWithQuietBGM[i] != 0xFFFF; i++)
+ for (i = 0; gMovesWithQuietBGM[i] != INVALID_U16; i++)
{
if (tableId == gMovesWithQuietBGM[i])
{
@@ -1558,7 +1558,7 @@ static void AddSpriteIndex(u16 index)
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
{
- if (sAnimSpriteIndexArray[i] == 0xFFFF)
+ if (sAnimSpriteIndexArray[i] == INVALID_U16)
{
sAnimSpriteIndexArray[i] = index;
return;
@@ -1574,7 +1574,7 @@ static void ClearSpriteIndex(u16 index)
{
if (sAnimSpriteIndexArray[i] == index)
{
- sAnimSpriteIndexArray[i] |= 0xFFFF;
+ sAnimSpriteIndexArray[i] |= INVALID_U16;
return;
}
}
@@ -1712,7 +1712,7 @@ static void ScriptCmd_delay(void)
sBattleAnimScriptPtr++;
gAnimFramesToWait = sBattleAnimScriptPtr[0];
if (gAnimFramesToWait == 0)
- gAnimFramesToWait = -1;
+ gAnimFramesToWait = INVALID_S8;
sBattleAnimScriptPtr++;
gAnimScriptCallback = WaitAnimFrameCount;
}
@@ -1746,7 +1746,7 @@ static void ScriptCmd_end(void)
// Keep waiting as long as there are animations to be done.
if (gAnimVisualTaskCount != 0 || gAnimSoundTaskCount != 0
- || sMonAnimTaskIdArray[0] != 0xFF || sMonAnimTaskIdArray[1] != 0xFF)
+ || sMonAnimTaskIdArray[0] != INVALID_U8 || sMonAnimTaskIdArray[1] != INVALID_U8)
{
sSoundAnimFramesToWait = 0;
gAnimFramesToWait = 1;
@@ -1773,11 +1773,11 @@ static void ScriptCmd_end(void)
for (i = 0; i < ANIM_SPRITE_INDEX_COUNT; i++)
{
- if (sAnimSpriteIndexArray[i] != 0xFFFF)
+ if (sAnimSpriteIndexArray[i] != INVALID_U16)
{
FreeSpriteTilesByTag(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
battlerId = gBattleAnimTarget;
- if (sMonAnimTaskIdArray[0] != 0xFF)
+ if (sMonAnimTaskIdArray[0] != INVALID_U8)
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;
else
animBattlerId = 0;
@@ -2148,17 +2148,17 @@ static void sub_80A4980(u8 taskId)
else
to_BG2 = TRUE;
- if (sMonAnimTaskIdArray[0] != 0xFF)
+ if (sMonAnimTaskIdArray[0] != INVALID_U8)
{
sub_80A477C(to_BG2);
DestroyTask(sMonAnimTaskIdArray[0]);
- sMonAnimTaskIdArray[0] = 0xFF;
+ sMonAnimTaskIdArray[0] = INVALID_U8;
}
if (gTasks[taskId].data[0] > 1)
{
sub_80A477C(to_BG2 ^ 1);
DestroyTask(sMonAnimTaskIdArray[1]);
- sMonAnimTaskIdArray[1] = 0xFF;
+ sMonAnimTaskIdArray[1] = INVALID_U8;
}
DestroyTask(taskId);
}
@@ -2421,7 +2421,7 @@ static void Task_FadeToBg(u8 taskId)
{
s16 bgId = gTasks[taskId].tBackgroundId;
- if (bgId == -1)
+ if (bgId == INVALID_S16)
LoadDefaultBg();
else
LoadMoveBg(bgId);
@@ -2477,7 +2477,7 @@ static void ScriptCmd_restorebg(void)
sBattleAnimScriptPtr++;
taskId = CreateTask(Task_FadeToBg, 5);
- gTasks[taskId].tBackgroundId = -1;
+ gTasks[taskId].tBackgroundId = INVALID_S16;
sAnimBackgroundFadeState = 1;
}
@@ -3001,7 +3001,7 @@ static void ScriptCmd_invisible(void)
u8 spriteId;
spriteId = GetAnimBattlerSpriteId(sBattleAnimScriptPtr[1]);
- if (spriteId != 0xFF)
+ if (spriteId != INVALID_U8)
gSprites[spriteId].invisible = TRUE;
sBattleAnimScriptPtr += 2;
@@ -3012,7 +3012,7 @@ static void ScriptCmd_visible(void)
u8 spriteId;
spriteId = GetAnimBattlerSpriteId(sBattleAnimScriptPtr[1]);
- if (spriteId != 0xFF)
+ if (spriteId != INVALID_U8)
gSprites[spriteId].invisible = FALSE;
sBattleAnimScriptPtr += 2;
@@ -3039,7 +3039,7 @@ static void ScriptCmd_doublebattle_2D(void)
r4 = sub_80A8364(gBattleAnimTarget);
spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
}
- if (spriteId != 0xFF)
+ if (spriteId != INVALID_U8)
{
gSprites[spriteId].invisible = FALSE;
if (r4 == 2)
@@ -3075,7 +3075,7 @@ static void ScriptCmd_doublebattle_2E(void)
spriteId = GetAnimBattlerSpriteId(ANIM_TARGET);
}
- if (spriteId != 0xFF && r4 == 2)
+ if (spriteId != INVALID_U8 && r4 == 2)
gSprites[spriteId].oam.priority = 2;
}
}
diff --git a/src/battle_anim_80A5C6C.c b/src/battle_anim_80A5C6C.c
index 2ac6cca90..1a2c279ec 100644
--- a/src/battle_anim_80A5C6C.c
+++ b/src/battle_anim_80A5C6C.c
@@ -7,7 +7,7 @@
#include "decompress.h"
#include "dma3.h"
#include "gpu_regs.h"
-#include "malloc.h"
+#include "alloc.h"
#include "palette.h"
#include "pokemon_icon.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)
diff --git a/src/battle_anim_80A9C70.c b/src/battle_anim_80A9C70.c
index f1245a032..c329a134d 100644
--- a/src/battle_anim_80A9C70.c
+++ b/src/battle_anim_80A9C70.c
@@ -183,7 +183,7 @@ void sub_80A9EF4(u8 taskId)
SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL);
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16));
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;
SetSubspriteTables(&gSprites[spriteId], gUnknown_0853EF40);
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_EVASION): goesDown = TRUE; animStatId = 4; sharply = TRUE; break;
- case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = 0xFF; sharply = FALSE; break;
- case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = 0xFF; sharply = TRUE; break;
- case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = 0xFF; sharply = FALSE; break;
- case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = 0xFF; sharply = TRUE; break;
+ case STAT_ANIM_MULTIPLE_PLUS1: goesDown = FALSE; animStatId = INVALID_U8; sharply = FALSE; break;
+ case STAT_ANIM_MULTIPLE_PLUS2: goesDown = FALSE; animStatId = INVALID_U8; sharply = TRUE; break;
+ case STAT_ANIM_MULTIPLE_MINUS1: goesDown = TRUE; animStatId = INVALID_U8; sharply = FALSE; break;
+ case STAT_ANIM_MULTIPLE_MINUS2: goesDown = TRUE; animStatId = INVALID_U8; sharply = TRUE; break;
default:
DestroyAnimVisualTask(taskId);
diff --git a/src/battle_anim_sound_tasks.c b/src/battle_anim_sound_tasks.c
index 07fb604b8..36738d36e 100644
--- a/src/battle_anim_sound_tasks.c
+++ b/src/battle_anim_sound_tasks.c
@@ -214,7 +214,7 @@ void sub_8158E9C(u8 taskId)
if (species != SPECIES_NONE)
{
- if (gBattleAnimArgs[1] == 0xFF)
+ if (gBattleAnimArgs[1] == INVALID_U8)
PlayCry3(species, pan, 9);
else
PlayCry3(species, pan, 7);
@@ -238,7 +238,7 @@ static void sub_8158FF4(u8 taskId)
}
else
{
- if (gTasks[taskId].data[0] == 0xFF)
+ if (gTasks[taskId].data[0] == INVALID_U8)
{
if (!IsCryPlaying())
{
diff --git a/src/battle_anim_utility_funcs.c b/src/battle_anim_utility_funcs.c
index 6dfebe77f..5ed30ddc0 100644
--- a/src/battle_anim_utility_funcs.c
+++ b/src/battle_anim_utility_funcs.c
@@ -3,7 +3,7 @@
#include "contest.h"
#include "gpu_regs.h"
#include "graphics.h"
-#include "malloc.h"
+#include "alloc.h"
#include "palette.h"
#include "sound.h"
#include "sprite.h"
@@ -82,7 +82,7 @@ void sub_8116664(u8 taskId)
animBattlers[1] = gBattleAnimTarget;
break;
case 5:
- animBattlers[0] = 0xFF;
+ animBattlers[0] = INVALID_U8;
break;
case 6:
selectedPalettes = 0;
diff --git a/src/battle_arena.c b/src/battle_arena.c
index cd2c976da..591fc82b9 100644
--- a/src/battle_arena.c
+++ b/src/battle_arena.c
@@ -449,7 +449,7 @@ static const union AnimCmd *const sSpriteAnimTable_8611F4C[] =
static const struct SpriteTemplate sSpriteTemplate_JudgmentIcon =
{
.tileTag = 0x3E8,
- .paletteTag = 0xFFFF,
+ .paletteTag = INVALID_U16,
.oam = &sOamData_8611F24,
.anims = sSpriteAnimTable_8611F4C,
.images = NULL,
diff --git a/src/battle_controller_link_opponent.c b/src/battle_controller_link_opponent.c
index 8cbc62aab..d65c61884 100644
--- a/src/battle_controller_link_opponent.c
+++ b/src/battle_controller_link_opponent.c
@@ -212,7 +212,7 @@ static void sub_8064470(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;
LinkOpponentBufferExecCompleted();
@@ -395,7 +395,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
- if (hpValue != -1)
+ if (hpValue != INVALID_S16)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
diff --git a/src/battle_controller_link_partner.c b/src/battle_controller_link_partner.c
index 0cd15f39e..8bbbcbfd1 100644
--- a/src/battle_controller_link_partner.c
+++ b/src/battle_controller_link_partner.c
@@ -203,7 +203,7 @@ static void sub_814AF54(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;
LinkPartnerBufferExecCompleted();
@@ -279,7 +279,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
- if (hpValue != -1)
+ if (hpValue != INVALID_S16)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
diff --git a/src/battle_controller_opponent.c b/src/battle_controller_opponent.c
index c057e8575..0aeb24c32 100644
--- a/src/battle_controller_opponent.c
+++ b/src/battle_controller_opponent.c
@@ -220,7 +220,7 @@ static void sub_805F240(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;
OpponentBufferExecCompleted();
@@ -389,7 +389,7 @@ static void CompleteOnHealthbarDone(void)
{
s16 hpValue = MoveBattleBar(gActiveBattler, gHealthboxSpriteIds[gActiveBattler], HEALTH_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
- if (hpValue != -1)
+ if (hpValue != INVALID_S16)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
diff --git a/src/battle_controller_player.c b/src/battle_controller_player.c
index 2bd5ef365..3053e6c37 100644
--- a/src/battle_controller_player.c
+++ b/src/battle_controller_player.c
@@ -635,7 +635,7 @@ u32 sub_8057FBC(void) // unused
PlaySE(SE_SELECT);
gBattle_BG0_X = 0;
gBattle_BG0_Y = 0x140;
- var = 0xFF;
+ var = INVALID_U8;
}
if (gMain.newKeys & DPAD_LEFT && gMoveSelectionCursor[gActiveBattler] & 1)
{
@@ -936,7 +936,7 @@ static void sub_80588B4(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;
PlayerBufferExecCompleted();
@@ -1119,7 +1119,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
- if (hpValue != -1)
+ if (hpValue != INVALID_S16)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
@@ -1221,7 +1221,7 @@ static void sub_8059400(u8 taskId)
newExpPoints = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
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;
s32 currExp;
diff --git a/src/battle_controller_player_partner.c b/src/battle_controller_player_partner.c
index 02dd1383b..775b7676f 100644
--- a/src/battle_controller_player_partner.c
+++ b/src/battle_controller_player_partner.c
@@ -218,7 +218,7 @@ static void sub_81BAE98(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;
PlayerPartnerBufferExecCompleted();
@@ -294,7 +294,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
- if (hpValue != -1)
+ if (hpValue != INVALID_S16)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
@@ -397,7 +397,7 @@ static void sub_81BB4E4(u8 taskId)
r4 = MoveBattleBar(battlerId, gHealthboxSpriteIds[battlerId], EXP_BAR, 0);
SetHealthboxSpriteVisible(gHealthboxSpriteIds[battlerId]);
- if (r4 == -1)
+ if (r4 == INVALID_S16)
{
u8 level;
s32 currExp;
diff --git a/src/battle_controller_recorded_opponent.c b/src/battle_controller_recorded_opponent.c
index 0cf3634dc..842facd44 100644
--- a/src/battle_controller_recorded_opponent.c
+++ b/src/battle_controller_recorded_opponent.c
@@ -213,7 +213,7 @@ static void sub_81865C8(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;
RecordedOpponentBufferExecCompleted();
@@ -377,7 +377,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
- if (hpValue != -1)
+ if (hpValue != INVALID_S16)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
diff --git a/src/battle_controller_recorded_player.c b/src/battle_controller_recorded_player.c
index 4d7fdc01e..60bec78b1 100644
--- a/src/battle_controller_recorded_player.c
+++ b/src/battle_controller_recorded_player.c
@@ -202,7 +202,7 @@ static void sub_81899F0(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;
RecordedPlayerBufferExecCompleted();
@@ -360,7 +360,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
- if (hpValue != -1)
+ if (hpValue != INVALID_S16)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
diff --git a/src/battle_controller_wally.c b/src/battle_controller_wally.c
index 5d87c4f90..9078ef577 100644
--- a/src/battle_controller_wally.c
+++ b/src/battle_controller_wally.c
@@ -348,7 +348,7 @@ static void CompleteOnHealthbarDone(void)
SetHealthboxSpriteVisible(gHealthboxSpriteIds[gActiveBattler]);
- if (hpValue != -1)
+ if (hpValue != INVALID_S16)
{
UpdateHpTextInHealthbox(gHealthboxSpriteIds[gActiveBattler], hpValue, HP_CURRENT);
}
diff --git a/src/battle_controllers.c b/src/battle_controllers.c
index a6d6e9294..e24549d82 100644
--- a/src/battle_controllers.c
+++ b/src/battle_controllers.c
@@ -51,7 +51,7 @@ void SetUpBattleVarsAndBirchZigzagoon(void)
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
{
gBattlerControllerFuncs[i] = nullsub_21;
- gBattlerPositions[i] = 0xFF;
+ gBattlerPositions[i] = INVALID_U8;
gActionSelectionCursor[i] = 0;
gMoveSelectionCursor[i] = 0;
}
diff --git a/src/battle_dome.c b/src/battle_dome.c
index 0f5721fb9..f03de7505 100644
--- a/src/battle_dome.c
+++ b/src/battle_dome.c
@@ -8,7 +8,7 @@
#include "event_data.h"
#include "overworld.h"
#include "util.h"
-#include "malloc.h"
+#include "alloc.h"
#include "string_util.h"
#include "random.h"
#include "task.h"
@@ -3032,7 +3032,7 @@ static s32 GetTypeEffectivenessPoints(s32 move, s32 targetSpecies, s32 arg2)
s32 i = 0;
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;
defType1 = gBaseStats[targetSpecies].type1;
@@ -3434,14 +3434,14 @@ static s32 TournamentIdOfOpponent(s32 roundId, s32 trainerId)
if (j != val)
return gUnknown_0860D14C[j];
else
- return 0xFF;
+ return INVALID_U8;
}
else
{
if (!gSaveBlock2Ptr->frontier.domeTrainers[sIdToOpponentId[i][roundId]].isEliminated)
return sIdToOpponentId[i][roundId];
else
- return 0xFF;
+ return INVALID_U8;
}
}
@@ -3562,7 +3562,7 @@ static void sub_8190400(u8 taskId)
SetVBlankCallback(VblankCb0_BattleDome);
sBattleDomeStruct = AllocZeroed(sizeof(*sBattleDomeStruct));
for (i = 0; i < DOME_TOURNAMENT_TRAINERS_COUNT; i++)
- sBattleDomeStruct->arr[i] |= 0xFF;
+ sBattleDomeStruct->arr[i] |= INVALID_U8;
LoadMonIconPalettes();
i = CreateTask(sub_8190CD4, 0);
gTasks[i].data[0] = 0;
@@ -3624,7 +3624,7 @@ static void SpriteCb_TrainerIconCardScrollUp(struct Sprite *sprite)
{
if (sprite->pos1.y >= 192)
{
- sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
FreeAndDestroyTrainerPicSprite(sprite->data[3]);
}
}
@@ -3644,7 +3644,7 @@ static void SpriteCb_TrainerIconCardScrollDown(struct Sprite *sprite)
{
if (sprite->pos1.y <= -32)
{
- sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
FreeAndDestroyTrainerPicSprite(sprite->data[3]);
}
}
@@ -3664,7 +3664,7 @@ static void SpriteCb_TrainerIconCardScrollLeft(struct Sprite *sprite)
{
if (sprite->pos1.x >= 272)
{
- sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
FreeAndDestroyTrainerPicSprite(sprite->data[3]);
}
}
@@ -3684,7 +3684,7 @@ static void SpriteCb_TrainerIconCardScrollRight(struct Sprite *sprite)
{
if (sprite->pos1.x <= -32)
{
- sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
FreeAndDestroyTrainerPicSprite(sprite->data[3]);
}
}
@@ -3714,7 +3714,7 @@ static void SpriteCb_MonIconCardScrollUp(struct Sprite *sprite)
{
if (sprite->pos1.y >= 176)
{
- sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
sub_80D2EF8(sprite);
}
}
@@ -3736,7 +3736,7 @@ static void SpriteCb_MonIconCardScrollDown(struct Sprite *sprite)
{
if (sprite->pos1.y <= -16)
{
- sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
sub_80D2EF8(sprite);
}
}
@@ -3758,7 +3758,7 @@ static void SpriteCb_MonIconCardScrollLeft(struct Sprite *sprite)
{
if (sprite->pos1.x >= 256)
{
- sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
sub_80D2EF8(sprite);
}
}
@@ -3780,7 +3780,7 @@ static void SpriteCb_MonIconCardScrollRight(struct Sprite *sprite)
{
if (sprite->pos1.x <= -16)
{
- sBattleDomeStruct->arr[sprite->data[2]] = 0xFF;
+ sBattleDomeStruct->arr[sprite->data[2]] = INVALID_U8;
sub_80D2EF8(sprite);
}
}
@@ -4005,7 +4005,7 @@ static void sub_8190CD4(u8 taskId)
{
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]].data[0] = gTasks[taskId].data[2] ^ 1;
@@ -4016,7 +4016,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollUp;
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 (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollUp;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4040,7 +4040,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollUp;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4121,7 +4121,7 @@ static void sub_8190CD4(u8 taskId)
{
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]].data[0] = gTasks[taskId].data[2] ^ 1;
@@ -4132,7 +4132,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollDown;
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 (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollDown;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4156,7 +4156,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollDown;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4204,7 +4204,7 @@ static void sub_8190CD4(u8 taskId)
{
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]].data[0] = gTasks[taskId].data[2] ^ 1;
@@ -4215,7 +4215,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
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 (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4239,7 +4239,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4287,7 +4287,7 @@ static void sub_8190CD4(u8 taskId)
{
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]].data[0] = gTasks[taskId].data[2] ^ 1;
@@ -4298,7 +4298,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
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 (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4322,7 +4322,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollLeft;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4368,7 +4368,7 @@ static void sub_8190CD4(u8 taskId)
{
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]].data[0] = gTasks[taskId].data[2] ^ 1;
@@ -4379,7 +4379,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
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 (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4403,7 +4403,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4451,7 +4451,7 @@ static void sub_8190CD4(u8 taskId)
{
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]].data[0] = gTasks[taskId].data[2] ^ 1;
@@ -4462,7 +4462,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
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 (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_TrainerIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4486,7 +4486,7 @@ static void sub_8190CD4(u8 taskId)
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
{
gSprites[sBattleDomeStruct->arr[i]].callback = SpriteCb_MonIconCardScrollRight;
gSprites[sBattleDomeStruct->arr[i]].data[0] = gTasks[taskId].data[2];
@@ -4556,12 +4556,12 @@ static void sub_8190CD4(u8 taskId)
{
if (i < 2)
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
FreeAndDestroyTrainerPicSprite(sBattleDomeStruct->arr[i]);
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
sub_80D2EF8(&gSprites[sBattleDomeStruct->arr[i]]);
}
}
@@ -4569,12 +4569,12 @@ static void sub_8190CD4(u8 taskId)
{
if (i < 10)
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
FreeAndDestroyTrainerPicSprite(sBattleDomeStruct->arr[i]);
}
else
{
- if (sBattleDomeStruct->arr[i] != 0xFF)
+ if (sBattleDomeStruct->arr[i] != INVALID_U8)
sub_80D2EF8(&gSprites[sBattleDomeStruct->arr[i]]);
}
}
@@ -5483,13 +5483,13 @@ static u8 sub_8193BDC(u8 taskId)
}
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;
- 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;
- 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;
- 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;
}
@@ -6314,21 +6314,21 @@ static void DecideRoundWinners(u8 roundId)
tournamentId1 = i;
tournamentId2 = TournamentIdOfOpponent(roundId, gSaveBlock2Ptr->frontier.domeTrainers[tournamentId1].trainerId);
// 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].eliminatedAt = roundId;
gSaveBlock2Ptr->frontier.field_EC0[tournamentId2] = GetWinningMove(tournamentId1, tournamentId2, roundId);
}
// 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].eliminatedAt = roundId;
gSaveBlock2Ptr->frontier.field_EC0[tournamentId1] = GetWinningMove(tournamentId2, tournamentId1, roundId);
}
// 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.
diff --git a/src/battle_factory.c b/src/battle_factory.c
index 1d7fbafc9..dd82da746 100644
--- a/src/battle_factory.c
+++ b/src/battle_factory.c
@@ -202,9 +202,9 @@ static void sub_81A5E94(void)
gUnknown_03001288 = FALSE;
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++)
- gUnknown_03006298[i] |= 0xFFFF;
+ gUnknown_03006298[i] |= INVALID_U16;
saved_warp2_set(0, gSaveBlock1Ptr->location.mapGroup, gSaveBlock1Ptr->location.mapNum, -1);
gTrainerBattleOpponent_A = 0;
diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c
index 42a9b579c..60b233daf 100644
--- a/src/battle_factory_screen.c
+++ b/src/battle_factory_screen.c
@@ -10,7 +10,7 @@
#include "palette.h"
#include "task.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "bg.h"
#include "gpu_regs.h"
#include "string_util.h"
diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c
index 6f9d2db80..88dbb5360 100644
--- a/src/battle_gfx_sfx_util.c
+++ b/src/battle_gfx_sfx_util.c
@@ -6,7 +6,7 @@
#include "constants/battle_anim.h"
#include "battle_interface.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "graphics.h"
#include "random.h"
#include "util.h"
@@ -122,7 +122,7 @@ void FreeBattleSpritesData(void)
u16 ChooseMoveAndTargetInBattlePalace(void)
{
s32 i, var1, var2;
- s32 chosenMoveId = -1;
+ s32 chosenMoveId = INVALID_S32;
struct ChooseMoveStruct *moveInfo = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]);
u8 unusableMovesBits = CheckMoveLimitations(gActiveBattler, 0, 0xFF);
s32 percent = Random() % 100;
diff --git a/src/battle_interface.c b/src/battle_interface.c
index c7eb11293..fd6d2a0ab 100644
--- a/src/battle_interface.c
+++ b/src/battle_interface.c
@@ -589,17 +589,17 @@ static void sub_8072308(s16 arg0, u16 *arg1, u8 arg2)
for (; i > -1; i--)
{
- array[i] = 0xFF;
+ array[i] = INVALID_U8;
}
- if (arrayPtr[3] == 0xFF)
+ if (arrayPtr[3] == INVALID_U8)
arrayPtr[3] = 0;
if (arg2 == 0)
{
for (i = 0, j = 0; i < 4; i++)
{
- if (array[j] == 0xFF)
+ if (array[j] == INVALID_U8)
{
arg1[j] &= 0xFC00;
arg1[j] |= 0x1E;
@@ -622,7 +622,7 @@ static void sub_8072308(s16 arg0, u16 *arg1, u8 arg2)
{
for (i = 0; i < 4; i++)
{
- if (array[i] == 0xFF)
+ if (array[i] == INVALID_U8)
{
arg1[i] &= 0xFC00;
arg1[i] |= 0x1E;
@@ -1580,7 +1580,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{
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]].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++)
{
- 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]].data[7] = 1;
@@ -1628,7 +1628,7 @@ u8 CreatePartyStatusSummarySprites(u8 battlerId, struct HpAndStatus *partyInfo,
{
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]].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++)
{
- 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]].data[7] = 1;
@@ -1765,7 +1765,7 @@ static void sub_8073E64(u8 taskId)
s32 i;
u8 battlerId = gTasks[taskId].tBattler;
- if (--gTasks[taskId].tData15 == -1)
+ if (--gTasks[taskId].tData15 == INVALID_S16)
{
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));
}
- else if (gTasks[taskId].tData15 == -1)
+ else if (gTasks[taskId].tData15 == INVALID_S16)
{
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))
MoveBattleBarGraphically(battlerId, whichBar);
- if (currentBarValue == -1)
+ if (currentBarValue == INVALID_S32)
gBattleSpritesDataPtr->battleBars[battlerId].currValue = 0;
return currentBarValue;
@@ -2376,12 +2376,12 @@ static s32 CalcNewBarValue(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *c
if (maxValue < scale)
{
if (newValue == Q_24_8_TO_INT(*currValue) && (*currValue & 0xFF) == 0)
- return -1;
+ return INVALID_S32;
}
else
{
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
@@ -2403,7 +2403,7 @@ static s32 CalcNewBarValue(s32 maxValue, s32 oldValue, s32 receivedValue, s32 *c
*currValue -= toAdd;
ret = Q_24_8_TO_INT(*currValue);
// try round up
- if ((*currValue & 0xFF) > 0)
+ if ((*currValue & INVALID_U8) > 0)
ret++;
if (ret <= newValue)
{
diff --git a/src/battle_main.c b/src/battle_main.c
index de0becd2a..19e85f1cf 100644
--- a/src/battle_main.c
+++ b/src/battle_main.c
@@ -23,7 +23,7 @@
#include "link_rfu.h"
#include "load_save.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "m4a.h"
#include "palette.h"
#include "party_menu.h"
@@ -500,7 +500,7 @@ const struct TrainerMoney gTrainerMoneyTable[] =
{TRAINER_CLASS_HIKER, 10},
{TRAINER_CLASS_YOUNG_COUPLE, 8},
{TRAINER_CLASS_WINSTRATE, 10},
- {0xFF, 5},
+ {INVALID_U8, 5},
};
#include "data/text/abilities.h"
@@ -2251,7 +2251,7 @@ static void sub_8038F34(void)
ShowBg(0);
ShowBg(1);
ShowBg(2);
- gBattleCommunication[1] = 0xFF;
+ gBattleCommunication[1] = INVALID_U8;
gBattleCommunication[MULTIUSE_STATE]++;
break;
case 1:
@@ -2993,7 +2993,7 @@ static void BattleStartClearSetData(void)
gLastLandedMoves[i] = 0;
gLastHitByType[i] = 0;
gLastResultingMoves[i] = 0;
- gLastHitBy[i] = 0xFF;
+ gLastHitBy[i] = INVALID_U8;
gLockedMoves[i] = 0;
gLastPrintedMoves[i] = 0;
gBattleResources->flags->flags[i] = 0;
@@ -3161,7 +3161,7 @@ void SwitchInClearSetData(void)
gLastHitByType[gActiveBattler] = 0;
gLastResultingMoves[gActiveBattler] = 0;
gLastPrintedMoves[gActiveBattler] = 0;
- gLastHitBy[gActiveBattler] = 0xFF;
+ gLastHitBy[gActiveBattler] = INVALID_U8;
*(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 0) = 0;
*(gBattleStruct->lastTakenMove + gActiveBattler * 2 + 1) = 0;
@@ -3192,7 +3192,7 @@ void SwitchInClearSetData(void)
gBattleResources->flags->flags[gActiveBattler] = 0;
gCurrentMove = 0;
- gBattleStruct->field_DA = 0xFF;
+ gBattleStruct->field_DA = INVALID_U8;
ClearBattlerMoveHistory(gActiveBattler);
ClearBattlerAbilityHistory(gActiveBattler);
@@ -3253,7 +3253,7 @@ void FaintClearSetData(void)
gLastHitByType[gActiveBattler] = 0;
gLastResultingMoves[gActiveBattler] = 0;
gLastPrintedMoves[gActiveBattler] = 0;
- gLastHitBy[gActiveBattler] = 0xFF;
+ gLastHitBy[gActiveBattler] = INVALID_U8;
*(u8*)((u8*)(&gBattleStruct->choicedMove[gActiveBattler]) + 0) = 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
|| GetMonData(&gEnemyParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{
- hpStatus[i].hp = 0xFFFF;
+ hpStatus[i].hp = INVALID_U16;
hpStatus[i].status = 0;
}
else
@@ -3458,7 +3458,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{
- hpStatus[i].hp = 0xFFFF;
+ hpStatus[i].hp = INVALID_U16;
hpStatus[i].status = 0;
}
else
@@ -3484,7 +3484,7 @@ static void BattleIntroDrawPartySummaryScreens(void)
if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{
- hpStatus[i].hp = 0xFFFF;
+ hpStatus[i].hp = INVALID_U16;
hpStatus[i].status = 0;
}
else
@@ -3991,7 +3991,7 @@ void BattleTurnPassed(void)
return;
}
- if (gBattleResults.battleTurnCounter < 0xFF)
+ if (gBattleResults.battleTurnCounter < INVALID_U8)
{
gBattleResults.battleTurnCounter++;
gBattleStruct->field_DA++;
@@ -4375,7 +4375,7 @@ static void HandleTurnActionSelectionState(void)
return;
default:
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;
RecordedBattle_ClearBattlerAction(gActiveBattler, 1);
@@ -5740,7 +5740,7 @@ static void HandleAction_ThrowPokeblock(void)
gBattleCommunication[MULTISTRING_CHOOSER] = gBattleBufferB[gBattlerAttacker][1] - 1;
gLastUsedItem = gBattleBufferB[gBattlerAttacker][2];
- if (gBattleResults.pokeblockThrows < 0xFF)
+ if (gBattleResults.pokeblockThrows < INVALID_U8)
gBattleResults.pokeblockThrows++;
if (gBattleStruct->safariPkblThrowCounter < 3)
gBattleStruct->safariPkblThrowCounter++;
diff --git a/src/battle_message.c b/src/battle_message.c
index 47c4cbe1d..c483740f6 100644
--- a/src/battle_message.c
+++ b/src/battle_message.c
@@ -1156,7 +1156,7 @@ const u16 gCaughtMonStringIds[] =
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!");
@@ -2967,7 +2967,7 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId)
printerTemplate.bgColor = textInfo[windowId].bgColor;
printerTemplate.shadowColor = textInfo[windowId].shadowColor;
- if (printerTemplate.x == 0xFF)
+ if (printerTemplate.x == INVALID_U8)
{
u32 width = sub_80397C4(gBattleScripting.windowsType, windowId);
s32 alignX = GetStringCenterAlignXOffsetWithLetterSpacing(printerTemplate.fontId, printerTemplate.currentChar, width, printerTemplate.letterSpacing);
diff --git a/src/battle_pike.c b/src/battle_pike.c
index 38d3e7d4a..590fd3d74 100644
--- a/src/battle_pike.c
+++ b/src/battle_pike.c
@@ -9,7 +9,7 @@
#include "task.h"
#include "battle_tower.h"
#include "party_menu.h"
-#include "malloc.h"
+#include "alloc.h"
#include "palette.h"
#include "script.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)
{
- if (FindTaskIdByFunc(sub_81A7D54) == 0xFF)
+ if (FindTaskIdByFunc(sub_81A7D54) == INVALID_U8)
return TRUE;
else
return FALSE;
@@ -1448,7 +1448,7 @@ static void sub_81A84B4(void)
u8 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)
diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c
index 23343ba20..36c757c93 100644
--- a/src/battle_pyramid.c
+++ b/src/battle_pyramid.c
@@ -21,7 +21,7 @@
#include "main.h"
#include "load_save.h"
#include "script.h"
-#include "malloc.h"
+#include "alloc.h"
#include "overworld.h"
#include "event_scripts.h"
#include "constants/battle_frontier.h"
@@ -1541,7 +1541,7 @@ void sub_81AA1D8(void)
u8 var0, var1;
for (i = 0; i < 8; i++)
- gSaveBlock2Ptr->frontier.field_CB4[i] |= 0xFFFF;
+ gSaveBlock2Ptr->frontier.field_CB4[i] |= INVALID_U16;
id = sub_81AA9E4();
sub_81AA33C(&var0, &var1);
diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c
index 2225a3e55..8b3a509b9 100644
--- a/src/battle_pyramid_bag.c
+++ b/src/battle_pyramid_bag.c
@@ -17,7 +17,7 @@
#include "list_menu.h"
#include "mail.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "overworld.h"
@@ -388,11 +388,11 @@ void sub_81C4F98(u8 a0, void (*callback)(void))
gPyramidBagCursorData.callback = callback;
gPyramidBagResources->callback2 = NULL;
- gPyramidBagResources->unk814 = 0xFF;
- gPyramidBagResources->scrollIndicatorsTaskId = 0xFF;
+ gPyramidBagResources->unk814 = INVALID_U8;
+ gPyramidBagResources->scrollIndicatorsTaskId = INVALID_U8;
- memset(gPyramidBagResources->itemsSpriteIds, 0xFF, sizeof(gPyramidBagResources->itemsSpriteIds));
- memset(gPyramidBagResources->windowIds, 0xFF, sizeof(gPyramidBagResources->windowIds));
+ memset(gPyramidBagResources->itemsSpriteIds, INVALID_U8, sizeof(gPyramidBagResources->itemsSpriteIds));
+ memset(gPyramidBagResources->windowIds, INVALID_U8, sizeof(gPyramidBagResources->windowIds));
SetMainCallback2(sub_81C504C);
}
@@ -604,7 +604,7 @@ static void PyramidBagMoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMen
PlaySE(SE_SELECT);
sub_81C6F20();
}
- if (gPyramidBagResources->unk814 == 0xFF)
+ if (gPyramidBagResources->unk814 == INVALID_U8)
{
sub_81C6FF8(gPyramidBagResources->unk815 ^ 1);
if (itemIndex != LIST_B_PRESSED)
@@ -622,7 +622,7 @@ static void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y)
if (itemIndex == LIST_B_PRESSED)
return;
- if (gPyramidBagResources->unk814 != 0xFF)
+ if (gPyramidBagResources->unk814 != INVALID_U8)
{
if (gPyramidBagResources->unk814 == (u8)(itemIndex))
sub_81C5AB8(y, 1);
@@ -657,16 +657,16 @@ static void PrintItemDescription(s32 listMenuId)
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);
}
static void RemoveScrollArrow(void)
{
- if (gPyramidBagResources->scrollIndicatorsTaskId != 0xFF)
+ if (gPyramidBagResources->scrollIndicatorsTaskId != INVALID_U8)
{
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)
{
- if (arg1 == 0xFF)
+ if (arg1 == INVALID_U8)
FillWindowPixelRect(0, 0, 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
else
PrintOnWindow_Font1(0, gText_SelectorArrow2, 0, y, 0, 0, 0, arg1);
@@ -1323,7 +1323,7 @@ static void PerformItemSwap(u8 taskId)
else
{
MovePyramidBagItemSlotInList(data[1], var);
- gPyramidBagResources->unk814 = 0xFF;
+ gPyramidBagResources->unk814 = INVALID_U8;
sub_81C7028(TRUE);
DestroyListMenuTask(data[0], scrollOffset, selectedRow);
if (data[1] < var)
@@ -1340,7 +1340,7 @@ static void sub_81C6A14(u8 taskId)
u16 *scrollOffset = &gPyramidBagCursorData.scrollPosition;
u16 *selectedRow = &gPyramidBagCursorData.cursorPosition;
- gPyramidBagResources->unk814 = 0xFF;
+ gPyramidBagResources->unk814 = INVALID_U8;
sub_81C7028(TRUE);
DestroyListMenuTask(data[0], scrollOffset, selectedRow);
if (data[1] < *scrollOffset + *selectedRow)
@@ -1427,7 +1427,7 @@ static u8 sub_81C6D08(u8 windowArrayId)
static u8 sub_81C6D24(u8 windowArrayId)
{
u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId];
- if (*windowId == 0xFF)
+ if (*windowId == INVALID_U8)
{
*windowId = AddWindow(&gUnknown_0861F350[windowArrayId]);
SetWindowBorderStyle(*windowId, FALSE, 1, 0xE);
@@ -1439,13 +1439,13 @@ static u8 sub_81C6D24(u8 windowArrayId)
static void sub_81C6D6C(u8 windowArrayId)
{
u8 *windowId = &gPyramidBagResources->windowIds[windowArrayId];
- if (*windowId != 0xFF)
+ if (*windowId != INVALID_U8)
{
sub_8198070(*windowId, FALSE);
ClearWindowTilemap(*windowId);
RemoveWindow(*windowId);
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)
{
u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[itemSpriteArrayId];
- if (*spriteId != 0xFF)
+ if (*spriteId != INVALID_U8)
{
FreeSpriteTilesByTag(ITEM_IMAGE_TAG + itemSpriteArrayId);
FreeSpritePaletteByTag(ITEM_IMAGE_TAG + itemSpriteArrayId);
FreeSpriteOamMatrix(&gSprites[*spriteId]);
DestroySprite(&gSprites[*spriteId]);
- *spriteId = 0xFF;
+ *spriteId = INVALID_U8;
}
}
@@ -1524,7 +1524,7 @@ static void ShowItemImage(u16 itemId, u8 itemSpriteArrayId)
{
u8 itemSpriteId;
u8 *spriteId = &gPyramidBagResources->itemsSpriteIds[itemSpriteArrayId + 1];
- if (*spriteId == 0xFF)
+ if (*spriteId == INVALID_U8)
{
FreeSpriteTilesByTag(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId);
FreeSpritePaletteByTag(ITEM_IMAGE_TAG + 1 + itemSpriteArrayId);
diff --git a/src/battle_records.c b/src/battle_records.c
index f64b5f494..f9c40d8de 100644
--- a/src/battle_records.c
+++ b/src/battle_records.c
@@ -18,7 +18,7 @@
#include "international_string_util.h"
#include "sound.h"
#include "constants/songs.h"
-#include "malloc.h"
+#include "alloc.h"
#include "gpu_regs.h"
#include "constants/game_stat.h"
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 6a7ca1725..53f8defa5 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -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};
#define MIMIC_FORBIDDEN_END 0xFFFE
-#define METRONOME_FORBIDDEN_END 0xFFFF
-#define ASSIST_FORBIDDEN_END 0xFFFF
+#define METRONOME_FORBIDDEN_END INVALID_U16
+#define ASSIST_FORBIDDEN_END INVALID_U16
static const u16 sMovesForbiddenToCopy[] =
{
@@ -822,7 +822,7 @@ static const u16 sWeightToDamageTable[] =
500, 60,
1000, 80,
2000, 100,
- 0xFFFF, 0xFFFF
+ INVALID_U16, INVALID_U16
};
static const u16 sPickupItems[] =
@@ -1976,7 +1976,7 @@ static void atk0C_datahpupdate(void)
{
gActiveBattler = GetBattlerForBattleScript(gBattlescriptCurrInstr[1]);
if (gSpecialStatuses[gActiveBattler].dmg == 0)
- gSpecialStatuses[gActiveBattler].dmg = 0xFFFF;
+ gSpecialStatuses[gActiveBattler].dmg = INVALID_U16;
}
gBattlescriptCurrInstr += 2;
}
@@ -2579,7 +2579,7 @@ void SetMoveEffect(bool8 primary, u8 certain)
u16 PayDay = gPaydayMoney;
gPaydayMoney += (gBattleMons[gBattlerAttacker].level * 5);
if (PayDay > gPaydayMoney)
- gPaydayMoney = 0xFFFF;
+ gPaydayMoney = INVALID_U16;
}
BattleScriptPush(gBattlescriptCurrInstr + 1);
gBattlescriptCurrInstr = sMoveEffectBS_Ptrs[gBattleCommunication[MOVE_EFFECT_BYTE]];
@@ -4520,7 +4520,7 @@ static void atk49_moveend(void)
u8 arg1, arg2;
u16 originallyUsedMove;
- if (gChosenMove == 0xFFFF)
+ if (gChosenMove == INVALID_U16)
originallyUsedMove = 0;
else
originallyUsedMove = gChosenMove;
@@ -4593,7 +4593,7 @@ static void atk49_moveend(void)
break;
case ATK49_CHOICE_MOVE: // update choice band move
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;
if (gChosenMove == MOVE_BATON_PASS && !(gMoveResultFlags & MOVE_RESULT_FAILED))
{
@@ -4708,8 +4708,8 @@ static void atk49_moveend(void)
}
else
{
- gLastMoves[gBattlerAttacker] = 0xFFFF;
- gLastResultingMoves[gBattlerAttacker] = 0xFFFF;
+ gLastMoves[gBattlerAttacker] = INVALID_U16;
+ gLastResultingMoves[gBattlerAttacker] = INVALID_U16;
}
if (!(gHitMarker & HITMARKER_FAINTED(gBattlerTarget)))
@@ -4717,7 +4717,7 @@ static void atk49_moveend(void)
if (gHitMarker & HITMARKER_OBEYS && !(gMoveResultFlags & MOVE_RESULT_NO_EFFECT))
{
- if (gChosenMove == 0xFFFF)
+ if (gChosenMove == INVALID_U16)
{
gLastLandedMoves[gBattlerTarget] = gChosenMove;
}
@@ -4729,7 +4729,7 @@ static void atk49_moveend(void)
}
else
{
- gLastLandedMoves[gBattlerTarget] = 0xFFFF;
+ gLastLandedMoves[gBattlerTarget] = INVALID_U16;
}
}
gBattleScripting.atk49_state++;
@@ -5662,7 +5662,7 @@ static void atk59_handlelearnnewmove(void)
{
gBattlescriptCurrInstr = jumpPtr2;
}
- else if (ret == 0xFFFF)
+ else if (ret == INVALID_U16)
{
gBattlescriptCurrInstr += 10;
}
@@ -6015,7 +6015,7 @@ static void atk61_drawpartystatussummary(void)
if (GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_NONE
|| GetMonData(&party[i], MON_DATA_SPECIES2) == SPECIES_EGG)
{
- hpStatuses[i].hp = 0xFFFF;
+ hpStatuses[i].hp = INVALID_U16;
hpStatuses[i].status = 0;
}
else
@@ -6930,7 +6930,7 @@ static void atk7C_trymirrormove(void)
move = *(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 0)
| (*(i * 2 + gBattlerAttacker * 8 + (u8*)(gBattleStruct->lastTakenMoveFrom) + 1) << 8);
- if (move != 0 && move != 0xFFFF)
+ if (move != 0 && move != INVALID_U16)
{
movesArray[validMovesCount] = move;
validMovesCount++;
@@ -6941,7 +6941,7 @@ static void atk7C_trymirrormove(void)
move = *(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 0)
| (*(gBattleStruct->lastTakenMove + gBattlerAttacker * 2 + 1) << 8);
- if (move != 0 && move != 0xFFFF)
+ if (move != 0 && move != INVALID_U16)
{
gHitMarker &= ~(HITMARKER_ATTACKSTRING_PRINTED);
gCurrentMove = move;
@@ -7094,7 +7094,7 @@ bool8 UproarWakeUpCheck(u8 battlerId)
gBattleScripting.battler = i;
- if (gBattlerTarget == 0xFF)
+ if (gBattlerTarget == INVALID_U8)
gBattlerTarget = i;
else if (gBattlerTarget == i)
gBattleCommunication[MULTISTRING_CHOOSER] = 0;
@@ -8008,7 +8008,7 @@ static void atk9A_setfocusenergy(void)
static void atk9B_transformdataexecution(void)
{
- gChosenMove = 0xFFFF;
+ gChosenMove = INVALID_U16;
gBattlescriptCurrInstr++;
if (gBattleMons[gBattlerTarget].status2 & STATUS2_TRANSFORMED
|| gStatuses3[gBattlerTarget] & STATUS3_SEMI_INVULNERABLE)
@@ -8088,12 +8088,12 @@ static bool8 IsMoveUncopyableByMimic(u16 move)
static void atk9D_mimicattackcopy(void)
{
- gChosenMove = 0xFFFF;
+ gChosenMove = INVALID_U16;
if (IsMoveUncopyableByMimic(gLastMoves[gBattlerTarget])
|| gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED
|| gLastMoves[gBattlerTarget] == 0
- || gLastMoves[gBattlerTarget] == 0xFFFF)
+ || gLastMoves[gBattlerTarget] == INVALID_U16)
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
@@ -8296,7 +8296,7 @@ static void atkA5_painsplitdmgcalc(void)
storeLoc[3] = (painSplitHp & 0xFF000000) >> 24;
gBattleMoveDamage = gBattleMons[gBattlerAttacker].hp - hpDiff;
- gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF;
+ gSpecialStatuses[gBattlerTarget].dmg = INVALID_U16;
gBattlescriptCurrInstr += 5;
}
@@ -8309,7 +8309,7 @@ static void atkA5_painsplitdmgcalc(void)
static void atkA6_settypetorandomresistance(void) // conversion 2
{
if (gLastLandedMoves[gBattlerAttacker] == 0
- || gLastLandedMoves[gBattlerAttacker] == 0xFFFF)
+ || gLastLandedMoves[gBattlerAttacker] == INVALID_U16)
{
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 1);
}
@@ -8376,12 +8376,12 @@ static void atkA7_setalwayshitflag(void)
static void atkA8_copymovepermanently(void) // sketch
{
- gChosenMove = 0xFFFF;
+ gChosenMove = INVALID_U16;
if (!(gBattleMons[gBattlerAttacker].status2 & STATUS2_TRANSFORMED)
&& gLastPrintedMoves[gBattlerTarget] != MOVE_STRUGGLE
&& gLastPrintedMoves[gBattlerTarget] != 0
- && gLastPrintedMoves[gBattlerTarget] != 0xFFFF
+ && gLastPrintedMoves[gBattlerTarget] != INVALID_U16
&& gLastPrintedMoves[gBattlerTarget] != MOVE_SKETCH)
{
s32 i;
@@ -8550,7 +8550,7 @@ static void atkAC_remaininghptopower(void)
static void atkAD_tryspiteppreduce(void)
{
if (gLastMoves[gBattlerTarget] != 0
- && gLastMoves[gBattlerTarget] != 0xFFFF)
+ && gLastMoves[gBattlerTarget] != INVALID_U16)
{
s32 i;
@@ -9671,13 +9671,13 @@ static void atkDC_trysetgrudge(void)
static void atkDD_weightdamagecalculation(void)
{
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))
break;
}
- if (sWeightToDamageTable[i] != 0xFFFF)
+ if (sWeightToDamageTable[i] != INVALID_U16)
gDynamicBasePower = sWeightToDamageTable[i + 1];
else
gDynamicBasePower = 120;
diff --git a/src/battle_setup.c b/src/battle_setup.c
index 4243d2f3f..0b5cd9e21 100644
--- a/src/battle_setup.c
+++ b/src/battle_setup.c
@@ -1530,7 +1530,7 @@ static s32 FirstBattleTrainerIdToRematchTableId(const struct RematchTrainer *tab
return i;
}
- return -1;
+ return INVALID_S32;
}
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)
@@ -1640,7 +1640,7 @@ static bool8 IsFirstTrainerIdReadyForRematch(const struct RematchTrainer *table,
{
s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId);
- if (tableId == -1)
+ if (tableId == INVALID_S32)
return FALSE;
if (tableId >= 100)
return FALSE;
@@ -1654,7 +1654,7 @@ static bool8 IsTrainerReadyForRematch_(const struct RematchTrainer *table, u16 t
{
s32 tableId = TrainerIdToRematchTableId(table, trainerId);
- if (tableId == -1)
+ if (tableId == INVALID_S32)
return FALSE;
if (tableId >= 100)
return FALSE;
@@ -1670,7 +1670,7 @@ static u16 GetRematchTrainerIdFromTable(const struct RematchTrainer *table, u16
s32 i;
s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId);
- if (tableId == -1)
+ if (tableId == INVALID_S32)
return FALSE;
trainerEntry = &table[tableId];
@@ -1691,7 +1691,7 @@ static u16 GetLastBeatenRematchTrainerIdFromTable(const struct RematchTrainer *t
s32 i;
s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId);
- if (tableId == -1)
+ if (tableId == INVALID_S32)
return FALSE;
trainerEntry = &table[tableId];
@@ -1710,7 +1710,7 @@ static void ClearTrainerWantRematchState(const struct RematchTrainer *table, u16
{
s32 tableId = TrainerIdToRematchTableId(table, firstBattleTrainerId);
- if (tableId != -1)
+ if (tableId != INVALID_S32)
gSaveBlock1Ptr->trainerRematches[tableId] = 0;
}
@@ -1724,7 +1724,7 @@ static u32 GetTrainerMatchCallFlag(u32 trainerId)
return FLAG_MATCH_CALL_REGISTERED + i;
}
- return 0xFFFF;
+ return INVALID_U16;
}
static void RegisterTrainerInMatchCall(void)
@@ -1732,7 +1732,7 @@ static void RegisterTrainerInMatchCall(void)
if (FlagGet(FLAG_HAS_MATCH_CALL))
{
u32 matchCallFlagId = GetTrainerMatchCallFlag(gTrainerBattleOpponent_A);
- if (matchCallFlagId != 0xFFFF)
+ if (matchCallFlagId != INVALID_U16)
FlagSet(matchCallFlagId);
}
}
@@ -1741,7 +1741,7 @@ static bool8 WasSecondRematchWon(const struct RematchTrainer *table, u16 firstBa
{
s32 tableId = FirstBattleTrainerIdToRematchTableId(table, firstBattleTrainerId);
- if (tableId == -1)
+ if (tableId == INVALID_S32)
return FALSE;
if (!HasTrainerBeenFought(table[tableId].trainerIds[1]))
return FALSE;
diff --git a/src/battle_tent.c b/src/battle_tent.c
index c7e70912c..836b2b6de 100644
--- a/src/battle_tent.c
+++ b/src/battle_tent.c
@@ -364,7 +364,7 @@ static void sub_81BA040(void)
} while (i != gSaveBlock2Ptr->frontier.curChallengeBattleNum);
gTrainerBattleOpponent_A = trainerId;
- while (gFacilityTrainers[gTrainerBattleOpponent_A].monSets[setsCount] != 0xFFFF)
+ while (gFacilityTrainers[gTrainerBattleOpponent_A].monSets[setsCount] != INVALID_U16)
setsCount++;
if (setsCount > 8)
break;
diff --git a/src/battle_tower.c b/src/battle_tower.c
index f9dfcabd1..c74cfd9a0 100644
--- a/src/battle_tower.c
+++ b/src/battle_tower.c
@@ -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
// successfully chosen. The trainer's party may not have duplicate pokemon species
// or duplicate held items.
- for (bfMonCount = 0; monSets[bfMonCount] != 0xFFFF; bfMonCount++)
+ for (bfMonCount = 0; monSets[bfMonCount] != INVALID_U16; bfMonCount++)
;
i = 0;
otID = Random32();
@@ -1081,11 +1081,11 @@ u16 RandomizeFacilityTrainerMonSet(u16 trainerId)
u8 bfMonCount = 0;
u32 monSetId = monSets[bfMonCount];
- while (monSetId != 0xFFFF)
+ while (monSetId != INVALID_U16)
{
bfMonCount++;
monSetId = monSets[bfMonCount];
- if (monSetId == 0xFFFF)
+ if (monSetId == INVALID_U16)
break;
}
@@ -2641,11 +2641,11 @@ static void FillTentTrainerParty_(u16 trainerId, u8 firstMonId, u8 monCount)
bfMonCount = 0;
monSetId = monSets[bfMonCount];
- while (monSetId != 0xFFFF)
+ while (monSetId != INVALID_U16)
{
bfMonCount++;
monSetId = monSets[bfMonCount];
- if (monSetId == 0xFFFF)
+ if (monSetId == INVALID_U16)
break;
}
diff --git a/src/battle_transition.c b/src/battle_transition.c
index 94b9e78f9..f15514f50 100644
--- a/src/battle_transition.c
+++ b/src/battle_transition.c
@@ -7,7 +7,7 @@
#include "field_effect.h"
#include "gpu_regs.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "overworld.h"
#include "palette.h"
#include "random.h"
@@ -749,7 +749,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_85C8E60[] =
static const struct SpriteTemplate gUnknown_085C8E68 =
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 4105,
.oam = &gEventObjectBaseOam_32x32,
.anims = sSpriteAnimTable_85C8E3C,
@@ -798,7 +798,7 @@ static const union AnimCmd *const sSpriteAnimTable_85C8EA0[] =
static const struct SpriteTemplate sSpriteTemplate_85C8EA4 =
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 4106,
.oam = &gOamData_85C8E80,
.anims = sSpriteAnimTable_85C8EA0,
@@ -809,7 +809,7 @@ static const struct SpriteTemplate sSpriteTemplate_85C8EA4 =
static const struct SpriteTemplate sSpriteTemplate_85C8EBC =
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 4106,
.oam = &gOamData_85C8E80,
.anims = sSpriteAnimTable_85C8EA0,
@@ -998,7 +998,7 @@ static bool8 Transition_Phase1(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++;
return TRUE;
@@ -1019,7 +1019,7 @@ static bool8 Transition_Phase2(struct Task *task)
static bool8 Transition_WaitForPhase2(struct Task *task)
{
task->tTransitionDone = FALSE;
- if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionId]) == 0xFF)
+ if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionId]) == INVALID_U8)
task->tTransitionDone = TRUE;
return FALSE;
}
@@ -3605,7 +3605,7 @@ static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4)
static bool8 IsPhase1Done(void)
{
- if (FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) == 0xFF)
+ if (FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) == INVALID_U8)
return TRUE;
else
return FALSE;
diff --git a/src/battle_tv.c b/src/battle_tv.c
index 535046fd1..edd506708 100644
--- a/src/battle_tv.c
+++ b/src/battle_tv.c
@@ -26,9 +26,9 @@ static const u16 sVariableDmgMoves[] =
MOVE_WATER_SPOUT, MOVE_DREAM_EATER, MOVE_WEATHER_BALL,
MOVE_SNORE, MOVE_PAIN_SPLIT, MOVE_GUILLOTINE,
MOVE_FRUSTRATION, MOVE_RETURN, MOVE_ENDEAVOR,
- MOVE_PRESENT, MOVE_REVENGE, 0xFFFF,
+ MOVE_PRESENT, MOVE_REVENGE, INVALID_U16,
// those are handled by the function itself
- MOVE_MAGNITUDE, MOVE_PSYWAVE, 0xFFFF
+ MOVE_MAGNITUDE, MOVE_PSYWAVE, INVALID_U16
};
static const u16 sUnknown_0860A4E0[] =
@@ -199,7 +199,7 @@ static const u16 sUnknown_0860A8A4[] =
STRINGID_PKMNAFFLICTEDBYCURSE, STRINGID_PKMNSAPPEDBYLEECHSEED, STRINGID_PKMNLOCKEDINNIGHTMARE,
STRINGID_PKMNHURTBY, STRINGID_PKMNHURTBYBURN, STRINGID_PKMNHURTBYPOISON,
STRINGID_PKMNHURTBYSPIKES, STRINGID_ATTACKERFAINTED, STRINGID_TARGETFAINTED,
- STRINGID_PKMNHITWITHRECOIL, STRINGID_PKMNCRASHED, 0xFFFF
+ STRINGID_PKMNHITWITHRECOIL, STRINGID_PKMNCRASHED, INVALID_U16
};
// code
@@ -625,9 +625,9 @@ static bool8 sub_817E0B8(u16 stringId)
if (sUnknown_0860A8A4[i] == stringId)
break;
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;
else
return FALSE;
@@ -1164,7 +1164,7 @@ static void AddMovePoints(u8 caseId, u16 arg1, u8 arg2, u8 arg3)
break;
}
i += 2;
- } while (ptr[i] != 0xFFFF);
+ } while (ptr[i] != INVALID_U16);
break;
case 19:
tvPtr->side[arg2 ^ 1].faintCause = 0;
@@ -1415,9 +1415,9 @@ static void TrySetBattleSeminarShow(void)
if (currMoveSaved == sVariableDmgMoves[i])
break;
i++;
- } while (sVariableDmgMoves[i] != 0xFFFF);
+ } while (sVariableDmgMoves[i] != INVALID_U16);
- if (sVariableDmgMoves[i] != 0xFFFF)
+ if (sVariableDmgMoves[i] != INVALID_U16)
return;
dmgByMove[gMoveSelectionCursor[gBattlerAttacker]] = gBattleMoveDamage;
@@ -1490,9 +1490,9 @@ static bool8 ShouldCalculateDamage(u16 moveId, s32 *dmg, u16 *powerOverride)
if (moveId == sVariableDmgMoves[i])
break;
i++;
- } while (sVariableDmgMoves[i] != 0xFFFF);
+ } while (sVariableDmgMoves[i] != INVALID_U16);
- if (sVariableDmgMoves[i] != 0xFFFF)
+ if (sVariableDmgMoves[i] != INVALID_U16)
{
*dmg = 0;
return FALSE;
diff --git a/src/battle_util.c b/src/battle_util.c
index 251a545c9..12ca6bc9c 100644
--- a/src/battle_util.c
+++ b/src/battle_util.c
@@ -29,7 +29,7 @@ extern u8 weather_get_current(void);
static const u16 sSoundMovesTable[] =
{
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)
@@ -382,7 +382,7 @@ u8 TrySetCantSelectMoveBattleScript(void)
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;
gLastUsedItem = gBattleMons[gActiveBattler].item;
@@ -442,7 +442,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check)
unusableMoves |= gBitTable[i];
if (gDisableStructs[battlerId].encoreTimer && gDisableStructs[battlerId].encoredMove != gBattleMons[battlerId].moves[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];
}
return unusableMoves;
@@ -451,7 +451,7 @@ u8 CheckMoveLimitations(u8 battlerId, u8 unusableMoves, u8 check)
bool8 AreAllMovesUnusable(void)
{
u8 unusable;
- unusable = CheckMoveLimitations(gActiveBattler, 0, 0xFF);
+ unusable = CheckMoveLimitations(gActiveBattler, 0, INVALID_U8);
if (unusable == 0xF) // All moves are unusable.
{
@@ -1137,7 +1137,7 @@ bool8 HandleWishPerishSongOnTurnEnd(void)
gBattlerTarget = gActiveBattler;
gBattlerAttacker = gWishFutureKnock.futureSightAttacker[gActiveBattler];
gBattleMoveDamage = gWishFutureKnock.futureSightDmg[gActiveBattler];
- gSpecialStatuses[gBattlerTarget].dmg = 0xFFFF;
+ gSpecialStatuses[gBattlerTarget].dmg = INVALID_U16;
BattleScriptExecute(BattleScript_MonTookFutureAttack);
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
if (gLastUsedAbility == ABILITY_SOUNDPROOF)
{
- for (i = 0; sSoundMovesTable[i] != 0xFFFF; i++)
+ for (i = 0; sSoundMovesTable[i] != INVALID_U16; i++)
{
if (sSoundMovesTable[i] == move)
break;
}
- if (sSoundMovesTable[i] != 0xFFFF)
+ if (sSoundMovesTable[i] != INVALID_U16)
{
if (gBattleMons[gBattlerAttacker].status2 & STATUS2_MULTIPLETURNS)
gHitMarker |= HITMARKER_NO_PPDEDUCT;
@@ -2527,7 +2527,7 @@ u8 AbilityBattleEffects(u8 caseID, u8 battler, u8 ability, u8 special, u16 moveA
break;
}
- if (effect && caseID < ABILITYEFFECT_CHECK_OTHER_SIDE && gLastUsedAbility != 0xFF)
+ if (effect && caseID < ABILITYEFFECT_CHECK_OTHER_SIDE && gLastUsedAbility != INVALID_U8)
RecordAbilityBattle(battler, gLastUsedAbility);
}
@@ -3213,7 +3213,7 @@ u8 ItemBattleEffects(u8 caseID, u8 battlerId, bool8 moveTurn)
case HOLD_EFFECT_SHELL_BELL:
if (!(gMoveResultFlags & MOVE_RESULT_NO_EFFECT)
&& gSpecialStatuses[gBattlerTarget].dmg != 0
- && gSpecialStatuses[gBattlerTarget].dmg != 0xFFFF
+ && gSpecialStatuses[gBattlerTarget].dmg != INVALID_U16
&& gBattlerAttacker != gBattlerTarget
&& gBattleMons[gBattlerAttacker].hp != gBattleMons[gBattlerAttacker].maxHP
&& gBattleMons[gBattlerAttacker].hp != 0)
@@ -3394,7 +3394,7 @@ u8 IsMonDisobedient(void)
calc = (gBattleMons[gBattlerAttacker].level + obedienceLevel) * rnd >> 8;
if (calc < obedienceLevel)
{
- calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], 0xFF);
+ calc = CheckMoveLimitations(gBattlerAttacker, gBitTable[gCurrMovePos], INVALID_U8);
if (calc == 0xF) // all moves cannot be used
{
gBattleCommunication[MULTISTRING_CHOOSER] = Random() & 3;
diff --git a/src/battle_util2.c b/src/battle_util2.c
index 5881abf25..a9891814c 100644
--- a/src/battle_util2.c
+++ b/src/battle_util2.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "battle.h"
#include "battle_controllers.h"
-#include "malloc.h"
+#include "alloc.h"
#include "pokemon.h"
#include "event_data.h"
#include "constants/abilities.h"
diff --git a/src/berry_blender.c b/src/berry_blender.c
index 7320e905f..e977bdbeb 100644
--- a/src/berry_blender.c
+++ b/src/berry_blender.c
@@ -12,7 +12,7 @@
#include "bg.h"
#include "palette.h"
#include "decompress.h"
-#include "malloc.h"
+#include "alloc.h"
#include "gpu_regs.h"
#include "text.h"
#include "text_window.h"
@@ -1455,7 +1455,7 @@ static void sub_808074C(void)
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];
}
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++)
{
- if (sBerryBlenderData->field_8E[i] != 0xFF)
+ if (sBerryBlenderData->field_8E[i] != INVALID_U8)
{
sBerryBlenderData->syncArrowSpriteIds[sBerryBlenderData->field_8E[i]] = sBerryBlenderData->syncArrowSprite2Ids[i];
StartSpriteAnim(&gSprites[sBerryBlenderData->syncArrowSpriteIds[sBerryBlenderData->field_8E[i]]], i);
diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c
index a90906d05..d87509e10 100644
--- a/src/berry_fix_program.c
+++ b/src/berry_fix_program.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "gpu_regs.h"
#include "multiboot.h"
-#include "malloc.h"
+#include "alloc.h"
#include "bg.h"
#include "graphics.h"
#include "main.h"
diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c
index 39927ab99..22f99a426 100644
--- a/src/berry_tag_screen.c
+++ b/src/berry_tag_screen.c
@@ -21,7 +21,7 @@
#include "string_util.h"
#include "strings.h"
#include "bg.h"
-#include "malloc.h"
+#include "alloc.h"
#include "scanline_effect.h"
#include "gpu_regs.h"
#include "graphics.h"
diff --git a/src/bg.c b/src/bg.c
index a41075ad7..fd6ffca6e 100644
--- a/src/bg.c
+++ b/src/bg.c
@@ -87,37 +87,37 @@ void SetBgControlAttributes(u8 bg, u8 charBaseIndex, u8 mapBaseIndex, u8 screenS
{
if (IsInvalidBg(bg) == FALSE)
{
- if (charBaseIndex != 0xFF)
+ if (charBaseIndex != INVALID_U8)
{
sGpuBgConfigs.configs[bg].charBaseIndex = charBaseIndex & 0x3;
}
- if (mapBaseIndex != 0xFF)
+ if (mapBaseIndex != INVALID_U8)
{
sGpuBgConfigs.configs[bg].mapBaseIndex = mapBaseIndex & 0x1F;
}
- if (screenSize != 0xFF)
+ if (screenSize != INVALID_U8)
{
sGpuBgConfigs.configs[bg].screenSize = screenSize & 0x3;
}
- if (paletteMode != 0xFF)
+ if (paletteMode != INVALID_U8)
{
sGpuBgConfigs.configs[bg].paletteMode = paletteMode;
}
- if (priority != 0xFF)
+ if (priority != INVALID_U8)
{
sGpuBgConfigs.configs[bg].priority = priority & 0x3;
}
- if (mosaic != 0xFF)
+ if (mosaic != INVALID_U8)
{
sGpuBgConfigs.configs[bg].mosaic = mosaic & 0x1;
}
- if (wraparound != 0xFF)
+ if (wraparound != INVALID_U8)
{
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)
@@ -379,7 +379,7 @@ u16 LoadBgTiles(u8 bg, const void* src, u16 size, u16 destOffset)
cursor = LoadBgVram(bg, src, size, tileOffset, DISPCNT_MODE_1);
- if (cursor == 0xFF)
+ if (cursor == INVALID_U8)
{
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);
- if (cursor == 0xFF)
+ if (cursor == INVALID_U8)
{
return -1;
}
@@ -480,25 +480,25 @@ void SetBgAttribute(u8 bg, u8 attributeId, u8 value)
switch (attributeId)
{
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;
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;
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;
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;
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;
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;
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;
}
}
@@ -1284,7 +1284,7 @@ u32 GetBgType(u8 bg)
break;
}
- return 0xFFFF;
+ return INVALID_U16;
}
bool32 IsInvalidBg32(u8 bg)
diff --git a/src/blit.c b/src/blit.c
index b4d5f7de5..2ba0e489c 100644
--- a/src/blit.c
+++ b/src/blit.c
@@ -3,7 +3,7 @@
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)
@@ -33,7 +33,7 @@ void BlitBitmapRect4Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 sr
multiplierSrcY = (src->width + (src->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++)
{
@@ -132,7 +132,7 @@ void BlitBitmapRect4BitTo8Bit(struct Bitmap *src, struct Bitmap *dst, u16 srcX,
multiplierSrcY = (src->width + (src->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++)
{
diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c
index b17ffad33..6a2e42c4e 100644
--- a/src/braille_puzzles.c
+++ b/src/braille_puzzles.c
@@ -465,7 +465,7 @@ bool8 ShouldDoBrailleRegicePuzzle(void)
}
varValue = VarGet(0x403B);
- if (varValue != 0xFFFF || VarGet(0x403C) != varValue || VarGet(0x403D) != 0xF)
+ if (varValue != INVALID_U16 || VarGet(0x403C) != varValue || VarGet(0x403D) != 0xF)
return FALSE;
if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 21)
diff --git a/src/cable_club.c b/src/cable_club.c
index 56154d5bf..649534711 100644
--- a/src/cable_club.c
+++ b/src/cable_club.c
@@ -70,7 +70,7 @@ static void sub_80B3220(u8 taskId);
static void sub_80B236C(u8 arg0, u8 arg1)
{
- if (FindTaskIdByFunc(sub_80B2634) == 0xFF)
+ if (FindTaskIdByFunc(sub_80B2634) == INVALID_U8)
{
u8 taskId1;
@@ -604,7 +604,7 @@ void sub_80B2EA8(void)
{
u32 taskId = FindTaskIdByFunc(sub_80B2EE4);
- if (taskId == 0xFF)
+ if (taskId == INVALID_U8)
{
taskId = CreateTask(sub_80B2EE4, 80);
gTasks[taskId].data[0] = 0;
@@ -702,7 +702,7 @@ void sub_80B3028(void)
u8 sub_80B3050(void)
{
if (FuncIsActiveTask(sub_80B3144) != FALSE)
- return 0xFF;
+ return INVALID_U8;
switch (gSpecialVar_0x8004)
{
diff --git a/src/contest.c b/src/contest.c
index 0c3a041b0..716ed5dfc 100644
--- a/src/contest.c
+++ b/src/contest.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "gpu_regs.h"
#include "bg.h"
-#include "malloc.h"
+#include "alloc.h"
#include "constants/items.h"
#include "constants/event_objects.h"
#include "constants/moves.h"
@@ -324,7 +324,7 @@ void sub_80D787C(void)
*gContestResources->field_0 = (struct Contest){};
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++)
{
@@ -344,7 +344,7 @@ void sub_80D787C(void)
sub_80DCE58(0);
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];
}
sub_80DD590();
@@ -2097,7 +2097,7 @@ void sub_80DAB8C(u8 contestType, u8 rank)
opponents[opponentsCount++] = i;
}
}
- opponents[opponentsCount] = 0xFF;
+ opponents[opponentsCount] = INVALID_U8;
// Choose three random opponents from the list
for (i = 0; i < 3; i++)
@@ -2106,7 +2106,7 @@ void sub_80DAB8C(u8 contestType, u8 rank)
s32 j;
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];
opponentsCount--;
}
@@ -2151,7 +2151,7 @@ void sub_80DACBC(u8 contestType, u8 rank, bool32 isPostgame)
else if (contestType == CONTEST_CATEGORY_TOUGH && gContestOpponents[i].aiPool_Tough)
opponents[opponentsCount++] = i;
}
- opponents[opponentsCount] = 0xFF;
+ opponents[opponentsCount] = INVALID_U8;
for (i = 0; i < 4 - gUnknown_02039F30; i++)
{
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]];
sub_80DF9D4(gContestMons[gUnknown_02039F30 + i].trainerName);
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];
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 + 0x10, 0x0b, 0x20, 0x05, 0x01, 0x11, 0x01);
- if (gContestEffects[gContestMoves[a].effect].appeal == 0xFF)
+ if (gContestEffects[gContestMoves[a].effect].appeal == INVALID_U8)
numHearts = 0;
else
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, 0x5012, 0x15, 0x1f, numHearts, 0x01, 0x11);
- if (gContestEffects[gContestMoves[a].effect].jam == 0xFF)
+ if (gContestEffects[gContestMoves[a].effect].jam == INVALID_U8)
numHearts = 0;
else
numHearts = gContestEffects[gContestMoves[a].effect].jam / 10;
diff --git a/src/contest_effect.c b/src/contest_effect.c
index 760d74d69..6f1c19fe2 100644
--- a/src/contest_effect.c
+++ b/src/contest_effect.c
@@ -144,7 +144,7 @@ static void ContestEffect_StartleFrontMon(void)
break;
}
shared192D0.jamQueue[0] = i;
- shared192D0.jamQueue[1] = 0xFF;
+ shared192D0.jamQueue[1] = INVALID_U8;
idx = WasAtLeastOneOpponentJammed();
}
if (idx == 0)
@@ -168,7 +168,7 @@ static void ContestEffect_StartlePrevMons(void)
shared192D0.jamQueue[j++] = i;
}
- shared192D0.jamQueue[j] = 0xFF;
+ shared192D0.jamQueue[j] = INVALID_U8;
idx = WasAtLeastOneOpponentJammed();
}
if (idx == 0)
@@ -211,7 +211,7 @@ static void ContestEffect_StartlePrevMons2(void)
u8 rval, jam;
shared192D0.jamQueue[0] = i;
- shared192D0.jamQueue[1] = 0xFF;
+ shared192D0.jamQueue[1] = INVALID_U8;
rval = Random() % 10;
if (rval == 0)
@@ -288,7 +288,7 @@ static void ContestEffect_StartleMonWithJudgesAttention(void)
else
shared192D0.jam = 10;
shared192D0.jamQueue[0] = i;
- shared192D0.jamQueue[1] = 0xFF;
+ shared192D0.jamQueue[1] = INVALID_U8;
if (WasAtLeastOneOpponentJammed())
numStartled++;
}
@@ -393,7 +393,7 @@ static void ContestEffect_MakeFollowingMonsNervous(void)
s16 oddsMod[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++)
{
if (shared192D0.turnOrder[shared192D0.contestant] < shared192D0.turnOrder[i] &&
@@ -431,7 +431,7 @@ static void ContestEffect_MakeFollowingMonsNervous(void)
}
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]])
{
@@ -504,7 +504,7 @@ static void ContestEffect_BadlyStartlesMonsInGoodCondition(void)
else
shared192D0.jam = 10;
shared192D0.jamQueue[0] = i;
- shared192D0.jamQueue[1] = 0xFF;
+ shared192D0.jamQueue[1] = INVALID_U8;
if (WasAtLeastOneOpponentJammed())
numHit++;
}
@@ -755,7 +755,7 @@ static void ContestEffect_NextAppealEarlier(void)
for (i = 0; i < 4; i++)
turnOrder[i] = sContestantStatus[i].nextTurnOrder;
- turnOrder[shared192D0.contestant] = 0xFF;
+ turnOrder[shared192D0.contestant] = INVALID_U8;
for (i = 0; i < 4; i++)
{
@@ -797,7 +797,7 @@ static void ContestEffect_NextAppealLater(void)
for (i = 0; i < 4; i++)
turnOrder[i] = sContestantStatus[i].nextTurnOrder;
- turnOrder[shared192D0.contestant] = 0xFF;
+ turnOrder[shared192D0.contestant] = INVALID_U8;
for (i = 3; i > -1; i--)
{
@@ -855,12 +855,12 @@ static void ContestEffect_ScrambleNextTurnOrder(void)
for (j = 0; j < 4; j++)
{
- if (unselectedContestants[j] != 0xFF)
+ if (unselectedContestants[j] != INVALID_U8)
{
if (rval == 0)
{
turnOrder[j] = i;
- unselectedContestants[j] = 0xFF;
+ unselectedContestants[j] = INVALID_U8;
break;
}
else
@@ -906,7 +906,7 @@ static void ContestEffect_BadlyStartleMonsWithGoodAppeals(void)
else
shared192D0.jam = 10;
shared192D0.jamQueue[0] = i;
- shared192D0.jamQueue[1] = 0xFF;
+ shared192D0.jamQueue[1] = INVALID_U8;
if (WasAtLeastOneOpponentJammed())
numJammed++;
}
@@ -974,7 +974,7 @@ static void JamByMoveCategory(u8 category)
else
shared192D0.jam = 10;
shared192D0.jamQueue[0] = i;
- shared192D0.jamQueue[1] = 0xFF;
+ shared192D0.jamQueue[1] = INVALID_U8;
if (WasAtLeastOneOpponentJammed())
numJammed++;
}
@@ -1013,7 +1013,7 @@ static bool8 WasAtLeastOneOpponentJammed(void)
s16 jamBuffer[4] = {0};
int i;
- for (i = 0; shared192D0.jamQueue[i] != 0xFF; i++)
+ for (i = 0; shared192D0.jamQueue[i] != INVALID_U8; i++)
{
u8 contestant = shared192D0.jamQueue[i];
if (CanUnnerveContestant(contestant))
diff --git a/src/credits.c b/src/credits.c
index df17ec70b..02b01c072 100644
--- a/src/credits.c
+++ b/src/credits.c
@@ -3,7 +3,7 @@
#include "main.h"
#include "task.h"
#include "bg.h"
-#include "malloc.h"
+#include "alloc.h"
#include "window.h"
#include "text.h"
#include "menu.h"
diff --git a/src/data2b.c b/src/data2b.c
index 022903375..bb1baa266 100644
--- a/src/data2b.c
+++ b/src/data2b.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "data2.h"
#include "graphics.h"
-#include "malloc.h"
+#include "alloc.h"
#include "constants/species.h"
const u16 gUnknown_082FF1D8[] = INCBIN_U16("graphics/link/minigame_digits.gbapal");
diff --git a/src/daycare.c b/src/daycare.c
index 2356b36f5..227451f48 100644
--- a/src/daycare.c
+++ b/src/daycare.c
@@ -251,7 +251,7 @@ static void ApplyDaycareExperience(struct Pokemon *mon)
while ((learnedMove = MonTryLearningNewMove(mon, firstMove)) != 0)
{
firstMove = FALSE;
- if (learnedMove == 0xFFFF)
+ if (learnedMove == INVALID_U16)
{
// Mon already knows 4 moves.
DeleteFirstMoveAndGiveMoveToMon(mon, gMoveToLearn);
@@ -535,7 +535,7 @@ static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv)
s32 i, j;
u8 temp[NUM_STATS];
- ivs[selectedIv] = 0xff;
+ ivs[selectedIv] = INVALID_U8;
for (i = 0; i < NUM_STATS; i++)
{
temp[i] = ivs[i];
@@ -544,7 +544,7 @@ static void RemoveIVIndexFromList(u8 *ivs, u8 selectedIv)
j = 0;
for (i = 0; i < NUM_STATS; i++)
{
- if (temp[i] != 0xff)
+ if (temp[i] != INVALID_U8)
ivs[j++] = temp[i];
}
}
@@ -684,7 +684,7 @@ static void BuildEggMoveset(struct Pokemon *egg, struct BoxPokemon *father, stru
{
if (sHatchedEggFatherMoves[i] == sHatchedEggEggMoves[j])
{
- if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == 0xffff)
+ if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == INVALID_U16)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFatherMoves[i]);
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 (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == 0xffff)
+ if (GiveMoveToMon(egg, sHatchedEggFatherMoves[i]) == INVALID_U16)
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 (GiveMoveToMon(egg, sHatchedEggFinalMoves[i]) == 0xffff)
+ if (GiveMoveToMon(egg, sHatchedEggFinalMoves[i]) == INVALID_U16)
DeleteFirstMoveAndGiveMoveToMon(egg, sHatchedEggFinalMoves[i]);
break;
}
@@ -773,7 +773,7 @@ static void GiveVoltTackleIfLightBall(struct Pokemon *mon, struct DayCare *dayca
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);
}
}
@@ -909,7 +909,7 @@ static bool8 _DoEggActions_CheckHatch(struct DayCare *daycare)
}
// 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);
if (loveScore > (Random() * 100u) / USHRT_MAX)
diff --git a/src/decompress.c b/src/decompress.c
index da1df436b..287a03e55 100644
--- a/src/decompress.c
+++ b/src/decompress.c
@@ -2,7 +2,7 @@
#include "decompress.h"
#include "constants/species.h"
#include "text.h"
-#include "malloc.h"
+#include "alloc.h"
#include "pokemon.h"
EWRAM_DATA ALIGNED(4) u8 gDecompressionBuffer[0x4000] = {0};
diff --git a/src/decoration.c b/src/decoration.c
index eb85b4f5c..11fd59286 100644
--- a/src/decoration.c
+++ b/src/decoration.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "constants/decorations.h"
#include "decompress.h"
-#include "malloc.h"
+#include "alloc.h"
#include "text.h"
#include "string_util.h"
#include "international_string_util.h"
@@ -312,7 +312,7 @@ const struct SpriteFrameImage sDecorSelectorSpriteFrameImages = {
};
const struct SpriteTemplate sDecorSelectorSpriteTemplate = {
- 0xffff,
+ INVALID_U16,
OVERWORLD_PLACE_DECOR_SELECTOR_PAL_TAG,
&sDecorSelectorOam,
sDecorSelectorAnims,
@@ -409,7 +409,7 @@ const struct SpriteFrameImage Unknown_085A73FC = {
};
const struct SpriteTemplate gUnknown_085A7404 = {
- 0xFFFF,
+ INVALID_U16,
OVERWORLD_PLACE_DECOR_PLAYER_PAL_TAG,
&Unknown_085A73E8,
Unknown_085A73F8,
@@ -881,7 +881,7 @@ void sub_81274A0(u8 a0, s32 a1, u8 a2)
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);
}
@@ -889,10 +889,10 @@ void sub_8127500(void)
void sub_8127554(void)
{
- if (sDecorPCBuffer->unk_522 != 0xFF)
+ if (sDecorPCBuffer->unk_522 != INVALID_U8)
{
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_8127718(sCurDecorationCategory);
sDecorPCBuffer = calloc(1, sizeof(struct DecorPCBuffer));
- sDecorPCBuffer->unk_522 = 0xFF;
+ sDecorPCBuffer->unk_522 = INVALID_U8;
sub_8127284();
sub_81272C8();
sub_81272F8();
@@ -1188,7 +1188,7 @@ void sub_8127B90(u16 mapX, u16 mapY, u8 decWidth, u8 decHeight, u16 decor)
v0 = 0;
}
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);
}
diff --git a/src/dewford_trend.c b/src/dewford_trend.c
index 3050ebecf..cad5ef9c2 100644
--- a/src/dewford_trend.c
+++ b/src/dewford_trend.c
@@ -3,7 +3,7 @@
#include "easy_chat.h"
#include "event_data.h"
#include "link.h"
-#include "malloc.h"
+#include "alloc.h"
#include "random.h"
#include "text.h"
#include "tv.h"
diff --git a/src/diploma.c b/src/diploma.c
index f8556eb7d..b3d5a48fa 100644
--- a/src/diploma.c
+++ b/src/diploma.c
@@ -5,7 +5,7 @@
#include "gpu_regs.h"
#include "scanline_effect.h"
#include "task.h"
-#include "malloc.h"
+#include "alloc.h"
#include "decompress.h"
#include "bg.h"
#include "window.h"
diff --git a/src/easy_chat.c b/src/easy_chat.c
index e4233fb7f..25ef069e4 100644
--- a/src/easy_chat.c
+++ b/src/easy_chat.c
@@ -1,7 +1,7 @@
// Includes
#include "global.h"
-#include "malloc.h"
+#include "alloc.h"
#include "constants/songs.h"
#include "sound.h"
#include "overworld.h"
diff --git a/src/egg_hatch.c b/src/egg_hatch.c
index 4b7ee9a61..77296c707 100644
--- a/src/egg_hatch.c
+++ b/src/egg_hatch.c
@@ -17,7 +17,7 @@
#include "menu.h"
#include "trig.h"
#include "random.h"
-#include "malloc.h"
+#include "alloc.h"
#include "dma3.h"
#include "gpu_regs.h"
#include "bg.h"
diff --git a/src/event_object_movement.c b/src/event_object_movement.c
index e509c7738..0606364cd 100644
--- a/src/event_object_movement.c
+++ b/src/event_object_movement.c
@@ -9,7 +9,7 @@
#include "field_effect_helpers.h"
#include "field_player_avatar.h"
#include "fieldmap.h"
-#include "malloc.h"
+#include "alloc.h"
#include "mauville_old_man.h"
#include "metatile_behavior.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 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 *) = {
CameraObject_0,
@@ -1093,10 +1093,10 @@ const u8 gUnknown_0850DC3F[][4] = {
static void ClearEventObject(struct EventObject *eventObject)
{
*eventObject = (struct EventObject){};
- eventObject->localId = 0xFF;
- eventObject->mapNum = 0xFF;
- eventObject->mapGroup = 0xFF;
- eventObject->movementActionId = 0xFF;
+ eventObject->localId = INVALID_U8;
+ eventObject->mapNum = INVALID_U8;
+ eventObject->mapGroup = INVALID_U8;
+ eventObject->movementActionId = INVALID_U8;
}
static void ClearAllEventObjects(void)
@@ -1537,7 +1537,7 @@ static u8 TrySetupEventObjectSprite(struct EventObjectTemplate *eventObjectTempl
{
eventObject->invisible = TRUE;
}
- *(u16 *)&spriteTemplate->paletteTag = 0xFFFF;
+ *(u16 *)&spriteTemplate->paletteTag = INVALID_U16;
spriteId = CreateSprite(spriteTemplate, 0, 0, 0);
if (spriteId == MAX_SPRITES)
{
@@ -1666,7 +1666,7 @@ u8 AddPseudoEventObject(u16 graphicsId, void (*callback)(struct Sprite *), s16 x
spriteTemplate = malloc(sizeof(struct SpriteTemplate));
MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, callback, spriteTemplate, &subspriteTables);
- if (spriteTemplate->paletteTag != 0xFFFF)
+ if (spriteTemplate->paletteTag != INVALID_U16)
{
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);
MakeObjectTemplateFromEventObjectGraphicsInfo(graphicsId, UpdateEventObjectSpriteSubpriorityAndVisibility, &spriteTemplate, &subspriteTables);
- *(u16 *)&spriteTemplate.paletteTag = 0xFFFF;
+ *(u16 *)&spriteTemplate.paletteTag = INVALID_U16;
x += 7;
y += 7;
sub_80930E0(&x, &y, 8, 16);
@@ -1849,7 +1849,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y)
spriteFrameImage.size = graphicsInfo->size;
MakeObjectTemplateFromEventObjectGraphicsInfoWithCallbackIndex(eventObject->graphicsId, eventObject->movementType, &spriteTemplate, &subspriteTables);
spriteTemplate.images = &spriteFrameImage;
- *(u16 *)&spriteTemplate.paletteTag = 0xFFFF;
+ *(u16 *)&spriteTemplate.paletteTag = INVALID_U16;
paletteSlot = graphicsInfo->paletteSlot;
if (paletteSlot == 0)
{
@@ -1864,7 +1864,7 @@ static void sub_808E1B8(u8 eventObjectId, s16 x, s16 y)
paletteSlot -= 16;
sub_808EAB0(graphicsInfo->paletteTag1, paletteSlot);
}
- *(u16 *)&spriteTemplate.paletteTag = 0xFFFF;
+ *(u16 *)&spriteTemplate.paletteTag = INVALID_U16;
spriteId = CreateSprite(&spriteTemplate, 0, 0, 0);
if (spriteId != MAX_SPRITES)
{
@@ -2146,9 +2146,9 @@ void Unused_LoadEventObjectPaletteSet(u16 *paletteTags)
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);
}
@@ -2181,7 +2181,7 @@ static u8 FindEventObjectPaletteIndexByTag(u16 tag)
return i;
}
}
- return 0xFF;
+ return INVALID_U8;
}
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))
{
- return 0xFF;
+ return INVALID_U8;
}
return gEventObjects[eventObjectId].trainerType;
}
@@ -2529,7 +2529,7 @@ u8 sub_808F0D4(u8 localId, u8 mapNum, u8 mapGroup)
if (TryGetEventObjectIdByLocalIdAndMap(localId, mapNum, mapGroup, &eventObjectId))
{
- return 0xFF;
+ return INVALID_U8;
}
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)
{
- 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;
}
@@ -4553,7 +4553,7 @@ movement_type_def(MovementType_CopyPlayerInGrass, gMovementTypeFuncs_CopyPlayerI
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;
}
@@ -4699,7 +4699,7 @@ static void ClearEventObjectMovement(struct EventObject *eventObject, struct Spr
eventObject->singleMovementActive = 0;
eventObject->heldMovementActive = FALSE;
eventObject->heldMovementFinished = FALSE;
- eventObject->movementActionId = 0xFF;
+ eventObject->movementActionId = INVALID_U8;
sprite->data[1] = 0;
}
@@ -5105,7 +5105,7 @@ bool8 EventObjectIsMovementOverridden(struct EventObject *eventObject)
bool8 EventObjectIsHeldMovementActive(struct EventObject *eventObject)
{
- if (eventObject->heldMovementActive && eventObject->movementActionId != 0xFF)
+ if (eventObject->heldMovementActive && eventObject->movementActionId != INVALID_U8)
return TRUE;
return FALSE;
@@ -5138,7 +5138,7 @@ void EventObjectClearHeldMovementIfActive(struct EventObject *eventObject)
void EventObjectClearHeldMovement(struct EventObject *eventObject)
{
- eventObject->movementActionId = 0xFF;
+ eventObject->movementActionId = INVALID_U8;
eventObject->heldMovementActive = FALSE;
eventObject->heldMovementFinished = FALSE;
gSprites[eventObject->spriteId].data[1] = 0;
@@ -5167,7 +5167,7 @@ u8 EventObjectGetHeldMovementActionId(struct EventObject *eventObject)
if (eventObject->heldMovementActive)
return eventObject->movementActionId;
- return 0xFF;
+ return INVALID_U8;
}
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))
{
- eventObject->movementActionId = 0xFF;
+ eventObject->movementActionId = INVALID_U8;
sprite->data[2] = 0;
return TRUE;
}
@@ -5706,7 +5706,7 @@ u8 sub_80940C4(struct EventObject *eventObject, struct Sprite *sprite, u8 callba
eventObject->triggerGroundEffectsOnMove = TRUE;
eventObject->disableCoveringGroundEffects = TRUE;
}
- else if (result == 0xFF)
+ else if (result == INVALID_U8)
{
ShiftStillEventObjectCoords(eventObject);
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)
{
- if (sub_8094188(eventObject, sprite) == 0xFF)
+ if (sub_8094188(eventObject, sprite) == INVALID_U8)
{
return TRUE;
}
@@ -5737,7 +5737,7 @@ bool8 sub_80941B0(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;
}
@@ -9122,7 +9122,7 @@ void CreateLevitateMovementTask(struct EventObject *eventObject)
StoreWordInTwoHalfwords(&task->data[0], (u32)eventObject);
eventObject->warpArrowSpriteId = taskId;
- task->data[3] = 0xFFFF;
+ task->data[3] = INVALID_U16;
}
static void ApplyLevitateMovement(u8 taskId)
diff --git a/src/evolution_scene.c b/src/evolution_scene.c
index 0d2072a15..25d85a855 100644
--- a/src/evolution_scene.c
+++ b/src/evolution_scene.c
@@ -2,7 +2,7 @@
#include "evolution_scene.h"
#include "evolution_graphics.h"
#include "sprite.h"
-#include "malloc.h"
+#include "alloc.h"
#include "task.h"
#include "palette.h"
#include "main.h"
@@ -748,7 +748,7 @@ static void Task_EvolutionScene(u8 taskID)
GetMonData(mon, MON_DATA_NICKNAME, 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;
else if (var == 0xFFFE) // it already knows that move
break;
@@ -1105,7 +1105,7 @@ static void Task_TradeEvolutionScene(u8 taskID)
GetMonData(mon, MON_DATA_NICKNAME, text);
StringCopy10(gBattleTextBuff1, text);
- if (var == 0xFFFF)
+ if (var == INVALID_U16)
gTasks[taskID].tState = 20;
else if (var == 0xFFFE)
break;
diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c
index c52f5190f..1dce3169e 100644
--- a/src/field_control_avatar.c
+++ b/src/field_control_avatar.c
@@ -266,7 +266,7 @@ const u8 *GetInteractedLinkPlayerScript(struct MapPosition *position, u8 metatil
else
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;
for (i = 0; i < 4; i++)
@@ -287,14 +287,14 @@ static const u8 *GetInteractedEventObjectScript(struct MapPosition *position, u8
const u8 *script;
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)
return NULL;
// 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);
- if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == 0xFF)
+ if (eventObjectId == 16 || gEventObjects[eventObjectId].localId == INVALID_U8)
return NULL;
}
diff --git a/src/field_door.c b/src/field_door.c
index c197aca14..a1fe5bb97 100644
--- a/src/field_door.c
+++ b/src/field_door.c
@@ -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)
{
- if (frame->offset == 0xFFFF)
+ if (frame->offset == INVALID_U16)
{
DrawClosedDoorTiles(gfx, x, y);
if (sub_808A964())
diff --git a/src/field_effect.c b/src/field_effect.c
index 935501130..91d61ef2f 100644
--- a/src/field_effect.c
+++ b/src/field_effect.c
@@ -305,7 +305,7 @@ const union AnimCmd *const gNewGameBirchImageAnimTable[] = {
};
const struct SpriteTemplate gNewGameBirchObjectTemplate = {
- .tileTag = 0xffff,
+ .tileTag = INVALID_U16,
.paletteTag = 4102,
.oam = &gNewGameBirchOamAttributes,
.anims = gNewGameBirchImageAnimTable,
@@ -383,7 +383,7 @@ const union AnimCmd *const gSpriteAnimTable_855C300[] = {
};
const struct SpriteTemplate gSpriteTemplate_855C304 = {
- .tileTag = 0xffff,
+ .tileTag = INVALID_U16,
.paletteTag = 4103,
.oam = &gOamData_855C218,
.anims = gSpriteAnimTable_855C2F8,
@@ -393,7 +393,7 @@ const struct SpriteTemplate gSpriteTemplate_855C304 = {
};
const struct SpriteTemplate gSpriteTemplate_855C31C = {
- .tileTag = 0xffff,
+ .tileTag = INVALID_U16,
.paletteTag = 4100,
.oam = &gOamData_855C220,
.anims = gSpriteAnimTable_855C2F8,
@@ -403,7 +403,7 @@ const struct SpriteTemplate gSpriteTemplate_855C31C = {
};
const struct SpriteTemplate gSpriteTemplate_855C334 = {
- .tileTag = 0xffff,
+ .tileTag = INVALID_U16,
.paletteTag = 4112,
.oam = &gOamData_855C220,
.anims = gSpriteAnimTable_855C300,
@@ -413,7 +413,7 @@ const struct SpriteTemplate gSpriteTemplate_855C334 = {
};
const struct SpriteTemplate gSpriteTemplate_855C34C = {
- .tileTag = 0xffff,
+ .tileTag = INVALID_U16,
.paletteTag = 4112,
.oam = &gOamData_855C26C,
.anims = gSpriteAnimTable_855C300,
@@ -618,7 +618,7 @@ u32 FieldEffectScript_ReadWord(u8 **script)
void FieldEffectScript_LoadTiles(u8 **script)
{
struct SpriteSheet *sheet = (struct SpriteSheet *)FieldEffectScript_ReadWord(script);
- if (GetSpriteTileStartByTag(sheet->tag) == 0xFFFF)
+ if (GetSpriteTileStartByTag(sheet->tag) == INVALID_U16)
LoadSpriteSheet(sheet);
(*script) += 4;
}
@@ -665,7 +665,7 @@ void FieldEffectFreeTilesIfUnused(u16 tileStart)
u8 i;
u16 tag = GetSpriteTileTagByTileStart(tileStart);
- if (tag != 0xFFFF)
+ if (tag != INVALID_U16)
{
for (i = 0; i < MAX_SPRITES; i++)
if (gSprites[i].inUse && gSprites[i].usingSheet && tileStart == gSprites[i].sheetTileStart)
@@ -679,7 +679,7 @@ void FieldEffectFreePaletteIfUnused(u8 paletteNum)
u8 i;
u16 tag = GetSpritePaletteTagByPaletteNum(paletteNum);
- if (tag != 0xFFFF)
+ if (tag != INVALID_U16)
{
for (i = 0; i < MAX_SPRITES; i++)
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);
PreservePaletteInWeather(IndexOfSpritePaletteTag(gMonPaletteTable[species].tag) + 0x10);
- if (spriteId == 0xFFFF)
+ if (spriteId == INVALID_U16)
return MAX_SPRITES;
else
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);
u16 spriteId = CreateMonPicSprite_HandleDeoxys(species, d, g, 1, x, y, 0, spritePalette->tag);
PreservePaletteInWeather(IndexOfSpritePaletteTag(spritePalette->tag) + 0x10);
- if (spriteId == 0xFFFF)
+ if (spriteId == INVALID_U16)
return MAX_SPRITES;
else
return spriteId;
@@ -3591,7 +3591,7 @@ const union AnimCmd *const gSpriteAnimTable_855C5DC[] = {
};
const struct SpriteTemplate gUnknown_0855C5EC = {
- .tileTag = 0xffff,
+ .tileTag = INVALID_U16,
.paletteTag = 4378,
.oam = &gOamData_855C218,
.anims = gSpriteAnimTable_855C5DC,
diff --git a/src/field_message_box.c b/src/field_message_box.c
index 46da9e9e5..0725ca8c7 100755
--- a/src/field_message_box.c
+++ b/src/field_message_box.c
@@ -53,7 +53,7 @@ void task_add_textbox(void)
void task_del_textbox(void)
{
u8 taskId = FindTaskIdByFunc(sub_8098154);
- if (taskId != 0xFF)
+ if (taskId != INVALID_U8)
DestroyTask(taskId);
}
diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c
index a5aa23e32..7da89fe83 100644
--- a/src/field_player_avatar.c
+++ b/src/field_player_avatar.c
@@ -1389,7 +1389,7 @@ void InitPlayerAvatar(s16 x, s16 y, u8 direction, u8 gender)
u8 eventObjectId;
struct EventObject *eventObject;
- playerEventObjTemplate.localId = 0xFF;
+ playerEventObjTemplate.localId = INVALID_U8;
playerEventObjTemplate.graphicsId = GetPlayerAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, gender);
playerEventObjTemplate.x = x - 7;
playerEventObjTemplate.y = y - 7;
diff --git a/src/field_region_map.c b/src/field_region_map.c
index 40f48e668..d49ce3a4e 100644
--- a/src/field_region_map.c
+++ b/src/field_region_map.c
@@ -3,7 +3,7 @@
#include "gpu_regs.h"
#include "international_string_util.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "palette.h"
#include "region_map.h"
diff --git a/src/field_specials.c b/src/field_specials.c
index 4da751b27..629f2d0de 100644
--- a/src/field_specials.c
+++ b/src/field_specials.c
@@ -20,7 +20,7 @@
#include "link.h"
#include "list_menu.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "match_call.h"
#include "menu.h"
#include "overworld.h"
@@ -1957,12 +1957,12 @@ void sub_8139D98(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;
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)
return TRUE;
@@ -2946,10 +2946,10 @@ void sub_813AA44(void)
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_085B3142[] = { 0x0071, 0x006f, 0x0072, 0x0073, 0x0074, 0xffff };
- static const u16 gUnknown_085B314E[] = { 0x0040, 0x0043, 0x0041, 0x0046, 0x0042, 0x003f, 0xffff };
- static const u16 gUnknown_085B315C[] = { 0x00c8, 0x00b4, 0x00b7, 0x00b9, 0x00b3, 0x00ba, 0x00bb, 0x00c4, 0x00c6, 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, INVALID_U16 };
+ 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, INVALID_U16 };
static const u8 *const gUnknown_085B3170[] = {
BattleFrontier_BattlePointExchangeServiceCorner_Text_2601AA,
@@ -3004,7 +3004,7 @@ static void sub_813AA60(u16 a0, u16 a1)
{
case 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]);
}
@@ -3017,7 +3017,7 @@ static void sub_813AA60(u16 a0, u16 a1)
break;
case 4:
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]);
}
@@ -3841,13 +3841,13 @@ bool32 sub_813B9C0(void)
MAP_TRADE_CENTER,
MAP_RECORD_CORNER,
MAP_DOUBLE_BATTLE_COLOSSEUM,
- 0xffff
+ INVALID_U16
};
int i;
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)
{
diff --git a/src/fieldmap.c b/src/fieldmap.c
index 0d8a706b1..aef17d49d 100644
--- a/src/fieldmap.c
+++ b/src/fieldmap.c
@@ -496,7 +496,7 @@ u16 GetBehaviorByMetatileId(u16 metatile)
}
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)
{
- if (a2 == 0xFF)
+ if (a2 == INVALID_U8)
return FALSE;
if (a2 == 0)
diff --git a/src/fldeff_cut.c b/src/fldeff_cut.c
index 230a95e0b..2cffd5d41 100644
--- a/src/fldeff_cut.c
+++ b/src/fldeff_cut.c
@@ -6,7 +6,7 @@
#include "field_player_avatar.h"
#include "fieldmap.h"
#include "fldeff_cut.h"
-#include "malloc.h"
+#include "alloc.h"
#include "metatile_behavior.h"
#include "overworld.h"
#include "party_menu.h"
@@ -164,7 +164,7 @@ const struct SpritePalette gFieldEffectObjectPaletteInfo6 = {gFieldEffectObjectP
static const struct SpriteTemplate sSpriteTemplate_CutGrass =
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0x1000,
.oam = &sOamData_CutGrass,
.anims = sSpriteAnimTable_CutGrass,
diff --git a/src/fldeff_groundshake.c b/src/fldeff_groundshake.c
index e9a46bb86..3bbc489c1 100644
--- a/src/fldeff_groundshake.c
+++ b/src/fldeff_groundshake.c
@@ -2,7 +2,7 @@
#include "event_data.h"
#include "event_object_movement.h"
#include "field_camera.h"
-#include "malloc.h"
+#include "alloc.h"
#include "random.h"
#include "roulette_util.h"
#include "script.h"
@@ -236,7 +236,7 @@ static void sub_81BE968(void)
u8 taskId;
taskId = FindTaskIdByFunc(sub_81BE9C0);
- if(taskId != 0xFF)
+ if(taskId != INVALID_U8)
gTasks[taskId].data[0]++;
}
diff --git a/src/fossil_specials.c b/src/fossil_specials.c
index 8164a3a78..8f6e38e91 100644
--- a/src/fossil_specials.c
+++ b/src/fossil_specials.c
@@ -8,7 +8,7 @@
#include "fieldmap.h"
#include "global.fieldmap.h"
#include "gpu_regs.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "random.h"
#include "script.h"
@@ -302,7 +302,7 @@ static void sub_81BED50(u8 taskId)
case 4:
UnsetBgTilemapBuffer(0);
anotherTaskId = FindTaskIdByFunc(sub_81BEBB4);
- if (anotherTaskId != 0xFF)
+ if (anotherTaskId != INVALID_U8)
DestroyTask(anotherTaskId);
sUnknown_0203CF14[1] = sUnknown_0203CF14[0] = 0;
sub_81BEB90();
diff --git a/src/frontier_util.c b/src/frontier_util.c
index 5af7b3db7..e799f96c8 100644
--- a/src/frontier_util.c
+++ b/src/frontier_util.c
@@ -24,7 +24,7 @@
#include "data2.h"
#include "record_mixing.h"
#include "strings.h"
-#include "malloc.h"
+#include "alloc.h"
#include "save.h"
#include "load_save.h"
#include "battle_dome.h"
@@ -681,7 +681,7 @@ static const u8 sFacilityToBrainEventObjGfx[][2] =
const u16 gFrontierBannedSpecies[] =
{
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] =
@@ -1829,7 +1829,7 @@ void sub_81A3ACC(void)
s32 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)
@@ -1974,10 +1974,10 @@ static void AppendIfValid(u16 species, u16 heldItem, u16 hp, u8 lvlMode, u8 monL
if (species == SPECIES_EGG || species == SPECIES_NONE)
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;
if (lvlMode == FRONTIER_LVL_50 && monLevel > 50)
return;
@@ -2060,7 +2060,7 @@ static void sub_81A3FD4(void)
s32 i;
s32 caughtBannedMons = 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))
caughtBannedMons++;
@@ -2068,7 +2068,7 @@ static void sub_81A3FD4(void)
gStringVar1[0] = EOS;
gSpecialVar_0x8004 = 1;
count = 0;
- for (i = 0; gFrontierBannedSpecies[i] != 0xFFFF; i++)
+ for (i = 0; gFrontierBannedSpecies[i] != INVALID_U16; i++)
count = sub_81A3DD0(gFrontierBannedSpecies[i], count, caughtBannedMons);
if (count == 0)
diff --git a/src/ground.c b/src/ground.c
index 6cb7b8557..abfeb3f3e 100644
--- a/src/ground.c
+++ b/src/ground.c
@@ -588,7 +588,7 @@ void sub_81152DC(u8 taskId)
break;
default:
task->data[9] = GetAnimBattlerSpriteId(gBattleAnimArgs[0]);
- if (task->data[9] == 0xFF)
+ if (task->data[9] == INVALID_U8)
{
DestroyAnimVisualTask(taskId);
}
diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c
index 315990256..b75243b84 100644
--- a/src/hall_of_fame.c
+++ b/src/hall_of_fame.c
@@ -6,7 +6,7 @@
#include "pokemon.h"
#include "text.h"
#include "text_window.h"
-#include "malloc.h"
+#include "alloc.h"
#include "gpu_regs.h"
#include "graphics.h"
#include "main.h"
@@ -467,11 +467,11 @@ static void Task_Hof_InitMonData(u8 taskId)
sUnknown_0203BCD4 = 0;
gTasks[taskId].tDisplayedMonId = 0;
- gTasks[taskId].tPlayerSpriteID = 0xFF;
+ gTasks[taskId].tPlayerSpriteID = INVALID_U8;
for (i = 0; i < PARTY_SIZE; i++)
{
- gTasks[taskId].tMonSpriteId(i) = 0xFF;
+ gTasks[taskId].tMonSpriteId(i) = INVALID_U8;
}
if (gTasks[taskId].tDontSaveData)
@@ -522,7 +522,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId)
static void Task_Hof_TrySaveData(u8 taskId)
{
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(3);
@@ -645,7 +645,7 @@ static void Task_Hof_PaletteFadeAndPrintWelcomeText(u8 taskId)
BeginNormalPaletteFade(0xFFFF0000, 0, 0, 0, RGB_BLACK);
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;
}
@@ -668,7 +668,7 @@ static void sub_8173DC0(u8 taskId)
u16 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;
}
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++)
{
u8 spriteId = gTasks[taskId].tMonSpriteId(i);
- if (spriteId != 0xFF)
+ if (spriteId != INVALID_U8)
{
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
FreeAndDestroyMonPicSprite(spriteId);
@@ -847,7 +847,7 @@ void CB2_DoHallOfFamePC(void)
for (i = 0; i < PARTY_SIZE; i++)
{
- gTasks[taskId].tMonSpriteId(i) = 0xFF;
+ gTasks[taskId].tMonSpriteId(i) = INVALID_U8;
}
sHofMonPtr = AllocZeroed(0x2000);
@@ -937,7 +937,7 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId)
}
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++)
{
u16 spriteId = gTasks[taskId].tMonSpriteId(i);
- if (spriteId != 0xFF)
+ if (spriteId != INVALID_U8)
gSprites[spriteId].oam.priority = 1;
}
@@ -999,10 +999,10 @@ static void Task_HofPC_HandleInput(u8 taskId)
for (i = 0; i < 6; i++)
{
u8 spriteId = gTasks[taskId].tMonSpriteId(i);
- if (spriteId != 0xFF)
+ if (spriteId != INVALID_U8)
{
FreeAndDestroyMonPicSprite(spriteId);
- gTasks[taskId].tMonSpriteId(i) = 0xFF;
+ gTasks[taskId].tMonSpriteId(i) = INVALID_U8;
}
}
if (gTasks[taskId].tCurrPageNo != 0)
@@ -1060,10 +1060,10 @@ static void Task_HofPC_HandleExit(u8 taskId)
for (i = 0; i < PARTY_SIZE; i++)
{
u16 spriteId = gTasks[taskId].tMonSpriteId(i);
- if (spriteId != 0xFF)
+ if (spriteId != INVALID_U8)
{
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);
dexNumber = SpeciesToPokedexNum(currMon->species);
- if (dexNumber != 0xFFFF)
+ if (dexNumber != INVALID_U16)
{
stringPtr[0] = (dexNumber / 100) + CHAR_0;
stringPtr++;
@@ -1417,7 +1417,7 @@ void sub_8175280(void)
gSpecialVar_0x8004 = 180;
taskId = CreateTask(sub_8175364, 0);
- if (taskId != 0xFF)
+ if (taskId != INVALID_U8)
{
gTasks[taskId].data[1] = gSpecialVar_0x8004;
gSpecialVar_0x8005 = taskId;
@@ -1428,7 +1428,7 @@ static void sub_81752C0(void)
{
u8 taskId;
- if ((taskId = FindTaskIdByFunc(sub_8175364)) != 0xFF)
+ if ((taskId = FindTaskIdByFunc(sub_8175364)) != INVALID_U8)
DestroyTask(taskId);
sub_8152254();
@@ -1473,7 +1473,7 @@ static void sub_8175364(u8 taskId)
{
DestroyTask(taskId);
gSpecialVar_0x8004 = var;
- gSpecialVar_0x8005 = 0xFFFF;
+ gSpecialVar_0x8005 = INVALID_U16;
}
LoadCompressedObjectPic(sHallOfFame_ConfettiSpriteSheet);
LoadCompressedObjectPalette(sHallOfFame_ConfettiSpritePalette);
@@ -1483,7 +1483,7 @@ static void sub_8175364(u8 taskId)
if (data[1] != 0 && data[1] % 3 == 0)
{
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);
if ((Random() & 3) == 0)
@@ -1496,12 +1496,12 @@ static void sub_8175364(u8 taskId)
if (data[1] != 0)
data[1]--;
else if (data[15] == 0)
- data[0] = 0xFF;
+ data[0] = INVALID_U8;
break;
- case 0xFF:
+ case INVALID_U8:
sub_81752C0();
gSpecialVar_0x8004 = var;
- gSpecialVar_0x8005 = 0xFFFF;
+ gSpecialVar_0x8005 = INVALID_U16;
break;
}
}
diff --git a/src/intro.c b/src/intro.c
index 5a0e13869..44d1c086d 100644
--- a/src/intro.c
+++ b/src/intro.c
@@ -5,7 +5,7 @@
#include "task.h"
#include "title_screen.h"
#include "libgcnmultiboot.h"
-#include "malloc.h"
+#include "alloc.h"
#include "gpu_regs.h"
#include "link.h"
#include "multiboot_pokemon_colosseum.h"
diff --git a/src/intro_credits_graphics.c b/src/intro_credits_graphics.c
index 20a360901..1b4e9e15a 100644
--- a/src/intro_credits_graphics.c
+++ b/src/intro_credits_graphics.c
@@ -58,7 +58,7 @@ static void sub_817B7C4(struct Sprite *sprite);
static void nullsub_66(struct Sprite *sprite);
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[] = {
diff --git a/src/item.c b/src/item.c
index 6d2dbd561..e2583ddb1 100644
--- a/src/item.c
+++ b/src/item.c
@@ -4,7 +4,7 @@
#include "string_util.h"
#include "text.h"
#include "event_data.h"
-#include "malloc.h"
+#include "alloc.h"
#include "secret_base.h"
#include "item_menu.h"
#include "strings.h"
diff --git a/src/item_icon.c b/src/item_icon.c
index 41c6589f5..2af938ff8 100644
--- a/src/item_icon.c
+++ b/src/item_icon.c
@@ -2,7 +2,7 @@
#include "decompress.h"
#include "graphics.h"
#include "item_icon.h"
-#include "malloc.h"
+#include "alloc.h"
#include "sprite.h"
#include "constants/items.h"
@@ -161,7 +161,7 @@ u8 AddCustomItemIconSprite(struct SpriteTemplate *customSpriteTemplate, u16 tile
const void *GetItemIconPicOrPalette(u16 itemId, u8 which)
{
- if (itemId == 0xFFFF)
+ if (itemId == INVALID_U16)
itemId = ITEM_FIELD_ARROW;
else if (itemId >= ITEMS_COUNT)
itemId = 0;
diff --git a/src/item_menu.c b/src/item_menu.c
index 1744a1bfa..5b18b06ec 100755
--- a/src/item_menu.c
+++ b/src/item_menu.c
@@ -23,7 +23,7 @@
#include "link.h"
#include "mail.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "map_name_popup.h"
#include "menu.h"
#include "money.h"
@@ -532,11 +532,11 @@ void GoToBagMenu(u8 bagMenuType, u8 pocketId, void ( *postExitMenuMainCallback2)
if (temp <= 1)
gUnknown_0203CE54->unk81B = 1;
gUnknown_0203CE54->unk0 = 0;
- gUnknown_0203CE54->unk81A = 0xFF;
+ gUnknown_0203CE54->unk81A = INVALID_U8;
gUnknown_0203CE54->unk81E = -1;
gUnknown_0203CE54->unk81F = -1;
- memset(gUnknown_0203CE54->unk804, 0xFF, sizeof(gUnknown_0203CE54->unk804));
- memset(gUnknown_0203CE54->unk810, 0xFF, 10);
+ memset(gUnknown_0203CE54->unk804, INVALID_U8, sizeof(gUnknown_0203CE54->unk804));
+ memset(gUnknown_0203CE54->unk810, INVALID_U8, 10);
SetMainCallback2(CB2_Bag);
}
}
@@ -819,7 +819,7 @@ void bag_menu_change_item_callback(s32 a, bool8 b, struct ListMenu *unused)
PlaySE(SE_SELECT);
ShakeBagVisual();
}
- if (gUnknown_0203CE54->unk81A == 0xFF)
+ if (gUnknown_0203CE54->unk81A == INVALID_U8)
{
RemoveBagItemIconSprite(1 ^ gUnknown_0203CE54->unk81B_1);
if (a != -2)
@@ -840,7 +840,7 @@ void sub_81AB520(u8 rboxId, int item_index_in_pocket, u8 a)
int offset;
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)
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)
{
- if (b == 0xFF)
+ if (b == INVALID_U8)
FillWindowPixelRect(0, 0, 0, a, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1));
else
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)
{
- 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]);
}
void sub_81AB824(void)
{
- if (gUnknown_0203CE54->unk81E != 0xFF)
+ if (gUnknown_0203CE54->unk81E != INVALID_U8)
{
RemoveScrollIndicatorArrowPair(gUnknown_0203CE54->unk81E);
- gUnknown_0203CE54->unk81E = 0xFF;
+ gUnknown_0203CE54->unk81E = INVALID_U8;
}
sub_81AB89C();
}
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);
}
void sub_81AB89C(void)
{
- if (gUnknown_0203CE54->unk81F != 0xFF)
+ if (gUnknown_0203CE54->unk81F != INVALID_U8)
{
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 *ptr = &gUnknown_0203CE54->unk810[a];
- if (*ptr == 0xFF)
+ if (*ptr == INVALID_U8)
{
*ptr = AddWindow(&gUnknown_086141AC[a]);
SetWindowBorderStyle(*ptr, 0, 1, 14);
@@ -2315,20 +2315,20 @@ u8 bag_menu_add_window(u8 a)
void bag_menu_remove_window(u8 a)
{
u8 *ptr = &gUnknown_0203CE54->unk810[a];
- if (*ptr != 0xFF)
+ if (*ptr != INVALID_U8)
{
sub_8198070(*ptr, 0);
ClearWindowTilemap(*ptr);
RemoveWindow(*ptr);
schedule_bg_copy_tilemap_to_vram(1);
- *ptr = 0xFF;
+ *ptr = INVALID_U8;
}
}
u8 AddItemMessageWindow(u8 a)
{
u8 *ptr = &gUnknown_0203CE54->unk810[a];
- if (*ptr == 0xFF)
+ if (*ptr == INVALID_U8)
*ptr = AddWindow(&gUnknown_086141AC[a]);
return *ptr;
}
@@ -2336,13 +2336,13 @@ u8 AddItemMessageWindow(u8 a)
void bag_menu_RemoveBagItem_message_window(u8 a)
{
u8 *ptr = &gUnknown_0203CE54->unk810[a];
- if (*ptr != 0xFF)
+ if (*ptr != INVALID_U8)
{
sub_8197DF8(*ptr, 0);
ClearWindowTilemap(*ptr);
RemoveWindow(*ptr);
schedule_bg_copy_tilemap_to_vram(1);
- *ptr = 0xFF;
+ *ptr = INVALID_U8;
}
}
diff --git a/src/item_menu_icons.c b/src/item_menu_icons.c
index 85b42b9b3..67add5926 100644
--- a/src/item_menu_icons.c
+++ b/src/item_menu_icons.c
@@ -301,7 +301,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_857FC74[] =
static const struct SpriteTemplate gUnknown_0857FC7C =
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0x7544,
.oam = &sOamData_857FBD0,
.anims = sSpriteAnimTable_857FBE0,
@@ -410,13 +410,13 @@ static const struct SpriteTemplate gUnknown_0857FE10 =
void RemoveBagSprite(u8 id)
{
u8 *spriteId = &gUnknown_0203CE54->unk804[id];
- if (*spriteId != 0xFF)
+ if (*spriteId != INVALID_U8)
{
FreeSpriteTilesByTag(id + 100);
FreeSpritePaletteByTag(id + 100);
FreeSpriteOamMatrix(&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)
{
u8 *spriteId = &gUnknown_0203CE54->unk804[id + 2];
- if (*spriteId == 0xFF)
+ if (*spriteId == INVALID_U8)
{
u8 iconSpriteId;
diff --git a/src/learn_move.c b/src/learn_move.c
index 7717a5193..cb8bb66ff 100644
--- a/src/learn_move.c
+++ b/src/learn_move.c
@@ -9,7 +9,7 @@
#include "gpu_regs.h"
#include "learn_move.h"
#include "list_menu.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "overworld.h"
@@ -381,7 +381,7 @@ static void LearnMoveMain(void)
if (selection == 0)
{
- if (GiveMoveToMon(&gPlayerParty[sLearnMoveStruct->partyMon], GetCurrentItemId()) != 0xFFFF)
+ if (GiveMoveToMon(&gPlayerParty[sLearnMoveStruct->partyMon], GetCurrentItemId()) != INVALID_U16)
{
sub_816084C(gText_PkmnLearnedMove4);
gSpecialVar_0x8004 = 1;
@@ -727,12 +727,12 @@ static void CreateHearts(void)
static void AddScrollArrows(void)
{
- if (sLearnMoveStruct->scrollArrowTaskId2 == 0xFF)
+ if (sLearnMoveStruct->scrollArrowTaskId2 == INVALID_U8)
{
sLearnMoveStruct->scrollArrowTaskId2 = AddScrollIndicatorArrowPair(&gUnknown_085CEBC0, &sLearnMoveStruct->scrollOffset);
}
- if (sLearnMoveStruct->scrollArrowTaskId1 == 0xFF)
+ if (sLearnMoveStruct->scrollArrowTaskId1 == INVALID_U8)
{
gTempScrollArrowTemplate = gUnknown_085CEBD0;
gTempScrollArrowTemplate.fullyDownThreshold = sLearnMoveStruct->numMenuChoices - sLearnMoveStruct->numToShowAtOnce;
@@ -742,16 +742,16 @@ static void AddScrollArrows(void)
static void RemoveScrollArrows(void)
{
- if (sLearnMoveStruct->scrollArrowTaskId2 != 0xFF)
+ if (sLearnMoveStruct->scrollArrowTaskId2 != INVALID_U8)
{
RemoveScrollIndicatorArrowPair(sLearnMoveStruct->scrollArrowTaskId2);
- sLearnMoveStruct->scrollArrowTaskId2 = 0xFF;
+ sLearnMoveStruct->scrollArrowTaskId2 = INVALID_U8;
}
- if (sLearnMoveStruct->scrollArrowTaskId1 != 0xFF)
+ if (sLearnMoveStruct->scrollArrowTaskId1 != INVALID_U8)
{
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);
- if (numHearts == 0xFF)
+ if (numHearts == INVALID_U8)
{
numHearts = 0;
}
@@ -812,7 +812,7 @@ void ShowHideHearts(s32 item)
numHearts = (u8)(gContestEffects[gContestMoves[item].effect].jam / 10);
- if (numHearts == 0xFF)
+ if (numHearts == INVALID_U8)
{
numHearts = 0;
}
diff --git a/src/librfu_rfu.c b/src/librfu_rfu.c
index c5aa25c10..2f706fcc8 100644
--- a/src/librfu_rfu.c
+++ b/src/librfu_rfu.c
@@ -64,7 +64,7 @@
v12 = (u16*)((u32)&sub_82E53F4 & ~1);
v13 = (u16*)gUnknown_03007898->unk_8;
- for (i = 47; i != 0xFFFF; i--)
+ for (i = 47; i != INVALID_U16; i--)
{
*v13 = *v12;
++v12;
diff --git a/src/librfu_stwi.c b/src/librfu_stwi.c
index 556b79bf8..81363ae0d 100644
--- a/src/librfu_stwi.c
+++ b/src/librfu_stwi.c
@@ -116,7 +116,7 @@ u16 STWI_read_status(u8 index)
case 3:
return gRfuState->activeCommand;
default:
- return 0xFFFF;
+ return INVALID_U16;
}
}
diff --git a/src/link.c b/src/link.c
index 687a6c07b..e4bd5053c 100644
--- a/src/link.c
+++ b/src/link.c
@@ -2,7 +2,7 @@
// Includes
#include "global.h"
#include "m4a.h"
-#include "malloc.h"
+#include "alloc.h"
#include "reset_save_heap.h"
#include "save.h"
#include "bg.h"
@@ -2250,7 +2250,7 @@ static bool8 DoHandshake(void)
u16 minRecv;
playerCount = 0;
- minRecv = 0xFFFF;
+ minRecv = INVALID_U16;
if (gLink.handshakeAsMaster == TRUE)
{
REG_SIOMLT_SEND = MASTER_HANDSHAKE;
@@ -2274,7 +2274,7 @@ static bool8 DoHandshake(void)
}
else
{
- if (gLink.tempRecvBuffer[i] != 0xFFFF)
+ if (gLink.tempRecvBuffer[i] != INVALID_U16)
{
playerCount = 0;
}
diff --git a/src/link_rfu.c b/src/link_rfu.c
index 308ad615c..fe5676770 100644
--- a/src/link_rfu.c
+++ b/src/link_rfu.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "alloc.h"
#include "battle.h"
#include "berry_blender.h"
#include "decompress.h"
@@ -7,7 +8,6 @@
#include "librfu.h"
#include "link.h"
#include "link_rfu.h"
-#include "malloc.h"
#include "overworld.h"
#include "random.h"
#include "palette.h"
@@ -276,7 +276,7 @@ const struct {
{ gBlockSendBuffer, 40 }
};
const u16 gUnknown_082ED6E0[] = {
- 0x0002, 0x7f7d, 0x0000, 0xffff
+ 0x0002, 0x7f7d, 0x0000, INVALID_U16
};
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++)
{
- if (*buffer++ == 0xFFFF)
+ if (*buffer++ == INVALID_U16)
{
break;
}
@@ -754,7 +754,7 @@ void sub_800C54C(u32 a0)
switch (gUnknown_03004140.unk_04)
{
case 23:
- r2 = sub_800BEC0() == 0x8001 ? 0x44 : 0xFF;
+ r2 = sub_800BEC0() == 0x8001 ? 0x44 : INVALID_U8;
gUnknown_03004140.unk_04 = gUnknown_03004140.unk_05 = 0;
sub_800D30C(r2, 0);
break;
@@ -1168,7 +1168,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
gUnknown_03004140.unk_00 &= ~gUnknown_03004140.unk_14;
if (gUnknown_03004140.unk_07)
{
- if (gUnknown_03007890->unk_00 == 0xFF)
+ if (gUnknown_03007890->unk_00 == INVALID_U8)
{
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)
{
@@ -1198,7 +1198,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
break;
case 38:
sub_800D20C();
- if (gUnknown_03007890->unk_00 != 0xFF)
+ if (gUnknown_03007890->unk_00 != INVALID_U8)
{
sub_800D30C(0x50, 0x00);
}
@@ -1241,7 +1241,7 @@ static void sub_800C7B4(u16 r8, u16 r6)
sub_800D610();
}
}
- if (r8 == 0xFF)
+ if (r8 == INVALID_U8)
{
sub_800D30C(0xf2, 0x00);
sub_800D610();
@@ -1322,7 +1322,7 @@ static void sub_800CF34(void)
if (gUnknown_03007880[i]->unk_61 == 1)
{
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)
{
@@ -1469,7 +1469,7 @@ static u8 sub_800D294(void)
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)
{
@@ -2242,12 +2242,12 @@ void sub_800E084(void)
void sub_800E0E8(void)
{
- if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == 0xFFFF)
+ if (GetSpriteTileStartByTag(sWirelessStatusIndicatorSpriteSheet.tag) == INVALID_U16)
{
LoadCompressedObjectPic(&sWirelessStatusIndicatorSpriteSheet);
}
LoadSpritePalette(&sWirelessStatusIndicatorSpritePalette);
- gWirelessStatusIndicatorSpriteId = 0xFF;
+ gWirelessStatusIndicatorSpriteId = INVALID_U8;
}
u8 sub_800E124(void)
@@ -2277,7 +2277,7 @@ void sub_800E15C(struct Sprite *sprite, s32 signalStrengthAnimNum)
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];
u8 signalStrength = 255;
@@ -2461,7 +2461,7 @@ void sub_800E604(void)
u8 unk_ee_bak = gUnknown_03005000.unk_ee;
CpuFill16(0, &gUnknown_03005000, sizeof gUnknown_03005000);
gUnknown_03005000.unk_ee = unk_ee_bak;
- gUnknown_03005000.unk_0c = 0xFF;
+ gUnknown_03005000.unk_0c = INVALID_U8;
if (gUnknown_03005000.unk_ee != 4)
{
gUnknown_03005000.unk_ee = 0;
@@ -3077,7 +3077,7 @@ bool32 sub_800F1E0(void)
{
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)
sub_8011170(0x8100);
@@ -3778,7 +3778,7 @@ bool32 sub_8010454(u32 a0)
s32 i;
for (i = 0; gUnknown_082ED6E0[i] != a0; i++)
{
- if (gUnknown_082ED6E0[i] == 0xffff)
+ if (gUnknown_082ED6E0[i] == INVALID_U16)
return FALSE;
}
return TRUE;
@@ -3881,7 +3881,7 @@ bool32 sub_80105EC(void)
bool32 sub_801064C(u16 a0, const u8 *a1)
{
u8 r1 = sub_8011CE4(a1, a0);
- if (r1 == 0xFF)
+ if (r1 == INVALID_U8)
return TRUE;
if (gUnknown_03005000.unk_cd1[r1] == 9)
return TRUE;
@@ -3906,7 +3906,7 @@ void sub_80106D4(void)
u32 sub_8010714(u16 a0, const u8 *a1)
{
u8 r0 = sub_8011CE4(a1, a0);
- if (r0 == 0xff)
+ if (r0 == INVALID_U8)
return 2;
if (gUnknown_03007880[r0]->unk_0 == 0)
return 1;
diff --git a/src/list_menu.c b/src/list_menu.c
index 6907a75a3..e066d1e9c 100644
--- a/src/list_menu.c
+++ b/src/list_menu.c
@@ -8,7 +8,7 @@
#include "trig.h"
#include "decompress.h"
#include "palette.h"
-#include "malloc.h"
+#include "alloc.h"
#include "strings.h"
#include "sound.h"
#include "constants/songs.h"
@@ -392,7 +392,7 @@ u8 ListMenuInitInRect(struct ListMenuTemplate *listMenuTemplate, struct ListMenu
s32 i;
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,
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)
{
@@ -1143,7 +1143,7 @@ static void Task_ScrollIndicatorArrowPair(u8 taskId)
struct ScrollIndicatorPair *data = (void*) gTasks[taskId].data;
u16 currItem = (*data->scrollOffset);
- if (currItem == data->fullyUpThreshold && currItem != 0xFFFF)
+ if (currItem == data->fullyUpThreshold && currItem != INVALID_U16)
gSprites[data->topSpriteId].invisible = TRUE;
else
gSprites[data->topSpriteId].invisible = FALSE;
diff --git a/src/load_save.c b/src/load_save.c
index 960a98981..8ecf89959 100644
--- a/src/load_save.c
+++ b/src/load_save.c
@@ -4,7 +4,7 @@
#include "main.h"
#include "pokemon.h"
#include "random.h"
-#include "malloc.h"
+#include "alloc.h"
#include "item.h"
#include "overworld.h"
#include "decoration_inventory.h"
diff --git a/src/mail.c b/src/mail.c
index 513900746..7b096ed00 100644
--- a/src/mail.c
+++ b/src/mail.c
@@ -17,7 +17,7 @@
#include "bg.h"
#include "pokemon_icon.h"
#include "constants/species.h"
-#include "malloc.h"
+#include "alloc.h"
#include "easy_chat.h"
extern const u16 gMailPalette_Orange[];
diff --git a/src/mail_data.c b/src/mail_data.c
index 809dcc2a8..cf75636b3 100644
--- a/src/mail_data.c
+++ b/src/mail_data.c
@@ -20,7 +20,7 @@ void ClearMailStruct(struct MailStruct *mail)
s32 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++)
mail->playerName[i] = EOS;
@@ -35,7 +35,7 @@ void ClearMailStruct(struct MailStruct *mail)
bool8 MonHasMail(struct Pokemon *mon)
{
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;
else
return FALSE;
@@ -56,7 +56,7 @@ u8 GiveMailToMon(struct Pokemon *mon, u16 itemId)
if (gSaveBlock1Ptr->mail[id].itemId == 0)
{
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++)
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)
@@ -113,8 +113,8 @@ u8 GiveMailToMon2(struct Pokemon *mon, struct MailStruct *mail)
u16 itemId = mail->itemId;
u8 mailId = GiveMailToMon(mon, itemId);
- if (mailId == 0xFF)
- return 0xFF;
+ if (mailId == INVALID_U8)
+ return INVALID_U8;
gSaveBlock1Ptr->mail[mailId] = *mail;
@@ -142,7 +142,7 @@ void TakeMailFromMon(struct Pokemon *mon)
{
mailId = GetMonData(mon, MON_DATA_MAIL);
gSaveBlock1Ptr->mail[mailId].itemId = ITEM_NONE;
- mailId = 0xFF;
+ mailId = INVALID_U8;
heldItem[0] = ITEM_NONE;
heldItem[1] = ITEM_NONE << 8;
SetMonData(mon, MON_DATA_MAIL, &mailId);
@@ -163,7 +163,7 @@ u8 TakeMailFromMon2(struct Pokemon *mon)
newHeldItem[0] = ITEM_NONE;
newHeldItem[1] = ITEM_NONE << 8;
- newMailId = 0xFF;
+ newMailId = INVALID_U8;
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)
diff --git a/src/main.c b/src/main.c
index d069ab3bc..c4962286c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,6 @@
#include "global.h"
#include "crt0.h"
-#include "malloc.h"
+#include "alloc.h"
#include "link.h"
#include "link_rfu.h"
#include "librfu.h"
diff --git a/src/malloc.c b/src/malloc.c
deleted file mode 100644
index 1d64351c3..000000000
--- a/src/malloc.c
+++ /dev/null
@@ -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;
-}
diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c
index 110ec068e..2fd60cd5b 100644
--- a/src/mauville_old_man.c
+++ b/src/mauville_old_man.c
@@ -250,7 +250,7 @@ void ScrSpecial_HipsterTeachWord(void)
{
u16 var = sub_811F01C();
- if (var == 0xFFFF)
+ if (var == INVALID_U16)
{
gSpecialVar_Result = FALSE;
}
@@ -283,7 +283,7 @@ void ScrSpecial_GenerateGiddyLine(void)
if (giddy->taleCounter == 0)
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;
u32 adjective = Random();
@@ -348,7 +348,7 @@ static void InitGiddyTaleList(void)
r1 = Random() % 10;
if (r1 < 3 && r7 < 8)
{
- giddy->randomWords[i] = 0xFFFF;
+ giddy->randomWords[i] = INVALID_U16;
r7++;
}
else
diff --git a/src/menu.c b/src/menu.c
index dde0e0a1a..e1dd136d1 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -7,7 +7,7 @@
#include "main.h"
#include "sound.h"
#include "menu_helpers.h"
-#include "malloc.h"
+#include "alloc.h"
#include "task.h"
#include "dma3.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)
{
InitWindows(gUnknown_0860F098);
- gStartMenuWindowId = 0xFF;
- gUnknown_0203CD8D = 0xFF;
+ gStartMenuWindowId = INVALID_U8;
+ gUnknown_0203CD8D = INVALID_U8;
}
void sub_81971F4(void)
@@ -486,7 +486,7 @@ u8 GetPlayerTextSpeedDelay(void)
u8 sub_81979C4(u8 a1)
{
- if (gStartMenuWindowId == 0xFF)
+ if (gStartMenuWindowId == INVALID_U8)
gStartMenuWindowId = sub_8198AA4(0, 0x16, 1, 7, (a1 * 2) + 2, 0xF, 0x139);
return gStartMenuWindowId;
}
@@ -498,10 +498,10 @@ u8 GetStartMenuWindowId(void)
void RemoveStartMenuWindow(void)
{
- if (gStartMenuWindowId != 0xFF)
+ if (gStartMenuWindowId != INVALID_U8)
{
RemoveWindow(gStartMenuWindowId);
- gStartMenuWindowId = 0xFF;
+ gStartMenuWindowId = INVALID_U8;
}
}
@@ -517,7 +517,7 @@ u16 sub_8197A38(void)
u8 AddMapNamePopUpWindow(void)
{
- if (gUnknown_0203CD8D == 0xFF)
+ if (gUnknown_0203CD8D == INVALID_U8)
gUnknown_0203CD8D = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107);
return gUnknown_0203CD8D;
}
@@ -529,10 +529,10 @@ u8 GetMapNamePopUpWindowId(void)
void RemoveMapNamePopUpWindow(void)
{
- if (gUnknown_0203CD8D != 0xFF)
+ if (gUnknown_0203CD8D != INVALID_U8)
{
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;
- if (gUnknown_0203CDA0 != 0xFF)
+ if (gUnknown_0203CDA0 != INVALID_U8)
{
PutWindowTilemap(gUnknown_0203CDA0);
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];
u16 width = 0;
- if (gUnknown_0203CDA0 != 0xFF)
+ if (gUnknown_0203CDA0 != INVALID_U8)
{
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)
{
- if (gUnknown_0203CDA0 != 0xFF)
+ if (gUnknown_0203CDA0 != INVALID_U8)
CopyWindowToVram(gUnknown_0203CDA0, 3);
}
void sub_81982F0(void)
{
- if (gUnknown_0203CDA0 != 0xFF)
+ if (gUnknown_0203CDA0 != INVALID_U8)
{
FillWindowPixelBuffer(gUnknown_0203CDA0, 0xFF);
CopyWindowToVram(gUnknown_0203CDA0, 3);
@@ -880,13 +880,13 @@ void sub_81982F0(void)
void sub_8198314(void)
{
- if (gUnknown_0203CDA0 != 0xFF)
+ if (gUnknown_0203CDA0 != INVALID_U8)
{
FillWindowPixelBuffer(gUnknown_0203CDA0, 0);
ClearWindowTilemap(gUnknown_0203CDA0);
CopyWindowToVram(gUnknown_0203CDA0, 3);
RemoveWindow(gUnknown_0203CDA0);
- gUnknown_0203CDA0 = 0xFF;
+ gUnknown_0203CDA0 = INVALID_U8;
}
}
diff --git a/src/mossdeep_gym.c b/src/mossdeep_gym.c
index cd377ad83..07920fe4c 100644
--- a/src/mossdeep_gym.c
+++ b/src/mossdeep_gym.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "event_object_movement.h"
#include "fieldmap.h"
-#include "malloc.h"
+#include "alloc.h"
#include "mossdeep_gym.h"
#include "script_movement.h"
#include "constants/event_object_movement_constants.h"
diff --git a/src/naming_screen.c b/src/naming_screen.c
index 9902df04c..12ff4240f 100644
--- a/src/naming_screen.c
+++ b/src/naming_screen.c
@@ -1,6 +1,6 @@
#include "global.h"
#include "naming_screen.h"
-#include "malloc.h"
+#include "alloc.h"
#include "palette.h"
#include "task.h"
#include "sprite.h"
@@ -2141,7 +2141,7 @@ static const struct SpriteTemplate sSpriteTemplate_Underscore =
static const struct SpriteTemplate gUnknown_0858C180 =
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0x0000,
.oam = &gOamData_858BFEC,
.anims = gSpriteAnimTable_858C0BC,
diff --git a/src/overworld.c b/src/overworld.c
index 3193ec0d3..13c36819f 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -27,7 +27,7 @@
#include "link_rfu.h"
#include "load_save.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "m4a.h"
#include "map_name_popup.h"
#include "menu.h"
@@ -1110,7 +1110,7 @@ static bool16 IsInflitratedSpaceCenter(struct WarpData *warp)
u16 GetLocationMusic(struct WarpData *warp)
{
if (NoMusicInSotopolisWithLegendaries(warp) == TRUE)
- return 0xFFFF;
+ return INVALID_U16;
else if (ShouldLegendaryMusicPlayAtLocation(warp) == TRUE)
return MUS_OOAME;
else if (IsInflitratedSpaceCenter(warp) == TRUE)
@@ -1171,7 +1171,7 @@ void Overworld_PlaySpecialMapMusic(void)
{
u16 music = GetCurrLocationDefaultMusic();
- if (music != MUS_OOAME && music != 0xFFFF)
+ if (music != MUS_OOAME && music != INVALID_U16)
{
if (gSaveBlock1Ptr->savedMusic)
music = gSaveBlock1Ptr->savedMusic;
@@ -1201,7 +1201,7 @@ static void sub_8085810(void)
{
u16 newMusic = GetWarpDestinationMusic();
u16 currentMusic = GetCurrentMapMusic();
- if (newMusic != MUS_OOAME && newMusic != 0xFFFF)
+ if (newMusic != MUS_OOAME && newMusic != INVALID_U16)
{
if (currentMusic == MUS_DEEPDEEP || currentMusic == MUS_NAMINORI)
return;
diff --git a/src/palette.c b/src/palette.c
index 1e92f4bba..3c7485d05 100644
--- a/src/palette.c
+++ b/src/palette.c
@@ -63,7 +63,7 @@ static EWRAM_DATA u32 sPlttBufferTransferPending = 0;
EWRAM_DATA u8 gPaletteDecompressionBuffer[PLTT_DECOMP_BUFFER_SIZE] = {0};
static const struct PaletteStructTemplate gDummyPaletteStructTemplate = {
- .uid = 0xFFFF,
+ .uid = INVALID_U16,
.pst_field_B_5 = 1
};
diff --git a/src/player_pc.c b/src/player_pc.c
index 59ba36350..f42d59147 100644
--- a/src/player_pc.c
+++ b/src/player_pc.c
@@ -15,7 +15,7 @@
#include "list_menu.h"
#include "mail.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "overworld.h"
diff --git a/src/pokeblock.c b/src/pokeblock.c
index 01343c6eb..41d6dcc8f 100644
--- a/src/pokeblock.c
+++ b/src/pokeblock.c
@@ -13,7 +13,7 @@
#include "lilycove_lady.h"
#include "list_menu.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "overworld.h"
@@ -435,7 +435,7 @@ void OpenPokeblockCase(u8 caseId, void (*callback)(void))
sPokeblockMenu = Alloc(sizeof(*sPokeblockMenu));
sPokeblockMenu->caseId = caseId;
sPokeblockMenu->callbackOnUse = NULL;
- sPokeblockMenu->unkTaskId = 0xFF;
+ sPokeblockMenu->unkTaskId = INVALID_U8;
sPokeblockMenu->isSwapping = FALSE;
sSavedPokeblockData.callback = callback;
@@ -901,7 +901,7 @@ static void sub_8136344(void)
static void sub_81363BC(void)
{
- if (sPokeblockMenu->unkTaskId == 0xFF)
+ if (sPokeblockMenu->unkTaskId == INVALID_U8)
{
sPokeblockMenu->unkTaskId = AddScrollIndicatorArrowPairParameterized(SCROLL_ARROW_UP, 0xB0, 8, 0x98, sPokeblockMenu->itemsNo - sPokeblockMenu->maxShowed,
0x456, 0x456, &sSavedPokeblockData.lastItemPage);
@@ -910,10 +910,10 @@ static void sub_81363BC(void)
static void sub_8136418(void)
{
- if (sPokeblockMenu->unkTaskId != 0xFF)
+ if (sPokeblockMenu->unkTaskId != INVALID_U8)
{
RemoveScrollIndicatorArrowPair(sPokeblockMenu->unkTaskId);
- sPokeblockMenu->unkTaskId = 0xFF;
+ sPokeblockMenu->unkTaskId = INVALID_U8;
}
}
@@ -1016,7 +1016,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId)
break;
case LIST_B_PRESSED:
PlaySE(SE_SELECT);
- gSpecialVar_Result = 0xFFFF;
+ gSpecialVar_Result = INVALID_U16;
gSpecialVar_ItemId = 0;
FadePaletteAndSetTaskToClosePokeblockCase(taskId);
break;
diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c
index 0a8f1b8c2..91dbd1c99 100644
--- a/src/pokeblock_feed.c
+++ b/src/pokeblock_feed.c
@@ -7,7 +7,7 @@
#include "gpu_regs.h"
#include "graphics.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "m4a.h"
diff --git a/src/pokedex.c b/src/pokedex.c
index 7578f9687..4e28c8a14 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -8,7 +8,7 @@
#include "graphics.h"
#include "international_string_util.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "m4a.h"
#include "overworld.h"
@@ -1271,7 +1271,7 @@ static void ResetPokedexView(struct PokedexView *pokedexView)
pokedexView->seenCount = 0;
pokedexView->ownCount = 0;
for (i = 0; i <= 3; i++)
- pokedexView->unk61E[i] |= 0xFFFF;
+ pokedexView->unk61E[i] |= INVALID_U16;
pokedexView->unk628 = 0;
pokedexView->unk62A = 0;
pokedexView->unk62C = 0;
@@ -2459,7 +2459,7 @@ u32 sub_80BDACC(u16 num, s16 x, s16 y)
return spriteId;
}
}
- return 0xFFFF;
+ return INVALID_U16;
}
static void CreateInterfaceSprites(u8 a)
@@ -2717,8 +2717,8 @@ void sub_80BE4E0(struct Sprite *sprite)
sprite->pos2.y = gSineTable[(u8)sprite->data[5]] * 76 / 256;
var = 0x10000 / gSineTable[sprite->data[5] + 0x40];
- if (var > 0xFFFF)
- var = 0xFFFF;
+ if (var > INVALID_U16)
+ var = INVALID_U16;
SetOamMatrix(sprite->data[1] + 1, 0x100, 0, 0, var);
sprite->oam.matrixNum = data1 + 1;
@@ -4627,12 +4627,12 @@ u32 sub_80C0E68(u16 a)
u16 sub_80C0E9C(u16 num, s16 x, s16 y, u16 paletteSlot)
{
num = NationalPokedexNumToSpecies(num);
- return CreateMonPicSprite_HandleDeoxys(num, 8, sub_80C0E68(num), TRUE, x, y, paletteSlot, 0xFFFF);
+ return CreateMonPicSprite_HandleDeoxys(num, 8, sub_80C0E68(num), TRUE, x, y, paletteSlot, INVALID_U16);
}
u16 sub_80C0EF8(u16 species, s16 x, s16 y, s8 paletteSlot)
{
- return CreateTrainerPicSprite(species, TRUE, x, y, paletteSlot, 0xFFFF);
+ return CreateTrainerPicSprite(species, TRUE, x, y, paletteSlot, INVALID_U16);
}
int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8 type2)
@@ -4655,7 +4655,7 @@ int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8
sPokedexView->pokemonListCount = resultsCount;
// Search by name
- if (abcGroup != 0xFF)
+ if (abcGroup != INVALID_U8)
{
for (i = 0, resultsCount = 0; i < sPokedexView->pokemonListCount; i++)
{
@@ -4674,7 +4674,7 @@ int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8
}
// Search by body color
- if (bodyColor != 0xFF)
+ if (bodyColor != INVALID_U8)
{
for (i = 0, resultsCount = 0; i < sPokedexView->pokemonListCount; i++)
{
@@ -4690,15 +4690,15 @@ int sub_80C0F30(u8 dexMode, u8 sortMode, u8 abcGroup, u8 bodyColor, u8 type1, u8
}
// Search by type
- if (type1 != 0xFF || type2 != 0xFF)
+ if (type1 != INVALID_U8 || type2 != INVALID_U8)
{
- if (type1 == 0xFF)
+ if (type1 == INVALID_U8)
{
type1 = type2;
- type2 = 0xFF;
+ type2 = INVALID_U8;
}
- if (type2 == 0xFF)
+ if (type2 == INVALID_U8)
{
for (i = 0, resultsCount = 0; i < sPokedexView->pokemonListCount; i++)
{
@@ -4987,7 +4987,7 @@ void sub_80C170C(u8 taskId)
return;
}
- if ((gMain.newKeys & DPAD_LEFT) && r6[gTasks[taskId].data[1]][0] != 0xFF)
+ if ((gMain.newKeys & DPAD_LEFT) && r6[gTasks[taskId].data[1]][0] != INVALID_U8)
{
PlaySE(SE_SELECT);
gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][0];
@@ -4995,7 +4995,7 @@ void sub_80C170C(u8 taskId)
CopyWindowToVram(0, 2);
CopyBgTilemapBufferToVram(3);
}
- if ((gMain.newKeys & DPAD_RIGHT) && r6[gTasks[taskId].data[1]][1] != 0xFF)
+ if ((gMain.newKeys & DPAD_RIGHT) && r6[gTasks[taskId].data[1]][1] != INVALID_U8)
{
PlaySE(SE_SELECT);
gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][1];
@@ -5003,7 +5003,7 @@ void sub_80C170C(u8 taskId)
CopyWindowToVram(0, 2);
CopyBgTilemapBufferToVram(3);
}
- if ((gMain.newKeys & DPAD_UP) && r6[gTasks[taskId].data[1]][2] != 0xFF)
+ if ((gMain.newKeys & DPAD_UP) && r6[gTasks[taskId].data[1]][2] != INVALID_U8)
{
PlaySE(SE_SELECT);
gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][2];
@@ -5011,7 +5011,7 @@ void sub_80C170C(u8 taskId)
CopyWindowToVram(0, 2);
CopyBgTilemapBufferToVram(3);
}
- if ((gMain.newKeys & DPAD_DOWN) && r6[gTasks[taskId].data[1]][3] != 0xFF)
+ if ((gMain.newKeys & DPAD_DOWN) && r6[gTasks[taskId].data[1]][3] != INVALID_U8)
{
PlaySE(SE_SELECT);
gTasks[taskId].data[1] = r6[gTasks[taskId].data[1]][3];
@@ -5475,12 +5475,12 @@ u8 sub_80C2318(u8 taskId, u8 b)
return gUnknown_0856EFAE[r2];
case 0:
if (r2 == 0)
- return 0xFF;
+ return INVALID_U8;
else
return r2;
case 1:
if (r2 == 0)
- return 0xFF;
+ return INVALID_U8;
else
return r2 - 1;
case 2:
diff --git a/src/pokedex_cry_screen.c b/src/pokedex_cry_screen.c
index f3eeeed07..4a9227b99 100755
--- a/src/pokedex_cry_screen.c
+++ b/src/pokedex_cry_screen.c
@@ -2,7 +2,7 @@
#include "bg.h"
#include "m4a.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "palette.h"
#include "pokedex_cry_screen.h"
#include "sound.h"
diff --git a/src/pokemon.c b/src/pokemon.c
index f528ce331..1f8d5339b 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -12,7 +12,7 @@
#include "item.h"
#include "link.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "m4a.h"
#include "pokedex.h"
#include "pokeblock.h"
@@ -2300,7 +2300,7 @@ static const u8 sHoldEffectToType[][2] =
const struct SpriteTemplate gUnknown_08329D98[MAX_BATTLERS_COUNT] =
{
{ // B_POSITION_PLAYER_LEFT
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2309,7 +2309,7 @@ const struct SpriteTemplate gUnknown_08329D98[MAX_BATTLERS_COUNT] =
.callback = sub_8039BB4,
},
{ // B_POSITION_OPPONENT_LEFT
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACA8,
.anims = NULL,
@@ -2318,7 +2318,7 @@ const struct SpriteTemplate gUnknown_08329D98[MAX_BATTLERS_COUNT] =
.callback = oac_poke_opponent,
},
{ // B_POSITION_PLAYER_RIGHT
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2327,7 +2327,7 @@ const struct SpriteTemplate gUnknown_08329D98[MAX_BATTLERS_COUNT] =
.callback = sub_8039BB4,
},
{ // B_POSITION_OPPONENT_RIGHT
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACA8,
.anims = NULL,
@@ -2340,7 +2340,7 @@ const struct SpriteTemplate gUnknown_08329D98[MAX_BATTLERS_COUNT] =
static const struct SpriteTemplate gUnknown_08329DF8[] =
{
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2349,7 +2349,7 @@ static const struct SpriteTemplate gUnknown_08329DF8[] =
.callback = sub_8039BB4,
},
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2358,7 +2358,7 @@ static const struct SpriteTemplate gUnknown_08329DF8[] =
.callback = sub_8039BB4,
},
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2367,7 +2367,7 @@ static const struct SpriteTemplate gUnknown_08329DF8[] =
.callback = sub_8039BB4,
},
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2376,7 +2376,7 @@ static const struct SpriteTemplate gUnknown_08329DF8[] =
.callback = sub_8039BB4,
},
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2385,7 +2385,7 @@ static const struct SpriteTemplate gUnknown_08329DF8[] =
.callback = sub_8039BB4,
},
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2394,7 +2394,7 @@ static const struct SpriteTemplate gUnknown_08329DF8[] =
.callback = sub_8039BB4,
},
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2403,7 +2403,7 @@ static const struct SpriteTemplate gUnknown_08329DF8[] =
.callback = sub_8039BB4,
},
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0,
.oam = &gUnknown_0831ACB0,
.anims = NULL,
@@ -2450,7 +2450,7 @@ static const s8 gUnknown_08329ECE[][3] =
static const u16 sHMMoves[] =
{
MOVE_CUT, MOVE_FLY, MOVE_SURF, MOVE_STRENGTH, MOVE_FLASH,
- MOVE_ROCK_SMASH, MOVE_WATERFALL, MOVE_DIVE, 0xFFFF
+ MOVE_ROCK_SMASH, MOVE_WATERFALL, MOVE_DIVE, INVALID_U16
};
static const struct SpeciesItem sAlteringCaveWildMonHeldItems[] =
@@ -2485,8 +2485,8 @@ static const struct OamData sOamData_8329F20 =
static const struct SpriteTemplate gUnknown_08329F28 =
{
- .tileTag = 0xFFFF,
- .paletteTag = 0xFFFF,
+ .tileTag = INVALID_U16,
+ .paletteTag = INVALID_U16,
.oam = &sOamData_8329F20,
.anims = gDummySpriteAnimTable,
.images = NULL,
@@ -3286,7 +3286,7 @@ u16 GiveMoveToBoxMon(struct BoxPokemon *boxMon, u16 move)
if (existingMove == move)
return -2;
}
- return -1;
+ return INVALID_U16;
}
u16 GiveMoveToBattleMon(struct BattlePokemon *mon, u16 move)
@@ -3303,7 +3303,7 @@ u16 GiveMoveToBattleMon(struct BattlePokemon *mon, u16 move)
}
}
- return -1;
+ return INVALID_U16;
}
void SetMonMoveSlot(struct Pokemon *mon, u16 move, u8 slot)
@@ -3341,7 +3341,7 @@ void GiveBoxMonInitialMoveset(struct BoxPokemon *boxMon)
move = (gLevelUpLearnsets[species][i] & 0x1FF);
- if (GiveMoveToBoxMon(boxMon, move) == 0xFFFF)
+ if (GiveMoveToBoxMon(boxMon, move) == INVALID_U16)
DeleteFirstMoveAndGiveMoveToBoxMon(boxMon, move);
}
}
@@ -6495,7 +6495,7 @@ u8 GetMoveRelearnerMoves(struct Pokemon *mon, u16 *moves)
{
u16 moveLevel;
- if (gLevelUpLearnsets[species][i] == 0xFFFF)
+ if (gLevelUpLearnsets[species][i] == INVALID_U16)
break;
moveLevel = gLevelUpLearnsets[species][i] & 0xFE00;
@@ -6524,7 +6524,7 @@ u8 GetLevelUpMovesBySpecies(u16 species, u16 *moves)
u8 numMoves = 0;
int i;
- for (i = 0; i < 20 && gLevelUpLearnsets[species][i] != 0xFFFF; i++)
+ for (i = 0; i < 20 && gLevelUpLearnsets[species][i] != INVALID_U16; i++)
moves[numMoves++] = gLevelUpLearnsets[species][i] & 0x1FF;
return numMoves;
@@ -6549,7 +6549,7 @@ u8 GetNumberOfRelearnableMoves(struct Pokemon *mon)
{
u16 moveLevel;
- if (gLevelUpLearnsets[species][i] == 0xFFFF)
+ if (gLevelUpLearnsets[species][i] == INVALID_U16)
break;
moveLevel = gLevelUpLearnsets[species][i] & 0xFE00;
@@ -6584,7 +6584,7 @@ u16 SpeciesToPokedexNum(u16 species)
species = SpeciesToHoennPokedexNum(species);
if (species <= 202)
return species;
- return 0xFFFF;
+ return INVALID_U16;
}
}
@@ -6747,7 +6747,7 @@ const struct CompressedSpritePalette *GetMonSpritePalStructFromOtIdPersonality(u
bool32 IsHMMove2(u16 move)
{
int i = 0;
- while (sHMMoves[i] != 0xFFFF)
+ while (sHMMoves[i] != INVALID_U16)
{
if (sHMMoves[i++] == move)
return TRUE;
diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c
index 989bce37d..c9a4f5c91 100644
--- a/src/pokemon_animation.c
+++ b/src/pokemon_animation.c
@@ -588,7 +588,7 @@ static const u8 sUnknown_0860AA64[][2] =
{0, 2},
{1, 2},
{0, 2},
- {0, 0xFF}
+ {0, INVALID_U8}
};
static const u8 sUnknown_0860AA80[][2] =
@@ -1666,7 +1666,7 @@ static void sub_818031C(struct Sprite *sprite)
else
amplitude = 0;
- if (var5 == 0xFF)
+ if (var5 == INVALID_U8)
{
sprite->callback = SpriteCB_SetDummyOnAnimEnd;
sprite->pos2.y = 0;
@@ -2570,7 +2570,7 @@ static void pokemonanimfunc_2C(struct Sprite *sprite)
sprite->data[4] = 0;
}
- if (sUnknown_0860AA64[sprite->data[6]][1] == 0xFF)
+ if (sUnknown_0860AA64[sprite->data[6]][1] == INVALID_U8)
{
sprite->callback = SpriteCB_SetDummyOnAnimEnd;
}
@@ -4157,17 +4157,17 @@ static void sub_8183574(struct Sprite *sprite)
u8 var9 = sprite->data[6];
u8 var5 = sUnknown_0860AA80[sprite->data[5]][0];
u8 var2 = var5;
- if (var5 != 0xFF)
+ if (var5 != INVALID_U8)
var5 = sprite->data[7];
else
- var5 = 0xFF; // needed to match
+ var5 = INVALID_U8; // needed to match
var6 = sUnknown_0860AA80[sprite->data[5]][1];
var7 = 0;
if (var2 != 0xFE)
var7 = (var6 - var9) * var5 / var6;
- if (var5 == 0xFF)
+ if (var5 == INVALID_U8)
{
sprite->callback = SpriteCB_SetDummyOnAnimEnd;
sprite->pos2.y = 0;
@@ -5278,7 +5278,7 @@ static const struct YellowBlendStruct sUnknown_0860ADCC[] =
{0, 1},
{1, 1},
{0, 1},
- {0, 0xFF}
+ {0, INVALID_U8}
};
static const struct YellowBlendStruct sUnknown_0860AE1C[] =
@@ -5296,7 +5296,7 @@ static const struct YellowBlendStruct sUnknown_0860AE1C[] =
{0, 2},
{1, 2},
{0, 2},
- {0, 0xFF}
+ {0, INVALID_U8}
};
static const struct YellowBlendStruct sUnknown_0860AE54[] =
@@ -5310,7 +5310,7 @@ static const struct YellowBlendStruct sUnknown_0860AE54[] =
{0, 20},
{1, 1},
{0, 1},
- {0, 0xFF}
+ {0, INVALID_U8}
};
static const struct YellowBlendStruct *const sUnknown_0860AE7C[] =
@@ -5324,7 +5324,7 @@ static void BackAnimBlendYellow(struct Sprite *sprite)
{
const struct YellowBlendStruct *array = sUnknown_0860AE7C[sprite->data[3]];
sub_8184770(sprite);
- if (array[sprite->data[6]].field_1 == 0xFF)
+ if (array[sprite->data[6]].field_1 == INVALID_U8)
{
sprite->pos2.x = 0;
sprite->callback = SpriteCB_SetDummyOnAnimEnd;
diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c
index 994cc520e..5926f9513 100644
--- a/src/pokemon_icon.c
+++ b/src/pokemon_icon.c
@@ -1153,14 +1153,14 @@ void SafeLoadMonIconPalette(u16 species)
if (species > SPECIES_EGG)
species = 260;
palIndex = gMonIconPaletteIndices[species];
- if (IndexOfSpritePaletteTag(gMonIconPaletteTable[palIndex].tag) == 0xFF)
+ if (IndexOfSpritePaletteTag(gMonIconPaletteTable[palIndex].tag) == INVALID_U8)
LoadSpritePalette(&gMonIconPaletteTable[palIndex]);
}
void LoadMonIconPalette(u16 species)
{
u8 palIndex = gMonIconPaletteIndices[species];
- if (IndexOfSpritePaletteTag(gMonIconPaletteTable[palIndex].tag) == 0xFF)
+ if (IndexOfSpritePaletteTag(gMonIconPaletteTable[palIndex].tag) == INVALID_U8)
LoadSpritePalette(&gMonIconPaletteTable[palIndex]);
}
@@ -1287,7 +1287,7 @@ static u8 CreateMonIconSprite(struct MonIconSpriteTemplate *iconTemplate, s16 x,
struct SpriteTemplate spriteTemplate =
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = iconTemplate->paletteTag,
.oam = iconTemplate->oam,
.anims = iconTemplate->anims,
diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c
index 2d9a2f08f..f90a6b8c2 100644
--- a/src/pokemon_size_record.c
+++ b/src/pokemon_size_record.c
@@ -109,7 +109,7 @@ static void FormatMonSizeRecord(u8 *string, u32 size)
static u8 CompareMonSize(u16 species, u16 *sizeRecord)
{
- if (gSpecialVar_Result == 0xFF)
+ if (gSpecialVar_Result == INVALID_U8)
{
return 0;
}
diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c
index 465b97da2..30e16da28 100644
--- a/src/pokemon_storage_system.c
+++ b/src/pokemon_storage_system.c
@@ -134,7 +134,7 @@ s16 GetFirstFreeBoxSpot(u8 boxId)
return i;
}
- return -1; // all spots are taken
+ return INVALID_S16; // all spots are taken
}
u8 CountPartyNonEggMons(void)
@@ -426,7 +426,7 @@ s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx
return i;
}
}
- return -1;
+ return INVALID_S16;
}
void ResetPokemonStorageSystem(void)
diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c
index f152e70a4..bef127cce 100644
--- a/src/pokemon_summary_screen.c
+++ b/src/pokemon_summary_screen.c
@@ -19,7 +19,7 @@
#include "item.h"
#include "link.h"
#include "m4a.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "mon_markings.h"
@@ -1152,7 +1152,7 @@ static bool8 SummaryScreen_LoadGraphics(void)
break;
case 17:
pssData->spriteIds[0] = sub_81C45F4(&pssData->currentMon, &pssData->unk40F0);
- if (pssData->spriteIds[0] != 0xFF)
+ if (pssData->spriteIds[0] != INVALID_U8)
{
pssData->unk40F0 = 0;
gMain.state++;
@@ -1509,7 +1509,7 @@ static void sub_81C0604(u8 taskId, s8 a)
r4_2 = sub_81C08F8(a);
}
- if (r4_2 != -1)
+ if (r4_2 != INVALID_S8)
{
PlaySE(SE_SELECT);
if (pssData->summary.unk7 != 0)
@@ -1564,7 +1564,7 @@ static void sub_81C0704(u8 taskId)
break;
case 8:
pssData->spriteIds[0] = sub_81C45F4(&pssData->currentMon, &data[1]);
- if (pssData->spriteIds[0] == 0xFF)
+ if (pssData->spriteIds[0] == INVALID_U8)
return;
gSprites[pssData->spriteIds[0]].data[2] = 1;
sub_81C0E24();
@@ -1601,9 +1601,9 @@ static s8 sub_81C08F8(s8 a)
if (pssData->currPageIndex == PSS_PAGE_INFO)
{
if (a == -1 && pssData->curMonIndex == 0)
- return -1;
+ return INVALID_S8;
else if (a == 1 && pssData->curMonIndex >= pssData->maxMonIndex)
- return -1;
+ return INVALID_S8;
else
return pssData->curMonIndex + a;
}
@@ -1615,7 +1615,7 @@ static s8 sub_81C08F8(s8 a)
{
index += a;
if (index < 0 || index > pssData->maxMonIndex)
- return -1;
+ return INVALID_S8;
} while (GetMonData(&mon[index], MON_DATA_IS_EGG) != 0);
return index;
}
@@ -1643,7 +1643,7 @@ static s8 sub_81C09B4(s8 a)
r5 += a;
if (r5 < 0 || r5 >= 6)
- return -1;
+ return INVALID_S8;
b = c[r5];
if (sub_81C0A50(&mon[b]) == TRUE)
return b;
@@ -2341,7 +2341,7 @@ static void sub_81C1DA4(u16 a, s16 b)
else
{
u8 taskId = FindTaskIdByFunc(sub_81C1E20);
- if (taskId == 0xFF)
+ if (taskId == INVALID_U8)
{
taskId = CreateTask(sub_81C1E20, 8);
}
@@ -2392,7 +2392,7 @@ static void sub_81C1EFC(u16 a, s16 b, u16 move)
else
{
u8 taskId = FindTaskIdByFunc(sub_81C1F80);
- if (taskId == 0xFF)
+ if (taskId == INVALID_U8)
taskId = CreateTask(sub_81C1F80, 8);
gTasks[taskId].data[0] = b;
gTasks[taskId].data[1] = a;
@@ -2580,12 +2580,12 @@ static void sub_81C240C(u16 move)
{
effectValue = gContestEffects[gContestMoves[move].effect].appeal;
- if (effectValue != 0xFF)
+ if (effectValue != INVALID_U8)
effectValue /= 10;
for (i = 0; i < 8; i++)
{
- if (effectValue != 0xFF && i < effectValue)
+ if (effectValue != INVALID_U8 && i < effectValue)
{
tilemap[(i / 4 * 32) + (i & 3) + 0x1E6] = 0x103A;
}
@@ -2597,12 +2597,12 @@ static void sub_81C240C(u16 move)
effectValue = gContestEffects[gContestMoves[move].effect].jam;
- if (effectValue != 0xFF)
+ if (effectValue != INVALID_U8)
effectValue /= 10;
for (i = 0; i < 8; i++)
{
- if (effectValue != 0xFF && i < effectValue)
+ if (effectValue != INVALID_U8 && i < effectValue)
{
tilemap[(i / 4 * 32) + (i & 3) + 0x226] = 0x103C;
}
@@ -2634,7 +2634,7 @@ static void sub_81C2554(void)
}
for (i = 0; i < 8; i++)
{
- pssData->windowIds[i] = 0xFF;
+ pssData->windowIds[i] = INVALID_U8;
}
}
@@ -2661,7 +2661,7 @@ static void sub_81C2628(void)
struct Pokemon *mon = &pssData->currentMon;
struct PokeSummary *summary = &pssData->summary;
u16 dexNum = SpeciesToPokedexNum(summary->species);
- if (dexNum != 0xFFFF)
+ if (dexNum != INVALID_U16)
{
StringCopy(gStringVar1, &gText_UnkCtrlF908Clear01[0]);
ConvertIntToDecimalStringN(gStringVar2, dexNum, 2, 3);
@@ -2895,7 +2895,7 @@ static void sub_81C2C38(u8 a)
static u8 AddWindowFromTemplateList(const struct WindowTemplate *template, u8 templateId)
{
u8 *windowIdPtr = &(pssData->windowIds[templateId]);
- if (*windowIdPtr == 0xFF)
+ if (*windowIdPtr == INVALID_U8)
{
*windowIdPtr = AddWindow(&template[templateId]);
FillWindowPixelBuffer(*windowIdPtr, 0);
@@ -2906,11 +2906,11 @@ static u8 AddWindowFromTemplateList(const struct WindowTemplate *template, u8 te
static void SummaryScreen_RemoveWindowByIndex(u8 windowIndex)
{
u8 *windowIdPtr = &(pssData->windowIds[windowIndex]);
- if (*windowIdPtr != 0xFF)
+ if (*windowIdPtr != INVALID_U8)
{
ClearWindowTilemap(*windowIdPtr);
RemoveWindow(*windowIdPtr);
- *windowIdPtr = 0xFF;
+ *windowIdPtr = INVALID_U8;
}
}
@@ -2919,7 +2919,7 @@ static void sub_81C2D9C(u8 pageIndex)
u16 i;
for (i = 0; i < 8; i++)
{
- if (pssData->windowIds[i] != 0xFF)
+ if (pssData->windowIds[i] != INVALID_U8)
FillWindowPixelBuffer(pssData->windowIds[i], 0);
}
gUnknown_0861CE54[pageIndex]();
@@ -3651,16 +3651,16 @@ static void sub_81C4190(void)
for (i = 0; i < 28; i++)
{
- pssData->spriteIds[i] = 0xFF;
+ pssData->spriteIds[i] = INVALID_U8;
}
}
static void DestroySpriteInArray(u8 spriteArrayId)
{
- if (pssData->spriteIds[spriteArrayId] != 0xFF)
+ if (pssData->spriteIds[spriteArrayId] != INVALID_U8)
{
DestroySprite(&gSprites[pssData->spriteIds[spriteArrayId]]);
- pssData->spriteIds[spriteArrayId] = 0xFF;
+ pssData->spriteIds[spriteArrayId] = INVALID_U8;
}
}
@@ -3675,7 +3675,7 @@ static void sub_81C424C(void)
for (i = 3; i < 28; i++)
{
- if (pssData->spriteIds[i] != 0xFF)
+ if (pssData->spriteIds[i] != INVALID_U8)
sub_81C4204(i, TRUE);
}
}
@@ -3704,7 +3704,7 @@ static void sub_81C42C8(void)
for (i = 3; i < 8; i++)
{
- if (pssData->spriteIds[i] == 0xFF)
+ if (pssData->spriteIds[i] == INVALID_U8)
pssData->spriteIds[i] = CreateSprite(&sSpriteTemplate_MoveTypes, 0, 0, 2);
sub_81C4204(i, TRUE);
@@ -3851,13 +3851,13 @@ static u8 sub_81C45F4(struct Pokemon *mon, s16 *a1)
}
}
(*a1)++;
- return -1;
+ return INVALID_S8;
case 1:
pal = GetMonSpritePalStructFromOtIdPersonality(summary->species2, summary->OTID, summary->pid);
LoadCompressedObjectPalette(pal);
SetMultiuseSpriteTemplateToPokemon(pal->tag, 1);
(*a1)++;
- return -1;
+ return INVALID_S8;
}
}
@@ -3921,10 +3921,10 @@ void SummaryScreen_SetUnknownTaskId(u8 a0)
void SummaryScreen_DestroyUnknownTask(void)
{
- if (sUnknownTaskId != 0xFF)
+ if (sUnknownTaskId != INVALID_U8)
{
DestroyTask(sUnknownTaskId);
- sUnknownTaskId = 0xFF;
+ sUnknownTaskId = INVALID_U8;
}
}
@@ -3994,7 +3994,7 @@ static void CreateSetStatusSprite(void)
u8 *spriteId = &pssData->spriteIds[2];
u8 anim;
- if (*spriteId == 0xFF)
+ if (*spriteId == INVALID_U8)
{
*spriteId = CreateSprite(&sSpriteTemplate_StatusCondition, 64, 152, 0);
}
diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c
index 4783f73c0..d0f65c4b0 100644
--- a/src/rayquaza_scene.c
+++ b/src/rayquaza_scene.c
@@ -5,7 +5,7 @@
#include "graphics.h"
#include "bg.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "palette.h"
#include "scanline_effect.h"
#include "menu.h"
diff --git a/src/record_mixing.c b/src/record_mixing.c
index df4a1a720..4a4941294 100644
--- a/src/record_mixing.c
+++ b/src/record_mixing.c
@@ -1,5 +1,5 @@
#include "global.h"
-#include "malloc.h"
+#include "alloc.h"
#include "random.h"
#include "constants/items.h"
#include "text.h"
@@ -1763,7 +1763,7 @@ static void sub_80E8880(struct RankingHall1P *arg0, struct RankingHall1P *arg1)
for (i = 0; i < 3; i++)
{
s32 highestWinStreak = 0;
- s32 highestId = -1;
+ s32 highestId = INVALID_S32;
for (j = 0; j < 6; j++)
{
if (arg1[j].winStreak > highestWinStreak)
@@ -1788,7 +1788,7 @@ static void sub_80E88CC(struct RankingHall2P *arg0, struct RankingHall2P *arg1)
for (i = 0; i < 3; i++)
{
s32 highestWinStreak = 0;
- s32 highestId = -1;
+ s32 highestId = INVALID_S32;
for (j = 0; j < 6; j++)
{
if (arg1[j].winStreak > highestWinStreak)
diff --git a/src/recorded_battle.c b/src/recorded_battle.c
index 5d79cb789..3fc08ff3f 100644
--- a/src/recorded_battle.c
+++ b/src/recorded_battle.c
@@ -9,7 +9,7 @@
#include "string_util.h"
#include "palette.h"
#include "save.h"
-#include "malloc.h"
+#include "alloc.h"
#include "util.h"
#include "task.h"
#include "text.h"
@@ -221,7 +221,7 @@ u8 RecordedBattle_GetBattlerAction(u8 battlerId)
ResetPaletteFadeControl();
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
SetMainCallback2(CB2_QuitRecordedBattle);
- return -1;
+ return INVALID_U8;
}
else
{
diff --git a/src/region_map.c b/src/region_map.c
index 262a7d020..d7b53d631 100644
--- a/src/region_map.c
+++ b/src/region_map.c
@@ -2,7 +2,7 @@
#include "main.h"
#include "text.h"
#include "menu.h"
-#include "malloc.h"
+#include "alloc.h"
#include "gpu_regs.h"
#include "palette.h"
#include "party_menu.h"
diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c
index 34444cbf4..da94c5c46 100644
--- a/src/reset_rtc_screen.c
+++ b/src/reset_rtc_screen.c
@@ -160,7 +160,7 @@ static const union AnimCmd *const sSpriteAnimTable_85104E4[] =
static const struct SpriteTemplate sSpriteTemplate_85104F0 =
{
- .tileTag = 0xFFFF,
+ .tileTag = INVALID_U16,
.paletteTag = 0x1000,
.oam = &sOamData_08510464,
.anims = sSpriteAnimTable_85104E4,
diff --git a/src/reset_save_heap.c b/src/reset_save_heap.c
index 1d90448b2..d7c93a75c 100644
--- a/src/reset_save_heap.c
+++ b/src/reset_save_heap.c
@@ -6,7 +6,7 @@
#include "save.h"
#include "new_game.h"
#include "overworld.h"
-#include "malloc.h"
+#include "alloc.h"
void sub_81700F8(void)
{
diff --git a/src/rock.c b/src/rock.c
index 3b8e505d8..b50ecc155 100644
--- a/src/rock.c
+++ b/src/rock.c
@@ -738,7 +738,7 @@ void sub_811131C(struct Sprite *sprite)
if (TranslateAnimArc(sprite))
{
u8 taskId = FindTaskIdByFunc(sub_81110A4);
- if (taskId != 0xFF)
+ if (taskId != INVALID_U8)
gTasks[taskId].data[11]--;
DestroySprite(sprite);
diff --git a/src/rom_8011DC0.c b/src/rom_8011DC0.c
index a197598de..ef82cbf0a 100644
--- a/src/rom_8011DC0.c
+++ b/src/rom_8011DC0.c
@@ -7,7 +7,7 @@
#include "link.h"
#include "link_rfu.h"
#include "librfu.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "list_menu.h"
#include "menu_helpers.h"
@@ -961,7 +961,7 @@ u8 sub_80132D4(struct UnkStruct_Main0 *arg0)
if (var == 1)
{
id = sub_80176E4(&data->field_0->arr[i], data->field_4->arr);
- if (id != 0xFF)
+ if (id != INVALID_U8)
{
data->field_0->arr[i].unk = data->field_4->arr[id].unk0;
data->field_0->arr[i].field_18 = var;
@@ -1382,7 +1382,7 @@ void sub_8013C7C(u8 taskId)
case 3:
if (sub_8013E44() == 1)
PlaySE(SE_PC_LOGIN);
- if (gTasks[taskId].data[15] == 0xFF)
+ if (gTasks[taskId].data[15] == INVALID_U8)
data->state = 10;
break;
case 10:
@@ -1401,14 +1401,14 @@ void sub_8013C7C(u8 taskId)
bool32 sub_8013D88(u32 arg0, u32 id)
{
- if (id == 0xFF)
+ if (id == INVALID_U8)
return TRUE;
if (id <= ARRAY_COUNT(gUnknown_082F04D8)) // UB: <= may access data outside the array
{
const u8 *bytes = gUnknown_082F04D8[id];
- while ((*(bytes) != 0xFF))
+ while ((*(bytes) != INVALID_U8))
{
if ((*bytes) == arg0)
return TRUE;
@@ -1454,7 +1454,7 @@ u8 sub_8013E44(void)
if (data->field_0->arr[i].field_1A_0 != 0)
{
id = sub_80176E4(&data->field_0->arr[i], data->field_4->arr);
- if (id != 0xFF)
+ if (id != INVALID_U8)
{
if (data->field_0->arr[i].field_1A_0 == 1)
{
@@ -1500,7 +1500,7 @@ u8 sub_8013E44(void)
for (id = 0; id < 4; id++)
{
- if (sub_8017734(data->field_0->arr, &data->field_4->arr[id].unk0, 16) != 0xFF)
+ if (sub_8017734(data->field_0->arr, &data->field_4->arr[id].unk0, 16) != INVALID_U8)
ret = 1;
}
@@ -2178,7 +2178,7 @@ void sub_8014F48(u8 taskId)
break;
case 0:
id = ListMenuHandleInputGetItemId(data->listTaskId);
- if (gMain.newKeys & A_BUTTON && id != -1)
+ if (gMain.newKeys & A_BUTTON && id != INVALID_S32)
{
// this unused variable along with the assignment is needed to match
u32 unusedVar;
@@ -2732,7 +2732,7 @@ void sub_80156E0(u8 taskId)
break;
case 6:
var5 = sub_8017178(&data->textState, &data->field_1B, &data->field_1C, &gUnknown_082F021C, &gUnknown_082F0244);
- if (var5 != -1)
+ if (var5 != INVALID_S32)
{
if (gReceivedRemoteLinkPlayers == 0)
{
diff --git a/src/rom_8034C54.c b/src/rom_8034C54.c
index be6d6614a..47d9eaf70 100644
--- a/src/rom_8034C54.c
+++ b/src/rom_8034C54.c
@@ -1,6 +1,6 @@
#include "global.h"
#include "rom_8034C54.h"
-#include "malloc.h"
+#include "alloc.h"
#include "decompress.h"
#include "main.h"
@@ -255,7 +255,7 @@ static void sub_8035164(struct UnkStruct2 *arg0, s32 arg1, bool32 arg2)
u32 r5 = arg0->field_14;
gUnknown_03000DD4 = arg0->firstOamId;
gUnknown_03000DD8 = 0;
- gUnknown_03000DDC = -1;
+ gUnknown_03000DDC = INVALID_S32;
while (r5 != 0)
{
@@ -263,12 +263,12 @@ static void sub_8035164(struct UnkStruct2 *arg0, s32 arg1, bool32 arg2)
arg1 -= (r4 * r5);
r5 /= 10;
- if (r4 != 0 || gUnknown_03000DDC != -1 || r5 == 0)
+ if (r4 != 0 || gUnknown_03000DDC != INVALID_S32 || r5 == 0)
{
gMain.oamBuffer[gUnknown_03000DD4].tileNum = (r4 * arg0->field_9) + arg0->tileStart;
gMain.oamBuffer[gUnknown_03000DD4].affineMode = 0;
- if (gUnknown_03000DDC == -1)
+ if (gUnknown_03000DDC == INVALID_S32)
gUnknown_03000DDC = gUnknown_03000DD8;
}
else
diff --git a/src/rom_81520A8.c b/src/rom_81520A8.c
index f6d14d49c..f06823594 100644
--- a/src/rom_81520A8.c
+++ b/src/rom_81520A8.c
@@ -1,6 +1,6 @@
#include "global.h"
#include "rom_81520A8.h"
-#include "malloc.h"
+#include "alloc.h"
#include "main.h"
#include "rom_8034C54.h"
diff --git a/src/rotating_gate.c b/src/rotating_gate.c
index f617321af..395ced06e 100644
--- a/src/rotating_gate.c
+++ b/src/rotating_gate.c
@@ -461,7 +461,7 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_RotatingGate[] =
static const struct SpriteTemplate sSpriteTemplate_RotatingGateLarge =
{
.tileTag = ROTATING_GATE_TILE_TAG,
- .paletteTag = 0xFFFF,
+ .paletteTag = INVALID_U16,
.oam = &sOamData_RotatingGateLarge,
.anims = sSpriteAnimTable_RotatingGateLarge,
.images = NULL,
@@ -472,7 +472,7 @@ static const struct SpriteTemplate sSpriteTemplate_RotatingGateLarge =
static const struct SpriteTemplate sSpriteTemplate_RotatingGateRegular =
{
.tileTag = ROTATING_GATE_TILE_TAG,
- .paletteTag = 0xFFFF,
+ .paletteTag = INVALID_U16,
.oam = &sOamData_RotatingGateRegular,
.anims = sSpriteAnimTable_RotatingGateRegular,
.images = NULL,
diff --git a/src/rtc.c b/src/rtc.c
index 3f413d0e3..7553d7629 100644
--- a/src/rtc.c
+++ b/src/rtc.c
@@ -46,12 +46,12 @@ void RtcRestoreInterrupts(void)
u32 ConvertBcdToBinary(u8 bcd)
{
if (bcd > 0x9F)
- return 0xFF;
+ return INVALID_U8;
if ((bcd & 0xF) <= 9)
return (10 * ((bcd >> 4) & 0xF)) + (bcd & 0xF);
else
- return 0xFF;
+ return INVALID_U8;
}
bool8 IsLeapYear(u32 year)
@@ -166,17 +166,17 @@ u16 RtcCheckInfo(struct SiiRtcInfo *rtc)
year = ConvertBcdToBinary(rtc->year);
- if (year == 0xFF)
+ if (year == INVALID_U8)
errorFlags |= RTC_ERR_INVALID_YEAR;
month = ConvertBcdToBinary(rtc->month);
- if (month == 0xFF || month == 0 || month > 12)
+ if (month == INVALID_U8 || month == 0 || month > 12)
errorFlags |= RTC_ERR_INVALID_MONTH;
value = ConvertBcdToBinary(rtc->day);
- if (value == 0xFF)
+ if (value == INVALID_U8)
errorFlags |= RTC_ERR_INVALID_DAY;
if (month == MONTH_FEB)
diff --git a/src/safari_zone.c b/src/safari_zone.c
index accf94981..69914b565 100644
--- a/src/safari_zone.c
+++ b/src/safari_zone.c
@@ -185,7 +185,7 @@ struct Pokeblock *SafariZoneGetPokeblockInFront(void)
{
GetPokeblockFeederInFront();
- if (gSpecialVar_Result == 0xFFFF)
+ if (gSpecialVar_Result == INVALID_U16)
return NULL;
else
return &sPokeblockFeeders[gSpecialVar_Result].pokeblock;
@@ -195,7 +195,7 @@ struct Pokeblock *SafariZoneGetActivePokeblock(void)
{
GetPokeblockFeederWithinRange();
- if (gSpecialVar_Result == 0xFFFF)
+ if (gSpecialVar_Result == INVALID_U16)
return NULL;
else
return &sPokeblockFeeders[gSpecialVar_Result].pokeblock;
@@ -245,7 +245,7 @@ bool8 GetInFrontFeederPokeblockAndSteps(void)
{
GetPokeblockFeederInFront();
- if (gSpecialVar_Result == 0xFFFF)
+ if (gSpecialVar_Result == INVALID_U16)
{
return FALSE;
}
diff --git a/src/save.c b/src/save.c
index 4ae516fc9..de103864b 100644
--- a/src/save.c
+++ b/src/save.c
@@ -160,7 +160,7 @@ static u8 save_write_to_flash(u16 a1, const struct SaveSectionLocation *location
if (gDamagedSaveSectors != 0) // skip the damaged sector.
{
- retVal = 0xFF;
+ retVal = INVALID_U8;
gLastWrittenSector = gLastKnownGoodSector;
gSaveCounter = gLastSaveCounter;
}
@@ -220,7 +220,7 @@ static u8 TryWriteSector(u8 sector, u8 *data)
if (ProgramFlashSectorAndVerify(sector, data) != 0) // is damaged?
{
SetDamagedSectorBits(ENABLE, sector); // set damaged sector bits.
- return 0xFF;
+ return INVALID_U8;
}
else
{
@@ -263,14 +263,14 @@ static u8 sub_81529D4(u16 a1, const struct SaveSectionLocation *location)
gUnknown_03006208++;
if (gDamagedSaveSectors)
{
- retVal = 0xFF;
+ retVal = INVALID_U8;
gLastWrittenSector = gLastKnownGoodSector;
gSaveCounter = gLastSaveCounter;
}
}
else
{
- retVal = 0xFF;
+ retVal = INVALID_U8;
}
return retVal;
@@ -284,7 +284,7 @@ static u8 sub_8152A34(u16 a1, const struct SaveSectionLocation *location)
if (gDamagedSaveSectors)
{
- retVal = 0xFF;
+ retVal = INVALID_U8;
gLastWrittenSector = gLastKnownGoodSector;
gSaveCounter = gLastSaveCounter;
}
@@ -329,15 +329,15 @@ static u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location)
{
if (ProgramFlashByte(sector, i, ((u8 *)gFastSaveSection)[i]))
{
- status = 0xFF;
+ status = INVALID_U8;
break;
}
}
- if (status == 0xFF)
+ if (status == INVALID_U8)
{
SetDamagedSectorBits(ENABLE, sector);
- return 0xFF;
+ return INVALID_U8;
}
else
{
@@ -347,15 +347,15 @@ static u8 ClearSaveData_2(u16 a1, const struct SaveSectionLocation *location)
{
if (ProgramFlashByte(sector, 0xFF9 + i, ((u8 *)gFastSaveSection)[0xFF9 + i]))
{
- status = 0xFF;
+ status = INVALID_U8;
break;
}
}
- if (status == 0xFF)
+ if (status == INVALID_U8)
{
SetDamagedSectorBits(ENABLE, sector);
- return 0xFF;
+ return INVALID_U8;
}
else
{
@@ -379,7 +379,7 @@ static u8 sav12_xor_get(u16 a1, const struct SaveSectionLocation *location)
SetDamagedSectorBits(ENABLE, sector);
gLastWrittenSector = gLastKnownGoodSector;
gSaveCounter = gLastSaveCounter;
- return 0xFF;
+ return INVALID_U8;
}
else
{
@@ -402,7 +402,7 @@ static u8 sub_8152CAC(u16 a1, const struct SaveSectionLocation *location)
SetDamagedSectorBits(ENABLE, sector);
gLastWrittenSector = gLastKnownGoodSector;
gSaveCounter = gLastSaveCounter;
- return 0xFF;
+ return INVALID_U8;
}
else
{
@@ -425,7 +425,7 @@ static u8 sub_8152D44(u16 a1, const struct SaveSectionLocation *location)
SetDamagedSectorBits(ENABLE, sector);
gLastWrittenSector = gLastKnownGoodSector;
gSaveCounter = gLastSaveCounter;
- return 0xFF;
+ return INVALID_U8;
}
else
{
@@ -440,7 +440,7 @@ static u8 sub_8152DD0(u16 a1, const struct SaveSectionLocation *location)
gFastSaveSection = &gSaveDataBuffer;
if (a1 != 0xFFFF)
{
- retVal = 0xFF;
+ retVal = INVALID_U8;
}
else
{
@@ -715,8 +715,8 @@ u8 TrySavingData(u8 saveType)
{
if (gFlashMemoryPresent != TRUE)
{
- gUnknown_03006294 = 0xFF;
- return 0xFF;
+ gUnknown_03006294 = INVALID_U8;
+ return INVALID_U8;
}
HandleSavingData(saveType);
@@ -728,8 +728,8 @@ u8 TrySavingData(u8 saveType)
else
{
DoSaveFailedScreen(saveType);
- gUnknown_03006294 = 0xFF;
- return 0xFF;
+ gUnknown_03006294 = INVALID_U8;
+ return INVALID_U8;
}
}
@@ -748,7 +748,7 @@ bool8 sub_81533AC(void) // trade.s save
u8 retVal = sub_81529D4(SECTOR_SAVE_SLOT_LENGTH, gRamSaveSectionLocations);
if (gDamagedSaveSectors)
DoSaveFailedScreen(0);
- if (retVal == 0xFF)
+ if (retVal == INVALID_U8)
return TRUE;
else
return FALSE;
@@ -808,7 +808,7 @@ u8 Save_LoadGameData(u8 a1)
if (gFlashMemoryPresent != TRUE)
{
gSaveFileStatus = 4;
- return 0xFF;
+ return INVALID_U8;
}
UpdateSaveAddresses();
@@ -861,10 +861,10 @@ u32 TryCopySpecialSaveSection(u8 sector, u8* dst)
u8* savData;
if (sector != SECTOR_ID_TRAINER_HILL && sector != SECTOR_ID_RECORDED_BATTLE)
- return 0xFF;
+ return INVALID_U8;
ReadFlash(sector, 0, (u8 *)&gSaveDataBuffer, sizeof(struct SaveSection));
if (*(u32*)(&gSaveDataBuffer.data[0]) != 0xB39D)
- return 0xFF;
+ return INVALID_U8;
// copies whole save section except u32 counter
i = 0;
size = 0xFFB;
@@ -882,7 +882,7 @@ u32 sub_8153634(u8 sector, u8* src)
void* savDataBuffer;
if (sector != 30 && sector != 31)
- return 0xFF;
+ return INVALID_U8;
savDataBuffer = &gSaveDataBuffer;
*(u32*)(savDataBuffer) = 0xB39D;
@@ -894,7 +894,7 @@ u32 sub_8153634(u8 sector, u8* src)
for (; i <= size; i++)
savData[i] = src[i];
if (ProgramFlashSectorAndVerify(sector, savDataBuffer) != 0)
- return 0xFF;
+ return INVALID_U8;
return 1;
}
diff --git a/src/save_location.c b/src/save_location.c
index d49afa736..f7d3aa60b 100644
--- a/src/save_location.c
+++ b/src/save_location.c
@@ -12,7 +12,7 @@ static bool32 IsCurMapInLocationList(const u16 *list)
s32 i;
u16 locSum = (gSaveBlock1Ptr->location.mapGroup << 8) + (gSaveBlock1Ptr->location.mapNum);
- for (i = 0; list[i] != 0xFFFF; i++)
+ for (i = 0; list[i] != INVALID_U16; i++)
{
if (list[i] == locSum)
return TRUE;
@@ -61,7 +61,7 @@ static const u16 sSaveLocationPokeCenterList[] =
MAP_TRADE_CENTER,
MAP_RECORD_CORNER,
MAP_DOUBLE_BATTLE_COLOSSEUM,
- 0xFFFF,
+ INVALID_U16,
};
static bool32 IsCurMapPokeCenter(void)
@@ -72,7 +72,7 @@ static bool32 IsCurMapPokeCenter(void)
static const u16 sSaveLocationReloadLocList[] = // There's only 1 location, and it's presumed its for the save reload feature for battle tower.
{
MAP_BATTLE_FRONTIER_BATTLE_TOWER_LOBBY,
- 0xFFFF,
+ INVALID_U16,
};
static bool32 IsCurMapReloadLocation(void)
@@ -83,7 +83,7 @@ static bool32 IsCurMapReloadLocation(void)
// Nulled out list. Unknown what this would have been.
static const u16 sUnknown_0861440E[] =
{
- 0xFFFF,
+ INVALID_U16,
};
static bool32 sub_81AFCEC(void)
diff --git a/src/scanline_effect.c b/src/scanline_effect.c
index a9ae9427b..2e264ee29 100644
--- a/src/scanline_effect.c
+++ b/src/scanline_effect.c
@@ -22,10 +22,10 @@ void ScanlineEffect_Stop(void)
{
gScanlineEffect.state = 0;
DmaStop(0);
- if (gScanlineEffect.waveTaskId != 0xFF)
+ if (gScanlineEffect.waveTaskId != INVALID_U8)
{
DestroyTask(gScanlineEffect.waveTaskId);
- gScanlineEffect.waveTaskId = 0xFF;
+ gScanlineEffect.waveTaskId = INVALID_U8;
}
}
@@ -40,7 +40,7 @@ void ScanlineEffect_Clear(void)
gScanlineEffect.state = 0;
gScanlineEffect.unused16 = 0;
gScanlineEffect.unused17 = 0;
- gScanlineEffect.waveTaskId = 0xFF;
+ gScanlineEffect.waveTaskId = INVALID_U8;
}
void ScanlineEffect_SetParams(struct ScanlineEffectParams params)
@@ -132,7 +132,7 @@ static void TaskFunc_UpdateWavePerFrame(u8 taskId)
if (sShouldStopWaveTask)
{
DestroyTask(taskId);
- gScanlineEffect.waveTaskId = 0xFF;
+ gScanlineEffect.waveTaskId = INVALID_U8;
}
else
{
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 310387337..4217f7237 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -790,7 +790,7 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx)
u16 y;
PlayerGetDestCoords(&x, &y);
- if (mapGroup == 0xFF && mapNum == 0xFF)
+ if (mapGroup == INVALID_U8 && mapNum == INVALID_U8)
SetFixedHoleWarpAsDestination(x - 7, y - 7);
else
Overworld_SetWarpDestination(mapGroup, mapNum, -1, x - 7, y - 7);
@@ -1491,7 +1491,7 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx)
if (width > 0x1C)
width = 0x1C;
- for (i = 0, height = 4; gStringVar4[i] != 0xFF;)
+ for (i = 0, height = 4; gStringVar4[i] != INVALID_U8;)
{
if (gStringVar4[i++] == 0xFE)
height += 3;
diff --git a/src/script.c b/src/script.c
index c61ae7183..4e133a188 100644
--- a/src/script.c
+++ b/src/script.c
@@ -391,11 +391,11 @@ bool32 sub_80991F8(void)
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
if (scriptData->magic != RAM_SCRIPT_MAGIC)
return FALSE;
- if (scriptData->mapGroup != 0xFF)
+ if (scriptData->mapGroup != INVALID_U8)
return FALSE;
- if (scriptData->mapNum != 0xFF)
+ if (scriptData->mapNum != INVALID_U8)
return FALSE;
- if (scriptData->objectId != 0xFF)
+ if (scriptData->objectId != INVALID_U8)
return FALSE;
if (CalculateRamScriptChecksum() != gSaveBlock1Ptr->ramScript.checksum)
return FALSE;
@@ -409,11 +409,11 @@ u8 *sub_8099244(void)
return NULL;
if (scriptData->magic != RAM_SCRIPT_MAGIC)
return NULL;
- if (scriptData->mapGroup != 0xFF)
+ if (scriptData->mapGroup != INVALID_U8)
return NULL;
- if (scriptData->mapNum != 0xFF)
+ if (scriptData->mapNum != INVALID_U8)
return NULL;
- if (scriptData->objectId != 0xFF)
+ if (scriptData->objectId != INVALID_U8)
return NULL;
if (CalculateRamScriptChecksum() != gSaveBlock1Ptr->ramScript.checksum)
{
diff --git a/src/script_menu.c b/src/script_menu.c
index 2aa546288..fcb2d17a2 100644
--- a/src/script_menu.c
+++ b/src/script_menu.c
@@ -1040,7 +1040,7 @@ bool8 ScriptMenu_Multichoice(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPress)
}
else
{
- gSpecialVar_Result = 0xFF;
+ gSpecialVar_Result = INVALID_U8;
DrawMultichoiceMenu(left, top, multichoiceId, ignoreBPress, 0);
return TRUE;
}
@@ -1054,7 +1054,7 @@ bool8 ScriptMenu_MultichoiceWithDefault(u8 left, u8 top, u8 multichoiceId, bool8
}
else
{
- gSpecialVar_Result = 0xFF;
+ gSpecialVar_Result = INVALID_U8;
DrawMultichoiceMenu(left, top, multichoiceId, ignoreBPress, defaultChoice);
return TRUE;
}
@@ -1201,7 +1201,7 @@ bool8 ScriptMenu_YesNo(u8 left, u8 top)
}
else
{
- gSpecialVar_Result = 0xFF;
+ gSpecialVar_Result = INVALID_U8;
DisplayYesNoMenu();
taskId = CreateTask(Task_HandleYesNoInput, 0x50);
return TRUE;
@@ -1211,7 +1211,7 @@ bool8 ScriptMenu_YesNo(u8 left, u8 top)
// unused
bool8 IsScriptActive(void)
{
- if (gSpecialVar_Result == 0xFF)
+ if (gSpecialVar_Result == INVALID_U8)
return FALSE;
else
return TRUE;
@@ -1261,7 +1261,7 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPr
int i;
u8 newWidth;
- gSpecialVar_Result = 0xFF;
+ gSpecialVar_Result = INVALID_U8;
width = 0;
for (i = 0; i < gMultichoiceLists[multichoiceId].count; i++)
@@ -1320,7 +1320,7 @@ bool8 ScrSpecial_CreatePCMenu(void)
}
else
{
- gSpecialVar_Result = 0xFF;
+ gSpecialVar_Result = INVALID_U8;
CreatePCMenu();
return TRUE;
}
@@ -1389,7 +1389,7 @@ bool8 sub_80E2548(void)
}
else
{
- gSpecialVar_Result = 0xFF;
+ gSpecialVar_Result = INVALID_U8;
sub_80E2578();
return TRUE;
}
@@ -1407,7 +1407,7 @@ static void sub_80E2578(void)
for (i = 0; i < ARRAY_COUNT(gUnknown_03001124); i++)
{
- gUnknown_03001124[i] |= 0xFF;
+ gUnknown_03001124[i] |= INVALID_U8;
}
GetFontAttribute(1, FONTATTR_MAX_LETTER_WIDTH);
@@ -1508,7 +1508,7 @@ static void sub_80E2578(void)
for (j = 0; j < ARRAY_COUNT(gUnknown_0858BB80); j++)
{
u8 test = gUnknown_03001124[j];
- if (test != 0xFF)
+ if (test != INVALID_U8)
{
pixelWidth = display_text_and_get_width(gUnknown_0858BB80[test], pixelWidth);
}
@@ -1520,7 +1520,7 @@ static void sub_80E2578(void)
for (temp = 0, i = 0; i < ARRAY_COUNT(gUnknown_0858BB80); i++)
{
- if (gUnknown_03001124[i] != 0xFF)
+ if (gUnknown_03001124[i] != INVALID_U8)
{
AddTextPrinterParameterized(windowId, 1, gUnknown_0858BB80[gUnknown_03001124[i]], 8, temp * 16 + 1, TEXT_SPEED_FF, NULL);
temp++;
@@ -1575,7 +1575,7 @@ bool8 ScriptMenu_ShowPokemonPic(u16 species, u8 x, u8 y)
u8 taskId;
u8 spriteId;
- if (FindTaskIdByFunc(Task_PokemonPicWindow) != 0xFF)
+ if (FindTaskIdByFunc(Task_PokemonPicWindow) != INVALID_U8)
{
return FALSE;
}
@@ -1599,7 +1599,7 @@ bool8 (*ScriptMenu_GetPicboxWaitFunc(void))(void)
{
u8 taskId = FindTaskIdByFunc(Task_PokemonPicWindow);
- if (taskId == 0xFF)
+ if (taskId == INVALID_U8)
return NULL;
gTasks[taskId].tState++;
return IsPicboxClosed;
@@ -1607,7 +1607,7 @@ bool8 (*ScriptMenu_GetPicboxWaitFunc(void))(void)
static bool8 IsPicboxClosed(void)
{
- if (FindTaskIdByFunc(Task_PokemonPicWindow) == 0xFF)
+ if (FindTaskIdByFunc(Task_PokemonPicWindow) == INVALID_U8)
return TRUE;
else
return FALSE;
@@ -1672,7 +1672,7 @@ bool16 sp106_CreateStartMenu(void)
return FALSE;
}
- gSpecialVar_Result = 0xFF;
+ gSpecialVar_Result = INVALID_U8;
CreateStartMenu();
return TRUE;
}
diff --git a/src/script_movement.c b/src/script_movement.c
index 9fee9e060..54e6f9995 100644
--- a/src/script_movement.c
+++ b/src/script_movement.c
@@ -50,7 +50,7 @@ void sub_80D338C(void)
u8 taskId;
taskId = sub_80D33F4();
- if (taskId != 0xFF)
+ if (taskId != INVALID_U8)
{
UnfreezeObjects(taskId);
DestroyTask(taskId);
@@ -65,7 +65,7 @@ static void sub_80D33AC(u8 priority)
taskId = CreateTask(sub_80D3660, priority);
for (i = 1; i < 16; i++)
- gTasks[taskId].data[i] = 0xFFFF;
+ gTasks[taskId].data[i] = INVALID_U16;
}
static u8 sub_80D33F4(void)
@@ -188,7 +188,7 @@ static void UnfreezeObjects(u8 taskId)
pEventObjId = (u8 *)&gTasks[taskId].data[1];
for (i = 0; i < 16; i++, pEventObjId++)
{
- if (*pEventObjId != 0xFF)
+ if (*pEventObjId != INVALID_U8)
UnfreezeEventObject(&gEventObjects[*pEventObjId]);
}
}
@@ -201,7 +201,7 @@ static void sub_80D3660(u8 taskId)
for (i = 0; i < 16; i++)
{
sub_80D3508(taskId, i, &var);
- if (var != 0xFF)
+ if (var != INVALID_U8)
sub_80A2490(taskId, i, var, sub_80D35CC(i));
}
}
diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c
index 7fc61f953..77c1a88e0 100755
--- a/src/script_pokemon_util_80F87D8.c
+++ b/src/script_pokemon_util_80F87D8.c
@@ -318,7 +318,7 @@ void ShowContestEntryMonPic(void)
u8 taskId;
u8 left, top;
- if (FindTaskIdByFunc(sub_80F8EE8) == 0xFF)
+ if (FindTaskIdByFunc(sub_80F8EE8) == INVALID_U8)
{
AllocateMonSpritesGfx();
left = 10;
@@ -361,7 +361,7 @@ void ShowContestEntryMonPic(void)
void sub_80F8EB8(void)
{
u8 taskId = FindTaskIdByFunc(sub_80F8EE8);
- if (taskId != 0xFF)
+ if (taskId != INVALID_U8)
{
gTasks[taskId].data[0]++;
FreeMonSpritesGfx();
diff --git a/src/secret_base.c b/src/secret_base.c
index 8436d8520..78e6bd7d0 100644
--- a/src/secret_base.c
+++ b/src/secret_base.c
@@ -3,7 +3,7 @@
#include "global.h"
#include "constants/bg_event_constants.h"
#include "constants/decorations.h"
-#include "malloc.h"
+#include "alloc.h"
#include "main.h"
#include "task.h"
#include "palette.h"
@@ -1385,7 +1385,7 @@ s16 sub_80EA990(u8 secretBaseRecordId)
return i;
}
}
- return -1;
+ return INVALID_S16;
}
u8 sub_80EA9D8(void)
@@ -1427,7 +1427,7 @@ u8 sub_80EAA64(struct SecretBaseRecord *base, u32 version, u32 language)
secretBaseRecordId = sub_80EA990(base->secretBaseId);
if (secretBaseRecordId != 0)
{
- if (secretBaseRecordId != -1)
+ if (secretBaseRecordId != INVALID_S16)
{
if (gSaveBlock1Ptr->secretBases[secretBaseRecordId].sbr_field_1_0 == 1)
{
@@ -1757,7 +1757,7 @@ void ReceiveSecretBasesData(void *records, size_t recordSize, u8 linkIdx)
gSaveBlock1Ptr->secretBases[i].sbr_field_1_6 = 0;
}
}
- if (gSaveBlock1Ptr->secretBases[0].secretBaseId != 0 && gSaveBlock1Ptr->secretBases[0].sbr_field_e != 0xFFFF)
+ if (gSaveBlock1Ptr->secretBases[0].secretBaseId != 0 && gSaveBlock1Ptr->secretBases[0].sbr_field_e != INVALID_U16)
{
gSaveBlock1Ptr->secretBases[0].sbr_field_e ++;
}
diff --git a/src/shop.c b/src/shop.c
index a0eddee01..c0359bda0 100755
--- a/src/shop.c
+++ b/src/shop.c
@@ -17,7 +17,7 @@
#include "item_menu.h"
#include "list_menu.h"
#include "main.h"
-#include "malloc.h"
+#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "money.h"
@@ -446,9 +446,9 @@ static void CB2_InitBuyMenu(void)
ResetTasks();
clear_scheduled_bg_copies_to_vram();
gShopDataPtr = AllocZeroed(sizeof(struct ShopData));
- gShopDataPtr->scrollIndicatorsTaskId = 0xFF;
- gShopDataPtr->itemSpriteIds[0] = -1;
- gShopDataPtr->itemSpriteIds[1] = -1;
+ gShopDataPtr->scrollIndicatorsTaskId = INVALID_U8;
+ gShopDataPtr->itemSpriteIds[0] = INVALID_U8;
+ gShopDataPtr->itemSpriteIds[1] = INVALID_U8;
BuyMenuBuildListMenuTemplate();
BuyMenuInitBgs();
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20);
@@ -580,7 +580,7 @@ static void BuyMenuPrintPriceInList(u8 windowId, int item, u8 y)
static void BuyMenuAddScrollIndicatorArrows(void)
{
- if (gShopDataPtr->scrollIndicatorsTaskId == 0xFF && gMartInfo.itemCount + 1 > 8)
+ if (gShopDataPtr->scrollIndicatorsTaskId == INVALID_U8 && gMartInfo.itemCount + 1 > 8)
{
gShopDataPtr->scrollIndicatorsTaskId = AddScrollIndicatorArrowPairParameterized(
SCROLL_ARROW_UP,
@@ -596,10 +596,10 @@ static void BuyMenuAddScrollIndicatorArrows(void)
static void BuyMenuRemoveScrollIndicatorArrows(void)
{
- if (gShopDataPtr->scrollIndicatorsTaskId != 0xFF)
+ if (gShopDataPtr->scrollIndicatorsTaskId != INVALID_U8)
{
RemoveScrollIndicatorArrowPair(gShopDataPtr->scrollIndicatorsTaskId);
- gShopDataPtr->scrollIndicatorsTaskId = 0xFF;
+ gShopDataPtr->scrollIndicatorsTaskId = INVALID_U8;
}
}
@@ -613,10 +613,10 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
{
u8 spriteId;
u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot];
- if (*spriteIdPtr != 0xFF)
+ if (*spriteIdPtr != INVALID_U8)
return;
- if (gMartInfo.martType == MART_TYPE_0 || item == 0xFFFF)
+ if (gMartInfo.martType == MART_TYPE_0 || item == INVALID_U16)
{
spriteId = AddItemIconSprite(iconSlot + 2110, iconSlot + 2110, item);
if (spriteId != MAX_SPRITES)
@@ -637,13 +637,13 @@ static void BuyMenuAddItemIcon(u16 item, u8 iconSlot)
static void BuyMenuRemoveItemIcon(u16 item, u8 iconSlot)
{
u8 *spriteIdPtr = &gShopDataPtr->itemSpriteIds[iconSlot];
- if (*spriteIdPtr == 0xFF)
+ if (*spriteIdPtr == INVALID_U8)
return;
FreeSpriteTilesByTag(iconSlot + 2110);
FreeSpritePaletteByTag(iconSlot + 2110);
DestroySprite(&gSprites[*spriteIdPtr]);
- *spriteIdPtr = 0xFF;
+ *spriteIdPtr = INVALID_U8;
}
static void BuyMenuInitBgs(void)
diff --git a/src/slot_machine.c b/src/slot_machine.c
index 01ef6d85c..97fe0b146 100644
--- a/src/slot_machine.c
+++ b/src/slot_machine.c
@@ -14,7 +14,7 @@
#include "util.h"
#include "text.h"
#include "menu.h"
-#include "malloc.h"
+#include "alloc.h"
#include "bg.h"
#include "gpu_regs.h"
#include "coins.h"
@@ -1637,7 +1637,7 @@ void PlaySlotMachine(u8 arg0, MainCallback cb)
/*static */bool8 sub_8102A44(void)
{
- if (FindTaskIdByFunc(sub_8102A64) == 0xff)
+ if (FindTaskIdByFunc(sub_8102A64) == INVALID_U8)
return TRUE;
else
return FALSE;
@@ -2672,7 +2672,7 @@ s16 sub_8102D5C(s16 a0)
/*static */bool8 sub_810432C(void)
{
- if (FindTaskIdByFunc(sub_810434C) == 0xFF)
+ if (FindTaskIdByFunc(sub_810434C) == INVALID_U8)
return TRUE;
return FALSE;
}
@@ -3007,7 +3007,7 @@ s16 sub_8102D5C(s16 a0)
/*static */bool8 sub_8104AEC(void)
{
- if (FindTaskIdByFunc(sub_8104B0C) == 0xFF)
+ if (FindTaskIdByFunc(sub_8104B0C) == INVALID_U8)
return TRUE;
else
return FALSE;
@@ -3108,7 +3108,7 @@ s16 sub_8102D5C(s16 a0)
task = gTasks + sSlotMachine->unk3D;
task->data[1] = arg0;
- for (i = 0; gUnknown_083ED048[arg0][i].unk00 != 0xFF; i++)
+ for (i = 0; gUnknown_083ED048[arg0][i].unk00 != INVALID_U8; i++)
{
u8 spriteId;
spriteId = sub_8105BB4(
@@ -3138,7 +3138,7 @@ s16 sub_8102D5C(s16 a0)
{
u8 i;
struct Task *task = gTasks + sSlotMachine->unk3D;
- if ((u16)task->data[1] != 0xFFFF)
+ if ((u16)task->data[1] != INVALID_U16)
gUnknown_083ED064[task->data[1]]();
for (i = 4; i < 16; i++)
{
diff --git a/src/smokescreen.c b/src/smokescreen.c
index 9b37cd234..1119e9e90 100644
--- a/src/smokescreen.c
+++ b/src/smokescreen.c
@@ -12,7 +12,7 @@ u8 sub_807521C(s16 x, s16 y, u8 a3)
u8 spriteId1, spriteId2, spriteId3, spriteId4;
struct Sprite *mainSprite;
- if (GetSpriteTileStartByTag(gUnknown_0831C620.tag) == 0xFFFF)
+ if (GetSpriteTileStartByTag(gUnknown_0831C620.tag) == INVALID_U16)
{
LoadCompressedObjectPicUsingHeap(&gUnknown_0831C620);
LoadCompressedObjectPaletteUsingHeap(&gUnknown_0831C628);
diff --git a/src/sound.c b/src/sound.c
index ba3f659cc..7798700c3 100644
--- a/src/sound.c
+++ b/src/sound.c
@@ -247,7 +247,7 @@ void FadeInNewBGM(u16 songNum, u8 speed)
{
if (gDisableMusic)
songNum = 0;
- if (songNum == 0xFFFF)
+ if (songNum == INVALID_U16)
songNum = 0;
m4aSongNumStart(songNum);
m4aMPlayImmInit(&gMPlayInfo_BGM);
@@ -544,7 +544,7 @@ void PlayBGM(u16 songNum)
{
if (gDisableMusic)
songNum = 0;
- if (songNum == 0xFFFF)
+ if (songNum == INVALID_U16)
songNum = 0;
m4aSongNumStart(songNum);
}
diff --git a/src/sprite.c b/src/sprite.c
index 4087dd8c4..3f0223dee 100644
--- a/src/sprite.c
+++ b/src/sprite.c
@@ -108,7 +108,7 @@ typedef void (*AffineAnimCmdFunc)(u8 matrixNum, struct Sprite *);
0 \
}
-#define ANIM_END 0xFFFF
+#define ANIM_END INVALID_U16
#define AFFINE_ANIM_END 0x7FFF
// forward declarations
@@ -204,7 +204,7 @@ const union AffineAnimCmd * const gDummySpriteAffineAnimTable[] = { &sDummyAffin
const struct SpriteTemplate gDummySpriteTemplate =
{
.tileTag = 0,
- .paletteTag = 0xFFFF,
+ .paletteTag = INVALID_U16,
.oam = &gDummyOamData,
.anims = gDummySpriteAnimTable,
.images = NULL,
@@ -572,12 +572,12 @@ u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y,
CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode);
- if (template->tileTag == 0xFFFF)
+ if (template->tileTag == INVALID_U16)
{
s16 tileNum;
sprite->images = template->images;
tileNum = AllocSpriteTiles((u8)(sprite->images->size / TILE_SIZE_4BPP));
- if (tileNum == -1)
+ if (tileNum == INVALID_S16)
{
ResetSprite(sprite);
return MAX_SPRITES;
@@ -595,7 +595,7 @@ u8 CreateSpriteAt(u8 index, const struct SpriteTemplate *template, s16 x, s16 y,
if (sprite->oam.affineMode & ST_OAM_AFFINE_ON_MASK)
InitSpriteAffineAnim(sprite);
- if (template->paletteTag != 0xFFFF)
+ if (template->paletteTag != INVALID_U16)
sprite->oam.paletteNum = IndexOfSpritePaletteTag(template->paletteTag);
return index;
@@ -740,7 +740,7 @@ s16 AllocSpriteTiles(u16 tileCount)
i++;
if (i == TOTAL_OBJ_TILE_COUNT)
- return -1;
+ return INVALID_S16;
}
start = i;
@@ -751,7 +751,7 @@ s16 AllocSpriteTiles(u16 tileCount)
i++;
if (i == TOTAL_OBJ_TILE_COUNT)
- return -1;
+ return INVALID_S16;
if (!SPRITE_TILE_IS_ALLOCATED(i))
numTilesFound++;
@@ -877,7 +877,7 @@ void ResetAllSprites(void)
void FreeSpriteTiles(struct Sprite *sprite)
{
- if (sprite->template->tileTag != 0xFFFF)
+ if (sprite->template->tileTag != INVALID_U16)
FreeSpriteTilesByTag(sprite->template->tileTag);
}
@@ -923,7 +923,7 @@ void BeginAnim(struct Sprite *sprite)
sprite->animLoopCounter = 0;
imageValue = sprite->anims[sprite->animNum][sprite->animCmdIndex].frame.imageValue;
- if (imageValue != -1)
+ if (imageValue != INVALID_S16)
{
sprite->animBeginning = FALSE;
duration = sprite->anims[sprite->animNum][sprite->animCmdIndex].frame.duration;
@@ -1441,7 +1441,7 @@ u8 AllocOamMatrix(void)
bit <<= 1;
}
- return 0xFF;
+ return INVALID_U8;
}
void FreeOamMatrix(u8 matrixNum)
@@ -1462,7 +1462,7 @@ void FreeOamMatrix(u8 matrixNum)
void InitSpriteAffineAnim(struct Sprite *sprite)
{
u8 matrixNum = AllocOamMatrix();
- if (matrixNum != 0xFF)
+ if (matrixNum != INVALID_U8)
{
CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode);
sprite->oam.matrixNum = matrixNum;
@@ -1508,7 +1508,7 @@ void LoadSpriteSheets(const struct SpriteSheet *sheets)
void FreeSpriteTilesByTag(u16 tag)
{
u8 index = IndexOfSpriteTileTag(tag);
- if (index != 0xFF)
+ if (index != INVALID_U8)
{
u16 i;
u16 *rangeStarts;
@@ -1523,7 +1523,7 @@ void FreeSpriteTilesByTag(u16 tag)
for (i = start; i < start + count; i++)
FREE_SPRITE_TILE(i);
- sSpriteTileRangeTags[index] = 0xFFFF;
+ sSpriteTileRangeTags[index] = INVALID_U16;
}
}
@@ -1533,7 +1533,7 @@ void FreeSpriteTileRanges(void)
for (i = 0; i < MAX_SPRITES; i++)
{
- sSpriteTileRangeTags[i] = 0xFFFF;
+ sSpriteTileRangeTags[i] = INVALID_U16;
SET_SPRITE_TILE_RANGE(i, 0, 0);
}
}
@@ -1541,8 +1541,8 @@ void FreeSpriteTileRanges(void)
u16 GetSpriteTileStartByTag(u16 tag)
{
u8 index = IndexOfSpriteTileTag(tag);
- if (index == 0xFF)
- return 0xFFFF;
+ if (index == INVALID_U8)
+ return INVALID_U16;
return sSpriteTileRanges[index * 2];
}
@@ -1554,7 +1554,7 @@ u8 IndexOfSpriteTileTag(u16 tag)
if (sSpriteTileRangeTags[i] == tag)
return i;
- return 0xFF;
+ return INVALID_U8;
}
u16 GetSpriteTileTagByTileStart(u16 start)
@@ -1563,16 +1563,16 @@ u16 GetSpriteTileTagByTileStart(u16 start)
for (i = 0; i < MAX_SPRITES; i++)
{
- if (sSpriteTileRangeTags[i] != 0xFFFF && sSpriteTileRanges[i * 2] == start)
+ if (sSpriteTileRangeTags[i] != INVALID_U16 && sSpriteTileRanges[i * 2] == start)
return sSpriteTileRangeTags[i];
}
- return 0xFFFF;
+ return INVALID_U16;
}
void AllocSpriteTileRange(u16 tag, u16 start, u16 count)
{
- u8 freeIndex = IndexOfSpriteTileTag(0xFFFF);
+ u8 freeIndex = IndexOfSpriteTileTag(INVALID_U16);
sSpriteTileRangeTags[freeIndex] = tag;
SET_SPRITE_TILE_RANGE(freeIndex, start, count);
}
@@ -1582,21 +1582,21 @@ void FreeAllSpritePalettes(void)
u8 i;
gReservedSpritePaletteCount = 0;
for (i = 0; i < 16; i++)
- sSpritePaletteTags[i] = 0xFFFF;
+ sSpritePaletteTags[i] = INVALID_U16;
}
u8 LoadSpritePalette(const struct SpritePalette *palette)
{
u8 index = IndexOfSpritePaletteTag(palette->tag);
- if (index != 0xFF)
+ if (index != INVALID_U8)
return index;
- index = IndexOfSpritePaletteTag(0xFFFF);
+ index = IndexOfSpritePaletteTag(INVALID_U16);
- if (index == 0xFF)
+ if (index == INVALID_U8)
{
- return 0xFF;
+ return INVALID_U8;
}
else
{
@@ -1610,7 +1610,7 @@ void LoadSpritePalettes(const struct SpritePalette *palettes)
{
u8 i;
for (i = 0; palettes[i].data != NULL; i++)
- if (LoadSpritePalette(&palettes[i]) == 0xFF)
+ if (LoadSpritePalette(&palettes[i]) == INVALID_U8)
break;
}
@@ -1621,10 +1621,10 @@ void DoLoadSpritePalette(const u16 *src, u16 paletteOffset)
u8 AllocSpritePalette(u16 tag)
{
- u8 index = IndexOfSpritePaletteTag(0xFFFF);
- if (index == 0xFF)
+ u8 index = IndexOfSpritePaletteTag(INVALID_U16);
+ if (index == INVALID_U8)
{
- return 0xFF;
+ return INVALID_U8;
}
else
{
@@ -1640,7 +1640,7 @@ u8 IndexOfSpritePaletteTag(u16 tag)
if (sSpritePaletteTags[i] == tag)
return i;
- return 0xFF;
+ return INVALID_U8;
}
u16 GetSpritePaletteTagByPaletteNum(u8 paletteNum)
@@ -1651,8 +1651,8 @@ u16 GetSpritePaletteTagByPaletteNum(u8 paletteNum)
void FreeSpritePaletteByTag(u16 tag)
{
u8 index = IndexOfSpritePaletteTag(tag);
- if (index != 0xFF)
- sSpritePaletteTags[index] = 0xFFFF;
+ if (index != INVALID_U8)
+ sSpritePaletteTags[index] = INVALID_U16;
}
void SetSubspriteTables(struct Sprite *sprite, const struct SubspriteTable *subspriteTables)
diff --git a/src/task.c b/src/task.c
index f067e21b4..2a77b8a9b 100644
--- a/src/task.c
+++ b/src/task.c
@@ -19,7 +19,7 @@ void ResetTasks(void)
gTasks[i].func = TaskDummy;
gTasks[i].prev = i;
gTasks[i].next = i + 1;
- gTasks[i].priority = -1;
+ gTasks[i].priority = INVALID_S8;
memset(gTasks[i].data, 0, sizeof(gTasks[i].data));
}
@@ -186,7 +186,7 @@ u8 FindTaskIdByFunc(TaskFunc func)
if (gTasks[i].isActive == TRUE && gTasks[i].func == func)
return (u8)i;
- return -1;
+ return INVALID_U8;
}
u8 GetTaskCount(void)
diff --git a/src/text.c b/src/text.c
index 07c15596e..44895722d 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1877,7 +1877,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
if (func == NULL)
return 0;
- if (letterSpacing == -1)
+ if (letterSpacing == INVALID_S16)
localLetterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING);
else
localLetterSpacing = letterSpacing;
@@ -1953,7 +1953,7 @@ u32 GetStringWidth(u8 fontId, const u8 *str, s16 letterSpacing)
func = GetFontWidthFunc(*++str);
if (func == NULL)
return 0;
- if (letterSpacing == -1)
+ if (letterSpacing == INVALID_S16)
localLetterSpacing = GetFontAttribute(*str, FONTATTR_LETTER_SPACING);
break;
case 0x11:
diff --git a/src/trader.c b/src/trader.c
index e23efb4ce..afb0cca48 100644
--- a/src/trader.c
+++ b/src/trader.c
@@ -155,7 +155,7 @@ void ScrSpecial_IsDecorationFull(void)
{
gSpecialVar_Result = FALSE;
if (gDecorations[gSpecialVar_0x8004].category != gDecorations[gSpecialVar_0x8006].category
- && GetFirstEmptyDecorSlot(gDecorations[gSpecialVar_0x8004].category) == -1)
+ && GetFirstEmptyDecorSlot(gDecorations[gSpecialVar_0x8004].category) == INVALID_S8)
{
sub_8127250(gStringVar2, gDecorations[gSpecialVar_0x8004].category);
gSpecialVar_Result = TRUE;
diff --git a/src/trainer_pokemon_sprites.c b/src/trainer_pokemon_sprites.c
index 040310901..fd97623fe 100644
--- a/src/trainer_pokemon_sprites.c
+++ b/src/trainer_pokemon_sprites.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "sprite.h"
#include "window.h"
-#include "malloc.h"
+#include "alloc.h"
#include "constants/species.h"
#include "palette.h"
#include "decompress.h"
@@ -107,9 +107,9 @@ static void LoadPicPaletteByTagOrSlot(u16 species, u32 otId, u32 personality, u8
{
if (!isTrainer)
{
- if (paletteTag == 0xFFFF)
+ if (paletteTag == INVALID_U16)
{
- sCreatingSpriteTemplate.paletteTag |= 0xFFFF;
+ sCreatingSpriteTemplate.paletteTag |= INVALID_U16;
LoadCompressedPalette(GetFrontSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x100 + paletteSlot * 0x10, 0x20);
}
else
@@ -120,9 +120,9 @@ static void LoadPicPaletteByTagOrSlot(u16 species, u32 otId, u32 personality, u8
}
else
{
- if (paletteTag == 0xFFFF)
+ if (paletteTag == INVALID_U16)
{
- sCreatingSpriteTemplate.paletteTag |= 0xFFFF;
+ sCreatingSpriteTemplate.paletteTag |= INVALID_U16;
LoadCompressedPalette(gTrainerFrontPicPaletteTable[species].data, 0x100 + paletteSlot * 0x10, 0x20);
}
else
@@ -166,30 +166,30 @@ static u16 CreatePicSprite(u16 species, u32 otId, u32 personality, bool8 isFront
}
if (i == PICS_COUNT)
{
- return 0xFFFF;
+ return INVALID_U16;
}
framePics = Alloc(4 * 0x800);
if (!framePics)
{
- return 0xFFFF;
+ return INVALID_U16;
}
images = Alloc(4 * sizeof(struct SpriteFrameImage));
if (!images)
{
Free(framePics);
- return 0xFFFF;
+ return INVALID_U16;
}
if (DecompressPic(species, personality, isFrontPic, framePics, isTrainer, ignoreDeoxys))
{
// debug trap?
- return 0xFFFF;
+ return INVALID_U16;
}
for (j = 0; j < 4; j ++)
{
images[j].data = framePics + 0x800 * j;
images[j].size = 0x800;
}
- sCreatingSpriteTemplate.tileTag = 0xFFFF;
+ sCreatingSpriteTemplate.tileTag = INVALID_U16;
sCreatingSpriteTemplate.oam = &gUnknown_0860B064;
AssignSpriteAnimsTable(isTrainer);
sCreatingSpriteTemplate.images = images;
@@ -197,7 +197,7 @@ static u16 CreatePicSprite(u16 species, u32 otId, u32 personality, bool8 isFront
sCreatingSpriteTemplate.callback = DummyPicSpriteCallback;
LoadPicPaletteByTagOrSlot(species, otId, personality, paletteSlot, paletteTag, isTrainer);
spriteId = CreateSprite(&sCreatingSpriteTemplate, x, y, 0);
- if (paletteTag == 0xFFFF)
+ if (paletteTag == INVALID_U16)
{
gSprites[spriteId].oam.paletteNum = paletteSlot;
}
@@ -232,12 +232,12 @@ u16 CreatePicSprite2(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s1
}
if (i == PICS_COUNT)
{
- return 0xFFFF;
+ return INVALID_U16;
}
framePics = Alloc(4 * 0x800);
if (!framePics)
{
- return 0xFFFF;
+ return INVALID_U16;
}
if (flags & 0x80)
{
@@ -252,19 +252,19 @@ u16 CreatePicSprite2(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s1
if (!images)
{
Free(framePics);
- return 0xFFFF;
+ return INVALID_U16;
}
if (DecompressPic(species, personality, flags, framePics, FALSE, FALSE))
{
// debug trap?
- return 0xFFFF;
+ return INVALID_U16;
}
for (j = 0; j < 4; j ++)
{
images[j].data = framePics + 0x800 * j;
images[j].size = 0x800;
}
- sCreatingSpriteTemplate.tileTag = 0xFFFF;
+ sCreatingSpriteTemplate.tileTag = INVALID_U16;
sCreatingSpriteTemplate.anims = gMonAnimationsSpriteAnimsPtrTable[species];
sCreatingSpriteTemplate.images = images;
if (flags2 == 0x01)
@@ -285,7 +285,7 @@ u16 CreatePicSprite2(u16 species, u32 otId, u32 personality, u8 flags, s16 x, s1
sCreatingSpriteTemplate.callback = DummyPicSpriteCallback;
LoadPicPaletteByTagOrSlot(species, otId, personality, paletteSlot, paletteTag, FALSE);
spriteId = CreateSprite(&sCreatingSpriteTemplate, x, y, 0);
- if (paletteTag == 0xFFFF)
+ if (paletteTag == INVALID_U16)
{
gSprites[spriteId].oam.paletteNum = paletteSlot;
}
@@ -312,11 +312,11 @@ static u16 FreeAndDestroyPicSpriteInternal(u16 spriteId)
}
if (i == PICS_COUNT)
{
- return 0xFFFF;
+ return INVALID_U16;
}
framePics = sSpritePics[i].frames;
images = sSpritePics[i].images;
- if (sSpritePics[i].paletteTag != 0xFFFF)
+ if (sSpritePics[i].paletteTag != INVALID_U16)
{
FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[spriteId].oam.paletteNum));
}
@@ -331,7 +331,7 @@ static u16 sub_818D65C(u16 species, u32 otId, u32 personality, bool8 isFrontPic,
{
if (DecompressPic_HandleDeoxys(species, personality, isFrontPic, (u8 *)GetWindowAttribute(windowId, WINDOW_TILE_DATA), FALSE))
{
- return 0xFFFF;
+ return INVALID_U16;
}
LoadPicPaletteBySlot(species, otId, personality, paletteSlot, isTrainer);
return 0;
@@ -349,7 +349,7 @@ static u16 sub_818D6CC(u16 species, u32 otId, u32 personality, bool8 isFrontPic,
Free(framePics);
return 0;
}
- return 0xFFFF;
+ return INVALID_U16;
}
static u16 CreateMonPicSprite(u16 species, u32 otId, u32 personality, bool8 isFrontPic, s16 x, s16 y, u8 paletteSlot, u16 paletteTag, bool8 ignoreDeoxys)
diff --git a/src/tv.c b/src/tv.c
index d3d1e797b..0c5c3f564 100644
--- a/src/tv.c
+++ b/src/tv.c
@@ -30,7 +30,7 @@
#include "text.h"
#include "script_menu.h"
#include "naming_screen.h"
-#include "malloc.h"
+#include "alloc.h"
#include "region_map.h"
#include "constants/region_map_sections.h"
#include "decoration.h"
@@ -799,7 +799,7 @@ u8 special_0x44(void)
j --;
}
} while (j != selIdx);
- return 0xFF;
+ return INVALID_U8;
}
u8 FindAnyTVShowOnTheAir(void)
@@ -807,9 +807,9 @@ u8 FindAnyTVShowOnTheAir(void)
u8 response;
response = special_0x44();
- if (response == 0xFF)
+ if (response == INVALID_U8)
{
- return 0xFF;
+ return INVALID_U8;
}
if (gSaveBlock1Ptr->outbreakPokemonSpecies != SPECIES_NONE && gSaveBlock1Ptr->tvShows[response].common.kind == TVSHOW_MASS_OUTBREAK)
{
@@ -833,7 +833,7 @@ void UpdateTVScreensOnMap(int width, int height)
{
SetTVMetatilesOnMap(width, height, 0x3);
}
- else if (FlagGet(FLAG_SYS_TV_START) && (FindAnyTVShowOnTheAir() != 0xff || FindAnyTVNewsOnTheAir() != 0xff || IsTVShowInSearchOfTrainersAiring()))
+ else if (FlagGet(FLAG_SYS_TV_START) && (FindAnyTVShowOnTheAir() != INVALID_U8 || FindAnyTVNewsOnTheAir() != INVALID_U8 || IsTVShowInSearchOfTrainersAiring()))
{
FlagClear(FLAG_SYS_TV_WATCH);
SetTVMetatilesOnMap(width, height, 0x3);
@@ -887,7 +887,7 @@ u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void)
return i;
}
}
- return 0xFF;
+ return INVALID_U8;
}
u8 special_0x4a(void)
@@ -932,7 +932,7 @@ void GabbyAndTyBeforeInterview(void)
gSaveBlock1Ptr->gabbyAndTyData.mon1 = gBattleResults.playerMon1Species;
gSaveBlock1Ptr->gabbyAndTyData.mon2 = gBattleResults.playerMon2Species;
gSaveBlock1Ptr->gabbyAndTyData.lastMove = gBattleResults.lastUsedMovePlayer;
- if (gSaveBlock1Ptr->gabbyAndTyData.battleNum != 0xFF)
+ if (gSaveBlock1Ptr->gabbyAndTyData.battleNum != INVALID_U8)
{
gSaveBlock1Ptr->gabbyAndTyData.battleNum ++;
}
@@ -1007,7 +1007,7 @@ bool8 IsTVShowInSearchOfTrainersAiring(void)
bool8 GabbyAndTyGetLastQuote(void)
{
- if (gSaveBlock1Ptr->gabbyAndTyData.quote[0] == 0xFFFF)
+ if (gSaveBlock1Ptr->gabbyAndTyData.quote[0] == INVALID_U16)
{
return FALSE;
}
@@ -1125,7 +1125,7 @@ void PutPokemonTodayCaughtOnAir(void)
if (!rbernoulli(1, 1) && StringCompare(gSpeciesNames[gBattleResults.caughtMonSpecies], gBattleResults.caughtMonNick))
{
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_CAUGHT, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_CAUGHT, FALSE) != TRUE)
{
for (i = 0; i < 11; i ++)
{
@@ -1206,7 +1206,7 @@ void PutPokemonTodayFailedOnTheAir(void)
if (ct > 2 && (gBattleOutcome == B_OUTCOME_MON_FLED || gBattleOutcome == B_OUTCOME_WON))
{
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_FAILED, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_POKEMON_TODAY_FAILED, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->pokemonTodayFailed.kind = TVSHOW_POKEMON_TODAY_FAILED;
@@ -1282,7 +1282,7 @@ void PutBattleUpdateOnTheAir(u8 opponentLinkPlayerId, u16 move, u16 speciesPlaye
u8 name[32];
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
FindActiveBroadcastByShowType_SetScriptResult(TVSHOW_BATTLE_UPDATE);
if (gSpecialVar_Result != 1)
@@ -1329,7 +1329,7 @@ bool8 Put3CheersForPokeblocksOnTheAir(const u8 *partnersName, u8 flavor, u8 unus
u8 name[32];
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot == -1)
+ if (sCurTVShowSlot == INVALID_S8)
{
return FALSE;
}
@@ -1396,7 +1396,7 @@ void ContestLiveUpdates_BeforeInterview_1(u8 a0)
DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, 24);
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show = &gSaveBlock1Ptr->tvShows[24];
show->contestLiveUpdates.round1Rank = a0;
@@ -1410,7 +1410,7 @@ void ContestLiveUpdates_BeforeInterview_2(u8 a0)
show = &gSaveBlock1Ptr->tvShows[24];
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show->contestLiveUpdates.round2Rank = a0;
}
@@ -1422,7 +1422,7 @@ void ContestLiveUpdates_BeforeInterview_3(u8 a0)
show = &gSaveBlock1Ptr->tvShows[24];
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show->contestLiveUpdates.appealFlags1 = a0;
}
@@ -1434,7 +1434,7 @@ void ContestLiveUpdates_BeforeInterview_4(u16 a0)
show = &gSaveBlock1Ptr->tvShows[24];
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show->contestLiveUpdates.move = a0;
}
@@ -1446,7 +1446,7 @@ void ContestLiveUpdates_BeforeInterview_5(u8 a0, u8 a1)
show = &gSaveBlock1Ptr->tvShows[24];
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show->contestLiveUpdates.winningSpecies = gContestMons[a1].species;
StringCopy(show->contestLiveUpdates.winningTrainerName, gContestMons[a1].trainerName);
@@ -1507,7 +1507,7 @@ void BravoTrainerPokemonProfile_BeforeInterview1(u16 a0)
show = &gSaveBlock1Ptr->tvShows[24];
InterviewBefore_BravoTrainerPkmnProfile();
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
DeleteTVShowInArrayByIdx(gSaveBlock1Ptr->tvShows, 24);
show->bravoTrainer.move = a0;
@@ -1521,7 +1521,7 @@ void BravoTrainerPokemonProfile_BeforeInterview2(u8 a0)
show = &gSaveBlock1Ptr->tvShows[24];
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show->bravoTrainer.contestResult = a0;
show->bravoTrainer.contestCategory = gSpecialVar_ContestCategory;
@@ -1577,7 +1577,7 @@ void SaveRecordedItemPurchasesForTVShow(void)
&& !rbernoulli(1, 3))
{
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SMART_SHOPPER, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SMART_SHOPPER, FALSE) != TRUE)
{
TV_SortPurchasesByQuantity();
if (gMartPurchaseHistory[0].quantity >= 20)
@@ -1742,7 +1742,7 @@ static void sub_80ED718(void)
if (!rbernoulli(1, 200))
{
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
outbreakIdx = Random() % ARRAY_COUNT(sPokeOutbreakSpeciesList);
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
@@ -1843,7 +1843,7 @@ void sub_80ED950(bool8 flag)
PutFishingAdviceShowOnTheAir();
}
sPokemonAnglerAttemptCounters &= 0xFF;
- if (sPokemonAnglerAttemptCounters != 0xFF)
+ if (sPokemonAnglerAttemptCounters != INVALID_U8)
{
sPokemonAnglerAttemptCounters += 0x01;
}
@@ -1855,7 +1855,7 @@ void sub_80ED950(bool8 flag)
PutFishingAdviceShowOnTheAir();
}
sPokemonAnglerAttemptCounters &= 0xFF00;
- if (sPokemonAnglerAttemptCounters >> 8 != 0xFF)
+ if (sPokemonAnglerAttemptCounters >> 8 != INVALID_U8)
{
sPokemonAnglerAttemptCounters += 0x0100;
}
@@ -1867,7 +1867,7 @@ void PutFishingAdviceShowOnTheAir(void)
TVShow *show;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_FISHING_ADVICE, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_FISHING_ADVICE, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->pokemonAngler.kind = TVSHOW_FISHING_ADVICE;
@@ -1910,7 +1910,7 @@ void sub_80EDA80(void)
if (!rbernoulli(1, 1))
{
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_WORLD_OF_MASTERS, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_WORLD_OF_MASTERS, FALSE) != TRUE)
{
show2 = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show2->worldOfMasters.kind = TVSHOW_WORLD_OF_MASTERS;
@@ -1936,7 +1936,7 @@ void sub_80EDB44(void)
HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TODAYS_RIVAL_TRAINER, TRUE);
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->rivalTrainer.kind = TVSHOW_TODAYS_RIVAL_TRAINER;
@@ -1984,7 +1984,7 @@ void sub_80EDC60(const u16 *words)
TVShow *show;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TREND_WATCHER, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TREND_WATCHER, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->trendWatcher.kind = TVSHOW_TREND_WATCHER;
@@ -2003,7 +2003,7 @@ void sub_80EDCE8(void)
TVShow *show;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TREASURE_INVESTIGATORS, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TREASURE_INVESTIGATORS, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->treasureInvestigators.kind = TVSHOW_TREASURE_INVESTIGATORS;
@@ -2024,7 +2024,7 @@ void sub_80EDD78(u16 nCoinsPaidOut)
u16 nCoinsWon;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_FIND_THAT_GAMER, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_FIND_THAT_GAMER, FALSE) != TRUE)
{
flag = FALSE;
switch (sFindThatGamerWhichGame)
@@ -2207,7 +2207,7 @@ void TV_PutSecretBaseVisitOnTheAir(void)
HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SECRET_BASE_VISIT, TRUE);
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->secretBaseVisit.kind = TVSHOW_SECRET_BASE_VISIT;
@@ -2227,7 +2227,7 @@ void sub_80EE184(void)
u16 balls;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_BREAKING_NEWS, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_BREAKING_NEWS, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->breakingNews.kind = TVSHOW_BREAKING_NEWS;
@@ -2298,7 +2298,7 @@ void sub_80EE2CC(void)
TVShow *show;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_LOTTO_WINNER, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_LOTTO_WINNER, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->lottoWinner.kind = TVSHOW_LOTTO_WINNER;
@@ -2318,7 +2318,7 @@ void sub_80EE35C(u16 foeSpecies, u16 species, u8 moveIdx, const u16 *movePtr, u1
u8 j;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_BATTLE_SEMINAR, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_BATTLE_SEMINAR, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->battleSeminar.kind = TVSHOW_BATTLE_SEMINAR;
@@ -2347,7 +2347,7 @@ void sub_80EE44C(u8 nMonsCaught, u8 nPkblkUsed)
TVShow *show;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SAFARI_FAN_CLUB, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SAFARI_FAN_CLUB, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->safariFanClub.kind = TVSHOW_SAFARI_FAN_CLUB;
@@ -2365,7 +2365,7 @@ void sub_80EE4DC(struct Pokemon *pokemon, u8 ribbonMonDataIdx)
TVShow *show;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_CUTIES, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_CUTIES, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->cuties.kind = TVSHOW_CUTIES;
@@ -2440,7 +2440,7 @@ void sub_80EE72C(void)
TVShow *show;
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TRAINER_FAN_CLUB, FALSE) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_TRAINER_FAN_CLUB, FALSE) != TRUE)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->trainerFanClub.kind = TVSHOW_TRAINER_FAN_CLUB;
@@ -2456,7 +2456,7 @@ void sub_80EE72C(void)
bool8 sub_80EE7C0(void)
{
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot == -1)
+ if (sCurTVShowSlot == INVALID_S8)
{
return TRUE;
}
@@ -2493,7 +2493,7 @@ bool8 sub_80EE818(void)
}
}
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot == -1)
+ if (sCurTVShowSlot == INVALID_S8)
{
return FALSE;
}
@@ -2557,7 +2557,7 @@ void sub_80EEA70(void)
if (HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_SECRET_BASE_SECRETS, FALSE) != TRUE)
{
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->secretBaseSecrets.kind = TVSHOW_SECRET_BASE_SECRETS;
@@ -2608,7 +2608,7 @@ static void sub_80EEBF4(u8 actionIdx)
HasMixableShowAlreadyBeenSpawnedWithPlayerID(TVSHOW_NUMBER_ONE, TRUE);
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
show = &gSaveBlock1Ptr->tvShows[sCurTVShowSlot];
show->numberOne.kind = TVSHOW_NUMBER_ONE;
@@ -2665,7 +2665,7 @@ static void sub_80EED88(void)
if (FlagGet(FLAG_SYS_GAME_CLEAR))
{
sCurTVShowSlot = sub_80EEE30(gSaveBlock1Ptr->pokeNews);
- if (sCurTVShowSlot != -1 && rbernoulli(1, 100) != TRUE)
+ if (sCurTVShowSlot != INVALID_S8 && rbernoulli(1, 100) != TRUE)
{
newsKind = (Random() % 4) + POKENEWS_SLATEPORT;
if (sub_80EF0E4(newsKind) != TRUE)
@@ -2689,7 +2689,7 @@ s8 sub_80EEE30(PokeNews *pokeNews)
return i;
}
}
- return -1;
+ return INVALID_S8;
}
void ClearPokemonNews(void)
@@ -2742,7 +2742,7 @@ u8 FindAnyTVNewsOnTheAir(void)
return i;
}
}
- return -1;
+ return INVALID_U8;
}
void DoPokeNews(void)
@@ -2751,7 +2751,7 @@ void DoPokeNews(void)
u16 n;
i = FindAnyTVNewsOnTheAir();
- if (i == 0xFF)
+ if (i == INVALID_U8)
{
gSpecialVar_Result = FALSE;
}
@@ -3252,7 +3252,7 @@ static void sub_80EFA88(void)
{
sCurTVShowSlot = FindEmptyTVSlotWithinFirstFiveShowsOfArray(gSaveBlock1Ptr->tvShows);
gSpecialVar_0x8006 = sCurTVShowSlot;
- if (sCurTVShowSlot == -1)
+ if (sCurTVShowSlot == INVALID_S8)
{
gSpecialVar_Result = TRUE;
}
@@ -3273,7 +3273,7 @@ s8 FindEmptyTVSlotWithinFirstFiveShowsOfArray(TVShow *shows)
return i;
}
}
- return -1;
+ return INVALID_S8;
}
s8 FindEmptyTVSlotBeyondFirstFiveShowsOfArray(TVShow *shows)
@@ -3287,7 +3287,7 @@ s8 FindEmptyTVSlotBeyondFirstFiveShowsOfArray(TVShow *shows)
return i;
}
}
- return -1;
+ return INVALID_S8;
}
bool8 TV_BernoulliTrial(u16 ratio)
@@ -3310,7 +3310,7 @@ void TV_FanClubLetter_RandomWordToStringVar3(TVShow *show)
{
i = 0;
}
- if (show->fanclubLetter.words[i] != 0xFFFF)
+ if (show->fanclubLetter.words[i] != INVALID_U16)
{
break;
}
@@ -3677,7 +3677,7 @@ static void sub_80F0358(TVShow player1[25], TVShow player2[25], TVShow player3[2
sRecordMixingPartnersWithoutShowsToShare = i;
}
sTVShowMixingCurSlot = sub_80F06D0(argslist[i][0]);
- if (sTVShowMixingCurSlot == -1)
+ if (sTVShowMixingCurSlot == INVALID_S8)
{
sRecordMixingPartnersWithoutShowsToShare ++;
if (sRecordMixingPartnersWithoutShowsToShare == sTVShowMixingNumPlayers)
@@ -3690,7 +3690,7 @@ static void sub_80F0358(TVShow player1[25], TVShow player2[25], TVShow player3[2
for (j = 0; j < sTVShowMixingNumPlayers - 1; j ++)
{
sCurTVShowSlot = FindEmptyTVSlotBeyondFirstFiveShowsOfArray(argslist[(i + j + 1) % sTVShowMixingNumPlayers][0]);
- if (sCurTVShowSlot != -1
+ if (sCurTVShowSlot != INVALID_S8
&& sub_80F049C(&argslist[(i + j + 1) % sTVShowMixingNumPlayers][0], &argslist[i][0], (i + j + 1) % sTVShowMixingNumPlayers) == 1)
{
break;
@@ -3801,7 +3801,7 @@ static s8 sub_80F06D0(TVShow *tvShows)
return i;
}
}
- return -1;
+ return INVALID_S8;
}
#ifdef NONMATCHING
@@ -4486,12 +4486,12 @@ static void sub_80F0D60(PokeNews player1[16], PokeNews player2[16], PokeNews pla
for (j = 0; j < sTVShowNewsMixingNumPlayers; j ++)
{
sTVShowMixingCurSlot = sub_80F0ECC(*argslist[j], i);
- if (sTVShowMixingCurSlot != -1)
+ if (sTVShowMixingCurSlot != INVALID_S8)
{
for (k = 0; k < sTVShowNewsMixingNumPlayers - 1; k++)
{
sCurTVShowSlot = sub_80EEE30(*argslist[(j + k + 1) % sTVShowNewsMixingNumPlayers]);
- if (sCurTVShowSlot != -1)
+ if (sCurTVShowSlot != INVALID_S8)
{
sub_80F0E58(argslist[(j + k + 1) % sTVShowNewsMixingNumPlayers], argslist[j]);
}
@@ -4538,7 +4538,7 @@ static s8 sub_80F0ECC(PokeNews *pokeNews, u8 idx)
{
if (pokeNews[idx].kind == POKENEWS_NONE)
{
- return -1;
+ return INVALID_S8;
}
return idx;
}
@@ -7425,7 +7425,7 @@ static void DoTVShowSecretBaseSecrets(void)
}
break;
default:
- for (i = 0; i < 0xFFFF; i ++)
+ for (i = 0; i < INVALID_U16; i ++)
{
sTVSecretBaseSecretsRandomValues[1] = Random() % bitCount;
if (sTVSecretBaseSecretsRandomValues[1] != sTVSecretBaseSecretsRandomValues[0])
@@ -7447,7 +7447,7 @@ static void DoTVShowSecretBaseSecrets(void)
}
else
{
- for (i = 0; i < 0xFFFF; i ++)
+ for (i = 0; i < INVALID_U16; i ++)
{
sTVSecretBaseSecretsRandomValues[2] = Random() % bitCount;
if (sTVSecretBaseSecretsRandomValues[2] != sTVSecretBaseSecretsRandomValues[0] && sTVSecretBaseSecretsRandomValues[2] != sTVSecretBaseSecretsRandomValues[1])
diff --git a/src/unk_pokedex_area_screen_helper.c b/src/unk_pokedex_area_screen_helper.c
index 6b88069bb..67fd52cb5 100644
--- a/src/unk_pokedex_area_screen_helper.c
+++ b/src/unk_pokedex_area_screen_helper.c
@@ -2,7 +2,7 @@
#include "main.h"
#include "menu.h"
#include "bg.h"
-#include "malloc.h"
+#include "alloc.h"
#include "palette.h"
#include "unk_pokedex_area_screen_helper.h"
diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c
index 72c33100f..762019ecd 100644
--- a/src/use_pokeblock.c
+++ b/src/use_pokeblock.c
@@ -1,7 +1,7 @@
#include "global.h"
#include "main.h"
#include "pokeblock.h"
-#include "malloc.h"
+#include "alloc.h"
#include "palette.h"
#include "pokenav.h"
#include "scanline_effect.h"
diff --git a/src/walda_phrase.c b/src/walda_phrase.c
index ff2ee7399..44da22f31 100644
--- a/src/walda_phrase.c
+++ b/src/walda_phrase.c
@@ -176,7 +176,7 @@ static void sub_81D9C90(u8 *array, s32 arg1, s32 arg2)
s32 i, j;
u8 var1, var2;
- for (i = arg2 - 1; i != -1; i--)
+ for (i = arg2 - 1; i != INVALID_S32; i--)
{
var1 = (array[0] & 0x80) >> 7;
diff --git a/src/wild_encounter.c b/src/wild_encounter.c
index 9b3c70ad7..8fb7d08d6 100644
--- a/src/wild_encounter.c
+++ b/src/wild_encounter.c
@@ -4825,7 +4825,7 @@ static u16 GetCurrentMapWildMonHeaderId(void)
for (i = 0; ; i++)
{
const struct WildPokemonHeader *wildHeader = &gWildMonHeaders[i];
- if (wildHeader->mapGroup == 0xFF)
+ if (wildHeader->mapGroup == INVALID_U8)
break;
if (gWildMonHeaders[i].mapGroup == gSaveBlock1Ptr->location.mapGroup &&
@@ -4845,7 +4845,7 @@ static u16 GetCurrentMapWildMonHeaderId(void)
}
}
- return -1;
+ return INVALID_S16;
}
static u8 PickWildMonNature(void)
@@ -5079,7 +5079,7 @@ bool8 StandardWildEncounter(u16 currMetaTileBehavior, u16 previousMetaTileBehavi
return FALSE;
headerId = GetCurrentMapWildMonHeaderId();
- if (headerId == 0xFFFF) // invalid
+ if (headerId == INVALID_U16)
{
if (gMapHeader.mapLayoutId == 0x166)
{
@@ -5190,7 +5190,7 @@ void RockSmashWildEncounter(void)
{
u16 headerId = GetCurrentMapWildMonHeaderId();
- if (headerId != 0xFFFF)
+ if (headerId != INVALID_U16)
{
const struct WildPokemonInfo *wildPokemonInfo = gWildMonHeaders[headerId].rockSmashMonsInfo;
@@ -5222,7 +5222,7 @@ bool8 SweetScentWildEncounter(void)
PlayerGetDestCoords(&x, &y);
headerId = GetCurrentMapWildMonHeaderId();
- if (headerId == 0xFFFF) // invalid
+ if (headerId == INVALID_U16)
{
if (gMapHeader.mapLayoutId == 0x166)
{
@@ -5292,7 +5292,7 @@ bool8 DoesCurrentMapHaveFishingMons(void)
{
u16 headerId = GetCurrentMapWildMonHeaderId();
- if (headerId != 0xFFFF && gWildMonHeaders[headerId].fishingMonsInfo != NULL)
+ if (headerId != INVALID_U16 && gWildMonHeaders[headerId].fishingMonsInfo != NULL)
return TRUE;
else
return FALSE;
@@ -5326,7 +5326,7 @@ u16 GetLocalWildMon(bool8 *isWaterMon)
*isWaterMon = FALSE;
headerId = GetCurrentMapWildMonHeaderId();
- if (headerId == 0xFFFF)
+ if (headerId == INVALID_U16)
return SPECIES_NONE;
landMonsInfo = gWildMonHeaders[headerId].landMonsInfo;
waterMonsInfo = gWildMonHeaders[headerId].waterMonsInfo;
@@ -5358,7 +5358,7 @@ u16 GetLocalWaterMon(void)
{
u16 headerId = GetCurrentMapWildMonHeaderId();
- if (headerId != 0xFFFF)
+ if (headerId != INVALID_U16)
{
const struct WildPokemonInfo *waterMonsInfo = gWildMonHeaders[headerId].waterMonsInfo;
diff --git a/src/window.c b/src/window.c
index 8efd1c281..d5b996df1 100644
--- a/src/window.c
+++ b/src/window.c
@@ -1,6 +1,6 @@
#include "global.h"
#include "window.h"
-#include "malloc.h"
+#include "alloc.h"
#include "bg.h"
#include "blit.h"
@@ -52,12 +52,12 @@ bool16 InitWindows(const struct WindowTemplate *templates)
gWindows[i].tileData = NULL;
}
- for (i = 0, allocatedBaseBlock = 0, bgLayer = templates[i].bg; bgLayer != 0xFF && i < 0x20; ++i, bgLayer = templates[i].bg)
+ for (i = 0, allocatedBaseBlock = 0, bgLayer = templates[i].bg; bgLayer != INVALID_U8 && i < 0x20; ++i, bgLayer = templates[i].bg)
{
if (gUnneededFireRedVariable == 1)
{
allocatedBaseBlock = DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, 0, templates[i].width * templates[i].height, 0);
- if (allocatedBaseBlock == -1)
+ if (allocatedBaseBlock == INVALID_S32)
return FALSE;
}
@@ -65,7 +65,7 @@ bool16 InitWindows(const struct WindowTemplate *templates)
{
attrib = GetBgAttribute(bgLayer, 0x8);
- if (attrib != 0xFFFF)
+ if (attrib != INVALID_U16)
{
allocatedTilemapBuffer = AllocZeroed(attrib);
@@ -121,12 +121,12 @@ u16 AddWindow(const struct WindowTemplate *template)
for (win = 0; win < WINDOWS_MAX; ++win)
{
- if ((bgLayer = gWindows[win].window.bg) == 0xFF)
+ if ((bgLayer = gWindows[win].window.bg) == INVALID_U8)
break;
}
if (win == WINDOWS_MAX)
- return 0xFF;
+ return INVALID_U8;
bgLayer = template->bg;
allocatedBaseBlock = 0;
@@ -135,20 +135,20 @@ u16 AddWindow(const struct WindowTemplate *template)
{
allocatedBaseBlock = DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, 0, template->width * template->height, 0);
- if (allocatedBaseBlock == -1)
- return 0xFF;
+ if (allocatedBaseBlock == INVALID_S32)
+ return INVALID_U8;
}
if (gUnknown_03002F70[bgLayer] == NULL)
{
attrib = GetBgAttribute(bgLayer, 0x8);
- if (attrib != 0xFFFF)
+ if (attrib != INVALID_U16)
{
allocatedTilemapBuffer = AllocZeroed(attrib);
if (allocatedTilemapBuffer == NULL)
- return 0xFF;
+ return INVALID_U8;
for (i = 0; i < attrib; ++i)
allocatedTilemapBuffer[i] = 0;
@@ -167,7 +167,7 @@ u16 AddWindow(const struct WindowTemplate *template)
Free(gUnknown_03002F70[bgLayer]);
gUnknown_03002F70[bgLayer] = allocatedTilemapBuffer;
}
- return 0xFF;
+ return INVALID_U8;
}
gWindows[win].tileData = allocatedTilemapBuffer;
@@ -190,12 +190,12 @@ int AddWindowWithoutTileMap(const struct WindowTemplate *template)
for (win = 0; win < WINDOWS_MAX; ++win)
{
- if (gWindows[win].window.bg == 0xFF)
+ if (gWindows[win].window.bg == INVALID_U8)
break;
}
if (win == WINDOWS_MAX)
- return 0xFF;
+ return INVALID_U8;
bgLayer = template->bg;
allocatedBaseBlock = 0;
@@ -204,8 +204,8 @@ int AddWindowWithoutTileMap(const struct WindowTemplate *template)
{
allocatedBaseBlock = DummiedOutFireRedLeafGreenTileAllocFunc(bgLayer, 0, template->width * template->height, 0);
- if (allocatedBaseBlock == -1)
- return 0xFF;
+ if (allocatedBaseBlock == INVALID_S32)
+ return INVALID_U8;
}
gWindows[win].window = *template;
@@ -609,21 +609,21 @@ u16 AddWindow8Bit(struct WindowTemplate *template)
for (windowId = 0; windowId < 32; windowId++)
{
- if (gWindows[windowId].window.bg == 0xFF)
+ if (gWindows[windowId].window.bg == INVALID_U8)
break;
}
if (windowId == WINDOWS_MAX)
- return 0xFF;
+ return INVALID_U8;
bgLayer = template->bg;
if (gUnknown_03002F70[bgLayer] == 0)
{
u16 attribute = GetBgAttribute(bgLayer, 8);
- if (attribute != 0xFFFF)
+ if (attribute != INVALID_U16)
{
s32 i;
memAddress = Alloc(attribute);
if (memAddress == NULL)
- return 0xFF;
+ return INVALID_U8;
for (i = 0; i < attribute; i++) // if we're going to zero out the memory anyway, why not call AllocZeroed?
memAddress[i] = 0;
gUnknown_03002F70[bgLayer] = memAddress;
@@ -638,7 +638,7 @@ u16 AddWindow8Bit(struct WindowTemplate *template)
Free(gUnknown_03002F70[bgLayer]);
gUnknown_03002F70[bgLayer] = NULL;
}
- return 0xFF;
+ return INVALID_U8;
}
else
{