diff options
Diffstat (limited to 'src')
79 files changed, 916 insertions, 944 deletions
diff --git a/src/bard_music.c b/src/bard_music.c index ee70f5319..43c2923d2 100644 --- a/src/bard_music.c +++ b/src/bard_music.c @@ -48,7 +48,7 @@ static s16 sub_814A2B8(u32 arg0, u32 arg1) struct BardSound *sub_814A2D0(u16 arg0, u16 arg1) { struct BardSound *sounds = gBardMusicTable[arg0]; - + return &sounds[arg1]; } @@ -57,28 +57,28 @@ s32 sub_814A2EC(struct UnkBard2 *dest, struct UnkBard *src, u16 arg2) s32 i; s32 j; s32 thirty; - + for (i = 0; i < 6; i++) { dest->var18[i].var00 = src[i].var00; if (src[i].var00 != 0xFF) { s32 r1 = src[i].var01 +gUnknown_084170F4[src[i].var00]; - + dest->var18[i].var02 = r1; dest->var18[i].var06 = src[i].var04; dest->var04 += r1; } } - + for (j = 0, thirty = 30; j < i; j++) dest->var18[j].var04 = sub_814A2B8(thirty + arg2, j); - + dest->var00++; dest->var01 = 0; dest->var02 = 0; dest->var03 = 0; dest->var0A = 0; - + //warning: no return statement in function returning non-void } diff --git a/src/battle_811DA74.c b/src/battle_811DA74.c index fbd379427..81d1a8d18 100644 --- a/src/battle_811DA74.c +++ b/src/battle_811DA74.c @@ -1,8 +1,8 @@ #include "global.h" #include "asm.h" #include "link.h" -#include "main.h" #include "m4a.h" +#include "main.h" #include "palette.h" #include "pokemon.h" #include "sound.h" @@ -116,7 +116,7 @@ void sub_811DB84(void) void sub_811DBC0(void) { bool8 r6 = FALSE; - + if (!IsDoubleBattle() || (IsDoubleBattle() && (gBattleTypeFlags & 0x40))) { if (gSprites[gUnknown_03004340[gUnknown_02024A60]].callback == SpriteCallbackDummy) @@ -140,7 +140,7 @@ void sub_811DBC0(void) void sub_811DCA0(void) { u8 r2; - + if (!(EWRAM_17810[gUnknown_02024A60].unk0 & 8)) { r2 = EWRAM_17810[gUnknown_02024A60 ^ 2].unk0 & 8; @@ -174,7 +174,7 @@ void sub_811DDE8(void) void bx_t3_healthbar_update(void) { s16 r4; - + r4 = sub_8045C78(gUnknown_02024A60, gUnknown_03004340[gUnknown_02024A60], 0, 0); sub_8043DFC(gUnknown_03004340[gUnknown_02024A60]); if (r4 != -1) @@ -233,7 +233,7 @@ void bx_blink_t3(void) { gSprites[spriteId].invisible ^= 1; } - gSprites[spriteId].data1++; + gSprites[spriteId].data1++; } } @@ -317,7 +317,7 @@ void sub_811E29C(void) void dp01_tbl3_exec_completed(void) { u8 multiplayerId; - + gUnknown_03004330[gUnknown_02024A60] = sub_811DA94; if (gBattleTypeFlags & 2) { @@ -352,7 +352,7 @@ void dp01t_00_3_getattr(void) u8 unk[4]; int r6 = 0; s32 i; - + if (*((u8 *)&gUnknown_02023A60 + 2 + gUnknown_02024A60 * 0x200) == 0) { r6 = dp01_getattr_by_ch1_for_player_pokemon(gUnknown_02024A6A[gUnknown_02024A60], unk); @@ -360,7 +360,7 @@ void dp01t_00_3_getattr(void) else { u8 r4 = *((u8 *)&gUnknown_02023A60 + gUnknown_02024A60 * 0x200 + 2); - + for (i = 0; i < 6; i++) { if (r4 & 1) diff --git a/src/battle_ai.c b/src/battle_ai.c index ca767a3a3..26db24f14 100644 --- a/src/battle_ai.c +++ b/src/battle_ai.c @@ -1,12 +1,12 @@ #include "global.h" -#include "battle.h" +#include "abilities.h" #include "asm.h" +#include "battle.h" +#include "battle_move_effects.h" +#include "item.h" #include "pokemon.h" #include "rng.h" -#include "abilities.h" #include "species.h" -#include "item.h" -#include "battle_move_effects.h" #define AIScriptRead32(ptr) ((ptr)[0] | (ptr)[1] << 8 | (ptr)[2] << 16 | (ptr)[3] << 24) #define AIScriptRead16(ptr) ((ptr)[0] | (ptr)[1] << 8) @@ -1655,7 +1655,7 @@ static void BattleAICmd_unk_36(void) gAIThinkingSpace.funcResult = 0; if(gBattleWeather & 0x80) gAIThinkingSpace.funcResult = 3; - + gAIScriptPtr += 1; } @@ -1683,7 +1683,7 @@ static void BattleAICmd_if_stat_level_less_than(void) party = gUnknown_02024C07; else party = gUnknown_02024C08; - + if(gBattleMons[party].statStages[gAIScriptPtr[2]] < gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); else @@ -1698,7 +1698,7 @@ static void BattleAICmd_if_stat_level_more_than(void) party = gUnknown_02024C07; else party = gUnknown_02024C08; - + if(gBattleMons[party].statStages[gAIScriptPtr[2]] > gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); else @@ -1713,7 +1713,7 @@ static void BattleAICmd_if_stat_level_equal(void) party = gUnknown_02024C07; else party = gUnknown_02024C08; - + if(gBattleMons[party].statStages[gAIScriptPtr[2]] == gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); else @@ -1728,7 +1728,7 @@ static void BattleAICmd_if_stat_level_not_equal(void) party = gUnknown_02024C07; else party = gUnknown_02024C08; - + if(gBattleMons[party].statStages[gAIScriptPtr[2]] != gAIScriptPtr[3]) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 4); else @@ -1750,13 +1750,13 @@ static void BattleAICmd_if_can_faint(void) gUnknown_02024BE6 = gAIThinkingSpace.unk2; sub_801CAF8(gUnknown_02024C07, gUnknown_02024C08); move_effectiveness_something(gUnknown_02024BE6, gUnknown_02024C07, gUnknown_02024C08); - + gBattleMoveDamage = gBattleMoveDamage * gAIThinkingSpace.unk18[gAIThinkingSpace.moveConsidered] / 100; - + // moves always do at least 1 damage. if(gBattleMoveDamage == 0) gBattleMoveDamage = 1; - + if(gBattleMons[gUnknown_02024C08].hp <= gBattleMoveDamage) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else @@ -1779,7 +1779,7 @@ static void BattleAICmd_if_cant_faint(void) gUnknown_02024BE6 = gAIThinkingSpace.unk2; sub_801CAF8(gUnknown_02024C07, gUnknown_02024C08); move_effectiveness_something(gUnknown_02024BE6, gUnknown_02024C07, gUnknown_02024C08); - + gBattleMoveDamage = gBattleMoveDamage * gAIThinkingSpace.unk18[gAIThinkingSpace.moveConsidered] / 100; // this macro is missing the damage 0 = 1 assumption. @@ -1794,7 +1794,7 @@ static void BattleAICmd_unk_3F(void) { int i; u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2); - + switch(gAIScriptPtr[1]) { case 1: @@ -1838,7 +1838,7 @@ static void BattleAICmd_unk_40(void) { int i; u16 *temp_ptr = (u16 *)(gAIScriptPtr + 2); - + switch(gAIScriptPtr[1]) { case 1: @@ -1881,7 +1881,7 @@ static void BattleAICmd_unk_40(void) static void BattleAICmd_if_move_effect(void) { int i; - + switch(gAIScriptPtr[1]) { case 1: @@ -1910,7 +1910,7 @@ static void BattleAICmd_if_move_effect(void) static void BattleAICmd_if_not_move_effect(void) { int i; - + switch(gAIScriptPtr[1]) { case 1: @@ -1939,12 +1939,12 @@ static void BattleAICmd_if_not_move_effect(void) static void BattleAICmd_if_last_move_did_damage(void) { u8 var; - + if(gAIScriptPtr[1] == USER) var = gUnknown_02024C07; else var = gUnknown_02024C08; - + if(gAIScriptPtr[2] == 0) { if(gUnknown_02024CA8[var].unk4 == 0) @@ -2002,7 +2002,7 @@ static void BattleAICmd_unk_45(void) static void BattleAICmd_if_random_2(void) { u8 var = battle_2000000.unk88 * 5; - + if((u8)(Random() % 100) < var) gAIScriptPtr = AIScriptReadPtr(gAIScriptPtr + 1); else @@ -2019,12 +2019,12 @@ static void BattleAICmd_get_hold_effect(void) u8 var; u16 status; u8 *aiPtr; - + if(gAIScriptPtr[1] == USER) var = gUnknown_02024C07; else var = gUnknown_02024C08; - + if(battle_side_get_owner(var) == 0) { // weird pointer arithmetic is needed to match. @@ -2034,21 +2034,21 @@ static void BattleAICmd_get_hold_effect(void) } else gAIThinkingSpace.funcResult = ItemId_GetHoldEffect(gBattleMons[var].item); - + gAIScriptPtr += 2; } static void BattleAICmd_get_gender(void) { u8 var; - + if(gAIScriptPtr[1] == USER) var = gUnknown_02024C07; else var = gUnknown_02024C08; - + gAIThinkingSpace.funcResult = GetGenderFromSpeciesAndPersonality(gBattleMons[var].species, gBattleMons[var].personality); - + gAIScriptPtr += 2; } @@ -2060,9 +2060,9 @@ static void BattleAICmd_is_first_turn(void) var = gUnknown_02024C07; else var = gUnknown_02024C08; - + gAIThinkingSpace.funcResult = gUnknown_02024CA8[var].unk16; - + gAIScriptPtr += 2; } @@ -2074,66 +2074,66 @@ static void BattleAICmd_get_stockpile_count(void) var = gUnknown_02024C07; else var = gUnknown_02024C08; - + gAIThinkingSpace.funcResult = gUnknown_02024CA8[var].unk9; - + gAIScriptPtr += 2; } static void BattleAICmd_unk_4C(void) { gAIThinkingSpace.funcResult = gBattleTypeFlags & 1; - + gAIScriptPtr += 1; } static void BattleAICmd_get_item(void) { u8 var; - + if (gAIScriptPtr[1] == USER) var = gUnknown_02024C07; else var = gUnknown_02024C08; - + // this hack and a half matches. whatever. i dont care. someone else fix this mess later. ((struct AI_ThinkingStruct *)(unk_2000000 + 0x16800))->funcResult = unk_2000000[0x160CC + var * 2]; - + gAIScriptPtr += 2; } static void BattleAICmd_unk_4E(void) { gAIThinkingSpace.funcResult = gBattleMoves[gAIThinkingSpace.funcResult].type; - + gAIScriptPtr += 1; } static void BattleAICmd_unk_4F(void) { gAIThinkingSpace.funcResult = gBattleMoves[gAIThinkingSpace.funcResult].power; - + gAIScriptPtr += 1; } static void BattleAICmd_unk_50(void) { gAIThinkingSpace.funcResult = gBattleMoves[gAIThinkingSpace.funcResult].effect; - + gAIScriptPtr += 1; } static void BattleAICmd_get_protect_count(void) { u8 var; - + if(gAIScriptPtr[1] == USER) var = gUnknown_02024C07; else var = gUnknown_02024C08; gAIThinkingSpace.funcResult = gUnknown_02024CA8[var].unk8; - + gAIScriptPtr += 2; } diff --git a/src/battle_anim.c b/src/battle_anim.c index 9464b4949..90a53a412 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -235,7 +235,7 @@ static void (*const sScriptCmdTable[])(void) = { void sub_8075624(void) { s32 i; - + gUnknown_0202F7B0 = 0; gUnknown_0202F7B1 = 0; gUnknown_0202F7B2 = 0; @@ -268,7 +268,7 @@ void move_anim_start_t1(u16 a) void move_something(const u8 *const moveAnims[], u16 b, u8 c) { s32 i; - + if (sub_8076BE0() == 0) { sub_8079E24(); @@ -339,7 +339,7 @@ void move_anim_related_task_del(u8 taskId) static void sub_8075940(u16 a) { s32 i; - + for (i = 0; i < 8; i++) { if (gUnknown_03004B10[i] == 0xFFFF) @@ -353,7 +353,7 @@ static void sub_8075940(u16 a) static void sub_8075970(u16 a) { s32 i; - + for (i = 0; i < 8; i++) { if (gUnknown_03004B10[i] == a) @@ -388,7 +388,7 @@ static void sub_80759D0(void) static void ScriptCmd_loadsprite(void) { u16 r4; - + gBattleAnimScriptPtr++; r4 = SCRIPT_READ_16(gBattleAnimScriptPtr); LoadCompressedObjectPic(&gBattleAnimPicTable[r4 - 10000]); @@ -402,7 +402,7 @@ static void ScriptCmd_loadsprite(void) static void ScriptCmd_unloadsprite(void) { u16 r4; - + gBattleAnimScriptPtr++; r4 = SCRIPT_READ_16(gBattleAnimScriptPtr); FreeSpriteTilesByTag(gBattleAnimPicTable[r4 - 10000].tag); @@ -422,7 +422,7 @@ static void ScriptCmd_sprite(void) u16 r6; u8 r2; s8 r1; - + gBattleAnimScriptPtr++; r7 = (struct SpriteTemplate *)(SCRIPT_READ_32(gBattleAnimScriptPtr)); gBattleAnimScriptPtr += 4; @@ -444,7 +444,7 @@ static void ScriptCmd_sprite(void) r4 = -r4; _r0 = sub_8079E90(gUnknown_0202F7C9); r1 = r4; - + } else { @@ -459,7 +459,7 @@ static void ScriptCmd_sprite(void) r6 = _r0 + r1; if ((s16)r6 < 3) r6 = 3; - + r4 = sub_8077ABC(gUnknown_0202F7C9, 2); r2 = sub_8077ABC(gUnknown_0202F7C9, 3); CreateSpriteAndAnimate(r7, r4, r2, r6); @@ -603,7 +603,7 @@ static void ScriptCmd_createtask(void) u8 taskId; u8 numArgs; s32 i; - + gBattleAnimScriptPtr++; taskFunc = (TaskFunc)SCRIPT_READ_32(gBattleAnimScriptPtr); gBattleAnimScriptPtr += 4; @@ -656,7 +656,7 @@ static void ScriptCmd_end(void) { s32 i; int zero = 0; - + if (gUnknown_0202F7B2 != 0 || gUnknown_0202F7B3 != 0 || gUnknown_0202F7C2[0] != 0xFF || gUnknown_0202F7C2[1] != 0xFF) { @@ -664,7 +664,7 @@ static void ScriptCmd_end(void) gUnknown_0202F7B0 = 1; return; } - + if (IsSEPlaying()) { gUnknown_03004AF0++; @@ -716,7 +716,7 @@ static void ScriptCmd_monbg(void) u8 r7; u16 r4; u8 taskId; - + gBattleAnimScriptPtr++; r6 = SCRIPT_READ_8(gBattleAnimScriptPtr); if (r6 == 0) @@ -754,7 +754,7 @@ static void ScriptCmd_monbg(void) gTasks[taskId].data[5] = r7; gTasks[taskId].data[6] = r5; gUnknown_0202F7C2[0] = taskId; - + } r5 ^= 2; if (r6 > 1 && b_side_obj__get_some_boolean(r5)) @@ -881,7 +881,7 @@ void sub_8076034(u8 a, u8 b) volatile u8 pointlessZero; u16 *addr2; u8 spriteId; - + if (b == 0) { struct UnknownStruct2 s; @@ -889,7 +889,7 @@ void sub_8076034(u8 a, u8 b) u32 size; u8 r2; u16 *addr3; - + sub_8078914(&s); addr = s.unk0; size = 0x2000; @@ -908,25 +908,25 @@ void sub_8076034(u8 a, u8 b) pointlessZero = 0; addr2 = (void *)s.unk4; DmaFill16(3, 0xFF, addr2, 0x1000); - + REG_BG1CNT_BITFIELD.priority = 2; REG_BG1CNT_BITFIELD.screenSize = 1; REG_BG1CNT_BITFIELD.areaOverflowMode = 0; - + spriteId = gUnknown_02024BE0[a]; gUnknown_030042C0 = -(gSprites[spriteId].pos1.x + gSprites[spriteId].pos2.x) + 32; if (sub_8076BE0() != 0 && sub_80AEB1C(EWRAM_19348) != 0) gUnknown_030042C0--; gUnknown_030041B4 = -(gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y) + 32; gSprites[gUnknown_02024BE0[a]].invisible = TRUE; - + REG_BG1HOFS = gUnknown_030042C0; REG_BG1VOFS = gUnknown_030041B4; - + LoadPalette(gPlttBufferUnfaded + 0x100 + a * 16, s.unk8 * 16, 32); addr3 = (u16 *)PLTT + s.unk8 * 16; DmaCopy32(3, gPlttBufferUnfaded + 0x100 + a * 16, addr3, 32); - + if (sub_8076BE0() != 0) r2 = 0; else @@ -940,7 +940,7 @@ void sub_8076034(u8 a, u8 b) u8 *addr; u32 size; u16 *addr3; - + addr = (void *)(VRAM + 0x6000); size = 0x2000; while (1) @@ -958,23 +958,23 @@ void sub_8076034(u8 a, u8 b) pointlessZero = 0; addr2 = (void *)(VRAM + 0xF000); DmaFill32(3, 0, addr2, 0x800); - + REG_BG2CNT_BITFIELD.priority = 2; REG_BG2CNT_BITFIELD.screenSize = 1; REG_BG2CNT_BITFIELD.areaOverflowMode = 0; - + spriteId = gUnknown_02024BE0[a]; gUnknown_03004288 = -(gSprites[spriteId].pos1.x + gSprites[spriteId].pos2.x) + 32; gUnknown_03004280 = -(gSprites[spriteId].pos1.y + gSprites[spriteId].pos2.y) + 32; gSprites[gUnknown_02024BE0[a]].invisible = TRUE; - + REG_BG2HOFS = gUnknown_03004288; REG_BG2VOFS = gUnknown_03004280; - + LoadPalette(gPlttBufferUnfaded + 0x100 + a * 16, 0x90, 32); addr3 = (void *)(PLTT + 0x120); DmaCopy32(3, gPlttBufferUnfaded + 0x100 + a * 16, addr3, 32); - + sub_80E4EF8(0, 0, battle_get_per_side_status(a), 9, 0x6000, 0x1E, REG_BG2CNT_BITFIELD.charBaseBlock); } } @@ -985,7 +985,7 @@ static void sub_8076380(void) int j; struct UnknownStruct2 s; u16 *ptr; - + if (sub_80AEB1C(EWRAM_19348) != 0) { sub_8078914(&s); @@ -995,7 +995,7 @@ static void sub_8076380(void) for (j = 0; j < 4; j++) { u16 temp = ptr[j + i * 32]; - + ptr[j + i * 32] = ptr[7 - j + i * 32]; ptr[7 - j + i * 32] = temp; } @@ -1013,7 +1013,7 @@ void sub_80763FC(u16 a, u16 *b, u32 c, u8 d) u8 i; u8 j; u32 r9; - + if (d == 0) r9 = 32; else @@ -1032,12 +1032,12 @@ void sub_8076464(u8 a) u32 size; volatile u8 pointlessZero; struct UnknownStruct2 s; - + sub_8078914(&s); if (a == 0 || sub_8076BE0() != 0) { u16 *addr2; - + addr = s.unk0; size = 0x2000; while (1) @@ -1061,7 +1061,7 @@ void sub_8076464(u8 a) else { u16 *addr2; - + addr = (void *)(VRAM + 0x6000); size = 0x2000; while (1) @@ -1091,7 +1091,7 @@ static void task_pA_ma0A_obj_to_bg_pal(u8 taskId) s16 r3; s16 r2; struct UnknownStruct2 s; - + r4 = gTasks[taskId].data[0]; r6 = gTasks[taskId].data[6]; sub_8078914(&s); @@ -1101,7 +1101,7 @@ static void task_pA_ma0A_obj_to_bg_pal(u8 taskId) { u16 *src; u16 *dst; - + gUnknown_030042C0 = r3 + gTasks[taskId].data[3]; gUnknown_030041B4 = r2 + gTasks[taskId].data[4]; src = gPlttBufferFaded + 0x100 + r6 * 16; @@ -1112,7 +1112,7 @@ static void task_pA_ma0A_obj_to_bg_pal(u8 taskId) { u16 *src; u16 *dst; - + gUnknown_03004288 = r3 + gTasks[taskId].data[3]; gUnknown_03004280 = r2 + gTasks[taskId].data[4]; src = gPlttBufferFaded + 0x100 + r6 * 16; @@ -1126,7 +1126,7 @@ static void ScriptCmd_clearmonbg(void) u8 r4; u8 r5; u8 taskId; - + gBattleAnimScriptPtr++; r4 = SCRIPT_READ_8(gBattleAnimScriptPtr); if (r4 == 0) @@ -1153,7 +1153,7 @@ static void sub_807672C(u8 taskId) { u8 var; u8 r4; - + gTasks[taskId].data[1]++; if (gTasks[taskId].data[1] != 1) { @@ -1185,7 +1185,7 @@ static void ScriptCmd_monbg_22(void) u8 r4; u8 r0; u8 r1; - + gBattleAnimScriptPtr++; r5 = SCRIPT_READ_8(gBattleAnimScriptPtr); if (r5 == 0) @@ -1227,7 +1227,7 @@ static void ScriptCmd_clearmonbg_23(void) u8 r5; u8 r6; u8 taskId; - + gBattleAnimScriptPtr++; r5 = SCRIPT_READ_8(gBattleAnimScriptPtr); if (r5 == 0) @@ -1255,7 +1255,7 @@ static void sub_80769A4(u8 taskId) u8 r0; u8 r4; u8 r5; - + gTasks[taskId].data[1]++; if (gTasks[taskId].data[1] != 1) { @@ -1278,7 +1278,7 @@ static void ScriptCmd_setalpha(void) { u16 r3; u16 r1; - + gBattleAnimScriptPtr++; r3 = *(gBattleAnimScriptPtr++); r1 = *(gBattleAnimScriptPtr++) << 8; @@ -1290,7 +1290,7 @@ static void ScriptCmd_setbldcnt(void) { u16 r3; u16 r1; - + gBattleAnimScriptPtr++; r3 = *(gBattleAnimScriptPtr++); r1 = *(gBattleAnimScriptPtr++) << 8; @@ -1307,7 +1307,7 @@ static void ScriptCmd_blendoff(void) static void ScriptCmd_call(void) { u32 addr; - + gBattleAnimScriptPtr++; gBattleAnimScriptRetAddr = gBattleAnimScriptPtr + 4; addr = SCRIPT_READ_32(gBattleAnimScriptPtr); @@ -1324,7 +1324,7 @@ static void ScriptCmd_setvar(void) const u8 *addr = gBattleAnimScriptPtr; u16 r4; u8 r2; - + gBattleAnimScriptPtr++; r2 = SCRIPT_READ_8(gBattleAnimScriptPtr); gBattleAnimScriptPtr++; @@ -1336,7 +1336,7 @@ static void ScriptCmd_setvar(void) static void ScriptCmd_ifelse(void) { u32 addr; - + gBattleAnimScriptPtr++; if (gUnknown_0202F7C4 & 1) gBattleAnimScriptPtr += 4; @@ -1348,7 +1348,7 @@ static void ScriptCmd_jumpif(void) { u8 r1; u32 addr; - + gBattleAnimScriptPtr++; r1 = SCRIPT_READ_8(gBattleAnimScriptPtr); gBattleAnimScriptPtr++; @@ -1366,7 +1366,7 @@ static void ScriptCmd_jumpif(void) static void ScriptCmd_jump(void) { u32 addr; - + gBattleAnimScriptPtr++; addr = SCRIPT_READ_32(gBattleAnimScriptPtr); gBattleAnimScriptPtr = (u8 *)addr; @@ -1385,7 +1385,7 @@ static void ScriptCmd_fadetobg(void) { u8 r4; u8 taskId; - + gBattleAnimScriptPtr++; r4 = SCRIPT_READ_8(gBattleAnimScriptPtr); gBattleAnimScriptPtr++; @@ -1400,7 +1400,7 @@ static void ScriptCmd_fadetobg_25(void) u8 r7; u8 r6; u8 taskId; - + gBattleAnimScriptPtr++; r8 = gBattleAnimScriptPtr[0]; r7 = gBattleAnimScriptPtr[1]; @@ -1434,7 +1434,7 @@ static void task_p5_load_battle_screen_elements(u8 taskId) else if (gTasks[taskId].data[10] == 2) { s16 data0 = (u16)gTasks[taskId].data[0]; - + if (data0 == -1) dp01t_11_3_message_for_player_only(); else @@ -1459,7 +1459,7 @@ static void sub_8076DB8(u16 a) void *tilemap = gBattleAnimBackgroundTable[a].tilemap; void *dmaSrc; void *dmaDest; - + sub_800D238(tilemap, sub_8076BE0() ? EWRAM_14800 : EWRAM_18000); sub_80763FC(sub_80789BC(), sub_8076BE0() ? EWRAM_14800 : EWRAM_18000, 0x100, 0); dmaSrc = sub_8076BE0() ? EWRAM_14800 : EWRAM_18000; @@ -1487,7 +1487,7 @@ static void dp01t_11_3_message_for_player_only(void) static void ScriptCmd_restorebg(void) { u8 taskId; - + gBattleAnimScriptPtr++; taskId = CreateTask(task_p5_load_battle_screen_elements, 5); gTasks[taskId].data[0] = 0xFFFF; @@ -1547,7 +1547,7 @@ s8 sub_8076F98(s8 a) if (a < -0x40) a = 0xC0; return a; - } + } } //_08077004 else @@ -1559,7 +1559,7 @@ s8 sub_8076F98(s8 a) //_08077042 else { - + } //_0807706C } @@ -1717,7 +1717,7 @@ s8 sub_8077094(s8 a) s16 sub_8077104(s16 a) { s16 var = a; - + if (var > 63) var = 63; else if (var < -64) @@ -1728,7 +1728,7 @@ s16 sub_8077104(s16 a) s16 sub_807712C(s16 a, s16 b, s16 c) { u16 var; - + if (a < b) var = ((c < 0) ? -c : c); else if (a > b) @@ -1742,7 +1742,7 @@ static void ScriptCmd_panse_19(void) { u16 r4; s8 r0; - + gBattleAnimScriptPtr++; r4 = SCRIPT_READ_16(gBattleAnimScriptPtr); r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); @@ -1753,7 +1753,7 @@ static void ScriptCmd_panse_19(void) static void ScriptCmd_setpan(void) { s8 r0; - + gBattleAnimScriptPtr++; r0 = SCRIPT_READ_8(gBattleAnimScriptPtr); SE12PanpotControl(sub_8076F98(r0)); @@ -1770,7 +1770,7 @@ static void ScriptCmd_panse_1B(void) s8 panning; s8 r8; u8 taskId; - + gBattleAnimScriptPtr++; songNum = SCRIPT_READ_16(gBattleAnimScriptPtr); r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); @@ -1800,7 +1800,7 @@ static void c3_08073CEC(u8 taskId) s16 r3; s16 r4; int foo; - + r0 = gTasks[taskId].data[8]; gTasks[taskId].data[8]++; if (r0 >= gTasks[taskId].data[3]) @@ -1935,7 +1935,7 @@ static void ScriptCmd_panse_26(void) s8 r6; u8 r10; u8 taskId; - + gBattleAnimScriptPtr++; r8 = SCRIPT_READ_16(gBattleAnimScriptPtr); r4 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); @@ -1964,7 +1964,7 @@ static void ScriptCmd_panse_27(void) s8 r5; s8 r4_2; u8 taskId; - + gBattleAnimScriptPtr++; r9 = SCRIPT_READ_16(gBattleAnimScriptPtr); r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); @@ -1993,7 +1993,7 @@ static void ScriptCmd_panse_1C(void) u8 r9; s8 r4; u8 taskId; - + gBattleAnimScriptPtr++; r5 = SCRIPT_READ_16(gBattleAnimScriptPtr); r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); @@ -2017,7 +2017,7 @@ static void sub_80774FC(u8 taskId) u16 r0; s8 r1; u8 r4; - + data8 = gTasks[taskId].data[8]; gTasks[taskId].data[8]++; if (data8 >= gTasks[taskId].data[2]) @@ -2043,7 +2043,7 @@ static void ScriptCmd_panse_1D(void) u8 r8; s8 r4; u8 taskId; - + gBattleAnimScriptPtr++; r5 = SCRIPT_READ_16(gBattleAnimScriptPtr); r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 2); @@ -2060,7 +2060,7 @@ static void ScriptCmd_panse_1D(void) static void sub_80775CC(u8 taskId) { s16 r0; - + r0 = gTasks[taskId].data[2]; gTasks[taskId].data[2]--; if (r0 <= 0) @@ -2077,7 +2077,7 @@ static void ScriptCmd_createtask_1F(void) u8 numArgs; int i; u8 taskId; - + gBattleAnimScriptPtr++; func = (TaskFunc)SCRIPT_READ_32(gBattleAnimScriptPtr); gBattleAnimScriptPtr += 4; @@ -2127,7 +2127,7 @@ static void ScriptCmd_jumpvareq(void) u8 r2; s16 r1; u8 *addr; - + gBattleAnimScriptPtr++; r2 = SCRIPT_READ_8(gBattleAnimScriptPtr); r1 = SCRIPT_READ_16(gBattleAnimScriptPtr + 1); @@ -2145,7 +2145,7 @@ static void ScriptCmd_jumpvareq(void) static void ScriptCmd_jumpunkcond(void) { u8 *addr; - + gBattleAnimScriptPtr++; if (sub_8076BE0()) { @@ -2163,7 +2163,7 @@ static void ScriptCmd_monbgprio_28(void) u8 r2; u8 r0; u8 r4; - + r2 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); gBattleAnimScriptPtr += 2; if (r2 != 0) @@ -2193,7 +2193,7 @@ static void ScriptCmd_monbgprio_2A(void) u8 r6; u8 r4; u8 r0; - + r6 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); gBattleAnimScriptPtr += 2; if (battle_side_get_owner(gUnknown_0202F7C8) != battle_side_get_owner(gUnknown_0202F7C9)) @@ -2215,7 +2215,7 @@ static void ScriptCmd_invisible(void) { u8 r0; u8 spriteId; - + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); spriteId = obj_id_for_side_relative_to_move(r0); if (spriteId != 0xFF) @@ -2229,7 +2229,7 @@ static void ScriptCmd_visible(void) { u8 r0; u8 spriteId; - + r0 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); spriteId = obj_id_for_side_relative_to_move(r0); if (spriteId != 0xFF) @@ -2244,7 +2244,7 @@ static void ScriptCmd_doublebattle_2D(void) u8 r7; u8 r4; u8 spriteId; - + r7 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); gBattleAnimScriptPtr += 2; if (!sub_8076BE0() && IsDoubleBattle() @@ -2278,7 +2278,7 @@ static void ScriptCmd_doublebattle_2E(void) u8 r7; u8 r4; u8 spriteId; - + r7 = SCRIPT_READ_8(gBattleAnimScriptPtr + 1); gBattleAnimScriptPtr += 2; if (!sub_8076BE0() && IsDoubleBattle() diff --git a/src/battle_anim_80A7E7C.c b/src/battle_anim_80A7E7C.c index 2c7a10be5..f6c3d70c3 100644 --- a/src/battle_anim_80A7E7C.c +++ b/src/battle_anim_80A7E7C.c @@ -1,6 +1,6 @@ #include "global.h" -#include "task.h" #include "sprite.h" +#include "task.h" #include "trig.h" #define TASK gTasks[task] diff --git a/src/battle_setup.c b/src/battle_setup.c index 1c3e8e836..6d3e6a215 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -1,25 +1,26 @@ #include "global.h" #include "battle_setup.h" #include "asm.h" -#include "safari_zone.h" -#include "weather.h" -#include "palette.h" -#include "field_player_avatar.h" -#include "rom4.h" #include "battle.h" +#include "event_data.h" +#include "field_message_box.h" +#include "field_player_avatar.h" #include "main.h" -#include "species.h" +#include "metatile_behavior.h" +#include "palette.h" +#include "rng.h" +#include "rom4.h" +#include "safari_zone.h" +#include "script.h" #include "songs.h" #include "sound.h" -#include "task.h" +#include "species.h" +#include "starter_choose.h" #include "string_util.h" -#include "rng.h" -#include "event_data.h" -#include "script.h" -#include "field_message_box.h" +#include "task.h" +#include "text.h" #include "trainer.h" -#include "starter_choose.h" -#include "metatile_behavior.h" +#include "weather.h" #define NUM_TRAINER_EYE_TRAINERS 56 #define TRAINER_REMATCH_STEPS 255 @@ -117,8 +118,6 @@ extern struct TrainerBattleSpec gTrainerBattleSpecs_2[]; extern struct TrainerBattleSpec gTrainerBattleSpecs_3[]; extern struct TrainerBattleSpec gTrainerBattleSpecs_4[]; -extern u8 gStringVar4[]; - extern u8 gBattleTransitionTable_Wild[][2]; extern u8 gBattleTransitionTable_Trainer[][2]; @@ -387,7 +386,7 @@ u16 GetSumOfPartyMonLevel(u8 numMons) for (i = 0; i < 6; i++) { u32 species = GetMonData(&gPlayerParty[i], MON_DATA_SPECIES2); - + if (species != SPECIES_EGG && species != SPECIES_NONE && GetMonData(&gPlayerParty[i], MON_DATA_HP) != 0) { sum += GetMonData(&gPlayerParty[i], MON_DATA_LEVEL); diff --git a/src/berry.c b/src/berry.c index 84db22a27..2a8ce8380 100644 --- a/src/berry.c +++ b/src/berry.c @@ -2,10 +2,10 @@ #include "berry.h" #include "asm.h" #include "item.h" +#include "items.h" #include "main.h" -#include "text.h" #include "rng.h" -#include "items.h" +#include "text.h" #define FIRST_BERRY ITEM_CHERI_BERRY #define LAST_BERRY ITEM_ENIGMA_BERRY @@ -29,7 +29,7 @@ void SetEnigmaBerry(u8 *src) { u32 i; u8 *dest = (u8*)&gSaveBlock1.enigmaBerry; - + for (i = 0; i < sizeof(gSaveBlock1.enigmaBerry); i++) dest[i] = src[i]; @@ -94,7 +94,7 @@ struct BerryTree *GetBerryTreeInfo(u8 id) bool32 FieldObjectInteractionWaterBerryTree(void) { struct BerryTree *tree = GetBerryTreeInfo(FieldObjectGetBerryTreeId(gSelectedMapObject)); - + switch (tree->stage) { case 1: @@ -137,7 +137,7 @@ void ClearBerryTrees(void) int i; struct SaveBlock1 *saveBlock1 = &gSaveBlock1; struct BerryTree berryTree = gBlankBerryTree; - + for (i = 0; i < 128; i++) saveBlock1->berryTrees[i] = berryTree; } @@ -175,7 +175,7 @@ void BerryTreeTimeUpdate(int time) { int i; struct BerryTree *tree; - + for (i = 0; i < 128; i++) { tree = &gSaveBlock1.berryTrees[i]; @@ -189,7 +189,7 @@ void BerryTreeTimeUpdate(int time) else { int time2 = time; - + while (time2 != 0) { if (tree->secondsUntilNextStage > time2) @@ -212,7 +212,7 @@ void BerryTreeTimeUpdate(int time) void PlantBerryTree(u8 id, u8 berry, u8 stage, bool8 sparkle) { struct BerryTree *tree = GetBerryTreeInfo(id); - + *tree = gBlankBerryTree; tree->berry = berry; tree->secondsUntilNextStage = GetStageDurationByBerryType(berry); @@ -246,7 +246,7 @@ u8 GetStageByBerryTreeId(u8 id) u8 ItemIdToBerryType(u16 item) { u16 berry = item - FIRST_BERRY; - + if (berry > LAST_BERRY - FIRST_BERRY) return 1; else @@ -256,7 +256,7 @@ u8 ItemIdToBerryType(u16 item) u16 BerryTypeToItemId(u16 berry) { u16 item = berry - 1; - + if (item > LAST_BERRY - FIRST_BERRY) return FIRST_BERRY; else @@ -277,7 +277,7 @@ void ResetBerryTreeSparkleFlag(u8 id) u8 BerryTreeGetNumStagesWatered(struct BerryTree *tree) { u8 count = 0; - + if (tree->watered1) count++; if (tree->watered2) @@ -300,7 +300,7 @@ u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water) u32 randMax; u32 rand; u32 extraYield; - + if (water == 0) return min; else @@ -308,7 +308,7 @@ u8 CalcBerryYieldInternal(u16 max, u16 min, u8 water) randMin = (max - min) * (water - 1); randMax = (max - min) * (water); rand = randMin + Random() % (randMax - randMin + 1); - + if ((rand & 3) > 1) extraYield = rand / 4 + 1; else @@ -322,7 +322,7 @@ u8 CalcBerryYield(struct BerryTree *tree) struct Berry *berry = GetBerryInfo(tree->berry); u8 min = berry->minYield; u8 max = berry->maxYield; - + return CalcBerryYieldInternal(max, min, BerryTreeGetNumStagesWatered(tree)); } @@ -343,7 +343,7 @@ void FieldObjectInteractionGetBerryTreeData(void) u8 unk; u8 group; u8 num; - + id = FieldObjectGetBerryTreeId(gSelectedMapObject); berry = GetBerryTypeByBerryTreeId(id); ResetBerryTreeSparkleFlag(id); @@ -367,7 +367,7 @@ void sub_80B4EE4(void) void FieldObjectInteractionPlantBerryTree(void) { u8 berry = ItemIdToBerryType(gScriptItemId); - + PlantBerryTree(FieldObjectGetBerryTreeId(gSelectedMapObject), berry, 1, TRUE); FieldObjectInteractionGetBerryTreeData(); } @@ -376,7 +376,7 @@ void FieldObjectInteractionPickBerryTree(void) { u8 id = FieldObjectGetBerryTreeId(gSelectedMapObject); u8 berry = GetBerryTypeByBerryTreeId(id); - + gSpecialVar_0x8004 = AddBagItem(BerryTypeToItemId(berry), GetBerryCountByBerryTreeId(id)); } diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index 164e2cfc2..a0e0a419f 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -3,6 +3,7 @@ #include "asm.h" #include "berry.h" #include "decompress.h" +#include "items.h" #include "main.h" #include "menu.h" #include "palette.h" @@ -13,7 +14,6 @@ #include "string_util.h" #include "task.h" #include "text.h" -#include "items.h" #define OFFSET_7B (123) #define FIRST_BERRY ITEM_CHERI_BERRY @@ -30,7 +30,6 @@ struct BerryTagStatus }; extern struct Struct2000000 unk_2000000; -extern u16 gBGTilemapBuffers[4][0x400]; extern u8 gUnknown_0203932C; extern struct BerryTagStatus gUnknown_0203932E; extern u16 gScriptItemId; diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index 1493f1793..cf05bdf20 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -1,16 +1,17 @@ #include "global.h" -#include "event_data.h" -#include "flags.h" #include "asm.h" +#include "event_data.h" #include "field_camera.h" #include "field_effect.h" +#include "flags.h" #include "map_obj_lock.h" -#include "sound.h" +#include "menu.h" #include "script.h" #include "songs.h" +#include "sound.h" #include "species.h" #include "task.h" -#include "menu.h" +#include "text.h" extern u8 gPlayerPartyCount; extern u8 gUnknown_03005CE0; @@ -103,7 +104,7 @@ bool8 ShouldDoBrailleFlyEffect(void) if(gSaveBlock1.pos.x == 8 && gSaveBlock1.pos.y == 25) return TRUE; } - + return FALSE; } @@ -116,7 +117,7 @@ void DoBrailleFlyEffect(void) bool8 FldEff_UseFlyAncientTomb(void) { u8 taskId = oei_task_add(); - + gTasks[taskId].data[8] = (u32)UseFlyAncientTomb_Callback >> 16; gTasks[taskId].data[9] = (u32)UseFlyAncientTomb_Callback; return FALSE; @@ -204,12 +205,12 @@ void Task_BrailleWait(u8 taskId) bool32 BrailleWait_CheckButtonPress(void) { u16 var = 0xFF; - + if(gSaveBlock2.optionsButtonMode == 1) var |= 0x300; if(gSaveBlock2.optionsButtonMode == 2) var |= 0x200; - + if((var & gMain.newKeys) != FALSE) return TRUE; else @@ -219,7 +220,7 @@ bool32 BrailleWait_CheckButtonPress(void) void DoSealedChamberShakingEffect1(void) { u8 taskId = CreateTask(SealedChamberShakingEffect, 0x9); - + gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 0; gTasks[taskId].data[4] = 2; @@ -231,7 +232,7 @@ void DoSealedChamberShakingEffect1(void) void DoSealedChamberShakingEffect2(void) { u8 taskId = CreateTask(SealedChamberShakingEffect, 0x9); - + gTasks[taskId].data[1] = 0; gTasks[taskId].data[2] = 0; gTasks[taskId].data[4] = 3; @@ -243,7 +244,7 @@ void DoSealedChamberShakingEffect2(void) void SealedChamberShakingEffect(u8 taskId) { struct Task *task = &gTasks[taskId]; - + task->data[1]++; if(!(task->data[1] % task->data[5])) diff --git a/src/calculate_base_damage.c b/src/calculate_base_damage.c index 86446e588..8e020829a 100644 --- a/src/calculate_base_damage.c +++ b/src/calculate_base_damage.c @@ -1,17 +1,17 @@ #include "global.h" -#include "text.h" -#include "string_util.h" -#include "pokemon.h" -#include "species.h" -#include "main.h" -#include "sprite.h" -#include "berry.h" -#include "item.h" #include "abilities.h" -#include "hold_effects.h" -#include "event_data.h" #include "battle.h" +#include "berry.h" +#include "event_data.h" +#include "hold_effects.h" +#include "item.h" #include "items.h" +#include "main.h" +#include "pokemon.h" +#include "species.h" +#include "sprite.h" +#include "string_util.h" +#include "text.h" extern u8 gPlayerPartyCount; extern struct Pokemon gPlayerParty[6]; @@ -307,7 +307,7 @@ s32 CalculateBaseDamage(struct BattlePokemon *attacker, struct BattlePokemon *de // does lack of sun half solar beam damage? if ((gBattleWeather & 0x9F) && gUnknown_02024BE6 == 76) damage /= 2; - + // sunny? if (gBattleWeather & 0x60) { diff --git a/src/clear_save_data_menu.c b/src/clear_save_data_menu.c index 198dce340..6b0cc821a 100644 --- a/src/clear_save_data_menu.c +++ b/src/clear_save_data_menu.c @@ -1,13 +1,13 @@ #include "global.h" #include "clear_save_data_menu.h" -#include "save.h" -#include "task.h" -#include "songs.h" -#include "menu.h" #include "main.h" -#include "sprite.h" +#include "menu.h" #include "palette.h" +#include "save.h" +#include "songs.h" #include "sound.h" +#include "sprite.h" +#include "task.h" extern u8 gSystemText_ClearAllSaveDataPrompt[]; extern u8 gSystemText_ClearingData[]; diff --git a/src/clock.c b/src/clock.c index e660abdd3..85188cd19 100644 --- a/src/clock.c +++ b/src/clock.c @@ -1,10 +1,10 @@ #include "global.h" -#include "main.h" -#include "rtc.h" +#include "berry.h" #include "event_data.h" #include "lottery_corner.h" -#include "berry.h" +#include "main.h" #include "rom4.h" +#include "rtc.h" #include "wallclock.h" extern void sub_80FA220(u16); diff --git a/src/coins.c b/src/coins.c index ad4f5fc34..18b11a9d9 100644 --- a/src/coins.c +++ b/src/coins.c @@ -29,7 +29,7 @@ void PrintCoins(s32 a, u8 b, u8 c, u8 d) u8 *ptr; u8 r1; u8 foo; - + ConvertIntToDecimalString(string, a); r1 = (b * 6 + 0x21 - 8 * (b + 2)); c = c - r1 / 8; @@ -58,7 +58,7 @@ u16 GetCoins(void) bool8 GiveCoins(u16 coins) { u32 newCoins; - + if(GetCoins() >= MAX_COINS) return FALSE; newCoins = coins + gSaveBlock1.coins; diff --git a/src/contest_painting.c b/src/contest_painting.c index b6cdda034..7de005a46 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -194,7 +194,7 @@ static void ShowContestPainting(void) { u8 *addr; size_t size; - + ResetPaletteFade(); addr = (void *)VRAM; size = 0x18000; @@ -261,7 +261,7 @@ static void HoldContestPainting(void) if ((gMain.newKeys & 1) || (gMain.newKeys & 2)) { u8 two = 2; //needed to make the asm match - + gUnknown_03000750 = two; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); } @@ -515,7 +515,7 @@ void sub_8106B90(u8 a[][8][8][4], u16 b[], u16 c[][8][8][8]) u16 j; u16 k; u16 l; - + for (i = 0; i < 8; i++) { for (j = 0; j < 8; j++) @@ -527,7 +527,7 @@ void sub_8106B90(u8 a[][8][8][4], u16 b[], u16 c[][8][8][8]) //u8 *arr = a[i][j][k]; //u8 r1 = arr[l / 2]; u8 r1 = a[i][j][k][l / 2]; - + if (l & 1) r1 /= 16; else @@ -650,7 +650,7 @@ _08106C08:\n\ static void sub_8106C40(u8 arg0, u8 arg1) { u8 x, y; - + LoadPalette(gPictureFramePalettes, 0, 128 * 2); if (arg1 == 1) { @@ -677,11 +677,11 @@ static void sub_8106C40(u8 arg0, u8 arg1) RLUnCompWram(gPictureFrameTilemap_4, gUnknown_03005E10); break; } - + #define VRAM_PICTURE_DATA(x, y) (((u16 *)(VRAM + 0x6000))[(y) * 32 + (x)]) - + // Set the background - for (y = 0; y < 20; y++) + for (y = 0; y < 20; y++) { for (x = 0; x < 32; x++) VRAM_PICTURE_DATA(x, y) = 0x1015; @@ -697,7 +697,7 @@ static void sub_8106C40(u8 arg0, u8 arg1) // Re-set the entire top row to the first top frame part for (x = 0; x < 16; x++) VRAM_PICTURE_DATA(x + 7, 2) = (*gUnknown_03005E10)[2][7]; - + #undef VRAM_PICTURE_DATA } else if (arg0 < 8) @@ -739,14 +739,14 @@ static void sub_8106E98(u8 arg0) #ifndef NONMATCHING asm(""::"r"(arg0)); #endif - + gMain.oamBuffer[0] = gOamData_83F6138; gMain.oamBuffer[0].tileNum = 0; - + #ifndef NONMATCHING if (arg0) arg0 = gMain.oamBuffer[0].tileNum; #endif - + gMain.oamBuffer[0].x = 88; gMain.oamBuffer[0].y = 24; } diff --git a/src/credits.c b/src/credits.c index e16702051..52aeffbbf 100644 --- a/src/credits.c +++ b/src/credits.c @@ -7,10 +7,12 @@ #include "palette.h" #include "songs.h" #include "sound.h" -#include "species.h" -#include "sprite.h" -#include "task.h" -#include "text.h" + +asm(".set REG_BASE, 0x4000000"); +asm(".set OFFSET_REG_BLDCNT, 0x50"); +asm(".set OFFSET_REG_BLDALPHA, 0x52"); +asm(".set REG_BLDCNT, REG_BASE + OFFSET_REG_BLDCNT"); +asm(".set REG_BLDALPHA, REG_BASE + OFFSET_REG_BLDALPHA"); u32 NationalPokedexNumToSpecies(u16 nationalNum); @@ -18,19 +20,8 @@ struct MonCoords { u8 x, y; }; - extern void *species_and_otid_get_pal(u32, u16, u16); -asm(".set REG_BASE, 0x4000000"); -asm(".set OFFSET_REG_BG3HOFS, 0x1c"); -asm(".set OFFSET_REG_BG3VOFS, 0x1e"); -asm(".set OFFSET_REG_BLDCNT, 0x50"); -asm(".set OFFSET_REG_BLDALPHA, 0x52"); -asm(".set REG_BG3HOFS, REG_BASE + OFFSET_REG_BG3HOFS"); -asm(".set REG_BG3VOFS, REG_BASE + OFFSET_REG_BG3VOFS"); -asm(".set REG_BLDCNT, REG_BASE + OFFSET_REG_BLDCNT"); -asm(".set REG_BLDALPHA, REG_BASE + OFFSET_REG_BLDALPHA"); - enum { PAGE_TITLE, PAGE_DIRECTOR, @@ -132,17 +123,12 @@ enum { }; struct Unk201C000 { - u8 pad_00[0x88]; - u16 var_88; - u16 var_8A; - u16 var_8C; - u16 var_8E; -}; - -struct HallOfFame { - u8 sheet0[0x800]; - u8 sheet1[0x800]; - u8 sheet2[0x800]; + u16 unk0[8]; + u8 pad_10[0x78]; + u16 unk88; + u16 unk8A; + u16 unk8C; + u16 unk8E; }; struct CreditsEntry { @@ -170,7 +156,6 @@ extern s16 gUnknown_02039320; extern u16 gUnknown_02039322; // TASK A extern u8 gUnknown_02039324; extern u8 gUnknown_02039325; - extern u16 gUnknown_02039358; extern u16 gUnknown_0203935A; extern s16 gUnknown_0203935C; @@ -233,11 +218,11 @@ static void task_a_8144114(u8 taskIdA); static void sub_8144130(void); static void task_b_81441B8(u8 taskIdB); static u8 sub_8144454(u8 page, u8 taskIdA); -void task_d_8144514(u8 taskIdD); +static void task_d_8144514(u8 taskIdD); static bool8 sub_8144ECC(u8 data, u8 taskIdA); static void sub_81450AC(u8 taskIdA); void sub_8145128(u16, u16, u16); -void sub_81452D0(u16 arg0, u16 arg1); +static void sub_81452D0(u16 arg0, u16 arg1); static void spritecb_player_8145378(struct Sprite *sprite); static void spritecb_rival_8145420(struct Sprite *sprite); u8 sub_81456B4(u16 nationalNum, u16 x, u16 y, u16 arg3); @@ -339,9 +324,9 @@ void sub_81439D0(void) { sub_81458DC(); - c000->var_88 = 0; - c000->var_8A = 0; - c000->var_8C = 0; + c000->unk88 = 0; + c000->unk8A = 0; + c000->unk8C = 0; gUnknown_02039322 = taskIdA; } @@ -455,7 +440,7 @@ void task_a_8143D04(u8 taskIdA) HALL_OF_FAME_SHEET_1[i] = 0x22; for (i = 0; i < 0x800; i++) HALL_OF_FAME_SHEET_2[i] = 0x33; - + EWRAM_1F800[0] = 0; EWRAM_1F800[1] = 0x53FF; // light yellow EWRAM_1F800[2] = 0x529F; // light red @@ -810,36 +795,25 @@ static u8 sub_8144454(u8 page, u8 taskIdA) { #define UNK_DEFINE_44 (0x44) -struct UnknownStruct -{ - u16 unk0[0x44]; - u16 unk88; - u16 unk8A; - u16 unk8C; - u16 unk8E; -}; - -#define EWRAM_1C000 (*(struct UnknownStruct *)(unk_2000000 + 0x1C000)) +#define EWRAM_1C000 (*(struct Unk201C000 *)(unk_2000000 + 0x1C000)) -extern void task_a_8143B68(u8); - -void task_d_8144514(u8 taskId) +static void task_d_8144514(u8 taskIdD) { - struct UnknownStruct *r6 = &EWRAM_1C000; + struct Unk201C000 *r6 = &EWRAM_1C000; u8 r2; - - switch (gTasks[taskId].data[TDD_STATE]) + + switch (gTasks[taskIdD].data[TDD_STATE]) { case 0: break; case 1: - if (r6->unk8A == 0 && gTasks[gTasks[taskId].data[TDD_TASK_A_ID]].data[14] == 0) + if (r6->unk8A == 0 && gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] == 0) break; - gTasks[gTasks[taskId].data[TDD_TASK_A_ID]].data[TDA_14] = 0; - gTasks[taskId].data[TDD_STATE]++; + gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].data[TDA_14] = 0; + gTasks[taskIdD].data[TDD_STATE]++; break; case 2: - if (r6->unk88 == 68 || gTasks[gTasks[taskId].data[TDD_TASK_A_ID]].func != task_a_8143B68) + if (r6->unk88 == UNK_DEFINE_44 || gTasks[gTasks[taskIdD].data[TDD_TASK_A_ID]].func != task_a_8143B68) break; r2 = sub_81456B4(r6->unk0[r6->unk8C], gUnknown_0840CA00[r6->unk8A][0], gUnknown_0840CA00[r6->unk8A][1], r6->unk8A); if (r6->unk8C < r6->unk8E - 1) @@ -857,14 +831,14 @@ void task_d_8144514(u8 taskId) r6->unk8A = 0; else r6->unk8A++; - gTasks[taskId].data[TDD_3] = 50; - gTasks[taskId].data[TDD_STATE]++; + gTasks[taskIdD].data[TDD_3] = 50; + gTasks[taskIdD].data[TDD_STATE]++; break; case 3: - if (gTasks[taskId].data[TDD_3] != 0) - gTasks[taskId].data[TDD_3]--; + if (gTasks[taskIdD].data[TDD_3] != 0) + gTasks[taskIdD].data[TDD_3]--; else - gTasks[taskId].data[TDD_STATE] = 1; + gTasks[taskIdD].data[TDD_STATE] = 1; break; } } @@ -1658,15 +1632,15 @@ _0814528C:\n\ .syntax divided\n"); } -void sub_81452D0(u16 arg0, u16 arg1) +static void sub_81452D0(u16 arg0, u16 arg1) { u16 i; u16 foo = arg1 / 16; u16 bar = foo * 4096; - + for (i = 0; i < 0x400; i ++) ((u16 *)(VRAM + arg0))[i] = bar + 1; - + sub_814524C(&gUnknown_0840B83C, 3, 7, arg0, arg1); sub_814524C(&gUnknown_0840B84B, 7, 7, arg0, arg1); sub_814524C(&gUnknown_0840B85A, 11, 7, arg0, arg1); diff --git a/src/decompress.c b/src/decompress.c index 8f573fecb..5906491c6 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -1,7 +1,8 @@ #include "global.h" #include "decompress.h" -#include "species.h" #include "asm.h" +#include "species.h" +#include "text.h" #define WRAM 0x02000000 @@ -22,7 +23,7 @@ void LZDecompressVram(const void *src, void *dest) void LoadCompressedObjectPic(const struct SpriteSheet *a) { struct SpriteSheet spriteSheet; - + LZ77UnCompWram(a->data, (void *)WRAM); spriteSheet.data = (void *)WRAM; spriteSheet.size = a->size; @@ -33,7 +34,7 @@ void LoadCompressedObjectPic(const struct SpriteSheet *a) void LoadCompressedObjectPicOverrideBuffer(const struct SpriteSheet *a, void *buffer) { struct SpriteSheet spriteSheet; - + LZ77UnCompWram(a->data, buffer); spriteSheet.data = buffer; spriteSheet.size = a->size; @@ -44,7 +45,7 @@ void LoadCompressedObjectPicOverrideBuffer(const struct SpriteSheet *a, void *bu void LoadCompressedObjectPalette(const struct SpritePalette *a) { struct SpritePalette spritePalette; - + LZ77UnCompWram(a->data, (void *)WRAM); spritePalette.data = (void *)WRAM; spritePalette.tag = a->tag; @@ -54,7 +55,7 @@ void LoadCompressedObjectPalette(const struct SpritePalette *a) void LoadCompressedObjectPaletteOverrideBuffer(const struct SpritePalette *a, void *buffer) { struct SpritePalette spritePalette; - + LZ77UnCompWram(a->data, buffer); spritePalette.data = buffer; spritePalette.tag = a->tag; @@ -72,7 +73,7 @@ void DecompressPicFromTable_2(const struct SpriteSheet *a, u8 b, u8 c, void *d, void HandleLoadSpecialPokePic(const struct SpriteSheet *spriteSheet, u32 b, u32 c, u32 d, void *dest, s32 species, u32 g) { u32 frontOrBack; - + // gUnknown_081FAF4C appears to be a list of pointers to locations to store poke pics for back and front pic here. the first and third pointers are used for back while the others are used for front. if (dest == gUnknown_081FAF4C[0] || dest == gUnknown_081FAF4C[2]) frontOrBack = 0; // backPic @@ -85,11 +86,11 @@ void HandleLoadSpecialPokePic(const struct SpriteSheet *spriteSheet, u32 b, u32 void LoadSpecialPokePic(const struct SpriteSheet *spriteSheet, u32 b, u32 c, u32 d, void *dest, s32 species, u32 g, u32 frontOrBack) { u8 frontOrBack8 = frontOrBack; - + if (species == SPECIES_UNOWN) { u16 i = (((g & 0x3000000) >> 18) | ((g & 0x30000) >> 12) | ((g & 0x300) >> 6) | (g & 3)) % 0x1C; - + // if it is Unown A, set the index to where Unown begins, otherwise add the egg index to get the correct letter to load. if (i == 0) i = SPECIES_UNOWN; diff --git a/src/dewford_trend.c b/src/dewford_trend.c index ffc98d488..f302e0599 100644 --- a/src/dewford_trend.c +++ b/src/dewford_trend.c @@ -1,8 +1,9 @@ #include "global.h" #include "asm.h" +#include "event_data.h" #include "link.h" #include "rng.h" -#include "event_data.h" +#include "text.h" extern u8 unk_2000000[]; diff --git a/src/diploma.c b/src/diploma.c index 8fabe3a2f..cab528bec 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -13,7 +13,6 @@ extern u8 gDiplomaTiles[]; extern u8 gDiplomaTilemap[]; extern u8 gDiplomaPalettes[]; -extern u8 gStringVar1[]; extern u8 gOtherText_NationalDex[]; extern u8 gOtherText_HoennDex[]; extern u8 gOtherText_DiplomaCertificationGameFreak[]; @@ -35,9 +34,9 @@ static void VBlankCB(void) void sub_8145D88(void) { u32 savedIme; - + SetVBlankCallback(NULL); - + REG_DISPCNT = 0; REG_BG3CNT = 0; REG_BG2CNT = 0; @@ -51,14 +50,14 @@ void sub_8145D88(void) REG_BG1VOFS = 0; REG_BG0HOFS = 0; REG_BG0VOFS = 0; - + DmaFill16(3, 0, VRAM, VRAM_SIZE); DmaFill32(3, 0, OAM, OAM_SIZE); DmaFill16(3, 0, PLTT, PLTT_SIZE); - + LZ77UnCompVram(gDiplomaTiles, (void *)VRAM); LZ77UnCompVram(gDiplomaTilemap, (void *)(VRAM + 0x3000)); - + remove_some_task(); ResetTasks(); ResetSpriteData(); @@ -69,22 +68,22 @@ void sub_8145D88(void) InitMenuWindow(&gWindowConfig_81E6CE4); DisplayDiplomaText(); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - + savedIme = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; REG_IME = savedIme; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - + SetVBlankCallback(VBlankCB); SetMainCallback2(MainCB2); - + REG_BLDCNT = 0; REG_BLDALPHA = 0; REG_BLDY = 0; REG_BG3CNT = 0x4603; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; - + CreateTask(Task_DiplomaFadeIn, 0); } diff --git a/src/field_camera.c b/src/field_camera.c index c55d8e2a3..72dcbd721 100644 --- a/src/field_camera.c +++ b/src/field_camera.c @@ -1,14 +1,12 @@ #include "global.h" #include "field_camera.h" #include "asm.h" +#include "asm_fieldmap.h" #include "berry.h" #include "field_player_avatar.h" -#include "asm_fieldmap.h" #include "sprite.h" #include "text.h" -extern u16 gBGTilemapBuffers[4][0x400]; - extern u8 gUnknown_0202E854; @@ -91,7 +89,7 @@ void sub_8057A58(void) *gBGVOffsetRegs[2] = gUnknown_03000590.unk1 + gUnknown_0300059A + 8; *gBGHOffsetRegs[3] = gUnknown_03000590.unk0 + gUnknown_03000598; *gBGVOffsetRegs[3] = gUnknown_03000590.unk1 + gUnknown_0300059A + 8; - + if(gUnknown_03000590.unk4) { DmaCopy16(3, gBGTilemapBuffers[1], (void *)(VRAM + 0xE800), 0x800); @@ -119,7 +117,7 @@ static void DrawWholeMapViewInternal(int x, int y, struct MapData *mapData) u8 j; u32 r6; u8 temp; - + for(i = 0; i < 32; i += 2) { temp = gUnknown_03000590.unk3 + i; @@ -139,7 +137,7 @@ static void DrawWholeMapViewInternal(int x, int y, struct MapData *mapData) static void RedrawMapSlicesForCameraUpdate(struct UnknownStruct *a, int x, int y) { struct MapData *mapData = gMapHeader.mapData; - + if(x > 0) RedrawMapSliceWest(a, mapData); if(x < 0) @@ -156,7 +154,7 @@ static void RedrawMapSliceNorth(struct UnknownStruct *a, struct MapData *mapData u8 i; u8 temp; u32 r7; - + temp = a->unk3 + 28; if(temp >= 32) temp -= 32; @@ -175,7 +173,7 @@ static void RedrawMapSliceSouth(struct UnknownStruct *a, struct MapData *mapData u8 i; u8 temp; u32 r7 = a->unk3 * 32; - + for(i = 0; i < 32; i += 2) { temp = a->unk2 + i; @@ -190,7 +188,7 @@ static void RedrawMapSliceEast(struct UnknownStruct *a, struct MapData *mapData) u8 i; u8 temp; u32 r6 = a->unk2; - + for(i = 0; i < 32; i += 2) { temp = a->unk3 + i; @@ -205,7 +203,7 @@ static void RedrawMapSliceWest(struct UnknownStruct *a, struct MapData *mapData) u8 i; u8 temp; u8 r5 = a->unk2 + 28; - + if(r5 >= 32) r5 -= 32; for(i = 0; i < 32; i += 2) @@ -220,7 +218,7 @@ static void RedrawMapSliceWest(struct UnknownStruct *a, struct MapData *mapData) void CurrentMapDrawMetatileAt(int a, int b) { int offset = MapPosToBgTilemapOffset(&gUnknown_03000590, a, b); - + if(offset >= 0) { DrawMetatileAt(gMapHeader.mapData, offset, a, b); @@ -231,7 +229,7 @@ void CurrentMapDrawMetatileAt(int a, int b) void DrawDoorMetatileAt(int x, int y, u16 *arr) { int offset = MapPosToBgTilemapOffset(&gUnknown_03000590, x, y); - + if(offset >= 0) { DrawMetatile(1, arr, offset); @@ -243,7 +241,7 @@ static void DrawMetatileAt(struct MapData *mapData, u16 b, int c, int d) { u16 metatileId = MapGridGetMetatileIdAt(c, d); u16 *metatiles; - + if(metatileId > 1024) metatileId = 0; if(metatileId < 512) @@ -265,12 +263,12 @@ static void DrawMetatile(s32 a, u16 *b, u16 c) gBGTilemapBuffers[3][c + 1] = b[1]; gBGTilemapBuffers[3][c + 0x20] = b[2]; gBGTilemapBuffers[3][c + 0x21] = b[3]; - + gBGTilemapBuffers[2][c] = 0; gBGTilemapBuffers[2][c + 1] = 0; gBGTilemapBuffers[2][c + 0x20] = 0; gBGTilemapBuffers[2][c + 0x21] = 0; - + gBGTilemapBuffers[1][c] = b[4]; gBGTilemapBuffers[1][c + 1] = b[5]; gBGTilemapBuffers[1][c + 0x20] = b[6]; @@ -281,12 +279,12 @@ static void DrawMetatile(s32 a, u16 *b, u16 c) gBGTilemapBuffers[3][c + 1] = b[1]; gBGTilemapBuffers[3][c + 0x20] = b[2]; gBGTilemapBuffers[3][c + 0x21] = b[3]; - + gBGTilemapBuffers[2][c] = b[4]; gBGTilemapBuffers[2][c + 1] = b[5]; gBGTilemapBuffers[2][c + 0x20] = b[6]; gBGTilemapBuffers[2][c + 0x21] = b[7]; - + gBGTilemapBuffers[1][c] = 0; gBGTilemapBuffers[1][c + 1] = 0; gBGTilemapBuffers[1][c + 0x20] = 0; @@ -297,12 +295,12 @@ static void DrawMetatile(s32 a, u16 *b, u16 c) gBGTilemapBuffers[3][c + 1] = 0x3014; gBGTilemapBuffers[3][c + 0x20] = 0x3014; gBGTilemapBuffers[3][c + 0x21] = 0x3014; - + gBGTilemapBuffers[2][c] = b[0]; gBGTilemapBuffers[2][c + 1] = b[1]; gBGTilemapBuffers[2][c + 0x20] = b[2]; gBGTilemapBuffers[2][c + 0x21] = b[3]; - + gBGTilemapBuffers[1][c] = b[4]; gBGTilemapBuffers[1][c + 1] = b[5]; gBGTilemapBuffers[1][c + 0x20] = b[6]; @@ -320,14 +318,14 @@ static s32 MapPosToBgTilemapOffset(struct UnknownStruct *a, s32 x, s32 y) x = x + a->unk2; if(x >= 32) x -= 32; - + y = (y - gSaveBlock1.pos.y) * 2; if(y >= 32 || y < 0) return -1; y = y + a->unk3; if(y >= 32) y -= 32; - + return y * 32 + x; } @@ -367,7 +365,7 @@ void CameraUpdate(void) int r1; int r7; int r8; - + if(gUnknown_03004880.callback != NULL) gUnknown_03004880.callback(&gUnknown_03004880); r7 = gUnknown_03004880.unk8; @@ -376,8 +374,8 @@ void CameraUpdate(void) deltaY = 0; r1 = gUnknown_03004880.unk10; r0 = gUnknown_03004880.unk14; - - + + if(r1 == 0 && r7 != 0) { if(r7 > 0) @@ -406,12 +404,12 @@ void CameraUpdate(void) else deltaX = -1; } - + gUnknown_03004880.unk10 += r7; - gUnknown_03004880.unk10 = gUnknown_03004880.unk10 - 16 * (gUnknown_03004880.unk10 / 16); + gUnknown_03004880.unk10 = gUnknown_03004880.unk10 - 16 * (gUnknown_03004880.unk10 / 16); gUnknown_03004880.unk14 += r8; gUnknown_03004880.unk14 = gUnknown_03004880.unk14 - 16 * (gUnknown_03004880.unk14 / 16); - + if(deltaX != 0 || deltaY != 0) { CameraMove(deltaX, deltaY); @@ -421,7 +419,7 @@ void CameraUpdate(void) tilemap_move_something(&gUnknown_03000590, deltaX * 2, deltaY * 2); RedrawMapSlicesForCameraUpdate(&gUnknown_03000590, deltaX * 2, deltaY * 2); } - + coords8_add(&gUnknown_03000590, r7, r8); gUnknown_0300489C -= r7; gUnknown_03004898 -= r8; @@ -467,7 +465,7 @@ void UpdateCameraPanning(void) static void CameraPanningCB_PanAhead(void) { u8 var; - + if (gUnknown_0202E854 == 0) { InstallCameraPanAheadCallback(); @@ -484,7 +482,7 @@ static void CameraPanningCB_PanAhead(void) { gUnknown_0300059C = 0; } - + var = player_get_direction_upper_nybble(); if (var == 2) { diff --git a/src/field_door.c b/src/field_door.c index 85a5965a0..f527681ac 100644 --- a/src/field_door.c +++ b/src/field_door.c @@ -1,8 +1,8 @@ #include "global.h" #include "asm.h" -#include "task.h" #include "field_camera.h" #include "metatile_behavior.h" +#include "task.h" struct DoorGraphics { @@ -31,7 +31,7 @@ static void door_build_blockdef(u16 *a, u16 b, u8 *c) { int i; u16 unk; - + for (i = 0; i < 4; i++) { unk = *(c++) << 12; @@ -47,7 +47,7 @@ static void door_build_blockdef(u16 *a, u16 b, u8 *c) static void DrawCurrentDoorAnimFrame(u32 x, u32 y, u8 *c) { u16 arr[8]; - + door_build_blockdef(arr, 0x3F8, c); DrawDoorMetatileAt(x, y - 1, arr); door_build_blockdef(arr, 0x3FC, c + 4); @@ -103,7 +103,7 @@ static void Task_AnimateDoor(u8 taskId) u16 *taskData = gTasks[taskId].data; struct DoorAnimFrame *frames = (struct DoorAnimFrame *)(taskData[TD_FRAMELIST] << 16 | taskData[TD_FRAMELIST + 1]); struct DoorGraphics *gfx = (struct DoorGraphics *)(taskData[TD_GFX] << 16 | taskData[TD_GFX + 1]); - + if (sub_8058464(gfx, frames, taskData) == FALSE) DestroyTask(taskId); } @@ -134,16 +134,16 @@ static s8 StartDoorAnimationTask(struct DoorGraphics *gfx, struct DoorAnimFrame { u8 taskId = CreateTask(Task_AnimateDoor, 0x50); s16 *taskData = gTasks[taskId].data; - + taskData[TD_X] = x; taskData[TD_Y] = y; - + taskData[TD_FRAMELIST + 1] = (u32)frames; taskData[TD_FRAMELIST] = (u32)frames >> 16; - + taskData[TD_GFX + 1] = (u32)gfx; taskData[TD_GFX] = (u32)gfx >> 16; - + return taskId; } } diff --git a/src/field_effect.c b/src/field_effect.c index fe586fcb6..b0c028c8d 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -1,7 +1,8 @@ #include "global.h" #include "field_effect.h" -#include "weather.h" #include "sprite.h" +#include "text.h" +#include "weather.h" typedef bool8 (*FldEffCmd)(u8 **, u32 *); diff --git a/src/field_map_obj_helpers.c b/src/field_map_obj_helpers.c index 6e835d744..815a5aabd 100644 --- a/src/field_map_obj_helpers.c +++ b/src/field_map_obj_helpers.c @@ -1,8 +1,8 @@ #include "global.h" #include "asm.h" -#include "sprite.h" #include "asm_fieldmap.h" #include "field_effect.h" +#include "sprite.h" typedef void (*SpriteStepFunc)(struct Sprite *sprite, u8 dir); diff --git a/src/field_message_box.c b/src/field_message_box.c index a7d1a2fd8..2a5f90d15 100644 --- a/src/field_message_box.c +++ b/src/field_message_box.c @@ -1,9 +1,9 @@ #include "global.h" +#include "field_message_box.h" +#include "string_util.h" +#include "task.h" #include "text.h" #include "text_window.h" -#include "task.h" -#include "string_util.h" -#include "field_message_box.h" extern struct Window gFieldMessageBoxWindow; extern u16 gMenuTextWindowContentTileOffset; diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index fdd5ae5c5..79f1b67e9 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -1,20 +1,20 @@ #include "global.h" #include "field_player_avatar.h" #include "asm.h" -#include "field_map_obj.h" -#include "rom4.h" +#include "asm_fieldmap.h" #include "event_data.h" +#include "field_effect.h" +#include "field_map_obj.h" #include "main.h" #include "menu.h" +#include "metatile_behavior.h" #include "rng.h" +#include "rom4.h" #include "script.h" #include "songs.h" #include "sound.h" #include "task.h" -#include "field_effect.h" #include "wild_encounter.h" -#include "asm_fieldmap.h" -#include "metatile_behavior.h" extern u8 gOtherText_OhABite[]; extern u8 gOtherText_PokeOnHook[]; @@ -92,7 +92,7 @@ static u32 sub_80587D8(void) void player_step(u8 a, u16 b, u16 c) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + sub_8059D60(playerMapObj); if (gPlayerAvatar.unk6 == 0) { @@ -116,7 +116,7 @@ static bool8 sub_8058854(struct MapObject *a, u8 b) && !FieldObjectClearAnimIfSpecialAnimFinished(a)) { u8 specialAnim = FieldObjectGetSpecialAnim(a); - + if (specialAnim > 24 && specialAnim < 29 && b != 0 && a->placeholder18 != b) { FieldObjectClearAnim(a); @@ -161,11 +161,11 @@ static u8 TryDoMetatileBehaviorForcedMovement(void) static u8 GetForcedMovementByMetatileBehavior(void) { u8 i; - + if (!(gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_5)) { u8 r5 = gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E; - + for (i = 0; i < 18; i++) { if (gUnknown_0830FB58[i](r5)) @@ -180,7 +180,7 @@ u8 ForcedMovement_None(void) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_6) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + playerMapObj->mapobj_bit_9 = 0; playerMapObj->mapobj_bit_11 = 1; FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18); @@ -193,7 +193,7 @@ static u8 DoForcedMovement(u8 a, void (*b)(u8)) { struct PlayerAvatar *playerAvatar = &gPlayerAvatar; u8 r7 = CheckForPlayerAvatarCollision(a); - + playerAvatar->flags |= PLAYER_AVATAR_FLAG_6; if (r7 != 0) { @@ -222,7 +222,7 @@ static u8 DoForcedMovement(u8 a, void (*b)(u8)) static u8 DoForcedMovementInCurrentDirection(void (*a)(u8)) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + playerMapObj->mapobj_bit_10 = 1; return DoForcedMovement(playerMapObj->placeholder18, a); } @@ -275,7 +275,7 @@ u8 sub_8058B54(void) static u8 ForcedMovement_Slide(u8 a, void (*b)(u8)) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + playerMapObj->mapobj_bit_10 = 1; playerMapObj->mapobj_bit_9 = 1; return DoForcedMovement(a, b); @@ -316,7 +316,7 @@ u8 sub_8058C10(void) u8 ForcedMovement_MuddySlope(void) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + if (playerMapObj->placeholder18 != 2 || sub_80E6034() <= 3) { sub_80E6010(0); @@ -366,7 +366,7 @@ void PlayerNotOnBikeTurningInPlace(u8 a, u16 b) void sub_8058D0C(u8 a, u16 b) { u8 r1 = CheckForPlayerAvatarCollision(a); - + switch (r1) { case 6: @@ -399,7 +399,7 @@ static u8 CheckForPlayerAvatarCollision(u8 a) { s16 x, y; struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + x = playerMapObj->coords2.x; y = playerMapObj->coords2.y; MoveCoords(a, &x, &y); @@ -409,7 +409,7 @@ static u8 CheckForPlayerAvatarCollision(u8 a) u8 CheckForFieldObjectCollision(struct MapObject *a, s16 b, s16 c, u8 d, u8 e) { u8 sp0; - + sp0 = npc_block_way(a, b, c, d); if (sp0 == 3 && sub_8058EF0(b, c, d)) return 5; @@ -420,7 +420,7 @@ u8 CheckForFieldObjectCollision(struct MapObject *a, s16 b, s16 c, u8 d, u8 e) } if (sp0 == 4 && sub_8058F6C(b, c, d)) return 7; - + if (sp0 == 0) { if (CheckForRotatingGatePuzzleCollision(d, b, c)) @@ -458,7 +458,7 @@ static u8 sub_8058F6C(s16 a, s16 b, u8 c) if (FlagGet(SYS_USE_STRENGTH)) { u8 mapObjectId = GetFieldObjectIdByXY(a, b); - + if (mapObjectId != 16) { if (gMapObjects[mapObjectId].graphicsId == 0x57) @@ -481,7 +481,7 @@ static u8 sub_8058F6C(s16 a, s16 b, u8 c) static void check_acro_bike_metatile(int unused1, int unused2, u8 c, u8 *d) { u8 i; - + for (i = 0; i < 5; i++) { if (gUnknown_0830FBF8[i](c)) @@ -502,7 +502,7 @@ static void DoPlayerAvatarTransition(void) { u8 i; u32 flags = gPlayerAvatar.bike; - + if (flags != 0) { for (i = 0; i < 8; i++, flags >>= 1) @@ -555,7 +555,7 @@ void PlayerAvatarTransition_AcroBike(struct MapObject *a) void PlayerAvatarTransition_Surfing(struct MapObject *a) { u8 unk; - + sub_805B980(a, GetPlayerAvatarGraphicsIdByStateId(3)); FieldObjectTurn(a, a->placeholder18); SetPlayerAvatarStateMask(8); @@ -601,7 +601,7 @@ void sub_8059204(void) static bool8 player_is_anim_in_certain_ranges(void) { u8 unk = gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1C; - + if (unk < 4 || (unk >= 16 && unk < 0x15) || (unk >= 25 && unk < 41) @@ -780,7 +780,7 @@ static void PlayCollisionSoundIfNotFacingWarp(u8 a) { s16 x, y; u8 unk = gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1E; - + if (!gUnknown_0830FC34[a - 1](unk)) { if (a == 2) @@ -850,7 +850,7 @@ void sub_80597E8(void) void sub_80597F4(void) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + npc_clear_strange_bits(playerMapObj); FieldObjectSetDirection(playerMapObj, playerMapObj->mapobj_unk_18); if (TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_MACH_BIKE | PLAYER_AVATAR_FLAG_ACRO_BIKE)) @@ -914,7 +914,7 @@ u8 GetPlayerAvatarGenderByGraphicsId(u8 a) bool8 PartyHasMonWithSurf(void) { u8 i; - + if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_SURFING)) { for (i = 0; i < 6; i++) @@ -941,7 +941,7 @@ bool8 IsPlayerFacingSurfableFishableWater(void) struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; s16 x = playerMapObj->coords2.x; s16 y = playerMapObj->coords2.y; - + MoveCoords(playerMapObj->mapobj_unk_18, &x, &y); if (npc_block_way(playerMapObj, x, y, playerMapObj->mapobj_unk_18) == 3 && PlayerGetZCoord() == 3 && MetatileBehavior_IsSurfableFishableWater(MapGridGetMetatileBehaviorAt(x, y))) @@ -965,7 +965,7 @@ void SetPlayerAvatarStateMask(u8 a) static u8 GetPlayerAvatarStateTransitionByGraphicsId(u8 a, u8 gender) { u8 i; - + for (i = 0; i < 5; i++) { if (gUnknown_0830FC64[gender][i][0] == a) @@ -978,7 +978,7 @@ u8 GetPlayerAvatarGraphicsIdByCurrentState(void) { u8 i; u8 r5 = gPlayerAvatar.flags; - + for (i = 0; i < 5; i++) { if (gUnknown_0830FC64[gPlayerAvatar.gender][i][1] & r5) @@ -990,7 +990,7 @@ u8 GetPlayerAvatarGraphicsIdByCurrentState(void) void SetPlayerAvatarExtraStateTransition(u8 a, u8 b) { u8 unk = GetPlayerAvatarStateTransitionByGraphicsId(a, gPlayerAvatar.gender); - + gPlayerAvatar.bike |= unk | b; DoPlayerAvatarTransition(); } @@ -1000,7 +1000,7 @@ void InitPlayerAvatar(s16 a, s16 b, u8 c, u8 d) struct UnknownStruct_FPA s; u8 mapObjectId; struct MapObject *mapObject; - + s.unk0 = 0xFF; s.unk1 = GetPlayerAvatarGraphicsIdByStateIdAndGender(0, d); s.unk4 = a - 7; @@ -1065,7 +1065,7 @@ static void sub_8059D60(struct MapObject *a) s16 y; u8 r6; u8 r8 = a->mapobj_unk_1E; - + for (x = 0, r6 = 1; x < 4; x++, r6++) { if (gUnknown_0830FC78[x](r8) && r6 == a->placeholder18) @@ -1087,7 +1087,7 @@ static void sub_8059E2C(u8 taskId); static void StartStrengthAnim(u8 a, u8 b) { u8 taskId = CreateTask(sub_8059E2C, 0xFF); - + gTasks[taskId].data[1] = a; gTasks[taskId].data[2] = b; sub_8059E2C(taskId); @@ -1150,7 +1150,7 @@ static void sub_8059FB4(u8 taskId); static void sub_8059F94(void) { u8 taskId = CreateTask(sub_8059FB4, 0xFF); - + sub_8059FB4(taskId); } @@ -1185,7 +1185,7 @@ static void sub_805A08C(u8 taskId); static void sub_805A06C(void) { u8 taskId = CreateTask(sub_805A08C, 0xFF); - + sub_805A08C(taskId); } @@ -1208,12 +1208,12 @@ u8 sub_805A0D8(struct Task *task, struct MapObject *mapObject) u8 sub_805A100(struct Task *task, struct MapObject *mapObject) { u8 directions[4]; - + memcpy(directions, gUnknown_0830FCA8, sizeof(directions)); if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) { u8 direction; - + FieldObjectSetSpecialAnim(mapObject, GetFaceDirectionAnimId(direction = directions[mapObject->placeholder18 - 1])); if (direction == (u8)task->data[1]) task->data[2]++; @@ -1227,7 +1227,7 @@ u8 sub_805A100(struct Task *task, struct MapObject *mapObject) u8 sub_805A178(struct Task *task, struct MapObject *mapObject) { u8 arr[5]; - + memcpy(arr, gUnknown_0830FCAC, sizeof(arr)); if (FieldObjectClearAnimIfSpecialAnimFinished(mapObject)) { @@ -1257,7 +1257,7 @@ static void sub_805A2D0(u8 taskId); void sub_805A20C(u8 a) { u8 taskId; - + ScriptContext2_Enable(); sav1_reset_battle_music_maybe(); sub_8053F84(); @@ -1272,7 +1272,7 @@ void sub_805A20C(u8 a) static void taskFF_0805D1D4(u8 taskId) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + if (FieldObjectIsSpecialAnimOrDirectionSequenceAnimActive(playerMapObj)) { if (!FieldObjectClearAnimIfSpecialAnimFinished(playerMapObj)) @@ -1286,7 +1286,7 @@ static void taskFF_0805D1D4(u8 taskId) static void sub_805A2D0(u8 taskId) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + if (FieldObjectClearAnimIfSpecialAnimFinished(playerMapObj)) { sub_805B980(playerMapObj, GetPlayerAvatarGraphicsIdByStateId(0)); @@ -1306,7 +1306,7 @@ static void sub_805A954(void); void StartFishing(u8 a) { u8 taskId = CreateTask(Task_Fishing, 0xFF); - + gTasks[taskId].data[15] = a; Task_Fishing(taskId); } @@ -1330,7 +1330,7 @@ u8 Fishing2(struct Task *task) s16 arr1[3]; s16 arr2[3]; struct MapObject *playerMapObj; - + memcpy(arr1, gUnknown_0830FCF4, sizeof(arr1)); memcpy(arr2, gUnknown_0830FCFA, sizeof(arr2)); task->data[12] = 0; @@ -1356,7 +1356,7 @@ u8 Fishing3(struct Task *task) u8 Fishing4(struct Task *task) { u32 randVal; - + MenuDisplayMessageBox(); task->data[0]++; task->data[1] = 0; @@ -1374,7 +1374,7 @@ u8 Fishing4(struct Task *task) u8 Fishing5(struct Task *task) { u8 dot[2]; - + memcpy(dot, gUnknown_0830FD00, sizeof(dot)); sub_805A954(); task->data[1]++; @@ -1430,7 +1430,7 @@ u8 Fishing7(struct Task *task) u8 Fishing8(struct Task *task) { s16 arr[3]; - + memcpy(arr, gUnknown_0830FD02, sizeof(arr)); sub_805A954(); task->data[1]++; @@ -1444,7 +1444,7 @@ u8 Fishing8(struct Task *task) u8 Fishing9(struct Task *task) { s16 arr[3][2]; - + memcpy(arr, gUnknown_0830FD08, sizeof(arr)); sub_805A954(); task->data[0]++; @@ -1455,7 +1455,7 @@ u8 Fishing9(struct Task *task) else if (task->data[12] < 2) { s16 randVal = Random() % 100; - + if (arr[task->data[15]][task->data[12]] > randVal) task->data[0] = 3; } @@ -1482,7 +1482,7 @@ u8 Fishing11(struct Task *task) if (MenuUpdateWindowText()) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + sub_805B980(playerMapObj, task->data[14]); FieldObjectTurn(playerMapObj, playerMapObj->placeholder18); if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) @@ -1540,7 +1540,7 @@ u8 Fishing15(struct Task *task) if (gSprites[gPlayerAvatar.spriteId].animEnded) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; - + sub_805B980(playerMapObj, task->data[14]); FieldObjectTurn(playerMapObj, playerMapObj->placeholder18); if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) @@ -1571,7 +1571,7 @@ static void sub_805A954(void) struct Sprite *playerSprite = &gSprites[gPlayerAvatar.spriteId]; u8 animCmdIndex; u8 animType; - + AnimateSprite(playerSprite); playerSprite->pos2.x = 0; playerSprite->pos2.y = 0; diff --git a/src/field_poison.c b/src/field_poison.c index 6a243c280..dff5abd31 100644 --- a/src/field_poison.c +++ b/src/field_poison.c @@ -5,6 +5,7 @@ #include "script.h" #include "string_util.h" #include "task.h" +#include "text.h" extern struct Pokemon gPlayerParty[6]; extern u16 gScriptResult; @@ -14,7 +15,7 @@ bool32 CheckMonIsValid(struct Pokemon *pkmn) { // UB: Too few arguments for function 'GetMonData' u16 species2 = GetMonData(pkmn, MON_DATA_SPECIES2); - + if (species2 == 0 || species2 == 0x19C) return FALSE; else @@ -25,7 +26,7 @@ bool32 AllMonsFainted(void) { struct Pokemon *pkmn = &gPlayerParty[0]; int i; - + for (i = 0; i < 6; i++, pkmn++) { // UB: Too few arguments for function 'GetMonData' @@ -39,7 +40,7 @@ void MonFaintFromPoisonOnField(u8 partyMember) { struct Pokemon *pkmn = &gPlayerParty[partyMember]; u32 val = 0; - + AdjustFriendship(pkmn, 7); SetMonData(pkmn, MON_DATA_STATUS, (u8*)&val); GetMonData(pkmn, MON_DATA_NICKNAME, gStringVar1); @@ -49,7 +50,7 @@ void MonFaintFromPoisonOnField(u8 partyMember) bool32 CheckMonFaintedFromPoison(u8 partyMember) { struct Pokemon *pkmn = &gPlayerParty[partyMember]; - + // UB: Too few arguments for function 'GetMonData' if (CheckMonIsValid(pkmn) && GetMonData(pkmn, MON_DATA_HP) == 0 && pokemon_ailments_get_primary(GetMonData(pkmn, MON_DATA_STATUS)) == 1) @@ -68,7 +69,7 @@ enum void Task_WhiteOut(u8 taskId) { s16 *taskData = gTasks[taskId].data; - + switch (taskData[TD_STATE]) { case 0: //Check if Pokemon have fainted due to poison @@ -112,11 +113,11 @@ s32 overworld_poison(void) u32 numPoisoned = 0; u32 numFainting = 0; int i; - + for(i = 0; i < 6; i++) { u32 hp; - + // UB: Too few arguments for function 'GetMonData' if (GetMonData(pkmn, MON_DATA_SANITY_BIT2) != 0 && pokemon_ailments_get_primary(GetMonData(pkmn, MON_DATA_STATUS)) == 1) diff --git a/src/field_special_scene.c b/src/field_special_scene.c index 80a1727d8..f90306bba 100644 --- a/src/field_special_scene.c +++ b/src/field_special_scene.c @@ -1,15 +1,15 @@ #include "global.h" #include "field_special_scene.h" #include "asm.h" +#include "event_data.h" +#include "field_camera.h" #include "palette.h" -#include "task.h" +#include "rom4.h" #include "script.h" #include "songs.h" #include "sound.h" -#include "field_camera.h" -#include "rom4.h" -#include "event_data.h" #include "sprite.h" +#include "task.h" extern s8 gTruckCamera_HorizontalTable[]; diff --git a/src/fieldmap.c b/src/fieldmap.c index 4dcfbe30b..841964f18 100644 --- a/src/fieldmap.c +++ b/src/fieldmap.c @@ -393,7 +393,7 @@ void MapGridSetMetatileIdAt(int x, int y, u16 metatile) { if (x >= 0 && x < gUnknown_03004870.width && y >= 0 && y < gUnknown_03004870.height) { i = x + y * gUnknown_03004870.width; - gUnknown_03004870.map[i] = (gUnknown_03004870.map[i] & 0xf000) | (metatile & 0xfff); + gUnknown_03004870.map[i] = (gUnknown_03004870.map[i] & 0xf000) | (metatile & 0xfff); } } diff --git a/src/fldeff_strength.c b/src/fldeff_strength.c index 4da04326a..dedb62a90 100644 --- a/src/fldeff_strength.c +++ b/src/fldeff_strength.c @@ -1,9 +1,10 @@ #include "global.h" -#include "field_effect.h" #include "asm.h" +#include "field_effect.h" #include "pokemon.h" #include "script.h" #include "task.h" +#include "text.h" static void sub_811AA18(void); static void sub_811AA38(void); diff --git a/src/fldeff_teleport.c b/src/fldeff_teleport.c index 906832766..afa5ea997 100644 --- a/src/fldeff_teleport.c +++ b/src/fldeff_teleport.c @@ -1,8 +1,8 @@ #include "global.h" -#include "field_effect.h" -#include "rom4.h" #include "asm.h" +#include "field_effect.h" #include "field_player_avatar.h" +#include "rom4.h" extern void sub_8087BA8(void); diff --git a/src/heal_location.c b/src/heal_location.c index 13bb125b6..73d6ef65a 100644 --- a/src/heal_location.c +++ b/src/heal_location.c @@ -8,7 +8,7 @@ extern const struct HealLocation gHealLocations[]; u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum) { u32 i; - + for (i = 0; i < NUM_HEAL_LOCATIONS; i++) { if(gHealLocations[i].group == mapGroup && gHealLocations[i].map == mapNum) @@ -20,7 +20,7 @@ u32 GetHealLocationIndexByMap(u16 mapGroup, u16 mapNum) const struct HealLocation *GetHealLocationByMap(u16 mapGroup, u16 mapNum) { u32 index = GetHealLocationIndexByMap(mapGroup, mapNum); - + if (index == 0) return NULL; else diff --git a/src/intro.c b/src/intro.c index 544d8b64f..d72bc7609 100644 --- a/src/intro.c +++ b/src/intro.c @@ -1,21 +1,21 @@ #include "global.h" #include "intro.h" #include "asm.h" +#include "decompress.h" #include "gba/m4a_internal.h" -#include "m4a.h" #include "libgncmultiboot.h" -#include "save.h" -#include "decompress.h" -#include "title_screen.h" -#include "new_game.h" #include "link.h" +#include "m4a.h" #include "main.h" +#include "new_game.h" #include "palette.h" #include "rng.h" +#include "save.h" #include "songs.h" #include "sound.h" #include "species.h" #include "task.h" +#include "title_screen.h" #include "trig.h" extern void *species_and_otid_get_pal(/*TODO: arg types*/); @@ -323,19 +323,19 @@ static void Task_IntroWaterDrops(u8 taskId) //start moving rock if (gIntroFrameCounter == 76) gSprites[gTasks[taskId].data[0]].data0 = 1; - + //drop rock if (gIntroFrameCounter == 251) gSprites[gTasks[taskId].data[0]].data0 = 2; - + if (gIntroFrameCounter == 368) CreateWaterDrop(48, 0, 0x400, 5, 0x70, TRUE); if (gIntroFrameCounter == 384) CreateWaterDrop(200, 60, 0x400, 9, 0x80, TRUE); - + if (gIntroFrameCounter == 560) CreateGameFreakLogo(DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, CreateTask(sub_813CCE8, 0)); - + if (gIntroFrameCounter > 739) { gTasks[taskId].data[1] = 0x50; @@ -353,7 +353,7 @@ static void Task_IntroScrollDownAndShowEon(u8 taskId) if (gIntroFrameCounter < 904) { s32 r2; - + //slide backgrounds downward r2 = (gTasks[taskId].data[1] << 16) + (u16)gTasks[taskId].data[2] - 0xC000; gTasks[taskId].data[1] = r2 >> 16; @@ -367,12 +367,12 @@ static void Task_IntroScrollDownAndShowEon(u8 taskId) gTasks[taskId].data[5] = r2 >> 16; gTasks[taskId].data[6] = r2; REG_BG0VOFS = gTasks[taskId].data[5]; - + //show Lati@s sprite if (gIntroFrameCounter == 880) { u8 spriteId = CreateSprite(&gSpriteTemplate_840AFF0, 200, 160, 10); - + gSprites[spriteId].invisible = 1; } } @@ -412,7 +412,7 @@ static void Task_IntroLoadPart2Graphics(u8 taskId) static void Task_IntroStartBikeRide(u8 taskId) { u8 spriteId; - + if (gUnknown_02039318 == 0) LoadCompressedObjectPic(&gIntro2BrendanSpriteSheet); else @@ -454,7 +454,7 @@ static void Task_IntroHandleBikeAndEonMovement(u8 taskId) { s16 a; u16 sine; - + if (gIntroFrameCounter > 1823) { BeginNormalPaletteFade(0xFFFFFFFF, 16, 0, 16, 0xFFFF); @@ -472,7 +472,7 @@ static void Task_IntroHandleBikeAndEonMovement(u8 taskId) gSprites[gTasks[taskId].data[1]].data0 = 3; if (gIntroFrameCounter == 1727) gSprites[gTasks[taskId].data[1]].data0 = 4; - + //TODO: Clean this up a = (((u16)gTasks[taskId].data[3] << 16) >> 18) & 0x7F; sine = Sin(a, 48); @@ -545,7 +545,7 @@ static void Task_IntroLoadPart3Streaks(u8 taskId) { u16 i; void *vram; - + intro_reset_and_hide_bgs(); for (i = 0; i < 32; i++) { @@ -599,11 +599,11 @@ static void task_intro_14(u8 taskId) static void task_intro_15(u8 taskId) { u16 foo = gTasks[taskId].data[0]; - + if (gTasks[taskId].data[0] != 32) { u32 bar; //needed to match for some reason - + gTasks[taskId].data[0] += 4; REG_WIN0V = (gTasks[taskId].data[0] * 256) - (bar = foo - 0x9C); } @@ -628,7 +628,7 @@ static void task_intro_17(u8 taskId) static void Task_IntroPokemonBattle(u8 taskId) { u8 spriteId; - + if (gIntroFrameCounter == 80) { spriteId = sub_813CE88(SPECIES_SHARPEDO, 0xF0, 0xA0, 5, 1); @@ -834,7 +834,7 @@ static void sub_813CCE8(u8 taskId) { u32 foo; u32 bar asm("r2"); - + gTasks[taskId].data[1]--; //tail merge at _0813CDC2 foo = gTasks[taskId].data[1] + (gTasks[taskId].data[1] < 0); @@ -865,7 +865,7 @@ static void sub_813CCE8(u8 taskId) { u32 foo; u32 bar asm("r2"); - + gTasks[taskId].data[1]++; //_0813CDC2 foo = gTasks[taskId].data[1] + (gTasks[taskId].data[1] < 0); @@ -1077,7 +1077,7 @@ void sub_813CE30(u16 scrX, u16 scrY, u16 zoom, u16 alpha) { struct BgAffineSrcData src; struct BgAffineDstData dest; - + src.texX = 0x8000; src.texY = 0x8000; src.scrX = scrX; @@ -1098,7 +1098,7 @@ static u16 sub_813CE88(u16 species, s16 x, s16 y, u16 d, u8 front) { void *pal; u8 spriteId; - + if (front) LoadSpecialPokePic(&gMonFrontPicTable[species], gMonFrontPicCoords[species].x, gMonFrontPicCoords[species].y, 0x2000000, gUnknown_0840B5A0[d], species, 0, 1); else @@ -1115,7 +1115,7 @@ static u16 sub_813CE88(u16 species, s16 x, s16 y, u16 d, u8 front) static u8 sub_813CFA8(u16 a, u16 b, u16 c, u16 d) { u8 spriteId; - + DecompressPicFromTable_2(&gTrainerBackPicTable[a], gTrainerBackPicCoords[a].x, gTrainerBackPicCoords[a].y, (void *)0x2000000, gUnknown_0840B5A0[d], a); LoadCompressedPalette(gTrainerBackPicPaletteTable[a].data, 0x100 + d * 0x10, 0x20); sub_8143680(d, d); @@ -1129,7 +1129,7 @@ static u8 sub_813CFA8(u16 a, u16 b, u16 c, u16 d) static void sub_813D084(u8 a) { u16 color; - + switch (a) { default: @@ -1150,7 +1150,7 @@ static void sub_813D084(u8 a) void sub_813D0CC(struct Sprite *sprite) { u8 r0; - + if (sprite->data2 >= 192) { if (sprite->data3 != 0) @@ -1229,7 +1229,7 @@ void sub_813D220(struct Sprite *sprite) s16 var3; s16 var4; s16 temp; - + data4 = sprite->data4; sin1 = gSineTable[(u8)data4]; sin2 = gSineTable[(u8)(data4 + 64)]; @@ -1261,7 +1261,7 @@ void sub_813D368(struct Sprite *sprite) if (sprite->data4 != 64) { u16 data4; - + sprite->data4 -= 8; data4 = sprite->data4; sprite->pos2.x = gSineTable[(u8)(data4 + 64)] / 64; @@ -1279,7 +1279,7 @@ void sub_813D414(struct Sprite *sprite) if (sprite->data0 != 2) { s16 r2; - + sprite->data4 += 8; r2 = gSineTable[(u8)sprite->data4] / 16 + 64; sprite->pos2.x = gSineTable[(u8)(r2 + 64)] / 64; @@ -1340,7 +1340,7 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) { u8 spriteId; u8 oldSpriteId; - + spriteId = CreateSprite(&gSpriteTemplate_840AE20, x, y, 0); gSprites[spriteId].data0 = 0; gSprites[spriteId].data7 = 0; @@ -1358,7 +1358,7 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) else gSprites[spriteId].callback = SpriteCB_WaterDropFall_2; oldSpriteId = spriteId; - + spriteId = CreateSprite(&gSpriteTemplate_840AE20, x, y, 0); gSprites[spriteId].data7 = oldSpriteId; gSprites[spriteId].data1 = d + 1; @@ -1366,7 +1366,7 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) gSprites[spriteId].oam.matrixNum = d + 1; CalcCenterToCornerVec(&gSprites[spriteId], 0, 2, 2); gSprites[spriteId].callback = sub_813D158; - + spriteId = CreateSprite(&gSpriteTemplate_840AE20, x, y, 0); gSprites[spriteId].data7 = oldSpriteId; gSprites[spriteId].data1 = d + 2; @@ -1375,11 +1375,11 @@ static u8 CreateWaterDrop(s16 x, s16 y, u16 c, u16 d, u16 e, u8 fallImmediately) gSprites[spriteId].oam.matrixNum = d + 2; CalcCenterToCornerVec(&gSprites[spriteId], 0, 2, 2); gSprites[spriteId].callback = sub_813D158; - + SetOamMatrix(d, c + 32, 0, 0, c + 32); SetOamMatrix(d + 1, c + 32, 0, 0, c + 32); SetOamMatrix(d + 2, c + 32, 0, 0, 2 * (c + 32)); - + return oldSpriteId; } @@ -1482,7 +1482,7 @@ static u8 CreateGameFreakLogo(s16 a, s16 b, u8 c) { u8 spriteId; u16 i; - + for (i = 0; i < 9; i++) { spriteId = CreateSprite(&gSpriteTemplate_840AF94, gUnknown_0840AF50[i][1] + a, b - 4, 0); @@ -1497,7 +1497,7 @@ static u8 CreateGameFreakLogo(s16 a, s16 b, u8 c) } spriteId = CreateSprite(&gSpriteTemplate_840AFC4, 120, b - 4, 0); gSprites[spriteId].data0 = c; - + return spriteId; } @@ -1505,7 +1505,7 @@ static u8 CreateGameFreakLogo(s16 a, s16 b, u8 c) void sub_813DA64(struct Sprite *sprite) { sprite->data7++; - + switch(sprite->data0) { case 0: @@ -1527,7 +1527,7 @@ void sub_813DA64(struct Sprite *sprite) s16 foo; s16 r5; s16 r2; - + //_0813DAC0 if (sprite->data3 < 0x50) { @@ -1543,9 +1543,9 @@ void sub_813DA64(struct Sprite *sprite) foo = sin1 * sprite->data1 / 256; r5 = -r3 * sprite->data1 / 256; r2 = r3 * sprite->data1 / 256; - + SetOamMatrix(1, r6, r2, r5, foo); - + if (sprite->data1 < 0x100) sprite->data1 += 8; else @@ -1789,7 +1789,7 @@ void sub_813DB9C(struct Sprite *sprite) && sprite->pos1.x + sprite->pos2.x > -64) { u16 r2; - + sprite->pos2.y = -(sprite->data4 * sprite->data4) / 8; if (sprite->data2 != 0) sprite->pos2.x += sprite->data4; @@ -1806,7 +1806,7 @@ void sub_813DB9C(struct Sprite *sprite) else { DestroySprite(sprite); - } + } } } @@ -1894,7 +1894,7 @@ void sub_813DE70(struct Sprite *sprite) case 4: { s16 r4, r5; - + r5 = gSprites[sprite->data6].pos1.x + gSprites[sprite->data6].pos2.x; r4 = gSprites[sprite->data6].pos1.y + gSprites[sprite->data6].pos2.y; DestroySprite(&gSprites[sprite->data6]); @@ -1904,7 +1904,7 @@ void sub_813DE70(struct Sprite *sprite) gSprites[sprite->data6].data1 = 1; gSprites[sprite->data6].data2 = 1; sub_813E580(r5, r4); - + r5 = gSprites[sprite->data7].pos1.x + gSprites[sprite->data7].pos2.x; r4 = gSprites[sprite->data7].pos1.y + gSprites[sprite->data7].pos2.y; DestroySprite(&gSprites[sprite->data7]); @@ -1914,7 +1914,7 @@ void sub_813DE70(struct Sprite *sprite) gSprites[sprite->data7].data1 = 2; gSprites[sprite->data7].data2 = 0; sub_813E580(r5, r4); - + BeginNormalPaletteFade(0xFF0000, 0, 16, 16, RGB(31, 23, 31)); sprite->data0 = 1; break; @@ -2070,7 +2070,7 @@ void sub_813E210(struct Sprite *sprite) void sub_813E30C(struct Sprite *sprite) { u16 r4, r1; - + sprite->data7++; switch (sprite->data0) { @@ -2127,7 +2127,7 @@ void sub_813E4B8(struct Sprite *sprite) u16 r4; u16 r2; u16 r1; - + sprite->data7++; if (sprite->data7 & 1) sprite->invisible = FALSE; @@ -2157,7 +2157,7 @@ static void sub_813E580(u16 x, u16 y) { u8 i; u8 spriteId; - + for (i = 0; i < 8; i++) { spriteId = CreateSprite(&gSpriteTemplate_840B0B0, x, y, 0); @@ -2196,7 +2196,7 @@ void sub_813E6C0(struct Sprite *sprite) u8 i; s16 var1; s16 var2; - + if (gUnknown_0203931A != 0) { DestroySprite(sprite); @@ -2215,7 +2215,7 @@ void sub_813E6C0(struct Sprite *sprite) //Make redundant copies of these variables to get the asm to match s16 _var1 = var1; s16 _var2 = var2; - + spriteId = CreateSprite(&gSpriteTemplate_840B0DC, _var1, _var2, r3); if (spriteId != 64) { @@ -2235,7 +2235,7 @@ void sub_813E6C0(struct Sprite *sprite) static void sub_813E7C0(u8 a) { u8 spriteId; - + spriteId = CreateSprite(&gSpriteTemplate_840B0F4, 0, 0, 0); if (spriteId != 64) { @@ -2275,7 +2275,7 @@ static void sub_813E930(u8 a) { u8 i; u8 spriteId; - + for (i = 0; i < 8; i++) { spriteId = CreateSprite(&gSpriteTemplate_840B124, gSprites[a].pos1.x, gSprites[a].pos1.y, 0); @@ -2297,7 +2297,7 @@ void sub_813E980(struct Sprite *sprite) { u8 r0; u16 matrixNum; - + sprite->invisible = gSprites[sprite->data0].invisible; sprite->data7++; sprite->data6 += 8; @@ -2318,7 +2318,7 @@ void sub_813EA60(struct Sprite *sprite) bool32 r6; s16 r1, r2; u8 spriteId; - + if (gUnknown_0203931A != 0) { DestroySprite(sprite); @@ -2355,7 +2355,7 @@ static void InitIntroTorchicAttackAnim(u8 a) { u8 spriteId; u8 i; - + spriteId = CreateSprite(&gSpriteTemplate_840B170, 0, 0, 0); if (spriteId != 64) { @@ -2371,7 +2371,7 @@ static void InitIntroTorchicAttackAnim(u8 a) } void sub_813EBBC(struct Sprite *sprite) -{ +{ if (gUnknown_0203931A != 0) { DestroySprite(sprite); @@ -2396,7 +2396,7 @@ void sub_813EC90(struct Sprite *sprite) s16 r1, r2; u8 spriteId; u16 foo; - + if (gUnknown_0203931A != 0) { DestroySprite(sprite); @@ -2438,7 +2438,7 @@ void sub_813EC90(struct Sprite *sprite) static void InitIntroMudkipAttackAnim(u8 a) { u8 spriteId; - + spriteId = CreateSprite(&gSpriteTemplate_840B1C8, 0, 0, 0); if (spriteId != 64) { @@ -2452,7 +2452,7 @@ static void InitIntroMudkipAttackAnim(u8 a) void sub_813EDFC(struct Sprite *sprite) { u16 foo; - + //I'm not sure why a switch statement was used here. //if (sprite->data0 != 1) would have been more appropriate. switch (sprite->data0) diff --git a/src/item.c b/src/item.c index 3f74b5925..25b538251 100644 --- a/src/item.c +++ b/src/item.c @@ -61,7 +61,7 @@ void CopyItemName(u16 itemId, u8 *string) s8 CountUsedBagPocketSlots(u8 pocket) { u8 i; - + for (i = 0; i < gBagPockets[pocket].capacity; i++) { if (gBagPockets[pocket].itemSlots[i].itemId == 0) @@ -73,7 +73,7 @@ s8 CountUsedBagPocketSlots(u8 pocket) bool8 IsBagPocketNonEmpty(u8 pocket) { u8 i; - + for (i = 0; i < gBagPockets[pocket - 1].capacity; i++) { if (gBagPockets[pocket - 1].itemSlots[i].itemId != 0) @@ -86,7 +86,7 @@ bool8 CheckBagHasItem(u16 itemId, u16 count) { u8 i; u8 pocket; - + if (ItemId_GetPocket(itemId) == 0) return FALSE; pocket = ItemId_GetPocket(itemId) - 1; @@ -112,7 +112,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) u8 i; u8 pocket; u16 slotCapacity; - + if (ItemId_GetPocket(itemId) == 0) return FALSE; pocket = ItemId_GetPocket(itemId) - 1; @@ -120,7 +120,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) slotCapacity = 99; else slotCapacity = 999; - + //Check space in any existing item slots that already contain this item for (i = 0; i < gBagPockets[pocket].capacity; i++) { @@ -135,7 +135,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) return TRUE; } } - + //Check space in empty item slots if (count > 0) { @@ -152,7 +152,7 @@ bool8 CheckBagHasSpace(u16 itemId, u16 count) if (count > 0) return FALSE; //No more item slots. The bag is full } - + return TRUE; } @@ -162,7 +162,7 @@ bool8 AddBagItem(u16 itemId, u16 count) u8 pocket; u16 slotCapacity; struct ItemSlot newItems[64]; - + if (ItemId_GetPocket(itemId) == 0) return FALSE; pocket = ItemId_GetPocket(itemId) - 1; @@ -172,7 +172,7 @@ bool8 AddBagItem(u16 itemId, u16 count) slotCapacity = 99; else slotCapacity = 999; - + //Use any item slots that already contain this item for (i = 0; i < gBagPockets[pocket].capacity; i++) { @@ -193,7 +193,7 @@ bool8 AddBagItem(u16 itemId, u16 count) goto copy_items; } } - + //Put any remaining items into new item slots. if (count > 0) { @@ -214,7 +214,7 @@ bool8 AddBagItem(u16 itemId, u16 count) if (count > 0) return FALSE; //No more empty item slots. The bag is full. } - + copy_items: //Copy pocket back into the bag. memcpy(gBagPockets[pocket].itemSlots, newItems, gBagPockets[pocket].capacity * sizeof(struct ItemSlot)); @@ -226,11 +226,11 @@ bool8 RemoveBagItem(u16 itemId, u16 count) u8 i; u8 pocket; u16 totalQuantity = 0; - + if (ItemId_GetPocket(itemId) == 0 || itemId == 0) return FALSE; pocket = ItemId_GetPocket(itemId) - 1; - + for (i = 0; i < gBagPockets[pocket].capacity; i++) { if (gBagPockets[pocket].itemSlots[i].itemId == itemId) @@ -238,7 +238,7 @@ bool8 RemoveBagItem(u16 itemId, u16 count) } if (totalQuantity < count) return FALSE; //We don't have enough of the item - + if (gBagPockets[pocket].capacity > gUnknown_02038560 && gBagPockets[pocket].itemSlots[gUnknown_02038560].itemId == itemId) { @@ -257,7 +257,7 @@ bool8 RemoveBagItem(u16 itemId, u16 count) if (count == 0) return TRUE; } - + for (i = 0; i < gBagPockets[pocket].capacity; i++) { if (gBagPockets[pocket].itemSlots[i].itemId == itemId) @@ -289,7 +289,7 @@ u8 GetPocketByItemId(u16 itemId) void ClearItemSlots(struct ItemSlot *itemSlots, u8 b) { u16 i; - + for (i = 0; i < b; i++) { itemSlots[i].itemId = 0; @@ -300,7 +300,7 @@ void ClearItemSlots(struct ItemSlot *itemSlots, u8 b) static s32 FindFreePCItemSlot(void) { s8 i; - + for (i = 0; i < 50; i++) { if (gSaveBlock1.pcItems[i].itemId == 0) @@ -313,7 +313,7 @@ u8 CountUsedPCItemSlots(void) { u8 usedSlots = 0; u8 i; - + for (i = 0; i < 50; i++) { if (gSaveBlock1.pcItems[i].itemId != 0) @@ -325,7 +325,7 @@ u8 CountUsedPCItemSlots(void) bool8 CheckPCHasItem(u16 itemId, u16 count) { u8 i; - + for (i = 0; i < 50; i++) { if (gSaveBlock1.pcItems[i].itemId == itemId && gSaveBlock1.pcItems[i].quantity >= count) @@ -339,10 +339,10 @@ bool8 AddPCItem(u16 itemId, u16 count) u8 i; s8 freeSlot; struct ItemSlot newItems[50]; - + //Copy PC items memcpy(newItems, gSaveBlock1.pcItems, sizeof(newItems)); - + //Use any item slots that already contain this item for (i = 0; i < 50; i++) { @@ -363,7 +363,7 @@ bool8 AddPCItem(u16 itemId, u16 count) } } } - + //Put any remaining items into a new item slot. if (count > 0) { @@ -373,7 +373,7 @@ bool8 AddPCItem(u16 itemId, u16 count) newItems[freeSlot].itemId = itemId; newItems[freeSlot].quantity = count; } - + //Copy items back to the PC memcpy(gSaveBlock1.pcItems, newItems, sizeof(gSaveBlock1.pcItems)); return TRUE; @@ -393,7 +393,7 @@ static void CompactPCItems(void) { u16 i; u16 j; - + for (i = 0; i < 49; i++) { for (j = i + 1; j <= 49; j++) @@ -464,7 +464,7 @@ bool8 ItemId_CopyDescription(u8 *a, u32 itemId, u32 c) u32 r5 = c + 1; u8 *description = gItems[SanitizeItemId(itemId)].description; u8 *str = a; - + for (;;) { if (*description == 0xFF || *description == 0xFE) diff --git a/src/item_use.c b/src/item_use.c index 557705460..bed1736bc 100644 --- a/src/item_use.c +++ b/src/item_use.c @@ -1,21 +1,21 @@ #include "global.h" -#include "task.h" -#include "item.h" -#include "palette.h" -#include "weather.h" -#include "string_util.h" -#include "menu.h" -#include "mail.h" #include "asm.h" -#include "rom4.h" -#include "metatile_behavior.h" -#include "field_player_avatar.h" #include "event_data.h" +#include "field_player_avatar.h" +#include "field_player_avatar.h" +#include "item.h" +#include "mail.h" #include "map_obj_lock.h" +#include "menu.h" +#include "metatile_behavior.h" +#include "palette.h" +#include "rom4.h" #include "script.h" -#include "field_player_avatar.h" -#include "sound.h" #include "songs.h" +#include "sound.h" +#include "string_util.h" +#include "task.h" +#include "weather.h" extern void (* const gExitToOverworldFuncList[])(); extern void (* gUnknown_03005D00)(u8); @@ -91,7 +91,7 @@ void SetUpItemUseOnFieldCallback(u8 taskId) void HandleDeniedItemUseMessage(u8 var1, u8 playerMenuStatus, const u8 *var3) { StringExpandPlaceholders(gStringVar4, var3); - + switch(playerMenuStatus) { case 0: // Item Menu @@ -146,10 +146,10 @@ void ItemUseOutOfBattle_Bike(u8 taskId) { s16 x, y; u8 tileBehavior; - + PlayerGetDestCoords(&x, &y); tileBehavior = MapGridGetMetatileBehaviorAt(x, y); - + if(FlagGet(SYS_CYCLING_ROAD) == TRUE // on cycling road? || MetatileBehavior_IsVerticalRail(tileBehavior) == TRUE || MetatileBehavior_IsHorizontalRail(tileBehavior) == TRUE @@ -176,7 +176,7 @@ void ItemUseOnFieldCB_Bike(u8 taskId) GetOnOffBike(2); if(ItemId_GetSecondaryId(gScriptItemId) == 1) GetOnOffBike(4); - + sub_8064E2C(); ScriptContext2_Disable(); DestroyTask(taskId); diff --git a/src/link.c b/src/link.c index 7b4625bfd..2b463f6b4 100644 --- a/src/link.c +++ b/src/link.c @@ -1,17 +1,17 @@ #include "global.h" #include "link.h" #include "asm.h" +#include "battle.h" #include "main.h" -#include "task.h" -#include "text.h" -#include "sprite.h" -#include "songs.h" +#include "menu.h" #include "palette.h" #include "rng.h" -#include "menu.h" -#include "sound.h" #include "save.h" -#include "battle.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "text.h" #define SIO_MULTI_CNT ((struct SioMultiCnt *)REG_ADDR_SIOCNT) diff --git a/src/load_save.c b/src/load_save.c index 5babb843e..56d9b2b4d 100644 --- a/src/load_save.c +++ b/src/load_save.c @@ -80,7 +80,7 @@ void LoadPlayerParty(void) static void SaveMapObjects(void) { int i; - + for(i = 0; i < 16; i++) gSaveBlock1.mapObjects[i] = gMapObjects[i]; } @@ -88,7 +88,7 @@ static void SaveMapObjects(void) static void LoadMapObjects(void) { int i; - + for(i = 0; i < 16; i++) gMapObjects[i] = gSaveBlock1.mapObjects[i]; } diff --git a/src/lottery_corner.c b/src/lottery_corner.c index c18aeef48..3d456f372 100644 --- a/src/lottery_corner.c +++ b/src/lottery_corner.c @@ -1,10 +1,11 @@ #include "global.h" #include "lottery_corner.h" -#include "rng.h" -#include "string_util.h" #include "event_data.h" -#include "species.h" #include "items.h" +#include "rng.h" +#include "species.h" +#include "string_util.h" +#include "text.h" extern u16 gScriptResult; extern u16 gSpecialVar_0x8004; @@ -36,11 +37,11 @@ void ResetLotteryCorner(void) void SetRandomLotteryNumber(u16 i) { u32 var = Random(); - + while(--i != 0xFFFF) var = var * 1103515245 + 12345; - SetLotteryNumber(var); + SetLotteryNumber(var); } void RetrieveLotteryNumber(void) @@ -55,14 +56,14 @@ void PickLotteryCornerTicket(void) u16 j; u32 box; u32 slot; - + gSpecialVar_0x8004 = 0; slot = 0; box = 0; for(i = 0; i < 6; i++) { struct Pokemon *pkmn = &gPlayerParty[i]; - + // UB: Too few arguments for function GetMonData if(GetMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE) { @@ -71,7 +72,7 @@ void PickLotteryCornerTicket(void) { u32 otId = GetMonData(pkmn, MON_DATA_OT_ID); u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId); - + if(numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) { gSpecialVar_0x8004 = numMatchingDigits - 1; @@ -83,7 +84,7 @@ void PickLotteryCornerTicket(void) else // pokemon are always arranged from populated spots first to unpopulated, so the moment a NONE species is found, that's the end of the list. break; } - + // player has 14 boxes. for(i = 0; i < 14; i++) { @@ -91,14 +92,14 @@ void PickLotteryCornerTicket(void) for(j = 0; j < 30; j++) { struct BoxPokemon *pkmn = &gPokemonStorage.boxes[i][j]; - + // UB: Too few arguments for function GetMonData if(GetBoxMonData(pkmn, MON_DATA_SPECIES) != SPECIES_NONE && !GetBoxMonData(pkmn, MON_DATA_IS_EGG)) { u32 otId = GetBoxMonData(pkmn, MON_DATA_OT_ID); u8 numMatchingDigits = GetMatchingDigits(gScriptResult, otId); - + if(numMatchingDigits > gSpecialVar_0x8004 && numMatchingDigits > 1) { gSpecialVar_0x8004 = numMatchingDigits - 1; @@ -108,11 +109,11 @@ void PickLotteryCornerTicket(void) } } } - + if(gSpecialVar_0x8004 != 0) { gSpecialVar_0x8005 = sLotteryPrizes[gSpecialVar_0x8004 - 1]; - + if(box == 14) { gSpecialVar_0x8006 = 0; @@ -131,12 +132,12 @@ static u8 GetMatchingDigits(u16 winNumber, u16 otId) { u8 i; u8 matchingDigits = 0; - + for(i = 0; i < 5; i++) { sWinNumberDigit = winNumber % 10; sOtIdDigit = otId % 10; - + if(sWinNumberDigit == sOtIdDigit) { winNumber = winNumber / 10; @@ -163,7 +164,7 @@ u32 GetLotteryNumber(void) { u16 highNum = VarGet(VAR_POKELOT_RND1); u16 lowNum = VarGet(VAR_POKELOT_RND2); - + return (lowNum << 16) | highNum; } diff --git a/src/mail.c b/src/mail.c index 6cff514a1..a0f448205 100644 --- a/src/mail.c +++ b/src/mail.c @@ -1,6 +1,7 @@ #include "global.h" #include "mail.h" #include "asm.h" +#include "items.h" #include "menu.h" #include "palette.h" #include "rom4.h" @@ -8,7 +9,6 @@ #include "string_util.h" #include "task.h" #include "text.h" -#include "items.h" struct UnkMailStruct { diff --git a/src/main_menu.c b/src/main_menu.c index 7adbda096..dee9af852 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -2,6 +2,7 @@ #include "main_menu.h" #include "asm.h" #include "decompress.h" +#include "event_data.h" #include "menu.h" #include "mystery_event_menu.h" #include "option_menu.h" @@ -16,7 +17,6 @@ #include "task.h" #include "text.h" #include "title_screen.h" -#include "event_data.h" #define BirchSpeechUpdateWindowText() ((u8)MenuUpdateWindowText_OverrideLineLength(24)) @@ -71,8 +71,6 @@ extern const u8 gSystemText_NewPara[]; extern u8 gSpriteAffineAnimTable_81E79AC[]; -extern u8 gStringVar4[]; - extern u8 unk_2000000[]; //Task data diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 65766c130..c10a3f9de 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -1,8 +1,8 @@ #include "global.h" -#include "menu.h" +#include "asm.h" #include "event_data.h" +#include "menu.h" #include "task.h" -#include "asm.h" EWRAM_DATA static u8 sTaskId = 0; diff --git a/src/matsuda_debug_menu.c b/src/matsuda_debug_menu.c index 131369e91..a3e611020 100644 --- a/src/matsuda_debug_menu.c +++ b/src/matsuda_debug_menu.c @@ -120,7 +120,7 @@ u8 unref_sub_80A9B28(void) static bool8 sub_80A9B78(void) { s8 choice = ProcessMenuInput(); - + switch(choice) { case -2: @@ -171,7 +171,7 @@ s8 MatsudaDebugMenu_CommTest(void) { u8 newTaskId; u8 newTaskId2; - + newTaskId = CreateTask(sub_80A9E3C, 0); SetTaskFuncWithFollowupFunc(newTaskId, sub_80A9E3C, sub_80A9C98); newTaskId2 = CreateTask(sub_80A9E04, 1); @@ -247,7 +247,7 @@ static void sub_80A9E04(u8 taskId) static void sub_80A9E3C(u8 taskId) { u8 i; - + OpenLink(); for(i = 0; i < 4; i++) @@ -268,7 +268,7 @@ static void sub_80A9E80(u8 taskId) if(GetLinkPlayerCount_2() > 3) { gTasks[taskId].data[0] = 0; - + if(IsLinkMaster()) { func = sub_80A9ED8; @@ -334,7 +334,7 @@ static void sub_80A9FE4(void) u8 *addr; u32 i; u8 ptr[5]; - + memcpy(ptr, gMatsudaDebugMenu_UnknownByteArray, 5); addr = (void *)VRAM; @@ -395,7 +395,7 @@ static void sub_80AA10C(void) ResetSpriteData(); ResetTasks(); FreeAllSpritePalettes(); - sub_80A9FE4(); + sub_80A9FE4(); SetVBlankCallback(sub_80AA090); SetMainCallback2(sub_80AA064); gPaletteFade.bufferTransferDisabled = 0; @@ -408,8 +408,8 @@ static void sub_80AA10C(void) for(i = 0; i < 6; i++) { - sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList1[i], - (0xA * i + 0x2A), gMatsudaDebugMenuContestTopLeft[i][0], + sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList1[i], + (0xA * i + 0x2A), gMatsudaDebugMenuContestTopLeft[i][0], gMatsudaDebugMenuContestTopLeft[i][1]); } @@ -727,7 +727,7 @@ void sub_80AABF0(struct Sprite *sprite, s8 var2) { s8 a = (var2 > 0) ? 1 : -1; s8 r4 = sprite->data3 + a; - + if (r4 < 0) r4 = 0; else if (r4 > 4) @@ -781,7 +781,7 @@ void sub_80AAD44(struct Sprite *sprite, s8 var2) if (var2 == 1) { int i; - + SetDebugMonForContest(); for (i = 0; i < 4; i++) gUnknown_02038670[i] = sub_80AE770(i, gScriptContestCategory); @@ -799,22 +799,22 @@ void sub_80AAD84(u8 *string, u8 b, u8 c, u8 d) //u32 sp44; //u32 sp48; u32 sp58; - + gMain.state = 0; - + r5 = d + 1; //Could also be DmaClear32 DmaFill32(3, 0, (u8 *)VRAM + 0x18000 - r5 * 256, 0x100); - + r7 = StringLength(string); if (r7 > 8) r7 = 8; sp58 = d * 2; - + //More stuff - + r7_2 = 0x7C - sp58; - + } */ @@ -1000,7 +1000,7 @@ void unref_sub_80AAEE8(s32 a, u8 b, u8 c, u8 d) { u8 string[12]; u8 offset = 0; - + if (a < 0) { string[0] = 0xAE; @@ -1013,7 +1013,7 @@ void unref_sub_80AAEE8(s32 a, u8 b, u8 c, u8 d) void sub_80AAF30(void) { s32 i; - + gUnknown_0203856C = 1; gContestPlayerMonIndex = 3; sub_80AE098(0); @@ -1044,7 +1044,7 @@ int MatsudaDebugMenu_SetHighScore(void) int MatsudaDebugMenu_ResetHighScore(void) { s32 i; - + gUnknown_0203856C = 0; for (i = 0; i < 4; i++) { @@ -1060,7 +1060,7 @@ int MatsudaDebugMenu_ResetHighScore(void) int MatsudaDebugMenu_SetArtMuseumItems(void) { s32 i; - + gContestPlayerMonIndex = 3; sub_80AE098(0); for (i = 3; i > -1; i--) @@ -1076,7 +1076,7 @@ void unref_sub_80AB084(u8 *text) u16 savedIme; u8 *addr; size_t size; - + REG_BG0HOFS = 0; REG_BG0VOFS = 0; REG_BG1HOFS = 0; @@ -1090,7 +1090,7 @@ void unref_sub_80AB084(u8 *text) REG_WIN1H = 0; REG_WIN1V = 0; REG_DISPCNT = 0x1F40; - + savedIme = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; @@ -1099,7 +1099,7 @@ void unref_sub_80AB084(u8 *text) ResetTasks(); ResetSpriteData(); SetMainCallback2(sub_80AB184); - + addr = (void *)VRAM; size = 0x18000; while(1) diff --git a/src/menu.c b/src/menu.c index ee9376079..a4e5d9065 100644 --- a/src/menu.c +++ b/src/menu.c @@ -1,13 +1,13 @@ #include "global.h" #include "menu.h" #include "main.h" -#include "text.h" -#include "songs.h" -#include "text_window.h" -#include "sound.h" -#include "menu_cursor.h" #include "map_obj_lock.h" +#include "menu_cursor.h" #include "script.h" +#include "songs.h" +#include "sound.h" +#include "text.h" +#include "text_window.h" struct Menu { diff --git a/src/menu_cursor.c b/src/menu_cursor.c index 201c6c4d8..8f1a0ac37 100644 --- a/src/menu_cursor.c +++ b/src/menu_cursor.c @@ -1,7 +1,7 @@ #include "global.h" #include "menu_cursor.h" -#include "sprite.h" #include "palette.h" +#include "sprite.h" extern struct SpriteSheet gUnknown_0842F140[]; extern struct SpriteSheet gUnknown_0842F1C0[]; diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 1ea4bfa83..01cf5dc6a 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -367,7 +367,7 @@ bool8 is_tile_x84(u8 var) bool8 sub_80571C0(u8 var) { - if(var == MB_91 || var == MB_93 || var == MB_95 || var == MB_97 + if(var == MB_91 || var == MB_93 || var == MB_95 || var == MB_97 || var == MB_99 || var == MB_9B || var == MB_9D) return TRUE; else @@ -645,7 +645,7 @@ bool8 sub_80574D8(u8 var) if(var == MB_MOUNTAIN_TOP) return TRUE; else - return FALSE; + return FALSE; } bool8 sub_80574EC(u8 var) diff --git a/src/mori_debug_menu.c b/src/mori_debug_menu.c index 645aecc9e..413de6a95 100644 --- a/src/mori_debug_menu.c +++ b/src/mori_debug_menu.c @@ -1,11 +1,11 @@ #include "global.h" #include "mori_debug_menu.h" #include "asm.h" -#include "start_menu.h" -#include "menu.h" +#include "link.h" #include "main.h" +#include "menu.h" +#include "start_menu.h" #include "string_util.h" -#include "link.h" #define SIO_MULTI_CNT ((struct SioMultiCnt *)REG_ADDR_SIOCNT) @@ -49,7 +49,7 @@ u8 MoriDebugMenu_SearchChild(u8 a1, u8 a2, u8 *ptr) u8 localPtr[52]; u16 monData; u16 var; - + monData = GetMonData(gPlayerParty, 11, ptr); var = sub_8041870(monData); StringCopy(localPtr, gSpeciesNames[monData]); @@ -85,14 +85,14 @@ s8 MoriDebugMenu_1000Steps(void) { sub_8041790(1000); CloseMenu(); - return 1; + return 1; } s8 MoriDebugMenu_10000Steps(void) { sub_8041790(10000); CloseMenu(); - return 1; + return 1; } s8 MoriDebugMenu_MoveTutor(void) @@ -130,10 +130,10 @@ s8 MoriDebugMenu_LongName(void) s8 MoriDebugMenu_PokeblockCase(void) { s32 loopCounter; - + for(loopCounter = 0; loopCounter <= 39; loopCounter++) sub_810CA6C((u8)loopCounter); - + CloseMenu(); return 1; } diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c index 09523ff40..3c867fb01 100644 --- a/src/mystery_event_menu.c +++ b/src/mystery_event_menu.c @@ -1,17 +1,17 @@ #include "global.h" -#include "sprite.h" -#include "menu.h" +#include "mystery_event_menu.h" +#include "asm.h" #include "link.h" -#include "text.h" #include "main.h" +#include "menu.h" #include "palette.h" -#include "task.h" -#include "string_util.h" +#include "save.h" #include "songs.h" #include "sound.h" -#include "save.h" -#include "asm.h" -#include "mystery_event_menu.h" +#include "sprite.h" +#include "string_util.h" +#include "task.h" +#include "text.h" extern u8 unk_2000000[]; extern u8 gUnknown_02039338; diff --git a/src/mystery_event_script.c b/src/mystery_event_script.c index 4aa3784d7..515a0722f 100644 --- a/src/mystery_event_script.c +++ b/src/mystery_event_script.c @@ -1,6 +1,7 @@ #include "global.h" #include "script.h" #include "string_util.h" +#include "text.h" #ifdef SAPPHIRE #define UNK_MASK 0x100 diff --git a/src/name_string_util.c b/src/name_string_util.c index 27e6d99d0..a1812d5e9 100644 --- a/src/name_string_util.c +++ b/src/name_string_util.c @@ -1,6 +1,6 @@ #include "global.h" -#include "text.h" #include "string_util.h" +#include "text.h" void PadNameString(u8 *a1, u8 a2) { diff --git a/src/new_game.c b/src/new_game.c index 4f93e4e3c..ddc9ea403 100644 --- a/src/new_game.c +++ b/src/new_game.c @@ -2,15 +2,15 @@ #include "new_game.h" #include "asm.h" #include "berry.h" +#include "event_data.h" +#include "lottery_corner.h" #include "play_time.h" -#include "pokemon_size_record.h" -#include "script.h" -#include "rom4.h" #include "pokedex.h" -#include "lottery_corner.h" +#include "pokemon_size_record.h" #include "rng.h" +#include "rom4.h" #include "rtc.h" -#include "event_data.h" +#include "script.h" extern u8 gUnknown_020297EC; diff --git a/src/option_menu.c b/src/option_menu.c index f597429c1..d323eb853 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -98,7 +98,7 @@ void CB2_InitOptionMenu(void) { u8 *addr; u32 size; - + SetVBlankCallback(NULL); REG_DISPCNT = 0; REG_BG2CNT = 0; @@ -160,7 +160,7 @@ void CB2_InitOptionMenu(void) case 7: { u16 savedIme; - + REG_WIN0H = 0; REG_WIN0V = 0; REG_WIN1H = 0; @@ -184,7 +184,7 @@ void CB2_InitOptionMenu(void) case 8: { u8 taskId = CreateTask(Task_OptionMenuFadeIn, 0); - + gTasks[taskId].data[TD_MENUSELECTION] = 0; gTasks[taskId].data[TD_TEXTSPEED] = gSaveBlock2.optionsTextSpeed; gTasks[taskId].data[TD_BATTLESCENE] = gSaveBlock2.optionsBattleSceneOff; @@ -192,10 +192,10 @@ void CB2_InitOptionMenu(void) gTasks[taskId].data[TD_SOUND] = gSaveBlock2.optionsSound; gTasks[taskId].data[TD_BUTTONMODE] = gSaveBlock2.optionsButtonMode; gTasks[taskId].data[TD_FRAMETYPE] = gSaveBlock2.optionsWindowFrameType; - + MenuDrawTextWindow(2, 0, 27, 3); MenuDrawTextWindow(2, 4, 27, 19); - + MenuPrint(gSystemText_OptionMenu, 4, 1); MenuPrint(gSystemText_TextSpeed, 4, 5); MenuPrint(gSystemText_BattleScene, 4, 7); @@ -204,17 +204,17 @@ void CB2_InitOptionMenu(void) MenuPrint(gSystemText_ButtonMode, 4, 13); MenuPrint(gSystemText_Frame, 4, 15); MenuPrint(gSystemText_Cancel, 4, 17); - + TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]); BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]); BattleStyle_DrawChoices(gTasks[taskId].data[TD_BATTLESTYLE]); Sound_DrawChoices(gTasks[taskId].data[TD_SOUND]); ButtonMode_DrawChoices(gTasks[taskId].data[TD_BUTTONMODE]); FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]); - + REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(1, 31); - + HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]); gMain.state++; break; @@ -300,7 +300,7 @@ static void Task_OptionMenuSave(u8 taskId) gSaveBlock2.optionsSound = gTasks[taskId].data[TD_SOUND]; gSaveBlock2.optionsButtonMode = gTasks[taskId].data[TD_BUTTONMODE]; gSaveBlock2.optionsWindowFrameType = gTasks[taskId].data[TD_FRAMETYPE]; - + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); gTasks[taskId].func = Task_OptionMenuFadeOut; } @@ -327,10 +327,10 @@ static void DrawOptionMenuChoice(u8 *text, u8 x, u8 y, u8 style) { u8 dst[16]; u16 i; - + for(i = 0; *text != EOS && i <= 14; i++) dst[i] = *(text++); - + dst[2] = style; dst[i] = EOS; MenuPrint_PixelCoords(dst, x, y, 1); @@ -358,12 +358,12 @@ static u8 TextSpeed_ProcessInput(u8 selection) static void TextSpeed_DrawChoices(u8 selection) { u8 styles[3]; - + styles[0] = 0xF; styles[1] = 0xF; styles[2] = 0xF; styles[selection] = 0x8; - + DrawOptionMenuChoice(gSystemText_Slow, 120, 40, styles[0]); DrawOptionMenuChoice(gSystemText_Mid, 155, 40, styles[1]); DrawOptionMenuChoice(gSystemText_Fast, 184, 40, styles[2]); @@ -379,11 +379,11 @@ static u8 BattleScene_ProcessInput(u8 selection) static void BattleScene_DrawChoices(u8 selection) { u8 styles[2]; - + styles[0] = 0xF; styles[1] = 0xF; styles[selection] = 0x8; - + DrawOptionMenuChoice(gSystemText_On, 120, 56, styles[0]); DrawOptionMenuChoice(gSystemText_Off, 190, 56, styles[1]); } @@ -398,11 +398,11 @@ static u8 BattleStyle_ProcessInput(u8 selection) static void BattleStyle_DrawChoices(u8 selection) { u8 styles[2]; - + styles[0] = 0xF; styles[1] = 0xF; styles[selection] = 0x8; - + DrawOptionMenuChoice(gSystemText_Shift, 120, 72, styles[0]); DrawOptionMenuChoice(gSystemText_Set, 190, 72, styles[1]); } @@ -420,11 +420,11 @@ static u8 Sound_ProcessInput(u8 selection) static void Sound_DrawChoices(u8 selection) { u8 styles[3]; - + styles[0] = 0xF; styles[1] = 0xF; styles[selection] = 0x8; - + DrawOptionMenuChoice(gSystemText_Mono, 120, 88, styles[0]); DrawOptionMenuChoice(gSystemText_Stereo, 172, 88, styles[1]); } @@ -457,10 +457,10 @@ static void FrameType_DrawChoices(u8 selection) u8 text[8]; u8 n = selection + 1; u16 i; - + for(i = 0; gSystemText_Terminator[i] != EOS && i <= 5; i++) text[i] = gSystemText_Terminator[i]; - + //Convert number to decimal string if(n / 10 != 0) { @@ -476,7 +476,7 @@ static void FrameType_DrawChoices(u8 selection) text[i] = CHAR_SPACE; i++; } - + text[i] = EOS; MenuPrint(gSystemText_Type, 15, 15); MenuPrint(text, 18, 15); @@ -504,12 +504,12 @@ static u8 ButtonMode_ProcessInput(u8 selection) static void ButtonMode_DrawChoices(u8 selection) { u8 styles[3]; - + styles[0] = 0xF; styles[1] = 0xF; styles[2] = 0xF; styles[selection] = 0x8; - + DrawOptionMenuChoice(gSystemText_Normal, 120, 104, styles[0]); DrawOptionMenuChoice(gSystemText_LR, 166, 104, styles[1]); DrawOptionMenuChoice(gSystemText_LA, 188, 104, styles[2]); diff --git a/src/party_menu.c b/src/party_menu.c index ce1b0f32a..723f66e85 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -29,7 +29,6 @@ struct Unk201B260 { extern struct Unk201B260 unk_201B260; extern struct Unk201C000 unk_201C000; -extern u8 gStringVar1[]; extern u8 gUnknown_0202E8F4; extern u8 gUnknown_0202E8F6; diff --git a/src/player_pc.c b/src/player_pc.c index 822e2108e..682e46b61 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -1,14 +1,14 @@ #include "global.h" +#include "asm.h" #include "item.h" -#include "task.h" -#include "menu.h" -#include "sound.h" #include "main.h" -#include "script.h" +#include "menu.h" #include "palette.h" -#include "weather.h" -#include "asm.h" +#include "script.h" +#include "sound.h" #include "string_util.h" +#include "task.h" +#include "weather.h" extern void DisplayItemMessageOnField(u8, u8*, TaskFunc, u16); extern void ItemStorageMenuProcessInput(u8); @@ -74,7 +74,7 @@ void NewGameInitPCItems(void) void BedroomPC(void) { u8 taskId; - + gUnknown_02039314 = gUnknown_084062B8; gUnknown_030007B4 = 4; taskId = CreateTask(TaskDummy, 0); @@ -84,7 +84,7 @@ void BedroomPC(void) void PlayerPC(void) { u8 taskId; - + gUnknown_02039314 = gUnknown_084062BC; gUnknown_030007B4 = 3; taskId = CreateTask(TaskDummy, 0); @@ -216,7 +216,7 @@ void ItemStorageMenuProcessInput(u8 var) sub_8072DEC(); PlaySE(5); gUnknown_084062C0[3].func(var); - } + } } void Task_ItemStorage_Deposit(u8 taskId) @@ -252,7 +252,7 @@ void ItemStorage_Withdraw(u8 taskId) { u8 var; u16 * data = gTasks[taskId].data; - + sub_8072DEC(); MenuZeroFillWindowRect(0, 0, 11, 9); var = CountUsedPCItemSlots(); @@ -276,7 +276,7 @@ void ItemStorage_Toss(u8 taskId) { u8 var; u16 * data = gTasks[taskId].data; - + sub_8072DEC(); MenuZeroFillWindowRect(0, 0, 11, 9); var = CountUsedPCItemSlots(); @@ -322,7 +322,7 @@ void sub_813A240(u8 taskId) void sub_813A280(u8 taskId) { s16 *data = gTasks[taskId].data; - + if(gMain.newAndRepeatedKeys & 0x40) { if(data[0]) @@ -686,7 +686,7 @@ void sub_813A4B4(u8 taskId) sub_80F996C(0); sub_80F996C(1); - + if(data[6]) { if(gSaveBlock1.pcItems[var].itemId == 1) diff --git a/src/pokedex.c b/src/pokedex.c index 48e3a57aa..458f7e9bc 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -1,18 +1,18 @@ #include "global.h" #include "pokedex.h" #include "asm.h" +#include "decompress.h" +#include "event_data.h" #include "gba/m4a_internal.h" -#include "string_util.h" #include "m4a.h" -#include "decompress.h" #include "main.h" #include "menu.h" #include "palette.h" #include "rng.h" #include "songs.h" #include "sound.h" +#include "string_util.h" #include "task.h" -#include "event_data.h" // I'm #define-ing these just for now so I can keep using the old unkXXX member names #define unk60E selectedPokemon @@ -134,7 +134,7 @@ void DestroyCryMeterNeedleSprite(); void sub_808C02C(void) { u16 i; - + gUnknown_0202FFB8 = 0; gUnknown_0202FFBA = 0x40; gUnknown_03005CE8 = 0; @@ -171,7 +171,7 @@ void sub_808C0B8(void) void ClearPokedexView(struct PokedexView *pokedexView) { u16 i; - + for(i = 0; i <= 385; i++) { pokedexView->unk0[i].dexNum |= 0xFFFF; @@ -228,7 +228,7 @@ void CB2_InitPokedex(void) { u8 *addr; u32 size; - + SetVBlankCallback(NULL); sub_8091060(0); addr = (u8 *)VRAM; @@ -303,7 +303,7 @@ void CB2_InitPokedex(void) case 3: { u16 savedIme; - + savedIme = REG_IME; REG_IME = 0; REG_IE |= 1; @@ -321,7 +321,7 @@ u8 unref_sub_808C540(void (*func)(u8)) { u16 savedIme; u8 taskId; - + SetVBlankCallback(NULL); sub_8091060(0x200); remove_some_task(); @@ -363,7 +363,7 @@ void Task_PokedexShowMainScreen(u8 taskId) void Task_PokedexMainScreen(u8 taskId) { REG_BG0VOFS = gPokedexView->menuY; - + //If menu is open, slide it down, off screen if(gPokedexView->menuY) gPokedexView->menuY -= 8; @@ -429,7 +429,7 @@ void sub_808C898(u8 taskId) void Task_PokedexMainScreenMenu(u8 taskId) { REG_BG0VOFS = gPokedexView->menuY; - + //If menu is not open, slide it up, on screen if(gPokedexView->menuY != 80) gPokedexView->menuY += 8; @@ -464,7 +464,7 @@ void Task_PokedexMainScreenMenu(u8 taskId) break; } } - + //Exit menu when Start or B is pressed if(gMain.newKeys & (START_BUTTON | B_BUTTON)) { @@ -518,7 +518,7 @@ void sub_808CAE4(u8 taskId) void sub_808CB8C(u8 taskId) { bool8 isActive = gTasks[gTasks[taskId].data[0]].isActive; - + if(!isActive) { if(gPokedexView->unk64F) @@ -564,7 +564,7 @@ void sub_808CCC4(u8 taskId) void Task_PokedexResultsScreen(u8 taskId) { REG_BG0VOFS = gPokedexView->menuY; - + if(gPokedexView->menuY) gPokedexView->menuY -= 8; else @@ -572,7 +572,7 @@ void Task_PokedexResultsScreen(u8 taskId) if((gMain.newKeys & A_BUTTON) && gPokedexView->unk0[gPokedexView->selectedPokemon].seen) { u32 a; - + sub_808E6BC(); a = (1 << (gSprites[gPokedexView->unk626].oam.paletteNum + 16)); gSprites[gPokedexView->unk626].callback = sub_808EDB8; @@ -604,7 +604,7 @@ void Task_PokedexResultsScreen(u8 taskId) } else { - //Handle D-pad + //Handle D-pad gPokedexView->selectedPokemon = sub_808E48C(gPokedexView->selectedPokemon, 0xE); if(gPokedexView->unk62E) gTasks[taskId].func = sub_808CEF8; @@ -621,7 +621,7 @@ void sub_808CEF8(u8 taskId) void Task_PokedexResultsScreenMenu(u8 taskId) { REG_BG0VOFS = gPokedexView->menuY; - + if(gPokedexView->menuY != 0x60) gPokedexView->menuY += 8; else @@ -660,7 +660,7 @@ void Task_PokedexResultsScreenMenu(u8 taskId) break; } } - + //Exit menu when Start or B is pressed if(gMain.newKeys & (START_BUTTON | B_BUTTON)) { @@ -837,9 +837,9 @@ void SortPokedex(u8 dexMode, u8 sortMode) { u16 vars[3]; //I have no idea why three regular variables are stored in an array, but whatever. s16 i; - + gPokedexView->unk60C = 0; - + switch(dexMode) { default: @@ -860,7 +860,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) } break; } - + switch(sortMode) { case 0: @@ -906,7 +906,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) for(i = 0; i < 411; i++) { vars[2] = gPokedexOrder_Alphabetical[i]; - + if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 0)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; @@ -920,7 +920,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) for(i = 385; i >= 0; i--) { vars[2] = gPokedexOrder_Weight[i]; - + if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; @@ -934,7 +934,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) for(i = 0; i < 386; i++) { vars[2] = gPokedexOrder_Weight[i]; - + if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; @@ -948,7 +948,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) for(i = 385; i >=0; i--) { vars[2] = gPokedexOrder_Height[i]; - + if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; @@ -962,7 +962,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) for(i = 0; i < 386; i++) { vars[2] = gPokedexOrder_Height[i]; - + if(NationalToHoennOrder(vars[2]) <= vars[0] && sub_8090D90(vars[2], 1)) { gPokedexView->unk0[gPokedexView->unk60C].dexNum = vars[2]; @@ -971,7 +971,7 @@ void SortPokedex(u8 dexMode, u8 sortMode) gPokedexView->unk60C++; } } - break; + break; } for(i = gPokedexView->unk60C; i < 386; i++) { @@ -990,7 +990,7 @@ void sub_808DBE8(u8 a, u16 b, u16 c) { u16 i; s16 _b = b - 5; - + for(i = 0; i <= 10; i++) { if((u16)_b > 385 || gPokedexView->unk0[_b].dexNum == 0xFFFF) @@ -1018,7 +1018,7 @@ void sub_808DBE8(u8 a, u16 b, u16 c) case 1: { s16 _b = b - 5; - + if((u16)_b > 385 || gPokedexView->unk0[_b].dexNum == 0xFFFF) sub_808E090(0x11, gPokedexView->unk630 * 2, c); else @@ -1043,7 +1043,7 @@ void sub_808DBE8(u8 a, u16 b, u16 c) { s16 _b = b + 5; u16 r2 = gPokedexView->unk630 + 10; - + if(r2 > 15) r2 -= 16; if((u16)_b > 385 || gPokedexView->unk0[_b].dexNum == 0xFFFF) @@ -1074,7 +1074,7 @@ void sub_808DEB0(u16 a, u8 b, u8 c, u16 d) u8 text[4]; u16 unk[2]; u16 r7 = gPokedexView->unk0[a].dexNum; - + if(gPokedexView->dexMode == DEX_MODE_HOENN) r7 = NationalToHoennOrder(r7); unk[0] = 0x3FC; @@ -1091,7 +1091,7 @@ void sub_808DEB0(u16 a, u8 b, u8 c, u16 d) void sub_808DF88(u16 a, u8 b, u8 c, u16 d) { u16 unk[2]; - + if(a) { unk[0] = 0x3FE; @@ -1113,7 +1113,7 @@ u8 sub_808DFE4(u16 a, u8 b, u8 c) u8 text[10]; u8 i; u32 species; - + for(i = 0; i < 10; i++) text[i] = 0; text[i] = EOS; @@ -1230,7 +1230,7 @@ _0808E070:\n\ void sub_808E090(u8 a, u8 b, u16 c) { u8 i; - + for(i = 0; i < 12; i++) { *(u16 *)(VRAM + c * 0x800 + b * 64 + (a + i) * 2) = 0; @@ -1243,7 +1243,7 @@ void sub_808E0CC(u16 a, u16 b) u8 i; u16 unk; u8 spriteId; - + for(i = 0; i < 4; i++) gPokedexView->unk61E[i] |= 0xFFFF; gPokedexView->unk626 = 0xFFFF; @@ -1278,7 +1278,7 @@ bool8 sub_808E208(u8 a, u8 b, u8 c) { u16 i; u8 foo; - + if(gPokedexView->unk62E) { gPokedexView->unk62E--; @@ -1319,7 +1319,7 @@ void sub_808E398(u8 a, u16 b) { u16 unk; u8 spriteId; - + gPokedexView->unk632 = gPokedexView->unk630; switch(a) { @@ -1366,7 +1366,7 @@ u16 sub_808E48C(u16 a, u16 b) { u8 i; u16 r6; - + //_0808E4B6 if(gMain.heldKeys & 0x80) { @@ -1374,7 +1374,7 @@ u16 sub_808E48C(u16 a, u16 b) goto _0808E5C4; } //_0808E4CE - + if((gMain.newKeys & 0x20) && a != 0) { r6 = a; @@ -1383,7 +1383,7 @@ u16 sub_808E48C(u16 a, u16 b) { a = sub_8091818(1, a, 0, gPokedexView->unk60C - 1); } - + gPokedexView->unk62C += (a - r6) * 16; sub_808E82C(); sub_808E0CC(a, 0xE); @@ -1393,25 +1393,25 @@ u16 sub_808E48C(u16 a, u16 b) //_0808E53C if(!(gMain.newKeys & 0x10) || a >= gPokedexView->unk60C - 1) goto _0808E5A2; - + r6 = a; for(i = 0; i < 7; i++) { a = sub_8091818(0, a, 0, gPokedexView->unk60C - 1); } - + gPokedexView->unk62C += (a - r6) * 16; sub_808E82C(); sub_808E0CC(a, 0xE); PlaySE(SE_Z_PAGE); goto _0808E5A2; - + _0808E5A2: if(r10 != 0) goto _0808E628; gPokedexView->unk638 = r10; return a; - + _0808E5C4: r10 = 2; a = sub_8091818(0, a, 0, gPokedexView->unk60C - 1); @@ -1432,7 +1432,7 @@ u16 sub_808E48C(u16 a, u16 b) } //_0808E60E goto _0808E5A2; - + _0808E628: r5 = gUnknown_083A05EC[gPokedexView->unk638 / 4]; r3 = gUnknown_083A05F1[gPokedexView->unk638 / 4]; @@ -1719,11 +1719,11 @@ _0808E6B8: .4byte 0x0000062f\n\ void sub_808E6BC(void) { u16 i; - + for(i = 0; i < 4; i++) { u16 spriteId = gPokedexView->unk61E[i]; - + if(gSprites[spriteId].pos2.x == 0 && gSprites[spriteId].pos2.y == 0 && spriteId != 0xFFFF) gPokedexView->unk626 = spriteId; } @@ -1733,21 +1733,21 @@ u8 sub_808E71C(void) { u16 r2; u16 r4 = gPokedexView->selectedPokemon; - + if((gMain.newKeys & DPAD_UP) && r4) { r2 = r4; while(r2 != 0) { r2 = sub_8091818(1, r2, 0, gPokedexView->unk60C - 1); - + if(gPokedexView->unk0[r2].seen) { r4 = r2; break; } } - + if(gPokedexView->selectedPokemon == r4) return 0; else @@ -1763,14 +1763,14 @@ u8 sub_808E71C(void) while(r2 < gPokedexView->unk60C - 1) { r2 = sub_8091818(0, r2, 0, gPokedexView->unk60C - 1); - + if(gPokedexView->unk0[r2].seen) { r4 = r2; break; } } - + if(gPokedexView->selectedPokemon == r4) return 0; else @@ -1786,7 +1786,7 @@ u8 sub_808E71C(void) u8 sub_808E82C(void) { u16 i; - + for(i = 0; i < 4; i++) { if(gPokedexView->unk61E[i] != 0xFFFF) @@ -1811,13 +1811,13 @@ u16 sub_808E888(u16 a1) u32 sub_808E8C8(u16 a, u16 b, u16 c) { u8 i; - + for(i = 0; i < 4; i++) { if(gPokedexView->unk61E[i] == 0xFFFF) { u8 spriteId = sub_80918EC(a, (s16)b, (s16)c, i); - + gSprites[spriteId].oam.affineMode = 1; gSprites[spriteId].oam.priority = 3; gSprites[spriteId].data0 = 0; @@ -1834,49 +1834,49 @@ void sub_808E978(u8 a) { u8 spriteId; u16 r5; - + spriteId = CreateSprite(&gSpriteTemplate_83A053C, 0xB8, 4, 0); gSprites[spriteId].data1 = 0; - + spriteId = CreateSprite(&gSpriteTemplate_83A053C, 0xB8, 0x9C, 0); gSprites[spriteId].data1 = 1; gSprites[spriteId].vFlip = 1; - + CreateSprite(&gSpriteTemplate_83A0524, 0xEA, 0x14, 0); CreateSprite(&gSpriteTemplate_83A0554, 0x10, 0x8A, 0); - + spriteId = CreateSprite(&gSpriteTemplate_83A0554, 0x30, 0x8A, 0); StartSpriteAnim(&gSprites[spriteId], 3); - + spriteId = CreateSprite(&gSpriteTemplate_83A0554, 0x10, 0x9E, 0); StartSpriteAnim(&gSprites[spriteId], 2); gSprites[spriteId].data2 = 0x80; - + spriteId = CreateSprite(&gSpriteTemplate_83A0554, 0x30, 0x9E, 0); StartSpriteAnim(&gSprites[spriteId], 1); - + spriteId = CreateSprite(&gSpriteTemplate_83A056C, 0, 0x50, 2); gSprites[spriteId].oam.affineMode = 1; gSprites[spriteId].oam.matrixNum = 30; gSprites[spriteId].data0 = 0x1E; gSprites[spriteId].data1 = 0; - + spriteId = CreateSprite(&gSpriteTemplate_83A056C, 0, 0x50, 2); gSprites[spriteId].oam.affineMode = 1; gSprites[spriteId].oam.matrixNum = 31; gSprites[spriteId].data0 = 0x1F; gSprites[spriteId].data1 = 0x80; - + if(a == 0) { u32 _a; - + CreateSprite(&gSpriteTemplate_83A0584, 0x20, 0x28, 1); - + spriteId = CreateSprite(&gSpriteTemplate_83A0584, 0x20, 0x48, 1); StartSpriteAnim(&gSprites[spriteId], 1); _a = 0; - + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x1C, 0x30, 1); r5 = gPokedexView->unk61A / 100; StartSpriteAnim(&gSprites[spriteId], r5); @@ -1884,19 +1884,19 @@ void sub_808E978(u8 a) _a = 1; else gSprites[spriteId].invisible = 1; - + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x22, 0x30, 1); r5 = (gPokedexView->unk61A % 100) / 10; if(r5 != 0 || _a != 0) StartSpriteAnim(&gSprites[spriteId], r5); else gSprites[spriteId].invisible = 1; - + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x28, 0x30, 1); r5 = (gPokedexView->unk61A % 100) % 10; StartSpriteAnim(&gSprites[spriteId], r5); _a = 0; - + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x1C, 0x50, 1); r5 = gPokedexView->unk61C / 100; StartSpriteAnim(&gSprites[spriteId], r5); @@ -1904,18 +1904,18 @@ void sub_808E978(u8 a) _a = 1; else gSprites[spriteId].invisible = 1; - + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x22, 0x50, 1); r5 = (gPokedexView->unk61C % 100) / 10; if(r5 != 0 || _a != 0) StartSpriteAnim(&gSprites[spriteId], r5); else gSprites[spriteId].invisible = 1; - + spriteId = CreateSprite(&gSpriteTemplate_83A059C, 0x28, 0x50, 1); r5 = (gPokedexView->unk61C % 100) % 10; StartSpriteAnim(&gSprites[spriteId], r5); - + spriteId = CreateSprite(&gSpriteTemplate_83A05B4, 0x8C, 0x60, 1); gSprites[spriteId].invisible = 1; } @@ -1962,7 +1962,7 @@ void sub_808EDB8(struct Sprite *sprite) void sub_808EE28(struct Sprite *sprite) { u8 data1 = sprite->data1; - + if(gPokedexView->unk64A != 0 && gPokedexView->unk64A != 3) { DestroySprite(sprite); @@ -1972,14 +1972,14 @@ void sub_808EE28(struct Sprite *sprite) { //_0808EE58 s32 var; - + sprite->pos2.y = gSineTable[(u8)sprite->data5] * 76 / 256; var = 0x10000 / gSineTable[sprite->data5 + 0x40]; if((u32)var > 0xFFFF) var = 0xFFFF; SetOamMatrix(sprite->data1 + 1, 0x100, 0, 0, var); sprite->oam.matrixNum = data1 + 1; - + //ToDo: clean up these inequalities if((u16)(sprite->data5 + 0x3F) <= 0x7E) { @@ -2015,9 +2015,9 @@ void sub_808EF8C(struct Sprite *sprite) else { u8 r0; - + if(sprite->data1 != 0) - { + { if(gPokedexView->selectedPokemon == gPokedexView->unk60C - 1) sprite->invisible = 1; else @@ -2055,14 +2055,14 @@ void sub_808F0B4(struct Sprite *sprite) else { s16 r3; - + u8 unk = gPokedexView->unk62C + sprite->data1; u16 foo = gSineTable[unk]; //u8 unk2 = sprite->data0; //u16 bar = gSineTable[unk + 0x40]; - + SetOamMatrix(sprite->data0, foo, gSineTable[unk + 0x40], (-(u16)foo) >> 16, gSineTable[unk + 0x40]); - + r3 = gSineTable[sprite->data1 + gPokedexView->unk62C]; sprite->pos2.x = gSineTable[sprite->data1 + gPokedexView->unk62C + 0x40] * 5 / 256; sprite->pos2.y = r3 * 40 / 256; @@ -2173,7 +2173,7 @@ void sub_808F168(struct Sprite *sprite) else { u16 r1 = gPokedexView->unk64A == 0 ? 0x50 : 0x60; - + if(gPokedexView->menuIsOpen != 0 && gPokedexView->menuY == r1) { sprite->invisible = 0; @@ -2189,7 +2189,7 @@ void sub_808F168(struct Sprite *sprite) u8 sub_808F210(struct PokedexListItem *item, u8 b) { u8 taskId; - + gUnknown_0202FFBC = item; taskId = CreateTask(Task_InitPageScreenMultistep, 0); gTasks[taskId].data[0] = 0; @@ -2227,7 +2227,7 @@ void Task_InitPageScreenMultistep(u8 taskId) if(!gPaletteFade.active) { u16 r2; - + gPokedexView->unk64A = 1; gPokedexView->unk64E = 0; gUnknown_03005CEC = gMain.vblankCallback; @@ -2296,7 +2296,7 @@ void Task_InitPageScreenMultistep(u8 taskId) case 6: { u32 r3 = 0; - + if(gTasks[taskId].data[2] != 0) r3 = 0x14; if(gTasks[taskId].data[1] != 0) @@ -2523,7 +2523,7 @@ void Task_InitCryScreenMultistep(u8 taskId) case 6: { struct CryRelatedStruct sp8; - + sp8.unk0 = 0x4020; sp8.unk2 = 0x1F; sp8.unk3 = 8; @@ -2535,11 +2535,11 @@ void Task_InitCryScreenMultistep(u8 taskId) gUnknown_03005E98 = 0; } break; - } + } case 7: { struct CryRelatedStruct sp10; - + sp10.unk0 = 0x3000; sp10.unk2 = 0xE; sp10.unk3 = 9; @@ -2577,12 +2577,12 @@ void Task_InitCryScreenMultistep(u8 taskId) void Task_CryScreenProcessInput(u8 taskId) { sub_8119F88(0); - + if (IsCryPlaying()) sub_8090040(1); else sub_8090040(0); - + if (gMain.newKeys & A_BUTTON) { sub_8090040(1); @@ -2648,7 +2648,7 @@ void sub_808FFBC(u8 taskId) void sub_8090040(u8 a) { u16 unk; - + if(a != 0) unk = 0x392; else @@ -2659,7 +2659,7 @@ void sub_8090040(u8 a) void Task_InitSizeScreenMultistep(u8 taskId) { u8 spriteId; - + switch(gMain.state) { default: @@ -2688,7 +2688,7 @@ void Task_InitSizeScreenMultistep(u8 taskId) case 3: { u8 string[40]; //I hope this is the correct size - + SetUpWindowConfig(&gWindowConfig_81E702C); InitMenuWindow(&gWindowConfig_81E702C); string[0] = EOS; @@ -2802,15 +2802,15 @@ void sub_8090584(u8 a, u16 b) u8 j; //r3 u32 r6; register u8 r7; - + for(i = 0; i < 4; i++) { r7 = i * 5 + 1; r6 = 0x4000; - + if(i == a) r6 = 0x2000; - + for(j = 0; j < 5; j++) { u32 r0 = b * 0x800 + (r7 + j) * 2; @@ -2827,7 +2827,7 @@ void sub_8090584(u8 a, u16 b) { u32 r0 = b * 0x800 + j * 2; u8 *ptr; - + ptr = VRAM + 0x32; *(u16 *)(ptr + r0) = *(u16 *)(ptr + r0) & 0xFFF | r6; ptr = VRAM + 0x72; @@ -2946,32 +2946,32 @@ void sub_8090644(u8 a, u16 b) { u8 i; u8 j; - + for(i = 0; i < 4; i++) { u8 r8 = i * 5 + 1; u32 r5; - + if(i == a || i == 0) r5 = 0x2000; else if(a != 0) r5 = 0x4000; - + for(j = 0; j < 5; j++) { u16 (*vramData)[0x400]; - + vramData = (u16 (*)[])VRAM; vramData[b][r8 + j] = vramData[b][r8 + j] & 0xFFF | r5; vramData = (u16 (*)[])(VRAM + 0x40); vramData[b][r8 + j] = vramData[b][r8 + j] & 0xFFF | r5; } } - + for(j = 0; j < 5; j++) { u16 (*vramData)[0x400]; - + vramData = (u16 (*)[])(VRAM + 0x32); vramData[b][j] = vramData[b][j] & 0xFFF | 0x4000; vramData = (u16 (*)[])(VRAM + 0x72); @@ -3093,7 +3093,7 @@ _08090708: .4byte 0x06000072\n\ u8 sub_809070C(u16 dexNum, u32 b, u32 c) { u8 taskId = CreateTask(sub_8090750, 0); - + gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = dexNum; gTasks[taskId].data[12] = b; @@ -3107,7 +3107,7 @@ u8 sub_809070C(u16 dexNum, u32 b, u32 c) void sub_8090750(u8 taskId) { u16 dexNum = gTasks[taskId].data[1]; - + switch(gTasks[taskId].data[0]) { default: @@ -3123,7 +3123,7 @@ void sub_8090750(u8 taskId) case 1: { u16 i; - + LZ77UnCompVram(gPokedexMenu_Gfx, (void *)(VRAM + 0x4000)); LZ77UnCompVram(gUnknown_08E96BD4, (void *)(VRAM + 0x7800)); for(i = 0; i < 0x280; i++) @@ -3160,7 +3160,7 @@ void sub_8090750(u8 taskId) case 4: { u8 spriteId = sub_80918EC(dexNum, 0x30, 0x38, 0); - + gSprites[spriteId].oam.priority = 0; BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); SetVBlankCallback(gUnknown_03005CEC); diff --git a/src/pokemon_1.c b/src/pokemon_1.c index b8735fbc4..1c11449c3 100644 --- a/src/pokemon_1.c +++ b/src/pokemon_1.c @@ -1,14 +1,14 @@ #include "global.h" #include "asm.h" -#include "text.h" -#include "string_util.h" +#include "items.h" +#include "main.h" #include "pokemon.h" +#include "rng.h" #include "rom4.h" #include "species.h" -#include "main.h" -#include "rng.h" #include "sprite.h" -#include "items.h" +#include "string_util.h" +#include "text.h" //Extracts the upper 16 bits of a 32-bit number #define HIHALF(n) (((n) & 0xFFFF0000) >> 16) diff --git a/src/pokemon_2.c b/src/pokemon_2.c index f6bd432c7..69ae03767 100644 --- a/src/pokemon_2.c +++ b/src/pokemon_2.c @@ -1,13 +1,13 @@ #include "global.h" #include "asm.h" -#include "text.h" -#include "string_util.h" +#include "event_data.h" +#include "main.h" #include "pokemon.h" #include "rng.h" #include "species.h" -#include "main.h" #include "sprite.h" -#include "event_data.h" +#include "string_util.h" +#include "text.h" extern u8 gPlayerPartyCount; extern struct Pokemon gPlayerParty[6]; diff --git a/src/pokemon_3.c b/src/pokemon_3.c index cf172b122..f313bff49 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1,16 +1,16 @@ #include "global.h" #include "asm.h" -#include "text.h" -#include "string_util.h" +#include "event_data.h" +#include "item.h" +#include "items.h" +#include "main.h" #include "pokemon.h" #include "rng.h" +#include "rtc.h" #include "species.h" -#include "main.h" #include "sprite.h" -#include "event_data.h" -#include "rtc.h" -#include "item.h" -#include "items.h" +#include "string_util.h" +#include "text.h" #define EVO_FRIENDSHIP 0x0001 // Pokémon levels up with friendship ≥ 220 #define EVO_FRIENDSHIP_DAY 0x0002 // Pokémon levels up during the day with friendship ≥ 220 diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c index 6cf3411a9..1c6b6accb 100644 --- a/src/pokemon_size_record.c +++ b/src/pokemon_size_record.c @@ -1,8 +1,9 @@ #include "global.h" #include "pokemon_size_record.h" -#include "string_util.h" -#include "species.h" #include "event_data.h" +#include "species.h" +#include "string_util.h" +#include "text.h" extern u16 SpeciesToNationalPokedexNum(u16); extern u16 GetPokedexHeightWeight(u16, u8); diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index b6b24b9d7..7bf9ef078 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1,12 +1,9 @@ #include "global.h" #include "asm.h" +#include "link.h" #include "menu.h" #include "pokemon.h" #include "string_util.h" -#include "link.h" - -extern u8 gStringVar1[]; -extern u8 gStringVar4[]; extern struct Pokemon *unk_2018000; diff --git a/src/record_mixing.c b/src/record_mixing.c index 12b87b2b1..554f360fa 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -1,6 +1,7 @@ #include "global.h" #include "record_mixing.h" #include "asm.h" +#include "event_data.h" #include "link.h" #include "menu.h" #include "rom4.h" @@ -9,7 +10,6 @@ #include "sound.h" #include "string_util.h" #include "task.h" -#include "event_data.h" extern void *recordMixingSecretBases; extern void *recordMixingTvShows; @@ -59,7 +59,7 @@ void sub_80B92AC(void) { sub_80BC300(); sub_80C045C(); - + memcpy(unk_2018000.secretBases, recordMixingSecretBases, sizeof(unk_2018000.secretBases)); memcpy(unk_2018000.tvShows, recordMixingTvShows, sizeof(unk_2018000.tvShows)); memcpy(unk_2018000.filler1004, gUnknown_083D0274, 0x40); @@ -70,7 +70,7 @@ void sub_80B92AC(void) sub_8041324(gSaveBlock1.filler_2F9C, gUnknown_02038738); memcpy(unk_2018000.filler10AC, gUnknown_083D0280, 0x78); memcpy(unk_2018000.filler1124, gUnknown_083D0284, 0xA4); - + if(GetMultiplayerId() == 0) unk_2018000.filler11C8[0] = sub_8126338(); } @@ -211,7 +211,7 @@ void sub_80B9450(u8 taskId) void sub_80B9484(u8 taskId) { s16 *taskData = gTasks[taskId].data; - + switch(taskData[TD_STATE]) { case 0: @@ -268,7 +268,7 @@ void sub_80B9484(u8 taskId) void sub_80B95F0(u8 taskId) { struct Task *task = &gTasks[taskId]; - + switch(task->data[TD_STATE]) { case 0: @@ -290,7 +290,7 @@ void sub_80B95F0(u8 taskId) case 101: { u8 players = GetLinkPlayerCount_2(); - + if(IsLinkMaster() == 1) { if(players == sub_800820C()) @@ -339,7 +339,7 @@ void sub_80B95F0(u8 taskId) case 2: { u8 subTaskId; - + task->data[6] = GetLinkPlayerCount_2(); task->data[TD_STATE] = 0; task->data[5] = GetMultiplayerId_(); @@ -366,13 +366,13 @@ void sub_80B95F0(u8 taskId) void sub_80B97DC(u8 taskId) { struct Task *task = &gTasks[taskId]; - + switch(task->data[TD_STATE]) { case 0: //Copy record data to send buffer { void *recordData = (u8 *)LoadPtrFromTaskData(&task->data[2]) + BUFFER_CHUNK_SIZE * task->data[4]; - + memcpy(gBlockSendBuffer, recordData, BUFFER_CHUNK_SIZE); task->data[TD_STATE]++; break; @@ -402,18 +402,18 @@ void Task_CopyRecvBuffer(u8 taskId) struct Task *task = &gTasks[taskId]; s32 recvStatus = GetBlockReceivedStatus(); u32 sp8 = 0; - + if(recvStatus == sub_8008198()) { u8 player; - + for(player = 0; player < GetLinkPlayerCount(); player++) { //_080B98D4 u8 *ptr; void *src; u8 *dst; - + if((recvStatus >> player) & 1) { ptr = LoadPtrFromTaskData(&task->data[5]); @@ -441,7 +441,7 @@ void Task_CopyRecvBuffer(u8 taskId) void sub_80B99B4(u8 taskId) { struct Task *task = &gTasks[taskId]; - + if(!gTasks[task->data[10]].isActive) DestroyTask(taskId); } @@ -449,7 +449,7 @@ void sub_80B99B4(u8 taskId) void sub_80B99E8(u8 taskId) { struct Task *task = &gTasks[taskId]; - + task->func = sub_80B99B4; if(gUnknown_03000718 == 1) sub_80B93B0(task->data[5]); @@ -492,7 +492,7 @@ void sub_80B9A88(u8 *a) u32 i; u32 id; u32 players = GetLinkPlayerCount(); - + switch(players) { case 2: @@ -518,7 +518,7 @@ void sub_80B9B1C(u8 *a, size_t size, u8 index) { u8 arr[4]; u8 *ptr; - + sub_80B9A88(arr); //Probably not how it was originally written, but this matches. memcpy(a + index * size, (ptr = gUnknown_083D0278), 0x40); @@ -623,7 +623,7 @@ u8 sub_80B9C4C(u8 *a) { int i; u8 r2 = 0; - + for(i = 0; i < 0x100; i++) r2 += a[i]; return r2; @@ -647,7 +647,7 @@ struct UnkStruct1 u32 unk48; u32 unk4C; u32 unk50; - + }; /* @@ -657,7 +657,7 @@ extern void sub_80B9C6C(void *a, u32 b, u8 c, void *d) struct UnkStruct1 s; u16 r8; u16 r3; - + s.unk2C = a; s.unk30 = b; s.unk38 = d; @@ -666,15 +666,15 @@ extern void sub_80B9C6C(void *a, u32 b, u8 c, void *d) SeedRng(gLinkPlayers[0].trainerId); r8 = GetLinkPlayerCount(); r3 = 0; - + s.unk4C = 12; - + while(r3 < 4) { s.unk4[r3] |= 0xFF; s.unk8[r3] = 0; - + s.unk1C[r3][0] = 0; s.unk1C[r3][1] = 0; r3++; @@ -683,7 +683,7 @@ extern void sub_80B9C6C(void *a, u32 b, u8 c, void *d) r3 = 0; s.unk50 = r8 << 16; s.unk48 = s.unk30 * s.unk34; - + if(s.unk3C < r8) { do //_080B9D00 @@ -691,7 +691,7 @@ extern void sub_80B9C6C(void *a, u32 b, u8 c, void *d) u32 *r6 = (u32 *)(s.unk2C + s.unk30 * r3); if(r6[0x1C] != 0 && r6[0x1C] > 0) { - + } //_080B9D3C } diff --git a/src/rom4.c b/src/rom4.c index 521f07a48..fe5b7cb45 100644 --- a/src/rom4.c +++ b/src/rom4.c @@ -4,17 +4,19 @@ #include "asm_fieldmap.h" #include "battle_setup.h" #include "berry.h" +#include "event_data.h" #include "field_camera.h" #include "field_effect.h" #include "field_map_obj.h" #include "field_message_box.h" #include "field_player_avatar.h" -#include "event_data.h" +#include "field_special_scene.h" #include "heal_location.h" #include "link.h" #include "load_save.h" #include "main.h" #include "menu.h" +#include "metatile_behavior.h" #include "new_game.h" #include "palette.h" #include "play_time.h" @@ -26,10 +28,8 @@ #include "start_menu.h" #include "task.h" #include "tileset_anim.h" -#include "field_special_scene.h" #include "weather.h" #include "wild_encounter.h" -#include "metatile_behavior.h" #ifdef SAPPHIRE #define LEGENDARY_MUSIC BGM_OOAME // Heavy Rain @@ -667,15 +667,15 @@ bool32 IsBikingAllowedByMap(void) return FALSE; if (gMapHeader.mapType == MAP_TYPE_UNDERWATER) return FALSE; - + // is player in SeafloorCavern_Room9? if (gSaveBlock1.location.mapGroup == 24 && gSaveBlock1.location.mapNum == 36) return FALSE; - + // is player in CaveOfOrigin_B4F? if (gSaveBlock1.location.mapGroup == 24 && gSaveBlock1.location.mapNum == 42) return FALSE; - + return TRUE; } diff --git a/src/rom_8080874.c b/src/rom_8080874.c index 8c41b913a..29aeac97b 100644 --- a/src/rom_8080874.c +++ b/src/rom_8080874.c @@ -1,9 +1,9 @@ #include "global.h" -#include "global.fieldmap.h" #include "gba/syscall.h" -#include "weather.h" -#include "task.h" +#include "global.fieldmap.h" #include "script.h" +#include "task.h" +#include "weather.h" void palette_bg_fill_white(void); void palette_bg_fill_black(void); diff --git a/src/safari_zone.c b/src/safari_zone.c index 08bfbefbf..8c2b63469 100644 --- a/src/safari_zone.c +++ b/src/safari_zone.c @@ -1,12 +1,13 @@ #include "global.h" #include "safari_zone.h" #include "asm.h" -#include "field_player_avatar.h" #include "event_data.h" +#include "field_player_avatar.h" #include "main.h" +#include "rom4.h" #include "script.h" #include "string_util.h" -#include "rom4.h" +#include "text.h" struct PokeblockFeeder { diff --git a/src/save.c b/src/save.c index 49db679f8..1bb8703c4 100644 --- a/src/save.c +++ b/src/save.c @@ -1,10 +1,10 @@ #include "global.h" +#include "gba/gba.h" #include "save.h" #include "asm.h" -#include "gba/gba.h" +#include "gba/flash_internal.h" #include "load_save.h" #include "rom4.h" -#include "gba/flash_internal.h" #include "save_failed_screen.h" extern struct SaveSection unk_2000000; diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 2396aab15..962e8207b 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -1,14 +1,14 @@ #include "global.h" +#include "asm.h" +#include "gba/flash_internal.h" +#include "m4a.h" #include "main.h" -#include "sprite.h" +#include "menu.h" #include "palette.h" +#include "save.h" +#include "sprite.h" #include "task.h" #include "text.h" -#include "menu.h" -#include "save.h" -#include "m4a.h" -#include "gba/flash_internal.h" -#include "asm.h" // In English 1.0, the text window is too small, causing text to overflow. diff --git a/src/save_menu_util.c b/src/save_menu_util.c index 64acd12f7..7790bbb1b 100644 --- a/src/save_menu_util.c +++ b/src/save_menu_util.c @@ -1,10 +1,10 @@ #include "global.h" #include "save_menu_util.h" #include "asm.h" -#include "menu.h" #include "event_data.h" -#include "string_util.h" +#include "menu.h" #include "pokedex.h" +#include "string_util.h" extern u8 gOtherText_Player[]; extern u8 gOtherText_Badges[]; @@ -54,9 +54,9 @@ void HandleCloseSaveWindow(u16 left, u16 top) MenuZeroFillWindowRect(left, top, left + width, top + 9); } -/* -theory: This function was used to handle the save menu window's width being auto sized from -either 12 or 13 in an older source. Whatever was here might have either been optimized out by +/* +theory: This function was used to handle the save menu window's width being auto sized from +either 12 or 13 in an older source. Whatever was here might have either been optimized out by GF's compiler or was dummied out to always return a TRUE at some point. */ u8 IsResizeSaveWindowEnabled(void) // i don't know what else to name it.. diff --git a/src/scrcmd.c b/src/scrcmd.c index f41d57ffb..a13a42e87 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -1,28 +1,28 @@ #include "global.h" #include "asm.h" +#include "asm_fieldmap.h" #include "battle_setup.h" #include "berry.h" +#include "coins.h" +#include "decoration.h" +#include "event_data.h" +#include "field_effect.h" +#include "field_message_box.h" #include "field_player_avatar.h" #include "item.h" -#include "script.h" -#include "rng.h" -#include "palette.h" -#include "rtc.h" -#include "pokemon.h" -#include "asm_fieldmap.h" #include "main.h" +#include "map_obj_lock.h" #include "menu.h" #include "money.h" -#include "decoration.h" -#include "field_message_box.h" +#include "palette.h" +#include "pokemon.h" +#include "rng.h" +#include "rom4.h" +#include "rtc.h" +#include "script.h" #include "sound.h" #include "string_util.h" -#include "event_data.h" -#include "rom4.h" #include "weather.h" -#include "map_obj_lock.h" -#include "coins.h" -#include "field_effect.h" typedef u16 (*SpecialFunc)(void); typedef void (*NativeFunc)(void); diff --git a/src/script_menu.c b/src/script_menu.c index c4f0b5292..e1783208c 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -1,11 +1,11 @@ #include "global.h" -#include "task.h" +#include "event_data.h" #include "menu.h" #include "palette.h" #include "script.h" #include "sound.h" -#include "event_data.h" #include "sprite.h" +#include "task.h" struct MultichoiceListStruct { @@ -369,7 +369,7 @@ void sub_80B5838(void) void task_picbox(u8 taskId) { struct Task *task = &gTasks[taskId]; - + switch(task->data[0]) { case 0: diff --git a/src/sound.c b/src/sound.c index e757eedf5..ea8d5b49c 100644 --- a/src/sound.c +++ b/src/sound.c @@ -1,11 +1,11 @@ #include "global.h" #include "sound.h" #include "asm.h" +#include "battle.h" #include "gba/m4a_internal.h" -#include "task.h" -#include "songs.h" #include "m4a.h" -#include "battle.h" +#include "songs.h" +#include "task.h" struct Fanfare { diff --git a/src/sprite.c b/src/sprite.c index df101b61f..f20ea2927 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -1,8 +1,8 @@ #include "global.h" #include "sprite.h" #include "main.h" -#include "palette.h" #include "menu_cursor.h" +#include "palette.h" #define MAX_SPRITE_COPY_REQUESTS 64 diff --git a/src/start_menu.c b/src/start_menu.c index 8ef3a9d2b..ee6582553 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -1,8 +1,8 @@ #include "global.h" #include "start_menu.h" #include "asm.h" -#include "field_player_avatar.h" #include "event_data.h" +#include "field_player_avatar.h" #include "load_save.h" #include "main.h" #include "map_obj_lock.h" @@ -191,7 +191,7 @@ static void BuildStartMenuActions_Link(void) AddStartMenuAction(MENU_ACTION_POKENAV); AddStartMenuAction(MENU_ACTION_PLAYER_LINK); AddStartMenuAction(MENU_ACTION_OPTION); - AddStartMenuAction(MENU_ACTION_EXIT); + AddStartMenuAction(MENU_ACTION_EXIT); } //Show number of safari balls left @@ -206,7 +206,7 @@ static void DisplaySafariBallsWindow(void) static bool32 PrintStartMenuItemsMultistep(s16 *index, u32 n) { int _index = *index; - + do { MenuPrint(sStartMenuItems[sCurrentStartMenuActions[_index]].text, 23, 2 + _index * 2); @@ -258,7 +258,7 @@ static void InitStartMenu(void) { s16 step = 0; s16 index = 0; - + while(InitStartMenuMultistep(&step, &index) == FALSE) ; } @@ -275,7 +275,7 @@ static void Task_StartMenu(u8 taskId) void CreateStartMenuTask(void (*func)(u8)) { u8 taskId; - + InitMenuWindow(&gWindowConfig_81E6CE4); taskId = CreateTask(Task_StartMenu, 0x50); SetTaskFuncWithFollowupFunc(taskId, Task_StartMenu, func); @@ -490,7 +490,7 @@ static u8 SaveCallback2(void) return TRUE; } return FALSE; -} +} static void sub_807160C(void) { @@ -528,13 +528,13 @@ static void DisplaySaveMessageWithCallback(u8 *ptr, u8 (*func)(void)) static void Task_SaveDialog(u8 taskId) { u8 status = RunSaveDialogCallback(); - + switch(status) { case SAVE_CANCELED: case SAVE_ERROR: gScriptResult = 0; - break; + break; case SAVE_SUCCESS: gScriptResult = status; break; @@ -671,7 +671,7 @@ static u8 SaveDialogCB_DisplaySavingMessage(void) static u8 SaveDialogCB_DoSave(void) { u8 a; - + IncrementGameStat(0); if(gUnknown_020297EC == TRUE) { @@ -682,7 +682,7 @@ static u8 SaveDialogCB_DoSave(void) { a = sub_8125D44(0); } - + if(a == 1) { //"(Player) saved the game." @@ -693,7 +693,7 @@ static u8 SaveDialogCB_DoSave(void) //"Save error. Please exchange the backup memory." DisplaySaveMessageWithCallback(gSystemText_SaveErrorExchangeBackup, SaveDialogCB_SaveError); } - + SaveDialogStartTimeout(); return SAVE_IN_PROGRESS; } @@ -753,7 +753,7 @@ static bool32 sub_80719FC(u8 *step) { u8 *addr; u32 size; - + REG_DISPCNT = 0; SetVBlankCallback(NULL); remove_some_task(); @@ -787,7 +787,7 @@ static bool32 sub_80719FC(u8 *step) case 3: { u32 savedIme; - + BlendPalettes(-1, 0x10, 0); SetVBlankCallback(sub_80719F0); savedIme = REG_IME; @@ -821,7 +821,7 @@ static void sub_8071B54(void) static void Task_8071B64(u8 taskId) { s16 *step = gTasks[taskId].data; - + if(!gPaletteFade.active) { switch(*step) @@ -850,7 +850,7 @@ static void Task_8071B64(u8 taskId) case 4: SetMainCallback2(gMain.savedCallback); DestroyTask(taskId); - break; + break; } } } diff --git a/src/starter_choose.c b/src/starter_choose.c index 9bd817cce..28dd6a820 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -1,17 +1,17 @@ #include "global.h" #include "starter_choose.h" #include "asm.h" +#include "decompress.h" #include "main.h" #include "menu.h" #include "palette.h" #include "pokedex.h" #include "songs.h" #include "sound.h" +#include "sprite.h" #include "string_util.h" #include "task.h" #include "trig.h" -#include "decompress.h" -#include "sprite.h" struct MonCoords { @@ -87,9 +87,9 @@ void CB2_ChooseStarter(void) u16 savedIme; u8 taskId; u8 spriteId; - + SetVBlankCallback(NULL); - + REG_DISPCNT = 0; REG_BG3CNT = 0; REG_BG2CNT = 0; @@ -103,11 +103,11 @@ void CB2_ChooseStarter(void) REG_BG1VOFS = 0; REG_BG0HOFS = 0; REG_BG0VOFS = 0; - + DmaFill16(3, 0, VRAM, VRAM_SIZE); DmaFill32(3, 0, OAM, OAM_SIZE); DmaFill16(3, 0, PLTT, PLTT_SIZE); - + LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM); LZ77UnCompVram(&gBirchBagTilemap, (void *)(VRAM + 0x3000)); LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800)); @@ -123,16 +123,16 @@ void CB2_ChooseStarter(void) SetUpWindowConfig(&gWindowConfig_81E6C3C); InitMenuWindow(&gWindowConfig_81E6CE4); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); - + savedIme = REG_IME; REG_IME = 0; REG_IE |= INTR_FLAG_VBLANK; REG_IME = savedIme; REG_DISPSTAT |= DISPSTAT_VBLANK_INTR; - + SetVBlankCallback(VblankCallback); SetMainCallback2(MainCallback2); - + REG_WININ = 0x3F; REG_WINOUT = 0x1F; REG_WIN0H = 0; @@ -144,14 +144,14 @@ void CB2_ChooseStarter(void) REG_BG2CNT = 0x602; REG_BG0CNT = 0x1F08; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG2_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON; - + taskId = CreateTask(Task_StarterChoose1, 0); gTasks[taskId].data[TD_STARTERSELECTION] = 1; - + //Create hand sprite spriteId = CreateSprite(&gSpriteTemplate_83F77CC, 120, 56, 2); gSprites[spriteId].data0 = taskId; - + //Create three Pokeball sprites spriteId = CreateSprite( &gSpriteTemplate_83F77E4, @@ -189,20 +189,20 @@ static void Task_StarterChoose1(u8 taskId) static void Task_StarterChoose2(u8 taskId) { u8 selection = gTasks[taskId].data[TD_STARTERSELECTION]; - + if(gMain.newKeys & A_BUTTON) { u8 spriteId; - + MenuZeroFillWindowRect( gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1], gStarterChoose_LabelCoords[selection][0] + 13, gStarterChoose_LabelCoords[selection][1] + 3); - + REG_WIN0H = 0; REG_WIN0V = 0; - + //Create white circle background spriteId = CreateSprite( &gSpriteTemplate_83F77FC, @@ -210,7 +210,7 @@ static void Task_StarterChoose2(u8 taskId) gStarterChoose_PokeballCoords[selection][1], 1); gTasks[taskId].data[TD_CIRCLE_SPRITE_ID] = spriteId; - + //Create Pokemon sprite spriteId = CreatePokemonFrontSprite( GetStarterPokemon(gTasks[taskId].data[TD_STARTERSELECTION]), @@ -219,7 +219,7 @@ static void Task_StarterChoose2(u8 taskId) gSprites[spriteId].affineAnims = gSpriteAffineAnimTable_83F778C; gSprites[spriteId].callback = StarterPokemonSpriteAnimCallback; gTasks[taskId].data[TD_PKMN_SPRITE_ID] = spriteId; - + gTasks[taskId].func = Task_StarterChoose3; } else @@ -260,7 +260,7 @@ static void Task_StarterChoose4(u8 taskId) static void Task_StarterChoose5(u8 taskId) { u8 spriteId; - + switch(ProcessMenuInputNoWrap_()) { case 0: //YES @@ -272,12 +272,12 @@ static void Task_StarterChoose5(u8 taskId) case -1: //B button PlaySE(SE_SELECT); MenuZeroFillWindowRect(21, 7, 27, 12); - + spriteId = gTasks[taskId].data[TD_PKMN_SPRITE_ID]; FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[spriteId].oam.paletteNum)); FreeOamMatrix(gSprites[spriteId].oam.matrixNum); DestroySprite(&gSprites[spriteId]); - + spriteId = gTasks[taskId].data[TD_CIRCLE_SPRITE_ID]; FreeOamMatrix(gSprites[spriteId].oam.matrixNum); DestroySprite(&gSprites[spriteId]); @@ -313,12 +313,12 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) u8 srcIndex; u8 dstIndex; u16 species; - + u8 labelLeft; u8 labelRight; u8 labelTop; u8 labelBottom; - + if(prevSelection != 0xFF) { //Remove the old Pokemon label @@ -337,7 +337,7 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) SET_CHAR(labelText, 5, EXT_CTRL_CODE_BEGIN); SET_CHAR(labelText, 6, 0x11); SET_CHAR(labelText, 7, dstIndex); - + //Copy category string to label dstIndex = 8; srcIndex = 0; @@ -348,7 +348,7 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) dstIndex++; } labelText[dstIndex++] = CHAR_SPACE; - + //Copy POKEMON string to label StringCopy(labelText + dstIndex, gOtherText_Poke); MenuPrint( @@ -356,14 +356,14 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1]); AddTextColorCtrlCode(labelText, 0, 15, 8); - + //Copy Pokemon name to label sub_8072C74(labelText + 5, gSpeciesNames[species], 0x6B, 1); MenuPrint( labelText, gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1] + 2); - + labelLeft = gStarterChoose_LabelCoords[selection][0] * 8 + 4; labelRight = (gStarterChoose_LabelCoords[selection][0] + 13) * 8 + 4; labelTop = gStarterChoose_LabelCoords[selection][1] * 8; @@ -374,13 +374,13 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) void nullsub_72(struct Sprite *sprite) { - + } static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y) { u8 spriteId; - + DecompressPicFromTable_2( &gMonFrontPicTable[species], gMonFrontPicCoords[species].x, gMonFrontPicCoords[species].y, diff --git a/src/text.c b/src/text.c index 6089fdba8..44ce6655f 100644 --- a/src/text.c +++ b/src/text.c @@ -1,11 +1,11 @@ #include "global.h" #include "text.h" +#include "battle.h" #include "main.h" -#include "string_util.h" -#include "songs.h" #include "palette.h" +#include "songs.h" #include "sound.h" -#include "battle.h" +#include "string_util.h" enum { diff --git a/src/text_window.c b/src/text_window.c index 1ac624dd0..9a88789d1 100644 --- a/src/text_window.c +++ b/src/text_window.c @@ -1,8 +1,8 @@ #include "global.h" #include "text_window.h" #include "main.h" -#include "text.h" #include "palette.h" +#include "text.h" #define STD_MSG_BOX_LEFT 0 #define STD_MSG_BOX_TOP 14 diff --git a/src/title_screen.c b/src/title_screen.c index ffa803d2e..35f3d049c 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -2,17 +2,17 @@ #include "title_screen.h" #include "asm.h" #include "clear_save_data_menu.h" -#include "m4a.h" -#include "main_menu.h" -#include "intro.h" +#include "decompress.h" +#include "event_data.h" #include "gba/m4a_internal.h" +#include "intro.h" +#include "m4a.h" #include "main.h" +#include "main_menu.h" #include "palette.h" #include "sound.h" #include "sprite.h" #include "task.h" -#include "decompress.h" -#include "event_data.h" extern u8 gReservedSpritePaletteCount; extern struct MusicPlayerInfo gMPlay_BGM; @@ -69,7 +69,7 @@ static void UpdateLegendaryMarkingColor(u8); void SpriteCallback_VersionBannerLeft(struct Sprite *sprite) { struct Task *task = &gTasks[sprite->data1]; - + if (task->data[1] != 0) { sprite->oam.objMode = 0; @@ -93,7 +93,7 @@ void SpriteCallback_VersionBannerLeft(struct Sprite *sprite) void SpriteCallback_VersionBannerRight(struct Sprite *sprite) { struct Task *task = &gTasks[sprite->data1]; - + if (task->data[1] != 0) { sprite->oam.objMode = 0; @@ -130,7 +130,7 @@ static void CreatePressStartBanner(s16 x, s16 y) { u8 i; u8 spriteId; - + x -= 32; for (i = 0; i < 3; i++, x += 32) { @@ -144,7 +144,7 @@ static void CreateCopyrightBanner(s16 x, s16 y) { u8 i; u8 spriteId; - + x -= 64; for (i = 0; i < 5; i++, x += 32) { @@ -160,7 +160,7 @@ void SpriteCallback_PokemonLogoShine(struct Sprite *sprite) if (sprite->data0) //Flash background { u16 backgroundColor; - + if (sprite->pos1.x < DISPLAY_WIDTH / 2) { //Brighten background color @@ -194,7 +194,7 @@ void SpriteCallback_PokemonLogoShine(struct Sprite *sprite) static void StartPokemonLogoShine(bool8 flashBackground) { u8 spriteId = CreateSprite(&gSpriteTemplate_8393FC0, 0, 68, 0); - + gSprites[spriteId].oam.objMode = 2; gSprites[spriteId].data0 = flashBackground; } @@ -264,7 +264,7 @@ void CB2_InitTitleScreen(void) case 2: { u8 taskId = CreateTask(Task_TitleScreenPhase1, 0); - + gTasks[taskId].data[TD_COUNTER] = 0x100; gTasks[taskId].data[TD_SKIP] = FALSE; gTasks[taskId].data[2] = -16; @@ -281,7 +281,7 @@ void CB2_InitTitleScreen(void) case 4: { u16 savedIme; - + sub_813CE30(0x78, 0x50, 0x100, 0); REG_BG2X = -29 * 256; REG_BG2Y = -33 * 256; @@ -340,11 +340,11 @@ static void Task_TitleScreenPhase1(u8 taskId) gTasks[taskId].data[TD_SKIP] = TRUE; gTasks[taskId].data[TD_COUNTER] = 0; } - + if (gTasks[taskId].data[TD_COUNTER] != 0) { u16 frameNum = gTasks[taskId].data[TD_COUNTER]; - + if (frameNum == 160 || frameNum == 64) StartPokemonLogoShine(TRUE); gTasks[taskId].data[TD_COUNTER]--; @@ -352,24 +352,24 @@ static void Task_TitleScreenPhase1(u8 taskId) else { u8 spriteId; - + REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; REG_WININ = 0; REG_WINOUT = 0; REG_BLDCNT = 0x3F50; REG_BLDALPHA = 0x1F; REG_BLDY = 0; - + //Create left side of version banner spriteId = CreateSprite(&gSpriteTemplate_8393ECC, 0x62, 0x1A, 0); gSprites[spriteId].invisible = TRUE; gSprites[spriteId].data1 = taskId; - + //Create right side of version banner spriteId = CreateSprite(&gSpriteTemplate_8393EE4, 0xA2, 0x1A, 0); gSprites[spriteId].invisible = TRUE; gSprites[spriteId].data1 = taskId; - + gTasks[taskId].data[5] = 88; gTasks[taskId].data[TD_COUNTER] = 144; gTasks[taskId].func = Task_TitleScreenPhase2; @@ -385,7 +385,7 @@ static void Task_TitleScreenPhase2(u8 taskId) gTasks[taskId].data[TD_SKIP] = TRUE; gTasks[taskId].data[TD_COUNTER] = 0; } - + if (gTasks[taskId].data[TD_COUNTER] != 0) gTasks[taskId].data[TD_COUNTER]--; else @@ -402,10 +402,10 @@ static void Task_TitleScreenPhase2(u8 taskId) gTasks[taskId].data[4] = 0; gTasks[taskId].func = Task_TitleScreenPhase3; } - + if (!(gTasks[taskId].data[TD_COUNTER] & 1) && gTasks[taskId].data[3] != 0) gTasks[taskId].data[3]++; - + //Slide Pokemon logo up REG_BG2Y = gTasks[taskId].data[3] * 256; } @@ -416,7 +416,7 @@ static void Task_TitleScreenPhase3(u8 taskId) REG_BLDCNT = 0x2142; REG_BLDALPHA = 0x1F0F; REG_BLDY = 0; - + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & START_BUTTON)) { FadeOutBGM(4); @@ -481,12 +481,12 @@ static void CB2_GoToResetRtcScreen(void) static void UpdateLegendaryMarkingColor(u8 frameNum) { u16 palette; - + if ((frameNum % 4) == 0) //Change color every 4th frame { u8 colorIntensity = (frameNum >> 2) & 31; //Take bits 2-6 of frameNum the color intensity u8 fadeDarker = (frameNum >> 2) & 32; - + if (!fadeDarker) palette = LEGENDARY_MARKING_COLOR(colorIntensity); else diff --git a/src/trainer_card.c b/src/trainer_card.c index 83551eb2b..d4e8c5e9f 100644 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -342,7 +342,7 @@ void sub_8093390(struct TrainerCard *arg1) { u8 sub_80934C4(u8 id) { return gTrainerCards[id].stars; -} +} static u32 sav12_xor_get_clamped_above(u8 index, u32 maxVal) { u32 value = GetGameStat(index); diff --git a/src/trainer_see.c b/src/trainer_see.c index c6cdc5658..28904d04d 100644 --- a/src/trainer_see.c +++ b/src/trainer_see.c @@ -1,14 +1,14 @@ #include "global.h" #include "trainer_see.h" #include "asm.h" -#include "battle_setup.h" -#include "field_player_avatar.h" -#include "field_map_obj.h" #include "asm_fieldmap.h" -#include "task.h" -#include "sprite.h" +#include "battle_setup.h" #include "field_effect.h" +#include "field_map_obj.h" +#include "field_player_avatar.h" #include "script.h" +#include "sprite.h" +#include "task.h" extern bool8 (*gIsTrainerInRange[])(struct MapObject *, u16, s16, s16); extern bool8 (*gTrainerSeeFuncList[])(u8, struct Task *, struct MapObject *); @@ -395,7 +395,7 @@ u8 FldEff_ExclamationMarkIcon1(void) if (spriteId != 64) sub_8084894(&gSprites[spriteId], 0, 0); - + return 0; } @@ -405,7 +405,7 @@ u8 FldEff_ExclamationMarkIcon2(void) if (spriteId != 64) sub_8084894(&gSprites[spriteId], 33, 1); - + return 0; } @@ -415,7 +415,7 @@ u8 FldEff_HeartIcon(void) if (spriteId != 64) sub_8084894(&gSprites[spriteId], 46, 0); - + return 0; } @@ -423,13 +423,13 @@ void sub_8084894(struct Sprite *sprite, u16 a2, u8 a3) { sprite->oam.priority = 1; sprite->coordOffsetEnabled = 1; - + sprite->data0 = gUnknown_0202FF84[0]; sprite->data1 = gUnknown_0202FF84[1]; sprite->data2 = gUnknown_0202FF84[2]; sprite->data3 = -5; sprite->data7 = a2; - + StartSpriteAnim(sprite, a3); } @@ -3,7 +3,6 @@ #include "event_data.h" #include "field_message_box.h" #include "flags.h" -#include "global.h" #include "rng.h" #include "string_util.h" #include "text.h" diff --git a/src/wallclock.c b/src/wallclock.c index 147a68d31..2c4a78956 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -7,9 +7,9 @@ #include "palette.h" #include "rtc.h" #include "songs.h" +#include "sound.h" #include "task.h" #include "trig.h" -#include "sound.h" extern u16 gSpecialVar_0x8004; extern u16 gMiscClockMale_Pal[]; @@ -80,7 +80,7 @@ static void LoadWallClockGraphics(void) { u8 *addr; u32 size; - + SetVBlankCallback(0); REG_DISPCNT = 0; REG_BG3CNT = 0; @@ -95,7 +95,7 @@ static void LoadWallClockGraphics(void) REG_BG1VOFS = 0; REG_BG0HOFS = 0; REG_BG0VOFS = 0; - + addr = (void *)VRAM; size = 0x18000; while(1) @@ -111,7 +111,7 @@ static void LoadWallClockGraphics(void) } DmaClear32(3, OAM, OAM_SIZE); DmaClear16(3, PLTT, PLTT_SIZE); - + LZ77UnCompVram(gMiscClock_Gfx, (void *)VRAM); if(gSpecialVar_0x8004 == MALE) LoadPalette(gMiscClockMale_Pal, 0, 32); @@ -131,7 +131,7 @@ static void LoadWallClockGraphics(void) static void WallClockInit(void) { u16 ime; - + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); ime = REG_IME; REG_IME = 0; @@ -154,10 +154,10 @@ void CB2_StartWallClock(void) { u8 taskId; u8 spriteId; - + LoadWallClockGraphics(); LZ77UnCompVram(&gUnknown_08E954B0, (void *)(VRAM + 0x3800)); - + taskId = CreateTask(Task_SetClock1, 0); gTasks[taskId].data[TD_HOURS] = 10; gTasks[taskId].data[TD_MINUTES] = 0; @@ -166,25 +166,25 @@ void CB2_StartWallClock(void) gTasks[taskId].data[TD_SETSPEED] = 0; gTasks[taskId].data[TD_MHAND_ANGLE] = 0; gTasks[taskId].data[TD_HHAND_ANGLE] = 300; - + spriteId = CreateSprite(&gSpriteTemplate_83F7AD8, 0x78, 0x50, 1); gSprites[spriteId].data0 = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 0; - + spriteId = CreateSprite(&gSpriteTemplate_83F7AF0, 0x78, 0x50, 0); gSprites[spriteId].data0 = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 1; - + spriteId = CreateSprite(&gSpriteTemplate_83F7B28, 0x78, 0x50, 2); gSprites[spriteId].data0 = taskId; gSprites[spriteId].data1 = 45; - + spriteId = CreateSprite(&gSpriteTemplate_83F7B40, 0x78, 0x50, 2); gSprites[spriteId].data0 = taskId; gSprites[spriteId].data1 = 90; - + WallClockInit(); } @@ -195,10 +195,10 @@ void CB2_ViewWallClock(void) s16 angle1; s16 angle2; u8 spriteId; - + LoadWallClockGraphics(); LZ77UnCompVram(gUnknown_08E95774, (void *)(VRAM + 0x3800)); - + taskId = CreateTask(Task_ViewClock1, 0); InitClockWithRtc(taskId); if(gTasks[taskId].data[TD_PERIOD] == 0) @@ -211,25 +211,25 @@ void CB2_ViewWallClock(void) angle1 = 90; angle2 = 135; } - + spriteId = CreateSprite(&gSpriteTemplate_83F7AD8, 120, 80, 1); gSprites[spriteId].data0 = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 0; - + spriteId = CreateSprite(&gSpriteTemplate_83F7AF0, 120, 80, 0); gSprites[spriteId].data0 = taskId; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; gSprites[spriteId].oam.matrixNum = 1; - + spriteId = CreateSprite(&gSpriteTemplate_83F7B28, 120, 80, 2); gSprites[spriteId].data0 = taskId; gSprites[spriteId].data1 = angle1; - + spriteId = CreateSprite(&gSpriteTemplate_83F7B40, 120, 80, 2); gSprites[spriteId].data0 = taskId; gSprites[spriteId].data1 = angle2; - + WallClockInit(); } @@ -377,7 +377,7 @@ static u8 CalcMinHandDelta(u16 speed) static u16 CalcNewMinHandAngle(u16 angle, u8 direction, u8 speed) { u8 delta = CalcMinHandDelta(speed); - + switch(direction) { case BACKWARD: @@ -435,7 +435,7 @@ static u8 AdvanceClock(u8 taskId, u8 direction) static void UpdateClockPeriod(u8 taskId, u8 direction) { u8 hours = gTasks[taskId].data[TD_HOURS]; - + switch(direction) { case BACKWARD: @@ -483,20 +483,20 @@ void sub_810B05C(struct Sprite *sprite) s16 cos; u16 x; u16 y; - + angle = gTasks[sprite->data0].data[TD_MHAND_ANGLE]; sin = Sin2(angle) / 16; cos = Cos2(angle) / 16; SetOamMatrix(0, cos, sin, -sin, cos); x = gClockHandCoords[angle][0]; y = gClockHandCoords[angle][1]; - + //Manual sign extension if(x > 0x80) x |= 0xFF00; if(y > 0x80) y |= 0xFF00; - + sprite->pos2.x = x; sprite->pos2.y = y; } @@ -508,20 +508,20 @@ void sub_810B0F4(struct Sprite *sprite) s16 cos; u16 x; u16 y; - + angle = gTasks[sprite->data0].data[TD_HHAND_ANGLE]; sin = Sin2(angle) / 16; cos = Cos2(angle) / 16; SetOamMatrix(1, cos, sin, -sin, cos); x = gClockHandCoords[angle][0]; y = gClockHandCoords[angle][1]; - + //Manual sign extension if(x > 0x80) x |= 0xFF00; if(y > 0x80) y |= 0xFF00; - + sprite->pos2.x = x; sprite->pos2.y = y; } @@ -530,7 +530,7 @@ void sub_810B18C(struct Sprite *sprite) { s16 sin; s16 cos; - + if(gTasks[sprite->data0].data[TD_PERIOD] != AM) { if((u16)(sprite->data1 - 60) <= 29) @@ -555,7 +555,7 @@ void sub_810B230(struct Sprite *sprite) { s16 sin; s16 cos; - + if(gTasks[sprite->data0].data[TD_PERIOD] != AM) { if(sprite->data1 >= 105 && sprite->data1 < 135) diff --git a/src/weather.c b/src/weather.c index 520185441..f3c79b42c 100644 --- a/src/weather.c +++ b/src/weather.c @@ -1,9 +1,9 @@ #include "global.h" #include "weather.h" #include "asm.h" -#include "task.h" -#include "sprite.h" #include "palette.h" +#include "sprite.h" +#include "task.h" struct Weather { u8 filler_000[0x200]; diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 8e983c300..820ff34f5 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -1,15 +1,15 @@ #include "global.h" #include "wild_encounter.h" +#include "abilities.h" #include "asm.h" -#include "field_player_avatar.h" -#include "safari_zone.h" #include "battle_setup.h" -#include "abilities.h" -#include "rng.h" -#include "script.h" #include "event_data.h" -#include "rom4.h" +#include "field_player_avatar.h" #include "metatile_behavior.h" +#include "rng.h" +#include "rom4.h" +#include "safari_zone.h" +#include "script.h" struct WildPokemon { @@ -66,7 +66,7 @@ static u16 GetRoute119WaterTileNum(s16 x, s16 y, u8 section) u16 yMin = gRoute119WaterTileData[section * 3 + 0]; u16 yMax = gRoute119WaterTileData[section * 3 + 1]; u16 tileNum = gRoute119WaterTileData[section * 3 + 2]; - + for (yCur = yMin; yCur <= yMax; yCur++) { for (xCur = 0; xCur < gMapHeader.mapData->width; xCur++) @@ -96,7 +96,7 @@ static bool8 CheckFeebas(void) GetXYCoordsOneStepInFrontOfPlayer(&x, &y); x -= 7; y -= 7; - + #ifdef NONMATCHING if (y >= gRoute119WaterTileData[3 * 1 + 0] && y <= gRoute119WaterTileData[3 * 1 + 1]) route119section = 1; @@ -111,7 +111,7 @@ static bool8 CheckFeebas(void) route119section = 2; } #endif - + if (Random() % 100 > 49) //50% chance of encountering Feebas return FALSE; FeebasSeedRng(gSaveBlock1.easyChatPairs[0].unk2); @@ -185,7 +185,7 @@ static u8 ChooseWildMonIndex_Water(void) if (rand >= 90 && rand < 95) //5% chance return 2; if (rand >= 95 && rand < 99) //4% chance - return 3; + return 3; else //1% chance return 4; } |