diff options
Diffstat (limited to 'src')
142 files changed, 6387 insertions, 5747 deletions
diff --git a/src/apprentice.c b/src/apprentice.c index 5d1c4287b..6255b9215 100644 --- a/src/apprentice.c +++ b/src/apprentice.c @@ -632,7 +632,7 @@ static void CreateApprenticeMenu(u8 menu) pixelWidth = 0; for (i = 0; i < count; i++) { - s32 width = GetStringWidth(1, strings[i], 0); + s32 width = GetStringWidth(FONT_NORMAL, strings[i], 0); if (width > pixelWidth) pixelWidth = width; } @@ -643,9 +643,9 @@ static void CreateApprenticeMenu(u8 menu) SetStandardWindowBorderStyle(windowId, 0); for (i = 0; i < count; i++) - AddTextPrinterParameterized(windowId, 1, strings[i], 8, (i * 16) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, strings[i], 8, (i * 16) + 1, TEXT_SKIP_DRAW, NULL); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, count, 0); + InitMenuInUpperLeftCornerNormal(windowId, count, 0); CreateChooseAnswerTask(TRUE, count, windowId); } @@ -691,7 +691,7 @@ static u8 CreateAndShowWindow(u8 left, u8 top, u8 width, u8 height) windowId = AddWindow(&winTemplate); PutWindowTilemap(windowId); - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); return windowId; } diff --git a/src/battle_ai_script_commands.c b/src/battle_ai_script_commands.c index 6fdfb0d7a..e9f55bd8b 100644 --- a/src/battle_ai_script_commands.c +++ b/src/battle_ai_script_commands.c @@ -274,7 +274,7 @@ static const u16 sIgnoredPowerfulMoveEffects[] = EFFECT_SKY_ATTACK, EFFECT_RECHARGE, EFFECT_SKULL_BASH, - EFFECT_SOLARBEAM, + EFFECT_SOLAR_BEAM, EFFECT_SPIT_UP, EFFECT_FOCUS_PUNCH, EFFECT_SUPERPOWER, diff --git a/src/battle_anim_effects_1.c b/src/battle_anim_effects_1.c index ebdb471bf..f54ebfbf7 100644 --- a/src/battle_anim_effects_1.c +++ b/src/battle_anim_effects_1.c @@ -26,9 +26,9 @@ struct { static void AnimMovePowderParticle(struct Sprite *); static void AnimMovePowderParticle_Step(struct Sprite *); static void AnimPowerAbsorptionOrb(struct Sprite *); -static void AnimSolarbeamBigOrb(struct Sprite *); -static void AnimSolarbeamSmallOrb(struct Sprite *); -static void AnimSolarbeamSmallOrb_Step(struct Sprite *); +static void AnimSolarBeamBigOrb(struct Sprite *); +static void AnimSolarBeamSmallOrb(struct Sprite *); +static void AnimSolarBeamSmallOrb_Step(struct Sprite *); static void AnimAbsorptionOrb(struct Sprite *); static void AnimAbsorptionOrb_Step(struct Sprite *); static void AnimHyperBeamOrb(struct Sprite *); @@ -208,49 +208,49 @@ const struct SpriteTemplate gPoisonPowderParticleSpriteTemplate = .callback = AnimMovePowderParticle, }; -const union AnimCmd gSolarbeamBigOrbAnimCmds1[] = +const union AnimCmd gSolarBeamBigOrbAnimCmds1[] = { ANIMCMD_FRAME(0, 1), ANIMCMD_END, }; -const union AnimCmd gSolarbeamBigOrbAnimCmds2[] = +const union AnimCmd gSolarBeamBigOrbAnimCmds2[] = { ANIMCMD_FRAME(1, 1), ANIMCMD_END, }; -const union AnimCmd gSolarbeamBigOrbAnimCmds3[] = +const union AnimCmd gSolarBeamBigOrbAnimCmds3[] = { ANIMCMD_FRAME(2, 1), ANIMCMD_END, }; -const union AnimCmd gSolarbeamBigOrbAnimCmds4[] = +const union AnimCmd gSolarBeamBigOrbAnimCmds4[] = { ANIMCMD_FRAME(3, 1), ANIMCMD_END, }; -const union AnimCmd gSolarbeamBigOrbAnimCmds5[] = +const union AnimCmd gSolarBeamBigOrbAnimCmds5[] = { ANIMCMD_FRAME(4, 1), ANIMCMD_END, }; -const union AnimCmd gSolarbeamBigOrbAnimCmds6[] = +const union AnimCmd gSolarBeamBigOrbAnimCmds6[] = { ANIMCMD_FRAME(5, 1), ANIMCMD_END, }; -const union AnimCmd gSolarbeamBigOrbAnimCmds7[] = +const union AnimCmd gSolarBeamBigOrbAnimCmds7[] = { ANIMCMD_FRAME(6, 1), ANIMCMD_END, }; -const union AnimCmd gSolarbeamSmallOrbAnimCms[] = +const union AnimCmd gSolarBeamSmallOrbAnimCms[] = { ANIMCMD_FRAME(7, 1), ANIMCMD_END, @@ -262,20 +262,20 @@ const union AnimCmd gPowerAbsorptionOrbAnimCmds[] = ANIMCMD_END, }; -const union AnimCmd *const gSolarbeamBigOrbAnimTable[] = +const union AnimCmd *const gSolarBeamBigOrbAnimTable[] = { - gSolarbeamBigOrbAnimCmds1, - gSolarbeamBigOrbAnimCmds2, - gSolarbeamBigOrbAnimCmds3, - gSolarbeamBigOrbAnimCmds4, - gSolarbeamBigOrbAnimCmds5, - gSolarbeamBigOrbAnimCmds6, - gSolarbeamBigOrbAnimCmds7, + gSolarBeamBigOrbAnimCmds1, + gSolarBeamBigOrbAnimCmds2, + gSolarBeamBigOrbAnimCmds3, + gSolarBeamBigOrbAnimCmds4, + gSolarBeamBigOrbAnimCmds5, + gSolarBeamBigOrbAnimCmds6, + gSolarBeamBigOrbAnimCmds7, }; -const union AnimCmd *const gSolarbeamSmallOrbAnimTable[] = +const union AnimCmd *const gSolarBeamSmallOrbAnimTable[] = { - gSolarbeamSmallOrbAnimCms, + gSolarBeamSmallOrbAnimCms, }; const union AnimCmd *const gPowerAbsorptionOrbAnimTable[] = @@ -303,26 +303,26 @@ const struct SpriteTemplate gPowerAbsorptionOrbSpriteTemplate = .callback = AnimPowerAbsorptionOrb, }; -const struct SpriteTemplate gSolarbeamBigOrbSpriteTemplate = +const struct SpriteTemplate gSolarBeamBigOrbSpriteTemplate = { .tileTag = ANIM_TAG_ORBS, .paletteTag = ANIM_TAG_ORBS, .oam = &gOamData_AffineOff_ObjNormal_8x8, - .anims = gSolarbeamBigOrbAnimTable, + .anims = gSolarBeamBigOrbAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = AnimSolarbeamBigOrb, + .callback = AnimSolarBeamBigOrb, }; -const struct SpriteTemplate gSolarbeamSmallOrbSpriteTemplate = +const struct SpriteTemplate gSolarBeamSmallOrbSpriteTemplate = { .tileTag = ANIM_TAG_ORBS, .paletteTag = ANIM_TAG_ORBS, .oam = &gOamData_AffineOff_ObjNormal_8x8, - .anims = gSolarbeamSmallOrbAnimTable, + .anims = gSolarBeamSmallOrbAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = AnimSolarbeamSmallOrb, + .callback = AnimSolarBeamSmallOrb, }; const union AffineAnimCmd gStockpileAbsorptionOrbAffineCmds[] = { @@ -371,7 +371,7 @@ const struct SpriteTemplate gHyperBeamOrbSpriteTemplate = .tileTag = ANIM_TAG_ORBS, .paletteTag = ANIM_TAG_ORBS, .oam = &gOamData_AffineOff_ObjNormal_8x8, - .anims = gSolarbeamBigOrbAnimTable, + .anims = gSolarBeamBigOrbAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = AnimHyperBeamOrb, @@ -2252,7 +2252,7 @@ static void AnimPowerAbsorptionOrb(struct Sprite* sprite) // arg 1: initial y pixel offset // arg 2: duration // arg 3: sprite anim number -static void AnimSolarbeamBigOrb(struct Sprite* sprite) +static void AnimSolarBeamBigOrb(struct Sprite* sprite) { InitSpritePosToAnimAttacker(sprite, TRUE); StartSpriteAnim(sprite, gBattleAnimArgs[3]); @@ -2264,12 +2264,12 @@ static void AnimSolarbeamBigOrb(struct Sprite* sprite) } // Moves a small orb in a wavy pattern towards the target mon. -// The small orb "circles" the big orbs in AnimSolarbeamBigOrb. +// The small orb "circles" the big orbs in AnimSolarBeamBigOrb. // arg 0: initial x pixel offset // arg 1: initial y pixel offset // arg 2: duration // arg 3: initial wave offset -static void AnimSolarbeamSmallOrb(struct Sprite* sprite) +static void AnimSolarBeamSmallOrb(struct Sprite* sprite) { InitSpritePosToAnimAttacker(sprite, TRUE); sprite->data[0] = gBattleAnimArgs[2]; @@ -2279,11 +2279,11 @@ static void AnimSolarbeamSmallOrb(struct Sprite* sprite) sprite->data[4] = GetBattlerSpriteCoord(gBattleAnimTarget, BATTLER_COORD_Y_PIC_OFFSET); InitAnimLinearTranslation(sprite); sprite->data[5] = gBattleAnimArgs[3]; - sprite->callback = AnimSolarbeamSmallOrb_Step; + sprite->callback = AnimSolarBeamSmallOrb_Step; sprite->callback(sprite); } -static void AnimSolarbeamSmallOrb_Step(struct Sprite* sprite) +static void AnimSolarBeamSmallOrb_Step(struct Sprite* sprite) { if (AnimTranslateLinear(sprite)) { @@ -2302,10 +2302,10 @@ static void AnimSolarbeamSmallOrb_Step(struct Sprite* sprite) } } -// Creates 15 small secondary orbs used in the solarbeam anim effect. +// Creates 15 small secondary orbs used in the SolarBeam anim effect. // There is a 7-frame delay between each of them. // No args. -void AnimTask_CreateSmallSolarbeamOrbs(u8 taskId) +void AnimTask_CreateSmallSolarBeamOrbs(u8 taskId) { if (--gTasks[taskId].data[0] == -1) { @@ -2315,7 +2315,7 @@ void AnimTask_CreateSmallSolarbeamOrbs(u8 taskId) gBattleAnimArgs[1] = 0; gBattleAnimArgs[2] = 80; gBattleAnimArgs[3] = 0; - CreateSpriteAndAnimate(&gSolarbeamSmallOrbSpriteTemplate, 0, 0, GetBattlerSpriteSubpriority(gBattleAnimTarget) + 1); + CreateSpriteAndAnimate(&gSolarBeamSmallOrbSpriteTemplate, 0, 0, GetBattlerSpriteSubpriority(gBattleAnimTarget) + 1); } if (gTasks[taskId].data[1] == 15) diff --git a/src/battle_anim_effects_3.c b/src/battle_anim_effects_3.c index 267b6db9c..85dee5287 100755 --- a/src/battle_anim_effects_3.c +++ b/src/battle_anim_effects_3.c @@ -718,7 +718,7 @@ const struct SpriteTemplate gSweetScentPetalSpriteTemplate = .callback = AnimSweetScentPetal, }; -static const u16 sUnusedPalette[] = INCBIN_U16("graphics/battle_anims/unused.gbapal"); +static const u16 sUnusedPalette[] = INCBIN_U16("graphics/battle_anims/unused/unknown.gbapal"); const union AnimCmd gPainSplitAnimCmds[] = { diff --git a/src/battle_anim_water.c b/src/battle_anim_water.c index 1c2d08d6a..50918a24e 100644 --- a/src/battle_anim_water.c +++ b/src/battle_anim_water.c @@ -54,8 +54,8 @@ static void AnimTask_WaterSport_Step(u8); static void CreateWaterSportDroplet(struct Task*); static void CreateWaterPulseRingBubbles(struct Sprite*, int, int); -static const u8 sUnusedWater_Gfx[] = INCBIN_U8("graphics/battle_anims/unused_water_gfx.4bpp"); -static const u8 sUnusedWater[] = INCBIN_U8("graphics/battle_anims/unused_water.bin"); +static const u8 sUnusedWater_Gfx[] = INCBIN_U8("graphics/battle_anims/unused/water_gfx.4bpp"); +static const u8 sUnusedWater[] = INCBIN_U8("graphics/battle_anims/unused/water.bin"); static const union AnimCmd sAnim_RainDrop[] = { diff --git a/src/battle_bg.c b/src/battle_bg.c index cbd293294..0e4370485 100644 --- a/src/battle_bg.c +++ b/src/battle_bg.c @@ -1124,13 +1124,13 @@ void DrawBattleEntryBackground(void) { if (gBattleTypeFlags & BATTLE_TYPE_LINK) { - LZDecompressVram(gUnknown_08D778F0, (void*)(BG_CHAR_ADDR(1))); + LZDecompressVram(gBattleVSFrame_Gfx, (void*)(BG_CHAR_ADDR(1))); LZDecompressVram(gVsLettersGfx, (void*)OBJ_VRAM0); - LoadCompressedPalette(gUnknown_08D77AE4, 0x60, 0x20); + LoadCompressedPalette(gBattleVSFrame_Pal, 0x60, 0x20); SetBgAttribute(1, BG_ATTR_SCREENSIZE, 1); SetGpuReg(REG_OFFSET_BG1CNT, 0x5C04); - CopyToBgTilemapBuffer(1, gUnknown_08D779D8, 0, 0); - CopyToBgTilemapBuffer(2, gUnknown_08D779D8, 0, 0); + CopyToBgTilemapBuffer(1, gBattleVSFrame_Tilemap, 0, 0); + CopyToBgTilemapBuffer(2, gBattleVSFrame_Tilemap, 0, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_OBJ | WININ_WIN0_CLR); @@ -1148,10 +1148,12 @@ void DrawBattleEntryBackground(void) } else { + // Set up bg for the multi battle intro where both teams slide in facing the screen. + // Note Steven's multi battle (which has a dedicated back pic) is excluded above. SetBgAttribute(1, BG_ATTR_CHARBASEINDEX, 2); SetBgAttribute(2, BG_ATTR_CHARBASEINDEX, 2); - CopyToBgTilemapBuffer(1, gUnknown_08D857A8, 0, 0); - CopyToBgTilemapBuffer(2, gUnknown_08D85A1C, 0, 0); + CopyToBgTilemapBuffer(1, gMultiBattleIntroBg_Opponent_Tilemap, 0, 0); + CopyToBgTilemapBuffer(2, gMultiBattleIntroBg_Player_Tilemap, 0, 0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); } diff --git a/src/battle_dome.c b/src/battle_dome.c index 944918631..45df83c7c 100644 --- a/src/battle_dome.c +++ b/src/battle_dome.c @@ -104,7 +104,7 @@ static void HblankCb_TourneyTree(void); static void VblankCb_TourneyTree(void); static u8 UpdateTourneyTreeCursor(u8 taskId); static void DecideRoundWinners(u8 roundId); -static u8 sub_81953E8(u8 tournamentId, u8); +static u8 GetOpposingNPCTournamentIdByRound(u8 tournamentId, u8); static void DrawTourneyAdvancementLine(u8, u8); static void SpriteCb_HorizontalScrollArrow(struct Sprite *sprite); static void SpriteCb_VerticalScrollArrow(struct Sprite *sprite); @@ -1197,7 +1197,7 @@ static const u8 sLastMatchCardNum[DOME_ROUNDS_COUNT] = [DOME_FINAL] = 30 }; -static const u8 gUnknown_0860D1A0[DOME_TOURNAMENT_TRAINERS_COUNT / 2][DOME_ROUNDS_COUNT] = +static const u8 sTrainerAndRoundToLastMatchCardNum[DOME_TOURNAMENT_TRAINERS_COUNT / 2][DOME_ROUNDS_COUNT] = { {16, 24, 28, 30}, {17, 24, 28, 30}, @@ -1209,7 +1209,7 @@ static const u8 gUnknown_0860D1A0[DOME_TOURNAMENT_TRAINERS_COUNT / 2][DOME_ROUND {23, 27, 29, 30}, }; -static const u8 gUnknown_0860D1C0[DOME_TOURNAMENT_TRAINERS_COUNT] = {0, 15, 8, 7, 3, 12, 11, 4, 1, 14, 9, 6, 2, 13, 10, 5}; +static const u8 sTournamentIdToPairedTrainerIds[DOME_TOURNAMENT_TRAINERS_COUNT] = {0, 15, 8, 7, 3, 12, 11, 4, 1, 14, 9, 6, 2, 13, 10, 5}; // The first line of text on a trainers info card. It describes their potential to win, based on their seed in the tournament tree. // Dome Ace Tucker has their own separate potential text. @@ -3428,7 +3428,7 @@ static void Task_HandleInfoCardInput(u8 taskId) for (i = windowId; i < windowId + 9; i++) { - CopyWindowToVram(i, 2); + CopyWindowToVram(i, COPYWIN_GFX); FillWindowPixelBuffer(i, PIXEL_FILL(0)); } gTasks[taskId].tState = STATE_REACT_INPUT; @@ -4178,7 +4178,7 @@ static u8 Task_GetInfoCardInput(u8 taskId) if (input == INFOCARD_INPUT_AB) { if (sInfoCard->pos != 0) - gTasks[taskId2].data[1] = gUnknown_0860D1A0[position / 2][sInfoCard->pos - 1]; + gTasks[taskId2].data[1] = sTrainerAndRoundToLastMatchCardNum[position / 2][sInfoCard->pos - 1]; else gTasks[taskId2].data[1] = position; } @@ -4218,9 +4218,9 @@ static u8 Task_GetInfoCardInput(u8 taskId) if (input == INFOCARD_INPUT_AB) { if (sInfoCard->pos == 0) // On left trainer info card - gTasks[taskId2].data[1] = gUnknown_0860D1C0[sInfoCard->tournamentIds[0]]; + gTasks[taskId2].data[1] = sTournamentIdToPairedTrainerIds[sInfoCard->tournamentIds[0]]; else if (sInfoCard->pos == 2) // On right trainer info card - gTasks[taskId2].data[1] = gUnknown_0860D1C0[sInfoCard->tournamentIds[1]]; + gTasks[taskId2].data[1] = sTournamentIdToPairedTrainerIds[sInfoCard->tournamentIds[1]]; else // On match info card gTasks[taskId2].data[1] = position; } @@ -4312,7 +4312,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId) } // Initialize the text printer - textPrinter.fontId = 2; + textPrinter.fontId = FONT_SHORT; textPrinter.x = 0; textPrinter.y = 0; textPrinter.currentX = textPrinter.x; @@ -4358,7 +4358,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId) textPrinter.currentChar = gStringVar1; textPrinter.windowId = windowId; PutWindowTilemap(windowId); - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); AddTextPrinter(&textPrinter, 0, NULL); textPrinter.letterSpacing = 0; @@ -4380,12 +4380,12 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId) textPrinter.currentX = 0; PutWindowTilemap(1 + i + windowId); - CopyWindowToVram(1 + i + windowId, 3); + CopyWindowToVram(1 + i + windowId, COPYWIN_FULL); AddTextPrinter(&textPrinter, 0, NULL); } PutWindowTilemap(windowId + 4); - CopyWindowToVram(windowId + 4, 3); + CopyWindowToVram(windowId + 4, COPYWIN_FULL); // Print text about trainers potential in the tourney if (trainerId == TRAINER_FRONTIER_BRAIN) @@ -4393,7 +4393,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId) else textPrinter.currentChar = sBattleDomePotentialTexts[trainerTourneyId]; - textPrinter.fontId = 1; + textPrinter.fontId = FONT_NORMAL; textPrinter.windowId = windowId + 4; textPrinter.currentX = 0; textPrinter.y = 4; @@ -4859,9 +4859,9 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) StringExpandPlaceholders(gStringVar4, sBattleDomeWinTexts[winStringId]); textPrinter.currentChar = gStringVar4; textPrinter.windowId = windowId + 8; - textPrinter.fontId = 1; + textPrinter.fontId = FONT_NORMAL; PutWindowTilemap(windowId + 8); - CopyWindowToVram(windowId + 8, 3); + CopyWindowToVram(windowId + 8, COPYWIN_FULL); textPrinter.currentX = 0; textPrinter.currentY = textPrinter.y = 0; AddTextPrinter(&textPrinter, 0, NULL); @@ -4874,14 +4874,14 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) else CopyDomeTrainerName(gStringVar1, trainerIds[0]); - textPrinter.fontId = 2; + textPrinter.fontId = FONT_SHORT; textPrinter.letterSpacing = 2; textPrinter.currentChar = gStringVar1; textPrinter.windowId = windowId + 6; textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0x40, textPrinter.letterSpacing); textPrinter.currentY = textPrinter.y = 2; PutWindowTilemap(windowId + 6); - CopyWindowToVram(windowId + 6, 3); + CopyWindowToVram(windowId + 6, COPYWIN_FULL); AddTextPrinter(&textPrinter, 0, NULL); // Print right trainer's name. @@ -4897,7 +4897,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0x40, textPrinter.letterSpacing); textPrinter.currentY = textPrinter.y = 2; PutWindowTilemap(windowId + 7); - CopyWindowToVram(windowId + 7, 3); + CopyWindowToVram(windowId + 7, COPYWIN_FULL); AddTextPrinter(&textPrinter, 0, NULL); // Print match number. @@ -4907,7 +4907,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo) textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0xA0, textPrinter.letterSpacing); textPrinter.currentY = textPrinter.y = 2; PutWindowTilemap(windowId + 5); - CopyWindowToVram(windowId + 5, 3); + CopyWindowToVram(windowId + 5, COPYWIN_FULL); AddTextPrinter(&textPrinter, 0, NULL); } @@ -5224,7 +5224,7 @@ static u16 GetWinningMove(int winnerTournamentId, int loserTournamentId, u8 roun { for (i = 0; i < roundId - 1; i++) { - if (gSaveBlock2Ptr->frontier.domeWinningMoves[sub_81953E8(winnerTournamentId, i)] == moveIds[j]) + if (gSaveBlock2Ptr->frontier.domeWinningMoves[GetOpposingNPCTournamentIdByRound(winnerTournamentId, i)] == moveIds[j]) break; } if (i != roundId - 1) @@ -5281,10 +5281,10 @@ static void Task_ShowTourneyTree(u8 taskId) gBattle_BG0_Y = 0; gBattle_BG1_X = 0; gBattle_BG1_Y = 0; - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0xB00, 0); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0xB00, BG_COORD_SET); gTasks[taskId].tState++; break; case 1: @@ -5339,7 +5339,7 @@ static void Task_ShowTourneyTree(u8 taskId) gTasks[taskId].tState++; break; case 4: - textPrinter.fontId = 2; + textPrinter.fontId = FONT_SHORT; textPrinter.currentChar = gText_BattleTourney; textPrinter.windowId = 2; textPrinter.x = 0; @@ -5442,9 +5442,9 @@ static void Task_ShowTourneyTree(u8 taskId) PutWindowTilemap(0); PutWindowTilemap(1); PutWindowTilemap(2); - CopyWindowToVram(0, 3); - CopyWindowToVram(1, 3); - CopyWindowToVram(2, 3); + CopyWindowToVram(0, COPYWIN_FULL); + CopyWindowToVram(1, COPYWIN_FULL); + CopyWindowToVram(2, COPYWIN_FULL); SetHBlankCallback(HblankCb_TourneyTree); SetVBlankCallback(VblankCb_TourneyTree); if (r4 == 2) @@ -5524,7 +5524,7 @@ static void Task_HandleStaticTourneyTreeInput(u8 taskId) { gTasks[taskId].tState = STATE_DELAY; gTasks[taskId].data[3] = 64; - textPrinter.fontId = 2; + textPrinter.fontId = FONT_SHORT; textPrinter.x = 0; textPrinter.y = 0; textPrinter.letterSpacing = 2; @@ -5597,8 +5597,8 @@ static void CB2_TourneyTree(void) static void VblankCb_TourneyInfoCard(void) { - ChangeBgX(3, 0x80, 1); - ChangeBgY(3, 0x80, 2); + ChangeBgX(3, 0x80, BG_COORD_ADD); + ChangeBgY(3, 0x80, BG_COORD_SUB); SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_X); SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_Y); SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); @@ -5693,8 +5693,8 @@ static void VblankCb_TourneyTree(void) SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_Y); SetGpuReg(REG_OFFSET_BG1HOFS, gBattle_BG1_X); SetGpuReg(REG_OFFSET_BG1VOFS, gBattle_BG1_Y); - ChangeBgY(2, 0x80, 2); - ChangeBgY(3, 0x80, 1); + ChangeBgY(2, 0x80, BG_COORD_SUB); + ChangeBgY(3, 0x80, BG_COORD_ADD); LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); @@ -5934,10 +5934,10 @@ int TrainerIdToDomeTournamentId(u16 trainerId) return i; } -static u8 sub_81953E8(u8 tournamentId, u8 round) +static u8 GetOpposingNPCTournamentIdByRound(u8 tournamentId, u8 round) { u8 tournamentIds[2]; - BufferDomeWinString(gUnknown_0860D1A0[gUnknown_0860D1C0[tournamentId] / 2][round] - 16, tournamentIds); + BufferDomeWinString(sTrainerAndRoundToLastMatchCardNum[sTournamentIdToPairedTrainerIds[tournamentId] / 2][round] - 16, tournamentIds); if (tournamentId == tournamentIds[0]) return tournamentIds[1]; else diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index 64d564062..247b8712f 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -1147,12 +1147,12 @@ static void CB2_InitSelectScreen(void) sSelectMonPicBgTilesetBuffer = AllocZeroed(0x440); sSelectMenuTilemapBuffer = Alloc(BG_SCREEN_SIZE); sSelectMonPicBgTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); SetGpuReg(REG_OFFSET_BLDY, 0); @@ -1854,15 +1854,15 @@ static void Select_ErasePopupMenu(u8 windowId) gSprites[sFactorySelectScreen->menuCursor1SpriteId].invisible = TRUE; gSprites[sFactorySelectScreen->menuCursor2SpriteId].invisible = TRUE; FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); ClearWindowTilemap(windowId); } static void Select_PrintRentalPkmnString(void) { FillWindowPixelBuffer(SELECT_WIN_TITLE, PIXEL_FILL(0)); - AddTextPrinterParameterized(SELECT_WIN_TITLE, 1, gText_RentalPkmn2, 2, 1, 0, NULL); - CopyWindowToVram(SELECT_WIN_TITLE, 3); + AddTextPrinterParameterized(SELECT_WIN_TITLE, FONT_NORMAL, gText_RentalPkmn2, 2, 1, 0, NULL); + CopyWindowToVram(SELECT_WIN_TITLE, COPYWIN_FULL); } static void Select_PrintMonSpecies(void) @@ -1874,9 +1874,9 @@ static void Select_PrintMonSpecies(void) FillWindowPixelBuffer(SELECT_WIN_SPECIES, PIXEL_FILL(0)); species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); - x = GetStringRightAlignXOffset(1, gStringVar4, 86); - AddTextPrinterParameterized3(SELECT_WIN_SPECIES, 1, x, 1, sSpeciesNameTextColors, 0, gStringVar4); - CopyWindowToVram(SELECT_WIN_SPECIES, 2); + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 86); + AddTextPrinterParameterized3(SELECT_WIN_SPECIES, FONT_NORMAL, x, 1, sSpeciesNameTextColors, 0, gStringVar4); + CopyWindowToVram(SELECT_WIN_SPECIES, COPYWIN_GFX); } static void Select_PrintSelectMonString(void) @@ -1893,15 +1893,15 @@ static void Select_PrintSelectMonString(void) else str = gText_TheseThreePkmnOkay; - AddTextPrinterParameterized(SELECT_WIN_INFO, 1, str, 2, 5, 0, NULL); - CopyWindowToVram(SELECT_WIN_INFO, 2); + AddTextPrinterParameterized(SELECT_WIN_INFO, FONT_NORMAL, str, 2, 5, 0, NULL); + CopyWindowToVram(SELECT_WIN_INFO, COPYWIN_GFX); } static void Select_PrintCantSelectSameMon(void) { FillWindowPixelBuffer(SELECT_WIN_INFO, PIXEL_FILL(0)); - AddTextPrinterParameterized(SELECT_WIN_INFO, 1, gText_CantSelectSamePkmn, 2, 5, 0, NULL); - CopyWindowToVram(SELECT_WIN_INFO, 2); + AddTextPrinterParameterized(SELECT_WIN_INFO, FONT_NORMAL, gText_CantSelectSamePkmn, 2, 5, 0, NULL); + CopyWindowToVram(SELECT_WIN_INFO, COPYWIN_GFX); } static void Select_PrintMenuOptions(void) @@ -1910,23 +1910,23 @@ static void Select_PrintMenuOptions(void) PutWindowTilemap(SELECT_WIN_OPTIONS); FillWindowPixelBuffer(SELECT_WIN_OPTIONS, PIXEL_FILL(0)); - AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, 1, 7, 1, sMenuOptionTextColors, 0, gText_Summary); + AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, FONT_NORMAL, 7, 1, sMenuOptionTextColors, 0, gText_Summary); if (selectedId != 0) - AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, 1, 7, 17, sMenuOptionTextColors, 0, gText_Deselect); + AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, FONT_NORMAL, 7, 17, sMenuOptionTextColors, 0, gText_Deselect); else - AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, 1, 7, 17, sMenuOptionTextColors, 0, gText_Rent); + AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, FONT_NORMAL, 7, 17, sMenuOptionTextColors, 0, gText_Rent); - AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, 1, 7, 33, sMenuOptionTextColors, 0, gText_Others2); - CopyWindowToVram(SELECT_WIN_OPTIONS, 3); + AddTextPrinterParameterized3(SELECT_WIN_OPTIONS, FONT_NORMAL, 7, 33, sMenuOptionTextColors, 0, gText_Others2); + CopyWindowToVram(SELECT_WIN_OPTIONS, COPYWIN_FULL); } static void Select_PrintYesNoOptions(void) { PutWindowTilemap(SELECT_WIN_YES_NO); FillWindowPixelBuffer(SELECT_WIN_YES_NO, PIXEL_FILL(0)); - AddTextPrinterParameterized3(SELECT_WIN_YES_NO, 1, 7, 1, sMenuOptionTextColors, 0, gText_Yes2); - AddTextPrinterParameterized3(SELECT_WIN_YES_NO, 1, 7, 17, sMenuOptionTextColors, 0, gText_No2); - CopyWindowToVram(SELECT_WIN_YES_NO, 3); + AddTextPrinterParameterized3(SELECT_WIN_YES_NO, FONT_NORMAL, 7, 1, sMenuOptionTextColors, 0, gText_Yes2); + AddTextPrinterParameterized3(SELECT_WIN_YES_NO, FONT_NORMAL, 7, 17, sMenuOptionTextColors, 0, gText_No2); + CopyWindowToVram(SELECT_WIN_YES_NO, COPYWIN_FULL); } static u8 Select_RunMenuOptionFunc(void) @@ -1994,9 +1994,9 @@ static void Select_PrintMonCategory(void) FillWindowPixelBuffer(SELECT_WIN_MON_CATEGORY, PIXEL_FILL(0)); species = GetMonData(&sFactorySelectScreen->mons[monId].monData, MON_DATA_SPECIES, NULL); CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text); - x = GetStringRightAlignXOffset(1, text, 0x76); - AddTextPrinterParameterized(SELECT_WIN_MON_CATEGORY, 1, text, x, 1, 0, NULL); - CopyWindowToVram(SELECT_WIN_MON_CATEGORY, 2); + x = GetStringRightAlignXOffset(FONT_NORMAL, text, 0x76); + AddTextPrinterParameterized(SELECT_WIN_MON_CATEGORY, FONT_NORMAL, text, x, 1, 0, NULL); + CopyWindowToVram(SELECT_WIN_MON_CATEGORY, COPYWIN_GFX); } } @@ -3012,7 +3012,7 @@ static void Swap_Task_ScreenInfoTransitionOut(u8 taskId) if (!gPaletteFade.active) { FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); - CopyWindowToVram(SWAP_WIN_ACTION_FADE, 2); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_GFX); if (sFactorySwapScreen->inEnemyScreen == TRUE) { // Start "Pkmn for Swap" button slide offscreen @@ -3150,7 +3150,7 @@ static void Swap_Task_ScreenInfoTransitionIn(u8 taskId) break; case 6: FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); - CopyWindowToVram(SWAP_WIN_ACTION_FADE, 2); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_GFX); gTasks[taskId].tState++; break; case 7: @@ -3280,14 +3280,14 @@ static void CB2_InitSwapScreen(void) sSwapMonPicBgTilesetBuffer = AllocZeroed(0x440); sSwapMenuTilemapBuffer = Alloc(BG_SCREEN_SIZE); sSwapMonPicBgTilemapBuffer = AllocZeroed(BG_SCREEN_SIZE); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_MOSAIC, 0); SetGpuReg(REG_OFFSET_WIN0H, 0); @@ -3724,7 +3724,7 @@ static void Swap_ErasePopupMenu(u8 windowId) gSprites[sFactorySwapScreen->menuCursor1SpriteId].invisible = TRUE; gSprites[sFactorySwapScreen->menuCursor2SpriteId].invisible = TRUE; FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); ClearWindowTilemap(windowId); } @@ -3732,14 +3732,14 @@ static void Swap_EraseSpeciesWindow(void) { PutWindowTilemap(SWAP_WIN_SPECIES); FillWindowPixelBuffer(SWAP_WIN_SPECIES, PIXEL_FILL(0)); - CopyWindowToVram(SWAP_WIN_SPECIES, 2); + CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_GFX); } static void Swap_EraseSpeciesAtFadeWindow(void) { PutWindowTilemap(SWAP_WIN_SPECIES_AT_FADE); FillWindowPixelBuffer(SWAP_WIN_SPECIES_AT_FADE, PIXEL_FILL(0)); - CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, 2); + CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, COPYWIN_GFX); } static void Swap_EraseActionFadeWindow(void) @@ -3747,14 +3747,14 @@ static void Swap_EraseActionFadeWindow(void) Swap_EraseSpeciesWindow(); PutWindowTilemap(SWAP_WIN_ACTION_FADE); FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); - CopyWindowToVram(SWAP_WIN_ACTION_FADE, 2); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_GFX); } static void Swap_PrintPkmnSwap(void) { FillWindowPixelBuffer(SWAP_WIN_TITLE, PIXEL_FILL(1)); - AddTextPrinterParameterized(SWAP_WIN_TITLE, 1, gText_PkmnSwap, 2, 1, 0, NULL); - CopyWindowToVram(SWAP_WIN_TITLE, 3); + AddTextPrinterParameterized(SWAP_WIN_TITLE, FONT_NORMAL, gText_PkmnSwap, 2, 1, 0, NULL); + CopyWindowToVram(SWAP_WIN_TITLE, COPYWIN_FULL); } static void Swap_PrintMonSpecies(void) @@ -3765,7 +3765,7 @@ static void Swap_PrintMonSpecies(void) FillWindowPixelBuffer(SWAP_WIN_SPECIES, PIXEL_FILL(0)); if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE) { - CopyWindowToVram(SWAP_WIN_SPECIES, 2); + CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_GFX); } else { @@ -3775,42 +3775,42 @@ static void Swap_PrintMonSpecies(void) else species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); - x = GetStringRightAlignXOffset(1, gStringVar4, 86); - AddTextPrinterParameterized3(SWAP_WIN_SPECIES, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); - CopyWindowToVram(SWAP_WIN_SPECIES, 3); + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 86); + AddTextPrinterParameterized3(SWAP_WIN_SPECIES, FONT_NORMAL, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); + CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_FULL); } } static void Swap_PrintOnInfoWindow(const u8 *str) { FillWindowPixelBuffer(SWAP_WIN_INFO, PIXEL_FILL(0)); - AddTextPrinterParameterized(SWAP_WIN_INFO, 1, str, 2, 5, 0, NULL); - CopyWindowToVram(SWAP_WIN_INFO, 2); + AddTextPrinterParameterized(SWAP_WIN_INFO, FONT_NORMAL, str, 2, 5, 0, NULL); + CopyWindowToVram(SWAP_WIN_INFO, COPYWIN_GFX); } static void Swap_PrintMenuOptions(void) { PutWindowTilemap(SWAP_WIN_OPTIONS); FillWindowPixelBuffer(SWAP_WIN_OPTIONS, PIXEL_FILL(0)); - AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, 1, 15, 1, sSwapMenuOptionsTextColors, 0, gText_Summary2); - AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, 1, 15, 17, sSwapMenuOptionsTextColors, 0, gText_Swap); - AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, 1, 15, 33, sSwapMenuOptionsTextColors, 0, gText_Rechoose); - CopyWindowToVram(SWAP_WIN_OPTIONS, 3); + AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, FONT_NORMAL, 15, 1, sSwapMenuOptionsTextColors, 0, gText_Summary2); + AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, FONT_NORMAL, 15, 17, sSwapMenuOptionsTextColors, 0, gText_Swap); + AddTextPrinterParameterized3(SWAP_WIN_OPTIONS, FONT_NORMAL, 15, 33, sSwapMenuOptionsTextColors, 0, gText_Rechoose); + CopyWindowToVram(SWAP_WIN_OPTIONS, COPYWIN_FULL); } static void Swap_PrintYesNoOptions(void) { PutWindowTilemap(SWAP_WIN_YES_NO); FillWindowPixelBuffer(SWAP_WIN_YES_NO, PIXEL_FILL(0)); - AddTextPrinterParameterized3(SWAP_WIN_YES_NO, 1, 7, 1, sSwapMenuOptionsTextColors, 0, gText_Yes3); - AddTextPrinterParameterized3(SWAP_WIN_YES_NO, 1, 7, 17, sSwapMenuOptionsTextColors, 0, gText_No3); - CopyWindowToVram(SWAP_WIN_YES_NO, 3); + AddTextPrinterParameterized3(SWAP_WIN_YES_NO, FONT_NORMAL, 7, 1, sSwapMenuOptionsTextColors, 0, gText_Yes3); + AddTextPrinterParameterized3(SWAP_WIN_YES_NO, FONT_NORMAL, 7, 17, sSwapMenuOptionsTextColors, 0, gText_No3); + CopyWindowToVram(SWAP_WIN_YES_NO, COPYWIN_FULL); } static void Swap_PrintActionString(const u8 *str, u32 y, u32 windowId) { - s32 x = GetStringRightAlignXOffset(0, str, 0x46); - AddTextPrinterParameterized3(windowId, 0, x, y, sSwapMenuOptionsTextColors, 0, str); + s32 x = GetStringRightAlignXOffset(FONT_SMALL, str, 0x46); + AddTextPrinterParameterized3(windowId, FONT_SMALL, x, y, sSwapMenuOptionsTextColors, 0, str); } static void Swap_PrintActionStrings(void) @@ -3824,7 +3824,7 @@ static void Swap_PrintActionStrings(void) Swap_PrintActionString(gText_Cancel3, 24, SWAP_WIN_ACTION_FADE); break; } - CopyWindowToVram(SWAP_WIN_ACTION_FADE, 3); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_FULL); } static void Swap_PrintActionStrings2(void) @@ -3838,7 +3838,7 @@ static void Swap_PrintActionStrings2(void) Swap_PrintActionString(gText_Cancel3, 32, SWAP_WIN_OPTIONS); break; } - CopyWindowToVram(SWAP_WIN_OPTIONS, 3); + CopyWindowToVram(SWAP_WIN_OPTIONS, COPYWIN_FULL); } static void Swap_PrintOneActionString(u8 which) @@ -3853,7 +3853,7 @@ static void Swap_PrintOneActionString(u8 which) Swap_PrintActionString(gText_Cancel3, 32, SWAP_WIN_OPTIONS); break; } - CopyWindowToVram(SWAP_WIN_OPTIONS, 3); + CopyWindowToVram(SWAP_WIN_OPTIONS, COPYWIN_FULL); } // For printing the species name once its selected. Keep the current fade but don't keep fading in and out @@ -3874,7 +3874,7 @@ static void Swap_PrintMonSpeciesAtFade(void) FillWindowPixelBuffer(SWAP_WIN_SPECIES_AT_FADE, PIXEL_FILL(0)); if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE) { - CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, 3); + CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, COPYWIN_FULL); } else { @@ -3884,9 +3884,9 @@ static void Swap_PrintMonSpeciesAtFade(void) else species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); - x = GetStringRightAlignXOffset(1, gStringVar4, 86); - AddTextPrinterParameterized3(SWAP_WIN_SPECIES_AT_FADE, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); - CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, 3); + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 86); + AddTextPrinterParameterized3(SWAP_WIN_SPECIES_AT_FADE, FONT_NORMAL, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); + CopyWindowToVram(SWAP_WIN_SPECIES_AT_FADE, COPYWIN_FULL); } } @@ -3901,7 +3901,7 @@ static void Swap_PrintMonSpeciesForTransition(void) if (sFactorySwapScreen->cursorPos >= FRONTIER_PARTY_SIZE) { - CopyWindowToVram(SWAP_WIN_SPECIES, 2); + CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_GFX); } else { @@ -3911,9 +3911,9 @@ static void Swap_PrintMonSpeciesForTransition(void) else species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); StringCopy(gStringVar4, gSpeciesNames[species]); - x = GetStringRightAlignXOffset(1, gStringVar4, 86); - AddTextPrinterParameterized3(SWAP_WIN_SPECIES, 1, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); - CopyWindowToVram(SWAP_WIN_SPECIES, 3); + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 86); + AddTextPrinterParameterized3(SWAP_WIN_SPECIES, FONT_NORMAL, x, 1, sSwapSpeciesNameTextColors, 0, gStringVar4); + CopyWindowToVram(SWAP_WIN_SPECIES, COPYWIN_FULL); } } @@ -3927,7 +3927,7 @@ static void Swap_PrintMonCategory(void) FillWindowPixelBuffer(SWAP_WIN_MON_CATEGORY, PIXEL_FILL(0)); if (monId >= FRONTIER_PARTY_SIZE) { - CopyWindowToVram(SWAP_WIN_MON_CATEGORY, 2); + CopyWindowToVram(SWAP_WIN_MON_CATEGORY, COPYWIN_GFX); } else { @@ -3937,9 +3937,9 @@ static void Swap_PrintMonCategory(void) else species = GetMonData(&gEnemyParty[monId], MON_DATA_SPECIES, NULL); CopyMonCategoryText(SpeciesToNationalPokedexNum(species), text); - x = GetStringRightAlignXOffset(1, text, 0x76); - AddTextPrinterParameterized(SWAP_WIN_MON_CATEGORY, 1, text, x, 1, 0, NULL); - CopyWindowToVram(SWAP_WIN_MON_CATEGORY, 2); + x = GetStringRightAlignXOffset(FONT_NORMAL, text, 0x76); + AddTextPrinterParameterized(SWAP_WIN_MON_CATEGORY, FONT_NORMAL, text, x, 1, 0, NULL); + CopyWindowToVram(SWAP_WIN_MON_CATEGORY, COPYWIN_GFX); } } @@ -4126,7 +4126,7 @@ static void Swap_TaskCantHaveSameMons(u8 taskId) if (sFactorySwapScreen->monPicAnimating != TRUE) { FillWindowPixelBuffer(SWAP_WIN_ACTION_FADE, PIXEL_FILL(0)); - CopyWindowToVram(SWAP_WIN_ACTION_FADE, 2); + CopyWindowToVram(SWAP_WIN_ACTION_FADE, COPYWIN_GFX); gTasks[taskId].tState++; } break; diff --git a/src/battle_gfx_sfx_util.c b/src/battle_gfx_sfx_util.c index c01c76b7c..f36524f37 100644 --- a/src/battle_gfx_sfx_util.c +++ b/src/battle_gfx_sfx_util.c @@ -785,7 +785,7 @@ bool8 BattleLoadAllHealthBoxesGfx(u8 state) void LoadBattleBarGfx(u8 arg0) { - LZDecompressWram(gUnknown_08C093F0, gMonSpritesGfxPtr->barFontGfx); + LZDecompressWram(gBattleInterfaceGfx_BattleBar, gMonSpritesGfxPtr->barFontGfx); } bool8 BattleInitAllSprites(u8 *state1, u8 *battlerId) diff --git a/src/battle_interface.c b/src/battle_interface.c index 77308cb3c..94850ec57 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -617,7 +617,7 @@ static const struct SubspriteTable sUnknown_0832C2CC[] = }; // unused unknown image -static const u8 sUnknown_0832C2D4[] = INCBIN_U8("graphics/battle_interface/unknown_32C2D4.4bpp"); +static const u8 sUnusedStatusSummary[] = INCBIN_U8("graphics/battle_interface/unused_status_summary.4bpp"); static const struct CompressedSpriteSheet sStatusSummaryBarSpriteSheet = { @@ -640,7 +640,7 @@ static const struct SpriteSheet sStatusSummaryBallsSpriteSheet = }; // unused oam data -static const struct OamData sUnknown_0832C354 = +static const struct OamData sOamData_Unused64x32 = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -718,21 +718,8 @@ static const struct SpriteTemplate sStatusSummaryBallsSpriteTemplates[2] = } }; -// possibly text -static const u8 sUnknown_0832C3C4[] = -{ - 0xfc, 0x01, 0x01, 0xfc, 0x02, 0x02, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, -}; - -// possibly text -static const u8 sUnknown_0832C3D8[] = -{ - 0xfc, 0x01, 0x01, 0xfc, 0x02, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, -}; +static const u8 sEmptyWhiteText_GrayHighlight[] = __("{COLOR WHITE}{HIGHLIGHT DARK_GRAY} "); +static const u8 sEmptyWhiteText_TransparentHighlight[] = __("{COLOR WHITE}{HIGHLIGHT TRANSPARENT} "); enum { @@ -1166,7 +1153,7 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) { u8 battler; - memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4)); + memcpy(text, sEmptyWhiteText_GrayHighlight, sizeof(sEmptyWhiteText_GrayHighlight)); battler = gSprites[healthboxSpriteId].hMain_Battler; if (IsDoubleBattle() == TRUE || GetBattlerSide(battler) == B_SIDE_OPPONENT) { @@ -1193,7 +1180,7 @@ void UpdateHpTextInHealthbox(u8 healthboxSpriteId, s16 value, u8 maxOrCurrent) } ConvertIntToDecimalStringN(text + 6, value, STR_CONV_MODE_RIGHT_ALIGN, 3); - RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text); + RenderTextHandleBold(gMonSpritesGfxPtr->barFontGfx, FONT_BOLD, text); for (i = 0; i < 3; i++) { @@ -1245,7 +1232,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 { u8 battlerId; - memcpy(text, sUnknown_0832C3D8, sizeof(sUnknown_0832C3D8)); + memcpy(text, sEmptyWhiteText_TransparentHighlight, sizeof(sEmptyWhiteText_TransparentHighlight)); battlerId = gSprites[healthboxSpriteId].hMain_Battler; if (gBattleSpritesDataPtr->battlerData[battlerId].hpNumbersNoBars) // don't print text if only bars are visible @@ -1262,7 +1249,7 @@ static void UpdateHpTextInHealthboxInDoubles(u8 healthboxSpriteId, s16 value, u8 txtPtr = ConvertIntToDecimalStringN(text + 6, value, STR_CONV_MODE_RIGHT_ALIGN, 3); if (!maxOrCurrent) StringCopy(txtPtr, gText_Slash); - RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text); + RenderTextHandleBold(gMonSpritesGfxPtr->barFontGfx, FONT_BOLD, text); for (i = var; i < var + 3; i++) { @@ -1308,12 +1295,12 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon) u8 *barFontGfx; u8 i, var, nature, healthBarSpriteId; - memcpy(text, sUnknown_0832C3C4, sizeof(sUnknown_0832C3C4)); + memcpy(text, sEmptyWhiteText_GrayHighlight, sizeof(sEmptyWhiteText_GrayHighlight)); barFontGfx = &gMonSpritesGfxPtr->barFontGfx[0x520 + (GetBattlerPosition(gSprites[healthboxSpriteId].hMain_Battler) * 384)]; var = 5; nature = GetNature(mon); StringCopy(text + 6, gNatureNamePointers[nature]); - RenderTextFont9(barFontGfx, 9, text); + RenderTextHandleBold(barFontGfx, FONT_BOLD, text); for (j = 6, i = 0; i < var; i++, j++) { @@ -1345,7 +1332,7 @@ static void PrintSafariMonInfo(u8 healthboxSpriteId, struct Pokemon *mon) ConvertIntToDecimalStringN(text + 9, gBattleStruct->safariEscapeFactor, STR_CONV_MODE_RIGHT_ALIGN, 2); text[5] = CHAR_SPACE; text[8] = CHAR_SLASH; - RenderTextFont9(gMonSpritesGfxPtr->barFontGfx, 9, text); + RenderTextHandleBold(gMonSpritesGfxPtr->barFontGfx, FONT_BOLD, text); j = healthBarSpriteId; // Needed to match for some reason. for (j = 0; j < 5; j++) @@ -2130,7 +2117,7 @@ static void UpdateLeftNoOfBallsTextOnHealthbox(u8 healthboxSpriteId) txtPtr = StringCopy(text, gText_SafariBallLeft); ConvertIntToDecimalStringN(txtPtr, gNumSafariBalls, STR_CONV_MODE_LEFT_ALIGN, 2); - windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(text, GetStringRightAlignXOffset(0, text, 0x2F), 3, 2, &windowId); + windowTileData = AddTextPrinterAndCreateWindowOnHealthbox(text, GetStringRightAlignXOffset(FONT_SMALL, text, 0x2F), 3, 2, &windowId); spriteTileNum = gSprites[healthboxSpriteId].oam.tileNum * TILE_SIZE_4BPP; SafariTextIntoHealthboxObject((void*)(OBJ_VRAM0 + 0x2C0) + spriteTileNum, windowTileData, 2); SafariTextIntoHealthboxObject((void*)(OBJ_VRAM0 + 0xA00) + spriteTileNum, windowTileData + 0x40, 4); @@ -2538,7 +2525,7 @@ static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y, color[1] = 1; color[2] = 3; - AddTextPrinterParameterized4(winId, 0, x, y, 0, 0, color, -1, str); + AddTextPrinterParameterized4(winId, FONT_SMALL, x, y, 0, 0, color, TEXT_SKIP_DRAW, str); *windowId = winId; return (u8*)(GetWindowAttribute(winId, WINDOW_TILE_DATA)); diff --git a/src/battle_main.c b/src/battle_main.c index ec093ecc7..8079546d4 100644 --- a/src/battle_main.c +++ b/src/battle_main.c @@ -682,7 +682,7 @@ static void CB2_InitBattleInternal(void) { CreateNPCTrainerParty(&gEnemyParty[0], gTrainerBattleOpponent_A, TRUE); if (gBattleTypeFlags & BATTLE_TYPE_TWO_OPPONENTS) - CreateNPCTrainerParty(&gEnemyParty[3], gTrainerBattleOpponent_B, FALSE); + CreateNPCTrainerParty(&gEnemyParty[PARTY_SIZE / 2], gTrainerBattleOpponent_B, FALSE); SetWildMonHeldItem(); } diff --git a/src/battle_message.c b/src/battle_message.c index b69a171a1..b88eedfb3 100644 --- a/src/battle_message.c +++ b/src/battle_message.c @@ -8,6 +8,7 @@ #include "data.h" #include "event_data.h" #include "frontier_util.h" +#include "graphics.h" #include "international_string_util.h" #include "item.h" #include "link.h" @@ -42,18 +43,13 @@ struct BattleWindowText u8 shadowColor; }; -extern const u16 gUnknown_08D85620[]; - -// this file's functions static void ChooseMoveUsedParticle(u8 *textPtr); static void ChooseTypeOfMoveUsedString(u8 *dst); static void ExpandBattleTextBuffPlaceholders(const u8 *src, u8 *dst); -// EWRAM vars static EWRAM_DATA u8 sBattlerAbilities[MAX_BATTLERS_COUNT] = {0}; EWRAM_DATA struct BattleMsgData *gBattleMsgDataPtr = NULL; -// const rom data // todo: make some of those names less vague: attacker/target vs pkmn, etc. static const u8 sText_Trainer1LoseText[] = _("{B_TRAINER1_LOSE_TEXT}"); @@ -1482,7 +1478,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = { [B_WIN_MSG] = { .fillValue = PIXEL_FILL(0xF), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1494,7 +1490,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_ACTION_PROMPT] = { .fillValue = PIXEL_FILL(0xF), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 1, .y = 1, .letterSpacing = 0, @@ -1506,7 +1502,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_ACTION_MENU] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1518,7 +1514,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_MOVE_NAME_1] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1530,7 +1526,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_MOVE_NAME_2] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1542,7 +1538,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_MOVE_NAME_3] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1554,7 +1550,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_MOVE_NAME_4] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1566,7 +1562,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_PP] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1578,7 +1574,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_DUMMY] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1590,7 +1586,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_PP_REMAINING] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 2, .y = 1, .letterSpacing = 0, @@ -1602,7 +1598,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_MOVE_TYPE] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1614,7 +1610,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_SWITCH_PROMPT] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1626,7 +1622,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_YESNO] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1638,7 +1634,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_LEVEL_UP_BOX] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1650,7 +1646,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_LEVEL_UP_BANNER] = { .fillValue = PIXEL_FILL(0), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 32, .y = 1, .letterSpacing = 0, @@ -1662,7 +1658,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_PLAYER] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1674,7 +1670,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_OPPONENT] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1686,7 +1682,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_MULTI_PLAYER_1] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1698,7 +1694,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_MULTI_PLAYER_2] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1710,7 +1706,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_MULTI_PLAYER_3] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1722,7 +1718,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_MULTI_PLAYER_4] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1734,7 +1730,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_OUTCOME_DRAW] = { .fillValue = PIXEL_FILL(0), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1746,7 +1742,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_OUTCOME_LEFT] = { .fillValue = PIXEL_FILL(0), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1758,7 +1754,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Normal[] = }, [B_WIN_VS_OUTCOME_RIGHT] = { .fillValue = PIXEL_FILL(0x0), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1774,7 +1770,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = { [B_WIN_MSG] = { .fillValue = PIXEL_FILL(0xF), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1786,7 +1782,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_ACTION_PROMPT] = { .fillValue = PIXEL_FILL(0xF), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 1, .y = 1, .letterSpacing = 0, @@ -1798,7 +1794,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_ACTION_MENU] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1810,7 +1806,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_MOVE_NAME_1] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1822,7 +1818,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_MOVE_NAME_2] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1834,7 +1830,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_MOVE_NAME_3] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1846,7 +1842,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_MOVE_NAME_4] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1858,7 +1854,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_PP] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1870,7 +1866,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_DUMMY] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1882,7 +1878,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_PP_REMAINING] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 2, .y = 1, .letterSpacing = 0, @@ -1894,7 +1890,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_MOVE_TYPE] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1906,7 +1902,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_SWITCH_PROMPT] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 7, + .fontId = FONT_NARROW, .x = 0, .y = 1, .letterSpacing = 0, @@ -1918,7 +1914,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_YESNO] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1930,7 +1926,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_LEVEL_UP_BOX] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -1942,7 +1938,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [B_WIN_LEVEL_UP_BANNER] = { .fillValue = PIXEL_FILL(0), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 32, .y = 1, .letterSpacing = 0, @@ -1954,7 +1950,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [ARENA_WIN_PLAYER_NAME] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1966,7 +1962,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [ARENA_WIN_VS] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1978,7 +1974,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [ARENA_WIN_OPPONENT_NAME] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -1990,7 +1986,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [ARENA_WIN_MIND] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -2002,7 +1998,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [ARENA_WIN_SKILL] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -2014,7 +2010,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [ARENA_WIN_BODY] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -2026,7 +2022,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [ARENA_WIN_JUDGEMENT_TITLE] = { .fillValue = PIXEL_FILL(0xE), - .fontId = 1, + .fontId = FONT_NORMAL, .x = -1, .y = 1, .letterSpacing = 0, @@ -2038,7 +2034,7 @@ static const struct BattleWindowText sTextOnWindowsInfo_Arena[] = }, [ARENA_WIN_JUDGEMENT_TEXT] = { .fillValue = PIXEL_FILL(0x1), - .fontId = 1, + .fontId = FONT_NORMAL, .x = 0, .y = 1, .letterSpacing = 0, @@ -2058,7 +2054,6 @@ static const struct BattleWindowText *const sBattleTextOnWindowsInfo[] = static const u8 sRecordedBattleTextSpeeds[] = {8, 4, 1, 0}; -// code void BufferStringBattle(u16 stringID) { s32 i; @@ -3118,14 +3113,14 @@ void BattlePutTextOnWindow(const u8 *text, u8 windowId) if (copyToVram) { PutWindowTilemap(windowId); - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } } void SetPpNumbersPaletteInMoveSelection(void) { struct ChooseMoveStruct *chooseMoveStruct = (struct ChooseMoveStruct*)(&gBattleBufferA[gActiveBattler][4]); - const u16 *palPtr = gUnknown_08D85620; + const u16 *palPtr = gPPTextPalette; u8 var = GetCurrentPpToMaxPpState(chooseMoveStruct->currentPp[gMoveSelectionCursor[gActiveBattler]], chooseMoveStruct->maxPp[gMoveSelectionCursor[gActiveBattler]]); diff --git a/src/battle_pyramid.c b/src/battle_pyramid.c index e334e75d5..48155c833 100644 --- a/src/battle_pyramid.c +++ b/src/battle_pyramid.c @@ -26,6 +26,7 @@ #include "malloc.h" #include "overworld.h" #include "event_scripts.h" +#include "graphics.h" #include "constants/battle_frontier.h" #include "constants/battle_pyramid.h" #include "constants/event_objects.h" @@ -39,9 +40,6 @@ #include "constants/trainers.h" extern const struct MapLayout *const gMapLayouts[]; -extern const u16 gUnknown_08D856C8[][16]; - - struct PyramidWildMon { @@ -1188,7 +1186,7 @@ static void Task_SetPyramidFloorPalette(u8 taskId) { if (gPaletteFade.active) { - CpuCopy16(gUnknown_08D856C8[gSaveBlock2Ptr->frontier.curChallengeBattleNum], &gPlttBufferUnfaded[96], 32); + CpuCopy16(gBattlePyramidFloor_Pal[gSaveBlock2Ptr->frontier.curChallengeBattleNum], &gPlttBufferUnfaded[96], 32); DestroyTask(taskId); } } diff --git a/src/battle_pyramid_bag.c b/src/battle_pyramid_bag.c index 179f4dc65..d1b946146 100644 --- a/src/battle_pyramid_bag.c +++ b/src/battle_pyramid_bag.c @@ -88,8 +88,8 @@ static void CopyBagItemName(u8 *, u16); static void FreeItemIconSpriteByAltId(u8); static void PrintItemDescription(s32); static void PrintSelectorArrowAtPos(u8, u8); -static void PrintOnWindow_Font1(u8, const u8 *, u8, u8, u8, u8, u8, u8); -static void PrintOnWindow_Font7(u8, const u8 *, u8, u8, u8, u8, u8, u8); +static void PyramidBagPrint(u8, const u8 *, u8, u8, u8, u8, u8, u8); +static void PyramidBagPrint_Quantity(u8, const u8 *, u8, u8, u8, u8, u8, u8); static u8 OpenMenuActionWindowById(u8); static void CloseMenuActionWindowById(u8); static void PrintMenuActionText_SingleRow(u8); @@ -159,7 +159,7 @@ static const struct ListMenuTemplate sListMenuTemplate = .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, - .fontId = 7, + .fontId = FONT_NARROW, .cursorKind = 0 }; @@ -358,7 +358,7 @@ static const union AffineAnimCmd * const sAffineAnims_PyramidBag[] = [ANIM_BAG_SHAKE] = sAffineAnim_PyramidBag_Shake, }; -static const struct CompressedSpriteSheet sSpriteSheet_PyramidBag = {gBattleFrontierGfx_PyramidBag, 0x0800, TAG_PYRAMID_BAG}; +static const struct CompressedSpriteSheet sSpriteSheet_PyramidBag = {gBattlePyramidBag_Gfx, 0x0800, TAG_PYRAMID_BAG}; static const struct SpriteTemplate sSpriteTemplate_PyramidBag = { @@ -452,9 +452,9 @@ static void VBlankCB_PyramidBag(void) static void CB2_LoadPyramidBagMenu(void) { - while (MenuHelpers_CallLinkSomething() != TRUE + while (MenuHelpers_ShouldWaitForLinkRecv() != TRUE && LoadPyramidBagMenu() != TRUE - && MenuHelpers_LinkSomething() != TRUE); + && MenuHelpers_IsLinkActive() != TRUE); } static bool8 LoadPyramidBagMenu(void) @@ -484,7 +484,7 @@ static bool8 LoadPyramidBagMenu(void) gMain.state++; break; case 5: - if (!MenuHelpers_LinkSomething()) + if (!MenuHelpers_IsLinkActive()) ResetTasks(); gMain.state++; break; @@ -573,12 +573,12 @@ static bool8 LoadPyramidBagGfx(void) case 1: if (FreeTempTileDataBuffersIfPossible() != TRUE) { - LZDecompressWram(gBattleFrontierGfx_PyramidBagTileMap, gPyramidBagMenu->tilemapBuffer); + LZDecompressWram(gBattlePyramidBagTilemap, gPyramidBagMenu->tilemapBuffer); gPyramidBagMenu->state++; } break; case 2: - LoadCompressedPalette(gUnknown_08D9AF44, 0, 32); + LoadCompressedPalette(gBattlePyramidBagInterface_Pal, 0, 32); gPyramidBagMenu->state++; break; case 3: @@ -672,8 +672,8 @@ static void PrintItemQuantity(u8 windowId, u32 itemIndex, u8 y) STR_CONV_MODE_RIGHT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, gText_xVar1); - xAlign = GetStringRightAlignXOffset(7, gStringVar4, 119); - PrintOnWindow_Font7(windowId, gStringVar4, xAlign, y, 0, 0, TEXT_SPEED_FF, COLORID_DARK_GRAY); + xAlign = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 119); + PyramidBagPrint_Quantity(windowId, gStringVar4, xAlign, y, 0, 0, TEXT_SKIP_DRAW, COLORID_DARK_GRAY); } static void PrintItemDescription(s32 listMenuId) @@ -690,7 +690,7 @@ static void PrintItemDescription(s32 listMenuId) desc = gStringVar4; } FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PrintOnWindow_Font1(WIN_INFO, desc, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); + PyramidBagPrint(WIN_INFO, desc, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); } static void AddScrollArrows(void) @@ -849,9 +849,9 @@ static void PrintSelectorArrow(u8 listMenuTaskId, u8 colorId) static void PrintSelectorArrowAtPos(u8 y, u8 colorId) { if (colorId == COLORID_NONE) // If 'no color', erase arrow - FillWindowPixelRect(WIN_LIST, PIXEL_FILL(0), 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); + FillWindowPixelRect(WIN_LIST, PIXEL_FILL(0), 0, y, GetMenuCursorDimensionByFont(FONT_NORMAL, 0), GetMenuCursorDimensionByFont(FONT_NORMAL, 1)); else - PrintOnWindow_Font1(WIN_LIST, gText_SelectorArrow2, 0, y, 0, 0, 0, colorId); + PyramidBagPrint(WIN_LIST, gText_SelectorArrow2, 0, y, 0, 0, 0, colorId); } void CloseBattlePyramidBag(u8 taskId) @@ -885,7 +885,7 @@ static void Task_ClosePyramidBag(u8 taskId) static void Task_HandlePyramidBagInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (MenuHelpers_CallLinkSomething() == TRUE || gPaletteFade.active) + if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE || gPaletteFade.active) return; if (JOY_NEW(SELECT_BUTTON)) @@ -962,7 +962,7 @@ static void OpenContextMenu(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected); FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PrintOnWindow_Font1(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); + PyramidBagPrint(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); if (gPyramidBagMenu->menuActionsCount == 1) PrintMenuActionText_SingleRow(OpenMenuActionWindowById(MENU_WIN_1x1)); else if (gPyramidBagMenu->menuActionsCount == 2) @@ -978,19 +978,19 @@ static void OpenContextMenu(u8 taskId) static void PrintMenuActionText_SingleRow(u8 windowId) { - AddItemMenuActionTextPrinters(windowId, 7, 8, 1, 0, 0x10, gPyramidBagMenu->menuActionsCount, sMenuActions, gPyramidBagMenu->menuActionIds); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, gPyramidBagMenu->menuActionsCount, 0); + PrintMenuActionTexts(windowId, FONT_NARROW, 8, 1, 0, 0x10, gPyramidBagMenu->menuActionsCount, sMenuActions, gPyramidBagMenu->menuActionIds); + InitMenuInUpperLeftCornerNormal(windowId, gPyramidBagMenu->menuActionsCount, 0); } static void PrintMenuActionText_MultiRow(u8 windowId, u8 horizontalCount, u8 verticalCount) { - PrintMenuActionGrid(windowId, 7, 8, 1, 56, horizontalCount, verticalCount, sMenuActions, gPyramidBagMenu->menuActionIds); + PrintMenuActionGrid(windowId, FONT_NARROW, 8, 1, 56, horizontalCount, verticalCount, sMenuActions, gPyramidBagMenu->menuActionIds); InitMenuActionGrid(windowId, 56, horizontalCount, verticalCount, 0); } static void HandleMenuActionInput_SingleRow(u8 taskId) { - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { s32 id = Menu_ProcessInputNoWrap(); switch (id) @@ -1012,7 +1012,7 @@ static void HandleMenuActionInput_SingleRow(u8 taskId) static void HandleMenuActionInput_2x2(u8 taskId) { - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { s8 id = Menu_GetCursorPos(); if (JOY_NEW(DPAD_UP)) @@ -1020,7 +1020,7 @@ static void HandleMenuActionInput_2x2(u8 taskId) if (id > 0 && IsValidMenuAction(id - 2)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); } } else if (JOY_NEW(DPAD_DOWN)) @@ -1028,7 +1028,7 @@ static void HandleMenuActionInput_2x2(u8 taskId) if (id < gPyramidBagMenu->menuActionsCount - 2 && IsValidMenuAction(id + 2)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); } } else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) @@ -1036,7 +1036,7 @@ static void HandleMenuActionInput_2x2(u8 taskId) if (id & 1 && IsValidMenuAction(id - 1)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); } } else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) @@ -1044,7 +1044,7 @@ static void HandleMenuActionInput_2x2(u8 taskId) if (!(id & 1) && IsValidMenuAction(id + 1)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); } } else if (JOY_NEW(A_BUTTON)) @@ -1137,7 +1137,7 @@ static void BagAction_Toss(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_TossHowManyVar1s); FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PrintOnWindow_Font1(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); + PyramidBagPrint(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); ShowNumToToss(); gTasks[taskId].func = Task_ChooseHowManyToToss; } @@ -1151,7 +1151,7 @@ static void AskConfirmToss(u8 taskId) ConvertIntToDecimalStringN(gStringVar2, tNumToToss, STR_CONV_MODE_LEFT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems); FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PrintOnWindow_Font1(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); + PyramidBagPrint(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); CreatePyramidBagYesNo(taskId, &sYesNoTossFuncions); } @@ -1170,8 +1170,8 @@ static void ShowNumToToss(void) ConvertIntToDecimalStringN(gStringVar1, 1, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_xVar1); DrawTossNumberWindow(WIN_TOSS_NUM); - x = GetStringCenterAlignXOffset(1, gStringVar4, 0x28); - AddTextPrinterParameterized(WIN_TOSS_NUM, 1, gStringVar4, x, 2, 0, NULL); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 0x28); + AddTextPrinterParameterized(WIN_TOSS_NUM, FONT_NORMAL, gStringVar4, x, 2, 0, NULL); } static void UpdateNumToToss(s16 num) @@ -1179,8 +1179,8 @@ static void UpdateNumToToss(s16 num) s32 x; ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_xVar1); - x = GetStringCenterAlignXOffset(1, gStringVar4, 0x28); - AddTextPrinterParameterized(WIN_TOSS_NUM, 1, gStringVar4, x, 2, 0, NULL); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 0x28); + AddTextPrinterParameterized(WIN_TOSS_NUM, FONT_NORMAL, gStringVar4, x, 2, 0, NULL); } static void Task_ChooseHowManyToToss(u8 taskId) @@ -1219,7 +1219,7 @@ static void TossItem(u8 taskId) ConvertIntToDecimalStringN(gStringVar2, tNumToToss, STR_CONV_MODE_LEFT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, gText_ThrewAwayVar2Var1s); FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PrintOnWindow_Font1(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); + PyramidBagPrint(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); gTasks[taskId].func = Task_TossItem; } @@ -1316,7 +1316,7 @@ static void Task_BeginItemSwap(u8 taskId) CopyItemName(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][tListPos], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where); FillWindowPixelBuffer(WIN_INFO, PIXEL_FILL(0)); - PrintOnWindow_Font1(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); + PyramidBagPrint(WIN_INFO, gStringVar4, 3, 0, 0, 1, 0, COLORID_DARK_GRAY); PrintSelectorArrow(tListTaskId, COLORID_LIGHT_GRAY); UpdateSwapLinePos(tListPos); gTasks[taskId].func = Task_ItemSwapHandleInput; @@ -1325,7 +1325,7 @@ static void Task_BeginItemSwap(u8 taskId) static void Task_ItemSwapHandleInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { if (JOY_NEW(SELECT_BUTTON)) { @@ -1443,7 +1443,7 @@ static void InitPyramidBagWindows(void) DeactivateAllTextPrinters(); LoadUserWindowBorderGfx(0, 0x1, 0xE0); LoadMessageBoxGfx(0, 0xA, 0xD0); - LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(gStandardMenuPalette, 0xF0, 0x20); for (i = 0; i < ARRAY_COUNT(sWindowTemplates); i++) FillWindowPixelBuffer(i, PIXEL_FILL(0)); @@ -1454,14 +1454,14 @@ static void InitPyramidBagWindows(void) ScheduleBgCopyTilemapToVram(1); } -static void PrintOnWindow_Font1(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId) +static void PyramidBagPrint(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId) { - AddTextPrinterParameterized4(windowId, 1, x, y, letterSpacing, lineSpacing, sTextColors[colorTableId], speed, src); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, letterSpacing, lineSpacing, sTextColors[colorTableId], speed, src); } -static void PrintOnWindow_Font7(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId) +static void PyramidBagPrint_Quantity(u8 windowId, const u8 *src, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, u8 speed, u8 colorTableId) { - AddTextPrinterParameterized4(windowId, 7, x, y, letterSpacing, lineSpacing, sTextColors[colorTableId], speed, src); + AddTextPrinterParameterized4(windowId, FONT_NARROW, x, y, letterSpacing, lineSpacing, sTextColors[colorTableId], speed, src); } static void DrawTossNumberWindow(u8 windowId) @@ -1509,7 +1509,7 @@ static void CreatePyramidBagYesNo(u8 taskId, const struct YesNoFuncTable *yesNoT void DisplayItemMessageInBattlePyramid(u8 taskId, const u8 *str, void (*callback)(u8 taskId)) { FillWindowPixelBuffer(WIN_MSG, PIXEL_FILL(1)); - DisplayMessageAndContinueTask(taskId, WIN_MSG, 0xA, 0xD, 1, GetPlayerTextSpeedDelay(), str, callback); + DisplayMessageAndContinueTask(taskId, WIN_MSG, 0xA, 0xD, FONT_NORMAL, GetPlayerTextSpeedDelay(), str, callback); ScheduleBgCopyTilemapToVram(1); } @@ -1541,7 +1541,7 @@ static void LoadPyramidBagPalette(void) struct SpritePalette spritePalette; u16 *palPtr = Alloc(0x40); - LZDecompressWram(gBattleFrontierGfx_PyramidBag_Pal, palPtr); + LZDecompressWram(gBattlePyramidBag_Pal, palPtr); spritePalette.data = palPtr + (gSaveBlock2Ptr->frontier.lvlMode * 16); spritePalette.tag = TAG_PYRAMID_BAG; LoadSpritePalette(&spritePalette); diff --git a/src/battle_records.c b/src/battle_records.c index 5dff8e6d3..f576d5912 100644 --- a/src/battle_records.c +++ b/src/battle_records.c @@ -24,21 +24,18 @@ #include "trainer_hill.h" #include "constants/rgb.h" -// this file's functions static void Task_CloseTrainerHillRecordsOnButton(u8 taskId); static void Task_BeginPaletteFade(u8 taskId); static void Task_ExitTrainerHillRecords(u8 taskId); static void RemoveTrainerHillRecordsWindow(u8 windowId); static void CB2_ShowTrainerHillRecords(void); -// EWRAM variables EWRAM_DATA u8 gRecordsWindowId = 0; EWRAM_DATA static u8 *sTilemapBuffer = NULL; -// const rom data -static const u32 sTrainerHillWindowTileset[] = INCBIN_U32("graphics/unknown/unknown_5B3484.4bpp"); -static const u16 sTrainerHillWindowPalette[] = INCBIN_U16("graphics/unknown/unknown_5B3484.gbapal"); -static const u32 sTrainerHillWindowTilemap[] = INCBIN_U32("graphics/unknown/unknown_5B3564.bin"); +static const u32 sTrainerHillWindowTileset[] = INCBIN_U32("graphics/trainer_hill/records_window.4bpp"); +static const u16 sTrainerHillWindowPalette[] = INCBIN_U16("graphics/trainer_hill/records_window.gbapal"); +static const u32 sTrainerHillWindowTilemap[] = INCBIN_U32("graphics/trainer_hill/records_window.bin"); static const struct BgTemplate sTrainerHillRecordsBgTemplates[] = { @@ -282,8 +279,8 @@ static void PrintLinkBattleWinsLossesDraws(struct LinkBattleRecord *records) ConvertIntToDecimalStringN(gStringVar3, GetGameStat(GAME_STAT_LINK_BATTLE_DRAWS), STR_CONV_MODE_LEFT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, gText_TotalRecordWLD); - x = GetStringCenterAlignXOffset(1, gStringVar4, 0xD0); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x, 0x11, 0, NULL); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 0xD0); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x, 0x11, 0, NULL); } static void PrintLinkBattleRecord(struct LinkBattleRecord *record, u8 y, s32 language) @@ -291,10 +288,10 @@ static void PrintLinkBattleRecord(struct LinkBattleRecord *record, u8 y, s32 lan if (record->wins == 0 && record->losses == 0 && record->draws == 0) { // empty slot - AddTextPrinterParameterized(gRecordsWindowId, 1, sText_DashesNoPlayer, 8, (y * 8) + 1, 0, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, sText_DashesNoScore, 80, (y * 8) + 1, 0, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, sText_DashesNoScore, 128, (y * 8) + 1, 0, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, sText_DashesNoScore, 176, (y * 8) + 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, sText_DashesNoPlayer, 8, (y * 8) + 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, sText_DashesNoScore, 80, (y * 8) + 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, sText_DashesNoScore, 128, (y * 8) + 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, sText_DashesNoScore, 176, (y * 8) + 1, 0, NULL); } else { @@ -302,16 +299,16 @@ static void PrintLinkBattleRecord(struct LinkBattleRecord *record, u8 y, s32 lan StringCopyN(gStringVar1, record->name, 7); ConvertInternationalString(gStringVar1, language); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar1, 8, (y * 8) + 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar1, 8, (y * 8) + 1, 0, NULL); ConvertIntToDecimalStringN(gStringVar1, record->wins, STR_CONV_MODE_RIGHT_ALIGN, 4); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar1, 80, (y * 8) + 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar1, 80, (y * 8) + 1, 0, NULL); ConvertIntToDecimalStringN(gStringVar1, record->losses, STR_CONV_MODE_RIGHT_ALIGN, 4); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar1, 128, (y * 8) + 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar1, 128, (y * 8) + 1, 0, NULL); ConvertIntToDecimalStringN(gStringVar1, record->draws, STR_CONV_MODE_RIGHT_ALIGN, 4); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar1, 176, (y * 8) + 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar1, 176, (y * 8) + 1, 0, NULL); } } @@ -324,12 +321,12 @@ void ShowLinkBattleRecords(void) FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1)); StringExpandPlaceholders(gStringVar4, gText_PlayersBattleResults); - x = GetStringCenterAlignXOffset(1, gStringVar4, 208); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x, 1, 0, NULL); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 208); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x, 1, 0, NULL); PrintLinkBattleWinsLossesDraws(gSaveBlock1Ptr->linkBattleRecords.entries); StringExpandPlaceholders(gStringVar4, gText_WinLoseDraw); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, 0, 41, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, 0, 41, 0, NULL); for (i = 0; i < LINK_B_RECORDS_COUNT; i++) { @@ -337,7 +334,7 @@ void ShowLinkBattleRecords(void) } PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } void RemoveRecordsWindow(void) @@ -385,7 +382,7 @@ static void RemoveTrainerHillRecordsWindow(u8 windowId) { FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); ClearWindowTilemap(windowId); - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); RemoveWindow(windowId); } @@ -428,14 +425,14 @@ static void ClearTasksAndGraphicalStructs(void) static void ResetBgCoordinates(void) { - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); } static void SetDispcntReg(void) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 92d4b9707..391e82850 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -5921,7 +5921,7 @@ static void Cmd_drawlvlupbox(void) // Draw page 1 of level up box DrawLevelUpWindow1(); PutWindowTilemap(B_WIN_LEVEL_UP_BOX); - CopyWindowToVram(B_WIN_LEVEL_UP_BOX, 3); + CopyWindowToVram(B_WIN_LEVEL_UP_BOX, COPYWIN_FULL); gBattleScripting.drawlvlupboxState++; break; case 5: @@ -5939,7 +5939,7 @@ static void Cmd_drawlvlupbox(void) // Draw page 2 of level up box PlaySE(SE_SELECT); DrawLevelUpWindow2(); - CopyWindowToVram(B_WIN_LEVEL_UP_BOX, 2); + CopyWindowToVram(B_WIN_LEVEL_UP_BOX, COPYWIN_GFX); gBattleScripting.drawlvlupboxState++; } break; @@ -5956,10 +5956,10 @@ static void Cmd_drawlvlupbox(void) if (!SlideOutLevelUpBanner()) { ClearWindowTilemap(B_WIN_LEVEL_UP_BANNER); - CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, 1); + CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, COPYWIN_MAP); ClearWindowTilemap(B_WIN_LEVEL_UP_BOX); - CopyWindowToVram(B_WIN_LEVEL_UP_BOX, 1); + CopyWindowToVram(B_WIN_LEVEL_UP_BOX, COPYWIN_MAP); SetBgAttribute(2, BG_ATTR_PRIORITY, 2); ShowBg(2); @@ -6004,7 +6004,7 @@ static void InitLevelUpBanner(void) LoadPalette(sLevelUpBanner_Pal, 0x60, 0x20); CopyToWindowPixelBuffer(B_WIN_LEVEL_UP_BANNER, sLevelUpBanner_Gfx, 0, 0); PutWindowTilemap(B_WIN_LEVEL_UP_BANNER); - CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, 3); + CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, COPYWIN_FULL); PutMonIconOnLvlUpBanner(); } @@ -6041,7 +6041,7 @@ static void DrawLevelUpBannerText(void) printerTemplate.currentChar = gStringVar4; printerTemplate.windowId = B_WIN_LEVEL_UP_BANNER; - printerTemplate.fontId = 0; + printerTemplate.fontId = FONT_SMALL; printerTemplate.x = 32; printerTemplate.y = 0; printerTemplate.currentX = 32; @@ -6053,7 +6053,7 @@ static void DrawLevelUpBannerText(void) printerTemplate.bgColor = TEXT_COLOR_TRANSPARENT; printerTemplate.shadowColor = TEXT_COLOR_DARK_GRAY; - AddTextPrinter(&printerTemplate, TEXT_SPEED_FF, NULL); + AddTextPrinter(&printerTemplate, TEXT_SKIP_DRAW, NULL); txtPtr = gStringVar4; *(txtPtr)++ = CHAR_EXTRA_SYMBOL; @@ -6083,9 +6083,9 @@ static void DrawLevelUpBannerText(void) printerTemplate.y = 10; printerTemplate.currentY = 10; - AddTextPrinter(&printerTemplate, TEXT_SPEED_FF, NULL); + AddTextPrinter(&printerTemplate, TEXT_SKIP_DRAW, NULL); - CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, 2); + CopyWindowToVram(B_WIN_LEVEL_UP_BANNER, COPYWIN_GFX); } static bool8 SlideOutLevelUpBanner(void) @@ -8098,7 +8098,7 @@ static bool8 IsTwoTurnsMove(u16 move) if (gBattleMoves[move].effect == EFFECT_SKULL_BASH || gBattleMoves[move].effect == EFFECT_RAZOR_WIND || gBattleMoves[move].effect == EFFECT_SKY_ATTACK - || gBattleMoves[move].effect == EFFECT_SOLARBEAM + || gBattleMoves[move].effect == EFFECT_SOLAR_BEAM || gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE || gBattleMoves[move].effect == EFFECT_BIDE) return TRUE; @@ -8118,14 +8118,14 @@ static bool8 IsInvalidForSleepTalkOrAssist(u16 move) static u8 AttacksThisTurn(u8 battlerId, u16 move) // Note: returns 1 if it's a charging turn, otherwise 2 { // first argument is unused - if (gBattleMoves[move].effect == EFFECT_SOLARBEAM + if (gBattleMoves[move].effect == EFFECT_SOLAR_BEAM && (gBattleWeather & B_WEATHER_SUN)) return 2; if (gBattleMoves[move].effect == EFFECT_SKULL_BASH || gBattleMoves[move].effect == EFFECT_RAZOR_WIND || gBattleMoves[move].effect == EFFECT_SKY_ATTACK - || gBattleMoves[move].effect == EFFECT_SOLARBEAM + || gBattleMoves[move].effect == EFFECT_SOLAR_BEAM || gBattleMoves[move].effect == EFFECT_SEMI_INVULNERABLE || gBattleMoves[move].effect == EFFECT_BIDE) { diff --git a/src/battle_setup.c b/src/battle_setup.c index 90c004b55..a9d4eeddf 100644 --- a/src/battle_setup.c +++ b/src/battle_setup.c @@ -46,9 +46,16 @@ #include "constants/maps.h" #include "constants/trainers.h" #include "constants/trainer_hill.h" +#include "constants/weather.h" -enum -{ +enum { + TRANSITION_TYPE_NORMAL, + TRANSITION_TYPE_CAVE, + TRANSITION_TYPE_FLASH, + TRANSITION_TYPE_WATER, +}; + +enum { TRAINER_PARAM_LOAD_VAL_8BIT, TRAINER_PARAM_LOAD_VAL_16BIT, TRAINER_PARAM_LOAD_VAL_32BIT, @@ -85,7 +92,6 @@ static void HandleRematchVarsOnBattleEnd(void); static const u8 *GetIntroSpeechOfApproachingTrainer(void); static const u8 *GetTrainerCantBattleSpeech(void); -// ewram vars EWRAM_DATA static u16 sTrainerBattleMode = 0; EWRAM_DATA u16 gTrainerBattleOpponent_A = 0; EWRAM_DATA u16 gTrainerBattleOpponent_B = 0; @@ -103,24 +109,22 @@ EWRAM_DATA static u8 *sTrainerBBattleScriptRetAddr = NULL; EWRAM_DATA static bool8 sShouldCheckTrainerBScript = FALSE; EWRAM_DATA static u8 sNoOfPossibleTrainerRetScripts = 0; -// const rom data - // The first transition is used if the enemy pokemon are lower level than our pokemon. // Otherwise, the second transition is used. static const u8 sBattleTransitionTable_Wild[][2] = { - {B_TRANSITION_SLICE, B_TRANSITION_WHITEFADE}, // Normal - {B_TRANSITION_CLOCKWISE_BLACKFADE, B_TRANSITION_GRID_SQUARES}, // Cave - {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, // Cave with flash used - {B_TRANSITION_WAVE, B_TRANSITION_RIPPLE}, // Water + [TRANSITION_TYPE_NORMAL] = {B_TRANSITION_SLICE, B_TRANSITION_WHITE_BARS_FADE}, + [TRANSITION_TYPE_CAVE] = {B_TRANSITION_CLOCKWISE_WIPE, B_TRANSITION_GRID_SQUARES}, + [TRANSITION_TYPE_FLASH] = {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, + [TRANSITION_TYPE_WATER] = {B_TRANSITION_WAVE, B_TRANSITION_RIPPLE}, }; static const u8 sBattleTransitionTable_Trainer[][2] = { - {B_TRANSITION_POKEBALLS_TRAIL, B_TRANSITION_SHARDS}, // Normal - {B_TRANSITION_SHUFFLE, B_TRANSITION_BIG_POKEBALL}, // Cave - {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, // Cave with flash used - {B_TRANSITION_SWIRL, B_TRANSITION_RIPPLE}, // Water + [TRANSITION_TYPE_NORMAL] = {B_TRANSITION_POKEBALLS_TRAIL, B_TRANSITION_ANGLED_WIPES}, + [TRANSITION_TYPE_CAVE] = {B_TRANSITION_SHUFFLE, B_TRANSITION_BIG_POKEBALL}, + [TRANSITION_TYPE_FLASH] = {B_TRANSITION_BLUR, B_TRANSITION_GRID_SQUARES}, + [TRANSITION_TYPE_WATER] = {B_TRANSITION_SWIRL, B_TRANSITION_RIPPLE}, }; // Battle Frontier (excluding Pyramid and Dome, which have their own tables below) @@ -552,7 +556,7 @@ void StartGroudonKyogreBattle(void) gBattleTypeFlags = BATTLE_TYPE_LEGENDARY | BATTLE_TYPE_KYOGRE_GROUDON; if (gGameVersion == VERSION_RUBY) - CreateBattleStartTask(B_TRANSITION_SHARDS, MUS_VS_KYOGRE_GROUDON); // GROUDON + CreateBattleStartTask(B_TRANSITION_ANGLED_WIPES, MUS_VS_KYOGRE_GROUDON); // GROUDON else CreateBattleStartTask(B_TRANSITION_RIPPLE, MUS_VS_KYOGRE_GROUDON); // KYOGRE @@ -683,7 +687,7 @@ u8 BattleSetup_GetTerrainId(void) } if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(ROUTE113) && gSaveBlock1Ptr->location.mapNum == MAP_NUM(ROUTE113)) return BATTLE_TERRAIN_SAND; - if (GetSav1Weather() == 8) + if (GetSav1Weather() == WEATHER_SANDSTORM) return BATTLE_TERRAIN_SAND; return BATTLE_TERRAIN_PLAIN; @@ -697,20 +701,20 @@ static u8 GetBattleTransitionTypeByMap(void) PlayerGetDestCoords(&x, &y); tileBehavior = MapGridGetMetatileBehaviorAt(x, y); if (Overworld_GetFlashLevel()) - return B_TRANSITION_SHUFFLE; + return TRANSITION_TYPE_FLASH; if (!MetatileBehavior_IsSurfableWaterOrUnderwater(tileBehavior)) { switch (gMapHeader.mapType) { case MAP_TYPE_UNDERGROUND: - return B_TRANSITION_SWIRL; + return TRANSITION_TYPE_CAVE; case MAP_TYPE_UNDERWATER: - return B_TRANSITION_BIG_POKEBALL; + return TRANSITION_TYPE_WATER; default: - return B_TRANSITION_BLUR; + return TRANSITION_TYPE_NORMAL; } } - return B_TRANSITION_BIG_POKEBALL; + return TRANSITION_TYPE_WATER; } static u16 GetSumOfPlayerPartyLevel(u8 numMons) diff --git a/src/battle_tower.c b/src/battle_tower.c index b2f81cc1a..d9bd18bf7 100644 --- a/src/battle_tower.c +++ b/src/battle_tower.c @@ -1909,7 +1909,7 @@ static void FillFactoryTentTrainerParty(u16 trainerId, u8 firstMonId) void FrontierSpeechToString(const u16 *words) { ConvertEasyChatWordsToString(gStringVar4, words, 3, 2); - if (GetStringWidth(1, gStringVar4, -1) > 204u) + if (GetStringWidth(FONT_NORMAL, gStringVar4, -1) > 204u) { s32 i = 0; diff --git a/src/battle_transition.c b/src/battle_transition.c index 2fc4c6854..1e421b5e4 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -25,6 +25,33 @@ #include "constants/trainers.h" #include "constants/rgb.h" +#define PALTAG_UNUSED_MUGSHOT 0x100A + +#define B_TRANS_DMA_FLAGS (1 | ((DMA_SRC_INC | DMA_DEST_FIXED | DMA_REPEAT | DMA_16BIT | DMA_START_HBLANK | DMA_ENABLE) << 16)) + +// Used by each transition task to determine which of its functions to call +#define tState data[0] + +// Below are data defines for InitBlackWipe and UpdateBlackWipe, for the TransitionData data array. +// These will be re-used by any transitions that use these functions. +#define tWipeStartX data[0] +#define tWipeStartY data[1] +#define tWipeCurrX data[2] +#define tWipeCurrY data[3] +#define tWipeEndX data[4] +#define tWipeEndY data[5] +#define tWipeXMove data[6] +#define tWipeYMove data[7] +#define tWipeXDist data[8] +#define tWipeYDist data[9] +#define tWipeTemp data[10] + +#define SET_TILE(ptr, posY, posX, tile) \ +{ \ + u32 index = (posY) * 32 + posX; \ + ptr[index] = tile | (0xF0 << 8); \ +} + struct TransitionData { vu8 VBlank_DMA; @@ -32,245 +59,242 @@ struct TransitionData u16 WINOUT; u16 WIN0H; u16 WIN0V; - u16 field_A; // unused - u16 field_C; // unused + u16 unused1; + u16 unused2; u16 BLDCNT; u16 BLDALPHA; u16 BLDY; - s16 field_14; - s16 field_16; - s16 BG0HOFS_1; - s16 BG0HOFS_2; + s16 cameraX; + s16 cameraY; + s16 BG0HOFS_Lower; + s16 BG0HOFS_Upper; s16 BG0VOFS; // used but not set - s16 field_1E; // unused - s16 field_20; - s16 field_22; // unused + s16 unused3; + s16 counter; + s16 unused4; s16 data[11]; }; -struct StructRectangularSpiral +struct RectangularSpiralLine { - u8 field_0; - s16 field_2; - u8 field_4; - s16 field_6; - u8 field_8; + u8 state; + s16 position; + u8 moveIdx; + s16 reboundPosition; + bool8 outward; }; typedef bool8 (*TransitionStateFunc)(struct Task *task); typedef bool8 (*TransitionSpriteCallback)(struct Sprite *sprite); -// this file's functions -static void LaunchBattleTransitionTask(u8 transitionId); -static void Task_BattleTransitionMain(u8 taskId); -static void Phase1Task_TransitionAll(u8 taskId); -static void Phase2Task_Blur(u8 taskId); -static void Phase2Task_Swirl(u8 taskId); -static void Phase2Task_Shuffle(u8 taskId); -static void Phase2Task_BigPokeball(u8 taskId); -static void Phase2Task_PokeballsTrail(u8 taskId); -static void Phase2Task_Clockwise_BlackFade(u8 taskId); -static void Phase2Task_Ripple(u8 taskId); -static void Phase2Task_Wave(u8 taskId); -static void Phase2Task_Slice(u8 taskId); -static void Phase2Task_WhiteFade(u8 taskId); -static void Phase2Task_GridSquares(u8 taskId); -static void Phase2Task_Shards(u8 taskId); -static void Phase2Task_Sidney(u8 taskId); -static void Phase2Task_Phoebe(u8 taskId); -static void Phase2Task_Glacia(u8 taskId); -static void Phase2Task_Drake(u8 taskId); -static void Phase2Task_Champion(u8 taskId); -static void Phase2Task_Aqua(u8 taskId); -static void Phase2Task_Magma(u8 taskId); -static void Phase2Task_Regice(u8 taskId); -static void Phase2Task_Registeel(u8 taskId); -static void Phase2Task_Regirock(u8 taskId); -static void Phase2Task_Kyogre(u8 taskId); -static void Phase2Task_Groudon(u8 taskId); -static void Phase2Task_Rayquaza(u8 taskId); -static void Phase2Task_ShredSplit(u8 taskId); -static void Phase2Task_Blackhole1(u8 taskId); -static void Phase2Task_Blackhole2(u8 taskId); -static void Phase2Task_RectangularSpiral(u8 taskId); -static void Phase2Task_FrontierLogoWiggle(u8 taskId); -static void Phase2Task_FrontierLogoWave(u8 taskId); -static void Phase2Task_FrontierSquares(u8 taskId); -static void Phase2Task_FrontierSquaresScroll(u8 taskId); -static void Phase2Task_FrontierSquaresSpiral(u8 taskId); +static bool8 Transition_StartIntro(struct Task *); +static bool8 Transition_WaitForIntro(struct Task *); +static bool8 Transition_StartMain(struct Task *); +static bool8 Transition_WaitForMain(struct Task *); + +static void LaunchBattleTransitionTask(u8); +static void Task_BattleTransition(u8); +static void Task_Intro(u8); +static void Task_Blur(u8); +static void Task_Swirl(u8); +static void Task_Shuffle(u8); +static void Task_BigPokeball(u8); +static void Task_PokeballsTrail(u8); +static void Task_ClockwiseWipe(u8); +static void Task_Ripple(u8); +static void Task_Wave(u8); +static void Task_Slice(u8); +static void Task_WhiteBarsFade(u8); +static void Task_GridSquares(u8); +static void Task_AngledWipes(u8); +static void Task_Sidney(u8); +static void Task_Phoebe(u8); +static void Task_Glacia(u8); +static void Task_Drake(u8); +static void Task_Champion(u8); +static void Task_Aqua(u8); +static void Task_Magma(u8); +static void Task_Regice(u8); +static void Task_Registeel(u8); +static void Task_Regirock(u8); +static void Task_Kyogre(u8); +static void Task_Groudon(u8); +static void Task_Rayquaza(u8); +static void Task_ShredSplit(u8); +static void Task_Blackhole(u8); +static void Task_BlackholePulsate(u8); +static void Task_RectangularSpiral(u8); +static void Task_FrontierLogoWiggle(u8); +static void Task_FrontierLogoWave(u8); +static void Task_FrontierSquares(u8); +static void Task_FrontierSquaresScroll(u8); +static void Task_FrontierSquaresSpiral(u8); static void VBlankCB_BattleTransition(void); -static void VBlankCB_Phase2_Swirl(void); -static void HBlankCB_Phase2_Swirl(void); -static void VBlankCB_Phase2_Shuffle(void); -static void HBlankCB_Phase2_Shuffle(void); -static void VBlankCB0_Phase2_BigPokeball(void); -static void VBlankCB1_Phase2_BigPokeball(void); -static void VBlankCB_Phase2_Clockwise_BlackFade(void); -static void VBlankCB_Phase2_Ripple(void); -static void HBlankCB_Phase2_Ripple(void); -static void VBlankCB_Phase2_30(void); -static void HBlankCB_Phase2_30(void); -static void VBlankCB_Phase2_Wave(void); -static void VBlankCB_Phase2_Slice(void); -static void HBlankCB_Phase2_Slice(void); -static void VBlankCB0_Phase2_WhiteFade(void); -static void VBlankCB1_Phase2_WhiteFade(void); -static void HBlankCB_Phase2_WhiteFade(void); -static void VBlankCB_Phase2_Shards(void); -static void VBlankCB_Phase2_Rayquaza(void); -static bool8 Phase2_Blur_Func1(struct Task *task); -static bool8 Phase2_Blur_Func2(struct Task *task); -static bool8 Phase2_Blur_Func3(struct Task *task); -static bool8 Phase2_Swirl_Func1(struct Task *task); -static bool8 Phase2_Swirl_Func2(struct Task *task); -static bool8 Phase2_Shuffle_Func1(struct Task *task); -static bool8 Phase2_Shuffle_Func2(struct Task *task); -static bool8 Phase2_Aqua_Func1(struct Task *task); -static bool8 Phase2_Aqua_Func2(struct Task *task); -static bool8 Phase2_Magma_Func1(struct Task *task); -static bool8 Phase2_Magma_Func2(struct Task *task); -static bool8 Phase2_FramesCountdown(struct Task *task); -static bool8 Phase2_Regi_Func1(struct Task *task); -static bool8 Phase2_Regice_Func2(struct Task *task); -static bool8 Phase2_Registeel_Func2(struct Task *task); -static bool8 Phase2_Regirock_Func2(struct Task *task); -static bool8 Phase2_WeatherTrio_Func1(struct Task *task); -static bool8 Phase2_WaitPaletteFade(struct Task *task); -static bool8 Phase2_Kyogre_Func3(struct Task *task); -static bool8 Phase2_Kyogre_Func4(struct Task *task); -static bool8 Phase2_Kyogre_Func5(struct Task *task); -static bool8 Phase2_Groudon_Func3(struct Task *task); -static bool8 Phase2_Groudon_Func4(struct Task *task); -static bool8 Phase2_Groudon_Func5(struct Task *task); -static bool8 Phase2_WeatherDuo_Func6(struct Task *task); -static bool8 Phase2_WeatherDuo_Func7(struct Task *task); -static bool8 Phase2_BigPokeball_Func1(struct Task *task); -static bool8 Phase2_BigPokeball_Func2(struct Task *task); -static bool8 Phase2_BigPokeball_Func3(struct Task *task); -static bool8 Phase2_BigPokeball_Func4(struct Task *task); -static bool8 Phase2_BigPokeball_Func5(struct Task *task); -static bool8 Phase2_BigPokeball_Func6(struct Task *task); -static bool8 Phase2_PokeballsTrail_Func1(struct Task *task); -static bool8 Phase2_PokeballsTrail_Func2(struct Task *task); -static bool8 Phase2_PokeballsTrail_Func3(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func2(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func4(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func6(struct Task *task); -static bool8 Phase2_Clockwise_BlackFade_Func7(struct Task *task); -static bool8 Phase2_Ripple_Func1(struct Task *task); -static bool8 Phase2_Ripple_Func2(struct Task *task); -static bool8 Phase2_Wave_Func1(struct Task *task); -static bool8 Phase2_Wave_Func2(struct Task *task); -static bool8 Phase2_Wave_Func3(struct Task *task); -static bool8 Phase2_Slice_Func1(struct Task *task); -static bool8 Phase2_Slice_Func2(struct Task *task); -static bool8 Phase2_Slice_Func3(struct Task *task); -static bool8 Phase2_WhiteFade_Func1(struct Task *task); -static bool8 Phase2_WhiteFade_Func2(struct Task *task); -static bool8 Phase2_WhiteFade_Func3(struct Task *task); -static bool8 Phase2_WhiteFade_Func4(struct Task *task); -static bool8 Phase2_WhiteFade_Func5(struct Task *task); -static bool8 Phase2_GridSquares_Func1(struct Task *task); -static bool8 Phase2_GridSquares_Func2(struct Task *task); -static bool8 Phase2_GridSquares_Func3(struct Task *task); -static bool8 Phase2_Shards_Func1(struct Task *task); -static bool8 Phase2_Shards_Func2(struct Task *task); -static bool8 Phase2_Shards_Func3(struct Task *task); -static bool8 Phase2_Shards_Func4(struct Task *task); -static bool8 Phase2_Shards_Func5(struct Task *task); -static bool8 Phase2_ShredSplit_Func1(struct Task *task); -static bool8 Phase2_ShredSplit_Func2(struct Task *task); -static bool8 Phase2_ShredSplit_Func3(struct Task *task); -static bool8 Phase2_ShredSplit_Func4(struct Task *task); -static bool8 Phase2_Blackhole_Func1(struct Task *task); -static bool8 Phase2_Blackhole1_Func2(struct Task *task); -static bool8 Phase2_Blackhole1_Func3(struct Task *task); -static bool8 Phase2_Blackhole2_Func2(struct Task *task); -static bool8 Phase2_RectangularSpiral_Func1(struct Task *task); -static bool8 Phase2_RectangularSpiral_Func2(struct Task *task); -static bool8 Phase2_RectangularSpiral_Func3(struct Task *task); -static bool8 Phase2_FrontierLogoWiggle_Func1(struct Task *task); -static bool8 Phase2_FrontierLogoWiggle_Func2(struct Task *task); -static bool8 Phase2_FrontierLogoWave_Func1(struct Task *task); -static bool8 Phase2_FrontierLogoWave_Func2(struct Task *task); -static bool8 Phase2_FrontierLogoWave_Func3(struct Task *task); -static bool8 Phase2_FrontierLogoWave_Func4(struct Task *task); -static bool8 Phase2_Rayquaza_Func3(struct Task *task); -static bool8 Phase2_Rayquaza_Func4(struct Task *task); -static bool8 Phase2_Rayquaza_Func5(struct Task *task); -static bool8 Phase2_Rayquaza_Func6(struct Task *task); -static bool8 Phase2_Rayquaza_Func7(struct Task *task); -static bool8 Phase2_Rayquaza_Func8(struct Task *task); -static bool8 Phase2_Rayquaza_Func9(struct Task *task); -static bool8 Phase2_FrontierSquares_Func1(struct Task *task); -static bool8 Phase2_FrontierSquares_Func2(struct Task *task); -static bool8 Phase2_FrontierSquares_Func3(struct Task *task); -static bool8 Phase2_FrontierSquares_End(struct Task *task); -static bool8 Phase2_FrontierSquaresSpiral_Func1(struct Task *task); -static bool8 Phase2_FrontierSquaresSpiral_Func2(struct Task *task); -static bool8 Phase2_FrontierSquaresSpiral_Func3(struct Task *task); -static bool8 Phase2_FrontierSquaresSpiral_Func4(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func1(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func2(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func3(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func4(struct Task *task); -static bool8 Phase2_FrontierSquaresScroll_Func5(struct Task *task); -static bool8 Phase2_Mugshot_Func1(struct Task *task); -static bool8 Phase2_Mugshot_Func2(struct Task *task); -static bool8 Phase2_Mugshot_Func3(struct Task *task); -static bool8 Phase2_Mugshot_Func4(struct Task *task); -static bool8 Phase2_Mugshot_Func5(struct Task *task); -static bool8 Phase2_Mugshot_Func6(struct Task *task); -static bool8 Phase2_Mugshot_Func7(struct Task *task); -static bool8 Phase2_Mugshot_Func8(struct Task *task); -static bool8 Phase2_Mugshot_Func9(struct Task *task); -static bool8 Phase2_Mugshot_Func10(struct Task *task); -static void Phase2Task_MugShotTransition(u8 taskId); -static void Mugshots_CreateOpponentPlayerSprites(struct Task *task); -static void VBlankCB0_Phase2_Mugshots(void); -static void VBlankCB1_Phase2_Mugshots(void); -static void HBlankCB_Phase2_Mugshots(void); -static bool8 Transition_Phase1(struct Task *task); -static bool8 Transition_WaitForPhase1(struct Task *task); -static bool8 Transition_Phase2(struct Task *task); -static bool8 Transition_WaitForPhase2(struct Task *task); -static void InitTransitionStructVars(void); +static void VBlankCB_Swirl(void); +static void HBlankCB_Swirl(void); +static void VBlankCB_Shuffle(void); +static void HBlankCB_Shuffle(void); +static void VBlankCB_PatternWeave(void); +static void VBlankCB_CircularMask(void); +static void VBlankCB_ClockwiseWipe(void); +static void VBlankCB_Ripple(void); +static void HBlankCB_Ripple(void); +static void VBlankCB_FrontierLogoWave(void); +static void HBlankCB_FrontierLogoWave(void); +static void VBlankCB_Wave(void); +static void VBlankCB_Slice(void); +static void HBlankCB_Slice(void); +static void VBlankCB_WhiteBarsFade(void); +static void VBlankCB_WhiteBarsFade_Blend(void); +static void HBlankCB_WhiteBarsFade(void); +static void VBlankCB_AngledWipes(void); +static void VBlankCB_Rayquaza(void); +static bool8 Blur_Init(struct Task *); +static bool8 Blur_Main(struct Task *); +static bool8 Blur_End(struct Task *); +static bool8 Swirl_Init(struct Task *); +static bool8 Swirl_End(struct Task *); +static bool8 Shuffle_Init(struct Task *); +static bool8 Shuffle_End(struct Task *); +static bool8 Aqua_Init(struct Task *); +static bool8 Aqua_SetGfx(struct Task *); +static bool8 Magma_Init(struct Task *); +static bool8 Magma_SetGfx(struct Task *); +static bool8 FramesCountdown(struct Task *); +static bool8 Regi_Init(struct Task *); +static bool8 Regice_SetGfx(struct Task *); +static bool8 Registeel_SetGfx(struct Task *); +static bool8 Regirock_SetGfx(struct Task *); +static bool8 WeatherTrio_BgFadeBlack(struct Task *); +static bool8 WeatherTrio_WaitFade(struct Task *); +static bool8 Kyogre_Init(struct Task *); +static bool8 Kyogre_PaletteFlash(struct Task *); +static bool8 Kyogre_PaletteBrighten(struct Task *); +static bool8 Groudon_Init(struct Task *); +static bool8 Groudon_PaletteFlash(struct Task *); +static bool8 Groudon_PaletteBrighten(struct Task *); +static bool8 WeatherDuo_FadeOut(struct Task *); +static bool8 WeatherDuo_End(struct Task *); +static bool8 BigPokeball_Init(struct Task *); +static bool8 BigPokeball_SetGfx(struct Task *); +static bool8 PatternWeave_Blend1(struct Task *); +static bool8 PatternWeave_Blend2(struct Task *); +static bool8 PatternWeave_FinishAppear(struct Task *); +static bool8 PatternWeave_CircularMask(struct Task *); +static bool8 PokeballsTrail_Init(struct Task *); +static bool8 PokeballsTrail_Main(struct Task *); +static bool8 PokeballsTrail_End(struct Task *); +static bool8 ClockwiseWipe_Init(struct Task *); +static bool8 ClockwiseWipe_TopRight(struct Task *); +static bool8 ClockwiseWipe_Right(struct Task *); +static bool8 ClockwiseWipe_Bottom(struct Task *); +static bool8 ClockwiseWipe_Left(struct Task *); +static bool8 ClockwiseWipe_TopLeft(struct Task *); +static bool8 ClockwiseWipe_End(struct Task *); +static bool8 Ripple_Init(struct Task *); +static bool8 Ripple_Main(struct Task *); +static bool8 Wave_Init(struct Task *); +static bool8 Wave_Main(struct Task *); +static bool8 Wave_End(struct Task *); +static bool8 Slice_Init(struct Task *); +static bool8 Slice_Main(struct Task *); +static bool8 Slice_End(struct Task *); +static bool8 WhiteBarsFade_Init(struct Task *); +static bool8 WhiteBarsFade_StartBars(struct Task *); +static bool8 WhiteBarsFade_WaitBars(struct Task *); +static bool8 WhiteBarsFade_BlendToBlack(struct Task *); +static bool8 WhiteBarsFade_End(struct Task *); +static bool8 GridSquares_Init(struct Task *); +static bool8 GridSquares_Main(struct Task *); +static bool8 GridSquares_End(struct Task *); +static bool8 AngledWipes_Init(struct Task *); +static bool8 AngledWipes_SetWipeData(struct Task *); +static bool8 AngledWipes_DoWipe(struct Task *); +static bool8 AngledWipes_TryEnd(struct Task *); +static bool8 AngledWipes_StartNext(struct Task *); +static bool8 ShredSplit_Init(struct Task *); +static bool8 ShredSplit_Main(struct Task *); +static bool8 ShredSplit_BrokenCheck(struct Task *); +static bool8 ShredSplit_End(struct Task *); +static bool8 Blackhole_Init(struct Task *); +static bool8 Blackhole_Vibrate(struct Task *); +static bool8 Blackhole_GrowEnd(struct Task *); +static bool8 BlackholePulsate_Main(struct Task *); +static bool8 RectangularSpiral_Init(struct Task *); +static bool8 RectangularSpiral_Main(struct Task *); +static bool8 RectangularSpiral_End(struct Task *); +static bool8 FrontierLogoWiggle_Init(struct Task *); +static bool8 FrontierLogoWiggle_SetGfx(struct Task *); +static bool8 FrontierLogoWave_Init(struct Task *); +static bool8 FrontierLogoWave_SetGfx(struct Task *); +static bool8 FrontierLogoWave_InitScanline(struct Task *); +static bool8 FrontierLogoWave_Main(struct Task *); +static bool8 Rayquaza_Init(struct Task *); +static bool8 Rayquaza_SetGfx(struct Task *); +static bool8 Rayquaza_PaletteFlash(struct Task *); +static bool8 Rayquaza_FadeToBlack(struct Task *); +static bool8 Rayquaza_WaitFade(struct Task *); +static bool8 Rayquaza_SetBlack(struct Task *); +static bool8 Rayquaza_TriRing(struct Task *); +static bool8 FrontierSquares_Init(struct Task *); +static bool8 FrontierSquares_Draw(struct Task *); +static bool8 FrontierSquares_Shrink(struct Task *); +static bool8 FrontierSquares_End(struct Task *); +static bool8 FrontierSquaresSpiral_Init(struct Task *); +static bool8 FrontierSquaresSpiral_Outward(struct Task *); +static bool8 FrontierSquaresSpiral_SetBlack(struct Task *); +static bool8 FrontierSquaresSpiral_Inward(struct Task *); +static bool8 FrontierSquaresScroll_Init(struct Task *); +static bool8 FrontierSquaresScroll_Draw(struct Task *); +static bool8 FrontierSquaresScroll_SetBlack(struct Task *); +static bool8 FrontierSquaresScroll_Erase(struct Task *); +static bool8 FrontierSquaresScroll_End(struct Task *); +static bool8 Mugshot_Init(struct Task *); +static bool8 Mugshot_SetGfx(struct Task *); +static bool8 Mugshot_ShowBanner(struct Task *); +static bool8 Mugshot_StartOpponentSlide(struct Task *); +static bool8 Mugshot_WaitStartPlayerSlide(struct Task *); +static bool8 Mugshot_WaitPlayerSlide(struct Task *); +static bool8 Mugshot_GradualWhiteFade(struct Task *); +static bool8 Mugshot_InitFadeWhiteToBlack(struct Task *); +static bool8 Mugshot_FadeToBlack(struct Task *); +static bool8 Mugshot_End(struct Task *); +static void DoMugshotTransition(u8); +static void Mugshots_CreateTrainerPics(struct Task *); +static void VBlankCB_Mugshots(void); +static void VBlankCB_MugshotsFadeOut(void); +static void HBlankCB_Mugshots(void); +static void InitTransitionData(void); static void FadeScreenBlack(void); -static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4); -static void sub_814A014(u16 *a0, s16 a1, s16 a2, s16 a3); -static void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize); -static void GetBg0TilemapDst(u16 **tileset); -static void sub_814A1AC(s16 *a0, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6); -static bool8 sub_814A228(s16 *a0, bool8 a1, bool8 a2); -static void SetTrainerPicSlideTable(s16 spriteId, s16 arrId); -static void IncrementTrainerPicState(s16 spriteId); -static s16 IsTrainerPicSlideDone(s16 spriteId); -static bool8 Phase1_TransitionAll_Func1(struct Task *task); -static bool8 Phase1_TransitionAll_Func2(struct Task *task); -static bool8 IsPhase1Done(void); -static bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpiral *arg1); -static void sub_814713C(struct Sprite *sprite); -static void SpriteCb_TrainerPic(struct Sprite *sprite); -static void sub_8149864(struct Sprite *sprite); -static bool8 TrainerPicCb_Nothing(struct Sprite *sprite); -static bool8 TrainerPicCb_SetSlideOffsets(struct Sprite *sprite); -static bool8 TrainerPicCb_Slide1(struct Sprite *sprite); -static bool8 TrainerPicCb_Slide2(struct Sprite *sprite); -static bool8 TrainerPicCb_Slide3(struct Sprite *sprite); - -// iwram bss vars -static s16 sUnusedRectangularSpiralVar; +static void CreateIntroTask(s16, s16, s16, s16, s16); +static void SetCircularMask(u16 *, s16, s16, s16); +static void SetSinWave(s16 *, s16, s16, s16, s16, s16); +static void GetBg0TilemapDst(u16 **); +static void InitBlackWipe(s16 *, s16, s16, s16, s16, s16, s16); +static bool8 UpdateBlackWipe(s16 *, bool8, bool8); +static void SetTrainerPicSlideDirection(s16, s16); +static void IncrementTrainerPicState(s16); +static s16 IsTrainerPicSlideDone(s16); +static bool8 TransitionIntro_FadeToGray(struct Task *); +static bool8 TransitionIntro_FadeFromGray(struct Task *); +static bool8 IsIntroTaskDone(void); +static bool16 UpdateRectangularSpiralLine(const s16 * const *, struct RectangularSpiralLine *); +static void SpriteCB_FldEffPokeballTrail(struct Sprite *); +static void SpriteCB_MugshotTrainerPic(struct Sprite *); +static void SpriteCB_WhiteBarFade(struct Sprite *); +static bool8 MugshotTrainerPic_Pause(struct Sprite *); +static bool8 MugshotTrainerPic_Init(struct Sprite *); +static bool8 MugshotTrainerPic_Slide(struct Sprite *); +static bool8 MugshotTrainerPic_SlideSlow(struct Sprite *); +static bool8 MugshotTrainerPic_SlideOffscreen(struct Sprite *); + +static s16 sDebug_RectangularSpiralData; static u8 sTestingTransitionId; static u8 sTestingTransitionState; -static struct StructRectangularSpiral sRectangularSpiralTransition[4]; +static struct RectangularSpiralLine sRectangularSpiralLines[4]; -// ewram vars -EWRAM_DATA static struct TransitionData *sTransitionStructPtr = NULL; +EWRAM_DATA static struct TransitionData *sTransitionData = NULL; -// const rom data static const u32 sBigPokeball_Tileset[] = INCBIN_U32("graphics/battle_transitions/big_pokeball.4bpp"); static const u32 sPokeballTrail_Tileset[] = INCBIN_U32("graphics/battle_transitions/pokeball_trail.4bpp"); static const u8 sPokeball_Gfx[] = INCBIN_U8("graphics/battle_transitions/pokeball.4bpp"); @@ -290,7 +314,7 @@ static const u16 sRegirock_Palette[] = INCBIN_U16("graphics/battle_transitions/r static const u32 sRegice_Tilemap[] = INCBIN_U32("graphics/battle_transitions/regice.bin"); static const u32 sRegisteel_Tilemap[] = INCBIN_U32("graphics/battle_transitions/registeel.bin"); static const u32 sRegirock_Tilemap[] = INCBIN_U32("graphics/battle_transitions/regirock.bin"); -static const u16 gUnknown_085BDB14[] = INCBIN_U16("graphics/battle_transitions/85BDB14.gbapal"); +static const u16 sUnused_Palette[] = INCBIN_U16("graphics/battle_transitions/unused.gbapal"); static const u32 sKyogre_Tileset[] = INCBIN_U32("graphics/battle_transitions/kyogre.4bpp.lz"); static const u32 sKyogre_Tilemap[] = INCBIN_U32("graphics/battle_transitions/kyogre.bin.lz"); static const u32 sGroudon_Tileset[] = INCBIN_U32("graphics/battle_transitions/groudon.4bpp.lz"); @@ -312,213 +336,217 @@ static const u32 sFrontierSquares_Shrink1_Tileset[] = INCBIN_U32("graphics/battl static const u32 sFrontierSquares_Shrink2_Tileset[] = INCBIN_U32("graphics/battle_transitions/frontier_square_4.4bpp.lz"); static const u32 sFrontierSquares_Tilemap[] = INCBIN_U32("graphics/battle_transitions/frontier_squares.bin"); -static const TaskFunc sPhase1_Tasks[B_TRANSITION_COUNT] = +// All battle transitions use the same intro +static const TaskFunc sTasks_Intro[B_TRANSITION_COUNT] = { - [0 ... B_TRANSITION_COUNT - 1] = &Phase1Task_TransitionAll + [0 ... B_TRANSITION_COUNT - 1] = &Task_Intro }; -static const TaskFunc sPhase2_Tasks[B_TRANSITION_COUNT] = -{ - [B_TRANSITION_BLUR] = Phase2Task_Blur, - [B_TRANSITION_SWIRL] = Phase2Task_Swirl, - [B_TRANSITION_SHUFFLE] = Phase2Task_Shuffle, - [B_TRANSITION_BIG_POKEBALL] = Phase2Task_BigPokeball, - [B_TRANSITION_POKEBALLS_TRAIL] = Phase2Task_PokeballsTrail, - [B_TRANSITION_CLOCKWISE_BLACKFADE] = Phase2Task_Clockwise_BlackFade, - [B_TRANSITION_RIPPLE] = Phase2Task_Ripple, - [B_TRANSITION_WAVE] = Phase2Task_Wave, - [B_TRANSITION_SLICE] = Phase2Task_Slice, - [B_TRANSITION_WHITEFADE] = Phase2Task_WhiteFade, - [B_TRANSITION_GRID_SQUARES] = Phase2Task_GridSquares, - [B_TRANSITION_SHARDS] = Phase2Task_Shards, - [B_TRANSITION_SIDNEY] = Phase2Task_Sidney, - [B_TRANSITION_PHOEBE] = Phase2Task_Phoebe, - [B_TRANSITION_GLACIA] = Phase2Task_Glacia, - [B_TRANSITION_DRAKE] = Phase2Task_Drake, - [B_TRANSITION_CHAMPION] = Phase2Task_Champion, - [B_TRANSITION_AQUA] = Phase2Task_Aqua, - [B_TRANSITION_MAGMA] = Phase2Task_Magma, - [B_TRANSITION_REGICE] = Phase2Task_Regice, - [B_TRANSITION_REGISTEEL] = Phase2Task_Registeel, - [B_TRANSITION_REGIROCK] = Phase2Task_Regirock, - [B_TRANSITION_KYOGRE] = Phase2Task_Kyogre, - [B_TRANSITION_GROUDON] = Phase2Task_Groudon, - [B_TRANSITION_RAYQUAZA] = Phase2Task_Rayquaza, - [B_TRANSITION_SHRED_SPLIT] = Phase2Task_ShredSplit, - [B_TRANSITION_BLACKHOLE1] = Phase2Task_Blackhole1, - [B_TRANSITION_BLACKHOLE2] = Phase2Task_Blackhole2, - [B_TRANSITION_RECTANGULAR_SPIRAL] = Phase2Task_RectangularSpiral, - [B_TRANSITION_FRONTIER_LOGO_WIGGLE] = Phase2Task_FrontierLogoWiggle, - [B_TRANSITION_FRONTIER_LOGO_WAVE] = Phase2Task_FrontierLogoWave, - [B_TRANSITION_FRONTIER_SQUARES] = Phase2Task_FrontierSquares, - [B_TRANSITION_FRONTIER_SQUARES_SCROLL] = Phase2Task_FrontierSquaresScroll, - [B_TRANSITION_FRONTIER_SQUARES_SPIRAL] = Phase2Task_FrontierSquaresSpiral, - [B_TRANSITION_FRONTIER_CIRCLES_MEET] = Phase2Task_FrontierCirclesMeet, - [B_TRANSITION_FRONTIER_CIRCLES_CROSS] = Phase2Task_FrontierCirclesCross, - [B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL] = Phase2Task_FrontierCirclesAsymmetricSpiral, - [B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL] = Phase2Task_FrontierCirclesSymmetricSpiral, - [B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ] = Phase2Task_FrontierCirclesMeetInSeq, - [B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ] = Phase2Task_FrontierCirclesCrossInSeq, - [B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ] = Phase2Task_FrontierCirclesAsymmetricSpiralInSeq, - [B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ] = Phase2Task_FrontierCirclesSymmetricSpiralInSeq, +// After the intro each transition has a unique main task. +// This task will call the functions that do the transition effects. +static const TaskFunc sTasks_Main[B_TRANSITION_COUNT] = +{ + [B_TRANSITION_BLUR] = Task_Blur, + [B_TRANSITION_SWIRL] = Task_Swirl, + [B_TRANSITION_SHUFFLE] = Task_Shuffle, + [B_TRANSITION_BIG_POKEBALL] = Task_BigPokeball, + [B_TRANSITION_POKEBALLS_TRAIL] = Task_PokeballsTrail, + [B_TRANSITION_CLOCKWISE_WIPE] = Task_ClockwiseWipe, + [B_TRANSITION_RIPPLE] = Task_Ripple, + [B_TRANSITION_WAVE] = Task_Wave, + [B_TRANSITION_SLICE] = Task_Slice, + [B_TRANSITION_WHITE_BARS_FADE] = Task_WhiteBarsFade, + [B_TRANSITION_GRID_SQUARES] = Task_GridSquares, + [B_TRANSITION_ANGLED_WIPES] = Task_AngledWipes, + [B_TRANSITION_SIDNEY] = Task_Sidney, + [B_TRANSITION_PHOEBE] = Task_Phoebe, + [B_TRANSITION_GLACIA] = Task_Glacia, + [B_TRANSITION_DRAKE] = Task_Drake, + [B_TRANSITION_CHAMPION] = Task_Champion, + [B_TRANSITION_AQUA] = Task_Aqua, + [B_TRANSITION_MAGMA] = Task_Magma, + [B_TRANSITION_REGICE] = Task_Regice, + [B_TRANSITION_REGISTEEL] = Task_Registeel, + [B_TRANSITION_REGIROCK] = Task_Regirock, + [B_TRANSITION_KYOGRE] = Task_Kyogre, + [B_TRANSITION_GROUDON] = Task_Groudon, + [B_TRANSITION_RAYQUAZA] = Task_Rayquaza, + [B_TRANSITION_SHRED_SPLIT] = Task_ShredSplit, + [B_TRANSITION_BLACKHOLE] = Task_Blackhole, + [B_TRANSITION_BLACKHOLE_PULSATE] = Task_BlackholePulsate, + [B_TRANSITION_RECTANGULAR_SPIRAL] = Task_RectangularSpiral, + [B_TRANSITION_FRONTIER_LOGO_WIGGLE] = Task_FrontierLogoWiggle, + [B_TRANSITION_FRONTIER_LOGO_WAVE] = Task_FrontierLogoWave, + [B_TRANSITION_FRONTIER_SQUARES] = Task_FrontierSquares, + [B_TRANSITION_FRONTIER_SQUARES_SCROLL] = Task_FrontierSquaresScroll, + [B_TRANSITION_FRONTIER_SQUARES_SPIRAL] = Task_FrontierSquaresSpiral, + [B_TRANSITION_FRONTIER_CIRCLES_MEET] = Task_FrontierCirclesMeet, + [B_TRANSITION_FRONTIER_CIRCLES_CROSS] = Task_FrontierCirclesCross, + [B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL] = Task_FrontierCirclesAsymmetricSpiral, + [B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL] = Task_FrontierCirclesSymmetricSpiral, + [B_TRANSITION_FRONTIER_CIRCLES_MEET_IN_SEQ] = Task_FrontierCirclesMeetInSeq, + [B_TRANSITION_FRONTIER_CIRCLES_CROSS_IN_SEQ] = Task_FrontierCirclesCrossInSeq, + [B_TRANSITION_FRONTIER_CIRCLES_ASYMMETRIC_SPIRAL_IN_SEQ] = Task_FrontierCirclesAsymmetricSpiralInSeq, + [B_TRANSITION_FRONTIER_CIRCLES_SYMMETRIC_SPIRAL_IN_SEQ] = Task_FrontierCirclesSymmetricSpiralInSeq, }; -static const TransitionStateFunc sMainTransitionPhases[] = +static const TransitionStateFunc sTaskHandlers[] = { - &Transition_Phase1, - &Transition_WaitForPhase1, - &Transition_Phase2, - &Transition_WaitForPhase2 + &Transition_StartIntro, + &Transition_WaitForIntro, + &Transition_StartMain, + &Transition_WaitForMain }; -static const TransitionStateFunc sPhase2_Blur_Funcs[] = +static const TransitionStateFunc sBlur_Funcs[] = { - Phase2_Blur_Func1, - Phase2_Blur_Func2, - Phase2_Blur_Func3 + Blur_Init, + Blur_Main, + Blur_End }; -static const TransitionStateFunc sPhase2_Swirl_Funcs[] = +static const TransitionStateFunc sSwirl_Funcs[] = { - Phase2_Swirl_Func1, - Phase2_Swirl_Func2, + Swirl_Init, + Swirl_End, }; -static const TransitionStateFunc sPhase2_Shuffle_Funcs[] = +static const TransitionStateFunc sShuffle_Funcs[] = { - Phase2_Shuffle_Func1, - Phase2_Shuffle_Func2, + Shuffle_Init, + Shuffle_End, }; -static const TransitionStateFunc sPhase2_Aqua_Funcs[] = +static const TransitionStateFunc sAqua_Funcs[] = { - Phase2_Aqua_Func1, - Phase2_Aqua_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_FramesCountdown, - Phase2_BigPokeball_Func6 + Aqua_Init, + Aqua_SetGfx, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + FramesCountdown, + PatternWeave_CircularMask }; -static const TransitionStateFunc sPhase2_Magma_Funcs[] = +static const TransitionStateFunc sMagma_Funcs[] = { - Phase2_Magma_Func1, - Phase2_Magma_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_FramesCountdown, - Phase2_BigPokeball_Func6 + Magma_Init, + Magma_SetGfx, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + FramesCountdown, + PatternWeave_CircularMask }; -static const TransitionStateFunc sPhase2_BigPokeball_Funcs[] = +static const TransitionStateFunc sBigPokeball_Funcs[] = { - Phase2_BigPokeball_Func1, - Phase2_BigPokeball_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + BigPokeball_Init, + BigPokeball_SetGfx, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; -static const TransitionStateFunc sPhase2_Regice_Funcs[] = +static const TransitionStateFunc sRegice_Funcs[] = { - Phase2_Regi_Func1, - Phase2_Regice_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + Regi_Init, + Regice_SetGfx, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; -static const TransitionStateFunc sPhase2_Registeel_Funcs[] = +static const TransitionStateFunc sRegisteel_Funcs[] = { - Phase2_Regi_Func1, - Phase2_Registeel_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + Regi_Init, + Registeel_SetGfx, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; -static const TransitionStateFunc sPhase2_Regirock_Funcs[] = +static const TransitionStateFunc sRegirock_Funcs[] = { - Phase2_Regi_Func1, - Phase2_Regirock_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + Regi_Init, + Regirock_SetGfx, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; -static const TransitionStateFunc sPhase2_Kyogre_Funcs[] = +static const TransitionStateFunc sKyogre_Funcs[] = { - Phase2_WeatherTrio_Func1, - Phase2_WaitPaletteFade, - Phase2_Kyogre_Func3, - Phase2_Kyogre_Func4, - Phase2_Kyogre_Func5, - Phase2_FramesCountdown, - Phase2_WeatherDuo_Func6, - Phase2_WeatherDuo_Func7 + WeatherTrio_BgFadeBlack, + WeatherTrio_WaitFade, + Kyogre_Init, + Kyogre_PaletteFlash, + Kyogre_PaletteBrighten, + FramesCountdown, + WeatherDuo_FadeOut, + WeatherDuo_End }; -static const TransitionStateFunc sPhase2_PokeballsTrail_Funcs[] = +static const TransitionStateFunc sPokeballsTrail_Funcs[] = { - Phase2_PokeballsTrail_Func1, - Phase2_PokeballsTrail_Func2, - Phase2_PokeballsTrail_Func3 + PokeballsTrail_Init, + PokeballsTrail_Main, + PokeballsTrail_End }; -static const s16 sUnknown_085C8B88[2] = {-16, 256}; -static const s16 sUnknown_085C8B8C[5] = {0, 32, 64, 18, 48}; -static const s16 sUnknown_085C8B96[2] = {8, -8}; +#define NUM_POKEBALL_TRAILS 5 +static const s16 sPokeballsTrail_StartXCoords[2] = { -16, DISPLAY_WIDTH + 16 }; +static const s16 sPokeballsTrail_Delays[NUM_POKEBALL_TRAILS] = {0, 32, 64, 18, 48}; +static const s16 sPokeballsTrail_Speeds[2] = {8, -8}; -static const TransitionStateFunc sPhase2_Clockwise_BlackFade_Funcs[] = +static const TransitionStateFunc sClockwiseWipe_Funcs[] = { - Phase2_Clockwise_BlackFade_Func1, - Phase2_Clockwise_BlackFade_Func2, - Phase2_Clockwise_BlackFade_Func3, - Phase2_Clockwise_BlackFade_Func4, - Phase2_Clockwise_BlackFade_Func5, - Phase2_Clockwise_BlackFade_Func6, - Phase2_Clockwise_BlackFade_Func7 + ClockwiseWipe_Init, + ClockwiseWipe_TopRight, + ClockwiseWipe_Right, + ClockwiseWipe_Bottom, + ClockwiseWipe_Left, + ClockwiseWipe_TopLeft, + ClockwiseWipe_End }; -static const TransitionStateFunc sPhase2_Ripple_Funcs[] = +static const TransitionStateFunc sRipple_Funcs[] = { - Phase2_Ripple_Func1, - Phase2_Ripple_Func2 + Ripple_Init, + Ripple_Main }; -static const TransitionStateFunc sPhase2_Wave_Funcs[] = +static const TransitionStateFunc sWave_Funcs[] = { - Phase2_Wave_Func1, - Phase2_Wave_Func2, - Phase2_Wave_Func3 + Wave_Init, + Wave_Main, + Wave_End }; -static const TransitionStateFunc sPhase2_Mugshot_Funcs[] = -{ - Phase2_Mugshot_Func1, - Phase2_Mugshot_Func2, - Phase2_Mugshot_Func3, - Phase2_Mugshot_Func4, - Phase2_Mugshot_Func5, - Phase2_Mugshot_Func6, - Phase2_Mugshot_Func7, - Phase2_Mugshot_Func8, - Phase2_Mugshot_Func9, - Phase2_Mugshot_Func10 +static const TransitionStateFunc sMugshot_Funcs[] = +{ + Mugshot_Init, + Mugshot_SetGfx, + Mugshot_ShowBanner, + Mugshot_StartOpponentSlide, + Mugshot_WaitStartPlayerSlide, + Mugshot_WaitPlayerSlide, + Mugshot_GradualWhiteFade, + Mugshot_InitFadeWhiteToBlack, + Mugshot_FadeToBlack, + Mugshot_End }; static const u8 sMugshotsTrainerPicIDsTable[MUGSHOTS_COUNT] = { - [MUGSHOT_SIDNEY] = TRAINER_PIC_ELITE_FOUR_SIDNEY, - [MUGSHOT_PHOEBE] = TRAINER_PIC_ELITE_FOUR_PHOEBE, - [MUGSHOT_GLACIA] = TRAINER_PIC_ELITE_FOUR_GLACIA, - [MUGSHOT_DRAKE] = TRAINER_PIC_ELITE_FOUR_DRAKE, + [MUGSHOT_SIDNEY] = TRAINER_PIC_ELITE_FOUR_SIDNEY, + [MUGSHOT_PHOEBE] = TRAINER_PIC_ELITE_FOUR_PHOEBE, + [MUGSHOT_GLACIA] = TRAINER_PIC_ELITE_FOUR_GLACIA, + [MUGSHOT_DRAKE] = TRAINER_PIC_ELITE_FOUR_DRAKE, [MUGSHOT_CHAMPION] = TRAINER_PIC_CHAMPION_WALLACE, }; static const s16 sMugshotsOpponentRotationScales[MUGSHOTS_COUNT][2] = @@ -531,185 +559,222 @@ static const s16 sMugshotsOpponentRotationScales[MUGSHOTS_COUNT][2] = }; static const s16 sMugshotsOpponentCoords[MUGSHOTS_COUNT][2] = { - [MUGSHOT_SIDNEY] = {0, 0}, - [MUGSHOT_PHOEBE] = {0, 0}, - [MUGSHOT_GLACIA] = {-4, 4}, - [MUGSHOT_DRAKE] = {0, 5}, - [MUGSHOT_CHAMPION] = {-8, 7}, + [MUGSHOT_SIDNEY] = { 0, 0}, + [MUGSHOT_PHOEBE] = { 0, 0}, + [MUGSHOT_GLACIA] = {-4, 4}, + [MUGSHOT_DRAKE] = { 0, 5}, + [MUGSHOT_CHAMPION] = {-8, 7}, }; -static const TransitionSpriteCallback sTrainerPicSpriteCbs[] = +static const TransitionSpriteCallback sMugshotTrainerPicFuncs[] = { - TrainerPicCb_Nothing, - TrainerPicCb_SetSlideOffsets, - TrainerPicCb_Slide1, - TrainerPicCb_Slide2, - TrainerPicCb_Nothing, - TrainerPicCb_Slide3, - TrainerPicCb_Nothing + MugshotTrainerPic_Pause, + MugshotTrainerPic_Init, + MugshotTrainerPic_Slide, + MugshotTrainerPic_SlideSlow, + MugshotTrainerPic_Pause, + MugshotTrainerPic_SlideOffscreen, + MugshotTrainerPic_Pause }; -static const s16 sTrainerPicSlideOffsets1[2] = {12, -12}; -static const s16 sTrainerPicSlideOffsets2[2] = {-1, 1}; +// One element per slide direction. +// Sign of acceleration is opposite speed, so slide decelerates. +static const s16 sTrainerPicSlideSpeeds[2] = {12, -12}; +static const s16 sTrainerPicSlideAccels[2] = {-1, 1}; -static const TransitionStateFunc sPhase2_Slice_Funcs[] = +static const TransitionStateFunc sSlice_Funcs[] = { - Phase2_Slice_Func1, - Phase2_Slice_Func2, - Phase2_Slice_Func3 + Slice_Init, + Slice_Main, + Slice_End }; -static const TransitionStateFunc sPhase2_ShredSplit_Funcs[] = +static const TransitionStateFunc sShredSplit_Funcs[] = { - Phase2_ShredSplit_Func1, - Phase2_ShredSplit_Func2, - Phase2_ShredSplit_Func3, - Phase2_ShredSplit_Func4 + ShredSplit_Init, + ShredSplit_Main, + ShredSplit_BrokenCheck, + ShredSplit_End }; -static const u8 gUnknown_085C8C64[] = {39, 119}; -static const s16 gUnknown_085C8C66[] = {1, -1}; +static const u8 sShredSplit_SectionYCoords[] = {39, DISPLAY_HEIGHT - 41}; +static const s16 sShredSplit_SectionMoveDirs[] = {1, -1}; -static const TransitionStateFunc sPhase2_Blackhole1_Funcs[] = +static const TransitionStateFunc sBlackhole_Funcs[] = { - Phase2_Blackhole_Func1, - Phase2_Blackhole1_Func2, - Phase2_Blackhole1_Func3 + Blackhole_Init, + Blackhole_Vibrate, + Blackhole_GrowEnd }; -static const TransitionStateFunc sPhase2_Blackhole2_Funcs[] = +static const TransitionStateFunc sBlackholePulsate_Funcs[] = { - Phase2_Blackhole_Func1, - Phase2_Blackhole2_Func2 + Blackhole_Init, + BlackholePulsate_Main }; -static const s16 gUnknown_085C8C80[] = {-6, 4}; +// Blackhole rapidly alternates adding these values to the radius, +// resulting in a vibrating shrink/grow effect. +static const s16 sBlackhole_Vibrations[] = {-6, 4}; -static const TransitionStateFunc sPhase2_RectangularSpiral_Funcs[] = +static const TransitionStateFunc sRectangularSpiral_Funcs[] = { - Phase2_RectangularSpiral_Func1, - Phase2_RectangularSpiral_Func2, - Phase2_RectangularSpiral_Func3 + RectangularSpiral_Init, + RectangularSpiral_Main, + RectangularSpiral_End }; -static const s16 gUnknown_085C8C90[] = {1, 27, 275, -1}; -static const s16 gUnknown_085C8C98[] = {2, 486, -1}; -static const s16 gUnknown_085C8C9E[] = {3, 262, -1}; -static const s16 gUnknown_085C8CA4[] = {4, 507, -2}; -static const s16 gUnknown_085C8CAA[] = {1, 213, -1}; -static const s16 gUnknown_085C8CB0[] = {2, 548, -2}; -static const s16 gUnknown_085C8CB6[] = {3, 196, -1}; -static const s16 gUnknown_085C8CBC[] = {4, 573, 309, -1}; -static const s16 gUnknown_085C8CC4[] = {1, 474, -1}; -static const s16 gUnknown_085C8CCA[] = {2, 295, 32, -1}; -static const s16 gUnknown_085C8CD2[] = {3, 58, -1}; -static const s16 gUnknown_085C8CD8[] = {4, 455, -1}; -static const s16 gUnknown_085C8CDE[] = {1, 540, -1}; -static const s16 gUnknown_085C8CE4[] = {2, 229, -1}; -static const s16 gUnknown_085C8CEA[] = {3, 244, 28, -1}; -static const s16 gUnknown_085C8CF2[] = {4, 517, -1}; - -static const s16 *const gUnknown_085C8CF8[] = -{ - gUnknown_085C8C90, - gUnknown_085C8CA4, - gUnknown_085C8C98, - gUnknown_085C8C9E, - gUnknown_085C8CEA, - gUnknown_085C8CE4, - gUnknown_085C8CF2, - gUnknown_085C8CDE +#define SPIRAL_END (-1) +#define SPIRAL_REBOUND (-2) + +// Note that the directions are inverted for the lines originating at the bottom. +// i.e. MOVE_RIGHT is a right move for the top lines and a left move for the inverted bottom lines. +enum { + MOVE_RIGHT = 1, + MOVE_LEFT, + MOVE_UP, + MOVE_DOWN, +}; + +// Offsets of the movement data for spiraling in either direction. +#define SPIRAL_INWARD_START 0 +#define SPIRAL_INWARD_END 3 +#define SPIRAL_OUTWARD_START 4 +#define SPIRAL_OUTWARD_END 7 + +static const s16 sRectangularSpiral_Major_InwardRight[] = {MOVE_RIGHT, 27, 275, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_InwardLeft[] = {MOVE_LEFT, 486, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_InwardUp[] = {MOVE_UP, 262, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_InwardDown[] = {MOVE_DOWN, 507, SPIRAL_REBOUND}; + +static const s16 sRectangularSpiral_Minor_InwardRight[] = {MOVE_RIGHT, 213, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_InwardLeft[] = {MOVE_LEFT, 548, SPIRAL_REBOUND}; +static const s16 sRectangularSpiral_Minor_InwardUp[] = {MOVE_UP, 196, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_InwardDown[] = {MOVE_DOWN, 573, 309, SPIRAL_END}; + +static const s16 sRectangularSpiral_Minor_OutwardRight[] = {MOVE_RIGHT, 474, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_OutwardLeft[] = {MOVE_LEFT, 295, 32, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_OutwardUp[] = {MOVE_UP, 58, SPIRAL_END}; +static const s16 sRectangularSpiral_Minor_OutwardDown[] = {MOVE_DOWN, 455, SPIRAL_END}; + +static const s16 sRectangularSpiral_Major_OutwardRight[] = {MOVE_RIGHT, 540, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_OutwardLeft[] = {MOVE_LEFT, 229, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_OutwardUp[] = {MOVE_UP, 244, 28, SPIRAL_END}; +static const s16 sRectangularSpiral_Major_OutwardDown[] = {MOVE_DOWN, 517, SPIRAL_END}; + +// Move data for spiral lines starting in the top left / bottom right +static const s16 *const sRectangularSpiral_MoveDataTable_MajorDiagonal[] = +{ + [SPIRAL_INWARD_START] = + sRectangularSpiral_Major_InwardRight, + sRectangularSpiral_Major_InwardDown, + sRectangularSpiral_Major_InwardLeft, + sRectangularSpiral_Major_InwardUp, + + [SPIRAL_OUTWARD_START] = + sRectangularSpiral_Major_OutwardUp, + sRectangularSpiral_Major_OutwardLeft, + sRectangularSpiral_Major_OutwardDown, + sRectangularSpiral_Major_OutwardRight }; -static const s16 *const gUnknown_085C8D18[] = +// Move data for spiral lines starting in the top right / bottom left +static const s16 *const sRectangularSpiral_MoveDataTable_MinorDiagonal[] = { - gUnknown_085C8CBC, - gUnknown_085C8CB0, - gUnknown_085C8CB6, - gUnknown_085C8CAA, - gUnknown_085C8CCA, - gUnknown_085C8CD8, - gUnknown_085C8CC4, - gUnknown_085C8CD2 + [SPIRAL_INWARD_START] = + sRectangularSpiral_Minor_InwardDown, + sRectangularSpiral_Minor_InwardLeft, + sRectangularSpiral_Minor_InwardUp, + sRectangularSpiral_Minor_InwardRight, + + [SPIRAL_OUTWARD_START] = + sRectangularSpiral_Minor_OutwardLeft, + sRectangularSpiral_Minor_OutwardDown, + sRectangularSpiral_Minor_OutwardRight, + sRectangularSpiral_Minor_OutwardUp }; -static const s16 *const *const gUnknown_085C8D38[] = +static const s16 *const *const sRectangularSpiral_MoveDataTables[] = { - gUnknown_085C8CF8, - gUnknown_085C8D18 + sRectangularSpiral_MoveDataTable_MajorDiagonal, + sRectangularSpiral_MoveDataTable_MinorDiagonal }; -static const TransitionStateFunc sPhase2_Groudon_Funcs[] = +static const TransitionStateFunc sGroudon_Funcs[] = { - Phase2_WeatherTrio_Func1, - Phase2_WaitPaletteFade, - Phase2_Groudon_Func3, - Phase2_Groudon_Func4, - Phase2_Groudon_Func5, - Phase2_FramesCountdown, - Phase2_WeatherDuo_Func6, - Phase2_WeatherDuo_Func7 + WeatherTrio_BgFadeBlack, + WeatherTrio_WaitFade, + Groudon_Init, + Groudon_PaletteFlash, + Groudon_PaletteBrighten, + FramesCountdown, + WeatherDuo_FadeOut, + WeatherDuo_End }; -static const TransitionStateFunc sPhase2_Rayquaza_Funcs[] = -{ - Phase2_WeatherTrio_Func1, - Phase2_WaitPaletteFade, - Phase2_Rayquaza_Func3, - Phase2_Rayquaza_Func4, - Phase2_Rayquaza_Func5, - Phase2_Rayquaza_Func6, - Phase2_Rayquaza_Func7, - Phase2_Rayquaza_Func8, - Phase2_Rayquaza_Func9, - Phase2_Blackhole1_Func2, - Phase2_Blackhole1_Func3 +static const TransitionStateFunc sRayquaza_Funcs[] = +{ + WeatherTrio_BgFadeBlack, + WeatherTrio_WaitFade, + Rayquaza_Init, + Rayquaza_SetGfx, + Rayquaza_PaletteFlash, + Rayquaza_FadeToBlack, + Rayquaza_WaitFade, + Rayquaza_SetBlack, + Rayquaza_TriRing, + Blackhole_Vibrate, + Blackhole_GrowEnd }; -static const TransitionStateFunc sPhase2_WhiteFade_Funcs[] = +static const TransitionStateFunc sWhiteBarsFade_Funcs[] = { - Phase2_WhiteFade_Func1, - Phase2_WhiteFade_Func2, - Phase2_WhiteFade_Func3, - Phase2_WhiteFade_Func4, - Phase2_WhiteFade_Func5 + WhiteBarsFade_Init, + WhiteBarsFade_StartBars, + WhiteBarsFade_WaitBars, + WhiteBarsFade_BlendToBlack, + WhiteBarsFade_End }; -static const s16 sUnknown_085C8DA0[] = {0, 20, 15, 40, 10, 25, 35, 5}; +#define NUM_WHITE_BARS 8 +static const s16 sWhiteBarsFade_StartDelays[NUM_WHITE_BARS] = {0, 20, 15, 40, 10, 25, 35, 5}; -static const TransitionStateFunc sPhase2_GridSquares_Funcs[] = +static const TransitionStateFunc sGridSquares_Funcs[] = { - Phase2_GridSquares_Func1, - Phase2_GridSquares_Func2, - Phase2_GridSquares_Func3 + GridSquares_Init, + GridSquares_Main, + GridSquares_End }; -static const TransitionStateFunc sPhase2_Shards_Funcs[] = +static const TransitionStateFunc sAngledWipes_Funcs[] = { - Phase2_Shards_Func1, - Phase2_Shards_Func2, - Phase2_Shards_Func3, - Phase2_Shards_Func4, - Phase2_Shards_Func5 + AngledWipes_Init, + AngledWipes_SetWipeData, + AngledWipes_DoWipe, + AngledWipes_TryEnd, + AngledWipes_StartNext }; -static const s16 sUnknown_085C8DD0[][5] = +#define NUM_ANGLED_WIPES 7 + +static const s16 sAngledWipes_MoveData[NUM_ANGLED_WIPES][5] = { - {56, 0, 0, 160, 0}, - {104, 160, 240, 88, 1}, - {240, 72, 56, 0, 1}, - {0, 32, 144, 160, 0}, - {144, 160, 184, 0, 1}, - {56, 0, 168, 160, 0}, - {168, 160, 48, 0, 1}, +// startX startY endX endY yDirection + {56, 0, 0, DISPLAY_HEIGHT, 0}, + {104, DISPLAY_HEIGHT, DISPLAY_WIDTH, 88, 1}, + {DISPLAY_WIDTH, 72, 56, 0, 1}, + {0, 32, 144, DISPLAY_HEIGHT, 0}, + {144, DISPLAY_HEIGHT, 184, 0, 1}, + {56, 0, 168, DISPLAY_HEIGHT, 0}, + {168, DISPLAY_HEIGHT, 48, 0, 1}, }; -static const s16 sUnknown_085C8E16[] = {8, 4, 2, 1, 1, 1, 0}; +static const s16 sAngledWipes_EndDelays[NUM_ANGLED_WIPES] = {8, 4, 2, 1, 1, 1, 0}; -static const TransitionStateFunc sPhase1_TransitionAll_Funcs[] = +static const TransitionStateFunc sTransitionIntroFuncs[] = { - Phase1_TransitionAll_Func1, - Phase1_TransitionAll_Func2 + TransitionIntro_FadeToGray, + TransitionIntro_FadeFromGray }; static const struct SpriteFrameImage sSpriteImage_Pokeball[] = @@ -749,12 +814,12 @@ static const union AffineAnimCmd *const sSpriteAffineAnimTable_Pokeball[] = static const struct SpriteTemplate sSpriteTemplate_Pokeball = { .tileTag = TAG_NONE, - .paletteTag = FLDEFF_PAL_TAG_POKEBALL, + .paletteTag = FLDEFF_PAL_TAG_POKEBALL_TRAIL, .oam = &gObjectEventBaseOam_32x32, .anims = sSpriteAnimTable_Pokeball, .images = sSpriteImage_Pokeball, .affineAnims = sSpriteAffineAnimTable_Pokeball, - .callback = sub_814713C + .callback = SpriteCB_FldEffPokeballTrail }; static const struct OamData sOam_UnusedBrendanLass = @@ -798,28 +863,28 @@ static const union AnimCmd *const sSpriteAnimTable_UnusedBrendanLass[] = static const struct SpriteTemplate sSpriteTemplate_UnusedBrendan = { .tileTag = TAG_NONE, - .paletteTag = 0x100A, + .paletteTag = PALTAG_UNUSED_MUGSHOT, .oam = &sOam_UnusedBrendanLass, .anims = sSpriteAnimTable_UnusedBrendanLass, .images = sImageTable_UnusedBrendan, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCb_TrainerPic + .callback = SpriteCB_MugshotTrainerPic }; static const struct SpriteTemplate sSpriteTemplate_UnusedLass = { .tileTag = TAG_NONE, - .paletteTag = 0x100A, + .paletteTag = PALTAG_UNUSED_MUGSHOT, .oam = &sOam_UnusedBrendanLass, .anims = sSpriteAnimTable_UnusedBrendanLass, .images = sImageTable_UnusedLass, .affineAnims = gDummySpriteAffineAnimTable, - .callback = SpriteCb_TrainerPic + .callback = SpriteCB_MugshotTrainerPic }; static const u16 sFieldEffectPal_Pokeball[] = INCBIN_U16("graphics/field_effects/palettes/pokeball.gbapal"); -const struct SpritePalette gSpritePalette_Pokeball = {sFieldEffectPal_Pokeball, FLDEFF_PAL_TAG_POKEBALL}; +const struct SpritePalette gSpritePalette_Pokeball = {sFieldEffectPal_Pokeball, FLDEFF_PAL_TAG_POKEBALL_TRAIL}; static const u16 sMugshotPal_Sidney[] = INCBIN_U16("graphics/battle_transitions/sidney_bg.gbapal"); static const u16 sMugshotPal_Phoebe[] = INCBIN_U16("graphics/battle_transitions/phoebe_bg.gbapal"); @@ -845,59 +910,90 @@ static const u16 *const sPlayerMugshotsPals[GENDER_COUNT] = }; static const u16 sUnusedTrainerPalette[] = INCBIN_U16("graphics/battle_transitions/unused_trainer.gbapal"); -static const struct SpritePalette sSpritePalette_UnusedTrainer = {sUnusedTrainerPalette, 0x100A}; +static const struct SpritePalette sSpritePalette_UnusedTrainer = {sUnusedTrainerPalette, PALTAG_UNUSED_MUGSHOT}; static const u16 sBigPokeball_Tilemap[] = INCBIN_U16("graphics/battle_transitions/big_pokeball_map.bin"); static const u16 sMugshotsTilemap[] = INCBIN_U16("graphics/battle_transitions/elite_four_bg_map.bin"); -static const TransitionStateFunc sPhase2_FrontierLogoWiggle_Funcs[] = +static const TransitionStateFunc sFrontierLogoWiggle_Funcs[] = { - Phase2_FrontierLogoWiggle_Func1, - Phase2_FrontierLogoWiggle_Func2, - Phase2_BigPokeball_Func3, - Phase2_BigPokeball_Func4, - Phase2_BigPokeball_Func5, - Phase2_BigPokeball_Func6 + FrontierLogoWiggle_Init, + FrontierLogoWiggle_SetGfx, + PatternWeave_Blend1, + PatternWeave_Blend2, + PatternWeave_FinishAppear, + PatternWeave_CircularMask }; -static const TransitionStateFunc sPhase2_FrontierLogoWave_Funcs[] = +static const TransitionStateFunc sFrontierLogoWave_Funcs[] = { - Phase2_FrontierLogoWave_Func1, - Phase2_FrontierLogoWave_Func2, - Phase2_FrontierLogoWave_Func3, - Phase2_FrontierLogoWave_Func4 + FrontierLogoWave_Init, + FrontierLogoWave_SetGfx, + FrontierLogoWave_InitScanline, + FrontierLogoWave_Main }; -static const TransitionStateFunc sPhase2_FrontierSquares_Funcs[] = +static const TransitionStateFunc sFrontierSquares_Funcs[] = { - Phase2_FrontierSquares_Func1, - Phase2_FrontierSquares_Func2, - Phase2_FrontierSquares_Func3, - Phase2_FrontierSquares_End + FrontierSquares_Init, + FrontierSquares_Draw, + FrontierSquares_Shrink, + FrontierSquares_End }; -static const TransitionStateFunc sPhase2_FrontierSquaresSpiral_Funcs[] = +static const TransitionStateFunc sFrontierSquaresSpiral_Funcs[] = { - Phase2_FrontierSquaresSpiral_Func1, - Phase2_FrontierSquaresSpiral_Func2, - Phase2_FrontierSquaresSpiral_Func3, - Phase2_FrontierSquaresSpiral_Func4, - Phase2_FrontierSquares_End + FrontierSquaresSpiral_Init, + FrontierSquaresSpiral_Outward, + FrontierSquaresSpiral_SetBlack, + FrontierSquaresSpiral_Inward, + FrontierSquares_End }; -static const TransitionStateFunc sPhase2_FrontierSquaresScroll_Funcs[] = +static const TransitionStateFunc sFrontierSquaresScroll_Funcs[] = { - Phase2_FrontierSquaresScroll_Func1, - Phase2_FrontierSquaresScroll_Func2, - Phase2_FrontierSquaresScroll_Func3, - Phase2_FrontierSquaresScroll_Func4, - Phase2_FrontierSquaresScroll_Func5 + FrontierSquaresScroll_Init, + FrontierSquaresScroll_Draw, + FrontierSquaresScroll_SetBlack, + FrontierSquaresScroll_Erase, + FrontierSquaresScroll_End }; -static const u8 gUnknown_085C9A30[] = {0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x1b, 0x14, 0x0d, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x07, 0x0e, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x13, 0x0c, 0x0b, 0x0a, 0x09, 0x08, 0x0f, 0x10, 0x11, 0x12}; -static const u8 gUnknown_085C9A53[] = {0x00, 0x10, 0x29, 0x16, 0x2c, 0x02, 0x2b, 0x15, 0x2e, 0x1b, 0x09, 0x30, 0x26, 0x05, 0x39, 0x3b, 0x0c, 0x3f, 0x23, 0x1c, 0x0a, 0x35, 0x07, 0x31, 0x27, 0x17, 0x37, 0x01, 0x3e, 0x11, 0x3d, 0x1e, 0x06, 0x22, 0x0f, 0x33, 0x20, 0x3a, 0x0d, 0x2d, 0x25, 0x34, 0x0b, 0x18, 0x3c, 0x13, 0x38, 0x21, 0x1d, 0x32, 0x28, 0x36, 0x0e, 0x03, 0x2f, 0x14, 0x12, 0x19, 0x04, 0x24, 0x1a, 0x2a, 0x1f, 0x08, 0x00}; +#define SQUARE_SIZE 4 +#define MARGIN_SIZE 1 // Squares do not fit evenly across the width, so there is a margin on either side. +#define NUM_SQUARES_PER_ROW ((DISPLAY_WIDTH - (MARGIN_SIZE * 8 * 2)) / (SQUARE_SIZE * 8)) +#define NUM_SQUARES_PER_COL (DISPLAY_HEIGHT / (SQUARE_SIZE * 8)) +#define NUM_SQUARES (NUM_SQUARES_PER_ROW * NUM_SQUARES_PER_COL) + +// The order in which the squares should appear/disappear to create +// the spiral effect. Spiraling inward starts with the first element, +// and spiraling outward starts with the last. The positions are the +// squares numbered left-to-right top-to-bottom. +static const u8 sFrontierSquaresSpiral_Positions[NUM_SQUARES] = { + 28, 29, 30, 31, 32, 33, 34, + 27, 20, 13, 6, 5, 4, 3, + 2, 1, 0, 7, 14, 21, 22, + 23, 24, 25, 26, 19, 12, 11, + 10, 9, 8, 15, 16, 17, 18 +}; + +// In the scrolling version the squares appear/disappear in a "random" order +// dictated by the list below. +static const u8 sFrontierSquaresScroll_Positions[] = { + 0, 16, 41, 22, 44, 2, 43, 21, + 46, 27, 9, 48, 38, 5, 57, 59, + 12, 63, 35, 28, 10, 53, 7, 49, + 39, 23, 55, 1, 62, 17, 61, 30, + 6, 34, 15, 51, 32, 58, 13, 45, + 37, 52, 11, 24, 60, 19, 56, 33, + 29, 50, 40, 54, 14, 3, 47, 20, + 18, 25, 4, 36, 26, 42, 31, 8 +}; + +//--------------------------- +// Main transition functions +//--------------------------- -// code static void CB2_TestBattleTransition(void) { switch (sTestingTransitionState) @@ -921,7 +1017,8 @@ static void CB2_TestBattleTransition(void) UpdatePaletteFade(); } -void TestBattleTransition(u8 transitionId) +// Unused +static void TestBattleTransition(u8 transitionId) { sTestingTransitionId = transitionId; SetMainCallback2(CB2_TestBattleTransition); @@ -938,20 +1035,17 @@ void BattleTransition_Start(u8 transitionId) LaunchBattleTransitionTask(transitionId); } -// in all tasks data[0] is reserved for the state -#define tState data[0] - // main task that launches sub-tasks for phase1 and phase2 #define tTransitionId data[1] #define tTransitionDone data[15] bool8 IsBattleTransitionDone(void) { - u8 taskId = FindTaskIdByFunc(Task_BattleTransitionMain); + u8 taskId = FindTaskIdByFunc(Task_BattleTransition); if (gTasks[taskId].tTransitionDone) { DestroyTask(taskId); - FREE_AND_SET_NULL(sTransitionStructPtr); + FREE_AND_SET_NULL(sTransitionData); return TRUE; } else @@ -962,23 +1056,23 @@ bool8 IsBattleTransitionDone(void) static void LaunchBattleTransitionTask(u8 transitionId) { - u8 taskId = CreateTask(Task_BattleTransitionMain, 2); + u8 taskId = CreateTask(Task_BattleTransition, 2); gTasks[taskId].tTransitionId = transitionId; - sTransitionStructPtr = AllocZeroed(sizeof(*sTransitionStructPtr)); + sTransitionData = AllocZeroed(sizeof(*sTransitionData)); } -static void Task_BattleTransitionMain(u8 taskId) +static void Task_BattleTransition(u8 taskId) { - while (sMainTransitionPhases[gTasks[taskId].tState](&gTasks[taskId])); + while (sTaskHandlers[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Transition_Phase1(struct Task *task) +static bool8 Transition_StartIntro(struct Task *task) { SetWeatherScreenFadeOut(); - CpuCopy32(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); - if (sPhase1_Tasks[task->tTransitionId] != NULL) + CpuCopy32(gPlttBufferFaded, gPlttBufferUnfaded, sizeof(gPlttBufferUnfaded)); + if (sTasks_Intro[task->tTransitionId] != NULL) { - CreateTask(sPhase1_Tasks[task->tTransitionId], 4); + CreateTask(sTasks_Intro[task->tTransitionId], 4); task->tState++; return FALSE; } @@ -989,9 +1083,9 @@ static bool8 Transition_Phase1(struct Task *task) } } -static bool8 Transition_WaitForPhase1(struct Task *task) +static bool8 Transition_WaitForIntro(struct Task *task) { - if (FindTaskIdByFunc(sPhase1_Tasks[task->tTransitionId]) == TASK_NONE) + if (FindTaskIdByFunc(sTasks_Intro[task->tTransitionId]) == TASK_NONE) { task->tState++; return TRUE; @@ -1002,17 +1096,17 @@ static bool8 Transition_WaitForPhase1(struct Task *task) } } -static bool8 Transition_Phase2(struct Task *task) +static bool8 Transition_StartMain(struct Task *task) { - CreateTask(sPhase2_Tasks[task->tTransitionId], 0); + CreateTask(sTasks_Main[task->tTransitionId], 0); task->tState++; return FALSE; } -static bool8 Transition_WaitForPhase2(struct Task *task) +static bool8 Transition_WaitForMain(struct Task *task) { task->tTransitionDone = FALSE; - if (FindTaskIdByFunc(sPhase2_Tasks[task->tTransitionId]) == TASK_NONE) + if (FindTaskIdByFunc(sTasks_Main[task->tTransitionId]) == TASK_NONE) task->tTransitionDone = TRUE; return FALSE; } @@ -1020,38 +1114,32 @@ static bool8 Transition_WaitForPhase2(struct Task *task) #undef tTransitionId #undef tTransitionDone -static void Phase1Task_TransitionAll(u8 taskId) +static void Task_Intro(u8 taskId) { if (gTasks[taskId].tState == 0) { gTasks[taskId].tState++; - CreatePhase1Task(0, 0, 3, 2, 2); // creates a sub-task for this sub-task + CreateIntroTask(0, 0, 3, 2, 2); } - else if (IsPhase1Done()) + else if (IsIntroTaskDone()) { DestroyTask(taskId); } } -// sub-task for phase2 -#define tData1 data[1] -#define tData2 data[2] -#define tData3 data[3] -#define tData4 data[4] -#define tData5 data[5] -#define tData6 data[6] -#define tFuncState data[7] -#define tFrames data[8] -#define tOpponentSpriteId data[13] -#define tPlayerSpriteId data[14] -#define tMugshotId data[15] +//-------------------- +// B_TRANSITION_BLUR +//-------------------- -static void Phase2Task_Blur(u8 taskId) +#define tDelay data[1] +#define tCounter data[2] + +static void Task_Blur(u8 taskId) { - while (sPhase2_Blur_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBlur_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Blur_Func1(struct Task *task) +static bool8 Blur_Init(struct Task *task) { SetGpuReg(REG_OFFSET_MOSAIC, 0); SetGpuRegBits(REG_OFFSET_BG1CNT, BGCNT_MOSAIC); @@ -1061,48 +1149,58 @@ static bool8 Phase2_Blur_Func1(struct Task *task) return TRUE; } -static bool8 Phase2_Blur_Func2(struct Task *task) +static bool8 Blur_Main(struct Task *task) { - if (task->tData1 != 0) + if (task->tDelay != 0) { - task->tData1--; + task->tDelay--; } else { - task->tData1 = 4; - if (++task->tData2 == 10) - BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 0x10, RGB_BLACK); - SetGpuReg(REG_OFFSET_MOSAIC, (task->tData2 & 15) * 17); - if (task->tData2 > 14) + task->tDelay = 4; + if (++task->tCounter == 10) + BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 16, RGB_BLACK); + SetGpuReg(REG_OFFSET_MOSAIC, (task->tCounter & 15) * 17); + if (task->tCounter > 14) task->tState++; } return FALSE; } -static bool8 Phase2_Blur_Func3(struct Task *task) +static bool8 Blur_End(struct Task *task) { if (!gPaletteFade.active) { - u8 taskId = FindTaskIdByFunc(Phase2Task_Blur); + u8 taskId = FindTaskIdByFunc(Task_Blur); DestroyTask(taskId); } return FALSE; } -static void Phase2Task_Swirl(u8 taskId) +#undef tDelay +#undef tCounter + +//-------------------- +// B_TRANSITION_SWIRL +//-------------------- + +#define tSinIndex data[1] +#define tAmplitude data[2] + +static void Task_Swirl(u8 taskId) { - while (sPhase2_Swirl_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sSwirl_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Swirl_Func1(struct Task *task) +static bool8 Swirl_Init(struct Task *task) { - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 0x10, RGB_BLACK); - sub_8149F98(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_14, 0, 2, 0, 160); + BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 16, RGB_BLACK); + SetSinWave(gScanlineEffectRegBuffers[1], sTransitionData->cameraX, 0, 2, 0, DISPLAY_HEIGHT); - SetVBlankCallback(VBlankCB_Phase2_Swirl); - SetHBlankCallback(HBlankCB_Phase2_Swirl); + SetVBlankCallback(VBlankCB_Swirl); + SetHBlankCallback(HBlankCB_Swirl); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK); @@ -1110,32 +1208,32 @@ static bool8 Phase2_Swirl_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_Swirl_Func2(struct Task *task) +static bool8 Swirl_End(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - task->tData1 += 4; - task->tData2 += 8; + sTransitionData->VBlank_DMA = FALSE; + task->tSinIndex += 4; + task->tAmplitude += 8; - sub_8149F98(gScanlineEffectRegBuffers[0], sTransitionStructPtr->field_14, task->tData1, 2, task->tData2, 160); + SetSinWave(gScanlineEffectRegBuffers[0], sTransitionData->cameraX, task->tSinIndex, 2, task->tAmplitude, DISPLAY_HEIGHT); if (!gPaletteFade.active) { - u8 taskId = FindTaskIdByFunc(Phase2Task_Swirl); + u8 taskId = FindTaskIdByFunc(Task_Swirl); DestroyTask(taskId); } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static void VBlankCB_Phase2_Swirl(void) +static void VBlankCB_Swirl(void) { VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); } -static void HBlankCB_Phase2_Swirl(void) +static void HBlankCB_Swirl(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1HOFS = var; @@ -1143,21 +1241,31 @@ static void HBlankCB_Phase2_Swirl(void) REG_BG3HOFS = var; } -static void Phase2Task_Shuffle(u8 taskId) +#undef tSinIndex +#undef tAmplitude + +//---------------------- +// B_TRANSITION_SHUFFLE +//---------------------- + +#define tSinVal data[1] +#define tAmplitude data[2] + +static void Task_Shuffle(u8 taskId) { - while (sPhase2_Shuffle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sShuffle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Shuffle_Func1(struct Task *task) +static bool8 Shuffle_Init(struct Task *task) { - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 0x10, RGB_BLACK); - memset(gScanlineEffectRegBuffers[1], sTransitionStructPtr->field_16, 0x140); + BeginNormalPaletteFade(PALETTES_ALL, 4, 0, 16, RGB_BLACK); + memset(gScanlineEffectRegBuffers[1], sTransitionData->cameraY, DISPLAY_HEIGHT * 2); - SetVBlankCallback(VBlankCB_Phase2_Shuffle); - SetHBlankCallback(HBlankCB_Phase2_Shuffle); + SetVBlankCallback(VBlankCB_Shuffle); + SetHBlankCallback(HBlankCB_Shuffle); EnableInterrupts(INTR_FLAG_VBLANK | INTR_FLAG_HBLANK); @@ -1165,38 +1273,38 @@ static bool8 Phase2_Shuffle_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_Shuffle_Func2(struct Task *task) +static bool8 Shuffle_End(struct Task *task) { u8 i; - u16 r3, r4; + u16 amplitude, sinVal; - sTransitionStructPtr->VBlank_DMA = FALSE; - r4 = task->tData1; - r3 = task->tData2 >> 8; - task->tData1 += 4224; - task->tData2 += 384; + sTransitionData->VBlank_DMA = FALSE; + sinVal = task->tSinVal; + amplitude = task->tAmplitude >> 8; + task->tSinVal += 4224; + task->tAmplitude += 384; - for (i = 0; i < 160; i++, r4 += 4224) + for (i = 0; i < DISPLAY_HEIGHT; i++, sinVal += 4224) { - u16 var = r4 / 256; - gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3); + u16 sinIndex = sinVal / 256; + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(sinIndex, amplitude); } if (!gPaletteFade.active) - DestroyTask(FindTaskIdByFunc(Phase2Task_Shuffle)); + DestroyTask(FindTaskIdByFunc(Task_Shuffle)); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static void VBlankCB_Phase2_Shuffle(void) +static void VBlankCB_Shuffle(void) { VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); } -static void HBlankCB_Phase2_Shuffle(void) +static void HBlankCB_Shuffle(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1VOFS = var; @@ -1204,221 +1312,240 @@ static void HBlankCB_Phase2_Shuffle(void) REG_BG3VOFS = var; } -static void Phase2Task_BigPokeball(u8 taskId) +#undef tSinVal +#undef tAmplitude + +//------------------------------------------------------------------------ +// B_TRANSITION_BIG_POKEBALL, B_TRANSITION_AQUA, B_TRANSITION_MAGMA, +// B_TRANSITION_REGICE, B_TRANSITION_REGISTEEL, B_TRANSITION_REGIROCK +// and B_TRANSITION_KYOGRE. +// +// With the exception of B_TRANSITION_KYOGRE, all of the above transitions +// use the same weave effect (see the PatternWeave functions). +// Unclear why Kyogre's was grouped here and not with Groudon/Rayquaza's. +//------------------------------------------------------------------------ + +#define tBlendTarget1 data[1] +#define tBlendTarget2 data[2] +#define tBlendDelay data[3] + +// Data 1-3 change purpose for PatternWeave_CircularMask +#define tRadius data[1] +#define tRadiusDelta data[2] +#define tVBlankSet data[3] + +#define tSinIndex data[4] +#define tAmplitude data[5] +#define tEndDelay data[8] + +static void Task_BigPokeball(u8 taskId) { - while (sPhase2_BigPokeball_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBigPokeball_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Aqua(u8 taskId) +static void Task_Aqua(u8 taskId) { - while (sPhase2_Aqua_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sAqua_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Magma(u8 taskId) +static void Task_Magma(u8 taskId) { - while (sPhase2_Magma_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sMagma_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Regice(u8 taskId) +static void Task_Regice(u8 taskId) { - while (sPhase2_Regice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRegice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Registeel(u8 taskId) +static void Task_Registeel(u8 taskId) { - while (sPhase2_Registeel_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRegisteel_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Regirock(u8 taskId) +static void Task_Regirock(u8 taskId) { - while (sPhase2_Regirock_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRegirock_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Kyogre(u8 taskId) +static void Task_Kyogre(u8 taskId) { - while (sPhase2_Kyogre_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sKyogre_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void sub_814669C(struct Task *task) +static void InitPatternWeaveTransition(struct Task *task) { s32 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - task->tData1 = 16; - task->tData2 = 0; - task->tData4 = 0; - task->tData5 = 0x4000; - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; - sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData2, task->tData1); - - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = 240; - } + task->tBlendTarget1 = 16; + task->tBlendTarget2 = 0; + task->tSinIndex = 0; + task->tAmplitude = 0x4000; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->WIN0V = DISPLAY_HEIGHT; + sTransitionData->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); + + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = DISPLAY_WIDTH; - SetVBlankCallback(VBlankCB0_Phase2_BigPokeball); + SetVBlankCallback(VBlankCB_PatternWeave); } -static bool8 Phase2_Aqua_Func1(struct Task *task) +static bool8 Aqua_Init(struct Task *task) { u16 *tilemap, *tileset; - task->tFrames = 60; - sub_814669C(task); + task->tEndDelay = 60; + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sTeamAqua_Tileset, tileset); - LoadPalette(sEvilTeam_Palette, 0xF0, 0x20); + LoadPalette(sEvilTeam_Palette, 0xF0, sizeof(sEvilTeam_Palette)); task->tState++; return FALSE; } -static bool8 Phase2_Magma_Func1(struct Task *task) +static bool8 Magma_Init(struct Task *task) { u16 *tilemap, *tileset; - task->tFrames = 60; - sub_814669C(task); + task->tEndDelay = 60; + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sTeamMagma_Tileset, tileset); - LoadPalette(sEvilTeam_Palette, 0xF0, 0x20); + LoadPalette(sEvilTeam_Palette, 0xF0, sizeof(sEvilTeam_Palette)); task->tState++; return FALSE; } -static bool8 Phase2_Regi_Func1(struct Task *task) +static bool8 Regi_Init(struct Task *task) { u16 *tilemap, *tileset; - task->tFrames = 60; - sub_814669C(task); + task->tEndDelay = 60; + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); CpuCopy16(sRegis_Tileset, tileset, 0x2000); task->tState++; return FALSE; } -static bool8 Phase2_BigPokeball_Func1(struct Task *task) +static bool8 BigPokeball_Init(struct Task *task) { u16 *tilemap, *tileset; - sub_814669C(task); + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); - CpuCopy16(sBigPokeball_Tileset, tileset, 0x580); - LoadPalette(sFieldEffectPal_Pokeball, 0xF0, 0x20); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); + CpuCopy16(sBigPokeball_Tileset, tileset, sizeof(sBigPokeball_Tileset)); + LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->tState++; return FALSE; } -#define SOME_VRAM_STORE(ptr, posY, posX, toStore) \ -{ \ - u32 index = (posY) * 32 + posX; \ - ptr[index] = toStore; \ -} - -static bool8 Phase2_BigPokeball_Func2(struct Task *task) +static bool8 BigPokeball_SetGfx(struct Task *task) { s16 i, j; u16 *tilemap, *tileset; - const u16 *BigPokeballMap; + const u16 *bigPokeballMap; GetBg0TilesDst(&tilemap, &tileset); - BigPokeballMap = sBigPokeball_Tilemap; + bigPokeballMap = sBigPokeball_Tilemap; for (i = 0; i < 20; i++) { - for (j = 0; j < 30; j++, BigPokeballMap++) - { - SOME_VRAM_STORE(tilemap, i, j, *BigPokeballMap | 0xF000); - } + for (j = 0; j < 30; j++, bigPokeballMap++) + SET_TILE(tilemap, i, j, *bigPokeballMap); } - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return TRUE; } -static bool8 Phase2_Aqua_Func2(struct Task *task) +static bool8 Aqua_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sTeamAqua_Tilemap, tilemap); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Phase2_Magma_Func2(struct Task *task) +static bool8 Magma_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sTeamMagma_Tilemap, tilemap); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Phase2_Regice_Func2(struct Task *task) +static bool8 Regice_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - LoadPalette(sRegice_Palette, 0xF0, 0x20); + LoadPalette(sRegice_Palette, 0xF0, sizeof(sRegice_Palette)); CpuCopy16(sRegice_Tilemap, tilemap, 0x500); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Phase2_Registeel_Func2(struct Task *task) +static bool8 Registeel_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - LoadPalette(sRegisteel_Palette, 0xF0, 0x20); + LoadPalette(sRegisteel_Palette, 0xF0, sizeof(sRegisteel_Palette)); CpuCopy16(sRegisteel_Tilemap, tilemap, 0x500); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Phase2_Regirock_Func2(struct Task *task) +static bool8 Regirock_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - LoadPalette(sRegirock_Palette, 0xF0, 0x20); + LoadPalette(sRegirock_Palette, 0xF0, sizeof(sRegirock_Palette)); CpuCopy16(sRegirock_Tilemap, tilemap, 0x500); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return FALSE; } -static bool8 Phase2_Kyogre_Func3(struct Task *task) +#define tTimer data[1] + +static bool8 Kyogre_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sKyogre_Tileset, tileset); LZ77UnCompVram(sKyogre_Tilemap, tilemap); @@ -1426,48 +1553,48 @@ static bool8 Phase2_Kyogre_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_Kyogre_Func4(struct Task *task) +static bool8 Kyogre_PaletteFlash(struct Task *task) { - if (task->tData1 % 3 == 0) + if (task->tTimer % 3 == 0) { - u16 var = task->tData1 % 30; - var /= 3; - LoadPalette(sKyogre1_Palette + (var * 16), 0xF0, 0x20); + u16 offset = task->tTimer % 30; + offset /= 3; + LoadPalette(&sKyogre1_Palette[offset * 16], 0xF0, 0x20); } - if (++task->tData1 > 58) + if (++task->tTimer > 58) { task->tState++; - task->tData1 = 0; + task->tTimer = 0; } return FALSE; } -static bool8 Phase2_Kyogre_Func5(struct Task *task) +static bool8 Kyogre_PaletteBrighten(struct Task *task) { - if (task->tData1 % 5 == 0) + if (task->tTimer % 5 == 0) { - s16 var = task->tData1 / 5; - LoadPalette(sKyogre2_Palette + (var * 16), 0xF0, 0x20); + s16 offset = task->tTimer / 5; + LoadPalette(&sKyogre2_Palette[offset * 16], 0xF0, 0x20); } - if (++task->tData1 > 68) + if (++task->tTimer > 68) { task->tState++; - task->tData1 = 0; - task->tFrames = 30; + task->tTimer = 0; + task->tEndDelay = 30; } return FALSE; } -static bool8 Phase2_WeatherDuo_Func6(struct Task *task) +static bool8 WeatherDuo_FadeOut(struct Task *task) { - BeginNormalPaletteFade(PALETTES_OBJECTS | 0x8000, 1, 0, 0x10, RGB_BLACK); + BeginNormalPaletteFade(PALETTES_OBJECTS | (1 << 15), 1, 0, 16, RGB_BLACK); task->tState++; return FALSE; } -static bool8 Phase2_WeatherDuo_Func7(struct Task *task) +static bool8 WeatherDuo_End(struct Task *task) { if (!gPaletteFade.active) { @@ -1478,100 +1605,106 @@ static bool8 Phase2_WeatherDuo_Func7(struct Task *task) return FALSE; } -static bool8 Phase2_BigPokeball_Func3(struct Task *task) +#undef tTimer + +// The PatternWeave_ functions are used by several different transitions. +// They create an effect where a pattern/image (such as the Magma emblem) is +// formed by a shimmering weave effect. +static bool8 PatternWeave_Blend1(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tData3 == 0 || --task->tData3 == 0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tBlendDelay == 0 || --task->tBlendDelay == 0) { - task->tData2++; - task->tData3 = 2; + task->tBlendTarget2++; + task->tBlendDelay = 2; } - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData2, task->tData1); - if (task->tData2 > 15) + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); + if (task->tBlendTarget2 > 15) task->tState++; - task->tData4 += 8; - task->tData5 -= 256; + task->tSinIndex += 8; + task->tAmplitude -= 256; - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude >> 8, DISPLAY_HEIGHT); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_BigPokeball_Func4(struct Task *task) +static bool8 PatternWeave_Blend2(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tData3 == 0 || --task->tData3 == 0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tBlendDelay == 0 || --task->tBlendDelay == 0) { - task->tData1--; - task->tData3 = 2; + task->tBlendTarget1--; + task->tBlendDelay = 2; } - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData2, task->tData1); - if (task->tData1 == 0) + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); + if (task->tBlendTarget1 == 0) task->tState++; - task->tData4 += 8; - task->tData5 -= 256; + task->tSinIndex += 8; + task->tAmplitude -= 256; - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude >> 8, DISPLAY_HEIGHT); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_BigPokeball_Func5(struct Task *task) +static bool8 PatternWeave_FinishAppear(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - task->tData4 += 8; - task->tData5 -= 256; + sTransitionData->VBlank_DMA = FALSE; + task->tSinIndex += 8; + task->tAmplitude -= 256; - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5 >> 8, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude >> 8, DISPLAY_HEIGHT); - if (task->tData5 <= 0) + if (task->tAmplitude <= 0) { task->tState++; - task->tData1 = 160; - task->tData2 = 256; - task->tData3 = 0; + task->tRadius = DISPLAY_HEIGHT; + task->tRadiusDelta = 1 << 8; + task->tVBlankSet = FALSE; } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_FramesCountdown(struct Task *task) +static bool8 FramesCountdown(struct Task *task) { - if (--task->tFrames == 0) + if (--task->tEndDelay == 0) task->tState++; return FALSE; } -static bool8 Phase2_WeatherTrio_Func1(struct Task *task) +static bool8 WeatherTrio_BgFadeBlack(struct Task *task) { - BeginNormalPaletteFade(PALETTES_BG, 1, 0, 0x10, RGB_BLACK); + BeginNormalPaletteFade(PALETTES_BG, 1, 0, 16, RGB_BLACK); task->tState++; return FALSE; } -static bool8 Phase2_WaitPaletteFade(struct Task *task) +static bool8 WeatherTrio_WaitFade(struct Task *task) { if (!gPaletteFade.active) task->tState++; return FALSE; } -static bool8 Phase2_BigPokeball_Func6(struct Task *task) +// Do a shrinking circular mask to go to a black screen after the pattern appears. +static bool8 PatternWeave_CircularMask(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tData2 < 1024) - task->tData2 += 128; - if (task->tData1 != 0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tRadiusDelta < (4 << 8)) + task->tRadiusDelta += 128; // 256 is 1 unit of speed. Speed up every other frame (128 / 256) + if (task->tRadius != 0) { - task->tData1 -= (task->tData2 >> 8); - if (task->tData1 < 0) - task->tData1 = 0; + task->tRadius -= task->tRadiusDelta >> 8; + if (task->tRadius < 0) + task->tRadius = 0; } - sub_814A014(gScanlineEffectRegBuffers[0], 120, 80, task->tData1); - if (task->tData1 == 0) + SetCircularMask(gScanlineEffectRegBuffers[0], DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, task->tRadius); + if (task->tRadius == 0) { SetVBlankCallback(NULL); DmaStop(0); @@ -1580,357 +1713,382 @@ static bool8 Phase2_BigPokeball_Func6(struct Task *task) } else { - if (task->tData3 == 0) + if (!task->tVBlankSet) { - task->tData3++; - SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); + task->tVBlankSet++; + SetVBlankCallback(VBlankCB_CircularMask); } - - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; } - return FALSE; } -static void Transition_BigPokeball_Vblank(void) +static void VBlankCB_SetWinAndBlend(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + REG_BLDCNT = sTransitionData->BLDCNT; + REG_BLDALPHA = sTransitionData->BLDALPHA; } -static void VBlankCB0_Phase2_BigPokeball(void) +static void VBlankCB_PatternWeave(void) { - Transition_BigPokeball_Vblank(); - DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, 0xA2400001); + VBlankCB_SetWinAndBlend(); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, B_TRANS_DMA_FLAGS); } -static void VBlankCB1_Phase2_BigPokeball(void) +static void VBlankCB_CircularMask(void) { - Transition_BigPokeball_Vblank(); - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); + VBlankCB_SetWinAndBlend(); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } -static void Phase2Task_PokeballsTrail(u8 taskId) +#undef tAmplitude +#undef tSinIndex +#undef tBlendTarget1 +#undef tBlendTarget2 +#undef tRadius +#undef tRadiusDelta +#undef tVBlankSet + +//------------------------------ +// B_TRANSITION_POKEBALLS_TRAIL +//------------------------------ + +#define sSide data[0] +#define sDelay data[1] +#define sPrevX data[2] + +static void Task_PokeballsTrail(u8 taskId) { - while (sPhase2_PokeballsTrail_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sPokeballsTrail_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_PokeballsTrail_Func1(struct Task *task) +static bool8 PokeballsTrail_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); CpuSet(sPokeballTrail_Tileset, tileset, 0x20); - CpuFill32(0, tilemap, 0x800); - LoadPalette(sFieldEffectPal_Pokeball, 0xF0, 0x20); + CpuFill32(0, tilemap, BG_SCREEN_SIZE); + LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->tState++; return FALSE; } -static bool8 Phase2_PokeballsTrail_Func2(struct Task *task) +static bool8 PokeballsTrail_Main(struct Task *task) { s16 i; - s16 rand; - s16 arr0[ARRAY_COUNT(sUnknown_085C8B88)]; - s16 arr1[ARRAY_COUNT(sUnknown_085C8B8C)]; - - memcpy(arr0, sUnknown_085C8B88, sizeof(sUnknown_085C8B88)); - memcpy(arr1, sUnknown_085C8B8C, sizeof(sUnknown_085C8B8C)); - rand = Random() & 1; - for (i = 0; i <= 4; i++, rand ^= 1) + s16 side; + s16 startX[ARRAY_COUNT(sPokeballsTrail_StartXCoords)]; + s16 delays[ARRAY_COUNT(sPokeballsTrail_Delays)]; + memcpy(startX, sPokeballsTrail_StartXCoords, sizeof(sPokeballsTrail_StartXCoords)); + memcpy(delays, sPokeballsTrail_Delays, sizeof(sPokeballsTrail_Delays)); + + // Randomly pick which side the first ball should start on. + // The side is then flipped for each subsequent ball. + side = Random() & 1; + for (i = 0; i < NUM_POKEBALL_TRAILS; i++, side ^= 1) { - gFieldEffectArguments[0] = arr0[rand]; // x - gFieldEffectArguments[1] = (i * 32) + 16; // y - gFieldEffectArguments[2] = rand; - gFieldEffectArguments[3] = arr1[i]; - FieldEffectStart(FLDEFF_POKEBALL); + gFieldEffectArguments[0] = startX[side]; // x + gFieldEffectArguments[1] = (i * 32) + 16; // y + gFieldEffectArguments[2] = side; + gFieldEffectArguments[3] = delays[i]; + FieldEffectStart(FLDEFF_POKEBALL_TRAIL); } task->tState++; return FALSE; } -static bool8 Phase2_PokeballsTrail_Func3(struct Task *task) +static bool8 PokeballsTrail_End(struct Task *task) { - if (!FieldEffectActiveListContains(FLDEFF_POKEBALL)) + if (!FieldEffectActiveListContains(FLDEFF_POKEBALL_TRAIL)) { FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_PokeballsTrail)); + DestroyTask(FindTaskIdByFunc(Task_PokeballsTrail)); } return FALSE; } -bool8 FldEff_Pokeball(void) +bool8 FldEff_PokeballTrail(void) { u8 spriteId = CreateSpriteAtEnd(&sSpriteTemplate_Pokeball, gFieldEffectArguments[0], gFieldEffectArguments[1], 0); gSprites[spriteId].oam.priority = 0; gSprites[spriteId].oam.affineMode = ST_OAM_AFFINE_NORMAL; - gSprites[spriteId].data[0] = gFieldEffectArguments[2]; - gSprites[spriteId].data[1] = gFieldEffectArguments[3]; - gSprites[spriteId].data[2] = -1; + gSprites[spriteId].sSide = gFieldEffectArguments[2]; + gSprites[spriteId].sDelay = gFieldEffectArguments[3]; + gSprites[spriteId].sPrevX = -1; InitSpriteAffineAnim(&gSprites[spriteId]); StartSpriteAffineAnim(&gSprites[spriteId], gFieldEffectArguments[2]); return FALSE; } -static void sub_814713C(struct Sprite *sprite) +static void SpriteCB_FldEffPokeballTrail(struct Sprite *sprite) { - s16 arr0[ARRAY_COUNT(sUnknown_085C8B96)]; + s16 speeds[ARRAY_COUNT(sPokeballsTrail_Speeds)]; + memcpy(speeds, sPokeballsTrail_Speeds, sizeof(sPokeballsTrail_Speeds)); - memcpy(arr0, sUnknown_085C8B96, sizeof(sUnknown_085C8B96)); - if (sprite->data[1] != 0) + if (sprite->sDelay != 0) { - sprite->data[1]--; + sprite->sDelay--; } else { if (sprite->x >= 0 && sprite->x <= DISPLAY_WIDTH) { + // Set Pokéball position s16 posX = sprite->x >> 3; s16 posY = sprite->y >> 3; - if (posX != sprite->data[2]) + // If Pokéball moved forward clear trail behind it + if (posX != sprite->sPrevX) { u32 var; u16 *ptr; - sprite->data[2] = posX; - var = (((REG_BG0CNT >> 8) & 0x1F) << 11); - ptr = (u16 *)(VRAM + var); + sprite->sPrevX = posX; + var = ((REG_BG0CNT >> 8) & 0x1F) << 11; + ptr = (u16 *)(BG_VRAM + var); - SOME_VRAM_STORE(ptr, posY - 2, posX, 0xF001); - SOME_VRAM_STORE(ptr, posY - 1, posX, 0xF001); - SOME_VRAM_STORE(ptr, posY - 0, posX, 0xF001); - SOME_VRAM_STORE(ptr, posY + 1, posX, 0xF001); + SET_TILE(ptr, posY - 2, posX, 1); + SET_TILE(ptr, posY - 1, posX, 1); + SET_TILE(ptr, posY - 0, posX, 1); + SET_TILE(ptr, posY + 1, posX, 1); } } - sprite->x += arr0[sprite->data[0]]; - if (sprite->x < -15 || sprite->x > 255) - FieldEffectStop(sprite, FLDEFF_POKEBALL); + sprite->x += speeds[sprite->sSide]; + if (sprite->x < -15 || sprite->x > DISPLAY_WIDTH + 15) + FieldEffectStop(sprite, FLDEFF_POKEBALL_TRAIL); } } -static void Phase2Task_Clockwise_BlackFade(u8 taskId) +#undef sSide +#undef sDelay +#undef sPrevX + +//----------------------------- +// B_TRANSITION_CLOCKWISE_WIPE +//----------------------------- + +static void Task_ClockwiseWipe(u8 taskId) { - while (sPhase2_Clockwise_BlackFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sClockwiseWipe_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Clockwise_BlackFade_Func1(struct Task *task) +static bool8 ClockwiseWipe_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = 0; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_ALL; - sTransitionStructPtr->WIN0H = -3855; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = 0; + sTransitionData->WINOUT = WINOUT_WIN01_ALL; + sTransitionData->WIN0H = WIN_RANGE(DISPLAY_WIDTH, DISPLAY_WIDTH + 1); + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = 0xF3F4; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = ((DISPLAY_WIDTH + 3) << 8) | (DISPLAY_WIDTH + 4); - SetVBlankCallback(VBlankCB_Phase2_Clockwise_BlackFade); - sTransitionStructPtr->data[4] = 120; + SetVBlankCallback(VBlankCB_ClockwiseWipe); + sTransitionData->tWipeEndX = DISPLAY_WIDTH / 2; task->tState++; return TRUE; } -static bool8 Phase2_Clockwise_BlackFade_Func2(struct Task *task) +static bool8 ClockwiseWipe_TopRight(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], -1, 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sTransitionData->tWipeEndX, -1, 1, 1); do { - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] + 1) | 0x7800; - } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = (sTransitionData->tWipeCurrX + 1) | ((DISPLAY_WIDTH / 2) << 8); + } while (!UpdateBlackWipe(sTransitionData->data, TRUE, TRUE)); - sTransitionStructPtr->data[4] += 16; - if (sTransitionStructPtr->data[4] >= 240) + sTransitionData->tWipeEndX += 16; + if (sTransitionData->tWipeEndX >= DISPLAY_WIDTH) { - sTransitionStructPtr->data[5] = 0; + sTransitionData->tWipeEndY = 0; task->tState++; } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func3(struct Task *task) +static bool8 ClockwiseWipe_Right(struct Task *task) { - s16 r1, r3; - vu8 var = 0; + s16 start, end; + vu8 finished = FALSE; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, 240, sTransitionStructPtr->data[5], 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, DISPLAY_WIDTH, sTransitionData->tWipeEndY, 1, 1); while (1) { - r1 = 120, r3 = sTransitionStructPtr->data[2] + 1; - if (sTransitionStructPtr->data[5] >= 80) - r1 = sTransitionStructPtr->data[2], r3 = 240; - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r3) | (r1 << 8); - if (var != 0) + start = DISPLAY_WIDTH / 2, end = sTransitionData->tWipeCurrX + 1; + if (sTransitionData->tWipeEndY >= DISPLAY_HEIGHT / 2) + start = sTransitionData->tWipeCurrX, end = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = end | (start << 8); + if (finished) break; - var = sub_814A228(sTransitionStructPtr->data, 1, 1); + finished = UpdateBlackWipe(sTransitionData->data, TRUE, TRUE); } - sTransitionStructPtr->data[5] += 8; - if (sTransitionStructPtr->data[5] >= 160) + sTransitionData->tWipeEndY += 8; + if (sTransitionData->tWipeEndY >= DISPLAY_HEIGHT) { - sTransitionStructPtr->data[4] = 240; + sTransitionData->tWipeEndX = DISPLAY_WIDTH; task->tState++; } else { - while (sTransitionStructPtr->data[3] < sTransitionStructPtr->data[5]) - { - gScanlineEffectRegBuffers[0][++sTransitionStructPtr->data[3]] = (r3) | (r1 << 8); - } + while (sTransitionData->tWipeCurrY < sTransitionData->tWipeEndY) + gScanlineEffectRegBuffers[0][++sTransitionData->tWipeCurrY] = end | (start << 8); } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func4(struct Task *task) +static bool8 ClockwiseWipe_Bottom(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], 160, 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sTransitionData->tWipeEndX, DISPLAY_HEIGHT, 1, 1); do { - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (sTransitionStructPtr->data[2] << 8) | 0xF0; - } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = (sTransitionData->tWipeCurrX << 8) | DISPLAY_WIDTH; + } while (!UpdateBlackWipe(sTransitionData->data, TRUE, TRUE)); - sTransitionStructPtr->data[4] -= 16; - if (sTransitionStructPtr->data[4] <= 0) + sTransitionData->tWipeEndX -= 16; + if (sTransitionData->tWipeEndX <= 0) { - sTransitionStructPtr->data[5] = 160; + sTransitionData->tWipeEndY = DISPLAY_HEIGHT; task->tState++; } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func5(struct Task *task) +static bool8 ClockwiseWipe_Left(struct Task *task) { - s16 r1, r2, var4; - vu8 var = 0; + s16 end, start, temp; + vu8 finished = FALSE; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, 0, sTransitionStructPtr->data[5], 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, 0, sTransitionData->tWipeEndY, 1, 1); while (1) { - r1 = (gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]]) & 0xFF; - r2 = sTransitionStructPtr->data[2]; - if (sTransitionStructPtr->data[5] <= 80) - r2 = 120, r1 = sTransitionStructPtr->data[2]; - var4 = (r1) | (r2 << 8); - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = var4; - if (var != 0) + end = (gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY]) & 0xFF; + start = sTransitionData->tWipeCurrX; + if (sTransitionData->tWipeEndY <= DISPLAY_HEIGHT / 2) + start = DISPLAY_WIDTH / 2, end = sTransitionData->tWipeCurrX; + temp = end | (start << 8); + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = temp; + if (finished) break; - var = sub_814A228(sTransitionStructPtr->data, 1, 1); + finished = UpdateBlackWipe(sTransitionData->data, TRUE, TRUE); } - sTransitionStructPtr->data[5] -= 8; - if (sTransitionStructPtr->data[5] <= 0) + sTransitionData->tWipeEndY -= 8; + if (sTransitionData->tWipeEndY <= 0) { - sTransitionStructPtr->data[4] = 0; + sTransitionData->tWipeEndX = 0; task->tState++; } else { - while (sTransitionStructPtr->data[3] > sTransitionStructPtr->data[5]) - { - gScanlineEffectRegBuffers[0][--sTransitionStructPtr->data[3]] = (r1) | (r2 << 8); - } + while (sTransitionData->tWipeCurrY > sTransitionData->tWipeEndY) + gScanlineEffectRegBuffers[0][--sTransitionData->tWipeCurrY] = end | (start << 8); } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func6(struct Task *task) +static bool8 ClockwiseWipe_TopLeft(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - sub_814A1AC(sTransitionStructPtr->data, 120, 80, sTransitionStructPtr->data[4], 0, 1, 1); + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sTransitionData->tWipeEndX, 0, 1, 1); do { - s16 r2, r3; - - r2 = 120, r3 = sTransitionStructPtr->data[2]; - if (sTransitionStructPtr->data[2] >= 120) - r2 = 0, r3 = 240; - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r3) | (r2 << 8); - - } while (!sub_814A228(sTransitionStructPtr->data, 1, 1)); - - sTransitionStructPtr->data[4] += 16; - if (sTransitionStructPtr->data[2] > 120) + s16 start, end; + start = DISPLAY_WIDTH / 2, end = sTransitionData->tWipeCurrX; + if (sTransitionData->tWipeCurrX >= DISPLAY_WIDTH / 2) + start = 0, end = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = end | (start << 8); + } while (!UpdateBlackWipe(sTransitionData->data, TRUE, TRUE)); + + sTransitionData->tWipeEndX += 16; + if (sTransitionData->tWipeCurrX > DISPLAY_WIDTH / 2) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Clockwise_BlackFade_Func7(struct Task *task) +static bool8 ClockwiseWipe_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_Clockwise_BlackFade)); + DestroyTask(FindTaskIdByFunc(Task_ClockwiseWipe)); return FALSE; } -static void VBlankCB_Phase2_Clockwise_BlackFade(void) +static void VBlankCB_ClockwiseWipe(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; + if (sTransitionData->VBlank_DMA != 0) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; REG_WIN0H = gScanlineEffectRegBuffers[1][0]; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } -static void Phase2Task_Ripple(u8 taskId) +//--------------------- +// B_TRANSITION_RIPPLE +//--------------------- + +#define tSinVal data[1] +#define tAmplitudeVal data[2] +#define tTimer data[3] +#define tFadeStarted data[4] + +static void Task_Ripple(u8 taskId) { - while (sPhase2_Ripple_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRipple_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Ripple_Func1(struct Task *task) +static bool8 Ripple_Init(struct Task *task) { u8 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = sTransitionData->cameraY; - SetVBlankCallback(VBlankCB_Phase2_Ripple); - SetHBlankCallback(HBlankCB_Phase2_Ripple); + SetVBlankCallback(VBlankCB_Ripple); + SetHBlankCallback(HBlankCB_Ripple); EnableInterrupts(INTR_FLAG_HBLANK); @@ -1938,48 +2096,48 @@ static bool8 Phase2_Ripple_Func1(struct Task *task) return TRUE; } -static bool8 Phase2_Ripple_Func2(struct Task *task) +static bool8 Ripple_Main(struct Task *task) { u8 i; - s16 r3; - u16 r4, r8; + s16 amplitude; + u16 sinVal, speed; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - r3 = task->tData2 >> 8; - r4 = task->tData1; - r8 = 384; - task->tData1 += 0x400; - if (task->tData2 <= 0x1FFF) - task->tData2 += 0x180; + amplitude = task->tAmplitudeVal >> 8; + sinVal = task->tSinVal; + speed = 0x180; + task->tSinVal += 0x400; + if (task->tAmplitudeVal <= 0x1FFF) + task->tAmplitudeVal += 0x180; - for (i = 0; i < 160; i++, r4 += r8) + for (i = 0; i < DISPLAY_HEIGHT; i++, sinVal += speed) { - s16 var = r4 >> 8; - gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var & 0xffff, r3); + s16 sinIndex = sinVal >> 8; + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(sinIndex & 0xffff, amplitude); } - if (++task->tData3 == 81) + if (++task->tTimer == 81) { - task->tData4++; - BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 0x10, RGB_BLACK); + task->tFadeStarted++; + BeginNormalPaletteFade(PALETTES_ALL, -2, 0, 16, RGB_BLACK); } - if (task->tData4 != 0 && !gPaletteFade.active) - DestroyTask(FindTaskIdByFunc(Phase2Task_Ripple)); + if (task->tFadeStarted && !gPaletteFade.active) + DestroyTask(FindTaskIdByFunc(Task_Ripple)); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static void VBlankCB_Phase2_Ripple(void) +static void VBlankCB_Ripple(void) { VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); } -static void HBlankCB_Phase2_Ripple(void) +static void HBlankCB_Ripple(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1VOFS = var; @@ -1987,146 +2145,181 @@ static void HBlankCB_Phase2_Ripple(void) REG_BG3VOFS = var; } -static void Phase2Task_Wave(u8 taskId) +#undef tSinVal +#undef tAmplitudeVal +#undef tTimer +#undef tFadeStarted + +//------------------- +// B_TRANSITION_WAVE +//------------------- + +#define tX data[1] +#define tSinIndex data[2] + +static void Task_Wave(u8 taskId) { - while (sPhase2_Wave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Wave_Func1(struct Task *task) +static bool8 Wave_Init(struct Task *task) { u8 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = 242; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = DISPLAY_WIDTH + 2; - SetVBlankCallback(VBlankCB_Phase2_Wave); + SetVBlankCallback(VBlankCB_Wave); task->tState++; return TRUE; } -static bool8 Phase2_Wave_Func2(struct Task *task) +static bool8 Wave_Main(struct Task *task) { - u8 i, r5; + u8 i, sinIndex; u16* toStore; - bool8 nextFunc; + bool8 finished; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; toStore = gScanlineEffectRegBuffers[0]; - r5 = task->tData2; - task->tData2 += 16; - task->tData1 += 8; + sinIndex = task->tSinIndex; + task->tSinIndex += 16; + task->tX += 8; - for (i = 0, nextFunc = TRUE; i < 160; i++, r5 += 4, toStore++) + for (i = 0, finished = TRUE; i < DISPLAY_HEIGHT; i++, sinIndex += 4, toStore++) { - s16 value = task->tData1 + Sin(r5, 40); - if (value < 0) - value = 0; - if (value > 240) - value = 240; - *toStore = (value << 8) | (0xF1); - if (value < 240) - nextFunc = FALSE; + s16 x = task->tX + Sin(sinIndex, 40); + if (x < 0) + x = 0; + if (x > DISPLAY_WIDTH) + x = DISPLAY_WIDTH; + *toStore = (x << 8) | (DISPLAY_WIDTH + 1); + if (x < DISPLAY_WIDTH) + finished = FALSE; } - if (nextFunc) + if (finished) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Wave_Func3(struct Task *task) +static bool8 Wave_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_Wave)); + DestroyTask(FindTaskIdByFunc(Task_Wave)); return FALSE; } -static void VBlankCB_Phase2_Wave(void) +static void VBlankCB_Wave(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); -} + if (sTransitionData->VBlank_DMA != 0) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); +} + +#undef tX +#undef tSinIndex + +//---------------------------------------------------------------- +// B_TRANSITION_SIDNEY, B_TRANSITION_PHOEBE, B_TRANSITION_GLACIA, +// B_TRANSITION_DRAKE, and B_TRANSITION_CHAMPION +// +// These are all the "mugshot" transitions, where a banner shows +// the trainer pic of the player and their opponent. +//---------------------------------------------------------------- + +#define tSinIndex data[1] +#define tTopBannerX data[2] +#define tBottomBannerX data[3] +#define tTimer data[3] // Re-used +#define tFadeSpread data[4] +#define tOpponentSpriteId data[13] +#define tPlayerSpriteId data[14] +#define tMugshotId data[15] -static void Phase2Task_Sidney(u8 taskId) +// Sprite data for trainer sprites in mugshots +#define sState data[0] +#define sSlideSpeed data[1] +#define sSlideAccel data[2] +#define sDone data[6] +#define sSlideDir data[7] + +static void Task_Sidney(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_SIDNEY; - Phase2Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } -static void Phase2Task_Phoebe(u8 taskId) +static void Task_Phoebe(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_PHOEBE; - Phase2Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } -static void Phase2Task_Glacia(u8 taskId) +static void Task_Glacia(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_GLACIA; - Phase2Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } -static void Phase2Task_Drake(u8 taskId) +static void Task_Drake(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_DRAKE; - Phase2Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } -static void Phase2Task_Champion(u8 taskId) +static void Task_Champion(u8 taskId) { gTasks[taskId].tMugshotId = MUGSHOT_CHAMPION; - Phase2Task_MugShotTransition(taskId); + DoMugshotTransition(taskId); } -static void Phase2Task_MugShotTransition(u8 taskId) +static void DoMugshotTransition(u8 taskId) { - while (sPhase2_Mugshot_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sMugshot_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Mugshot_Func1(struct Task *task) +static bool8 Mugshot_Init(struct Task *task) { u8 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - Mugshots_CreateOpponentPlayerSprites(task); + Mugshots_CreateTrainerPics(task); - task->tData1 = 0; - task->tData2 = 1; - task->tData3 = 239; - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + task->tSinIndex = 0; + task->tTopBannerX = 1; + task->tBottomBannerX = DISPLAY_WIDTH - 1; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = WINOUT_WIN01_BG1 | WINOUT_WIN01_BG2 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ | WINOUT_WIN01_CLR; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = 0xF0F1; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = (DISPLAY_WIDTH << 8) | (DISPLAY_WIDTH + 1); - SetVBlankCallback(VBlankCB0_Phase2_Mugshots); + SetVBlankCallback(VBlankCB_Mugshots); task->tState++; return FALSE; } -static bool8 Phase2_Mugshot_Func2(struct Task *task) +static bool8 Mugshot_SetGfx(struct Task *task) { s16 i, j; u16 *tilemap, *tileset; @@ -2141,99 +2334,108 @@ static bool8 Phase2_Mugshot_Func2(struct Task *task) for (i = 0; i < 20; i++) { for (j = 0; j < 32; j++, mugshotsMap++) - { - SOME_VRAM_STORE(tilemap, i, j, *mugshotsMap | 0xF000); - } + SET_TILE(tilemap, i, j, *mugshotsMap); } EnableInterrupts(INTR_FLAG_HBLANK); - SetHBlankCallback(HBlankCB_Phase2_Mugshots); + SetHBlankCallback(HBlankCB_Mugshots); task->tState++; return FALSE; } -static bool8 Phase2_Mugshot_Func3(struct Task *task) +static bool8 Mugshot_ShowBanner(struct Task *task) { - u8 i, r5; + u8 i, sinIndex; u16* toStore; - s16 value; + s16 x; s32 mergedValue; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; toStore = gScanlineEffectRegBuffers[0]; - r5 = task->tData1; - task->tData1 += 0x10; + sinIndex = task->tSinIndex; + task->tSinIndex += 16; - for (i = 0; i < 80; i++, toStore++, r5 += 0x10) + // Update top banner + for (i = 0; i < DISPLAY_HEIGHT / 2; i++, toStore++, sinIndex += 16) { - value = task->tData2 + Sin(r5, 0x10); - if (value < 0) - value = 1; - if (value > 0xF0) - value = 0xF0; - *toStore = value; + x = task->tTopBannerX + Sin(sinIndex, 16); + if (x < 0) + x = 1; + if (x > DISPLAY_WIDTH) + x = DISPLAY_WIDTH; + *toStore = x; } - for (; i < 160; i++, toStore++, r5 += 0x10) + + // Update bottom banner + for (; i < DISPLAY_HEIGHT; i++, toStore++, sinIndex += 16) { - value = task->tData3 - Sin(r5, 0x10); - if (value < 0) - value = 0; - if (value > 0xEF) - value = 0xEF; - *toStore = (value << 8) | (0xF0); + x = task->tBottomBannerX - Sin(sinIndex, 16); + if (x < 0) + x = 0; + if (x > DISPLAY_WIDTH - 1) + x = DISPLAY_WIDTH - 1; + *toStore = (x << 8) | DISPLAY_WIDTH; } - task->tData2 += 8; - task->tData3 -= 8; - if (task->tData2 > 0xF0) - task->tData2 = 0xF0; - if (task->tData3 < 0) - task->tData3 = 0; - mergedValue = *(s32*)(&task->tData2); - if (mergedValue == 0xF0) + // Slide banners across screen + task->tTopBannerX += 8; + task->tBottomBannerX -= 8; + + if (task->tTopBannerX > DISPLAY_WIDTH) + task->tTopBannerX = DISPLAY_WIDTH; + if (task->tBottomBannerX < 0) + task->tBottomBannerX = 0; + + mergedValue = *(s32*)(&task->tTopBannerX); + if (mergedValue == DISPLAY_WIDTH) task->tState++; - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Mugshot_Func4(struct Task *task) +static bool8 Mugshot_StartOpponentSlide(struct Task *task) { u8 i; u16* toStore; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - for (i = 0, toStore = gScanlineEffectRegBuffers[0]; i < 160; i++, toStore++) - { - *toStore = 0xF0; - } + for (i = 0, toStore = gScanlineEffectRegBuffers[0]; i < DISPLAY_HEIGHT; i++, toStore++) + *toStore = DISPLAY_WIDTH; task->tState++; - task->tData1 = 0; - task->tData2 = 0; - task->tData3 = 0; - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; - - SetTrainerPicSlideTable(task->tOpponentSpriteId, 0); - SetTrainerPicSlideTable(task->tPlayerSpriteId, 1); + + // Clear old data + task->tSinIndex = 0; + task->tTopBannerX = 0; + task->tBottomBannerX = 0; + + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; + + SetTrainerPicSlideDirection(task->tOpponentSpriteId, 0); + SetTrainerPicSlideDirection(task->tPlayerSpriteId, 1); + + // Start opponent slide IncrementTrainerPicState(task->tOpponentSpriteId); PlaySE(SE_MUGSHOT); - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Mugshot_Func5(struct Task *task) +static bool8 Mugshot_WaitStartPlayerSlide(struct Task *task) { - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; + + // Start player's slide in once the opponent is finished if (IsTrainerPicSlideDone(task->tOpponentSpriteId)) { task->tState++; @@ -2242,94 +2444,99 @@ static bool8 Phase2_Mugshot_Func5(struct Task *task) return FALSE; } -static bool8 Phase2_Mugshot_Func6(struct Task *task) +static bool8 Mugshot_WaitPlayerSlide(struct Task *task) { - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; + if (IsTrainerPicSlideDone(task->tPlayerSpriteId)) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; SetVBlankCallback(NULL); DmaStop(0); - memset(gScanlineEffectRegBuffers[0], 0, 0x140); - memset(gScanlineEffectRegBuffers[1], 0, 0x140); + memset(gScanlineEffectRegBuffers[0], 0, DISPLAY_HEIGHT * 2); + memset(gScanlineEffectRegBuffers[1], 0, DISPLAY_HEIGHT * 2); SetGpuReg(REG_OFFSET_WIN0H, DISPLAY_WIDTH); SetGpuReg(REG_OFFSET_BLDY, 0); task->tState++; - task->tData3 = 0; - task->tData4 = 0; - sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; - SetVBlankCallback(VBlankCB1_Phase2_Mugshots); + task->tTimer = 0; + task->tFadeSpread = 0; + sTransitionData->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; + SetVBlankCallback(VBlankCB_MugshotsFadeOut); } return FALSE; } -static bool8 Phase2_Mugshot_Func7(struct Task *task) +static bool8 Mugshot_GradualWhiteFade(struct Task *task) { - bool32 r6; + bool32 active; - sTransitionStructPtr->VBlank_DMA = FALSE; - r6 = TRUE; - sTransitionStructPtr->BG0HOFS_1 -= 8; - sTransitionStructPtr->BG0HOFS_2 += 8; + sTransitionData->VBlank_DMA = FALSE; + active = TRUE; + sTransitionData->BG0HOFS_Lower -= 8; + sTransitionData->BG0HOFS_Upper += 8; - if (task->tData4 < 0x50) - task->tData4 += 2; - if (task->tData4 > 0x50) - task->tData4 = 0x50; + if (task->tFadeSpread < DISPLAY_HEIGHT / 2) + task->tFadeSpread += 2; + if (task->tFadeSpread > DISPLAY_HEIGHT / 2) + task->tFadeSpread = DISPLAY_HEIGHT / 2; - if (++task->tData3 & 1) + if (++task->tTimer & 1) { s16 i; - for (i = 0, r6 = FALSE; i <= task->tData4; i++) + for (i = 0, active = FALSE; i <= task->tFadeSpread; i++) { - s16 index1 = 0x50 - i; - s16 index2 = 0x50 + i; + // Fade starts in middle of screen and + // spreads outwards in both directions. + s16 index1 = DISPLAY_HEIGHT / 2 - i; + s16 index2 = DISPLAY_HEIGHT / 2 + i; if (gScanlineEffectRegBuffers[0][index1] <= 15) { - r6 = TRUE; + active = TRUE; gScanlineEffectRegBuffers[0][index1]++; } if (gScanlineEffectRegBuffers[0][index2] <= 15) { - r6 = TRUE; + active = TRUE; gScanlineEffectRegBuffers[0][index2]++; } } } - if (task->tData4 == 0x50 && !r6) + if (task->tFadeSpread == DISPLAY_HEIGHT / 2 && !active) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Mugshot_Func8(struct Task *task) +// Set palette to white to replace the scanline white fade +// before the screen fades to black. +static bool8 Mugshot_InitFadeWhiteToBlack(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - BlendPalettes(PALETTES_ALL, 0x10, RGB_WHITE); - sTransitionStructPtr->BLDCNT = 0xFF; - task->tData3 = 0; + sTransitionData->VBlank_DMA = FALSE; + BlendPalettes(PALETTES_ALL, 16, RGB_WHITE); + sTransitionData->BLDCNT = 0xFF; + task->tTimer = 0; task->tState++; return TRUE; } -static bool8 Phase2_Mugshot_Func9(struct Task *task) +static bool8 Mugshot_FadeToBlack(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - task->tData3++; - memset(gScanlineEffectRegBuffers[0], task->tData3, 0x140); - if (task->tData3 > 15) + task->tTimer++; + memset(gScanlineEffectRegBuffers[0], task->tTimer, DISPLAY_HEIGHT * 2); + if (task->tTimer > 15) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Mugshot_Func10(struct Task *task) +static bool8 Mugshot_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -2337,60 +2544,56 @@ static bool8 Phase2_Mugshot_Func10(struct Task *task) return FALSE; } -static void VBlankCB0_Phase2_Mugshots(void) +static void VBlankCB_Mugshots(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_BG0VOFS = sTransitionStructPtr->BG0VOFS; - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); + if (sTransitionData->VBlank_DMA != 0) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_BG0VOFS = sTransitionData->BG0VOFS; + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); } -static void VBlankCB1_Phase2_Mugshots(void) +static void VBlankCB_MugshotsFadeOut(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA != 0) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_BLDY, 0xA2400001); + if (sTransitionData->VBlank_DMA != 0) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_BLDCNT = sTransitionData->BLDCNT; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_BLDY, B_TRANS_DMA_FLAGS); } -static void HBlankCB_Phase2_Mugshots(void) +static void HBlankCB_Mugshots(void) { - if (REG_VCOUNT < 80) - REG_BG0HOFS = sTransitionStructPtr->BG0HOFS_1; + if (REG_VCOUNT < DISPLAY_HEIGHT / 2) + REG_BG0HOFS = sTransitionData->BG0HOFS_Lower; else - REG_BG0HOFS = sTransitionStructPtr->BG0HOFS_2; + REG_BG0HOFS = sTransitionData->BG0HOFS_Upper; } -// data fields for player/opponent sprites in mugshots -#define sState data[0] -#define sOffsetX data[1] -#define sOffsetX2 data[2] -#define sDone data[6] -#define sSlideTableId data[7] - -static void Mugshots_CreateOpponentPlayerSprites(struct Task *task) +static void Mugshots_CreateTrainerPics(struct Task *task) { struct Sprite *opponentSprite, *playerSprite; s16 mugshotId = task->tMugshotId; task->tOpponentSpriteId = CreateTrainerSprite(sMugshotsTrainerPicIDsTable[mugshotId], - sMugshotsOpponentCoords[mugshotId][0] - 32, - sMugshotsOpponentCoords[mugshotId][1] + 42, - 0, gDecompressionBuffer); - task->tPlayerSpriteId = CreateTrainerSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), DISPLAY_WIDTH + 32, 106, 0, gDecompressionBuffer); + sMugshotsOpponentCoords[mugshotId][0] - 32, + sMugshotsOpponentCoords[mugshotId][1] + 42, + 0, gDecompressionBuffer); + task->tPlayerSpriteId = CreateTrainerSprite(PlayerGenderToFrontTrainerPicId(gSaveBlock2Ptr->playerGender), + DISPLAY_WIDTH + 32, + 106, + 0, gDecompressionBuffer); opponentSprite = &gSprites[task->tOpponentSpriteId]; playerSprite = &gSprites[task->tPlayerSpriteId]; - opponentSprite->callback = SpriteCb_TrainerPic; - playerSprite->callback = SpriteCb_TrainerPic; + opponentSprite->callback = SpriteCB_MugshotTrainerPic; + playerSprite->callback = SpriteCB_MugshotTrainerPic; opponentSprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE; playerSprite->oam.affineMode = ST_OAM_AFFINE_DOUBLE; @@ -2411,68 +2614,75 @@ static void Mugshots_CreateOpponentPlayerSprites(struct Task *task) SetOamMatrixRotationScaling(playerSprite->oam.matrixNum, -512, 512, 0); } -static void SpriteCb_TrainerPic(struct Sprite *sprite) +static void SpriteCB_MugshotTrainerPic(struct Sprite *sprite) { - while (sTrainerPicSpriteCbs[sprite->sState](sprite)); + while (sMugshotTrainerPicFuncs[sprite->sState](sprite)); } -static bool8 TrainerPicCb_Nothing(struct Sprite *sprite) +// Wait until IncrementTrainerPicState is called +static bool8 MugshotTrainerPic_Pause(struct Sprite *sprite) { return FALSE; } -static bool8 TrainerPicCb_SetSlideOffsets(struct Sprite *sprite) +static bool8 MugshotTrainerPic_Init(struct Sprite *sprite) { - s16 offfsets1[ARRAY_COUNT(sTrainerPicSlideOffsets1)]; - s16 offfsets2[ARRAY_COUNT(sTrainerPicSlideOffsets2)]; + s16 speeds[ARRAY_COUNT(sTrainerPicSlideSpeeds)]; + s16 accels[ARRAY_COUNT(sTrainerPicSlideAccels)]; - memcpy(offfsets1, sTrainerPicSlideOffsets1, sizeof(sTrainerPicSlideOffsets1)); - memcpy(offfsets2, sTrainerPicSlideOffsets2, sizeof(sTrainerPicSlideOffsets2)); + memcpy(speeds, sTrainerPicSlideSpeeds, sizeof(sTrainerPicSlideSpeeds)); + memcpy(accels, sTrainerPicSlideAccels, sizeof(sTrainerPicSlideAccels)); sprite->sState++; - sprite->sOffsetX = offfsets1[sprite->sSlideTableId]; - sprite->sOffsetX2 = offfsets2[sprite->sSlideTableId]; + sprite->sSlideSpeed = speeds[sprite->sSlideDir]; + sprite->sSlideAccel = accels[sprite->sSlideDir]; return TRUE; } -// fast slide to around middle screen -static bool8 TrainerPicCb_Slide1(struct Sprite *sprite) +static bool8 MugshotTrainerPic_Slide(struct Sprite *sprite) { - sprite->x += sprite->sOffsetX; - if (sprite->sSlideTableId && sprite->x < 133) + sprite->x += sprite->sSlideSpeed; + + // Advance state when pic passes ~40% of screen + if (sprite->sSlideDir && sprite->x < DISPLAY_WIDTH - 107) sprite->sState++; - else if (!sprite->sSlideTableId && sprite->x > 103) + else if (!sprite->sSlideDir && sprite->x > 103) sprite->sState++; return FALSE; } -// slower but accelerating slide -static bool8 TrainerPicCb_Slide2(struct Sprite *sprite) +static bool8 MugshotTrainerPic_SlideSlow(struct Sprite *sprite) { - sprite->sOffsetX += sprite->sOffsetX2; - sprite->x += sprite->sOffsetX; - if (sprite->sOffsetX == 0) + // Add acceleration value to speed, then add speed. + // For both sides acceleration is opposite speed, so slide slows down. + sprite->sSlideSpeed += sprite->sSlideAccel; + sprite->x += sprite->sSlideSpeed; + + // Advance state when slide comes to a stop + if (sprite->sSlideSpeed == 0) { sprite->sState++; - sprite->sOffsetX2 = -sprite->sOffsetX2; + sprite->sSlideAccel = -sprite->sSlideAccel; sprite->sDone = TRUE; } return FALSE; } -// Has no practical effect -static bool8 TrainerPicCb_Slide3(struct Sprite *sprite) +// Slides trainer pic offscreen. This is never reached, because it's preceded +// by a second MugshotTrainerPic_Pause, and IncrementTrainerPicState is +// only called once per trainer pic. +static bool8 MugshotTrainerPic_SlideOffscreen(struct Sprite *sprite) { - sprite->sOffsetX += sprite->sOffsetX2; - sprite->x += sprite->sOffsetX; - if (sprite->x < -31 || sprite->x > 271) + sprite->sSlideSpeed += sprite->sSlideAccel; + sprite->x += sprite->sSlideSpeed; + if (sprite->x < -31 || sprite->x > DISPLAY_WIDTH + 31) sprite->sState++; return FALSE; } -static void SetTrainerPicSlideTable(s16 spriteId, s16 arrId) +static void SetTrainerPicSlideDirection(s16 spriteId, s16 dirId) { - gSprites[spriteId].sSlideTableId = arrId; + gSprites[spriteId].sSlideDir = dirId; } static void IncrementTrainerPicState(s16 spriteId) @@ -2486,106 +2696,124 @@ static s16 IsTrainerPicSlideDone(s16 spriteId) } #undef sState -#undef sOffsetX -#undef sOffsetX2 +#undef sSlideSpeed +#undef sSlideAccel #undef sDone -#undef sSlideTableId +#undef sSlideDir +#undef tSinIndex +#undef tTopBannerX +#undef tBottomBannerX +#undef tTimer +#undef tFadeSpread +#undef tOpponentSpriteId +#undef tPlayerSpriteId +#undef tMugshotId + +//-------------------- +// B_TRANSITION_SLICE +//-------------------- -static void Phase2Task_Slice(u8 taskId) +#define tEffectX data[1] +#define tSpeed data[2] +#define tAccel data[3] + +static void Task_Slice(u8 taskId) { - while (sPhase2_Slice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sSlice_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Slice_Func1(struct Task *task) +static bool8 Slice_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - task->tData2 = 256; - task->tData3 = 1; - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; - sTransitionStructPtr->VBlank_DMA = FALSE; + task->tSpeed = 1 << 8; + task->tAccel = 1; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0V = DISPLAY_HEIGHT; + sTransitionData->VBlank_DMA = FALSE; - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { - gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_14; - gScanlineEffectRegBuffers[1][160 + i] = 0xF0; + gScanlineEffectRegBuffers[1][i] = sTransitionData->cameraX; + gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT + i] = DISPLAY_WIDTH; } EnableInterrupts(INTR_FLAG_HBLANK); SetGpuRegBits(REG_OFFSET_DISPSTAT, DISPSTAT_HBLANK_INTR); - SetVBlankCallback(VBlankCB_Phase2_Slice); - SetHBlankCallback(HBlankCB_Phase2_Slice); + SetVBlankCallback(VBlankCB_Slice); + SetHBlankCallback(HBlankCB_Slice); task->tState++; return TRUE; } -static bool8 Phase2_Slice_Func2(struct Task *task) +static bool8 Slice_Main(struct Task *task) { u16 i; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - task->tData1 += (task->tData2 >> 8); - if (task->tData1 > 0xF0) - task->tData1 = 0xF0; - if (task->tData2 <= 0xFFF) - task->tData2 += task->tData3; - if (task->tData3 < 128) - task->tData3 <<= 1; // multiplying by two + task->tEffectX += (task->tSpeed >> 8); + if (task->tEffectX > DISPLAY_WIDTH) + task->tEffectX = DISPLAY_WIDTH; + if (task->tSpeed <= 0xFFF) + task->tSpeed += task->tAccel; + if (task->tAccel < 128) + task->tAccel <<= 1; // multiplying by two - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { u16 *storeLoc1 = &gScanlineEffectRegBuffers[0][i]; - u16 *storeLoc2 = &gScanlineEffectRegBuffers[0][i + 160]; - if (i & 1) + u16 *storeLoc2 = &gScanlineEffectRegBuffers[0][i + DISPLAY_HEIGHT]; + + // Alternate rows + if (i % 2) { - *storeLoc1 = sTransitionStructPtr->field_14 + task->tData1; - *storeLoc2 = 0xF0 - task->tData1; + *storeLoc1 = sTransitionData->cameraX + task->tEffectX; + *storeLoc2 = DISPLAY_WIDTH - task->tEffectX; } else { - *storeLoc1 = sTransitionStructPtr->field_14 - task->tData1; - *storeLoc2 = (task->tData1 << 8) | (0xF1); + *storeLoc1 = sTransitionData->cameraX - task->tEffectX; + *storeLoc2 = (task->tEffectX << 8) | (DISPLAY_WIDTH + 1); } } - if (task->tData1 > 0xEF) + if (task->tEffectX >= DISPLAY_WIDTH) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Slice_Func3(struct Task *task) +static bool8 Slice_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_Slice)); + DestroyTask(FindTaskIdByFunc(Task_Slice)); return FALSE; } -static void VBlankCB_Phase2_Slice(void) +static void VBlankCB_Slice(void) { DmaStop(0); VBlankCB_BattleTransition(); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640); - DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 4); + DmaSet(0, &gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT], ®_WIN0H, B_TRANS_DMA_FLAGS); } -static void HBlankCB_Phase2_Slice(void) +static void HBlankCB_Slice(void) { - if (REG_VCOUNT < 160) + if (REG_VCOUNT < DISPLAY_HEIGHT) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1HOFS = var; @@ -2594,77 +2822,92 @@ static void HBlankCB_Phase2_Slice(void) } } -static void Phase2Task_ShredSplit(u8 taskId) +#undef tEffectX +#undef tSpeed +#undef tAccel + +//-------------------------- +// B_TRANSITION_SHRED_SPLIT +//-------------------------- + +// Data starts at 4. Possible it shared data +// with Slice above, which ends at 3. +#define tDelayTimer data[4] +#define tExtent data[5] +#define tDelay data[6] + +static void Task_ShredSplit(u8 taskId) { - while (sPhase2_ShredSplit_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sShredSplit_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_ShredSplit_Func1(struct Task *task) +static bool8 ShredSplit_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 0xA0; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { - gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_14; - gScanlineEffectRegBuffers[1][0xA0 + i] = 0xF0; - gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_14; - gScanlineEffectRegBuffers[0][0xA0 + i] = 0xF0; - gScanlineEffectRegBuffers[0][0x140 + i] = 0; - gScanlineEffectRegBuffers[0][0x1E0 + i] = 0x100; - gScanlineEffectRegBuffers[0][0x280 + i] = 1; + gScanlineEffectRegBuffers[1][i] = sTransitionData->cameraX; + gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT + i] = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraX; + gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT + i] = DISPLAY_WIDTH; + gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT * 2 + i] = 0; + gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT * 3 + i] = 256; + gScanlineEffectRegBuffers[0][DISPLAY_HEIGHT * 4 + i] = 1; } - task->tData4 = 0; - task->tData5 = 0; - task->tData6 = 7; + task->tDelayTimer = 0; + task->tExtent = 0; + task->tDelay = 7; EnableInterrupts(INTR_FLAG_HBLANK); - SetVBlankCallback(VBlankCB_Phase2_Slice); - SetHBlankCallback(HBlankCB_Phase2_Slice); + SetVBlankCallback(VBlankCB_Slice); + SetHBlankCallback(HBlankCB_Slice); task->tState++; return TRUE; } -static bool8 Phase2_ShredSplit_Func2(struct Task *task) +static bool8 ShredSplit_Main(struct Task *task) { u16 i, j, k; - u8 arr1[ARRAY_COUNT(gUnknown_085C8C64)]; - s16 arr2[ARRAY_COUNT(gUnknown_085C8C66)]; - u8 var; + u8 baseY[ARRAY_COUNT(sShredSplit_SectionYCoords)]; + s16 moveDirs[ARRAY_COUNT(sShredSplit_SectionMoveDirs)]; + u8 linesFinished; u16 *ptr4, *ptr3, *ptr1, *ptr2; - s16 unkVar; + s16 y; - memcpy(arr1, gUnknown_085C8C64, sizeof(arr1)); - memcpy(arr2, gUnknown_085C8C66, sizeof(arr2)); + memcpy(baseY, sShredSplit_SectionYCoords, sizeof(baseY)); + memcpy(moveDirs, sShredSplit_SectionMoveDirs, sizeof(moveDirs)); - sTransitionStructPtr->VBlank_DMA = FALSE; - var = 0; + sTransitionData->VBlank_DMA = FALSE; + linesFinished = 0; - for (i = 0; i <= task->tData5; i++) + for (i = 0; i <= task->tExtent; i++) { + // Slide half of the pixel rows (alternating) right for (j = 0; j < 2; j++) { for (k = 0; k < 2; k++) { - unkVar = (arr1[j]) + (arr2[k] * -(i) * 2); - if (unkVar >= 0 && (unkVar != 79 || j != 1)) + y = baseY[j] + (moveDirs[k] * -i * 2); + if (y >= 0 && (y != DISPLAY_HEIGHT / 2 - 1 || j != 1)) { - ptr4 = &gScanlineEffectRegBuffers[0][unkVar + 320]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 480]; - ptr1 = &gScanlineEffectRegBuffers[0][unkVar + 640]; - if (*ptr4 > 0xEF) + ptr4 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 2]; + ptr3 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 3]; + ptr1 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 4]; + if (*ptr4 >= DISPLAY_WIDTH) { - *ptr4 = 0xF0; - var++; + *ptr4 = DISPLAY_WIDTH; + linesFinished++; } else { @@ -2674,10 +2917,10 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) if (*ptr3 <= 0xFFF) *ptr3 += *ptr1; } - ptr2 = &gScanlineEffectRegBuffers[0][unkVar]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 160]; - *ptr2 = sTransitionStructPtr->field_14 + *ptr4; - *ptr3 = 0xF0 - *ptr4; + ptr2 = &gScanlineEffectRegBuffers[0][y]; + ptr3 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT]; + *ptr2 = sTransitionData->cameraX + *ptr4; + *ptr3 = DISPLAY_WIDTH - *ptr4; if (i == 0) break; @@ -2685,20 +2928,21 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) } } + // Slide the other half of the rows left for (j = 0; j < 2; j++) { for (k = 0; k < 2; k++) { - unkVar = (arr1[j] + 1) + (arr2[k] * -(i) * 2); - if (unkVar <= 160 && (unkVar != 80 || j != 1)) + y = baseY[j] + 1 + (moveDirs[k] * -i * 2); + if (y <= DISPLAY_HEIGHT && (y != DISPLAY_HEIGHT / 2 || j != 1)) { - ptr4 = &gScanlineEffectRegBuffers[0][unkVar + 320]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 480]; - ptr1 = &gScanlineEffectRegBuffers[0][unkVar + 640]; - if (*ptr4 > 0xEF) + ptr4 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 2]; + ptr3 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 3]; + ptr1 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT * 4]; + if (*ptr4 >= DISPLAY_WIDTH) { - *ptr4 = 0xF0; - var++; + *ptr4 = DISPLAY_WIDTH; + linesFinished++; } else { @@ -2708,10 +2952,10 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) if (*ptr3 <= 0xFFF) *ptr3 += *ptr1; } - ptr2 = &gScanlineEffectRegBuffers[0][unkVar]; - ptr3 = &gScanlineEffectRegBuffers[0][unkVar + 160]; - *ptr2 = sTransitionStructPtr->field_14 - *ptr4; - *ptr3 = (*ptr4 << 8) | (0xF1); + ptr2 = &gScanlineEffectRegBuffers[0][y]; + ptr3 = &gScanlineEffectRegBuffers[0][y + DISPLAY_HEIGHT]; + *ptr2 = sTransitionData->cameraX - *ptr4; + *ptr3 = (*ptr4 << 8) | (DISPLAY_WIDTH + 1); if (i == 0) break; @@ -2720,14 +2964,22 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) } } - if (--task->tData4 < 0) - task->tData4 = 0; - if (task->tData4 <= 0 && task->tData5 + 1 <= 20) - task->tData4 = task->tData6, task->tData5++; - if (var > 0x9F) + // Count down to next move + if (--task->tDelayTimer < 0) + task->tDelayTimer = 0; + + // Try increase effect's extent + if (task->tDelayTimer <= 0 && task->tExtent + 1 <= DISPLAY_HEIGHT / 8) + { + task->tDelayTimer = task->tDelay; + task->tExtent++; + } + + // All lines have reached screen width, move on. + if (linesFinished >= DISPLAY_HEIGHT) task->tState++; - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } @@ -2735,16 +2987,17 @@ static bool8 Phase2_ShredSplit_Func2(struct Task *task) // is always false, resulting in the game being stuck in an infinite loop. // It's possible this transition is only partially // done and the second part was left out. -static bool8 Phase2_ShredSplit_Func3(struct Task *task) +// In any case removing or bypassing this state allows the transition to finish. +static bool8 ShredSplit_BrokenCheck(struct Task *task) { u16 i; bool32 done = TRUE; u16 checkVar2 = 0xFF10; - for (i = 0; i < 0xA0; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { - if (gScanlineEffectRegBuffers[1][i] != 0xF0 && gScanlineEffectRegBuffers[1][i] != checkVar2) - done = FALSE; // a break statement should be put here + if (gScanlineEffectRegBuffers[1][i] != DISPLAY_WIDTH && gScanlineEffectRegBuffers[1][i] != checkVar2) + done = FALSE; } if (done == TRUE) @@ -2753,54 +3006,68 @@ static bool8 Phase2_ShredSplit_Func3(struct Task *task) return FALSE; } -static bool8 Phase2_ShredSplit_Func4(struct Task *task) +static bool8 ShredSplit_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_ShredSplit)); + DestroyTask(FindTaskIdByFunc(Task_ShredSplit)); return FALSE; } -static void Phase2Task_Blackhole1(u8 taskId) +#undef tDelayTimer +#undef tExtent +#undef tDelay + +//----------------------------------------------------------- +// B_TRANSITION_BLACKHOLE and B_TRANSITION_BLACKHOLE_PULSATE +//----------------------------------------------------------- + +#define tRadius data[1] +#define tGrowSpeed data[2] +#define tSinIndex data[5] +#define tVibrateId data[6] +#define tAmplitude data[6] // Used differently by the two transitions +#define tFlag data[7] // Used generally to indicate an action has taken place. + +static void Task_Blackhole(u8 taskId) { - while (sPhase2_Blackhole1_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBlackhole_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_Blackhole2(u8 taskId) +static void Task_BlackholePulsate(u8 taskId) { - while (sPhase2_Blackhole2_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sBlackholePulsate_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Blackhole_Func1(struct Task *task) +// Init is shared by both transitions +static bool8 Blackhole_Init(struct Task *task) { s32 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = 0; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_ALL; - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = 0; + sTransitionData->WINOUT = WINOUT_WIN01_ALL; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 0xA0; i++) - { + for (i = 0; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[1][i] = 0; - } - SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); + SetVBlankCallback(VBlankCB_CircularMask); task->tState++; - task->tData1 = 1; - task->tData2 = 0x100; - task->tFuncState = 0; + task->tRadius = 1; + task->tGrowSpeed = 1 << 8; + task->tFlag = FALSE; return FALSE; } -static bool8 Phase2_Blackhole1_Func3(struct Task *task) +static bool8 Blackhole_GrowEnd(struct Task *task) { - if (task->tFuncState == 1) + if (task->tFlag == TRUE) { DmaStop(0); SetVBlankCallback(NULL); @@ -2808,141 +3075,161 @@ static bool8 Phase2_Blackhole1_Func3(struct Task *task) } else { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tData2 < 0x400) - task->tData2 += 0x80; - if (task->tData1 < 0xA0) - task->tData1 += (task->tData2 >> 8); - if (task->tData1 > 0xA0) - task->tData1 = 0xA0; - sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); - if (task->tData1 == 0xA0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tGrowSpeed < 1024) + task->tGrowSpeed += 128; + if (task->tRadius < DISPLAY_HEIGHT) + task->tRadius += task->tGrowSpeed >> 8; + if (task->tRadius > DISPLAY_HEIGHT) + task->tRadius = DISPLAY_HEIGHT; + SetCircularMask(gScanlineEffectRegBuffers[0], DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, task->tRadius); + if (task->tRadius == DISPLAY_HEIGHT) { - task->tFuncState = 1; + task->tFlag = TRUE; FadeScreenBlack(); } else { - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; } } return FALSE; } -static bool8 Phase2_Blackhole1_Func2(struct Task *task) +static bool8 Blackhole_Vibrate(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tFuncState == 0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tFlag == FALSE) { - task->tFuncState++; - task->tData1 = 0x30; - task->tData6 = 0; + task->tFlag++; + task->tRadius = 48; + task->tVibrateId = 0; } - task->tData1 += gUnknown_085C8C80[task->tData6]; - task->tData6 = (task->tData6 + 1) % 2; - sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); - if (task->tData1 < 9) + task->tRadius += sBlackhole_Vibrations[task->tVibrateId]; + task->tVibrateId = (task->tVibrateId + 1) % (int)ARRAY_COUNT(sBlackhole_Vibrations); + SetCircularMask(gScanlineEffectRegBuffers[0], DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, task->tRadius); + if (task->tRadius < 9) { task->tState++; - task->tFuncState = 0; + task->tFlag = FALSE; } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Blackhole2_Func2(struct Task *task) +static bool8 BlackholePulsate_Main(struct Task *task) { u16 index; // should be s16 I think s16 amplitude; - sTransitionStructPtr->VBlank_DMA = FALSE; - if (task->tFuncState == 0) + sTransitionData->VBlank_DMA = FALSE; + if (task->tFlag == FALSE) { - task->tFuncState++; - task->tData5 = 2; - task->tData6 = 2; + task->tFlag++; + task->tSinIndex = 2; + task->tAmplitude = 2; } - if (task->tData1 > 0xA0) - task->tData1 = 0xA0; - sub_814A014(gScanlineEffectRegBuffers[0], 0x78, 0x50, task->tData1); - if (task->tData1 == 0xA0) + if (task->tRadius > DISPLAY_HEIGHT) + task->tRadius = DISPLAY_HEIGHT; + + SetCircularMask(gScanlineEffectRegBuffers[0], DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, task->tRadius); + if (task->tRadius == DISPLAY_HEIGHT) { DmaStop(0); FadeScreenBlack(); DestroyTask(FindTaskIdByFunc(task->func)); } - index = task->tData5; - if ((task->tData5 & 0xFF) <= 128) + index = task->tSinIndex; + if ((task->tSinIndex & 0xFF) <= 128) { - amplitude = task->tData6; - task->tData5 += 8; + amplitude = task->tAmplitude; + task->tSinIndex += 8; } else { - amplitude = task->tData6 - 1; - task->tData5 += 16; + amplitude = task->tAmplitude - 1; + task->tSinIndex += 16; } - task->tData1 += Sin(index & 0xFF, amplitude); + task->tRadius += Sin(index & 0xFF, amplitude); - if (task->tData1 <= 0) - task->tData1 = 1; - if (task->tData5 > 0xFE) - task->tData5 >>= 8, task->tData6++; + if (task->tRadius <= 0) + task->tRadius = 1; + + if (task->tSinIndex >= 0xFF) + { + task->tSinIndex >>= 8; + task->tAmplitude++; + } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static void Phase2Task_RectangularSpiral(u8 taskId) +#undef tRadius +#undef tGrowSpeed +#undef tSinIndex +#undef tVibrateId +#undef tAmplitude +#undef tFlag + +//--------------------------------- +// B_TRANSITION_RECTANGULAR_SPIRAL +//--------------------------------- + +static void Task_RectangularSpiral(u8 taskId) { - while (sPhase2_RectangularSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRectangularSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_RectangularSpiral_Func1(struct Task *task) +static bool8 RectangularSpiral_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); CpuCopy16(sShrinkingBoxTileset, tileset, 0x20); - CpuCopy16(sShrinkingBoxTileset + 0x70, tileset + 0x20, 0x20); - CpuFill16(0xF000, tilemap, 0x800); - LoadPalette(sFieldEffectPal_Pokeball, 0xF0, 0x20); + CpuCopy16(&sShrinkingBoxTileset[0x70], &tileset[0x20], 0x20); + CpuFill16(0xF0 << 8, tilemap, BG_SCREEN_SIZE); + LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); - task->tData3 = 1; + task->data[3] = 1; task->tState++; - sRectangularSpiralTransition[0].field_0 = 0; - sRectangularSpiralTransition[0].field_2 = -1; - sRectangularSpiralTransition[0].field_4 = 1; - sRectangularSpiralTransition[0].field_6 = 308; - sRectangularSpiralTransition[0].field_8 = 0; - - sRectangularSpiralTransition[1].field_0 = 0; - sRectangularSpiralTransition[1].field_2 = -1; - sRectangularSpiralTransition[1].field_4 = 1; - sRectangularSpiralTransition[1].field_6 = 308; - sRectangularSpiralTransition[1].field_8 = 0; - - sRectangularSpiralTransition[2].field_0 = 0; - sRectangularSpiralTransition[2].field_2 = -3; - sRectangularSpiralTransition[2].field_4 = 1; - sRectangularSpiralTransition[2].field_6 = 307; - sRectangularSpiralTransition[2].field_8 = 0; - - sRectangularSpiralTransition[3].field_0 = 0; - sRectangularSpiralTransition[3].field_2 = -3; - sRectangularSpiralTransition[3].field_4 = 1; - sRectangularSpiralTransition[3].field_6 = 307; - sRectangularSpiralTransition[3].field_8 = 0; + // Line starting in top left + sRectangularSpiralLines[0].state = SPIRAL_INWARD_START; + sRectangularSpiralLines[0].position = -1; + sRectangularSpiralLines[0].moveIdx = 1; + sRectangularSpiralLines[0].reboundPosition = 308; + sRectangularSpiralLines[0].outward = FALSE; + + // Line starting in bottom right + sRectangularSpiralLines[1].state = SPIRAL_INWARD_START; + sRectangularSpiralLines[1].position = -1; + sRectangularSpiralLines[1].moveIdx = 1; + sRectangularSpiralLines[1].reboundPosition = 308; + sRectangularSpiralLines[1].outward = FALSE; + + // Line starting in top right + sRectangularSpiralLines[2].state = SPIRAL_INWARD_START; + sRectangularSpiralLines[2].position = -3; + sRectangularSpiralLines[2].moveIdx = 1; + sRectangularSpiralLines[2].reboundPosition = 307; + sRectangularSpiralLines[2].outward = FALSE; + + // Line starting in bottom left + sRectangularSpiralLines[3].state = SPIRAL_INWARD_START; + sRectangularSpiralLines[3].position = -3; + sRectangularSpiralLines[3].moveIdx = 1; + sRectangularSpiralLines[3].reboundPosition = 307; + sRectangularSpiralLines[3].outward = FALSE; return FALSE; } -static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) +static bool8 RectangularSpiral_Main(struct Task *task) { u16 *tilemap, *tileset; u8 i; @@ -2951,24 +3238,28 @@ static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) GetBg0TilesDst(&tilemap, &tileset); + // Draw 2 tiles at a time for each spiral line for (i = 0; i < 2; i++) { - for (j = 0; j < ARRAY_COUNT(sRectangularSpiralTransition); j++) + for (j = 0; j < ARRAY_COUNT(sRectangularSpiralLines); j++) { - s16 var = 0, var2 = 0; - s32 var3 = 0; + s16 position = 0; + s16 x = 0, y = 0; - if (sub_8149048(gUnknown_085C8D38[j / 2], &sRectangularSpiralTransition[j])) + if (UpdateRectangularSpiralLine(sRectangularSpiral_MoveDataTables[j / 2], &sRectangularSpiralLines[j])) { + // The line moved to a new position, draw the tile. done = FALSE; - var = sRectangularSpiralTransition[j].field_2; + position = sRectangularSpiralLines[j].position; + + // Invert position for the two lines that start at the bottom. if ((j % 2) == 1) - var = 0x27D - var; + position = 637 - position; - var2 = var % 32; - var3 = var / 32; + x = position % 32; + y = position / 32; - SOME_VRAM_STORE(tilemap, var3, var2, 0xF002); + SET_TILE(tilemap, y, x, 2); } } } @@ -2978,7 +3269,7 @@ static bool8 Phase2_RectangularSpiral_Func2(struct Task *task) return FALSE; } -static bool8 Phase2_RectangularSpiral_Func3(struct Task *task) +static bool8 RectangularSpiral_End(struct Task *task) { DmaStop(0); FadeScreenBlack(); @@ -2986,575 +3277,655 @@ static bool8 Phase2_RectangularSpiral_Func3(struct Task *task) return FALSE; } -static bool16 sub_8149048(const s16 * const *arg0, struct StructRectangularSpiral *arg1) +// Returns TRUE if a tile should be drawn, FALSE otherwise +static bool16 UpdateRectangularSpiralLine(const s16 * const *moveDataTable, struct RectangularSpiralLine *line) { - const s16 *array = arg0[arg1->field_0]; - if (array[arg1->field_4] == -1) + const s16 *moveData = moveDataTable[line->state]; + + // Has spiral finished? + // Note that most move data arrays endsin SPIRAL_END but it is + // only ever reached on the final array of spiraling outward. + if (moveData[line->moveIdx] == SPIRAL_END) return FALSE; - // ?? - sUnusedRectangularSpiralVar = array[0]; - sUnusedRectangularSpiralVar = array[1]; - sUnusedRectangularSpiralVar = array[2]; - sUnusedRectangularSpiralVar = array[3]; - - switch (array[0]) + // Presumably saving data for debug. + sDebug_RectangularSpiralData = moveData[0]; + sDebug_RectangularSpiralData = moveData[1]; + sDebug_RectangularSpiralData = moveData[2]; + sDebug_RectangularSpiralData = moveData[3]; + + // Note that for the two lines originating at the bottom the + // position is inverted, so the directions are flipped. + // i.e. position += 1 is right for the top lines and left + // for their inverted partners on the bottom. + switch (moveData[0]) { - case 1: - arg1->field_2 += 0x1; + case MOVE_RIGHT: + line->position += 1; break; - case 2: - arg1->field_2 -= 0x1; + case MOVE_LEFT: + line->position -= 1; break; - case 3: - arg1->field_2 -= 0x20; + case MOVE_UP: + line->position -= 32; break; - case 4: - arg1->field_2 += 0x20; + case MOVE_DOWN: + line->position += 32; break; } - if (arg1->field_2 > 0x27F || array[arg1->field_4] == -1) + // Below check is never true. + // SPIRAL_END was already checked, and position is never >= 640 + if (line->position >= 640 || moveData[line->moveIdx] == SPIRAL_END) return FALSE; - if (arg1->field_8 == 0 && array[arg1->field_4] == -2) + if (!line->outward && moveData[line->moveIdx] == SPIRAL_REBOUND) { - arg1->field_8 = 1; - arg1->field_4 = 1; - arg1->field_2 = arg1->field_6; - arg1->field_0 = 4; + // Line has reached the final point of spiraling inward. + // Time to flip and start spiraling outward. + line->outward = TRUE; + line->moveIdx = 1; + line->position = line->reboundPosition; + line->state = SPIRAL_OUTWARD_START; } - if (arg1->field_2 == array[arg1->field_4]) + // Reached move target, advance to next movement. + if (line->position == moveData[line->moveIdx]) { - (arg1->field_0)++; - if (arg1->field_8 == 1) + line->state++; + if (line->outward == TRUE) { - if (arg1->field_0 > 7) + if (line->state > SPIRAL_OUTWARD_END) { - (arg1->field_4)++; - (arg1->field_0) = 4; + // Still spiraling outward, loop back to the first state + // but use the second set of move targets. + // For example, the 28 in sRectangularSpiral_Major_OutwardUp + line->moveIdx++; + line->state = SPIRAL_OUTWARD_START; } } else { - if (arg1->field_0 > 3) + if (line->state > SPIRAL_INWARD_END) { - (arg1->field_4)++; - (arg1->field_0) = 0; + // Still spiraling inward, loop back to the first state + // but use the second set of move targets. + // For example, the 275 in sRectangularSpiral_Major_InwardRight + line->moveIdx++; + line->state = SPIRAL_INWARD_START; } } } - return TRUE; } -static void Phase2Task_Groudon(u8 taskId) +//---------------------- +// B_TRANSITION_GROUDON +//---------------------- + +#define tTimer data[1] + +static void Task_Groudon(u8 taskId) { - while (sPhase2_Groudon_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sGroudon_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Groudon_Func3(struct Task *task) +static bool8 Groudon_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sGroudon_Tileset, tileset); LZ77UnCompVram(sGroudon_Tilemap, tilemap); task->tState++; - task->tData1 = 0; + task->tTimer = 0; return FALSE; } -static bool8 Phase2_Groudon_Func4(struct Task *task) +static bool8 Groudon_PaletteFlash(struct Task *task) { - if (task->tData1 % 3 == 0) + if (task->tTimer % 3 == 0) { - u16 var = (task->tData1 % 30) / 3; - LoadPalette(sGroudon1_Palette + (var * 16), 0xF0, 0x20); + u16 offset = (task->tTimer % 30) / 3; + LoadPalette(&sGroudon1_Palette[offset * 16], 0xF0, 0x20); } - if (++task->tData1 > 58) + if (++task->tTimer > 58) { task->tState++; - task->tData1 = 0; + task->tTimer = 0; } return FALSE; } -static bool8 Phase2_Groudon_Func5(struct Task *task) +static bool8 Groudon_PaletteBrighten(struct Task *task) { - if (task->tData1 % 5 == 0) + if (task->tTimer % 5 == 0) { - s16 var = task->tData1 / 5; - LoadPalette(sGroudon2_Palette + (var * 16), 0xF0, 0x20); + s16 offset = task->tTimer / 5; + LoadPalette(&sGroudon2_Palette[offset * 16], 0xF0, 0x20); } - if (++task->tData1 > 68) + if (++task->tTimer > 68) { task->tState++; - task->tData1 = 0; - task->tFrames = 30; + task->tTimer = 0; + task->tEndDelay = 30; } return FALSE; } -static void Phase2Task_Rayquaza(u8 taskId) +#undef tTimer +#undef tEndDelay + +//----------------------- +// B_TRANSITION_RAYQUAZA +//----------------------- + +#define tTimer data[1] +#define tGrowSpeed data[2] // Shared from B_TRANSITION_BLACKHOLE +#define tFlag data[7] // Shared from B_TRANSITION_BLACKHOLE + +static void Task_Rayquaza(u8 taskId) { - while (sPhase2_Rayquaza_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sRayquaza_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Rayquaza_Func3(struct Task *task) +static bool8 Rayquaza_Init(struct Task *task) { u16 *tilemap, *tileset; u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); SetGpuReg(REG_OFFSET_BG0CNT, BGCNT_CHARBASE(2) | BGCNT_SCREENBASE(26) | BGCNT_TXT256x512); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); CpuCopy16(sRayquaza_Tileset, tileset, 0x2000); - sTransitionStructPtr->field_20 = 0; + sTransitionData->counter = 0; task->tState++; - LoadPalette(sRayquaza_Palette + 0x50, 0xF0, 0x20); + LoadPalette(&sRayquaza_Palette[0x50], 0xF0, 0x20); - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { gScanlineEffectRegBuffers[0][i] = 0; gScanlineEffectRegBuffers[1][i] = 0x100; } - SetVBlankCallback(VBlankCB_Phase2_Rayquaza); + SetVBlankCallback(VBlankCB_Rayquaza); return FALSE; } -static bool8 Phase2_Rayquaza_Func4(struct Task *task) +static bool8 Rayquaza_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - CpuCopy16(sRayquaza_Tilemap, tilemap, 0x1000); + CpuCopy16(sRayquaza_Tilemap, tilemap, sizeof(sRayquaza_Tilemap)); task->tState++; return FALSE; } -static bool8 Phase2_Rayquaza_Func5(struct Task *task) +static bool8 Rayquaza_PaletteFlash(struct Task *task) { - if ((task->tData1 % 4) == 0) + if ((task->tTimer % 4) == 0) { - u16 value = task->tData1 / 4; + u16 value = task->tTimer / 4; const u16 *palPtr = &sRayquaza_Palette[(value + 5) * 16]; LoadPalette(palPtr, 0xF0, 0x20); } - if (++task->tData1 > 40) + if (++task->tTimer > 40) { task->tState++; - task->tData1 = 0; + task->tTimer = 0; } return FALSE; } -static bool8 Phase2_Rayquaza_Func6(struct Task *task) +static bool8 Rayquaza_FadeToBlack(struct Task *task) { - if (++task->tData1 > 20) + if (++task->tTimer > 20) { task->tState++; - task->tData1 = 0; - BeginNormalPaletteFade(PALETTES_OBJECTS | 0x8000, 2, 0, 0x10, RGB_BLACK); + task->tTimer = 0; + BeginNormalPaletteFade(PALETTES_OBJECTS | (1 << 15), 2, 0, 16, RGB_BLACK); } return FALSE; } -static bool8 Phase2_Rayquaza_Func7(struct Task *task) +static bool8 Rayquaza_WaitFade(struct Task *task) { if (!gPaletteFade.active) { - sTransitionStructPtr->field_20 = 1; + sTransitionData->counter = 1; task->tState++; } - return FALSE; } -static bool8 Phase2_Rayquaza_Func8(struct Task *task) +static bool8 Rayquaza_SetBlack(struct Task *task) { - BlendPalettes(PALETTES_BG & ~(0x8000), 8, 0); - BlendPalettes(PALETTES_OBJECTS | 0x8000, 0, 0); + BlendPalettes(PALETTES_BG & ~(1 << 15), 8, RGB_BLACK); + BlendPalettes(PALETTES_OBJECTS | (1 << 15), 0, RGB_BLACK); task->tState++; return FALSE; } -static bool8 Phase2_Rayquaza_Func9(struct Task *task) +static bool8 Rayquaza_TriRing(struct Task *task) { - if ((task->tData1 % 3) == 0) + if ((task->tTimer % 3) == 0) { - u16 value = task->tData1 / 3; + u16 value = task->tTimer / 3; const u16 *palPtr = &sRayquaza_Palette[(value + 0) * 16]; LoadPalette(palPtr, 0xF0, 0x20); } - if (++task->tData1 >= 40) + if (++task->tTimer >= 40) { u16 i; - sTransitionStructPtr->WININ = 0; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_ALL; - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = 0; + sTransitionData->WINOUT = WINOUT_WIN01_ALL; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { + for (i = 0; i < DISPLAY_HEIGHT; i++) gScanlineEffectRegBuffers[1][i] = 0; - } - SetVBlankCallback(VBlankCB1_Phase2_BigPokeball); + SetVBlankCallback(VBlankCB_CircularMask); task->tState++; - task->tData2 = 0x100; - task->tFuncState = 0; + task->tGrowSpeed = 1 << 8; + task->tFlag = FALSE; ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON); } return FALSE; } -static void VBlankCB_Phase2_Rayquaza(void) +static void VBlankCB_Rayquaza(void) { void *dmaSrc; DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->field_20 == 0) + if (sTransitionData->counter == 0) dmaSrc = gScanlineEffectRegBuffers[0]; - else if (sTransitionStructPtr->field_20 == 1) + else if (sTransitionData->counter == 1) dmaSrc = gScanlineEffectRegBuffers[1]; else dmaSrc = gScanlineEffectRegBuffers[0]; - DmaSet(0, dmaSrc, ®_BG0VOFS, 0xA2400001); + DmaSet(0, dmaSrc, ®_BG0VOFS, B_TRANS_DMA_FLAGS); } -static void Phase2Task_WhiteFade(u8 taskId) +#undef tTimer +#undef tGrowSpeed +#undef tFlag + +//------------------------------ +// B_TRANSITION_WHITE_BARS_FADE +//------------------------------ + +#define sFade data[0] +#define sFinished data[1] +#define sDestroyAttempts data[2] +#define sDelay data[5] +#define sIsMainSprite data[6] + +#define FADE_TARGET (16 << 8) + +static void Task_WhiteBarsFade(u8 taskId) { - while (sPhase2_WhiteFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sWhiteBarsFade_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_WhiteFade_Func1(struct Task *task) +static bool8 WhiteBarsFade_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; - sTransitionStructPtr->BLDY = 0; - sTransitionStructPtr->WININ = WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ; - sTransitionStructPtr->WINOUT = WINOUT_WIN01_ALL; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->BLDCNT = BLDCNT_TGT1_ALL | BLDCNT_EFFECT_LIGHTEN; + sTransitionData->BLDY = 0; + sTransitionData->WININ = WININ_WIN0_BG1 | WININ_WIN0_BG2 | WININ_WIN0_BG3 | WININ_WIN0_OBJ; + sTransitionData->WINOUT = WINOUT_WIN01_ALL; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) + for (i = 0; i < DISPLAY_HEIGHT; i++) { gScanlineEffectRegBuffers[1][i] = 0; - gScanlineEffectRegBuffers[1][i + 160] = 0xF0; + gScanlineEffectRegBuffers[1][i + DISPLAY_HEIGHT] = DISPLAY_WIDTH; } EnableInterrupts(INTR_FLAG_HBLANK); - SetHBlankCallback(HBlankCB_Phase2_WhiteFade); - SetVBlankCallback(VBlankCB0_Phase2_WhiteFade); + SetHBlankCallback(HBlankCB_WhiteBarsFade); + SetVBlankCallback(VBlankCB_WhiteBarsFade); task->tState++; return FALSE; } -static bool8 Phase2_WhiteFade_Func2(struct Task *task) +static bool8 WhiteBarsFade_StartBars(struct Task *task) { s16 i, posY; - s16 arr1[ARRAY_COUNT(sUnknown_085C8DA0)]; + s16 delays[ARRAY_COUNT(sWhiteBarsFade_StartDelays)]; struct Sprite *sprite; + memcpy(delays, sWhiteBarsFade_StartDelays, sizeof(sWhiteBarsFade_StartDelays)); - memcpy(arr1, sUnknown_085C8DA0, sizeof(sUnknown_085C8DA0)); - for (i = 0, posY = 0; i < 8; i++, posY += 0x14) + for (i = 0, posY = 0; i < NUM_WHITE_BARS; i++, posY += DISPLAY_HEIGHT / NUM_WHITE_BARS) { - sprite = &gSprites[CreateInvisibleSprite(sub_8149864)]; - sprite->x = 0xF0; + sprite = &gSprites[CreateInvisibleSprite(SpriteCB_WhiteBarFade)]; + sprite->x = DISPLAY_WIDTH; sprite->y = posY; - sprite->data[5] = arr1[i]; + sprite->sDelay = delays[i]; } - sprite->data[6]++; + + // Set on one sprite only. This one will enable the DMA + // copy in VBlank and wait for the others to destroy. + sprite->sIsMainSprite++; task->tState++; return FALSE; } -static bool8 Phase2_WhiteFade_Func3(struct Task *task) +static bool8 WhiteBarsFade_WaitBars(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = 0; - if (sTransitionStructPtr->field_20 > 7) + sTransitionData->VBlank_DMA = 0; + if (sTransitionData->counter >= NUM_WHITE_BARS) { - BlendPalettes(PALETTES_ALL, 0x10, 0x7FFF); + BlendPalettes(PALETTES_ALL, 16, RGB_WHITE); task->tState++; } return FALSE; } -static bool8 Phase2_WhiteFade_Func4(struct Task *task) +static bool8 WhiteBarsFade_BlendToBlack(struct Task *task) { - sTransitionStructPtr->VBlank_DMA = 0; + sTransitionData->VBlank_DMA = 0; DmaStop(0); SetVBlankCallback(0); SetHBlankCallback(0); - sTransitionStructPtr->WIN0H = DISPLAY_WIDTH; - sTransitionStructPtr->BLDY = 0; - sTransitionStructPtr->BLDCNT = 0xFF; - sTransitionStructPtr->WININ = WININ_WIN0_ALL; + sTransitionData->WIN0H = DISPLAY_WIDTH; + sTransitionData->BLDY = 0; + sTransitionData->BLDCNT = 0xFF; + sTransitionData->WININ = WININ_WIN0_ALL; - SetVBlankCallback(VBlankCB1_Phase2_WhiteFade); + SetVBlankCallback(VBlankCB_WhiteBarsFade_Blend); task->tState++; return FALSE; } -static bool8 Phase2_WhiteFade_Func5(struct Task *task) +static bool8 WhiteBarsFade_End(struct Task *task) { - if (++sTransitionStructPtr->BLDY > 16) + if (++sTransitionData->BLDY > 16) { FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_WhiteFade)); + DestroyTask(FindTaskIdByFunc(Task_WhiteBarsFade)); } return FALSE; } -static void VBlankCB0_Phase2_WhiteFade(void) +static void VBlankCB_WhiteBarsFade(void) { DmaStop(0); VBlankCB_BattleTransition(); - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640); - DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); + REG_BLDCNT = sTransitionData->BLDCNT; + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 4); + DmaSet(0, &gScanlineEffectRegBuffers[1][DISPLAY_HEIGHT], ®_WIN0H, B_TRANS_DMA_FLAGS); } -static void VBlankCB1_Phase2_WhiteFade(void) +static void VBlankCB_WhiteBarsFade_Blend(void) { VBlankCB_BattleTransition(); - REG_BLDY = sTransitionStructPtr->BLDY; - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0H = sTransitionStructPtr->WIN0H; - REG_WIN0V = sTransitionStructPtr->WIN0V; + REG_BLDY = sTransitionData->BLDY; + REG_BLDCNT = sTransitionData->BLDCNT; + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0H = sTransitionData->WIN0H; + REG_WIN0V = sTransitionData->WIN0V; } -static void HBlankCB_Phase2_WhiteFade(void) +static void HBlankCB_WhiteBarsFade(void) { REG_BLDY = gScanlineEffectRegBuffers[1][REG_VCOUNT]; } -static void sub_8149864(struct Sprite *sprite) +static void SpriteCB_WhiteBarFade(struct Sprite *sprite) { - if (sprite->data[5]) + if (sprite->sDelay) { - sprite->data[5]--; - if (sprite->data[6]) - sTransitionStructPtr->VBlank_DMA = 1; + sprite->sDelay--; + if (sprite->sIsMainSprite) + sTransitionData->VBlank_DMA = 1; } else { u16 i; u16* ptr1 = &gScanlineEffectRegBuffers[0][sprite->y]; - u16* ptr2 = &gScanlineEffectRegBuffers[0][sprite->y + 160]; - for (i = 0; i < 20; i++) + u16* ptr2 = &gScanlineEffectRegBuffers[0][sprite->y + DISPLAY_HEIGHT]; + for (i = 0; i < DISPLAY_HEIGHT / NUM_WHITE_BARS; i++) { - ptr1[i] = sprite->data[0] >> 8; - ptr2[i] = (u8)(sprite->x); + ptr1[i] = sprite->sFade >> 8; + ptr2[i] = (u8)sprite->x; } - if (sprite->x == 0 && sprite->data[0] == 0x1000) - sprite->data[1] = 1; + if (sprite->x == 0 && sprite->sFade == FADE_TARGET) + sprite->sFinished = TRUE; sprite->x -= 16; - sprite->data[0] += 0x80; + sprite->sFade += FADE_TARGET / 32; if (sprite->x < 0) sprite->x = 0; - if (sprite->data[0] > 0x1000) - sprite->data[0] = 0x1000; + if (sprite->sFade > FADE_TARGET) + sprite->sFade = FADE_TARGET; - if (sprite->data[6]) - sTransitionStructPtr->VBlank_DMA = 1; + if (sprite->sIsMainSprite) + sTransitionData->VBlank_DMA = 1; - if (sprite->data[1]) + if (sprite->sFinished) { - if (sprite->data[6] == 0 || (sTransitionStructPtr->field_20 > 6 && sprite->data[2]++ > 7)) + // If not the main sprite, destroy self. Otherwise, wait until the + // others have destroyed themselves, or until enough time has elapsed. + if (!sprite->sIsMainSprite || (sTransitionData->counter >= NUM_WHITE_BARS - 1 && sprite->sDestroyAttempts++ > 7)) { - sTransitionStructPtr->field_20++; + sTransitionData->counter++; DestroySprite(sprite); } } } } -static void Phase2Task_GridSquares(u8 taskId) +#undef sFade +#undef sFinished +#undef sDestroyAttempts +#undef sDelay +#undef sIsMainSprite + +//--------------------------- +// B_TRANSITION_GRID_SQUARES +//--------------------------- + +#define tDelay data[1] +#define tShrinkStage data[2] + +static void Task_GridSquares(u8 taskId) { - while (sPhase2_GridSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sGridSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_GridSquares_Func1(struct Task *task) +static bool8 GridSquares_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - CpuSet(sShrinkingBoxTileset, tileset, 0x10); - CpuFill16(0xF000, tilemap, 0x800); - LoadPalette(sFieldEffectPal_Pokeball, 0xF0, 0x20); + CpuSet(sShrinkingBoxTileset, tileset, 16); + CpuFill16(0xF0 << 8, tilemap, BG_SCREEN_SIZE); + LoadPalette(sFieldEffectPal_Pokeball, 0xF0, sizeof(sFieldEffectPal_Pokeball)); task->tState++; return FALSE; } -static bool8 Phase2_GridSquares_Func2(struct Task *task) +static bool8 GridSquares_Main(struct Task *task) { u16* tileset; - if (task->tData1 == 0) + if (task->tDelay == 0) { GetBg0TilemapDst(&tileset); - task->tData1 = 3; - task->tData2++; - CpuSet(sShrinkingBoxTileset + (task->tData2 * 8), tileset, 0x10); - if (task->tData2 > 0xD) + task->tDelay = 3; + task->tShrinkStage++; + CpuSet(&sShrinkingBoxTileset[task->tShrinkStage * 8], tileset, 16); + if (task->tShrinkStage > 13) { task->tState++; - task->tData1 = 16; + task->tDelay = 16; } } - task->tData1--; + task->tDelay--; return FALSE; } -static bool8 Phase2_GridSquares_Func3(struct Task *task) +static bool8 GridSquares_End(struct Task *task) { - if (--task->tData1 == 0) + if (--task->tDelay == 0) { FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_GridSquares)); + DestroyTask(FindTaskIdByFunc(Task_GridSquares)); } return FALSE; } -static void Phase2Task_Shards(u8 taskId) +#undef tDelay +#undef tShrinkStage + +//--------------------------- +// B_TRANSITION_ANGLED_WIPES +//--------------------------- + +#define tWipeId data[1] +#define tDir data[2] +#define tDelay data[3] + +static void Task_AngledWipes(u8 taskId) { - while (sPhase2_Shards_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sAngledWipes_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_Shards_Func1(struct Task *task) +static bool8 AngledWipes_Init(struct Task *task) { u16 i; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); - sTransitionStructPtr->WININ = WININ_WIN0_ALL; - sTransitionStructPtr->WINOUT = 0; - sTransitionStructPtr->WIN0V = DISPLAY_HEIGHT; + sTransitionData->WININ = WININ_WIN0_ALL; + sTransitionData->WINOUT = 0; + sTransitionData->WIN0V = DISPLAY_HEIGHT; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[0][i] = 0xF0; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[0][i] = DISPLAY_WIDTH; - CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 0xA0); - SetVBlankCallback(VBlankCB_Phase2_Shards); + CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT); + SetVBlankCallback(VBlankCB_AngledWipes); task->tState++; return TRUE; } -static bool8 Phase2_Shards_Func2(struct Task *task) +static bool8 AngledWipes_SetWipeData(struct Task *task) { - sub_814A1AC(sTransitionStructPtr->data, - sUnknown_085C8DD0[task->tData1][0], - sUnknown_085C8DD0[task->tData1][1], - sUnknown_085C8DD0[task->tData1][2], - sUnknown_085C8DD0[task->tData1][3], - 1, 1); - task->tData2 = sUnknown_085C8DD0[task->tData1][4]; + InitBlackWipe(sTransitionData->data, + sAngledWipes_MoveData[task->tWipeId][0], + sAngledWipes_MoveData[task->tWipeId][1], + sAngledWipes_MoveData[task->tWipeId][2], + sAngledWipes_MoveData[task->tWipeId][3], + 1, 1); + task->tDir = sAngledWipes_MoveData[task->tWipeId][4]; task->tState++; return TRUE; } -static bool8 Phase2_Shards_Func3(struct Task *task) +static bool8 AngledWipes_DoWipe(struct Task *task) { s16 i; - bool8 nextFunc; + bool8 finished; - sTransitionStructPtr->VBlank_DMA = 0; + sTransitionData->VBlank_DMA = 0; - for (i = 0, nextFunc = FALSE; i < 16; i++) + for (i = 0, finished = FALSE; i < 16; i++) { - s16 r3 = gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] >> 8; - s16 r4 = gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] & 0xFF; - if (task->tData2 == 0) + s16 r3 = gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] >> 8; + s16 r4 = gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] & 0xFF; + if (task->tDir == 0) { - if (r3 < sTransitionStructPtr->data[2]) - r3 = sTransitionStructPtr->data[2]; + // Moving down + if (r3 < sTransitionData->tWipeCurrX) + r3 = sTransitionData->tWipeCurrX; if (r3 > r4) r3 = r4; } else { - if (r4 > sTransitionStructPtr->data[2]) - r4 = sTransitionStructPtr->data[2]; + // Moving up + if (r4 > sTransitionData->tWipeCurrX) + r4 = sTransitionData->tWipeCurrX; if (r4 <= r3) r4 = r3; } - gScanlineEffectRegBuffers[0][sTransitionStructPtr->data[3]] = (r4) | (r3 << 8); - if (nextFunc) + gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = (r4) | (r3 << 8); + if (finished) { task->tState++; break; } - else - nextFunc = sub_814A228(sTransitionStructPtr->data, 1, 1); + finished = UpdateBlackWipe(sTransitionData->data, TRUE, TRUE); } - sTransitionStructPtr->VBlank_DMA++; + sTransitionData->VBlank_DMA++; return FALSE; } -static bool8 Phase2_Shards_Func4(struct Task *task) +static bool8 AngledWipes_TryEnd(struct Task *task) { - if (++task->tData1 < 7) + if (++task->tWipeId < NUM_ANGLED_WIPES) { + // Continue with next wipe task->tState++; - task->tData3 = sUnknown_085C8E16[task->tData1 - 1]; + task->tDelay = sAngledWipes_EndDelays[task->tWipeId - 1]; return TRUE; } else { + // End transition DmaStop(0); FadeScreenBlack(); - DestroyTask(FindTaskIdByFunc(Phase2Task_Shards)); + DestroyTask(FindTaskIdByFunc(Task_AngledWipes)); return FALSE; } } -static bool8 Phase2_Shards_Func5(struct Task *task) +static bool8 AngledWipes_StartNext(struct Task *task) { - if (--task->tData3 == 0) + if (--task->tDelay == 0) { + // Return to AngledWipes_SetWipeData task->tState = 1; return TRUE; } @@ -3562,118 +3933,121 @@ static bool8 Phase2_Shards_Func5(struct Task *task) return FALSE; } -static void VBlankCB_Phase2_Shards(void) +static void VBlankCB_AngledWipes(void) { DmaStop(0); VBlankCB_BattleTransition(); - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); - REG_WININ = sTransitionStructPtr->WININ; - REG_WINOUT = sTransitionStructPtr->WINOUT; - REG_WIN0V = sTransitionStructPtr->WIN0V; + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); + REG_WININ = sTransitionData->WININ; + REG_WINOUT = sTransitionData->WINOUT; + REG_WIN0V = sTransitionData->WIN0V; REG_WIN0H = gScanlineEffectRegBuffers[1][0]; - DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); -} - -// sub-task for phase2 -#undef tData1 -#undef tData2 -#undef tData3 -#undef tData4 -#undef tData5 -#undef tData6 -#undef tFuncState -#undef tFrames -#undef tOpponentSpriteId -#undef tPlayerSpriteId -#undef tMugshotId + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, B_TRANS_DMA_FLAGS); +} + +#undef tWipeId +#undef tDir +#undef tDelay -// sub-task for sub-task phase -#define tData1 data[1] -#define tData2 data[2] -#define tData3 data[3] -#define tData4 data[4] -#define tData5 data[5] -#define tData6 data[6] -#define tData7 data[7] +//----------------------------------- +// Transition intro +//----------------------------------- -static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4) +#define tFadeToGrayDelay data[1] +#define tFadeFromGrayDelay data[2] +#define tNumFades data[3] +#define tFadeToGrayIncrement data[4] +#define tFadeFromGrayIncrement data[5] +#define tDelayTimer data[6] +#define tBlend data[7] + +static void CreateIntroTask(s16 fadeToGrayDelay, s16 fadeFromGrayDelay, s16 numFades, s16 fadeToGrayIncrement, s16 fadeFromGrayIncrement) { - u8 taskId = CreateTask(TransitionPhase1_Task_RunFuncs, 3); - gTasks[taskId].tData1 = a0; - gTasks[taskId].tData2 = a1; - gTasks[taskId].tData3 = a2; - gTasks[taskId].tData4 = a3; - gTasks[taskId].tData5 = a4; - gTasks[taskId].tData6 = a0; + u8 taskId = CreateTask(Task_BattleTransition_Intro, 3); + gTasks[taskId].tFadeToGrayDelay = fadeToGrayDelay; + gTasks[taskId].tFadeFromGrayDelay = fadeFromGrayDelay; + gTasks[taskId].tNumFades = numFades; + gTasks[taskId].tFadeToGrayIncrement = fadeToGrayIncrement; + gTasks[taskId].tFadeFromGrayIncrement = fadeFromGrayIncrement; + gTasks[taskId].tDelayTimer = fadeToGrayDelay; } -static bool8 IsPhase1Done(void) +static bool8 IsIntroTaskDone(void) { - if (FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) == TASK_NONE) + if (FindTaskIdByFunc(Task_BattleTransition_Intro) == TASK_NONE) return TRUE; else return FALSE; } -void TransitionPhase1_Task_RunFuncs(u8 taskId) +void Task_BattleTransition_Intro(u8 taskId) { - while (sPhase1_TransitionAll_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sTransitionIntroFuncs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase1_TransitionAll_Func1(struct Task *task) +static bool8 TransitionIntro_FadeToGray(struct Task *task) { - if (task->tData6 == 0 || --task->tData6 == 0) + if (task->tDelayTimer == 0 || --task->tDelayTimer == 0) { - task->tData6 = task->tData1; - task->tData7 += task->tData4; - if (task->tData7 > 16) - task->tData7 = 16; - BlendPalettes(PALETTES_ALL, task->tData7, 0x2D6B); + task->tDelayTimer = task->tFadeToGrayDelay; + task->tBlend += task->tFadeToGrayIncrement; + if (task->tBlend > 16) + task->tBlend = 16; + BlendPalettes(PALETTES_ALL, task->tBlend, RGB(11, 11, 11)); } - if (task->tData7 > 15) + if (task->tBlend >= 16) { + // Fade to gray complete, start fade back task->tState++; - task->tData6 = task->tData2; + task->tDelayTimer = task->tFadeFromGrayDelay; } return FALSE; } -static bool8 Phase1_TransitionAll_Func2(struct Task *task) +static bool8 TransitionIntro_FadeFromGray(struct Task *task) { - if (task->tData6 == 0 || --task->tData6 == 0) + if (task->tDelayTimer == 0 || --task->tDelayTimer == 0) { - task->tData6 = task->tData2; - task->tData7 -= task->tData5; - if (task->tData7 < 0) - task->tData7 = 0; - BlendPalettes(PALETTES_ALL, task->tData7, 0x2D6B); + task->tDelayTimer = task->tFadeFromGrayDelay; + task->tBlend -= task->tFadeFromGrayIncrement; + if (task->tBlend < 0) + task->tBlend = 0; + BlendPalettes(PALETTES_ALL, task->tBlend, RGB(11, 11, 11)); } - if (task->tData7 == 0) + if (task->tBlend == 0) { - if (--task->tData3 == 0) - DestroyTask(FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs)); + if (--task->tNumFades == 0) + { + // All fades done, end intro + DestroyTask(FindTaskIdByFunc(Task_BattleTransition_Intro)); + } else { - task->tData6 = task->tData1; + // Fade from gray complete, start new fade + task->tDelayTimer = task->tFadeToGrayDelay; task->tState = 0; } } return FALSE; } -#undef tData1 -#undef tData2 -#undef tData3 -#undef tData4 -#undef tData5 -#undef tData6 -#undef tData7 +#undef tFadeToGrayDelay +#undef tFadeFromGrayDelay +#undef tNumFades +#undef tFadeToGrayIncrement +#undef tFadeFromGrayIncrement +#undef tDelayTimer +#undef tBlend -static void InitTransitionStructVars(void) +//----------------------------------- +// General transition functions +//----------------------------------- + +static void InitTransitionData(void) { - memset(sTransitionStructPtr, 0, sizeof(*sTransitionStructPtr)); - GetCameraOffsetWithPan(&sTransitionStructPtr->field_14, &sTransitionStructPtr->field_16); + memset(sTransitionData, 0, sizeof(*sTransitionData)); + GetCameraOffsetWithPan(&sTransitionData->cameraX, &sTransitionData->cameraY); } static void VBlankCB_BattleTransition(void) @@ -3686,8 +4060,8 @@ static void VBlankCB_BattleTransition(void) static void GetBg0TilemapDst(u16 **tileset) { u16 charBase = REG_BG0CNT >> 2; - charBase <<= 0xE; - *tileset = (u16*)(VRAM + charBase); + charBase <<= 14; + *tileset = (u16*)(BG_VRAM + charBase); } void GetBg0TilesDst(u16 **tilemap, u16 **tileset) @@ -3695,11 +4069,11 @@ void GetBg0TilesDst(u16 **tilemap, u16 **tileset) u16 screenBase = REG_BG0CNT >> 8; u16 charBase = REG_BG0CNT >> 2; - screenBase <<= 0xB; - charBase <<= 0xE; + screenBase <<= 11; + charBase <<= 14; - *tilemap = (u16*)(VRAM + screenBase); - *tileset = (u16*)(VRAM + charBase); + *tilemap = (u16*)(BG_VRAM + screenBase); + *tileset = (u16*)(BG_VRAM + charBase); } static void FadeScreenBlack(void) @@ -3707,207 +4081,237 @@ static void FadeScreenBlack(void) BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); } -static void sub_8149F98(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize) +static void SetSinWave(s16 *array, s16 sinAdd, s16 index, s16 indexIncrementer, s16 amplitude, s16 arrSize) { u8 i; for (i = 0; arrSize > 0; arrSize--, i++, index += indexIncrementer) - { - array[i] = sinAdd + Sin(0xFF & index, amplitude); - } + array[i] = sinAdd + Sin(index & 0xFF, amplitude); } -static void sub_814A014(u16 *array, s16 a1, s16 a2, s16 a3) +static void SetCircularMask(u16 *buffer, s16 centerX, s16 centerY, s16 radius) { s16 i; - memset(array, 0xA, 160 * sizeof(s16)); + memset(buffer, 10, DISPLAY_HEIGHT * sizeof(u16)); for (i = 0; i < 64; i++) { s16 sinResult, cosResult; - s16 toStoreOrr, r2, r3, toStore, r7, r8; - - sinResult = Sin(i, a3); - cosResult = Cos(i, a3); - - toStoreOrr = a1 - sinResult; - toStore = a1 + sinResult; - r7 = a2 - cosResult; - r8 = a2 + cosResult; - - if (toStoreOrr < 0) - toStoreOrr = 0; - if (toStore > 0xF0) - toStore = 0xF0; - if (r7 < 0) - r7 = 0; - if (r8 > 0x9F) - r8 = 0x9F; - - toStore |= (toStoreOrr << 8); - array[r7] = toStore; - array[r8] = toStore; - - cosResult = Cos(i + 1, a3); - r3 = a2 - cosResult; - r2 = a2 + cosResult; - - if (r3 < 0) - r3 = 0; - if (r2 > 0x9F) - r2 = 0x9F; - - while (r7 > r3) - array[--r7] = toStore; - while (r7 < r3) - array[++r7] = toStore; - - while (r8 > r2) - array[--r8] = toStore; - while (r8 < r2) - array[++r8] = toStore; + s16 drawXLeft, drawYBottNext, drawYTopNext, drawX, drawYTop, drawYBott; + + sinResult = Sin(i, radius); + cosResult = Cos(i, radius); + + drawXLeft = centerX - sinResult; + drawX = centerX + sinResult; + drawYTop = centerY - cosResult; + drawYBott = centerY + cosResult; + + if (drawXLeft < 0) + drawXLeft = 0; + if (drawX > DISPLAY_WIDTH) + drawX = DISPLAY_WIDTH; + if (drawYTop < 0) + drawYTop = 0; + if (drawYBott > DISPLAY_HEIGHT - 1) + drawYBott = DISPLAY_HEIGHT - 1; + + drawX |= (drawXLeft << 8); + buffer[drawYTop] = drawX; + buffer[drawYBott] = drawX; + + cosResult = Cos(i + 1, radius); + drawYTopNext = centerY - cosResult; + drawYBottNext = centerY + cosResult; + + if (drawYTopNext < 0) + drawYTopNext = 0; + if (drawYBottNext > DISPLAY_HEIGHT - 1) + drawYBottNext = DISPLAY_HEIGHT - 1; + + while (drawYTop > drawYTopNext) + buffer[--drawYTop] = drawX; + while (drawYTop < drawYTopNext) + buffer[++drawYTop] = drawX; + + while (drawYBott > drawYBottNext) + buffer[--drawYBott] = drawX; + while (drawYBott < drawYBottNext) + buffer[++drawYBott] = drawX; } } -static void sub_814A1AC(s16 *data, s16 a1, s16 a2, s16 a3, s16 a4, s16 a5, s16 a6) +static void InitBlackWipe(s16 *data, s16 startX, s16 startY, s16 endX, s16 endY, s16 xMove, s16 yMove) { - data[0] = a1; - data[1] = a2; - data[2] = a1; - data[3] = a2; - data[4] = a3; - data[5] = a4; - data[6] = a5; - data[7] = a6; - data[8] = a3 - a1; - if (data[8] < 0) + tWipeStartX = startX; + tWipeStartY = startY; + tWipeCurrX = startX; + tWipeCurrY = startY; + tWipeEndX = endX; + tWipeEndY = endY; + tWipeXMove = xMove; + tWipeYMove = yMove; + tWipeXDist = endX - startX; + if (tWipeXDist < 0) { - data[8] = -data[8]; - data[6] = -a5; + // If end was less than start, reverse direction + tWipeXDist = -tWipeXDist; + tWipeXMove = -xMove; } - data[9] = a4 - a2; - if (data[9] < 0) + tWipeYDist = endY - startY; + if (tWipeYDist < 0) { - data[9] = -data[9]; - data[7] = -a6; + // If end was less than start, reverse direction + tWipeYDist = -tWipeYDist; + tWipeYMove = -yMove; } - data[10] = 0; + tWipeTemp = 0; } -static bool8 sub_814A228(s16 *data, bool8 a1, bool8 a2) +static bool8 UpdateBlackWipe(s16 *data, bool8 xExact, bool8 yExact) { - u8 var; - if (data[8] > data[9]) + u8 numFinished; + + if (tWipeXDist > tWipeYDist) { - data[2] += data[6]; - data[10] += data[9]; - if (data[10] > data[8]) + // X has further to move, move it first + tWipeCurrX += tWipeXMove; + + // If it has been far enough since Y's + // last move then move it too + tWipeTemp += tWipeYDist; + if (tWipeTemp > tWipeXDist) { - data[3] += data[7]; - data[10] -= data[8]; + tWipeCurrY += tWipeYMove; + tWipeTemp -= tWipeXDist; } } else { - data[3] += data[7]; - data[10] += data[8]; - if (data[10] > data[9]) + // Y has further to move, move it first + tWipeCurrY += tWipeYMove; + + // If it has been far enough since X's + // last move then move it too + tWipeTemp += tWipeXDist; + if (tWipeTemp > tWipeYDist) { - data[2] += data[6]; - data[10] -= data[9]; + tWipeCurrX += tWipeXMove; + tWipeTemp -= tWipeYDist; } } - var = 0; - if ((data[6] > 0 && data[2] >= data[4]) || (data[6] < 0 && data[2] <= data[4])) + + numFinished = 0; + + // Has X coord reached end? + if ((tWipeXMove > 0 && tWipeCurrX >= tWipeEndX) + || (tWipeXMove < 0 && tWipeCurrX <= tWipeEndX)) { - var++; - if (a1) - data[2] = data[4]; + numFinished++; + if (xExact) + tWipeCurrX = tWipeEndX; } - if ((data[7] > 0 && data[3] >= data[5]) || (data[7] < 0 && data[3] <= data[5])) + + // Has Y coord reached end? + if ((tWipeYMove > 0 && tWipeCurrY >= tWipeEndY) + || (tWipeYMove < 0 && tWipeCurrY <= tWipeEndY)) { - var++; - if (a2) - data[3] = data[5]; + numFinished++; + if (yExact) + tWipeCurrY = tWipeEndY; } - if (var == 2) + // Return TRUE if both coords have reached end + if (numFinished == 2) return TRUE; else return FALSE; } -// sub-task for phase2 of a couple of new transitions -#define tData1 data[1] -#define tData2 data[2] -#define tData3 data[3] -#define tData4 data[4] -#define tData5 data[5] -#define tData6 data[6] -#define tData7 data[7] +//----------------------------------- +// B_TRANSITION_FRONTIER_LOGO_WIGGLE +//----------------------------------- + +#define tSinIndex data[4] +#define tAmplitude data[5] -static bool8 Phase2_FrontierLogoWiggle_Func1(struct Task *task) +static bool8 FrontierLogoWiggle_Init(struct Task *task) { u16 *tilemap, *tileset; - sub_814669C(task); + InitPatternWeaveTransition(task); GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sFrontierLogo_Tileset, tileset); - LoadPalette(sFrontierLogo_Palette, 0xF0, 0x20); + LoadPalette(sFrontierLogo_Palette, 0xF0, sizeof(sFrontierLogo_Palette)); task->tState++; return FALSE; } -static bool8 Phase2_FrontierLogoWiggle_Func2(struct Task *task) +static bool8 FrontierLogoWiggle_SetGfx(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierLogo_Tilemap, tilemap); - sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 0x84, task->tData5, 160); + SetSinWave(gScanlineEffectRegBuffers[0], 0, task->tSinIndex, 132, task->tAmplitude, DISPLAY_HEIGHT); task->tState++; return TRUE; } -static void Phase2Task_FrontierLogoWiggle(u8 taskId) +static void Task_FrontierLogoWiggle(u8 taskId) { - while (sPhase2_FrontierLogoWiggle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierLogoWiggle_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_FrontierLogoWave(u8 taskId) +#undef tSinIndex +#undef tAmplitude + +//--------------------------------- +// B_TRANSITION_FRONTIER_LOGO_WAVE +//--------------------------------- + +#define tSinVal data[1] +#define tAmplitudeVal data[2] +#define tTimer data[3] +#define tStartedFade data[4] +#define tBlendTarget2 data[5] +#define tBlendTarget1 data[6] +#define tSinDecrement data[7] + +static void Task_FrontierLogoWave(u8 taskId) { - while (sPhase2_FrontierLogoWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierLogoWave_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_FrontierLogoWave_Func1(struct Task *task) +static bool8 FrontierLogoWave_Init(struct Task *task) { u16 *tilemap, *tileset; - InitTransitionStructVars(); + InitTransitionData(); ScanlineEffect_Clear(); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON); - task->tData2 = 0x2000; - task->tData1 = 0x7FFF; - task->tData5 = 0; - task->tData6 = 16; - task->tData7 = 2560; - sTransitionStructPtr->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData5, task->tData6); - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; + task->tAmplitudeVal = 32 << 8; + task->tSinVal = 0x7FFF; + task->tBlendTarget2 = 0; + task->tBlendTarget1 = 16; + task->tSinDecrement = 2560; + sTransitionData->BLDCNT = BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL; + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); + REG_BLDCNT = sTransitionData->BLDCNT; + REG_BLDALPHA = sTransitionData->BLDALPHA; GetBg0TilesDst(&tilemap, &tileset); - CpuFill16(0, tilemap, 0x800); + CpuFill16(0, tilemap, BG_SCREEN_SIZE); LZ77UnCompVram(sFrontierLogo_Tileset, tileset); - LoadPalette(sFrontierLogo_Palette, 0xF0, 0x20); - sTransitionStructPtr->field_16 = 0; + LoadPalette(sFrontierLogo_Palette, 0xF0, sizeof(sFrontierLogo_Palette)); + sTransitionData->cameraY = 0; task->tState++; return FALSE; } -static bool8 Phase2_FrontierLogoWave_Func2(struct Task *task) +static bool8 FrontierLogoWave_SetGfx(struct Task *task) { u16 *tilemap, *tileset; @@ -3918,164 +4322,190 @@ static bool8 Phase2_FrontierLogoWave_Func2(struct Task *task) return TRUE; } -static bool8 Phase2_FrontierLogoWave_Func3(struct Task *task) +static bool8 FrontierLogoWave_InitScanline(struct Task *task) { u8 i; - for (i = 0; i < 160; i++) - { - gScanlineEffectRegBuffers[1][i] = sTransitionStructPtr->field_16; - } + for (i = 0; i < DISPLAY_HEIGHT; i++) + gScanlineEffectRegBuffers[1][i] = sTransitionData->cameraY; - SetVBlankCallback(VBlankCB_Phase2_30); - SetHBlankCallback(HBlankCB_Phase2_30); + SetVBlankCallback(VBlankCB_FrontierLogoWave); + SetHBlankCallback(HBlankCB_FrontierLogoWave); EnableInterrupts(INTR_FLAG_HBLANK); task->tState++; return TRUE; } -static bool8 Phase2_FrontierLogoWave_Func4(struct Task *task) +static bool8 FrontierLogoWave_Main(struct Task *task) { u8 i; - u16 var6, amplitude, var8; + u16 sinVal, amplitude, sinSpread; - sTransitionStructPtr->VBlank_DMA = FALSE; + sTransitionData->VBlank_DMA = FALSE; - amplitude = task->tData2 >> 8; - var6 = task->tData1; - var8 = 384; + amplitude = task->tAmplitudeVal >> 8; + sinVal = task->tSinVal; + sinSpread = 384; - task->tData1 = var6 - task->tData7; + task->tSinVal -= task->tSinDecrement; - if (task->tData3 >= 70) + if (task->tTimer >= 70) { - if (task->tData2 - 384 >= 0) - task->tData2 -= 384; + // Decrease amount of logo movement and distortion + // until it rests normally in the middle of the screen. + if (task->tAmplitudeVal - 384 >= 0) + task->tAmplitudeVal -= 384; else - task->tData2 = 0; + task->tAmplitudeVal = 0; } - if (task->tData3 >= 0 && task->tData3 % 3 == 0) + if (task->tTimer >= 0 && task->tTimer % 3 == 0) { - if (task->tData5 < 16) - task->tData5++; - else if (task->tData6 > 0) - task->tData6--; + // Blend logo into view + if (task->tBlendTarget2 < 16) + task->tBlendTarget2++; + else if (task->tBlendTarget1 > 0) + task->tBlendTarget1--; - sTransitionStructPtr->BLDALPHA = BLDALPHA_BLEND(task->tData5, task->tData6); + sTransitionData->BLDALPHA = BLDALPHA_BLEND(task->tBlendTarget2, task->tBlendTarget1); } - for (i = 0; i < 160; i++, var6 += var8) + // Move logo up and down and distort it + for (i = 0; i < DISPLAY_HEIGHT; i++, sinVal += sinSpread) { - s16 index = var6 / 256; - gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(index & 0xff, amplitude); + s16 index = sinVal / 256; + gScanlineEffectRegBuffers[0][i] = sTransitionData->cameraY + Sin(index & 0xff, amplitude); } - if (++task->tData3 == 101) + if (++task->tTimer == 101) { - task->tData4++; - BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 0x10, RGB_BLACK); + task->tStartedFade++; + BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK); } - if (task->tData4 != 0 && !gPaletteFade.active) - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierLogoWave)); + if (task->tStartedFade && !gPaletteFade.active) + DestroyTask(FindTaskIdByFunc(Task_FrontierLogoWave)); - task->tData7 -= 17; - sTransitionStructPtr->VBlank_DMA++; + task->tSinDecrement -= 17; + sTransitionData->VBlank_DMA++; return FALSE; } -static void VBlankCB_Phase2_30(void) +static void VBlankCB_FrontierLogoWave(void) { VBlankCB_BattleTransition(); - REG_BLDCNT = sTransitionStructPtr->BLDCNT; - REG_BLDALPHA = sTransitionStructPtr->BLDALPHA; + REG_BLDCNT = sTransitionData->BLDCNT; + REG_BLDALPHA = sTransitionData->BLDALPHA; - if (sTransitionStructPtr->VBlank_DMA) - DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); + if (sTransitionData->VBlank_DMA) + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], DISPLAY_HEIGHT * 2); } -static void HBlankCB_Phase2_30(void) +static void HBlankCB_FrontierLogoWave(void) { u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG0VOFS = var; } -static void Phase2Task_FrontierSquares(u8 taskId) +#undef tSinVal +#undef tAmplitudeVal +#undef tTimer +#undef tStartedFade +#undef tBlendTarget2 +#undef tBlendTarget1 +#undef tSinDecrement + +//---------------------------------------------------------------------- +// B_TRANSITION_FRONTIER_SQUARES, B_TRANSITION_FRONTIER_SQUARES_SCROLL, +// and B_TRANSITION_FRONTIER_SQUARES_SPIRAL +//---------------------------------------------------------------------- + +#define tPosX data[2] +#define tPosY data[3] +#define tRowPos data[4] +#define tShrinkState data[5] +#define tShrinkDelayTimer data[6] +#define tShrinkDelay data[7] + +static void Task_FrontierSquares(u8 taskId) { - while (sPhase2_FrontierSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierSquares_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_FrontierSquaresSpiral(u8 taskId) +static void Task_FrontierSquaresSpiral(u8 taskId) { - while (sPhase2_FrontierSquaresSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierSquaresSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static void Phase2Task_FrontierSquaresScroll(u8 taskId) +static void Task_FrontierSquaresScroll(u8 taskId) { - while (sPhase2_FrontierSquaresScroll_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierSquaresScroll_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } -static bool8 Phase2_FrontierSquares_Func1(struct Task *task) +static bool8 FrontierSquares_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset); - FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); - FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF); - FillBgTilemapBufferRect(0, 1, 0x1D, 0, 1, 0x20, 0xF); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); + FillBgTilemapBufferRect(0, 1, 0, 0, MARGIN_SIZE, 32, 15); + FillBgTilemapBufferRect(0, 1, 30 - MARGIN_SIZE, 0, MARGIN_SIZE, 32, 15); CopyBgTilemapBufferToVram(0); - LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20); + LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); - task->tData2 = 1; - task->tData3 = 0; - task->tData4 = 0; - task->tData7 = 10; + task->tPosX = MARGIN_SIZE; + task->tPosY = 0; + task->tRowPos = 0; + task->tShrinkDelay = 10; task->tState++; return FALSE; } -static bool8 Phase2_FrontierSquares_Func2(struct Task *task) +static bool8 FrontierSquares_Draw(struct Task *task) { - CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, 4, 4, task->tData2, task->tData3, 4, 4, 0xF, 0, 0); + CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, + SQUARE_SIZE, SQUARE_SIZE, + task->tPosX, task->tPosY, + SQUARE_SIZE, SQUARE_SIZE, + 15, 0, 0); CopyBgTilemapBufferToVram(0); - task->tData2 += 4; - if (++task->tData4 == 7) + task->tPosX += SQUARE_SIZE; + if (++task->tRowPos == NUM_SQUARES_PER_ROW) { - task->tData2 = 1; - task->tData3 += 4; - task->tData4 = 0; - if (task->tData3 > 19) + task->tPosX = MARGIN_SIZE; + task->tPosY += SQUARE_SIZE; + task->tRowPos = 0; + if (task->tPosY >= NUM_SQUARES_PER_COL * SQUARE_SIZE) task->tState++; } return FALSE; } -static bool8 Phase2_FrontierSquares_Func3(struct Task *task) +static bool8 FrontierSquares_Shrink(struct Task *task) { u8 i; u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); - if (task->tData6++ >= task->tData7) + if (task->tShrinkDelayTimer++ >= task->tShrinkDelay) { - switch (task->tData5) + switch (task->tShrinkState) { case 0: for (i = 250; i < 255; i++) { - gPlttBufferUnfaded[i] = 0; - gPlttBufferFaded[i] = 0; + gPlttBufferUnfaded[i] = RGB_BLACK; + gPlttBufferFaded[i] = RGB_BLACK; } break; case 1: - BlendPalettes(PALETTES_ALL & ~(0x8000), 0x10, 0); + BlendPalettes(PALETTES_ALL & ~(1 << 15), 16, RGB_BLACK); LZ77UnCompVram(sFrontierSquares_EmptyBg_Tileset, tileset); break; case 2: @@ -4085,169 +4515,183 @@ static bool8 Phase2_FrontierSquares_Func3(struct Task *task) LZ77UnCompVram(sFrontierSquares_Shrink2_Tileset, tileset); break; default: - FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 32, 32); CopyBgTilemapBufferToVram(0); task->tState++; return FALSE; } - task->tData6 = 0; - task->tData5++; + task->tShrinkDelayTimer = 0; + task->tShrinkState++; } return FALSE; } -static bool8 Phase2_FrontierSquaresSpiral_Func1(struct Task *task) +#undef tPosX +#undef tPosY +#undef tRowPos +#undef tShrinkState +#undef tShrinkDelayTimer +#undef tShrinkDelay + +#define tSquareNum data[2] +#define tFadeFlag data[3] + +static bool8 FrontierSquaresSpiral_Init(struct Task *task) { u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset); - FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); - FillBgTilemapBufferRect(0, 1, 0, 0, 1, 0x20, 0xF); - FillBgTilemapBufferRect(0, 1, 0x1D, 0, 1, 0x20, 0xF); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); + FillBgTilemapBufferRect(0, 1, 0, 0, MARGIN_SIZE, 32, 15); + FillBgTilemapBufferRect(0, 1, 30 - MARGIN_SIZE, 0, MARGIN_SIZE, 32, 15); CopyBgTilemapBufferToVram(0); - LoadPalette(sFrontierSquares_Palette, 0xE0, 0x20); - LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20); - BlendPalette(0xE0, 0x10, 8, 0); + LoadPalette(sFrontierSquares_Palette, 0xE0, sizeof(sFrontierSquares_Palette)); + LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); + BlendPalette(0xE0, 16, 8, RGB_BLACK); - task->tData2 = 34; - task->tData3 = 0; + task->tSquareNum = NUM_SQUARES - 1; + task->tFadeFlag = 0; task->tState++; return FALSE; } -static bool8 Phase2_FrontierSquaresSpiral_Func2(struct Task *task) +static bool8 FrontierSquaresSpiral_Outward(struct Task *task) { - u8 var = gUnknown_085C9A30[task->tData2]; - u8 varMod = var % 7; - u8 varDiv = var / 7; - CopyRectToBgTilemapBufferRect(0, &sFrontierSquares_Tilemap, 0, 0, 4, 4, 4 * varMod + 1, 4 * varDiv, 4, 4, 0xF, 0, 0); + u8 pos = sFrontierSquaresSpiral_Positions[task->tSquareNum]; + u8 x = pos % NUM_SQUARES_PER_ROW; + u8 y = pos / NUM_SQUARES_PER_ROW; + CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, + SQUARE_SIZE, SQUARE_SIZE, + SQUARE_SIZE * x + MARGIN_SIZE, SQUARE_SIZE * y, + SQUARE_SIZE, SQUARE_SIZE, + 15, 0, 0); CopyBgTilemapBufferToVram(0); - if (--task->tData2 < 0) + if (--task->tSquareNum < 0) task->tState++; return FALSE; } -static bool8 Phase2_FrontierSquaresSpiral_Func3(struct Task *task) +// Now that the overworld is completely covered by the squares, +// set it to black so it's not revealed when the squares are removed. +static bool8 FrontierSquaresSpiral_SetBlack(struct Task *task) { - BlendPalette(0xE0, 0x10, 3, 0); - BlendPalettes(PALETTES_ALL & ~(0x8000 | 0x4000), 0x10, 0); + BlendPalette(0xE0, 16, 3, RGB_BLACK); + BlendPalettes(PALETTES_ALL & ~(1 << 15 | 1 << 14), 16, RGB_BLACK); - task->tData2 = 0; - task->tData3 = 0; + task->tSquareNum = 0; + task->tFadeFlag = 0; task->tState++; return FALSE; } -static bool8 Phase2_FrontierSquaresSpiral_Func4(struct Task *task) +// Spiral inward erasing the squares +static bool8 FrontierSquaresSpiral_Inward(struct Task *task) { - if ((task->tData3 ^= 1)) + // Each square is faded first, then the one that was faded last move is erased. + if (task->tFadeFlag ^= 1) { - CopyRectToBgTilemapBufferRect( - 0, - sFrontierSquares_Tilemap, - 0, - 0, - 4, - 4, - 4 * (gUnknown_085C9A30[task->tData2] % 7) + 1, - 4 * (gUnknown_085C9A30[task->tData2] / 7), - 4, - 4, - 0xE, - 0, - 0); + // Shade square + CopyRectToBgTilemapBufferRect(0, sFrontierSquares_Tilemap, 0, 0, + SQUARE_SIZE, SQUARE_SIZE, + SQUARE_SIZE * (sFrontierSquaresSpiral_Positions[task->tSquareNum] % NUM_SQUARES_PER_ROW) + MARGIN_SIZE, + SQUARE_SIZE * (sFrontierSquaresSpiral_Positions[task->tSquareNum] / NUM_SQUARES_PER_ROW), + SQUARE_SIZE, SQUARE_SIZE, + 14, 0, 0); } else { - if (task->tData2 > 0) + if (task->tSquareNum > 0) { - FillBgTilemapBufferRect( - 0, - 1, - 4 * (gUnknown_085C9A30[task->tData2 - 1] % 7) + 1, - 4 * (gUnknown_085C9A30[task->tData2 - 1] / 7), - 4, - 4, - 0xF); + // Erase square + FillBgTilemapBufferRect(0, 1, + SQUARE_SIZE * (sFrontierSquaresSpiral_Positions[task->tSquareNum - 1] % NUM_SQUARES_PER_ROW) + MARGIN_SIZE, + SQUARE_SIZE * (sFrontierSquaresSpiral_Positions[task->tSquareNum - 1] / NUM_SQUARES_PER_ROW), + SQUARE_SIZE, SQUARE_SIZE, + 15); } - - task->tData2++; + task->tSquareNum++; } - if (task->tData2 > 34) + if (task->tSquareNum >= NUM_SQUARES) task->tState++; CopyBgTilemapBufferToVram(0); return FALSE; } -static bool8 Phase2_FrontierSquares_End(struct Task *task) +static bool8 FrontierSquares_End(struct Task *task) { - FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 32, 32); CopyBgTilemapBufferToVram(0); - BlendPalettes(PALETTES_ALL, 0x10, 0); + BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); DestroyTask(FindTaskIdByFunc(task->func)); return FALSE; } -// sub task for phase2 32 -#define tSub32_X_delta data[0] -#define tSub32_Y_delta data[1] -#define tSub32_Bool data[2] +#undef tSquareNum +#undef tFadeFlag + +#define tScrollXDir data[0] +#define tScrollYDir data[1] +#define tScrollUpdateFlag data[2] + +#define tSquareNum data[2] -static void sub_814ABE4(u8 taskId) +static void Task_ScrollBg(u8 taskId) { - if (!(gTasks[taskId].tSub32_Bool ^= 1)) + if (!(gTasks[taskId].tScrollUpdateFlag ^= 1)) { SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_X); SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_Y); - gBattle_BG0_X += gTasks[taskId].tSub32_X_delta; - gBattle_BG0_Y += gTasks[taskId].tSub32_Y_delta; + gBattle_BG0_X += gTasks[taskId].tScrollXDir; + gBattle_BG0_Y += gTasks[taskId].tScrollYDir; } } -static bool8 Phase2_FrontierSquaresScroll_Func1(struct Task *task) +static bool8 FrontierSquaresScroll_Init(struct Task *task) { u8 taskId = 0; u16 *tilemap, *tileset; GetBg0TilesDst(&tilemap, &tileset); LZ77UnCompVram(sFrontierSquares_FilledBg_Tileset, tileset); - FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); CopyBgTilemapBufferToVram(0); - LoadPalette(sFrontierSquares_Palette, 0xF0, 0x20); + LoadPalette(sFrontierSquares_Palette, 0xF0, sizeof(sFrontierSquares_Palette)); gBattle_BG0_X = 0; gBattle_BG0_Y = 0; SetGpuReg(REG_OFFSET_BG0VOFS, gBattle_BG0_X); SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_Y); - task->tData2 = 0; - taskId = CreateTask(sub_814ABE4, 1); + task->tSquareNum = 0; + + // Start scrolling bg in a random direction. + taskId = CreateTask(Task_ScrollBg, 1); switch (Random() % 4) { - case 0: - gTasks[taskId].tSub32_X_delta = 1; - gTasks[taskId].tSub32_Y_delta = 1; + case 0: // Down/right + gTasks[taskId].tScrollXDir = 1; + gTasks[taskId].tScrollYDir = 1; break; - case 1: - gTasks[taskId].tSub32_X_delta = -1; - gTasks[taskId].tSub32_Y_delta = -1; + case 1: // Up/left + gTasks[taskId].tScrollXDir = -1; + gTasks[taskId].tScrollYDir = -1; break; - case 2: - gTasks[taskId].tSub32_X_delta = 1; - gTasks[taskId].tSub32_Y_delta = -1; + case 2: // Up/right + gTasks[taskId].tScrollXDir = 1; + gTasks[taskId].tScrollYDir = -1; break; - default: - gTasks[taskId].tSub32_X_delta = -1; - gTasks[taskId].tSub32_Y_delta = 1; + default: // Down/left + gTasks[taskId].tScrollXDir = -1; + gTasks[taskId].tScrollYDir = 1; break; } @@ -4255,75 +4699,67 @@ static bool8 Phase2_FrontierSquaresScroll_Func1(struct Task *task) return FALSE; } -static bool8 Phase2_FrontierSquaresScroll_Func2(struct Task *task) -{ - u8 var = gUnknown_085C9A53[task->tData2]; - u8 varDiv = var / 8; - u8 varAnd = var & 7; - - CopyRectToBgTilemapBufferRect( - 0, - &sFrontierSquares_Tilemap, - 0, - 0, - 4, - 4, - 4 * varDiv + 1, - 4 * varAnd, - 4, - 4, - 0xF, - 0, - 0); +static bool8 FrontierSquaresScroll_Draw(struct Task *task) +{ + u8 pos = sFrontierSquaresScroll_Positions[task->tSquareNum]; + u8 x = pos / (NUM_SQUARES_PER_ROW + 1); // +1 because during scroll an additional column covers the margin. + u8 y = pos % (NUM_SQUARES_PER_ROW + 1); + + CopyRectToBgTilemapBufferRect(0, &sFrontierSquares_Tilemap, 0, 0, + SQUARE_SIZE, SQUARE_SIZE, + SQUARE_SIZE * x + MARGIN_SIZE, SQUARE_SIZE * y, + SQUARE_SIZE, SQUARE_SIZE, + 15, 0, 0); CopyBgTilemapBufferToVram(0); - if (++task->tData2 > 63) + if (++task->tSquareNum >= (int)ARRAY_COUNT(sFrontierSquaresScroll_Positions)) task->tState++; return 0; } -static bool8 Phase2_FrontierSquaresScroll_Func3(struct Task *task) +// Now that the overworld is completely covered by the squares, +// set it to black so it's not revealed when the squares are removed. +static bool8 FrontierSquaresScroll_SetBlack(struct Task *task) { - BlendPalettes(PALETTES_ALL & ~(0x8000), 0x10, 0); + BlendPalettes(PALETTES_ALL & ~(1 << 15), 16, RGB_BLACK); - task->tData2 = 0; + task->tSquareNum = 0; task->tState++; return FALSE; } -static bool8 Phase2_FrontierSquaresScroll_Func4(struct Task *task) +static bool8 FrontierSquaresScroll_Erase(struct Task *task) { - u8 var = gUnknown_085C9A53[task->tData2]; - u8 varDiv = var / 8; - u8 varAnd = var & 7; + u8 pos = sFrontierSquaresScroll_Positions[task->tSquareNum]; + u8 x = pos / (NUM_SQUARES_PER_ROW + 1); + u8 y = pos % (NUM_SQUARES_PER_ROW + 1); - FillBgTilemapBufferRect(0, 1, 4 * varDiv + 1, 4 * varAnd, 4, 4, 0xF); + FillBgTilemapBufferRect(0, 1, + SQUARE_SIZE * x + MARGIN_SIZE, SQUARE_SIZE * y, + SQUARE_SIZE, SQUARE_SIZE, + 15); CopyBgTilemapBufferToVram(0); - if (++task->tData2 > 63) + if (++task->tSquareNum >= (int)ARRAY_COUNT(sFrontierSquaresScroll_Positions)) { - DestroyTask(FindTaskIdByFunc(sub_814ABE4)); + DestroyTask(FindTaskIdByFunc(Task_ScrollBg)); task->tState++; } return FALSE; } -#undef tSub32_X_delta -#undef tSub32_Y_delta -#undef tSub32_Bool - -static bool8 Phase2_FrontierSquaresScroll_Func5(struct Task *task) +static bool8 FrontierSquaresScroll_End(struct Task *task) { gBattle_BG0_X = 0; gBattle_BG0_Y = 0; SetGpuReg(REG_OFFSET_BG0VOFS, 0); SetGpuReg(REG_OFFSET_BG0HOFS, gBattle_BG0_Y); - FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(0, 1, 0, 0, 32, 32); CopyBgTilemapBufferToVram(0); - BlendPalettes(PALETTES_ALL, 0x10, 0); + BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); DestroyTask(FindTaskIdByFunc(task->func)); @@ -4333,10 +4769,7 @@ static bool8 Phase2_FrontierSquaresScroll_Func5(struct Task *task) return FALSE; } -#undef tData1 -#undef tData2 -#undef tData3 -#undef tData4 -#undef tData5 -#undef tData6 -#undef tData7 +#undef tScrollXDir +#undef tScrollYDir +#undef tScrollUpdateFlag +#undef tSquareNum diff --git a/src/battle_transition_frontier.c b/src/battle_transition_frontier.c index 2d34c9f86..a1a39abda 100644 --- a/src/battle_transition_frontier.c +++ b/src/battle_transition_frontier.c @@ -21,7 +21,6 @@ typedef bool8 (*TransitionStateFunc)(struct Task *task); -// this file's functions static void SpriteCB_LogoCircleSlide(struct Sprite *sprite); static void SpriteCB_LogoCircleSpiral(struct Sprite *sprite); static bool8 WaitForLogoCirclesAnim(struct Task *task); @@ -46,7 +45,6 @@ static bool8 CirclesSymmetricSpiralInSeq_End(struct Task *task); #define PALTAG_LOGO_CIRCLES 0x2E90 -// const rom data static const u32 sLogoCenter_Gfx[] = INCBIN_U32("graphics/battle_transitions/frontier_logo_center.4bpp.lz"); static const u32 sLogoCenter_Tilemap[] = INCBIN_U32("graphics/battle_transitions/frontier_logo_center.bin"); static const u32 sLogoCircles_Gfx[] = INCBIN_U32("graphics/battle_transitions/frontier_logo_circles.4bpp.lz"); @@ -121,7 +119,7 @@ static const struct SpriteTemplate sSpriteTemplate_LogoCircles = .callback = SpriteCallbackDummy, }; -static const TransitionStateFunc sPhase2_FrontierCirclesMeet_Funcs[] = +static const TransitionStateFunc sFrontierCirclesMeet_Funcs[] = { Circles_Init, CirclesMeet_CreateSprites, @@ -130,7 +128,7 @@ static const TransitionStateFunc sPhase2_FrontierCirclesMeet_Funcs[] = CirclesMeet_End }; -static const TransitionStateFunc sPhase2_FrontierCirclesCross_Funcs[] = +static const TransitionStateFunc sFrontierCirclesCross_Funcs[] = { Circles_Init, CirclesCross_CreateSprites, @@ -139,7 +137,7 @@ static const TransitionStateFunc sPhase2_FrontierCirclesCross_Funcs[] = CirclesCross_End }; -static const TransitionStateFunc sPhase2_FrontierCirclesAsymmetricSpiral_Funcs[] = +static const TransitionStateFunc sFrontierCirclesAsymmetricSpiral_Funcs[] = { Circles_Init, CirclesAsymmetricSpiral_CreateSprites, @@ -148,7 +146,7 @@ static const TransitionStateFunc sPhase2_FrontierCirclesAsymmetricSpiral_Funcs[] CirclesAsymmetricSpiral_End }; -static const TransitionStateFunc sPhase2_FrontierCirclesSymmetricSpiral_Funcs[] = +static const TransitionStateFunc sFrontierCirclesSymmetricSpiral_Funcs[] = { Circles_Init, CirclesSymmetricSpiral_CreateSprites, @@ -157,7 +155,7 @@ static const TransitionStateFunc sPhase2_FrontierCirclesSymmetricSpiral_Funcs[] CirclesSymmetricSpiral_End }; -static const TransitionStateFunc sPhase2_FrontierCirclesMeetInSeq_Funcs[] = +static const TransitionStateFunc sFrontierCirclesMeetInSeq_Funcs[] = { Circles_Init, CirclesMeetInSeq_CreateSprites, @@ -166,7 +164,7 @@ static const TransitionStateFunc sPhase2_FrontierCirclesMeetInSeq_Funcs[] = CirclesMeetInSeq_End }; -static const TransitionStateFunc sPhase2_FrontierCirclesCrossInSeq_Funcs[] = +static const TransitionStateFunc sFrontierCirclesCrossInSeq_Funcs[] = { Circles_Init, CirclesCrossInSeq_CreateSprites, @@ -175,7 +173,7 @@ static const TransitionStateFunc sPhase2_FrontierCirclesCrossInSeq_Funcs[] = CirclesCrossInSeq_End }; -static const TransitionStateFunc sPhase2_FrontierCirclesAsymmetricSpiralInSeq_Funcs[] = +static const TransitionStateFunc sFrontierCirclesAsymmetricSpiralInSeq_Funcs[] = { Circles_Init, CirclesAsymmetricSpiralInSeq_CreateSprites, @@ -184,7 +182,7 @@ static const TransitionStateFunc sPhase2_FrontierCirclesAsymmetricSpiralInSeq_Fu CirclesAsymmetricSpiralInSeq_End }; -static const TransitionStateFunc sPhase2_FrontierCirclesSymmetricSpiralInSeq_Funcs[] = +static const TransitionStateFunc sFrontierCirclesSymmetricSpiralInSeq_Funcs[] = { Circles_Init, CirclesSymmetricSpiralInSeq_CreateSprites, @@ -193,45 +191,72 @@ static const TransitionStateFunc sPhase2_FrontierCirclesSymmetricSpiralInSeq_Fun CirclesSymmetricSpiralInSeq_End }; -// code +// Task data +#define tState data[0] +#define tTimer data[1] +#define tBlend data[2] +#define tFadeTimer data[3] +#define tCircle1SpriteId data[4] +#define tCircle2SpriteId data[5] +#define tCircle3SpriteId data[6] + +#define sTargetX data[0] +#define sTargetY data[1] + +// Sprite data for CreateSlidingLogoCircleSprite +#define sSpeedX data[2] +#define sSpeedY data[3] +#define sTimerX data[4] +#define sTimerY data[5] +#define sDelayX data[6] +#define sDelayY data[7] + +// Sprite data for CreateSpiralingLogoCircleSprite +#define sAngle data[2] +#define sRotateSpeed data[3] +#define sRadius data[4] +#define sTargetRadius data[5] +#define sRadiusDelta data[6] + + static void LoadLogoGfx(void) { - u16 *dst1, *dst2; + u16 *tilemap, *tileset; - GetBg0TilesDst(&dst1, &dst2); - LZ77UnCompVram(sLogoCenter_Gfx, dst2); - LZ77UnCompVram(sLogoCenter_Tilemap, dst1); - LoadPalette(sLogo_Pal, 0xF0, 0x20); + GetBg0TilesDst(&tilemap, &tileset); + LZ77UnCompVram(sLogoCenter_Gfx, tileset); + LZ77UnCompVram(sLogoCenter_Tilemap, tilemap); + LoadPalette(sLogo_Pal, 0xF0, sizeof(sLogo_Pal)); LoadCompressedSpriteSheet(&sSpriteSheet_LogoCircles); LoadSpritePalette(&sSpritePalette_LogoCircles); } -static u8 CreateSlidingLogoCircleSprite(s16 x, s16 y, u8 arg2, u8 arg3, s8 arg4, s8 arg5, u8 spriteAnimNum) +static u8 CreateSlidingLogoCircleSprite(s16 x, s16 y, u8 delayX, u8 delayY, s8 speedX, s8 speedY, u8 spriteAnimNum) { u8 spriteId = CreateSprite(&sSpriteTemplate_LogoCircles, x, y, 0); switch (spriteAnimNum) { case 0: - gSprites[spriteId].data[0] = 120; - gSprites[spriteId].data[1] = 45; + gSprites[spriteId].sTargetX = 120; + gSprites[spriteId].sTargetY = 45; break; case 1: - gSprites[spriteId].data[0] = 89; - gSprites[spriteId].data[1] = 97; + gSprites[spriteId].sTargetX = 89; + gSprites[spriteId].sTargetY = 97; break; case 2: - gSprites[spriteId].data[0] = 151; - gSprites[spriteId].data[1] = 97; + gSprites[spriteId].sTargetX = 151; + gSprites[spriteId].sTargetY = 97; break; } - gSprites[spriteId].data[2] = arg4; - gSprites[spriteId].data[3] = arg5; - gSprites[spriteId].data[6] = arg2; - gSprites[spriteId].data[7] = arg3; - gSprites[spriteId].data[4] = 0; - gSprites[spriteId].data[5] = 0; + gSprites[spriteId].sSpeedX = speedX; + gSprites[spriteId].sSpeedY = speedY; + gSprites[spriteId].sDelayX = delayX; + gSprites[spriteId].sDelayY = delayY; + gSprites[spriteId].sTimerX = 0; + gSprites[spriteId].sTimerY = 0; StartSpriteAnim(&gSprites[spriteId], spriteAnimNum); gSprites[spriteId].callback = SpriteCB_LogoCircleSlide; @@ -243,59 +268,60 @@ static void SpriteCB_LogoCircleSlide(struct Sprite *sprite) { s16 *data = sprite->data; - if (sprite->x == data[0] && sprite->y == data[1]) + if (sprite->x == sTargetX && sprite->y == sTargetY) { sprite->callback = SpriteCallbackDummy; } else { - if (data[4] == data[6]) + if (sTimerX == sDelayX) { - sprite->x += data[2]; - data[4] = 0; + sprite->x += sSpeedX; + sTimerX = 0; } else { - data[4]++; + sTimerX++; } - if (data[5] == data[7]) + if (sTimerY == sDelayY) { - sprite->y += data[3]; - data[5] = 0; + sprite->y += sSpeedY; + sTimerY = 0; } else { - data[5]++; + sTimerY++; } } } -static u8 CreateSpiralingLogoCircleSprite(s16 x, s16 y, s16 arg2, s16 arg3, s16 arg4, s16 arg5, s16 arg6, u8 spriteAnimNum) +static u8 CreateSpiralingLogoCircleSprite(s16 x, s16 y, s16 angle, s16 rotateSpeed, s16 radiusStart, s16 radiusEnd, s16 radiusDelta, u8 spriteAnimNum) { u8 spriteId = CreateSprite(&sSpriteTemplate_LogoCircles, x, y, 0); + // Target coords are set but irrelevant switch (spriteAnimNum) { case 0: - gSprites[spriteId].data[0] = 120; - gSprites[spriteId].data[1] = 45; + gSprites[spriteId].sTargetX = 120; + gSprites[spriteId].sTargetY = 45; break; case 1: - gSprites[spriteId].data[0] = 89; - gSprites[spriteId].data[1] = 97; + gSprites[spriteId].sTargetX = 89; + gSprites[spriteId].sTargetY = 97; break; case 2: - gSprites[spriteId].data[0] = 151; - gSprites[spriteId].data[1] = 97; + gSprites[spriteId].sTargetX = 151; + gSprites[spriteId].sTargetY = 97; break; } - gSprites[spriteId].data[2] = arg2; - gSprites[spriteId].data[3] = arg3; - gSprites[spriteId].data[4] = arg4; - gSprites[spriteId].data[5] = arg5; - gSprites[spriteId].data[6] = arg6; + gSprites[spriteId].sAngle = angle; + gSprites[spriteId].sRotateSpeed = rotateSpeed; + gSprites[spriteId].sRadius = radiusStart; + gSprites[spriteId].sTargetRadius = radiusEnd; + gSprites[spriteId].sRadiusDelta = radiusDelta; StartSpriteAnim(&gSprites[spriteId], spriteAnimNum); gSprites[spriteId].callback = SpriteCB_LogoCircleSpiral; @@ -305,34 +331,32 @@ static u8 CreateSpiralingLogoCircleSprite(s16 x, s16 y, s16 arg2, s16 arg3, s16 static void SpriteCB_LogoCircleSpiral(struct Sprite *sprite) { - sprite->x2 = (Sin2(sprite->data[2]) * sprite->data[4]) >> 12; // div by 4096 - sprite->y2 = (Cos2(sprite->data[2]) * sprite->data[4]) >> 12; // div by 4096 + sprite->x2 = (Sin2(sprite->sAngle) * sprite->sRadius) >> 12; // div by 4096 + sprite->y2 = (Cos2(sprite->sAngle) * sprite->sRadius) >> 12; // div by 4096 - sprite->data[2] = (sprite->data[2] + sprite->data[3]) % 360; + sprite->sAngle = (sprite->sAngle + sprite->sRotateSpeed) % 360; - if (sprite->data[4] != sprite->data[5]) - sprite->data[4] += sprite->data[6]; + if (sprite->sRadius != sprite->sTargetRadius) + sprite->sRadius += sprite->sRadiusDelta; else sprite->callback = SpriteCallbackDummy; } -#define tState data[0] - static void DestroyLogoCirclesGfx(struct Task *task) { FreeSpriteTilesByTag(PALTAG_LOGO_CIRCLES); FreeSpritePaletteByTag(PALTAG_LOGO_CIRCLES); - DestroySprite(&gSprites[task->data[4]]); - DestroySprite(&gSprites[task->data[5]]); - DestroySprite(&gSprites[task->data[6]]); + DestroySprite(&gSprites[task->tCircle1SpriteId]); + DestroySprite(&gSprites[task->tCircle2SpriteId]); + DestroySprite(&gSprites[task->tCircle3SpriteId]); } static bool8 IsLogoCirclesAnimFinished(struct Task *task) { - if (gSprites[task->data[4]].callback == SpriteCallbackDummy - && gSprites[task->data[5]].callback == SpriteCallbackDummy - && gSprites[task->data[6]].callback == SpriteCallbackDummy) + if (gSprites[task->tCircle1SpriteId].callback == SpriteCallbackDummy + && gSprites[task->tCircle2SpriteId].callback == SpriteCallbackDummy + && gSprites[task->tCircle3SpriteId].callback == SpriteCallbackDummy) return TRUE; else return FALSE; @@ -340,13 +364,13 @@ static bool8 IsLogoCirclesAnimFinished(struct Task *task) static bool8 Circles_Init(struct Task *task) { - if (task->data[1] == 0) + if (task->tTimer == 0) { ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN1_ON); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON); - task->data[1]++; + task->tTimer++; return FALSE; } else @@ -354,11 +378,11 @@ static bool8 Circles_Init(struct Task *task) LoadLogoGfx(); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG0 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0, 16)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgY(0, 0x500, 2); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgY(0, 0x500, BG_COORD_SUB); - task->data[1] = 0; + task->tTimer = 0; task->tState++; return TRUE; } @@ -366,27 +390,27 @@ static bool8 Circles_Init(struct Task *task) static bool8 FadeInCenterLogoCircle(struct Task *task) { - if (task->data[2] == 0) + if (task->tBlend == 0) SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG0_ON); - if (task->data[2] == 16) + if (task->tBlend == 16) { - if (task->data[3] == 31) + if (task->tFadeTimer == 31) { BeginNormalPaletteFade(PALETTES_ALL, -1, 0, 0x10, RGB_BLACK); task->tState++; } else { - task->data[3]++; + task->tFadeTimer++; } } else { u16 blnd; - task->data[2]++; - blnd = task->data[2]; + task->tBlend++; + blnd = task->tBlend; SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(blnd, 16 - blnd)); } @@ -401,16 +425,16 @@ static bool8 WaitForLogoCirclesAnim(struct Task *task) return FALSE; } -void Phase2Task_FrontierCirclesMeet(u8 taskId) +void Task_FrontierCirclesMeet(u8 taskId) { - while (sPhase2_FrontierCirclesMeet_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierCirclesMeet_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static bool8 CirclesMeet_CreateSprites(struct Task *task) { - task->data[4] = CreateSlidingLogoCircleSprite(120, -51, 0, 0, 0, 2, 0); - task->data[5] = CreateSlidingLogoCircleSprite(-7, 193, 0, 0, 2, -2, 1); - task->data[6] = CreateSlidingLogoCircleSprite(247, 193, 0, 0, -2, -2, 2); + task->tCircle1SpriteId = CreateSlidingLogoCircleSprite(120, -51, 0, 0, 0, 2, 0); + task->tCircle2SpriteId = CreateSlidingLogoCircleSprite(-7, 193, 0, 0, 2, -2, 1); + task->tCircle3SpriteId = CreateSlidingLogoCircleSprite(247, 193, 0, 0, -2, -2, 2); task->tState++; return FALSE; @@ -421,22 +445,22 @@ static bool8 CirclesMeet_End(struct Task *task) if (!gPaletteFade.active) { DestroyLogoCirclesGfx(task); - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesMeet)); + DestroyTask(FindTaskIdByFunc(Task_FrontierCirclesMeet)); } return FALSE; } -void Phase2Task_FrontierCirclesCross(u8 taskId) +void Task_FrontierCirclesCross(u8 taskId) { - while (sPhase2_FrontierCirclesCross_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierCirclesCross_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static bool8 CirclesCross_CreateSprites(struct Task *task) { - task->data[4] = CreateSlidingLogoCircleSprite(120, 197, 0, 0, 0, -4, 0); - task->data[5] = CreateSlidingLogoCircleSprite(241, 59, 0, 1, -4, 2, 1); - task->data[6] = CreateSlidingLogoCircleSprite(-1, 59, 0, 1, 4, 2, 2); + task->tCircle1SpriteId = CreateSlidingLogoCircleSprite(120, 197, 0, 0, 0, -4, 0); + task->tCircle2SpriteId = CreateSlidingLogoCircleSprite(241, 59, 0, 1, -4, 2, 1); + task->tCircle3SpriteId = CreateSlidingLogoCircleSprite(-1, 59, 0, 1, 4, 2, 2); task->tState++; return FALSE; @@ -447,22 +471,22 @@ static bool8 CirclesCross_End(struct Task *task) if (!gPaletteFade.active) { DestroyLogoCirclesGfx(task); - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesCross)); + DestroyTask(FindTaskIdByFunc(Task_FrontierCirclesCross)); } return FALSE; } -void Phase2Task_FrontierCirclesAsymmetricSpiral(u8 taskId) +void Task_FrontierCirclesAsymmetricSpiral(u8 taskId) { - while (sPhase2_FrontierCirclesAsymmetricSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierCirclesAsymmetricSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static bool8 CirclesAsymmetricSpiral_CreateSprites(struct Task *task) { - task->data[4] = CreateSpiralingLogoCircleSprite(120, 45, 12, 4, 128, 0, -4, 0); - task->data[5] = CreateSpiralingLogoCircleSprite(89, 97, 252, 4, 128, 0, -4, 1); - task->data[6] = CreateSpiralingLogoCircleSprite(151, 97, 132, 4, 128, 0, -4, 2); + task->tCircle1SpriteId = CreateSpiralingLogoCircleSprite(120, 45, 12, 4, 128, 0, -4, 0); + task->tCircle2SpriteId = CreateSpiralingLogoCircleSprite(89, 97, 252, 4, 128, 0, -4, 1); + task->tCircle3SpriteId = CreateSpiralingLogoCircleSprite(151, 97, 132, 4, 128, 0, -4, 2); task->tState++; return FALSE; @@ -473,22 +497,22 @@ static bool8 CirclesAsymmetricSpiral_End(struct Task *task) if (!gPaletteFade.active) { DestroyLogoCirclesGfx(task); - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesAsymmetricSpiral)); + DestroyTask(FindTaskIdByFunc(Task_FrontierCirclesAsymmetricSpiral)); } return FALSE; } -void Phase2Task_FrontierCirclesSymmetricSpiral(u8 taskId) +void Task_FrontierCirclesSymmetricSpiral(u8 taskId) { - while (sPhase2_FrontierCirclesSymmetricSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierCirclesSymmetricSpiral_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static bool8 CirclesSymmetricSpiral_CreateSprites(struct Task *task) { - task->data[4] = CreateSpiralingLogoCircleSprite(120, 80, 284, 8, 131, 35, -3, 0); - task->data[5] = CreateSpiralingLogoCircleSprite(120, 80, 44, 8, 131, 35, -3, 1); - task->data[6] = CreateSpiralingLogoCircleSprite(121, 80, 164, 8, 131, 35, -3, 2); + task->tCircle1SpriteId = CreateSpiralingLogoCircleSprite(120, 80, 284, 8, 131, 35, -3, 0); + task->tCircle2SpriteId = CreateSpiralingLogoCircleSprite(120, 80, 44, 8, 131, 35, -3, 1); + task->tCircle3SpriteId = CreateSpiralingLogoCircleSprite(121, 80, 164, 8, 131, 35, -3, 2); task->tState++; return FALSE; @@ -499,34 +523,34 @@ static bool8 CirclesSymmetricSpiral_End(struct Task *task) if (!gPaletteFade.active) { DestroyLogoCirclesGfx(task); - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesSymmetricSpiral)); + DestroyTask(FindTaskIdByFunc(Task_FrontierCirclesSymmetricSpiral)); } return FALSE; } -void Phase2Task_FrontierCirclesMeetInSeq(u8 taskId) +void Task_FrontierCirclesMeetInSeq(u8 taskId) { - while (sPhase2_FrontierCirclesMeetInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierCirclesMeetInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static bool8 CirclesMeetInSeq_CreateSprites(struct Task *task) { - if (task->data[1] == 0) + if (task->tTimer == 0) { - task->data[4] = CreateSlidingLogoCircleSprite(120, -51, 0, 0, 0, 4, 0); + task->tCircle1SpriteId = CreateSlidingLogoCircleSprite(120, -51, 0, 0, 0, 4, 0); } - else if (task->data[1] == 16) + else if (task->tTimer == 16) { - task->data[5] = CreateSlidingLogoCircleSprite(-7, 193, 0, 0, 4, -4, 1); + task->tCircle2SpriteId = CreateSlidingLogoCircleSprite(-7, 193, 0, 0, 4, -4, 1); } - else if (task->data[1] == 32) + else if (task->tTimer == 32) { - task->data[6] = CreateSlidingLogoCircleSprite(247, 193, 0, 0, -4, -4, 2); + task->tCircle3SpriteId = CreateSlidingLogoCircleSprite(247, 193, 0, 0, -4, -4, 2); task->tState++; } - task->data[1]++; + task->tTimer++; return FALSE; } @@ -535,34 +559,34 @@ static bool8 CirclesMeetInSeq_End(struct Task *task) if (!gPaletteFade.active) { DestroyLogoCirclesGfx(task); - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesMeetInSeq)); + DestroyTask(FindTaskIdByFunc(Task_FrontierCirclesMeetInSeq)); } return FALSE; } -void Phase2Task_FrontierCirclesCrossInSeq(u8 taskId) +void Task_FrontierCirclesCrossInSeq(u8 taskId) { - while (sPhase2_FrontierCirclesCrossInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierCirclesCrossInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static bool8 CirclesCrossInSeq_CreateSprites(struct Task *task) { - if (task->data[1] == 0) + if (task->tTimer == 0) { - task->data[4] = CreateSlidingLogoCircleSprite(120, 197, 0, 0, 0, -8, 0); + task->tCircle1SpriteId = CreateSlidingLogoCircleSprite(120, 197, 0, 0, 0, -8, 0); } - else if (task->data[1] == 16) + else if (task->tTimer == 16) { - task->data[5] = CreateSlidingLogoCircleSprite(241, 78, 0, 0, -8, 1, 1); + task->tCircle2SpriteId = CreateSlidingLogoCircleSprite(241, 78, 0, 0, -8, 1, 1); } - else if (task->data[1] == 32) + else if (task->tTimer == 32) { - task->data[6] = CreateSlidingLogoCircleSprite(-1, 78, 0, 0, 8, 1, 2); + task->tCircle3SpriteId = CreateSlidingLogoCircleSprite(-1, 78, 0, 0, 8, 1, 2); task->tState++; } - task->data[1]++; + task->tTimer++; return FALSE; } @@ -571,34 +595,34 @@ static bool8 CirclesCrossInSeq_End(struct Task *task) if (!gPaletteFade.active) { DestroyLogoCirclesGfx(task); - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesCrossInSeq)); + DestroyTask(FindTaskIdByFunc(Task_FrontierCirclesCrossInSeq)); } return FALSE; } -void Phase2Task_FrontierCirclesAsymmetricSpiralInSeq(u8 taskId) +void Task_FrontierCirclesAsymmetricSpiralInSeq(u8 taskId) { - while (sPhase2_FrontierCirclesAsymmetricSpiralInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierCirclesAsymmetricSpiralInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static bool8 CirclesAsymmetricSpiralInSeq_CreateSprites(struct Task *task) { - if (task->data[1] == 0) + if (task->tTimer == 0) { - task->data[4] = CreateSpiralingLogoCircleSprite(120, 45, 12, 4, 128, 0, -4, 0); + task->tCircle1SpriteId = CreateSpiralingLogoCircleSprite(120, 45, 12, 4, 128, 0, -4, 0); } - else if (task->data[1] == 16) + else if (task->tTimer == 16) { - task->data[5] = CreateSpiralingLogoCircleSprite(89, 97, 252, 4, 128, 0, -4, 1); + task->tCircle2SpriteId = CreateSpiralingLogoCircleSprite(89, 97, 252, 4, 128, 0, -4, 1); } - else if (task->data[1] == 32) + else if (task->tTimer == 32) { - task->data[6] = CreateSpiralingLogoCircleSprite(151, 97, 132, 4, 128, 0, -4, 2); + task->tCircle3SpriteId = CreateSpiralingLogoCircleSprite(151, 97, 132, 4, 128, 0, -4, 2); task->tState++; } - task->data[1]++; + task->tTimer++; return FALSE; } @@ -607,34 +631,34 @@ static bool8 CirclesAsymmetricSpiralInSeq_End(struct Task *task) if (!gPaletteFade.active) { DestroyLogoCirclesGfx(task); - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesAsymmetricSpiralInSeq)); + DestroyTask(FindTaskIdByFunc(Task_FrontierCirclesAsymmetricSpiralInSeq)); } return FALSE; } -void Phase2Task_FrontierCirclesSymmetricSpiralInSeq(u8 taskId) +void Task_FrontierCirclesSymmetricSpiralInSeq(u8 taskId) { - while (sPhase2_FrontierCirclesSymmetricSpiralInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId])); + while (sFrontierCirclesSymmetricSpiralInSeq_Funcs[gTasks[taskId].tState](&gTasks[taskId])); } static bool8 CirclesSymmetricSpiralInSeq_CreateSprites(struct Task *task) { - if (task->data[1] == 0) + if (task->tTimer == 0) { - task->data[4] = CreateSpiralingLogoCircleSprite(120, 80, 284, 8, 131, 35, -3, 0); + task->tCircle1SpriteId = CreateSpiralingLogoCircleSprite(120, 80, 284, 8, 131, 35, -3, 0); } - else if (task->data[1] == 16) + else if (task->tTimer == 16) { - task->data[5] = CreateSpiralingLogoCircleSprite(120, 80, 44, 8, 131, 35, -3, 1); + task->tCircle2SpriteId = CreateSpiralingLogoCircleSprite(120, 80, 44, 8, 131, 35, -3, 1); } - else if (task->data[1] == 32) + else if (task->tTimer == 32) { - task->data[6] = CreateSpiralingLogoCircleSprite(121, 80, 164, 8, 131, 35, -3, 2); + task->tCircle3SpriteId = CreateSpiralingLogoCircleSprite(121, 80, 164, 8, 131, 35, -3, 2); task->tState++; } - task->data[1]++; + task->tTimer++; return FALSE; } @@ -643,7 +667,7 @@ static bool8 CirclesSymmetricSpiralInSeq_End(struct Task *task) if (!gPaletteFade.active) { DestroyLogoCirclesGfx(task); - DestroyTask(FindTaskIdByFunc(Phase2Task_FrontierCirclesSymmetricSpiralInSeq)); + DestroyTask(FindTaskIdByFunc(Task_FrontierCirclesSymmetricSpiralInSeq)); } return FALSE; diff --git a/src/battle_tv.c b/src/battle_tv.c index c78f1bff4..f65bf73ea 100644 --- a/src/battle_tv.c +++ b/src/battle_tv.c @@ -237,7 +237,7 @@ static const u16 sPoints_MoveEffect[NUM_BATTLE_MOVE_EFFECTS] = [EFFECT_FUTURE_SIGHT] = 1, [EFFECT_GUST] = 1, [EFFECT_FLINCH_MINIMIZE_HIT] = 1, - [EFFECT_SOLARBEAM] = 1, + [EFFECT_SOLAR_BEAM] = 1, [EFFECT_THUNDER] = 1, [EFFECT_TELEPORT] = 1, [EFFECT_BEAT_UP] = 2, diff --git a/src/berry_blender.c b/src/berry_blender.c index 9701c8c81..7d22eae77 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -1013,10 +1013,10 @@ static void DrawBlenderBg(void) ShowBg(0); ShowBg(1); SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); } static void InitBerryBlenderWindows(void) @@ -1608,7 +1608,7 @@ static void PrintPlayerNames(void) text[0] = EOS; StringCopy(text, gLinkPlayers[sBerryBlender->arrowIdToPlayerId[i]].name); - xPos = GetStringCenterAlignXOffset(1, text, 0x38); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, text, 0x38); if (playerId == sBerryBlender->arrowIdToPlayerId[i]) Blender_AddTextPrinter(i, text, xPos, 1, 0, 2); // Highlight player's name in red @@ -1616,7 +1616,7 @@ static void PrintPlayerNames(void) Blender_AddTextPrinter(i, text, xPos, 1, 0, 1); PutWindowTilemap(i); - CopyWindowToVram(i, 3); + CopyWindowToVram(i, COPYWIN_FULL); } } } @@ -2684,7 +2684,7 @@ static void CB2_EndBlenderGame(void) if (sBerryBlender->arrowIdToPlayerId[i] != NO_PLAYER) { PutWindowTilemap(i); - CopyWindowToVram(i, 3); + CopyWindowToVram(i, COPYWIN_FULL); } } break; @@ -2696,7 +2696,7 @@ static void CB2_EndBlenderGame(void) if (sBerryBlender->arrowIdToPlayerId[i] != NO_PLAYER) { PutWindowTilemap(i); - CopyWindowToVram(i, 3); + CopyWindowToVram(i, COPYWIN_FULL); } } break; @@ -3494,8 +3494,8 @@ static bool8 PrintBlendingResults(void) u16 minutes, seconds; u8 *txtPtr; - xPos = GetStringCenterAlignXOffset(1, sText_BlendingResults, 0xA8); - Blender_AddTextPrinter(5, sText_BlendingResults, xPos, 1, TEXT_SPEED_FF, 0); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, sText_BlendingResults, 0xA8); + Blender_AddTextPrinter(5, sText_BlendingResults, xPos, 1, TEXT_SKIP_DRAW, 0); if (sBerryBlender->numPlayers == BLENDER_MAX_PLAYERS) yPos = 17; @@ -3510,15 +3510,15 @@ static bool8 PrintBlendingResults(void) StringAppend(sBerryBlender->stringVar, sText_Dot); StringAppend(sBerryBlender->stringVar, gText_Space); StringAppend(sBerryBlender->stringVar, gLinkPlayers[place].name); - Blender_AddTextPrinter(5, sBerryBlender->stringVar, 8, yPos, TEXT_SPEED_FF, 3); + Blender_AddTextPrinter(5, sBerryBlender->stringVar, 8, yPos, TEXT_SKIP_DRAW, 3); StringCopy(sBerryBlender->stringVar, sBerryBlender->blendedBerries[place].name); ConvertInternationalString(sBerryBlender->stringVar, gLinkPlayers[place].language); StringAppend(sBerryBlender->stringVar, sText_SpaceBerry); - Blender_AddTextPrinter(5, sBerryBlender->stringVar, 0x54, yPos, TEXT_SPEED_FF, 3); + Blender_AddTextPrinter(5, sBerryBlender->stringVar, 0x54, yPos, TEXT_SKIP_DRAW, 3); } - Blender_AddTextPrinter(5, sText_MaximumSpeed, 0, 0x51, TEXT_SPEED_FF, 3); + Blender_AddTextPrinter(5, sText_MaximumSpeed, 0, 0x51, TEXT_SKIP_DRAW, 3); ConvertIntToDecimalStringN(sBerryBlender->stringVar, sBerryBlender->maxRPM / 100, STR_CONV_MODE_RIGHT_ALIGN, 3); StringAppend(sBerryBlender->stringVar, sText_Dot); @@ -3526,9 +3526,9 @@ static bool8 PrintBlendingResults(void) StringAppend(sBerryBlender->stringVar, text); StringAppend(sBerryBlender->stringVar, sText_RPM); - xPos = GetStringRightAlignXOffset(1, sBerryBlender->stringVar, 0xA8); - Blender_AddTextPrinter(5, sBerryBlender->stringVar, xPos, 0x51, TEXT_SPEED_FF, 3); - Blender_AddTextPrinter(5, sText_Time, 0, 0x61, TEXT_SPEED_FF, 3); + xPos = GetStringRightAlignXOffset(FONT_NORMAL, sBerryBlender->stringVar, 0xA8); + Blender_AddTextPrinter(5, sBerryBlender->stringVar, xPos, 0x51, TEXT_SKIP_DRAW, 3); + Blender_AddTextPrinter(5, sText_Time, 0, 0x61, TEXT_SKIP_DRAW, 3); seconds = (sBerryBlender->gameFrameTime / 60) % 60; minutes = (sBerryBlender->gameFrameTime / (60 * 60)); @@ -3539,13 +3539,13 @@ static bool8 PrintBlendingResults(void) ConvertIntToDecimalStringN(txtPtr, seconds, STR_CONV_MODE_LEADING_ZEROS, 2); StringAppend(sBerryBlender->stringVar, sText_Sec); - xPos = GetStringRightAlignXOffset(1, sBerryBlender->stringVar, 0xA8); - Blender_AddTextPrinter(5, sBerryBlender->stringVar, xPos, 0x61, TEXT_SPEED_FF, 3); + xPos = GetStringRightAlignXOffset(FONT_NORMAL, sBerryBlender->stringVar, 0xA8); + Blender_AddTextPrinter(5, sBerryBlender->stringVar, xPos, 0x61, TEXT_SKIP_DRAW, 3); sBerryBlender->framesToWait = 0; sBerryBlender->mainState++; - CopyWindowToVram(5, 2); + CopyWindowToVram(5, COPYWIN_GFX); } break; case 4: @@ -3562,7 +3562,7 @@ static bool8 PrintBlendingResults(void) if (sBerryBlender->arrowIdToPlayerId[i] != NO_PLAYER) { PutWindowTilemap(i); - CopyWindowToVram(i, 3); + CopyWindowToVram(i, COPYWIN_FULL); } } @@ -3693,8 +3693,8 @@ static bool8 PrintBlendingRanking(void) break; case 3: DrawStdFrameWithCustomTileAndPalette(5, 0, 1, 0xD); - xPos = GetStringCenterAlignXOffset(1, sText_Ranking, 168); - Blender_AddTextPrinter(5, sText_Ranking, xPos, 1, TEXT_SPEED_FF, 0); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, sText_Ranking, 168); + Blender_AddTextPrinter(5, sText_Ranking, xPos, 1, TEXT_SKIP_DRAW, 0); sBerryBlender->scoreIconIds[SCORE_BEST] = CreateSprite(&sSpriteTemplate_ScoreSymbols, 128, 52, 0); StartSpriteAnim(&gSprites[sBerryBlender->scoreIconIds[SCORE_BEST]], SCOREANIM_BEST_STATIC); @@ -3718,20 +3718,20 @@ static bool8 PrintBlendingRanking(void) StringAppend(sBerryBlender->stringVar, sText_Dot); StringAppend(sBerryBlender->stringVar, gText_Space); StringAppend(sBerryBlender->stringVar, gLinkPlayers[place].name); - Blender_AddTextPrinter(5, sBerryBlender->stringVar, 0, yPos, TEXT_SPEED_FF, 3); + Blender_AddTextPrinter(5, sBerryBlender->stringVar, 0, yPos, TEXT_SKIP_DRAW, 3); ConvertIntToDecimalStringN(sBerryBlender->stringVar, sBerryBlender->scores[place][SCORE_BEST], STR_CONV_MODE_RIGHT_ALIGN, 3); - Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78, yPos, TEXT_SPEED_FF, 3); + Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78, yPos, TEXT_SKIP_DRAW, 3); ConvertIntToDecimalStringN(sBerryBlender->stringVar, sBerryBlender->scores[place][SCORE_GOOD], STR_CONV_MODE_RIGHT_ALIGN, 3); - Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78 + 32, yPos, TEXT_SPEED_FF, 3); + Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78 + 32, yPos, TEXT_SKIP_DRAW, 3); ConvertIntToDecimalStringN(sBerryBlender->stringVar, sBerryBlender->scores[place][SCORE_MISS], STR_CONV_MODE_RIGHT_ALIGN, 3); - Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78 + 64, yPos, TEXT_SPEED_FF, 3); + Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78 + 64, yPos, TEXT_SKIP_DRAW, 3); } PutWindowTilemap(5); - CopyWindowToVram(5, 3); + CopyWindowToVram(5, COPYWIN_FULL); sBerryBlender->framesToWait = 0; sBerryBlender->mainState++; @@ -3767,9 +3767,9 @@ void ShowBerryBlenderRecordWindow(void) DrawStdWindowFrame(gRecordsWindowId, 0); FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1)); - xPos = GetStringCenterAlignXOffset(1, gText_BlenderMaxSpeedRecord, 144); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_BlenderMaxSpeedRecord, xPos, 1, 0, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_234Players, 4, 41, 0, NULL); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, gText_BlenderMaxSpeedRecord, 144); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_BlenderMaxSpeedRecord, xPos, 1, 0, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_234Players, 4, 41, 0, NULL); for (i = 0, yPos = 41; i < NUM_SCORE_TYPES; i++) { @@ -3783,12 +3783,12 @@ void ShowBerryBlenderRecordWindow(void) txtPtr = ConvertIntToDecimalStringN(txtPtr, record % 100, STR_CONV_MODE_LEADING_ZEROS, 2); txtPtr = StringAppend(txtPtr, sText_RPM); - xPos = GetStringRightAlignXOffset(1, text, 140); - AddTextPrinterParameterized(gRecordsWindowId, 1, text, xPos, yPos + (i * 16), 0, NULL); + xPos = GetStringRightAlignXOffset(FONT_NORMAL, text, 140); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, text, xPos, yPos + (i * 16), 0, NULL); } PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } static void Task_PlayPokeblockFanfare(u8 taskId) @@ -3879,7 +3879,7 @@ static void Blender_AddTextPrinter(u8 windowId, const u8 *string, u8 x, u8 y, s3 FillWindowPixelBuffer(windowId, PIXEL_FILL(txtColor[0])); } - AddTextPrinterParameterized4(windowId, 1, x, y, letterSpacing, 1, txtColor, speed, string); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, letterSpacing, 1, txtColor, speed, string); } static bool32 Blender_PrintText(s16 *textState, const u8 *string, s32 textSpeed) @@ -3890,7 +3890,7 @@ static bool32 Blender_PrintText(s16 *textState, const u8 *string, s32 textSpeed) DrawDialogFrameWithCustomTileAndPalette(4, FALSE, 0x14, 0xF); Blender_AddTextPrinter(4, string, 0, 1, textSpeed, 0); PutWindowTilemap(4); - CopyWindowToVram(4, 3); + CopyWindowToVram(4, COPYWIN_FULL); (*textState)++; break; case 1: diff --git a/src/berry_crush.c b/src/berry_crush.c index dcd7363bd..6f432a3f9 100755 --- a/src/berry_crush.c +++ b/src/berry_crush.c @@ -1202,12 +1202,12 @@ static s32 ShowGameDisplay(void) SetBgTilemapBuffer(1, game->gfx.bgBuffers[0]); SetBgTilemapBuffer(2, game->gfx.bgBuffers[2]); SetBgTilemapBuffer(3, game->gfx.bgBuffers[3]); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); break; @@ -1249,8 +1249,8 @@ static s32 ShowGameDisplay(void) CreateWirelessStatusIndicatorSprite(0, 0); CreateGameSprites(game); SetGpuReg(REG_OFFSET_BG1VOFS, -gSpriteCoordOffsetY); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); break; case 9: gPaletteFade.bufferTransferDisabled = FALSE; @@ -1591,8 +1591,8 @@ static void FramesToMinSec(struct BerryCrushGame_Gfx *gfx, u16 frames) static void PrintTextCentered(u8 windowId, u8 left, u8 colorId, const u8 *string) { - left = (left * 4) - (GetStringWidth(2, string, -1) / 2u); - AddTextPrinterParameterized3(windowId, 2, left, 0, sTextColorTable[colorId], 0, string); + left = (left * 4) - (GetStringWidth(FONT_SHORT, string, -1) / 2u); + AddTextPrinterParameterized3(windowId, FONT_SHORT, left, 0, sTextColorTable[colorId], 0, string); } static void PrintResultsText(struct BerryCrushGame * game, u8 page, u8 sp14, u8 baseY) @@ -1652,8 +1652,8 @@ static void PrintResultsText(struct BerryCrushGame * game, u8 page, u8 sp14, u8 StringExpandPlaceholders(gStringVar4, sResultsTexts[page]); break; } - x = GetStringRightAlignXOffset(2, gStringVar4, sp14 - 4); - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); + x = GetStringRightAlignXOffset(FONT_SHORT, gStringVar4, sp14 - 4); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); if (playerId == game->localId) StringCopy(gStringVar3, gText_1DotBlueF700); else @@ -1661,7 +1661,7 @@ static void PrintResultsText(struct BerryCrushGame * game, u8 page, u8 sp14, u8 gStringVar3[0] = ranking + CHAR_1; DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, game->players[playerId].name); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gStringVar3); - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, 4, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, 4, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); } } @@ -1676,34 +1676,34 @@ static void PrintCrushingResults(struct BerryCrushGame *game) FramesToMinSec(&game->gfx, results->time); // Print time text - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gText_TimeColon); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gText_TimeColon); // Print seconds text - x = 176 - (u8)GetStringWidth(2, gText_SpaceSec, -1); - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gText_SpaceSec); + x = 176 - (u8)GetStringWidth(FONT_SHORT, gText_SpaceSec, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gText_SpaceSec); // Print seconds value ConvertIntToDecimalStringN(gStringVar1, game->gfx.secondsInt, STR_CONV_MODE_LEADING_ZEROS, 2); ConvertIntToDecimalStringN(gStringVar2, game->gfx.secondsFrac, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_XDotY2); - x -= GetStringWidth(2, gStringVar4, -1); - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); + x -= GetStringWidth(FONT_SHORT, gStringVar4, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); // Print minutes text - x -= GetStringWidth(2, gText_SpaceMin, -1); - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gText_SpaceMin); + x -= GetStringWidth(FONT_SHORT, gText_SpaceMin, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gText_SpaceMin); // Print minutes value ConvertIntToDecimalStringN(gStringVar1, game->gfx.minutes, STR_CONV_MODE_LEADING_ZEROS, 1); StringExpandPlaceholders(gStringVar4, gText_StrVar1); - x -= GetStringWidth(2, gStringVar4, -1); - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); + x -= GetStringWidth(FONT_SHORT, gStringVar4, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); // Print pressing speed text y += 14; - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, 0, y, sTextColorTable[COLORID_GRAY], 0, gText_PressingSpeed); - x = 176 - (u8)GetStringWidth(2, gText_TimesPerSec, -1); - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gText_TimesPerSec); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, 0, y, sTextColorTable[COLORID_GRAY], 0, gText_PressingSpeed); + x = 176 - (u8)GetStringWidth(FONT_SHORT, gText_TimesPerSec, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gText_TimesPerSec); // Print pressing speed value for (i = 0; i < 8; i++) @@ -1712,21 +1712,21 @@ static void PrintCrushingResults(struct BerryCrushGame *game) ConvertIntToDecimalStringN(gStringVar1, game->pressingSpeed >> 8, STR_CONV_MODE_RIGHT_ALIGN, 3); ConvertIntToDecimalStringN(gStringVar2, pressingSpeedFrac / 1000000, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_XDotY3); - x -= GetStringWidth(2, gStringVar4, -1); + x -= GetStringWidth(FONT_SHORT, gStringVar4, -1); if (game->newRecord) - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_RED], 0, gStringVar4); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_RED], 0, gStringVar4); else - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); // Print silkiness text y += 14; - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, 0, y, sTextColorTable[COLORID_GRAY], 0, gText_Silkiness); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, 0, y, sTextColorTable[COLORID_GRAY], 0, gText_Silkiness); // Print silkiness value ConvertIntToDecimalStringN(gStringVar1, results->silkiness, STR_CONV_MODE_RIGHT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_Var1Percent); - x = 176 - (u8)GetStringWidth(2, gStringVar4, -1); - AddTextPrinterParameterized3(game->gfx.resultsWindowId, 2, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); + x = 176 - (u8)GetStringWidth(FONT_SHORT, gStringVar4, -1); + AddTextPrinterParameterized3(game->gfx.resultsWindowId, FONT_SHORT, x, y, sTextColorTable[COLORID_GRAY], 0, gStringVar4); } static bool32 OpenResultsWindow(struct BerryCrushGame *game, struct BerryCrushGame_Gfx *gfx) @@ -1778,7 +1778,7 @@ static bool32 OpenResultsWindow(struct BerryCrushGame *game, struct BerryCrushGa PrintCrushingResults(game); break; case 5: - CopyWindowToVram(gfx->resultsWindowId, 3); + CopyWindowToVram(gfx->resultsWindowId, COPYWIN_FULL); gfx->resultsState = 0; return TRUE; } @@ -1814,10 +1814,10 @@ static void Task_ShowRankings(u8 taskId) break; case 1: // Print header text - xPos = 96 - GetStringWidth(1, gText_BerryCrush2, -1) / 2u; - AddTextPrinterParameterized3(tWindowId, 1, xPos, 1, sTextColorTable[COLORID_BLUE], 0, gText_BerryCrush2); - xPos = 96 - GetStringWidth(1, gText_PressingSpeedRankings, -1) / 2u; - AddTextPrinterParameterized3(tWindowId, 1, xPos, 17, sTextColorTable[COLORID_BLUE], 0, gText_PressingSpeedRankings); + xPos = 96 - GetStringWidth(FONT_NORMAL, gText_BerryCrush2, -1) / 2u; + AddTextPrinterParameterized3(tWindowId, FONT_NORMAL, xPos, 1, sTextColorTable[COLORID_BLUE], 0, gText_BerryCrush2); + xPos = 96 - GetStringWidth(FONT_NORMAL, gText_PressingSpeedRankings, -1) / 2u; + AddTextPrinterParameterized3(tWindowId, FONT_NORMAL, xPos, 17, sTextColorTable[COLORID_BLUE], 0, gText_PressingSpeedRankings); // Print pressing speed record for each group size, ranked yPos = 41; @@ -1825,9 +1825,9 @@ static void Task_ShowRankings(u8 taskId) { ConvertIntToDecimalStringN(gStringVar1, i + 2, STR_CONV_MODE_LEFT_ALIGN, 1); StringExpandPlaceholders(gStringVar4, gText_Var1Players); - AddTextPrinterParameterized3(tWindowId, 1, 0, yPos, sTextColorTable[COLORID_GRAY], 0, gStringVar4); - xPos = 192 - (u8)GetStringWidth(1, gText_TimesPerSec, -1); - AddTextPrinterParameterized3(tWindowId, 1, xPos, yPos, sTextColorTable[COLORID_GRAY], 0, gText_TimesPerSec); + AddTextPrinterParameterized3(tWindowId, FONT_NORMAL, 0, yPos, sTextColorTable[COLORID_GRAY], 0, gStringVar4); + xPos = 192 - (u8)GetStringWidth(FONT_NORMAL, gText_TimesPerSec, -1); + AddTextPrinterParameterized3(tWindowId, FONT_NORMAL, xPos, yPos, sTextColorTable[COLORID_GRAY], 0, gText_TimesPerSec); for (j = 0; j < 8; j++) { if (((tPressingSpeeds(i) & 0xFF) >> (7 - j)) & 1) @@ -1836,12 +1836,12 @@ static void Task_ShowRankings(u8 taskId) ConvertIntToDecimalStringN(gStringVar1, (u16)tPressingSpeeds(i) >> 8, STR_CONV_MODE_RIGHT_ALIGN, 3); ConvertIntToDecimalStringN(gStringVar2, score / 1000000, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(gStringVar4, gText_XDotY3); - xPos -= GetStringWidth(1, gStringVar4, -1); - AddTextPrinterParameterized3(tWindowId, 1, xPos, yPos, sTextColorTable[COLORID_GRAY], 0, gStringVar4); + xPos -= GetStringWidth(FONT_NORMAL, gStringVar4, -1); + AddTextPrinterParameterized3(tWindowId, FONT_NORMAL, xPos, yPos, sTextColorTable[COLORID_GRAY], 0, gStringVar4); yPos += 16; score = 0; } - CopyWindowToVram(tWindowId, 3); + CopyWindowToVram(tWindowId, COPYWIN_FULL); break; case 2: if (JOY_NEW(A_BUTTON | B_BUTTON)) @@ -1913,8 +1913,8 @@ static void DrawPlayerNameWindows(struct BerryCrushGame *game) // Print the player's name AddTextPrinterParameterized4( game->gfx.nameWindowIds[i], - 2, - 36 - GetStringWidth(2, game->players[i].name, 0) / 2u, + FONT_SHORT, + 36 - GetStringWidth(FONT_SHORT, game->players[i].name, 0) / 2u, 1, 0, 0, @@ -1928,8 +1928,8 @@ static void DrawPlayerNameWindows(struct BerryCrushGame *game) // Print a partner's name AddTextPrinterParameterized4( game->gfx.nameWindowIds[i], - 2, - 36 - GetStringWidth(2, game->players[i].name, 0) / 2u, + FONT_SHORT, + 36 - GetStringWidth(FONT_SHORT, game->players[i].name, 0) / 2u, 1, 0, 0, @@ -1938,7 +1938,7 @@ static void DrawPlayerNameWindows(struct BerryCrushGame *game) game->players[i].name ); } - CopyWindowToVram(game->gfx.nameWindowIds[i], 3); + CopyWindowToVram(game->gfx.nameWindowIds[i], COPYWIN_FULL); } CopyBgTilemapBufferToVram(0); } @@ -2258,13 +2258,13 @@ static u32 Cmd_PrintMessage(struct BerryCrushGame *game, u8 *args) if (args[1] & F_MSG_EXPAND) { StringExpandPlaceholders(gStringVar4, sMessages[args[0]]); - AddTextPrinterParameterized2(0, 1, gStringVar4, game->textSpeed, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, game->textSpeed, 0, 2, 1, 3); } else { - AddTextPrinterParameterized2(0, 1, sMessages[args[0]], game->textSpeed, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sMessages[args[0]], game->textSpeed, 0, 2, 1, 3); } - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); break; case 1: if (!IsTextPrinterActive(0)) @@ -3242,8 +3242,8 @@ static u32 Cmd_SaveGame(struct BerryCrushGame *game, u8 *args) if (!IsLinkTaskFinished()) return 0; DrawDialogueFrame(0, 0); - AddTextPrinterParameterized2(0, 1, gText_SavingDontTurnOffPower, 0, 0, 2, 1, 3); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_SavingDontTurnOffPower, 0, 0, 2, 1, 3); + CopyWindowToVram(0, COPYWIN_FULL); CreateTask(Task_LinkSave, 0); break; case 3: @@ -3391,10 +3391,10 @@ static u32 Cmd_StopGame(struct BerryCrushGame *game, u8 *args) case 0: DrawDialogueFrame(0, 0); if (game->playAgainState == PLAY_AGAIN_NO_BERRIES) - AddTextPrinterParameterized2(0, 1, sMessages[MSG_NO_BERRIES], game->textSpeed, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sMessages[MSG_NO_BERRIES], game->textSpeed, 0, 2, 1, 3); else - AddTextPrinterParameterized2(0, 1, sMessages[MSG_DROPPED], game->textSpeed, 0, 2, 1, 3); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sMessages[MSG_DROPPED], game->textSpeed, 0, 2, 1, 3); + CopyWindowToVram(0, COPYWIN_FULL); break; case 1: if (IsTextPrinterActive(0)) diff --git a/src/berry_fix_program.c b/src/berry_fix_program.c index dc025c0a4..e8c4bc7e6 100644 --- a/src/berry_fix_program.c +++ b/src/berry_fix_program.c @@ -290,10 +290,10 @@ static void BerryFix_GpuSet(void) ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBerryFixBgTemplates, ARRAY_COUNT(sBerryFixBgTemplates)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); InitWindows(sBerryFixWindowTemplates); DeactivateAllTextPrinters(); @@ -303,25 +303,25 @@ static void BerryFix_GpuSet(void) FillWindowPixelBuffer(3, PIXEL_FILL(0)); FillWindowPixelBuffer(0, PIXEL_FILL(10)); - width = GetStringWidth(0, sText_Emerald, 0); + width = GetStringWidth(FONT_SMALL, sText_Emerald, 0); left = (120 - width) / 2; - AddTextPrinterParameterized3(2, 0, left, 3, sGameTitleTextColors, TEXT_SPEED_FF, sText_Emerald); + AddTextPrinterParameterized3(2, FONT_SMALL, left, 3, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_Emerald); - width = GetStringWidth(0, sText_RubySapphire, 0); + width = GetStringWidth(FONT_SMALL, sText_RubySapphire, 0); left = (120 - width) / 2 + 120; - AddTextPrinterParameterized3(2, 0, left, 3, sGameTitleTextColors, TEXT_SPEED_FF, sText_RubySapphire); + AddTextPrinterParameterized3(2, FONT_SMALL, left, 3, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_RubySapphire); - width = GetStringWidth(0, sText_RubySapphire, 0); + width = GetStringWidth(FONT_SMALL, sText_RubySapphire, 0); left = (112 - width) / 2; - AddTextPrinterParameterized3(3, 0, left, 0, sGameTitleTextColors, TEXT_SPEED_FF, sText_RubySapphire); + AddTextPrinterParameterized3(3, FONT_SMALL, left, 0, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_RubySapphire); - width = GetStringWidth(1, sText_BerryProgramUpdate, 0); + width = GetStringWidth(FONT_NORMAL, sText_BerryProgramUpdate, 0); left = (208 - width) / 2; - AddTextPrinterParameterized3(0, 1, left, 2, sBerryProgramTextColors, TEXT_SPEED_FF, sText_BerryProgramUpdate); + AddTextPrinterParameterized3(0, FONT_NORMAL, left, 2, sBerryProgramTextColors, TEXT_SKIP_DRAW, sText_BerryProgramUpdate); - CopyWindowToVram(2, 2); - CopyWindowToVram(3, 2); - CopyWindowToVram(0, 2); + CopyWindowToVram(2, COPYWIN_GFX); + CopyWindowToVram(3, COPYWIN_GFX); + CopyWindowToVram(0, COPYWIN_GFX); } static int BerryFix_TrySetScene(int scene) @@ -346,9 +346,9 @@ static void BerryFix_SetScene(int scene) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); FillWindowPixelBuffer(1, PIXEL_FILL(10)); - AddTextPrinterParameterized3(1, 1, 0, 0, sBerryProgramTextColors, -1, sBerryProgramTexts[scene]); + AddTextPrinterParameterized3(1, FONT_NORMAL, 0, 0, sBerryProgramTextColors, TEXT_SKIP_DRAW, sBerryProgramTexts[scene]); PutWindowTilemap(1); - CopyWindowToVram(1, 2); + CopyWindowToVram(1, COPYWIN_GFX); switch (scene) { case SCENE_ENSURE_CONNECT: diff --git a/src/berry_powder.c b/src/berry_powder.c index f77265412..96f14d6e4 100755 --- a/src/berry_powder.c +++ b/src/berry_powder.c @@ -205,13 +205,13 @@ u32 GetBerryPowder(void) static void PrintBerryPowderAmount(u8 windowId, int amount, u8 x, u8 y, u8 speed) { ConvertIntToDecimalStringN(gStringVar1, amount, STR_CONV_MODE_RIGHT_ALIGN, 5); - AddTextPrinterParameterized(windowId, 1, gStringVar1, x, y, speed, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar1, x, y, speed, NULL); } static void DrawPlayerPowderAmount(u8 windowId, u16 baseTileOffset, u8 paletteNum, u32 amount) { DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, baseTileOffset, paletteNum); - AddTextPrinterParameterized(windowId, 1, gText_Powder, 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_Powder, 0, 1, TEXT_SKIP_DRAW, NULL); PrintBerryPowderAmount(windowId, amount, 26, 17, 0); } diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index babbbb3eb..92b1f65d1 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -200,11 +200,11 @@ static void CB2_InitBerryTagScreen(void) { while (1) { - if (MenuHelpers_CallLinkSomething() == TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE) break; if (InitBerryTagScreen() == TRUE) break; - if (MenuHelpers_LinkSomething() == TRUE) + if (MenuHelpers_IsLinkActive() == TRUE) break; } } @@ -237,7 +237,7 @@ static bool8 InitBerryTagScreen(void) gMain.state++; break; case 5: - if (!MenuHelpers_LinkSomething()) + if (!MenuHelpers_IsLinkActive()) ResetTasks(); gMain.state++; break; @@ -376,14 +376,14 @@ static void HandleInitWindows(void) static void PrintTextInBerryTagScreen(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed, u8 colorStructId) { - AddTextPrinterParameterized4(windowId, 1, x, y, 0, 0, sTextColors[colorStructId], speed, text); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, 0, 0, sTextColors[colorStructId], speed, text); } static void AddBerryTagTextToBg0(void) { memcpy(GetBgTilemapBuffer(0), sBerryTag->tilemapBuffers[2], sizeof(sBerryTag->tilemapBuffers[2])); FillWindowPixelBuffer(WIN_BERRY_TAG, PIXEL_FILL(15)); - PrintTextInBerryTagScreen(WIN_BERRY_TAG, gText_BerryTag, GetStringCenterAlignXOffset(1, gText_BerryTag, 0x40), 1, 0, 1); + PrintTextInBerryTagScreen(WIN_BERRY_TAG, gText_BerryTag, GetStringCenterAlignXOffset(FONT_NORMAL, gText_BerryTag, 0x40), 1, 0, 1); PutWindowTilemap(WIN_BERRY_TAG); ScheduleBgCopyTilemapToVram(0); } @@ -409,7 +409,7 @@ static void PrintBerryNumberAndName(void) static void PrintBerrySize(void) { const struct Berry *berry = GetBerryInfo(sBerryTag->berryId); - AddTextPrinterParameterized(WIN_SIZE_FIRM, 1, gText_SizeSlash, 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(WIN_SIZE_FIRM, FONT_NORMAL, gText_SizeSlash, 0, 1, TEXT_SKIP_DRAW, NULL); if (berry->size != 0) { u32 inches, fraction; @@ -423,34 +423,34 @@ static void PrintBerrySize(void) ConvertIntToDecimalStringN(gStringVar1, inches, STR_CONV_MODE_LEFT_ALIGN, 2); ConvertIntToDecimalStringN(gStringVar2, fraction, STR_CONV_MODE_LEFT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, gText_Var1DotVar2); - AddTextPrinterParameterized(WIN_SIZE_FIRM, 1, gStringVar4, 0x28, 1, 0, NULL); + AddTextPrinterParameterized(WIN_SIZE_FIRM, FONT_NORMAL, gStringVar4, 0x28, 1, 0, NULL); } else { - AddTextPrinterParameterized(WIN_SIZE_FIRM, 1, gText_ThreeMarks, 0x28, 1, 0, NULL); + AddTextPrinterParameterized(WIN_SIZE_FIRM, FONT_NORMAL, gText_ThreeMarks, 0x28, 1, 0, NULL); } } static void PrintBerryFirmness(void) { const struct Berry *berry = GetBerryInfo(sBerryTag->berryId); - AddTextPrinterParameterized(WIN_SIZE_FIRM, 1, gText_FirmSlash, 0, 0x11, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(WIN_SIZE_FIRM, FONT_NORMAL, gText_FirmSlash, 0, 0x11, TEXT_SKIP_DRAW, NULL); if (berry->firmness != 0) - AddTextPrinterParameterized(WIN_SIZE_FIRM, 1, sBerryFirmnessStrings[berry->firmness - 1], 0x28, 0x11, 0, NULL); + AddTextPrinterParameterized(WIN_SIZE_FIRM, FONT_NORMAL, sBerryFirmnessStrings[berry->firmness - 1], 0x28, 0x11, 0, NULL); else - AddTextPrinterParameterized(WIN_SIZE_FIRM, 1, gText_ThreeMarks, 0x28, 0x11, 0, NULL); + AddTextPrinterParameterized(WIN_SIZE_FIRM, FONT_NORMAL, gText_ThreeMarks, 0x28, 0x11, 0, NULL); } static void PrintBerryDescription1(void) { const struct Berry *berry = GetBerryInfo(sBerryTag->berryId); - AddTextPrinterParameterized(WIN_DESC, 1, berry->description1, 0, 1, 0, NULL); + AddTextPrinterParameterized(WIN_DESC, FONT_NORMAL, berry->description1, 0, 1, 0, NULL); } static void PrintBerryDescription2(void) { const struct Berry *berry = GetBerryInfo(sBerryTag->berryId); - AddTextPrinterParameterized(WIN_DESC, 1, berry->description2, 0, 0x11, 0, NULL); + AddTextPrinterParameterized(WIN_DESC, FONT_NORMAL, berry->description2, 0, 0x11, 0, NULL); } static void CreateBerrySprite(void) diff --git a/src/bike.c b/src/bike.c index 39433522e..20166392e 100644 --- a/src/bike.c +++ b/src/bike.c @@ -71,12 +71,12 @@ static void (*const sMachBikeTransitions[])(u8) = MachBikeTransition_TrySlowDown, }; -// bikeFrameCounter is input which is represented by sMachBikeSpeeds in order: 0 is normal speed (1 speed), 1 is fast speed (2 speed), 2 is fastest speed (4 speed) +// bikeFrameCounter is input which is represented by sMachBikeSpeeds in order static void (*const sMachBikeSpeedCallbacks[])(u8) = { - PlayerGoSpeed1, // normal speed (1 speed) - PlayerGoSpeed2, // fast speed (2 speed) - PlayerGoSpeed4, // fastest speed (4 speed) + PlayerWalkNormal, + PlayerWalkFast, + PlayerWalkFaster, }; static void (*const sAcroBikeTransitions[])(u8) = @@ -108,7 +108,7 @@ static u8 (*const sAcroBikeInputHandlers[])(u8 *, u16, u16) = }; // used with bikeFrameCounter from mach bike -static const u16 sMachBikeSpeeds[] = {SPEED_NORMAL, SPEED_FAST, SPEED_FASTEST}; +static const u16 sMachBikeSpeeds[] = {BIKE_SPEED_NORMAL, BIKE_SPEED_FAST, BIKE_SPEED_FASTEST}; // this is a list of timers to compare against later, terminated with 0. the only timer being compared against is 4 frames in this list. static const u8 sAcroBikeJumpTimerList[] = {4, 0}; @@ -147,7 +147,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling) if (*dirTraveling == 0) { *dirTraveling = direction; // update the direction, since below we either faced a direction or we started moving. - if (gPlayerAvatar.bikeSpeed == SPEED_STANDING) + if (gPlayerAvatar.bikeSpeed == BIKE_SPEED_STANDING) { gPlayerAvatar.runningState = NOT_MOVING; return MACH_TRANS_FACE_DIRECTION; @@ -159,7 +159,7 @@ static u8 GetMachBikeTransition(u8 *dirTraveling) // we need to check if the last traveled direction changed from the new direction as well as ensuring that we dont update the state while the player is moving: see the else check. if (*dirTraveling != direction && gPlayerAvatar.runningState != MOVING) { - if (gPlayerAvatar.bikeSpeed != SPEED_STANDING) + if (gPlayerAvatar.bikeSpeed != BIKE_SPEED_STANDING) { *dirTraveling = direction; // implement the new direction gPlayerAvatar.runningState = MOVING; @@ -246,7 +246,7 @@ static void MachBikeTransition_TrySlowDown(u8 direction) { u8 collision; - if (gPlayerAvatar.bikeSpeed != SPEED_STANDING) + if (gPlayerAvatar.bikeSpeed != BIKE_SPEED_STANDING) gPlayerAvatar.bikeFrameCounter = --gPlayerAvatar.bikeSpeed; collision = GetBikeCollision(direction); @@ -306,7 +306,7 @@ static u8 AcroBikeHandleInputNormal(u8 *newDirection, u16 newKeys, u16 heldKeys) return ACRO_TRANS_FACE_DIRECTION; } } - if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == SPEED_STANDING) + if (*newDirection == direction && (heldKeys & B_BUTTON) && gPlayerAvatar.bikeSpeed == BIKE_SPEED_STANDING) { gPlayerAvatar.bikeSpeed++; gPlayerAvatar.acroBikeState = ACRO_STATE_WHEELIE_MOVING; @@ -342,7 +342,7 @@ static u8 AcroBikeHandleInputTurning(u8 *newDirection, u16 newKeys, u16 heldKeys if (*newDirection == AcroBike_GetJumpDirection()) { Bike_SetBikeStill(); // Bike_SetBikeStill sets speed to standing, but the next line immediately overrides it. could have just reset acroBikeState to 0 here instead of wasting a jump. - gPlayerAvatar.bikeSpeed = SPEED_NORMAL; + gPlayerAvatar.bikeSpeed = BIKE_SPEED_NORMAL; if (*newDirection == GetOppositeDirection(direction)) { // do a turn jump. @@ -658,7 +658,7 @@ static void AcroBikeTransition_SideJump(u8 direction) playerObjEvent = &gObjectEvents[gPlayerAvatar.objectEventId]; PlaySE(SE_BIKE_HOP); playerObjEvent->facingDirectionLocked = 1; - PlayerSetAnimId(GetJumpMovementAction(direction), 2); + PlayerSetAnimId(GetJumpMovementAction(direction), COPY_MOVE_WALK); } static void AcroBikeTransition_TurnJump(u8 direction) @@ -775,7 +775,7 @@ static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is u else { Bike_UpdateDirTimerHistory(direction); - gPlayerAvatar.bikeSpeed = SPEED_STANDING; + gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING; } direction = heldKeys & (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON); // directions is reused for some reason. @@ -787,7 +787,7 @@ static void AcroBike_TryHistoryUpdate(u16 newKeys, u16 heldKeys) // newKeys is u else { Bike_UpdateABStartSelectHistory(direction); - gPlayerAvatar.bikeSpeed = SPEED_STANDING; + gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING; } } @@ -994,7 +994,7 @@ void BikeClearState(int newDirHistory, int newAbStartHistory) gPlayerAvatar.acroBikeState = ACRO_STATE_NORMAL; gPlayerAvatar.newDirBackup = DIR_NONE; gPlayerAvatar.bikeFrameCounter = 0; - gPlayerAvatar.bikeSpeed = SPEED_STANDING; + gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING; gPlayerAvatar.directionHistory = newDirHistory; gPlayerAvatar.abStartSelectHistory = newAbStartHistory; @@ -1014,7 +1014,7 @@ void Bike_UpdateBikeCounterSpeed(u8 counter) static void Bike_SetBikeStill(void) { gPlayerAvatar.bikeFrameCounter = 0; - gPlayerAvatar.bikeSpeed = SPEED_STANDING; + gPlayerAvatar.bikeSpeed = BIKE_SPEED_STANDING; } s16 GetPlayerSpeed(void) @@ -1027,11 +1027,11 @@ s16 GetPlayerSpeed(void) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_MACH_BIKE) return machSpeeds[gPlayerAvatar.bikeFrameCounter]; else if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_ACRO_BIKE) - return SPEED_FASTER; + return BIKE_SPEED_FASTER; else if (gPlayerAvatar.flags & (PLAYER_AVATAR_FLAG_SURFING | PLAYER_AVATAR_FLAG_DASH)) - return SPEED_FAST; + return BIKE_SPEED_FAST; else - return SPEED_NORMAL; + return BIKE_SPEED_NORMAL; } void Bike_HandleBumpySlopeJump(void) diff --git a/src/braille.c b/src/braille.c new file mode 100644 index 000000000..b4ee43ad0 --- /dev/null +++ b/src/braille.c @@ -0,0 +1,208 @@ +#include "global.h" +#include "main.h" +#include "window.h" +#include "text.h" +#include "sound.h" + +// This file handles the braille font. +// For printing braille messages, see ScrCmd_braillemessage + +ALIGNED(4) +static const u8 sScrollDistances[] = {1, 2, 4}; +static const u16 sFont_Braille[] = INCBIN_U16("graphics/fonts/braille.fwjpnfont"); + +static void DecompressGlyph_Braille(u16); + +u16 FontFunc_Braille(struct TextPrinter *textPrinter) +{ + u16 char_; + struct TextPrinterSubStruct *subStruct; + subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); + + switch (textPrinter->state) + { + case RENDER_STATE_HANDLE_CHAR: + if (JOY_HELD(A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp) + { + textPrinter->delayCounter = 0; + } + if (textPrinter->delayCounter && textPrinter->textSpeed) + { + textPrinter->delayCounter --; + if (gTextFlags.canABSpeedUpPrint && JOY_NEW(A_BUTTON | B_BUTTON)) + { + subStruct->hasPrintBeenSpedUp = TRUE; + textPrinter->delayCounter = 0; + } + return RENDER_UPDATE; + } + if (gTextFlags.autoScroll) + textPrinter->delayCounter = 3; + else + textPrinter->delayCounter = textPrinter->textSpeed; + + char_ = *textPrinter->printerTemplate.currentChar++; + switch (char_) + { + case EOS: + return RENDER_FINISH; + case CHAR_NEWLINE: + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY += gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; + return RENDER_REPEAT; + case PLACEHOLDER_BEGIN: + textPrinter->printerTemplate.currentChar++; + return RENDER_REPEAT; + case EXT_CTRL_CODE_BEGIN: + char_ = *textPrinter->printerTemplate.currentChar++; + switch (char_) + { + case EXT_CTRL_CODE_COLOR: + textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); + return RENDER_REPEAT; + case EXT_CTRL_CODE_HIGHLIGHT: + textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); + return RENDER_REPEAT; + case EXT_CTRL_CODE_SHADOW: + textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar++; + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); + return RENDER_REPEAT; + case EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW: + textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.bgColor = *++textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.shadowColor = *++textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + + GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); + return RENDER_REPEAT; + case EXT_CTRL_CODE_PALETTE: + textPrinter->printerTemplate.currentChar++; + return RENDER_REPEAT; + case EXT_CTRL_CODE_FONT: + subStruct->fontId = *textPrinter->printerTemplate.currentChar; + textPrinter->printerTemplate.currentChar++; + return RENDER_REPEAT; + case EXT_CTRL_CODE_RESET_SIZE: + return RENDER_REPEAT; + case EXT_CTRL_CODE_PAUSE: + textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar++; + textPrinter->state = RENDER_STATE_PAUSE; + return RENDER_REPEAT; + case EXT_CTRL_CODE_PAUSE_UNTIL_PRESS: + textPrinter->state = RENDER_STATE_WAIT; + if (gTextFlags.autoScroll) + subStruct->autoScrollDelay = 0; + return RENDER_UPDATE; + case EXT_CTRL_CODE_WAIT_SE: + textPrinter->state = RENDER_STATE_WAIT_SE; + return RENDER_UPDATE; + case EXT_CTRL_CODE_PLAY_BGM: + case EXT_CTRL_CODE_PLAY_SE: + textPrinter->printerTemplate.currentChar += 2; + return RENDER_REPEAT; + case EXT_CTRL_CODE_ESCAPE: + char_ = *++textPrinter->printerTemplate.currentChar; + break; + case EXT_CTRL_CODE_SHIFT_TEXT: + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar++; + return RENDER_REPEAT; + case EXT_CTRL_CODE_SHIFT_DOWN: + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar++; + return RENDER_REPEAT; + case EXT_CTRL_CODE_FILL_WINDOW: + FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); + return RENDER_REPEAT; + } + break; + case CHAR_PROMPT_CLEAR: + textPrinter->state = RENDER_STATE_CLEAR; + TextPrinterInitDownArrowCounters(textPrinter); + return RENDER_UPDATE; + case CHAR_PROMPT_SCROLL: + textPrinter->state = RENDER_STATE_SCROLL_START; + TextPrinterInitDownArrowCounters(textPrinter); + return RENDER_UPDATE; + case CHAR_EXTRA_SYMBOL: + char_ = *textPrinter->printerTemplate.currentChar++| 0x100; + break; + case CHAR_KEYPAD_ICON: + textPrinter->printerTemplate.currentChar++; + return RENDER_PRINT; + } + DecompressGlyph_Braille(char_); + CopyGlyphToWindow(textPrinter); + textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing; + return RENDER_PRINT; + case RENDER_STATE_WAIT: + if (TextPrinterWait(textPrinter)) + textPrinter->state = RENDER_STATE_HANDLE_CHAR; + return RENDER_UPDATE; + case RENDER_STATE_CLEAR: + if (TextPrinterWaitWithDownArrow(textPrinter)) + { + FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y; + textPrinter->state = RENDER_STATE_HANDLE_CHAR; + } + return RENDER_UPDATE; + case RENDER_STATE_SCROLL_START: + if (TextPrinterWaitWithDownArrow(textPrinter)) + { + TextPrinterClearDownArrow(textPrinter); + textPrinter->scrollDistance = gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; + textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; + textPrinter->state = RENDER_STATE_SCROLL; + } + return RENDER_UPDATE; + case RENDER_STATE_SCROLL: + if (textPrinter->scrollDistance) + { + if (textPrinter->scrollDistance < sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed]) + { + ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); + textPrinter->scrollDistance = 0; + } + else + { + ScrollWindow(textPrinter->printerTemplate.windowId, 0, sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor)); + textPrinter->scrollDistance -= sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed]; + } + CopyWindowToVram(textPrinter->printerTemplate.windowId, COPYWIN_GFX); + } + else + { + textPrinter->state = RENDER_STATE_HANDLE_CHAR; + } + return RENDER_UPDATE; + case RENDER_STATE_WAIT_SE: + if (!IsSEPlaying()) + textPrinter->state = RENDER_STATE_HANDLE_CHAR; + return RENDER_UPDATE; + case RENDER_STATE_PAUSE: + if (textPrinter->delayCounter) + textPrinter->delayCounter --; + else + textPrinter->state = RENDER_STATE_HANDLE_CHAR; + return RENDER_UPDATE; + } + return RENDER_FINISH; +} + +static void DecompressGlyph_Braille(u16 glyph) +{ + const u16 *glyphs = sFont_Braille + 0x100 * (glyph / 8) + 0x10 * (glyph % 8); + DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); + DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); + DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); + DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8); + gCurGlyph.width = 16; + gCurGlyph.height = 16; +} + +u32 GetGlyphWidth_Braille(u16 glyphId, bool32 isJapanese) +{ + return 16; +} diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c index d8410988d..61fab39e2 100644 --- a/src/braille_puzzles.c +++ b/src/braille_puzzles.c @@ -13,16 +13,9 @@ #include "party_menu.h" #include "fldeff.h" -// why do this, GF? -enum -{ - REGIROCK_PUZZLE, - REGISTEEL_PUZZLE -}; - -EWRAM_DATA static u8 sBraillePuzzleCallbackFlag = 0; +EWRAM_DATA static bool8 sIsRegisteelPuzzle = 0; -static const u8 gRegicePathCoords[][2] = +static const u8 sRegicePathCoords[][2] = { {4, 21}, {5, 21}, @@ -62,9 +55,9 @@ static const u8 gRegicePathCoords[][2] = {4, 22}, }; -void SealedChamberShakingEffect(u8); -void DoBrailleRegirockEffect(void); -void DoBrailleRegisteelEffect(void); +static void Task_SealedChamberShakingEffect(u8); +static void DoBrailleRegirockEffect(void); +static void DoBrailleRegisteelEffect(void); bool8 ShouldDoBrailleDigEffect(void) { @@ -116,43 +109,48 @@ void ShouldDoBrailleRegirockEffectOld(void) { } -void DoSealedChamberShakingEffect1(void) +#define tDelayCounter data[1] +#define tShakeCounter data[2] +#define tVerticalPan data[4] +#define tDelay data[5] +#define tNumShakes data[6] + +void DoSealedChamberShakingEffect_Long(void) { - u8 taskId = CreateTask(SealedChamberShakingEffect, 9); + u8 taskId = CreateTask(Task_SealedChamberShakingEffect, 9); - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[4] = 2; - gTasks[taskId].data[5] = 5; - gTasks[taskId].data[6] = 50; + gTasks[taskId].tDelayCounter = 0; + gTasks[taskId].tShakeCounter = 0; + gTasks[taskId].tVerticalPan = 2; + gTasks[taskId].tDelay = 5; + gTasks[taskId].tNumShakes = 50; SetCameraPanningCallback(0); } -void DoSealedChamberShakingEffect2(void) +void DoSealedChamberShakingEffect_Short(void) { - u8 taskId = CreateTask(SealedChamberShakingEffect, 9); + u8 taskId = CreateTask(Task_SealedChamberShakingEffect, 9); - gTasks[taskId].data[1] = 0; - gTasks[taskId].data[2] = 0; - gTasks[taskId].data[4] = 3; - gTasks[taskId].data[5] = 5; - gTasks[taskId].data[6] = 2; + gTasks[taskId].tDelayCounter = 0; + gTasks[taskId].tShakeCounter = 0; + gTasks[taskId].tVerticalPan = 3; + gTasks[taskId].tDelay = 5; + gTasks[taskId].tNumShakes = 2; SetCameraPanningCallback(0); } -void SealedChamberShakingEffect(u8 taskId) +static void Task_SealedChamberShakingEffect(u8 taskId) { struct Task *task = &gTasks[taskId]; - task->data[1]++; - - if (!(task->data[1] % task->data[5])) + task->tDelayCounter++; + if (task->tDelayCounter % task->tDelay == 0) { - task->data[1] = 0; - task->data[2]++; - task->data[4] = -task->data[4]; - SetCameraPanning(0, task->data[4]); - if (task->data[2] == task->data[6]) + task->tDelayCounter = 0; + task->tShakeCounter++; + task->tVerticalPan = -task->tVerticalPan; + SetCameraPanning(0, task->tVerticalPan); + if (task->tShakeCounter == task->tNumShakes) { DestroyTask(taskId); EnableBothScriptContexts(); @@ -161,7 +159,12 @@ void SealedChamberShakingEffect(u8 taskId) } } -// moved later in the function because it was rewritten. +#undef tDelayCounter +#undef tShakeCounter +#undef tVerticalPan +#undef tDelay +#undef tNumShakes + bool8 ShouldDoBrailleRegirockEffect(void) { if (!FlagGet(FLAG_SYS_REGIROCK_PUZZLE_COMPLETED) @@ -170,17 +173,17 @@ bool8 ShouldDoBrailleRegirockEffect(void) { if (gSaveBlock1Ptr->pos.x == 6 && gSaveBlock1Ptr->pos.y == 23) { - sBraillePuzzleCallbackFlag = REGIROCK_PUZZLE; + sIsRegisteelPuzzle = FALSE; return TRUE; } else if (gSaveBlock1Ptr->pos.x == 5 && gSaveBlock1Ptr->pos.y == 23) { - sBraillePuzzleCallbackFlag = REGIROCK_PUZZLE; + sIsRegisteelPuzzle = FALSE; return TRUE; } else if (gSaveBlock1Ptr->pos.x == 7 && gSaveBlock1Ptr->pos.y == 23) { - sBraillePuzzleCallbackFlag = REGIROCK_PUZZLE; + sIsRegisteelPuzzle = FALSE; return TRUE; } } @@ -200,7 +203,7 @@ void UseRegirockHm_Callback(void) DoBrailleRegirockEffect(); } -void DoBrailleRegirockEffect(void) +static void DoBrailleRegirockEffect(void) { MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft); MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); @@ -220,7 +223,7 @@ bool8 ShouldDoBrailleRegisteelEffect(void) { if (gSaveBlock1Ptr->pos.x == 8 && gSaveBlock1Ptr->pos.y == 25) { - sBraillePuzzleCallbackFlag = REGISTEEL_PUZZLE; + sIsRegisteelPuzzle = TRUE; return TRUE; } } @@ -239,7 +242,7 @@ void UseRegisteelHm_Callback(void) DoBrailleRegisteelEffect(); } -void DoBrailleRegisteelEffect(void) +static void DoBrailleRegisteelEffect(void) { MapGridSetMetatileIdAt(7 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopLeft); MapGridSetMetatileIdAt(8 + MAP_OFFSET, 19 + MAP_OFFSET, METATILE_Cave_SealedChamberEntrance_TopMid); @@ -254,7 +257,7 @@ void DoBrailleRegisteelEffect(void) } // theory: another commented out DoBrailleWait and Task_BrailleWait. -void DoBrailleWait(void) +static void DoBrailleWait(void) { } @@ -263,7 +266,7 @@ bool8 FldEff_UsePuzzleEffect(void) { u8 taskId = CreateFieldMoveTask(); - if (sBraillePuzzleCallbackFlag == REGISTEEL_PUZZLE) + if (sIsRegisteelPuzzle == TRUE) { gTasks[taskId].data[8] = (u32)UseRegisteelHm_Callback >> 16; gTasks[taskId].data[9] = (u32)UseRegisteelHm_Callback; @@ -290,10 +293,10 @@ bool8 ShouldDoBrailleRegicePuzzle(void) if (FlagGet(FLAG_TEMP_3) == TRUE) return FALSE; - for (i = 0; i < 36; i++) + for (i = 0; i < ARRAY_COUNT(sRegicePathCoords); i++) { - u8 xPos = gRegicePathCoords[i][0]; - u8 yPos = gRegicePathCoords[i][1]; + u8 xPos = sRegicePathCoords[i][0]; + u8 yPos = sRegicePathCoords[i][1]; if (gSaveBlock1Ptr->pos.x == xPos && gSaveBlock1Ptr->pos.y == yPos) { u16 varValue; diff --git a/src/cable_club.c b/src/cable_club.c index 3083ed9c0..1f943b03a 100644 --- a/src/cable_club.c +++ b/src/cable_club.c @@ -99,17 +99,17 @@ static void PrintNumPlayersInLink(u16 windowId, u32 numPlayers) ConvertIntToDecimalStringN(gStringVar1, numPlayers, STR_CONV_MODE_LEFT_ALIGN, 1); SetStandardWindowBorderStyle(windowId, 0); StringExpandPlaceholders(gStringVar4, gText_NumPlayerLink); - xPos = GetStringCenterAlignXOffset(1, gStringVar4, 88); - AddTextPrinterParameterized(windowId, 1, gStringVar4, xPos, 1, 0xFF, NULL); - CopyWindowToVram(windowId, 3); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 88); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, xPos, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(windowId, COPYWIN_FULL); } static void ClearLinkPlayerCountWindow(u16 windowId) { - // Following this call with a copy-to-vram with mode 3 is identical to + // Following this call with a copy-to-vram with mode COPYWIN_FULL is identical to // calling ClearStdWindowAndFrame(windowId, TRUE). ClearStdWindowAndFrame(windowId, FALSE); - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } static void UpdateLinkPlayerCountDisplay(u8 taskId, u8 numPlayers) @@ -1078,7 +1078,7 @@ static void Task_EnterCableClubSeat(u8 taskId) case 3: // Exit, failure SetLinkWaitingForScript(); - sub_8197AE8(TRUE); + EraseFieldMessageBox(TRUE); DestroyTask(taskId); EnableBothScriptContexts(); break; diff --git a/src/clear_save_data_screen.c b/src/clear_save_data_screen.c index 0d69eb0fa..9bde45e97 100644 --- a/src/clear_save_data_screen.c +++ b/src/clear_save_data_screen.c @@ -80,7 +80,7 @@ void CB2_InitClearSaveDataScreen(void) static void Task_DoClearSaveDataScreenYesNo(u8 taskId) { DrawStdFrameWithCustomTileAndPalette(0, 0, 2, 14); - AddTextPrinterParameterized(0, 1, gText_ClearAllSaveData, 0, 1, 0, 0); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_ClearAllSaveData, 0, 1, 0, 0); CreateYesNoMenu(sClearSaveYesNo, 2, 14, 1); gTasks[taskId].func = Task_ClearSaveDataScreenYesNoChoice; } @@ -91,7 +91,7 @@ static void Task_ClearSaveDataScreenYesNoChoice(u8 taskId) { case 0: FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized(0, 1, gText_ClearingData, 0, 1, 0, 0); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_ClearingData, 0, 1, 0, 0); gTasks[taskId].func = Task_ClearSaveData; break; case 1: @@ -205,5 +205,5 @@ static void InitClearSaveDataScreenWindows(void) DeactivateAllTextPrinters(); FillWindowPixelBuffer(0, PIXEL_FILL(0)); LoadWindowGfx(0, 0, 2, 224); - LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(gStandardMenuPalette, 0xF0, 0x20); } diff --git a/src/coins.c b/src/coins.c index 52c7dd3ec..17fd147b7 100644 --- a/src/coins.c +++ b/src/coins.c @@ -17,8 +17,8 @@ void PrintCoinsString(u32 coinAmount) ConvertIntToDecimalStringN(gStringVar1, coinAmount, STR_CONV_MODE_RIGHT_ALIGN, MAX_COIN_DIGITS); StringExpandPlaceholders(gStringVar4, gText_Coins); - xAlign = GetStringRightAlignXOffset(1, gStringVar4, 0x40); - AddTextPrinterParameterized(sCoinsWindowId, 1, gStringVar4, xAlign, 1, 0, NULL); + xAlign = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 0x40); + AddTextPrinterParameterized(sCoinsWindowId, FONT_NORMAL, gStringVar4, xAlign, 1, 0, NULL); } void ShowCoinsWindow(u32 coinAmount, u8 x, u8 y) diff --git a/src/confetti_util.c b/src/confetti_util.c index bcf19f705..9ede3088a 100644 --- a/src/confetti_util.c +++ b/src/confetti_util.c @@ -10,43 +10,6 @@ static EWRAM_DATA struct struct ConfettiUtil *array; } *sWork = NULL; -static void sub_81520A8(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) // Unused. -{ - u8 i; - u8 j; - u8 x; - u8 y; - - for (i = 0, y = top; i < height; i++) - { - for (x = left, j = 0; j < width; j++) - { - *(u16 *)((dest) + (y * 64 + x * 2)) = value; - x = (x + 1) % 32; - } - y = (y + 1) % 32; - } -} - -static void sub_8152134(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) // Unused. -{ - u8 i; - u8 j; - u8 x; - u8 y; - const u16 *_src; - - for (i = 0, _src = src, y = top; i < height; i++) - { - for (x = left, j = 0; j < width; j++) - { - *(u16 *)((dest) + (y * 64 + x * 2)) = *(_src++); - x = (x + 1) % 32; - } - y = (y + 1) % 32; - } -} - bool32 ConfettiUtil_Init(u8 count) { u8 i = 0; diff --git a/src/contest.c b/src/contest.c index 05dd39483..b5a035ff8 100644 --- a/src/contest.c +++ b/src/contest.c @@ -666,7 +666,7 @@ static const struct CompressedSpriteSheet sSpriteSheet_JudgeSymbols = const struct CompressedSpritePalette sSpritePalette_JudgeSymbols = { - .data = gContest3Pal, + .data = gContestJudgeSymbolsPal, .tag = TAG_CONTEST_SYMBOLS_PAL }; @@ -1028,11 +1028,11 @@ void LoadContestBgAfterMoveAnim(void) { s32 i; - LZDecompressVram(gContestMiscGfx, (void *)VRAM); + LZDecompressVram(gContestInterfaceGfx, (void *)VRAM); LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4))); - CopyToBgTilemapBuffer(3, gOldContestGfx, 0, 0); + CopyToBgTilemapBuffer(3, gContestAudienceTilemap, 0, 0); CopyBgTilemapBufferToVram(3); - LoadCompressedPalette(gOldContestPalette, 0, 0x200); + LoadCompressedPalette(gContestInterfaceAudiencePalette, 0, 0x200); LoadContestPalettes(); for (i = 0; i < CONTESTANT_COUNT; i++) { @@ -1310,24 +1310,24 @@ static bool8 SetupContestGraphics(u8 *stateVar) RequestDma3Fill(0, (void *)VRAM + 0x10000, 0x8000, 1); break; case 1: - LZDecompressVram(gContestMiscGfx, (void *)VRAM); + LZDecompressVram(gContestInterfaceGfx, (void *)VRAM); break; case 2: LZDecompressVram(gContestAudienceGfx, (void *)(BG_SCREEN_ADDR(4))); DmaCopyLarge32(3, (void *)(BG_SCREEN_ADDR(4)), eUnzippedContestAudience_Gfx, 0x2000, 0x1000); break; case 3: - CopyToBgTilemapBuffer(3, gOldContestGfx, 0, 0); + CopyToBgTilemapBuffer(3, gContestAudienceTilemap, 0, 0); CopyBgTilemapBufferToVram(3); break; case 4: - CopyToBgTilemapBuffer(2, gUnknown_08C17170, 0, 0); + CopyToBgTilemapBuffer(2, gContestInterfaceTilemap, 0, 0); CopyBgTilemapBufferToVram(2); // This is a bug, and copies random junk. savedJunk is never read. DmaCopy32Defvars(3, gContestResources->contestBgTilemaps[2], eContestTempSave.savedJunk, sizeof(eContestTempSave.savedJunk)); break; case 5: - LoadCompressedPalette(gOldContestPalette, 0, 0x200); + LoadCompressedPalette(gContestInterfaceAudiencePalette, 0, 0x200); CpuCopy32(gPlttBufferUnfaded + 128, tempPalette1, 16 * sizeof(u16)); CpuCopy32(gPlttBufferUnfaded + (5 + gContestPlayerMonIndex) * 16, tempPalette2, 16 * sizeof(u16)); CpuCopy32(tempPalette2, gPlttBufferUnfaded + 128, 16 * sizeof(u16)); @@ -1543,7 +1543,7 @@ static void Task_ShowMoveSelectScreen(u8 taskId) moveNameBuffer = StringCopy(moveNameBuffer, gMoveNames[move]); FillWindowPixelBuffer(i + MOVE_WINDOWS_START, PIXEL_FILL(0)); - Contest_PrintTextToBg0WindowAt(i + MOVE_WINDOWS_START, moveName, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(i + MOVE_WINDOWS_START, moveName, 5, 1, FONT_NARROW); } DrawMoveSelectArrow(eContest.playerMoveChoice); @@ -1667,7 +1667,7 @@ static void Task_HideMoveSelectScreen(u8 taskId) { FillWindowPixelBuffer(MOVE_WINDOWS_START + i, PIXEL_FILL(0)); PutWindowTilemap(MOVE_WINDOWS_START + i); - CopyWindowToVram(MOVE_WINDOWS_START + i, 2); + CopyWindowToVram(MOVE_WINDOWS_START + i, COPYWIN_GFX); } Contest_SetBgCopyFlags(0); // This seems to be a bug; it should have just copied PLTT_BUFFER_SIZE. @@ -3029,10 +3029,10 @@ static void PrintContestantTrainerNameWithColor(u8 contestant, u8 color) StringCopy(buffer, gText_Slash); StringAppend(buffer, gContestMons[contestant].trainerName); Contest_CopyStringWithColor(buffer, color); - offset = GetStringRightAlignXOffset(7, gDisplayedStringBattle, 0x60); + offset = GetStringRightAlignXOffset(FONT_NARROW, gDisplayedStringBattle, 0x60); if (offset > 55) offset = 55; - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[contestant], gDisplayedStringBattle, offset, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[contestant], gDisplayedStringBattle, offset, 1, FONT_NARROW); } static void PrintContestantMonName(u8 contestant) @@ -3043,7 +3043,7 @@ static void PrintContestantMonName(u8 contestant) static void PrintContestantMonNameWithColor(u8 contestant, u8 color) { Contest_CopyStringWithColor(gContestMons[contestant].nickname, color); - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[contestant], gDisplayedStringBattle, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[contestant], gDisplayedStringBattle, 5, 1, FONT_NARROW); } static u16 CalculateContestantRound1Points(u8 who, u8 contestCategory) @@ -3377,7 +3377,7 @@ static void DrawStatusSymbols(void) static void ContestClearGeneralTextWindow(void) { FillWindowPixelBuffer(WIN_GENERAL_TEXT, PIXEL_FILL(0)); - CopyWindowToVram(WIN_GENERAL_TEXT, 2); + CopyWindowToVram(WIN_GENERAL_TEXT, COPYWIN_GFX); Contest_SetBgCopyFlags(0); } @@ -4273,7 +4273,7 @@ static void ContestDebugDoPrint(void) txtPtr = StringCopy(txtPtr, gText_OneDash); } ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4); - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 55, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 55, 1, FONT_NARROW); } for (i = 0; i < CONTESTANT_COUNT; i++) { @@ -4285,7 +4285,7 @@ static void ContestDebugDoPrint(void) txtPtr = StringCopy(txtPtr, gText_OneDash); } ConvertIntToDecimalStringN(txtPtr, value, STR_CONV_MODE_LEFT_ALIGN, 4); - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text, 5, 1, FONT_NARROW); } SwapMoveDescAndContestTilemaps(); break; @@ -5089,7 +5089,7 @@ static void SetBgForCurtainDrop(void) CpuFill32(0, gContestResources->contestBgTilemaps[1], 0x1000); - CopyToBgTilemapBuffer(1, gUnknown_08C17980, 0, 0); + CopyToBgTilemapBuffer(1, gContestCurtainTilemap, 0, 0); Contest_SetBgCopyFlags(1); for (i = 0; i < CONTESTANT_COUNT; i++) @@ -5410,7 +5410,7 @@ static void Contest_PrintTextToBg0WindowStd(u32 windowId, const u8 *b) printerTemplate.currentChar = b; printerTemplate.windowId = windowId; - printerTemplate.fontId = 1; + printerTemplate.fontId = FONT_NORMAL; printerTemplate.x = 0; printerTemplate.y = 1; printerTemplate.currentX = 0; @@ -5457,7 +5457,7 @@ static void Contest_StartTextPrinter(const u8 *currChar, bool32 b) printerTemplate.currentChar = currChar; printerTemplate.windowId = 4; - printerTemplate.fontId = 1; + printerTemplate.fontId = FONT_NORMAL; printerTemplate.x = 0; printerTemplate.y = 1; printerTemplate.currentX = 0; @@ -5968,7 +5968,7 @@ static void ContestDebugPrintBitStrings(void) for (i = 0; i < CONTESTANT_COUNT; i++) { txtPtr = StringCopy(text1, gText_CDot); - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1, 5, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1, 5, 1, FONT_NARROW); bits = gContestResources->tv[i].winnerFlags; for (j = 7; j > -1; j--) // Weird loop. { @@ -5981,7 +5981,7 @@ static void ContestDebugPrintBitStrings(void) text2[j] = EOS; Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text2, 5, 1, 7); - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, FONT_NARROW); } } else // CONTEST_DEBUG_MODE_PRINT_LOSER_FLAGS @@ -6001,8 +6001,8 @@ static void ContestDebugPrintBitStrings(void) text2[j] = text1[j]; text2[j] = EOS; - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text2, 5, 1, 7); - Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, 7); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text2, 5, 1, FONT_NARROW); + Contest_PrintTextToBg0WindowAt(gContestantTurnOrder[i], text1 + j, 55, 1, FONT_NARROW); } } SwapMoveDescAndContestTilemaps(); @@ -6031,10 +6031,10 @@ static u8 GetMonNicknameLanguage(u8 *nickname) || *nickname == CHAR_SLASH || *nickname == CHAR_HYPHEN || *nickname == CHAR_ELLIPSIS - || *nickname == CHAR_DBL_QUOT_LEFT - || *nickname == CHAR_DBL_QUOT_RIGHT - || *nickname == CHAR_SGL_QUOT_LEFT - || *nickname == CHAR_DBL_QUOT_LEFT) // Most likely a typo, CHAR_SGL_QUOT_RIGHT should be here instead. + || *nickname == CHAR_DBL_QUOTE_LEFT + || *nickname == CHAR_DBL_QUOTE_RIGHT + || *nickname == CHAR_SGL_QUOTE_LEFT + || *nickname == CHAR_DBL_QUOTE_LEFT) // Most likely a typo, CHAR_SGL_QUOTE_RIGHT should be here instead. { nickname++; } diff --git a/src/contest_painting.c b/src/contest_painting.c index c591fc9ef..e71cf391f 100644 --- a/src/contest_painting.c +++ b/src/contest_painting.c @@ -267,14 +267,14 @@ static void InitContestPaintingWindow(void) { ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); SetBgTilemapBuffer(1, AllocZeroed(BG_SCREEN_SIZE)); sWindowId = AddWindow(&sWindowTemplate); DeactivateAllTextPrinters(); FillWindowPixelBuffer(sWindowId, PIXEL_FILL(0)); PutWindowTilemap(sWindowId); - CopyWindowToVram(sWindowId, 3); + CopyWindowToVram(sWindowId, COPYWIN_FULL); ShowBg(1); } @@ -306,8 +306,8 @@ static void PrintContestPaintingCaption(u8 contestType, bool8 isForArtist) StringExpandPlaceholders(gStringVar4, sMuseumCaptions[category]); } - x = GetStringCenterAlignXOffset(1, gStringVar4, 208); - AddTextPrinterParameterized(sWindowId, 1, gStringVar4, x, 1, 0, 0); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 208); + AddTextPrinterParameterized(sWindowId, FONT_NORMAL, gStringVar4, x, 1, 0, 0); CopyBgTilemapBufferToVram(1); } diff --git a/src/contest_util.c b/src/contest_util.c index d3e1a600e..37a5dedcd 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -1176,12 +1176,12 @@ static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId) windowId = AddWindow(&windowTemplate); FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); - origWidth = GetStringWidth(1, text, 0); + origWidth = GetStringWidth(FONT_NORMAL, text, 0); strWidth = (origWidth + 9) / 8; if (strWidth > 30) strWidth = 30; - AddTextPrinterParameterized3(windowId, 1, (strWidth * 8 - origWidth) / 2, 1, sContestLinkTextColors, -1, text); + AddTextPrinterParameterized3(windowId, FONT_NORMAL, (strWidth * 8 - origWidth) / 2, 1, sContestLinkTextColors, TEXT_SKIP_DRAW, text); { s32 i; struct Sprite *sprite; @@ -1931,7 +1931,7 @@ static void AddContestTextPrinter(int windowId, u8 *str, int x) struct TextPrinterTemplate textPrinter; textPrinter.currentChar = str; textPrinter.windowId = windowId; - textPrinter.fontId = 7; + textPrinter.fontId = FONT_NARROW; textPrinter.x = x; textPrinter.y = 2; textPrinter.currentX = x; diff --git a/src/credits.c b/src/credits.c index 519cfe39e..43c8d6628 100644 --- a/src/credits.c +++ b/src/credits.c @@ -369,7 +369,7 @@ static void InitCreditsBgsAndWindows(void) InitWindows(sWindowTemplates); DeactivateAllTextPrinters(); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); ShowBg(0); } @@ -400,8 +400,8 @@ static void PrintCreditsText(const u8 *string, u8 y, bool8 isTitle) color[2] = TEXT_COLOR_DARK_GRAY; } - x = GetStringCenterAlignXOffsetWithLetterSpacing(1, string, DISPLAY_WIDTH, 1); - AddTextPrinterParameterized4(0, 1, x, y, 1, 0, color, -1, string); + x = GetStringCenterAlignXOffsetWithLetterSpacing(FONT_NORMAL, string, DISPLAY_WIDTH, 1); + AddTextPrinterParameterized4(0, FONT_NORMAL, x, y, 1, 0, color, TEXT_SKIP_DRAW, string); } #define tMainTaskId data[1] @@ -761,7 +761,7 @@ static void Task_UpdatePage(u8 taskId) sCreditsEntryPointerTable[gTasks[taskId].tCurrentPage][i]->text, 5 + i * 16, sCreditsEntryPointerTable[gTasks[taskId].tCurrentPage][i]->isTitle); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); gTasks[taskId].tCurrentPage++; gTasks[taskId].tState++; @@ -811,7 +811,7 @@ static void Task_UpdatePage(u8 taskId) { // Still more Credits pages to show, return to state 2 to print FillWindowPixelBuffer(0, PIXEL_FILL(0)); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); gTasks[taskId].tState = 2; } return; diff --git a/src/data/battle_anim.h b/src/data/battle_anim.h index 5b24981d5..58b990c73 100644 --- a/src/data/battle_anim.h +++ b/src/data/battle_anim.h @@ -1619,7 +1619,7 @@ const struct BattleAnimBackground gBattleAnimBackgroundTable[] = [BG_FISSURE] = {gBattleAnimBgImage_Fissure, gBattleAnimBgPalette_Fissure, gBattleAnimBgTilemap_Fissure}, [BG_BUG_OPPONENT] = {gBattleAnimBgImage_Highspeed, gBattleAnimBgPalette_Bug, gBattleAnimBgTilemap_HighspeedOpponent}, [BG_BUG_PLAYER] = {gBattleAnimBgImage_Highspeed, gBattleAnimBgPalette_Bug, gBattleAnimBgTilemap_HighspeedPlayer}, - [BG_SOLARBEAM_OPPONENT] = {gBattleAnimBgImage_Impact, gBattleAnimBgPalette_Solarbeam, gBattleAnimBgTilemap_ImpactOpponent}, - [BG_SOLARBEAM_PLAYER] = {gBattleAnimBgImage_Impact, gBattleAnimBgPalette_Solarbeam, gBattleAnimBgTilemap_ImpactPlayer}, - [BG_SOLARBEAM_CONTESTS] = {gBattleAnimBgImage_Impact, gBattleAnimBgPalette_Solarbeam, gBattleAnimBgTilemap_ImpactContests}, + [BG_SOLAR_BEAM_OPPONENT] = {gBattleAnimBgImage_Impact, gBattleAnimBgPalette_SolarBeam, gBattleAnimBgTilemap_ImpactOpponent}, + [BG_SOLAR_BEAM_PLAYER] = {gBattleAnimBgImage_Impact, gBattleAnimBgPalette_SolarBeam, gBattleAnimBgTilemap_ImpactPlayer}, + [BG_SOLAR_BEAM_CONTESTS] = {gBattleAnimBgImage_Impact, gBattleAnimBgPalette_SolarBeam, gBattleAnimBgTilemap_ImpactContests}, }; diff --git a/src/data/battle_moves.h b/src/data/battle_moves.h index f78fa2c8c..82892120f 100644 --- a/src/data/battle_moves.h +++ b/src/data/battle_moves.h @@ -990,7 +990,7 @@ const struct BattleMove gBattleMoves[MOVES_COUNT] = [MOVE_SOLAR_BEAM] = { - .effect = EFFECT_SOLARBEAM, + .effect = EFFECT_SOLAR_BEAM, .power = 120, .type = TYPE_GRASS, .accuracy = 100, diff --git a/src/data/graphics/pokemon.h b/src/data/graphics/pokemon.h index bce0b7a21..f69fafec8 100644 --- a/src/data/graphics/pokemon.h +++ b/src/data/graphics/pokemon.h @@ -2696,12 +2696,12 @@ const u32 gMonBackPic_Deoxys[] = INCBIN_U32("graphics/pokemon/deoxys/back.4bpp.l const u32 gMonShinyPalette_Deoxys[] = INCBIN_U32("graphics/pokemon/deoxys/shiny.gbapal.lz"); const u8 gMonIcon_Deoxys[] = INCBIN_U8("graphics/pokemon/deoxys/icon.4bpp"); const u8 gMonIcon_DeoxysSpeed[] = INCBIN_U8("graphics/pokemon/deoxys/icon_speed.4bpp"); -const u8 gMonIcon_DeoxysSpeedWide[] = INCBIN_U8("graphics/unused/deoxys_speed_icon_wide.4bpp"); +const u8 gMonIcon_DeoxysSpeedWide[] = INCBIN_U8("graphics/pokemon/deoxys/icon_speed_wide.4bpp"); // Unused // Probably the leftover space from the other Deoxys forms static const u8 sEmpty[0x6800] = {0}; -const u16 gUnknown_D437F8[] = INCBIN_U16("graphics/unknown/unknown_D437F8.bin"); +const u16 gMonUnusedGarbage[] = INCBIN_U16("graphics/pokemon/unused_garbage.bin"); const u8 gMonFootprint_Deoxys[] = INCBIN_U8("graphics/pokemon/deoxys/footprint.1bpp"); diff --git a/src/data/items.h b/src/data/items.h index 370cd2022..20ee057da 100644 --- a/src/data/items.h +++ b/src/data/items.h @@ -3744,10 +3744,10 @@ const struct Item gItems[] = .fieldUseFunc = ItemUseOutOfBattle_TMHM, }, - [ITEM_TM22_SOLARBEAM] = + [ITEM_TM22_SOLAR_BEAM] = { .name = _("TM22"), - .itemId = ITEM_TM22_SOLARBEAM, + .itemId = ITEM_TM22_SOLAR_BEAM, .price = 3000, .description = sTM22Desc, .pocket = POCKET_TM_HM, diff --git a/src/data/object_events/movement_action_func_tables.h b/src/data/object_events/movement_action_func_tables.h index 4df07be0d..f601cf82b 100755 --- a/src/data/object_events/movement_action_func_tables.h +++ b/src/data/object_events/movement_action_func_tables.h @@ -73,10 +73,10 @@ u8 MovementAction_WalkInPlaceFastDown_Step0(struct ObjectEvent *, struct Sprite u8 MovementAction_WalkInPlaceFastUp_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_WalkInPlaceFastLeft_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_WalkInPlaceFastRight_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkInPlaceFastestDown_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkInPlaceFastestUp_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkInPlaceFastestLeft_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkInPlaceFastestRight_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkInPlaceFasterDown_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkInPlaceFasterUp_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkInPlaceFasterLeft_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkInPlaceFasterRight_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_RideWaterCurrentDown_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_RideWaterCurrentDown_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementAction_RideWaterCurrentUp_Step0(struct ObjectEvent *, struct Sprite *); @@ -85,14 +85,14 @@ u8 MovementAction_RideWaterCurrentLeft_Step0(struct ObjectEvent *, struct Sprite u8 MovementAction_RideWaterCurrentLeft_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementAction_RideWaterCurrentRight_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_RideWaterCurrentRight_Step1(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkFastestDown_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkFastestDown_Step1(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkFastestUp_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkFastestUp_Step1(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkFastestLeft_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkFastestLeft_Step1(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkFastestRight_Step0(struct ObjectEvent *, struct Sprite *); -u8 MovementAction_WalkFastestRight_Step1(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkFasterDown_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkFasterDown_Step1(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkFasterUp_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkFasterUp_Step1(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkFasterLeft_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkFasterLeft_Step1(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkFasterRight_Step0(struct ObjectEvent *, struct Sprite *); +u8 MovementAction_WalkFasterRight_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementAction_SlideDown_Step0(struct ObjectEvent *, struct Sprite *); u8 MovementAction_SlideDown_Step1(struct ObjectEvent *, struct Sprite *); u8 MovementAction_SlideUp_Step0(struct ObjectEvent *, struct Sprite *); @@ -299,18 +299,18 @@ u8 (*const gMovementActionFuncs_WalkInPlaceFastDown[])(struct ObjectEvent *, str u8 (*const gMovementActionFuncs_WalkInPlaceFastUp[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_WalkInPlaceFastLeft[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_WalkInPlaceFastRight[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkInPlaceFastestDown[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkInPlaceFastestUp[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkInPlaceFastestLeft[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkInPlaceFastestRight[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkInPlaceFasterDown[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkInPlaceFasterUp[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkInPlaceFasterLeft[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkInPlaceFasterRight[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_RideWaterCurrentDown[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_RideWaterCurrentUp[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_RideWaterCurrentLeft[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_RideWaterCurrentRight[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkFastestDown[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkFastestUp[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkFastestLeft[])(struct ObjectEvent *, struct Sprite *); -u8 (*const gMovementActionFuncs_WalkFastestRight[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkFasterDown[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkFasterUp[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkFasterLeft[])(struct ObjectEvent *, struct Sprite *); +u8 (*const gMovementActionFuncs_WalkFasterRight[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_SlideDown[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_SlideUp[])(struct ObjectEvent *, struct Sprite *); u8 (*const gMovementActionFuncs_SlideLeft[])(struct ObjectEvent *, struct Sprite *); @@ -459,18 +459,18 @@ u8 (*const *const gMovementActionFuncs[])(struct ObjectEvent *, struct Sprite *) [MOVEMENT_ACTION_WALK_IN_PLACE_FAST_UP] = gMovementActionFuncs_WalkInPlaceFastUp, [MOVEMENT_ACTION_WALK_IN_PLACE_FAST_LEFT] = gMovementActionFuncs_WalkInPlaceFastLeft, [MOVEMENT_ACTION_WALK_IN_PLACE_FAST_RIGHT] = gMovementActionFuncs_WalkInPlaceFastRight, - [MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN] = gMovementActionFuncs_WalkInPlaceFastestDown, - [MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_UP] = gMovementActionFuncs_WalkInPlaceFastestUp, - [MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_LEFT] = gMovementActionFuncs_WalkInPlaceFastestLeft, - [MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT] = gMovementActionFuncs_WalkInPlaceFastestRight, + [MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_DOWN] = gMovementActionFuncs_WalkInPlaceFasterDown, + [MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_UP] = gMovementActionFuncs_WalkInPlaceFasterUp, + [MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_LEFT] = gMovementActionFuncs_WalkInPlaceFasterLeft, + [MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_RIGHT] = gMovementActionFuncs_WalkInPlaceFasterRight, [MOVEMENT_ACTION_RIDE_WATER_CURRENT_DOWN] = gMovementActionFuncs_RideWaterCurrentDown, [MOVEMENT_ACTION_RIDE_WATER_CURRENT_UP] = gMovementActionFuncs_RideWaterCurrentUp, [MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT] = gMovementActionFuncs_RideWaterCurrentLeft, [MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT] = gMovementActionFuncs_RideWaterCurrentRight, - [MOVEMENT_ACTION_WALK_FASTEST_DOWN] = gMovementActionFuncs_WalkFastestDown, - [MOVEMENT_ACTION_WALK_FASTEST_UP] = gMovementActionFuncs_WalkFastestUp, - [MOVEMENT_ACTION_WALK_FASTEST_LEFT] = gMovementActionFuncs_WalkFastestLeft, - [MOVEMENT_ACTION_WALK_FASTEST_RIGHT] = gMovementActionFuncs_WalkFastestRight, + [MOVEMENT_ACTION_WALK_FASTER_DOWN] = gMovementActionFuncs_WalkFasterDown, + [MOVEMENT_ACTION_WALK_FASTER_UP] = gMovementActionFuncs_WalkFasterUp, + [MOVEMENT_ACTION_WALK_FASTER_LEFT] = gMovementActionFuncs_WalkFasterLeft, + [MOVEMENT_ACTION_WALK_FASTER_RIGHT] = gMovementActionFuncs_WalkFasterRight, [MOVEMENT_ACTION_SLIDE_DOWN] = gMovementActionFuncs_SlideDown, [MOVEMENT_ACTION_SLIDE_UP] = gMovementActionFuncs_SlideUp, [MOVEMENT_ACTION_SLIDE_LEFT] = gMovementActionFuncs_SlideLeft, @@ -603,11 +603,11 @@ u8 (*const gMovementActionFuncs_FaceRight[])(struct ObjectEvent *, struct Sprite }; static u8 (*const sDirectionAnimFuncsBySpeed[])(u8) = { - GetMoveDirectionAnimNum, - GetMoveDirectionFastAnimNum, - GetMoveDirectionFastAnimNum, - GetMoveDirectionFasterAnimNum, - GetMoveDirectionFastestAnimNum, + [MOVE_SPEED_NORMAL] = GetMoveDirectionAnimNum, + [MOVE_SPEED_FAST_1] = GetMoveDirectionFastAnimNum, + [MOVE_SPEED_FAST_2] = GetMoveDirectionFastAnimNum, + [MOVE_SPEED_FASTER] = GetMoveDirectionFasterAnimNum, + [MOVE_SPEED_FASTEST] = GetMoveDirectionFastestAnimNum, }; u8 (*const gMovementActionFuncs_WalkSlowDiagonalUpLeft[])(struct ObjectEvent *, struct Sprite *) = { @@ -859,26 +859,26 @@ u8 (*const gMovementActionFuncs_WalkInPlaceFastRight[])(struct ObjectEvent *, st MovementAction_PauseSpriteAnim, }; -u8 (*const gMovementActionFuncs_WalkInPlaceFastestDown[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkInPlaceFastestDown_Step0, +u8 (*const gMovementActionFuncs_WalkInPlaceFasterDown[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkInPlaceFasterDown_Step0, MovementAction_WalkInPlace_Step1, MovementAction_PauseSpriteAnim, }; -u8 (*const gMovementActionFuncs_WalkInPlaceFastestUp[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkInPlaceFastestUp_Step0, +u8 (*const gMovementActionFuncs_WalkInPlaceFasterUp[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkInPlaceFasterUp_Step0, MovementAction_WalkInPlace_Step1, MovementAction_PauseSpriteAnim, }; -u8 (*const gMovementActionFuncs_WalkInPlaceFastestLeft[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkInPlaceFastestLeft_Step0, +u8 (*const gMovementActionFuncs_WalkInPlaceFasterLeft[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkInPlaceFasterLeft_Step0, MovementAction_WalkInPlace_Step1, MovementAction_PauseSpriteAnim, }; -u8 (*const gMovementActionFuncs_WalkInPlaceFastestRight[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkInPlaceFastestRight_Step0, +u8 (*const gMovementActionFuncs_WalkInPlaceFasterRight[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkInPlaceFasterRight_Step0, MovementAction_WalkInPlace_Step1, MovementAction_PauseSpriteAnim, }; @@ -907,27 +907,27 @@ u8 (*const gMovementActionFuncs_RideWaterCurrentRight[])(struct ObjectEvent *, s MovementAction_PauseSpriteAnim, }; -u8 (*const gMovementActionFuncs_WalkFastestDown[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkFastestDown_Step0, - MovementAction_WalkFastestDown_Step1, +u8 (*const gMovementActionFuncs_WalkFasterDown[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkFasterDown_Step0, + MovementAction_WalkFasterDown_Step1, MovementAction_PauseSpriteAnim, }; -u8 (*const gMovementActionFuncs_WalkFastestUp[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkFastestUp_Step0, - MovementAction_WalkFastestUp_Step1, +u8 (*const gMovementActionFuncs_WalkFasterUp[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkFasterUp_Step0, + MovementAction_WalkFasterUp_Step1, MovementAction_PauseSpriteAnim, }; -u8 (*const gMovementActionFuncs_WalkFastestLeft[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkFastestLeft_Step0, - MovementAction_WalkFastestLeft_Step1, +u8 (*const gMovementActionFuncs_WalkFasterLeft[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkFasterLeft_Step0, + MovementAction_WalkFasterLeft_Step1, MovementAction_PauseSpriteAnim, }; -u8 (*const gMovementActionFuncs_WalkFastestRight[])(struct ObjectEvent *, struct Sprite *) = { - MovementAction_WalkFastestRight_Step0, - MovementAction_WalkFastestRight_Step1, +u8 (*const gMovementActionFuncs_WalkFasterRight[])(struct ObjectEvent *, struct Sprite *) = { + MovementAction_WalkFasterRight_Step0, + MovementAction_WalkFasterRight_Step1, MovementAction_PauseSpriteAnim, }; diff --git a/src/data/object_events/movement_type_func_tables.h b/src/data/object_events/movement_type_func_tables.h index f4890d684..f5189d838 100755 --- a/src/data/object_events/movement_type_func_tables.h +++ b/src/data/object_events/movement_type_func_tables.h @@ -388,17 +388,17 @@ u8 (*const gMovementTypeFuncs_CopyPlayer[])(struct ObjectEvent *, struct Sprite }; bool8 (*const gCopyPlayerMovementFuncs[])(struct ObjectEvent *, struct Sprite *, u8, bool8(u8)) = { - CopyablePlayerMovement_None, - CopyablePlayerMovement_FaceDirection, - CopyablePlayerMovement_GoSpeed0, - CopyablePlayerMovement_GoSpeed1, - CopyablePlayerMovement_GoSpeed2, - CopyablePlayerMovement_Slide, - cph_IM_DIFFERENT, - CopyablePlayerMovement_GoSpeed4, - CopyablePlayerMovement_Jump, - CopyablePlayerMovement_None, - CopyablePlayerMovement_None, + [COPY_MOVE_NONE] = CopyablePlayerMovement_None, + [COPY_MOVE_FACE] = CopyablePlayerMovement_FaceDirection, + [COPY_MOVE_WALK] = CopyablePlayerMovement_WalkNormal, + [COPY_MOVE_WALK_FAST] = CopyablePlayerMovement_WalkFast, + [COPY_MOVE_WALK_FASTER] = CopyablePlayerMovement_WalkFaster, + [COPY_MOVE_SLIDE] = CopyablePlayerMovement_Slide, + [COPY_MOVE_JUMP_IN_PLACE] = CopyablePlayerMovement_JumpInPlace, + [COPY_MOVE_JUMP] = CopyablePlayerMovement_Jump, + [COPY_MOVE_JUMP2] = CopyablePlayerMovement_Jump2, + [COPY_MOVE_EMPTY_1] = CopyablePlayerMovement_None, + [COPY_MOVE_EMPTY_2] = CopyablePlayerMovement_None, }; u8 (*const gMovementTypeFuncs_CopyPlayerInGrass[])(struct ObjectEvent *, struct Sprite *) = { diff --git a/src/data/pokemon/tmhm_learnsets.h b/src/data/pokemon/tmhm_learnsets.h index deeeda16f..cb42d7c6f 100644 --- a/src/data/pokemon/tmhm_learnsets.h +++ b/src/data/pokemon/tmhm_learnsets.h @@ -15,7 +15,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -35,7 +35,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -57,7 +57,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) @@ -239,7 +239,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -264,7 +264,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM31_BRICK_BREAK) | TMHM(TM32_DOUBLE_TEAM) @@ -758,7 +758,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -794,7 +794,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -867,7 +867,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM27_RETURN) @@ -901,7 +901,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM27_RETURN) @@ -974,7 +974,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -992,7 +992,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -1011,7 +1011,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -1029,7 +1029,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM32_DOUBLE_TEAM) @@ -1052,7 +1052,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM32_DOUBLE_TEAM) @@ -1073,7 +1073,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM32_DOUBLE_TEAM) @@ -1093,7 +1093,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM32_DOUBLE_TEAM) @@ -1607,7 +1607,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -1626,7 +1626,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -1646,7 +1646,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -1778,7 +1778,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM11_SUNNY_DAY) | TMHM(TM17_PROTECT) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) @@ -1797,7 +1797,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM15_HYPER_BEAM) | TMHM(TM17_PROTECT) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) @@ -2348,7 +2348,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM32_DOUBLE_TEAM) @@ -2372,7 +2372,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM32_DOUBLE_TEAM) @@ -2495,7 +2495,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -2647,7 +2647,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -2680,7 +2680,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -2706,7 +2706,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -2872,7 +2872,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM27_RETURN) @@ -3021,7 +3021,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -3198,7 +3198,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -3356,7 +3356,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM26_EARTHQUAKE) @@ -3560,7 +3560,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -3608,7 +3608,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -3655,7 +3655,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) @@ -3676,7 +3676,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) @@ -3700,7 +3700,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) @@ -3874,7 +3874,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM27_RETURN) @@ -3903,7 +3903,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -3976,7 +3976,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM31_BRICK_BREAK) @@ -4000,7 +4000,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM31_BRICK_BREAK) @@ -4020,7 +4020,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM29_PSYCHIC) @@ -4040,7 +4040,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM29_PSYCHIC) @@ -4151,7 +4151,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -4177,7 +4177,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM29_PSYCHIC) @@ -4202,7 +4202,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -4229,7 +4229,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -4258,7 +4258,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -4284,7 +4284,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -4373,7 +4373,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -4493,7 +4493,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM40_AERIAL_ACE) @@ -4510,7 +4510,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM40_AERIAL_ACE) @@ -4528,7 +4528,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM40_AERIAL_ACE) @@ -4547,7 +4547,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -4577,7 +4577,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -4598,7 +4598,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -4615,7 +4615,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -4855,7 +4855,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -4877,7 +4877,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -4901,7 +4901,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -4982,7 +4982,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM26_EARTHQUAKE) @@ -5017,7 +5017,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -5455,7 +5455,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM12_TAUNT) | TMHM(TM17_PROTECT) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) @@ -5481,7 +5481,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM15_HYPER_BEAM) | TMHM(TM17_PROTECT) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) @@ -5568,7 +5568,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -5593,7 +5593,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -5731,7 +5731,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -5766,7 +5766,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -5826,7 +5826,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -6003,7 +6003,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM26_EARTHQUAKE) @@ -6039,7 +6039,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -6114,7 +6114,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -6140,7 +6140,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -6169,7 +6169,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) @@ -6450,7 +6450,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -6473,7 +6473,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) | TMHM(TM30_SHADOW_BALL) @@ -6499,7 +6499,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM42_FACADE) @@ -6522,7 +6522,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM31_BRICK_BREAK) | TMHM(TM32_DOUBLE_TEAM) @@ -6552,7 +6552,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM31_BRICK_BREAK) | TMHM(TM32_DOUBLE_TEAM) @@ -6575,7 +6575,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM30_SHADOW_BALL) @@ -6595,7 +6595,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM30_SHADOW_BALL) @@ -6621,7 +6621,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM30_SHADOW_BALL) @@ -6646,7 +6646,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM30_SHADOW_BALL) @@ -6666,7 +6666,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM30_SHADOW_BALL) @@ -6688,7 +6688,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) | TMHM(TM30_SHADOW_BALL) @@ -6745,7 +6745,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -6767,7 +6767,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM27_RETURN) | TMHM(TM31_BRICK_BREAK) @@ -6866,7 +6866,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) | TMHM(TM32_DOUBLE_TEAM) @@ -6888,7 +6888,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) | TMHM(TM32_DOUBLE_TEAM) @@ -6960,7 +6960,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -6987,7 +6987,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -7014,7 +7014,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -7048,7 +7048,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -7073,7 +7073,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -7383,7 +7383,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -7404,7 +7404,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM28_DIG) @@ -7428,7 +7428,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) @@ -7660,7 +7660,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM37_SANDSTORM) @@ -7680,7 +7680,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM37_SANDSTORM) @@ -7769,7 +7769,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM29_PSYCHIC) @@ -7906,7 +7906,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM31_BRICK_BREAK) | TMHM(TM32_DOUBLE_TEAM) @@ -7982,7 +7982,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM40_AERIAL_ACE) @@ -8005,7 +8005,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) @@ -8085,7 +8085,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) | TMHM(TM32_DOUBLE_TEAM) @@ -8108,7 +8108,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM27_RETURN) @@ -8140,7 +8140,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM26_EARTHQUAKE) @@ -8174,7 +8174,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM26_EARTHQUAKE) @@ -8204,7 +8204,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) | TMHM(TM32_DOUBLE_TEAM) @@ -8229,7 +8229,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) | TMHM(TM32_DOUBLE_TEAM) @@ -8253,7 +8253,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM19_GIGA_DRAIN) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) @@ -8279,7 +8279,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) | TMHM(TM32_DOUBLE_TEAM) @@ -8302,7 +8302,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) @@ -8332,7 +8332,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM30_SHADOW_BALL) @@ -8538,7 +8538,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -8649,7 +8649,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -8683,7 +8683,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM27_RETURN) @@ -8710,7 +8710,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM27_RETURN) @@ -8736,7 +8736,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM27_RETURN) @@ -8759,7 +8759,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) | TMHM(TM36_SLUDGE_BOMB) @@ -8777,7 +8777,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM19_GIGA_DRAIN) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM26_EARTHQUAKE) | TMHM(TM27_RETURN) | TMHM(TM32_DOUBLE_TEAM) @@ -9160,7 +9160,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -9196,7 +9196,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM17_PROTECT) | TMHM(TM18_RAIN_DANCE) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM23_IRON_TAIL) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) @@ -9234,7 +9234,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM26_EARTHQUAKE) @@ -9272,7 +9272,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM26_EARTHQUAKE) @@ -9337,7 +9337,7 @@ const u32 gTMHMLearnsets[][2] = | TMHM(TM18_RAIN_DANCE) | TMHM(TM20_SAFEGUARD) | TMHM(TM21_FRUSTRATION) - | TMHM(TM22_SOLARBEAM) + | TMHM(TM22_SOLAR_BEAM) | TMHM(TM24_THUNDERBOLT) | TMHM(TM25_THUNDER) | TMHM(TM27_RETURN) diff --git a/src/daycare.c b/src/daycare.c index 8105c2e9c..c900e3493 100644 --- a/src/daycare.c +++ b/src/daycare.c @@ -77,7 +77,7 @@ static const struct ListMenuTemplate sDaycareListMenuLevelTemplate = .lettersSpacing = 1, .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 0 }; @@ -1186,7 +1186,7 @@ static void DaycareAddTextPrinter(u8 windowId, const u8 *text, u32 x, u32 y) printer.currentChar = text; printer.windowId = windowId; - printer.fontId = 1; + printer.fontId = FONT_NORMAL; printer.x = x; printer.y = y; printer.currentX = x; @@ -1199,7 +1199,7 @@ static void DaycareAddTextPrinter(u8 windowId, const u8 *text, u32 x, u32 y) printer.bgColor = 1; printer.shadowColor = 3; - AddTextPrinter(&printer, 0xFF, NULL); + AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL); } static void DaycarePrintMonNickname(struct DayCare *daycare, u8 windowId, u32 daycareSlotId, u32 y) @@ -1222,7 +1222,7 @@ static void DaycarePrintMonLvl(struct DayCare *daycare, u8 windowId, u32 daycare level = GetLevelAfterDaycareSteps(&daycare->mons[daycareSlotId].mon, daycare->mons[daycareSlotId].steps); ConvertIntToDecimalStringN(intText, level, STR_CONV_MODE_LEFT_ALIGN, 3); StringAppend(lvlText, intText); - x = GetStringRightAlignXOffset(1, lvlText, 112); + x = GetStringRightAlignXOffset(FONT_NORMAL, lvlText, 112); DaycareAddTextPrinter(windowId, lvlText, x, y); } @@ -1285,7 +1285,7 @@ void ShowDaycareLevelMenu(void) menuTemplate.windowId = windowId; listMenuTaskId = ListMenuInit(&menuTemplate, 0, 0); - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); daycareMenuTaskId = CreateTask(Task_HandleDaycareLevelMenuInput, 3); gTasks[daycareMenuTaskId].tMenuListTaskId = listMenuTaskId; diff --git a/src/decompress.c b/src/decompress.c index a65f38c2d..b74d4e814 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -113,7 +113,7 @@ void Unused_LZDecompressWramIndirect(const void **src, void *dest) LZ77UnCompWram(*src, dest); } -void sub_803471C(s32 object_size, s32 object_count, u8 *src_tiles, u8 *dest_tiles) +static void StitchObjectsOn8x8Canvas(s32 object_size, s32 object_count, u8 *src_tiles, u8 *dest_tiles) { /* This function appears to emulate behaviour found in the GB(C) versions regarding how the Pokemon images diff --git a/src/decoration.c b/src/decoration.c index 838b5cb66..bb2dea7f9 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -315,7 +315,7 @@ static const struct ListMenuTemplate sDecorationItemsListMenuTemplate = .lettersSpacing = FALSE, .itemVerticalPadding = 0, .scrollMultiple = FALSE, - .fontId = 7 + .fontId = FONT_NARROW }; #include "data/decoration/icon.h" @@ -557,7 +557,7 @@ static void AddDecorationActionsWindow(void) { u8 windowId = AddDecorationWindow(WINDOW_MAIN_MENU); PrintMenuTable(windowId, ARRAY_COUNT(sDecorationMainMenuActions), sDecorationMainMenuActions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, ARRAY_COUNT(sDecorationMainMenuActions), sDecorationActionsCursorPos); + InitMenuInUpperLeftCornerNormal(windowId, ARRAY_COUNT(sDecorationMainMenuActions), sDecorationActionsCursorPos); } static void InitDecorationActionsWindow(void) @@ -615,7 +615,7 @@ static void HandleDecorationActionsMenuInput(u8 taskId) static void PrintCurMainMenuDescription(void) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sSecretBasePCMenuItemDescriptions[sDecorationActionsCursorPos], 0, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sSecretBasePCMenuItemDescriptions[sDecorationActionsCursorPos], 0, 0, 2, 1, 3); } static void DecorationMenuAction_Decorate(u8 taskId) @@ -697,7 +697,7 @@ static void InitDecorationCategoriesWindow(u8 taskId) { u8 windowId = AddDecorationWindow(WINDOW_DECORATION_CATEGORIES); PrintDecorationCategoryMenuItems(taskId); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, DECORCAT_COUNT + 1, sCurDecorationCategory); + InitMenuInUpperLeftCornerNormal(windowId, DECORCAT_COUNT + 1, sCurDecorationCategory); gTasks[taskId].func = HandleDecorationCategoriesMenuInput; } @@ -705,7 +705,7 @@ static void ReinitDecorationCategoriesWindow(u8 taskId) { FillWindowPixelBuffer(sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES], PIXEL_FILL(1)); PrintDecorationCategoryMenuItems(taskId); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES], DECORCAT_COUNT + 1, sCurDecorationCategory); + InitMenuInUpperLeftCornerNormal(sDecorMenuWindowIds[WINDOW_DECORATION_CATEGORIES], DECORCAT_COUNT + 1, sCurDecorationCategory); gTasks[taskId].func = HandleDecorationCategoriesMenuInput; } @@ -723,12 +723,12 @@ static void PrintDecorationCategoryMenuItems(u8 taskId) { // Only DOLL and CUSHION decorations are enabled when decorating the player's room. if (shouldDisable == TRUE && i != DECORCAT_DOLL && i != DECORCAT_CUSHION) - PrintDecorationCategoryMenuItem(windowId, i, 8, i * 16, TRUE, TEXT_SPEED_FF); + PrintDecorationCategoryMenuItem(windowId, i, 8, i * 16, TRUE, TEXT_SKIP_DRAW); else - PrintDecorationCategoryMenuItem(windowId, i, 8, i * 16, FALSE, TEXT_SPEED_FF); + PrintDecorationCategoryMenuItem(windowId, i, 8, i * 16, FALSE, TEXT_SKIP_DRAW); } - AddTextPrinterParameterized(windowId, 1, gTasks[taskId].tDecorationMenuCommand == DECOR_MENU_TRADE ? gText_Exit : gText_Cancel, 8, i * 16 + 1, 0, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gTasks[taskId].tDecorationMenuCommand == DECOR_MENU_TRADE ? gText_Exit : gText_Cancel, 8, i * 16 + 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); } @@ -742,12 +742,12 @@ static void PrintDecorationCategoryMenuItem(u8 winid, u8 category, u8 x, u8 y, b ColorMenuItemString(gStringVar4, disabled); str = StringLength(gStringVar4) + gStringVar4; StringCopy(str, sDecorationCategoryNames[category]); - AddTextPrinterParameterized(winid, 1, gStringVar4, x, y, speed, NULL); + AddTextPrinterParameterized(winid, FONT_NORMAL, gStringVar4, x, y, speed, NULL); str = ConvertIntToDecimalStringN(str, GetNumOwnedDecorationsInCategory(category), STR_CONV_MODE_RIGHT_ALIGN, 2); *(str++) = CHAR_SLASH; ConvertIntToDecimalStringN(str, gDecorationInventories[category].size, STR_CONV_MODE_RIGHT_ALIGN, 2); - x = GetStringRightAlignXOffset(1, gStringVar4, width); - AddTextPrinterParameterized(winid, 1, gStringVar4, x, y, speed, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, width); + AddTextPrinterParameterized(winid, FONT_NORMAL, gStringVar4, x, y, speed, NULL); } static void ColorMenuItemString(u8 *str, bool8 disabled) @@ -1024,7 +1024,7 @@ static void PrintDecorationItemDescription(s32 itemIndex) else str = gDecorations[gCurDecorationItems[itemIndex]].description; - AddTextPrinterParameterized(windowId, 1, str, 0, 1, 0, 0); + AddTextPrinterParameterized(windowId, FONT_NORMAL, str, 0, 1, 0, 0); } static void RemoveDecorationItemsOtherWindows(void) diff --git a/src/diploma.c b/src/diploma.c index dca0912e3..76b4ae65c 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -83,7 +83,7 @@ void CB2_ShowDiploma(void) LZDecompressWram(sDiplomaTilemap, sDiplomaTilemapPtr); CopyBgTilemapBufferToVram(1); DisplayDiplomaText(); - BlendPalettes(-1, 16, 0); + BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); EnableInterrupts(1); SetVBlankCallback(VBlankCB); @@ -140,7 +140,7 @@ static void DisplayDiplomaText(void) StringExpandPlaceholders(gStringVar4, gText_PokedexDiploma); PrintDiplomaText(gStringVar4, 0, 1); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } static const struct BgTemplate sDiplomaBgTemplates[2] = @@ -196,7 +196,7 @@ static void InitDiplomaWindow(void) { InitWindows(sDiplomaWinTemplates); DeactivateAllTextPrinters(); - LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(gStandardMenuPalette, 0xF0, 0x20); FillWindowPixelBuffer(0, PIXEL_FILL(0)); PutWindowTilemap(0); } @@ -205,5 +205,5 @@ static void PrintDiplomaText(u8 *text, u8 var1, u8 var2) { u8 color[3] = {0, 2, 3}; - AddTextPrinterParameterized4(0, 1, var1, var2, 0, 0, color, -1, text); + AddTextPrinterParameterized4(0, FONT_NORMAL, var1, var2, 0, 0, color, TEXT_SKIP_DRAW, text); } diff --git a/src/dodrio_berry_picking.c b/src/dodrio_berry_picking.c index d7361ce96..e680b56d3 100644 --- a/src/dodrio_berry_picking.c +++ b/src/dodrio_berry_picking.c @@ -1352,14 +1352,14 @@ static void ResetGame(void) } break; case 2: - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); sGame->state++; break; case 3: @@ -2954,10 +2954,10 @@ static void Task_ShowDodrioBerryPickingRecords(u8 taskId) { case 0: window = sWindowTemplates_Records; - width = GetStringWidth(1, gText_BerryPickingRecords, 0); + width = GetStringWidth(FONT_NORMAL, gText_BerryPickingRecords, 0); for (i = 0; i < ARRAY_COUNT(sRecordsTexts); i++) { - widthCurr = GetStringWidth(1, sRecordsTexts[i], 0) + 50; + widthCurr = GetStringWidth(FONT_NORMAL, sRecordsTexts[i], 0) + 50; if (widthCurr > width) width = widthCurr; } @@ -2968,7 +2968,7 @@ static void Task_ShowDodrioBerryPickingRecords(u8 taskId) window.width = width; tWindowId = AddWindow(&window); PrintRecordsText(tWindowId, width); - CopyWindowToVram(tWindowId, 3); + CopyWindowToVram(tWindowId, COPYWIN_FULL); tState++; break; case 1: @@ -2979,7 +2979,7 @@ static void Task_ShowDodrioBerryPickingRecords(u8 taskId) if (JOY_NEW(A_BUTTON | B_BUTTON)) { rbox_fill_rectangle(tWindowId); - CopyWindowToVram(tWindowId, 1); + CopyWindowToVram(tWindowId, COPYWIN_MAP); tState++; } break; @@ -3008,14 +3008,14 @@ static void PrintRecordsText(u8 windowId, s32 width) LoadUserWindowBorderGfx_(windowId, 0x21D, 0xD0); DrawTextBorderOuter(windowId, 0x21D, 0xD); FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); - AddTextPrinterParameterized(windowId, 1, gText_BerryPickingRecords, GetStringCenterAlignXOffset(1, gText_BerryPickingRecords, width * 8), 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_BerryPickingRecords, GetStringCenterAlignXOffset(FONT_NORMAL, gText_BerryPickingRecords, width * 8), 1, TEXT_SKIP_DRAW, NULL); for (i = 0; i < NUM_RECORD_TYPES; i++) { ConvertIntToDecimalStringN(gStringVar1, recordNums[i], STR_CONV_MODE_LEFT_ALIGN, sRecordNumMaxDigits[i]); - numWidth = GetStringWidth(1, gStringVar1, -1); - AddTextPrinterParameterized(windowId, 1, sRecordsTexts[i], 0, sRecordTextYCoords[i][0], TEXT_SPEED_FF, NULL); + numWidth = GetStringWidth(FONT_NORMAL, gStringVar1, -1); + AddTextPrinterParameterized(windowId, FONT_NORMAL, sRecordsTexts[i], 0, sRecordTextYCoords[i][0], TEXT_SKIP_DRAW, NULL); x = (width * 8) - numWidth; - AddTextPrinterParameterized(windowId, 1, gStringVar1, x, sRecordNumYCoords[i][0], TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar1, x, sRecordNumYCoords[i][0], TEXT_SKIP_DRAW, NULL); } PutWindowTilemap(windowId); } @@ -4640,7 +4640,7 @@ static void ShowNames(void) { colorsId = COLORID_GRAY; playerId = GetPlayerIdByPos(i); - left = (56 - GetStringWidth(1, GetPlayerName(playerId), -1)) / 2u; + left = (56 - GetStringWidth(FONT_NORMAL, GetPlayerName(playerId), -1)) / 2u; window.tilemapLeft = coords->left; window.tilemapTop = coords->top; sGfx->windowIds[i] = AddWindow(&window); @@ -4649,8 +4649,8 @@ static void ShowNames(void) if (playerId == GetMultiplayerId()) colorsId = COLORID_BLUE; name = GetPlayerName(playerId); - AddTextPrinterParameterized3(sGfx->windowIds[i], 1, left, 1, sTextColorTable[colorsId], -1, name); - CopyWindowToVram(sGfx->windowIds[i], 2); + AddTextPrinterParameterized3(sGfx->windowIds[i], FONT_NORMAL, left, 1, sTextColorTable[colorsId], TEXT_SKIP_DRAW, name); + CopyWindowToVram(sGfx->windowIds[i], COPYWIN_GFX); window.baseBlock += 0xE; DrawMessageWindow(&window); } @@ -4726,22 +4726,22 @@ static void PrintRankedScores(u8 numPlayers_) } // Print text - x = 216 - GetStringWidth(1, gText_SpacePoints, 0); + x = 216 - GetStringWidth(FONT_NORMAL, gText_SpacePoints, 0); for (i = 0; i < numPlayers; i++) { u8 colorsId = COLORID_GRAY; u8 playerId = playersByRanking[i]; u32 points = scoreResults[playerId].score; - AddTextPrinterParameterized(sGfx->windowIds[1], 1, sRankingTexts[scoreResults[playerId].ranking], 8, sRankingYCoords[i], -1, NULL); + AddTextPrinterParameterized(sGfx->windowIds[1], FONT_NORMAL, sRankingTexts[scoreResults[playerId].ranking], 8, sRankingYCoords[i], TEXT_SKIP_DRAW, NULL); if (playerId == GetMultiplayerId()) colorsId = COLORID_BLUE; name = GetPlayerName(playerId); - AddTextPrinterParameterized3(sGfx->windowIds[1], 1, 28, sRankingYCoords[i], sTextColorTable[colorsId], -1, name); + AddTextPrinterParameterized3(sGfx->windowIds[1], FONT_NORMAL, 28, sRankingYCoords[i], sTextColorTable[colorsId], TEXT_SKIP_DRAW, name); ConvertIntToDecimalStringN(numString, points, STR_CONV_MODE_LEFT_ALIGN, 7); - numWidth = GetStringWidth(1, numString, -1); - AddTextPrinterParameterized(sGfx->windowIds[1], 1, numString, x - numWidth, sRankingYCoords[i], -1, NULL); - AddTextPrinterParameterized(sGfx->windowIds[1], 1, gText_SpacePoints, x, sRankingYCoords[i], -1, NULL); + numWidth = GetStringWidth(FONT_NORMAL, numString, -1); + AddTextPrinterParameterized(sGfx->windowIds[1], FONT_NORMAL, numString, x - numWidth, sRankingYCoords[i], TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(sGfx->windowIds[1], FONT_NORMAL, gText_SpacePoints, x, sRankingYCoords[i], TEXT_SKIP_DRAW, NULL); } } @@ -4770,10 +4770,10 @@ static void ShowResults(void) case 2: FillWindowPixelBuffer(sGfx->windowIds[0], PIXEL_FILL(1)); FillWindowPixelBuffer(sGfx->windowIds[1], PIXEL_FILL(1)); - strWidth = GetStringWidth(1, gText_BerryPickingResults, -1); + strWidth = GetStringWidth(FONT_NORMAL, gText_BerryPickingResults, -1); x = (224 - strWidth) / 2; - AddTextPrinterParameterized(sGfx->windowIds[0], 1, gText_BerryPickingResults, x, 1, -1, NULL); - AddTextPrinterParameterized(sGfx->windowIds[1], 1, gText_10P30P50P50P, 68, 17, -1, NULL); + AddTextPrinterParameterized(sGfx->windowIds[0], FONT_NORMAL, gText_BerryPickingResults, x, 1, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(sGfx->windowIds[1], FONT_NORMAL, gText_10P30P50P50P, 68, 17, TEXT_SKIP_DRAW, NULL); for (i = 0; i < numPlayers; i++) { u8 colorsId = COLORID_GRAY; @@ -4781,7 +4781,7 @@ static void ShowResults(void) colorsId = COLORID_BLUE; name = GetPlayerName(i); - AddTextPrinterParameterized3(sGfx->windowIds[1], 1, 0, sResultsYCoords[i], sTextColorTable[colorsId], -1, name); + AddTextPrinterParameterized3(sGfx->windowIds[1], FONT_NORMAL, 0, sResultsYCoords[i], sTextColorTable[colorsId], TEXT_SKIP_DRAW, name); for (j = 0; j < 4; j++) { u32 width; @@ -4789,17 +4789,17 @@ static void ShowResults(void) u16 maxBerriesPicked = Min(GetHighestBerryResult(j), MAX_BERRIES); ConvertIntToDecimalStringN(gStringVar4, berriesPicked, STR_CONV_MODE_LEFT_ALIGN, 4); - width = GetStringWidth(1, gStringVar4, -1); + width = GetStringWidth(FONT_NORMAL, gStringVar4, -1); // If player got the most of a berry type, highlight their number in red if (maxBerriesPicked == berriesPicked && maxBerriesPicked != 0) - AddTextPrinterParameterized3(sGfx->windowIds[1], 1, sResultsXCoords[j] - width, sResultsYCoords[i], sTextColorTable[COLORID_RED], -1, gStringVar4); + AddTextPrinterParameterized3(sGfx->windowIds[1], FONT_NORMAL, sResultsXCoords[j] - width, sResultsYCoords[i], sTextColorTable[COLORID_RED], TEXT_SKIP_DRAW, gStringVar4); else - AddTextPrinterParameterized(sGfx->windowIds[1], 1, gStringVar4, sResultsXCoords[j] - width, sResultsYCoords[i], -1, NULL); + AddTextPrinterParameterized(sGfx->windowIds[1], FONT_NORMAL, gStringVar4, sResultsXCoords[j] - width, sResultsYCoords[i], TEXT_SKIP_DRAW, NULL); } } - CopyWindowToVram(sGfx->windowIds[0], 2); - CopyWindowToVram(sGfx->windowIds[1], 2); + CopyWindowToVram(sGfx->windowIds[0], COPYWIN_GFX); + CopyWindowToVram(sGfx->windowIds[1], COPYWIN_GFX); sGfx->state++; break; case 3: @@ -4824,15 +4824,15 @@ static void ShowResults(void) case 5: FillWindowPixelBuffer(sGfx->windowIds[0], PIXEL_FILL(1)); FillWindowPixelBuffer(sGfx->windowIds[1], PIXEL_FILL(1)); - strWidth = GetStringWidth(1, gText_AnnouncingRankings, -1); + strWidth = GetStringWidth(FONT_NORMAL, gText_AnnouncingRankings, -1); x = (224 - strWidth) / 2; - AddTextPrinterParameterized(sGfx->windowIds[0], 1, gText_AnnouncingRankings, x, 1, -1, NULL); + AddTextPrinterParameterized(sGfx->windowIds[0], FONT_NORMAL, gText_AnnouncingRankings, x, 1, TEXT_SKIP_DRAW, NULL); sGfx->state++; break; case 6: PrintRankedScores(numPlayers); - CopyWindowToVram(sGfx->windowIds[0], 2); - CopyWindowToVram(sGfx->windowIds[1], 2); + CopyWindowToVram(sGfx->windowIds[0], COPYWIN_GFX); + CopyWindowToVram(sGfx->windowIds[1], COPYWIN_GFX); sGfx->state++; break; case 7: @@ -4870,14 +4870,14 @@ static void ShowResults(void) PlayNewMapMusic(MUS_LEVEL_UP); FillWindowPixelBuffer(sGfx->windowIds[0], PIXEL_FILL(1)); FillWindowPixelBuffer(sGfx->windowIds[1], PIXEL_FILL(1)); - strWidth = GetStringWidth(1, gText_AnnouncingPrizes, -1); + strWidth = GetStringWidth(FONT_NORMAL, gText_AnnouncingPrizes, -1); x = (224 - strWidth) / 2; - AddTextPrinterParameterized(sGfx->windowIds[0], 1, gText_AnnouncingPrizes, x, 1, -1, NULL); + AddTextPrinterParameterized(sGfx->windowIds[0], FONT_NORMAL, gText_AnnouncingPrizes, x, 1, TEXT_SKIP_DRAW, NULL); DynamicPlaceholderTextUtil_Reset(); CopyItemName(GetPrizeItemId(), gStringVar1); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_FirstPlacePrize); - AddTextPrinterParameterized(sGfx->windowIds[1], 1, gStringVar4, 0, 1, -1, NULL); + AddTextPrinterParameterized(sGfx->windowIds[1], FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); prizeState = TryGivePrize(); if (prizeState != PRIZE_RECEIVED && prizeState != NO_PRIZE) { @@ -4888,10 +4888,10 @@ static void ShowResults(void) DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_CantHoldAnyMore); else if (prizeState == PRIZE_FILLED_BAG) DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_FilledStorageSpace); - AddTextPrinterParameterized(sGfx->windowIds[1], 1, gStringVar4, 0, 41, -1, NULL); + AddTextPrinterParameterized(sGfx->windowIds[1], FONT_NORMAL, gStringVar4, 0, 41, TEXT_SKIP_DRAW, NULL); } - CopyWindowToVram(sGfx->windowIds[0], 2); - CopyWindowToVram(sGfx->windowIds[1], 2); + CopyWindowToVram(sGfx->windowIds[0], COPYWIN_GFX); + CopyWindowToVram(sGfx->windowIds[1], COPYWIN_GFX); sGfx->state++; break; case 10: @@ -4946,12 +4946,12 @@ static void Msg_WantToPlayAgain(void) // Print text FillWindowPixelBuffer(sGfx->windowIds[WIN_PLAY_AGAIN], PIXEL_FILL(1)); FillWindowPixelBuffer(sGfx->windowIds[WIN_YES_NO], PIXEL_FILL(1)); - AddTextPrinterParameterized(sGfx->windowIds[WIN_PLAY_AGAIN], 1, gText_WantToPlayAgain, 0, 5, -1, NULL); - AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], 1, gText_Yes, 8, 1, -1, NULL); - AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], 1, gText_No, 8, 17, -1, NULL); - AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], 1, gText_SelectorArrow2, 0, 1, -1, NULL); - CopyWindowToVram(sGfx->windowIds[WIN_PLAY_AGAIN], 2); - CopyWindowToVram(sGfx->windowIds[WIN_YES_NO], 2); + AddTextPrinterParameterized(sGfx->windowIds[WIN_PLAY_AGAIN], FONT_NORMAL, gText_WantToPlayAgain, 0, 5, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], FONT_NORMAL, gText_Yes, 8, 1, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], FONT_NORMAL, gText_No, 8, 17, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], FONT_NORMAL, gText_SelectorArrow2, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sGfx->windowIds[WIN_PLAY_AGAIN], COPYWIN_GFX); + CopyWindowToVram(sGfx->windowIds[WIN_YES_NO], COPYWIN_GFX); sGfx->state++; break; case 2: @@ -4970,10 +4970,10 @@ static void Msg_WantToPlayAgain(void) if (y == PLAY_AGAIN_NONE) y = PLAY_AGAIN_YES; FillWindowPixelBuffer(sGfx->windowIds[WIN_YES_NO], PIXEL_FILL(1)); - AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], 1, gText_Yes, 8, 1, -1, NULL); - AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], 1, gText_No, 8, 17, -1, NULL); - AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], 1, gText_SelectorArrow2, 0, ((y - 1) * 16) + 1, -1, NULL); - CopyWindowToVram(sGfx->windowIds[WIN_YES_NO], 3); + AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], FONT_NORMAL, gText_Yes, 8, 1, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], FONT_NORMAL, gText_No, 8, 17, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(sGfx->windowIds[WIN_YES_NO], FONT_NORMAL, gText_SelectorArrow2, 0, ((y - 1) * 16) + 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sGfx->windowIds[WIN_YES_NO], COPYWIN_FULL); // Increment state only if A or B button have been pressed. if (JOY_NEW(A_BUTTON)) @@ -5025,11 +5025,11 @@ static void Msg_SavingDontTurnOff(void) { case 0: DrawDialogueFrame(0, FALSE); - AddTextPrinterParameterized2(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); sGfx->state++; break; case 1: - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); sGfx->state++; break; case 2: @@ -5063,8 +5063,8 @@ static void Msg_CommunicationStandby(void) break; case 1: FillWindowPixelBuffer(sGfx->windowIds[0], PIXEL_FILL(1)); - AddTextPrinterParameterized(sGfx->windowIds[0], 1, gText_CommunicationStandby3, 0, 5, -1, NULL); - CopyWindowToVram(sGfx->windowIds[0], 2); + AddTextPrinterParameterized(sGfx->windowIds[0], FONT_NORMAL, gText_CommunicationStandby3, 0, 5, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sGfx->windowIds[0], COPYWIN_GFX); sGfx->state++; break; case 2: @@ -5103,8 +5103,8 @@ static void Msg_SomeoneDroppedOut(void) break; case 1: FillWindowPixelBuffer(sGfx->windowIds[0], PIXEL_FILL(1)); - AddTextPrinterParameterized(sGfx->windowIds[0], 1, gText_SomeoneDroppedOut, 0, 5, -1, NULL); - CopyWindowToVram(sGfx->windowIds[0], 2); + AddTextPrinterParameterized(sGfx->windowIds[0], FONT_NORMAL, gText_SomeoneDroppedOut, 0, 5, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sGfx->windowIds[0], COPYWIN_GFX); sGfx->state++; break; case 2: @@ -5172,14 +5172,14 @@ static void InitBgs(void) SetGpuReg(REG_OFFSET_DISPCNT, 0); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); InitStandardTextBoxWindows(); InitTextBoxGfxAndPrinters(); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP); diff --git a/src/easy_chat.c b/src/easy_chat.c index b18d09b83..1b992caf2 100644 --- a/src/easy_chat.c +++ b/src/easy_chat.c @@ -1310,7 +1310,7 @@ static void StartEasyChatScreen(u8 taskId, TaskFunc taskFunc) static void Task_InitEasyChatScreen(u8 taskId) { - if (!IsUpdateLinkStateCBActive()) + if (!IsOverworldLinkActive()) { while (InitEasyChatScreen(taskId)); } @@ -3176,7 +3176,7 @@ static bool8 UpdateMainCursor(void) else { CopyEasyChatWord(str, *ecWord); - stringWidth = GetStringWidth(1, str, 0); + stringWidth = GetStringWidth(FONT_NORMAL, str, 0); } trueStringWidth = stringWidth + 17; @@ -3900,14 +3900,14 @@ static bool8 InitEasyChatScreenControl_(void) static void InitEasyChatBgs(void) { - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON); } @@ -3930,11 +3930,11 @@ static void PrintTitle(void) if (!titleText) return; - xOffset = GetStringCenterAlignXOffset(1, titleText, 144); + xOffset = GetStringCenterAlignXOffset(FONT_NORMAL, titleText, 144); FillWindowPixelBuffer(0, PIXEL_FILL(0)); - PrintEasyChatTextWithColors(0, 1, titleText, xOffset, 1, TEXT_SPEED_FF, TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY); + PrintEasyChatTextWithColors(0, FONT_NORMAL, titleText, xOffset, 1, TEXT_SKIP_DRAW, TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } static void PrintEasyChatText(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16)) @@ -4003,12 +4003,12 @@ static void PrintEasyChatStdMessage(u8 msgId) FillWindowPixelBuffer(1, PIXEL_FILL(1)); if (text1) - PrintEasyChatText(1, 1, text1, 0, 1, TEXT_SPEED_FF, 0); + PrintEasyChatText(1, FONT_NORMAL, text1, 0, 1, TEXT_SKIP_DRAW, 0); if (text2) - PrintEasyChatText(1, 1, text2, 0, 17, TEXT_SPEED_FF, 0); + PrintEasyChatText(1, FONT_NORMAL, text2, 0, 17, TEXT_SKIP_DRAW, 0); - CopyWindowToVram(1, 3); + CopyWindowToVram(1, COPYWIN_FULL); } static void CreateEasyChatYesNoMenu(u8 initialCursorPos) @@ -4099,10 +4099,10 @@ static void PrintCurrentPhrase(void) } *str = EOS; - PrintEasyChatText(sScreenControl->windowId, 1, sScreenControl->phrasePrintBuffer, 0, i * 16 + 1, TEXT_SPEED_FF, 0); + PrintEasyChatText(sScreenControl->windowId, FONT_NORMAL, sScreenControl->phrasePrintBuffer, 0, i * 16 + 1, TEXT_SKIP_DRAW, 0); } - CopyWindowToVram(sScreenControl->windowId, 3); + CopyWindowToVram(sScreenControl->windowId, COPYWIN_FULL); } static void BufferFrameTilemap(u16 *tilemap) @@ -4216,7 +4216,7 @@ static void InitLowerWindowText(u32 whichText) break; } - CopyWindowToVram(2, 2); + CopyWindowToVram(2, COPYWIN_GFX); } static void PrintKeyboardText(void) @@ -4245,7 +4245,7 @@ static void PrintKeyboardGroupNames(void) return; } - PrintEasyChatText(2, 1, GetEasyChatWordGroupName(groupId), x * 84 + 10, y, TEXT_SPEED_FF, NULL); + PrintEasyChatText(2, FONT_NORMAL, GetEasyChatWordGroupName(groupId), x * 84 + 10, y, TEXT_SKIP_DRAW, NULL); } y += 16; @@ -4257,7 +4257,7 @@ static void PrintKeyboardAlphabet(void) u32 i; for (i = 0; i < ARRAY_COUNT(sEasyChatKeyboardAlphabet); i++) - PrintEasyChatText(2, 1, sEasyChatKeyboardAlphabet[i], 10, 97 + i * 16, TEXT_SPEED_FF, NULL); + PrintEasyChatText(2, FONT_NORMAL, sEasyChatKeyboardAlphabet[i], 10, 97 + i * 16, TEXT_SKIP_DRAW, NULL); } static void PrintInitialWordSelectText(void) @@ -4328,16 +4328,16 @@ static void PrintWordSelectText(u8 scrollOffset, u8 numRows) { CopyEasyChatWordPadded(sScreenControl->wordSelectPrintBuffer, easyChatWord, 0); if (!DummyWordCheck(easyChatWord)) - PrintEasyChatText(2, 1, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SPEED_FF, NULL); + PrintEasyChatText(2, FONT_NORMAL, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SKIP_DRAW, NULL); else // Never reached - PrintEasyChatTextWithColors(2, 1, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SPEED_FF, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_RED, TEXT_COLOR_LIGHT_GRAY); + PrintEasyChatTextWithColors(2, FONT_NORMAL, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SKIP_DRAW, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_RED, TEXT_COLOR_LIGHT_GRAY); } } y += 16; } - CopyWindowToVram(2, 2); + CopyWindowToVram(2, COPYWIN_GFX); } static void EraseWordSelectRows(u8 scrollOffset, u8 numRows) @@ -4369,7 +4369,7 @@ static void EraseWordSelectRows(u8 scrollOffset, u8 numRows) static void ClearWordSelectWindow(void) { FillWindowPixelBuffer(2, PIXEL_FILL(1)); - CopyWindowToVram(2, 2); + CopyWindowToVram(2, COPYWIN_GFX); } static void InitLowerWindowAnim(int winAnimType) @@ -4550,7 +4550,7 @@ static void BufferLowerWindowFrame(int left, int top, int width, int height) static void ResetLowerWindowScroll(void) { - ChangeBgY(2, 0x800, 0); + ChangeBgY(2, 0x800, BG_COORD_SET); sScreenControl->scrollOffset = 0; } @@ -4572,7 +4572,7 @@ static void InitLowerWindowScroll(s16 scrollChange, u8 speed) } else { - ChangeBgY(2, bgY, 0); + ChangeBgY(2, bgY, BG_COORD_SET); } } @@ -4587,7 +4587,7 @@ static bool8 UpdateLowerWindowScroll(void) } else { - ChangeBgY(2, sScreenControl->scrollSpeed, 1); + ChangeBgY(2, sScreenControl->scrollSpeed, BG_COORD_ADD); return TRUE; } } @@ -5082,7 +5082,7 @@ static void AddMainScreenButtonWindow(void) if (str) { int x = sFooterOptionXOffsets[footerIndex][i]; - PrintEasyChatText(windowId, 1, str, x, 1, 0, NULL); + PrintEasyChatText(windowId, FONT_NORMAL, str, x, 1, 0, NULL); } } diff --git a/src/egg_hatch.c b/src/egg_hatch.c index e491b7b14..283ec753a 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -495,10 +495,10 @@ static void CB2_EggHatch_0(void) ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBgTemplates_EggHatch, ARRAY_COUNT(sBgTemplates_EggHatch)); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); SetBgAttribute(1, BG_ATTR_PRIORITY, 2); SetBgTilemapBuffer(1, Alloc(0x1000)); @@ -640,11 +640,11 @@ static void CB2_EggHatch_1(void) case 5: GetMonNickname2(&gPlayerParty[sEggHatchData->eggPartyID], gStringVar1); StringExpandPlaceholders(gStringVar4, gText_HatchedFromEgg); - EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 3, 0xFF); + EggHatchPrintMessage(sEggHatchData->windowId, gStringVar4, 0, 3, TEXT_SKIP_DRAW); PlayFanfare(MUS_EVOLVED); sEggHatchData->CB2_state++; PutWindowTilemap(sEggHatchData->windowId); - CopyWindowToVram(sEggHatchData->windowId, 3); + CopyWindowToVram(sEggHatchData->windowId, COPYWIN_FULL); break; case 6: if (IsFanfareTaskInactive()) @@ -866,7 +866,7 @@ static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed) sEggHatchData->textColor[0] = 0; sEggHatchData->textColor[1] = 5; sEggHatchData->textColor[2] = 6; - AddTextPrinterParameterized4(windowId, 1, x, y, 0, 0, sEggHatchData->textColor, speed, string); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, 0, 0, sEggHatchData->textColor, speed, string); } u8 GetEggCyclesToSubtract(void) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 074fa2386..107ee47ab 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -26,12 +26,21 @@ #include "constants/event_objects.h" #include "constants/field_effects.h" #include "constants/items.h" +#include "constants/maps.h" #include "constants/mauville_old_man.h" #include "constants/trainer_types.h" #include "constants/union_room.h" // this file was known as evobjmv.c in Game Freak's original source +enum { + MOVE_SPEED_NORMAL, // walking + MOVE_SPEED_FAST_1, // running / surfing / sliding (ice tile) + MOVE_SPEED_FAST_2, // water current / acro bike + MOVE_SPEED_FASTER, // mach bike's max speed + MOVE_SPEED_FASTEST, +}; + // Sprite data used throughout #define sObjEventId data[0] #define sTypeFuncId data[1] // Index into corresponding gMovementTypeFuncs_* table @@ -71,7 +80,7 @@ static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *, struct Sp static void SetMovementDelay(struct Sprite *, s16); static bool8 WaitForMovementDelay(struct Sprite *); static u8 GetCollisionInDirection(struct ObjectEvent *, u8); -static u32 state_to_direction(u8, u32, u32); +static u32 GetCopyDirection(u8, u32, u32); static void TryEnableObjectEventAnim(struct ObjectEvent *, struct Sprite *); static void ObjectEventExecHeldMovementAction(struct ObjectEvent *, struct Sprite *); static void UpdateObjectEventSpriteAnimPause(struct ObjectEvent *, struct Sprite *); @@ -259,88 +268,48 @@ static void (*const sMovementTypeCallbacks[])(struct Sprite *) = [MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_RIGHT] = MovementType_WalkSlowlyInPlace, }; -const u8 gRangedMovementTypes[] = { - [MOVEMENT_TYPE_NONE] = 0, - [MOVEMENT_TYPE_LOOK_AROUND] = 0, - [MOVEMENT_TYPE_WANDER_AROUND] = 1, - [MOVEMENT_TYPE_WANDER_UP_AND_DOWN] = 1, - [MOVEMENT_TYPE_WANDER_DOWN_AND_UP] = 1, - [MOVEMENT_TYPE_WANDER_LEFT_AND_RIGHT] = 1, - [MOVEMENT_TYPE_WANDER_RIGHT_AND_LEFT] = 1, - [MOVEMENT_TYPE_FACE_UP] = 0, - [MOVEMENT_TYPE_FACE_DOWN] = 0, - [MOVEMENT_TYPE_FACE_LEFT] = 0, - [MOVEMENT_TYPE_FACE_RIGHT] = 0, - [MOVEMENT_TYPE_PLAYER] = 0, - [MOVEMENT_TYPE_BERRY_TREE_GROWTH] = 0, - [MOVEMENT_TYPE_FACE_DOWN_AND_UP] = 0, - [MOVEMENT_TYPE_FACE_LEFT_AND_RIGHT] = 0, - [MOVEMENT_TYPE_FACE_UP_AND_LEFT] = 0, - [MOVEMENT_TYPE_FACE_UP_AND_RIGHT] = 0, - [MOVEMENT_TYPE_FACE_DOWN_AND_LEFT] = 0, - [MOVEMENT_TYPE_FACE_DOWN_AND_RIGHT] = 0, - [MOVEMENT_TYPE_FACE_DOWN_UP_AND_LEFT] = 0, - [MOVEMENT_TYPE_FACE_DOWN_UP_AND_RIGHT] = 0, - [MOVEMENT_TYPE_FACE_UP_LEFT_AND_RIGHT] = 0, - [MOVEMENT_TYPE_FACE_DOWN_LEFT_AND_RIGHT] = 0, - [MOVEMENT_TYPE_ROTATE_COUNTERCLOCKWISE] = 0, - [MOVEMENT_TYPE_ROTATE_CLOCKWISE] = 0, - [MOVEMENT_TYPE_WALK_UP_AND_DOWN] = 1, - [MOVEMENT_TYPE_WALK_DOWN_AND_UP] = 1, - [MOVEMENT_TYPE_WALK_LEFT_AND_RIGHT] = 1, - [MOVEMENT_TYPE_WALK_RIGHT_AND_LEFT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_LEFT_DOWN] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_DOWN_UP] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_RIGHT_LEFT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_UP_RIGHT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_RIGHT_DOWN] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_DOWN_UP] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_LEFT_RIGHT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_UP_LEFT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_DOWN_RIGHT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_RIGHT_LEFT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_UP_DOWN] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_LEFT_UP] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_DOWN_LEFT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_LEFT_RIGHT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_UP_DOWN] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_RIGHT_UP] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_DOWN_RIGHT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_UP_LEFT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_RIGHT_UP] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_LEFT_DOWN] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_DOWN_LEFT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_UP_RIGHT] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_RIGHT_DOWN] = 1, - [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_LEFT_UP] = 1, - [MOVEMENT_TYPE_COPY_PLAYER] = 1, - [MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE] = 1, - [MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE] = 1, - [MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE] = 1, - [MOVEMENT_TYPE_TREE_DISGUISE] = 0, - [MOVEMENT_TYPE_MOUNTAIN_DISGUISE] = 0, - [MOVEMENT_TYPE_COPY_PLAYER_IN_GRASS] = 1, - [MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE_IN_GRASS] = 1, - [MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE_IN_GRASS] = 1, - [MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE_IN_GRASS] = 1, - [MOVEMENT_TYPE_BURIED] = 0, - [MOVEMENT_TYPE_WALK_IN_PLACE_DOWN] = 0, - [MOVEMENT_TYPE_WALK_IN_PLACE_UP] = 0, - [MOVEMENT_TYPE_WALK_IN_PLACE_LEFT] = 0, - [MOVEMENT_TYPE_WALK_IN_PLACE_RIGHT] = 0, - [MOVEMENT_TYPE_JOG_IN_PLACE_DOWN] = 0, - [MOVEMENT_TYPE_JOG_IN_PLACE_UP] = 0, - [MOVEMENT_TYPE_JOG_IN_PLACE_LEFT] = 0, - [MOVEMENT_TYPE_JOG_IN_PLACE_RIGHT] = 0, - [MOVEMENT_TYPE_RUN_IN_PLACE_DOWN] = 0, - [MOVEMENT_TYPE_RUN_IN_PLACE_UP] = 0, - [MOVEMENT_TYPE_RUN_IN_PLACE_LEFT] = 0, - [MOVEMENT_TYPE_RUN_IN_PLACE_RIGHT] = 0, - [MOVEMENT_TYPE_INVISIBLE] = 0, - [MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_DOWN] = 0, - [MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_UP] = 0, - [MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_LEFT] = 0, - [MOVEMENT_TYPE_WALK_SLOWLY_IN_PLACE_RIGHT] = 0, +static const bool8 sMovementTypeHasRange[NUM_MOVEMENT_TYPES] = { + [MOVEMENT_TYPE_WANDER_AROUND] = TRUE, + [MOVEMENT_TYPE_WANDER_UP_AND_DOWN] = TRUE, + [MOVEMENT_TYPE_WANDER_DOWN_AND_UP] = TRUE, + [MOVEMENT_TYPE_WANDER_LEFT_AND_RIGHT] = TRUE, + [MOVEMENT_TYPE_WANDER_RIGHT_AND_LEFT] = TRUE, + [MOVEMENT_TYPE_WALK_UP_AND_DOWN] = TRUE, + [MOVEMENT_TYPE_WALK_DOWN_AND_UP] = TRUE, + [MOVEMENT_TYPE_WALK_LEFT_AND_RIGHT] = TRUE, + [MOVEMENT_TYPE_WALK_RIGHT_AND_LEFT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_LEFT_DOWN] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_DOWN_UP] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_RIGHT_LEFT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_UP_RIGHT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_RIGHT_DOWN] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_DOWN_UP] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_UP_LEFT_RIGHT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_UP_LEFT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_DOWN_RIGHT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_RIGHT_LEFT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_LEFT_UP_DOWN] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_LEFT_UP] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_DOWN_LEFT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_UP_DOWN_LEFT_RIGHT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_RIGHT_UP_DOWN] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_RIGHT_UP] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_UP_LEFT_DOWN_RIGHT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_RIGHT_UP_LEFT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_DOWN_RIGHT_UP] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_UP_LEFT_DOWN] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_UP_RIGHT_DOWN_LEFT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_DOWN_LEFT_UP_RIGHT] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_LEFT_UP_RIGHT_DOWN] = TRUE, + [MOVEMENT_TYPE_WALK_SEQUENCE_RIGHT_DOWN_LEFT_UP] = TRUE, + [MOVEMENT_TYPE_COPY_PLAYER] = TRUE, + [MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE] = TRUE, + [MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE] = TRUE, + [MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE] = TRUE, + [MOVEMENT_TYPE_COPY_PLAYER_IN_GRASS] = TRUE, + [MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE_IN_GRASS] = TRUE, + [MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE_IN_GRASS] = TRUE, + [MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE_IN_GRASS] = TRUE, }; const u8 gInitialMovementTypeFacingDirections[] = { @@ -509,7 +478,7 @@ static const struct SpritePalette sObjectEventSpritePalettes[] = { {gObjectEventPal_Lugia, OBJ_EVENT_PAL_TAG_LUGIA}, {gObjectEventPal_RubySapphireBrendan, OBJ_EVENT_PAL_TAG_RS_BRENDAN}, {gObjectEventPal_RubySapphireMay, OBJ_EVENT_PAL_TAG_RS_MAY}, - {NULL, 0x0000}, + {}, }; static const u16 sReflectionPaletteTags_Brendan[] = { @@ -941,12 +910,12 @@ const u8 gRideWaterCurrentMovementActions[] = { MOVEMENT_ACTION_RIDE_WATER_CURRENT_LEFT, MOVEMENT_ACTION_RIDE_WATER_CURRENT_RIGHT, }; -const u8 gWalkFastestMovementActions[] = { - MOVEMENT_ACTION_WALK_FASTEST_DOWN, - MOVEMENT_ACTION_WALK_FASTEST_DOWN, - MOVEMENT_ACTION_WALK_FASTEST_UP, - MOVEMENT_ACTION_WALK_FASTEST_LEFT, - MOVEMENT_ACTION_WALK_FASTEST_RIGHT, +const u8 gWalkFasterMovementActions[] = { + MOVEMENT_ACTION_WALK_FASTER_DOWN, + MOVEMENT_ACTION_WALK_FASTER_DOWN, + MOVEMENT_ACTION_WALK_FASTER_UP, + MOVEMENT_ACTION_WALK_FASTER_LEFT, + MOVEMENT_ACTION_WALK_FASTER_RIGHT, }; const u8 gSlideMovementActions[] = { MOVEMENT_ACTION_SLIDE_DOWN, @@ -1018,12 +987,12 @@ const u8 gWalkInPlaceFastMovementActions[] = { MOVEMENT_ACTION_WALK_IN_PLACE_FAST_LEFT, MOVEMENT_ACTION_WALK_IN_PLACE_FAST_RIGHT, }; -const u8 gWalkInPlaceFastestMovementActions[] = { - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_DOWN, - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_UP, - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_LEFT, - MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT, +const u8 gWalkInPlaceFasterMovementActions[] = { + MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_DOWN, + MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_DOWN, + MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_UP, + MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_LEFT, + MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_RIGHT, }; const u8 gAcroWheelieFaceDirectionMovementActions[] = { MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN, @@ -1107,31 +1076,75 @@ static const u8 sOppositeDirections[] = { DIR_SOUTHWEST, }; -const u8 gUnknown_0850DC2F[][4] = { - {2, 1, 4, 3}, - {1, 2, 3, 4}, - {3, 4, 2, 1}, - {4, 3, 1, 2} +// Takes the player's original and current facing direction to get the direction that should be considered to copy. +// Note that this means an NPC who copies the player's movement changes how they copy them based on how +// the player entered the area. For instance an NPC who does the same movements as the player when they +// entered the area facing South will do the opposite movements as the player if they enter facing North. +static const u8 sPlayerDirectionsForCopy[][4] = { + [DIR_SOUTH - 1] = { + [DIR_SOUTH - 1] = DIR_NORTH, + [DIR_NORTH - 1] = DIR_SOUTH, + [DIR_WEST - 1] = DIR_EAST, + [DIR_EAST - 1] = DIR_WEST + }, + [DIR_NORTH - 1] = { + [DIR_SOUTH - 1] = DIR_SOUTH, + [DIR_NORTH - 1] = DIR_NORTH, + [DIR_WEST - 1] = DIR_WEST, + [DIR_EAST - 1] = DIR_EAST + }, + [DIR_WEST - 1] = { + [DIR_SOUTH - 1] = DIR_WEST, + [DIR_NORTH - 1] = DIR_EAST, + [DIR_WEST - 1] = DIR_NORTH, + [DIR_EAST - 1] = DIR_SOUTH + }, + [DIR_EAST - 1] = { + [DIR_SOUTH - 1] = DIR_EAST, + [DIR_NORTH - 1] = DIR_WEST, + [DIR_WEST - 1] = DIR_SOUTH, + [DIR_EAST - 1] = DIR_NORTH + } }; -const u8 gUnknown_0850DC3F[][4] = { - {2, 1, 4, 3}, - {1, 2, 3, 4}, - {4, 3, 1, 2}, - {3, 4, 2, 1} +// Indexed first with the NPC's initial facing direction based on movement type, and secondly with the player direction to copy. +// Returns the direction the copy NPC should travel in. +static const u8 sPlayerDirectionToCopyDirection[][4] = { + [DIR_SOUTH - 1] = { // MOVEMENT_TYPE_COPY_PLAYER_OPPOSITE(_IN_GRASS) + [DIR_SOUTH - 1] = DIR_NORTH, + [DIR_NORTH - 1] = DIR_SOUTH, + [DIR_WEST - 1] = DIR_EAST, + [DIR_EAST - 1] = DIR_WEST + }, + [DIR_NORTH - 1] = { // MOVEMENT_TYPE_COPY_PLAYER(_IN_GRASS) + [DIR_SOUTH - 1] = DIR_SOUTH, + [DIR_NORTH - 1] = DIR_NORTH, + [DIR_WEST - 1] = DIR_WEST, + [DIR_EAST - 1] = DIR_EAST + }, + [DIR_WEST - 1] = { // MOVEMENT_TYPE_COPY_PLAYER_COUNTERCLOCKWISE(_IN_GRASS) + [DIR_SOUTH - 1] = DIR_EAST, + [DIR_NORTH - 1] = DIR_WEST, + [DIR_WEST - 1] = DIR_SOUTH, + [DIR_EAST - 1] = DIR_NORTH + }, + [DIR_EAST - 1] = { // MOVEMENT_TYPE_COPY_PLAYER_CLOCKWISE(_IN_GRASS) + [DIR_SOUTH - 1] = DIR_WEST, + [DIR_NORTH - 1] = DIR_EAST, + [DIR_WEST - 1] = DIR_NORTH, + [DIR_EAST - 1] = DIR_SOUTH + } }; #include "data/object_events/movement_action_func_tables.h" -// Code - static void ClearObjectEvent(struct ObjectEvent *objectEvent) { *objectEvent = (struct ObjectEvent){}; objectEvent->localId = 0xFF; - objectEvent->mapNum = 0xFF; - objectEvent->mapGroup = 0xFF; - objectEvent->movementActionId = 0xFF; + objectEvent->mapNum = MAP_NUM(UNDEFINED); + objectEvent->mapGroup = MAP_GROUP(UNDEFINED); + objectEvent->movementActionId = MOVEMENT_ACTION_NONE; } static void ClearAllObjectEvents(void) @@ -1180,9 +1193,8 @@ u8 GetFirstInactiveObjectEventId(void) u8 GetObjectEventIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroupId) { if (localId < OBJ_EVENT_ID_PLAYER) - { return GetObjectEventIdByLocalIdAndMapInternal(localId, mapNum, mapGroupId); - } + return GetObjectEventIdByLocalId(localId); } @@ -1267,16 +1279,12 @@ static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template, objectEvent->previousMovementDirection = gInitialMovementTypeFacingDirections[template->movementType]; SetObjectEventDirection(objectEvent, objectEvent->previousMovementDirection); SetObjectEventDynamicGraphicsId(objectEvent); - if (gRangedMovementTypes[objectEvent->movementType]) + if (sMovementTypeHasRange[objectEvent->movementType]) { if (objectEvent->rangeX == 0) - { objectEvent->rangeX++; - } if (objectEvent->rangeY == 0) - { objectEvent->rangeY++; - } } return objectEventId; } @@ -1290,24 +1298,17 @@ u8 Unref_TryInitLocalObjectEvent(u8 localId) if (gMapHeader.events != NULL) { if (InBattlePyramid()) - { objectEventCount = GetNumBattlePyramidObjectEvents(); - } else if (InTrainerHill()) - { objectEventCount = 2; - } else - { objectEventCount = gMapHeader.events->objectEventCount; - } + for (i = 0; i < objectEventCount; i++) { template = &gSaveBlock1Ptr->objectEventTemplates[i]; if (template->localId == localId && !FlagGet(template->flagId)) - { return InitObjectEventStateFromTemplate(template, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup); - } } } return OBJECT_EVENTS_COUNT; @@ -1532,9 +1533,8 @@ u8 AddPseudoObjectEvent(u16 graphicsId, void (*callback)(struct Sprite *), s16 x spriteTemplate = malloc(sizeof(struct SpriteTemplate)); MakeObjectTemplateFromObjectEventGraphicsInfo(graphicsId, callback, spriteTemplate, &subspriteTables); if (spriteTemplate->paletteTag != TAG_NONE) - { LoadObjectEventPalette(spriteTemplate->paletteTag); - } + spriteId = CreateSprite(spriteTemplate, x, y, subpriority); free(spriteTemplate); @@ -1572,20 +1572,16 @@ u8 CreateObjectSprite(u8 graphicsId, u8 objectEventId, s16 x, s16 y, u8 z, u8 di sprite->y += sprite->centerToCornerVecY; sprite->oam.paletteNum = graphicsInfo->paletteSlot; if (sprite->oam.paletteNum >= 16) - { sprite->oam.paletteNum -= 16; - } + sprite->coordOffsetEnabled = TRUE; sprite->sObjEventId = objectEventId; sprite->data[1] = z; if (graphicsInfo->paletteSlot == 10) - { LoadSpecialObjectReflectionPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot); - } else if (graphicsInfo->paletteSlot >= 16) - { _PatchObjectPalette(graphicsInfo->paletteTag, graphicsInfo->paletteSlot | 0xf0); - } + if (subspriteTables != NULL) { SetSubspriteTables(sprite, subspriteTables); @@ -1809,9 +1805,7 @@ void ObjectEventSetGraphicsId(struct ObjectEvent *objectEvent, u8 graphicsId) sprite->x += 8; sprite->y += 16 + sprite->centerToCornerVecY; if (objectEvent->trackedByCamera) - { CameraObjectReset1(); - } } void ObjectEventSetGraphicsIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 graphicsId) @@ -1819,9 +1813,7 @@ void ObjectEventSetGraphicsIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 objectEventId; if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)) - { ObjectEventSetGraphicsId(&gObjectEvents[objectEventId], graphicsId); - } } void ObjectEventTurn(struct ObjectEvent *objectEvent, u8 direction) @@ -1839,9 +1831,7 @@ void ObjectEventTurnByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup, u8 direc u8 objectEventId; if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)) - { ObjectEventTurn(&gObjectEvents[objectEventId], direction); - } } void PlayerObjectTurn(struct PlayerAvatar *playerAvatar, u8 direction) @@ -1878,9 +1868,8 @@ const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u8 graphicsId) u8 bard; if (graphicsId >= OBJ_EVENT_GFX_VARS) - { graphicsId = VarGetObjectEventGraphicsId(graphicsId - OBJ_EVENT_GFX_VARS); - } + if (graphicsId == OBJ_EVENT_GFX_BARD) { bard = GetCurrentMauvilleOldMan(); @@ -1888,9 +1877,7 @@ const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u8 graphicsId) } if (graphicsId >= NUM_OBJ_EVENT_GFX) - { graphicsId = OBJ_EVENT_GFX_NINJA_BOY; - } return gObjectEventGraphicsInfoPointers[graphicsId]; } @@ -1898,9 +1885,7 @@ const struct ObjectEventGraphicsInfo *GetObjectEventGraphicsInfo(u8 graphicsId) static void SetObjectEventDynamicGraphicsId(struct ObjectEvent *objectEvent) { if (objectEvent->graphicsId >= OBJ_EVENT_GFX_VARS) - { objectEvent->graphicsId = VarGetObjectEventGraphicsId(objectEvent->graphicsId - OBJ_EVENT_GFX_VARS); - } } void SetObjectInvisibility(u8 localId, u8 mapNum, u8 mapGroup, bool8 invisible) @@ -1908,9 +1893,7 @@ void SetObjectInvisibility(u8 localId, u8 mapNum, u8 mapGroup, bool8 invisible) u8 objectEventId; if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)) - { gObjectEvents[objectEventId].invisible = invisible; - } } void ObjectEventGetLocalIdAndMap(struct ObjectEvent *objectEvent, void *localId, void *mapNum, void *mapGroup) @@ -2029,9 +2012,7 @@ static u8 FindObjectEventPaletteIndexByTag(u16 tag) for (i = 0; sObjectEventSpritePalettes[i].tag != OBJ_EVENT_PAL_TAG_NONE; i++) { if (sObjectEventSpritePalettes[i].tag == tag) - { return i; - } } return 0xFF; } @@ -2165,9 +2146,7 @@ u8 GetObjectEventIdByXYZ(u16 x, u16 y, u8 z) if (gObjectEvents[i].active) { if (gObjectEvents[i].currentCoords.x == x && gObjectEvents[i].currentCoords.y == y && ObjectEventDoesZCoordMatch(&gObjectEvents[i], z)) - { return i; - } } } return OBJECT_EVENTS_COUNT; @@ -2176,9 +2155,8 @@ u8 GetObjectEventIdByXYZ(u16 x, u16 y, u8 z) static bool8 ObjectEventDoesZCoordMatch(struct ObjectEvent *objectEvent, u8 z) { if (objectEvent->currentElevation != 0 && z != 0 && objectEvent->currentElevation != z) - { return FALSE; - } + return TRUE; } @@ -2280,9 +2258,8 @@ static u8 CameraObjectGetFollowedSpriteId(void) camera = FindCameraSprite(); if (camera == NULL) - { return MAX_SPRITES; - } + return camera->sLinkedSpriteId; } @@ -2290,13 +2267,9 @@ void CameraObjectReset2(void) { // UB: Possible null dereference #ifdef UBFIX - struct Sprite *camera; - - camera = FindCameraSprite(); - if (camera != NULL) - { + struct Sprite *camera = FindCameraSprite(); + if (camera) camera->sState = 2; - } #else FindCameraSprite()->sState = 2; #endif // UBFIX @@ -2382,9 +2355,8 @@ static u8 GetObjectTrainerTypeByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup u8 objectEventId; if (TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)) - { return 0xFF; - } + return gObjectEvents[objectEventId].trainerType; } @@ -2400,9 +2372,8 @@ u8 GetObjectEventBerryTreeIdByLocalIdAndMap(u8 localId, u8 mapNum, u8 mapGroup) u8 objectEventId; if (TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)) - { return 0xFF; - } + return gObjectEvents[objectEventId].trainerRange_berryTreeId; } @@ -2438,9 +2409,7 @@ static struct ObjectEventTemplate *FindObjectEventTemplateByLocalId(u8 localId, for (i = 0; i < count; i++) { if (templates[i].localId == localId) - { return &templates[i]; - } } return NULL; } @@ -2449,16 +2418,14 @@ struct ObjectEventTemplate *GetBaseTemplateForObjectEvent(const struct ObjectEve { int i; - if (objectEvent->mapNum != gSaveBlock1Ptr->location.mapNum || objectEvent->mapGroup != gSaveBlock1Ptr->location.mapGroup) - { + if (objectEvent->mapNum != gSaveBlock1Ptr->location.mapNum + || objectEvent->mapGroup != gSaveBlock1Ptr->location.mapGroup) return NULL; - } + for (i = 0; i < OBJECT_EVENT_TEMPLATES_COUNT; i++) { if (objectEvent->localId == gSaveBlock1Ptr->objectEventTemplates[i].localId) - { return &gSaveBlock1Ptr->objectEventTemplates[i]; - } } return NULL; } @@ -2490,9 +2457,7 @@ void TryOverrideTemplateCoordsForObjectEvent(const struct ObjectEvent *objectEve objectEventTemplate = GetBaseTemplateForObjectEvent(objectEvent); if (objectEventTemplate != NULL) - { objectEventTemplate->movementType = movementType; - } } void TryOverrideObjectEventTemplateCoords(u8 localId, u8 mapNum, u8 mapGroup) @@ -2540,15 +2505,12 @@ u16 GetObjectPaletteTag(u8 palSlot) u8 i; if (palSlot < 10) - { return sObjectPaletteTagSets[sCurrentReflectionType][palSlot]; - } + for (i = 0; sSpecialObjectReflectionPaletteSets[i].tag != OBJ_EVENT_PAL_TAG_NONE; i++) { if (sSpecialObjectReflectionPaletteSets[i].tag == sCurrentSpecialObjectPaletteTag) - { return sSpecialObjectReflectionPaletteSets[i].data[sCurrentReflectionType]; - } } return OBJ_EVENT_PAL_TAG_NONE; } @@ -2573,9 +2535,7 @@ bool8 MovementType_WanderAround_Step1(struct ObjectEvent *objectEvent, struct Sp bool8 MovementType_WanderAround_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (!ObjectEventExecSingleMovementAction(objectEvent, sprite)) - { return FALSE; - } SetMovementDelay(sprite, sMovementDelaysMedium[Random() & 3]); sprite->sTypeFuncId = 3; return TRUE; @@ -2636,13 +2596,11 @@ bool8 ObjectEventIsTrainerAndCloseToPlayer(struct ObjectEvent *objectEvent) s16 maxY; if (!TestPlayerAvatarFlags(PLAYER_AVATAR_FLAG_DASH)) - { return FALSE; - } + if (objectEvent->trainerType != TRAINER_TYPE_NORMAL && objectEvent->trainerType != TRAINER_TYPE_BURIED) - { return FALSE; - } + PlayerGetDestCoords(&playerX, &playerY); objX = objectEvent->currentCoords.x; objY = objectEvent->currentCoords.y; @@ -2650,10 +2608,10 @@ bool8 ObjectEventIsTrainerAndCloseToPlayer(struct ObjectEvent *objectEvent) minY = objY - objectEvent->trainerRange_berryTreeId; maxX = objX + objectEvent->trainerRange_berryTreeId; maxY = objY + objectEvent->trainerRange_berryTreeId; - if (minX > playerX || maxX < playerX || minY > playerY || maxY < playerY) - { + if (minX > playerX || maxX < playerX + || minY > playerY || maxY < playerY) return FALSE; - } + return TRUE; } @@ -3221,10 +3179,8 @@ bool8 MovementType_FaceDownAndUp_Step4(struct ObjectEvent *objectEvent, struct S u8 directions[2]; memcpy(directions, gUpAndDownDirections, sizeof gUpAndDownDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_SOUTH); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 1]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3273,10 +3229,8 @@ bool8 MovementType_FaceLeftAndRight_Step4(struct ObjectEvent *objectEvent, struc u8 directions[2]; memcpy(directions, gLeftAndRightDirections, sizeof gLeftAndRightDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_EAST_WEST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 1]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3325,10 +3279,8 @@ bool8 MovementType_FaceUpAndLeft_Step4(struct ObjectEvent *objectEvent, struct S u8 directions[2]; memcpy(directions, gUpAndLeftDirections, sizeof gUpAndLeftDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_WEST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 1]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3377,10 +3329,8 @@ bool8 MovementType_FaceUpAndRight_Step4(struct ObjectEvent *objectEvent, struct u8 directions[2]; memcpy(directions, gUpAndRightDirections, sizeof gUpAndRightDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_EAST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 1]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3429,10 +3379,8 @@ bool8 MovementType_FaceDownAndLeft_Step4(struct ObjectEvent *objectEvent, struct u8 directions[2]; memcpy(directions, gDownAndLeftDirections, sizeof gDownAndLeftDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_SOUTH_WEST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 1]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3481,10 +3429,8 @@ bool8 MovementType_FaceDownAndRight_Step4(struct ObjectEvent *objectEvent, struc u8 directions[2]; memcpy(directions, gDownAndRightDirections, sizeof gDownAndRightDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_SOUTH_EAST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 1]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3533,10 +3479,8 @@ bool8 MovementType_FaceDownUpAndLeft_Step4(struct ObjectEvent *objectEvent, stru u8 directions[4]; memcpy(directions, gDownUpAndLeftDirections, sizeof gDownUpAndLeftDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_SOUTH_WEST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 3]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3585,10 +3529,8 @@ bool8 MovementType_FaceDownUpAndRight_Step4(struct ObjectEvent *objectEvent, str u8 directions[4]; memcpy(directions, gDownUpAndRightDirections, sizeof gDownUpAndRightDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_SOUTH_EAST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 3]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3637,10 +3579,8 @@ bool8 MovementType_FaceUpLeftAndRight_Step4(struct ObjectEvent *objectEvent, str u8 directions[4]; memcpy(directions, gUpLeftAndRightDirections, sizeof gUpLeftAndRightDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_NORTH_EAST_WEST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 3]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3689,10 +3629,8 @@ bool8 MovementType_FaceDownLeftAndRight_Step4(struct ObjectEvent *objectEvent, s u8 directions[4]; memcpy(directions, gDownLeftAndRightDirections, sizeof gDownLeftAndRightDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_SOUTH_EAST_WEST); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[Random() & 3]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 1; return TRUE; @@ -3721,9 +3659,7 @@ bool8 MovementType_RotateCounterclockwise_Step1(struct ObjectEvent *objectEvent, bool8 MovementType_RotateCounterclockwise_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) - { sprite->sTypeFuncId = 3; - } return FALSE; } @@ -3733,10 +3669,8 @@ bool8 MovementType_RotateCounterclockwise_Step3(struct ObjectEvent *objectEvent, u8 directions[5]; memcpy(directions, gCounterclockwiseDirections, sizeof gCounterclockwiseDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_ANY); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[objectEvent->facingDirection]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 0; return TRUE; @@ -3765,9 +3699,7 @@ bool8 MovementType_RotateClockwise_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementType_RotateClockwise_Step2(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (WaitForMovementDelay(sprite) || ObjectEventIsTrainerAndCloseToPlayer(objectEvent)) - { sprite->sTypeFuncId = 3; - } return FALSE; } @@ -3777,10 +3709,8 @@ bool8 MovementType_RotateClockwise_Step3(struct ObjectEvent *objectEvent, struct u8 directions[5]; memcpy(directions, gClockwiseDirections, sizeof gClockwiseDirections); direction = TryGetTrainerEncounterDirection(objectEvent, RUNFOLLOW_ANY); - if (direction == 0) - { + if (direction == DIR_NONE) direction = directions[objectEvent->facingDirection]; - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 0; return TRUE; @@ -3801,9 +3731,7 @@ bool8 MovementType_WalkBackAndForth_Step1(struct ObjectEvent *objectEvent, struc direction = gInitialMovementTypeFacingDirections[objectEvent->movementType]; if (objectEvent->directionSequenceIndex) - { direction = GetOppositeDirection(direction); - } SetObjectEventDirection(objectEvent, direction); sprite->sTypeFuncId = 2; return TRUE; @@ -3900,9 +3828,8 @@ u8 MovementType_WalkSequenceUpRightLeftDown_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gUpRightLeftDownDirections)]; memcpy(directions, gUpRightLeftDownDirections, sizeof(gUpRightLeftDownDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -3913,9 +3840,8 @@ u8 MovementType_WalkSequenceRightLeftDownUp_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gRightLeftDownUpDirections)]; memcpy(directions, gRightLeftDownUpDirections, sizeof(gRightLeftDownUpDirections)); if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 2; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -3926,9 +3852,8 @@ u8 MovementType_WalkSequenceDownUpRightLeft_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gDownUpRightLeftDirections)]; memcpy(directions, gDownUpRightLeftDirections, sizeof(gDownUpRightLeftDirections)); if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 2; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -3939,9 +3864,8 @@ u8 MovementType_WalkSequenceLeftDownUpRight_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gLeftDownUpRightDirections)]; memcpy(directions, gLeftDownUpRightDirections, sizeof(gLeftDownUpRightDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -3952,9 +3876,8 @@ u8 MovementType_WalkSequenceUpLeftRightDown_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gUpLeftRightDownDirections)]; memcpy(directions, gUpLeftRightDownDirections, sizeof(gUpLeftRightDownDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -3965,9 +3888,8 @@ u8 MovementType_WalkSequenceLeftRightDownUp_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gLeftRightDownUpDirections)]; memcpy(directions, gLeftRightDownUpDirections, sizeof(gLeftRightDownUpDirections)); if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 2; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -3978,9 +3900,8 @@ u8 MovementType_WalkSequenceDownUpLeftRight_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gStandardDirections)]; memcpy(directions, gStandardDirections, sizeof(gStandardDirections)); if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 2; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -3991,9 +3912,8 @@ u8 MovementType_WalkSequenceRightDownUpLeft_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gRightDownUpLeftDirections)]; memcpy(directions, gRightDownUpLeftDirections, sizeof(gRightDownUpLeftDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4004,9 +3924,8 @@ u8 MovementType_WalkSequenceLeftUpDownRight_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gLeftUpDownRightDirections)]; memcpy(directions, gLeftUpDownRightDirections, sizeof(gLeftUpDownRightDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4017,9 +3936,8 @@ u8 MovementType_WalkSequenceUpDownRightLeft_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gUpDownRightLeftDirections)]; memcpy(directions, gUpDownRightLeftDirections, sizeof(gUpDownRightLeftDirections)); if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 2; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4030,9 +3948,8 @@ u8 MovementType_WalkSequenceRightLeftUpDown_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gRightLeftUpDownDirections)]; memcpy(directions, gRightLeftUpDownDirections, sizeof(gRightLeftUpDownDirections)); if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 2; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4043,9 +3960,8 @@ u8 MovementType_WalkSequenceDownRightLeftUp_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gDownRightLeftUpDirections)]; memcpy(directions, gDownRightLeftUpDirections, sizeof(gDownRightLeftUpDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4056,9 +3972,8 @@ u8 MovementType_WalkSequenceRightUpDownLeft_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gRightUpDownLeftDirections)]; memcpy(directions, gRightUpDownLeftDirections, sizeof(gRightUpDownLeftDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4069,9 +3984,8 @@ u8 MovementType_WalkSequenceUpDownLeftRight_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gUpDownLeftRightDirections)]; memcpy(directions, gUpDownLeftRightDirections, sizeof(gUpDownLeftRightDirections)); if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 2; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4082,9 +3996,8 @@ u8 MovementType_WalkSequenceLeftRightUpDown_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gLeftRightUpDownDirections)]; memcpy(directions, gLeftRightUpDownDirections, sizeof(gLeftRightUpDownDirections)); if (objectEvent->directionSequenceIndex == 1 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 2; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4095,9 +4008,8 @@ u8 MovementType_WalkSequenceDownLeftRightUp_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gDownLeftRightUpDirections)]; memcpy(directions, gDownLeftRightUpDirections, sizeof(gDownLeftRightUpDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4108,9 +4020,8 @@ u8 MovementType_WalkSequenceUpLeftDownRight_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gUpLeftDownRightDirections)]; memcpy(directions, gUpLeftDownRightDirections, sizeof(gUpLeftDownRightDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4121,9 +4032,8 @@ u8 MovementType_WalkSequenceDownRightUpLeft_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gDownRightUpLeftDirections)]; memcpy(directions, gDownRightUpLeftDirections, sizeof(gDownRightUpLeftDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4134,9 +4044,8 @@ u8 MovementType_WalkSequenceLeftDownRightUp_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gLeftDownRightUpDirections)]; memcpy(directions, gLeftDownRightUpDirections, sizeof(gLeftDownRightUpDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4147,9 +4056,8 @@ u8 MovementType_WalkSequenceRightUpLeftDown_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gRightUpLeftDownDirections)]; memcpy(directions, gRightUpLeftDownDirections, sizeof(gRightUpLeftDownDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4160,9 +4068,8 @@ u8 MovementType_WalkSequenceUpRightDownLeft_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gUpRightDownLeftDirections)]; memcpy(directions, gUpRightDownLeftDirections, sizeof(gUpRightDownLeftDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4173,9 +4080,8 @@ u8 MovementType_WalkSequenceDownLeftUpRight_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gDownLeftUpRightDirections)]; memcpy(directions, gDownLeftUpRightDirections, sizeof(gDownLeftUpRightDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.y == objectEvent->currentCoords.y) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4186,9 +4092,8 @@ u8 MovementType_WalkSequenceLeftUpRightDown_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gLeftUpRightDownDirections)]; memcpy(directions, gLeftUpRightDownDirections, sizeof(gLeftUpRightDownDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4199,9 +4104,8 @@ u8 MovementType_WalkSequenceRightDownLeftUp_Step1(struct ObjectEvent *objectEven u8 directions[sizeof(gRightDownLeftUpDirections)]; memcpy(directions, gRightDownLeftUpDirections, sizeof(gRightDownLeftUpDirections)); if (objectEvent->directionSequenceIndex == 2 && objectEvent->initialCoords.x == objectEvent->currentCoords.x) - { objectEvent->directionSequenceIndex = 3; - } + return MoveNextDirectionInSequence(objectEvent, sprite, directions); } @@ -4211,19 +4115,16 @@ bool8 MovementType_CopyPlayer_Step0(struct ObjectEvent *objectEvent, struct Spri { ClearObjectEventMovement(objectEvent, sprite); if (objectEvent->directionSequenceIndex == 0) - { objectEvent->directionSequenceIndex = GetPlayerFacingDirection(); - } sprite->sTypeFuncId = 1; return TRUE; } bool8 MovementType_CopyPlayer_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - if (gObjectEvents[gPlayerAvatar.objectEventId].movementActionId == 0xFF || gPlayerAvatar.tileTransitionState == T_TILE_CENTER) - { + if (gObjectEvents[gPlayerAvatar.objectEventId].movementActionId == MOVEMENT_ACTION_NONE || gPlayerAvatar.tileTransitionState == T_TILE_CENTER) return FALSE; - } + return gCopyPlayerMovementFuncs[PlayerGetCopyableMovement()](objectEvent, sprite, GetPlayerMovementDirection(), NULL); } @@ -4244,13 +4145,13 @@ bool8 CopyablePlayerMovement_None(struct ObjectEvent *objectEvent, struct Sprite bool8 CopyablePlayerMovement_FaceDirection(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) { - ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection))); + ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, playerDirection))); objectEvent->singleMovementActive = TRUE; sprite->sTypeFuncId = 2; return TRUE; } -bool8 CopyablePlayerMovement_GoSpeed0(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) +bool8 CopyablePlayerMovement_WalkNormal(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) { u32 direction; s16 x; @@ -4263,7 +4164,7 @@ bool8 CopyablePlayerMovement_GoSpeed0(struct ObjectEvent *objectEvent, struct Sp if (direction == DIR_NONE) { direction = playerDirection; - direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); + direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); ObjectEventMoveDestCoords(objectEvent, direction, &x, &y); ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); objectEvent->singleMovementActive = TRUE; @@ -4273,52 +4174,52 @@ bool8 CopyablePlayerMovement_GoSpeed0(struct ObjectEvent *objectEvent, struct Sp } else { - direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); + direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); } ObjectEventMoveDestCoords(objectEvent, direction, &x, &y); ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkNormalMovementAction(direction)); + if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y)))) - { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); - } + objectEvent->singleMovementActive = TRUE; sprite->sTypeFuncId = 2; return TRUE; } -bool8 CopyablePlayerMovement_GoSpeed1(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) +bool8 CopyablePlayerMovement_WalkFast(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) { u32 direction; s16 x; s16 y; direction = playerDirection; - direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); + direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); ObjectEventMoveDestCoords(objectEvent, direction, &x, &y); ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastMovementAction(direction)); + if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y)))) - { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); - } + objectEvent->singleMovementActive = TRUE; sprite->sTypeFuncId = 2; return TRUE; } -bool8 CopyablePlayerMovement_GoSpeed2(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) +bool8 CopyablePlayerMovement_WalkFaster(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) { u32 direction; s16 x; s16 y; direction = playerDirection; - direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); + direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); ObjectEventMoveDestCoords(objectEvent, direction, &x, &y); - ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFastestMovementAction(direction)); + ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkFasterMovementAction(direction)); + if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y)))) - { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); - } + objectEvent->singleMovementActive = TRUE; sprite->sTypeFuncId = 2; return TRUE; @@ -4331,65 +4232,65 @@ bool8 CopyablePlayerMovement_Slide(struct ObjectEvent *objectEvent, struct Sprit s16 y; direction = playerDirection; - direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); + direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); ObjectEventMoveDestCoords(objectEvent, direction, &x, &y); ObjectEventSetSingleMovement(objectEvent, sprite, GetSlideMovementAction(direction)); + if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y)))) - { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); - } + objectEvent->singleMovementActive = TRUE; sprite->sTypeFuncId = 2; return TRUE; } -bool8 cph_IM_DIFFERENT(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) +bool8 CopyablePlayerMovement_JumpInPlace(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) { u32 direction; direction = playerDirection; - direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); + direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpInPlaceMovementAction(direction)); objectEvent->singleMovementActive = TRUE; sprite->sTypeFuncId = 2; return TRUE; } -bool8 CopyablePlayerMovement_GoSpeed4(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) +bool8 CopyablePlayerMovement_Jump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) { u32 direction; s16 x; s16 y; direction = playerDirection; - direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); + direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); ObjectEventMoveDestCoords(objectEvent, direction, &x, &y); ObjectEventSetSingleMovement(objectEvent, sprite, GetJumpMovementAction(direction)); + if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y)))) - { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); - } + objectEvent->singleMovementActive = TRUE; sprite->sTypeFuncId = 2; return TRUE; } -bool8 CopyablePlayerMovement_Jump(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) +bool8 CopyablePlayerMovement_Jump2(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 playerDirection, bool8 tileCallback(u8)) { u32 direction; s16 x; s16 y; direction = playerDirection; - direction = state_to_direction(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); + direction = GetCopyDirection(gInitialMovementTypeFacingDirections[objectEvent->movementType], objectEvent->directionSequenceIndex, direction); x = objectEvent->currentCoords.x; y = objectEvent->currentCoords.y; MoveCoordsInDirection(direction, &x, &y, 2, 2); ObjectEventSetSingleMovement(objectEvent, sprite, GetJump2MovementAction(direction)); + if (GetCollisionAtCoords(objectEvent, x, y, direction) || (tileCallback != NULL && !tileCallback(MapGridGetMetatileBehaviorAt(x, y)))) - { ObjectEventSetSingleMovement(objectEvent, sprite, GetFaceDirectionMovementAction(direction)); - } + objectEvent->singleMovementActive = TRUE; sprite->sTypeFuncId = 2; return TRUE; @@ -4467,9 +4368,7 @@ bool8 MovementType_Buried_Step0(struct ObjectEvent *objectEvent, struct Sprite * bool8 MovementType_MoveInPlace_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (ObjectEventExecSingleMovementAction(objectEvent, sprite)) - { sprite->sTypeFuncId = 0; - } return FALSE; } @@ -4508,7 +4407,7 @@ movement_type_def(MovementType_RunInPlace, gMovementTypeFuncs_RunInPlace) bool8 MovementType_RunInPlace_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { ClearObjectEventMovement(objectEvent, sprite); - ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceFastestMovementAction(objectEvent->facingDirection)); + ObjectEventSetSingleMovement(objectEvent, sprite, GetWalkInPlaceFasterMovementAction(objectEvent->facingDirection)); sprite->sTypeFuncId = 1; return TRUE; } @@ -4544,7 +4443,7 @@ static void ClearObjectEventMovement(struct ObjectEvent *objectEvent, struct Spr objectEvent->singleMovementActive = FALSE; objectEvent->heldMovementActive = FALSE; objectEvent->heldMovementFinished = FALSE; - objectEvent->movementActionId = 0xFF; + objectEvent->movementActionId = MOVEMENT_ACTION_NONE; sprite->sTypeFuncId = 0; } @@ -4772,9 +4671,8 @@ static bool8 IsMetatileDirectionallyImpassable(struct ObjectEvent *objectEvent, { if (gOppositeDirectionBlockedMetatileFuncs[direction - 1](objectEvent->currentMetatileBehavior) || gDirectionBlockedMetatileFuncs[direction - 1](MapGridGetMetatileBehaviorAt(x, y))) - { return TRUE; - } + return FALSE; } @@ -4791,9 +4689,7 @@ static bool8 DoesObjectCollideWithObjectAt(struct ObjectEvent *objectEvent, s16 if ((curObject->currentCoords.x == x && curObject->currentCoords.y == y) || (curObject->previousCoords.x == x && curObject->previousCoords.y == y)) { if (AreZCoordsCompatible(objectEvent->currentElevation, curObject->currentElevation)) - { return TRUE; - } } } } @@ -4806,9 +4702,7 @@ bool8 IsBerryTreeSparkling(u8 localId, u8 mapNum, u8 mapGroup) if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId) && gSprites[gObjectEvents[objectEventId].spriteId].sBerryTreeFlags & BERRY_FLAG_SPARKLING) - { return TRUE; - } return FALSE; } @@ -4818,9 +4712,7 @@ void SetBerryTreeJustPicked(u8 localId, u8 mapNum, u8 mapGroup) u8 objectEventId; if (!TryGetObjectEventIdByLocalIdAndMap(localId, mapNum, mapGroup, &objectEventId)) - { gSprites[gObjectEvents[objectEventId].spriteId].sBerryTreeFlags |= BERRY_FLAG_JUST_PICKED; - } } #undef sTimer @@ -4925,7 +4817,7 @@ bool8 ObjectEventIsMovementOverridden(struct ObjectEvent *objectEvent) bool8 ObjectEventIsHeldMovementActive(struct ObjectEvent *objectEvent) { - if (objectEvent->heldMovementActive && objectEvent->movementActionId != 0xFF) + if (objectEvent->heldMovementActive && objectEvent->movementActionId != MOVEMENT_ACTION_NONE) return TRUE; return FALSE; @@ -4958,7 +4850,7 @@ void ObjectEventClearHeldMovementIfActive(struct ObjectEvent *objectEvent) void ObjectEventClearHeldMovement(struct ObjectEvent *objectEvent) { - objectEvent->movementActionId = 0xFF; + objectEvent->movementActionId = MOVEMENT_ACTION_NONE; objectEvent->heldMovementActive = FALSE; objectEvent->heldMovementFinished = FALSE; gSprites[objectEvent->spriteId].sTypeFuncId = 0; @@ -4994,14 +4886,12 @@ void UpdateObjectEventCurrentMovement(struct ObjectEvent *objectEvent, struct Sp { DoGroundEffects_OnSpawn(objectEvent, sprite); TryEnableObjectEventAnim(objectEvent, sprite); + if (ObjectEventIsHeldMovementActive(objectEvent)) - { ObjectEventExecHeldMovementAction(objectEvent, sprite); - } else if (!objectEvent->frozen) - { while (callback(objectEvent, sprite)); - } + DoGroundEffects_OnBeginStep(objectEvent, sprite); DoGroundEffects_OnFinishStep(objectEvent, sprite); UpdateObjectEventSpriteAnimPause(objectEvent, sprite); @@ -5025,7 +4915,7 @@ dirn_to_anim(GetWalkSlowMovementAction, gWalkSlowMovementActions); dirn_to_anim(GetWalkNormalMovementAction, gWalkNormalMovementActions); dirn_to_anim(GetWalkFastMovementAction, gWalkFastMovementActions); dirn_to_anim(GetRideWaterCurrentMovementAction, gRideWaterCurrentMovementActions); -dirn_to_anim(GetWalkFastestMovementAction, gWalkFastestMovementActions); +dirn_to_anim(GetWalkFasterMovementAction, gWalkFasterMovementActions); dirn_to_anim(GetSlideMovementAction, gSlideMovementActions); dirn_to_anim(GetPlayerRunMovementAction, gPlayerRunMovementActions); dirn_to_anim(GetJump2MovementAction, gJump2MovementActions); @@ -5036,7 +4926,7 @@ dirn_to_anim(GetJumpSpecialMovementAction, gJumpSpecialMovementActions); dirn_to_anim(GetWalkInPlaceSlowMovementAction, gWalkInPlaceSlowMovementActions); dirn_to_anim(GetWalkInPlaceNormalMovementAction, gWalkInPlaceNormalMovementActions); dirn_to_anim(GetWalkInPlaceFastMovementAction, gWalkInPlaceFastMovementActions); -dirn_to_anim(GetWalkInPlaceFastestMovementAction, gWalkInPlaceFastestMovementActions); +dirn_to_anim(GetWalkInPlaceFasterMovementAction, gWalkInPlaceFasterMovementActions); bool8 ObjectEventFaceOppositeDirection(struct ObjectEvent *objectEvent, u8 direction) { @@ -5060,46 +4950,45 @@ u8 GetOppositeDirection(u8 direction) memcpy(directions, sOppositeDirections, sizeof sOppositeDirections); if (direction <= DIR_NONE || direction > (sizeof sOppositeDirections)) - { return direction; - } + return directions[direction - 1]; } -static u32 zffu_offset_calc(u8 a0, u8 a1) +// Takes the player's original and current direction and gives a direction the copy NPC should consider as the player's direction. +// See comments at the table's definition. +static u32 GetPlayerDirectionForCopy(u8 initDir, u8 moveDir) { - return gUnknown_0850DC2F[a0 - 1][a1 - 1]; + return sPlayerDirectionsForCopy[initDir - 1][moveDir - 1]; } -static u32 state_to_direction(u8 a0, u32 a1, u32 a2) +// copyInitDir is the initial facing direction of the copying NPC. +// playerInitDir is the direction the player was facing when the copying NPC was spawned, as set by MovementType_CopyPlayer_Step0. +// playerMoveDir is the direction the player is currently moving. +static u32 GetCopyDirection(u8 copyInitDir, u32 playerInitDir, u32 playerMoveDir) { - u32 zffuOffset; - u8 a1_2; - u8 a2_2; + u32 dir; + u8 _playerInitDir = playerInitDir; + u8 _playerMoveDir = playerMoveDir; + if (_playerInitDir == DIR_NONE || _playerMoveDir == DIR_NONE + || _playerInitDir > DIR_EAST || _playerMoveDir > DIR_EAST) + return DIR_NONE; - a1_2 = a1; - a2_2 = a2; - if (a1_2 == 0 || a2_2 == 0 || a1_2 > DIR_EAST || a2_2 > DIR_EAST) - { - return 0; - } - zffuOffset = zffu_offset_calc(a1_2, a2); - return gUnknown_0850DC3F[a0 - 1][zffuOffset - 1]; + dir = GetPlayerDirectionForCopy(_playerInitDir, playerMoveDir); + return sPlayerDirectionToCopyDirection[copyInitDir - 1][dir - 1]; } static void ObjectEventExecHeldMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (gMovementActionFuncs[objectEvent->movementActionId][sprite->sActionFuncId](objectEvent, sprite)) - { objectEvent->heldMovementFinished = TRUE; - } } static bool8 ObjectEventExecSingleMovementAction(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (gMovementActionFuncs[objectEvent->movementActionId][sprite->sActionFuncId](objectEvent, sprite)) { - objectEvent->movementActionId = 0xFF; + objectEvent->movementActionId = MOVEMENT_ACTION_NONE; sprite->sActionFuncId = 0; return TRUE; } @@ -5176,7 +5065,7 @@ static void InitMovementNormal(struct ObjectEvent *objectEvent, struct Sprite *s static void StartRunningAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite, u8 direction) { - InitNpcForMovement(objectEvent, sprite, direction, 1); + InitNpcForMovement(objectEvent, sprite, direction, MOVE_SPEED_FAST_1); SetStepAnimHandleAlternation(objectEvent, sprite, GetRunningDirectionAnimNum(objectEvent->facingDirection)); } @@ -5356,7 +5245,7 @@ bool8 MovementAction_WalkSlowRight_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkNormalDiagonalUpLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_NORTHWEST, 0); + InitMovementNormal(objectEvent, sprite, DIR_NORTHWEST, MOVE_SPEED_NORMAL); return MovementAction_WalkNormalDiagonalUpLeft_Step1(objectEvent, sprite); } @@ -5372,7 +5261,7 @@ bool8 MovementAction_WalkNormalDiagonalUpLeft_Step1(struct ObjectEvent *objectEv bool8 MovementAction_WalkNormalDiagonalUpRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_NORTHEAST, 0); + InitMovementNormal(objectEvent, sprite, DIR_NORTHEAST, MOVE_SPEED_NORMAL); return MovementAction_WalkNormalDiagonalUpRight_Step1(objectEvent, sprite); } @@ -5388,7 +5277,7 @@ bool8 MovementAction_WalkNormalDiagonalUpRight_Step1(struct ObjectEvent *objectE bool8 MovementAction_WalkNormalDiagonalDownLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_SOUTHWEST, 0); + InitMovementNormal(objectEvent, sprite, DIR_SOUTHWEST, MOVE_SPEED_NORMAL); return MovementAction_WalkNormalDiagonalDownLeft_Step1(objectEvent, sprite); } @@ -5404,7 +5293,7 @@ bool8 MovementAction_WalkNormalDiagonalDownLeft_Step1(struct ObjectEvent *object bool8 MovementAction_WalkNormalDiagonalDownRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_SOUTHEAST, 0); + InitMovementNormal(objectEvent, sprite, DIR_SOUTHEAST, MOVE_SPEED_NORMAL); return MovementAction_WalkNormalDiagonalDownRight_Step1(objectEvent, sprite); } @@ -5420,7 +5309,7 @@ bool8 MovementAction_WalkNormalDiagonalDownRight_Step1(struct ObjectEvent *objec bool8 MovementAction_WalkNormalDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 0); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_NORMAL); return MovementAction_WalkNormalDown_Step1(objectEvent, sprite); } @@ -5436,7 +5325,7 @@ bool8 MovementAction_WalkNormalDown_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkNormalUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_NORTH, 0); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_NORMAL); return MovementAction_WalkNormalUp_Step1(objectEvent, sprite); } @@ -5452,7 +5341,7 @@ bool8 MovementAction_WalkNormalUp_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkNormalLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_WEST, 0); + InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_NORMAL); return MovementAction_WalkNormalLeft_Step1(objectEvent, sprite); } @@ -5468,7 +5357,7 @@ bool8 MovementAction_WalkNormalLeft_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkNormalRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_EAST, 0); + InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_NORMAL); return MovementAction_WalkNormalRight_Step1(objectEvent, sprite); } @@ -5701,7 +5590,7 @@ bool8 MovementAction_Delay16_Step0(struct ObjectEvent *objectEvent, struct Sprit bool8 MovementAction_WalkFastDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 1); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_FAST_1); return MovementAction_WalkFastDown_Step1(objectEvent, sprite); } @@ -5717,7 +5606,7 @@ bool8 MovementAction_WalkFastDown_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkFastUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_NORTH, 1); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_FAST_1); return MovementAction_WalkFastUp_Step1(objectEvent, sprite); } @@ -5733,7 +5622,7 @@ bool8 MovementAction_WalkFastUp_Step1(struct ObjectEvent *objectEvent, struct Sp bool8 MovementAction_WalkFastLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_WEST, 1); + InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FAST_1); return MovementAction_WalkFastLeft_Step1(objectEvent, sprite); } @@ -5749,7 +5638,7 @@ bool8 MovementAction_WalkFastLeft_Step1(struct ObjectEvent *objectEvent, struct bool8 MovementAction_WalkFastRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_EAST, 1); + InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FAST_1); return MovementAction_WalkFastRight_Step1(objectEvent, sprite); } @@ -5787,9 +5676,8 @@ bool8 MovementAction_WalkInPlace_Step1(struct ObjectEvent *objectEvent, struct S bool8 MovementAction_WalkInPlaceSlow_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (sprite->data[3] & 1) - { sprite->animDelayCounter++; - } + return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } @@ -5865,25 +5753,25 @@ bool8 MovementAction_WalkInPlaceFastRight_Step0(struct ObjectEvent *objectEvent, return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } -bool8 MovementAction_WalkInPlaceFastestDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkInPlaceFasterDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { InitMoveInPlace(objectEvent, sprite, DIR_SOUTH, GetMoveDirectionFasterAnimNum(DIR_SOUTH), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } -bool8 MovementAction_WalkInPlaceFastestUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkInPlaceFasterUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { InitMoveInPlace(objectEvent, sprite, DIR_NORTH, GetMoveDirectionFasterAnimNum(DIR_NORTH), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } -bool8 MovementAction_WalkInPlaceFastestLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkInPlaceFasterLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { InitMoveInPlace(objectEvent, sprite, DIR_WEST, GetMoveDirectionFasterAnimNum(DIR_WEST), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); } -bool8 MovementAction_WalkInPlaceFastestRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkInPlaceFasterRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { InitMoveInPlace(objectEvent, sprite, DIR_EAST, GetMoveDirectionFasterAnimNum(DIR_EAST), 4); return MovementAction_WalkInPlace_Step1(objectEvent, sprite); @@ -5891,7 +5779,7 @@ bool8 MovementAction_WalkInPlaceFastestRight_Step0(struct ObjectEvent *objectEve bool8 MovementAction_RideWaterCurrentDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 2); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_FAST_2); return MovementAction_RideWaterCurrentDown_Step1(objectEvent, sprite); } @@ -5907,7 +5795,7 @@ bool8 MovementAction_RideWaterCurrentDown_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_RideWaterCurrentUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_NORTH, 2); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_FAST_2); return MovementAction_RideWaterCurrentUp_Step1(objectEvent, sprite); } @@ -5923,7 +5811,7 @@ bool8 MovementAction_RideWaterCurrentUp_Step1(struct ObjectEvent *objectEvent, s bool8 MovementAction_RideWaterCurrentLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_WEST, 2); + InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FAST_2); return MovementAction_RideWaterCurrentLeft_Step1(objectEvent, sprite); } @@ -5939,7 +5827,7 @@ bool8 MovementAction_RideWaterCurrentLeft_Step1(struct ObjectEvent *objectEvent, bool8 MovementAction_RideWaterCurrentRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_EAST, 2); + InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FAST_2); return MovementAction_RideWaterCurrentRight_Step1(objectEvent, sprite); } @@ -5953,13 +5841,13 @@ bool8 MovementAction_RideWaterCurrentRight_Step1(struct ObjectEvent *objectEvent return FALSE; } -bool8 MovementAction_WalkFastestDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkFasterDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 3); - return MovementAction_WalkFastestDown_Step1(objectEvent, sprite); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_FASTER); + return MovementAction_WalkFasterDown_Step1(objectEvent, sprite); } -bool8 MovementAction_WalkFastestDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkFasterDown_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (UpdateMovementNormal(objectEvent, sprite)) { @@ -5969,13 +5857,13 @@ bool8 MovementAction_WalkFastestDown_Step1(struct ObjectEvent *objectEvent, stru return FALSE; } -bool8 MovementAction_WalkFastestUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkFasterUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_NORTH, 3); - return MovementAction_WalkFastestUp_Step1(objectEvent, sprite); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_FASTER); + return MovementAction_WalkFasterUp_Step1(objectEvent, sprite); } -bool8 MovementAction_WalkFastestUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkFasterUp_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (UpdateMovementNormal(objectEvent, sprite)) { @@ -5985,13 +5873,13 @@ bool8 MovementAction_WalkFastestUp_Step1(struct ObjectEvent *objectEvent, struct return FALSE; } -bool8 MovementAction_WalkFastestLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkFasterLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_WEST, 3); - return MovementAction_WalkFastestLeft_Step1(objectEvent, sprite); + InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FASTER); + return MovementAction_WalkFasterLeft_Step1(objectEvent, sprite); } -bool8 MovementAction_WalkFastestLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkFasterLeft_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (UpdateMovementNormal(objectEvent, sprite)) { @@ -6001,13 +5889,13 @@ bool8 MovementAction_WalkFastestLeft_Step1(struct ObjectEvent *objectEvent, stru return FALSE; } -bool8 MovementAction_WalkFastestRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkFasterRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_EAST, 3); - return MovementAction_WalkFastestRight_Step1(objectEvent, sprite); + InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FASTER); + return MovementAction_WalkFasterRight_Step1(objectEvent, sprite); } -bool8 MovementAction_WalkFastestRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) +bool8 MovementAction_WalkFasterRight_Step1(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (UpdateMovementNormal(objectEvent, sprite)) { @@ -6019,7 +5907,7 @@ bool8 MovementAction_WalkFastestRight_Step1(struct ObjectEvent *objectEvent, str bool8 MovementAction_SlideDown_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_SOUTH, 4); + InitMovementNormal(objectEvent, sprite, DIR_SOUTH, MOVE_SPEED_FASTEST); return MovementAction_SlideDown_Step1(objectEvent, sprite); } @@ -6035,7 +5923,7 @@ bool8 MovementAction_SlideDown_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_SlideUp_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_NORTH, 4); + InitMovementNormal(objectEvent, sprite, DIR_NORTH, MOVE_SPEED_FASTEST); return MovementAction_SlideUp_Step1(objectEvent, sprite); } @@ -6051,7 +5939,7 @@ bool8 MovementAction_SlideUp_Step1(struct ObjectEvent *objectEvent, struct Sprit bool8 MovementAction_SlideLeft_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_WEST, 4); + InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FASTEST); return MovementAction_SlideLeft_Step1(objectEvent, sprite); } @@ -6067,7 +5955,7 @@ bool8 MovementAction_SlideLeft_Step1(struct ObjectEvent *objectEvent, struct Spr bool8 MovementAction_SlideRight_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_EAST, 4); + InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FASTEST); return MovementAction_SlideRight_Step1(objectEvent, sprite); } @@ -6247,9 +6135,10 @@ bool8 MovementAction_FacePlayer_Step0(struct ObjectEvent *objectEvent, struct Sp u8 playerObjectId; if (!TryGetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0, &playerObjectId)) - { - FaceDirection(objectEvent, sprite, GetDirectionToFace(objectEvent->currentCoords.x, objectEvent->currentCoords.y, gObjectEvents[playerObjectId].currentCoords.x, gObjectEvents[playerObjectId].currentCoords.y)); - } + FaceDirection(objectEvent, sprite, GetDirectionToFace(objectEvent->currentCoords.x, + objectEvent->currentCoords.y, + gObjectEvents[playerObjectId].currentCoords.x, + gObjectEvents[playerObjectId].currentCoords.y)); sprite->sActionFuncId = 1; return TRUE; } @@ -6259,9 +6148,10 @@ bool8 MovementAction_FaceAwayPlayer_Step0(struct ObjectEvent *objectEvent, struc u8 playerObjectId; if (!TryGetObjectEventIdByLocalIdAndMap(OBJ_EVENT_ID_PLAYER, 0, 0, &playerObjectId)) - { - FaceDirection(objectEvent, sprite, GetOppositeDirection(GetDirectionToFace(objectEvent->currentCoords.x, objectEvent->currentCoords.y, gObjectEvents[playerObjectId].currentCoords.x, gObjectEvents[playerObjectId].currentCoords.y))); - } + FaceDirection(objectEvent, sprite, GetOppositeDirection(GetDirectionToFace(objectEvent->currentCoords.x, + objectEvent->currentCoords.y, + gObjectEvents[playerObjectId].currentCoords.x, + gObjectEvents[playerObjectId].currentCoords.y))); sprite->sActionFuncId = 1; return TRUE; } @@ -6728,7 +6618,7 @@ bool8 MovementAction_WalkDownAffine_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkLeftAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_WEST, 1); + InitMovementNormal(objectEvent, sprite, DIR_WEST, MOVE_SPEED_FAST_1); sprite->affineAnimPaused = FALSE; ChangeSpriteAffineAnimIfDifferent(sprite, 2); return MovementAction_WalkLeftAffine_Step1(objectEvent, sprite); @@ -6747,7 +6637,7 @@ bool8 MovementAction_WalkLeftAffine_Step1(struct ObjectEvent *objectEvent, struc bool8 MovementAction_WalkRightAffine_Step0(struct ObjectEvent *objectEvent, struct Sprite *sprite) { - InitMovementNormal(objectEvent, sprite, DIR_EAST, 1); + InitMovementNormal(objectEvent, sprite, DIR_EAST, MOVE_SPEED_FAST_1); sprite->affineAnimPaused = FALSE; ChangeSpriteAffineAnimIfDifferent(sprite, 3); return MovementAction_WalkRightAffine_Step1(objectEvent, sprite); @@ -7391,9 +7281,7 @@ bool8 MovementAction_PauseSpriteAnim(struct ObjectEvent *objectEvent, struct Spr static void UpdateObjectEventSpriteAnimPause(struct ObjectEvent *objectEvent, struct Sprite *sprite) { if (objectEvent->disableAnim) - { sprite->animPaused = TRUE; - } } static void TryEnableObjectEventAnim(struct ObjectEvent *objectEvent, struct Sprite *sprite) @@ -7544,14 +7432,10 @@ static void GetGroundEffectFlags_LongGrassOnBeginStep(struct ObjectEvent *objEve static void GetGroundEffectFlags_Tracks(struct ObjectEvent *objEvent, u32 *flags) { if (MetatileBehavior_IsDeepSand(objEvent->previousMetatileBehavior)) - { *flags |= GROUND_EFFECT_FLAG_DEEP_SAND; - } else if (MetatileBehavior_IsSandOrDeepSand(objEvent->previousMetatileBehavior) || MetatileBehavior_IsFootprints(objEvent->previousMetatileBehavior)) - { *flags |= GROUND_EFFECT_FLAG_SAND; - } } static void GetGroundEffectFlags_SandHeap(struct ObjectEvent *objEvent, u32 *flags) @@ -7561,14 +7445,14 @@ static void GetGroundEffectFlags_SandHeap(struct ObjectEvent *objEvent, u32 *fla { if (!objEvent->inSandPile) { - objEvent->inSandPile = 0; - objEvent->inSandPile = 1; + objEvent->inSandPile = FALSE; + objEvent->inSandPile = TRUE; *flags |= GROUND_EFFECT_FLAG_SAND_PILE; } } else { - objEvent->inSandPile = 0; + objEvent->inSandPile = FALSE; } } @@ -7581,14 +7465,14 @@ static void GetGroundEffectFlags_ShallowFlowingWater(struct ObjectEvent *objEven { if (!objEvent->inShallowFlowingWater) { - objEvent->inShallowFlowingWater = 0; - objEvent->inShallowFlowingWater = 1; + objEvent->inShallowFlowingWater = FALSE; + objEvent->inShallowFlowingWater = TRUE; *flags |= GROUND_EFFECT_FLAG_SHALLOW_FLOWING_WATER; } } else { - objEvent->inShallowFlowingWater = 0; + objEvent->inShallowFlowingWater = FALSE; } } @@ -7596,9 +7480,7 @@ static void GetGroundEffectFlags_Puddle(struct ObjectEvent *objEvent, u32 *flags { if (MetatileBehavior_IsPuddle(objEvent->currentMetatileBehavior) && MetatileBehavior_IsPuddle(objEvent->previousMetatileBehavior)) - { *flags |= GROUND_EFFECT_FLAG_PUDDLE; - } } static void GetGroundEffectFlags_Ripple(struct ObjectEvent *objEvent, u32 *flags) @@ -7614,14 +7496,14 @@ static void GetGroundEffectFlags_ShortGrass(struct ObjectEvent *objEvent, u32 *f { if (!objEvent->inShortGrass) { - objEvent->inShortGrass = 0; - objEvent->inShortGrass = 1; + objEvent->inShortGrass = FALSE; + objEvent->inShortGrass = TRUE; *flags |= GROUND_EFFECT_FLAG_SHORT_GRASS; } } else { - objEvent->inShortGrass = 0; + objEvent->inShortGrass = FALSE; } } @@ -7632,14 +7514,14 @@ static void GetGroundEffectFlags_HotSprings(struct ObjectEvent *objEvent, u32 *f { if (!objEvent->inHotSprings) { - objEvent->inHotSprings = 0; - objEvent->inHotSprings = 1; + objEvent->inHotSprings = FALSE; + objEvent->inHotSprings = TRUE; *flags |= GROUND_EFFECT_FLAG_HOT_SPRINGS; } } else { - objEvent->inHotSprings = 0; + objEvent->inHotSprings = FALSE; } } @@ -8205,11 +8087,11 @@ bool8 FreezeObjectEvent(struct ObjectEvent *objectEvent) } else { - objectEvent->frozen = 1; + objectEvent->frozen = TRUE; objectEvent->spriteAnimPausedBackup = gSprites[objectEvent->spriteId].animPaused; objectEvent->spriteAffineAnimPausedBackup = gSprites[objectEvent->spriteId].affineAnimPaused; - gSprites[objectEvent->spriteId].animPaused = 1; - gSprites[objectEvent->spriteId].affineAnimPaused = 1; + gSprites[objectEvent->spriteId].animPaused = TRUE; + gSprites[objectEvent->spriteId].affineAnimPaused = TRUE; return FALSE; } } @@ -8341,15 +8223,19 @@ static const SpriteStepFunc sStep8Funcs[] = { }; static const SpriteStepFunc *const sNpcStepFuncTables[] = { - sStep1Funcs, - sStep2Funcs, - sStep3Funcs, - sStep4Funcs, - sStep8Funcs, + [MOVE_SPEED_NORMAL] = sStep1Funcs, + [MOVE_SPEED_FAST_1] = sStep2Funcs, + [MOVE_SPEED_FAST_2] = sStep3Funcs, + [MOVE_SPEED_FASTER] = sStep4Funcs, + [MOVE_SPEED_FASTEST] = sStep8Funcs, }; static const s16 sStepTimes[] = { - 16, 8, 6, 4, 2 + [MOVE_SPEED_NORMAL] = 16, + [MOVE_SPEED_FAST_1] = 8, + [MOVE_SPEED_FAST_2] = 6, + [MOVE_SPEED_FASTER] = 4, + [MOVE_SPEED_FASTEST] = 2, }; static bool8 NpcTakeStep(struct Sprite *sprite) diff --git a/src/field_control_avatar.c b/src/field_control_avatar.c index e58fb783b..6d338c06d 100644 --- a/src/field_control_avatar.c +++ b/src/field_control_avatar.c @@ -421,7 +421,7 @@ static const u8 *GetInteractedMetatileScript(struct MapPosition *position, u8 me return SecretBase_EventScript_SandOrnament; if (MetatileBehavior_IsSecretBaseShieldOrToyTV(metatileBehavior) == TRUE) return SecretBase_EventScript_ShieldOrToyTV; - if (MetatileBehavior_IsMB_C6(metatileBehavior) == TRUE) + if (MetatileBehavior_IsSecretBaseDecorationBase(metatileBehavior) == TRUE) { CheckInteractedWithFriendsFurnitureBottom(); return NULL; @@ -729,9 +729,8 @@ static bool8 TryStartWarpEventScript(struct MapPosition *position, u16 metatileB DoTeleportTileWarp(); return TRUE; } - if (MetatileBehavior_IsBridgeOverOcean(metatileBehavior) == TRUE) + if (MetatileBehavior_IsUnionRoomWarp(metatileBehavior) == TRUE) { - // Maybe unused? This MB is used by log bridges, but there's never a warp event on them. DoSpinExitWarp(); return TRUE; } @@ -762,7 +761,7 @@ static bool8 IsWarpMetatileBehavior(u16 metatileBehavior) && MetatileBehavior_IsAquaHideoutWarp(metatileBehavior) != TRUE && MetatileBehavior_IsMtPyreHole(metatileBehavior) != TRUE && MetatileBehavior_IsMossdeepGymWarp(metatileBehavior) != TRUE - && MetatileBehavior_IsBridgeOverOcean(metatileBehavior) != TRUE) + && MetatileBehavior_IsUnionRoomWarp(metatileBehavior) != TRUE) return FALSE; return TRUE; } diff --git a/src/field_effect.c b/src/field_effect.c index 7e1ebdff4..574bec879 100644 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -2163,7 +2163,7 @@ static bool8 LavaridgeGym1FWarpEffect_AshPuff(struct Task *task, struct ObjectEv } else { task->data[1]++; - ObjectEventSetHeldMovement(objectEvent, GetWalkInPlaceFastestMovementAction(objectEvent->facingDirection)); + ObjectEventSetHeldMovement(objectEvent, GetWalkInPlaceFasterMovementAction(objectEvent->facingDirection)); PlaySE(SE_LAVARIDGE_FALL_WARP); } } diff --git a/src/field_player_avatar.c b/src/field_player_avatar.c index 6ce304c2c..9e54823a6 100644 --- a/src/field_player_avatar.c +++ b/src/field_player_avatar.c @@ -225,10 +225,10 @@ static void (*const sPlayerAvatarTransitionFuncs[])(struct ObjectEvent *) = static bool8 (*const sArrowWarpMetatileBehaviorChecks[])(u8) = { - MetatileBehavior_IsSouthArrowWarp, - MetatileBehavior_IsNorthArrowWarp, - MetatileBehavior_IsWestArrowWarp, - MetatileBehavior_IsEastArrowWarp, + [DIR_SOUTH - 1] = MetatileBehavior_IsSouthArrowWarp, + [DIR_NORTH - 1] = MetatileBehavior_IsNorthArrowWarp, + [DIR_WEST - 1] = MetatileBehavior_IsWestArrowWarp, + [DIR_EAST - 1] = MetatileBehavior_IsEastArrowWarp, }; static const u8 sRivalAvatarGfxIds[][2] = @@ -281,10 +281,10 @@ static const u8 sPlayerAvatarGfxToStateFlag[2][5][2] = static bool8 (*const sArrowWarpMetatileBehaviorChecks2[])(u8) = //Duplicate of sArrowWarpMetatileBehaviorChecks { - MetatileBehavior_IsSouthArrowWarp, - MetatileBehavior_IsNorthArrowWarp, - MetatileBehavior_IsWestArrowWarp, - MetatileBehavior_IsEastArrowWarp, + [DIR_SOUTH - 1] = MetatileBehavior_IsSouthArrowWarp, + [DIR_NORTH - 1] = MetatileBehavior_IsNorthArrowWarp, + [DIR_WEST - 1] = MetatileBehavior_IsWestArrowWarp, + [DIR_EAST - 1] = MetatileBehavior_IsEastArrowWarp, }; static bool8 (*const sPushBoulderFuncs[])(struct Task *, struct ObjectEvent *, struct ObjectEvent *) = @@ -470,27 +470,27 @@ static u8 DoForcedMovementInCurrentDirection(void (*a)(u8)) static bool8 ForcedMovement_Slip(void) { - return DoForcedMovementInCurrentDirection(PlayerGoSpeed2); + return DoForcedMovementInCurrentDirection(PlayerWalkFast); } static bool8 ForcedMovement_WalkSouth(void) { - return DoForcedMovement(DIR_SOUTH, PlayerGoSpeed1); + return DoForcedMovement(DIR_SOUTH, PlayerWalkNormal); } static bool8 ForcedMovement_WalkNorth(void) { - return DoForcedMovement(DIR_NORTH, PlayerGoSpeed1); + return DoForcedMovement(DIR_NORTH, PlayerWalkNormal); } static bool8 ForcedMovement_WalkWest(void) { - return DoForcedMovement(DIR_WEST, PlayerGoSpeed1); + return DoForcedMovement(DIR_WEST, PlayerWalkNormal); } static bool8 ForcedMovement_WalkEast(void) { - return DoForcedMovement(DIR_EAST, PlayerGoSpeed1); + return DoForcedMovement(DIR_EAST, PlayerWalkNormal); } static bool8 ForcedMovement_PushedSouthByCurrent(void) @@ -524,22 +524,22 @@ static u8 ForcedMovement_Slide(u8 direction, void (*b)(u8)) static bool8 ForcedMovement_SlideSouth(void) { - return ForcedMovement_Slide(DIR_SOUTH, PlayerGoSpeed2); + return ForcedMovement_Slide(DIR_SOUTH, PlayerWalkFast); } static bool8 ForcedMovement_SlideNorth(void) { - return ForcedMovement_Slide(DIR_NORTH, PlayerGoSpeed2); + return ForcedMovement_Slide(DIR_NORTH, PlayerWalkFast); } static bool8 ForcedMovement_SlideWest(void) { - return ForcedMovement_Slide(DIR_WEST, PlayerGoSpeed2); + return ForcedMovement_Slide(DIR_WEST, PlayerWalkFast); } static bool8 ForcedMovement_SlideEast(void) { - return ForcedMovement_Slide(DIR_EAST, PlayerGoSpeed2); + return ForcedMovement_Slide(DIR_EAST, PlayerWalkFast); } static bool8 ForcedMovement_MatJump(void) @@ -562,7 +562,7 @@ static bool8 ForcedMovement_MuddySlope(void) { Bike_UpdateBikeCounterSpeed(0); playerObjEvent->facingDirectionLocked = TRUE; - return DoForcedMovement(DIR_SOUTH, PlayerGoSpeed2); + return DoForcedMovement(DIR_SOUTH, PlayerWalkFast); } else { @@ -631,8 +631,8 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) if (gPlayerAvatar.flags & PLAYER_AVATAR_FLAG_SURFING) { - // speed 2 is fast, same speed as running - PlayerGoSpeed2(direction); + // same speed as running + PlayerWalkFast(direction); return; } @@ -645,7 +645,7 @@ static void PlayerNotOnBikeMoving(u8 direction, u16 heldKeys) } else { - PlayerGoSpeed1(direction); + PlayerWalkNormal(direction); } } @@ -903,7 +903,7 @@ static bool8 PlayerAnimIsMultiFrameStationary(void) if (movementActionId <= MOVEMENT_ACTION_FACE_RIGHT || (movementActionId >= MOVEMENT_ACTION_DELAY_1 && movementActionId <= MOVEMENT_ACTION_DELAY_16) - || (movementActionId >= MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN && movementActionId <= MOVEMENT_ACTION_WALK_IN_PLACE_FASTEST_RIGHT) + || (movementActionId >= MOVEMENT_ACTION_WALK_IN_PLACE_SLOW_DOWN && movementActionId <= MOVEMENT_ACTION_WALK_IN_PLACE_FASTER_RIGHT) || (movementActionId >= MOVEMENT_ACTION_ACRO_WHEELIE_FACE_DOWN && movementActionId <= MOVEMENT_ACTION_ACRO_END_WHEELIE_FACE_RIGHT) || (movementActionId >= MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_DOWN && movementActionId <= MOVEMENT_ACTION_ACRO_WHEELIE_IN_PLACE_RIGHT)) return TRUE; @@ -929,9 +929,9 @@ static bool8 PlayerCheckIfAnimFinishedOrInactive(void) return ObjectEventCheckHeldMovementStatus(&gObjectEvents[gPlayerAvatar.objectEventId]); } -static void PlayerSetCopyableMovement(u8 a) +static void PlayerSetCopyableMovement(u8 movement) { - gObjectEvents[gPlayerAvatar.objectEventId].playerCopyableMovement = a; + gObjectEvents[gPlayerAvatar.objectEventId].playerCopyableMovement = movement; } u8 PlayerGetCopyableMovement(void) @@ -953,70 +953,67 @@ void PlayerSetAnimId(u8 movementActionId, u8 copyableMovement) } } -// normal speed (1 speed) -void PlayerGoSpeed1(u8 a) +void PlayerWalkNormal(u8 direction) { - PlayerSetAnimId(GetWalkNormalMovementAction(a), 2); + PlayerSetAnimId(GetWalkNormalMovementAction(direction), COPY_MOVE_WALK); } -// fast speed (2 speed) -void PlayerGoSpeed2(u8 a) +void PlayerWalkFast(u8 direction) { - PlayerSetAnimId(GetWalkFastMovementAction(a), 2); + PlayerSetAnimId(GetWalkFastMovementAction(direction), COPY_MOVE_WALK); } -void PlayerRideWaterCurrent(u8 a) +void PlayerRideWaterCurrent(u8 direction) { - PlayerSetAnimId(GetRideWaterCurrentMovementAction(a), 2); + PlayerSetAnimId(GetRideWaterCurrentMovementAction(direction), COPY_MOVE_WALK); } -// fastest speed (4 speed) -void PlayerGoSpeed4(u8 a) +void PlayerWalkFaster(u8 direction) { - PlayerSetAnimId(GetWalkFastestMovementAction(a), 2); + PlayerSetAnimId(GetWalkFasterMovementAction(direction), COPY_MOVE_WALK); } -static void PlayerRun(u8 a) +static void PlayerRun(u8 direction) { - PlayerSetAnimId(GetPlayerRunMovementAction(a), 2); + PlayerSetAnimId(GetPlayerRunMovementAction(direction), COPY_MOVE_WALK); } -void PlayerOnBikeCollide(u8 a) +void PlayerOnBikeCollide(u8 direction) { - PlayCollisionSoundIfNotFacingWarp(a); - PlayerSetAnimId(GetWalkInPlaceNormalMovementAction(a), 2); + PlayCollisionSoundIfNotFacingWarp(direction); + PlayerSetAnimId(GetWalkInPlaceNormalMovementAction(direction), COPY_MOVE_WALK); } -void PlayerOnBikeCollideWithFarawayIslandMew(u8 a) +void PlayerOnBikeCollideWithFarawayIslandMew(u8 direction) { - PlayerSetAnimId(GetWalkInPlaceNormalMovementAction(a), 2); + PlayerSetAnimId(GetWalkInPlaceNormalMovementAction(direction), COPY_MOVE_WALK); } -static void PlayerNotOnBikeCollide(u8 a) +static void PlayerNotOnBikeCollide(u8 direction) { - PlayCollisionSoundIfNotFacingWarp(a); - PlayerSetAnimId(GetWalkInPlaceSlowMovementAction(a), 2); + PlayCollisionSoundIfNotFacingWarp(direction); + PlayerSetAnimId(GetWalkInPlaceSlowMovementAction(direction), COPY_MOVE_WALK); } -static void PlayerNotOnBikeCollideWithFarawayIslandMew(u8 a) +static void PlayerNotOnBikeCollideWithFarawayIslandMew(u8 direction) { - PlayerSetAnimId(GetWalkInPlaceSlowMovementAction(a), 2); + PlayerSetAnimId(GetWalkInPlaceSlowMovementAction(direction), COPY_MOVE_WALK); } void PlayerFaceDirection(u8 direction) { - PlayerSetAnimId(GetFaceDirectionMovementAction(direction), 1); + PlayerSetAnimId(GetFaceDirectionMovementAction(direction), COPY_MOVE_FACE); } void PlayerTurnInPlace(u8 direction) { - PlayerSetAnimId(GetWalkInPlaceFastMovementAction(direction), 1); + PlayerSetAnimId(GetWalkInPlaceFastMovementAction(direction), COPY_MOVE_FACE); } void PlayerJumpLedge(u8 direction) { PlaySE(SE_LEDGE); - PlayerSetAnimId(GetJump2MovementAction(direction), 8); + PlayerSetAnimId(GetJump2MovementAction(direction), COPY_MOVE_JUMP2); } // Stop player on current facing direction once they're done moving and if they're not currently Acro Biking on bumpy slope @@ -1032,81 +1029,82 @@ void PlayerFreeze(void) // wheelie idle void PlayerIdleWheelie(u8 direction) { - PlayerSetAnimId(GetAcroWheelieFaceDirectionMovementAction(direction), 1); + PlayerSetAnimId(GetAcroWheelieFaceDirectionMovementAction(direction), COPY_MOVE_FACE); } // normal to wheelie void PlayerStartWheelie(u8 direction) { - PlayerSetAnimId(GetAcroPopWheelieFaceDirectionMovementAction(direction), 1); + PlayerSetAnimId(GetAcroPopWheelieFaceDirectionMovementAction(direction), COPY_MOVE_FACE); } // wheelie to normal void PlayerEndWheelie(u8 direction) { - PlayerSetAnimId(GetAcroEndWheelieFaceDirectionMovementAction(direction), 1); + PlayerSetAnimId(GetAcroEndWheelieFaceDirectionMovementAction(direction), COPY_MOVE_FACE); } // wheelie hopping standing -void PlayerStandingHoppingWheelie(u8 a) +void PlayerStandingHoppingWheelie(u8 direction) { PlaySE(SE_BIKE_HOP); - PlayerSetAnimId(GetAcroWheelieHopFaceDirectionMovementAction(a), 1); + PlayerSetAnimId(GetAcroWheelieHopFaceDirectionMovementAction(direction), COPY_MOVE_FACE); } // wheelie hopping moving -void PlayerMovingHoppingWheelie(u8 a) +void PlayerMovingHoppingWheelie(u8 direction) { PlaySE(SE_BIKE_HOP); - PlayerSetAnimId(GetAcroWheelieHopDirectionMovementAction(a), 2); + PlayerSetAnimId(GetAcroWheelieHopDirectionMovementAction(direction), COPY_MOVE_WALK); } // wheelie hopping ledge -void PlayerLedgeHoppingWheelie(u8 a) +void PlayerLedgeHoppingWheelie(u8 direction) { PlaySE(SE_BIKE_HOP); - PlayerSetAnimId(GetAcroWheelieJumpDirectionMovementAction(a), 8); + PlayerSetAnimId(GetAcroWheelieJumpDirectionMovementAction(direction), COPY_MOVE_JUMP2); } // acro turn jump void PlayerAcroTurnJump(u8 direction) { PlaySE(SE_BIKE_HOP); - PlayerSetAnimId(GetJumpInPlaceTurnAroundMovementAction(direction), 1); + PlayerSetAnimId(GetJumpInPlaceTurnAroundMovementAction(direction), COPY_MOVE_FACE); } void PlayerWheelieInPlace(u8 direction) { PlaySE(SE_WALL_HIT); - PlayerSetAnimId(GetAcroWheelieInPlaceDirectionMovementAction(direction), 2); + PlayerSetAnimId(GetAcroWheelieInPlaceDirectionMovementAction(direction), COPY_MOVE_WALK); } void PlayerPopWheelieWhileMoving(u8 direction) { - PlayerSetAnimId(GetAcroPopWheelieMoveDirectionMovementAction(direction), 2); + PlayerSetAnimId(GetAcroPopWheelieMoveDirectionMovementAction(direction), COPY_MOVE_WALK); } void PlayerWheelieMove(u8 direction) { - PlayerSetAnimId(GetAcroWheelieMoveDirectionMovementAction(direction), 2); + PlayerSetAnimId(GetAcroWheelieMoveDirectionMovementAction(direction), COPY_MOVE_WALK); } void PlayerEndWheelieWhileMoving(u8 direction) { - PlayerSetAnimId(GetAcroEndWheelieMoveDirectionMovementAction(direction), 2); + PlayerSetAnimId(GetAcroEndWheelieMoveDirectionMovementAction(direction), COPY_MOVE_WALK); } -static void PlayCollisionSoundIfNotFacingWarp(u8 a) +static void PlayCollisionSoundIfNotFacingWarp(u8 direction) { s16 x, y; u8 metatileBehavior = gObjectEvents[gPlayerAvatar.objectEventId].currentMetatileBehavior; - if (!sArrowWarpMetatileBehaviorChecks[a - 1](metatileBehavior)) + if (!sArrowWarpMetatileBehaviorChecks[direction - 1](metatileBehavior)) { - if (a == 2) + // Check if walking up into a door + if (direction == DIR_NORTH) { PlayerGetDestCoords(&x, &y); - MoveCoords(2, &x, &y); + MoveCoords(direction, &x, &y); if (MetatileBehavior_IsWarpDoor(MapGridGetMetatileBehaviorAt(x, y))) return; } @@ -1766,7 +1764,7 @@ static bool8 Fishing_InitDots(struct Task *task) { u32 randVal; - sub_819786C(0, TRUE); + LoadMessageBoxAndFrameGfx(0, TRUE); task->tStep++; task->tFrameCounter = 0; task->tNumDots = 0; @@ -1807,7 +1805,7 @@ static bool8 Fishing_ShowDots(struct Task *task) } else { - AddTextPrinterParameterized(0, 1, dot, task->tNumDots * 8, 1, 0, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, dot, task->tNumDots * 8, 1, 0, NULL); task->tNumDots++; } } @@ -1856,7 +1854,7 @@ static bool8 Fishing_CheckForBite(struct Task *task) static bool8 Fishing_GotBite(struct Task *task) { AlignFishingAnimationFrames(); - AddTextPrinterParameterized(0, 1, gText_OhABite, 0, 17, 0, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_OhABite, 0, 17, 0, NULL); task->tStep++; task->tFrameCounter = 0; return FALSE; @@ -1911,7 +1909,7 @@ static bool8 Fishing_MonOnHook(struct Task *task) { AlignFishingAnimationFrames(); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, gText_PokemonOnHook, 1, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_PokemonOnHook, 1, 0, 2, 1, 3); task->tStep++; task->tFrameCounter = 0; return FALSE; @@ -1958,7 +1956,7 @@ static bool8 Fishing_NotEvenNibble(struct Task *task) AlignFishingAnimationFrames(); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, gText_NotEvenANibble, 1, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_NotEvenANibble, 1, 0, 2, 1, 3); task->tStep = FISHING_SHOW_RESULT; return TRUE; } @@ -1968,7 +1966,7 @@ static bool8 Fishing_GotAway(struct Task *task) AlignFishingAnimationFrames(); StartSpriteAnim(&gSprites[gPlayerAvatar.spriteId], GetFishingNoCatchDirectionAnimNum(GetPlayerFacingDirection())); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, gText_ItGotAway, 1, 0, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_ItGotAway, 1, 0, 2, 1, 3); task->tStep++; return TRUE; } diff --git a/src/field_region_map.c b/src/field_region_map.c index 99def4901..26ae736a6 100644 --- a/src/field_region_map.c +++ b/src/field_region_map.c @@ -151,8 +151,8 @@ static void FieldUpdateRegionMap(void) break; case 1: DrawStdFrameWithCustomTileAndPalette(1, 0, 0x27, 0xd); - offset = GetStringCenterAlignXOffset(1, gText_Hoenn, 0x38); - AddTextPrinterParameterized(1, 1, gText_Hoenn, offset, 1, 0, NULL); + offset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38); + AddTextPrinterParameterized(1, FONT_NORMAL, gText_Hoenn, offset, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); DrawStdFrameWithCustomTileAndPalette(0, 0, 0x27, 0xd); PrintRegionMapSecName(); @@ -207,12 +207,12 @@ static void PrintRegionMapSecName(void) if (sFieldRegionMapHandler->regionMap.mapSecType != MAPSECTYPE_NONE) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized(0, 1, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); } else { FillWindowPixelBuffer(0, PIXEL_FILL(1)); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } } diff --git a/src/field_screen_effect.c b/src/field_screen_effect.c index e573fe5ab..c27ec6c4c 100644 --- a/src/field_screen_effect.c +++ b/src/field_screen_effect.c @@ -1145,7 +1145,7 @@ static void Task_OrbEffect(u8 taskId) tState = 1; break; case 1: - sub_8199DF0(0, PIXEL_FILL(1), 0, 1); + BgDmaFill(0, PIXEL_FILL(1), 0, 1); LoadOrbEffectPalette(tBlueOrb); StartUpdateOrbFlashEffect(tCenterX, tCenterY, 1, 160, 1, 2); tState = 2; @@ -1190,7 +1190,7 @@ static void Task_OrbEffect(u8 taskId) if (UpdateOrbEffectBlend(tShakeDir) == TRUE) { tState = 5; - sub_8199DF0(0, PIXEL_FILL(0), 0, 1); + BgDmaFill(0, PIXEL_FILL(0), 0, 1); } } break; diff --git a/src/field_specials.c b/src/field_specials.c index 22fd6872b..ef569ca00 100644 --- a/src/field_specials.c +++ b/src/field_specials.c @@ -1910,14 +1910,14 @@ void ShowDeptStoreElevatorFloorSelect(void) sTutorMoveAndElevatorWindowId = AddWindow(&gElevatorFloor_WindowTemplate); SetStandardWindowBorderStyle(sTutorMoveAndElevatorWindowId, 0); - xPos = GetStringCenterAlignXOffset(1, gText_ElevatorNowOn, 64); - AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, 1, gText_ElevatorNowOn, xPos, 1, TEXT_SPEED_FF, NULL); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, gText_ElevatorNowOn, 64); + AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, FONT_NORMAL, gText_ElevatorNowOn, xPos, 1, TEXT_SKIP_DRAW, NULL); - xPos = GetStringCenterAlignXOffset(1, gDeptStoreFloorNames[gSpecialVar_0x8005], 64); - AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, 1, gDeptStoreFloorNames[gSpecialVar_0x8005], xPos, 17, TEXT_SPEED_FF, NULL); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, gDeptStoreFloorNames[gSpecialVar_0x8005], 64); + AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, FONT_NORMAL, gDeptStoreFloorNames[gSpecialVar_0x8005], xPos, 17, TEXT_SKIP_DRAW, NULL); PutWindowTilemap(sTutorMoveAndElevatorWindowId); - CopyWindowToVram(sTutorMoveAndElevatorWindowId, 3); + CopyWindowToVram(sTutorMoveAndElevatorWindowId, COPYWIN_FULL); } void CloseDeptStoreElevatorWindow(void) @@ -2653,7 +2653,7 @@ static void InitScrollableMultichoice(void) gScrollableMultichoice_ListMenuTemplate.lettersSpacing = 0; gScrollableMultichoice_ListMenuTemplate.itemVerticalPadding = 0; gScrollableMultichoice_ListMenuTemplate.scrollMultiple = 0; - gScrollableMultichoice_ListMenuTemplate.fontId = 1; + gScrollableMultichoice_ListMenuTemplate.fontId = FONT_NORMAL; gScrollableMultichoice_ListMenuTemplate.cursorKind = 0; } @@ -2723,7 +2723,7 @@ static void CloseScrollableMultichoice(u8 taskId) Free(sScrollableMultichoice_ListMenuItem); ClearStdWindowAndFrameToTransparent(task->tWindowId, 1); FillWindowPixelBuffer(task->tWindowId, PIXEL_FILL(0)); - CopyWindowToVram(task->tWindowId, 2); + CopyWindowToVram(task->tWindowId, COPYWIN_GFX); RemoveWindow(task->tWindowId); DestroyTask(taskId); EnableBothScriptContexts(); @@ -2957,8 +2957,8 @@ void UpdateBattlePointsWindow(void) u8 string[32]; u32 x; StringCopy(ConvertIntToDecimalStringN(string, gSaveBlock2Ptr->frontier.battlePoints, STR_CONV_MODE_RIGHT_ALIGN, 4), gText_BP); - x = GetStringRightAlignXOffset(1, string, 48); - AddTextPrinterParameterized(sBattlePointsWindowId, 1, string, x, 1, 0, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, string, 48); + AddTextPrinterParameterized(sBattlePointsWindowId, FONT_NORMAL, string, x, 1, 0, NULL); } void ShowBattlePointsWindow(void) @@ -2976,7 +2976,7 @@ void ShowBattlePointsWindow(void) sBattlePointsWindowId = AddWindow(&sBattlePoints_WindowTemplate); SetStandardWindowBorderStyle(sBattlePointsWindowId, 0); UpdateBattlePointsWindow(); - CopyWindowToVram(sBattlePointsWindowId, 2); + CopyWindowToVram(sBattlePointsWindowId, COPYWIN_GFX); } void CloseBattlePointsWindow(void) @@ -2988,25 +2988,17 @@ void CloseBattlePointsWindow(void) void TakeFrontierBattlePoints(void) { if (gSaveBlock2Ptr->frontier.battlePoints < gSpecialVar_0x8004) - { gSaveBlock2Ptr->frontier.battlePoints = 0; - } else - { gSaveBlock2Ptr->frontier.battlePoints -= gSpecialVar_0x8004; - } } void GiveFrontierBattlePoints(void) { if (gSaveBlock2Ptr->frontier.battlePoints + gSpecialVar_0x8004 > MAX_BATTLE_FRONTIER_POINTS) - { gSaveBlock2Ptr->frontier.battlePoints = MAX_BATTLE_FRONTIER_POINTS; - } else - { gSaveBlock2Ptr->frontier.battlePoints = gSaveBlock2Ptr->frontier.battlePoints + gSpecialVar_0x8004; - } } u16 GetFrontierBattlePoints(void) @@ -3028,7 +3020,7 @@ void ShowFrontierExchangeCornerItemIconWindow(void) sFrontierExchangeCorner_ItemIconWindowId = AddWindow(&sFrontierExchangeCorner_ItemIconWindowTemplate); SetStandardWindowBorderStyle(sFrontierExchangeCorner_ItemIconWindowId, 0); - CopyWindowToVram(sFrontierExchangeCorner_ItemIconWindowId, 2); + CopyWindowToVram(sFrontierExchangeCorner_ItemIconWindowId, COPYWIN_GFX); } void CloseFrontierExchangeCornerItemIconWindow(void) @@ -3047,7 +3039,7 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection) switch (menu) { case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_1: - AddTextPrinterParameterized2(0, 1, sFrontierExchangeCorner_Decor1Descriptions[selection], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sFrontierExchangeCorner_Decor1Descriptions[selection], 0, NULL, 2, 1, 3); if (sFrontierExchangeCorner_Decor1[selection] == 0xFFFF) { ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor1[selection]); @@ -3060,7 +3052,7 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection) } break; case SCROLL_MULTI_BF_EXCHANGE_CORNER_DECOR_VENDOR_2: - AddTextPrinterParameterized2(0, 1, sFrontierExchangeCorner_Decor2Descriptions[selection], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sFrontierExchangeCorner_Decor2Descriptions[selection], 0, NULL, 2, 1, 3); if (sFrontierExchangeCorner_Decor2[selection] == 0xFFFF) { ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Decor2[selection]); @@ -3073,11 +3065,11 @@ static void FillFrontierExchangeCornerWindowAndItemIcon(u16 menu, u16 selection) } break; case SCROLL_MULTI_BF_EXCHANGE_CORNER_VITAMIN_VENDOR: - AddTextPrinterParameterized2(0, 1, sFrontierExchangeCorner_VitaminsDescriptions[selection], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sFrontierExchangeCorner_VitaminsDescriptions[selection], 0, NULL, 2, 1, 3); ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_Vitamins[selection]); break; case SCROLL_MULTI_BF_EXCHANGE_CORNER_HOLD_ITEM_VENDOR: - AddTextPrinterParameterized2(0, 1, sFrontierExchangeCorner_HoldItemsDescriptions[selection], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sFrontierExchangeCorner_HoldItemsDescriptions[selection], 0, NULL, 2, 1, 3); ShowFrontierExchangeCornerItemIcon(sFrontierExchangeCorner_HoldItems[selection]); break; } @@ -3216,11 +3208,11 @@ static void ShowBattleFrontierTutorMoveDescription(u8 menu, u16 selection) FillWindowPixelRect(sTutorMoveAndElevatorWindowId, PIXEL_FILL(1), 0, 0, 96, 48); if (menu == SCROLL_MULTI_BF_MOVE_TUTOR_2) { - AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, 1, sBattleFrontier_TutorMoveDescriptions2[selection], 0, 1, 0, NULL); + AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, FONT_NORMAL, sBattleFrontier_TutorMoveDescriptions2[selection], 0, 1, 0, NULL); } else { - AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, 1, sBattleFrontier_TutorMoveDescriptions1[selection], 0, 1, 0, NULL); + AddTextPrinterParameterized(sTutorMoveAndElevatorWindowId, FONT_NORMAL, sBattleFrontier_TutorMoveDescriptions1[selection], 0, 1, 0, NULL); } } } @@ -3244,11 +3236,11 @@ void ScrollableMultichoice_RedrawPersistentMenu(void) SetStandardWindowBorderStyle(task->tWindowId, 0); for (i = 0; i < MAX_SCROLL_MULTI_ON_SCREEN; i++) - AddTextPrinterParameterized5(task->tWindowId, 1, sScrollableMultichoiceOptions[gSpecialVar_0x8004][scrollOffset + i], 10, i * 16, TEXT_SPEED_FF, NULL, 0, 0); + AddTextPrinterParameterized5(task->tWindowId, FONT_NORMAL, sScrollableMultichoiceOptions[gSpecialVar_0x8004][scrollOffset + i], 10, i * 16, TEXT_SKIP_DRAW, NULL, 0, 0); - AddTextPrinterParameterized(task->tWindowId, 1, gText_SelectorArrow, 0, selectedRow * 16, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(task->tWindowId, FONT_NORMAL, gText_SelectorArrow, 0, selectedRow * 16, TEXT_SKIP_DRAW, NULL); PutWindowTilemap(task->tWindowId); - CopyWindowToVram(task->tWindowId, 3); + CopyWindowToVram(task->tWindowId, COPYWIN_FULL); } } @@ -3303,7 +3295,7 @@ void ScrollableMultichoice_ClosePersistentMenu(void) ClearStdWindowAndFrameToTransparent(task->tWindowId, TRUE); FillWindowPixelBuffer(task->tWindowId, PIXEL_FILL(0)); ClearWindowTilemap(task->tWindowId); - CopyWindowToVram(task->tWindowId, 2); + CopyWindowToVram(task->tWindowId, COPYWIN_GFX); RemoveWindow(task->tWindowId); DestroyTask(taskId); } diff --git a/src/field_weather.c b/src/field_weather.c index c067e8ebd..cd3436441 100644 --- a/src/field_weather.c +++ b/src/field_weather.c @@ -719,7 +719,7 @@ void ApplyWeatherGammaShiftIfIdle(s8 gammaIndex) } } -void sub_80ABC7C(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay) +void ApplyWeatherGammaShiftIfIdle_Gradual(u8 gammaIndex, u8 gammaTargetIndex, u8 gammaStepDelay) { if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE) { @@ -779,7 +779,7 @@ void FadeScreen(u8 mode, s8 delay) if (fadeOut) { if (useWeatherPal) - CpuFastCopy(gPlttBufferFaded, gPlttBufferUnfaded, 0x400); + CpuFastCopy(gPlttBufferFaded, gPlttBufferUnfaded, PLTT_BUFFER_SIZE * 2); BeginNormalPaletteFade(PALETTES_ALL, delay, 0, 16, fadeColor); gWeatherPtr->palProcessingState = WEATHER_PAL_STATE_SCREEN_FADING_OUT; diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c index 27ade478f..5720363c2 100644 --- a/src/field_weather_effect.c +++ b/src/field_weather_effect.c @@ -1181,7 +1181,7 @@ void Thunderstorm_Main(void) case TSTORM_STATE_FADE_THUNDER_LONG: if (--gWeatherPtr->thunderDelay == 0) { - sub_80ABC7C(19, 3, 5); + ApplyWeatherGammaShiftIfIdle_Gradual(19, 3, 5); gWeatherPtr->initStep++; } break; diff --git a/src/fonts.c b/src/fonts.c new file mode 100644 index 000000000..df904baca --- /dev/null +++ b/src/fonts.c @@ -0,0 +1,292 @@ +#include "global.h" + +ALIGNED(4) const u16 gFontSmallNarrowLatinGlyphs[] = INCBIN_U16("graphics/fonts/small_narrow.latfont"); +ALIGNED(4) const u8 gFontSmallNarrowLatinGlyphWidths[] = { + 3, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 3, 4, 5, 5, 5, 5, 4, 3, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 6, 3, + 3, 3, 3, 3, 8, 0, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 5, 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 3, 4, + 3, 3, 3, 3, 3, 3, 3, 5, 3, 8, 8, 8, 8, 1, 2, 3, + 4, 5, 6, 7, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 7, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 3, 5, 5, + 5, 5, 5, 3, 3, 5, 5, 5, 3, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 5, + 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 7, + 3, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3, +}; + +ALIGNED(4) const u16 gFontSmallLatinGlyphs[] = INCBIN_U16("graphics/fonts/small.latfont"); +ALIGNED(4) const u8 gFontSmallLatinGlyphWidths[] = { + 3, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 3, 5, 5, 5, 5, 5, 4, 3, + 4, 4, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 8, 7, 8, 3, + 3, 3, 3, 3, 8, 8, 7, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 5, 5, 5, 8, 8, 8, 8, 8, 8, 8, 4, 7, 5, 5, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 3, 4, + 3, 3, 3, 3, 3, 3, 3, 5, 3, 8, 8, 8, 8, 1, 2, 3, + 4, 5, 6, 7, 5, 7, 7, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 8, 5, 8, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, + 7, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3, +}; + +ALIGNED(4) const u16 gFontNarrowLatinGlyphs[] = INCBIN_U16("graphics/fonts/narrow.latfont"); +ALIGNED(4) const u8 gFontNarrowLatinGlyphWidths[] = { + 3, 5, 5, 5, 5, 5, 5, 5, 5, 4, 3, 4, 4, 5, 5, 5, + 8, 5, 5, 5, 5, 6, 5, 5, 3, 5, 5, 5, 5, 5, 4, 3, + 4, 4, 5, 5, 5, 8, 5, 5, 5, 5, 5, 6, 9, 6, 6, 3, + 3, 3, 3, 3, 8, 8, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 5, 5, 4, 8, 8, 8, 7, 8, 8, 4, 4, 6, 4, 4, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 3, 3, 4, + 3, 3, 3, 3, 3, 3, 3, 5, 3, 7, 7, 7, 7, 1, 2, 3, + 4, 5, 6, 7, 5, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 3, 5, 3, + 5, 5, 5, 3, 3, 5, 5, 6, 3, 6, 6, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, + 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, + 3, 5, 5, 5, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 10, 10, 10, 10, 8, 8, 10, 8, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3, +}; + +ALIGNED(4) const u16 gFontShortLatinGlyphs[] = INCBIN_U16("graphics/fonts/short.latfont"); +ALIGNED(4) const u8 gFontShortLatinGlyphWidths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 6, 6, 6, 6, + 8, 6, 6, 6, 6, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 3, + 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 6, 9, 8, 8, 3, + 3, 3, 3, 3, 10, 8, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 6, 6, 6, 8, 8, 8, 8, 8, 8, 4, 6, 8, 5, 5, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 6, 3, 3, 3, 3, 3, 3, 6, + 3, 3, 3, 3, 3, 3, 3, 6, 3, 12, 12, 12, 12, 1, 2, 3, + 4, 5, 6, 7, 8, 8, 8, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 5, + 6, 6, 6, 3, 3, 6, 6, 8, 5, 9, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 4, 6, 5, + 5, 6, 5, 6, 6, 6, 5, 5, 5, 6, 6, 6, 6, 6, 6, 8, + 5, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 12, 12, 12, 12, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3, +}; + +ALIGNED(4) const u16 gFontNormalLatinGlyphs[] = INCBIN_U16("graphics/fonts/normal.latfont"); +ALIGNED(4) const u8 gFontNormalLatinGlyphWidths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 6, 6, 6, 6, + 8, 6, 6, 6, 6, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 3, + 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 6, 9, 7, 6, 3, + 3, 3, 3, 3, 10, 8, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 6, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 6, 3, 3, 3, 3, 3, 3, 6, + 3, 3, 3, 3, 3, 3, 3, 6, 3, 7, 7, 7, 7, 1, 2, 3, + 4, 5, 6, 7, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 6, 3, 6, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 7, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 4, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 8, + 3, 6, 6, 6, 6, 6, 6, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 10, 10, 10, 10, 8, 10, 10, 8, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 3, +}; + +ALIGNED(4) const u16 gFontSmallJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/small.hwjpnfont"); +ALIGNED(4) const u16 gFontNormalJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/normal.hwjpnfont"); + +ALIGNED(4) const u16 gFontFRLGMaleJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/frlg_male.fwjpnfont"); +ALIGNED(4) const u8 gFontFRLGMaleJapaneseGlyphWidths[] = { + 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, + 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 9, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 5, 9, 10, 10, 10, + 8, 10, 10, 10, 10, 8, 8, 8, 10, 10, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 2, 4, 6, + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 5, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, +}; + +ALIGNED(4) const u16 gFontFRLGFemaleJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/frlg_female.fwjpnfont"); +ALIGNED(4) const u8 gFontFRLGFemaleJapaneseGlyphWidths[] = { + 0, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, + 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, + 9, 9, 9, 9, 9, 9, 8, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 9, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 5, 9, 10, 10, 10, + 8, 10, 10, 10, 10, 8, 8, 8, 10, 10, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 2, 4, 6, + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 5, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, +}; + +ALIGNED(4) const u16 gFontShortJapaneseGlyphs[] = INCBIN_U16("graphics/fonts/short.fwjpnfont"); +ALIGNED(4) const u8 gFontShortJapaneseGlyphWidths[] = { + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, + 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 9, + 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 5, 9, 10, 10, 10, + 8, 10, 10, 10, 10, 8, 8, 8, 10, 10, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 5, 6, 6, 2, 4, 6, + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 5, 6, 6, 6, 6, 6, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, + 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, +}; diff --git a/src/frontier_pass.c b/src/frontier_pass.c index 53bd68eac..8ce1e14dc 100644 --- a/src/frontier_pass.c +++ b/src/frontier_pass.c @@ -561,14 +561,14 @@ static void ResetGpuRegsAndBgs(void) SetGpuReg(REG_OFFSET_BG2CNT, 0); SetGpuReg(REG_OFFSET_BG1CNT, 0); SetGpuReg(REG_OFFSET_BG0CNT, 0); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_BLDCNT, 0); SetGpuReg(REG_OFFSET_BLDY, 0); SetGpuReg(REG_OFFSET_BLDALPHA, 0); @@ -1150,23 +1150,23 @@ static void ShowAndPrintWindows(void) FillWindowPixelBuffer(i, PIXEL_FILL(0)); } - x = GetStringCenterAlignXOffset(1, gText_SymbolsEarned, 96); - AddTextPrinterParameterized3(WINDOW_EARNED_SYMBOLS, 1, x, 5, sTextColors[0], 0, gText_SymbolsEarned); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gText_SymbolsEarned, 96); + AddTextPrinterParameterized3(WINDOW_EARNED_SYMBOLS, FONT_NORMAL, x, 5, sTextColors[0], 0, gText_SymbolsEarned); - x = GetStringCenterAlignXOffset(1, gText_BattleRecord, 96); - AddTextPrinterParameterized3(WINDOW_BATTLE_RECORD, 1, x, 5, sTextColors[0], 0, gText_BattleRecord); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gText_BattleRecord, 96); + AddTextPrinterParameterized3(WINDOW_BATTLE_RECORD, FONT_NORMAL, x, 5, sTextColors[0], 0, gText_BattleRecord); - AddTextPrinterParameterized3(WINDOW_BATTLE_POINTS, 8, 5, 4, sTextColors[0], 0, gText_BattlePoints); + AddTextPrinterParameterized3(WINDOW_BATTLE_POINTS, FONT_SMALL_NARROW, 5, 4, sTextColors[0], 0, gText_BattlePoints); ConvertIntToDecimalStringN(gStringVar4, sPassData->battlePoints, STR_CONV_MODE_LEFT_ALIGN, 5); - x = GetStringRightAlignXOffset(8, gStringVar4, 91); - AddTextPrinterParameterized3(WINDOW_BATTLE_POINTS, 8, x, 16, sTextColors[0], 0, gStringVar4); + x = GetStringRightAlignXOffset(FONT_SMALL_NARROW, gStringVar4, 91); + AddTextPrinterParameterized3(WINDOW_BATTLE_POINTS, FONT_SMALL_NARROW, x, 16, sTextColors[0], 0, gStringVar4); sPassData->cursorArea = GetCursorAreaFromCoords(sPassData->cursorX - 5, sPassData->cursorY + 5); sPassData->previousCursorArea = CURSOR_AREA_NOTHING; PrintAreaDescription(sPassData->cursorArea); for (i = 0; i < WINDOW_COUNT; i++) - CopyWindowToVram(i, 3); + CopyWindowToVram(i, COPYWIN_FULL); CopyBgTilemapBufferToVram(0); } @@ -1176,11 +1176,11 @@ static void PrintAreaDescription(u8 cursorArea) FillWindowPixelBuffer(WINDOW_DESCRIPTION, PIXEL_FILL(0)); if (cursorArea == CURSOR_AREA_RECORD && !sPassData->hasBattleRecord) - AddTextPrinterParameterized3(WINDOW_DESCRIPTION, 1, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[CURSOR_AREA_NOTHING]); + AddTextPrinterParameterized3(WINDOW_DESCRIPTION, FONT_NORMAL, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[CURSOR_AREA_NOTHING]); else if (cursorArea != CURSOR_AREA_NOTHING) - AddTextPrinterParameterized3(WINDOW_DESCRIPTION, 1, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[cursorArea]); + AddTextPrinterParameterized3(WINDOW_DESCRIPTION, FONT_NORMAL, 2, 0, sTextColors[1], 0, sPassAreaDescriptions[cursorArea]); - CopyWindowToVram(WINDOW_DESCRIPTION, 3); + CopyWindowToVram(WINDOW_DESCRIPTION, COPYWIN_FULL); CopyBgTilemapBufferToVram(0); } @@ -1715,15 +1715,15 @@ static void PrintOnFrontierMap(void) for (i = 0; i < NUM_FRONTIER_FACILITIES; i++) { if (i == sMapData->cursorPos) - AddTextPrinterParameterized3(MAP_WINDOW_NAME, 7, 4, (i * 16) + 1, sTextColors[2], 0, sMapLandmarks[i].name); + AddTextPrinterParameterized3(MAP_WINDOW_NAME, FONT_NARROW, 4, (i * 16) + 1, sTextColors[2], 0, sMapLandmarks[i].name); else - AddTextPrinterParameterized3(MAP_WINDOW_NAME, 7, 4, (i * 16) + 1, sTextColors[1], 0, sMapLandmarks[i].name); + AddTextPrinterParameterized3(MAP_WINDOW_NAME, FONT_NARROW, 4, (i * 16) + 1, sTextColors[1], 0, sMapLandmarks[i].name); } - AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, 1, 4, 0, sTextColors[0], 0, sMapLandmarks[sMapData->cursorPos].description); + AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, FONT_NORMAL, 4, 0, sTextColors[0], 0, sMapLandmarks[sMapData->cursorPos].description); for (i = 0; i < MAP_WINDOW_COUNT; i++) - CopyWindowToVram(i, 3); + CopyWindowToVram(i, COPYWIN_FULL); CopyBgTilemapBufferToVram(0); } @@ -1743,8 +1743,8 @@ static void HandleFrontierMapCursorMove(u8 direction) sMapData->cursorPos = (oldCursorPos + 1) % NUM_FRONTIER_FACILITIES; } - AddTextPrinterParameterized3(MAP_WINDOW_NAME, 7, 4, (oldCursorPos * 16) + 1, sTextColors[1], 0, sMapLandmarks[oldCursorPos].name); - AddTextPrinterParameterized3(MAP_WINDOW_NAME, 7, 4, (sMapData->cursorPos * 16) + 1, sTextColors[2], 0, sMapLandmarks[sMapData->cursorPos].name); + AddTextPrinterParameterized3(MAP_WINDOW_NAME, FONT_NARROW, 4, (oldCursorPos * 16) + 1, sTextColors[1], 0, sMapLandmarks[oldCursorPos].name); + AddTextPrinterParameterized3(MAP_WINDOW_NAME, FONT_NARROW, 4, (sMapData->cursorPos * 16) + 1, sTextColors[2], 0, sMapLandmarks[sMapData->cursorPos].name); sMapData->cursorSprite->y = (sMapData->cursorPos * 16) + 8; @@ -1752,10 +1752,10 @@ static void HandleFrontierMapCursorMove(u8 direction) sMapData->mapIndicatorSprite->x = sMapLandmarks[sMapData->cursorPos].x; sMapData->mapIndicatorSprite->y = sMapLandmarks[sMapData->cursorPos].y; FillWindowPixelBuffer(MAP_WINDOW_DESCRIPTION, PIXEL_FILL(0)); - AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, 1, 4, 0, sTextColors[0], 0, sMapLandmarks[sMapData->cursorPos].description); + AddTextPrinterParameterized3(MAP_WINDOW_DESCRIPTION, FONT_NORMAL, 4, 0, sTextColors[0], 0, sMapLandmarks[sMapData->cursorPos].description); for (i = 0; i < MAP_WINDOW_COUNT; i++) - CopyWindowToVram(i, 3); + CopyWindowToVram(i, COPYWIN_FULL); CopyBgTilemapBufferToVram(0); PlaySE(SE_DEX_SCROLL); diff --git a/src/frontier_util.c b/src/frontier_util.c index ec3eba43a..03d7b0cb5 100644 --- a/src/frontier_util.c +++ b/src/frontier_util.c @@ -958,9 +958,9 @@ static bool8 IsWinStreakActive(u32 challenge) static void PrintAligned(const u8 *str, s32 y) { - s32 x = GetStringCenterAlignXOffset(1, str, 224); + s32 x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 224); y = (y * 8) + 1; - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x, y, TEXT_SKIP_DRAW, NULL); } static void PrintHyphens(s32 y) @@ -973,18 +973,18 @@ static void PrintHyphens(s32 y) text[i] = EOS; y = (y * 8) + 1; - AddTextPrinterParameterized(gRecordsWindowId, 1, text, 4, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, text, 4, y, TEXT_SKIP_DRAW, NULL); } // Battle Tower records. static void TowerPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) { - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x1, y, TEXT_SKIP_DRAW, NULL); if (num > MAX_STREAK) num = MAX_STREAK; ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, gText_WinStreak); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x2, y, TEXT_SKIP_DRAW, NULL); } static void TowerPrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) @@ -1056,15 +1056,15 @@ static void ShowTowerResultsWindow(u8 battleMode) StringExpandPlaceholders(gStringVar4, gText_LinkMultiBattleRoomResults); PrintAligned(gStringVar4, 2); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 16, 49, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 16, 97, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Lv502, 16, 49, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_OpenLv, 16, 97, TEXT_SKIP_DRAW, NULL); PrintHyphens(10); TowerPrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_50, 72, 132, 49); TowerPrintRecordStreak(battleMode, FRONTIER_LVL_50, 72, 132, 65); TowerPrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_OPEN, 72, 132, 97); TowerPrintRecordStreak(battleMode, FRONTIER_LVL_OPEN, 72, 132, 113); PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } // Battle Dome records. @@ -1079,10 +1079,10 @@ static u16 DomeGetWinStreak(u8 battleMode, u8 lvlMode) static void PrintTwoStrings(const u8 *str1, const u8 *str2, u16 num, u8 x1, u8 x2, u8 y) { - AddTextPrinterParameterized(gRecordsWindowId, 1, str1, x1, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str1, x1, y, TEXT_SKIP_DRAW, NULL); ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, str2); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x2, y, TEXT_SKIP_DRAW, NULL); } static void DomePrintPrevOrCurrentStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) @@ -1123,8 +1123,8 @@ static void ShowDomeResultsWindow(u8 battleMode) StringExpandPlaceholders(gStringVar4, gText_DoubleBattleTourneyResults); PrintAligned(gStringVar4, 0); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 8, 33, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 8, 97, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Lv502, 8, 33, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_OpenLv, 8, 97, TEXT_SKIP_DRAW, NULL); PrintHyphens(10); DomePrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_50, 64, 121, 33); PrintTwoStrings(gText_Record, gText_ClearStreak, gSaveBlock2Ptr->frontier.domeRecordWinStreaks[battleMode][FRONTIER_LVL_50], 64, 121, 49); @@ -1133,18 +1133,18 @@ static void ShowDomeResultsWindow(u8 battleMode) PrintTwoStrings(gText_Record, gText_ClearStreak, gSaveBlock2Ptr->frontier.domeRecordWinStreaks[battleMode][FRONTIER_LVL_OPEN], 64, 121, 113); PrintTwoStrings(gText_Total, gText_Championships, gSaveBlock2Ptr->frontier.domeTotalChampionships[battleMode][FRONTIER_LVL_OPEN], 64, 112, 129); PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } // Battle Palace records. static void PalacePrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) { - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x1, y, TEXT_SKIP_DRAW, NULL); if (num > MAX_STREAK) num = MAX_STREAK; ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, gText_WinStreak); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x2, y, TEXT_SKIP_DRAW, NULL); } static void PalacePrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 y) @@ -1199,15 +1199,15 @@ static void ShowPalaceResultsWindow(u8 battleMode) StringExpandPlaceholders(gStringVar4, gText_DoubleBattleHallResults); PrintAligned(gStringVar4, 2); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 16, 49, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 16, 97, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Lv502, 16, 49, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_OpenLv, 16, 97, TEXT_SKIP_DRAW, NULL); PrintHyphens(10); PalacePrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_50, 72, 131, 49); PalacePrintRecordStreak(battleMode, FRONTIER_LVL_50, 72, 131, 65); PalacePrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_OPEN, 72, 131, 97); PalacePrintRecordStreak(battleMode, FRONTIER_LVL_OPEN, 72, 131, 113); PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } // Battle Pike records. @@ -1222,10 +1222,10 @@ static u16 PikeGetWinStreak(u8 lvlMode) static void PikePrintCleared(const u8 *str1, const u8 *str2, u16 num, u8 x1, u8 x2, u8 y) { - AddTextPrinterParameterized(gRecordsWindowId, 1, str1, x1, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str1, x1, y, TEXT_SKIP_DRAW, NULL); ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, str2); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x2, y, TEXT_SKIP_DRAW, NULL); } static void PikePrintPrevOrCurrentStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) @@ -1251,8 +1251,8 @@ static void ShowPikeResultsWindow(void) FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1)); StringExpandPlaceholders(gStringVar4, gText_BattleChoiceResults); PrintAligned(gStringVar4, 0); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 8, 33, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 8, 97, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Lv502, 8, 33, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_OpenLv, 8, 97, TEXT_SKIP_DRAW, NULL); PrintHyphens(10); PikePrintPrevOrCurrentStreak(FRONTIER_LVL_50, 64, 114, 33); PikePrintCleared(gText_Record, gText_RoomsCleared, gSaveBlock2Ptr->frontier.pikeRecordStreaks[FRONTIER_LVL_50], 64, 114, 49); @@ -1261,18 +1261,18 @@ static void ShowPikeResultsWindow(void) PikePrintCleared(gText_Record, gText_RoomsCleared, gSaveBlock2Ptr->frontier.pikeRecordStreaks[FRONTIER_LVL_OPEN], 64, 114, 113); PikePrintCleared(gText_Total, gText_TimesCleared, gSaveBlock2Ptr->frontier.pikeTotalStreaks[FRONTIER_LVL_OPEN], 64, 114, 129); PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } // Battle Arena records. static void ArenaPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) { - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x1, y, TEXT_SKIP_DRAW, NULL); if (num > MAX_STREAK) num = MAX_STREAK; ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, gText_KOsInARow); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x2, y, TEXT_SKIP_DRAW, NULL); } static void ArenaPrintRecordStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) @@ -1314,29 +1314,29 @@ static void ShowArenaResultsWindow(void) PrintHyphens(10); StringExpandPlaceholders(gStringVar4, gText_SetKOTourneyResults); PrintAligned(gStringVar4, 2); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 16, 49, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 16, 97, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Lv502, 16, 49, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_OpenLv, 16, 97, TEXT_SKIP_DRAW, NULL); ArenaPrintPrevOrCurrentStreak(FRONTIER_LVL_50, 72, 126, 49); ArenaPrintRecordStreak(FRONTIER_LVL_50, 72, 126, 65); ArenaPrintPrevOrCurrentStreak(FRONTIER_LVL_OPEN, 72, 126, 97); ArenaPrintRecordStreak(FRONTIER_LVL_OPEN, 72, 126, 113); PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } // Battle Factory records. static void FactoryPrintStreak(const u8 *str, u16 num1, u16 num2, u8 x1, u8 x2, u8 x3, u8 y) { - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x1, y, TEXT_SKIP_DRAW, NULL); if (num1 > MAX_STREAK) num1 = MAX_STREAK; ConvertIntToDecimalStringN(gStringVar1, num1, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, gText_WinStreak); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x2, y, TEXT_SKIP_DRAW, NULL); ConvertIntToDecimalStringN(gStringVar1, num2, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, gText_TimesVar1); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x3, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x3, y, TEXT_SKIP_DRAW, NULL); } static void FactoryPrintRecordStreak(u8 battleMode, u8 lvlMode, u8 x1, u8 x2, u8 x3, u8 y) @@ -1403,27 +1403,27 @@ static void ShowFactoryResultsWindow(u8 battleMode) StringExpandPlaceholders(gStringVar4, gText_BattleSwapDoubleResults); PrintAligned(gStringVar4, 0); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 8, 33, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_RentalSwap, 152, 33, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 8, 97, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Lv502, 8, 33, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_RentalSwap, 152, 33, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_OpenLv, 8, 97, TEXT_SKIP_DRAW, NULL); PrintHyphens(10); FactoryPrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_50, 8, 64, 158, 49); FactoryPrintRecordStreak(battleMode, FRONTIER_LVL_50, 8, 64, 158, 65); FactoryPrintPrevOrCurrentStreak(battleMode, FRONTIER_LVL_OPEN, 8, 64, 158, 113); FactoryPrintRecordStreak(battleMode, FRONTIER_LVL_OPEN, 8, 64, 158, 129); PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } // Battle Pyramid records. static void PyramidPrintStreak(const u8 *str, u16 num, u8 x1, u8 x2, u8 y) { - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x1, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x1, y, TEXT_SKIP_DRAW, NULL); if (num > MAX_STREAK) num = MAX_STREAK; ConvertIntToDecimalStringN(gStringVar1, num, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, gText_FloorsCleared); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x2, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x2, y, TEXT_SKIP_DRAW, NULL); } static void PyramidPrintRecordStreak(u8 lvlMode, u8 x1, u8 x2, u8 y) @@ -1464,15 +1464,15 @@ static void ShowPyramidResultsWindow(void) FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1)); StringExpandPlaceholders(gStringVar4, gText_BattleQuestResults); PrintAligned(gStringVar4, 2); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Lv502, 8, 49, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_OpenLv, 8, 97, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Lv502, 8, 49, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_OpenLv, 8, 97, TEXT_SKIP_DRAW, NULL); PrintHyphens(10); PyramidPrintPrevOrCurrentStreak(FRONTIER_LVL_50, 64, 111, 49); PyramidPrintRecordStreak(FRONTIER_LVL_50, 64, 111, 65); PyramidPrintPrevOrCurrentStreak(FRONTIER_LVL_OPEN, 64, 111, 97); PyramidPrintRecordStreak(FRONTIER_LVL_OPEN, 64, 111, 113); PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } // Link contest records. Why is it in this file? @@ -1487,43 +1487,43 @@ static void ShowLinkContestResultsWindow(void) FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1)); StringExpandPlaceholders(gStringVar4, gText_LinkContestResults); - x = GetStringCenterAlignXOffset(1, gStringVar4, 208); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, x, 1, TEXT_SPEED_FF, NULL); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 208); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, x, 1, TEXT_SKIP_DRAW, NULL); str = gText_1st; - x = GetStringRightAlignXOffset(1, str, 38) + 50; - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, 25, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, str, 38) + 50; + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x, 25, TEXT_SKIP_DRAW, NULL); str = gText_2nd; - x = GetStringRightAlignXOffset(1, str, 38) + 88; - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, 25, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, str, 38) + 88; + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x, 25, TEXT_SKIP_DRAW, NULL); str = gText_3rd; - x = GetStringRightAlignXOffset(1, str, 38) + 126; - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, 25, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, str, 38) + 126; + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x, 25, TEXT_SKIP_DRAW, NULL); str = gText_4th; - x = GetStringRightAlignXOffset(1, str, 38) + 164; - AddTextPrinterParameterized(gRecordsWindowId, 1, str, x, 25, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, str, 38) + 164; + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, str, x, 25, TEXT_SKIP_DRAW, NULL); x = 6; - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Cool, x, 41, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Beauty, x, 57, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Cute, x, 73, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Smart, x, 89, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_Tough, x, 105, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Cool, x, 41, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Beauty, x, 57, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Cute, x, 73, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Smart, x, 89, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_Tough, x, 105, TEXT_SKIP_DRAW, NULL); for (i = 0; i < CONTEST_CATEGORIES_COUNT; i++) { for (j = 0; j < CONTESTANT_COUNT; j++) { ConvertIntToDecimalStringN(gStringVar4, gSaveBlock2Ptr->contestLinkResults[i][j], STR_CONV_MODE_RIGHT_ALIGN, 4); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, (j * 38) + 64, (i * 16) + 41, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, (j * 38) + 64, (i * 16) + 41, TEXT_SKIP_DRAW, NULL); } } PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } static void CheckPutFrontierTVShowOnAir(void) @@ -2224,18 +2224,18 @@ static void Print1PRecord(s32 position, s32 x, s32 y, struct RankingHall1P *hall u8 text[32]; u16 winStreak; - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_123Dot[position], x * 8, (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_123Dot[position], x * 8, (8 * (y + 5 * position)) + 1, TEXT_SKIP_DRAW, NULL); hallRecord->name[PLAYER_NAME_LENGTH] = EOS; if (hallRecord->winStreak) { TVShowConvertInternationalString(text, hallRecord->name, hallRecord->language); - AddTextPrinterParameterized(gRecordsWindowId, 1, text, (x + 2) * 8, (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, text, (x + 2) * 8, (8 * (y + 5 * position)) + 1, TEXT_SKIP_DRAW, NULL); winStreak = hallRecord->winStreak; if (winStreak > MAX_STREAK) winStreak = MAX_STREAK; ConvertIntToDecimalStringN(gStringVar2, winStreak, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, sHallFacilityToRecordsText[hallFacilityId]); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, GetStringRightAlignXOffset(1, sHallFacilityToRecordsText[hallFacilityId], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, GetStringRightAlignXOffset(FONT_NORMAL, sHallFacilityToRecordsText[hallFacilityId], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SKIP_DRAW, NULL); } } @@ -2244,25 +2244,25 @@ static void Print2PRecord(s32 position, s32 x, s32 y, struct RankingHall2P *hall u8 text[32]; u16 winStreak; - AddTextPrinterParameterized(gRecordsWindowId, 1, gText_123Dot[position], x * 8, (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gText_123Dot[position], x * 8, (8 * (y + 5 * position)) + 1, TEXT_SKIP_DRAW, NULL); if (hallRecord->winStreak) { hallRecord->name1[PLAYER_NAME_LENGTH] = EOS; hallRecord->name2[PLAYER_NAME_LENGTH] = EOS; TVShowConvertInternationalString(text, hallRecord->name1, hallRecord->language); - AddTextPrinterParameterized(gRecordsWindowId, 1, text, (x + 2) * 8, (8 * (y + 5 * position - 1)) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, text, (x + 2) * 8, (8 * (y + 5 * position - 1)) + 1, TEXT_SKIP_DRAW, NULL); if (IsStringJapanese(hallRecord->name2)) TVShowConvertInternationalString(text, hallRecord->name2, LANGUAGE_JAPANESE); else StringCopy(text, hallRecord->name2); - AddTextPrinterParameterized(gRecordsWindowId, 1, text, (x + 4) * 8, (8 * (y + 5 * position + 1)) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, text, (x + 4) * 8, (8 * (y + 5 * position + 1)) + 1, TEXT_SKIP_DRAW, NULL); winStreak = hallRecord->winStreak; if (winStreak > MAX_STREAK) winStreak = MAX_STREAK; ConvertIntToDecimalStringN(gStringVar2, winStreak, STR_CONV_MODE_RIGHT_ALIGN, 4); StringExpandPlaceholders(gStringVar4, sHallFacilityToRecordsText[RANKING_HALL_TOWER_LINK]); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, GetStringRightAlignXOffset(1, sHallFacilityToRecordsText[RANKING_HALL_TOWER_LINK], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, GetStringRightAlignXOffset(FONT_NORMAL, sHallFacilityToRecordsText[RANKING_HALL_TOWER_LINK], 0xC8), (8 * (y + 5 * position)) + 1, TEXT_SKIP_DRAW, NULL); } } @@ -2343,9 +2343,9 @@ static void PrintHallRecords(s32 hallFacilityId, s32 lvlMode) StringCopy(gStringVar1, sRecordsWindowChallengeTexts[hallFacilityId][0]); StringExpandPlaceholders(gStringVar4, sRecordsWindowChallengeTexts[hallFacilityId][1]); - AddTextPrinterParameterized(gRecordsWindowId, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); - x = GetStringRightAlignXOffset(1, sLevelModeText[lvlMode], 0xD0); - AddTextPrinterParameterized(gRecordsWindowId, 1, sLevelModeText[lvlMode], x, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, sLevelModeText[lvlMode], 0xD0); + AddTextPrinterParameterized(gRecordsWindowId, FONT_NORMAL, sLevelModeText[lvlMode], x, 1, TEXT_SKIP_DRAW, NULL); if (hallFacilityId == RANKING_HALL_TOWER_LINK) { gSaveBlock2Ptr->frontier.opponentNames[0][PLAYER_NAME_LENGTH] = EOS; @@ -2369,14 +2369,14 @@ void ShowRankingHallRecordsWindow(void) FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1)); PrintHallRecords(gSpecialVar_0x8005, FRONTIER_LVL_50); PutWindowTilemap(gRecordsWindowId); - CopyWindowToVram(gRecordsWindowId, 3); + CopyWindowToVram(gRecordsWindowId, COPYWIN_FULL); } void ScrollRankingHallRecordsWindow(void) { FillWindowPixelBuffer(gRecordsWindowId, PIXEL_FILL(1)); PrintHallRecords(gSpecialVar_0x8005, FRONTIER_LVL_OPEN); - CopyWindowToVram(gRecordsWindowId, 2); + CopyWindowToVram(gRecordsWindowId, COPYWIN_GFX); } void ClearRankingHallRecords(void) diff --git a/src/graphics.c b/src/graphics.c index 4e820caec..73825aebf 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -69,8 +69,7 @@ const u32 gBattleAnimSpriteGfx_BlackSmoke[] = INCBIN_U32("graphics/battle_anims/ const u32 gBattleAnimSpritePal_BlackSmoke[] = INCBIN_U32("graphics/battle_anims/sprites/black_smoke.gbapal.lz"); const u32 gBattleAnimSpriteGfx_BlackBall[] = INCBIN_U32("graphics/battle_anims/sprites/black_ball.4bpp.lz"); - -const u32 gUnknownGfx_C035B8[] = INCBIN_U32("graphics/unknown/unknown_C035B8.4bpp.lz"); +const u32 gBattleAnimSpritePal_BlackBall[] = INCBIN_U32("graphics/battle_anims/sprites/black_ball.bin"); const u32 gBattleAnimSpritePal_Glass[] = INCBIN_U32("graphics/battle_anims/sprites/glass.gbapal.lz"); const u32 gBattleAnimSpriteGfx_Glass[] = INCBIN_U32("graphics/battle_anims/sprites/glass.4bpp.lz"); @@ -81,9 +80,8 @@ const u32 gBattleAnimSpritePal_HornHit[] = INCBIN_U32("graphics/battle_anims/spr const u32 gBattleAnimSpritePal_BlueShards[] = INCBIN_U32("graphics/battle_anims/sprites/blue_shards.gbapal.lz"); const u32 gBattleAnimSpriteGfx_BlueShards[] = INCBIN_U32("graphics/battle_anims/sprites/blue_shards.4bpp.lz"); -const u32 gUnused_BattleSpritePalette_023[] = INCBIN_U32("graphics/unused/battle_anim_023.gbapal.lz"); - -const u32 gUnusedGfx_MusicNotes[] = INCBIN_U32("graphics/unused/music_notes.4bpp.lz"); +const u32 gBattleAnimUnusedPal_MusicNotes[] = INCBIN_U32("graphics/battle_anims/unused/music_notes.gbapal.lz"); +const u32 gBattleAnimUnusedGfx_MusicNotes[] = INCBIN_U32("graphics/battle_anims/unused/music_notes.4bpp.lz"); const u32 gBattleAnimSpritePal_Hit[] = INCBIN_U32("graphics/battle_anims/sprites/hit.gbapal.lz"); const u32 gBattleAnimSpriteGfx_Hit[] = INCBIN_U32("graphics/battle_anims/sprites/hit.4bpp.lz"); @@ -128,9 +126,9 @@ const u32 gBattleAnimSpriteGfx_Lightning2[] = INCBIN_U32("graphics/battle_anims/ const u32 gBattleAnimSpriteGfx_Lightning[] = INCBIN_U32("graphics/battle_anims/sprites/lightning.4bpp.lz"); -const u32 gUnknownGfx_C06D98[] = INCBIN_U32("graphics/unknown/unknown_C06D98.4bpp.lz"); -const u32 gUnknownPal_C06D98[] = INCBIN_U32("graphics/unknown/unknown_C06D98.gbapal.lz"); -const u32 gUnknownPal_C06D98_2[] = INCBIN_U32("graphics/unknown/unknown_C06D98_2.gbapal.lz"); +const u32 gBattleAnimSpriteGfx_SpinningBall[] = INCBIN_U32("graphics/battle_anims/unused/spinning_ball.4bpp.lz"); +const u32 gBattleAnimSpritePal_SpinningBall[] = INCBIN_U32("graphics/battle_anims/unused/spinning_ball.gbapal.lz"); +const u32 gBattleAnimSpritePal_SpinningBall2[] = INCBIN_U32("graphics/battle_anims/unused/spinning_ball_2.gbapal.lz"); // old battle interface data, unused @@ -164,18 +162,18 @@ const u32 gBattleAnimSpriteGfx_Glass2[] = INCBIN_U32("graphics/battle_anims/spri const u32 gBattleAnimSpritePal_PinkHeart2[] = INCBIN_U32("graphics/battle_anims/sprites/pink_heart_2.gbapal.lz"); const u32 gBattleAnimSpriteGfx_PinkHeart2[] = INCBIN_U32("graphics/battle_anims/sprites/pink_heart_2.4bpp.lz"); -const u32 gUnknown_08C08F0C[] = INCBIN_U32("graphics/battle_interface/unused_window.4bpp.lz"); -const u32 gUnknown_08C093C8[] = INCBIN_U32("graphics/battle_interface/unused_window.gbapal.lz"); +const u32 gBattleInterfaceGfx_UnusedWindow1[] = INCBIN_U32("graphics/battle_interface/unused_window.4bpp.lz"); +const u32 gBattleInterfacePal_UnusedWindow1[] = INCBIN_U32("graphics/battle_interface/unused_window.gbapal.lz"); -const u32 gUnknown_08C093F0[] = INCBIN_U32("graphics/interface/hp_numbers.4bpp.lz"); +const u32 gBattleInterfaceGfx_BattleBar[] = INCBIN_U32("graphics/interface/battle_bar.4bpp.lz"); const u32 gBattleAnimSpriteGfx_SapDrip[] = INCBIN_U32("graphics/battle_anims/sprites/sap_drip.4bpp.lz"); const u32 gBattleAnimSpritePal_SapDrip[] = INCBIN_U32("graphics/battle_anims/sprites/sap_drip.gbapal.lz"); const u32 gBattleAnimSpritePal_SapDrip2[] = INCBIN_U32("graphics/battle_anims/sprites/sap_drip_2.gbapal.lz"); -const u32 gUnusedGfx_Window2[] = INCBIN_U32("graphics/battle_interface/unused_window2.4bpp.lz"); -const u32 gUnusedGfx_Window2Bar[] = INCBIN_U32("graphics/battle_interface/unused_window2bar.4bpp.lz"); +const u32 gBattleInterfaceGfx_UnusedWindow2[] = INCBIN_U32("graphics/battle_interface/unused_window2.4bpp.lz"); +const u32 gBattleInterfaceGfx_UnusedWindow2Bar[] = INCBIN_U32("graphics/battle_interface/unused_window2bar.4bpp.lz"); const u32 gBattleAnimSpriteGfx_Sparkle1[] = INCBIN_U32("graphics/battle_anims/sprites/sparkle_1.4bpp.lz"); const u32 gBattleAnimSpritePal_Sparkle1[] = INCBIN_U32("graphics/battle_anims/sprites/sparkle_1.gbapal.lz"); @@ -187,8 +185,8 @@ const u32 gBattleAnimSpriteGfx_HumanoidFoot[] = INCBIN_U32("graphics/battle_anim const u32 gBattleAnimSpriteGfx_MonsterFoot[] = INCBIN_U32("graphics/battle_anims/sprites/monster_foot.4bpp.lz"); const u32 gBattleAnimSpriteGfx_HumanoidHand[] = INCBIN_U32("graphics/battle_anims/sprites/humanoid_hand.4bpp.lz"); -const u32 gUnusedGfx_LineSketch[] = INCBIN_U32("graphics/unused/line_sketch.4bpp.lz"); -const u32 gUnusedPal_LineSketch[] = INCBIN_U32("graphics/unused/line_sketch.gbapal.lz"); +const u32 gBattleAnimSpriteGfx_LineSketch[] = INCBIN_U32("graphics/battle_anims/unused/line_sketch.4bpp.lz"); +const u32 gBattleAnimSpritePal_LineSketch[] = INCBIN_U32("graphics/battle_anims/unused/line_sketch.gbapal.lz"); const u32 gBattleAnimSpriteGfx_YellowUnk[] = INCBIN_U32("graphics/battle_anims/sprites/yellow_unk.4bpp.lz"); const u32 gBattleAnimSpritePal_YellowUnk[] = INCBIN_U32("graphics/battle_anims/sprites/yellow_unk.gbapal.lz"); @@ -219,7 +217,7 @@ const u32 gBattleAnimSpritePal_SpinningGreenOrbs[] = INCBIN_U32("graphics/battle const u32 gBattleAnimSpriteGfx_Leaf[] = INCBIN_U32("graphics/battle_anims/sprites/leaf.4bpp.lz"); const u32 gBattleAnimSpritePal_Leaf[] = INCBIN_U32("graphics/battle_anims/sprites/leaf.gbapal.lz"); -const u32 gUnusedGfx_Metronome[] = INCBIN_U32("graphics/unused/metronome_hand_small.4bpp.lz"); // unused, was for metronome at one point +const u32 gBattleAnimSpriteGfx_MetronomeSmallHand[] = INCBIN_U32("graphics/battle_anims/unused/metronome_hand_small.4bpp.lz"); // unused, was for metronome at one point const u32 gBattleAnimSpritePal_Clapping[] = INCBIN_U32("graphics/battle_anims/sprites/clapping.gbapal.lz"); @@ -254,12 +252,13 @@ const u32 gBattleAnimSpritePal_Bell2[] = INCBIN_U32("graphics/battle_anims/sprit const u32 gBattleAnimSpriteGfx_PinkGlove[] = INCBIN_U32("graphics/battle_anims/sprites/pink_glove.4bpp.lz"); const u32 gBattleAnimSpritePal_PinkGlove[] = INCBIN_U32("graphics/battle_anims/sprites/pink_glove.gbapal.lz"); -const u16 gUnknown_C0CA1C[] = INCBIN_U16("graphics/unknown/unknown_C0CA1C.bin"); -const u16 gUnknown_C0CA40[] = INCBIN_U16("graphics/unknown/unknown_C0CA40.bin"); -const u16 gUnknown_C0CA64[] = INCBIN_U16("graphics/unknown/unknown_C0CA64.bin"); -const u32 gUnusedGfx8bpp_LineSketch2[] = INCBIN_U32("graphics/unused/line_sketch_2.8bpp.lz"); -const u16 gUnknown_C0CAE0[] = INCBIN_U16("graphics/unknown/unknown_C0CAE0.bin"); -const u32 gUnusedTilemap_LineSketch2[] = INCBIN_U32("graphics/unused/line_sketch_2.bin.lz"); +const u16 gBattleAnimUnused_Unknown1[] = INCBIN_U16("graphics/battle_anims/unused/unknown_1.bin"); +const u16 gBattleAnimUnused_Unknown2[] = INCBIN_U16("graphics/battle_anims/unused/unknown_2.bin"); +const u16 gBattleAnimUnused_Unknown3[] = INCBIN_U16("graphics/battle_anims/unused/unknown_3.bin"); + +const u32 gBattleAnimUnusedGfx_LineSketch2[] = INCBIN_U32("graphics/battle_anims/unused/line_sketch_2.8bpp.lz"); +const u16 gBattleAnimUnusedPal_LineSketch2[] = INCBIN_U16("graphics/battle_anims/unused/line_sketch_2_pal.bin"); +const u32 gBattleAnimUnusedTilemap_LineSketch2[] = INCBIN_U32("graphics/battle_anims/unused/line_sketch_2.bin.lz"); const u32 gBattleAnimSpriteGfx_BlueLines[] = INCBIN_U32("graphics/battle_anims/sprites/blue_lines.4bpp.lz"); const u32 gBattleAnimSpritePal_BlueLines[] = INCBIN_U32("graphics/battle_anims/sprites/blue_lines.gbapal.lz"); @@ -275,7 +274,7 @@ const u32 gBattleAnimSpritePal_RedTube[] = INCBIN_U32("graphics/battle_anims/spr const u32 gBattleAnimSpritePal_Amnesia[] = INCBIN_U32("graphics/battle_anims/sprites/amnesia.gbapal.lz"); const u32 gBattleAnimSpritePal_String2[] = INCBIN_U32("graphics/battle_anims/sprites/string_2.gbapal.lz"); -const u32 gUnknown_D0D2B4[] = INCBIN_U32("graphics/unknown/unknown_D0D2B4.bin.lz"); +const u32 gBattleAnimUnused_Unknown4[] = INCBIN_U32("graphics/battle_anims/unused/unknown_4.bin.lz"); const u32 gBattleAnimSpritePal_Pencil2[] = INCBIN_U32("graphics/battle_anims/sprites/pencil_2.gbapal.lz"); const u32 gBattleAnimSpritePal_Petal[] = INCBIN_U32("graphics/battle_anims/sprites/petal.gbapal.lz"); @@ -341,9 +340,9 @@ const u32 gUnusedPal_ColorFrames[] = INCBIN_U32("graphics/unused/color_frames.gb const u32 gBattleAnimSpriteGfx_RainDrops[] = INCBIN_U32("graphics/battle_anims/sprites/rain_drops.4bpp.lz"); -const u32 gUnusedGfx8bpp_WaterSplash [] = INCBIN_U32("graphics/unused/water_splash.8bpp.lz"); -const u32 gUnusedTilemap_WaterSplash[] = INCBIN_U32("graphics/unused/water_splash.bin.lz"); -const u32 gUnusedPalette_WaterSplash[] = INCBIN_U32("graphics/unused/water_splash.gbapal.lz"); +const u32 gBattleAnimUnusedGfx_WaterSplash[] = INCBIN_U32("graphics/battle_anims/unused/water_splash.8bpp.lz"); +const u32 gBattleAnimUnusedTilemap_WaterSplash[] = INCBIN_U32("graphics/battle_anims/unused/water_splash.bin.lz"); +const u32 gBattleAnimUnusedPal_WaterSplash[] = INCBIN_U32("graphics/battle_anims/unused/water_splash.gbapal.lz"); const u32 gUnusedGfx_BasicFrame[] = INCBIN_U32("graphics/unused/basic_frame.4bpp.lz"); const u32 gUnusedPal_BasicFrame[] = INCBIN_U32("graphics/unused/basic_frame.gbapal.lz"); @@ -434,39 +433,31 @@ const u32 gBattleAnimSpritePal_BlueFlames[] = INCBIN_U32("graphics/battle_anims/ const u32 gBattleAnimSpriteGfx_BlueFlames2[] = INCBIN_U32("graphics/battle_anims/sprites/blue_flames_2.4bpp.lz"); // Contest - -const u32 gUnusedGfx_OldContest[] = INCBIN_U32("graphics/unused/old_contest.4bpp.lz"); -const u32 gUnusedPal_OldContest[] = INCBIN_U32("graphics/unused/old_contest.gbapal.lz"); -const u32 gUnusedTilemap_OldContest[] = INCBIN_U32("graphics/unused/old_contest.bin.lz"); - -const u32 gUnknownTilemap_C15BC0[] = INCBIN_U32("graphics/unknown/unknown_C15BC0.bin.lz"); - -const u32 gUnusedGfx_OldContest2[] = INCBIN_U32("graphics/unused/old_contest_2.4bpp.lz"); -const u32 gOldContestPalette[] = INCBIN_U32("graphics/unused/old_contest_2.gbapal.lz"); -const u32 gOldContestGfx[] = INCBIN_U32("graphics/unused/old_contest_2.bin.lz"); - -const u32 gUnknown_08C17170[] = INCBIN_U32("graphics/unknown/unknown_C17170.bin.lz"); - -const u32 gUnknown_08C17410[] = INCBIN_U32("graphics/unknown/unknown_C17410.bin.lz"); - -const u32 gUnknown_08C1751C[] = INCBIN_U32("graphics/unknown/unknown_C1751C.bin.lz"); - -const u32 gUnknown_08C17980[] = INCBIN_U32("graphics/unknown/unknown_C17980.bin.lz"); - -const u32 gContestMiscGfx[] = INCBIN_U32("graphics/contest/misc.4bpp.lz"); - +const u32 gJPContestGfx1[] = INCBIN_U32("graphics/contest/japanese/composite_1.4bpp.lz"); +const u32 gJPContestPal[] = INCBIN_U32("graphics/contest/japanese/palette.gbapal.lz"); +const u32 gJPContestTilemap1[] = INCBIN_U32("graphics/contest/japanese/tilemap_1.bin.lz"); +const u32 gJPContestTilemap2[] = INCBIN_U32("graphics/contest/japanese/tilemap_2.bin.lz"); +const u32 gJPContestGfx2[] = INCBIN_U32("graphics/contest/japanese/composite_2.4bpp.lz"); + +const u32 gContestInterfaceAudiencePalette[] = INCBIN_U32("graphics/contest/interface_audience.gbapal.lz"); +const u32 gContestAudienceTilemap[] = INCBIN_U32("graphics/contest/audience.bin.lz"); +const u32 gContestInterfaceTilemap[] = INCBIN_U32("graphics/contest/interface.bin.lz"); +const u32 gContestUnusedTilemap1[] = INCBIN_U32("graphics/contest/unused_tilemap_1.bin.lz"); +const u32 gContestUnusedTilemap2[] = INCBIN_U32("graphics/contest/unused_tilemap_2.bin.lz"); +const u32 gContestCurtainTilemap[] = INCBIN_U32("graphics/contest/curtain.bin.lz"); + +const u32 gContestInterfaceGfx[] = INCBIN_U32("graphics/contest/interface.4bpp.lz"); const u32 gContestAudienceGfx[] = INCBIN_U32("graphics/contest/audience.4bpp.lz"); - const u32 gContestFaces_Gfx[] = INCBIN_U32("graphics/contest/faces.4bpp.lz"); - const u32 gContestJudgeSymbolsGfx[] = INCBIN_U32("graphics/contest/judge_symbols.4bpp.lz"); -const u32 gContest3Pal[] = INCBIN_U32("graphics/contest/judge_symbols.gbapal.lz"); - +const u32 gContestJudgeSymbolsPal[] = INCBIN_U32("graphics/contest/judge_symbols.gbapal.lz"); const u8 gContestSliderHeart_Gfx[] = INCBIN_U8("graphics/contest/slider_heart.4bpp"); -const u32 gUnknownGfx_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.4bpp.lz"); -const u32 gUnknownPal_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.gbapal.lz"); +// JP equivalent of the Applause meter +const u32 gJPContestVoltageGfx[] = INCBIN_U32("graphics/contest/japanese/voltage.4bpp.lz"); +const u32 gJPContestVoltagePal[] = INCBIN_U32("graphics/contest/japanese/voltage.gbapal.lz"); +// Contest results const u32 gContestResults_Gfx[] = INCBIN_U32("graphics/contest/results_screen/tiles.4bpp.lz"); const u32 gContestResults_WinnerBanner_Tilemap[] = INCBIN_U32("graphics/contest/results_screen/winner_banner.bin.lz"); const u32 gContestResults_Interface_Tilemap[] = INCBIN_U32("graphics/contest/results_screen/interface.bin.lz"); @@ -498,8 +489,8 @@ const u32 gBattleAnimSpritePal_IceCrystals[] = INCBIN_U32("graphics/battle_anims const u32 gBattleAnimSpriteGfx_IceSpikes[] = INCBIN_U32("graphics/battle_anims/sprites/ice_spikes.4bpp.lz"); -const u32 gUnusedGfx_OldBeatUp[] = INCBIN_U32("graphics/unused/old_beatup.4bpp.lz"); -const u32 gUnusedPal_OldBeatUp[] = INCBIN_U32("graphics/unused/old_beatup.gbapal.lz"); +const u32 gBattleAnimSpriteGfx_OldBeatUp[] = INCBIN_U32("graphics/battle_anims/unused/old_beatup.4bpp.lz"); +const u32 gBattleAnimSpritePal_OldBeatUp[] = INCBIN_U32("graphics/battle_anims/unused/old_beatup.gbapal.lz"); const u32 gBattleAnimSpriteGfx_Orbs[] = INCBIN_U32("graphics/battle_anims/sprites/orbs.4bpp.lz"); const u32 gBattleAnimSpritePal_Orbs[] = INCBIN_U32("graphics/battle_anims/sprites/orbs.gbapal.lz"); @@ -547,9 +538,9 @@ const u32 gBattleAnimSpritePal_RazorLeaf[] = INCBIN_U32("graphics/battle_anims/s const u32 gBattleAnimSpriteGfx_MistCloud[] = INCBIN_U32("graphics/battle_anims/sprites/mist_cloud.4bpp.lz"); const u32 gBattleAnimSpritePal_MistCloud[] = INCBIN_U32("graphics/battle_anims/sprites/mist_cloud.gbapal.lz"); -const u32 gUnknownGfx_D1C060[] = INCBIN_U32("graphics/unknown/unknown_D1C060.4bpp.lz"); -const u32 gUnknownPal_D1C060[] = INCBIN_U32("graphics/unknown/unknown_D1C060.gbapal.lz"); -const u32 gUnknownTilemap_D1C060[] = INCBIN_U32("graphics/unknown/unknown_D1C060.bin.lz"); +const u32 gBattleAnimUnusedGfx_Lights[] = INCBIN_U32("graphics/battle_anims/unused/lights.4bpp.lz"); +const u32 gBattleAnimUnusedPal_Lights[] = INCBIN_U32("graphics/battle_anims/unused/lights.gbapal.lz"); +const u32 gBattleAnimUnusedTilemap_Lights[] = INCBIN_U32("graphics/battle_anims/unused/lights.bin.lz"); const u32 gBattleAnimSpriteGfx_WhirlwindLines[] = INCBIN_U32("graphics/battle_anims/sprites/whirlwind_lines.4bpp.lz"); const u32 gBattleAnimSpritePal_WhirlwindLines[] = INCBIN_U32("graphics/battle_anims/sprites/whirlwind_lines.gbapal.lz"); @@ -590,9 +581,9 @@ const u32 gMetalShineGfx[] = INCBIN_U32("graphics/battle_anims/masks/metal_shine const u32 gMetalShinePalette[] = INCBIN_U32("graphics/battle_anims/masks/metal_shine.gbapal.lz"); const u32 gMetalShineTilemap[] = INCBIN_U32("graphics/battle_anims/masks/metal_shine.bin.lz"); -const u32 gUnusedGfx_Goosuto[] = INCBIN_U32("graphics/unused/goosuto.4bpp.lz"); // ghost -const u32 gUnusedPal_Goosuto[] = INCBIN_U32("graphics/unused/goosuto.gbapal.lz"); -const u32 gUnusedTilemap_Goosuto[] = INCBIN_U32("graphics/unused/goosuto.bin.lz"); +const u32 gUnusedGfx_Goosuto[] = INCBIN_U32("graphics/battle_anims/unused/goosuto.4bpp.lz"); // ghost +const u32 gUnusedPal_Goosuto[] = INCBIN_U32("graphics/battle_anims/unused/goosuto.gbapal.lz"); +const u32 gUnusedTilemap_Goosuto[] = INCBIN_U32("graphics/battle_anims/unused/goosuto.bin.lz"); const u32 gBattleAnimSpriteGfx_YellowStar[] = INCBIN_U32("graphics/battle_anims/sprites/yellow_star.4bpp.lz"); const u32 gBattleAnimSpritePal_YellowStar[] = INCBIN_U32("graphics/battle_anims/sprites/yellow_star.gbapal.lz"); @@ -942,7 +933,7 @@ const u32 gBattleAnimSpritePal_Meteor[] = INCBIN_U32("graphics/battle_anims/spri const u32 gBattleAnimSpriteGfx_FlatRock[] = INCBIN_U32("graphics/battle_anims/sprites/flat_rock.4bpp.lz"); const u32 gBattleAnimSpritePal_FlatRock[] = INCBIN_U32("graphics/battle_anims/sprites/flat_rock.gbapal.lz"); -const u32 gUnknownPal_C2F9E0[] = INCBIN_U32("graphics/unknown/unknown_C2F9E0.gbapal.lz"); +const u32 gBattleAnimUnusedPal_Unknown2[] = INCBIN_U32("graphics/battle_anims/unused/unknown_2.gbapal.lz"); #include "data/graphics/pokemon.h" #include "data/graphics/trainers.h" @@ -950,9 +941,9 @@ const u32 gUnknownPal_C2F9E0[] = INCBIN_U32("graphics/unknown/unknown_C2F9E0.gba const u8 gMonIcon_QuestionMark[] = INCBIN_U8("graphics/pokemon/question_mark/icon.4bpp"); const u8 gMonFootprint_QuestionMark[] = INCBIN_U8("graphics/pokemon/question_mark/footprint.1bpp"); -const u32 gUnknown_08D778F0[] = INCBIN_U32("graphics/battle_transitions/vs_frame.4bpp.lz"); -const u32 gUnknown_08D779D8[] = INCBIN_U32("graphics/battle_transitions/vs_frame.bin.lz"); -const u32 gUnknown_08D77AE4[] = INCBIN_U32("graphics/battle_transitions/vs_frame.gbapal.lz"); +const u32 gBattleVSFrame_Gfx[] = INCBIN_U32("graphics/battle_transitions/vs_frame.4bpp.lz"); +const u32 gBattleVSFrame_Tilemap[] = INCBIN_U32("graphics/battle_transitions/vs_frame.bin.lz"); +const u32 gBattleVSFrame_Pal[] = INCBIN_U32("graphics/battle_transitions/vs_frame.gbapal.lz"); const u32 gVsLettersGfx[] = INCBIN_U32("graphics/battle_transitions/vs.4bpp.lz"); @@ -976,7 +967,7 @@ const u32 gBattleArenaJudgementSymbolsGfx[] = INCBIN_U32("graphics/battle_fronti const u32 gBattleArenaJudgementSymbolsPalette[] = INCBIN_U32("graphics/battle_frontier/arena_judgement_symbols.gbapal.lz"); const u32 gBattleWindowTextPalette[] = INCBIN_U32("graphics/battle_interface/text.gbapal.lz"); -const u16 gUnknown_08D85620[] = INCBIN_U16("graphics/battle_frontier/text_pp.gbapal"); +const u16 gPPTextPalette[] = INCBIN_U16("graphics/battle_frontier/text_pp.gbapal"); const u16 gTilesetAnims_BattleDomePals0_0[] = INCBIN_U16("graphics/battle_frontier/dome_anim1.gbapal"); const u16 gTilesetAnims_BattleDomePals0_1[] = INCBIN_U16("graphics/battle_frontier/dome_anim2.gbapal"); @@ -985,10 +976,10 @@ const u16 gTilesetAnims_BattleDomePals0_3[] = INCBIN_U16("graphics/battle_fronti static const u16 sUnused0[] = {0x13F, 0x119, 0x113, 0x10E}; -const u16 gUnknown_08D856C8[] = INCBIN_U16("graphics/battle_frontier/pyramid_light.gbapal"); // unfaded pal for the player light in battle pyramid +const u16 gBattlePyramidFloor_Pal[] = INCBIN_U16("graphics/battle_frontier/pyramid_floor.gbapal"); -const u32 gUnknown_08D857A8[] = INCBIN_U32("graphics/battle_frontier/battle_tilemap1.bin.lz"); -const u32 gUnknown_08D85A1C[] = INCBIN_U32("graphics/battle_frontier/battle_tilemap2.bin.lz"); +const u32 gMultiBattleIntroBg_Opponent_Tilemap[] = INCBIN_U32("graphics/battle_frontier/multi_battle_intro_bg_opponent.bin.lz"); +const u32 gMultiBattleIntroBg_Player_Tilemap[] = INCBIN_U32("graphics/battle_frontier/multi_battle_intro_bg_player.bin.lz"); #include "data/graphics/intro_scene.h" @@ -1059,9 +1050,8 @@ const u32 gBattleAnimBgTilemap_Ghost[] = INCBIN_U32("graphics/battle_anims/backg const u32 gBattleAnimSpritePal_WhipHit[] = INCBIN_U32("graphics/battle_anims/sprites/whip_hit.gbapal.lz"); -const u32 gBattleAnimBgPalette_Solarbeam[] = INCBIN_U32("graphics/battle_anims/backgrounds/solarbeam.gbapal.lz"); - -const u32 gUnknown_E6BC04[] = INCBIN_U32("graphics/unknown/unknown_E6BC04.bin.lz"); +const u32 gBattleAnimBgPalette_SolarBeam[] = INCBIN_U32("graphics/battle_anims/backgrounds/solarbeam.gbapal.lz"); +const u32 gBattleAnimBgTilemap_SolarBeam[] = INCBIN_U32("graphics/battle_anims/backgrounds/solarbeam.bin.lz"); // Unused const u32 gBerryBlenderCenter_Gfx[] = INCBIN_U32("graphics/berry_blender/center.8bpp.lz"); const u32 gBerryBlenderOuter_Gfx[] = INCBIN_U32("graphics/berry_blender/outer.4bpp.lz"); @@ -1139,13 +1129,13 @@ const u32 gMoveTypes_Pal[] = INCBIN_U32("graphics/types/move_types.gbapal.lz"); const u32 gSummaryMoveSelect_Gfx[] = INCBIN_U32("graphics/interface/summary_frames.4bpp.lz"); const u32 gSummaryMoveSelect_Pal[] = INCBIN_U32("graphics/interface/summary_frames.gbapal.lz"); -const u32 gStatusScreenBitmap[] = INCBIN_U32("graphics/interface/status_screen.4bpp.lz"); -const u32 gStatusScreenPalette[] = INCBIN_U32("graphics/interface/status_screen.gbapal.lz"); -const u32 gPageInfoTilemap[] = INCBIN_U32("graphics/interface/status_screen.bin.lz"); -const u32 gPageSkillsTilemap[] = INCBIN_U32("graphics/interface/status_tilemap1.bin.lz"); -const u32 gPageBattleMovesTilemap[] = INCBIN_U32("graphics/interface/status_tilemap2.bin.lz"); -const u32 gPageContestMovesTilemap[] = INCBIN_U32("graphics/interface/status_tilemap3.bin.lz"); -const u32 gUnknown_08D98CC8[] = INCBIN_U32("graphics/interface/status_tilemap0.bin.lz"); +const u32 gSummaryScreen_Gfx[] = INCBIN_U32("graphics/interface/summary_screen.4bpp.lz"); +const u32 gSummaryScreen_Pal[] = INCBIN_U32("graphics/interface/summary_screen.gbapal.lz"); +const u32 gSummaryPage_Info_Tilemap[] = INCBIN_U32("graphics/interface/summary_page_info.bin.lz"); +const u32 gSummaryPage_Skills_Tilemap[] = INCBIN_U32("graphics/interface/summary_page_skills.bin.lz"); +const u32 gSummaryPage_BattleMoves_Tilemap[] = INCBIN_U32("graphics/interface/summary_page_battle_moves.bin.lz"); +const u32 gSummaryPage_ContestMoves_Tilemap[] = INCBIN_U32("graphics/interface/summary_page_contest_moves.bin.lz"); +const u32 gSummaryPage_InfoCopy_Tilemap[] = INCBIN_U32("graphics/interface/summary_page_info_copy.bin.lz"); const u32 gBagMaleTiles[] = INCBIN_U32("graphics/misc/bag_male.4bpp.lz"); const u32 gBagFemaleTiles[] = INCBIN_U32("graphics/misc/bag_female.4bpp.lz"); @@ -1157,11 +1147,10 @@ const u32 gBagScreenFemale_Pal[] = INCBIN_U32("graphics/interface/bag_screen_fem const u32 gBagScreen_Gfx[] = INCBIN_U32("graphics/interface/bag_screen.4bpp.lz"); const u32 gBagScreen_GfxTileMap[] = INCBIN_U32("graphics/interface/bag_screen_tilemap.bin.lz"); -const u32 gBattleFrontierGfx_PyramidBag[] = INCBIN_U32("graphics/interface/bag_pyramid.4bpp.lz"); -const u32 gBattleFrontierGfx_PyramidBag_Pal[] = INCBIN_U32("graphics/interface/bag_pyramid.gbapal.lz"); // female palette is first and male is second. -const u32 gBattleFrontierGfx_PyramidBagTileMap[] = INCBIN_U32("graphics/interface/bag_pyramid_tilemap.bin.lz"); - -const u32 gUnknown_08D9AF44[] = INCBIN_U32("graphics/unknown/unknown_D9AF44.gbapal.lz"); +const u32 gBattlePyramidBag_Gfx[] = INCBIN_U32("graphics/interface/bag_pyramid.4bpp.lz"); +const u32 gBattlePyramidBag_Pal[] = INCBIN_U32("graphics/interface/bag_pyramid.gbapal.lz"); // female palette is first and male is second. +const u32 gBattlePyramidBagTilemap[] = INCBIN_U32("graphics/interface/bag_pyramid_tilemap.bin.lz"); +const u32 gBattlePyramidBagInterface_Pal[] = INCBIN_U32("graphics/interface/bag_pyramid_interface.gbapal.lz"); const u32 gBagSwapLineGfx[] = INCBIN_U32("graphics/interface/bag_swap.4bpp.lz"); const u32 gBagSwapLinePal[] = INCBIN_U32("graphics/interface/bag_swap.gbapal.lz"); @@ -1283,10 +1272,10 @@ const u32 gPokedexAreaScreenAreaUnknown_Gfx[] = INCBIN_U32("graphics/pokedex/are // seems to be fire red leftovers, but the menu elements is reused in the item menu for TM descriptions. -const u16 gFireRedMenuElements1_Pal[] = INCBIN_U16("graphics/interface_fr/menu1.gbapal"); -const u16 gFireRedMenuElements2_Pal[] = INCBIN_U16("graphics/interface_fr/menu2.gbapal"); -const u16 gFireRedMenuElements3_Pal[] = INCBIN_U16("graphics/interface_fr/menu3.gbapal"); -const u8 gFireRedMenuElements_Gfx[] = INCBIN_U8("graphics/interface_fr/menu.4bpp"); //the types are reused for item menu +const u16 gMenuInfoElements1_Pal[] = INCBIN_U16("graphics/interface/menu_info1.gbapal"); +const u16 gMenuInfoElements2_Pal[] = INCBIN_U16("graphics/interface/menu_info2.gbapal"); +const u16 gMenuInfoElements3_Pal[] = INCBIN_U16("graphics/interface/menu_info3.gbapal"); +const u8 gMenuInfoElements_Gfx[] = INCBIN_U8("graphics/interface/menu_info.4bpp"); //the types are reused for item menu const u8 gBagMenuHMIcon_Gfx[] = INCBIN_U8("graphics/interface/hm.4bpp"); @@ -1473,8 +1462,8 @@ const u16 gTradeMenu_Pal[] = INCBIN_U16("graphics/trade/menu.gbapal"); const u16 gTradeCursor_Pal[] = INCBIN_U16("graphics/trade/cursor.gbapal"); const u8 gTradeMenu_Gfx[] = INCBIN_U8("graphics/trade/menu.4bpp"); const u8 gTradeCursor_Gfx[] = INCBIN_U8("graphics/trade/cursor.4bpp"); -const u16 gUnused_DDCEE4[] = INCBIN_U16("graphics/unused/unused_DDCEE4.bin"); -const u16 gUnknown_08DDCF04[] = INCBIN_U16("graphics/trade/unknown_DDCF04.bin"); +const u16 gTradeUnused_Tilemap[] = INCBIN_U16("graphics/trade/unused.bin"); +const u16 gTradeMenu_Tilemap[] = INCBIN_U16("graphics/trade/menu.bin"); const u16 gTradeMenuMonBox_Tilemap[] = INCBIN_U16("graphics/trade/menu_mon_box.bin"); const u16 gMessageBox_Pal[] = INCBIN_U16("graphics/text_window/message_box.gbapal"); @@ -1513,26 +1502,21 @@ const u16 gMonIconPalettes[][16] = INCBIN_U16("graphics/pokemon/icon_palettes/icon_palette_2.gbapal"), }; -const u16 gTitleScreenBgPalettes[] = INCBIN_U16("graphics/title_screen/pokemon_logo.gbapal", - "graphics/title_screen/rayquaza_and_clouds.gbapal"); - -const u16 gTitleScreenEmeraldVersionPal[] = INCBIN_U16("graphics/title_screen/emerald_version.gbapal"); - -const u32 gUnknown_08DDE458[] = INCBIN_U32("graphics/title_screen/title_screen1.bin.lz"); - -const u32 gTitleScreenPokemonLogoGfx[] = INCBIN_U32("graphics/title_screen/pokemon_logo.8bpp.lz"); - -const u32 gTitleScreenEmeraldVersionGfx[] = INCBIN_U32("graphics/title_screen/emerald_version.8bpp.lz"); - -const u16 gTitleScreenPressStartPal[] = INCBIN_U16("graphics/title_screen/press_start.gbapal"); -const u32 gTitleScreenPressStartGfx[] = INCBIN_U32("graphics/title_screen/press_start.4bpp.lz"); - -const u32 gUnknown_08DE0644[] = INCBIN_U32("graphics/title_screen/title_screen2.bin.lz"); - -const u16 gFrontierPassBg_Pal[][16] = INCBIN_U16("graphics/frontier_pass/bg.gbapal");// size in LoadPalette calls is reported as 0xD0 << 1, which is 0x1A0, but palette is only 0x100 bytes long so it loads garbage as well -const u32 gFrontierPassBg_Gfx[] = INCBIN_U32("graphics/frontier_pass/bg.4bpp.lz"); -const u32 gFrontierPassMapAndCard_Gfx[] = INCBIN_U32("graphics/frontier_pass/map_and_card.8bpp.lz"); -const u32 gFrontierPassBg_Tilemap[] = INCBIN_U32("graphics/frontier_pass/bg.bin.lz"); +const u16 gTitleScreenBgPalettes[] = INCBIN_U16("graphics/title_screen/pokemon_logo.gbapal", + "graphics/title_screen/rayquaza_and_clouds.gbapal"); +const u16 gTitleScreenEmeraldVersionPal[] = INCBIN_U16("graphics/title_screen/emerald_version.gbapal"); +const u32 gTitleScreenCloudsTilemap[] = INCBIN_U32("graphics/title_screen/title_screen1.bin.lz"); +const u32 gTitleScreenPokemonLogoGfx[] = INCBIN_U32("graphics/title_screen/pokemon_logo.8bpp.lz"); +const u32 gTitleScreenEmeraldVersionGfx[] = INCBIN_U32("graphics/title_screen/emerald_version.8bpp.lz"); +const u16 gTitleScreenPressStartPal[] = INCBIN_U16("graphics/title_screen/press_start.gbapal"); +const u32 gTitleScreenPressStartGfx[] = INCBIN_U32("graphics/title_screen/press_start.4bpp.lz"); +const u32 gTitleScreenPokemonLogoTilemap[] = INCBIN_U32("graphics/title_screen/title_screen2.bin.lz"); + +// size in LoadPalette calls is reported as 0xD0 << 1, which is 0x1A0, but palette is only 0x100 bytes long so it loads garbage as well +const u16 gFrontierPassBg_Pal[][16] = INCBIN_U16("graphics/frontier_pass/bg.gbapal"); +const u32 gFrontierPassBg_Gfx[] = INCBIN_U32("graphics/frontier_pass/bg.4bpp.lz"); +const u32 gFrontierPassMapAndCard_Gfx[] = INCBIN_U32("graphics/frontier_pass/map_and_card.8bpp.lz"); +const u32 gFrontierPassBg_Tilemap[] = INCBIN_U32("graphics/frontier_pass/bg.bin.lz"); const u16 gFrontierPassCancelButton_Tilemap[] = INCBIN_U16("graphics/frontier_pass/cancel.bin"); const u16 gFrontierPassCancelButtonHighlighted_Tilemap[] = INCBIN_U16("graphics/frontier_pass/cancel_highlighted.bin"); diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 3cbe8df6e..84f7d8fe6 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -343,7 +343,6 @@ static const struct HallofFameMon sDummyFameMon = static const u8 sHallOfFame_SlotOrder[] = { 2, 1, 3, 6, 4, 5, - 0, 0 }; // code @@ -514,8 +513,8 @@ static void Task_Hof_InitTeamSaveData(u8 taskId) *lastSavedTeam = *sHofMonPtr; DrawDialogueFrame(0, 0); - AddTextPrinterParameterized2(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); + CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_Hof_TrySaveData; } @@ -676,7 +675,7 @@ static void Task_Hof_DoConfetti(u8 taskId) } BeginNormalPaletteFade(sHofFadePalettes, 0, 12, 12, RGB(16, 29, 24)); FillWindowPixelBuffer(0, PIXEL_FILL(0)); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].tFrameCount = 7; gTasks[taskId].func = Task_Hof_WaitToDisplayPlayer; } @@ -724,8 +723,8 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId) FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); HallOfFame_PrintPlayerInfo(1, 2); DrawDialogueFrame(0, 0); - AddTextPrinterParameterized2(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_LeagueChamp, 0, NULL, 2, 1, 3); + CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_Hof_ExitOnKeyPressed; } } @@ -862,7 +861,7 @@ void CB2_DoHallOfFamePC(void) static void Task_HofPC_CopySaveData(u8 taskId) { - sub_81980F0(0, 0x1E, 0, 0xC, 0x226); + HofPCTopBar_AddWindow(0, 30, 0, 12, 0x226); if (Save_LoadGameData(SAVE_HALL_OF_FAME) != SAVE_STATUS_OK) { gTasks[taskId].func = Task_HofPC_PrintDataIsCorrupted; @@ -950,9 +949,9 @@ static void Task_HofPC_DrawSpritesPrintText(u8 taskId) StringExpandPlaceholders(gStringVar4, gText_HOFNumber); if (gTasks[taskId].tCurrTeamNo <= 0) - sub_8198204(gStringVar4, gText_PickCancel, 0, 0, TRUE); + HofPCTopBar_PrintPair(gStringVar4, gText_PickCancel, FALSE, 0, TRUE); else - sub_8198204(gStringVar4, gText_PickNextCancel, 0, 0, TRUE); + HofPCTopBar_PrintPair(gStringVar4, gText_PickNextCancel, FALSE, 0, TRUE); gTasks[taskId].func = Task_HofPC_PrintMonInfo; } @@ -1073,7 +1072,7 @@ static void Task_HofPC_HandleExit(u8 taskId) HideBg(0); HideBg(1); HideBg(3); - sub_8198314(); + HofPCTopBar_RemoveWindow(); FreeAllWindowBuffers(); UnsetBgTilemapBuffer(1); UnsetBgTilemapBuffer(3); @@ -1091,10 +1090,10 @@ static void Task_HofPC_HandleExit(u8 taskId) static void Task_HofPC_PrintDataIsCorrupted(u8 taskId) { - sub_8198180(gText_AButtonExit, 8, TRUE); + HofPCTopBar_Print(gText_AButtonExit, 8, TRUE); DrawDialogueFrame(0, 0); - AddTextPrinterParameterized2(0, 1, gText_HOFCorrupted, 0, NULL, 2, 1, 3); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_HOFCorrupted, 0, NULL, 2, 1, 3); + CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_HofPC_ExitOnButtonPress; } @@ -1114,8 +1113,8 @@ static void HallOfFame_PrintWelcomeText(u8 unusedPossiblyWindowId, u8 unused2) { FillWindowPixelBuffer(0, PIXEL_FILL(0)); PutWindowTilemap(0); - AddTextPrinterParameterized3(0, 1, GetStringCenterAlignXOffset(1, gText_WelcomeToHOF, 0xD0), 1, sMonInfoTextColors, 0, gText_WelcomeToHOF); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized3(0, FONT_NORMAL, GetStringCenterAlignXOffset(FONT_NORMAL, gText_WelcomeToHOF, 0xD0), 1, sMonInfoTextColors, 0, gText_WelcomeToHOF); + CopyWindowToVram(0, COPYWIN_FULL); } static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u8 unused2) @@ -1150,7 +1149,7 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u *(stringPtr)++ = CHAR_QUESTION_MARK; } stringPtr[0] = EOS; - AddTextPrinterParameterized3(0, 1, 0x10, 1, sMonInfoTextColors, -1, text); + AddTextPrinterParameterized3(0, FONT_NORMAL, 0x10, 1, sMonInfoTextColors, TEXT_SKIP_DRAW, text); } // nick, species names, gender and level @@ -1158,14 +1157,14 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u text[POKEMON_NAME_LENGTH] = EOS; if (currMon->species == SPECIES_EGG) { - width = GetStringCenterAlignXOffset(1, text, 0xD0); - AddTextPrinterParameterized3(0, 1, width, 1, sMonInfoTextColors, -1, text); - CopyWindowToVram(0, 3); + width = GetStringCenterAlignXOffset(FONT_NORMAL, text, 0xD0); + AddTextPrinterParameterized3(0, FONT_NORMAL, width, 1, sMonInfoTextColors, TEXT_SKIP_DRAW, text); + CopyWindowToVram(0, COPYWIN_FULL); } else { - width = GetStringRightAlignXOffset(1, text, 0x80); - AddTextPrinterParameterized3(0, 1, width, 1, sMonInfoTextColors, -1, text); + width = GetStringRightAlignXOffset(FONT_NORMAL, text, 0x80); + AddTextPrinterParameterized3(0, FONT_NORMAL, width, 1, sMonInfoTextColors, TEXT_SKIP_DRAW, text); text[0] = CHAR_SLASH; stringPtr = StringCopy(text + 1, gSpeciesNames[currMon->species]); @@ -1186,17 +1185,17 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 unused1, u } stringPtr[0] = EOS; - AddTextPrinterParameterized3(0, 1, 0x80, 1, sMonInfoTextColors, -1, text); + AddTextPrinterParameterized3(0, FONT_NORMAL, 0x80, 1, sMonInfoTextColors, TEXT_SKIP_DRAW, text); stringPtr = StringCopy(text, gText_Level); ConvertIntToDecimalStringN(stringPtr, currMon->lvl, STR_CONV_MODE_LEFT_ALIGN, 3); - AddTextPrinterParameterized3(0, 1, 0x24, 0x11, sMonInfoTextColors, -1, text); + AddTextPrinterParameterized3(0, FONT_NORMAL, 0x24, 0x11, sMonInfoTextColors, TEXT_SKIP_DRAW, text); stringPtr = StringCopy(text, gText_IDNumber); ConvertIntToDecimalStringN(stringPtr, (u16)(currMon->tid), STR_CONV_MODE_LEADING_ZEROS, 5); - AddTextPrinterParameterized3(0, 1, 0x68, 0x11, sMonInfoTextColors, -1, text); + AddTextPrinterParameterized3(0, FONT_NORMAL, 0x68, 0x11, sMonInfoTextColors, TEXT_SKIP_DRAW, text); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } } @@ -1209,23 +1208,23 @@ static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2) FillWindowPixelBuffer(1, PIXEL_FILL(1)); PutWindowTilemap(1); DrawStdFrameWithCustomTileAndPalette(1, FALSE, 0x21D, 0xD); - AddTextPrinterParameterized3(1, 1, 0, 1, sPlayerInfoTextColors, -1, gText_Name); + AddTextPrinterParameterized3(1, FONT_NORMAL, 0, 1, sPlayerInfoTextColors, TEXT_SKIP_DRAW, gText_Name); - width = GetStringRightAlignXOffset(1, gSaveBlock2Ptr->playerName, 0x70); - AddTextPrinterParameterized3(1, 1, width, 1, sPlayerInfoTextColors, -1, gSaveBlock2Ptr->playerName); + width = GetStringRightAlignXOffset(FONT_NORMAL, gSaveBlock2Ptr->playerName, 0x70); + AddTextPrinterParameterized3(1, FONT_NORMAL, width, 1, sPlayerInfoTextColors, TEXT_SKIP_DRAW, gSaveBlock2Ptr->playerName); trainerId = (gSaveBlock2Ptr->playerTrainerId[0]) | (gSaveBlock2Ptr->playerTrainerId[1] << 8); - AddTextPrinterParameterized3(1, 1, 0, 0x11, sPlayerInfoTextColors, 0, gText_IDNumber); + AddTextPrinterParameterized3(1, FONT_NORMAL, 0, 0x11, sPlayerInfoTextColors, 0, gText_IDNumber); text[0] = (trainerId % 100000) / 10000 + CHAR_0; text[1] = (trainerId % 10000) / 1000 + CHAR_0; text[2] = (trainerId % 1000) / 100 + CHAR_0; text[3] = (trainerId % 100) / 10 + CHAR_0; text[4] = (trainerId % 10) / 1 + CHAR_0; text[5] = EOS; - width = GetStringRightAlignXOffset(1, text, 0x70); - AddTextPrinterParameterized3(1, 1, width, 0x11, sPlayerInfoTextColors, -1, text); + width = GetStringRightAlignXOffset(FONT_NORMAL, text, 0x70); + AddTextPrinterParameterized3(1, FONT_NORMAL, width, 0x11, sPlayerInfoTextColors, TEXT_SKIP_DRAW, text); - AddTextPrinterParameterized3(1, 1, 0, 0x21, sPlayerInfoTextColors, -1, gText_Time); + AddTextPrinterParameterized3(1, FONT_NORMAL, 0, 0x21, sPlayerInfoTextColors, TEXT_SKIP_DRAW, gText_Time); text[0] = (gSaveBlock2Ptr->playTimeHours / 100) + CHAR_0; text[1] = (gSaveBlock2Ptr->playTimeHours % 100) / 10 + CHAR_0; text[2] = (gSaveBlock2Ptr->playTimeHours % 10) + CHAR_0; @@ -1240,10 +1239,10 @@ static void HallOfFame_PrintPlayerInfo(u8 unused1, u8 unused2) text[5] = (gSaveBlock2Ptr->playTimeMinutes % 10) + CHAR_0; text[6] = EOS; - width = GetStringRightAlignXOffset(1, text, 0x70); - AddTextPrinterParameterized3(1, 1, width, 0x21, sPlayerInfoTextColors, -1, text); + width = GetStringRightAlignXOffset(FONT_NORMAL, text, 0x70); + AddTextPrinterParameterized3(1, FONT_NORMAL, width, 0x21, sPlayerInfoTextColors, TEXT_SKIP_DRAW, text); - CopyWindowToVram(1, 3); + CopyWindowToVram(1, COPYWIN_FULL); } static void ClearVramOamPltt_LoadHofPal(void) @@ -1296,12 +1295,12 @@ static void InitHofBgs(void) InitBgsFromTemplates(0, sHof_BgTemplates, ARRAY_COUNT(sHof_BgTemplates)); SetBgTilemapBuffer(1, sHofGfxPtr->tilemap1); SetBgTilemapBuffer(3, sHofGfxPtr->tilemap2); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); } static bool8 LoadHofBgs(void) diff --git a/src/international_string_util.c b/src/international_string_util.c index b2ee9743e..e4b793b66 100644 --- a/src/international_string_util.c +++ b/src/international_string_util.c @@ -40,7 +40,7 @@ int GetMaxWidthInMenuTable(const struct MenuAction *actions, int numActions) for (maxWidth = 0, i = 0; i < numActions; i++) { - int stringWidth = GetStringWidth(1, actions[i].text, 0); + int stringWidth = GetStringWidth(FONT_NORMAL, actions[i].text, 0); if (stringWidth > maxWidth) maxWidth = stringWidth; } @@ -54,7 +54,7 @@ int GetMaxWidthInSubsetOfMenuTable(const struct MenuAction *actions, const u8* a for (maxWidth = 0, i = 0; i < numActions; i++) { - int stringWidth = GetStringWidth(1, actions[actionIds[i]].text, 0); + int stringWidth = GetStringWidth(FONT_NORMAL, actions[actionIds[i]].text, 0); if (stringWidth > maxWidth) maxWidth = stringWidth; } @@ -214,10 +214,11 @@ int GetNicknameLanguage(u8 *str) return GAME_LANGUAGE; } -void sub_81DB620(int windowId, int columnStart, int rowStart, int numFillTiles, int numRows) +// Used by Pokénav's Match Call to erase the previous trainer's flavor text when switching between their info pages. +void FillWindowTilesByRow(int windowId, int columnStart, int rowStart, int numFillTiles, int numRows) { u8 *windowTileData; - int fillSize, windowRowSize, rowsToFill; + int fillSize, windowRowSize, i; struct Window *window = &gWindows[windowId]; fillSize = numFillTiles * TILE_SIZE_4BPP; @@ -225,12 +226,10 @@ void sub_81DB620(int windowId, int columnStart, int rowStart, int numFillTiles, windowTileData = window->tileData + (rowStart * windowRowSize) + (columnStart * TILE_SIZE_4BPP); if (numRows > 0) { - rowsToFill = numRows; - while (rowsToFill) + for (i = numRows; i != 0; i--) { CpuFastFill8(0x11, windowTileData, fillSize); windowTileData += windowRowSize; - rowsToFill--; } } } diff --git a/src/item_menu.c b/src/item_menu.c index 53f478a31..56ef3cba3 100755 --- a/src/item_menu.c +++ b/src/item_menu.c @@ -260,7 +260,7 @@ static const struct ListMenuTemplate sItemListMenu = .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = 0, - .fontId = 7, + .fontId = FONT_NARROW, .cursorKind = 0 }; @@ -669,7 +669,7 @@ void VBlankCB_BagMenuRun(void) static void CB2_Bag(void) { - while(MenuHelpers_CallLinkSomething() != TRUE && SetupBagMenu() != TRUE && MenuHelpers_LinkSomething() != TRUE) + while(MenuHelpers_ShouldWaitForLinkRecv() != TRUE && SetupBagMenu() != TRUE && MenuHelpers_IsLinkActive() != TRUE) {}; } @@ -705,7 +705,7 @@ static bool8 SetupBagMenu(void) gMain.state++; break; case 6: - if (!MenuHelpers_LinkSomething()) + if (!MenuHelpers_IsLinkActive()) ResetTasks(); gMain.state++; break; @@ -973,16 +973,16 @@ static void BagMenu_ItemPrintCallback(u8 windowId, u32 itemIndex, u8 y) // Print berry quantity ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, BERRY_CAPACITY_DIGITS); StringExpandPlaceholders(gStringVar4, gText_xVar1); - offset = GetStringRightAlignXOffset(7, gStringVar4, 119); - BagMenu_Print(windowId, 7, gStringVar4, offset, y, 0, 0, TEXT_SPEED_FF, COLORID_NORMAL); + offset = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 119); + BagMenu_Print(windowId, FONT_NARROW, gStringVar4, offset, y, 0, 0, TEXT_SKIP_DRAW, COLORID_NORMAL); } else if (gBagPosition.pocket != KEYITEMS_POCKET && ItemId_GetImportance(itemId) == FALSE) { // Print item quantity ConvertIntToDecimalStringN(gStringVar1, itemQuantity, STR_CONV_MODE_RIGHT_ALIGN, BAG_ITEM_CAPACITY_DIGITS); StringExpandPlaceholders(gStringVar4, gText_xVar1); - offset = GetStringRightAlignXOffset(7, gStringVar4, 119); - BagMenu_Print(windowId, 7, gStringVar4, offset, y, 0, 0, TEXT_SPEED_FF, COLORID_NORMAL); + offset = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 119); + BagMenu_Print(windowId, FONT_NARROW, gStringVar4, offset, y, 0, 0, TEXT_SKIP_DRAW, COLORID_NORMAL); } else { @@ -1008,7 +1008,7 @@ static void PrintItemDescription(int itemIndex) str = gStringVar4; } FillWindowPixelBuffer(WIN_DESCRIPTION, PIXEL_FILL(0)); - BagMenu_Print(WIN_DESCRIPTION, 1, str, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, str, 3, 1, 0, 0, 0, COLORID_NORMAL); } static void BagMenu_PrintCursor(u8 listTaskId, u8 colorIndex) @@ -1019,9 +1019,9 @@ static void BagMenu_PrintCursor(u8 listTaskId, u8 colorIndex) static void BagMenu_PrintCursorAtPos(u8 y, u8 colorIndex) { if (colorIndex == COLORID_NONE) - FillWindowPixelRect(WIN_ITEM_LIST, PIXEL_FILL(0), 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); + FillWindowPixelRect(WIN_ITEM_LIST, PIXEL_FILL(0), 0, y, GetMenuCursorDimensionByFont(FONT_NORMAL, 0), GetMenuCursorDimensionByFont(FONT_NORMAL, 1)); else - BagMenu_Print(WIN_ITEM_LIST, 1, gText_SelectorArrow2, 0, y, 0, 0, 0, colorIndex); + BagMenu_Print(WIN_ITEM_LIST, FONT_NORMAL, gText_SelectorArrow2, 0, y, 0, 0, 0, colorIndex); } @@ -1195,7 +1195,7 @@ static void PrintItemQuantity(u8 windowId, s16 quantity) u8 numDigits = (gBagPosition.pocket == BERRIES_POCKET) ? BERRY_CAPACITY_DIGITS : BAG_ITEM_CAPACITY_DIGITS; ConvertIntToDecimalStringN(gStringVar1, quantity, STR_CONV_MODE_LEADING_ZEROS, numDigits); StringExpandPlaceholders(gStringVar4, gText_xVar1); - AddTextPrinterParameterized(windowId, 1, gStringVar4, GetStringCenterAlignXOffset(1, gStringVar4, 0x28), 2, 0, 0); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 0x28), 2, 0, 0); } // Prints the quantity of items to be sold and the amount that would be earned @@ -1204,7 +1204,7 @@ static void PrintItemSoldAmount(int windowId, int numSold, int moneyEarned) u8 numDigits = (gBagPosition.pocket == BERRIES_POCKET) ? BERRY_CAPACITY_DIGITS : BAG_ITEM_CAPACITY_DIGITS; ConvertIntToDecimalStringN(gStringVar1, numSold, STR_CONV_MODE_LEADING_ZEROS, numDigits); StringExpandPlaceholders(gStringVar4, gText_xVar1); - AddTextPrinterParameterized(windowId, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, 0); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, 0); PrintMoneyAmount(windowId, 38, 1, moneyEarned, 0); } @@ -1215,7 +1215,7 @@ static void Task_BagMenu_HandleInput(u8 taskId) u16* cursorPos = &gBagPosition.cursorPosition[gBagPosition.pocket]; s32 listPosition; - if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE && !gPaletteFade.active) { switch (GetSwitchBagPocketDirection()) { @@ -1354,7 +1354,7 @@ static void Task_SwitchBagPocket(u8 taskId) { s16* data = gTasks[taskId].data; - if (!MenuHelpers_LinkSomething() && !IsWallysBag()) + if (!MenuHelpers_IsLinkActive() && !IsWallysBag()) { switch (GetSwitchBagPocketDirection()) { @@ -1438,7 +1438,7 @@ static void StartItemSwap(u8 taskId) CopyItemName(BagGetItemIdByPocketPosition(gBagPosition.pocket + 1, tListPosition), gStringVar1); StringExpandPlaceholders(gStringVar4, gText_MoveVar1Where); FillWindowPixelBuffer(WIN_DESCRIPTION, PIXEL_FILL(0)); - BagMenu_Print(WIN_DESCRIPTION, 1, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); UpdateItemMenuSwapLinePos(tListPosition); DestroyPocketSwitchArrowPair(); BagMenu_PrintCursor(tListTaskId, COLORID_GRAY_CURSOR); @@ -1449,7 +1449,7 @@ static void Task_HandleSwappingItemsInput(u8 taskId) { s16* data = gTasks[taskId].data; - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { if (JOY_NEW(SELECT_BUTTON)) { @@ -1589,7 +1589,7 @@ static void OpenContextMenu(u8 taskId) case ITEMMENULOCATION_BERRY_TREE: case ITEMMENULOCATION_ITEMPC: default: - if (MenuHelpers_LinkSomething() == TRUE || InUnionRoom() == TRUE) + if (MenuHelpers_IsLinkActive() == TRUE || InUnionRoom() == TRUE) { if (gBagPosition.pocket == KEYITEMS_POCKET || !IsHoldingItemAllowed(gSpecialVar_ItemId)) { @@ -1653,7 +1653,7 @@ static void OpenContextMenu(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_Var1IsSelected); FillWindowPixelBuffer(WIN_DESCRIPTION, PIXEL_FILL(0)); - BagMenu_Print(WIN_DESCRIPTION, 1, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); } if (gBagMenu->contextMenuNumItems == 1) PrintContextMenuItems(BagMenu_AddWindow(ITEMWIN_1x1)); @@ -1667,13 +1667,13 @@ static void OpenContextMenu(u8 taskId) static void PrintContextMenuItems(u8 windowId) { - AddItemMenuActionTextPrinters(windowId, 7, 8, 1, 0, 16, gBagMenu->contextMenuNumItems, sItemMenuActions, gBagMenu->contextMenuItemsPtr); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, gBagMenu->contextMenuNumItems, 0); + PrintMenuActionTexts(windowId, FONT_NARROW, 8, 1, 0, 16, gBagMenu->contextMenuNumItems, sItemMenuActions, gBagMenu->contextMenuItemsPtr); + InitMenuInUpperLeftCornerNormal(windowId, gBagMenu->contextMenuNumItems, 0); } static void PrintContextMenuItemGrid(u8 windowId, u8 columns, u8 rows) { - PrintMenuActionGrid(windowId, 7, 8, 1, 56, columns, rows, sItemMenuActions, gBagMenu->contextMenuItemsPtr); + PrintMenuActionGrid(windowId, FONT_NARROW, 8, 1, 56, columns, rows, sItemMenuActions, gBagMenu->contextMenuItemsPtr); InitMenuActionGrid(windowId, 56, columns, rows, 0); } @@ -1691,7 +1691,7 @@ static void Task_ItemContext_Normal(u8 taskId) static void Task_ItemContext_SingleRow(u8 taskId) { - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { s8 selection = Menu_ProcessInputNoWrap(); switch (selection) @@ -1712,7 +1712,7 @@ static void Task_ItemContext_SingleRow(u8 taskId) static void Task_ItemContext_MultipleRows(u8 taskId) { - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { s8 cursorPos = Menu_GetCursorPos(); if (JOY_NEW(DPAD_UP)) @@ -1720,7 +1720,7 @@ static void Task_ItemContext_MultipleRows(u8 taskId) if (cursorPos > 0 && IsValidContextMenuPos(cursorPos - 2)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); } } else if (JOY_NEW(DPAD_DOWN)) @@ -1728,7 +1728,7 @@ static void Task_ItemContext_MultipleRows(u8 taskId) if (cursorPos < (gBagMenu->contextMenuNumItems - 2) && IsValidContextMenuPos(cursorPos + 2)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); } } else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) @@ -1736,7 +1736,7 @@ static void Task_ItemContext_MultipleRows(u8 taskId) if ((cursorPos & 1) && IsValidContextMenuPos(cursorPos - 1)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); } } else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) @@ -1744,7 +1744,7 @@ static void Task_ItemContext_MultipleRows(u8 taskId) if (!(cursorPos & 1) && IsValidContextMenuPos(cursorPos + 1)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); } } else if (JOY_NEW(A_BUTTON)) @@ -1819,7 +1819,7 @@ static void ItemMenu_Toss(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_TossHowManyVar1s); FillWindowPixelBuffer(WIN_DESCRIPTION, PIXEL_FILL(0)); - BagMenu_Print(WIN_DESCRIPTION, 1, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); AddItemQuantityWindow(ITEMWIN_QUANTITY); gTasks[taskId].func = Task_ChooseHowManyToToss; } @@ -1833,7 +1833,7 @@ static void AskTossItems(u8 taskId) ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, MAX_ITEM_DIGITS); StringExpandPlaceholders(gStringVar4, gText_ConfirmTossItems); FillWindowPixelBuffer(WIN_DESCRIPTION, PIXEL_FILL(0)); - BagMenu_Print(WIN_DESCRIPTION, 1, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); BagMenu_YesNo(taskId, ITEMWIN_YESNO_LOW, &sYesNoTossFunctions); } @@ -1876,7 +1876,7 @@ static void ConfirmToss(u8 taskId) ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, MAX_ITEM_DIGITS); StringExpandPlaceholders(gStringVar4, gText_ThrewAwayVar2Var1s); FillWindowPixelBuffer(WIN_DESCRIPTION, PIXEL_FILL(0)); - BagMenu_Print(WIN_DESCRIPTION, 1, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); gTasks[taskId].func = Task_RemoveItemFromBag; } @@ -1924,7 +1924,7 @@ static void ItemMenu_Give(u8 taskId) RemoveContextWindow(); if (!IsWritingMailAllowed(gSpecialVar_ItemId)) { - DisplayItemMessage(taskId, 1, gText_CantWriteMail, HandleErrorMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gText_CantWriteMail, HandleErrorMessage); } else if (!ItemId_GetImportance(gSpecialVar_ItemId)) { @@ -1946,14 +1946,14 @@ static void ItemMenu_Give(u8 taskId) static void PrintThereIsNoPokemon(u8 taskId) { - DisplayItemMessage(taskId, 1, gText_NoPokemon, HandleErrorMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gText_NoPokemon, HandleErrorMessage); } static void PrintItemCantBeHeld(u8 taskId) { CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeld); - DisplayItemMessage(taskId, 1, gStringVar4, HandleErrorMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, HandleErrorMessage); } static void HandleErrorMessage(u8 taskId) @@ -2001,13 +2001,13 @@ static void Task_ItemContext_GiveToParty(u8 taskId) { if (!IsWritingMailAllowed(gSpecialVar_ItemId)) { - DisplayItemMessage(taskId, 1, gText_CantWriteMail, HandleErrorMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gText_CantWriteMail, HandleErrorMessage); } else if (!IsHoldingItemAllowed(gSpecialVar_ItemId)) { CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_Var1CantBeHeldHere); - DisplayItemMessage(taskId, 1, gStringVar4, HandleErrorMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, HandleErrorMessage); } else if (gBagPosition.pocket != KEYITEMS_POCKET && !ItemId_GetImportance(gSpecialVar_ItemId)) { @@ -2023,7 +2023,7 @@ static void Task_ItemContext_GiveToParty(u8 taskId) static void Task_ItemContext_GiveToPC(u8 taskId) { if (ItemIsMail(gSpecialVar_ItemId) == TRUE) - DisplayItemMessage(taskId, 1, gText_CantWriteMail, HandleErrorMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gText_CantWriteMail, HandleErrorMessage); else if (gBagPosition.pocket != KEYITEMS_POCKET && !ItemId_GetImportance(gSpecialVar_ItemId)) gTasks[taskId].func = Task_FadeAndCloseBagMenu; else @@ -2039,7 +2039,7 @@ bool8 UseRegisteredKeyItemOnField(void) if (InUnionRoom() == TRUE || InBattlePyramid() || InBattlePike() || InMultiPartnerRoom() == TRUE) return FALSE; HideMapNamePopUpWindow(); - ChangeBgY_ScreenOff(0, 0, 0); + ChangeBgY_ScreenOff(0, 0, BG_COORD_SET); if (gSaveBlock1Ptr->registeredItem != ITEM_NONE) { if (CheckBagHasItem(gSaveBlock1Ptr->registeredItem, 1) == TRUE) @@ -2072,7 +2072,7 @@ static void Task_ItemContext_Sell(u8 taskId) { CopyItemName(gSpecialVar_ItemId, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_CantBuyKeyItem); - DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage); } else { @@ -2086,7 +2086,7 @@ static void Task_ItemContext_Sell(u8 taskId) { CopyItemName(gSpecialVar_ItemId, gStringVar2); StringExpandPlaceholders(gStringVar4, gText_HowManyToSell); - DisplayItemMessage(taskId, 1, gStringVar4, InitSellHowManyInput); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, InitSellHowManyInput); } } } @@ -2097,7 +2097,7 @@ static void DisplaySellItemPriceAndConfirm(u8 taskId) ConvertIntToDecimalStringN(gStringVar1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount, STR_CONV_MODE_LEFT_ALIGN, 6); StringExpandPlaceholders(gStringVar4, gText_ICanPayVar1); - DisplayItemMessage(taskId, 1, gStringVar4, AskSellItems); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, AskSellItems); } static void AskSellItems(u8 taskId) @@ -2157,7 +2157,7 @@ static void ConfirmSell(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar2); ConvertIntToDecimalStringN(gStringVar1, (ItemId_GetPrice(gSpecialVar_ItemId) / 2) * tItemCount, STR_CONV_MODE_LEFT_ALIGN, 6); StringExpandPlaceholders(gStringVar4, gText_TurnedOverVar1ForVar2); - DisplayItemMessage(taskId, 1, gStringVar4, SellItem); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, SellItem); } static void SellItem(u8 taskId) @@ -2203,7 +2203,7 @@ static void Task_ItemContext_Deposit(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar1); StringExpandPlaceholders(gStringVar4, gText_DepositHowManyVar1); FillWindowPixelBuffer(WIN_DESCRIPTION, PIXEL_FILL(0)); - BagMenu_Print(WIN_DESCRIPTION, 1, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); AddItemQuantityWindow(ITEMWIN_QUANTITY); gTasks[taskId].func = Task_ChooseHowManyToDeposit; } @@ -2241,7 +2241,7 @@ static void TryDepositItem(u8 taskId) if (ItemId_GetImportance(gSpecialVar_ItemId)) { // Can't deposit important items - BagMenu_Print(WIN_DESCRIPTION, 1, gText_CantStoreImportantItems, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gText_CantStoreImportantItems, 3, 1, 0, 0, 0, COLORID_NORMAL); gTasks[taskId].func = WaitDepositErrorMessage; } else if (AddPCItem(gSpecialVar_ItemId, tItemCount) == TRUE) @@ -2250,13 +2250,13 @@ static void TryDepositItem(u8 taskId) CopyItemName(gSpecialVar_ItemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, tItemCount, STR_CONV_MODE_LEFT_ALIGN, MAX_ITEM_DIGITS); StringExpandPlaceholders(gStringVar4, gText_DepositedVar2Var1s); - BagMenu_Print(WIN_DESCRIPTION, 1, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gStringVar4, 3, 1, 0, 0, 0, COLORID_NORMAL); gTasks[taskId].func = Task_RemoveItemFromBag; } else { // No room to deposit - BagMenu_Print(WIN_DESCRIPTION, 1, gText_NoRoomForItems, 3, 1, 0, 0, 0, COLORID_NORMAL); + BagMenu_Print(WIN_DESCRIPTION, FONT_NORMAL, gText_NoRoomForItems, 3, 1, 0, 0, 0, COLORID_NORMAL); gTasks[taskId].func = WaitDepositErrorMessage; } } @@ -2416,12 +2416,12 @@ static void PrintPocketNames(const u8 *pocketName1, const u8 *pocketName2) window.height = 2; windowId = AddWindow(&window); FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); - offset = GetStringCenterAlignXOffset(1, pocketName1, 0x40); - BagMenu_Print(windowId, 1, pocketName1, offset, 1, 0, 0, TEXT_SPEED_FF, COLORID_POCKET_NAME); + offset = GetStringCenterAlignXOffset(FONT_NORMAL, pocketName1, 0x40); + BagMenu_Print(windowId, FONT_NORMAL, pocketName1, offset, 1, 0, 0, TEXT_SKIP_DRAW, COLORID_POCKET_NAME); if (pocketName2) { - offset = GetStringCenterAlignXOffset(1, pocketName2, 0x40); - BagMenu_Print(windowId, 1, pocketName2, offset + 0x40, 1, 0, 0, TEXT_SPEED_FF, COLORID_POCKET_NAME); + offset = GetStringCenterAlignXOffset(FONT_NORMAL, pocketName2, 0x40); + BagMenu_Print(windowId, FONT_NORMAL, pocketName2, offset + 0x40, 1, 0, 0, TEXT_SKIP_DRAW, COLORID_POCKET_NAME); } CpuCopy32((u8*)GetWindowAttribute(windowId, WINDOW_TILE_DATA), gBagMenu->pocketNameBuffer, sizeof(gBagMenu->pocketNameBuffer)); RemoveWindow(windowId); @@ -2439,7 +2439,7 @@ static void CopyPocketNameToWindow(u32 a) CpuCopy32(tileDataBuffer[0][a], windowTileData, 0x100); // Top half of pocket name b = a + 16; CpuCopy32(tileDataBuffer[0][b], windowTileData + 0x100, 0x100); // Bottom half of pocket name - CopyWindowToVram(WIN_POCKET_NAME, 2); + CopyWindowToVram(WIN_POCKET_NAME, COPYWIN_GFX); } static void LoadBagMenuTextWindows(void) @@ -2451,7 +2451,7 @@ static void LoadBagMenuTextWindows(void) LoadUserWindowBorderGfx(0, 1, 0xE0); LoadMessageBoxGfx(0, 10, 0xD0); ListMenuLoadStdPalAt(0xC0, 1); - LoadPalette(&gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(&gStandardMenuPalette, 0xF0, 0x20); for (i = 0; i <= WIN_POCKET_NAME; i++) { FillWindowPixelBuffer(i, PIXEL_FILL(0)); @@ -2544,7 +2544,7 @@ static void PrepareTMHMMoveWindow(void) BlitMenuInfoIcon(WIN_TMHM_INFO_ICONS, MENU_INFO_ICON_POWER, 0, 12); BlitMenuInfoIcon(WIN_TMHM_INFO_ICONS, MENU_INFO_ICON_ACCURACY, 0, 24); BlitMenuInfoIcon(WIN_TMHM_INFO_ICONS, MENU_INFO_ICON_PP, 0, 36); - CopyWindowToVram(WIN_TMHM_INFO_ICONS, 2); + CopyWindowToVram(WIN_TMHM_INFO_ICONS, COPYWIN_GFX); } static void PrintTMHMMoveData(u16 itemId) @@ -2557,8 +2557,8 @@ static void PrintTMHMMoveData(u16 itemId) if (itemId == ITEM_NONE) { for (i = 0; i < 4; i++) - BagMenu_Print(WIN_TMHM_INFO, 1, gText_ThreeDashes, 7, i * 12, 0, 0, TEXT_SPEED_FF, COLORID_TMHM_INFO); - CopyWindowToVram(WIN_TMHM_INFO, 2); + BagMenu_Print(WIN_TMHM_INFO, FONT_NORMAL, gText_ThreeDashes, 7, i * 12, 0, 0, TEXT_SKIP_DRAW, COLORID_TMHM_INFO); + CopyWindowToVram(WIN_TMHM_INFO, COPYWIN_GFX); } else { @@ -2575,7 +2575,7 @@ static void PrintTMHMMoveData(u16 itemId) ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].power, STR_CONV_MODE_RIGHT_ALIGN, 3); text = gStringVar1; } - BagMenu_Print(WIN_TMHM_INFO, 1, text, 7, 12, 0, 0, TEXT_SPEED_FF, COLORID_TMHM_INFO); + BagMenu_Print(WIN_TMHM_INFO, FONT_NORMAL, text, 7, 12, 0, 0, TEXT_SKIP_DRAW, COLORID_TMHM_INFO); // Print TMHM accuracy if (gBattleMoves[moveId].accuracy == 0) @@ -2587,12 +2587,12 @@ static void PrintTMHMMoveData(u16 itemId) ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].accuracy, STR_CONV_MODE_RIGHT_ALIGN, 3); text = gStringVar1; } - BagMenu_Print(WIN_TMHM_INFO, 1, text, 7, 24, 0, 0, TEXT_SPEED_FF, COLORID_TMHM_INFO); + BagMenu_Print(WIN_TMHM_INFO, FONT_NORMAL, text, 7, 24, 0, 0, TEXT_SKIP_DRAW, COLORID_TMHM_INFO); // Print TMHM pp ConvertIntToDecimalStringN(gStringVar1, gBattleMoves[moveId].pp, STR_CONV_MODE_RIGHT_ALIGN, 3); - BagMenu_Print(WIN_TMHM_INFO, 1, gStringVar1, 7, 36, 0, 0, TEXT_SPEED_FF, COLORID_TMHM_INFO); + BagMenu_Print(WIN_TMHM_INFO, FONT_NORMAL, gStringVar1, 7, 36, 0, 0, TEXT_SKIP_DRAW, COLORID_TMHM_INFO); - CopyWindowToVram(WIN_TMHM_INFO, 2); + CopyWindowToVram(WIN_TMHM_INFO, COPYWIN_GFX); } } diff --git a/src/item_use.c b/src/item_use.c index 833e80b97..29ceb7cae 100755 --- a/src/item_use.c +++ b/src/item_use.c @@ -143,7 +143,7 @@ static void DisplayCannotUseItemMessage(u8 taskId, bool8 isUsingRegisteredKeyIte if (!isUsingRegisteredKeyItemOnField) { if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage); else DisplayItemMessageInBattlePyramid(taskId, gText_DadsAdvice, Task_CloseBattlePyramidBagMessage); } @@ -612,7 +612,7 @@ static void Task_StandingOnHiddenItem(u8 taskId) void ItemUseOutOfBattle_PokeblockCase(u8 taskId) { - if (MenuHelpers_LinkSomething() == TRUE) // link func + if (MenuHelpers_IsLinkActive() == TRUE) { DisplayDadsAdviceCannotUseItemMessage(taskId, gTasks[taskId].tUsingRegisteredKeyItem); } @@ -651,7 +651,7 @@ void ItemUseOutOfBattle_CoinCase(u8 taskId) if (!gTasks[taskId].tUsingRegisteredKeyItem) { - DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage); } else { @@ -666,7 +666,7 @@ void ItemUseOutOfBattle_PowderJar(u8 taskId) if (!gTasks[taskId].tUsingRegisteredKeyItem) { - DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage); } else { @@ -782,9 +782,9 @@ void ItemUseOutOfBattle_RareCandy(u8 taskId) void ItemUseOutOfBattle_TMHM(u8 taskId) { if (gSpecialVar_ItemId >= ITEM_HM01_CUT) - DisplayItemMessage(taskId, 1, gText_BootedUpHM, BootUpSoundTMHM); // HM + DisplayItemMessage(taskId, FONT_NORMAL, gText_BootedUpHM, BootUpSoundTMHM); // HM else - DisplayItemMessage(taskId, 1, gText_BootedUpTM, BootUpSoundTMHM); // TM + DisplayItemMessage(taskId, FONT_NORMAL, gText_BootedUpTM, BootUpSoundTMHM); // TM } static void BootUpSoundTMHM(u8 taskId) @@ -799,7 +799,7 @@ static void Task_ShowTMHMContainedMessage(u8 taskId) { StringCopy(gStringVar1, gMoveNames[ItemIdToBattleMoveId(gSpecialVar_ItemId)]); StringExpandPlaceholders(gStringVar4, gText_TMHMContainedVar1); - DisplayItemMessage(taskId, 1, gStringVar4, UseTMHMYesNo); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, UseTMHMYesNo); } } @@ -836,7 +836,7 @@ void ItemUseOutOfBattle_Repel(u8 taskId) if (VarGet(VAR_REPEL_STEP_COUNT) == 0) gTasks[taskId].func = Task_StartUseRepel; else if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, gText_RepelEffectsLingered, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gText_RepelEffectsLingered, CloseItemMessage); else DisplayItemMessageInBattlePyramid(taskId, gText_RepelEffectsLingered, Task_CloseBattlePyramidBagMessage); } @@ -860,7 +860,7 @@ static void Task_UseRepel(u8 taskId) VarSet(VAR_REPEL_STEP_COUNT, ItemId_GetHoldEffectParam(gSpecialVar_ItemId)); RemoveUsedItem(); if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage); else DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage); } @@ -872,7 +872,7 @@ static void Task_UsedBlackWhiteFlute(u8 taskId) { PlaySE(SE_GLASS_FLUTE); if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, gStringVar4, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, CloseItemMessage); else DisplayItemMessageInBattlePyramid(taskId, gStringVar4, Task_CloseBattlePyramidBagMessage); } @@ -951,7 +951,7 @@ void ItemUseInBattle_PokeBall(u8 taskId) } else if (!InBattlePyramid()) { - DisplayItemMessage(taskId, 1, gText_BoxFull, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gText_BoxFull, CloseItemMessage); } else DisplayItemMessageInBattlePyramid(taskId, gText_BoxFull, Task_CloseBattlePyramidBagMessage); @@ -975,7 +975,7 @@ static void Task_UseStatIncreaseItem(u8 taskId) PlaySE(SE_USE_ITEM); RemoveBagItem(gSpecialVar_ItemId, 1); if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, UseStatIncreaseItem(gSpecialVar_ItemId), Task_CloseStatIncreaseMessage); + DisplayItemMessage(taskId, FONT_NORMAL, UseStatIncreaseItem(gSpecialVar_ItemId), Task_CloseStatIncreaseMessage); else DisplayItemMessageInBattlePyramid(taskId, UseStatIncreaseItem(gSpecialVar_ItemId), Task_CloseStatIncreaseMessage); } @@ -989,7 +989,7 @@ void ItemUseInBattle_StatIncrease(u8 taskId) if (ExecuteTableBasedItemEffect(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE) { if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, gText_WontHaveEffect, CloseItemMessage); + DisplayItemMessage(taskId, FONT_NORMAL, gText_WontHaveEffect, CloseItemMessage); else DisplayItemMessageInBattlePyramid(taskId, gText_WontHaveEffect, Task_CloseBattlePyramidBagMessage); } @@ -1041,7 +1041,7 @@ void ItemUseInBattle_Escape(u8 taskId) { RemoveUsedItem(); if (!InBattlePyramid()) - DisplayItemMessage(taskId, 1, gStringVar4, Task_FadeAndCloseBagMenu); + DisplayItemMessage(taskId, FONT_NORMAL, gStringVar4, Task_FadeAndCloseBagMenu); else DisplayItemMessageInBattlePyramid(taskId, gStringVar4, CloseBattlePyramidBag); } diff --git a/src/libgcnmultiboot.s b/src/libgcnmultiboot.s index dbf70ccf8..5ecc7d2f9 100644 --- a/src/libgcnmultiboot.s +++ b/src/libgcnmultiboot.s @@ -4,11 +4,36 @@ .include "asm/macros.inc" .include "constants/constants.inc" + .equiv GCMB_STRUCT_COUNTER1, 0x00 + .equiv GCMB_STRUCT_COUNTER2, 0x01 + .equiv GCMB_STRUCT_MBPROGRESS, 0x02 + .equiv GCMB_STRUCT_SAVEDVCOUNT, 0x03 + .equiv GCMB_STRUCT_KEYA, 0x04 + .equiv GCMB_STRUCT_KEYB, 0x08 + .equiv GCMB_STRUCT_KEYC, 0x0C + .equiv GCMB_STRUCT_BOOT_KEY, 0x10 + .equiv GCMB_STRUCT_IMAGE_SIZE, 0x12 + .equiv GCMB_STRUCT_SESSION_KEY, 0x14 + .equiv GCMB_STRUCT_HASH_VAL, 0x18 + .equiv GCMB_STRUCT_KEYC_DERIVATION, 0x1C .equiv GCMB_STRUCT_BASE_DEST_PTR, 0x20 .equiv GCMB_STRUCT_CUR_DEST_PTR, 0x24 .equiv GCMB_STRUCT_SERIAL_INTR_HANDLER, 0x28 - .equiv ROM_HEADER_NINTENDO_LOGO_OFFSET, 0x4 + .equiv ROM_HEADER_NINTENDO_LOGO_OFFSET, 0x04 + .equiv ROM_HEADER_NINTENDO_LOGO_LENGTH, 0x98 + .equiv ROM_HEADER_NINTENDO_LOGO_END, 0xA0 + + .equiv MBPROGRESS_NONE, 0x00 + .equiv MBPROGRESS_LOGO_CORRECT, 0x01 + .equiv MBPROGRESS_READY_TO_BOOT, 0x02 + + .equiv GCMB_MAGIC_BOOTKEY_HASHVAL, 0xBB + .equiv GCMB_MAGIC_BOOTKEY, 0xBB + .equiv GCMB_MAGIC_COUNTER2, 0xCC + .equiv GCMB_MAGIC_KEYA, 0xDD + .equiv GCMB_MAGIC_KEYB, 0xEE + .equiv GCMB_MAGIC_KEYCDERIVATION, 0xFF .syntax unified @@ -22,7 +47,7 @@ GameCubeMultiBoot_Hash: @ 82DED70 movs r2, 0x20 GameCubeMultiBoot_Hash_Loop: - lsrs r3, #1 + lsrs r3, 1 bcc GameCubeMultiBoot_Hash_SkipEor eors r3, r4 @@ -37,137 +62,177 @@ GameCubeMultiBoot_Hash_SkipEor: thumb_func_start GameCubeMultiBoot_Main @ void GameCubeMultiBoot_Main(struct GameCubeMultiBoot *mb); GameCubeMultiBoot_Main: @ 82DED84 - ldr r1, [r0, #GCMB_STRUCT_SERIAL_INTR_HANDLER] - cmp r1, #0 - beq _082DEDAA - ldrb r1, [r0, 0x1] + @ If there is no interrupt handler, skip counter manipulation + ldr r1, [r0, GCMB_STRUCT_SERIAL_INTR_HANDLER] + cmp r1, 0 + beq GameCubeMultiBoot_Main_SkipCounters + @ Increment the second counter + ldrb r1, [r0, GCMB_STRUCT_COUNTER2] adds r1, 0x1 - strb r1, [r0, 0x1] - ldrb r1, [r0, 0x2] - cmp r1, 0x2 - beq _082DEDF4 + strb r1, [r0, GCMB_STRUCT_COUNTER2] + @ If there is nothing more to do, bail out + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] + cmp r1, MBPROGRESS_READY_TO_BOOT + beq GameCubeMultiBoot_Main_Return + @ Save current interrupt master register value ldr r3, pool_InterruptRegs - ldrh r2, [r3, #OFFSET_REG_IME - 0x200] + ldrh r2, [r3, OFFSET_REG_IME - 0x200] + @ Disable all interrupts movs r1, 0 - strh r1, [r3, #OFFSET_REG_IME - 0x200] - ldrb r1, [r0] + strh r1, [r3, OFFSET_REG_IME - 0x200] + @ Increment the first counter, if it's less than or equal to 10. + ldrb r1, [r0, GCMB_STRUCT_COUNTER1] cmp r1, 0xA - bgt _082DEDA8 + bgt GameCubeMultiBoot_Main_SkipCounter1Inc adds r1, 0x1 - strb r1, [r0] -_082DEDA8: - strh r2, [r3, #OFFSET_REG_IME - 0x200] -_082DEDAA: + strb r1, [r0, GCMB_STRUCT_COUNTER1] +GameCubeMultiBoot_Main_SkipCounter1Inc: + @ Load the saved interrupt master register value (re-enables interrupts if they were enabled before) + strh r2, [r3, OFFSET_REG_IME - 0x200] +GameCubeMultiBoot_Main_SkipCounters: + @ Initialise multiboot structures if required bcs GameCubeMultiBoot_Init - ldrb r1, [r0, 0x2] - cmp r1, 0 - bne _082DEDF6 - ldr r1, [r0, #GCMB_STRUCT_CUR_DEST_PTR] - ldr r2, [r0, #GCMB_STRUCT_BASE_DEST_PTR] + @ Skip this section (check Nintendo logo) if the check has already passed + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] + cmp r1, MBPROGRESS_NONE + bne GameCubeMultiBoot_Main_SkipLogoCheck + @ Bail out if no multiboot image data has been transferred yet + ldr r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + ldr r2, [r0, GCMB_STRUCT_BASE_DEST_PTR] subs r1, r2 - beq _082DEE76 - cmp r1, 0xA0 - bcc _082DEE76 + beq GameCubeMultiBoot_Main_Return2 + @ Also bail out if not enough data has been transferred + cmp r1, ROM_HEADER_NINTENDO_LOGO_END + bcc GameCubeMultiBoot_Main_Return2 + @ Compare the Nintendo logo of the transferred multiboot image header, with the one in the ROM image of the inserted cart push {r4-r6} - movs r1, 0x98 - adds r2, #ROM_HEADER_NINTENDO_LOGO_OFFSET + movs r1, ROM_HEADER_NINTENDO_LOGO_LENGTH + adds r2, ROM_HEADER_NINTENDO_LOGO_OFFSET ldr r4, pool_NintendoLogo -_082DEDC6: +GameCubeMultiBoot_Main_LogoCmpLoop: ldm r2!, {r5} ldm r4!, {r6} cmp r5, r6 - bne _082DEDDC + bne GameCubeMultiBoot_Main_LogoCmpEnd subs r1, 0x4 - bne _082DEDC6 + bne GameCubeMultiBoot_Main_LogoCmpLoop ldm r2!, {r5} ldm r4!, {r6} eors r5, r6 - lsrs r5, #8 - str r2, [r0, #GCMB_STRUCT_BASE_DEST_PTR] -_082DEDDC: + lsrs r5, 8 + str r2, [r0, GCMB_STRUCT_BASE_DEST_PTR] +GameCubeMultiBoot_Main_LogoCmpEnd: pop {r4-r6} + @ Throw everything away if the logo data didn't match bne GameCubeMultiBoot_Init - movs r1, 0x1 - strb r1, [r0, 0x2] - ldr r1, [r0, 0x4] - ldr r2, [r0, 0x8] + @ Logo matched, set the relevent multiboot progress bit + movs r1, MBPROGRESS_LOGO_CORRECT + strb r1, [r0, GCMB_STRUCT_MBPROGRESS] + @ XOR together KeyA and KeyB to get the initial multiboot image checksum value + ldr r1, [r0, GCMB_STRUCT_KEYA] + ldr r2, [r0, GCMB_STRUCT_KEYB] eors r1, r2 - str r1, [r0, 0x18] + str r1, [r0, GCMB_STRUCT_HASH_VAL] + @ ...also use it as the initial value for the image encryption session key. Algorithm is the same as the GBA BIOS multiboot: sessionkey = (initialvalue * 0x6177614b) + 1 ldr r2, pool_Kawa muls r1, r2 adds r1, 0x1 - str r1, [r0, 0x14] -_082DEDF4: + str r1, [r0, GCMB_STRUCT_SESSION_KEY] +GameCubeMultiBoot_Main_Return: bx lr -_082DEDF6: - ldr r1, [r0, #GCMB_STRUCT_CUR_DEST_PTR] +GameCubeMultiBoot_Main_SkipLogoCheck: + @ If this code is executed, then the logo check has passed, and the data being transferred in is encrypted. + @ Set up registers. + ldr r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] mov r12, r1 - ldr r3, [r0, 0x18] + ldr r3, [r0, GCMB_STRUCT_HASH_VAL] push {r4-r7} - ldr r4, [r0, #GCMB_STRUCT_BASE_DEST_PTR] + ldr r4, [r0, GCMB_STRUCT_BASE_DEST_PTR] ldr r5, pool_Kawa - ldr r6, [r0, 0x14] + ldr r6, [r0, GCMB_STRUCT_SESSION_KEY] ldr r7, pool_HashVal -_082DEE06: +GameCubeMultiBoot_Main_ImageDecryptHashLoop: + @ If there's no more data, break out of the loop cmp r4, r12 - bcs _082DEE26 + bcs GameCubeMultiBoot_Main_ImageDecryptHashEnd + @ Get the next uint32 ldr r1, [r4] + @ Decrypt the ciphertext: plaintext = (ciphertext ^ sessionkey) + hashval eors r1, r6 adds r1, r3 + @ Save the current uint32 of plaintext and advance the pointer stm r4!, {r1} + @ Advance the hashval with this uint32 of plaintext -- this is the same code as GameCubeMultiBoot_Hash. eors r3, r1 movs r2, 0x20 -_082DEE16: - lsrs r3, #1 - bcc _082DEE1C +GameCubeMultiBoot_Main_HashLoop: + lsrs r3, 1 + bcc GameCubeMultiBoot_Main_HashSkipEor eors r3, r7 -_082DEE1C: +GameCubeMultiBoot_Main_HashSkipEor: subs r2, 0x1 - bne _082DEE16 + bne GameCubeMultiBoot_Main_HashLoop + @ Advance the sessionkey with the usual algorithm: sessionkey = (sessionkey * 0x6177614b) + 1 muls r6, r5 adds r6, 0x1 - b _082DEE06 -_082DEE26: - str r4, [r0, #GCMB_STRUCT_BASE_DEST_PTR] - str r6, [r0, 0x14] + b GameCubeMultiBoot_Main_ImageDecryptHashLoop +GameCubeMultiBoot_Main_ImageDecryptHashEnd: + @ Save the new pointer, sessionkey, hashval + str r4, [r0, GCMB_STRUCT_BASE_DEST_PTR] + str r6, [r0, GCMB_STRUCT_SESSION_KEY] pop {r4-r7} - str r3, [r0, 0x18] - ldrh r1, [r0, 0x12] - cmp r1, #0 - bne _082DEE76 - ldr r1, [r0, #GCMB_STRUCT_CUR_DEST_PTR] - ldr r2, [r0, #GCMB_STRUCT_BASE_DEST_PTR] + str r3, [r0, GCMB_STRUCT_HASH_VAL] + @ Bail out if the image size is unknown + ldrh r1, [r0, GCMB_STRUCT_IMAGE_SIZE] + cmp r1, 0 + bne GameCubeMultiBoot_Main_Return2 + @ Bail out if no image data has been transferred + ldr r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + ldr r2, [r0, GCMB_STRUCT_BASE_DEST_PTR] cmp r1, r2 - bne _082DEE76 - ldr r1, [r0, 0xC] - cmp r1, #0 - beq _082DEE60 - ldrh r1, [r0, 0x10] - cmp r1, #0 - beq _082DEDF4 + bne GameCubeMultiBoot_Main_Return2 + @ If KeyC hasn't been generated yet, go generate it + ldr r1, [r0, GCMB_STRUCT_KEYC] + cmp r1, 0 + beq GameCubeMultiBoot_Main_GenerateKeyC + @ If the other side hasn't sent its boot key yet, bail out + ldrh r1, [r0, GCMB_STRUCT_BOOT_KEY] + cmp r1, 0 + beq GameCubeMultiBoot_Main_Return + @ Save off LR so it doesn't get clobbered by the upcoming function call mov r12, lr - movs r1, 0xBB - ldr r3, [r0, 0xC] + @ Generate the real boot key, which is the checksum of a hardcoded value and KeyC + movs r1, GCMB_MAGIC_BOOTKEY_HASHVAL + ldr r3, [r0, GCMB_STRUCT_KEYC] bl GameCubeMultiBoot_Hash - ldrh r1, [r0, 0x10] + ldrh r1, [r0, GCMB_STRUCT_BOOT_KEY] + @ Restore the saved LR value mov lr, r12 + @ Compare the two boot keys (real and passed in), if they don't match then throw everything away subs r1, r3 bne GameCubeMultiBoot_Init - movs r1, 0x2 - strb r1, [r0, 0x2] + @ The two boot keys matched, tell the caller that the image is ready to boot + movs r1, MBPROGRESS_READY_TO_BOOT + strb r1, [r0, GCMB_STRUCT_MBPROGRESS] + @ Nothing more to do, return. bx lr -_082DEE60: +GameCubeMultiBoot_Main_GenerateKeyC: + @ Save off LR so it doesn't get clobbered by the upcoming function call mov r12, lr - ldrb r1, [r0, 0x3] - lsls r1, #24 + @ KeyC = (SavedVCount << 24) - 1 + ldrb r1, [r0, GCMB_STRUCT_SAVEDVCOUNT] + lsls r1, 24 subs r1, 0x1 - str r1, [r0, 0xC] + str r1, [r0, GCMB_STRUCT_KEYC] + @ Hash the KeyC with the multiboot image checksum to generate the KeyC derivation material to be sent to the other side of the link bl GameCubeMultiBoot_Hash - lsls r3, #8 - adds r3, 0xFF - str r3, [r0, 0x1C] + @ Make sure the sent KeyC derivation material contains a magic value so that the other side can detect it + lsls r3, 8 + adds r3, GCMB_MAGIC_KEYCDERIVATION + @ Save off the KeyC derivation material and return to caller + str r3, [r0, GCMB_STRUCT_KEYC_DERIVATION] bx r12 -_082DEE76: +GameCubeMultiBoot_Main_Return2: bx lr thumb_func_end GameCubeMultiBoot_Main @@ -182,12 +247,15 @@ pool_NintendoLogo: .4byte RomHeaderNintendoLogo thumb_func_start GameCubeMultiBoot_ExecuteProgram @ void GameCubeMultiBoot_ExecuteProgram(struct GameCubeMultiBoot *mb); GameCubeMultiBoot_ExecuteProgram: @ 82DEE84 - ldrb r1, [r0, 0x2] - cmp r1, 0x2 + @ If there's no multiboot image ready, just return to caller + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] + cmp r1, MBPROGRESS_READY_TO_BOOT bne GameCubeMultiBoot_ExecuteProgram_Fail + @ Disable interrupts ldr r3, pool_InterruptRegs - movs r1, #0 - strh r1, [r3, #OFFSET_REG_IME - 0x200] + movs r1, 0 + strh r1, [r3, OFFSET_REG_IME - 0x200] + @ Jump to the real entry point of the multiboot image (past the image header), in ARM mode ldr r1, pool_MultiBootLoadAddr adds r1, 0xC0 bx r1 @@ -201,25 +269,25 @@ GameCubeMultiBoot_Init: @ 82DEE98 ldr r3, pool_InterruptRegs @ Save IME register. - ldrh r2, [r3, #OFFSET_REG_IME - 0x200] + ldrh r2, [r3, OFFSET_REG_IME - 0x200] @ Disable interrupts. movs r1, 0 - strh r1, [r3, #OFFSET_REG_IME - 0x200] + strh r1, [r3, OFFSET_REG_IME - 0x200] @ Set the handler to the "Stop" routine. @ Unless the first command that is received is a device reset command, the @ "Stop" routine will be executed and no further commands will be processed. adr r3, GcMbIntrHandler_Stop - str r3, [r0, #GCMB_STRUCT_SERIAL_INTR_HANDLER] + str r3, [r0, GCMB_STRUCT_SERIAL_INTR_HANDLER] ldrb r3, [r0, 0x3] push {r3} ldrb r3, [r0, 0x1] push {r0,r3} - adds r3, r0, #0 - adds r3, #GCMB_STRUCT_BASE_DEST_PTR + adds r3, r0, 0 + adds r3, GCMB_STRUCT_BASE_DEST_PTR @ clear all but the last 3 fields of the struct GameCubeMultiBoot_Init_ClearStructLoop: @@ -261,7 +329,7 @@ GameCubeMultiBoot_Init_ClearStructLoop: strh r1, [r3, OFFSET_REG_IE - 0x200] @ Restore IME register. - strh r2, [r3, #OFFSET_REG_IME - 0x200] + strh r2, [r3, OFFSET_REG_IME - 0x200] bx lr thumb_func_end GameCubeMultiBoot_Init @@ -275,11 +343,11 @@ GameCubeMultiBoot_HandleSerialInterrupt: @ 82DEEE2 ldrh r1, [r3, OFFSET_REG_JOYCNT - 0x120] strh r1, [r3, OFFSET_REG_JOYCNT - 0x120] - movs r2, #0 + movs r2, 0 strb r2, [r0] - ldr r2, [r0, #GCMB_STRUCT_SERIAL_INTR_HANDLER] - cmp r2, #0 + ldr r2, [r0, GCMB_STRUCT_SERIAL_INTR_HANDLER] + cmp r2, 0 beq GameCubeMultiBoot_HandleSerialInterruptDone lsrs r1, 1 @ was a device reset command received? @@ -297,7 +365,7 @@ GcMbIntrHandler_Stop: strh r2, [r3, OFFSET_REG_JOYSTAT - 0x120] GameCubeMultiBoot_SetInterruptHandler: - str r2, [r0, #GCMB_STRUCT_SERIAL_INTR_HANDLER] + str r2, [r0, GCMB_STRUCT_SERIAL_INTR_HANDLER] GameCubeMultiBoot_ReadVCount: ldr r3, pool_RegDispstat @@ -308,19 +376,25 @@ GameCubeMultiBoot_HandleSerialInterruptDone: bx lr GameCubeMultiBoot_BeginHandshake: + @ Throw away anything that got sent ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + @ Send the game code, the other side of the link must send back the same game code ldr r1, pool_RubyUSAGameCode str r1, [r3, OFFSET_REG_JOY_TRANS - 0x120] movs r1, 0x10 strh r1, [r3, OFFSET_REG_JOYSTAT - 0x120] - ldrb r1, [r0, 0x3] - strb r1, [r0, 0x9] - ldrb r1, [r0, 0x2] + @ Use the saved VCount value to provide 8 bits of entropy for KeyB + ldrb r1, [r0, GCMB_STRUCT_SAVEDVCOUNT] + strb r1, [r0, GCMB_STRUCT_KEYB + 1] + @ If a multiboot image has been transferred at least enough such that the Nintendo logo check has passed, stop everything. + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] cmp r1, 0 bne GcMbIntrHandler_Stop + @ Set the image destination pointers. ldr r1, pool_MultiBootLoadAddr - str r1, [r0, #GCMB_STRUCT_BASE_DEST_PTR] - str r1, [r0, #GCMB_STRUCT_CUR_DEST_PTR] + str r1, [r0, GCMB_STRUCT_BASE_DEST_PTR] + str r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + @ Set the new interrupt handler. adr r2, GcMbIntrHandler_CheckGameCodeSent b GameCubeMultiBoot_SetInterruptHandler @@ -347,149 +421,166 @@ GameCubeMultiBoot_CheckHandshakeResponse: ldr r2, pool_RubyUSAGameCode cmp r1, r2 bne GcMbIntrHandler_Stop @ stop if the GameCube didn't reply with the same game code - ldrb r1, [r0, 0x3] - strb r1, [r0, 0xB] - adr r2, GcMbIntrHandler_82DEF44 + @ Use the saved VCount value to provide another 8 bits of entropy for KeyB. + ldrb r1, [r0, GCMB_STRUCT_SAVEDVCOUNT] + strb r1, [r0, GCMB_STRUCT_KEYB + 3] + adr r2, GcMbIntrHandler_ReceiveKeyA b GameCubeMultiBoot_SetInterruptHandler .align 2, 0 -GcMbIntrHandler_82DEF44: @ 82DEF44 +GcMbIntrHandler_ReceiveKeyA: @ 82DEF44 lsrs r1, 1 @ is receive complete? bcc GcMbIntrHandler_Stop @ branch if not ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + @ make sure top 8 bits of the received value is the KeyA magic number, stop if KeyA is invalid lsrs r2, r1, 24 - cmp r2, 0xDD + cmp r2, GCMB_MAGIC_KEYA bne GcMbIntrHandler_Stop - str r1, [r0, 0x4] - ldrb r1, [r0, 0x1] - strb r1, [r0, 0xA] + @ save received KeyA + str r1, [r0, GCMB_STRUCT_KEYA] + @ use the second GameCubeMultiBoot_Main() counter as another 8 bits of entropy for KeyB + ldrb r1, [r0, GCMB_STRUCT_COUNTER2] + strb r1, [r0, GCMB_STRUCT_KEYB + 2] movs r2, 0 movs r3, 0 - ldr r1, [r0, 0x8] + ldr r1, [r0, GCMB_STRUCT_KEYB] lsrs r1, 8 -_082DEF5E: + @ make sure KeyB is valid (other side of the link is supposed to check KeyB too), if it's not then change the byte that was just set so it is +GameCubeMultiBoot_KeyBCheckLoop: lsrs r1, 1 adcs r2, r3 cmp r1, 0 - bne _082DEF5E + bne GameCubeMultiBoot_KeyBCheckLoop cmp r2, 0xE - bgt _082DEF70 + bgt GameCubeMultiBoot_KeyBSaveNewByte cmp r2, 0x7 - bge _082DEF72 + bge GameCubeMultiBoot_KeyBCheckEnd movs r1, 0xFF -_082DEF70: - strb r1, [r0, 0xA] -_082DEF72: - ldr r1, [r0, 0x8] - adds r1, 0xEE +GameCubeMultiBoot_KeyBSaveNewByte: + strb r1, [r0, GCMB_STRUCT_KEYB + 2] +GameCubeMultiBoot_KeyBCheckEnd: + @ add in the KeyB magic number and send off KeyB + ldr r1, [r0, GCMB_STRUCT_KEYB] + adds r1, GCMB_MAGIC_KEYB ldr r3, pool_SerialRegs str r1, [r3, OFFSET_REG_JOY_TRANS - 0x120] movs r1, 0x30 strh r1, [r3, OFFSET_REG_JOYSTAT - 0x120] - adr r2, GcMbIntrHandler_82DEF84 + @ set new interrupt handler + adr r2, GcMbIntrHandler_CheckKeyBSent b GameCubeMultiBoot_SetInterruptHandler .align 2, 0 -GcMbIntrHandler_82DEF84: @ 82DEF84 +GcMbIntrHandler_CheckKeyBSent: @ 82DEF84 lsls r1, 31 bcc GcMbIntrHandler_Stop @ stop if send failed - bmi _082DEF94 @ branch if receive is complete - adr r2, GcMbIntrHandler_82DEF90 + bmi GameCubeMultiBoot_CheckImageSizeResponse @ branch if receive is complete + adr r2, GcMbIntrHandler_CheckImageSizeResponse b GameCubeMultiBoot_SetInterruptHandler .align 2, 0 -GcMbIntrHandler_82DEF90: @ 82DEF90 +GcMbIntrHandler_CheckImageSizeResponse: @ 82DEF90 lsrs r1, 1 @ is receive complete? bcc GcMbIntrHandler_Stop @ branch if not -_082DEF94: +GameCubeMultiBoot_CheckImageSizeResponse: ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] - ldr r2, _082DF034 + ldr r2, GameCubeMultiBoot_MaximumImageSizeUInt32s cmp r1, r2 bhs GcMbIntrHandler_Stop adds r1, 0x1 adds r1, r1 - strh r1, [r0, 0x12] - ldrb r1, [r0, 0x2] + strh r1, [r0, GCMB_STRUCT_IMAGE_SIZE] + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] cmp r1, 0 -_082DEFA6: +GcMbIntrHandler_StopIfNotEqual: bne GcMbIntrHandler_Stop ldr r1, pool_MultiBootLoadAddr - str r1, [r0, #GCMB_STRUCT_BASE_DEST_PTR] - str r1, [r0, #GCMB_STRUCT_CUR_DEST_PTR] - adr r2, GcMbIntrHandler_82DEFB4 + str r1, [r0, GCMB_STRUCT_BASE_DEST_PTR] + str r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + adr r2, GcMbIntrHandler_CheckImageResponse b GameCubeMultiBoot_SetInterruptHandler .align 2, 0 -GcMbIntrHandler_82DEFB4: @ 82DEFB4 +GcMbIntrHandler_CheckImageResponse: @ 82DEFB4 lsrs r1, 1 @ is receive complete? bcc GcMbIntrHandler_Stop @ branch if not - ldr r2, [r0, #GCMB_STRUCT_CUR_DEST_PTR] + ldr r2, [r0, GCMB_STRUCT_CUR_DEST_PTR] movs r1, 0x4 ands r1, r2 adds r1, 0x8 lsls r1, 2 strh r1, [r3, OFFSET_REG_JOYSTAT - 0x120] + @ get the recieved uint32 ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + @ put it in the current destination pointer and advance that pointer stm r2!, {r1} - str r2, [r0, #GCMB_STRUCT_CUR_DEST_PTR] - ldrh r1, [r0, 0x12] + @ save off the advanced pointer + str r2, [r0, GCMB_STRUCT_CUR_DEST_PTR] + @ decrease the image size (in uint32s) + ldrh r1, [r0, GCMB_STRUCT_IMAGE_SIZE] subs r1, 0x1 - strh r1, [r0, 0x12] + strh r1, [r0, GCMB_STRUCT_IMAGE_SIZE] + @ branch away if the transfer is not yet complete bne GameCubeMultiBoot_ReadVCount -_082DEFD2: - ldrb r1, [r0, 0x1] +GcMbIntrHandler_SendCounter2: + @ send counter2 with magic number + ldrb r1, [r0, GCMB_STRUCT_COUNTER2] lsls r1, 8 - adds r1, 0xCC + adds r1, GCMB_MAGIC_COUNTER2 str r1, [r3, OFFSET_REG_JOY_TRANS - 0x120] - adr r2, _082DEFE0 + adr r2, GcMbIntrHandler_CheckCounter2Sent b GameCubeMultiBoot_SetInterruptHandler .align 2, 0 -_082DEFE0: +GcMbIntrHandler_CheckCounter2Sent: lsls r1, 31 -_082DEFE2: - bcc GcMbIntrHandler_Stop - ldr r1, [r0, 0x1C] +GcMbIntrHandler_StopIfSendFailed: + bcc GcMbIntrHandler_Stop @ stop if send failed + @ if KeyC derivation value has not yet been generated, send Counter2 again, otherwise, send KeyC derivation + ldr r1, [r0, GCMB_STRUCT_KEYC_DERIVATION] cmp r1, 0 - beq _082DEFD2 + beq GcMbIntrHandler_SendCounter2 str r1, [r3, OFFSET_REG_JOY_TRANS - 0x120] - adr r2, GcMbIntrHandler_82DEFF0 + adr r2, GcMbIntrHandler_CheckKeyCDerivationSent b GameCubeMultiBoot_SetInterruptHandler .align 2, 0 -GcMbIntrHandler_82DEFF0: @ 82DEFF0 +GcMbIntrHandler_CheckKeyCDerivationSent: @ 82DEFF0 lsls r1, 31 - bcc _082DEFE2 @ branch if send failed - bmi _082DF000 @ branch if receive is complete - adr r2, GcMbIntrHandler_82DEFFC + bcc GcMbIntrHandler_StopIfSendFailed @ branch if send failed + bmi GameCubeMultiBoot_CheckBootKeyResponse @ branch if receive is complete + adr r2, GcMbIntrHandler_CheckBootKeyResponse b GameCubeMultiBoot_SetInterruptHandler .align 2, 0 -GcMbIntrHandler_82DEFFC: @ 82DEFFC +GcMbIntrHandler_CheckBootKeyResponse: @ 82DEFFC lsrs r1, 1 @ is receive complete? - bcc _082DEFE2 @ branch if not + bcc GcMbIntrHandler_StopIfSendFailed @ branch if not -_082DF000: +GameCubeMultiBoot_CheckBootKeyResponse: ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + @ make sure received boot key contains expected magic number, stop if not lsrs r2, r1, 24 - cmp r2, 0xBB - bne _082DEFA6 - strh r1, [r0, 0x10] - adr r2, GcMbIntrHandler_82DF010 + cmp r2, GCMB_MAGIC_BOOTKEY + bne GcMbIntrHandler_StopIfNotEqual + @ save received bootkey to be checked in GameCubeMultiBoot_Main() + strh r1, [r0, GCMB_STRUCT_BOOT_KEY] + @ stop if anything more gets sent + adr r2, GcMbIntrHandler_StopUnconditionally b GameCubeMultiBoot_SetInterruptHandler .align 2, 0 -GcMbIntrHandler_82DF010: @ 82DF010 +GcMbIntrHandler_StopUnconditionally: @ 82DF010 b GcMbIntrHandler_Stop thumb_func_end GameCubeMultiBoot_HandleSerialInterrupt @@ -500,11 +591,11 @@ GameCubeMultiBoot_Quit: @ 82DF012 ldr r3, pool_InterruptRegs @ Save IME register. - ldrh r2, [r3, #OFFSET_REG_IME - 0x200] + ldrh r2, [r3, OFFSET_REG_IME - 0x200] @ Disable interrupts. movs r1, 0 - strh r1, [r3, #OFFSET_REG_IME - 0x200] + strh r1, [r3, OFFSET_REG_IME - 0x200] ldr r3, pool_SerialRegs @@ -528,14 +619,14 @@ GameCubeMultiBoot_Quit: @ 82DF012 strh r1, [r3, OFFSET_REG_IE - 0x200] @ Restore IME register. - strh r2, [r3, #OFFSET_REG_IME - 0x200] + strh r2, [r3, OFFSET_REG_IME - 0x200] bx lr thumb_func_end GameCubeMultiBoot_Quit .align 2, 0 -_082DF034: .4byte 0x4000 +GameCubeMultiBoot_MaximumImageSizeUInt32s: .4byte 0x4000 pool_InterruptRegs: .4byte REG_BASE + 0x200 diff --git a/src/link.c b/src/link.c index 19b6d0f81..01cc06e7c 100644 --- a/src/link.c +++ b/src/link.c @@ -1622,7 +1622,7 @@ void CB2_LinkError(void) SetGpuReg(REG_OFFSET_BG1HOFS, 0); SetGpuReg(REG_OFFSET_BG1VOFS, 0); ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJWIN_ON); - LoadPalette(gUnknown_0860F074, 0xf0, 0x20); + LoadPalette(gStandardMenuPalette, 0xf0, 0x20); gSoftResetDisabled = FALSE; CreateTask(Task_DestroySelf, 0); StopMapMusic(); @@ -1644,12 +1644,12 @@ static void ErrorMsg_MoveCloserToPartner(void) LoadPalette(sWirelessLinkDisplayPal, 0, 0x20); FillWindowPixelBuffer(0, PIXEL_FILL(0)); FillWindowPixelBuffer(2, PIXEL_FILL(0)); - AddTextPrinterParameterized3(0, 3, 2, 6, sTextColors, 0, gText_CommErrorEllipsis); - AddTextPrinterParameterized3(2, 3, 2, 1, sTextColors, 0, gText_MoveCloserToLinkPartner); + AddTextPrinterParameterized3(0, FONT_SHORT_COPY_1, 2, 6, sTextColors, 0, gText_CommErrorEllipsis); + AddTextPrinterParameterized3(2, FONT_SHORT_COPY_1, 2, 1, sTextColors, 0, gText_MoveCloserToLinkPartner); PutWindowTilemap(0); PutWindowTilemap(2); - CopyWindowToVram(0, 0); - CopyWindowToVram(2, 3); + CopyWindowToVram(0, COPYWIN_NONE); // Does nothing + CopyWindowToVram(2, COPYWIN_FULL); } static void ErrorMsg_CheckConnections(void) @@ -1657,11 +1657,11 @@ static void ErrorMsg_CheckConnections(void) LoadBgTiles(0, sCommErrorBg_Gfx, 0x20, 0); FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(2, PIXEL_FILL(0)); - AddTextPrinterParameterized3(1, 3, 2, 0, sTextColors, 0, gText_CommErrorCheckConnections); + AddTextPrinterParameterized3(1, FONT_SHORT_COPY_1, 2, 0, sTextColors, 0, gText_CommErrorCheckConnections); PutWindowTilemap(1); PutWindowTilemap(2); - CopyWindowToVram(1, 0); - CopyWindowToVram(2, 3); + CopyWindowToVram(1, COPYWIN_NONE); // Does nothing + CopyWindowToVram(2, COPYWIN_FULL); } static void CB2_PrintErrorMessage(void) @@ -1692,9 +1692,9 @@ static void CB2_PrintErrorMessage(void) break; case 130: if (gWirelessCommType == 2) - AddTextPrinterParameterized3(0, 3, 2, 20, sTextColors, 0, gText_ABtnTitleScreen); + AddTextPrinterParameterized3(0, FONT_SHORT_COPY_1, 2, 20, sTextColors, 0, gText_ABtnTitleScreen); else if (gWirelessCommType == 1) - AddTextPrinterParameterized3(0, 3, 2, 20, sTextColors, 0, gText_ABtnRegistrationCounter); + AddTextPrinterParameterized3(0, FONT_SHORT_COPY_1, 2, 20, sTextColors, 0, gText_ABtnRegistrationCounter); break; } if (gMain.state == 160) @@ -1832,9 +1832,9 @@ u32 GetLinkRecvQueueLength(void) return gLink.recvQueue.count; } -bool32 IsLinkRecvQueueLengthAtLeast3(void) +bool32 IsLinkRecvQueueAtOverworldMax(void) { - if (GetLinkRecvQueueLength() > 2) + if (GetLinkRecvQueueLength() >= OVERWORLD_RECV_QUEUE_MAX) return TRUE; return FALSE; diff --git a/src/list_menu.c b/src/list_menu.c index 84b917eec..ccb183891 100644 --- a/src/list_menu.c +++ b/src/list_menu.c @@ -330,7 +330,7 @@ s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const str gMultiuseListMenuTemplate = *listMenuTemplate; gMultiuseListMenuTemplate.windowId = sMysteryGiftLinkMenu.windowId; sMysteryGiftLinkMenu.listTaskId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); - CopyWindowToVram(sMysteryGiftLinkMenu.windowId, 1); + CopyWindowToVram(sMysteryGiftLinkMenu.windowId, COPYWIN_MAP); sMysteryGiftLinkMenu.state = 1; break; case 1: @@ -364,7 +364,7 @@ s32 DoMysteryGiftListMenu(const struct WindowTemplate *windowTemplate, const str } } - CopyWindowToVram(sMysteryGiftLinkMenu.windowId, 1); + CopyWindowToVram(sMysteryGiftLinkMenu.windowId, COPYWIN_MAP); } break; case 2: @@ -381,7 +381,7 @@ u8 ListMenuInit(struct ListMenuTemplate *listMenuTemplate, u16 scrollOffset, u16 { u8 taskId = ListMenuInitInternal(listMenuTemplate, scrollOffset, selectedRow); PutWindowTilemap(listMenuTemplate->windowId); - CopyWindowToVram(listMenuTemplate->windowId, 2); + CopyWindowToVram(listMenuTemplate->windowId, COPYWIN_GFX); return taskId; } @@ -401,7 +401,7 @@ u8 ListMenuInitInRect(struct ListMenuTemplate *listMenuTemplate, struct ListMenu rect[i].height, rect[i].palNum); } - CopyWindowToVram(listMenuTemplate->windowId, 2); + CopyWindowToVram(listMenuTemplate->windowId, COPYWIN_GFX); return taskId; } @@ -489,7 +489,7 @@ void RedrawListMenu(u8 listTaskId) FillWindowPixelBuffer(list->template.windowId, PIXEL_FILL(list->template.fillValue)); ListMenuPrintEntries(list, list->scrollOffset, 0, list->template.maxShowed); ListMenuDrawCursor(list); - CopyWindowToVram(list->template.windowId, 2); + CopyWindowToVram(list->template.windowId, COPYWIN_GFX); } // unused @@ -604,7 +604,7 @@ static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y) gListMenuOverride.fontId, x, y, gListMenuOverride.lettersSpacing, - 0, colors, TEXT_SPEED_FF, str); + 0, colors, TEXT_SKIP_DRAW, str); gListMenuOverride.enabled = FALSE; } @@ -617,7 +617,7 @@ static void ListMenuPrint(struct ListMenu *list, const u8 *str, u8 x, u8 y) list->template.fontId, x, y, list->template.lettersSpacing, - 0, colors, TEXT_SPEED_FF, str); + 0, colors, TEXT_SKIP_DRAW, str); } } @@ -862,7 +862,7 @@ static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAn ListMenuErasePrintedCursor(list, oldSelectedRow); ListMenuDrawCursor(list); ListMenuCallSelectionChangedCallback(list, FALSE); - CopyWindowToVram(list->template.windowId, 2); + CopyWindowToVram(list->template.windowId, COPYWIN_GFX); break; case 2: case 3: @@ -870,7 +870,7 @@ static bool8 ListMenuChangeSelection(struct ListMenu *list, bool8 updateCursorAn ListMenuScroll(list, cursorCount, movingDown); ListMenuDrawCursor(list); ListMenuCallSelectionChangedCallback(list, FALSE); - CopyWindowToVram(list->template.windowId, 2); + CopyWindowToVram(list->template.windowId, COPYWIN_GFX); break; } } diff --git a/src/mail.c b/src/mail.c index 8bb6f6991..651fcbb84 100644 --- a/src/mail.c +++ b/src/mail.c @@ -593,10 +593,8 @@ static bool8 MailReadBuildGraphics(void) } break; case 15: - if (Overworld_LinkRecvQueueLengthMoreThan2() == TRUE) - { + if (Overworld_IsRecvQueueAtMax() == TRUE) return FALSE; - } break; case 16: SetVBlankCallback(VBlankCB_MailRead); @@ -641,7 +639,7 @@ static void CB2_InitMailRead(void) SetMainCallback2(CB2_MailRead); break; } - } while (MenuHelpers_LinkSomething() != TRUE); + } while (MenuHelpers_IsLinkActive() != TRUE); } static void BufferMailText(void) @@ -692,16 +690,16 @@ static void PrintMailText(void) if (sMailRead->message[i][0] == EOS || sMailRead->message[i][0] == CHAR_SPACE) continue; - AddTextPrinterParameterized3(0, 1, sMailRead->layout->lines[i].xOffset + sMailRead->layout->wordsXPos, y + sMailRead->layout->wordsYPos, sTextColors, 0, sMailRead->message[i]); + AddTextPrinterParameterized3(0, FONT_NORMAL, sMailRead->layout->lines[i].xOffset + sMailRead->layout->wordsXPos, y + sMailRead->layout->wordsYPos, sTextColors, 0, sMailRead->message[i]); y += sMailRead->layout->lines[i].height; } bufptr = StringCopy(signature, gText_FromSpace); StringCopy(bufptr, sMailRead->playerName); - box_x = GetStringCenterAlignXOffset(1, signature, sMailRead->signatureWidth) + 104; + box_x = GetStringCenterAlignXOffset(FONT_NORMAL, signature, sMailRead->signatureWidth) + 104; box_y = sMailRead->layout->signatureYPos + 88; - AddTextPrinterParameterized3(0, 1, box_x, box_y, sTextColors, 0, signature); - CopyWindowToVram(0, 3); - CopyWindowToVram(1, 3); + AddTextPrinterParameterized3(0, FONT_NORMAL, box_x, box_y, sTextColors, 0, signature); + CopyWindowToVram(0, COPYWIN_FULL); + CopyWindowToVram(1, COPYWIN_FULL); } static void VBlankCB_MailRead(void) diff --git a/src/main_menu.c b/src/main_menu.c index b2879968c..601e66cb9 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -583,10 +583,10 @@ static u32 InitMainMenu(bool8 returningFromOptionsMenu) BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_WHITEALPHA); // fade to white ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sMainMenuBgTemplates, ARRAY_COUNT(sMainMenuBgTemplates)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); InitWindows(sWindowTemplates_MainMenu); DeactivateAllTextPrinters(); LoadMainMenuWindowFrameTiles(0, MAIN_MENU_BORDER_TILE); @@ -780,12 +780,12 @@ static void Task_DisplayMainMenu(u8 taskId) default: FillWindowPixelBuffer(0, PIXEL_FILL(0xA)); FillWindowPixelBuffer(1, PIXEL_FILL(0xA)); - AddTextPrinterParameterized3(0, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuNewGame); - AddTextPrinterParameterized3(1, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuOption); + AddTextPrinterParameterized3(0, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuNewGame); + AddTextPrinterParameterized3(1, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuOption); PutWindowTilemap(0); PutWindowTilemap(1); - CopyWindowToVram(0, 2); - CopyWindowToVram(1, 2); + CopyWindowToVram(0, COPYWIN_GFX); + CopyWindowToVram(1, COPYWIN_GFX); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[0], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[1], MAIN_MENU_BORDER_TILE); break; @@ -793,16 +793,16 @@ static void Task_DisplayMainMenu(u8 taskId) FillWindowPixelBuffer(2, PIXEL_FILL(0xA)); FillWindowPixelBuffer(3, PIXEL_FILL(0xA)); FillWindowPixelBuffer(4, PIXEL_FILL(0xA)); - AddTextPrinterParameterized3(2, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuContinue); - AddTextPrinterParameterized3(3, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuNewGame); - AddTextPrinterParameterized3(4, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuOption); + AddTextPrinterParameterized3(2, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuContinue); + AddTextPrinterParameterized3(3, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuNewGame); + AddTextPrinterParameterized3(4, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuOption); MainMenu_FormatSavegameText(); PutWindowTilemap(2); PutWindowTilemap(3); PutWindowTilemap(4); - CopyWindowToVram(2, 2); - CopyWindowToVram(3, 2); - CopyWindowToVram(4, 2); + CopyWindowToVram(2, COPYWIN_GFX); + CopyWindowToVram(3, COPYWIN_GFX); + CopyWindowToVram(4, COPYWIN_GFX); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE); @@ -812,19 +812,19 @@ static void Task_DisplayMainMenu(u8 taskId) FillWindowPixelBuffer(3, PIXEL_FILL(0xA)); FillWindowPixelBuffer(4, PIXEL_FILL(0xA)); FillWindowPixelBuffer(5, PIXEL_FILL(0xA)); - AddTextPrinterParameterized3(2, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuContinue); - AddTextPrinterParameterized3(3, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuNewGame); - AddTextPrinterParameterized3(4, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuMysteryGift); - AddTextPrinterParameterized3(5, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuOption); + AddTextPrinterParameterized3(2, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuContinue); + AddTextPrinterParameterized3(3, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuNewGame); + AddTextPrinterParameterized3(4, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuMysteryGift); + AddTextPrinterParameterized3(5, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuOption); MainMenu_FormatSavegameText(); PutWindowTilemap(2); PutWindowTilemap(3); PutWindowTilemap(4); PutWindowTilemap(5); - CopyWindowToVram(2, 2); - CopyWindowToVram(3, 2); - CopyWindowToVram(4, 2); - CopyWindowToVram(5, 2); + CopyWindowToVram(2, COPYWIN_GFX); + CopyWindowToVram(3, COPYWIN_GFX); + CopyWindowToVram(4, COPYWIN_GFX); + CopyWindowToVram(5, COPYWIN_GFX); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE); @@ -836,22 +836,22 @@ static void Task_DisplayMainMenu(u8 taskId) FillWindowPixelBuffer(4, PIXEL_FILL(0xA)); FillWindowPixelBuffer(5, PIXEL_FILL(0xA)); FillWindowPixelBuffer(6, PIXEL_FILL(0xA)); - AddTextPrinterParameterized3(2, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuContinue); - AddTextPrinterParameterized3(3, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuNewGame); - AddTextPrinterParameterized3(4, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuMysteryGift2); - AddTextPrinterParameterized3(5, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuMysteryEvents); - AddTextPrinterParameterized3(6, 1, 0, 1, sTextColor_Headers, -1, gText_MainMenuOption); + AddTextPrinterParameterized3(2, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuContinue); + AddTextPrinterParameterized3(3, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuNewGame); + AddTextPrinterParameterized3(4, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuMysteryGift2); + AddTextPrinterParameterized3(5, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuMysteryEvents); + AddTextPrinterParameterized3(6, FONT_NORMAL, 0, 1, sTextColor_Headers, TEXT_SKIP_DRAW, gText_MainMenuOption); MainMenu_FormatSavegameText(); PutWindowTilemap(2); PutWindowTilemap(3); PutWindowTilemap(4); PutWindowTilemap(5); PutWindowTilemap(6); - CopyWindowToVram(2, 2); - CopyWindowToVram(3, 2); - CopyWindowToVram(4, 2); - CopyWindowToVram(5, 2); - CopyWindowToVram(6, 2); + CopyWindowToVram(2, COPYWIN_GFX); + CopyWindowToVram(3, COPYWIN_GFX); + CopyWindowToVram(4, COPYWIN_GFX); + CopyWindowToVram(5, COPYWIN_GFX); + CopyWindowToVram(6, COPYWIN_GFX); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[2], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[3], MAIN_MENU_BORDER_TILE); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[4], MAIN_MENU_BORDER_TILE); @@ -861,8 +861,8 @@ static void Task_DisplayMainMenu(u8 taskId) gTasks[tScrollArrowTaskId].func = Task_ScrollIndicatorArrowPairOnMainMenu; if (sCurrItemAndOptionMenuCheck == 4) { - ChangeBgY(0, 0x2000, 1); - ChangeBgY(1, 0x2000, 1); + ChangeBgY(0, 0x2000, BG_COORD_ADD); + ChangeBgY(1, 0x2000, BG_COORD_ADD); tIsScrolled = TRUE; gTasks[tScrollArrowTaskId].tArrowTaskIsScrolled = TRUE; } @@ -901,8 +901,8 @@ static bool8 HandleMainMenuInput(u8 taskId) { if (tMenuType == HAS_MYSTERY_EVENTS && tIsScrolled == TRUE && tCurrItem == 1) { - ChangeBgY(0, 0x2000, 2); - ChangeBgY(1, 0x2000, 2); + ChangeBgY(0, 0x2000, BG_COORD_SUB); + ChangeBgY(1, 0x2000, BG_COORD_SUB); gTasks[tScrollArrowTaskId].tArrowTaskIsScrolled = tIsScrolled = FALSE; } tCurrItem--; @@ -913,8 +913,8 @@ static bool8 HandleMainMenuInput(u8 taskId) { if (tMenuType == HAS_MYSTERY_EVENTS && tCurrItem == 3 && tIsScrolled == FALSE) { - ChangeBgY(0, 0x2000, 1); - ChangeBgY(1, 0x2000, 1); + ChangeBgY(0, 0x2000, BG_COORD_ADD); + ChangeBgY(1, 0x2000, BG_COORD_ADD); gTasks[tScrollArrowTaskId].tArrowTaskIsScrolled = tIsScrolled = TRUE; } tCurrItem++; @@ -1048,8 +1048,8 @@ static void Task_HandleMainMenuAPressed(u8 taskId) } break; } - ChangeBgY(0, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); switch (action) { case ACTION_NEW_GAME: @@ -1330,7 +1330,7 @@ static void Task_NewGameBirchSpeech_WaitForSpriteFadeInWelcome(u8 taskId) LoadMessageBoxGfx(0, 0xFC, 0xF0); NewGameBirchSpeech_ShowDialogueWindow(0, 1); PutWindowTilemap(0); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); NewGameBirchSpeech_ClearWindow(0); StringExpandPlaceholders(gStringVar4, gText_Birch_Welcome); AddTextPrinterForMessage(1); @@ -1855,7 +1855,7 @@ static void CB2_NewGameBirchSpeech_ReturnFromNamingScreen(void) LoadMainMenuWindowFrameTiles(0, 0xF3); LoadMessageBoxGfx(0, 0xFC, 0xF0); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } static void SpriteCB_Null(struct Sprite *sprite) @@ -2090,9 +2090,9 @@ static void NewGameBirchSpeech_ShowGenderMenu(void) DrawMainMenuWindowBorder(&gNewGameBirchSpeechTextWindows[1], 0xF3); FillWindowPixelBuffer(1, PIXEL_FILL(1)); PrintMenuTable(1, ARRAY_COUNT(sMenuActions_Gender), sMenuActions_Gender); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0); + InitMenuInUpperLeftCornerNormal(1, 2, 0); PutWindowTilemap(1); - CopyWindowToVram(1, 3); + CopyWindowToVram(1, COPYWIN_FULL); } static s8 NewGameBirchSpeech_ProcessGenderMenuInput(void) @@ -2117,9 +2117,9 @@ static void NewGameBirchSpeech_SetDefaultPlayerName(u8 nameId) static void CreateMainMenuErrorWindow(const u8* str) { FillWindowPixelBuffer(7, PIXEL_FILL(1)); - AddTextPrinterParameterized(7, 1, str, 0, 1, 2, 0); + AddTextPrinterParameterized(7, FONT_NORMAL, str, 0, 1, 2, 0); PutWindowTilemap(7); - CopyWindowToVram(7, 2); + CopyWindowToVram(7, COPYWIN_GFX); DrawMainMenuWindowBorder(&sWindowTemplates_MainMenu[7], MAIN_MENU_BORDER_TILE); SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(9, DISPLAY_WIDTH - 9)); SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(113, DISPLAY_HEIGHT - 1)); @@ -2136,8 +2136,8 @@ static void MainMenu_FormatSavegameText(void) static void MainMenu_FormatSavegamePlayer(void) { StringExpandPlaceholders(gStringVar4, gText_ContinueMenuPlayer); - AddTextPrinterParameterized3(2, 1, 0, 17, sTextColor_MenuInfo, -1, gStringVar4); - AddTextPrinterParameterized3(2, 1, GetStringRightAlignXOffset(1, gSaveBlock2Ptr->playerName, 100), 17, sTextColor_MenuInfo, -1, gSaveBlock2Ptr->playerName); + AddTextPrinterParameterized3(2, FONT_NORMAL, 0, 17, sTextColor_MenuInfo, TEXT_SKIP_DRAW, gStringVar4); + AddTextPrinterParameterized3(2, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, gSaveBlock2Ptr->playerName, 100), 17, sTextColor_MenuInfo, TEXT_SKIP_DRAW, gSaveBlock2Ptr->playerName); } static void MainMenu_FormatSavegameTime(void) @@ -2146,11 +2146,11 @@ static void MainMenu_FormatSavegameTime(void) u8* ptr; StringExpandPlaceholders(gStringVar4, gText_ContinueMenuTime); - AddTextPrinterParameterized3(2, 1, 0x6C, 17, sTextColor_MenuInfo, -1, gStringVar4); + AddTextPrinterParameterized3(2, FONT_NORMAL, 0x6C, 17, sTextColor_MenuInfo, TEXT_SKIP_DRAW, gStringVar4); ptr = ConvertIntToDecimalStringN(str, gSaveBlock2Ptr->playTimeHours, STR_CONV_MODE_LEFT_ALIGN, 3); *ptr = 0xF0; ConvertIntToDecimalStringN(ptr + 1, gSaveBlock2Ptr->playTimeMinutes, STR_CONV_MODE_LEADING_ZEROS, 2); - AddTextPrinterParameterized3(2, 1, GetStringRightAlignXOffset(1, str, 0xD0), 17, sTextColor_MenuInfo, -1, str); + AddTextPrinterParameterized3(2, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, str, 0xD0), 17, sTextColor_MenuInfo, TEXT_SKIP_DRAW, str); } static void MainMenu_FormatSavegamePokedex(void) @@ -2165,9 +2165,9 @@ static void MainMenu_FormatSavegamePokedex(void) else dexCount = GetHoennPokedexCount(FLAG_GET_CAUGHT); StringExpandPlaceholders(gStringVar4, gText_ContinueMenuPokedex); - AddTextPrinterParameterized3(2, 1, 0, 33, sTextColor_MenuInfo, -1, gStringVar4); + AddTextPrinterParameterized3(2, FONT_NORMAL, 0, 33, sTextColor_MenuInfo, TEXT_SKIP_DRAW, gStringVar4); ConvertIntToDecimalStringN(str, dexCount, STR_CONV_MODE_LEFT_ALIGN, 3); - AddTextPrinterParameterized3(2, 1, GetStringRightAlignXOffset(1, str, 100), 33, sTextColor_MenuInfo, -1, str); + AddTextPrinterParameterized3(2, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, str, 100), 33, sTextColor_MenuInfo, TEXT_SKIP_DRAW, str); } } @@ -2183,9 +2183,9 @@ static void MainMenu_FormatSavegameBadges(void) badgeCount++; } StringExpandPlaceholders(gStringVar4, gText_ContinueMenuBadges); - AddTextPrinterParameterized3(2, 1, 0x6C, 33, sTextColor_MenuInfo, -1, gStringVar4); + AddTextPrinterParameterized3(2, FONT_NORMAL, 0x6C, 33, sTextColor_MenuInfo, TEXT_SKIP_DRAW, gStringVar4); ConvertIntToDecimalStringN(str, badgeCount, STR_CONV_MODE_LEADING_ZEROS, 1); - AddTextPrinterParameterized3(2, 1, GetStringRightAlignXOffset(1, str, 0xD0), 33, sTextColor_MenuInfo, -1, str); + AddTextPrinterParameterized3(2, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, str, 0xD0), 33, sTextColor_MenuInfo, TEXT_SKIP_DRAW, str); } static void LoadMainMenuWindowFrameTiles(u8 bgId, u16 tileOffset) @@ -2232,19 +2232,19 @@ static void NewGameBirchSpeech_ClearGenderWindow(u8 windowId, bool8 copyToVram) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); ClearWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } static void NewGameBirchSpeech_ClearWindow(u8 windowId) { - u8 bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); - u8 maxCharWidth = GetFontAttribute(1, FONTATTR_MAX_LETTER_WIDTH); - u8 maxCharHeight = GetFontAttribute(1, FONTATTR_MAX_LETTER_HEIGHT); + u8 bgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_BACKGROUND); + u8 maxCharWidth = GetFontAttribute(FONT_NORMAL, FONTATTR_MAX_LETTER_WIDTH); + u8 maxCharHeight = GetFontAttribute(FONT_NORMAL, FONTATTR_MAX_LETTER_HEIGHT); u8 winWidth = GetWindowAttribute(windowId, WINDOW_WIDTH); u8 winHeight = GetWindowAttribute(windowId, WINDOW_HEIGHT); FillWindowPixelRect(windowId, bgColor, 0, 0, maxCharWidth * winWidth, maxCharHeight * winHeight); - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } static void NewGameBirchSpeech_WaitForThisIsPokemonText(struct TextPrinterTemplate *printer, u16 a) diff --git a/src/map_name_popup.c b/src/map_name_popup.c index 97b02acf6..e44fb3383 100644 --- a/src/map_name_popup.c +++ b/src/map_name_popup.c @@ -325,12 +325,12 @@ static void ShowMapNamePopUpWindow(void) } AddMapNamePopUpWindow(); LoadMapNamePopUpWindowBg(); - x = GetStringCenterAlignXOffset(7, withoutPrefixPtr, 80); + x = GetStringCenterAlignXOffset(FONT_NARROW, withoutPrefixPtr, 80); mapDisplayHeader[0] = EXT_CTRL_CODE_BEGIN; mapDisplayHeader[1] = EXT_CTRL_CODE_HIGHLIGHT; mapDisplayHeader[2] = TEXT_COLOR_TRANSPARENT; - AddTextPrinterParameterized(GetMapNamePopUpWindowId(), 7, mapDisplayHeader, x, 3, 0xFF, NULL); - CopyWindowToVram(GetMapNamePopUpWindowId(), 3); + AddTextPrinterParameterized(GetMapNamePopUpWindowId(), FONT_NARROW, mapDisplayHeader, x, 3, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(GetMapNamePopUpWindowId(), COPYWIN_FULL); } #define TILE_TOP_EDGE_START 0x21D diff --git a/src/match_call.c b/src/match_call.c index 9939b09d2..9e4659ee6 100644 --- a/src/match_call.c +++ b/src/match_call.c @@ -1263,7 +1263,7 @@ static bool32 MatchCall_LoadGfx(u8 taskId) FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); LoadPalette(sMatchCallWindow_Pal, 0xE0, sizeof(sMatchCallWindow_Pal)); LoadPalette(sPokenavIcon_Pal, 0xF0, sizeof(sPokenavIcon_Pal)); - ChangeBgY(0, -0x2000, 0); + ChangeBgY(0, -0x2000, BG_COORD_SET); return TRUE; } @@ -1277,7 +1277,7 @@ static bool32 MatchCall_DrawWindow(u8 taskId) DrawMatchCallTextBoxBorder_Internal(tWindowId, TILE_MC_WINDOW, 14); WriteSequenceToBgTilemapBuffer(0, (0xF << 12) | TILE_POKENAV_ICON, 1, 15, 4, 4, 17, 1); tIconTaskId = CreateTask(Task_SpinPokenavIcon, 10); - CopyWindowToVram(tWindowId, 2); + CopyWindowToVram(tWindowId, COPYWIN_GFX); CopyBgTilemapBufferToVram(0); return TRUE; } @@ -1297,9 +1297,9 @@ static bool32 MatchCall_ReadyIntro(u8 taskId) static bool32 MatchCall_SlideWindowIn(u8 taskId) { - if (ChangeBgY(0, 0x600, 1) >= 0) + if (ChangeBgY(0, 0x600, BG_COORD_ADD) >= 0) { - ChangeBgY(0, 0, 0); + ChangeBgY(0, 0, BG_COORD_SET); return TRUE; } @@ -1329,7 +1329,7 @@ static bool32 MatchCall_PrintMessage(u8 taskId) if (!RunMatchCallTextPrinter(tWindowId) && !IsSEPlaying() && JOY_NEW(A_BUTTON | B_BUTTON)) { FillWindowPixelBuffer(tWindowId, PIXEL_FILL(8)); - CopyWindowToVram(tWindowId, 2); + CopyWindowToVram(tWindowId, COPYWIN_GFX); PlaySE(SE_POKENAV_HANG_UP); return TRUE; } @@ -1340,7 +1340,7 @@ static bool32 MatchCall_PrintMessage(u8 taskId) static bool32 MatchCall_SlideWindowOut(u8 taskId) { s16 *data = gTasks[taskId].data; - if (ChangeBgY(0, 0x600, 2) <= -0x2000) + if (ChangeBgY(0, 0x600, BG_COORD_SUB) <= -0x2000) { FillBgTilemapBufferRect_Palette0(0, 0, 0, 14, 30, 6); DestroyTask(tIconTaskId); @@ -1357,7 +1357,7 @@ static bool32 MatchCall_EndCall(u8 taskId) u8 playerObjectId; if (!IsDma3ManagerBusyWithBgCopy() && !IsSEPlaying()) { - ChangeBgY(0, 0, 0); + ChangeBgY(0, 0, BG_COORD_SET); if (!sMatchCallState.triggeredFromScript) { LoadMessageBoxAndBorderGfx(); @@ -1401,7 +1401,7 @@ static void InitMatchCallTextPrinter(int windowId, const u8 *str) struct TextPrinterTemplate printerTemplate; printerTemplate.currentChar = str; printerTemplate.windowId = windowId; - printerTemplate.fontId = 1; + printerTemplate.fontId = FONT_NORMAL; printerTemplate.x = 32; printerTemplate.y = 1; printerTemplate.currentX = 32; diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c index 2fd0e6730..06c3b8288 100644 --- a/src/mauville_old_man.c +++ b/src/mauville_old_man.c @@ -447,9 +447,9 @@ static void DisableTextPrinters(struct TextPrinterTemplate * printer, u16 a1) static void DrawSongTextWindow(const u8 * str) { DrawDialogueFrame(0, 0); - AddTextPrinterParameterized(0, 1, str, 0, 1, 1, DisableTextPrinters); + AddTextPrinterParameterized(0, FONT_NORMAL, str, 0, 1, 1, DisableTextPrinters); gDisableTextPrinters = TRUE; - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } static void BardSing(struct Task *task, struct BardSong *song) @@ -1324,7 +1324,7 @@ static void StorytellerDisplayStory(u32 player) static void PrintStoryList(void) { s32 i; - s32 width = GetStringWidth(1, gText_Exit, 0); + s32 width = GetStringWidth(FONT_NORMAL, gText_Exit, 0); for (i = 0; i < NUM_STORYTELLER_TALES; i++) { s32 curWidth; @@ -1332,7 +1332,7 @@ static void PrintStoryList(void) if (gameStatID == 0) break; - curWidth = GetStringWidth(1, GetStoryTitleByStat(gameStatID), 0); + curWidth = GetStringWidth(FONT_NORMAL, GetStoryTitleByStat(gameStatID), 0); if (curWidth > width) width = curWidth; } @@ -1343,11 +1343,11 @@ static void PrintStoryList(void) u16 gameStatID = sStorytellerPtr->gameStatIDs[i]; if (gameStatID == 0) break; - AddTextPrinterParameterized(sStorytellerWindowId, 1, GetStoryTitleByStat(gameStatID), 8, 16 * i + 1, 0xFF, NULL); + AddTextPrinterParameterized(sStorytellerWindowId, FONT_NORMAL, GetStoryTitleByStat(gameStatID), 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL); } - AddTextPrinterParameterized(sStorytellerWindowId, 1, gText_Exit, 8, 16 * i + 1, 0xFF, NULL); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sStorytellerWindowId, GetFreeStorySlot() + 1, 0); - CopyWindowToVram(sStorytellerWindowId, 3); + AddTextPrinterParameterized(sStorytellerWindowId, FONT_NORMAL, gText_Exit, 8, 16 * i + 1, TEXT_SKIP_DRAW, NULL); + InitMenuInUpperLeftCornerNormal(sStorytellerWindowId, GetFreeStorySlot() + 1, 0); + CopyWindowToVram(sStorytellerWindowId, COPYWIN_FULL); } static void Task_StoryListMenu(u8 taskId) diff --git a/src/menu.c b/src/menu.c index dcc32319e..6b915f9ce 100644 --- a/src/menu.c +++ b/src/menu.c @@ -48,19 +48,30 @@ struct Menu bool8 APressMuted; }; +static u16 AddWindowParameterized(u8, u8, u8, u8, u8, u8, u16); +static void WindowFunc_DrawStandardFrame(u8, u8, u8, u8, u8, u8); +static void WindowFunc_DrawDialogueFrame(u8, u8, u8, u8, u8, u8); +static void WindowFunc_ClearStdWindowAndFrame(u8, u8, u8, u8, u8, u8); +static void WindowFunc_ClearDialogWindowAndFrame(u8, u8, u8, u8, u8, u8); +static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8, u8); +static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8, u8, u8, u8, u8, u8); +static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8, u8); +static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8, u8, u8, u8, u8, u8); +static void task_free_buf_after_copying_tile_data_to_vram(u8 taskId); + static EWRAM_DATA u8 sStartMenuWindowId = 0; static EWRAM_DATA u8 sMapNamePopupWindowId = 0; static EWRAM_DATA struct Menu sMenu = {0}; static EWRAM_DATA u16 sTileNum = 0; static EWRAM_DATA u8 sPaletteNum = 0; static EWRAM_DATA u8 sYesNoWindowId = 0; -static EWRAM_DATA u8 sWindowId = 0; +static EWRAM_DATA u8 sHofPCTopBarWindowId = 0; static EWRAM_DATA u16 sFiller = 0; // needed to align static EWRAM_DATA bool8 sScheduledBgCopiesToVram[4] = {FALSE}; static EWRAM_DATA u16 sTempTileDataBufferIdx = 0; static EWRAM_DATA void *sTempTileDataBuffer[0x20] = {NULL}; -const u16 gUnknown_0860F074[] = INCBIN_U16("graphics/interface/860F074.gbapal"); +const u16 gStandardMenuPalette[] = INCBIN_U16("graphics/interface/std_menu.gbapal"); static const u8 sTextSpeedFrameDelays[] = { @@ -94,10 +105,10 @@ static const struct WindowTemplate sYesNo_WindowTemplates = .baseBlock = 0x125 }; -const u16 gUnknown_0860F0B0[] = INCBIN_U16("graphics/interface/860F0B0.gbapal"); -const u8 sTextColors[] = { TEXT_DYNAMIC_COLOR_6, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY }; +static const u16 sHofPC_TopBar_Pal[] = INCBIN_U16("graphics/interface/hof_pc_topbar.gbapal"); +static const u8 sTextColors[] = { TEXT_DYNAMIC_COLOR_6, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY }; -// Table of move info icon offsets in graphics/interface_fr/menu.png +// Table of move info icon offsets in graphics/interface/menu_info.png static const struct MenuInfoIcon sMenuInfoIcons[] = { // { width, height, offset } { 12, 12, 0x00 }, // Unused @@ -128,19 +139,6 @@ static const struct MenuInfoIcon sMenuInfoIcons[] = [MENU_INFO_ICON_BALL_BLUE] = { 8, 8, 0xAF }, // For placed decorations in player's room }; - -// Forward declarations -void WindowFunc_DrawStandardFrame(u8, u8, u8, u8, u8, u8); -void WindowFunc_DrawDialogueFrame(u8, u8, u8, u8, u8, u8); -void WindowFunc_ClearStdWindowAndFrame(u8, u8, u8, u8, u8, u8); -void WindowFunc_ClearDialogWindowAndFrame(u8, u8, u8, u8, u8, u8); -void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8, u8); -void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8, u8, u8, u8, u8, u8); -void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8, u8, u8, u8, u8, u8); -void WindowFunc_ClearStdWindowAndFrameToTransparent(u8, u8, u8, u8, u8, u8); -void sub_8198C78(void); -void task_free_buf_after_copying_tile_data_to_vram(u8 taskId); - void InitStandardTextBoxWindows(void) { InitWindows(sStandardTextBox_WindowTemplates); @@ -155,8 +153,8 @@ void FreeAllOverworldWindowBuffers(void) void InitTextBoxGfxAndPrinters(void) { - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); DeactivateAllTextPrinters(); LoadMessageBoxAndBorderGfx(); } @@ -193,19 +191,19 @@ void AddTextPrinterForMessage(bool8 allowSkippingDelayWithButtonPress) { void (*callback)(struct TextPrinterTemplate *, u16) = NULL; gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3); } void AddTextPrinterForMessage_2(bool8 allowSkippingDelayWithButtonPress) { gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), NULL, 2, 1, 3); } void AddTextPrinterWithCustomSpeedForMessage(bool8 allowSkippingDelayWithButtonPress, u8 speed) { gTextFlags.canABSpeedUpPrint = allowSkippingDelayWithButtonPress; - AddTextPrinterParameterized2(0, 1, gStringVar4, speed, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, speed, NULL, 2, 1, 3); } void LoadMessageBoxAndBorderGfx(void) @@ -220,7 +218,7 @@ void DrawDialogueFrame(u8 windowId, bool8 copyToVram) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } void DrawStdWindowFrame(u8 windowId, bool8 copyToVram) @@ -229,7 +227,7 @@ void DrawStdWindowFrame(u8 windowId, bool8 copyToVram) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram) @@ -238,7 +236,7 @@ void ClearDialogWindowAndFrame(u8 windowId, bool8 copyToVram) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); ClearWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } void ClearStdWindowAndFrame(u8 windowId, bool8 copyToVram) @@ -247,10 +245,10 @@ void ClearStdWindowAndFrame(u8 windowId, bool8 copyToVram) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); ClearWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } -void WindowFunc_DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +static void WindowFunc_DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { int i; @@ -317,7 +315,7 @@ void WindowFunc_DrawStandardFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width STD_WINDOW_PALETTE_NUM); } -void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +static void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { FillBgTilemapBufferRect(bg, DLG_WINDOW_BASE_TILE_NUM + 1, @@ -412,12 +410,12 @@ void WindowFunc_DrawDialogueFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width DLG_WINDOW_PALETTE_NUM); } -void WindowFunc_ClearStdWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +static void WindowFunc_ClearStdWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, STD_WINDOW_PALETTE_NUM); } -void WindowFunc_ClearDialogWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +static void WindowFunc_ClearDialogWindowAndFrame(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, STD_WINDOW_PALETTE_NUM); } @@ -427,39 +425,41 @@ void SetStandardWindowBorderStyle(u8 windowId, bool8 copyToVram) DrawStdFrameWithCustomTileAndPalette(windowId, copyToVram, STD_WINDOW_BASE_TILE_NUM, STD_WINDOW_PALETTE_NUM); } -void sub_819786C(u8 windowId, bool8 copyToVram) +void LoadMessageBoxAndFrameGfx(u8 windowId, bool8 copyToVram) { LoadMessageBoxGfx(windowId, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM * 0x10); DrawDialogFrameWithCustomTileAndPalette(windowId, copyToVram, DLG_WINDOW_BASE_TILE_NUM, 0xF); } -void sub_819789C(void) +void Menu_LoadStdPal(void) { - LoadPalette(gUnknown_0860F074, STD_WINDOW_PALETTE_NUM * 0x10, 0x14); + LoadPalette(gStandardMenuPalette, STD_WINDOW_PALETTE_NUM * 0x10, 0x14); } void Menu_LoadStdPalAt(u16 offset) { - LoadPalette(gUnknown_0860F074, offset, 0x14); + LoadPalette(gStandardMenuPalette, offset, 0x14); } -const u16 *sub_81978C8(void) +// Unused +static const u16 *Menu_GetStdPal(void) { - return gUnknown_0860F074; + return gStandardMenuPalette; } -u16 sub_81978D0(u8 colorNum) +// Unused +static u16 Menu_GetStdPalColor(u8 colorNum) { if (colorNum > 15) colorNum = 0; - return gUnknown_0860F074[colorNum]; + return gStandardMenuPalette[colorNum]; } void DisplayItemMessageOnField(u8 taskId, const u8 *string, TaskFunc callback) { LoadMessageBoxAndBorderGfx(); - DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, 1, GetPlayerTextSpeedDelay(), string, callback); - CopyWindowToVram(0, 3); + DisplayMessageAndContinueTask(taskId, 0, DLG_WINDOW_BASE_TILE_NUM, DLG_WINDOW_PALETTE_NUM, FONT_NORMAL, GetPlayerTextSpeedDelay(), string, callback); + CopyWindowToVram(0, COPYWIN_FULL); } void DisplayYesNoMenuDefaultYes(void) @@ -488,10 +488,10 @@ u8 GetPlayerTextSpeedDelay(void) return sTextSpeedFrameDelays[speed]; } -u8 sub_81979C4(u8 a1) +u8 AddStartMenuWindow(u8 numActions) { if (sStartMenuWindowId == WINDOW_NONE) - sStartMenuWindowId = sub_8198AA4(0, 0x16, 1, 7, (a1 * 2) + 2, 0xF, 0x139); + sStartMenuWindowId = AddWindowParameterized(0, 22, 1, 7, (numActions * 2) + 2, 15, 0x139); return sStartMenuWindowId; } @@ -524,7 +524,7 @@ static u16 GetStandardFrameBaseTileNum(void) u8 AddMapNamePopUpWindow(void) { if (sMapNamePopupWindowId == WINDOW_NONE) - sMapNamePopupWindowId = sub_8198AA4(0, 1, 1, 10, 3, 14, 0x107); + sMapNamePopupWindowId = AddWindowParameterized(0, 1, 1, 10, 3, 14, 0x107); return sMapNamePopupWindowId; } @@ -545,10 +545,10 @@ void RemoveMapNamePopUpWindow(void) void AddTextPrinterWithCallbackForMessage(bool8 a1, void (*callback)(struct TextPrinterTemplate *, u16)) { gTextFlags.canABSpeedUpPrint = a1; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), callback, 2, 1, 3); } -void sub_8197AE8(bool8 copyToVram) +void EraseFieldMessageBox(bool8 copyToVram) { FillBgTilemapBufferRect(0, 0, 0, 0, 32, 32, 0x11); if (copyToVram == TRUE) @@ -563,11 +563,11 @@ void DrawDialogFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } // Never used. -void DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 tileNum) +static void DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 tileNum) { sTileNum = tileNum; sPaletteNum = GetWindowAttribute(windowId, WINDOW_PALETTE_NUM); @@ -575,10 +575,10 @@ void DrawDialogFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 tileNum) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } -void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +static void WindowFunc_DrawDialogFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { FillBgTilemapBufferRect(bg, sTileNum + 1, @@ -680,10 +680,10 @@ void ClearDialogWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram) FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); ClearWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } -void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +static void WindowFunc_ClearDialogWindowAndFrameNullPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { FillBgTilemapBufferRect(bg, 0, tilemapLeft - 3, tilemapTop - 1, width + 6, height + 2, 0); } @@ -696,7 +696,7 @@ void DrawStdFrameWithCustomTileAndPalette(u8 windowId, bool8 copyToVram, u16 bas FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } // Never used. @@ -708,10 +708,10 @@ void DrawStdFrameWithCustomTile(u8 windowId, bool8 copyToVram, u16 baseTileNum) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } -void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +static void WindowFunc_DrawStdFrameWithCustomTileAndPalette(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { FillBgTilemapBufferRect(bg, sTileNum + 0, @@ -777,15 +777,16 @@ void ClearStdWindowAndFrameToTransparent(u8 windowId, bool8 copyToVram) FillWindowPixelBuffer(windowId, PIXEL_FILL(0)); ClearWindowTilemap(windowId); if (copyToVram == TRUE) - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } -void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) +static void WindowFunc_ClearStdWindowAndFrameToTransparent(u8 bg, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 paletteNum) { FillBgTilemapBufferRect(bg, 0, tilemapLeft - 1, tilemapTop - 1, width + 2, height + 2, 0); } -u8 sub_81980F0(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile) +// Creates the window used to display the info bar at the top of the HOF PC that shows the controls and team number. +u8 HofPCTopBar_AddWindow(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile) { struct WindowTemplate window; memset(&window, 0, sizeof(window)); @@ -797,51 +798,54 @@ u8 sub_81980F0(u8 bg, u8 xPos, u8 yPos, u8 palette, u16 baseTile) window.tilemapTop = yPos; window.height = 2; - window.tilemapLeft = 0x1E - xPos; + window.tilemapLeft = 30 - xPos; window.width = xPos; window.paletteNum = palette; window.baseBlock = baseTile; - sWindowId = AddWindow(&window); + sHofPCTopBarWindowId = AddWindow(&window); if (palette > 15) palette = 15 * 16; else palette *= 16; - LoadPalette(gUnknown_0860F0B0, palette, sizeof(gUnknown_0860F0B0)); - return sWindowId; + LoadPalette(sHofPC_TopBar_Pal, palette, sizeof(sHofPC_TopBar_Pal)); + return sHofPCTopBarWindowId; } -void sub_8198180(const u8 *string, u8 a2, bool8 copyToVram) +// All the below functions checking WINDOW_NONE only handle failure of AddWindow in the above function. +// Because sHofPCTopBarWindowId is not initialized to WINDOW_NONE anywhere it does not handle +// the window not having been drawn yet. +void HofPCTopBar_Print(const u8 *string, u8 left, bool8 copyToVram) { u16 width = 0; - if (sWindowId != WINDOW_NONE) + if (sHofPCTopBarWindowId != WINDOW_NONE) { - PutWindowTilemap(sWindowId); - FillWindowPixelBuffer(sWindowId, PIXEL_FILL(15)); - width = GetStringWidth(0, string, 0); - AddTextPrinterParameterized3(sWindowId, - 0, - 0xEC - (GetWindowAttribute(sWindowId, WINDOW_TILEMAP_LEFT) * 8) - a2 - width, + PutWindowTilemap(sHofPCTopBarWindowId); + FillWindowPixelBuffer(sHofPCTopBarWindowId, PIXEL_FILL(15)); + width = GetStringWidth(FONT_SMALL, string, 0); + AddTextPrinterParameterized3(sHofPCTopBarWindowId, + FONT_SMALL, + 236 - (GetWindowAttribute(sHofPCTopBarWindowId, WINDOW_TILEMAP_LEFT) * 8) - left - width, 1, sTextColors, 0, string); if (copyToVram) - CopyWindowToVram(sWindowId, 3); + CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL); } } -void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyToVram) +void HofPCTopBar_PrintPair(const u8 *string, const u8 *string2, bool8 noBg, u8 left, bool8 copyToVram) { u8 color[3]; u16 width = 0; - if (sWindowId != WINDOW_NONE) + if (sHofPCTopBarWindowId != WINDOW_NONE) { - if (a3 != 0) + if (noBg) { color[0] = TEXT_COLOR_TRANSPARENT; color[1] = TEXT_COLOR_WHITE; @@ -853,53 +857,55 @@ void sub_8198204(const u8 *string, const u8 *string2, u8 a3, u8 a4, bool8 copyTo color[1] = TEXT_COLOR_WHITE; color[2] = TEXT_COLOR_DARK_GRAY; } - PutWindowTilemap(sWindowId); - FillWindowPixelBuffer(sWindowId, PIXEL_FILL(15)); + PutWindowTilemap(sHofPCTopBarWindowId); + FillWindowPixelBuffer(sHofPCTopBarWindowId, PIXEL_FILL(15)); if (string2 != NULL) { - width = GetStringWidth(0, string2, 0); - AddTextPrinterParameterized3(sWindowId, - 0, - 0xEC - (GetWindowAttribute(sWindowId, WINDOW_TILEMAP_LEFT) * 8) - a4 - width, + width = GetStringWidth(FONT_SMALL, string2, 0); + AddTextPrinterParameterized3(sHofPCTopBarWindowId, + FONT_SMALL, + 236 - (GetWindowAttribute(sHofPCTopBarWindowId, WINDOW_TILEMAP_LEFT) * 8) - left - width, 1, color, 0, string2); } - AddTextPrinterParameterized4(sWindowId, 1, 4, 1, 0, 0, color, 0, string); + AddTextPrinterParameterized4(sHofPCTopBarWindowId, FONT_NORMAL, 4, 1, 0, 0, color, 0, string); if (copyToVram) - CopyWindowToVram(sWindowId, 3); + CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL); } } -void sub_81982D8(void) +// Unused +static void HofPCTopBar_CopyToVram(void) { - if (sWindowId != WINDOW_NONE) - CopyWindowToVram(sWindowId, 3); + if (sHofPCTopBarWindowId != WINDOW_NONE) + CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL); } -void sub_81982F0(void) +// Unused +static void HofPCTopBar_Clear(void) { - if (sWindowId != WINDOW_NONE) + if (sHofPCTopBarWindowId != WINDOW_NONE) { - FillWindowPixelBuffer(sWindowId, PIXEL_FILL(15)); - CopyWindowToVram(sWindowId, 3); + FillWindowPixelBuffer(sHofPCTopBarWindowId, PIXEL_FILL(15)); + CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL); } } -void sub_8198314(void) +void HofPCTopBar_RemoveWindow(void) { - if (sWindowId != WINDOW_NONE) + if (sHofPCTopBarWindowId != WINDOW_NONE) { - FillWindowPixelBuffer(sWindowId, PIXEL_FILL(0)); - ClearWindowTilemap(sWindowId); - CopyWindowToVram(sWindowId, 3); - RemoveWindow(sWindowId); - sWindowId = WINDOW_NONE; + FillWindowPixelBuffer(sHofPCTopBarWindowId, PIXEL_FILL(0)); + ClearWindowTilemap(sHofPCTopBarWindowId); + CopyWindowToVram(sHofPCTopBarWindowId, COPYWIN_FULL); + RemoveWindow(sHofPCTopBarWindowId); + sHofPCTopBarWindowId = WINDOW_NONE; } } -u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos, u8 a7) +static u8 InitMenu(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos, bool8 muteAPress) { s32 pos; @@ -910,7 +916,7 @@ u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numC sMenu.windowId = windowId; sMenu.fontId = fontId; sMenu.optionHeight = cursorHeight; - sMenu.APressMuted = a7; + sMenu.APressMuted = muteAPress; pos = initialCursorPos; @@ -923,15 +929,17 @@ u8 sub_8198348(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numC return sMenu.cursorPos; } -u8 sub_81983AC(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos) +// There is no muted version of this, so the version that plays sound when A is pressed is the "Normal" one. +u8 InitMenuNormal(u8 windowId, u8 fontId, u8 left, u8 top, u8 cursorHeight, u8 numChoices, u8 initialCursorPos) { - return sub_8198348(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos, 0); + return InitMenu(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos, FALSE); } -u8 sub_81983EC(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 initialCursorPos) +// Unused +static u8 InitMenuDefaultCursorHeight(u8 windowId, u8 fontId, u8 left, u8 top, u8 numChoices, u8 initialCursorPos) { u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1); - return sub_81983AC(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos); + return InitMenuNormal(windowId, fontId, left, top, cursorHeight, numChoices, initialCursorPos); } void RedrawMenuCursor(u8 oldPos, u8 newPos) @@ -1097,32 +1105,30 @@ s8 Menu_ProcessInputNoWrapAround_other(void) return MENU_NOTHING_CHOSEN; } -void PrintTextArray(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions) +void PrintMenuActionTextsAtPos(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions) { u8 i; for (i = 0; i < itemCount; i++) - { - AddTextPrinterParameterized(windowId, fontId, menuActions[i].text, left, (lineHeight * i) + top, 0xFF, NULL); - } - CopyWindowToVram(windowId, 2); + AddTextPrinterParameterized(windowId, fontId, menuActions[i].text, left, (lineHeight * i) + top, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(windowId, COPYWIN_GFX); } -void sub_81987BC(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, u8 a6, u8 a7) +// Unused +static void PrintMenuActionTextsWithSpacing(u8 windowId, u8 fontId, u8 left, u8 top, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, u8 letterSpacing, u8 lineSpacing) { u8 i; for (i = 0; i < itemCount; i++) - { - AddTextPrinterParameterized5(windowId, fontId, menuActions[i].text, left, (lineHeight * i) + top, 0xFF, NULL, a6, a7); - } - CopyWindowToVram(windowId, 2); + AddTextPrinterParameterized5(windowId, fontId, menuActions[i].text, left, (lineHeight * i) + top, TEXT_SKIP_DRAW, NULL, letterSpacing, lineSpacing); + CopyWindowToVram(windowId, COPYWIN_GFX); } -void sub_8198854(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions) +// Unused +static void PrintMenuActionTextsAtTop(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions) { - PrintTextArray(windowId, fontId, GetFontAttribute(fontId, 0), 1, lineHeight, itemCount, menuActions); + PrintMenuActionTextsAtPos(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, lineHeight, itemCount, menuActions); } -void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds) +void PrintMenuActionTexts(u8 windowId, u8 fontId, u8 left, u8 top, u8 letterSpacing, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds) { u8 i; struct TextPrinterTemplate printer; @@ -1143,15 +1149,16 @@ void AddItemMenuActionTextPrinters(u8 windowId, u8 fontId, u8 left, u8 top, u8 l printer.currentChar = menuActions[actionIds[i]].text; printer.y = (lineHeight * i) + top; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, NULL); + AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL); } - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } -void sub_81989B8(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds) +// Unused +static void PrintMenuActionTextsAtTopById(u8 windowId, u8 fontId, u8 lineHeight, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds) { - AddItemMenuActionTextPrinters(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, menuActions, actionIds); + PrintMenuActionTexts(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 1, GetFontAttribute(fontId, FONTATTR_LETTER_SPACING), lineHeight, itemCount, menuActions, actionIds); } void SetWindowTemplateFields(struct WindowTemplate *template, u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) @@ -1172,14 +1179,15 @@ struct WindowTemplate CreateWindowTemplate(u8 bg, u8 left, u8 top, u8 width, u8 return template; } -u16 sub_8198AA4(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) +u16 AddWindowParameterized(u8 bg, u8 left, u8 top, u8 width, u8 height, u8 paletteNum, u16 baseBlock) { struct WindowTemplate template; SetWindowTemplateFields(&template, bg, left, top, width, height, paletteNum, baseBlock); return AddWindow(&template); } -void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) +// As opposed to CreateYesNoMenu, which has a hard-coded position. +static void CreateYesNoMenuAtPos(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) { struct TextPrinterTemplate printer; @@ -1200,47 +1208,46 @@ void sub_8198AF8(const struct WindowTemplate *window, u8 fontId, u8 left, u8 top printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); - AddTextPrinter(&printer, 0xFF, NULL); + AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL); - sub_81983AC(sYesNoWindowId, fontId, left, top, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT), 2, initialCursorPos); + InitMenuNormal(sYesNoWindowId, fontId, left, top, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT), 2, initialCursorPos); } -void sub_8198C34(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) +static void CreateYesNoMenuInTopLeft(const struct WindowTemplate *window, u8 fontId, u16 baseTileNum, u8 paletteNum) { - sub_8198AF8(window, fontId, 0, 1, baseTileNum, paletteNum, 0); + CreateYesNoMenuAtPos(window, fontId, 0, 1, baseTileNum, paletteNum, 0); } s8 Menu_ProcessInputNoWrapClearOnChoose(void) { s8 result = Menu_ProcessInputNoWrap(); if (result != MENU_NOTHING_CHOSEN) - sub_8198C78(); + EraseYesNoWindow(); return result; } -void sub_8198C78(void) +void EraseYesNoWindow(void) { ClearStdWindowAndFrameToTransparent(sYesNoWindowId, TRUE); RemoveWindow(sYesNoWindowId); } -void sub_8198C94(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7, const struct MenuAction *menuActions) +static void PrintMenuActionGridText(u8 windowId, u8 fontId, u8 left, u8 top, u8 width, u8 height, u8 columns, u8 rows, const struct MenuAction *menuActions) { u8 i; u8 j; - for (i = 0; i < a7; i++) + for (i = 0; i < rows; i++) { - for (j = 0; j < a6; j++) - { - AddTextPrinterParameterized(windowId, fontId, menuActions[(i * a6) + j].text, (a4 * j) + left, (a5 * i) + top, 0xFF, NULL); - } + for (j = 0; j < columns; j++) + AddTextPrinterParameterized(windowId, fontId, menuActions[(i * columns) + j].text, (width * j) + left, (height * i) + top, TEXT_SKIP_DRAW, NULL); } - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } -void sub_8198D54(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *menuActions) +// Unused +static void PrintMenuActionGridTextAtTop(u8 windowId, u8 fontId, u8 a2, u8 a3, u8 a4, u8 a5, const struct MenuAction *menuActions) { - sub_8198C94(windowId, fontId, GetFontAttribute(fontId, 0), 0, a2, a3, a4, a5, menuActions); + PrintMenuActionGridText(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, a2, a3, a4, a5, menuActions); } void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *menuActions, const u8 *actionIds) @@ -1267,11 +1274,11 @@ void PrintMenuActionGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth printer.y = (GetFontAttribute(fontId, FONTATTR_MAX_LETTER_HEIGHT) * i) + top; printer.currentX = printer.x; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, NULL); + AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL); } } - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } // Unused @@ -1280,7 +1287,7 @@ static void PrintMenuActionGrid_TopLeft(u8 windowId, u8 fontId, u8 optionWidth, PrintMenuActionGrid(windowId, fontId, GetFontAttribute(fontId, FONTATTR_MAX_LETTER_WIDTH), 0, optionWidth, horizontalCount, verticalCount, menuActions, actionIds); } -u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, u8 a6, u8 a7, u8 numChoices, u8 a9) +static u8 InitMenuGrid(u8 windowId, u8 fontId, u8 left, u8 top, u8 optionWidth, u8 optionHeight, u8 columns, u8 rows, u8 numChoices, u8 cursorPos) { s32 pos; @@ -1290,12 +1297,12 @@ u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, sMenu.maxCursorPos = numChoices - 1; sMenu.windowId = windowId; sMenu.fontId = fontId; - sMenu.optionWidth = a4; - sMenu.optionHeight = cursorHeight; - sMenu.columns = a6; - sMenu.rows = a7; + sMenu.optionWidth = optionWidth; + sMenu.optionHeight = optionHeight; + sMenu.columns = columns; + sMenu.rows = rows; - pos = a9; + pos = cursorPos; if (pos < 0 || pos > sMenu.maxCursorPos) sMenu.cursorPos = 0; @@ -1303,42 +1310,34 @@ u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight, sMenu.cursorPos = pos; // Why call this when it's not gonna move? - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE); return sMenu.cursorPos; } // Unused -u8 sub_8198FD4(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 a5, u8 a6, u8 a7) +static u8 InitMenuGridDefaultCursorHeight(u8 windowId, u8 fontId, u8 left, u8 top, u8 width, u8 columns, u8 rows, u8 cursorPos) { u8 cursorHeight = GetMenuCursorDimensionByFont(fontId, 1); - u8 numChoices = a5 * a6; - return sub_8198F58(windowId, fontId, left, top, a4, cursorHeight, a5, a6, numChoices, a7); + u8 numChoices = columns * rows; + return InitMenuGrid(windowId, fontId, left, top, width, cursorHeight, columns, rows, numChoices, cursorPos); } -void sub_8199060(u8 oldCursorPos, u8 newCursorPos) +// Erase cursor at old position, draw cursor at new position. +static void MoveMenuGridCursor(u8 oldCursorPos, u8 newCursorPos) { u8 cursorWidth = GetMenuCursorDimensionByFont(sMenu.fontId, 0); u8 cursorHeight = GetMenuCursorDimensionByFont(sMenu.fontId, 1); + u8 xPos = (oldCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left; u8 yPos = (oldCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top; - FillWindowPixelRect(sMenu.windowId, - PIXEL_FILL(1), - xPos, - yPos, - cursorWidth, - cursorHeight); + FillWindowPixelRect(sMenu.windowId, PIXEL_FILL(1), xPos, yPos, cursorWidth, cursorHeight); + xPos = (newCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left; yPos = (newCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top; - AddTextPrinterParameterized(sMenu.windowId, - sMenu.fontId, - gText_SelectorArrow3, - xPos, - yPos, - 0, - 0); + AddTextPrinterParameterized(sMenu.windowId, sMenu.fontId, gText_SelectorArrow3, xPos, yPos, 0, 0); } -u8 ChangeListMenuCursorPosition(s8 deltaX, s8 deltaY) +u8 ChangeMenuGridCursorPosition(s8 deltaX, s8 deltaY) { u8 oldPos = sMenu.cursorPos; @@ -1369,7 +1368,7 @@ u8 ChangeListMenuCursorPosition(s8 deltaX, s8 deltaY) } else { - sub_8199060(oldPos, sMenu.cursorPos); + MoveMenuGridCursor(oldPos, sMenu.cursorPos); return sMenu.cursorPos; } } @@ -1403,12 +1402,13 @@ u8 ChangeGridMenuCursorPosition(s8 deltaX, s8 deltaY) } else { - sub_8199060(oldPos, sMenu.cursorPos); + MoveMenuGridCursor(oldPos, sMenu.cursorPos); return sMenu.cursorPos; } } -s8 sub_8199284(void) +// Unused +static s8 Menu_ProcessGridInput_NoSoundLimit(void) { if (JOY_NEW(A_BUTTON)) { @@ -1422,32 +1422,32 @@ s8 sub_8199284(void) else if (JOY_NEW(DPAD_UP)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_DOWN)) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_LEFT) || GetLRKeysPressed() == MENU_L_PRESSED) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } else if (JOY_NEW(DPAD_RIGHT) || GetLRKeysPressed() == MENU_R_PRESSED) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } return MENU_NOTHING_CHOSEN; } -s8 Menu_ProcessInputGridLayout(void) +s8 Menu_ProcessGridInput(void) { u8 oldPos = sMenu.cursorPos; @@ -1488,7 +1488,8 @@ s8 Menu_ProcessInputGridLayout(void) return MENU_NOTHING_CHOSEN; } -s8 sub_81993D8(void) +// Unused +static s8 Menu_ProcessGridInputRepeat_NoSoundLimit(void) { if (JOY_NEW(A_BUTTON)) { @@ -1499,36 +1500,36 @@ s8 sub_81993D8(void) { return MENU_B_PRESSED; } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_UP) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_UP); return MENU_NOTHING_CHOSEN; } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_DOWN) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_DOWN) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_DOWN); return MENU_NOTHING_CHOSEN; } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_LEFT || GetLRKeysPressedAndHeld() == MENU_L_PRESSED) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_LEFT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } - else if ((JOY_REPEAT(DPAD_ANY)) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) + else if (JOY_REPEAT(DPAD_ANY) == DPAD_RIGHT || GetLRKeysPressedAndHeld() == MENU_R_PRESSED) { PlaySE(SE_SELECT); - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_RIGHT, MENU_CURSOR_DELTA_NONE); return MENU_NOTHING_CHOSEN; } return MENU_NOTHING_CHOSEN; } -//Unused -s8 sub_8199484(void) +// Unused +static s8 Menu_ProcessGridInputRepeat(void) { u8 oldPos = sMenu.cursorPos; @@ -1578,7 +1579,7 @@ u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, boo sMenu.minCursorPos = 0; sMenu.maxCursorPos = itemCount - 1; sMenu.windowId = windowId; - sMenu.fontId = 1; + sMenu.fontId = FONT_NORMAL; sMenu.optionHeight = 16; sMenu.APressMuted = APressMuted; @@ -1592,7 +1593,8 @@ u8 InitMenuInUpperLeftCorner(u8 windowId, u8 itemCount, u8 initialCursorPos, boo return Menu_MoveCursor(0); } -u8 InitMenuInUpperLeftCornerPlaySoundWhenAPressed(u8 windowId, u8 itemCount, u8 initialCursorPos) +// There is no muted version of this function, so the version that plays sound when A is pressed is the "Normal" one. +u8 InitMenuInUpperLeftCornerNormal(u8 windowId, u8 itemCount, u8 initialCursorPos) { return InitMenuInUpperLeftCorner(windowId, itemCount, initialCursorPos, FALSE); } @@ -1602,24 +1604,22 @@ void PrintMenuTable(u8 windowId, u8 itemCount, const struct MenuAction *menuActi u32 i; for (i = 0; i < itemCount; i++) - { - AddTextPrinterParameterized(windowId, 1, menuActions[i].text, 8, (i * 16) + 1, 0xFF, NULL); - } + AddTextPrinterParameterized(windowId, 1, menuActions[i].text, 8, (i * 16) + 1, TEXT_SKIP_DRAW, NULL); - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } -void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds) +void PrintMenuActionTextsInUpperLeftCorner(u8 windowId, u8 itemCount, const struct MenuAction *menuActions, const u8 *actionIds) { u8 i; struct TextPrinterTemplate printer; printer.windowId = windowId; - printer.fontId = 1; - printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); - printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); - printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.fontId = FONT_NORMAL; + printer.fgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_SHADOW); + printer.unk = GetFontAttribute(FONT_NORMAL, FONTATTR_UNKNOWN); printer.letterSpacing = 0; printer.lineSpacing = 0; printer.x = 8; @@ -1630,10 +1630,10 @@ void sub_81995E4(u8 windowId, u8 itemCount, const struct MenuAction *menuActions printer.currentChar = menuActions[actionIds[i]].text; printer.y = (i * 16) + 1; printer.currentY = (i * 16) + 1; - AddTextPrinter(&printer, 0xFF, NULL); + AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL); } - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 paletteNum, u8 initialCursorPos) @@ -1645,20 +1645,20 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa printer.currentChar = gText_YesNo; printer.windowId = sYesNoWindowId; - printer.fontId = 1; + printer.fontId = FONT_NORMAL; printer.x = 8; printer.y = 1; printer.currentX = printer.x; printer.currentY = printer.y; - printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); - printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); - printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.fgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_SHADOW); + printer.unk = GetFontAttribute(FONT_NORMAL, FONTATTR_UNKNOWN); printer.letterSpacing = 0; printer.lineSpacing = 0; - AddTextPrinter(&printer, 0xFF, NULL); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sYesNoWindowId, 2, initialCursorPos); + AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL); + InitMenuInUpperLeftCornerNormal(sYesNoWindowId, 2, initialCursorPos); } void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *menuActions) @@ -1668,40 +1668,41 @@ void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const for (i = 0; i < rows; i++) { for (j = 0; j < columns; j++) - AddTextPrinterParameterized(windowId, 1, menuActions[(i * columns) + j].text, (optionWidth * j) + 8, (i * 16) + 1, 0xFF, NULL); + AddTextPrinterParameterized(windowId, 1, menuActions[(i * columns) + j].text, (optionWidth * j) + 8, (i * 16) + 1, TEXT_SKIP_DRAW, NULL); } - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } -void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct MenuAction *menuActions, const u8 *actionIds) +// Unused +static void PrintMenuActionGridTextNoSpacing(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *menuActions, const u8 *actionIds) { u8 i; u8 j; struct TextPrinterTemplate printer; printer.windowId = windowId; - printer.fontId = 1; - printer.fgColor = GetFontAttribute(1, FONTATTR_COLOR_FOREGROUND); - printer.bgColor = GetFontAttribute(1, FONTATTR_COLOR_BACKGROUND); - printer.shadowColor = GetFontAttribute(1, FONTATTR_COLOR_SHADOW); - printer.unk = GetFontAttribute(1, FONTATTR_UNKNOWN); + printer.fontId = FONT_NORMAL; + printer.fgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(FONT_NORMAL, FONTATTR_COLOR_SHADOW); + printer.unk = GetFontAttribute(FONT_NORMAL, FONTATTR_UNKNOWN); printer.letterSpacing = 0; printer.lineSpacing = 0; - for (i = 0; i < itemCount2; i++) + for (i = 0; i < rows; i++) { - for (j = 0; j < itemCount; j++) + for (j = 0; j < columns; j++) { - printer.currentChar = menuActions[actionIds[(itemCount * i) + j]].text; - printer.x = (a4 * j) + 8; + printer.currentChar = menuActions[actionIds[(columns * i) + j]].text; + printer.x = (optionWidth * j) + 8; printer.y = (16 * i) + 1; printer.currentX = printer.x; printer.currentY = printer.y; - AddTextPrinter(&printer, 0xFF, NULL); + AddTextPrinter(&printer, TEXT_SKIP_DRAW, NULL); } } - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } u8 InitMenuActionGrid(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos) @@ -1713,7 +1714,7 @@ u8 InitMenuActionGrid(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initi sMenu.minCursorPos = 0; sMenu.maxCursorPos = (columns * rows) - 1; sMenu.windowId = windowId; - sMenu.fontId = 1; + sMenu.fontId = FONT_NORMAL; sMenu.optionWidth = optionWidth; sMenu.optionHeight = 16; sMenu.columns = columns; @@ -1727,7 +1728,7 @@ u8 InitMenuActionGrid(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initi sMenu.cursorPos = pos; // Why call this when it's not gonna move? - ChangeListMenuCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE); + ChangeMenuGridCursorPosition(MENU_CURSOR_DELTA_NONE, MENU_CURSOR_DELTA_NONE); return sMenu.cursorPos; } @@ -1888,51 +1889,46 @@ void CopyToBufferFromBgTilemap(u8 bgId, u16 *dest, u8 left, u8 top, u8 width, u8 for (i = 0; i < height; i++) { for (j = 0; j < width; j++) - { dest[(i * width) + j] = src[(i + top) * 32 + j + left]; - } } } -void sub_8199D3C(void *ptr, int delta, int width, int height, bool32 is8BPP) +void AddValToTilemapBuffer(void *ptr, int delta, int width, int height, bool32 isAffine) { int i; int area = width * height; - if (is8BPP == TRUE) + if (isAffine == TRUE) { u8 *as8BPP = ptr; for (i = 0; i < area; i++) - { as8BPP[i] += delta; - } } else { + // Limit add to first 10 bits u16 *as4BPP = ptr; for (i = 0; i < area; i++) - { as4BPP[i] = (as4BPP[i] & 0xFC00) | ((as4BPP[i] + delta) & 0x3FF); - } } } void ResetBgPositions(void) { - ChangeBgX(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); } -void sub_8199DF0(u32 bg, u8 a1, int a2, int a3) +void BgDmaFill(u32 bg, u8 value, int offset, int size) { - int temp = (!GetBgAttribute(bg, BG_ATTR_PALETTEMODE)) ? 0x20 : 0x40; - void *addr = (void *)((GetBgAttribute(bg, BG_ATTR_CHARBASEINDEX) * 0x4000) + (GetBgAttribute(bg, BG_ATTR_BASETILE) + a2) * temp); - RequestDma3Fill(a1 << 24 | a1 << 16 | a1 << 8 | a1, addr + VRAM, a3 * temp, 1); + int temp = (!GetBgAttribute(bg, BG_ATTR_PALETTEMODE)) ? 32 : 64; + void *addr = (void *)((GetBgAttribute(bg, BG_ATTR_CHARBASEINDEX) * 0x4000) + (GetBgAttribute(bg, BG_ATTR_BASETILE) + offset) * temp); + RequestDma3Fill(value << 24 | value << 16 | value << 8 | value, VRAM + addr, size * temp, 1); } void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const u8 *color, s8 speed, const u8 *str) @@ -1946,8 +1942,8 @@ void AddTextPrinterParameterized3(u8 windowId, u8 fontId, u8 left, u8 top, const printer.y = top; printer.currentX = printer.x; printer.currentY = printer.y; - printer.letterSpacing = GetFontAttribute(fontId, 2); - printer.lineSpacing = GetFontAttribute(fontId, 3); + printer.letterSpacing = GetFontAttribute(fontId, FONTATTR_LETTER_SPACING); + printer.lineSpacing = GetFontAttribute(fontId, FONTATTR_LINE_SPACING); printer.unk = 0; printer.fgColor = color[1]; printer.bgColor = color[0]; @@ -1992,9 +1988,9 @@ void AddTextPrinterParameterized5(u8 windowId, u8 fontId, const u8 *str, u8 left printer.lineSpacing = lineSpacing; printer.unk = 0; - printer.fgColor = GetFontAttribute(fontId, 5); - printer.bgColor = GetFontAttribute(fontId, 6); - printer.shadowColor = GetFontAttribute(fontId, 7); + printer.fgColor = GetFontAttribute(fontId, FONTATTR_COLOR_FOREGROUND); + printer.bgColor = GetFontAttribute(fontId, FONTATTR_COLOR_BACKGROUND); + printer.shadowColor = GetFontAttribute(fontId, FONTATTR_COLOR_SHADOW); AddTextPrinter(&printer, speed, callback); } @@ -2007,11 +2003,10 @@ void PrintPlayerNameOnWindow(u8 windowId, const u8 *src, u16 x, u16 y) StringExpandPlaceholders(gStringVar4, src); - AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, 0xFF, 0); + AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, TEXT_SKIP_DRAW, 0); } -// Unused. Similar to BlitBitmapRect4Bit. -void sub_819A080(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height) +static void UnusedBlitBitmapRect(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 srcY, u16 dstX, u16 dstY, u16 width, u16 height) { int loopSrcY, loopDstY, loopSrcX, loopDstX, xEnd, yEnd, multiplierSrcY, multiplierDstY; const u8 *pixelsSrc; @@ -2028,8 +2023,8 @@ void sub_819A080(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 src else yEnd = srcY + height; - multiplierSrcY = (src->width + (src->width & 7)) >> 3; - multiplierDstY = (dst->width + (dst->width & 7)) >> 3; + multiplierSrcY = (src->width + (src->width % 8)) >> 3; + multiplierDstY = (dst->width + (dst->width % 8)) >> 3; for (loopSrcY = srcY, loopDstY = dstY; loopSrcY < yEnd; loopSrcY++, loopDstY++) { @@ -2038,14 +2033,14 @@ void sub_819A080(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 src pixelsSrc = src->pixels + ((loopSrcX >> 1) & 3) + ((loopSrcX >> 3) << 5) + (((loopSrcY >> 3) * multiplierSrcY) << 5) + ((u32)(loopSrcY << 29) >> 27); pixelsDst = (void*) dst->pixels + ((loopDstX >> 1) & 3) + ((loopDstX >> 3) << 5) + ((( loopDstY >> 3) * multiplierDstY) << 5) + ((u32)(loopDstY << 29) >> 27); - if ((uintptr_t)pixelsDst & 0x1) + if ((uintptr_t)pixelsDst & 1) { pixelsDst--; - if (loopDstX & 0x1) + if (loopDstX & 1) { toOrr = *(vu16*)pixelsDst; toOrr &= 0x0fff; - if (loopSrcX & 0x1) + if (loopSrcX & 1) toOrr |= ((*pixelsSrc & 0xf0) << 8); else toOrr |= ((*pixelsSrc & 0x0f) << 12); @@ -2054,7 +2049,7 @@ void sub_819A080(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 src { toOrr = *(vu16*)pixelsDst; toOrr &= 0xf0ff; - if (loopSrcX & 0x1) + if (loopSrcX & 1) toOrr |= ((*pixelsSrc & 0xf0) << 4); else toOrr |= ((*pixelsSrc & 0x0f) << 8); @@ -2086,12 +2081,14 @@ void sub_819A080(const struct Bitmap *src, struct Bitmap *dst, u16 srcX, u16 src } } -void sub_819A25C(u8 palOffset, u16 speciesId) +// Unused +static void LoadMonIconPalAtOffset(u8 palOffset, u16 speciesId) { LoadPalette(GetValidMonIconPalettePtr(speciesId), palOffset, 0x20); } -void sub_819A27C(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y) +// Unused +static void DrawMonIconAtPos(u8 windowId, u16 speciesId, u32 personality, u16 x, u16 y) { BlitBitmapToWindow(windowId, GetMonIconPtr(speciesId, personality, 1), x, y, 32, 32); } @@ -2104,13 +2101,13 @@ void ListMenuLoadStdPalAt(u8 palOffset, u8 palId) { case 0: default: - palette = gFireRedMenuElements1_Pal; + palette = gMenuInfoElements1_Pal; break; case 1: - palette = gFireRedMenuElements2_Pal; + palette = gMenuInfoElements2_Pal; break; case 2: - palette = gFireRedMenuElements3_Pal; + palette = gMenuInfoElements3_Pal; break; } @@ -2119,7 +2116,7 @@ void ListMenuLoadStdPalAt(u8 palOffset, u8 palId) void BlitMenuInfoIcon(u8 windowId, u8 iconId, u16 x, u16 y) { - BlitBitmapRectToWindow(windowId, gFireRedMenuElements_Gfx + sMenuInfoIcons[iconId].offset * 32, 0, 0, 128, 128, x, y, sMenuInfoIcons[iconId].width, sMenuInfoIcons[iconId].height); + BlitBitmapRectToWindow(windowId, &gMenuInfoElements_Gfx[sMenuInfoIcons[iconId].offset * 32], 0, 0, 128, 128, x, y, sMenuInfoIcons[iconId].width, sMenuInfoIcons[iconId].height); } void BufferSaveMenuText(u8 textId, u8 *dest, u8 color) diff --git a/src/menu_helpers.c b/src/menu_helpers.c index 331755590..5bc197010 100644 --- a/src/menu_helpers.c +++ b/src/menu_helpers.c @@ -106,14 +106,14 @@ void ResetVramOamAndBgCntRegs(void) void ResetAllBgsCoordinates(void) { - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); } void SetVBlankHBlankCallbacksToNull(void) @@ -278,51 +278,45 @@ u8 GetLRKeysPressedAndHeld(void) bool8 IsHoldingItemAllowed(u16 itemId) { // Enigma Berry can't be held in link areas - if (itemId != ITEM_ENIGMA_BERRY) - return TRUE; - else if (gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRADE_CENTER) - && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRADE_CENTER)) + if (itemId == ITEM_ENIGMA_BERRY + && ((gSaveBlock1Ptr->location.mapGroup == MAP_GROUP(TRADE_CENTER) + && gSaveBlock1Ptr->location.mapNum == MAP_NUM(TRADE_CENTER)) + || InUnionRoom() == TRUE)) return FALSE; - else if (InUnionRoom() != TRUE) - return TRUE; else - return FALSE; + return TRUE; } bool8 IsWritingMailAllowed(u16 itemId) { - if (IsUpdateLinkStateCBActive() != TRUE && InUnionRoom() != TRUE) - return TRUE; - else if (ItemIsMail(itemId) != TRUE) - return TRUE; - else + if ((IsOverworldLinkActive() == TRUE || InUnionRoom() == TRUE) && ItemIsMail(itemId) == TRUE) return FALSE; + else + return TRUE; } -bool8 MenuHelpers_LinkSomething(void) +bool8 MenuHelpers_IsLinkActive(void) { - if (IsUpdateLinkStateCBActive() == TRUE || gReceivedRemoteLinkPlayers == 1) + if (IsOverworldLinkActive() == TRUE || gReceivedRemoteLinkPlayers == 1) return TRUE; else return FALSE; } -static bool8 sub_81221D0(void) +static bool8 IsActiveOverworldLinkBusy(void) { - if (!MenuHelpers_LinkSomething()) + if (!MenuHelpers_IsLinkActive()) return FALSE; else - return Overworld_LinkRecvQueueLengthMoreThan2(); + return Overworld_IsRecvQueueAtMax(); } -bool8 MenuHelpers_CallLinkSomething(void) +bool8 MenuHelpers_ShouldWaitForLinkRecv(void) { - if (sub_81221D0() == TRUE) + if (IsActiveOverworldLinkBusy() == TRUE || IsLinkRecvQueueAtOverworldMax() == TRUE ) return TRUE; - else if (IsLinkRecvQueueLengthAtLeast3() != TRUE) - return FALSE; else - return TRUE; + return FALSE; } void SetItemListPerPageCount(struct ItemSlot *slots, u8 slotsCount, u8 *pageItems, u8 *totalItems, u8 maxPerPage) diff --git a/src/menu_specialized.c b/src/menu_specialized.c index c9d895e19..3a6a60885 100644 --- a/src/menu_specialized.c +++ b/src/menu_specialized.c @@ -203,7 +203,7 @@ static const struct ListMenuTemplate sMoveRelearnerMovesListTemplate = .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 0 }; @@ -268,7 +268,7 @@ static void MailboxMenu_ItemPrintFunc(u8 windowId, u32 itemId, u8 y) length = StringLength(buffer); if (length < PLAYER_NAME_LENGTH - 1) ConvertInternationalString(buffer, LANGUAGE_JAPANESE); - AddTextPrinterParameterized4(windowId, 1, 8, y, 0, 0, sPlayerNameTextColors, -1, buffer); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, 8, y, 0, 0, sPlayerNameTextColors, TEXT_SKIP_DRAW, buffer); } u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page) @@ -296,7 +296,7 @@ u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page) gMultiuseListMenuTemplate.cursorShadowPal = 3; gMultiuseListMenuTemplate.moveCursorFunc = MailboxMenu_MoveCursorFunc; gMultiuseListMenuTemplate.itemPrintFunc = MailboxMenu_ItemPrintFunc; - gMultiuseListMenuTemplate.fontId = 1; + gMultiuseListMenuTemplate.fontId = FONT_NORMAL; gMultiuseListMenuTemplate.cursorKind = 0; gMultiuseListMenuTemplate.lettersSpacing = 0; gMultiuseListMenuTemplate.itemVerticalPadding = 0; @@ -683,7 +683,7 @@ void InitMoveRelearnerWindows(bool8 useContextWindow) InitWindows(sMoveRelearnerWindowTemplates); DeactivateAllTextPrinters(); LoadUserWindowBorderGfx(0, 1, 0xE0); - LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(gStandardMenuPalette, 0xF0, 0x20); for (i = 0; i < 5; i++) { @@ -739,31 +739,31 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove) FillWindowPixelBuffer(0, PIXEL_FILL(1)); str = gText_MoveRelearnerBattleMoves; - x = GetStringCenterAlignXOffset(1, str, 0x80); - AddTextPrinterParameterized(0, 1, str, x, 1, TEXT_SPEED_FF, NULL); + x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 0x80); + AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL); str = gText_MoveRelearnerPP; - AddTextPrinterParameterized(0, 1, str, 4, 0x29, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, str, 4, 0x29, TEXT_SKIP_DRAW, NULL); str = gText_MoveRelearnerPower; - x = GetStringRightAlignXOffset(1, str, 0x6A); - AddTextPrinterParameterized(0, 1, str, x, 0x19, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x6A); + AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 0x19, TEXT_SKIP_DRAW, NULL); str = gText_MoveRelearnerAccuracy; - x = GetStringRightAlignXOffset(1, str, 0x6A); - AddTextPrinterParameterized(0, 1, str, x, 0x29, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x6A); + AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 0x29, TEXT_SKIP_DRAW, NULL); if (chosenMove == LIST_CANCEL) { - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); return; } move = &gBattleMoves[chosenMove]; str = gTypeNames[move->type]; - AddTextPrinterParameterized(0, 1, str, 4, 0x19, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, str, 4, 0x19, TEXT_SKIP_DRAW, NULL); - x = 4 + GetStringWidth(1, gText_MoveRelearnerPP, 0); + x = 4 + GetStringWidth(FONT_NORMAL, gText_MoveRelearnerPP, 0); ConvertIntToDecimalStringN(buffer, move->pp, STR_CONV_MODE_LEFT_ALIGN, 2); - AddTextPrinterParameterized(0, 1, buffer, x, 0x29, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, buffer, x, 0x29, TEXT_SKIP_DRAW, NULL); if (move->power < 2) { @@ -774,7 +774,7 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove) ConvertIntToDecimalStringN(buffer, move->power, STR_CONV_MODE_LEFT_ALIGN, 3); str = buffer; } - AddTextPrinterParameterized(0, 1, str, 0x6A, 0x19, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, str, 0x6A, 0x19, TEXT_SKIP_DRAW, NULL); if (move->accuracy == 0) { @@ -785,10 +785,10 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove) ConvertIntToDecimalStringN(buffer, move->accuracy, STR_CONV_MODE_LEFT_ALIGN, 3); str = buffer; } - AddTextPrinterParameterized(0, 1, str, 0x6A, 0x29, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, str, 0x6A, 0x29, TEXT_SKIP_DRAW, NULL); str = gMoveDescriptionPointers[chosenMove - 1]; - AddTextPrinterParameterized(0, 7, str, 0, 0x41, 0, NULL); + AddTextPrinterParameterized(0, FONT_NARROW, str, 0, 0x41, 0, NULL); } static void MoveRelearnerMenuLoadContestMoveDescription(u32 chosenMove) @@ -800,31 +800,31 @@ static void MoveRelearnerMenuLoadContestMoveDescription(u32 chosenMove) MoveRelearnerShowHideHearts(chosenMove); FillWindowPixelBuffer(1, PIXEL_FILL(1)); str = gText_MoveRelearnerContestMovesTitle; - x = GetStringCenterAlignXOffset(1, str, 0x80); - AddTextPrinterParameterized(1, 1, str, x, 1, TEXT_SPEED_FF, NULL); + x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 0x80); + AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL); str = gText_MoveRelearnerAppeal; - x = GetStringRightAlignXOffset(1, str, 0x5C); - AddTextPrinterParameterized(1, 1, str, x, 0x19, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x5C); + AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 0x19, TEXT_SKIP_DRAW, NULL); str = gText_MoveRelearnerJam; - x = GetStringRightAlignXOffset(1, str, 0x5C); - AddTextPrinterParameterized(1, 1, str, x, 0x29, TEXT_SPEED_FF, NULL); + x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x5C); + AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 0x29, TEXT_SKIP_DRAW, NULL); if (chosenMove == MENU_NOTHING_CHOSEN) { - CopyWindowToVram(1, 2); + CopyWindowToVram(1, COPYWIN_GFX); return; } move = &gContestMoves[chosenMove]; str = gContestMoveTypeTextPointers[move->contestCategory]; - AddTextPrinterParameterized(1, 1, str, 4, 0x19, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(1, FONT_NORMAL, str, 4, 0x19, TEXT_SKIP_DRAW, NULL); str = gContestEffectDescriptionPointers[move->effect]; - AddTextPrinterParameterized(1, 7, str, 0, 0x41, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(1, FONT_NARROW, str, 0, 0x41, TEXT_SKIP_DRAW, NULL); - CopyWindowToVram(1, 2); + CopyWindowToVram(1, COPYWIN_GFX); } static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list) @@ -842,7 +842,7 @@ void MoveRelearnerPrintText(u8 *str) FillWindowPixelBuffer(3, PIXEL_FILL(1)); gTextFlags.canABSpeedUpPrint = TRUE; speed = GetPlayerTextSpeedDelay(); - AddTextPrinterParameterized2(3, 1, str, speed, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, 3); + AddTextPrinterParameterized2(3, FONT_NORMAL, str, speed, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, 3); } bool16 MoveRelearnerRunTextPrinters(void) @@ -1512,7 +1512,7 @@ void DrawLevelUpWindowPg1(u16 windowId, u16 *statsBefore, u16 *statsAfter, u8 bg { AddTextPrinterParameterized3(windowId, - 1, + FONT_NORMAL, 0, 15 * i, color, @@ -1521,7 +1521,7 @@ void DrawLevelUpWindowPg1(u16 windowId, u16 *statsBefore, u16 *statsAfter, u8 bg StringCopy(text, (statsDiff[i] >= 0) ? gText_Plus : gText_Dash); AddTextPrinterParameterized3(windowId, - 1, + FONT_NORMAL, 56, 15 * i, color, @@ -1534,7 +1534,7 @@ void DrawLevelUpWindowPg1(u16 windowId, u16 *statsBefore, u16 *statsAfter, u8 bg ConvertIntToDecimalStringN(text, abs(statsDiff[i]), STR_CONV_MODE_LEFT_ALIGN, 2); AddTextPrinterParameterized3(windowId, - 1, + FONT_NORMAL, 56 + x, 15 * i, color, @@ -1576,7 +1576,7 @@ void DrawLevelUpWindowPg2(u16 windowId, u16 *currStats, u8 bgClr, u8 fgClr, u8 s x = 6 * (4 - numDigits); AddTextPrinterParameterized3(windowId, - 1, + FONT_NORMAL, 0, 15 * i, color, @@ -1584,7 +1584,7 @@ void DrawLevelUpWindowPg2(u16 windowId, u16 *currStats, u8 bgClr, u8 fgClr, u8 s sLvlUpStatStrings[i]); AddTextPrinterParameterized3(windowId, - 1, + FONT_NORMAL, 56 + x, 15 * i, color, diff --git a/src/metatile_behavior.c b/src/metatile_behavior.c index 3829523df..ad5eb42cc 100644 --- a/src/metatile_behavior.c +++ b/src/metatile_behavior.c @@ -136,8 +136,8 @@ static const u8 sTileBitAttributes[] = [MB_BRIDGE_OVER_POND_MED_EDGE_2] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_BRIDGE_OVER_POND_HIGH_EDGE_1] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_BRIDGE_OVER_POND_HIGH_EDGE_2] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), - [MB_UNUSED_BRIDGE_1] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), - [MB_UNUSED_BRIDGE_2] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + [MB_UNUSED_BRIDGE] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), + [MB_BIKE_BRIDGE_OVER_BARRIER] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_COUNTER] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_81] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_82] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), @@ -208,7 +208,7 @@ static const u8 sTileBitAttributes[] = [MB_HOLDS_LARGE_DECORATION] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_SECRET_BASE_TV_SHIELD] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), [MB_PLAYER_ROOM_PC_ON] = TILE_ATTRIBUTES(TRUE, FALSE, FALSE), - [MB_C6] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), + [MB_SECRET_BASE_DECORATION_BASE] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_SECRET_BASE_POSTER] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_C8] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), [MB_UNUSED_C9] = TILE_ATTRIBUTES(FALSE, FALSE, FALSE), @@ -711,9 +711,9 @@ bool8 MetatileBehavior_IsSecretBaseImpassable(u8 metatileBehavior) return FALSE; } -bool8 MetatileBehavior_IsMB_C6(u8 metatileBehavior) +bool8 MetatileBehavior_IsSecretBaseDecorationBase(u8 metatileBehavior) { - if (metatileBehavior == MB_C6) + if (metatileBehavior == MB_SECRET_BASE_DECORATION_BASE) return TRUE; else return FALSE; @@ -901,8 +901,8 @@ bool8 MetatileBehavior_IsBridgeOverWater(u8 metatileBehavior) || metatileBehavior == MB_BRIDGE_OVER_POND_HIGH) || (metatileBehavior == MB_BRIDGE_OVER_POND_HIGH_EDGE_1 || metatileBehavior == MB_BRIDGE_OVER_POND_HIGH_EDGE_2 - || metatileBehavior == MB_UNUSED_BRIDGE_1 - || metatileBehavior == MB_UNUSED_BRIDGE_2)) + || metatileBehavior == MB_UNUSED_BRIDGE + || metatileBehavior == MB_BIKE_BRIDGE_OVER_BARRIER)) return TRUE; else return FALSE; @@ -1262,12 +1262,11 @@ bool8 MetatileBehavior_IsAquaHideoutWarp(u8 metatileBehavior) return FALSE; } -// Very odd, used to initiate a teleport-style warp. -// No warp events seem to be on a metatile of this kind, and it's -// used by log bridges over ocean-style water, which wouldn't make -// sense to have a warp like this. -bool8 MetatileBehavior_IsBridgeOverOcean(u8 metatileBehavior) +bool8 MetatileBehavior_IsUnionRoomWarp(u8 metatileBehavior) { + // This metatile behavior is re-used for some reason by + // the Union Room exit metatile. This function is used to + // initiate a teleport-style warp. if (metatileBehavior == MB_BRIDGE_OVER_OCEAN) return TRUE; else diff --git a/src/minigame_countdown.c b/src/minigame_countdown.c index cd2971732..178b6d5b7 100644 --- a/src/minigame_countdown.c +++ b/src/minigame_countdown.c @@ -447,7 +447,7 @@ static bool32 RunMinigameCountdownDigitsAnim(u8 spriteId) switch (sprite->sState) { case 0: - sub_8007E18(sprite, 0x800, 0x1A); + SetSpriteMatrixAnchor(sprite, NO_ANCHOR, 26); sprite->sState++; // fallthrough case 1: diff --git a/src/mirage_tower.c b/src/mirage_tower.c index 7fc883ca1..9473b0f82 100644 --- a/src/mirage_tower.c +++ b/src/mirage_tower.c @@ -536,8 +536,8 @@ static void InitMirageTowerShake(u8 taskId) case 1: sMirageTowerGfxBuffer = (u8 *)AllocZeroed(MIRAGE_TOWER_GFX_LENGTH); sMirageTowerTilemapBuffer = (u8 *)AllocZeroed(BG_SCREEN_SIZE); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); gTasks[taskId].tState++; break; case 2: diff --git a/src/money.c b/src/money.c index 6213f2dd0..c331462d4 100644 --- a/src/money.c +++ b/src/money.c @@ -149,7 +149,7 @@ void PrintMoneyAmount(u8 windowId, u8 x, u8 y, int amount, u8 speed) *(txtPtr++) = 0x77; StringExpandPlaceholders(txtPtr, gText_PokedollarVar1); - AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, speed, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, x, y, speed, NULL); } void PrintMoneyAmountInMoneyBoxWithBorder(u8 windowId, u16 tileStart, u8 pallete, int amount) @@ -171,7 +171,7 @@ void DrawMoneyBox(int amount, u8 x, u8 y) sMoneyBoxWindowId = AddWindow(&template); FillWindowPixelBuffer(sMoneyBoxWindowId, PIXEL_FILL(0)); PutWindowTilemap(sMoneyBoxWindowId); - CopyWindowToVram(sMoneyBoxWindowId, 1); + CopyWindowToVram(sMoneyBoxWindowId, COPYWIN_MAP); PrintMoneyAmountInMoneyBoxWithBorder(sMoneyBoxWindowId, 0x214, 14, amount); AddMoneyLabelObject((8 * x) + 19, (8 * y) + 11); } @@ -180,7 +180,7 @@ void HideMoneyBox(void) { RemoveMoneyLabelObject(); ClearStdWindowAndFrameToTransparent(sMoneyBoxWindowId, FALSE); - CopyWindowToVram(sMoneyBoxWindowId, 2); + CopyWindowToVram(sMoneyBoxWindowId, COPYWIN_GFX); RemoveWindow(sMoneyBoxWindowId); } diff --git a/src/move_relearner.c b/src/move_relearner.c index 1fa947eba..92d230616 100644 --- a/src/move_relearner.c +++ b/src/move_relearner.c @@ -687,7 +687,7 @@ static void DoMoveRelearnerMain(void) ShowTeachMoveText(TRUE); } RemoveScrollArrows(); - CopyWindowToVram(3, 2); + CopyWindowToVram(3, COPYWIN_GFX); break; case MENU_STATE_TRY_OVERWRITE_MOVE: if (!gPaletteFade.active) @@ -766,7 +766,7 @@ static void HideHeartSpritesAndShowTeachMoveText(bool8 onlyHideSprites) { StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn); FillWindowPixelBuffer(3, 0x11); - AddTextPrinterParameterized(3, 1, gStringVar4, 0, 1, 0, NULL); + AddTextPrinterParameterized(3, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL); } } @@ -836,7 +836,7 @@ static void ShowTeachMoveText(bool8 shouldDoNothingInstead) { StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn); FillWindowPixelBuffer(3, 0x11); - AddTextPrinterParameterized(3, 1, gStringVar4, 0, 1, 0, NULL); + AddTextPrinterParameterized(3, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL); } } diff --git a/src/mystery_event_menu.c b/src/mystery_event_menu.c index 297883e9c..717931268 100644 --- a/src/mystery_event_menu.c +++ b/src/mystery_event_menu.c @@ -20,14 +20,11 @@ #include "decompress.h" #include "constants/rgb.h" -// this file's functions static void CB2_MysteryEventMenu(void); static void PrintMysteryMenuText(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed); -// EWRAM vars -static EWRAM_DATA u8 sUnknown_0203BCF8 = 0; // set but unused +static EWRAM_DATA u8 sUnused = 0; // set but unused -// const rom data static const struct BgTemplate sBgTemplates[] = { { @@ -136,7 +133,7 @@ static void CB2_MysteryEventMenu(void) case 0: DrawStdFrameWithCustomTileAndPalette(0, 1, 1, 0xD); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); ShowBg(0); BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_BLACK); gMain.state++; @@ -184,7 +181,7 @@ static void CB2_MysteryEventMenu(void) DrawStdFrameWithCustomTileAndPalette(1, 1, 1, 0xD); PrintMysteryMenuText(1, gText_LoadingEvent, 1, 2, 0); PutWindowTilemap(1); - CopyWindowToVram(1, 3); + CopyWindowToVram(1, COPYWIN_FULL); gMain.state++; } else if (JOY_NEW(B_BUTTON)) @@ -270,7 +267,7 @@ static void CB2_MysteryEventMenu(void) if (!IsTextPrinterActive(0)) { gMain.state++; - sUnknown_0203BCF8 = 0; + sUnused = 0; } break; case 14: @@ -315,5 +312,5 @@ static void PrintMysteryMenuText(u8 windowId, const u8 *text, u8 x, u8 y, s32 sp textColor[2] = 3; FillWindowPixelBuffer(windowId, PIXEL_FILL(textColor[0])); - AddTextPrinterParameterized4(windowId, 1, x, y, letterSpacing, lineSpacing, textColor, speed, text); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, letterSpacing, lineSpacing, textColor, speed, text); } diff --git a/src/mystery_gift_menu.c b/src/mystery_gift_menu.c index e1236adfd..b970711fd 100644 --- a/src/mystery_gift_menu.c +++ b/src/mystery_gift_menu.c @@ -235,7 +235,7 @@ static const struct ListMenuTemplate sListMenuTemplate_ThreeOptions = { .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = 0, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 0 }; @@ -280,7 +280,7 @@ static const struct ListMenuTemplate sListMenu_ReceiveSendToss = { .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = 0, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 0 }; @@ -301,7 +301,7 @@ static const struct ListMenuTemplate sListMenu_ReceiveToss = { .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = 0, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 0 }; @@ -322,7 +322,7 @@ static const struct ListMenuTemplate sListMenu_ReceiveSend = { .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = 0, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 0 }; @@ -343,11 +343,11 @@ static const struct ListMenuTemplate sListMenu_Receive = { .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = 0, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 0 }; -static const u8 *const Unref_082F0710[] = { +static const u8 *const sUnusedMenuTexts[] = { gText_VarietyOfEventsImportedWireless, gText_WonderCardsInPossession, gText_ReadNewsThatArrived, @@ -387,14 +387,14 @@ static bool32 HandleMysteryGiftOrEReaderSetup(s32 isEReader) ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBGTemplates, ARRAY_COUNT(sBGTemplates)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); SetBgTilemapBuffer(3, Alloc(BG_SCREEN_SIZE)); SetBgTilemapBuffer(2, Alloc(BG_SCREEN_SIZE)); @@ -490,9 +490,9 @@ void PrintMysteryGiftOrEReaderTopMenu(bool8 isEReader, bool32 useCancel) options = gJPText_DecideStop; } - AddTextPrinterParameterized4(0, 1, 4, 1, 0, 0, sTextColors_TopMenu, TEXT_SPEED_FF, header); - AddTextPrinterParameterized4(0, 0, GetStringRightAlignXOffset(0, options, 0xDE), 1, 0, 0, sTextColors_TopMenu, TEXT_SPEED_FF, options); - CopyWindowToVram(0, 2); + AddTextPrinterParameterized4(0, FONT_NORMAL, 4, 1, 0, 0, sTextColors_TopMenu, TEXT_SKIP_DRAW, header); + AddTextPrinterParameterized4(0, FONT_SMALL, GetStringRightAlignXOffset(FONT_SMALL, options, 0xDE), 1, 0, 0, sTextColors_TopMenu, TEXT_SKIP_DRAW, options); + CopyWindowToVram(0, COPYWIN_GFX); PutWindowTilemap(0); } @@ -537,17 +537,17 @@ void AddTextPrinterToWindow1(const u8 *str) { StringExpandPlaceholders(gStringVar4, str); FillWindowPixelBuffer(1, 0x11); - AddTextPrinterParameterized4(1, 1, 0, 1, 0, 0, sMG_Ereader_TextColor_2, 0, gStringVar4); + AddTextPrinterParameterized4(1, FONT_NORMAL, 0, 1, 0, 0, sMG_Ereader_TextColor_2, 0, gStringVar4); DrawTextBorderOuter(1, 0x001, 0xF); PutWindowTilemap(1); - CopyWindowToVram(1, 3); + CopyWindowToVram(1, COPYWIN_FULL); } static void ClearTextWindow(void) { rbox_fill_rectangle(1); ClearWindowTilemap(1); - CopyWindowToVram(1, 1); + CopyWindowToVram(1, COPYWIN_MAP); } #define DOWN_ARROW_X 208 @@ -649,7 +649,7 @@ static u32 MysteryGift_HandleThreeOptionMenu(u8 * unused0, u16 * unused1, u8 whi if (response != LIST_NOTHING_CHOSEN) { ClearWindowTilemap(2); - CopyWindowToVram(2, 1); + CopyWindowToVram(2, COPYWIN_MAP); } return response; } @@ -669,9 +669,9 @@ s8 DoMysteryGiftYesNo(u8 * textState, u16 * windowId, bool8 yesNoBoxPlacement, c else *windowId = AddWindow(&sWindowTemplate_YesNoMsg); FillWindowPixelBuffer(*windowId, 0x11); - AddTextPrinterParameterized4(*windowId, 1, 0, 1, 0, 0, sMG_Ereader_TextColor_2, 0, gStringVar4); + AddTextPrinterParameterized4(*windowId, FONT_NORMAL, 0, 1, 0, 0, sMG_Ereader_TextColor_2, 0, gStringVar4); DrawTextBorderOuter(*windowId, 0x001, 0x0F); - CopyWindowToVram(*windowId, 2); + CopyWindowToVram(*windowId, COPYWIN_GFX); PutWindowTilemap(*windowId); (*textState)++; break; @@ -693,7 +693,7 @@ s8 DoMysteryGiftYesNo(u8 * textState, u16 * windowId, bool8 yesNoBoxPlacement, c *textState = 0; rbox_fill_rectangle(*windowId); ClearWindowTilemap(*windowId); - CopyWindowToVram(*windowId, 1); + CopyWindowToVram(*windowId, COPYWIN_MAP); RemoveWindow(*windowId); return input; } @@ -702,7 +702,7 @@ s8 DoMysteryGiftYesNo(u8 * textState, u16 * windowId, bool8 yesNoBoxPlacement, c *textState = 0; rbox_fill_rectangle(*windowId); ClearWindowTilemap(*windowId); - CopyWindowToVram(*windowId, 1); + CopyWindowToVram(*windowId, COPYWIN_MAP); RemoveWindow(*windowId); return MENU_B_PRESSED; } @@ -726,9 +726,9 @@ static s32 HandleGiftSelectMenu(u8 * textState, u16 * windowId, bool32 cannotTos StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithNews); *windowId = AddWindow(&sWindowTemplate_GiftSelect); FillWindowPixelBuffer(*windowId, 0x11); - AddTextPrinterParameterized4(*windowId, 1, 0, 1, 0, 0, sMG_Ereader_TextColor_2, 0, gStringVar4); + AddTextPrinterParameterized4(*windowId, FONT_NORMAL, 0, 1, 0, 0, sMG_Ereader_TextColor_2, 0, gStringVar4); DrawTextBorderOuter(*windowId, 0x001, 0x0F); - CopyWindowToVram(*windowId, 2); + CopyWindowToVram(*windowId, COPYWIN_GFX); PutWindowTilemap(*windowId); (*textState)++; break; @@ -753,7 +753,7 @@ static s32 HandleGiftSelectMenu(u8 * textState, u16 * windowId, bool32 cannotTos *textState = 0; rbox_fill_rectangle(*windowId); ClearWindowTilemap(*windowId); - CopyWindowToVram(*windowId, 1); + CopyWindowToVram(*windowId, COPYWIN_MAP); RemoveWindow(*windowId); return input; } @@ -762,7 +762,7 @@ static s32 HandleGiftSelectMenu(u8 * textState, u16 * windowId, bool32 cannotTos *textState = 0; rbox_fill_rectangle(*windowId); ClearWindowTilemap(*windowId); - CopyWindowToVram(*windowId, 1); + CopyWindowToVram(*windowId, COPYWIN_MAP); RemoveWindow(*windowId); return LIST_CANCEL; } diff --git a/src/mystery_gift_view.c b/src/mystery_gift_view.c index 0e1c11520..3047a219e 100644 --- a/src/mystery_gift_view.c +++ b/src/mystery_gift_view.c @@ -424,25 +424,25 @@ static void DrawCardWindow(u8 whichWindow) { // Print card title/subtitle s32 x; - AddTextPrinterParameterized3(windowId, 3, 0, 1, sCard_TextColorTable[sWonderCardData->gfx->titleTextPal], 0, sWonderCardData->titleText); - x = 160 - GetStringWidth(3, sWonderCardData->subtitleText, GetFontAttribute(3, FONTATTR_LETTER_SPACING)); + AddTextPrinterParameterized3(windowId, FONT_SHORT_COPY_1, 0, 1, sCard_TextColorTable[sWonderCardData->gfx->titleTextPal], 0, sWonderCardData->titleText); + x = 160 - GetStringWidth(FONT_SHORT_COPY_1, sWonderCardData->subtitleText, GetFontAttribute(FONT_SHORT_COPY_1, FONTATTR_LETTER_SPACING)); if (x < 0) x = 0; - AddTextPrinterParameterized3(windowId, 3, x, 17, sCard_TextColorTable[sWonderCardData->gfx->titleTextPal], 0, sWonderCardData->subtitleText); + AddTextPrinterParameterized3(windowId, FONT_SHORT_COPY_1, x, 17, sCard_TextColorTable[sWonderCardData->gfx->titleTextPal], 0, sWonderCardData->subtitleText); // Print id number if (sWonderCardData->card.idNumber != 0) - AddTextPrinterParameterized3(windowId, 1, 166, 17, sCard_TextColorTable[sWonderCardData->gfx->titleTextPal], 0, sWonderCardData->idNumberText); + AddTextPrinterParameterized3(windowId, FONT_NORMAL, 166, 17, sCard_TextColorTable[sWonderCardData->gfx->titleTextPal], 0, sWonderCardData->idNumberText); break; } case CARD_WIN_BODY: // Print body text for (; i < WONDER_CARD_BODY_TEXT_LINES; i++) - AddTextPrinterParameterized3(windowId, 3, 0, 16 * i + 2, sCard_TextColorTable[sWonderCardData->gfx->bodyTextPal], 0, sWonderCardData->bodyText[i]); + AddTextPrinterParameterized3(windowId, FONT_SHORT_COPY_1, 0, 16 * i + 2, sCard_TextColorTable[sWonderCardData->gfx->bodyTextPal], 0, sWonderCardData->bodyText[i]); break; case CARD_WIN_FOOTER: // Print footer line 1 - AddTextPrinterParameterized3(windowId, 3, 0, + AddTextPrinterParameterized3(windowId, FONT_SHORT_COPY_1, 0, sCard_FooterTextOffsets[sWonderCardData->card.type], sCard_TextColorTable[sWonderCardData->gfx->footerTextPal], 0, sWonderCardData->footerLine1Text); @@ -452,7 +452,7 @@ static void DrawCardWindow(u8 whichWindow) { // Print gift text // Odd that CARD_TYPE_STAMP is not ignored, it has empty text for this - AddTextPrinterParameterized3(windowId, 3, 0, + AddTextPrinterParameterized3(windowId, FONT_SHORT_COPY_1, 0, 16 + sCard_FooterTextOffsets[sWonderCardData->card.type], sCard_TextColorTable[sWonderCardData->gfx->footerTextPal], 0, sWonderCardData->giftText); @@ -461,25 +461,25 @@ static void DrawCardWindow(u8 whichWindow) { s32 x = 0; s32 y = sCard_FooterTextOffsets[sWonderCardData->card.type] + 16; - s32 spacing = GetFontAttribute(3, FONTATTR_LETTER_SPACING); + s32 spacing = GetFontAttribute(FONT_SHORT_COPY_1, FONTATTR_LETTER_SPACING); for (; i < sWonderCardData->statFooterWidth; i++) { // Print stat text - AddTextPrinterParameterized3(windowId, 3, x, y, sCard_TextColorTable[sWonderCardData->gfx->footerTextPal], 0, sWonderCardData->statTextData[i].statText); + AddTextPrinterParameterized3(windowId, FONT_SHORT_COPY_1, x, y, sCard_TextColorTable[sWonderCardData->gfx->footerTextPal], 0, sWonderCardData->statTextData[i].statText); if (sWonderCardData->statTextData[i].statNumberText[0] != EOS) { // Print stat number - x += GetStringWidth(3, sWonderCardData->statTextData[i].statText, spacing); - AddTextPrinterParameterized3(windowId, 3, x, y, + x += GetStringWidth(FONT_SHORT_COPY_1, sWonderCardData->statTextData[i].statText, spacing); + AddTextPrinterParameterized3(windowId, FONT_SHORT_COPY_1, x, y, sCard_TextColorTable[sWonderCardData->gfx->footerTextPal], 0, sWonderCardData->statTextData[i].statNumberText); - x += GetStringWidth(3, sWonderCardData->statTextData[i].statNumberText, spacing) + sWonderCardData->statTextData[i].width; + x += GetStringWidth(FONT_SHORT_COPY_1, sWonderCardData->statTextData[i].statNumberText, spacing) + sWonderCardData->statTextData[i].width; } } } break; } - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } static void CreateCardSprites(void) @@ -678,10 +678,10 @@ s32 WonderNews_Enter(void) case 1: if (UpdatePaletteFade()) return 0; - ChangeBgY(0, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, DISPLAY_WIDTH)); SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(26, 152)); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ); @@ -753,7 +753,7 @@ s32 WonderNews_Exit(bool32 useCancel) case 1: if (UpdatePaletteFade()) return 0; - ChangeBgY(2, 0, 0); + ChangeBgY(2, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_WIN0H, 0); SetGpuReg(REG_OFFSET_WIN0V, 0); SetGpuReg(REG_OFFSET_WININ, 0); @@ -777,8 +777,8 @@ s32 WonderNews_Exit(bool32 useCancel) RemoveWindow(sWonderNewsData->windowIds[NEWS_WIN_TITLE]); break; case 4: - ChangeBgY(2, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); if (sWonderNewsData->arrowTaskId != TASK_NONE) { RemoveScrollIndicatorArrowPair(sWonderNewsData->arrowTaskId); @@ -893,20 +893,20 @@ static void DrawNewsWindows(void) FillWindowPixelBuffer(sWonderNewsData->windowIds[NEWS_WIN_BODY], 0); // Print title text - x = (224 - GetStringWidth(3, sWonderNewsData->titleText, GetFontAttribute(3, FONTATTR_LETTER_SPACING))) / 2; + x = (224 - GetStringWidth(FONT_SHORT_COPY_1, sWonderNewsData->titleText, GetFontAttribute(FONT_SHORT_COPY_1, FONTATTR_LETTER_SPACING))) / 2; if (x < 0) x = 0; - AddTextPrinterParameterized3(sWonderNewsData->windowIds[NEWS_WIN_TITLE], 3, x, 6, sNews_TextColorTable[sWonderNewsData->gfx->titleTextPal], 0, sWonderNewsData->titleText); + AddTextPrinterParameterized3(sWonderNewsData->windowIds[NEWS_WIN_TITLE], FONT_SHORT_COPY_1, x, 6, sNews_TextColorTable[sWonderNewsData->gfx->titleTextPal], 0, sWonderNewsData->titleText); // Print body text for (; i < WONDER_NEWS_BODY_TEXT_LINES; i++) - AddTextPrinterParameterized3(sWonderNewsData->windowIds[NEWS_WIN_BODY], 3, 0, + AddTextPrinterParameterized3(sWonderNewsData->windowIds[NEWS_WIN_BODY], FONT_SHORT_COPY_1, 0, 16 * i + 2, sNews_TextColorTable[sWonderNewsData->gfx->bodyTextPal], 0, sWonderNewsData->bodyText[i]); - CopyWindowToVram(sWonderNewsData->windowIds[NEWS_WIN_TITLE], 3); - CopyWindowToVram(sWonderNewsData->windowIds[NEWS_WIN_BODY], 3); + CopyWindowToVram(sWonderNewsData->windowIds[NEWS_WIN_TITLE], COPYWIN_FULL); + CopyWindowToVram(sWonderNewsData->windowIds[NEWS_WIN_BODY], COPYWIN_FULL); } static void UpdateNewsScroll(void) diff --git a/src/naming_screen.c b/src/naming_screen.c index f6558921b..dcd60259b 100644 --- a/src/naming_screen.c +++ b/src/naming_screen.c @@ -516,14 +516,14 @@ static void NamingScreen_InitBGs(void) ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); InitStandardTextBoxWindows(); InitTextBoxGfxAndPrinters(); @@ -740,8 +740,8 @@ static void DisplaySentToPCMessage(void) StringExpandPlaceholders(gStringVar4, sTransferredToPCMessages[stringToDisplay]); DrawDialogueFrame(0, 0); gTextFlags.canABSpeedUpPrint = TRUE; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), 0, 2, 1, 3); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), 0, 2, 1, 3); + CopyWindowToVram(0, COPYWIN_FULL); } static bool8 MainState_WaitSentToPCMessage(void) @@ -1714,7 +1714,7 @@ static void HandleDpadMovement(struct Task *task) static void DrawNormalTextEntryBox(void) { FillWindowPixelBuffer(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], PIXEL_FILL(1)); - AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], 1, sNamingScreen->template->title, 8, 1, 0, 0); + AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], FONT_NORMAL, sNamingScreen->template->title, 8, 1, 0, 0); PutWindowTilemap(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX]); } @@ -1725,7 +1725,7 @@ static void DrawMonTextEntryBox(void) StringCopy(buffer, gSpeciesNames[sNamingScreen->monSpecies]); StringAppendN(buffer, sNamingScreen->template->title, 15); FillWindowPixelBuffer(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], PIXEL_FILL(1)); - AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], 1, buffer, 8, 1, 0, 0); + AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX], FONT_NORMAL, buffer, 8, 1, 0, 0); PutWindowTilemap(sNamingScreen->windows[WIN_TEXT_ENTRY_BOX]); } @@ -1781,7 +1781,7 @@ static void DrawGenderIcon(void) StringCopy(text, gText_FemaleSymbol); isFemale = TRUE; } - AddTextPrinterParameterized3(sNamingScreen->windows[WIN_TEXT_ENTRY], 1, 0x68, 1, sGenderColors[isFemale], -1, text); + AddTextPrinterParameterized3(sNamingScreen->windows[WIN_TEXT_ENTRY], FONT_NORMAL, 0x68, 1, sGenderColors[isFemale], TEXT_SKIP_DRAW, text); } } @@ -1921,11 +1921,11 @@ static void DrawTextEntry(void) temp[1] = gText_ExpandedPlaceholder_Empty[0]; extraWidth = (IsWideLetter(temp[0]) == TRUE) ? 2 : 0; - AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY], 1, temp, i * 8 + x + extraWidth, 1, 0xFF, NULL); + AddTextPrinterParameterized(sNamingScreen->windows[WIN_TEXT_ENTRY], FONT_NORMAL, temp, i * 8 + x + extraWidth, 1, TEXT_SKIP_DRAW, NULL); } TryDrawGenderIcon(); - CopyWindowToVram(sNamingScreen->windows[WIN_TEXT_ENTRY], 2); + CopyWindowToVram(sNamingScreen->windows[WIN_TEXT_ENTRY], COPYWIN_GFX); PutWindowTilemap(sNamingScreen->windows[WIN_TEXT_ENTRY]); } @@ -1964,7 +1964,7 @@ static void PrintKeyboardKeys(u8 window, u8 page) FillWindowPixelBuffer(window, sFillValues[page]); for (i = 0; i < KBROW_COUNT; i++) - AddTextPrinterParameterized3(window, 1, 0, i * 16 + 1, sKeyboardTextColors[page], 0, sNamingScreenKeyboardText[page][i]); + AddTextPrinterParameterized3(window, FONT_NORMAL, 0, i * 16 + 1, sKeyboardTextColors[page], 0, sNamingScreenKeyboardText[page][i]); PutWindowTilemap(window); } @@ -2010,9 +2010,9 @@ static void PrintControls(void) const u8 color[3] = { TEXT_DYNAMIC_COLOR_6, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY }; FillWindowPixelBuffer(sNamingScreen->windows[WIN_BANNER], PIXEL_FILL(15)); - AddTextPrinterParameterized3(sNamingScreen->windows[WIN_BANNER], 0, 2, 1, color, 0, gText_MoveOkBack); + AddTextPrinterParameterized3(sNamingScreen->windows[WIN_BANNER], FONT_SMALL, 2, 1, color, 0, gText_MoveOkBack); PutWindowTilemap(sNamingScreen->windows[WIN_BANNER]); - CopyWindowToVram(sNamingScreen->windows[WIN_BANNER], 3); + CopyWindowToVram(sNamingScreen->windows[WIN_BANNER], COPYWIN_FULL); } static void CB2_NamingScreen(void) diff --git a/src/option_menu.c b/src/option_menu.c index 0174b69db..e66bddd7f 100644 --- a/src/option_menu.c +++ b/src/option_menu.c @@ -173,14 +173,14 @@ void CB2_InitOptionMenu(void) SetGpuReg(REG_OFFSET_DISPCNT, 0); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sOptionMenuBgTemplates, ARRAY_COUNT(sOptionMenuBgTemplates)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); InitWindows(sOptionMenuWinTemplates); DeactivateAllTextPrinters(); SetGpuReg(REG_OFFSET_WIN0H, 0); @@ -251,7 +251,7 @@ void CB2_InitOptionMenu(void) FrameType_DrawChoices(gTasks[taskId].data[TD_FRAMETYPE]); HighlightOptionMenuItem(gTasks[taskId].data[TD_MENUSELECTION]); - CopyWindowToVram(WIN_OPTIONS, 3); + CopyWindowToVram(WIN_OPTIONS, COPYWIN_FULL); gMain.state++; break; } @@ -351,7 +351,7 @@ static void Task_OptionMenuProcessInput(u8 taskId) if (sArrowPressed) { sArrowPressed = FALSE; - CopyWindowToVram(WIN_OPTIONS, 2); + CopyWindowToVram(WIN_OPTIONS, COPYWIN_GFX); } } } @@ -400,7 +400,7 @@ static void DrawOptionMenuChoice(const u8 *text, u8 x, u8 y, u8 style) } dst[i] = EOS; - AddTextPrinterParameterized(WIN_OPTIONS, 1, dst, x, y + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(WIN_OPTIONS, FONT_NORMAL, dst, x, y + 1, TEXT_SKIP_DRAW, NULL); } static u8 TextSpeed_ProcessInput(u8 selection) @@ -438,15 +438,15 @@ static void TextSpeed_DrawChoices(u8 selection) DrawOptionMenuChoice(gText_TextSpeedSlow, 104, YPOS_TEXTSPEED, styles[0]); - widthSlow = GetStringWidth(1, gText_TextSpeedSlow, 0); - widthMid = GetStringWidth(1, gText_TextSpeedMid, 0); - widthFast = GetStringWidth(1, gText_TextSpeedFast, 0); + widthSlow = GetStringWidth(FONT_NORMAL, gText_TextSpeedSlow, 0); + widthMid = GetStringWidth(FONT_NORMAL, gText_TextSpeedMid, 0); + widthFast = GetStringWidth(FONT_NORMAL, gText_TextSpeedFast, 0); widthMid -= 94; xMid = (widthSlow - widthMid - widthFast) / 2 + 104; DrawOptionMenuChoice(gText_TextSpeedMid, xMid, YPOS_TEXTSPEED, styles[1]); - DrawOptionMenuChoice(gText_TextSpeedFast, GetStringRightAlignXOffset(1, gText_TextSpeedFast, 198), YPOS_TEXTSPEED, styles[2]); + DrawOptionMenuChoice(gText_TextSpeedFast, GetStringRightAlignXOffset(FONT_NORMAL, gText_TextSpeedFast, 198), YPOS_TEXTSPEED, styles[2]); } static u8 BattleScene_ProcessInput(u8 selection) @@ -469,7 +469,7 @@ static void BattleScene_DrawChoices(u8 selection) styles[selection] = 1; DrawOptionMenuChoice(gText_BattleSceneOn, 104, YPOS_BATTLESCENE, styles[0]); - DrawOptionMenuChoice(gText_BattleSceneOff, GetStringRightAlignXOffset(1, gText_BattleSceneOff, 198), YPOS_BATTLESCENE, styles[1]); + DrawOptionMenuChoice(gText_BattleSceneOff, GetStringRightAlignXOffset(FONT_NORMAL, gText_BattleSceneOff, 198), YPOS_BATTLESCENE, styles[1]); } static u8 BattleStyle_ProcessInput(u8 selection) @@ -492,7 +492,7 @@ static void BattleStyle_DrawChoices(u8 selection) styles[selection] = 1; DrawOptionMenuChoice(gText_BattleStyleShift, 104, YPOS_BATTLESTYLE, styles[0]); - DrawOptionMenuChoice(gText_BattleStyleSet, GetStringRightAlignXOffset(1, gText_BattleStyleSet, 198), YPOS_BATTLESTYLE, styles[1]); + DrawOptionMenuChoice(gText_BattleStyleSet, GetStringRightAlignXOffset(FONT_NORMAL, gText_BattleStyleSet, 198), YPOS_BATTLESTYLE, styles[1]); } static u8 Sound_ProcessInput(u8 selection) @@ -516,7 +516,7 @@ static void Sound_DrawChoices(u8 selection) styles[selection] = 1; DrawOptionMenuChoice(gText_SoundMono, 104, YPOS_SOUND, styles[0]); - DrawOptionMenuChoice(gText_SoundStereo, GetStringRightAlignXOffset(1, gText_SoundStereo, 198), YPOS_SOUND, styles[1]); + DrawOptionMenuChoice(gText_SoundStereo, GetStringRightAlignXOffset(FONT_NORMAL, gText_SoundStereo, 198), YPOS_SOUND, styles[1]); } static u8 FrameType_ProcessInput(u8 selection) @@ -612,22 +612,22 @@ static void ButtonMode_DrawChoices(u8 selection) DrawOptionMenuChoice(gText_ButtonTypeNormal, 104, YPOS_BUTTONMODE, styles[0]); - widthNormal = GetStringWidth(1, gText_ButtonTypeNormal, 0); - widthLR = GetStringWidth(1, gText_ButtonTypeLR, 0); - widthLA = GetStringWidth(1, gText_ButtonTypeLEqualsA, 0); + widthNormal = GetStringWidth(FONT_NORMAL, gText_ButtonTypeNormal, 0); + widthLR = GetStringWidth(FONT_NORMAL, gText_ButtonTypeLR, 0); + widthLA = GetStringWidth(FONT_NORMAL, gText_ButtonTypeLEqualsA, 0); widthLR -= 94; xLR = (widthNormal - widthLR - widthLA) / 2 + 104; DrawOptionMenuChoice(gText_ButtonTypeLR, xLR, YPOS_BUTTONMODE, styles[1]); - DrawOptionMenuChoice(gText_ButtonTypeLEqualsA, GetStringRightAlignXOffset(1, gText_ButtonTypeLEqualsA, 198), YPOS_BUTTONMODE, styles[2]); + DrawOptionMenuChoice(gText_ButtonTypeLEqualsA, GetStringRightAlignXOffset(FONT_NORMAL, gText_ButtonTypeLEqualsA, 198), YPOS_BUTTONMODE, styles[2]); } static void DrawTextOption(void) { FillWindowPixelBuffer(WIN_TEXT_OPTION, PIXEL_FILL(1)); - AddTextPrinterParameterized(WIN_TEXT_OPTION, 1, gText_Option, 8, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(WIN_TEXT_OPTION, 3); + AddTextPrinterParameterized(WIN_TEXT_OPTION, FONT_NORMAL, gText_Option, 8, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(WIN_TEXT_OPTION, COPYWIN_FULL); } static void DrawOptionMenuTexts(void) @@ -636,10 +636,8 @@ static void DrawOptionMenuTexts(void) FillWindowPixelBuffer(WIN_OPTIONS, PIXEL_FILL(1)); for (i = 0; i < MENUITEM_COUNT; i++) - { - AddTextPrinterParameterized(WIN_OPTIONS, 1, sOptionMenuItemsNames[i], 8, (i * 16) + 1, TEXT_SPEED_FF, NULL); - } - CopyWindowToVram(WIN_OPTIONS, 3); + AddTextPrinterParameterized(WIN_OPTIONS, FONT_NORMAL, sOptionMenuItemsNames[i], 8, (i * 16) + 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(WIN_OPTIONS, COPYWIN_FULL); } #define TILE_TOP_CORNER_L 0x1A2 diff --git a/src/overworld.c b/src/overworld.c index a8d9a4a83..9a5c41a7f 100644 --- a/src/overworld.c +++ b/src/overworld.c @@ -166,7 +166,7 @@ static void ResetPlayerHeldKeys(u16 *); static u16 KeyInterCB_SelfIdle(u32); static u16 KeyInterCB_DeferToEventScript(u32); static u16 GetDirectionForDpadKey(u16); -static void CB1_UpdateLinkState(void); +static void CB1_OverworldLink(void); static void SetKeyInterceptCallback(u16 (*func)(u32)); static void SetFieldVBlankCallback(void); static void FieldClearVBlankHBlankCallbacks(void); @@ -1417,9 +1417,9 @@ static void ResetSafariZoneFlag_(void) ResetSafariZoneFlag(); } -bool32 IsUpdateLinkStateCBActive(void) +bool32 IsOverworldLinkActive(void) { - if (gMain.callback1 == CB1_UpdateLinkState) + if (gMain.callback1 == CB1_OverworldLink) return TRUE; else return FALSE; @@ -1606,7 +1606,7 @@ static void CB2_LoadMapOnReturnToFieldCableClub(void) if (LoadMapInStepsLink(&gMain.state)) { SetFieldVBlankCallback(); - SetMainCallback1(CB1_UpdateLinkState); + SetMainCallback1(CB1_OverworldLink); ResetAllMultiplayerState(); SetMainCallback2(CB2_Overworld); } @@ -1614,7 +1614,7 @@ static void CB2_LoadMapOnReturnToFieldCableClub(void) void CB2_ReturnToField(void) { - if (IsUpdateLinkStateCBActive() == TRUE) + if (IsOverworldLinkActive() == TRUE) { SetMainCallback2(CB2_ReturnToFieldLink); } @@ -1636,7 +1636,7 @@ static void CB2_ReturnToFieldLocal(void) static void CB2_ReturnToFieldLink(void) { - if (!Overworld_LinkRecvQueueLengthMoreThan2() && ReturnToFieldLink(&gMain.state)) + if (!Overworld_IsRecvQueueAtMax() && ReturnToFieldLink(&gMain.state)) SetMainCallback2(CB2_Overworld); } @@ -1644,7 +1644,7 @@ void CB2_ReturnToFieldFromMultiplayer(void) { FieldClearVBlankHBlankCallbacks(); StopMapMusic(); - SetMainCallback1(CB1_UpdateLinkState); + SetMainCallback1(CB1_OverworldLink); ResetAllMultiplayerState(); if (gWirelessCommType != 0) @@ -2101,14 +2101,14 @@ static void InitOverworldGraphicsRegisters(void) ScheduleBgCopyTilemapToVram(1); ScheduleBgCopyTilemapToVram(2); ScheduleBgCopyTilemapToVram(3); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_HBLANK_INTERVAL); ShowBg(0); @@ -2226,7 +2226,7 @@ static void CreateLinkPlayerSprites(void) } -static void CB1_UpdateLinkState(void) +static void CB1_OverworldLink(void) { if (gWirelessCommType == 0 || !IsRfuRecvQueueEmpty() || !IsSendingKeysToLink()) { @@ -2442,7 +2442,7 @@ static void UpdateHeldKeyCode(u16 key) if (gWirelessCommType != 0 && GetLinkSendQueueLength() > 1 - && IsUpdateLinkStateCBActive() == TRUE + && IsOverworldLinkActive() == TRUE && IsSendingKeysToLink() == TRUE) { switch (key) @@ -2541,7 +2541,7 @@ static u16 KeyInterCB_DeferToEventScript(u32 key) static u16 KeyInterCB_DeferToRecvQueue(u32 key) { u16 retVal; - if (GetLinkRecvQueueLength() > 2) + if (GetLinkRecvQueueLength() >= OVERWORLD_RECV_QUEUE_MAX) { retVal = LINK_KEY_CODE_EMPTY; } @@ -2613,7 +2613,7 @@ static u16 KeyInterCB_WaitForPlayersToExit(u32 keyOrPlayerId) { // keyOrPlayerId could be any keycode. This callback does no sanity checking // on the size of the key. It's assuming that it is being called from - // CB1_UpdateLinkState. + // CB1_OverworldLink. if (sPlayerLinkStates[keyOrPlayerId] != PLAYER_LINK_STATE_EXITING_ROOM) CheckRfuKeepAliveTimer(); if (AreAllPlayersInLinkState(PLAYER_LINK_STATE_EXITING_ROOM) == TRUE) @@ -2834,11 +2834,11 @@ static void RunTerminateLinkScript(void) ScriptContext2_Enable(); } -bool32 Overworld_LinkRecvQueueLengthMoreThan2(void) +bool32 Overworld_IsRecvQueueAtMax(void) { - if (!IsUpdateLinkStateCBActive()) + if (!IsOverworldLinkActive()) return FALSE; - if (GetLinkRecvQueueLength() >= 3) + if (GetLinkRecvQueueLength() >= OVERWORLD_RECV_QUEUE_MAX) sReceivingFromLink = TRUE; else sReceivingFromLink = FALSE; @@ -2849,9 +2849,9 @@ bool32 Overworld_RecvKeysFromLinkIsRunning(void) { u8 temp; - if (GetLinkRecvQueueLength() < 2) + if (GetLinkRecvQueueLength() < OVERWORLD_RECV_QUEUE_MAX - 1) return FALSE; - else if (IsUpdateLinkStateCBActive() != TRUE) + else if (IsOverworldLinkActive() != TRUE) return FALSE; else if (IsSendingKeysToLink() != TRUE) return FALSE; @@ -2875,7 +2875,7 @@ bool32 Overworld_SendKeysToLinkIsRunning(void) { if (GetLinkSendQueueLength() < 2) return FALSE; - else if (IsUpdateLinkStateCBActive() != TRUE) + else if (IsOverworldLinkActive() != TRUE) return FALSE; else if (IsSendingKeysToLink() != TRUE) return FALSE; diff --git a/src/palette_util.c b/src/palette_util.c index 3fbde9284..08239c336 100755 --- a/src/palette_util.c +++ b/src/palette_util.c @@ -439,7 +439,7 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend) } // Below used for the Roulette grid -void ClearTilemapRect(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height) +void FillTilemapRect(u16 *dest, u16 value, u8 left, u8 top, u8 width, u8 height) { u16 *_dest; u8 i; @@ -450,9 +450,7 @@ void ClearTilemapRect(u16 *dest, u16 src, u8 left, u8 top, u8 width, u8 height) { _dest = dest + i * 32; for (j = 0; j < width; j++) - { - *_dest++ = src; - } + *_dest++ = value; } } @@ -468,8 +466,39 @@ void SetTilemapRect(u16 *dest, u16 *src, u8 left, u8 top, u8 width, u8 height) { _dest = dest + i * 32; for (j = 0; j < width; j++) - { *_dest++ = *_src++; + } +} + +static void FillTilemapRect_Unused(void *dest, u16 value, u8 left, u8 top, u8 width, u8 height) +{ + u8 i, j; + u8 x, y; + + for (i = 0, y = top; i < height; i++) + { + for (x = left, j = 0; j < width; j++) + { + *(u16 *)((dest) + (y * 64 + x * 2)) = value; + x = (x + 1) % 32; + } + y = (y + 1) % 32; + } +} + +static void SetTilemapRect_Unused(void *dest, const u16 *src, u8 left, u8 top, u8 width, u8 height) +{ + u8 i, j; + u8 x, y; + const u16 *_src; + + for (i = 0, _src = src, y = top; i < height; i++) + { + for (x = left, j = 0; j < width; j++) + { + *(u16 *)((dest) + (y * 64 + x * 2)) = *(_src++); + x = (x + 1) % 32; } + y = (y + 1) % 32; } } diff --git a/src/party_menu.c b/src/party_menu.c index 95a4852db..43f522034 100755 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -476,7 +476,7 @@ static void CB2_InitPartyMenu(void) { while (TRUE) { - if (MenuHelpers_CallLinkSomething() == TRUE || ShowPartyMenu() == TRUE || MenuHelpers_LinkSomething() == TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE || ShowPartyMenu() == TRUE || MenuHelpers_IsLinkActive() == TRUE) break; } } @@ -509,7 +509,7 @@ static bool8 ShowPartyMenu(void) gMain.state++; break; case 5: - if (!MenuHelpers_LinkSomething()) + if (!MenuHelpers_IsLinkActive()) ResetTasks(); gMain.state++; break; @@ -754,7 +754,7 @@ static void RenderPartyMenuBox(u8 slot) LoadPartyBoxPalette(&sPartyMenuBoxes[slot], PARTY_PAL_NO_MON); else LoadPartyBoxPalette(&sPartyMenuBoxes[slot], PARTY_PAL_MULTI_ALT); - CopyWindowToVram(sPartyMenuBoxes[slot].windowId, 2); + CopyWindowToVram(sPartyMenuBoxes[slot].windowId, COPYWIN_GFX); PutWindowTilemap(sPartyMenuBoxes[slot].windowId); ScheduleBgCopyTilemapToVram(2); } @@ -764,7 +764,7 @@ static void RenderPartyMenuBox(u8 slot) { DrawEmptySlot(sPartyMenuBoxes[slot].windowId); LoadPartyBoxPalette(&sPartyMenuBoxes[slot], PARTY_PAL_NO_MON); - CopyWindowToVram(sPartyMenuBoxes[slot].windowId, 2); + CopyWindowToVram(sPartyMenuBoxes[slot].windowId, COPYWIN_GFX); } else { @@ -1182,7 +1182,7 @@ u8 GetPartyMenuType(void) void Task_HandleChooseMonInput(u8 taskId) { - if (!gPaletteFade.active && MenuHelpers_CallLinkSomething() != TRUE) + if (!gPaletteFade.active && MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { s8 *slotPtr = GetCurrentPartySlotPtr(); @@ -1319,7 +1319,7 @@ static void HandleChooseMonCancel(u8 taskId, s8 *slotPtr) PlaySE(SE_SELECT); if (DisplayCancelChooseMonYesNo(taskId) != TRUE) { - if (!MenuHelpers_LinkSomething()) + if (!MenuHelpers_IsLinkActive()) gSpecialVar_0x8004 = PARTY_SIZE + 1; gPartyMenuUseExitCallback = FALSE; *slotPtr = PARTY_SIZE + 1; @@ -1659,7 +1659,7 @@ bool8 IsPartyMenuTextPrinterActive(void) static void Task_WaitForLinkAndReturnToChooseMon(u8 taskId) { - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { DisplayPartyMenuStdMessage(PARTY_MSG_CHOOSE_MON); gTasks[taskId].func = Task_HandleChooseMonInput; @@ -1672,7 +1672,7 @@ static void Task_ReturnToChooseMonAfterText(u8 taskId) { ClearStdWindowAndFrameToTransparent(6, 0); ClearWindowTilemap(6); - if (MenuHelpers_LinkSomething() == TRUE) + if (MenuHelpers_IsLinkActive() == TRUE) { gTasks[taskId].func = Task_WaitForLinkAndReturnToChooseMon; } @@ -2019,7 +2019,7 @@ static void InitPartyMenuWindows(u8 layout) FillWindowPixelBuffer(i, PIXEL_FILL(0)); LoadUserWindowBorderGfx(0, 0x4F, 0xD0); LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20); - LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(gStandardMenuPalette, 0xF0, 0x20); } static void CreateCancelConfirmWindows(bool8 chooseHalf) @@ -2035,10 +2035,10 @@ static void CreateCancelConfirmWindows(bool8 chooseHalf) { confirmWindowId = AddWindow(&sConfirmButtonWindowTemplate); FillWindowPixelBuffer(confirmWindowId, PIXEL_FILL(0)); - mainOffset = GetStringCenterAlignXOffset(0, gMenuText_Confirm, 48); - AddTextPrinterParameterized4(confirmWindowId, 0, mainOffset, 1, 0, 0, sFontColorTable[0], -1, gMenuText_Confirm); + mainOffset = GetStringCenterAlignXOffset(FONT_SMALL, gMenuText_Confirm, 48); + AddTextPrinterParameterized4(confirmWindowId, FONT_SMALL, mainOffset, 1, 0, 0, sFontColorTable[0], TEXT_SKIP_DRAW, gMenuText_Confirm); PutWindowTilemap(confirmWindowId); - CopyWindowToVram(confirmWindowId, 2); + CopyWindowToVram(confirmWindowId, COPYWIN_GFX); cancelWindowId = AddWindow(&sMultiCancelButtonWindowTemplate); offset = 0; } @@ -2052,16 +2052,16 @@ static void CreateCancelConfirmWindows(bool8 chooseHalf) // Branches are functionally identical. Second branch is never reached, Spin Trade wasnt fully implemented if (gPartyMenu.menuType != PARTY_MENU_TYPE_SPIN_TRADE) { - mainOffset = GetStringCenterAlignXOffset(0, gText_Cancel, 48); - AddTextPrinterParameterized3(cancelWindowId, 0, mainOffset + offset, 1, sFontColorTable[0], -1, gText_Cancel); + mainOffset = GetStringCenterAlignXOffset(FONT_SMALL, gText_Cancel, 48); + AddTextPrinterParameterized3(cancelWindowId, FONT_SMALL, mainOffset + offset, 1, sFontColorTable[0], TEXT_SKIP_DRAW, gText_Cancel); } else { - mainOffset = GetStringCenterAlignXOffset(0, gText_Cancel2, 48); - AddTextPrinterParameterized3(cancelWindowId, 0, mainOffset + offset, 1, sFontColorTable[0], -1, gText_Cancel2); + mainOffset = GetStringCenterAlignXOffset(FONT_SMALL, gText_Cancel2, 48); + AddTextPrinterParameterized3(cancelWindowId, FONT_SMALL, mainOffset + offset, 1, sFontColorTable[0], TEXT_SKIP_DRAW, gText_Cancel2); } PutWindowTilemap(cancelWindowId); - CopyWindowToVram(cancelWindowId, 2); + CopyWindowToVram(cancelWindowId, COPYWIN_GFX); ScheduleBgCopyTilemapToVram(0); } } @@ -2205,7 +2205,7 @@ static void LoadPartyBoxPalette(struct PartyMenuBox *menuBox, u8 palFlags) static void DisplayPartyPokemonBarDetail(u8 windowId, const u8 *str, u8 color, const u8 *align) { - AddTextPrinterParameterized3(windowId, 0, align[0], align[1], sFontColorTable[color], 0, str); + AddTextPrinterParameterized3(windowId, FONT_SMALL, align[0], align[1], sFontColorTable[color], 0, str); } static void DisplayPartyPokemonNickname(struct Pokemon *mon, struct PartyMenuBox *menuBox, u8 c) @@ -2354,7 +2354,7 @@ static void DisplayPartyPokemonHPBar(u16 hp, u16 maxhp, struct PartyMenuBox *men FillWindowPixelRect(menuBox->windowId, 0x0D, menuBox->infoRects->dimensions[20] + hpFraction, menuBox->infoRects->dimensions[21], menuBox->infoRects->dimensions[22] - hpFraction, 1); FillWindowPixelRect(menuBox->windowId, 0x02, menuBox->infoRects->dimensions[20] + hpFraction, menuBox->infoRects->dimensions[21] + 1, menuBox->infoRects->dimensions[22] - hpFraction, 2); } - CopyWindowToVram(menuBox->windowId, 2); + CopyWindowToVram(menuBox->windowId, COPYWIN_GFX); } static void DisplayPartyPokemonDescriptionText(u8 stringID, struct PartyMenuBox *menuBox, u8 c) @@ -2366,7 +2366,7 @@ static void DisplayPartyPokemonDescriptionText(u8 stringID, struct PartyMenuBox menuBox->infoRects->blitFunc(menuBox->windowId, menuBox->infoRects->descTextLeft >> 3, menuBox->infoRects->descTextTop >> 3, width, height, TRUE); } if (c != 2) - AddTextPrinterParameterized3(menuBox->windowId, 1, menuBox->infoRects->descTextLeft, menuBox->infoRects->descTextTop, sFontColorTable[0], 0, sDescriptionStringTable[stringID]); + AddTextPrinterParameterized3(menuBox->windowId, FONT_NORMAL, menuBox->infoRects->descTextLeft, menuBox->infoRects->descTextTop, sFontColorTable[0], 0, sDescriptionStringTable[stringID]); } static void PartyMenuRemoveWindow(u8 *ptr) @@ -2421,7 +2421,7 @@ void DisplayPartyMenuStdMessage(u32 stringId) } DrawStdFrameWithCustomTileAndPalette(*windowPtr, FALSE, 0x4F, 0xD); StringExpandPlaceholders(gStringVar4, sActionStringTable[stringId]); - AddTextPrinterParameterized(*windowPtr, 1, gStringVar4, 0, 1, 0, 0); + AddTextPrinterParameterized(*windowPtr, FONT_NORMAL, gStringVar4, 0, 1, 0, 0); ScheduleBgCopyTilemapToVram(2); } } @@ -2449,7 +2449,7 @@ static u8 DisplaySelectionWindow(u8 windowType) { struct WindowTemplate window; u8 cursorDimension; - u8 fontAttribute; + u8 letterSpacing; u8 i; switch (windowType) @@ -2472,16 +2472,16 @@ static u8 DisplaySelectionWindow(u8 windowType) DrawStdFrameWithCustomTileAndPalette(sPartyMenuInternal->windowId[0], FALSE, 0x4F, 13); if (windowType == SELECTWINDOW_MOVES) return sPartyMenuInternal->windowId[0]; - cursorDimension = GetMenuCursorDimensionByFont(1, 0); - fontAttribute = GetFontAttribute(1, 2); + cursorDimension = GetMenuCursorDimensionByFont(FONT_NORMAL, 0); + letterSpacing = GetFontAttribute(FONT_NORMAL, FONTATTR_LETTER_SPACING); for (i = 0; i < sPartyMenuInternal->numActions; i++) { u8 fontColorsId = (sPartyMenuInternal->actions[i] >= MENU_FIELD_MOVES) ? 4 : 3; - AddTextPrinterParameterized4(sPartyMenuInternal->windowId[0], 1, cursorDimension, (i * 16) + 1, fontAttribute, 0, sFontColorTable[fontColorsId], 0, sCursorOptions[sPartyMenuInternal->actions[i]].text); + AddTextPrinterParameterized4(sPartyMenuInternal->windowId[0], FONT_NORMAL, cursorDimension, (i * 16) + 1, letterSpacing, 0, sFontColorTable[fontColorsId], 0, sCursorOptions[sPartyMenuInternal->actions[i]].text); } - InitMenuInUpperLeftCorner(sPartyMenuInternal->windowId[0], sPartyMenuInternal->numActions, 0, 1); + InitMenuInUpperLeftCorner(sPartyMenuInternal->windowId[0], sPartyMenuInternal->numActions, 0, TRUE); ScheduleBgCopyTilemapToVram(2); return sPartyMenuInternal->windowId[0]; @@ -2491,7 +2491,7 @@ static void PartyMenuPrintText(const u8 *text) { DrawStdFrameWithCustomTileAndPalette(6, FALSE, 0x4F, 13); gTextFlags.canABSpeedUpPrint = TRUE; - AddTextPrinterParameterized2(6, 1, text, GetPlayerTextSpeedDelay(), 0, 2, 1, 3); + AddTextPrinterParameterized2(6, FONT_NORMAL, text, GetPlayerTextSpeedDelay(), 0, 2, 1, 3); } static void PartyMenuDisplayYesNoMenu(void) @@ -2663,7 +2663,7 @@ static void Task_TryCreateSelectionWindow(u8 taskId) static void Task_HandleSelectionMenuInput(u8 taskId) { - if (!gPaletteFade.active && MenuHelpers_CallLinkSomething() != TRUE) + if (!gPaletteFade.active && MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { s8 input; s16 *data = gTasks[taskId].data; @@ -2792,7 +2792,7 @@ static void SwitchSelectedMons(u8 taskId) // returns FALSE if the slot has slid fully offscreen / back onscreen static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newWidth) { - if ((x + width) < 0) + if (x + width < 0) return FALSE; if (x > 31) return FALSE; @@ -2807,7 +2807,7 @@ static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newW { *leftMove = 0; *newX = x; - if ((x + width) > 31) + if (x + width > 31) *newWidth = 32 - x; else *newWidth = width; @@ -2818,14 +2818,13 @@ static bool8 TryMovePartySlot(s16 x, s16 width, u8 *leftMove, u8 *newX, u8 *newW static void MoveAndBufferPartySlot(const void *rectSrc, s16 x, s16 y, s16 width, s16 height, s16 dir) { - // The use of the dimension parameters here is a mess - u8 leftMove, newX, newWidth; // leftMove is used as a srcX, newX is used as both x and srcHeight, newWidth is used as both width and destY + u8 srcX, newX, newWidth; - if (TryMovePartySlot(x, width, &leftMove, &newX, &newWidth)) + if (TryMovePartySlot(x, width, &srcX, &newX, &newWidth)) { FillBgTilemapBufferRect_Palette0(0, 0, newX, y, newWidth, height); - if (TryMovePartySlot(x + dir, width, &leftMove, &newX, &newWidth)) - CopyRectToBgTilemapBufferRect(0, rectSrc, leftMove, 0, width, height, newX, y, newWidth, height, 17, 0, 0); + if (TryMovePartySlot(x + dir, width, &srcX, &newX, &newWidth)) + CopyRectToBgTilemapBufferRect(0, rectSrc, srcX, 0, width, height, newX, y, newWidth, height, 17, 0, 0); } } @@ -3635,7 +3634,7 @@ static void CursorCb_FieldMove(u8 taskId) PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[0]); PartyMenuRemoveWindow(&sPartyMenuInternal->windowId[1]); - if (MenuHelpers_LinkSomething() == TRUE || InUnionRoom() == TRUE) + if (MenuHelpers_IsLinkActive() == TRUE || InUnionRoom() == TRUE) { if (fieldMove == FIELD_MOVE_MILK_DRINK || fieldMove == FIELD_MOVE_SOFT_BOILED) DisplayPartyMenuStdMessage(PARTY_MSG_CANT_USE_HERE); @@ -4498,18 +4497,18 @@ static void ShowMoveSelectWindow(u8 slot) { u8 i; u8 moveCount = 0; - u8 fontId = 1; + u8 fontId = FONT_NORMAL; u8 windowId = DisplaySelectionWindow(SELECTWINDOW_MOVES); u16 move; for (i = 0; i < MAX_MON_MOVES; i++) { move = GetMonData(&gPlayerParty[slot], MON_DATA_MOVE1 + i); - AddTextPrinterParameterized(windowId, fontId, gMoveNames[move], 8, (i * 16) + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, fontId, gMoveNames[move], 8, (i * 16) + 1, TEXT_SKIP_DRAW, NULL); if (move != MOVE_NONE) moveCount++; } - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, moveCount, 0); + InitMenuInUpperLeftCornerNormal(windowId, moveCount, 0); ScheduleBgCopyTilemapToVram(2); } @@ -4955,7 +4954,7 @@ static void DisplayLevelUpStatsPg1(u8 taskId) arrayPtr[12] = CreateLevelUpStatsWindow(); DrawLevelUpWindowPg1(arrayPtr[12], arrayPtr, &arrayPtr[6], TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY); - CopyWindowToVram(arrayPtr[12], 2); + CopyWindowToVram(arrayPtr[12], COPYWIN_GFX); ScheduleBgCopyTilemapToVram(2); } @@ -4964,7 +4963,7 @@ static void DisplayLevelUpStatsPg2(u8 taskId) s16 *arrayPtr = sPartyMenuInternal->data; DrawLevelUpWindowPg2(arrayPtr[12], &arrayPtr[6], TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY); - CopyWindowToVram(arrayPtr[12], 2); + CopyWindowToVram(arrayPtr[12], COPYWIN_GFX); ScheduleBgCopyTilemapToVram(2); } @@ -6057,7 +6056,7 @@ static void Task_InitMultiPartnerPartySlideIn(u8 taskId) // The first slide step also sets the sprites offscreen gTasks[taskId].tXPos = 256; SlideMultiPartyMenuBoxSpritesOneStep(taskId); - ChangeBgX(2, 0x10000, 0); + ChangeBgX(2, 0x10000, BG_COORD_SET); gTasks[taskId].func = Task_MultiPartnerPartySlideIn; } @@ -6113,7 +6112,7 @@ static void SlideMultiPartyMenuBoxSpritesOneStep(u8 taskId) MoveMultiPartyMenuBoxSprite(sPartyMenuBoxes[i].statusSpriteId, tXPos - 8); } } - ChangeBgX(2, 0x800, 1); + ChangeBgX(2, 0x800, BG_COORD_ADD); } #undef tXpos diff --git a/src/player_pc.c b/src/player_pc.c index 3b37b0219..06f58fdeb 100644 --- a/src/player_pc.c +++ b/src/player_pc.c @@ -291,7 +291,7 @@ static const struct ListMenuTemplate sListMenuTemplate_ItemStorage = .lettersSpacing = FALSE, .itemVerticalPadding = 0, .scrollMultiple = FALSE, - .fontId = 7 + .fontId = FONT_NARROW }; static const struct WindowTemplate sWindowTemplates_ItemStorage[ITEMPC_WIN_COUNT] = @@ -399,8 +399,8 @@ static void InitPlayerPCMenu(u8 taskId) windowTemplate.width = GetMaxWidthInSubsetOfMenuTable(sPlayerPCMenuActions, sTopMenuOptionOrder, sTopMenuNumOptions); tWindowId = AddWindow(&windowTemplate); SetStandardWindowBorderStyle(tWindowId, 0); - sub_81995E4(tWindowId, sTopMenuNumOptions, sPlayerPCMenuActions, sTopMenuOptionOrder); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(tWindowId, sTopMenuNumOptions, 0); + PrintMenuActionTextsInUpperLeftCorner(tWindowId, sTopMenuNumOptions, sPlayerPCMenuActions, sTopMenuOptionOrder); + InitMenuInUpperLeftCornerNormal(tWindowId, sTopMenuNumOptions, 0); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = PlayerPCProcessMenuInput; } @@ -511,7 +511,7 @@ static void InitItemStorageMenu(u8 taskId, u8 var) tWindowId = AddWindow(&windowTemplate); SetStandardWindowBorderStyle(tWindowId, 0); PrintMenuTable(tWindowId, ARRAY_COUNT(sItemStorage_MenuActions), sItemStorage_MenuActions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(tWindowId, 4, var); + InitMenuInUpperLeftCornerNormal(tWindowId, 4, var); ScheduleBgCopyTilemapToVram(0); ItemStorageMenuPrint(sItemStorage_OptionDescriptions[var]); } @@ -519,7 +519,7 @@ static void InitItemStorageMenu(u8 taskId, u8 var) static void ItemStorageMenuPrint(const u8 *textPtr) { DrawDialogueFrame(0, 0); - AddTextPrinterParameterized(0, 1, textPtr, 0, 1, 0, 0); + AddTextPrinterParameterized(0, FONT_NORMAL, textPtr, 0, 1, 0, 0); } static void ItemStorageMenuProcessInput(u8 taskId) @@ -691,7 +691,7 @@ static void Mailbox_DrawMailboxMenu(u8 taskId) { u8 windowId = MailboxMenu_AddWindow(MAILBOXWIN_TITLE); MailboxMenu_AddWindow(MAILBOXWIN_LIST); - AddTextPrinterParameterized(windowId, 1, gText_Mailbox, GetStringCenterAlignXOffset(1, gText_Mailbox, 0x40), 1, 0, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_Mailbox, GetStringCenterAlignXOffset(FONT_NORMAL, gText_Mailbox, 0x40), 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].tListTaskId = MailboxMenu_CreateList(&gPlayerPCItemPageInfo); MailboxMenu_AddScrollArrows(&gPlayerPCItemPageInfo); @@ -753,7 +753,7 @@ static void Mailbox_PrintMailOptions(u8 taskId) { u8 windowId = MailboxMenu_AddWindow(MAILBOXWIN_OPTIONS); PrintMenuTable(windowId, ARRAY_COUNT(gMailboxMailOptions), gMailboxMailOptions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, 4, 0); + InitMenuInUpperLeftCornerNormal(windowId, 4, 0); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = Mailbox_MailOptionsProcessInput; } @@ -1027,13 +1027,13 @@ static void ItemStorage_PrintMenuItem(u8 windowId, u32 id, u8 yOffset) if (sItemStorageMenu->toSwapPos != NOT_SWAPPING) { if (sItemStorageMenu->toSwapPos == (u8)id) - ItemStorage_DrawSwapArrow(yOffset, 0, TEXT_SPEED_FF); + ItemStorage_DrawSwapArrow(yOffset, 0, TEXT_SKIP_DRAW); else - ItemStorage_DrawSwapArrow(yOffset, 0xFF, TEXT_SPEED_FF); + ItemStorage_DrawSwapArrow(yOffset, 0xFF, TEXT_SKIP_DRAW); } ConvertIntToDecimalStringN(gStringVar1, gSaveBlock1Ptr->pcItems[id].quantity, STR_CONV_MODE_RIGHT_ALIGN, 3); StringExpandPlaceholders(gStringVar4, gText_xVar1); - AddTextPrinterParameterized(windowId, 7, gStringVar4, GetStringRightAlignXOffset(7, gStringVar4, 104), yOffset, 0xFF, NULL); + AddTextPrinterParameterized(windowId, FONT_NARROW, gStringVar4, GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 104), yOffset, TEXT_SKIP_DRAW, NULL); } } @@ -1049,7 +1049,7 @@ static void ItemStorage_PrintDescription(s32 id) description = ItemStorage_GetMessage(MSG_GO_BACK_TO_PREV); FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); - AddTextPrinterParameterized(windowId, 1, description, 0, 1, 0, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, description, 0, 1, 0, NULL); } static void ItemStorage_AddScrollIndicator(void) @@ -1080,9 +1080,9 @@ static void ItemStorage_DrawSwapArrow(u8 y, u8 b, u8 speed) { u8 windowId = sItemStorageMenu->windowIds[ITEMPC_WIN_LIST]; if (b == 0xFF) - FillWindowPixelRect(windowId, PIXEL_FILL(1), 0, y, GetMenuCursorDimensionByFont(1, 0), GetMenuCursorDimensionByFont(1, 1)); + FillWindowPixelRect(windowId, PIXEL_FILL(1), 0, y, GetMenuCursorDimensionByFont(FONT_NORMAL, 0), GetMenuCursorDimensionByFont(FONT_NORMAL, 1)); else - AddTextPrinterParameterized4(windowId, 1, 0, y, 0, 0, sSwapArrowTextColors, speed, gText_SelectorArrow2); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, 0, y, 0, 0, sSwapArrowTextColors, speed, gText_SelectorArrow2); } static void ItemStorage_DrawItemIcon(u16 itemId) @@ -1142,9 +1142,9 @@ static void ItemStorage_CreateListMenu(u8 taskId) text = gText_TossItem; if (!toss) text = gText_WithdrawItem; - x = GetStringCenterAlignXOffset(1, text, 104); - AddTextPrinterParameterized(sItemStorageMenu->windowIds[ITEMPC_WIN_TITLE], 1, text, x, 1, 0, NULL); - CopyWindowToVram(sItemStorageMenu->windowIds[ITEMPC_WIN_ICON], 2); + x = GetStringCenterAlignXOffset(FONT_NORMAL, text, 104); + AddTextPrinterParameterized(sItemStorageMenu->windowIds[ITEMPC_WIN_TITLE], FONT_NORMAL, text, x, 1, 0, NULL); + CopyWindowToVram(sItemStorageMenu->windowIds[ITEMPC_WIN_ICON], COPYWIN_GFX); ItemStorage_CompactList(); ItemStorage_CompactCursor(); ItemStorage_RefreshListMenu(); @@ -1199,7 +1199,7 @@ static void ItemStorage_PrintMessage(const u8 *string) u8 windowId = sItemStorageMenu->windowIds[ITEMPC_WIN_MESSAGE]; FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); StringExpandPlaceholders(gStringVar4, string); - AddTextPrinterParameterized(windowId, 1, gStringVar4, 0, 1, 0, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL); } // Process input while on the item storage's item list @@ -1338,7 +1338,7 @@ static void ItemStorage_PrintItemQuantity(u8 windowId, u16 value, u32 mode, u8 x { ConvertIntToDecimalStringN(gStringVar1, value, mode, n); StringExpandPlaceholders(gStringVar4, gText_xVar1); - AddTextPrinterParameterized(windowId, 1, gStringVar4, GetStringCenterAlignXOffset(1, gStringVar4, 48), y, 0, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar4, 48), y, 0, NULL); } // Start an item Withdraw/Toss diff --git a/src/pokeblock.c b/src/pokeblock.c index 89c2bc962..58348e1cc 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -95,10 +95,6 @@ enum PKBL_GIVE_TO_LADY }; - -extern const u16 gUnknown_0860F074[]; - -// this file's functions static void CB2_InitPokeblockMenu(void); static bool8 InitPokeblockMenu(void); static bool8 LoadPokeblockMenuGfx(void); @@ -443,7 +439,7 @@ static const struct ListMenuTemplate sPokeblockListMenuTemplate = .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = LIST_MULTIPLE_SCROLL_DPAD, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 1 }; @@ -509,11 +505,11 @@ static void CB2_InitPokeblockMenu(void) { while (1) { - if (MenuHelpers_CallLinkSomething() == TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE) break; if (InitPokeblockMenu() == TRUE) break; - if (MenuHelpers_LinkSomething() == TRUE) + if (MenuHelpers_IsLinkActive() == TRUE) break; } } @@ -685,7 +681,7 @@ static void HandleInitWindows(void) DeactivateAllTextPrinters(); LoadUserWindowBorderGfx(0, 1, 0xE0); LoadMessageBoxGfx(0, 0xA, 0xD0); - LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(gStandardMenuPalette, 0xF0, 0x20); for (i = 0; i < ARRAY_COUNT(sWindowTemplates) - 1; i++) FillWindowPixelBuffer(i, PIXEL_FILL(0)); @@ -696,7 +692,7 @@ static void HandleInitWindows(void) static void PrintOnPokeblockWindow(u8 windowId, const u8 *string, s32 x) { - AddTextPrinterParameterized4(windowId, 1, x, 1, 0, 0, sTextColor, 0, string); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, 1, 0, 0, sTextColor, 0, string); } static void DrawPokeblockMenuTitleText(void) @@ -704,7 +700,7 @@ static void DrawPokeblockMenuTitleText(void) u8 i; const u8 *itemName = ItemId_GetName(ITEM_POKEBLOCK_CASE); - PrintOnPokeblockWindow(WIN_TITLE, itemName, GetStringCenterAlignXOffset(1, itemName, 0x48)); + PrintOnPokeblockWindow(WIN_TITLE, itemName, GetStringCenterAlignXOffset(FONT_NORMAL, itemName, 0x48)); PrintOnPokeblockWindow(WIN_SPICY, gText_Spicy, 0); PrintOnPokeblockWindow(WIN_DRY, gText_Dry, 0); @@ -732,7 +728,7 @@ static void UpdatePokeblockList(void) sPokeblockMenu->items[i].id = LIST_CANCEL; gMultiuseListMenuTemplate = sPokeblockListMenuTemplate; - gMultiuseListMenuTemplate.fontId = 7; + gMultiuseListMenuTemplate.fontId = FONT_NARROW; gMultiuseListMenuTemplate.totalItems = sPokeblockMenu->itemsNo; gMultiuseListMenuTemplate.items = sPokeblockMenu->items; gMultiuseListMenuTemplate.maxShowed = sPokeblockMenu->maxShowed; @@ -806,7 +802,7 @@ static void DrawPokeblockInfo(s32 pkblId) for (i = 0; i < FLAVOR_COUNT; i++) CopyToBgTilemapBufferRect(2, rectTilemapSrc, (i / 3 * 6) + 1, (i % 3 * 2) + 13, 1, 2); - CopyWindowToVram(7, 2); + CopyWindowToVram(7, COPYWIN_GFX); } ScheduleBgCopyTilemapToVram(0); @@ -1008,7 +1004,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (!gPaletteFade.active && MenuHelpers_CallLinkSomething() != TRUE) + if (!gPaletteFade.active && MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { if (JOY_NEW(SELECT_BUTTON)) { @@ -1061,7 +1057,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId) { s16 *data = gTasks[taskId].data; - if (MenuHelpers_CallLinkSomething() == TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE) return; if (JOY_NEW(SELECT_BUTTON)) @@ -1153,8 +1149,8 @@ static void ShowPokeblockActionsWindow(u8 taskId) DestroyScrollArrows(); DrawStdFrameWithCustomTileAndPalette(tWindowId, 0, 1, 0xE); - sub_81995E4(tWindowId, sPokeblockMenu->numActions, sPokeblockMenuActions, sPokeblockMenu->pokeblockActionIds); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(tWindowId, sPokeblockMenu->numActions, 0); + PrintMenuActionTextsInUpperLeftCorner(tWindowId, sPokeblockMenu->numActions, sPokeblockMenuActions, sPokeblockMenu->pokeblockActionIds); + InitMenuInUpperLeftCornerNormal(tWindowId, sPokeblockMenu->numActions, 0); PutWindowTilemap(tWindowId); ScheduleBgCopyTilemapToVram(1); @@ -1165,7 +1161,7 @@ static void Task_HandlePokeblockActionsInput(u8 taskId) { s8 itemId; - if (MenuHelpers_CallLinkSomething() == TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE) return; itemId = Menu_ProcessInputNoWrap(); @@ -1208,7 +1204,7 @@ static void PokeblockAction_Toss(u8 taskId) ClearStdWindowAndFrameToTransparent(tWindowId, FALSE); StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1Ptr->pokeblocks[gSpecialVar_ItemId].color]); StringExpandPlaceholders(gStringVar4, gText_ThrowAwayVar1); - DisplayMessageAndContinueTask(taskId, WIN_TOSS_MSG, 10, 13, 1, GetPlayerTextSpeedDelay(), gStringVar4, CreateTossPokeblockYesNoMenu); + DisplayMessageAndContinueTask(taskId, WIN_TOSS_MSG, 10, 13, FONT_NORMAL, GetPlayerTextSpeedDelay(), gStringVar4, CreateTossPokeblockYesNoMenu); } static void CreateTossPokeblockYesNoMenu(u8 taskId) @@ -1219,7 +1215,7 @@ static void CreateTossPokeblockYesNoMenu(u8 taskId) static void TossedPokeblockMessage(u8 taskId) { StringExpandPlaceholders(gStringVar4, gText_Var1ThrownAway); - DisplayMessageAndContinueTask(taskId, WIN_TOSS_MSG, 10, 13, 1, GetPlayerTextSpeedDelay(), gStringVar4, TossPokeblock); + DisplayMessageAndContinueTask(taskId, WIN_TOSS_MSG, 10, 13, FONT_NORMAL, GetPlayerTextSpeedDelay(), gStringVar4, TossPokeblock); } static void TossPokeblock(u8 taskId) diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index a4395d760..da9b7767c 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -116,8 +116,6 @@ struct PokeblockFeed u8 unused4; }; -extern const u16 gUnknown_0860F074[]; - static void HandleInitBackgrounds(void); static void HandleInitWindows(void); static void LaunchPokeblockFeedTask(void); @@ -690,11 +688,11 @@ void PreparePokeblockFeedScene(void) { while (1) { - if (MenuHelpers_CallLinkSomething() == TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() == TRUE) break; if (LoadPokeblockFeedScene() == TRUE) break; - if (MenuHelpers_LinkSomething() == TRUE) + if (MenuHelpers_IsLinkActive() == TRUE) break; } } @@ -786,7 +784,7 @@ static void HandleInitWindows(void) InitWindows(sWindowTemplates); DeactivateAllTextPrinters(); LoadUserWindowBorderGfx(0, 1, 0xE0); - LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(gStandardMenuPalette, 0xF0, 0x20); FillWindowPixelBuffer(0, PIXEL_FILL(0)); PutWindowTilemap(0); ScheduleBgCopyTilemapToVram(0); @@ -874,7 +872,7 @@ static void Task_PrintAtePokeblockMessage(u8 taskId) StringExpandPlaceholders(gStringVar4, gText_Var1DisdainfullyAteVar2); gTextFlags.canABSpeedUpPrint = TRUE; - AddTextPrinterParameterized2(0, 1, gStringVar4, GetPlayerTextSpeedDelay(), NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gStringVar4, GetPlayerTextSpeedDelay(), NULL, 2, 1, 3); gTasks[taskId].func = Task_WaitForAtePokeblockMessage; } diff --git a/src/pokedex.c b/src/pokedex.c index 81d7c6730..58676b215 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -2081,7 +2081,7 @@ static bool8 LoadPokedexListPage(u8 page) InitWindows(sPokemonList_WindowTemplate); DeactivateAllTextPrinters(); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); gMain.state = 1; break; case 1: @@ -2324,7 +2324,7 @@ static void PrintMonDexNumAndName(u8 windowId, u8 fontId, const u8* str, u8 left color[0] = TEXT_COLOR_TRANSPARENT; color[1] = TEXT_DYNAMIC_COLOR_6; color[2] = TEXT_COLOR_LIGHT_GRAY; - AddTextPrinterParameterized4(windowId, fontId, left * 8, (top * 8) + 1, 0, 0, color, -1, str); + AddTextPrinterParameterized4(windowId, fontId, left * 8, (top * 8) + 1, 0, 0, color, TEXT_SKIP_DRAW, str); } // u16 ignored is passed but never used @@ -2412,7 +2412,7 @@ static void CreateMonListEntry(u8 position, u16 b, u16 ignored) } break; } - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); } static void CreateMonDexNum(u16 entryNum, u8 left, u8 top, u16 unused) @@ -2427,7 +2427,7 @@ static void CreateMonDexNum(u16 entryNum, u8 left, u8 top, u16 unused) text[2] = CHAR_0 + dexNum / 100; text[3] = CHAR_0 + (dexNum % 100) / 10; text[4] = CHAR_0 + (dexNum % 100) % 10; - PrintMonDexNumAndName(0, 7, text, left, top); + PrintMonDexNumAndName(0, FONT_NARROW, text, left, top); } static void CreateCaughtBall(bool16 owned, u8 x, u8 y, u16 unused) @@ -2447,7 +2447,7 @@ static u8 CreateMonName(u16 num, u8 left, u8 top) str = gSpeciesNames[num]; else str = sText_TenDashes; - PrintMonDexNumAndName(0, 7, str, left, top); + PrintMonDexNumAndName(0, FONT_NARROW, str, left, top); return StringLength(str); } @@ -3167,7 +3167,7 @@ static void PrintInfoScreenText(const u8* str, u8 left, u8 top) color[1] = TEXT_DYNAMIC_COLOR_6; color[2] = TEXT_COLOR_LIGHT_GRAY; - AddTextPrinterParameterized4(0, 1, left, top, 0, 0, color, -1, str); + AddTextPrinterParameterized4(0, FONT_NORMAL, left, top, 0, 0, color, TEXT_SKIP_DRAW, str); } #define tScrolling data[0] @@ -3248,7 +3248,7 @@ static void Task_LoadInfoScreen(u8 taskId) PutWindowTilemap(WIN_INFO); PutWindowTilemap(WIN_FOOTPRINT); DrawFootprint(WIN_FOOTPRINT, sPokedexListItem->dexNum); - CopyWindowToVram(WIN_FOOTPRINT, 2); + CopyWindowToVram(WIN_FOOTPRINT, COPYWIN_GFX); gMain.state++; break; case 2: @@ -3264,7 +3264,7 @@ static void Task_LoadInfoScreen(u8 taskId) PrintMonInfo(sPokedexListItem->dexNum, sPokedexView->dexMode == DEX_MODE_HOENN ? FALSE : TRUE, sPokedexListItem->owned, 0); if (!sPokedexListItem->owned) LoadPalette(gPlttBufferUnfaded + 1, 0x31, 0x1E); - CopyWindowToVram(WIN_INFO, 3); + CopyWindowToVram(WIN_INFO, COPYWIN_FULL); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); @@ -3594,8 +3594,8 @@ static void Task_LoadCryScreen(u8 taskId) cryMeter.yPos = 3; if (LoadCryMeter(&cryMeter, 3)) gMain.state++; - CopyWindowToVram(WIN_VU_METER, 2); - CopyWindowToVram(WIN_INFO, 3); + CopyWindowToVram(WIN_VU_METER, COPYWIN_GFX); + CopyWindowToVram(WIN_INFO, COPYWIN_FULL); CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); @@ -3752,7 +3752,7 @@ static void Task_LoadSizeScreen(u8 taskId) StringCopy(string, gText_SizeComparedTo); StringAppend(string, gSaveBlock2Ptr->playerName); - PrintInfoScreenText(string, GetStringCenterAlignXOffset(1, string, 0xF0), 0x79); + PrintInfoScreenText(string, GetStringCenterAlignXOffset(FONT_NORMAL, string, 0xF0), 0x79); gMain.state++; } break; @@ -3780,7 +3780,7 @@ static void Task_LoadSizeScreen(u8 taskId) SetOamMatrix(2, gPokedexEntries[sPokedexListItem->dexNum].pokemonScale, 0, 0, gPokedexEntries[sPokedexListItem->dexNum].pokemonScale); LoadPalette(sSizeScreenSilhouette_Pal, (gSprites[spriteId].oam.paletteNum + 16) * 16, 0x20); gTasks[taskId].tMonSpriteId = spriteId; - CopyWindowToVram(WIN_INFO, 3); + CopyWindowToVram(WIN_INFO, COPYWIN_FULL); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); @@ -3975,7 +3975,7 @@ static void Task_DisplayCaughtMonDexPage(u8 taskId) PutWindowTilemap(WIN_INFO); PutWindowTilemap(WIN_FOOTPRINT); DrawFootprint(WIN_FOOTPRINT, gTasks[taskId].tDexNum); - CopyWindowToVram(WIN_FOOTPRINT, 2); + CopyWindowToVram(WIN_FOOTPRINT, COPYWIN_GFX); ResetPaletteFade(); LoadPokedexBgPalette(FALSE); gTasks[taskId].tState++; @@ -3985,7 +3985,7 @@ static void Task_DisplayCaughtMonDexPage(u8 taskId) break; case 3: PrintMonInfo(dexNum, IsNationalPokedexEnabled(), 1, 1); - CopyWindowToVram(WIN_INFO, 3); + CopyWindowToVram(WIN_INFO, COPYWIN_FULL); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); gTasks[taskId].tState++; @@ -4100,7 +4100,7 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) const u8 *description; if (newEntry) - PrintInfoScreenText(gText_PokedexRegistration, GetStringCenterAlignXOffset(1, gText_PokedexRegistration, 0xF0), 0); + PrintInfoScreenText(gText_PokedexRegistration, GetStringCenterAlignXOffset(FONT_NORMAL, gText_PokedexRegistration, 0xF0), 0); if (value == 0) value = NationalToHoennOrder(num); else @@ -4139,7 +4139,7 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) description = gPokedexEntries[num].description; else description = gExpandedPlaceholder_PokedexDescription; - PrintInfoScreenText(description, GetStringCenterAlignXOffset(1, description, 0xF0), 0x5F); + PrintInfoScreenText(description, GetStringCenterAlignXOffset(FONT_NORMAL, description, 0xF0), 0x5F); } static void PrintMonHeight(u16 height, u8 left, u8 top) @@ -4167,10 +4167,10 @@ static void PrintMonHeight(u16 height, u8 left, u8 top) buffer[i++] = feet / 10 + CHAR_0; buffer[i++] = (feet % 10) + CHAR_0; } - buffer[i++] = CHAR_SGL_QUOT_RIGHT; + buffer[i++] = CHAR_SGL_QUOTE_RIGHT; buffer[i++] = (inches / 10) + CHAR_0; buffer[i++] = (inches % 10) + CHAR_0; - buffer[i++] = CHAR_DBL_QUOT_RIGHT; + buffer[i++] = CHAR_DBL_QUOTE_RIGHT; buffer[i++] = EOS; PrintInfoScreenText(buffer, left, top); } @@ -4474,7 +4474,7 @@ static void PrintInfoSubMenuText(u8 windowId, const u8 *str, u8 left, u8 top) color[1] = TEXT_DYNAMIC_COLOR_6; color[2] = TEXT_COLOR_LIGHT_GRAY; - AddTextPrinterParameterized4(windowId, 1, left, top, 0, 0, color, -1, str); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, left, top, 0, 0, color, TEXT_SKIP_DRAW, str); } static void UnusedPrintNum(u8 windowId, u16 num, u8 left, u8 top) @@ -4781,7 +4781,7 @@ static void PrintSearchText(const u8 *str, u32 x, u32 y) color[0] = TEXT_COLOR_TRANSPARENT; color[1] = TEXT_DYNAMIC_COLOR_6; color[2] = TEXT_COLOR_DARK_GRAY; - AddTextPrinterParameterized4(0, 1, x, y, 0, 0, color, -1, str); + AddTextPrinterParameterized4(0, FONT_NORMAL, x, y, 0, 0, color, TEXT_SKIP_DRAW, str); } static void ClearSearchMenuRect(u32 x, u32 y, u32 width, u32 height) @@ -4847,7 +4847,7 @@ static void Task_LoadSearchMenu(u8 taskId) SetDefaultSearchModeAndOrder(taskId); HighlightSelectedSearchTopBarItem(SEARCH_TOPBAR_SEARCH); PrintSelectedSearchParameters(taskId); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); CopyBgTilemapBufferToVram(1); CopyBgTilemapBufferToVram(2); CopyBgTilemapBufferToVram(3); @@ -4901,7 +4901,7 @@ static void Task_SwitchToSearchMenuTopBar(u8 taskId) { HighlightSelectedSearchTopBarItem(gTasks[taskId].tTopBarItem); PrintSelectedSearchParameters(taskId); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); gTasks[taskId].func = Task_HandleSearchTopBarInput; } @@ -4940,7 +4940,7 @@ static void Task_HandleSearchTopBarInput(u8 taskId) PlaySE(SE_DEX_PAGE); gTasks[taskId].tTopBarItem--; HighlightSelectedSearchTopBarItem(gTasks[taskId].tTopBarItem); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); } if (JOY_NEW(DPAD_RIGHT) && gTasks[taskId].tTopBarItem < SEARCH_TOPBAR_CANCEL) @@ -4948,7 +4948,7 @@ static void Task_HandleSearchTopBarInput(u8 taskId) PlaySE(SE_DEX_PAGE); gTasks[taskId].tTopBarItem++; HighlightSelectedSearchTopBarItem(gTasks[taskId].tTopBarItem); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); } } @@ -4957,7 +4957,7 @@ static void Task_SwitchToSearchMenu(u8 taskId) { HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); PrintSelectedSearchParameters(taskId); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); gTasks[taskId].func = Task_HandleSearchMenuInput; } @@ -5013,7 +5013,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) EraseAndPrintSearchTextBox(gText_SearchingPleaseWait); gTasks[taskId].func = Task_StartPokedexSearch; PlaySE(SE_DEX_SEARCH); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); } } else @@ -5029,7 +5029,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) PlaySE(SE_SELECT); gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][0]; HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); } if (JOY_NEW(DPAD_RIGHT) && movementMap[gTasks[taskId].tMenuItem][1] != 0xFF) @@ -5037,7 +5037,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) PlaySE(SE_SELECT); gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][1]; HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); } if (JOY_NEW(DPAD_UP) && movementMap[gTasks[taskId].tMenuItem][2] != 0xFF) @@ -5045,7 +5045,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) PlaySE(SE_SELECT); gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][2]; HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); } if (JOY_NEW(DPAD_DOWN) && movementMap[gTasks[taskId].tMenuItem][3] != 0xFF) @@ -5053,7 +5053,7 @@ static void Task_HandleSearchMenuInput(u8 taskId) PlaySE(SE_SELECT); gTasks[taskId].tMenuItem = movementMap[gTasks[taskId].tMenuItem][3]; HighlightSelectedSearchMenuItem(gTasks[taskId].tTopBarItem, gTasks[taskId].tMenuItem); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); } } @@ -5086,7 +5086,7 @@ static void Task_WaitAndCompleteSearch(u8 taskId) EraseAndPrintSearchTextBox(gText_NoMatchingPkmnWereFound); } gTasks[taskId].func = Task_SearchCompleteWaitForInput; - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); } } @@ -5126,7 +5126,7 @@ static void Task_SelectSearchMenuItem(u8 taskId) PrintSearchParameterText(taskId); PrintSelectorArrow(*cursorPos); gTasks[taskId].func = Task_HandleSearchParameterInput; - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); } @@ -5151,7 +5151,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) ClearSearchParameterBoxText(); DrawOrEraseSearchParameterBox(TRUE); gTasks[taskId].func = Task_SwitchToSearchMenu; - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); return; } @@ -5163,7 +5163,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) *cursorPos = gTasks[taskId].tCursorPos; *scrollOffset = gTasks[taskId].tScrollOffset; gTasks[taskId].func = Task_SwitchToSearchMenu; - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); CopyBgTilemapBufferToVram(3); return; } @@ -5190,7 +5190,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) { PlaySE(SE_SELECT); EraseAndPrintSearchTextBox(texts[*cursorPos + *scrollOffset].description); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); } return; } @@ -5216,7 +5216,7 @@ static void Task_HandleSearchParameterInput(u8 taskId) { PlaySE(SE_SELECT); EraseAndPrintSearchTextBox(texts[*cursorPos + *scrollOffset].description); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); } return; } diff --git a/src/pokedex_area_region_map.c b/src/pokedex_area_region_map.c index 1ee5ca988..2ec2c5c8d 100644 --- a/src/pokedex_area_region_map.c +++ b/src/pokedex_area_region_map.c @@ -17,6 +17,7 @@ static const u32 sPokedexAreaMapAffine_Tilemap[] = INCBIN_U32("graphics/interfac void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) { u8 mode; + void * tilemap; sPokedexAreaMapBgNum = Alloc(sizeof(sPokedexAreaMapBgNum)); mode = template->mode; @@ -24,7 +25,8 @@ void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) { SetBgAttribute(template->bg, BG_ATTR_METRIC, 0); DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMap_Gfx, 0, template->offset, 0); - sub_8199D3C(DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMap_Tilemap, 0, 0, 1), template->offset, 32, 32, FALSE); + tilemap = DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMap_Tilemap, 0, 0, 1); + AddValToTilemapBuffer(tilemap, template->offset, 32, 32, FALSE); // template->offset is always 0, so this does nothing. } else { @@ -32,11 +34,12 @@ void LoadPokedexAreaMapGfx(const struct PokedexAreaMapTemplate *template) SetBgAttribute(template->bg, BG_ATTR_METRIC, 2); SetBgAttribute(template->bg, BG_ATTR_TYPE, BG_TYPE_AFFINE); // This does nothing. BG_ATTR_TYPE can't be set with this function DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Gfx, 0, template->offset, 0); - sub_8199D3C(DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Tilemap, 0, 0, 1), template->offset, 64, 64, TRUE); + tilemap = DecompressAndCopyTileDataToVram(template->bg, sPokedexAreaMapAffine_Tilemap, 0, 0, 1); + AddValToTilemapBuffer(tilemap, template->offset, 64, 64, TRUE); // template->offset is always 0, so this does nothing. } - ChangeBgX(template->bg, 0, 0); - ChangeBgY(template->bg, 0, 0); + ChangeBgX(template->bg, 0, BG_COORD_SET); + ChangeBgY(template->bg, 0, BG_COORD_SET); SetBgAttribute(template->bg, BG_ATTR_PALETTEMODE, 1); CpuCopy32(sPokedexAreaMap_Pal, &gPlttBufferUnfaded[0x70], 0x60); *sPokedexAreaMapBgNum = template->bg; @@ -62,5 +65,5 @@ void FreePokedexAreaMapBgNum(void) void PokedexAreaMapChangeBgY(u32 a0) { - ChangeBgY(*sPokedexAreaMapBgNum, a0 * 0x100, 0); + ChangeBgY(*sPokedexAreaMapBgNum, a0 * 0x100, BG_COORD_SET); } diff --git a/src/pokedex_area_screen.c b/src/pokedex_area_screen.c index 2f0d676cb..e2973dcab 100755 --- a/src/pokedex_area_screen.c +++ b/src/pokedex_area_screen.c @@ -319,7 +319,7 @@ static bool8 DrawAreaGlow(void) } return TRUE; case 4: - ChangeBgY(2, -0x800, 0); + ChangeBgY(2, -0x800, BG_COORD_SET); break; default: return FALSE; @@ -367,7 +367,7 @@ static void FindMapsWithMon(u16 species) } } - for (i = 0; gWildMonHeaders[i].mapGroup != 0xFF; i++) + for (i = 0; gWildMonHeaders[i].mapGroup != MAP_GROUP(UNDEFINED); i++) { if (MapHasMon(&gWildMonHeaders[i], species)) { diff --git a/src/pokedex_cry_screen.c b/src/pokedex_cry_screen.c index 350946f3b..4c9bfe15c 100644 --- a/src/pokedex_cry_screen.c +++ b/src/pokedex_cry_screen.c @@ -432,7 +432,7 @@ static void DrawWaveformSegment(u8 position, u8 amplitude) static void DrawWaveformWindow(u8 windowId) { - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } // rsVertical is leftover from a very different version of this function in RS @@ -443,7 +443,7 @@ static void ShiftWaveformOver(u8 windowId, s16 offset, bool8 rsVertical) if (!rsVertical) { u8 bg = GetWindowAttribute(windowId, WINDOW_BG); - ChangeBgX(bg, offset << 8, 0); + ChangeBgX(bg, offset << 8, BG_COORD_SET); } } diff --git a/src/pokemon_jump.c b/src/pokemon_jump.c index ab86ee09f..85acb2fee 100755 --- a/src/pokemon_jump.c +++ b/src/pokemon_jump.c @@ -3197,7 +3197,7 @@ static void LoadPokeJumpGfx(void) FillBgTilemapBufferRect_Palette0(BG_INTERFACE, 0, 0, 0, 0x20, 0x20); PrintScoreSuffixes(); PrintScore(0); - sub_8098C6C(0, 1, 0xE0); + LoadUserWindowBorderGfxOnBg(0, 1, 0xE0); CopyBgTilemapBufferToVram(BG_INTERFACE); CopyBgTilemapBufferToVram(BG_VENUSAUR); CopyBgTilemapBufferToVram(BG_BONUSES); @@ -3313,8 +3313,8 @@ static void Msg_WantToPlayAgain(void) { case 0: sPokemonJumpGfx->msgWindowId = AddMessageWindow(1, 8, 20, 2); - AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, 1, gText_WantToPlayAgain2, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sPokemonJumpGfx->msgWindowId, 2); + AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, FONT_NORMAL, gText_WantToPlayAgain2, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sPokemonJumpGfx->msgWindowId, COPYWIN_GFX); sPokemonJumpGfx->mainState++; break; case 1: @@ -3340,8 +3340,8 @@ static void Msg_SavingDontTurnOff(void) { case 0: sPokemonJumpGfx->msgWindowId = AddMessageWindow(2, 7, 26, 4); - AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, 1, gText_SavingDontTurnOffPower, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sPokemonJumpGfx->msgWindowId, 2); + AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, FONT_NORMAL, gText_SavingDontTurnOffPower, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sPokemonJumpGfx->msgWindowId, COPYWIN_GFX); sPokemonJumpGfx->mainState++; break; case 1: @@ -3366,7 +3366,7 @@ static void EraseMessage(void) { case 0: ClearMessageWindow(); - sub_8198C78(); + EraseYesNoWindow(); CopyBgTilemapBufferToVram(BG_INTERFACE); sPokemonJumpGfx->mainState++; break; @@ -3383,8 +3383,8 @@ static void Msg_SomeoneDroppedOut(void) { case 0: sPokemonJumpGfx->msgWindowId = AddMessageWindow(2, 8, 22, 4); - AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, 1, gText_SomeoneDroppedOut2, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sPokemonJumpGfx->msgWindowId, 2); + AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, FONT_NORMAL, gText_SomeoneDroppedOut2, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sPokemonJumpGfx->msgWindowId, COPYWIN_GFX); sPokemonJumpGfx->mainState++; break; case 1: @@ -3409,8 +3409,8 @@ static void Msg_CommunicationStandby(void) { case 0: sPokemonJumpGfx->msgWindowId = AddMessageWindow(7, 10, 16, 2); - AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, 1, gText_CommunicationStandby4, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sPokemonJumpGfx->msgWindowId, 2); + AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, FONT_NORMAL, gText_CommunicationStandby4, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sPokemonJumpGfx->msgWindowId, COPYWIN_GFX); sPokemonJumpGfx->mainState++; break; case 1: @@ -3487,8 +3487,8 @@ static void PrintPrizeMessage(u16 itemId, u16 quantity) DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, sPokemonJumpGfx->itemQuantityStr); DynamicPlaceholderTextUtil_ExpandPlaceholders(sPokemonJumpGfx->prizeMsg, gText_AwesomeWonF701F700); sPokemonJumpGfx->msgWindowId = AddMessageWindow(4, 8, 22, 4); - AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, 1, sPokemonJumpGfx->prizeMsg, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sPokemonJumpGfx->msgWindowId, 2); + AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, FONT_NORMAL, sPokemonJumpGfx->prizeMsg, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sPokemonJumpGfx->msgWindowId, COPYWIN_GFX); sPokemonJumpGfx->fanfare = MUS_LEVEL_UP; sPokemonJumpGfx->msgWindowState = 0; } @@ -3500,8 +3500,8 @@ static void PrintPrizeFilledBagMessage(u16 itemId) DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPokemonJumpGfx->itemName); DynamicPlaceholderTextUtil_ExpandPlaceholders(sPokemonJumpGfx->prizeMsg, gText_FilledStorageSpace2); sPokemonJumpGfx->msgWindowId = AddMessageWindow(4, 8, 22, 4); - AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, 1, sPokemonJumpGfx->prizeMsg, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sPokemonJumpGfx->msgWindowId, 2); + AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, FONT_NORMAL, sPokemonJumpGfx->prizeMsg, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sPokemonJumpGfx->msgWindowId, COPYWIN_GFX); sPokemonJumpGfx->fanfare = MUS_DUMMY; sPokemonJumpGfx->msgWindowState = 0; } @@ -3513,8 +3513,8 @@ static void PrintNoRoomForPrizeMessage(u16 itemId) DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, sPokemonJumpGfx->itemName); DynamicPlaceholderTextUtil_ExpandPlaceholders(sPokemonJumpGfx->prizeMsg, gText_CantHoldMore); sPokemonJumpGfx->msgWindowId = AddMessageWindow(4, 9, 22, 2); - AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, 1, sPokemonJumpGfx->prizeMsg, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sPokemonJumpGfx->msgWindowId, 2); + AddTextPrinterParameterized(sPokemonJumpGfx->msgWindowId, FONT_NORMAL, sPokemonJumpGfx->prizeMsg, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sPokemonJumpGfx->msgWindowId, COPYWIN_GFX); sPokemonJumpGfx->fanfare = MUS_DUMMY; sPokemonJumpGfx->msgWindowState = 0; } @@ -3558,7 +3558,7 @@ static void ClearMessageWindow(void) if (sPokemonJumpGfx->msgWindowId != WINDOW_NONE) { rbox_fill_rectangle(sPokemonJumpGfx->msgWindowId); - CopyWindowToVram(sPokemonJumpGfx->msgWindowId, 1); + CopyWindowToVram(sPokemonJumpGfx->msgWindowId, COPYWIN_MAP); sPokemonJumpGfx->msgWindowState = 0; } } @@ -3634,8 +3634,8 @@ static void PrintScoreSuffixes(void) PutWindowTilemap(WIN_TIMES); FillWindowPixelBuffer(WIN_POINTS, 0); FillWindowPixelBuffer(WIN_TIMES, 0); - AddTextPrinterParameterized3(WIN_POINTS, 0, 0, 1, color, 0, gText_SpacePoints2); - AddTextPrinterParameterized3(WIN_TIMES, 0, 0, 1, color, 0, gText_SpaceTimes3); + AddTextPrinterParameterized3(WIN_POINTS, FONT_SMALL, 0, 1, color, 0, gText_SpacePoints2); + AddTextPrinterParameterized3(WIN_TIMES, FONT_SMALL, 0, 1, color, 0, gText_SpaceTimes3); } // The venusaurs in the background are actually an empty 256x512 bg with 3 pairs of venusaurs on it. @@ -3732,7 +3732,7 @@ static void SetMonSpriteY(u32 id, s16 y) static void UpdateVineSwing(int vineState) { UpdateVineAnim(sPokemonJumpGfx, vineState); - ChangeBgY(BG_VENUSAUR, (sVenusaurStates[vineState] * 5) << 13, 0); + ChangeBgY(BG_VENUSAUR, (sVenusaurStates[vineState] * 5) << 13, BG_COORD_SET); } static int DoSameJumpTimeBonus(u8 flags) @@ -3855,10 +3855,10 @@ static void PrintPokeJumpPlayerName(int multiplayerId, u8 bgColor, u8 fgColor, u u8 colors[3] = {bgColor, fgColor, shadow}; FillWindowPixelBuffer(sPokemonJumpGfx->nameWindowIds[multiplayerId], 0); - x = 64 - GetStringWidth(1, GetPokeJumpPlayerName(multiplayerId), -1); + x = 64 - GetStringWidth(FONT_NORMAL, GetPokeJumpPlayerName(multiplayerId), -1); x /= 2; - AddTextPrinterParameterized3(sPokemonJumpGfx->nameWindowIds[multiplayerId], 1, x, 1, colors, -1, GetPokeJumpPlayerName(multiplayerId)); - CopyWindowToVram(sPokemonJumpGfx->nameWindowIds[multiplayerId], 2); + AddTextPrinterParameterized3(sPokemonJumpGfx->nameWindowIds[multiplayerId], FONT_NORMAL, x, 1, colors, TEXT_SKIP_DRAW, GetPokeJumpPlayerName(multiplayerId)); + CopyWindowToVram(sPokemonJumpGfx->nameWindowIds[multiplayerId], COPYWIN_GFX); } static void PrintPokeJumpPlayerNames(bool32 highlightSelf) @@ -3896,8 +3896,8 @@ static void DrawPlayerNameWindows(void) static void ShowBonus(u8 bonusId) { sPokemonJumpGfx->bonusTimer = 0; - ChangeBgX(BG_BONUSES, (bonusId / 2) * 256 * 256, 0); - ChangeBgY(BG_BONUSES, (((bonusId % 2) * 256) - 40) * 256, 0); + ChangeBgX(BG_BONUSES, (bonusId / 2) * 256 * 256, BG_COORD_SET); + ChangeBgY(BG_BONUSES, (((bonusId % 2) * 256) - 40) * 256, BG_COORD_SET); ShowBg(BG_BONUSES); CreateTask(Task_UpdateBonus, 4); } @@ -3910,7 +3910,7 @@ static bool32 UpdateBonus(void) } else { - ChangeBgY(BG_BONUSES, 128, 1); + ChangeBgY(BG_BONUSES, 128, BG_COORD_ADD); if (++sPokemonJumpGfx->bonusTimer >= 32) HideBg(BG_BONUSES); return TRUE; @@ -4162,10 +4162,10 @@ static void Task_ShowPokemonJumpRecords(u8 taskId) { case 0: window = sWindowTemplate_Records; - width = GetStringWidth(1, gText_PkmnJumpRecords, 0); + width = GetStringWidth(FONT_NORMAL, gText_PkmnJumpRecords, 0); for (i = 0; i < ARRAY_COUNT(sRecordsTexts); i++) { - widthCurr = GetStringWidth(1, sRecordsTexts[i], 0) + 38; + widthCurr = GetStringWidth(FONT_NORMAL, sRecordsTexts[i], 0) + 38; if (widthCurr > width) width = widthCurr; } @@ -4176,7 +4176,7 @@ static void Task_ShowPokemonJumpRecords(u8 taskId) window.width = width; tWindowId = AddWindow(&window); PrintRecordsText(tWindowId, width); - CopyWindowToVram(tWindowId, 3); + CopyWindowToVram(tWindowId, COPYWIN_FULL); tState++; break; case 1: @@ -4187,7 +4187,7 @@ static void Task_ShowPokemonJumpRecords(u8 taskId) if (JOY_NEW(A_BUTTON | B_BUTTON)) { rbox_fill_rectangle(tWindowId); - CopyWindowToVram(tWindowId, 1); + CopyWindowToVram(tWindowId, COPYWIN_MAP); tState++; } break; @@ -4217,14 +4217,14 @@ static void PrintRecordsText(u16 windowId, int width) LoadUserWindowBorderGfx_(windowId, 0x21D, 0xD0); DrawTextBorderOuter(windowId, 0x21D, 0xD); FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); - AddTextPrinterParameterized(windowId, 1, gText_PkmnJumpRecords, GetStringCenterAlignXOffset(1, gText_PkmnJumpRecords, width * 8), 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_PkmnJumpRecords, GetStringCenterAlignXOffset(FONT_NORMAL, gText_PkmnJumpRecords, width * 8), 1, TEXT_SKIP_DRAW, NULL); for (i = 0; i < ARRAY_COUNT(sRecordsTexts); i++) { - AddTextPrinterParameterized(windowId, 1, sRecordsTexts[i], 0, 25 + (i * 16), TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, sRecordsTexts[i], 0, 25 + (i * 16), TEXT_SKIP_DRAW, NULL); ConvertIntToDecimalStringN(gStringVar1, recordNums[i], STR_CONV_MODE_LEFT_ALIGN, 5); TruncateToFirstWordOnly(gStringVar1); - x = (width * 8) - GetStringWidth(1, gStringVar1, 0); - AddTextPrinterParameterized(windowId, 1, gStringVar1, x, 25 + (i * 16), TEXT_SPEED_FF, NULL); + x = (width * 8) - GetStringWidth(FONT_NORMAL, gStringVar1, 0); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar1, x, 25 + (i * 16), TEXT_SKIP_DRAW, NULL); } PutWindowTilemap(windowId); } diff --git a/src/pokemon_storage_system.c b/src/pokemon_storage_system.c index e18a6db76..f18dc68d1 100644 --- a/src/pokemon_storage_system.c +++ b/src/pokemon_storage_system.c @@ -1358,7 +1358,7 @@ void DrawTextWindowAndBufferTiles(const u8 *string, void *dst, u8 zero1, u8 zero txtColor[0] = zero2; txtColor[1] = TEXT_DYNAMIC_COLOR_6; txtColor[2] = TEXT_DYNAMIC_COLOR_5; - AddTextPrinterParameterized4(windowId, 1, 0, 1, 0, 0, txtColor, -1, string); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, 0, 1, 0, 0, txtColor, TEXT_SKIP_DRAW, string); tileBytesToBuffer = bytesToBuffer; if (tileBytesToBuffer > 6u) @@ -1402,7 +1402,7 @@ static void UnusedDrawTextWindow(const u8 *string, void *dst, u16 offset, u8 bgC txtColor[0] = bgColor; txtColor[1] = fgColor; txtColor[2] = shadowColor; - AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, txtColor, -1, string); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, 0, 2, 0, 0, txtColor, TEXT_SKIP_DRAW, string); CpuCopy16(tileData1, dst, tileSize); CpuCopy16(tileData2, dst + offset, tileSize); RemoveWindow(windowId); @@ -1561,9 +1561,9 @@ static void Task_PCMainMenu(u8 taskId) LoadMessageBoxAndBorderGfx(); DrawDialogueFrame(0, 0); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, TEXT_SPEED_FF, NULL, 2, 1, 3); - CopyWindowToVram(0, 3); - CopyWindowToVram(task->tWindowId, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, TEXT_SKIP_DRAW, NULL, 2, 1, 3); + CopyWindowToVram(0, COPYWIN_FULL); + CopyWindowToVram(task->tWindowId, COPYWIN_FULL); task->tState++; break; case STATE_FADE_IN: @@ -1585,7 +1585,7 @@ static void Task_PCMainMenu(u8 taskId) { task->tSelectedOption = task->tNextOption; FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3); } break; case MENU_B_PRESSED: @@ -1601,14 +1601,14 @@ static void Task_PCMainMenu(u8 taskId) { // Can't withdraw FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, gText_PartyFull, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_PartyFull, 0, NULL, 2, 1, 3); task->tState = STATE_ERROR_MSG; } else if (task->tInput == OPTION_DEPOSIT && CountPartyMons() == 1) { // Can't deposit FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, gText_JustOnePkmn, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_JustOnePkmn, 0, NULL, 2, 1, 3); task->tState = STATE_ERROR_MSG; } else @@ -1626,7 +1626,7 @@ static void Task_PCMainMenu(u8 taskId) if (JOY_NEW(A_BUTTON | B_BUTTON)) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3); task->tState = STATE_HANDLE_INPUT; } else if (JOY_NEW(DPAD_UP)) @@ -1636,7 +1636,7 @@ static void Task_PCMainMenu(u8 taskId) Menu_MoveCursor(-1); task->tSelectedOption = Menu_GetCursorPos(); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3); task->tState = STATE_HANDLE_INPUT; } else if (JOY_NEW(DPAD_DOWN)) @@ -1646,7 +1646,7 @@ static void Task_PCMainMenu(u8 taskId) Menu_MoveCursor(1); task->tSelectedOption = Menu_GetCursorPos(); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sMainMenuTexts[task->tSelectedOption].desc, 0, NULL, 2, 1, 3); task->tState = STATE_HANDLE_INPUT; } break; @@ -1699,7 +1699,7 @@ static void CreateMainMenu(u8 whichMenu, s16 *windowIdPtr) DrawStdWindowFrame(windowId, FALSE); PrintMenuTable(windowId, OPTIONS_COUNT, (void *)sMainMenuTexts); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, OPTIONS_COUNT, whichMenu); + InitMenuInUpperLeftCornerNormal(windowId, OPTIONS_COUNT, whichMenu); *windowIdPtr = windowId; } @@ -1950,14 +1950,14 @@ static void ChooseBoxMenu_PrintInfo(void) FillWindowPixelBuffer(windowId, PIXEL_FILL(4)); // Print box name - center = GetStringCenterAlignXOffset(1, boxName, 64); - AddTextPrinterParameterized3(windowId, 1, center, 1, sChooseBoxMenu_TextColors, TEXT_SPEED_FF, boxName); + center = GetStringCenterAlignXOffset(FONT_NORMAL, boxName, 64); + AddTextPrinterParameterized3(windowId, FONT_NORMAL, center, 1, sChooseBoxMenu_TextColors, TEXT_SKIP_DRAW, boxName); // Print #/30 for number of Pokémon in the box ConvertIntToDecimalStringN(numBoxMonsText, numInBox, STR_CONV_MODE_RIGHT_ALIGN, 2); StringAppend(numBoxMonsText, sText_OutOf30); - center = GetStringCenterAlignXOffset(1, numBoxMonsText, 64); - AddTextPrinterParameterized3(windowId, 1, center, 17, sChooseBoxMenu_TextColors, TEXT_SPEED_FF, numBoxMonsText); + center = GetStringCenterAlignXOffset(FONT_NORMAL, numBoxMonsText, 64); + AddTextPrinterParameterized3(windowId, FONT_NORMAL, center, 17, sChooseBoxMenu_TextColors, TEXT_SKIP_DRAW, numBoxMonsText); winTileData = GetWindowAttribute(windowId, WINDOW_TILE_DATA); CpuCopy32((void *)winTileData, (void *)OBJ_VRAM0 + 0x100 + (GetSpriteTileStartByTag(sChooseBoxMenu->tileTag) * 32), 0x400); @@ -3827,8 +3827,8 @@ static void SetScrollingBackground(void) static void ScrollBackground(void) { - ChangeBgX(3, 128, 1); - ChangeBgY(3, 128, 2); + ChangeBgX(3, 128, BG_COORD_ADD); + ChangeBgY(3, 128, BG_COORD_SUB); } static void LoadPokeStorageMenuGfx(void) @@ -4005,20 +4005,20 @@ static void PrintDisplayMonInfo(void) FillWindowPixelBuffer(0, PIXEL_FILL(1)); if (sStorage->boxOption != OPTION_MOVE_ITEMS) { - AddTextPrinterParameterized(0, 1, sStorage->displayMonNameText, 6, 0, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 2, sStorage->displayMonSpeciesName, 6, 15, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 2, sStorage->displayMonGenderLvlText, 10, 29, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 0, sStorage->displayMonItemName, 6, 43, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, sStorage->displayMonNameText, 6, 0, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(0, FONT_SHORT, sStorage->displayMonSpeciesName, 6, 15, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(0, FONT_SHORT, sStorage->displayMonGenderLvlText, 10, 29, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(0, FONT_SMALL, sStorage->displayMonItemName, 6, 43, TEXT_SKIP_DRAW, NULL); } else { - AddTextPrinterParameterized(0, 0, sStorage->displayMonItemName, 6, 0, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 1, sStorage->displayMonNameText, 6, 13, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 2, sStorage->displayMonSpeciesName, 6, 28, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(0, 2, sStorage->displayMonGenderLvlText, 10, 42, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, FONT_SMALL, sStorage->displayMonItemName, 6, 0, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, sStorage->displayMonNameText, 6, 13, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(0, FONT_SHORT, sStorage->displayMonSpeciesName, 6, 28, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(0, FONT_SHORT, sStorage->displayMonGenderLvlText, 10, 42, TEXT_SKIP_DRAW, NULL); } - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); if (sStorage->displayMonSpecies != SPECIES_NONE) { UpdateMonMarkingTiles(sStorage->displayMonMarkings, sStorage->markingComboTilesPtr); @@ -4319,10 +4319,10 @@ static void PrintMessage(u8 id) DynamicPlaceholderTextUtil_ExpandPlaceholders(sStorage->messageText, sMessages[id].text); FillWindowPixelBuffer(1, PIXEL_FILL(1)); - AddTextPrinterParameterized(1, 1, sStorage->messageText, 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(1, FONT_NORMAL, sStorage->messageText, 0, 1, TEXT_SKIP_DRAW, NULL); DrawTextBorderOuter(1, 2, 14); PutWindowTilemap(1); - CopyWindowToVram(1, 2); + CopyWindowToVram(1, COPYWIN_GFX); ScheduleBgCopyTilemapToVram(0); } @@ -5437,16 +5437,16 @@ static bool32 WaitForWallpaperGfxLoad(void) static void DrawWallpaper(const void *tilemap, s8 direction, u8 offset) { - s16 var = offset * 256; - s16 var2 = (offset * 2) + 3; + s16 tileOffset = offset * 256; + s16 paletteNum = (offset * 2) + 3; s16 x = ((sStorage->bg2_X / 8 + 10) + (direction * 24)) & 0x3F; - CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 0x14, 0x12, x, 2, 0x14, 0x12, 0x11, var, var2); + CopyRectToBgTilemapBufferRect(2, tilemap, 0, 0, 20, 18, x, 2, 20, 18, 17, tileOffset, paletteNum); if (direction == 0) return; if (direction > 0) - x += 0x14; + x += 20; else x -= 4; @@ -5635,7 +5635,7 @@ static void CycleBoxTitleColor(void) static s16 GetBoxTitleBaseX(const u8 *string) { - return DISPLAY_WIDTH - 64 - GetStringWidth(1, string, 0) / 2; + return DISPLAY_WIDTH - 64 - GetStringWidth(FONT_NORMAL, string, 0) / 2; } @@ -8024,7 +8024,7 @@ static void AddMenu(void) ClearWindowTilemap(sStorage->menuWindowId); DrawStdFrameWithCustomTileAndPalette(sStorage->menuWindowId, FALSE, 11, 14); PrintMenuTable(sStorage->menuWindowId, sStorage->menuItemsCount, (void*)sStorage->menuItems); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sStorage->menuWindowId, sStorage->menuItemsCount, 0); + InitMenuInUpperLeftCornerNormal(sStorage->menuWindowId, sStorage->menuItemsCount, 0); ScheduleBgCopyTilemapToVram(0); sStorage->menuUnusedField = 0; } @@ -8184,14 +8184,14 @@ static bool8 MultiMove_Start(void) GetCursorBoxColumnAndRow(&sMultiMove->fromColumn, &sMultiMove->fromRow); sMultiMove->toColumn = sMultiMove->fromColumn; sMultiMove->toRow = sMultiMove->fromRow; - ChangeBgX(0, -1024, 0); - ChangeBgY(0, -1024, 0); + ChangeBgX(0, -1024, BG_COORD_SET); + ChangeBgY(0, -1024, BG_COORD_SET); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); FillWindowPixelBuffer8Bit(sStorage->multiMoveWindowId, PIXEL_FILL(0)); MultiMove_SetIconToBg(sMultiMove->fromColumn, sMultiMove->fromRow); SetBgAttribute(0, BG_ATTR_PALETTEMODE, 1); PutWindowTilemap(sStorage->multiMoveWindowId); - CopyWindowToVram8Bit(sStorage->multiMoveWindowId, 3); + CopyWindowToVram8Bit(sStorage->multiMoveWindowId, COPYWIN_FULL); BlendPalettes(0x3F00, 8, RGB_WHITE); StartCursorAnim(CURSOR_ANIM_OPEN); SetGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); @@ -8247,7 +8247,7 @@ static bool8 MultiMove_ChangeSelection(void) MultiMove_UpdateSelectedIcons(); sMultiMove->toColumn = sMultiMove->cursorColumn; sMultiMove->toRow = sMultiMove->cursorRow; - CopyWindowToVram8Bit(sStorage->multiMoveWindowId, 2); + CopyWindowToVram8Bit(sStorage->multiMoveWindowId, COPYWIN_GFX); sMultiMove->state++; } break; @@ -8499,8 +8499,8 @@ static u8 MultiMove_UpdateMove(void) { if (sMultiMove->bgMoveSteps != 0) { - ChangeBgX(0, sMultiMove->bgX, 1); - ChangeBgY(0, sMultiMove->bgY, 1); + ChangeBgX(0, sMultiMove->bgX, BG_COORD_ADD); + ChangeBgY(0, sMultiMove->bgY, BG_COORD_ADD); sMultiMove->bgMoveSteps--; } @@ -8605,8 +8605,8 @@ static void MultiMove_SetPlacedMonData(void) static void MultiMove_ResetBg(void) { - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); SetBgAttribute(0, BG_ATTR_PALETTEMODE, 0); ClearGpuRegBits(REG_OFFSET_BG0CNT, BGCNT_256COLOR); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32); @@ -9203,7 +9203,7 @@ static void PrintItemDescription(void) description = ItemId_GetDescription(sStorage->displayMonItemId); FillWindowPixelBuffer(2, PIXEL_FILL(1)); - AddTextPrinterParameterized5(2, 1, description, 4, 0, 0, NULL, 0, 1); + AddTextPrinterParameterized5(2, FONT_NORMAL, description, 4, 0, 0, NULL, 0, 1); } static void InitItemInfoWindow(void) diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index f6371b088..82c173413 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -1146,7 +1146,7 @@ static void VBlank(void) static void CB2_InitSummaryScreen(void) { - while (MenuHelpers_CallLinkSomething() != TRUE && LoadGraphics() != TRUE && MenuHelpers_LinkSomething() != TRUE); + while (MenuHelpers_ShouldWaitForLinkRecv() != TRUE && LoadGraphics() != TRUE && MenuHelpers_IsLinkActive() != TRUE); } static bool8 LoadGraphics(void) @@ -1301,35 +1301,35 @@ static bool8 DecompressGraphics(void) { case 0: ResetTempTileDataBuffers(); - DecompressAndCopyTileDataToVram(1, &gStatusScreenBitmap, 0, 0, 0); + DecompressAndCopyTileDataToVram(1, &gSummaryScreen_Gfx, 0, 0, 0); sMonSummaryScreen->switchCounter++; break; case 1: if (FreeTempTileDataBuffersIfPossible() != 1) { - LZDecompressWram(gPageInfoTilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0]); + LZDecompressWram(gSummaryPage_Info_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][0]); sMonSummaryScreen->switchCounter++; } break; case 2: - LZDecompressWram(gUnknown_08D98CC8, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][1]); + LZDecompressWram(gSummaryPage_InfoCopy_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_INFO][1]); sMonSummaryScreen->switchCounter++; break; case 3: - LZDecompressWram(gPageSkillsTilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_SKILLS][1]); + LZDecompressWram(gSummaryPage_Skills_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_SKILLS][1]); sMonSummaryScreen->switchCounter++; break; case 4: - LZDecompressWram(gPageBattleMovesTilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_BATTLE_MOVES][1]); + LZDecompressWram(gSummaryPage_BattleMoves_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_BATTLE_MOVES][1]); sMonSummaryScreen->switchCounter++; break; case 5: - LZDecompressWram(gPageContestMovesTilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_CONTEST_MOVES][1]); + LZDecompressWram(gSummaryPage_ContestMoves_Tilemap, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_CONTEST_MOVES][1]); sMonSummaryScreen->switchCounter++; break; case 6: - LoadCompressedPalette(gStatusScreenPalette, 0, 0x100); - LoadPalette(&gUnknown_08D85620, 0x81, 0x1E); + LoadCompressedPalette(gSummaryScreen_Pal, 0, 0x100); + LoadPalette(&gPPTextPalette, 0x81, 0x1E); sMonSummaryScreen->switchCounter++; break; case 7: @@ -1462,7 +1462,7 @@ static void SetDefaultTilemaps(void) TilemapFiveMovesDisplay(sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_CONTEST_MOVES][0], 1, FALSE); SetBgTilemapBuffer(1, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_CONTEST_MOVES][0]); SetBgTilemapBuffer(2, sMonSummaryScreen->bgTilemapBuffers[PSS_PAGE_BATTLE_MOVES][0]); - ChangeBgX(2, 0x10000, 1); + ChangeBgX(2, 0x10000, BG_COORD_ADD); ClearWindowTilemap(PSS_LABEL_WINDOW_PORTRAIT_SPECIES); ClearWindowTilemap(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATUS); } @@ -1490,7 +1490,7 @@ static void BeginCloseSummaryScreen(u8 taskId) static void CloseSummaryScreen(u8 taskId) { - if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE && !gPaletteFade.active) { SetMainCallback2(sMonSummaryScreen->callback); gLastViewedMonIndex = sMonSummaryScreen->curMonIndex; @@ -1508,7 +1508,7 @@ static void CloseSummaryScreen(u8 taskId) static void Task_HandleInput(u8 taskId) { - if (MenuHelpers_CallLinkSomething() != TRUE && !gPaletteFade.active) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE && !gPaletteFade.active) { if (JOY_NEW(DPAD_UP)) { @@ -1660,7 +1660,7 @@ static void Task_ChangeSummaryMon(u8 taskId) gSprites[sMonSummaryScreen->spriteIds[SPRITE_ARR_ID_MON]].data[2] = 0; break; default: - if (MenuHelpers_CallLinkSomething() == 0 && FuncIsActiveTask(Task_ShowStatusWindow) == 0) + if (!MenuHelpers_ShouldWaitForLinkRecv() && !FuncIsActiveTask(Task_ShowStatusWindow)) { data[0] = 0; gTasks[taskId].func = Task_HandleInput; @@ -1778,12 +1778,12 @@ static void PssScrollRight(u8 taskId) // Scroll right SetBgAttribute(1, BG_ATTR_PRIORITY, 2); ScheduleBgCopyTilemapToVram(2); } - ChangeBgX(data[1], 0, 0); + ChangeBgX(data[1], 0, BG_COORD_SET); SetBgTilemapBuffer(data[1], sMonSummaryScreen->bgTilemapBuffers[sMonSummaryScreen->currPageIndex][0]); ShowBg(1); ShowBg(2); } - ChangeBgX(data[1], 0x2000, 1); + ChangeBgX(data[1], 0x2000, BG_COORD_ADD); data[0] += 32; if (data[0] > 0xFF) gTasks[taskId].func = PssScrollRightEnd; @@ -1811,9 +1811,9 @@ static void PssScrollLeft(u8 taskId) // Scroll left data[1] = 2; else data[1] = 1; - ChangeBgX(data[1], 0x10000, 0); + ChangeBgX(data[1], 0x10000, BG_COORD_SET); } - ChangeBgX(data[1], 0x2000, 2); + ChangeBgX(data[1], 0x2000, BG_COORD_SUB); data[0] += 32; if (data[0] > 0xFF) gTasks[taskId].func = PssScrollLeftEnd; @@ -1837,7 +1837,7 @@ static void PssScrollLeftEnd(u8 taskId) // display left if (sMonSummaryScreen->currPageIndex > 1) { SetBgTilemapBuffer(data[1], sMonSummaryScreen->bgTilemapBuffers[sMonSummaryScreen->currPageIndex - 1][0]); - ChangeBgX(data[1], 0x10000, 0); + ChangeBgX(data[1], 0x10000, BG_COORD_SET); } ShowBg(1); ShowBg(2); @@ -1889,7 +1889,7 @@ static void Task_HandleInput_MoveSelect(u8 taskId) { s16 *data = gTasks[taskId].data; - if (MenuHelpers_CallLinkSomething() != 1) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { if (JOY_NEW(DPAD_UP)) { @@ -2029,7 +2029,7 @@ static void Task_HandleInput_MovePositionSwitch(u8 taskId) { s16* data = gTasks[taskId].data; - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { if (JOY_NEW(DPAD_UP)) { @@ -2170,7 +2170,7 @@ static void Task_HandleReplaceMoveInput(u8 taskId) { s16* data = gTasks[taskId].data; - if (MenuHelpers_CallLinkSomething() != TRUE) + if (MenuHelpers_ShouldWaitForLinkRecv() != TRUE) { if (gPaletteFade.active != TRUE) { @@ -2681,9 +2681,9 @@ static void DrawContestMoveHearts(u16 move) static void LimitEggSummaryPageDisplay(void) // If the pokemon is an egg, limit the number of pages displayed to 1 { if (sMonSummaryScreen->summary.isEgg) - ChangeBgX(3, 0x10000, 0); + ChangeBgX(3, 0x10000, BG_COORD_SET); else - ChangeBgX(3, 0, 0); + ChangeBgX(3, 0, BG_COORD_SET); } static void ResetWindows(void) @@ -2700,7 +2700,7 @@ static void ResetWindows(void) static void PrintTextOnWindow(u8 windowId, const u8 *string, u8 x, u8 y, u8 lineSpacing, u8 colorId) { - AddTextPrinterParameterized4(windowId, 1, x, y, 0, lineSpacing, sTextColors[colorId], 0, string); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, 0, lineSpacing, sTextColors[colorId], 0, string); } static void PrintMonInfo(void) @@ -2803,21 +2803,21 @@ static void PrintPageNamesAndStats(void) PrintTextOnWindow(PSS_LABEL_WINDOW_BATTLE_MOVES_TITLE, gText_BattleMoves, 2, 1, 0, 1); PrintTextOnWindow(PSS_LABEL_WINDOW_CONTEST_MOVES_TITLE, gText_ContestMoves, 2, 1, 0, 1); - stringXPos = GetStringRightAlignXOffset(1, gText_Cancel2, 62); + stringXPos = GetStringRightAlignXOffset(FONT_NORMAL, gText_Cancel2, 62); iconXPos = stringXPos - 16; if (iconXPos < 0) iconXPos = 0; PrintAOrBButtonIcon(PSS_LABEL_WINDOW_PROMPT_CANCEL, FALSE, iconXPos); PrintTextOnWindow(PSS_LABEL_WINDOW_PROMPT_CANCEL, gText_Cancel2, stringXPos, 1, 0, 0); - stringXPos = GetStringRightAlignXOffset(1, gText_Info, 62); + stringXPos = GetStringRightAlignXOffset(FONT_NORMAL, gText_Info, 62); iconXPos = stringXPos - 16; if (iconXPos < 0) iconXPos = 0; PrintAOrBButtonIcon(PSS_LABEL_WINDOW_PROMPT_INFO, FALSE, iconXPos); PrintTextOnWindow(PSS_LABEL_WINDOW_PROMPT_INFO, gText_Info, stringXPos, 1, 0, 0); - stringXPos = GetStringRightAlignXOffset(1, gText_Switch, 62); + stringXPos = GetStringRightAlignXOffset(FONT_NORMAL, gText_Switch, 62); iconXPos = stringXPos - 16; if (iconXPos < 0) iconXPos = 0; @@ -2826,17 +2826,17 @@ static void PrintPageNamesAndStats(void) PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_INFO_RENTAL, gText_RentalPkmn, 0, 1, 0, 1); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_INFO_TYPE, gText_TypeSlash, 0, 1, 0, 0); - statsXPos = 6 + GetStringCenterAlignXOffset(1, gText_HP4, 42); + statsXPos = 6 + GetStringCenterAlignXOffset(FONT_NORMAL, gText_HP4, 42); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATS_LEFT, gText_HP4, statsXPos, 1, 0, 1); - statsXPos = 6 + GetStringCenterAlignXOffset(1, gText_Attack3, 42); + statsXPos = 6 + GetStringCenterAlignXOffset(FONT_NORMAL, gText_Attack3, 42); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATS_LEFT, gText_Attack3, statsXPos, 17, 0, 1); - statsXPos = 6 + GetStringCenterAlignXOffset(1, gText_Defense3, 42); + statsXPos = 6 + GetStringCenterAlignXOffset(FONT_NORMAL, gText_Defense3, 42); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATS_LEFT, gText_Defense3, statsXPos, 33, 0, 1); - statsXPos = 2 + GetStringCenterAlignXOffset(1, gText_SpAtk4, 36); + statsXPos = 2 + GetStringCenterAlignXOffset(FONT_NORMAL, gText_SpAtk4, 36); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATS_RIGHT, gText_SpAtk4, statsXPos, 1, 0, 1); - statsXPos = 2 + GetStringCenterAlignXOffset(1, gText_SpDef4, 36); + statsXPos = 2 + GetStringCenterAlignXOffset(FONT_NORMAL, gText_SpDef4, 36); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATS_RIGHT, gText_SpDef4, statsXPos, 17, 0, 1); - statsXPos = 2 + GetStringCenterAlignXOffset(1, gText_Speed2, 36); + statsXPos = 2 + GetStringCenterAlignXOffset(FONT_NORMAL, gText_Speed2, 36); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_SKILLS_STATS_RIGHT, gText_Speed2, statsXPos, 33, 0, 1); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_SKILLS_EXP, gText_ExpPoints, 6, 1, 0, 1); PrintTextOnWindow(PSS_LABEL_WINDOW_POKEMON_SKILLS_EXP, gText_NextLv, 6, 17, 0, 1); @@ -3045,7 +3045,7 @@ static void PrintMonOTName(void) { windowId = AddWindowFromTemplateList(sPageInfoTemplate, PSS_DATA_WINDOW_INFO_ORIGINAL_TRAINER); PrintTextOnWindow(windowId, gText_OTSlash, 0, 1, 0, 1); - x = GetStringWidth(1, gText_OTSlash, 0); + x = GetStringWidth(FONT_NORMAL, gText_OTSlash, 0); if (sMonSummaryScreen->summary.OTGender == 0) PrintTextOnWindow(windowId, sMonSummaryScreen->summary.OTName, x, 1, 0, 5); else @@ -3059,7 +3059,7 @@ static void PrintMonOTID(void) if (InBattleFactory() != TRUE && InSlateportBattleTent() != TRUE) { ConvertIntToDecimalStringN(StringCopy(gStringVar1, gText_IDNumber2), (u16)sMonSummaryScreen->summary.OTID, STR_CONV_MODE_LEADING_ZEROS, 5); - xPos = GetStringRightAlignXOffset(1, gStringVar1, 56); + xPos = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar1, 56); PrintTextOnWindow(AddWindowFromTemplateList(sPageInfoTemplate, PSS_DATA_WINDOW_INFO_ID), gStringVar1, xPos, 1, 0, 1); } } @@ -3204,7 +3204,7 @@ static bool8 IsInGamePartnerMon(void) static void PrintEggOTName(void) { u32 windowId = AddWindowFromTemplateList(sPageInfoTemplate, PSS_DATA_WINDOW_INFO_ORIGINAL_TRAINER); - u32 width = GetStringWidth(1, gText_OTSlash, 0); + u32 width = GetStringWidth(FONT_NORMAL, gText_OTSlash, 0); PrintTextOnWindow(windowId, gText_OTSlash, 0, 1, 0, 1); PrintTextOnWindow(windowId, gText_FiveMarks, width, 1, 0, 1); } @@ -3214,7 +3214,7 @@ static void PrintEggOTID(void) int x; StringCopy(gStringVar1, gText_IDNumber2); StringAppend(gStringVar1, gText_FiveMarks); - x = GetStringRightAlignXOffset(1, gStringVar1, 56); + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar1, 56); PrintTextOnWindow(AddWindowFromTemplateList(sPageInfoTemplate, PSS_DATA_WINDOW_INFO_ID), gStringVar1, x, 1, 0, 1); } @@ -3327,7 +3327,7 @@ static void PrintHeldItemName(void) text = gStringVar1; } - x = GetStringCenterAlignXOffset(1, text, 72) + 6; + x = GetStringCenterAlignXOffset(FONT_NORMAL, text, 72) + 6; PrintTextOnWindow(AddWindowFromTemplateList(sPageSkillsTemplate, PSS_DATA_WINDOW_SKILLS_HELD_ITEM), text, x, 1, 0, 0); } @@ -3347,7 +3347,7 @@ static void PrintRibbonCount(void) text = gStringVar4; } - x = GetStringCenterAlignXOffset(1, text, 70) + 6; + x = GetStringCenterAlignXOffset(FONT_NORMAL, text, 70) + 6; PrintTextOnWindow(AddWindowFromTemplateList(sPageSkillsTemplate, PSS_DATA_WINDOW_SKILLS_RIBBON_COUNT), text, x, 1, 0, 0); } @@ -3407,7 +3407,7 @@ static void PrintExpPointsNextLevel(void) u32 expToNextLevel; ConvertIntToDecimalStringN(gStringVar1, sum->exp, STR_CONV_MODE_RIGHT_ALIGN, 7); - x = GetStringRightAlignXOffset(1, gStringVar1, 42) + 2; + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar1, 42) + 2; PrintTextOnWindow(windowId, gStringVar1, x, 1, 0, 0); if (sum->level < MAX_LEVEL) @@ -3416,7 +3416,7 @@ static void PrintExpPointsNextLevel(void) expToNextLevel = 0; ConvertIntToDecimalStringN(gStringVar1, expToNextLevel, STR_CONV_MODE_RIGHT_ALIGN, 6); - x = GetStringRightAlignXOffset(1, gStringVar1, 42) + 2; + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar1, 42) + 2; PrintTextOnWindow(windowId, gStringVar1, x, 17, 0, 0); } @@ -3509,14 +3509,14 @@ static void PrintMoveNameAndPP(u8 moveIndex) DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, sMovesPPLayout); text = gStringVar4; ppState = GetCurrentPpToMaxPpState(summary->pp[moveIndex], pp) + 9; - x = GetStringRightAlignXOffset(1, text, 44); + x = GetStringRightAlignXOffset(FONT_NORMAL, text, 44); } else { PrintTextOnWindow(moveNameWindowId, gText_OneDash, 0, moveIndex * 16 + 1, 0, 1); text = gText_TwoDashes; ppState = 12; - x = GetStringCenterAlignXOffset(1, text, 44); + x = GetStringCenterAlignXOffset(FONT_NORMAL, text, 44); } PrintTextOnWindow(ppValueWindowId, text, x, moveIndex * 16 + 1, 0, ppState); @@ -3669,7 +3669,7 @@ static void PrintNewMoveDetailsOrCancelText(void) DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); DynamicPlaceholderTextUtil_SetPlaceholderPtr(1, gStringVar1); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, sMovesPPLayout); - PrintTextOnWindow(windowId2, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 44), 65, 0, 12); + PrintTextOnWindow(windowId2, gStringVar4, GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 44), 65, 0, 12); } } @@ -3677,7 +3677,7 @@ static void AddAndFillMoveNamesWindow(void) { u8 windowId = AddWindowFromTemplateList(sPageMovesTemplate, PSS_DATA_WINDOW_MOVE_NAMES); FillWindowPixelRect(windowId, PIXEL_FILL(0), 0, 66, 72, 16); - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } static void SwapMovesNamesPP(u8 moveIndex1, u8 moveIndex2) diff --git a/src/pokenav.c b/src/pokenav.c index 925560543..d30c523f9 100644 --- a/src/pokenav.c +++ b/src/pokenav.c @@ -212,7 +212,7 @@ u32 CreateLoopedTask(LoopedTask loopedTask, u32 priority) { u16 taskId; - if (!IsUpdateLinkStateCBActive()) + if (!IsOverworldLinkActive()) taskId = CreateTask(Task_RunLoopedTask, priority); else taskId = CreateTask(Task_RunLoopedTask_LinkMode, priority); @@ -288,7 +288,7 @@ static void Task_RunLoopedTask_LinkMode(u8 taskId) s16 *state; u32 action; - if (Overworld_LinkRecvQueueLengthMoreThan2()) + if (Overworld_IsRecvQueueAtMax()) return; task = (LoopedTask)GetWordTaskArg(taskId, 1); diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c index ef3792063..4799b163c 100644 --- a/src/pokenav_conditions_2.c +++ b/src/pokenav_conditions_2.c @@ -199,12 +199,12 @@ u32 LoopedTask_OpenPartyConditionGraph(s32 state) return LT_INC_AND_PAUSE; case 1: InitBgTemplates(sPartyConditionBgTemplates, ARRAY_COUNT(sPartyConditionBgTemplates)); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_WIN0_ON | DISPCNT_WIN1_ON | DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG3); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); @@ -240,8 +240,8 @@ u32 LoopedTask_OpenPartyConditionGraph(s32 state) SetConditionGraphIOWindows(2); return LT_INC_AND_PAUSE; case 5: - sub_8199DF0(1, 0, 0, 1); - sub_8199DF0(1, 17, 1, 1); + BgDmaFill(1, 0, 0, 1); + BgDmaFill(1, 17, 1, 1); CpuFill32(0, structPtr->tilemapBuffers[1], BG_SCREEN_SIZE); SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]); return LT_INC_AND_PAUSE; @@ -572,23 +572,23 @@ bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE) { str = GetConditionMonNameBuffer(bufferIndex); - AddTextPrinterParameterized(structPtr->nameGenderWindowId, 1, str, 0, 1, 0, NULL); + AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL); } break; case 2: if (IsConditionMenuSearchMode() == TRUE) { str = GetConditionMonLocationBuffer(bufferIndex); - AddTextPrinterParameterized(structPtr->nameGenderWindowId, 1, str, 0, 17, 0, NULL); + AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL); text[0] = EXT_CTRL_CODE_BEGIN; text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; text[2] = TEXT_COLOR_BLUE; text[3] = TEXT_COLOR_TRANSPARENT; text[4] = TEXT_COLOR_LIGHT_BLUE; StringCopy(text + 5, gText_Number2); - AddTextPrinterParameterized(structPtr->listIndexWindowId, 1, text, 4, 1, 0, NULL); + AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL); ConvertIntToDecimalStringN(text + 5, GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4); - AddTextPrinterParameterized(structPtr->listIndexWindowId, 1, text, 28, 1, 0, NULL); + AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL); } break; case 3: @@ -596,9 +596,9 @@ bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) { case 0: if (winMode) - CopyWindowToVram(structPtr->nameGenderWindowId, 3); + CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_FULL); else - CopyWindowToVram(structPtr->nameGenderWindowId, 2); + CopyWindowToVram(structPtr->nameGenderWindowId, COPYWIN_GFX); if (IsConditionMenuSearchMode() == TRUE) { @@ -612,9 +612,9 @@ bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) } case 1: if (winMode) - CopyWindowToVram(structPtr->listIndexWindowId, 3); + CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_FULL); else - CopyWindowToVram(structPtr->listIndexWindowId, 2); + CopyWindowToVram(structPtr->listIndexWindowId, COPYWIN_GFX); structPtr->windowModeState = 0; return TRUE; @@ -628,8 +628,8 @@ void CopyUnusedConditionWindowsToVram(void) { struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); - CopyWindowToVram(structPtr->unusedWindowId1, 3); - CopyWindowToVram(structPtr->unusedWindowId2, 3); + CopyWindowToVram(structPtr->unusedWindowId1, COPYWIN_FULL); + CopyWindowToVram(structPtr->unusedWindowId2, COPYWIN_FULL); } void sub_81CE964(struct Sprite *sprite) diff --git a/src/pokenav_conditions_3.c b/src/pokenav_conditions_3.c index 53987d11d..1172774d7 100644 --- a/src/pokenav_conditions_3.c +++ b/src/pokenav_conditions_3.c @@ -448,8 +448,8 @@ static u32 LoopedTask_OpenConditionSearchResults(s32 state) case 4: if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); ShowBg(1); ShowBg(2); HideBg(3); @@ -644,7 +644,7 @@ static void AddSearchResultListMenuWindow(struct PokenavSub8 *searchList) { searchList->winid = AddWindow(&sSearchResultListMenuWindowTemplate); PutWindowTilemap(searchList->winid); - CopyWindowToVram(searchList->winid, 1); + CopyWindowToVram(searchList->winid, COPYWIN_MAP); PrintSearchResultListMenuItems(searchList); } @@ -655,10 +655,10 @@ static void PrintSearchResultListMenuItems(struct PokenavSub8 *searchList) DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); *gStringVar1 = EOS; DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar2, gText_NumberF700); - AddTextPrinterParameterized(searchList->winid, 1, gStringVar2, 4, 1, 0xFF, NULL); + AddTextPrinterParameterized(searchList->winid, FONT_NORMAL, gStringVar2, 4, 1, TEXT_SKIP_DRAW, NULL); ConvertIntToDecimalStringN(gStringVar1, r7, STR_CONV_MODE_RIGHT_ALIGN, 3); - AddTextPrinterParameterized(searchList->winid, 1, gStringVar1, 34, 1, 0xFF, NULL); - CopyWindowToVram(searchList->winid, 2); + AddTextPrinterParameterized(searchList->winid, FONT_NORMAL, gStringVar1, 34, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(searchList->winid, COPYWIN_GFX); } static void InitConditionSearchListMenuTemplate(void) @@ -674,7 +674,7 @@ static void InitConditionSearchListMenuTemplate(void) template.listTop = 1; template.maxShowed = 8; template.fillValue = 2; - template.fontId = 1; + template.fontId = FONT_NORMAL; template.listFunc.printMonFunc = PrintSearchMonListItem; template.unk14 = NULL; sub_81C81D4(&sConditionSearchResultBgTemplates[1], &template, 0); @@ -705,7 +705,7 @@ static void PrintSearchMonListItem(struct PokenavMonList * item, u8 * dest) } StringGetEnd10(gStringVar3); - dest = GetStringClearToWidth(dest, 1, gStringVar3, 60); + dest = GetStringClearToWidth(dest, FONT_NORMAL, gStringVar3, 60); switch (gender) { default: @@ -723,5 +723,5 @@ static void PrintSearchMonListItem(struct PokenavMonList * item, u8 * dest) *s++ = CHAR_EXTRA_SYMBOL; *s++ = CHAR_LV_2; ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3); - GetStringClearToWidth(dest, 1, gStringVar1, 40); + GetStringClearToWidth(dest, FONT_NORMAL, gStringVar1, 40); } diff --git a/src/pokenav_main_menu.c b/src/pokenav_main_menu.c index 88c1773a6..714c8221a 100644 --- a/src/pokenav_main_menu.c +++ b/src/pokenav_main_menu.c @@ -421,9 +421,9 @@ static u32 LoopedTask_SlideMenuHeaderUp(s32 a0) case 0: return LT_INC_AND_PAUSE; case 2: - if (ChangeBgY(0, 384, 1) >= 0x2000u) + if (ChangeBgY(0, 384, BG_COORD_ADD) >= 0x2000u) { - ChangeBgY(0, 0x2000, 0); + ChangeBgY(0, 0x2000, BG_COORD_SET); return LT_FINISH; } @@ -433,9 +433,9 @@ static u32 LoopedTask_SlideMenuHeaderUp(s32 a0) static u32 LoopedTask_SlideMenuHeaderDown(s32 a0) { - if (ChangeBgY(0, 384, 2) <= 0) + if (ChangeBgY(0, 384, BG_COORD_SUB) <= 0) { - ChangeBgY(0, 0, 0); + ChangeBgY(0, 0, BG_COORD_SET); return LT_FINISH; } return LT_PAUSE; @@ -555,7 +555,7 @@ static void InitHelpBar(void) structPtr->helpBarWindowId = 0; DrawHelpBar(structPtr->helpBarWindowId); PutWindowTilemap(structPtr->helpBarWindowId); - CopyWindowToVram(structPtr->helpBarWindowId, 3); // TODO: Use a defined constant here. + CopyWindowToVram(structPtr->helpBarWindowId, COPYWIN_FULL); } void PrintHelpBarText(u32 textId) @@ -563,7 +563,7 @@ void PrintHelpBarText(u32 textId) struct PokenavMainMenuResources *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MAIN_MENU); DrawHelpBar(structPtr->helpBarWindowId); - AddTextPrinterParameterized3(structPtr->helpBarWindowId, 1, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]); + AddTextPrinterParameterized3(structPtr->helpBarWindowId, FONT_NORMAL, 0, 1, sHelpBarTextColors, 0, sHelpBarTexts[textId]); } bool32 WaitForHelpBar(void) diff --git a/src/pokenav_match_call_1.c b/src/pokenav_match_call_1.c index 64957995d..5612ba6cb 100755 --- a/src/pokenav_match_call_1.c +++ b/src/pokenav_match_call_1.c @@ -413,12 +413,12 @@ void BufferMatchCallNameAndDesc(struct PokenavMatchCallEntries *matchCallEntry, if (className && trainerName) { - u8 *str2 = GetStringClearToWidth(str, 7, className, 69); - GetStringClearToWidth(str2, 7, trainerName, 51); + u8 *str2 = GetStringClearToWidth(str, FONT_NARROW, className, 69); + GetStringClearToWidth(str2, FONT_NARROW, trainerName, 51); } else { - GetStringClearToWidth(str, 7, NULL, 120); + GetStringClearToWidth(str, FONT_NARROW, NULL, 120); } } diff --git a/src/pokenav_match_call_2.c b/src/pokenav_match_call_2.c index e3f0bb6ef..8f2220957 100755 --- a/src/pokenav_match_call_2.c +++ b/src/pokenav_match_call_2.c @@ -322,8 +322,8 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) { case 0: InitBgTemplates(sMatchCallBgTemplates, ARRAY_COUNT(sMatchCallBgTemplates)); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); DecompressAndCopyTileDataToVram(2, sMatchCallUI_Gfx, 0, 0, 0); SetBgTilemapBuffer(2, state->unk1024); CopyToBgTilemapBuffer(2, sMatchCallUI_Tilemap, 0, 0); @@ -335,7 +335,7 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) if (FreeTempTileDataBuffersIfPossible()) return LT_PAUSE; - sub_8199DF0(1, 0, 0, 1); + BgDmaFill(1, 0, 0, 1); SetBgTilemapBuffer(1, state->unk24); FillBgTilemapBufferRect_Palette0(1, 0x1000, 0, 0, 32, 20); CopyPaletteIntoBufferUnfaded(gUnknown_086226E0, 0x10, 0x20); @@ -367,8 +367,8 @@ static u32 LoopedTask_OpenMatchCall(s32 taskState) PrintMatchCallLocation(state, 0); return LT_INC_AND_PAUSE; case 6: - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); ShowBg(2); ShowBg(3); ShowBg(1); @@ -874,7 +874,7 @@ static void InitMatchCallPokenavListMenuTemplate(void) template.listTop = 1; template.maxShowed = 8; template.fillValue = 3; - template.fontId = 7; + template.fontId = FONT_NARROW; template.listFunc.unk10_2 = BufferMatchCallNameAndDesc; template.unk14 = TryDrawRematchPokeballIcon; sub_81C81D4(&sMatchCallBgTemplates[2], &template, 2); @@ -942,7 +942,7 @@ static void DrawMatchCallLeftColumnWindows(struct Pokenav4Struct *state) PutWindowTilemap(state->locWindowId); FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); PutWindowTilemap(state->infoBoxWindowId); - CopyWindowToVram(state->locWindowId, 1); + CopyWindowToVram(state->locWindowId, COPYWIN_MAP); } static void UpdateMatchCallInfoBox(struct Pokenav4Struct *state) @@ -952,7 +952,7 @@ static void UpdateMatchCallInfoBox(struct Pokenav4Struct *state) PrintNumberRegistered(state->infoBoxWindowId); PrintNumberOfBattlesLabel(state->infoBoxWindowId); PrintNumberOfBattles(state->infoBoxWindowId); - CopyWindowToVram(state->infoBoxWindowId, 2); + CopyWindowToVram(state->infoBoxWindowId, COPYWIN_GFX); } static void PrintNumberRegisteredLabel(u16 windowId) @@ -986,14 +986,14 @@ static void PrintNumberOfBattles(u16 windowId) static void PrintMatchCallInfoLabel(u16 windowId, const u8 *str, int top) { int y = top * 16 + 1; - AddTextPrinterParameterized(windowId, 7, str, 2, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NARROW, str, 2, y, TEXT_SKIP_DRAW, NULL); } static void PrintMatchCallInfoNumber(u16 windowId, const u8 *str, int top) { - int x = GetStringRightAlignXOffset(7, str, 86); + int x = GetStringRightAlignXOffset(FONT_NARROW, str, 86); int y = top * 16 + 1; - AddTextPrinterParameterized(windowId, 7, str, x, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NARROW, str, x, y, TEXT_SKIP_DRAW, NULL); } static void PrintMatchCallLocation(struct Pokenav4Struct *state, int arg1) @@ -1007,9 +1007,9 @@ static void PrintMatchCallLocation(struct Pokenav4Struct *state, int arg1) else StringCopy(mapName, gText_Unknown); - x = GetStringCenterAlignXOffset(7, mapName, 88); + x = GetStringCenterAlignXOffset(FONT_NARROW, mapName, 88); FillWindowPixelBuffer(state->locWindowId, PIXEL_FILL(1)); - AddTextPrinterParameterized(state->locWindowId, 7, mapName, x, 1, 0, NULL); + AddTextPrinterParameterized(state->locWindowId, FONT_NARROW, mapName, x, 1, 0, NULL); } static void PrintMatchCallSelectionOptions(struct Pokenav4Struct *state) @@ -1023,10 +1023,10 @@ static void PrintMatchCallSelectionOptions(struct Pokenav4Struct *state) if (optionText == MATCH_CALL_OPTION_COUNT) break; - AddTextPrinterParameterized(state->infoBoxWindowId, 7, sMatchCallOptionTexts[optionText], 16, i * 16 + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(state->infoBoxWindowId, FONT_NARROW, sMatchCallOptionTexts[optionText], 16, i * 16 + 1, TEXT_SKIP_DRAW, NULL); } - CopyWindowToVram(state->infoBoxWindowId, 2); + CopyWindowToVram(state->infoBoxWindowId, COPYWIN_GFX); } static bool32 sub_81CBFC4(struct Pokenav4Struct *state) @@ -1055,7 +1055,7 @@ static void UpdateWindowsToShowCheckPage(struct Pokenav4Struct *state) { CloseMatchCallSelectOptionsWindow(state); FillWindowPixelBuffer(state->infoBoxWindowId, PIXEL_FILL(1)); - CopyWindowToVram(state->infoBoxWindowId, 2); + CopyWindowToVram(state->infoBoxWindowId, COPYWIN_GFX); } static void sub_81CC034(struct Pokenav4Struct *state) @@ -1072,7 +1072,7 @@ static void DrawMsgBoxForMatchCallMsg(struct Pokenav4Struct *state) DrawMatchCallTextBoxBorder(state->msgBoxWindowId, 1, 4); FillWindowPixelBuffer(state->msgBoxWindowId, PIXEL_FILL(1)); PutWindowTilemap(state->msgBoxWindowId); - CopyWindowToVram(state->msgBoxWindowId, 3); + CopyWindowToVram(state->msgBoxWindowId, COPYWIN_FULL); sprite = PauseSpinningPokenavSprite(); sprite->x = 24; sprite->y = 112; @@ -1085,7 +1085,7 @@ static void DrawMsgBoxForCloseByMsg(struct Pokenav4Struct *state) DrawTextBorderOuter(state->msgBoxWindowId, 1, 4); FillWindowPixelBuffer(state->msgBoxWindowId, PIXEL_FILL(1)); PutWindowTilemap(state->msgBoxWindowId); - CopyWindowToVram(state->msgBoxWindowId, 3); + CopyWindowToVram(state->msgBoxWindowId, COPYWIN_FULL); } static bool32 IsDma3ManagerBusyWithBgCopy2(struct Pokenav4Struct *state) @@ -1095,7 +1095,7 @@ static bool32 IsDma3ManagerBusyWithBgCopy2(struct Pokenav4Struct *state) static void PrintCallingDots(struct Pokenav4Struct *state) { - AddTextPrinterParameterized(state->msgBoxWindowId, 1, sText_CallingDots, 32, 1, 1, NULL); + AddTextPrinterParameterized(state->msgBoxWindowId, FONT_NORMAL, sText_CallingDots, 32, 1, 1, NULL); } static bool32 WaitForCallingDotsText(struct Pokenav4Struct *state) @@ -1106,7 +1106,7 @@ static bool32 WaitForCallingDotsText(struct Pokenav4Struct *state) static void PrintTrainerIsCloseBy(struct Pokenav4Struct *state) { - AddTextPrinterParameterized(state->msgBoxWindowId, 1, gText_TrainerCloseBy, 0, 1, 1, NULL); + AddTextPrinterParameterized(state->msgBoxWindowId, FONT_NORMAL, gText_TrainerCloseBy, 0, 1, 1, NULL); } static bool32 WaitForTrainerIsCloseByText(struct Pokenav4Struct *state) @@ -1120,7 +1120,7 @@ static void PrintMatchCallMessage(struct Pokenav4Struct *state) int index = GetSelectedPokenavListIndex(); const u8 *str = GetMatchCallMessageText(index, &state->unkF); u8 speed = GetPlayerTextSpeedDelay(); - AddTextPrinterParameterized(state->msgBoxWindowId, 1, str, 32, 1, speed, NULL); + AddTextPrinterParameterized(state->msgBoxWindowId, FONT_NORMAL, str, 32, 1, speed, NULL); } static bool32 WaitForMatchCallMessageText(struct Pokenav4Struct *state) diff --git a/src/pokenav_match_call_ui.c b/src/pokenav_match_call_ui.c index ba495245b..47226ca72 100644 --- a/src/pokenav_match_call_ui.c +++ b/src/pokenav_match_call_ui.c @@ -6,6 +6,7 @@ #include "bg.h" #include "menu.h" #include "decompress.h" +#include "international_string_util.h" // TODO: This UI isnt just for match call, seems to be the general pokenav list UI @@ -66,8 +67,6 @@ struct PokenavSub17 u32 loopedTaskId; }; -extern void sub_81DB620(u32 windowId, u32 a1, u32 a2, u32 a3, u32 a4); - void sub_81C82E4(struct PokenavSub17 *matchCall); bool32 CopyPokenavListMenuTemplate(struct PokenavSub17Substruct *a0, const struct BgTemplate *a1, struct PokenavListTemplate *a2, s32 a3); void InitMatchCallWindowState(struct MatchCallWindowState *a0, struct PokenavListTemplate *a1); @@ -170,13 +169,13 @@ u32 LoopedTask_sub_81C8254(s32 state) void sub_81C82E4(struct PokenavSub17 *matchCall) { u16 tileNum = (matchCall->list.listWindow.unk1 << 12) | matchCall->list.listWindow.unk6; - sub_8199DF0(matchCall->list.listWindow.bg, PIXEL_FILL(1), matchCall->list.listWindow.unk6, 1); - sub_8199DF0(matchCall->list.listWindow.bg, PIXEL_FILL(4), matchCall->list.listWindow.unk6 + 1, 1); + BgDmaFill(matchCall->list.listWindow.bg, PIXEL_FILL(1), matchCall->list.listWindow.unk6, 1); + BgDmaFill(matchCall->list.listWindow.bg, PIXEL_FILL(4), matchCall->list.listWindow.unk6 + 1, 1); SetBgTilemapBuffer(matchCall->list.listWindow.bg, matchCall->tilemapBuffer); FillBgTilemapBufferRect_Palette0(matchCall->list.listWindow.bg, tileNum, 0, 0, 32, 32); - ChangeBgY(matchCall->list.listWindow.bg, 0, 0); - ChangeBgX(matchCall->list.listWindow.bg, 0, 0); - ChangeBgY(matchCall->list.listWindow.bg, matchCall->list.listWindow.unk3 << 11, 2); + ChangeBgY(matchCall->list.listWindow.bg, 0, BG_COORD_SET); + ChangeBgX(matchCall->list.listWindow.bg, 0, BG_COORD_SET); + ChangeBgY(matchCall->list.listWindow.bg, matchCall->list.listWindow.unk3 << 11, BG_COORD_SUB); CopyBgTilemapBufferToVram(matchCall->list.listWindow.bg); } @@ -184,7 +183,7 @@ void sub_81C835C(struct PokenavListMenuWindow *listWindow) { FillWindowPixelBuffer(listWindow->windowId, PIXEL_FILL(1)); PutWindowTilemap(listWindow->windowId); - CopyWindowToVram(listWindow->windowId, 1); + CopyWindowToVram(listWindow->windowId, COPYWIN_MAP); } void sub_81C837C(struct MatchCallWindowState *state, struct PokenavSub17Substruct *a1) @@ -232,9 +231,9 @@ u32 LoopedTask_sub_81C83F0(s32 state) if (++structPtr->listWindow.unkC >= structPtr->listWindow.unkE) { if (structPtr->unk38 != NULL) - CopyWindowToVram(structPtr->listWindow.windowId, 3); + CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_FULL); else - CopyWindowToVram(structPtr->listWindow.windowId, 2); + CopyWindowToVram(structPtr->listWindow.windowId, COPYWIN_GFX); return LT_INC_AND_PAUSE; } else @@ -296,9 +295,9 @@ void sub_81C8568(s32 a0, struct PokenavSub17Substruct *list) list->unk20 = GetBgY(list->listWindow.bg); list->unk24 = list->unk20 + (a0 << 12); if (a0 > 0) - list->unk30 = 1; + list->unk30 = BG_COORD_ADD; else - list->unk30 = 2; + list->unk30 = BG_COORD_SUB; list->unk2C = a0; list->loopedTaskId = CreateLoopedTask(LoopedTask_sub_81C85A0, 6); } @@ -320,12 +319,12 @@ u32 LoopedTask_sub_81C85A0(s32 state) flag = FALSE; y = GetBgY(subPtr->listWindow.bg); v1 = ChangeBgY(subPtr->listWindow.bg, 0x1000, subPtr->unk30); - if (subPtr->unk30 == 2) + if (subPtr->unk30 == BG_COORD_SUB) { if ((y > subPtr->unk24 || y <= subPtr->unk20) && v1 <= subPtr->unk24) flag = TRUE; } - else + else // BG_COORD_ADD { if ((y < subPtr->unk24 || y >= subPtr->unk20) && v1 >= subPtr->unk24) flag = TRUE; @@ -334,7 +333,7 @@ u32 LoopedTask_sub_81C85A0(s32 state) if (flag) { subPtr->listWindow.unkA = (subPtr->listWindow.unkA + subPtr->unk2C) & 0xF; - ChangeBgY(subPtr->listWindow.bg, subPtr->unk24, 0); + ChangeBgY(subPtr->listWindow.bg, subPtr->unk24, BG_COORD_SET); return LT_FINISH; } return LT_PAUSE; @@ -495,7 +494,7 @@ void sub_81C8838(void) struct PokenavSub17 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MATCH_CALL_LIST); struct MatchCallWindowState *subPtr = &structPtr->unk888; structPtr->list.unk38(structPtr->list.listWindow.windowId, subPtr->windowTopIndex + subPtr->selectedIndexOffset, (structPtr->list.listWindow.unkA + subPtr->selectedIndexOffset) & 0xF); - CopyWindowToVram(structPtr->list.listWindow.windowId, 1); + CopyWindowToVram(structPtr->list.listWindow.windowId, COPYWIN_MAP); } // TODO: @@ -673,7 +672,7 @@ void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) if (a1 + a2 <= 16) { CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, a2 * v2); - CopyWindowToVram(listWindow->windowId, 2); + CopyWindowToVram(listWindow->windowId, COPYWIN_GFX); } else { @@ -682,13 +681,13 @@ void sub_81C8B70(struct PokenavListMenuWindow *listWindow, s32 a1, s32 a2) CpuFastFill8(PIXEL_FILL(1), v1 + a1 * v2, v3 * v2); CpuFastFill8(PIXEL_FILL(1), v1, v4 * v2); - CopyWindowToVram(listWindow->windowId, 2); + CopyWindowToVram(listWindow->windowId, COPYWIN_GFX); } for (a2--; a2 != -1; a1 = (a1 + 1) & 0xF, a2--) ClearRematchPokeballIcon(listWindow->windowId, a1); - CopyWindowToVram(listWindow->windowId, 1); + CopyWindowToVram(listWindow->windowId, COPYWIN_MAP); } void sub_81C8C64(struct PokenavListMenuWindow *listWindow, u32 a1) @@ -713,18 +712,18 @@ void sub_81C8CB4(struct MatchCallWindowState *state, struct PokenavSub17Substruc list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer); list->unk38(list->listWindow.windowId, state->windowTopIndex, list->listWindow.unkA); FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(4), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16); - AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SPEED_FF, list->unkTextBuffer); + AddTextPrinterParameterized3(list->listWindow.windowId, list->listWindow.fontId, 8, (list->listWindow.unkA * 16) + 1, colors, TEXT_SKIP_DRAW, list->unkTextBuffer); sub_81C8C64(&list->listWindow, 1); - CopyWindowRectToVram(list->listWindow.windowId, 3, 0, list->listWindow.unkA * 2, list->listWindow.unk4, 2); + CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_FULL, 0, list->listWindow.unkA * 2, list->listWindow.unk4, 2); } void sub_81C8D4C(struct MatchCallWindowState *state, struct PokenavSub17Substruct *list) { list->unk34(state->unk10 + state->unkC * state->windowTopIndex, list->unkTextBuffer); FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, list->listWindow.unkA * 16, list->listWindow.unk4 * 8, 16); - AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->unkTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(list->listWindow.windowId, list->listWindow.fontId, list->unkTextBuffer, 8, list->listWindow.unkA * 16 + 1, TEXT_SKIP_DRAW, NULL); sub_81C8C64(&list->listWindow, 0); - CopyWindowToVram(list->listWindow.windowId, 3); + CopyWindowToVram(list->listWindow.windowId, COPYWIN_FULL); } void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fieldId) @@ -734,8 +733,8 @@ void PrintMatchCallFieldNames(struct PokenavSub17Substruct *list, u32 fieldId) u32 top = (list->listWindow.unkA + 1 + (fieldId * 2)) & 0xF; FillWindowPixelRect(list->listWindow.windowId, PIXEL_FILL(1), 0, top << 4, list->listWindow.unk4, 16); - AddTextPrinterParameterized3(list->listWindow.windowId, 7, 2, (top << 4) + 1, colors, -1, fieldNames[fieldId]); - CopyWindowRectToVram(list->listWindow.windowId, 2, 0, top << 1, list->listWindow.unk4, 2); + AddTextPrinterParameterized3(list->listWindow.windowId, FONT_NARROW, 2, (top << 4) + 1, colors, TEXT_SKIP_DRAW, fieldNames[fieldId]); + CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, top << 1, list->listWindow.unk4, 2); } static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct PokenavSub17Substruct *list, u32 checkPageEntry) @@ -754,9 +753,9 @@ static void PrintMatchCallFlavorText(struct MatchCallWindowState *a0, struct Pok if (str != NULL) { - sub_81DB620(list->listWindow.windowId, 1, r6 * 2, list->listWindow.unk4 - 1, 2); - AddTextPrinterParameterized(list->listWindow.windowId, 7, str, 2, (r6 << 4) + 1, TEXT_SPEED_FF, NULL); - CopyWindowRectToVram(list->listWindow.windowId, 2, 0, r6 * 2, list->listWindow.unk4, 2); + FillWindowTilesByRow(list->listWindow.windowId, 1, r6 * 2, list->listWindow.unk4 - 1, 2); + AddTextPrinterParameterized(list->listWindow.windowId, FONT_NARROW, str, 2, (r6 << 4) + 1, TEXT_SKIP_DRAW, NULL); + CopyWindowRectToVram(list->listWindow.windowId, COPYWIN_GFX, 0, r6 * 2, list->listWindow.unk4, 2); } } diff --git a/src/pokenav_menu_handler_2.c b/src/pokenav_menu_handler_2.c index 5f6c4460a..bcfe94cb7 100644 --- a/src/pokenav_menu_handler_2.c +++ b/src/pokenav_menu_handler_2.c @@ -415,12 +415,12 @@ static u32 LoopedTask_OpenMenu(s32 state) CopyToBgTilemapBuffer(1, gPokenavMessageBox_Tilemap, 0, 0); CopyBgTilemapBufferToVram(1); CopyPaletteIntoBufferUnfaded(gPokenavMessageBox_Pal, 0x10, 0x20); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); return LT_INC_AND_PAUSE; case 1: if (FreeTempTileDataBuffersIfPossible()) @@ -1125,7 +1125,7 @@ static void AddOptionDescriptionWindow(void) ptr->optionDescWindowId = AddWindow(&sOptionDescWindowTemplate); PutWindowTilemap(ptr->optionDescWindowId); FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - CopyWindowToVram(ptr->optionDescWindowId, 3); + CopyWindowToVram(ptr->optionDescWindowId, COPYWIN_FULL); } static void PrintCurrentOptionDescription(void) @@ -1133,9 +1133,9 @@ static void PrintCurrentOptionDescription(void) struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); int menuItem = GetCurrentMenuItemId(); const u8 * s = sPageDescriptions[menuItem]; - u32 width = GetStringWidth(1, s, -1); + u32 width = GetStringWidth(FONT_NORMAL, s, -1); FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - AddTextPrinterParameterized3(ptr->optionDescWindowId, 1, (192 - width) / 2, 1, sOptionDescTextColors, 0, s); + AddTextPrinterParameterized3(ptr->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors, 0, s); } // Printed when Ribbons is selected if no PC/party mons have ribbons @@ -1144,9 +1144,9 @@ static void PrintNoRibbonWinners(void) { struct Pokenav2Struct * ptr = GetSubstructPtr(POKENAV_SUBSTRUCT_MENU_ICONS); const u8 * s = gText_NoRibbonWinners; - u32 width = GetStringWidth(1, s, -1); + u32 width = GetStringWidth(FONT_NORMAL, s, -1); FillWindowPixelBuffer(ptr->optionDescWindowId, PIXEL_FILL(6)); - AddTextPrinterParameterized3(ptr->optionDescWindowId, 1, (192 - width) / 2, 1, sOptionDescTextColors2, 0, s); + AddTextPrinterParameterized3(ptr->optionDescWindowId, FONT_NORMAL, (192 - width) / 2, 1, sOptionDescTextColors2, 0, s); } static bool32 IsDma3ManagerBusyWithBgCopy_(void) @@ -1168,7 +1168,7 @@ static void DestroyMovingDotsBgTask(void) static void Task_MoveBgDots(u8 taskId) { - ChangeBgX(3, 0x80, 1); + ChangeBgX(3, 0x80, BG_COORD_ADD); } static void CreateBgDotPurplePalTask(void) diff --git a/src/pokenav_region_map.c b/src/pokenav_region_map.c index 13a7030da..89bd2f7c7 100755 --- a/src/pokenav_region_map.c +++ b/src/pokenav_region_map.c @@ -501,8 +501,8 @@ static void FreeCityZoomViewGfx(void) static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *state) { - sub_8199DF0(1, PIXEL_FILL(0), 0x40, 1); - sub_8199DF0(1, PIXEL_FILL(1), 0x41, 1); + BgDmaFill(1, PIXEL_FILL(0), 0x40, 1); + BgDmaFill(1, PIXEL_FILL(1), 0x41, 1); CpuFill16(0x1040, state->tilemapBuffer, 0x800); SetBgTilemapBuffer(1, state->tilemapBuffer); state->infoWindowId = AddWindow(&sMapSecInfoWindowTemplate); @@ -511,15 +511,15 @@ static void LoadPokenavRegionMapGfx(struct Pokenav5Struct_2 *state) DecompressAndCopyTileDataToVram(1, sRegionMapCityZoomTiles_Gfx, 0, 0, 0); FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); PutWindowTilemap(state->infoWindowId); - CopyWindowToVram(state->infoWindowId, 3); + CopyWindowToVram(state->infoWindowId, COPYWIN_FULL); CopyPaletteIntoBufferUnfaded(sMapSecInfoWindow_Pal, 0x10, 0x20); CopyPaletteIntoBufferUnfaded(gRegionMapCityZoomTiles_Pal, 0x30, 0x20); if (!IsRegionMapZoomed()) - ChangeBgY(1, -0x6000, 0); + ChangeBgY(1, -0x6000, BG_COORD_SET); else - ChangeBgY(1, 0, 0); + ChangeBgY(1, 0, BG_COORD_SET); - ChangeBgX(1, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); } static bool32 TryFreeTempTileDataBuffers(void) @@ -535,26 +535,26 @@ static void UpdateMapSecInfoWindow(struct Pokenav5Struct_2 *state) case MAPSECTYPE_CITY_CANFLY: FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); PutWindowRectTilemap(state->infoWindowId, 0, 0, 12, 2); - AddTextPrinterParameterized(state->infoWindowId, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(state->infoWindowId, FONT_NARROW, regionMap->mapSecName, 0, 1, TEXT_SKIP_DRAW, NULL); DrawCityMap(state, regionMap->mapSecId, regionMap->posWithinMapSec); - CopyWindowToVram(state->infoWindowId, 3); + CopyWindowToVram(state->infoWindowId, COPYWIN_FULL); SetCityZoomTextInvisibility(FALSE); break; case MAPSECTYPE_CITY_CANTFLY: FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); PutWindowRectTilemap(state->infoWindowId, 0, 0, 12, 2); - AddTextPrinterParameterized(state->infoWindowId, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(state->infoWindowId, FONT_NARROW, regionMap->mapSecName, 0, 1, TEXT_SKIP_DRAW, NULL); FillBgTilemapBufferRect(1, 0x1041, 17, 6, 12, 11, 17); - CopyWindowToVram(state->infoWindowId, 3); + CopyWindowToVram(state->infoWindowId, COPYWIN_FULL); SetCityZoomTextInvisibility(TRUE); break; case MAPSECTYPE_ROUTE: case MAPSECTYPE_BATTLE_FRONTIER: FillWindowPixelBuffer(state->infoWindowId, PIXEL_FILL(1)); PutWindowTilemap(state->infoWindowId); - AddTextPrinterParameterized(state->infoWindowId, 7, regionMap->mapSecName, 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(state->infoWindowId, FONT_NARROW, regionMap->mapSecName, 0, 1, TEXT_SKIP_DRAW, NULL); PrintLandmarkNames(state, regionMap->mapSecId, regionMap->posWithinMapSec); - CopyWindowToVram(state->infoWindowId, 3); + CopyWindowToVram(state->infoWindowId, COPYWIN_FULL); SetCityZoomTextInvisibility(TRUE); break; case MAPSECTYPE_NONE: @@ -587,9 +587,9 @@ static void Task_ChangeBgYForZoom(u8 taskId) { if (gTasks[taskId].tZoomIn) { - if (ChangeBgY(1, 0x480, 1) >= 0) + if (ChangeBgY(1, 0x480, BG_COORD_ADD) >= 0) { - ChangeBgY(1, 0, 0); + ChangeBgY(1, 0, BG_COORD_SET); DestroyTask(taskId); } @@ -597,9 +597,9 @@ static void Task_ChangeBgYForZoom(u8 taskId) } else { - if (ChangeBgY(1, 0x480, 2) <= -0x6000) + if (ChangeBgY(1, 0x480, BG_COORD_SUB) <= -0x6000) { - ChangeBgY(1, -0x6000, 0); + ChangeBgY(1, -0x6000, BG_COORD_SET); DestroyTask(taskId); } @@ -654,7 +654,7 @@ static void PrintLandmarkNames(struct Pokenav5Struct_2 *state, int mapSecId, int break; StringCopyPadded(gStringVar1, landmarkName, CHAR_SPACE, 12); - AddTextPrinterParameterized(state->infoWindowId, 7, gStringVar1, 0, i * 16 + 17, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(state->infoWindowId, FONT_NARROW, gStringVar1, 0, i * 16 + 17, TEXT_SKIP_DRAW, NULL); i++; } } diff --git a/src/pokenav_ribbons_1.c b/src/pokenav_ribbons_1.c index a8aaafa35..862128967 100644 --- a/src/pokenav_ribbons_1.c +++ b/src/pokenav_ribbons_1.c @@ -439,8 +439,8 @@ static u32 LoopedTask_OpenRibbonsMonList(s32 state) return LT_PAUSE; if (!UpdateMonListBgs()) return LT_PAUSE; - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); ShowBg(1); return LT_INC_AND_PAUSE; case 2: @@ -652,7 +652,7 @@ static void AddRibbonsMonListWindow(struct PokenavSub10 *monMenu) PutWindowTilemap(monMenu->winid); r2 = GetRibbonsMonListCount(); sub_81D02B0(monMenu->winid, 0, r2); - CopyWindowToVram(monMenu->winid, 1); + CopyWindowToVram(monMenu->winid, COPYWIN_MAP); sub_81D0288(monMenu); } @@ -661,7 +661,7 @@ static void sub_81D0288(struct PokenavSub10 *monMenu) s32 r4 = GetSelectedPokenavListIndex(); s32 r2 = GetRibbonsMonListCount(); sub_81D02B0(monMenu->winid, r4 + 1, r2); - CopyWindowToVram(monMenu->winid, 2); + CopyWindowToVram(monMenu->winid, COPYWIN_GFX); } static void sub_81D02B0(s32 windowId, s32 val1, s32 val2) @@ -673,8 +673,8 @@ static void sub_81D02B0(s32 windowId, s32 val1, s32 val2) ptr = ConvertIntToDecimalStringN(ptr, val1, STR_CONV_MODE_RIGHT_ALIGN, 3); *ptr++ = CHAR_SLASH; ConvertIntToDecimalStringN(ptr, val2, STR_CONV_MODE_RIGHT_ALIGN, 3); - x = GetStringCenterAlignXOffset(1, strbuf, 56); - AddTextPrinterParameterized(windowId, 1, strbuf, x, 1, 0xFF, NULL); + x = GetStringCenterAlignXOffset(FONT_NORMAL, strbuf, 56); + AddTextPrinterParameterized(windowId, FONT_NORMAL, strbuf, x, 1, TEXT_SKIP_DRAW, NULL); } static void InitMonRibbonPokenavListMenuTemplate(void) @@ -689,7 +689,7 @@ static void InitMonRibbonPokenavListMenuTemplate(void) template.listTop = 1; template.maxShowed = 8; template.fillValue = 2; - template.fontId = 1; + template.fontId = FONT_NORMAL; template.listFunc.printMonFunc = BufferRibbonMonInfoText; template.unk14 = NULL; sub_81C81D4(&sMonRibbonListBgTemplates[1], &template, 0); @@ -722,7 +722,7 @@ static void BufferRibbonMonInfoText(struct PokenavMonList * item0, u8 * dest) } StringGetEnd10(gStringVar3); - dest = GetStringClearToWidth(dest, 1, gStringVar3, 60); + dest = GetStringClearToWidth(dest, FONT_NORMAL, gStringVar3, 60); switch (gender) { default: @@ -741,6 +741,6 @@ static void BufferRibbonMonInfoText(struct PokenavMonList * item0, u8 * dest) *s++ = CHAR_EXTRA_SYMBOL; *s++ = CHAR_LV_2; ConvertIntToDecimalStringN(s, level, STR_CONV_MODE_LEFT_ALIGN, 3); - dest = GetStringClearToWidth(dest, 1, gStringVar1, 54); + dest = GetStringClearToWidth(dest, FONT_NORMAL, gStringVar1, 54); ConvertIntToDecimalStringN(dest, item->data, STR_CONV_MODE_RIGHT_ALIGN, 2); } diff --git a/src/pokenav_ribbons_2.c b/src/pokenav_ribbons_2.c index bf1886ed0..ef08ba392 100644 --- a/src/pokenav_ribbons_2.c +++ b/src/pokenav_ribbons_2.c @@ -578,7 +578,7 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state) case 1: if (!FreeTempTileDataBuffersIfPossible()) { - sub_8199DF0(1, 0, 0, 1); + BgDmaFill(1, 0, 0, 1); DecompressAndCopyTileDataToVram(1, sRibbonIconsSmall_Gfx, 0, 1, 0); SetBgTilemapBuffer(1, structPtr->tilemapBuffers[1]); FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 32, 20); @@ -631,10 +631,10 @@ static u32 LoopedTask_OpenRibbonsSummaryMenu(s32 state) if (!IsDma3ManagerBusyWithBgCopy()) { CreateBigRibbonSprite(structPtr); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); ShowBg(1); ShowBg(2); HideBg(3); @@ -809,8 +809,8 @@ static void PrintCurrentMonRibbonCount(struct PokenavSub14 *structPtr) DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gStringVar1); DynamicPlaceholderTextUtil_ExpandPlaceholders(gStringVar4, gText_RibbonsF700); FillWindowPixelBuffer(structPtr->ribbonCountWindowId, PIXEL_FILL(4)); - AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, 1, 0, 1, color, -1, gStringVar4); - CopyWindowToVram(structPtr->ribbonCountWindowId, 2); + AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, 1, color, TEXT_SKIP_DRAW, gStringVar4); + CopyWindowToVram(structPtr->ribbonCountWindowId, COPYWIN_GFX); } static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr) @@ -824,7 +824,7 @@ static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr) { // Print normal ribbon name/description for (i = 0; i < 2; i++) - AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, 1, 0, (i * 16) + 1, color, -1, gRibbonDescriptionPointers[ribbonId][i]); + AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gRibbonDescriptionPointers[ribbonId][i]); } else { @@ -840,10 +840,10 @@ static void PrintRibbonNameAndDescription(struct PokenavSub14 *structPtr) // Print gift ribbon name/description ribbonId--; for (i = 0; i < 2; i++) - AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, 1, 0, (i * 16) + 1, color, -1, gGiftRibbonDescriptionPointers[ribbonId][i]); + AddTextPrinterParameterized3(structPtr->ribbonCountWindowId, FONT_NORMAL, 0, (i * 16) + 1, color, TEXT_SKIP_DRAW, gGiftRibbonDescriptionPointers[ribbonId][i]); } - CopyWindowToVram(structPtr->ribbonCountWindowId, 2); + CopyWindowToVram(structPtr->ribbonCountWindowId, COPYWIN_GFX); } static const struct WindowTemplate sRibbonSummaryMonNameWindowTemplate = @@ -877,7 +877,7 @@ static void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr) FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); GetMonNicknameLevelGender(gStringVar3, &level, &gender); - AddTextPrinterParameterized(windowId, 1, gStringVar3, 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar3, 0, 1, TEXT_SKIP_DRAW, NULL); switch (gender) { case MON_MALE: @@ -896,8 +896,8 @@ static void PrintRibbbonsSummaryMonInfo(struct PokenavSub14 *structPtr) *(txtPtr++) = CHAR_EXTRA_SYMBOL; *(txtPtr++) = CHAR_LV_2; ConvertIntToDecimalStringN(txtPtr, level, STR_CONV_MODE_LEFT_ALIGN, 3); - AddTextPrinterParameterized(windowId, 1, gStringVar1, 60, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(windowId, 2); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar1, 60, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(windowId, COPYWIN_GFX); } static const struct WindowTemplate sRibbonMonListIndexWindowTemplate[] = @@ -932,9 +932,9 @@ static void PrintRibbonsMonListIndex(struct PokenavSub14 *structPtr) txtPtr = ConvertIntToDecimalStringN(gStringVar1, id, STR_CONV_MODE_RIGHT_ALIGN, 3); *(txtPtr++) = CHAR_SLASH; ConvertIntToDecimalStringN(txtPtr, count, STR_CONV_MODE_RIGHT_ALIGN, 3); - x = GetStringCenterAlignXOffset(1, gStringVar1, 56); - AddTextPrinterParameterized(structPtr->listIdxWindowId, 1, gStringVar1, x, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(structPtr->listIdxWindowId, 2); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gStringVar1, 56); + AddTextPrinterParameterized(structPtr->listIdxWindowId, FONT_NORMAL, gStringVar1, x, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(structPtr->listIdxWindowId, COPYWIN_GFX); } static void ResetSpritesAndDrawMonFrontPic(struct PokenavSub14 *structPtr) diff --git a/src/rayquaza_scene.c b/src/rayquaza_scene.c index 642fe6233..51498fa1d 100644 --- a/src/rayquaza_scene.c +++ b/src/rayquaza_scene.c @@ -1757,8 +1757,8 @@ static void DuoFight_LightningLong(void) static void DuoFight_AnimateRain(void) { - ChangeBgX(2, 0x400, 1); - ChangeBgY(2, 0x800, 2); + ChangeBgX(2, 0x400, BG_COORD_ADD); + ChangeBgY(2, 0x800, BG_COORD_SUB); } // Only used by the full version, which pans up at the end (so scene objects move down) @@ -1772,7 +1772,7 @@ static void DuoFight_PanOffScene(u8 taskId) bgY = GetBgY(1); if (GetBgY(1) == 0 || bgY > 0x8000) - ChangeBgY(1, 0x400, 2); + ChangeBgY(1, 0x400, BG_COORD_SUB); if (tTimer != 16) { @@ -1795,7 +1795,7 @@ static void Task_DuoFightEnd(u8 taskId) if (!gPaletteFade.active) { DestroyTask(tHelperTaskId); - ChangeBgY(1, 0, 0); + ChangeBgY(1, 0, BG_COORD_SET); SetVBlankCallback(NULL); ScanlineEffect_Stop(); ResetSpriteData(); @@ -2579,8 +2579,8 @@ static void Task_RayCharges_ShakeRayquaza(u8 taskId) s16 *data = gTasks[taskId].data; if ((tTimer & 3) == 0) { - ChangeBgX(1, (Random() % 8 - 4) << 8, 0); - ChangeBgY(1, (Random() % 8 - 4) << 8, 0); + ChangeBgX(1, (Random() % 8 - 4) << 8, BG_COORD_SET); + ChangeBgY(1, (Random() % 8 - 4) << 8, BG_COORD_SET); } tTimer++; @@ -2592,16 +2592,16 @@ static void Task_RayCharges_FlyOffscreen(u8 taskId) s16 *data = gTasks[taskId].data; if (tState == 0) { - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); tState++; tOffset = 10; tShakeDir = -1; } else if (tState == 1) { - ChangeBgX(1, tOffset << 8, 2); - ChangeBgY(1, tOffset << 8, 1); + ChangeBgX(1, tOffset << 8, BG_COORD_SUB); + ChangeBgY(1, tOffset << 8, BG_COORD_ADD); tOffset += tShakeDir; if (tOffset == -10) tShakeDir *= -1; @@ -2616,12 +2616,12 @@ static void Task_RayCharges_FlyOffscreen(u8 taskId) static void RayCharges_AnimateBg(void) { // Update yellow orbs - ChangeBgX(2, 0x400, 2); - ChangeBgY(2, 0x400, 1); + ChangeBgX(2, 0x400, BG_COORD_SUB); + ChangeBgY(2, 0x400, BG_COORD_ADD); // Update blue streaks - ChangeBgX(0, 0x800, 2); - ChangeBgY(0, 0x800, 1); + ChangeBgX(0, 0x800, BG_COORD_SUB); + ChangeBgY(0, 0x800, BG_COORD_ADD); } static void Task_RayChargesEnd(u8 taskId) diff --git a/src/record_mixing.c b/src/record_mixing.c index 7ffe6680f..f308e5b3d 100644 --- a/src/record_mixing.c +++ b/src/record_mixing.c @@ -286,8 +286,8 @@ static void ReceiveExchangePacket(u32 multiplayerId) static void PrintTextOnRecordMixing(const u8 *src) { DrawDialogueFrame(0, 0); - AddTextPrinterParameterized(0, 1, src, 0, 1, 0, NULL); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, src, 0, 1, 0, NULL); + CopyWindowToVram(0, COPYWIN_FULL); } #define tCounter data[0] diff --git a/src/region_map.c b/src/region_map.c index 4e547b5fb..021ef7c71 100644 --- a/src/region_map.c +++ b/src/region_map.c @@ -1718,7 +1718,7 @@ void CB2_OpenFlyMap(void) LoadPalette(sRegionMapFramePal, 0x10, 0x20); PutWindowTilemap(2); FillWindowPixelBuffer(2, PIXEL_FILL(0)); - AddTextPrinterParameterized(2, 1, gText_FlyToWhere, 0, 1, 0, NULL); + AddTextPrinterParameterized(2, FONT_NORMAL, gText_FlyToWhere, 0, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); gMain.state++; break; @@ -1784,9 +1784,9 @@ static void DrawFlyDestTextWindow(void) namePrinted = TRUE; ClearStdWindowAndFrameToTransparent(0, FALSE); DrawStdFrameWithCustomTileAndPalette(1, FALSE, 101, 13); - AddTextPrinterParameterized(1, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); + AddTextPrinterParameterized(1, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); name = sMultiNameFlyDestinations[i].name[sFlyMap->regionMap.posWithinMapSec]; - AddTextPrinterParameterized(1, 1, name, GetStringRightAlignXOffset(1, name, 96), 17, 0, NULL); + AddTextPrinterParameterized(1, FONT_NORMAL, name, GetStringRightAlignXOffset(FONT_NORMAL, name, 96), 17, 0, NULL); ScheduleBgCopyTilemapToVram(0); sDrawFlyDestTextWindow = TRUE; } @@ -1805,7 +1805,7 @@ static void DrawFlyDestTextWindow(void) // Window is already drawn, just empty it FillWindowPixelBuffer(0, PIXEL_FILL(1)); } - AddTextPrinterParameterized(0, 1, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); sDrawFlyDestTextWindow = FALSE; } @@ -1819,7 +1819,7 @@ static void DrawFlyDestTextWindow(void) DrawStdFrameWithCustomTileAndPalette(0, FALSE, 101, 13); } FillWindowPixelBuffer(0, PIXEL_FILL(1)); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); ScheduleBgCopyTilemapToVram(0); sDrawFlyDestTextWindow = FALSE; } diff --git a/src/reset_rtc_screen.c b/src/reset_rtc_screen.c index 5e6fcd436..25e3a7330 100644 --- a/src/reset_rtc_screen.c +++ b/src/reset_rtc_screen.c @@ -381,14 +381,14 @@ static void PrintTime(u8 windowId, u8 x, u8 y, u16 days, u8 hours, u8 minutes, u ConvertIntToDecimalStringN(gStringVar1, seconds, STR_CONV_MODE_LEADING_ZEROS, 2); dest = StringCopy(dest, gStringVar1); - AddTextPrinterParameterized(windowId, 1, gStringVar4, x, y, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gStringVar4, x, y, TEXT_SKIP_DRAW, NULL); } static void ShowChooseTimeWindow(u8 windowId, u16 days, u8 hours, u8 minutes, u8 seconds) { DrawStdFrameWithCustomTileAndPalette(windowId, FALSE, 0x214, 0xE); PrintTime(windowId, 0, 1, days, hours, minutes, seconds); - AddTextPrinterParameterized(windowId, 1, gText_Confirm2, 126, 1, 0, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_Confirm2, 126, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); } @@ -493,7 +493,7 @@ static void Task_ResetRtc_HandleInput(u8 taskId) { PlaySE(SE_SELECT); PrintTime(tWindowId, 0, 1, tDays, tHours, tMinutes, tSeconds); - CopyWindowToVram(tWindowId, 2); + CopyWindowToVram(tWindowId, COPYWIN_GFX); } } @@ -563,7 +563,7 @@ static void VBlankCB(void) static void ShowMessage(const u8 *str) { DrawDialogFrameWithCustomTileAndPalette(1, FALSE, 0x200, 0xF); - AddTextPrinterParameterized(1, 1, str, 0, 1, 0, NULL); + AddTextPrinterParameterized(1, FONT_NORMAL, str, 0, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); } @@ -578,7 +578,7 @@ static void Task_ShowResetRtcPrompt(u8 taskId) case 0: DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x214, 0xE); - AddTextPrinterParameterized(0, 1, gText_PresentTime, 0, 1, TEXT_SPEED_FF, 0); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_PresentTime, 0, 1, TEXT_SKIP_DRAW, 0); PrintTime( 0, 0, @@ -588,7 +588,7 @@ static void Task_ShowResetRtcPrompt(u8 taskId) gLocalTime.minutes, gLocalTime.seconds); - AddTextPrinterParameterized(0, 1, gText_PreviousTime, 0, 33, TEXT_SPEED_FF, 0); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_PreviousTime, 0, 33, TEXT_SKIP_DRAW, 0); PrintTime( 0, 0, @@ -599,7 +599,7 @@ static void Task_ShowResetRtcPrompt(u8 taskId) gSaveBlock2Ptr->lastBerryTreeUpdate.seconds); ShowMessage(gText_ResetRTCConfirmCancel); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); ScheduleBgCopyTilemapToVram(0); tState++; case 1: diff --git a/src/roulette.c b/src/roulette.c index b6ef1168b..ac4212d47 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -1223,8 +1223,8 @@ static void CB2_LoadRoulette(void) SetMultiplierSprite(SELECTION_NONE); DrawGridBackground(SELECTION_NONE); DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_ControlsInstruction, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_ControlsInstruction, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); gSpriteCoordOffsetX = -60; gSpriteCoordOffsetY = 0; break; @@ -1294,8 +1294,8 @@ static void Task_AskKeepPlaying(u8 taskId) { DisplayYesNoMenuDefaultYes(); DrawStdWindowFrame(sTextWindowId, 0); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_KeepPlaying, 0, 1, TEXT_SPEED_FF, 0); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_KeepPlaying, 0, 1, TEXT_SKIP_DRAW, 0); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); DoYesNoFuncWithChoice(taskId, &sYesNoTable_KeepPlaying); } @@ -1317,28 +1317,28 @@ static void UpdateGridSelectionRect(u8 selectionId) switch (selectionId) { case SELECTION_NONE: - ClearTilemapRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); + FillTilemapRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); break; case COL_WYNAUT: case COL_AZURILL: case COL_SKITTY: case COL_MAKUHITA: temp0 = (selectionId * 3 + 14); - ClearTilemapRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); + FillTilemapRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); SetTilemapRect(&sRoulette->tilemapBuffers[0][0], &sRoulette->gridTilemap[281], temp0, 7, 3, 13); break; case ROW_ORANGE: case ROW_GREEN: case ROW_PURPLE: temp1 = ((selectionId - 1) / 5 * 3 + 10); - ClearTilemapRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); + FillTilemapRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); SetTilemapRect(&sRoulette->tilemapBuffers[0][0], &sRoulette->gridTilemap[320], 14, temp1, 16, 3); break; // Individual square default: temp0 = GET_COL(selectionId) * 3 + 14; temp1 = ((selectionId - 1) / 5 * 3 + 7); - ClearTilemapRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); + FillTilemapRect(&sRoulette->tilemapBuffers[0][0], 0, 14, 7, 16, 13); SetTilemapRect(&sRoulette->tilemapBuffers[0][0], &sRoulette->gridTilemap[272], temp0, temp1, 3, 3); break; } @@ -1806,23 +1806,23 @@ static void Task_PrintSpinResult(u8 taskId) { PlayFanfare(MUS_SLOTS_JACKPOT); DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_Jackpot, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_Jackpot, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); } else { PlayFanfare(MUS_SLOTS_WIN); DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_ItsAHit, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_ItsAHit, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); } break; case FALSE: default: m4aSongNumStart(SE_FAILURE); DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_NothingDoing, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_NothingDoing, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); break; } gTasks[taskId].data[1] = 0; @@ -1866,8 +1866,8 @@ static void Task_PrintPayout(u8 taskId) ConvertIntToDecimalStringN(gStringVar1, (sRoulette->minBet * gTasks[taskId].tMultiplier), STR_CONV_MODE_LEFT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, Roulette_Text_YouveWonXCoins); DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); gTasks[taskId].tPayout = (sRoulette->minBet * gTasks[taskId].tMultiplier); gTasks[taskId].data[7] = 0; gTasks[taskId].func = Task_GivePayout; @@ -1902,16 +1902,16 @@ static void Task_TryPrintEndTurnMsg(u8 taskId) { // Reached Ball 6, clear board DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_BoardWillBeCleared, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_BoardWillBeCleared, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); StartTaskAfterDelayOrInput(taskId, Task_ClearBoard, NO_DELAY, A_BUTTON | B_BUTTON); } else if (gTasks[taskId].tCoins == MAX_COINS) { // Player maxed out coins DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_CoinCaseIsFull, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_CoinCaseIsFull, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); StartTaskAfterDelayOrInput(taskId, Task_AskKeepPlaying, NO_DELAY, A_BUTTON | B_BUTTON); } else @@ -1924,8 +1924,8 @@ static void Task_TryPrintEndTurnMsg(u8 taskId) { // Player out of coins DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_NoCoinsLeft, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_NoCoinsLeft, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); StartTaskAfterDelayOrInput(taskId, Task_StopPlaying, 60, A_BUTTON | B_BUTTON); } } @@ -1949,8 +1949,8 @@ static void Task_ClearBoard(u8 taskId) if (gTasks[taskId].tCoins == MAX_COINS) { DrawStdWindowFrame(sTextWindowId, FALSE); - AddTextPrinterParameterized(sTextWindowId, 1, Roulette_Text_CoinCaseIsFull, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(sTextWindowId, 3); + AddTextPrinterParameterized(sTextWindowId, FONT_NORMAL, Roulette_Text_CoinCaseIsFull, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sTextWindowId, COPYWIN_FULL); StartTaskAfterDelayOrInput(taskId, Task_AskKeepPlaying, NO_DELAY, A_BUTTON | B_BUTTON); } else @@ -3426,8 +3426,8 @@ static void Task_PrintMinBet(u8 taskId) ConvertIntToDecimalStringN(gStringVar1, minBet, STR_CONV_MODE_LEADING_ZEROS, 1); StringExpandPlaceholders(gStringVar4, Roulette_Text_PlayMinimumWagerIsX); DrawStdWindowFrame(0, FALSE); - AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_ShowMinBetYesNo; } } @@ -3445,8 +3445,8 @@ static void Task_PrintRouletteEntryMsg(u8 taskId) { // Special rate for Game Corner service day (only at second table) DrawStdWindowFrame(0, FALSE); - AddTextPrinterParameterized(0, 1, Roulette_Text_SpecialRateTable, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, Roulette_Text_SpecialRateTable, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_PrintMinBet; } else @@ -3454,8 +3454,8 @@ static void Task_PrintRouletteEntryMsg(u8 taskId) // Print minimum bet StringExpandPlaceholders(gStringVar4, Roulette_Text_PlayMinimumWagerIsX); DrawStdWindowFrame(0, FALSE); - AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_ShowMinBetYesNo; } } @@ -3464,8 +3464,8 @@ static void Task_PrintRouletteEntryMsg(u8 taskId) // Not enough for minimum bet StringExpandPlaceholders(gStringVar4, Roulette_Text_NotEnoughCoins); DrawStdWindowFrame(0, FALSE); - AddTextPrinterParameterized(0, 1, gStringVar4, 0, 1, TEXT_SPEED_FF, NULL); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(0, COPYWIN_FULL); gTasks[taskId].func = Task_NotEnoughForMinBet; gTasks[taskId].tCoins = 0; gTasks[taskId].data[0] = 0; diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 8f727310c..e7bdc3400 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -153,7 +153,7 @@ static void SaveFailedScreenTextPrint(const u8 *text, u8 x, u8 y) color[0] = TEXT_COLOR_TRANSPARENT; color[1] = TEXT_DYNAMIC_COLOR_6; color[2] = TEXT_COLOR_LIGHT_GRAY; - AddTextPrinterParameterized4(sWindowIds[TEXT_WIN_ID], 1, x * 8, y * 8 + 1, 0, 0, color, 0, text); + AddTextPrinterParameterized4(sWindowIds[TEXT_WIN_ID], FONT_NORMAL, x * 8, y * 8 + 1, 0, 0, color, 0, text); } void DoSaveFailedScreen(u8 saveType) @@ -217,13 +217,13 @@ static void CB2_SaveFailedScreen(void) LoadPalette(gBirchBagGrassPal, 0, 0x40); LoadPalette(sSaveFailedClockPal, 0x100, 0x20); LoadPalette(gTextWindowFrame1_Pal, 0xE0, 0x20); - LoadPalette(gUnknown_0860F074, 0xF0, 0x20); + LoadPalette(gStandardMenuPalette, 0xF0, 0x20); DrawStdFrameWithCustomTileAndPalette(sWindowIds[TEXT_WIN_ID], FALSE, 0x214, 0xE); DrawStdFrameWithCustomTileAndPalette(sWindowIds[CLOCK_WIN_ID], FALSE, 0x214, 0xE); FillWindowPixelBuffer(sWindowIds[CLOCK_WIN_ID], PIXEL_FILL(1)); // backwards? FillWindowPixelBuffer(sWindowIds[TEXT_WIN_ID], PIXEL_FILL(1)); - CopyWindowToVram(sWindowIds[CLOCK_WIN_ID], 2); // again? - CopyWindowToVram(sWindowIds[TEXT_WIN_ID], 1); + CopyWindowToVram(sWindowIds[CLOCK_WIN_ID], COPYWIN_GFX); // again? + CopyWindowToVram(sWindowIds[TEXT_WIN_ID], COPYWIN_MAP); SaveFailedScreenTextPrint(gText_SaveFailedCheckingBackup, 1, 0); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); EnableInterrupts(1); diff --git a/src/scrcmd.c b/src/scrcmd.c index 3e3beee59..144712860 100644 --- a/src/scrcmd.c +++ b/src/scrcmd.c @@ -49,6 +49,7 @@ #include "tv.h" #include "window.h" #include "constants/event_objects.h" +#include "constants/maps.h" typedef u16 (*SpecialFunc)(void); typedef void (*NativeFunc)(void); @@ -790,7 +791,7 @@ bool8 ScrCmd_warphole(struct ScriptContext *ctx) u16 y; PlayerGetDestCoords(&x, &y); - if (mapGroup == 0xFF && mapNum == 0xFF) + if (mapGroup == MAP_GROUP(UNDEFINED) && mapNum == MAP_NUM(UNDEFINED)) SetWarpDestinationToFixedHoleWarp(x - MAP_OFFSET, y - MAP_OFFSET); else SetWarpDestination(mapGroup, mapNum, -1, x - MAP_OFFSET, y - MAP_OFFSET); @@ -1207,7 +1208,7 @@ bool8 ScrCmd_turnvobject(struct ScriptContext *ctx) // The player is frozen after waiting for their current movement to finish. bool8 ScrCmd_lockall(struct ScriptContext *ctx) { - if (IsUpdateLinkStateCBActive()) + if (IsOverworldLinkActive()) { return FALSE; } @@ -1223,7 +1224,7 @@ bool8 ScrCmd_lockall(struct ScriptContext *ctx) // The player and selected object are frozen after waiting for their current movement to finish. bool8 ScrCmd_lock(struct ScriptContext *ctx) { - if (IsUpdateLinkStateCBActive()) + if (IsOverworldLinkActive()) { return FALSE; } @@ -1310,7 +1311,7 @@ bool8 ScrCmd_messageinstant(struct ScriptContext *ctx) msg = (const u8 *)ctx->data[0]; LoadMessageBoxAndBorderGfx(); DrawDialogueFrame(0, 1); - AddTextPrinterParameterized(0, 1, msg, 0, 1, 0, 0); + AddTextPrinterParameterized(0, FONT_NORMAL, msg, 0, 1, 0, 0); return FALSE; } @@ -1497,7 +1498,7 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) // in Emerald they are unused and position is calculated below instead StringExpandPlaceholders(gStringVar4, ptr + 6); - width = GetStringWidth(6, gStringVar4, -1) / 8u; + width = GetStringWidth(FONT_BRAILLE, gStringVar4, -1) / 8u; if (width > 28) width = 28; @@ -1532,8 +1533,8 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) DrawStdWindowFrame(gBrailleWindowId, 0); PutWindowTilemap(gBrailleWindowId); FillWindowPixelBuffer(gBrailleWindowId, PIXEL_FILL(1)); - AddTextPrinterParameterized(gBrailleWindowId, 6, gStringVar4, xText, yText, 0xFF, 0x0); - CopyWindowToVram(gBrailleWindowId, 3); + AddTextPrinterParameterized(gBrailleWindowId, FONT_BRAILLE, gStringVar4, xText, yText, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(gBrailleWindowId, COPYWIN_FULL); return FALSE; } @@ -2196,7 +2197,7 @@ bool8 ScrCmd_selectapproachingtrainer(struct ScriptContext *ctx) bool8 ScrCmd_lockfortrainer(struct ScriptContext *ctx) { - if (IsUpdateLinkStateCBActive()) + if (IsOverworldLinkActive()) { return FALSE; } diff --git a/src/script_menu.c b/src/script_menu.c index f3317773a..ae0fe91e6 100644 --- a/src/script_menu.c +++ b/src/script_menu.c @@ -109,7 +109,7 @@ static void DrawMultichoiceMenu(u8 left, u8 top, u8 multichoiceId, bool8 ignoreB windowId = CreateWindowFromRect(left, top, newWidth, count * 2); SetStandardWindowBorderStyle(windowId, 0); PrintMenuTable(windowId, count, actions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, count, cursorPos); + InitMenuInUpperLeftCornerNormal(windowId, count, cursorPos); ScheduleBgCopyTilemapToVram(0); InitMultichoiceCheckWrap(ignoreBPress, count, windowId, multichoiceId); } @@ -280,7 +280,7 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, bool8 ignore SetStandardWindowBorderStyle(gTasks[taskId].tWindowId, 0); PrintMenuGridTable(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, sMultichoiceLists[multichoiceId].list); InitMenuActionGrid(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, 0); - CopyWindowToVram(gTasks[taskId].tWindowId, 3); + CopyWindowToVram(gTasks[taskId].tWindowId, COPYWIN_FULL); return TRUE; } } @@ -288,7 +288,7 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, bool8 ignore static void Task_HandleMultichoiceGridInput(u8 taskId) { s16 *data = gTasks[taskId].data; - s8 selection = Menu_ProcessInputGridLayout(); + s8 selection = Menu_ProcessGridInput(); switch (selection) { @@ -353,34 +353,34 @@ static void CreatePCMultichoice(void) numChoices = 4; windowId = CreateWindowFromRect(0, 0, width, 8); SetStandardWindowBorderStyle(windowId, 0); - AddTextPrinterParameterized(windowId, 1, gText_HallOfFame, y, 33, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(windowId, 1, gText_LogOff, y, 49, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_HallOfFame, y, 33, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_LogOff, y, 49, TEXT_SKIP_DRAW, NULL); } else { numChoices = 3; windowId = CreateWindowFromRect(0, 0, width, 6); SetStandardWindowBorderStyle(windowId, 0); - AddTextPrinterParameterized(windowId, 1, gText_LogOff, y, 33, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_LogOff, y, 33, TEXT_SKIP_DRAW, NULL); } // Change PC name if player has met Lanette if (FlagGet(FLAG_SYS_PC_LANETTE)) - AddTextPrinterParameterized(windowId, 1, gText_LanettesPC, y, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_LanettesPC, y, 1, TEXT_SKIP_DRAW, NULL); else - AddTextPrinterParameterized(windowId, 1, gText_SomeonesPC, y, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_SomeonesPC, y, 1, TEXT_SKIP_DRAW, NULL); StringExpandPlaceholders(gStringVar4, gText_PlayersPC); PrintPlayerNameOnWindow(windowId, gStringVar4, y, 17); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, numChoices, 0); - CopyWindowToVram(windowId, 3); + InitMenuInUpperLeftCornerNormal(windowId, numChoices, 0); + CopyWindowToVram(windowId, COPYWIN_FULL); InitMultichoiceCheckWrap(FALSE, numChoices, windowId, MULTI_PC); } void ScriptMenu_DisplayPCStartupPrompt(void) { - sub_819786C(0, TRUE); - AddTextPrinterParameterized2(0, 1, gText_WhichPCShouldBeAccessed, 0, NULL, 2, 1, 3); + LoadMessageBoxAndFrameGfx(0, TRUE); + AddTextPrinterParameterized2(0, FONT_NORMAL, gText_WhichPCShouldBeAccessed, 0, NULL, 2, 1, 3); } bool8 ScriptMenu_CreateLilycoveSSTidalMultichoice(void) @@ -414,7 +414,7 @@ static void CreateLilycoveSSTidalMultichoice(void) sLilycoveSSTidalSelections[i] = 0xFF; } - GetFontAttribute(1, FONTATTR_MAX_LETTER_WIDTH); + GetFontAttribute(FONT_NORMAL, FONTATTR_MAX_LETTER_WIDTH); if (gSpecialVar_0x8004 == 0) { @@ -527,13 +527,13 @@ static void CreateLilycoveSSTidalMultichoice(void) { if (sLilycoveSSTidalSelections[i] != 0xFF) { - AddTextPrinterParameterized(windowId, 1, sLilycoveSSTidalDestinations[sLilycoveSSTidalSelections[i]], 8, selectionCount * 16 + 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, sLilycoveSSTidalDestinations[sLilycoveSSTidalSelections[i]], 8, selectionCount * 16 + 1, TEXT_SKIP_DRAW, NULL); selectionCount++; } } - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(windowId, count, count - 1); - CopyWindowToVram(windowId, 3); + InitMenuInUpperLeftCornerNormal(windowId, count, count - 1); + CopyWindowToVram(windowId, COPYWIN_FULL); InitMultichoiceCheckWrap(FALSE, count, windowId, MULTI_SSTIDAL_LILYCOVE); } } @@ -645,27 +645,27 @@ static void DrawLinkServicesMultichoiceMenu(u8 multichoiceId) { case MULTI_WIRELESS_NO_BERRY: FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sWirelessOptionsNoBerryCrush[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sWirelessOptionsNoBerryCrush[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); break; case MULTI_CABLE_CLUB_WITH_RECORD_MIX: FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sCableClubOptions_WithRecordMix[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sCableClubOptions_WithRecordMix[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); break; case MULTI_WIRELESS_NO_RECORD: FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sWirelessOptions_NoRecordMix[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sWirelessOptions_NoRecordMix[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); break; case MULTI_WIRELESS_ALL_SERVICES: FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sWirelessOptions_AllServices[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sWirelessOptions_AllServices[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); break; case MULTI_WIRELESS_NO_RECORD_BERRY: FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sWirelessOptions_NoRecordMixBerryCrush[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sWirelessOptions_NoRecordMixBerryCrush[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); break; case MULTI_CABLE_CLUB_NO_RECORD_MIX: FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized2(0, 1, sCableClubOptions_NoRecordMix[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); + AddTextPrinterParameterized2(0, FONT_NORMAL, sCableClubOptions_NoRecordMix[Menu_GetCursorPos()], 0, NULL, 2, 1, 3); break; } } @@ -688,17 +688,17 @@ static void CreateStartMenuForPokenavTutorial(void) { u8 windowId = CreateWindowFromRect(21, 0, 7, 18); SetStandardWindowBorderStyle(windowId, 0); - AddTextPrinterParameterized(windowId, 1, gText_MenuOptionPokedex, 8, 9, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(windowId, 1, gText_MenuOptionPokemon, 8, 25, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(windowId, 1, gText_MenuOptionBag, 8, 41, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(windowId, 1, gText_MenuOptionPokenav, 8, 57, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(windowId, 1, gSaveBlock2Ptr->playerName, 8, 73, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(windowId, 1, gText_MenuOptionSave, 8, 89, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(windowId, 1, gText_MenuOptionOption, 8, 105, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(windowId, 1, gText_MenuOptionExit, 8, 121, TEXT_SPEED_FF, NULL); - sub_81983AC(windowId, 1, 0, 9, 16, ARRAY_COUNT(MultichoiceList_ForcedStartMenu), 0); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_MenuOptionPokedex, 8, 9, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_MenuOptionPokemon, 8, 25, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_MenuOptionBag, 8, 41, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_MenuOptionPokenav, 8, 57, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gSaveBlock2Ptr->playerName, 8, 73, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_MenuOptionSave, 8, 89, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_MenuOptionOption, 8, 105, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(windowId, FONT_NORMAL, gText_MenuOptionExit, 8, 121, TEXT_SKIP_DRAW, NULL); + InitMenuNormal(windowId, FONT_NORMAL, 0, 9, 16, ARRAY_COUNT(MultichoiceList_ForcedStartMenu), 0); InitMultichoiceNoWrap(FALSE, ARRAY_COUNT(MultichoiceList_ForcedStartMenu), windowId, MULTI_FORCED_START_MENU); - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } #define tWindowId data[6] @@ -727,7 +727,7 @@ static int DisplayTextAndGetWidthInternal(const u8 *str) { u8 temp[64]; StringExpandPlaceholders(temp, str); - return GetStringWidth(1, temp, 0); + return GetStringWidth(FONT_NORMAL, temp, 0); } int DisplayTextAndGetWidth(const u8 *str, int prevWidth) diff --git a/src/secret_base.c b/src/secret_base.c index e728f3488..72560ee23 100644 --- a/src/secret_base.c +++ b/src/secret_base.c @@ -214,7 +214,7 @@ static const struct ListMenuTemplate sRegistryListMenuTemplate = .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, - .fontId = 1, + .fontId = FONT_NORMAL, .cursorKind = 0, }; @@ -1028,7 +1028,7 @@ static void ShowRegistryMenuActions(u8 taskId) tActionWindowId = AddWindow(&template); SetStandardWindowBorderStyle(tActionWindowId, 0); PrintMenuTable(tActionWindowId, ARRAY_COUNT(sRegistryMenuActions), sRegistryMenuActions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(tActionWindowId, 2, 0); + InitMenuInUpperLeftCornerNormal(tActionWindowId, 2, 0); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = HandleRegistryMenuActionsInput; } diff --git a/src/shop.c b/src/shop.c index f4e3fa2d8..fa4a73bbb 100755 --- a/src/shop.c +++ b/src/shop.c @@ -152,7 +152,7 @@ static const struct ListMenuTemplate sShopBuyMenuListTemplate = .lettersSpacing = 0, .itemVerticalPadding = 0, .scrollMultiple = LIST_NO_MULTIPLE_SCROLL, - .fontId = 7, + .fontId = FONT_NARROW, .cursorKind = 0 }; @@ -301,9 +301,9 @@ static u8 CreateShopMenu(u8 martType) SetStandardWindowBorderStyle(sMartInfo.windowId, 0); PrintMenuTable(sMartInfo.windowId, numMenuItems, sMartInfo.menuActions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sMartInfo.windowId, numMenuItems, 0); + InitMenuInUpperLeftCornerNormal(sMartInfo.windowId, numMenuItems, 0); PutWindowTilemap(sMartInfo.windowId); - CopyWindowToVram(sMartInfo.windowId, 1); + CopyWindowToVram(sMartInfo.windowId, COPYWIN_MAP); return CreateTask(Task_ShopMenu, 8); } @@ -576,8 +576,8 @@ static void BuyMenuPrintPriceInList(u8 windowId, u32 itemId, u8 y) } StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1); - x = GetStringRightAlignXOffset(7, gStringVar4, 0x78); - AddTextPrinterParameterized4(windowId, 7, x, y, 0, 0, sShopBuyMenuTextColors[1], -1, gStringVar4); + x = GetStringRightAlignXOffset(FONT_NARROW, gStringVar4, 0x78); + AddTextPrinterParameterized4(windowId, FONT_NARROW, x, y, 0, 0, sShopBuyMenuTextColors[1], TEXT_SKIP_DRAW, gStringVar4); } } @@ -692,12 +692,12 @@ static void BuyMenuInitWindows(void) static void BuyMenuPrint(u8 windowId, const u8 *text, u8 x, u8 y, s8 speed, u8 colorSet) { - AddTextPrinterParameterized4(windowId, 1, x, y, 0, 0, sShopBuyMenuTextColors[colorSet], speed, text); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, 0, 0, sShopBuyMenuTextColors[colorSet], speed, text); } static void BuyMenuDisplayMessage(u8 taskId, const u8 *text, TaskFunc callback) { - DisplayMessageAndContinueTask(taskId, 5, 10, 14, 1, GetPlayerTextSpeedDelay(), text, callback); + DisplayMessageAndContinueTask(taskId, 5, 10, 14, FONT_NORMAL, GetPlayerTextSpeedDelay(), text, callback); ScheduleBgCopyTilemapToVram(0); } @@ -1145,7 +1145,7 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId) s16 *data = gTasks[taskId].data; FillWindowPixelBuffer(4, PIXEL_FILL(1)); - PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SPEED_FF); + PrintMoneyAmount(4, 38, 1, sShopData->totalCost, TEXT_SKIP_DRAW); ConvertIntToDecimalStringN(gStringVar1, tItemCount, STR_CONV_MODE_LEADING_ZEROS, BAG_ITEM_CAPACITY_DIGITS); StringExpandPlaceholders(gStringVar4, gText_xVar1); BuyMenuPrint(4, gStringVar4, 0, 1, 0, 0); diff --git a/src/slot_machine.c b/src/slot_machine.c index af55e0d9b..1c21f230d 100644 --- a/src/slot_machine.c +++ b/src/slot_machine.c @@ -1253,8 +1253,8 @@ static bool8 SlotAction_HandleBetInput(struct Task *task) static bool8 SlotAction_PrintMsg_Need3Coins(struct Task *task) { DrawDialogueFrame(0, 0); - AddTextPrinterParameterized(0, 1, gText_YouDontHaveThreeCoins, 0, 1, 0, 0); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouDontHaveThreeCoins, 0, 1, 0, 0); + CopyWindowToVram(0, COPYWIN_FULL); sSlotMachine->state = SLOT_ACTION_WAIT_MSG_NEED_3_COINS; return FALSE; } @@ -1518,8 +1518,8 @@ static bool8 SlotAction_NoMatches(struct Task *task) static bool8 SlotAction_AskQuit(struct Task *task) { DrawDialogueFrame(0, 0); - AddTextPrinterParameterized(0, 1, gText_QuitTheGame, 0, 1, 0, 0); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_QuitTheGame, 0, 1, 0, 0); + CopyWindowToVram(0, COPYWIN_FULL); CreateYesNoMenuParameterized(0x15, 7, 0x214, 0x180, 0xE, 0xF); sSlotMachine->state = SLOT_ACTION_HANDLE_QUIT_INPUT; return FALSE; @@ -1550,8 +1550,8 @@ static bool8 SlotAction_HandleQuitInput(struct Task *task) static bool8 SlotAction_PrintMsg_9999Coins(struct Task *task) { DrawDialogueFrame(0, 0); - AddTextPrinterParameterized(0, 1, gText_YouveGot9999Coins, 0, 1, 0, 0); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouveGot9999Coins, 0, 1, 0, 0); + CopyWindowToVram(0, COPYWIN_FULL); sSlotMachine->state = SLOT_ACTION_WAIT_MSG_MAX_COINS; return FALSE; } @@ -1571,8 +1571,8 @@ static bool8 SlotAction_WaitMsg_9999Coins(struct Task *task) static bool8 SlotAction_PrintMsg_NoMoreCoins(struct Task *task) { DrawDialogueFrame(0, 0); - AddTextPrinterParameterized(0, 1, gText_YouveRunOutOfCoins, 0, 1, 0, 0); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_YouveRunOutOfCoins, 0, 1, 0, 0); + CopyWindowToVram(0, COPYWIN_FULL); sSlotMachine->state = SLOT_ACTION_WAIT_MSG_NO_MORE_COINS; return FALSE; } @@ -3444,8 +3444,8 @@ static void InfoBox_DrawWindow(struct Task *task) static void InfoBox_AddText(struct Task *task) { - AddTextPrinterParameterized3(1, 1, 2, 5, sColors_ReeltimeHelp, 0, gText_ReelTimeHelp); - CopyWindowToVram(1, 3); + AddTextPrinterParameterized3(1, FONT_NORMAL, 2, 5, sColors_ReeltimeHelp, 0, gText_ReelTimeHelp); + CopyWindowToVram(1, COPYWIN_FULL); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB(0, 0, 0)); task->tState++; } @@ -3456,7 +3456,7 @@ static void InfoBox_AwaitPlayerInput(struct Task *task) { FillWindowPixelBuffer(1, PIXEL_FILL(0)); ClearWindowTilemap(1); - CopyWindowToVram(1, 1); + CopyWindowToVram(1, COPYWIN_MAP); RemoveWindow(1); BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB(0, 0, 0)); task->tState++; diff --git a/src/start_menu.c b/src/start_menu.c index 59279d6b9..ef4c67832 100644 --- a/src/start_menu.c +++ b/src/start_menu.c @@ -251,7 +251,7 @@ static void BuildStartMenuActions(void) { sNumStartMenuActions = 0; - if (IsUpdateLinkStateCBActive() == TRUE) + if (IsOverworldLinkActive() == TRUE) { BuildLinkModeStartMenu(); } @@ -386,8 +386,8 @@ static void ShowSafariBallsWindow(void) DrawStdWindowFrame(sSafariBallsWindowId, FALSE); ConvertIntToDecimalStringN(gStringVar1, gNumSafariBalls, STR_CONV_MODE_RIGHT_ALIGN, 2); StringExpandPlaceholders(gStringVar4, gText_SafariBallStock); - AddTextPrinterParameterized(sSafariBallsWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL); - CopyWindowToVram(sSafariBallsWindowId, 2); + AddTextPrinterParameterized(sSafariBallsWindowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sSafariBallsWindowId, COPYWIN_GFX); } static void ShowPyramidFloorWindow(void) @@ -401,8 +401,8 @@ static void ShowPyramidFloorWindow(void) DrawStdWindowFrame(sBattlePyramidFloorWindowId, FALSE); StringCopy(gStringVar1, sPyramidFloorNames[gSaveBlock2Ptr->frontier.curChallengeBattleNum]); StringExpandPlaceholders(gStringVar4, gText_BattlePyramidFloor); - AddTextPrinterParameterized(sBattlePyramidFloorWindowId, 1, gStringVar4, 0, 1, 0xFF, NULL); - CopyWindowToVram(sBattlePyramidFloorWindowId, 2); + AddTextPrinterParameterized(sBattlePyramidFloorWindowId, FONT_NORMAL, gStringVar4, 0, 1, TEXT_SKIP_DRAW, NULL); + CopyWindowToVram(sBattlePyramidFloorWindowId, COPYWIN_GFX); } static void RemoveExtraStartMenuWindows(void) @@ -410,7 +410,7 @@ static void RemoveExtraStartMenuWindows(void) if (GetSafariZoneFlag()) { ClearStdWindowAndFrameToTransparent(sSafariBallsWindowId, FALSE); - CopyWindowToVram(sSafariBallsWindowId, 2); + CopyWindowToVram(sSafariBallsWindowId, COPYWIN_GFX); RemoveWindow(sSafariBallsWindowId); } if (InBattlePyramid()) @@ -433,7 +433,7 @@ static bool32 PrintStartMenuActions(s8 *pIndex, u32 count) else { StringExpandPlaceholders(gStringVar4, sStartMenuItems[sCurrentStartMenuActions[index]].text); - AddTextPrinterParameterized(GetStartMenuWindowId(), 1, gStringVar4, 8, (index << 4) + 9, 0xFF, NULL); + AddTextPrinterParameterized(GetStartMenuWindowId(), FONT_NORMAL, gStringVar4, 8, (index << 4) + 9, TEXT_SKIP_DRAW, NULL); } index++; @@ -466,7 +466,7 @@ static bool32 InitStartMenuStep(void) break; case 2: LoadMessageBoxAndBorderGfx(); - DrawStdWindowFrame(sub_81979C4(sNumStartMenuActions), FALSE); + DrawStdWindowFrame(AddStartMenuWindow(sNumStartMenuActions), FALSE); sInitStartMenuData[1] = 0; sInitStartMenuData[0]++; break; @@ -482,8 +482,8 @@ static bool32 InitStartMenuStep(void) sInitStartMenuData[0]++; break; case 5: - sStartMenuCursorPos = sub_81983AC(GetStartMenuWindowId(), 1, 0, 9, 16, sNumStartMenuActions, sStartMenuCursorPos); - CopyWindowToVram(GetStartMenuWindowId(), TRUE); + sStartMenuCursorPos = InitMenuNormal(GetStartMenuWindowId(), FONT_NORMAL, 0, 9, 16, sNumStartMenuActions, sStartMenuCursorPos); + CopyWindowToVram(GetStartMenuWindowId(), COPYWIN_MAP); return TRUE; } @@ -554,7 +554,7 @@ void Task_ShowStartMenu(u8 taskId) void ShowStartMenu(void) { - if (!IsUpdateLinkStateCBActive()) + if (!IsOverworldLinkActive()) { FreezeObjectEvents(); PlayerFreeze(); @@ -679,7 +679,7 @@ static bool8 StartMenuPlayerNameCallback(void) RemoveExtraStartMenuWindows(); CleanupOverworldWindowsAndTilemaps(); - if (IsUpdateLinkStateCBActive() || InUnionRoom()) + if (IsOverworldLinkActive() || InUnionRoom()) ShowPlayerTrainerCard(CB2_ReturnToFieldWithOpenMenu); // Display trainer card else if (FlagGet(FLAG_SYS_FRONTIER_PASS)) ShowFrontierPass(CB2_ReturnToFieldWithOpenMenu); // Display frontier pass @@ -876,7 +876,7 @@ void SaveGame(void) static void ShowSaveMessage(const u8 *message, u8 (*saveCallback)(void)) { StringExpandPlaceholders(gStringVar4, message); - sub_819786C(0, TRUE); + LoadMessageBoxAndFrameGfx(0, TRUE); AddTextPrinterForMessage_2(TRUE); sSavingComplete = TRUE; sSaveDialogCallback = saveCallback; @@ -1200,7 +1200,7 @@ static bool32 InitSaveWindowAfterLinkBattle(u8 *state) break; case 3: ShowBg(0); - BlendPalettes(-1, 16, 0); + BlendPalettes(PALETTES_ALL, 16, RGB_BLACK); SetVBlankCallback(VBlankCB_LinkBattleSave); EnableInterrupts(1); break; @@ -1238,16 +1238,16 @@ static void Task_SaveAfterLinkBattle(u8 taskId) case 0: FillWindowPixelBuffer(0, PIXEL_FILL(1)); AddTextPrinterParameterized2(0, - 1, + FONT_NORMAL, gText_SavingDontTurnOffPower, - TEXT_SPEED_FF, + TEXT_SKIP_DRAW, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY); DrawTextBorderOuter(0, 8, 14); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); if (gWirelessCommType != 0 && InUnionRoom()) @@ -1330,40 +1330,40 @@ static void ShowSaveInfoWindow(void) // Print region name yOffset = 1; BufferSaveMenuText(SAVE_MENU_LOCATION, gStringVar4, TEXT_COLOR_GREEN); - AddTextPrinterParameterized(sSaveInfoWindowId, 1, gStringVar4, 0, yOffset, 0xFF, NULL); + AddTextPrinterParameterized(sSaveInfoWindowId, FONT_NORMAL, gStringVar4, 0, yOffset, TEXT_SKIP_DRAW, NULL); // Print player name yOffset += 16; - AddTextPrinterParameterized(sSaveInfoWindowId, 1, gText_SavingPlayer, 0, yOffset, 0xFF, NULL); + AddTextPrinterParameterized(sSaveInfoWindowId, FONT_NORMAL, gText_SavingPlayer, 0, yOffset, TEXT_SKIP_DRAW, NULL); BufferSaveMenuText(SAVE_MENU_NAME, gStringVar4, color); - xOffset = GetStringRightAlignXOffset(1, gStringVar4, 0x70); + xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 0x70); PrintPlayerNameOnWindow(sSaveInfoWindowId, gStringVar4, xOffset, yOffset); // Print badge count yOffset += 16; - AddTextPrinterParameterized(sSaveInfoWindowId, 1, gText_SavingBadges, 0, yOffset, 0xFF, NULL); + AddTextPrinterParameterized(sSaveInfoWindowId, FONT_NORMAL, gText_SavingBadges, 0, yOffset, TEXT_SKIP_DRAW, NULL); BufferSaveMenuText(SAVE_MENU_BADGES, gStringVar4, color); - xOffset = GetStringRightAlignXOffset(1, gStringVar4, 0x70); - AddTextPrinterParameterized(sSaveInfoWindowId, 1, gStringVar4, xOffset, yOffset, 0xFF, NULL); + xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 0x70); + AddTextPrinterParameterized(sSaveInfoWindowId, FONT_NORMAL, gStringVar4, xOffset, yOffset, TEXT_SKIP_DRAW, NULL); if (FlagGet(FLAG_SYS_POKEDEX_GET) == TRUE) { // Print pokedex count yOffset += 16; - AddTextPrinterParameterized(sSaveInfoWindowId, 1, gText_SavingPokedex, 0, yOffset, 0xFF, NULL); + AddTextPrinterParameterized(sSaveInfoWindowId, FONT_NORMAL, gText_SavingPokedex, 0, yOffset, TEXT_SKIP_DRAW, NULL); BufferSaveMenuText(SAVE_MENU_CAUGHT, gStringVar4, color); - xOffset = GetStringRightAlignXOffset(1, gStringVar4, 0x70); - AddTextPrinterParameterized(sSaveInfoWindowId, 1, gStringVar4, xOffset, yOffset, 0xFF, NULL); + xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 0x70); + AddTextPrinterParameterized(sSaveInfoWindowId, FONT_NORMAL, gStringVar4, xOffset, yOffset, TEXT_SKIP_DRAW, NULL); } // Print play time yOffset += 16; - AddTextPrinterParameterized(sSaveInfoWindowId, 1, gText_SavingTime, 0, yOffset, 0xFF, NULL); + AddTextPrinterParameterized(sSaveInfoWindowId, FONT_NORMAL, gText_SavingTime, 0, yOffset, TEXT_SKIP_DRAW, NULL); BufferSaveMenuText(SAVE_MENU_PLAY_TIME, gStringVar4, color); - xOffset = GetStringRightAlignXOffset(1, gStringVar4, 0x70); - AddTextPrinterParameterized(sSaveInfoWindowId, 1, gStringVar4, xOffset, yOffset, 0xFF, NULL); + xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 0x70); + AddTextPrinterParameterized(sSaveInfoWindowId, FONT_NORMAL, gStringVar4, xOffset, yOffset, TEXT_SKIP_DRAW, NULL); - CopyWindowToVram(sSaveInfoWindowId, 2); + CopyWindowToVram(sSaveInfoWindowId, COPYWIN_GFX); } static void RemoveSaveInfoWindow(void) diff --git a/src/starter_choose.c b/src/starter_choose.c index d14846130..403964684 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -389,14 +389,14 @@ void CB2_ChooseStarter(void) SetGpuReg(REG_OFFSET_BG1CNT, 0); SetGpuReg(REG_OFFSET_BG0CNT, 0); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); DmaFill16(3, 0, VRAM, VRAM_SIZE); DmaFill32(3, 0, OAM, OAM_SIZE); @@ -480,7 +480,7 @@ static void Task_StarterChoose(u8 taskId) { CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection); DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x2A8, 0xD); - AddTextPrinterParameterized(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_BirchInTrouble, 0, 1, 0, NULL); PutWindowTilemap(0); ScheduleBgCopyTilemapToVram(0); gTasks[taskId].func = Task_HandleStarterChooseInput; @@ -534,7 +534,7 @@ static void Task_AskConfirmStarter(u8 taskId) { PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_ConfirmStarterChoice, 0, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); CreateYesNoMenu(&sWindowTemplate_ConfirmStarter, 0x2A8, 0xD, 0); gTasks[taskId].func = Task_HandleConfirmStarterInput; @@ -591,11 +591,11 @@ static void CreateStarterPokemonLabel(u8 selection) sStarterLabelWindowId = AddWindow(&winTemplate); FillWindowPixelBuffer(sStarterLabelWindowId, PIXEL_FILL(0)); - width = GetStringCenterAlignXOffset(7, categoryText, 0x68); - AddTextPrinterParameterized3(sStarterLabelWindowId, 7, width, 1, sTextColors, 0, categoryText); + width = GetStringCenterAlignXOffset(FONT_NARROW, categoryText, 0x68); + AddTextPrinterParameterized3(sStarterLabelWindowId, FONT_NARROW, width, 1, sTextColors, 0, categoryText); - width = GetStringCenterAlignXOffset(1, speciesName, 0x68); - AddTextPrinterParameterized3(sStarterLabelWindowId, 1, width, 17, sTextColors, 0, speciesName); + width = GetStringCenterAlignXOffset(FONT_NORMAL, speciesName, 0x68); + AddTextPrinterParameterized3(sStarterLabelWindowId, FONT_NORMAL, width, 17, sTextColors, 0, speciesName); PutWindowTilemap(sStarterLabelWindowId); ScheduleBgCopyTilemapToVram(0); diff --git a/src/strings.c b/src/strings.c index ae39e3d4d..3785766ce 100644 --- a/src/strings.c +++ b/src/strings.c @@ -839,17 +839,17 @@ const u8 gText_B4F[] = _("B4F"); const u8 gText_Rooftop[] = _("ROOFTOP"); const u8 gText_ElevatorNowOn[] = _("Now on:"); const u8 gText_BP[] = _("BP"); -const u8 gText_EnergyPowder50[] = _("ENERGYPOWDER{CLEAR_TO 0x72}{FONT 0}50"); -const u8 gText_EnergyRoot80[] = _("ENERGY ROOT{CLEAR_TO 0x72}{FONT 0}80"); -const u8 gText_HealPowder50[] = _("HEAL POWDER{CLEAR_TO 0x72}{FONT 0}50"); -const u8 gText_RevivalHerb300[] = _("REVIVAL HERB{CLEAR_TO 0x6C}{FONT 0}300"); -const u8 gText_Protein1000[] = _("PROTEIN{CLEAR_TO 0x63}{FONT 0}1,000"); -const u8 gText_Iron1000[] = _("IRON{CLEAR_TO 0x63}{FONT 0}1,000"); -const u8 gText_Carbos1000[] = _("CARBOS{CLEAR_TO 0x63}{FONT 0}1,000"); -const u8 gText_Calcium1000[] = _("CALCIUM{CLEAR_TO 0x63}{FONT 0}1,000"); -const u8 gText_Zinc1000[] = _("ZINC{CLEAR_TO 0x63}{FONT 0}1,000"); -const u8 gText_HPUp1000[] = _("HP UP{CLEAR_TO 0x63}{FONT 0}1,000"); -const u8 gText_PPUp3000[] = _("PP UP{CLEAR_TO 0x63}{FONT 0}3,000"); +const u8 gText_EnergyPowder50[] = _("ENERGYPOWDER{CLEAR_TO 114}{FONT_SMALL}50"); +const u8 gText_EnergyRoot80[] = _("ENERGY ROOT{CLEAR_TO 114}{FONT_SMALL}80"); +const u8 gText_HealPowder50[] = _("HEAL POWDER{CLEAR_TO 114}{FONT_SMALL}50"); +const u8 gText_RevivalHerb300[] = _("REVIVAL HERB{CLEAR_TO 108}{FONT_SMALL}300"); +const u8 gText_Protein1000[] = _("PROTEIN{CLEAR_TO 99}{FONT_SMALL}1,000"); +const u8 gText_Iron1000[] = _("IRON{CLEAR_TO 99}{FONT_SMALL}1,000"); +const u8 gText_Carbos1000[] = _("CARBOS{CLEAR_TO 99}{FONT_SMALL}1,000"); +const u8 gText_Calcium1000[] = _("CALCIUM{CLEAR_TO 99}{FONT_SMALL}1,000"); +const u8 gText_Zinc1000[] = _("ZINC{CLEAR_TO 99}{FONT_SMALL}1,000"); +const u8 gText_HPUp1000[] = _("HP UP{CLEAR_TO 99}{FONT_SMALL}1,000"); +const u8 gText_PPUp3000[] = _("PP UP{CLEAR_TO 99}{FONT_SMALL}3,000"); const u8 gText_RankingHall[] = _("RANKING HALL"); const u8 gText_ExchangeService[] = _("EXCHANGE SERVICE"); const u8 gText_LilycoveCity[] = _("LILYCOVE CITY"); diff --git a/src/text_window.c b/src/text_window.c index 864bd0831..798b791ce 100644 --- a/src/text_window.c +++ b/src/text_window.c @@ -6,7 +6,6 @@ #include "bg.h" #include "graphics.h" -// const rom data const u8 gTextWindowFrame1_Gfx[] = INCBIN_U8("graphics/text_window/1.4bpp"); static const u8 sTextWindowFrame2_Gfx[] = INCBIN_U8("graphics/text_window/2.4bpp"); static const u8 sTextWindowFrame3_Gfx[] = INCBIN_U8("graphics/text_window/3.4bpp"); @@ -190,7 +189,8 @@ const u16 *GetOverworldTextboxPalettePtr(void) return gMessageBox_Pal; } -void sub_8098C6C(u8 bg, u16 destOffset, u8 palOffset) +// Effectively LoadUserWindowBorderGfx but specifying the bg directly instead of a window from that bg +void LoadUserWindowBorderGfxOnBg(u8 bg, u16 destOffset, u8 palOffset) { LoadBgTiles(bg, sWindowFrames[gSaveBlock2Ptr->optionsWindowFrameType].tiles, 0x120, destOffset); LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, palOffset, 0x20); diff --git a/src/tileset_anims.c b/src/tileset_anims.c index f566fe3e0..71f8044f9 100644 --- a/src/tileset_anims.c +++ b/src/tileset_anims.c @@ -1169,7 +1169,7 @@ static void BlendAnimPalette_BattleDome_FloorLights(u16 timer) { CpuCopy16(gTilesetAnims_BattleDomeFloorLightPals[timer % 4], gPlttBufferUnfaded + 0x80, 32); BlendPalette(0x80, 16, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); - if ((u8)FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) != TASK_NONE) + if ((u8)FindTaskIdByFunc(Task_BattleTransition_Intro) != TASK_NONE) { sSecondaryTilesetAnimCallback = TilesetAnim_BattleDome2; sSecondaryTilesetAnimCounterMax = 32; @@ -1179,7 +1179,7 @@ static void BlendAnimPalette_BattleDome_FloorLights(u16 timer) static void BlendAnimPalette_BattleDome_FloorLightsNoBlend(u16 timer) { CpuCopy16(gTilesetAnims_BattleDomeFloorLightPals[timer % 4], gPlttBufferUnfaded + 0x80, 32); - if ((u8)FindTaskIdByFunc(TransitionPhase1_Task_RunFuncs) == TASK_NONE) + if ((u8)FindTaskIdByFunc(Task_BattleTransition_Intro) == TASK_NONE) { BlendPalette(0x80, 16, gPaletteFade.y, gPaletteFade.blendColor & 0x7FFF); if (!--sSecondaryTilesetAnimCounterMax) diff --git a/src/title_screen.c b/src/title_screen.c index ee71b6895..93e01327c 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -547,14 +547,14 @@ void CB2_InitTitleScreen(void) case 1: // bg2 LZ77UnCompVram(gTitleScreenPokemonLogoGfx, (void *)(BG_CHAR_ADDR(0))); - LZ77UnCompVram(gUnknown_08DE0644, (void *)(BG_SCREEN_ADDR(9))); + LZ77UnCompVram(gTitleScreenPokemonLogoTilemap, (void *)(BG_SCREEN_ADDR(9))); LoadPalette(gTitleScreenBgPalettes, 0, 0x1E0); // bg3 LZ77UnCompVram(sTitleScreenRayquazaGfx, (void *)(BG_CHAR_ADDR(2))); LZ77UnCompVram(sTitleScreenRayquazaTilemap, (void *)(BG_SCREEN_ADDR(26))); // bg1 LZ77UnCompVram(sTitleScreenCloudsGfx, (void *)(BG_CHAR_ADDR(3))); - LZ77UnCompVram(gUnknown_08DDE458, (void *)(BG_SCREEN_ADDR(27))); + LZ77UnCompVram(gTitleScreenCloudsTilemap, (void *)(BG_SCREEN_ADDR(27))); ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); diff --git a/src/trade.c b/src/trade.c index be2091ece..4089cf1df 100644 --- a/src/trade.c +++ b/src/trade.c @@ -334,8 +334,8 @@ static void InitTradeMenu(void) gPaletteFade.bufferTransferDisabled = TRUE; SetVBlankCallback(VBlankCB_TradeMenu); - LoadPalette(gUnknown_0860F074, 0xF0, 20); - LoadPalette(gUnknown_0860F074, 0xD0, 20); + LoadPalette(gStandardMenuPalette, 0xF0, 20); + LoadPalette(gStandardMenuPalette, 0xD0, 20); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sTradeMenuBgTemplates, ARRAY_COUNT(sTradeMenuBgTemplates)); SetBgTilemapBuffer(1, sTradeMenuData->tilemapBuffer); @@ -542,7 +542,7 @@ static void CB2_CreateTradeMenu(void) break; case 12: // Create player's name text sprites - xPos = GetStringCenterAlignXOffset(1, gSaveBlock2Ptr->playerName, 120); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, gSaveBlock2Ptr->playerName, 120); for (i = 0; i < GFXTAG_PLAYER_NAME; i++) { temp = sSpriteTemplate_MenuText; @@ -551,7 +551,7 @@ static void CB2_CreateTradeMenu(void) } // Create partner's name text sprites - xPos = GetStringCenterAlignXOffset(1, gLinkPlayers[GetMultiplayerId() ^ 1].name, 120); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, gLinkPlayers[GetMultiplayerId() ^ 1].name, 120); for (i = 0; i < GFXTAG_PARTNER_NAME; i++) { temp = sSpriteTemplate_MenuText; @@ -733,7 +733,7 @@ static void CB2_ReturnToTradeMenu(void) break; case 12: // Create player's name text sprites - xPos = GetStringCenterAlignXOffset(1, gSaveBlock2Ptr->playerName, 120); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, gSaveBlock2Ptr->playerName, 120); for (i = 0; i < GFXTAG_PLAYER_NAME; i++) { temp = sSpriteTemplate_MenuText; @@ -742,7 +742,7 @@ static void CB2_ReturnToTradeMenu(void) } // Create partner's name text sprites - xPos = GetStringCenterAlignXOffset(1, gLinkPlayers[GetMultiplayerId() ^ 1].name, 120); + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, gLinkPlayers[GetMultiplayerId() ^ 1].name, 120); for (i = 0; i < GFXTAG_PARTNER_NAME; i++) { temp = sSpriteTemplate_MenuText; @@ -913,7 +913,7 @@ static void LoadTradeBgGfx(u8 state) case 0: LoadPalette(gTradeMenu_Pal, 0, 0x60); LoadBgTiles(1, gTradeMenu_Gfx, 0x1280, 0); - CopyToBgTilemapBufferRect_ChangePalette(1, gUnknown_08DDCF04, 0, 0, 32, 20, 0); + CopyToBgTilemapBufferRect_ChangePalette(1, gTradeMenu_Tilemap, 0, 0, 32, 20, 0); LoadBgTilemap(2, sTradeStripesBG2Tilemap, 0x800, 0); break; case 1: @@ -924,9 +924,7 @@ static void LoadTradeBgGfx(u8 state) break; case 2: for (i = 0; i < 4; i++) - { SetGpuReg(REG_OFFSET_BG0HOFS + (i * 2), 0); - } ShowBg(0); ShowBg(1); ShowBg(2); @@ -1397,9 +1395,9 @@ static void TradeMenuProcessInput(void) DrawTextBorderOuter(1, 1, 14); FillWindowPixelBuffer(1, PIXEL_FILL(1)); PrintMenuTable(1, ARRAY_COUNT(sSelectTradeMonActions), sSelectTradeMonActions); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(1, 2, 0); + InitMenuInUpperLeftCornerNormal(1, 2, 0); PutWindowTilemap(1); - CopyWindowToVram(1, 3); + CopyWindowToVram(1, COPYWIN_FULL); sTradeMenuData->tradeMenuFunc = TRADEMENUFUNC_SELECTED_MON; } // Cursor is in partner's party @@ -1586,7 +1584,7 @@ static void RestoreNicknamesCoveredByYesNo(void) for (i = 0; i < sTradeMenuData->partyCounts[1] - 4; i++) { PutWindowTilemap(i + 12); - CopyWindowToVram(i + 12, 1); + CopyWindowToVram(i + 12, COPYWIN_MAP); } } @@ -1853,13 +1851,13 @@ static void DrawTradeMenuParty(u8 whichParty) gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].x2 = 0; gSprites[sTradeMenuData->partySpriteIds[0][partyIdx + (selectedMonParty * PARTY_SIZE)]].y2 = 0; nameStringWidth = GetMonNicknameWidth(nickname, selectedMonParty, partyIdx); - AddTextPrinterParameterized3((whichParty * 2) + 14, 0, (80 - nameStringWidth) / 2, 4, sTradeTextColors, 0, nickname); + AddTextPrinterParameterized3((whichParty * 2) + 14, FONT_SMALL, (80 - nameStringWidth) / 2, 4, sTradeTextColors, 0, nickname); BufferTradeMonMoves(movesString, selectedMonParty, partyIdx); - AddTextPrinterParameterized4((whichParty * 2) + 15, 1, 0, 0, 0, 0, sTradeTextColors, 0, movesString); + AddTextPrinterParameterized4((whichParty * 2) + 15, FONT_NORMAL, 0, 0, 0, 0, sTradeTextColors, 0, movesString); PutWindowTilemap((whichParty * 2) + 14); - CopyWindowToVram((whichParty * 2) + 14, 3); + CopyWindowToVram((whichParty * 2) + 14, COPYWIN_FULL); PutWindowTilemap((whichParty * 2) + 15); - CopyWindowToVram((whichParty * 2) + 15, 3); + CopyWindowToVram((whichParty * 2) + 15, COPYWIN_FULL); sTradeMenuData->drawPartyState[whichParty]++; break; case 4: @@ -1883,7 +1881,7 @@ static u8 GetMonNicknameWidth(u8 *str, u8 whichParty, u8 monIdx) GetMonData(&gEnemyParty[monIdx], MON_DATA_NICKNAME, nickname); StringCopy10(str, nickname); - return GetStringWidth(0, str, GetFontAttribute(0, FONTATTR_LETTER_SPACING)); + return GetStringWidth(FONT_SMALL, str, GetFontAttribute(FONT_SMALL, FONTATTR_LETTER_SPACING)); } static void BufferTradeMonMoves(u8 *str, u8 whichParty, u8 partyIdx) @@ -1928,10 +1926,10 @@ static void PrintMonNicknameForTradeMenu(u8 whichParty, u8 windowId, u8 *nicknam { u8 xPos; windowId += (whichParty * PARTY_SIZE) + 2; - xPos = GetStringCenterAlignXOffset(0, nickname, 64); - AddTextPrinterParameterized3(windowId, 0, xPos, 4, sTradeTextColors, 0, nickname); + xPos = GetStringCenterAlignXOffset(FONT_SMALL, nickname, 64); + AddTextPrinterParameterized3(windowId, FONT_SMALL, xPos, 4, sTradeTextColors, 0, nickname); PutWindowTilemap(windowId); - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } static void PrintPartyNicknamesForTradeMenu(u8 whichParty) @@ -2155,10 +2153,10 @@ static void DoQueuedActions(void) static void PrintTradeMessage(u8 messageId) { FillWindowPixelBuffer(0, PIXEL_FILL(1)); - AddTextPrinterParameterized(0, 1, sTradeMessages[messageId], 0, 1, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, sTradeMessages[messageId], 0, 1, TEXT_SKIP_DRAW, NULL); DrawTextBorderOuter(0, 20, 12); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } static bool8 LoadTradeMenuSpriteSheetsAndPalettes(void) @@ -2901,7 +2899,7 @@ void LinkTradeDrawWindow(void) { FillWindowPixelBuffer(0, PIXEL_FILL(15)); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } static void InitTradeBgInternal(void) @@ -2909,8 +2907,8 @@ static void InitTradeBgInternal(void) SetGpuReg(REG_OFFSET_DISPCNT, 0); ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sTradeSequenceBgTemplates, ARRAY_COUNT(sTradeSequenceBgTemplates)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); SetBgTilemapBuffer(0, Alloc(BG_SCREEN_SIZE)); SetBgTilemapBuffer(1, Alloc(BG_SCREEN_SIZE)); SetBgTilemapBuffer(3, Alloc(BG_SCREEN_SIZE)); @@ -2978,7 +2976,7 @@ static void CB2_InGameTrade(void) LoadTradeMonPic(TRADE_PARTNER, 1); FillWindowPixelBuffer(0, PIXEL_FILL(15)); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); gMain.state++; break; case 9: @@ -3435,7 +3433,7 @@ static bool8 AnimateTradeSequenceCable(void) { SetTradeSequenceBgGpuRegs(4); FillWindowPixelBuffer(0, PIXEL_FILL(15)); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); sTradeData->state++; } break; @@ -3906,7 +3904,7 @@ static bool8 AnimateTradeSequenceWireless(void) { SetTradeSequenceBgGpuRegs(4); FillWindowPixelBuffer(0, PIXEL_FILL(15)); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); sTradeData->state++; } break; @@ -4835,8 +4833,8 @@ void DrawTextOnTradeWindow(u8 windowId, const u8 *str, u8 speed) sTradeData->textColors[0] = TEXT_DYNAMIC_COLOR_6; sTradeData->textColors[1] = TEXT_COLOR_WHITE; sTradeData->textColors[2] = TEXT_COLOR_GREEN; - AddTextPrinterParameterized4(windowId, 1, 0, 2, 0, 0, sTradeData->textColors, speed, str); - CopyWindowToVram(windowId, 3); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, 0, 2, 0, 0, sTradeData->textColors, speed, str); + CopyWindowToVram(windowId, COPYWIN_FULL); } #define idx data[0] diff --git a/src/trader.c b/src/trader.c index 98b4f464c..1d4424e75 100644 --- a/src/trader.c +++ b/src/trader.c @@ -59,15 +59,15 @@ void CreateAvailableDecorationsMenu(u8 taskId) s16 * data = gTasks[taskId].data; struct MauvilleOldManTrader *trader = &gSaveBlock1Ptr->oldMan.trader; struct WindowTemplate windowTemplate = {0, 1, 1, 10, 10, 15, 1}; - s32 windowWidth = GetStringWidth(1, gText_Exit, 0); - s32 fiveMarksWidth = GetStringWidth(1, gText_FiveMarks, 0); + s32 windowWidth = GetStringWidth(FONT_NORMAL, gText_Exit, 0); + s32 fiveMarksWidth = GetStringWidth(FONT_NORMAL, gText_FiveMarks, 0); for (i = 0; i < 4; i++) { s32 curWidth; if (trader->decorations[i] > NUM_DECORATIONS) curWidth = fiveMarksWidth; else - curWidth = GetStringWidth(1, gDecorations[trader->decorations[i]].name, 0); + curWidth = GetStringWidth(FONT_NORMAL, gDecorations[trader->decorations[i]].name, 0); if (curWidth > windowWidth) windowWidth = curWidth; } @@ -77,12 +77,12 @@ void CreateAvailableDecorationsMenu(u8 taskId) for (i = 0; i < 4; i++) { if (trader->decorations[i] > NUM_DECORATIONS) - AddTextPrinterParameterized(data[3], 1, gText_FiveMarks, 8, 16 * i + 1, 255, NULL); + AddTextPrinterParameterized(data[3], FONT_NORMAL, gText_FiveMarks, 8, 16 * i + 1, 255, NULL); else - AddTextPrinterParameterized(data[3], 1, gDecorations[trader->decorations[i]].name, 8, 16 * i + 1, 255, NULL); + AddTextPrinterParameterized(data[3], FONT_NORMAL, gDecorations[trader->decorations[i]].name, 8, 16 * i + 1, 255, NULL); } - AddTextPrinterParameterized(data[3], 1, gText_Exit, 8, 16 * i + 1, 255, NULL); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(data[3], 5, 0); + AddTextPrinterParameterized(data[3], FONT_NORMAL, gText_Exit, 8, 16 * i + 1, 255, NULL); + InitMenuInUpperLeftCornerNormal(data[3], 5, 0); ScheduleBgCopyTilemapToVram(0); } diff --git a/src/trainer_card.c b/src/trainer_card.c index bad015644..264f15742 100755 --- a/src/trainer_card.c +++ b/src/trainer_card.c @@ -456,7 +456,7 @@ static void Task_TrainerCard(u8 taskId) } break; case STATE_WAIT_FLIP_TO_BACK: - if (IsCardFlipTaskActive() && Overworld_LinkRecvQueueLengthMoreThan2() != TRUE) + if (IsCardFlipTaskActive() && Overworld_IsRecvQueueAtMax() != TRUE) { PlaySE(SE_RG_CARD_OPEN); sData->mainState = STATE_HANDLE_INPUT_BACK; @@ -497,8 +497,8 @@ static void Task_TrainerCard(u8 taskId) case STATE_WAIT_LINK_PARTNER: SetCloseLinkCallback(); DrawDialogueFrame(0, 1); - AddTextPrinterParameterized(0, 1, gText_WaitingTrainerFinishReading, 0, 1, 255, 0); - CopyWindowToVram(0, 3); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_WaitingTrainerFinishReading, 0, 1, 255, 0); + CopyWindowToVram(0, COPYWIN_FULL); sData->mainState = STATE_CLOSE_CARD_LINK; break; case STATE_CLOSE_CARD_LINK: @@ -513,7 +513,7 @@ static void Task_TrainerCard(u8 taskId) CloseTrainerCard(taskId); break; case STATE_WAIT_FLIP_TO_FRONT: - if (IsCardFlipTaskActive() && Overworld_LinkRecvQueueLengthMoreThan2() != TRUE) + if (IsCardFlipTaskActive() && Overworld_IsRecvQueueAtMax() != TRUE) { sData->mainState = STATE_HANDLE_INPUT_FRONT; PlaySE(SE_RG_CARD_OPEN); @@ -884,14 +884,14 @@ static void InitBgsAndWindows(void) { ResetBgsAndClearDma3BusyFlags(0); InitBgsFromTemplates(0, sTrainerCardBgTemplates, ARRAY_COUNT(sTrainerCardBgTemplates)); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); InitWindows(sTrainerCardWindowTemplates); DeactivateAllTextPrinters(); LoadMessageBoxAndBorderGfx(); @@ -1001,9 +1001,9 @@ static void PrintNameOnCardFront(void) StringCopy(txtPtr, sData->trainerCard.playerName); ConvertInternationalString(txtPtr, sData->language); if (sData->cardType == CARD_TYPE_FRLG) - AddTextPrinterParameterized3(1, 1, 20, 28, sTrainerCardTextColors, TEXT_SPEED_FF, buffer); + AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 28, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer); else - AddTextPrinterParameterized3(1, 1, 16, 33, sTrainerCardTextColors, TEXT_SPEED_FF, buffer); + AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer); } static void PrintIdOnCard(void) @@ -1016,16 +1016,16 @@ static void PrintIdOnCard(void) ConvertIntToDecimalStringN(txtPtr, sData->trainerCard.trainerId, STR_CONV_MODE_LEADING_ZEROS, 5); if (sData->cardType == CARD_TYPE_FRLG) { - xPos = GetStringCenterAlignXOffset(1, buffer, 80) + 132; + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, buffer, 80) + 132; top = 9; } else { - xPos = GetStringCenterAlignXOffset(1, buffer, 96) + 120; + xPos = GetStringCenterAlignXOffset(FONT_NORMAL, buffer, 96) + 120; top = 9; } - AddTextPrinterParameterized3(1, 1, xPos, top, sTrainerCardTextColors, TEXT_SPEED_FF, buffer); + AddTextPrinterParameterized3(1, FONT_NORMAL, xPos, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer); } static void PrintMoneyOnCard(void) @@ -1034,23 +1034,23 @@ static void PrintMoneyOnCard(void) u8 top; if (!sData->isHoenn) - AddTextPrinterParameterized3(1, 1, 20, 56, sTrainerCardTextColors, TEXT_SPEED_FF, gText_TrainerCardMoney); + AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 56, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney); else - AddTextPrinterParameterized3(1, 1, 16, 57, sTrainerCardTextColors, TEXT_SPEED_FF, gText_TrainerCardMoney); + AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 57, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney); ConvertIntToDecimalStringN(gStringVar1, sData->trainerCard.money, STR_CONV_MODE_LEFT_ALIGN, 6); StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1); if (!sData->isHoenn) { - xOffset = GetStringRightAlignXOffset(1, gStringVar4, 144); + xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 144); top = 56; } else { - xOffset = GetStringRightAlignXOffset(1, gStringVar4, 128); + xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 128); top = 57; } - AddTextPrinterParameterized3(1, 1, xOffset, top, sTrainerCardTextColors, TEXT_SPEED_FF, gStringVar4); + AddTextPrinterParameterized3(1, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4); } static u16 GetCaughtMonsCount(void) @@ -1068,21 +1068,21 @@ static void PrintPokedexOnCard(void) if (FlagGet(FLAG_SYS_POKEDEX_GET)) { if (!sData->isHoenn) - AddTextPrinterParameterized3(1, 1, 20, 72, sTrainerCardTextColors, TEXT_SPEED_FF, gText_TrainerCardPokedex); + AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 72, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex); else - AddTextPrinterParameterized3(1, 1, 16, 73, sTrainerCardTextColors, TEXT_SPEED_FF, gText_TrainerCardPokedex); + AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 73, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex); StringCopy(ConvertIntToDecimalStringN(gStringVar4, sData->trainerCard.caughtMonsCount, STR_CONV_MODE_LEFT_ALIGN, 3), gText_EmptyString6); if (!sData->isHoenn) { - xOffset = GetStringRightAlignXOffset(1, gStringVar4, 144); + xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 144); top = 72; } else { - xOffset = GetStringRightAlignXOffset(1, gStringVar4, 128); + xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 128); top = 73; } - AddTextPrinterParameterized3(1, 1, xOffset, top, sTrainerCardTextColors, TEXT_SPEED_FF, gStringVar4); + AddTextPrinterParameterized3(1, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4); } } @@ -1096,9 +1096,9 @@ static void PrintTimeOnCard(void) u32 x, y, totalWidth; if (!sData->isHoenn) - AddTextPrinterParameterized3(1, 1, 20, 88, sTrainerCardTextColors, TEXT_SPEED_FF, gText_TrainerCardTime); + AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 88, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime); else - AddTextPrinterParameterized3(1, 1, 16, 89, sTrainerCardTextColors, TEXT_SPEED_FF, gText_TrainerCardTime); + AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 89, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime); if (sData->isLink) { @@ -1115,7 +1115,7 @@ static void PrintTimeOnCard(void) hours = 999; if (minutes > 59) minutes = 59; - width = GetStringWidth(1, gText_Colon2, 0); + width = GetStringWidth(FONT_NORMAL, gText_Colon2, 0); if (!sData->isHoenn) { @@ -1132,12 +1132,12 @@ static void PrintTimeOnCard(void) FillWindowPixelRect(1, PIXEL_FILL(0), x, y, totalWidth, 15); ConvertIntToDecimalStringN(gStringVar4, hours, STR_CONV_MODE_RIGHT_ALIGN, 3); - AddTextPrinterParameterized3(1, 1, x, y, sTrainerCardTextColors, TEXT_SPEED_FF, gStringVar4); + AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4); x += 18; - AddTextPrinterParameterized3(1, 1, x, y, sTimeColonTextColors[sData->timeColonInvisible], TEXT_SPEED_FF, gText_Colon2); + AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTimeColonTextColors[sData->timeColonInvisible], TEXT_SKIP_DRAW, gText_Colon2); x += width; ConvertIntToDecimalStringN(gStringVar4, minutes, STR_CONV_MODE_LEADING_ZEROS, 2); - AddTextPrinterParameterized3(1, 1, x, y, sTrainerCardTextColors, TEXT_SPEED_FF, gStringVar4); + AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4); } static void PrintProfilePhraseOnCard(void) @@ -1147,10 +1147,10 @@ static void PrintProfilePhraseOnCard(void) if (sData->isLink) { - AddTextPrinterParameterized3(1, 1, 8, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SPEED_FF, sData->easyChatProfile[0]); - AddTextPrinterParameterized3(1, 1, GetStringWidth(1, sData->easyChatProfile[0], 0) + 14, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SPEED_FF, sData->easyChatProfile[1]); - AddTextPrinterParameterized3(1, 1, 8, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SPEED_FF, sData->easyChatProfile[2]); - AddTextPrinterParameterized3(1, 1, GetStringWidth(1, sData->easyChatProfile[2], 0) + 14, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SPEED_FF, sData->easyChatProfile[3]); + AddTextPrinterParameterized3(1, FONT_NORMAL, 8, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[0]); + AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[0], 0) + 14, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[1]); + AddTextPrinterParameterized3(1, FONT_NORMAL, 8, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[2]); + AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[2], 0) + 14, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[3]); } } @@ -1168,9 +1168,9 @@ static void BufferNameForCardBack(void) static void PrintNameOnCardBack(void) { if (!sData->isHoenn) - AddTextPrinterParameterized3(1, 1, 136, 9, sTrainerCardTextColors, TEXT_SPEED_FF, sData->textPlayersCard); + AddTextPrinterParameterized3(1, FONT_NORMAL, 136, 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard); else - AddTextPrinterParameterized3(1, 1, GetStringRightAlignXOffset(1, sData->textPlayersCard, 216), 9, sTrainerCardTextColors, TEXT_SPEED_FF, sData->textPlayersCard); + AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, sData->textPlayersCard, 216), 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard); } static const u8 sText_HofTime[] = _("{STR_VAR_1}:{STR_VAR_2}:{STR_VAR_3}"); @@ -1191,8 +1191,8 @@ static void PrintStatOnBackOfCard(u8 top, const u8* statName, u8* stat, const u8 static const u8 xOffsets[] = {8, 16}; static const u8 widths[] = {216, 216}; - AddTextPrinterParameterized3(1, 1, xOffsets[sData->isHoenn], top * 16 + 33, sTrainerCardTextColors, TEXT_SPEED_FF, statName); - AddTextPrinterParameterized3(1, 1, GetStringRightAlignXOffset(1, stat, widths[sData->isHoenn]), top * 16 + 33, color, TEXT_SPEED_FF, stat); + AddTextPrinterParameterized3(1, FONT_NORMAL, xOffsets[sData->isHoenn], top * 16 + 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, statName); + AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, stat, widths[sData->isHoenn]), top * 16 + 33, color, TEXT_SKIP_DRAW, stat); } static void PrintHofDebutTimeOnCard(void) @@ -1408,7 +1408,7 @@ static void LoadStickerGfx(void) static void DrawTrainerCardWindow(u8 windowId) { PutWindowTilemap(windowId); - CopyWindowToVram(windowId, 3); + CopyWindowToVram(windowId, COPYWIN_FULL); } static u8 SetCardBgsAndPals(void) @@ -1663,7 +1663,7 @@ static bool8 Task_AnimateCardFlipDown(struct Task* task) static bool8 Task_DrawFlippedCardSide(struct Task* task) { sData->allowDMACopy = FALSE; - if (Overworld_LinkRecvQueueLengthMoreThan2() == TRUE) + if (Overworld_IsRecvQueueAtMax() == TRUE) return FALSE; do diff --git a/src/trainer_hill.c b/src/trainer_hill.c index 34fa24f74..2c34f196e 100644 --- a/src/trainer_hill.c +++ b/src/trainer_hill.c @@ -590,13 +590,13 @@ void PrintOnTrainerHillRecordsWindow(void) SetUpDataStruct(); FillWindowPixelBuffer(0, PIXEL_FILL(0)); - x = GetStringCenterAlignXOffset(1, gText_TimeBoard, 0xD0); - AddTextPrinterParameterized3(0, 1, x, 2, sRecordWinColors, TEXT_SPEED_FF, gText_TimeBoard); + x = GetStringCenterAlignXOffset(FONT_NORMAL, gText_TimeBoard, 0xD0); + AddTextPrinterParameterized3(0, FONT_NORMAL, x, 2, sRecordWinColors, TEXT_SKIP_DRAW, gText_TimeBoard); y = 18; for (i = 0; i < 4; i++) { - AddTextPrinterParameterized3(0, 1, 0, y, sRecordWinColors, TEXT_SPEED_FF, sTagMatchStrings[i]); + AddTextPrinterParameterized3(0, FONT_NORMAL, 0, y, sRecordWinColors, TEXT_SKIP_DRAW, sTagMatchStrings[i]); y += 15; total = GetTimerValue(&gSaveBlock1Ptr->trainerHillTimes[i]); minutes = total / (60 * 60); @@ -608,13 +608,13 @@ void PrintOnTrainerHillRecordsWindow(void) secondsFraction = (total * 168) / 100; ConvertIntToDecimalStringN(gStringVar3, secondsFraction, STR_CONV_MODE_LEADING_ZEROS, 2); StringExpandPlaceholders(StringCopy(gStringVar4, gText_TimeCleared), gText_XMinYDotZSec); - x = GetStringRightAlignXOffset(1, gStringVar4, 0xD0); - AddTextPrinterParameterized3(0, 1, x, y, sRecordWinColors, TEXT_SPEED_FF, gStringVar4); + x = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 0xD0); + AddTextPrinterParameterized3(0, FONT_NORMAL, x, y, sRecordWinColors, TEXT_SKIP_DRAW, gStringVar4); y += 17; } PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); FreeDataStruct(); } diff --git a/src/union_room.c b/src/union_room.c index 18cb02c33..1400a0b1d 100644 --- a/src/union_room.c +++ b/src/union_room.c @@ -306,7 +306,7 @@ static void PrintNumPlayersWaitingForMsg(u8 windowId, u8 capacityCode, u8 string break; } - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); } static void PrintPlayerNameAndIdOnWindow(u8 windowId) @@ -434,7 +434,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId) FillWindowPixelBuffer(data->bButtonCancelWindowId, PIXEL_FILL(2)); PrintUnionRoomText(data->bButtonCancelWindowId, 0, sText_BButtonCancel, 8, 1, UR_COLOR_CANCEL); PutWindowTilemap(data->bButtonCancelWindowId); - CopyWindowToVram(data->bButtonCancelWindowId, 2); + CopyWindowToVram(data->bButtonCancelWindowId, COPYWIN_GFX); DrawStdWindowFrame(data->listWindowId, FALSE); gMultiuseListMenuTemplate = sListMenuTemplate_PossibleGroupMembers; @@ -443,7 +443,7 @@ static void Task_TryBecomeLinkLeader(u8 taskId) DrawStdWindowFrame(data->nPlayerModeWindowId, FALSE); PutWindowTilemap(data->nPlayerModeWindowId); - CopyWindowToVram(data->nPlayerModeWindowId, 2); + CopyWindowToVram(data->nPlayerModeWindowId, COPYWIN_GFX); CopyBgTilemapBufferToVram(0); data->playerCount = 1; @@ -1014,7 +1014,7 @@ static void Task_TryJoinLinkGroup(u8 taskId) FillWindowPixelBuffer(data->bButtonCancelWindowId, PIXEL_FILL(2)); PrintUnionRoomText(data->bButtonCancelWindowId, 0, sText_ChooseJoinCancel, 8, 1, UR_COLOR_CANCEL); PutWindowTilemap(data->bButtonCancelWindowId); - CopyWindowToVram(data->bButtonCancelWindowId, 2); + CopyWindowToVram(data->bButtonCancelWindowId, COPYWIN_GFX); DrawStdWindowFrame(data->listWindowId, FALSE); gMultiuseListMenuTemplate = sListMenuTemplate_UnionRoomGroups; @@ -1024,7 +1024,7 @@ static void Task_TryJoinLinkGroup(u8 taskId) DrawStdWindowFrame(data->playerNameAndIdWindowId, FALSE); PutWindowTilemap(data->playerNameAndIdWindowId); PrintPlayerNameAndIdOnWindow(data->playerNameAndIdWindowId); - CopyWindowToVram(data->playerNameAndIdWindowId, 2); + CopyWindowToVram(data->playerNameAndIdWindowId, COPYWIN_GFX); CopyBgTilemapBufferToVram(0); data->leaderId = 0; @@ -2131,7 +2131,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId) FillWindowPixelBuffer(data->playerNameAndIdWindowId, PIXEL_FILL(1)); PutWindowTilemap(data->playerNameAndIdWindowId); PrintPlayerNameAndIdOnWindow(data->playerNameAndIdWindowId); - CopyWindowToVram(data->playerNameAndIdWindowId, 2); + CopyWindowToVram(data->playerNameAndIdWindowId, COPYWIN_GFX); CopyBgTilemapBufferToVram(0); data->leaderId = 0; @@ -3637,7 +3637,7 @@ static s8 UnionRoomHandleYesNo(u8 *state, bool32 noDraw) case 1: if (noDraw) { - sub_8198C78(); + EraseYesNoWindow(); *state = 0; return -3; } @@ -3658,7 +3658,7 @@ static u8 CreateTradeBoardWindow(const struct WindowTemplate * template) DrawStdWindowFrame(windowId, FALSE); FillWindowPixelBuffer(windowId, PIXEL_FILL(15)); PrintUnionRoomText(windowId, 1, sText_NameWantedOfferLv, 8, 1, UR_COLOR_TRADE_BOARD_OTHER); - CopyWindowToVram(windowId, 2); + CopyWindowToVram(windowId, COPYWIN_GFX); PutWindowTilemap(windowId); return windowId; } @@ -3689,7 +3689,7 @@ static s32 ListMenuHandler_AllItemsAvailable(u8 *state, u8 *windowId, u8 *listMe gMultiuseListMenuTemplate = *menuTemplate; gMultiuseListMenuTemplate.windowId = *windowId; *listMenuId = ListMenuInit(&gMultiuseListMenuTemplate, 0, 0); - CopyWindowToVram(*windowId, TRUE); + CopyWindowToVram(*windowId, COPYWIN_MAP); (*state)++; break; case 1: @@ -3736,7 +3736,7 @@ static s32 TradeBoardMenuHandler(u8 *state, u8 *mainWindowId, u8 *listMenuId, u8 (*state)++; break; case 1: - CopyWindowToVram(*mainWindowId, TRUE); + CopyWindowToVram(*mainWindowId, COPYWIN_MAP); (*state)++; break; case 2: @@ -3852,7 +3852,7 @@ static void PrintUnionRoomText(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y break; } - AddTextPrinter(&printerTemplate, TEXT_SPEED_FF, NULL); + AddTextPrinter(&printerTemplate, TEXT_SKIP_DRAW, NULL); } static void ClearRfuPlayerList(struct RfuPlayer *players, u8 count) @@ -3982,7 +3982,7 @@ static void PrintGroupMemberOnWindow(u8 windowId, u8 x, u8 y, struct RfuPlayer * ConvertIntToDecimalStringN(trainerId, player->rfu.data.compatibility.playerTrainerId[0] | (player->rfu.data.compatibility.playerTrainerId[1] << 8), STR_CONV_MODE_LEADING_ZEROS, 5); StringCopy(gStringVar4, sText_ID); StringAppend(gStringVar4, trainerId); - PrintUnionRoomText(windowId, 1, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 0x88), y, colorIdx); + PrintUnionRoomText(windowId, 1, gStringVar4, GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 0x88), y, colorIdx); } } @@ -3997,7 +3997,7 @@ static void PrintGroupCandidateOnWindow(u8 windowId, u8 x, u8 y, struct RfuPlaye ConvertIntToDecimalStringN(trainerId, player->rfu.data.compatibility.playerTrainerId[0] | (player->rfu.data.compatibility.playerTrainerId[1] << 8), STR_CONV_MODE_LEADING_ZEROS, 5); StringCopy(gStringVar4, sText_ID); StringAppend(gStringVar4, trainerId); - PrintUnionRoomText(windowId, 1, gStringVar4, GetStringRightAlignXOffset(1, gStringVar4, 0x68), y, colorIdx); + PrintUnionRoomText(windowId, 1, gStringVar4, GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 0x68), y, colorIdx); } } diff --git a/src/union_room_battle.c b/src/union_room_battle.c index 1ca414d79..1ec8be77b 100644 --- a/src/union_room_battle.c +++ b/src/union_room_battle.c @@ -78,7 +78,7 @@ static void AddTextPrinterForUnionRoomBattle(u8 windowId, const u8 * str, u8 x, s32 letterSpacing = 0; s32 lineSpacing = 1; FillWindowPixelBuffer(windowId, (sTextColors[0] << 4) | sTextColors[0]); - AddTextPrinterParameterized4(windowId, 1, x, y, letterSpacing, lineSpacing, sTextColors, speed, str); + AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, letterSpacing, lineSpacing, sTextColors, speed, str); } static bool32 PrintUnionRoomBattleMessage(s16 * state, const u8 * str, s32 speed) @@ -89,7 +89,7 @@ static bool32 PrintUnionRoomBattleMessage(s16 * state, const u8 * str, s32 speed DrawTextBorderOuter(0, 0x001, 0xD); AddTextPrinterForUnionRoomBattle(0, str, 0, 1, speed); PutWindowTilemap(0); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); (*state)++; break; case 1: @@ -132,7 +132,7 @@ void CB2_UnionRoomBattle(void) FillBgTilemapBufferRect(0, 0, 0, 0, 30, 20, 0xF); LoadUserWindowBorderGfx(0, 1, 0xD0); LoadUserWindowBorderGfx_(0, 1, 0xD0); - sub_819789C(); + Menu_LoadStdPal(); SetVBlankCallback(VBlankCB_UnionRoomBattle); gMain.state++; break; diff --git a/src/union_room_chat.c b/src/union_room_chat.c index 7debe3cd4..22268ef4a 100755 --- a/src/union_room_chat.c +++ b/src/union_room_chat.c @@ -249,7 +249,7 @@ static void SetBgTilemapBuffers(void); static void ClearBg0(void); static void LoadChatWindowBorderGfx(void); static void LoadChatWindowGfx(void); -static void sub_8020680(void); +static void LoadChatUnkPalette(void); static void LoadChatMessagesWindow(void); static void LoadKeyboardWindow(void); static void LoadKeyboardSwapWindow(void); @@ -458,10 +458,10 @@ static const u8 sCaseToggleTable[256] = { [CHAR_LEFT_PAREN] = CHAR_LEFT_PAREN, [CHAR_RIGHT_PAREN] = CHAR_RIGHT_PAREN, [CHAR_AMPERSAND] = CHAR_AMPERSAND, - [CHAR_DBL_QUOT_LEFT] = CHAR_DBL_QUOT_LEFT, - [CHAR_DBL_QUOT_RIGHT] = CHAR_DBL_QUOT_RIGHT, - [CHAR_SGL_QUOT_LEFT] = CHAR_SGL_QUOT_LEFT, - [CHAR_SGL_QUOT_RIGHT] = CHAR_SGL_QUOT_RIGHT, + [CHAR_DBL_QUOTE_LEFT] = CHAR_DBL_QUOTE_LEFT, + [CHAR_DBL_QUOTE_RIGHT] = CHAR_DBL_QUOTE_RIGHT, + [CHAR_SGL_QUOTE_LEFT] = CHAR_SGL_QUOTE_LEFT, + [CHAR_SGL_QUOTE_RIGHT] = CHAR_SGL_QUOTE_RIGHT, [CHAR_MASCULINE_ORDINAL] = CHAR_MASCULINE_ORDINAL, [CHAR_FEMININE_ORDINAL] = CHAR_FEMININE_ORDINAL, [CHAR_BULLET] = CHAR_BULLET, @@ -1983,10 +1983,10 @@ static int GetShouldShowCaseToggleIcon(void) { u8 *str = GetLastCharOfMessagePtr(); u32 character = *str; - if (character > 0xFF || sCaseToggleTable[character] == character || sCaseToggleTable[character] == 0) - return 3; + if (character > EOS || sCaseToggleTable[character] == character || sCaseToggleTable[character] == CHAR_SPACE) + return 3; // Don't show else - return 0; + return 0; // Show } static u8 *GetChatHostName(void) @@ -2063,7 +2063,7 @@ static void Task_ReceiveChatMessage(u8 taskId) switch (buffer[0]) { default: - case CHAT_MESSAGE_CHAT: tNextState = 3; break; + case CHAT_MESSAGE_CHAT: tNextState = 3; break; case CHAT_MESSAGE_JOIN: tNextState = 3; break; case CHAT_MESSAGE_LEAVE: tNextState = 4; break; case CHAT_MESSAGE_DROP: tNextState = 5; break; @@ -2246,7 +2246,7 @@ static bool32 Display_LoadGfx(u8 *state) LoadChatWindowGfx(); break; case 4: - sub_8020680(); + LoadChatUnkPalette(); break; case 5: LoadChatMessagesWindow(); @@ -2276,7 +2276,7 @@ static bool32 Display_ShowKeyboardSwapMenu(u8 *state) { case 0: ShowKeyboardSwapMenu(); - CopyWindowToVram(3, 3); + CopyWindowToVram(3, COPYWIN_FULL); break; case 1: return IsDma3ManagerBusyWithBgCopy(); @@ -2292,7 +2292,7 @@ static bool32 Display_HideKeyboardSwapMenu(u8 *state) { case 0: HideKeyboardSwapMenu(); - CopyWindowToVram(3, 3); + CopyWindowToVram(3, COPYWIN_FULL); break; case 1: return IsDma3ManagerBusyWithBgCopy(); @@ -2312,7 +2312,7 @@ static bool32 Display_SwitchPages(u8 *state) return TRUE; PrintCurrentKeyboardPage(); - CopyWindowToVram(2, 2); + CopyWindowToVram(2, COPYWIN_GFX); break; case 1: if (IsDma3ManagerBusyWithBgCopy()) @@ -2345,7 +2345,7 @@ static bool32 Display_AskQuitChatting(u8 *state) case 0: AddStdMessageWindow(STDMESSAGE_QUIT_CHATTING, 0); AddYesNoMenuAt(23, 11, 1); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); break; case 1: return IsDma3ManagerBusyWithBgCopy(); @@ -2389,7 +2389,7 @@ static bool32 Display_UpdateMessageBuffer(u8 *state) FillTextEntryWindow(x, width, 0); str = GetMessageEntryBuffer(); DrawTextEntryMessage(0, str, 3, 1, 2); - CopyWindowToVram(1, 2); + CopyWindowToVram(1, COPYWIN_GFX); break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) @@ -2418,13 +2418,13 @@ static bool32 Display_AskRegisterText(u8 *state) length = StringLength_Multibyte(str); FillTextEntryWindow(x, length, PIXEL_FILL(6)); DrawTextEntryMessage(x, str, 0, 4, 5); - CopyWindowToVram(1, 2); + CopyWindowToVram(1, COPYWIN_GFX); break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) { AddStdMessageWindow(STDMESSAGE_REGISTER_WHERE, 16); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); } else { @@ -2459,13 +2459,13 @@ static bool32 Display_CancelRegister(u8 *state) length = StringLength_Multibyte(str); FillTextEntryWindow(x, length, PIXEL_FILL(0)); DrawTextEntryMessage(x, str, 3, 1, 2); - CopyWindowToVram(1, 2); + CopyWindowToVram(1, COPYWIN_GFX); break; case 1: if (!IsDma3ManagerBusyWithBgCopy()) { HideStdMessageWindow(); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); } else { @@ -2497,7 +2497,7 @@ static bool32 Display_ReturnToKeyboard(u8 *state) { case 0: PrintCurrentKeyboardPage(); - CopyWindowToVram(2, 2); + CopyWindowToVram(2, COPYWIN_GFX); (*state)++; break; case 1: @@ -2523,7 +2523,7 @@ static bool32 Display_ScrollChat(u8 *state) str = GetLastReceivedMessage(); colorIdx = GetReceivedPlayerIndex(); PrintChatMessage(row, str, colorIdx); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); break; case 1: if (IsDma3ManagerBusyWithBgCopy()) @@ -2543,7 +2543,7 @@ static bool32 Display_ScrollChat(u8 *state) // fall through case 2: ScrollWindow(0, 0, 5, PIXEL_FILL(1)); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); sDisplay->scrollCount++; (*state)++; // fall through @@ -2588,7 +2588,7 @@ static bool32 Display_PrintInputText(u8 *state) { case 0: AddStdMessageWindow(STDMESSAGE_INPUT_TEXT, 16); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); (*state)++; break; case 1: @@ -2604,7 +2604,7 @@ static bool32 Display_PrintExitingChat(u8 *state) { case 0: AddStdMessageWindow(STDMESSAGE_EXITING_CHAT, 0); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); (*state)++; break; case 1: @@ -2625,7 +2625,7 @@ static bool32 Display_PrintLeaderLeft(u8 *state) str = GetChatHostName(); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, str); AddStdMessageWindow(STDMESSAGE_LEADER_LEFT, 0); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); (*state)++; break; case 1: @@ -2642,7 +2642,7 @@ static bool32 Display_AskSave(u8 *state) case 0: AddStdMessageWindow(STDMESSAGE_ASK_SAVE, 0); AddYesNoMenuAt(23, 10, 1); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); (*state)++; break; case 1: @@ -2659,7 +2659,7 @@ static bool32 Display_AskOverwriteSave(u8 *state) case 0: AddStdMessageWindow(STDMESSAGE_ASK_OVERWRITE, 0); AddYesNoMenuAt(23, 10, 1); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); (*state)++; break; case 1: @@ -2675,7 +2675,7 @@ static bool32 Display_PrintSavingDontTurnOff(u8 *state) { case 0: AddStdMessageWindow(STDMESSAGE_SAVING_NO_OFF, 0); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); (*state)++; break; case 1: @@ -2693,7 +2693,7 @@ static bool32 Display_PrintSavedTheGame(u8 *state) DynamicPlaceholderTextUtil_Reset(); DynamicPlaceholderTextUtil_SetPlaceholderPtr(0, gSaveBlock2Ptr->playerName); AddStdMessageWindow(STDMESSAGE_SAVED_THE_GAME, 0); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); (*state)++; break; case 1: @@ -2710,7 +2710,7 @@ static bool32 Display_AskConfirmLeaderLeave(u8 *state) case 0: AddStdMessageWindow(STDMESSAGE_WARN_LEADER_LEAVE, 0); AddYesNoMenuAt(23, 10, 1); - CopyWindowToVram(sDisplay->messageWindowId, 3); + CopyWindowToVram(sDisplay->messageWindowId, COPYWIN_FULL); (*state)++; break; case 1: @@ -2740,10 +2740,10 @@ static void AddYesNoMenuAt(u8 left, u8 top, u8 initialCursorPos) { FillWindowPixelBuffer(sDisplay->yesNoMenuWindowId, PIXEL_FILL(1)); PutWindowTilemap(sDisplay->yesNoMenuWindowId); - AddTextPrinterParameterized(sDisplay->yesNoMenuWindowId, 1, gText_Yes, 8, 1, TEXT_SPEED_FF, NULL); - AddTextPrinterParameterized(sDisplay->yesNoMenuWindowId, 1, gText_No, 8, 17, TEXT_SPEED_FF, NULL); + AddTextPrinterParameterized(sDisplay->yesNoMenuWindowId, FONT_NORMAL, gText_Yes, 8, 1, TEXT_SKIP_DRAW, NULL); + AddTextPrinterParameterized(sDisplay->yesNoMenuWindowId, FONT_NORMAL, gText_No, 8, 17, TEXT_SKIP_DRAW, NULL); DrawTextBorderOuter(sDisplay->yesNoMenuWindowId, 1, 13); - InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sDisplay->yesNoMenuWindowId, 2, initialCursorPos); + InitMenuInUpperLeftCornerNormal(sDisplay->yesNoMenuWindowId, 2, initialCursorPos); } } @@ -2803,7 +2803,7 @@ static void AddStdMessageWindow(int msgId, u16 bg0vofs) str = sDisplayStdMessages[msgId].text; } - ChangeBgY(0, bg0vofs * 256, 0); + ChangeBgY(0, bg0vofs * 256, BG_COORD_SET); FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); PutWindowTilemap(windowId); if (sDisplayStdMessages[msgId].boxType == 1) @@ -2811,11 +2811,11 @@ static void AddStdMessageWindow(int msgId, u16 bg0vofs) DrawTextBorderInner(windowId, 0xA, 2); AddTextPrinterParameterized5( windowId, - 1, + FONT_NORMAL, str, sDisplayStdMessages[msgId].x + 8, sDisplayStdMessages[msgId].y + 8, - TEXT_SPEED_FF, + TEXT_SKIP_DRAW, NULL, sDisplayStdMessages[msgId].letterSpacing, sDisplayStdMessages[msgId].lineSpacing); @@ -2825,11 +2825,11 @@ static void AddStdMessageWindow(int msgId, u16 bg0vofs) DrawTextBorderOuter(windowId, 0xA, 2); AddTextPrinterParameterized5( windowId, - 1, + FONT_NORMAL, str, sDisplayStdMessages[msgId].x, sDisplayStdMessages[msgId].y, - TEXT_SPEED_FF, + TEXT_SKIP_DRAW, NULL, sDisplayStdMessages[msgId].letterSpacing, sDisplayStdMessages[msgId].lineSpacing); @@ -2846,7 +2846,7 @@ static void HideStdMessageWindow(void) ClearWindowTilemap(sDisplay->messageWindowId); } - ChangeBgY(0, 0, 0); + ChangeBgY(0, 0, BG_COORD_SET); } static void DestroyStdMessageWindow(void) @@ -2877,7 +2877,7 @@ static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shad strBuffer[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING; strBuffer[2] = 8; StringCopy(&strBuffer[3], str); - AddTextPrinterParameterized3(1, 2, x * 8, 1, color, TEXT_SPEED_FF, strBuffer); + AddTextPrinterParameterized3(1, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer); } static void PrintCurrentKeyboardPage(void) @@ -2912,7 +2912,7 @@ static void PrintCurrentKeyboardPage(void) return; StringCopy(&str[3], sUnionRoomKeyboardText[page][i]); - AddTextPrinterParameterized3(2, 0, left, top, color, TEXT_SPEED_FF, str); + AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str); } } else @@ -2921,9 +2921,9 @@ static void PrintCurrentKeyboardPage(void) for (i = 0, top = 0; i < UNION_ROOM_KB_ROW_COUNT; i++, top += 12) { str2 = GetRegisteredTextByRow(i); - if (GetStringWidth(0, str2, 0) <= 40) + if (GetStringWidth(FONT_SMALL, str2, 0) <= 40) { - AddTextPrinterParameterized3(2, 0, left, top, color, TEXT_SPEED_FF, str2); + AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2); } else { @@ -2932,10 +2932,10 @@ static void PrintCurrentKeyboardPage(void) { length--; StringCopyN_Multibyte(str, str2, length); - } while (GetStringWidth(0, str, 0) > 35); + } while (GetStringWidth(FONT_SMALL, str, 0) > 35); - AddTextPrinterParameterized3(2, 0, left, top, color, TEXT_SPEED_FF, str); - AddTextPrinterParameterized3(2, 0, left + 35, top, color, TEXT_SPEED_FF, sText_Ellipsis); + AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str); + AddTextPrinterParameterized3(2, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis); } } } @@ -2987,8 +2987,8 @@ static void ShowKeyboardSwapMenu(void) { FillWindowPixelBuffer(3, PIXEL_FILL(1)); DrawTextBorderOuter(3, 1, 13); - PrintTextArray(3, 2, 8, 1, 14, 5, sKeyboardPageTitleTexts); - sub_81983AC(3, 2, 0, 1, 14, 5, GetCurrentKeyboardPage()); + PrintMenuActionTextsAtPos(3, FONT_SHORT, 8, 1, 14, 5, sKeyboardPageTitleTexts); + InitMenuNormal(3, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage()); PutWindowTilemap(3); } @@ -3006,19 +3006,19 @@ static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx) color[1] = colorIdx * 2 + 2; color[2] = colorIdx * 2 + 3; FillWindowPixelRect(0, PIXEL_FILL(1), 0, row * 15, 168, 15); - AddTextPrinterParameterized3(0, 2, 0, row * 15 + 1, color, TEXT_SPEED_FF, str); + AddTextPrinterParameterized3(0, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str); } static void ResetGpuBgState(void) { - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); ShowBg(0); ShowBg(1); ShowBg(2); @@ -3074,7 +3074,7 @@ static void LoadChatWindowGfx(void) CopyBgTilemapBufferToVram(2); } -static void sub_8020680(void) +static void LoadChatUnkPalette(void) { LoadPalette(sUnk_Palette1, 0x80, sizeof(sUnk_Palette1)); RequestDma3Fill(0, (void *)BG_CHAR_ADDR(1) + 0x20, 0x20, 1); @@ -3085,14 +3085,14 @@ static void LoadChatMessagesWindow(void) LoadPalette(sUnk_Palette2, 0xF0, sizeof(sUnk_Palette2)); PutWindowTilemap(0); FillWindowPixelBuffer(0, PIXEL_FILL(1)); - CopyWindowToVram(0, 3); + CopyWindowToVram(0, COPYWIN_FULL); } static void LoadKeyboardWindow(void) { PutWindowTilemap(2); PrintCurrentKeyboardPage(); - CopyWindowToVram(2, 3); + CopyWindowToVram(2, COPYWIN_FULL); } static void LoadTextEntryWindow(void) @@ -3107,7 +3107,7 @@ static void LoadTextEntryWindow(void) FillWindowPixelBuffer(1, PIXEL_FILL(0)); PutWindowTilemap(1); - CopyWindowToVram(1, 3); + CopyWindowToVram(1, COPYWIN_FULL); } static void LoadKeyboardSwapWindow(void) @@ -3115,7 +3115,7 @@ static void LoadKeyboardSwapWindow(void) FillWindowPixelBuffer(3, PIXEL_FILL(1)); LoadUserWindowBorderGfx(3, 1, 0xD0); LoadUserWindowBorderGfx_(3, 0xA, 0x20); - LoadPalette(gUnknown_0860F074, 0xE0, 0x20); + LoadPalette(gStandardMenuPalette, 0xE0, 0x20); } static void InitScanlineEffect(void) diff --git a/src/unk_text_util_2.c b/src/unk_text_util_2.c deleted file mode 100644 index a0eea575e..000000000 --- a/src/unk_text_util_2.c +++ /dev/null @@ -1,220 +0,0 @@ -#include "global.h" -#include "main.h" -#include "window.h" -#include "text.h" -#include "sound.h" - -ALIGNED(4) -static const u8 sScrollDistances[] = {1, 2, 4}; -static const u16 sFont6BrailleGlyphs[] = INCBIN_U16("graphics/fonts/font6.fwjpnfont"); - -static void DecompressGlyphFont6(u16); - -u16 Font6Func(struct TextPrinter *textPrinter) -{ - u16 char_; - struct TextPrinterSubStruct *subStruct; - subStruct = (struct TextPrinterSubStruct *)(&textPrinter->subStructFields); - - switch (textPrinter->state) - { - case 0: - if (JOY_HELD(A_BUTTON | B_BUTTON) && subStruct->hasPrintBeenSpedUp) - { - textPrinter->delayCounter = 0; - } - if (textPrinter->delayCounter && textPrinter->textSpeed) - { - textPrinter->delayCounter --; - if (gTextFlags.canABSpeedUpPrint && JOY_NEW(A_BUTTON | B_BUTTON)) - { - subStruct->hasPrintBeenSpedUp = TRUE; - textPrinter->delayCounter = 0; - } - return 3; - } - if (gTextFlags.autoScroll) - { - textPrinter->delayCounter = 3; - } - else - { - textPrinter->delayCounter = textPrinter->textSpeed; - } - char_ = *textPrinter->printerTemplate.currentChar++; - switch (char_) - { - case EOS: - return 1; - case CHAR_NEWLINE: - textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; - textPrinter->printerTemplate.currentY += gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; - return 2; - case PLACEHOLDER_BEGIN: - textPrinter->printerTemplate.currentChar++; - return 2; - case EXT_CTRL_CODE_BEGIN: - char_ = *textPrinter->printerTemplate.currentChar++; - switch (char_) - { - case EXT_CTRL_CODE_COLOR: - textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar++; - GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); - return 2; - case EXT_CTRL_CODE_HIGHLIGHT: - textPrinter->printerTemplate.bgColor = *textPrinter->printerTemplate.currentChar++; - GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); - return 2; - case EXT_CTRL_CODE_SHADOW: - textPrinter->printerTemplate.shadowColor = *textPrinter->printerTemplate.currentChar++; - GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); - return 2; - case EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW: - textPrinter->printerTemplate.fgColor = *textPrinter->printerTemplate.currentChar; - textPrinter->printerTemplate.bgColor = *++textPrinter->printerTemplate.currentChar; - textPrinter->printerTemplate.shadowColor = *++textPrinter->printerTemplate.currentChar; - textPrinter->printerTemplate.currentChar++; - - GenerateFontHalfRowLookupTable(textPrinter->printerTemplate.fgColor, textPrinter->printerTemplate.bgColor, textPrinter->printerTemplate.shadowColor); - return 2; - case EXT_CTRL_CODE_PALETTE: - textPrinter->printerTemplate.currentChar++; - return 2; - case EXT_CTRL_CODE_FONT: - subStruct->glyphId = *textPrinter->printerTemplate.currentChar; - textPrinter->printerTemplate.currentChar++; - return 2; - case EXT_CTRL_CODE_RESET_SIZE: - return 2; - case EXT_CTRL_CODE_PAUSE: - textPrinter->delayCounter = *textPrinter->printerTemplate.currentChar++; - textPrinter->state = 6; - return 2; - case EXT_CTRL_CODE_PAUSE_UNTIL_PRESS: - textPrinter->state = 1; - if (gTextFlags.autoScroll) - { - subStruct->autoScrollDelay = 0; - } - return 3; - case EXT_CTRL_CODE_WAIT_SE: - textPrinter->state = 5; - return 3; - case EXT_CTRL_CODE_PLAY_BGM: - case EXT_CTRL_CODE_PLAY_SE: - textPrinter->printerTemplate.currentChar += 2; - return 2; - case EXT_CTRL_CODE_ESCAPE: - char_ = *++textPrinter->printerTemplate.currentChar; - break; - case EXT_CTRL_CODE_SHIFT_TEXT: - textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x + *textPrinter->printerTemplate.currentChar++; - return 2; - case EXT_CTRL_CODE_SHIFT_DOWN: - textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y + *textPrinter->printerTemplate.currentChar++; - return 2; - case EXT_CTRL_CODE_FILL_WINDOW: - FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); - return 2; - } - break; - case CHAR_PROMPT_CLEAR: - textPrinter->state = 2; - TextPrinterInitDownArrowCounters(textPrinter); - return 3; - case CHAR_PROMPT_SCROLL: - textPrinter->state = 3; - TextPrinterInitDownArrowCounters(textPrinter); - return 3; - case CHAR_EXTRA_SYMBOL: - char_ = *textPrinter->printerTemplate.currentChar++| 0x100; - break; - case CHAR_KEYPAD_ICON: - textPrinter->printerTemplate.currentChar++; - return 0; - } - DecompressGlyphFont6(char_); - CopyGlyphToWindow(textPrinter); - textPrinter->printerTemplate.currentX += gCurGlyph.width + textPrinter->printerTemplate.letterSpacing; - return 0; - case 1: - if (TextPrinterWait(textPrinter)) - { - textPrinter->state = 0; - } - return 3; - case 2: - if (TextPrinterWaitWithDownArrow(textPrinter)) - { - FillWindowPixelBuffer(textPrinter->printerTemplate.windowId, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); - textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; - textPrinter->printerTemplate.currentY = textPrinter->printerTemplate.y; - textPrinter->state = 0; - } - return 3; - case 3: - if (TextPrinterWaitWithDownArrow(textPrinter)) - { - TextPrinterClearDownArrow(textPrinter); - textPrinter->scrollDistance = gFonts[textPrinter->printerTemplate.fontId].maxLetterHeight + textPrinter->printerTemplate.lineSpacing; - textPrinter->printerTemplate.currentX = textPrinter->printerTemplate.x; - textPrinter->state = 4; - } - return 3; - case 4: - if (textPrinter->scrollDistance) - { - if (textPrinter->scrollDistance < sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed]) - { - ScrollWindow(textPrinter->printerTemplate.windowId, 0, textPrinter->scrollDistance, PIXEL_FILL(textPrinter->printerTemplate.bgColor)); - textPrinter->scrollDistance = 0; - } - else - { - ScrollWindow(textPrinter->printerTemplate.windowId, 0, sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed], PIXEL_FILL(textPrinter->printerTemplate.bgColor)); - textPrinter->scrollDistance -= sScrollDistances[gSaveBlock2Ptr->optionsTextSpeed]; - } - CopyWindowToVram(textPrinter->printerTemplate.windowId, 2); - } - else - { - textPrinter->state = 0; - } - return 3; - case 5: - if (!IsSEPlaying()) - { - textPrinter->state = 0; - } - return 3; - case 6: - if (textPrinter->delayCounter) - { - textPrinter->delayCounter --; - } - else - { - textPrinter->state = 0; - } - return 3; - } - return 1; -} - -static void DecompressGlyphFont6(u16 glyph) -{ - const u16 *glyphs; - - glyphs = sFont6BrailleGlyphs + 0x100 * (glyph / 8) + 0x10 * (glyph % 8); - DecompressGlyphTile(glyphs, gCurGlyph.gfxBufferTop); - DecompressGlyphTile(glyphs + 0x8, gCurGlyph.gfxBufferTop + 8); - DecompressGlyphTile(glyphs + 0x80, gCurGlyph.gfxBufferBottom); - DecompressGlyphTile(glyphs + 0x88, gCurGlyph.gfxBufferBottom + 8); - gCurGlyph.width = 0x10; - gCurGlyph.height = 0x10; -} - -u32 GetGlyphWidthFont6(u16 glyphId, bool32 isJapanese) -{ - return 0x10; -} diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 6ebc707e5..9f8918ba2 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -876,9 +876,9 @@ static void AskUsePokeblock(void) StringCopy(gStringVar4, stringBuffer); FillWindowPixelBuffer(WIN_TEXT, 17); DrawTextBorderOuter(WIN_TEXT, 151, 14); - AddTextPrinterParameterized(WIN_TEXT, 1, gStringVar4, 0, 1, 0, NULL); + AddTextPrinterParameterized(WIN_TEXT, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL); PutWindowTilemap(WIN_TEXT); - CopyWindowToVram(WIN_TEXT, 3); + CopyWindowToVram(WIN_TEXT, COPYWIN_FULL); CreateYesNoMenu(&sUsePokeblockYesNoWinTemplate, 151, 14, 0); } @@ -919,7 +919,7 @@ static void PrintFirstEnhancement(void) PrintMenuWindowText(gStringVar4); PutWindowTilemap(WIN_TEXT); - CopyWindowToVram(WIN_TEXT, 3); + CopyWindowToVram(WIN_TEXT, COPYWIN_FULL); } static bool8 TryPrintNextEnhancement(void) @@ -943,7 +943,7 @@ static bool8 TryPrintNextEnhancement(void) BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]); PrintMenuWindowText(gStringVar4); - CopyWindowToVram(WIN_TEXT, 2); + CopyWindowToVram(WIN_TEXT, COPYWIN_GFX); return TRUE; } @@ -952,21 +952,21 @@ static void PrintWontEatAnymore(void) { FillWindowPixelBuffer(WIN_TEXT, 17); DrawTextBorderOuter(WIN_TEXT, 151, 14); - AddTextPrinterParameterized(WIN_TEXT, 1, gText_WontEatAnymore, 0, 1, 0, NULL); + AddTextPrinterParameterized(WIN_TEXT, FONT_NORMAL, gText_WontEatAnymore, 0, 1, 0, NULL); PutWindowTilemap(WIN_TEXT); - CopyWindowToVram(WIN_TEXT, 3); + CopyWindowToVram(WIN_TEXT, COPYWIN_FULL); } static void EraseMenuWindow(void) { rbox_fill_rectangle(WIN_TEXT); ClearWindowTilemap(WIN_TEXT); - CopyWindowToVram(WIN_TEXT, 3); + CopyWindowToVram(WIN_TEXT, COPYWIN_FULL); } static void PrintMenuWindowText(const u8 *message) { - AddTextPrinterParameterized(WIN_TEXT, 1, gStringVar4, 0, 1, 0, NULL); + AddTextPrinterParameterized(WIN_TEXT, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL); } static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement) @@ -1316,14 +1316,14 @@ static bool8 LoadUsePokeblockMenuGfx(void) switch (sMenu->info.helperState) { case 0: - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 136 << 6, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 136 << 6, BG_COORD_SET); SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON | DISPCNT_WIN0_ON | DISPCNT_WIN1_ON); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG2 | BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1); SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(11, 4)); @@ -1389,23 +1389,23 @@ static void UpdateMonInfoText(u16 loadId, bool8 firstPrint) FillWindowPixelBuffer(WIN_NATURE, PIXEL_FILL(0)); if (sMenu->info.curSelection != sMenu->info.numSelections - 1) { - AddTextPrinterParameterized(WIN_NAME, 1, sMenu->monNameStrings[loadId], 0, 1, 0, NULL); + AddTextPrinterParameterized(WIN_NAME, FONT_NORMAL, sMenu->monNameStrings[loadId], 0, 1, 0, NULL); partyIndex = GetPartyIdFromSelectionId(sMenu->info.curSelection); nature = GetNature(&gPlayerParty[partyIndex]); str = StringCopy(sMenu->info.natureText, gText_NatureSlash); str = StringCopy(str, gNatureNamePointers[nature]); - AddTextPrinterParameterized3(WIN_NATURE, 1, 2, 1, sNatureTextColors, 0, sMenu->info.natureText); + AddTextPrinterParameterized3(WIN_NATURE, FONT_NORMAL, 2, 1, sNatureTextColors, 0, sMenu->info.natureText); } if (firstPrint) { - CopyWindowToVram(WIN_NAME, 3); - CopyWindowToVram(WIN_NATURE, 3); + CopyWindowToVram(WIN_NAME, COPYWIN_FULL); + CopyWindowToVram(WIN_NATURE, COPYWIN_FULL); } else { - CopyWindowToVram(WIN_NAME, 2); - CopyWindowToVram(WIN_NATURE, 2); + CopyWindowToVram(WIN_NAME, COPYWIN_GFX); + CopyWindowToVram(WIN_NATURE, COPYWIN_GFX); } } diff --git a/src/wallclock.c b/src/wallclock.c index 6f9bc02ae..759b1d11f 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -628,14 +628,14 @@ static void LoadWallClockGraphics(void) SetGpuReg(REG_OFFSET_BG2CNT, 0); SetGpuReg(REG_OFFSET_BG1CNT, 0); SetGpuReg(REG_OFFSET_BG0CNT, 0); - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); - ChangeBgX(2, 0, 0); - ChangeBgY(2, 0, 0); - ChangeBgX(3, 0, 0); - ChangeBgY(3, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); + ChangeBgX(2, 0, BG_COORD_SET); + ChangeBgY(2, 0, BG_COORD_SET); + ChangeBgX(3, 0, BG_COORD_SET); + ChangeBgY(3, 0, BG_COORD_SET); DmaFillLarge16(3, 0, (void *)VRAM, VRAM_SIZE, 0x1000); DmaClear32(3, (void *)OAM, OAM_SIZE); DmaClear16(3, (void *)PLTT, PLTT_SIZE); @@ -715,7 +715,7 @@ void CB2_StartWallClock(void) WallClockInit(); - AddTextPrinterParameterized(1, 1, gText_Confirm3, 0, 1, 0, NULL); + AddTextPrinterParameterized(1, FONT_NORMAL, gText_Confirm3, 0, 1, 0, NULL); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(2); } @@ -763,7 +763,7 @@ void CB2_ViewWallClock(void) WallClockInit(); - AddTextPrinterParameterized(1, 1, gText_Cancel4, 0, 1, 0, NULL); + AddTextPrinterParameterized(1, FONT_NORMAL, gText_Cancel4, 0, 1, 0, NULL); PutWindowTilemap(1); ScheduleBgCopyTilemapToVram(2); } @@ -828,7 +828,7 @@ static void Task_SetClock_HandleInput(u8 taskId) static void Task_SetClock_AskConfirm(u8 taskId) { DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x250, 0x0d); - AddTextPrinterParameterized(0, 1, gText_IsThisTheCorrectTime, 0, 1, 0, NULL); + AddTextPrinterParameterized(0, FONT_NORMAL, gText_IsThisTheCorrectTime, 0, 1, 0, NULL); PutWindowTilemap(0); ScheduleBgCopyTilemapToVram(0); CreateYesNoMenu(&sWindowTemplate_ConfirmYesNo, 0x250, 0x0d, 1); diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 458882853..65d8c86d0 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -301,7 +301,7 @@ static u16 GetCurrentMapWildMonHeaderId(void) for (i = 0; ; i++) { const struct WildPokemonHeader *wildHeader = &gWildMonHeaders[i]; - if (wildHeader->mapGroup == 0xFF) + if (wildHeader->mapGroup == MAP_GROUP(UNDEFINED)) break; if (gWildMonHeaders[i].mapGroup == gSaveBlock1Ptr->location.mapGroup && diff --git a/src/wireless_communication_status_screen.c b/src/wireless_communication_status_screen.c index 5c5272a44..ffb86488a 100644 --- a/src/wireless_communication_status_screen.c +++ b/src/wireless_communication_status_screen.c @@ -189,10 +189,10 @@ static void CB2_InitWirelessCommunicationScreen(void) sStatusScreen->taskId = CreateTask(Task_WirelessCommunicationScreen, 0); sStatusScreen->rfuTaskId = CreateTask_ListenToWireless(); sStatusScreen->prevGroupCounts[GROUPTYPE_TOTAL] = 1; - ChangeBgX(0, 0, 0); - ChangeBgY(0, 0, 0); - ChangeBgX(1, 0, 0); - ChangeBgY(1, 0, 0); + ChangeBgX(0, 0, BG_COORD_SET); + ChangeBgY(0, 0, BG_COORD_SET); + ChangeBgX(1, 0, BG_COORD_SET); + ChangeBgY(1, 0, BG_COORD_SET); LoadPalette(sBgTiles_Pal, 0x00, 0x20); Menu_LoadStdPalAt(0xF0); DynamicPlaceholderTextUtil_Reset(); @@ -236,16 +236,16 @@ static void PrintHeaderTexts(void) FillWindowPixelBuffer(0, PIXEL_FILL(0)); FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(2, PIXEL_FILL(0)); - WCSS_AddTextPrinterParameterized(0, 1, sHeaderTexts[0], GetStringCenterAlignXOffset(1, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN); + WCSS_AddTextPrinterParameterized(0, FONT_NORMAL, sHeaderTexts[0], GetStringCenterAlignXOffset(FONT_NORMAL, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN); for (i = 0; i < (int)ARRAY_COUNT(*sHeaderTexts) - 1; i++) { - WCSS_AddTextPrinterParameterized(1, 1, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY); + WCSS_AddTextPrinterParameterized(1, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY); } - WCSS_AddTextPrinterParameterized(1, 1, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_RED); + WCSS_AddTextPrinterParameterized(1, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_RED); PutWindowTilemap(0); - CopyWindowToVram(0, 2); + CopyWindowToVram(0, COPYWIN_GFX); PutWindowTilemap(1); - CopyWindowToVram(1, 2); + CopyWindowToVram(1, COPYWIN_GFX); } #define tState data[0] @@ -280,12 +280,12 @@ static void Task_WirelessCommunicationScreen(u8 taskId) { ConvertIntToDecimalStringN(gStringVar4, sStatusScreen->groupCounts[i], STR_CONV_MODE_RIGHT_ALIGN, 2); if (i != GROUPTYPE_TOTAL) - WCSS_AddTextPrinterParameterized(2, 1, gStringVar4, 12, 30 * i + 8, COLORMODE_WHITE_LGRAY); + WCSS_AddTextPrinterParameterized(2, FONT_NORMAL, gStringVar4, 12, 30 * i + 8, COLORMODE_WHITE_LGRAY); else - WCSS_AddTextPrinterParameterized(2, 1, gStringVar4, 12, 98, COLORMODE_RED); + WCSS_AddTextPrinterParameterized(2, FONT_NORMAL, gStringVar4, 12, 98, COLORMODE_RED); } PutWindowTilemap(2); - CopyWindowToVram(2, 3); + CopyWindowToVram(2, COPYWIN_FULL); } if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON)) { @@ -344,7 +344,7 @@ static void WCSS_AddTextPrinterParameterized(u8 windowId, u8 fontId, const u8 * break; } - AddTextPrinterParameterized4(windowId, fontId, x, y, 0, 0, color, -1, str); + AddTextPrinterParameterized4(windowId, fontId, x, y, 0, 0, color, TEXT_SKIP_DRAW, str); } static u32 CountPlayersInGroupAndGetActivity(struct RfuPlayer * player, u32 * groupCounts) |