From a2a9f226129317c2557b908883903df47701324c Mon Sep 17 00:00:00 2001 From: GriffinR Date: Tue, 20 Apr 2021 21:16:47 -0400 Subject: [PATCH] Clean up contest_util --- .../bg.bin} | 0 .../interface.bin} | Bin .../results_screen/text_window.pal} | 0 .../results_screen/text_window.png} | Bin .../tiles.pal} | 0 .../tiles.png} | Bin .../title.bin} | Bin .../title_beauty.bin} | 0 .../title_cool.bin} | Bin .../title_cute.bin} | 0 .../title_hyper.bin} | Bin .../title_link.bin} | Bin .../title_master.bin} | Bin .../title_normal.bin} | Bin .../title_smart.bin} | 0 .../title_super.bin} | Bin .../title_tough.bin} | 0 .../winner_banner.bin} | Bin include/graphics.h | 28 +-- src/contest_util.c | 180 ++++++++++-------- src/graphics.c | 32 ++-- 21 files changed, 131 insertions(+), 109 deletions(-) rename graphics/contest/{misc_2_tilemap_3.bin => results_screen/bg.bin} (100%) rename graphics/contest/{misc_2_tilemap_2.bin => results_screen/interface.bin} (100%) rename graphics/{unknown/unknown_58D6B0.pal => contest/results_screen/text_window.pal} (100%) rename graphics/{unknown/unknown_58D6D0.png => contest/results_screen/text_window.png} (100%) rename graphics/contest/{results_screen.pal => results_screen/tiles.pal} (100%) rename graphics/contest/{results_screen.png => results_screen/tiles.png} (100%) rename graphics/contest/{results_screen.bin => results_screen/title.bin} (100%) rename graphics/contest/{results_screen_beauty.bin => results_screen/title_beauty.bin} (100%) rename graphics/contest/{results_screen_cool.bin => results_screen/title_cool.bin} (100%) rename graphics/contest/{results_screen_cute.bin => results_screen/title_cute.bin} (100%) rename graphics/contest/{results_screen_hyper.bin => results_screen/title_hyper.bin} (100%) rename graphics/contest/{results_screen_link.bin => results_screen/title_link.bin} (100%) rename graphics/contest/{results_screen_master.bin => results_screen/title_master.bin} (100%) rename graphics/contest/{results_screen_normal.bin => results_screen/title_normal.bin} (100%) rename graphics/contest/{results_screen_smart.bin => results_screen/title_smart.bin} (100%) rename graphics/contest/{results_screen_super.bin => results_screen/title_super.bin} (100%) rename graphics/contest/{results_screen_tough.bin => results_screen/title_tough.bin} (100%) rename graphics/contest/{misc_2_tilemap_1.bin => results_screen/winner_banner.bin} (100%) diff --git a/graphics/contest/misc_2_tilemap_3.bin b/graphics/contest/results_screen/bg.bin similarity index 100% rename from graphics/contest/misc_2_tilemap_3.bin rename to graphics/contest/results_screen/bg.bin diff --git a/graphics/contest/misc_2_tilemap_2.bin b/graphics/contest/results_screen/interface.bin similarity index 100% rename from graphics/contest/misc_2_tilemap_2.bin rename to graphics/contest/results_screen/interface.bin diff --git a/graphics/unknown/unknown_58D6B0.pal b/graphics/contest/results_screen/text_window.pal similarity index 100% rename from graphics/unknown/unknown_58D6B0.pal rename to graphics/contest/results_screen/text_window.pal diff --git a/graphics/unknown/unknown_58D6D0.png b/graphics/contest/results_screen/text_window.png similarity index 100% rename from graphics/unknown/unknown_58D6D0.png rename to graphics/contest/results_screen/text_window.png diff --git a/graphics/contest/results_screen.pal b/graphics/contest/results_screen/tiles.pal similarity index 100% rename from graphics/contest/results_screen.pal rename to graphics/contest/results_screen/tiles.pal diff --git a/graphics/contest/results_screen.png b/graphics/contest/results_screen/tiles.png similarity index 100% rename from graphics/contest/results_screen.png rename to graphics/contest/results_screen/tiles.png diff --git a/graphics/contest/results_screen.bin b/graphics/contest/results_screen/title.bin similarity index 100% rename from graphics/contest/results_screen.bin rename to graphics/contest/results_screen/title.bin diff --git a/graphics/contest/results_screen_beauty.bin b/graphics/contest/results_screen/title_beauty.bin similarity index 100% rename from graphics/contest/results_screen_beauty.bin rename to graphics/contest/results_screen/title_beauty.bin diff --git a/graphics/contest/results_screen_cool.bin b/graphics/contest/results_screen/title_cool.bin similarity index 100% rename from graphics/contest/results_screen_cool.bin rename to graphics/contest/results_screen/title_cool.bin diff --git a/graphics/contest/results_screen_cute.bin b/graphics/contest/results_screen/title_cute.bin similarity index 100% rename from graphics/contest/results_screen_cute.bin rename to graphics/contest/results_screen/title_cute.bin diff --git a/graphics/contest/results_screen_hyper.bin b/graphics/contest/results_screen/title_hyper.bin similarity index 100% rename from graphics/contest/results_screen_hyper.bin rename to graphics/contest/results_screen/title_hyper.bin diff --git a/graphics/contest/results_screen_link.bin b/graphics/contest/results_screen/title_link.bin similarity index 100% rename from graphics/contest/results_screen_link.bin rename to graphics/contest/results_screen/title_link.bin diff --git a/graphics/contest/results_screen_master.bin b/graphics/contest/results_screen/title_master.bin similarity index 100% rename from graphics/contest/results_screen_master.bin rename to graphics/contest/results_screen/title_master.bin diff --git a/graphics/contest/results_screen_normal.bin b/graphics/contest/results_screen/title_normal.bin similarity index 100% rename from graphics/contest/results_screen_normal.bin rename to graphics/contest/results_screen/title_normal.bin diff --git a/graphics/contest/results_screen_smart.bin b/graphics/contest/results_screen/title_smart.bin similarity index 100% rename from graphics/contest/results_screen_smart.bin rename to graphics/contest/results_screen/title_smart.bin diff --git a/graphics/contest/results_screen_super.bin b/graphics/contest/results_screen/title_super.bin similarity index 100% rename from graphics/contest/results_screen_super.bin rename to graphics/contest/results_screen/title_super.bin diff --git a/graphics/contest/results_screen_tough.bin b/graphics/contest/results_screen/title_tough.bin similarity index 100% rename from graphics/contest/results_screen_tough.bin rename to graphics/contest/results_screen/title_tough.bin diff --git a/graphics/contest/misc_2_tilemap_1.bin b/graphics/contest/results_screen/winner_banner.bin similarity index 100% rename from graphics/contest/misc_2_tilemap_1.bin rename to graphics/contest/results_screen/winner_banner.bin diff --git a/include/graphics.h b/include/graphics.h index cea8bbab1..6262d8862 100644 --- a/include/graphics.h +++ b/include/graphics.h @@ -4924,21 +4924,21 @@ extern const u32 gRouletteMultiplier_Gfx[]; // Contest util extern const u32 gContestResults_Gfx[]; -extern const u32 gUnknown_08C19EEC[]; -extern const u32 gUnknown_08C1A000[]; -extern const u32 gUnknown_08C1A12C[]; +extern const u32 gContestResults_WinnerBanner_Tilemap[]; +extern const u32 gContestResults_Interface_Tilemap[]; +extern const u32 gContestResults_Bg_Tilemap[]; extern const u32 gContestResults_Pal[]; -extern const u16 gLinkContestResults_Tilemap[]; -extern const u16 gNormalContestResults_Tilemap[]; -extern const u16 gSuperContestResults_Tilemap[]; -extern const u16 gHyperContestResults_Tilemap[]; -extern const u16 gMasterContestResults_Tilemap[]; -extern const u16 gCoolContestResults_Tilemap[]; -extern const u16 gBeautyContestResults_Tilemap[]; -extern const u16 gCuteContestResults_Tilemap[]; -extern const u16 gSmartContestResults_Tilemap[]; -extern const u16 gToughContestResults_Tilemap[]; -extern const u16 gContestResults_Tilemap[]; +extern const u16 gContestResultsTitle_Link_Tilemap[]; +extern const u16 gContestResultsTitle_Normal_Tilemap[]; +extern const u16 gContestResultsTitle_Super_Tilemap[]; +extern const u16 gContestResultsTitle_Hyper_Tilemap[]; +extern const u16 gContestResultsTitle_Master_Tilemap[]; +extern const u16 gContestResultsTitle_Cool_Tilemap[]; +extern const u16 gContestResultsTitle_Beauty_Tilemap[]; +extern const u16 gContestResultsTitle_Cute_Tilemap[]; +extern const u16 gContestResultsTitle_Smart_Tilemap[]; +extern const u16 gContestResultsTitle_Tough_Tilemap[]; +extern const u16 gContestResultsTitle_Tilemap[]; // Trainer Card. extern const u16 gHoennTrainerCard0Star_Pal[]; diff --git a/src/contest_util.c b/src/contest_util.c index 98854c4c6..700e44606 100644 --- a/src/contest_util.c +++ b/src/contest_util.c @@ -61,10 +61,29 @@ enum { #define GET_CONTEST_WINNER_ID(i) { for ((i) = 0; (i) < CONTESTANT_COUNT && gContestFinalStandings[(i)] != 0; (i)++); } +// Gfx/pal tags for the text window sprites on the contest results screen. +// Both types of text windows are made up of 4 individual sprites +// These tags are used by the spritesheets, and implicitly in the loop in CreateResultsTextWindowSprites +#define TAG_TEXT_WINDOW_BASE 3009 +enum { + TAG_RESULTS_TEXT_WINDOW_LEFT = TAG_TEXT_WINDOW_BASE, + TAG_RESULTS_TEXT_WINDOW_MIDLEFT, + TAG_RESULTS_TEXT_WINDOW_MIDRIGHT, + TAG_RESULTS_TEXT_WINDOW_RIGHT, + TAG_LINK_TEXT_WINDOW_LEFT, + TAG_LINK_TEXT_WINDOW_MIDLEFT, + TAG_LINK_TEXT_WINDOW_MIDRIGHT, + TAG_LINK_TEXT_WINDOW_RIGHT, // 3016 +}; #define TAG_CONFETTI 3017 +#define TAG_WIRELESS_INDICATOR_WINDOW 22222 #define MAX_BAR_LENGTH 87 +// Starting x/y for the sliding results screen text box +#define TEXT_BOX_X (DISPLAY_WIDTH + 32) +#define TEXT_BOX_Y (DISPLAY_HEIGHT - 16) + struct ContestResultsInternal { u8 slidingTextBoxSpriteId; @@ -105,14 +124,14 @@ struct ContestResults static EWRAM_DATA struct ContestResults *sContestResults = NULL; static void LoadAllContestMonIconPalettes(void); -static void LoadContestResultsTilemaps(void); +static void LoadContestResultsTitleBarTilemaps(void); static u8 GetNumPreliminaryPoints(u8, bool8); static s8 GetNumRound2Points(u8, bool8); static void AddContestTextPrinter(int, u8 *, int); static void AllocContestResults(void); static void FreeContestResults(void); static void LoadAllContestMonIcons(u8, u8); -static void LoadContestResultSprites(void); +static void CreateResultsTextWindowSprites(void); static void TryCreateWirelessSprites(void); static void Task_StartShowContestResults(u8 taskId); static void CB2_StartShowContestResults(void); @@ -166,11 +185,11 @@ static void SpriteCB_Confetti(struct Sprite *sprite); static void Task_ShowContestEntryMonPic(u8 taskId); static void Task_LinkContestWaitForConnection(u8 taskId); -static const u16 sUnknown_0858D6B0[] = INCBIN_U16("graphics/unknown/unknown_58D6B0.gbapal"); -static const u8 sUnknown_0858D6D0[] = INCBIN_U8("graphics/unknown/unknown_58D6D0.4bpp"); +static const u16 sResultsTextWindow_Pal[] = INCBIN_U16("graphics/contest/results_screen/text_window.gbapal"); +static const u8 sResultsTextWindow_Gfx[] = INCBIN_U8("graphics/contest/results_screen/text_window.4bpp"); static const u16 sMiscBlank_Pal[] = INCBIN_U16("graphics/interface/blank.gbapal"); -static const struct OamData sOamData_858D7F0 = +static const struct OamData sOamData_ResultsTextWindow = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -187,33 +206,33 @@ static const struct OamData sOamData_858D7F0 = .affineParam = 0, }; -static const struct SpriteTemplate sSpriteTemplate_858D7F8 = +static const struct SpriteTemplate sSpriteTemplate_ResultsTextWindow = { - .tileTag = 3009, - .paletteTag = 3009, - .oam = &sOamData_858D7F0, + .tileTag = TAG_TEXT_WINDOW_BASE, + .paletteTag = TAG_TEXT_WINDOW_BASE, + .oam = &sOamData_ResultsTextWindow, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteSheet sUnknown_0858D810[] = +static const struct SpriteSheet sSpriteSheets_ResultsTextWindow[] = { - { .data = gMiscBlank_Gfx, .size = 0x400, .tag = 3009 }, - { .data = gMiscBlank_Gfx, .size = 0x400, .tag = 3010 }, - { .data = gMiscBlank_Gfx, .size = 0x400, .tag = 3011 }, - { .data = gMiscBlank_Gfx, .size = 0x400, .tag = 3012 }, - { .data = gMiscBlank_Gfx, .size = 0x400, .tag = 3013 }, - { .data = gMiscBlank_Gfx, .size = 0x400, .tag = 3014 }, - { .data = gMiscBlank_Gfx, .size = 0x400, .tag = 3015 }, - { .data = gMiscBlank_Gfx, .size = 0x400, .tag = 3016 }, + { .data = gMiscBlank_Gfx, .size = 0x400, .tag = TAG_RESULTS_TEXT_WINDOW_LEFT }, + { .data = gMiscBlank_Gfx, .size = 0x400, .tag = TAG_RESULTS_TEXT_WINDOW_MIDLEFT }, + { .data = gMiscBlank_Gfx, .size = 0x400, .tag = TAG_RESULTS_TEXT_WINDOW_MIDRIGHT }, + { .data = gMiscBlank_Gfx, .size = 0x400, .tag = TAG_RESULTS_TEXT_WINDOW_RIGHT }, + { .data = gMiscBlank_Gfx, .size = 0x400, .tag = TAG_LINK_TEXT_WINDOW_LEFT }, + { .data = gMiscBlank_Gfx, .size = 0x400, .tag = TAG_LINK_TEXT_WINDOW_MIDLEFT }, + { .data = gMiscBlank_Gfx, .size = 0x400, .tag = TAG_LINK_TEXT_WINDOW_MIDRIGHT }, + { .data = gMiscBlank_Gfx, .size = 0x400, .tag = TAG_LINK_TEXT_WINDOW_RIGHT }, }; -static const struct SpritePalette sUnknown_0858D850 = +static const struct SpritePalette sSpritePalette_ResultsTextWindow = { .data = sMiscBlank_Pal, - .tag = 3009, + .tag = TAG_TEXT_WINDOW_BASE, }; static const struct OamData sOamData_Confetti = @@ -339,7 +358,7 @@ static const struct WindowTemplate sWindowTemplates[] = DUMMY_WIN_TEMPLATE, }; -static const struct OamData sUnknown_0858D8C0 = +static const struct OamData sOamData_WirelessIndicatorWindow = { .y = 0, .affineMode = ST_OAM_AFFINE_OFF, @@ -357,22 +376,22 @@ static const struct OamData sUnknown_0858D8C0 = }; -static const struct SpriteTemplate sSpriteTemplate_858D8C8 = +static const struct SpriteTemplate sSpriteTemplate_WirelessIndicatorWindow = { - .tileTag = 22222, + .tileTag = TAG_WIRELESS_INDICATOR_WINDOW, .paletteTag = 0, - .oam = &sUnknown_0858D8C0, + .oam = &sOamData_WirelessIndicatorWindow, .anims = gDummySpriteAnimTable, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallbackDummy }; -static const struct SpriteSheet sUnknown_0858D8E0 = +static const struct SpriteSheet sSpriteSheet_WirelessIndicatorWindow = { .data = gMiscBlank_Gfx, .size = 0x200, - .tag = 22222 + .tag = TAG_WIRELESS_INDICATOR_WINDOW }; static const u8 sContestLinkTextColors[4] = {TEXT_COLOR_WHITE, TEXT_DYNAMIC_COLOR_6, TEXT_DYNAMIC_COLOR_5}; @@ -430,12 +449,12 @@ static void LoadContestResultsBgGfx(void) u16 tile1, tile2; LZDecompressVram(gContestResults_Gfx, (void *)BG_CHAR_ADDR(0)); - CopyToBgTilemapBuffer(3, gUnknown_08C1A12C, 0, 0); - CopyToBgTilemapBuffer(2, gUnknown_08C1A000, 0, 0); - CopyToBgTilemapBuffer(0, gUnknown_08C19EEC, 0, 0); - LoadContestResultsTilemaps(); + CopyToBgTilemapBuffer(3, gContestResults_Bg_Tilemap, 0, 0); + CopyToBgTilemapBuffer(2, gContestResults_Interface_Tilemap, 0, 0); + CopyToBgTilemapBuffer(0, gContestResults_WinnerBanner_Tilemap, 0, 0); + LoadContestResultsTitleBarTilemaps(); LoadCompressedPalette(gContestResults_Pal, 0, 0x200); - LoadPalette(sUnknown_0858D6B0, 0xF0, 0x20); + LoadPalette(sResultsTextWindow_Pal, 0xF0, sizeof(sResultsTextWindow_Pal)); for (i = 0; i < CONTESTANT_COUNT; i++) { @@ -515,14 +534,14 @@ static void CB2_StartShowContestResults(void) LoadAllContestMonNames(); memset(sContestResults->data, 0, sizeof(*sContestResults->data)); memset(sContestResults->monResults, 0, sizeof(*sContestResults->monResults)); - LoadContestResultSprites(); + CreateResultsTextWindowSprites(); TryCreateWirelessSprites(); BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK); gPaletteFade.bufferTransferDisabled = FALSE; sContestResults->data->showResultsTaskId = CreateTask(Task_ShowContestResults, 5); SetMainCallback2(CB2_ShowContestResults); gBattle_WIN1H = WIN_RANGE(0, DISPLAY_WIDTH); - gBattle_WIN1V = WIN_RANGE(128, DISPLAY_HEIGHT); + gBattle_WIN1V = WIN_RANGE(DISPLAY_HEIGHT - 32, DISPLAY_HEIGHT); CreateTask(Task_SlideContestResultsBg, 20); CalculateContestantsResultData(); if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_WIRELESS) @@ -679,7 +698,7 @@ static void Task_AnnouncePreliminaryResults(u8 taskId) { CreateTask(Task_FlashStarsAndHearts, 20); x = DrawResultsTextWindow(gText_AnnouncingResults, sContestResults->data->slidingTextBoxSpriteId); - StartTextBoxSlideIn(x, DISPLAY_HEIGHT - 16, 120, 1088); + StartTextBoxSlideIn(x, TEXT_BOX_Y, 120, 1088); gTasks[taskId].tState++; } else if (gTasks[taskId].tState == 1) @@ -702,7 +721,7 @@ static void Task_AnnouncePreliminaryResults(u8 taskId) else if (gTasks[taskId].tState == 3) { x = DrawResultsTextWindow(gText_PreliminaryResults, sContestResults->data->slidingTextBoxSpriteId); - StartTextBoxSlideIn(x, DISPLAY_HEIGHT - 16, -1, 1088); + StartTextBoxSlideIn(x, TEXT_BOX_Y, -1, 1088); gTasks[taskId].tState++; } else if (gTasks[taskId].tState == 4) @@ -752,7 +771,7 @@ static void Task_AnnounceRound2Results(u8 taskId) { gTasks[taskId].tTimer = 0; x = DrawResultsTextWindow(gText_Round2Results, sContestResults->data->slidingTextBoxSpriteId); - StartTextBoxSlideIn(x, DISPLAY_HEIGHT - 16, -1, 1088); + StartTextBoxSlideIn(x, TEXT_BOX_Y, -1, 1088); } } else if (sContestResults->data->slidingTextBoxState == SLIDING_TEXT_ARRIVED) @@ -841,7 +860,7 @@ static void Task_AnnounceWinner(u8 taskId) StringCopy(gStringVar2, gContestMons[i].nickname); StringExpandPlaceholders(winnerTextBuffer, gText_ContestantsMonWon); x = DrawResultsTextWindow(winnerTextBuffer, sContestResults->data->slidingTextBoxSpriteId); - StartTextBoxSlideIn(x, DISPLAY_HEIGHT - 16, -1, 1088); + StartTextBoxSlideIn(x, TEXT_BOX_Y, -1, 1088); gTasks[taskId].tState++; } break; @@ -892,7 +911,7 @@ static void Task_ShowWinnerMonBanner(u8 taskId) LoadCompressedSpritePalette(pokePal); SetMultiuseSpriteTemplateToPokemon(species, B_POSITION_OPPONENT_LEFT); gMultiuseSpriteTemplate.paletteTag = pokePal->tag; - spriteId = CreateSprite(&gMultiuseSpriteTemplate, DISPLAY_WIDTH + 32, 80, 10); + spriteId = CreateSprite(&gMultiuseSpriteTemplate, DISPLAY_WIDTH + 32, DISPLAY_HEIGHT / 2, 10); gSprites[spriteId].data[1] = species; gSprites[spriteId].oam.priority = 0; gSprites[spriteId].callback = SpriteCB_WinnerMonSlideIn; @@ -1136,9 +1155,9 @@ static void TryCreateWirelessSprites(void) LoadWirelessStatusIndicatorSpriteGfx(); CreateWirelessStatusIndicatorSprite(8, 8); gSprites[gWirelessStatusIndicatorSpriteId].subpriority = 1; - sheet = LoadSpriteSheet(&sUnknown_0858D8E0); + sheet = LoadSpriteSheet(&sSpriteSheet_WirelessIndicatorWindow); RequestDma3Fill(0xFFFFFFFF, (void *)BG_CHAR_ADDR(4) + sheet * 0x20, 0x80, 1); - spriteId = CreateSprite(&sSpriteTemplate_858D8C8, 8, 8, 0); + spriteId = CreateSprite(&sSpriteTemplate_WirelessIndicatorWindow, 8, 8, 0); gSprites[spriteId].oam.objMode = ST_OAM_OBJ_WINDOW; } } @@ -1150,14 +1169,13 @@ static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId) int strWidth; u8 *spriteTilePtrs[4]; u8 *dst; - { - struct WindowTemplate windowTemplate; - memset(&windowTemplate, 0, sizeof(windowTemplate)); - windowTemplate.width = 30; - windowTemplate.height = 2; - windowId = AddWindow(&windowTemplate); - FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); - } + + struct WindowTemplate windowTemplate; + memset(&windowTemplate, 0, sizeof(windowTemplate)); + windowTemplate.width = 30; + windowTemplate.height = 2; + windowId = AddWindow(&windowTemplate); + FillWindowPixelBuffer(windowId, PIXEL_FILL(1)); origWidth = GetStringWidth(1, text, 0); strWidth = (origWidth + 9) / 8; @@ -1169,16 +1187,16 @@ static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId) s32 i; struct Sprite *sprite; const u8 *src, *windowTilesPtr; - windowTilesPtr = (u8 *)(GetWindowAttribute(windowId, WINDOW_TILE_DATA)); - src = (u8 *)(sUnknown_0858D6D0); + windowTilesPtr = (u8 *)GetWindowAttribute(windowId, WINDOW_TILE_DATA); + src = (u8 *)sResultsTextWindow_Gfx; sprite = &gSprites[spriteId]; spriteTilePtrs[0] = (u8 *)(sprite->oam.tileNum * 32 + OBJ_VRAM0); - for (i = 1; i < 4; i++) + for (i = 1; i < (int)ARRAY_COUNT(spriteTilePtrs); i++) spriteTilePtrs[i] = (void*)(gSprites[sprite->data[i - 1]].oam.tileNum * 32 + OBJ_VRAM0); - for (i = 0; i < 4; i++) + for (i = 0; i < (int)ARRAY_COUNT(spriteTilePtrs); i++) CpuFill32(0, spriteTilePtrs[i], 0x400); dst = spriteTilePtrs[0]; @@ -1208,27 +1226,31 @@ static s32 DrawResultsTextWindow(const u8 *text, u8 spriteId) return (DISPLAY_WIDTH - (strWidth + 2) * 8) / 2; } -static void LoadContestResultSprites(void) +static void CreateResultsTextWindowSprites(void) { int i; struct SpriteTemplate template; - u8 spriteIds[ARRAY_COUNT(sUnknown_0858D810)]; + u8 spriteIds[ARRAY_COUNT(sSpriteSheets_ResultsTextWindow)]; - template = sSpriteTemplate_858D7F8; - for (i = 0; i < (int)ARRAY_COUNT(sUnknown_0858D810); i++) - LoadSpriteSheet(&sUnknown_0858D810[i]); + template = sSpriteTemplate_ResultsTextWindow; + for (i = 0; i < (int)ARRAY_COUNT(sSpriteSheets_ResultsTextWindow); i++) + LoadSpriteSheet(&sSpriteSheets_ResultsTextWindow[i]); - LoadSpritePalette(&sUnknown_0858D850); - for (i = 0; i < (int)ARRAY_COUNT(sUnknown_0858D810); i++) + LoadSpritePalette(&sSpritePalette_ResultsTextWindow); + + // Create sprites for the two window types, each made up of 4 sprites + for (i = 0; i < (int)ARRAY_COUNT(sSpriteSheets_ResultsTextWindow); i++) { - spriteIds[i] = CreateSprite(&template, DISPLAY_WIDTH + 32, DISPLAY_HEIGHT - 16, 10); + spriteIds[i] = CreateSprite(&template, TEXT_BOX_X, TEXT_BOX_Y, 10); template.tileTag++; } + // Save sprite ids of the sliding text box onto its leftmost sprite gSprites[spriteIds[0]].data[0] = spriteIds[1]; gSprites[spriteIds[0]].data[1] = spriteIds[2]; gSprites[spriteIds[0]].data[2] = spriteIds[3]; + // Save sprite ids of the link text box onto its leftmost sprite gSprites[spriteIds[4]].data[0] = spriteIds[5]; gSprites[spriteIds[4]].data[1] = spriteIds[6]; gSprites[spriteIds[4]].data[2] = spriteIds[7]; @@ -1248,7 +1270,7 @@ static void LoadContestResultSprites(void) static void StartTextBoxSlideIn(s16 x, u16 y, u16 slideOutTimer, u16 slideIncrement) { struct Sprite *sprite = &gSprites[sContestResults->data->slidingTextBoxSpriteId]; - sprite->pos1.x = DISPLAY_WIDTH + 32; + sprite->pos1.x = TEXT_BOX_X; sprite->pos1.y = y; sprite->pos2.x = 0; sprite->pos2.y = 0; @@ -1275,8 +1297,8 @@ static void StartTextBoxSlideOut(u16 slideIncrement) static void EndTextBoxSlideOut(struct Sprite *sprite) { - sprite->pos1.x = DISPLAY_WIDTH + 32; - sprite->pos1.y = DISPLAY_HEIGHT - 16; + sprite->pos1.x = TEXT_BOX_X; + sprite->pos1.y = TEXT_BOX_Y; sprite->pos2.y = 0; sprite->pos2.x = 0; sprite->callback = SpriteCallbackDummy; @@ -1377,7 +1399,7 @@ static void HideLinkResultsTextBox(void) | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); } -static void LoadContestResultsTilemaps(void) +static void LoadContestResultsTitleBarTilemaps(void) { u8 palette; int x, y; @@ -1386,58 +1408,58 @@ static void LoadContestResultsTilemaps(void) y = 1; if (gLinkContestFlags & LINK_CONTEST_FLAG_IS_LINK) { - CopyToBgTilemapBufferRect(2, gLinkContestResults_Tilemap, 5, 1, 5, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Link_Tilemap, 5, 1, 5, 2); x = 10; } else if (gSpecialVar_ContestRank == CONTEST_RANK_NORMAL) { - CopyToBgTilemapBufferRect(2, gNormalContestResults_Tilemap, 5, 1, 10, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Normal_Tilemap, 5, 1, 10, 2); x = 15; } else if (gSpecialVar_ContestRank == CONTEST_RANK_SUPER) { - CopyToBgTilemapBufferRect(2, gSuperContestResults_Tilemap, 5, 1, 10, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Super_Tilemap, 5, 1, 10, 2); x = 15; } else if (gSpecialVar_ContestRank == CONTEST_RANK_HYPER) { - CopyToBgTilemapBufferRect(2, gHyperContestResults_Tilemap, 5, 1, 10, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Hyper_Tilemap, 5, 1, 10, 2); x = 15; } else // CONTEST_RANK_MASTER { - CopyToBgTilemapBufferRect(2, gMasterContestResults_Tilemap, 5, 1, 10, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Master_Tilemap, 5, 1, 10, 2); x = 15; } if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_COOL) { palette = 0; - CopyToBgTilemapBufferRect(2, gCoolContestResults_Tilemap, x, y, 5, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Cool_Tilemap, x, y, 5, 2); } else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_BEAUTY) { palette = 1; - CopyToBgTilemapBufferRect(2, gBeautyContestResults_Tilemap, x, y, 5, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Beauty_Tilemap, x, y, 5, 2); } else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_CUTE) { palette = 2; - CopyToBgTilemapBufferRect(2, gCuteContestResults_Tilemap, x, y, 5, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Cute_Tilemap, x, y, 5, 2); } else if (gSpecialVar_ContestCategory == CONTEST_CATEGORY_SMART) { palette = 3; - CopyToBgTilemapBufferRect(2, gSmartContestResults_Tilemap, x, y, 5, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Smart_Tilemap, x, y, 5, 2); } else // CONTEST_CATEGORY_TOUGH { palette = 4; - CopyToBgTilemapBufferRect(2, gToughContestResults_Tilemap, x, y, 5, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Tough_Tilemap, x, y, 5, 2); } x += 5; - CopyToBgTilemapBufferRect(2, gContestResults_Tilemap, x, y, 6, 2); + CopyToBgTilemapBufferRect(2, gContestResultsTitle_Tilemap, x, y, 6, 2); CopyToBgTilemapBufferRect_ChangePalette(2, sContestResults->tilemapBuffers[2], 0, 0, 32, 4, palette); } @@ -1567,10 +1589,10 @@ static void SpriteCB_WinnerMonSlideIn(struct Sprite *sprite) sprite->pos1.x -= delta >> 8; sprite->data[1] += 0x600; sprite->data[1] &= 0xFF; - if (sprite->pos1.x < 120) - sprite->pos1.x = 120; + if (sprite->pos1.x < DISPLAY_WIDTH / 2) + sprite->pos1.x = DISPLAY_WIDTH / 2; - if (sprite->pos1.x == 120) + if (sprite->pos1.x == DISPLAY_WIDTH / 2) { sprite->callback = SpriteCallbackDummy; sprite->data[1] = 0; @@ -1628,7 +1650,7 @@ static void SpriteCB_Confetti(struct Sprite *sprite) if (sContestResults->data->destroyConfetti) sprite->invisible = TRUE; - if (sprite->pos1.x > 248 || sprite->pos1.y > 116) + if (sprite->pos1.x > DISPLAY_WIDTH + 8 || sprite->pos1.y > 116) { DestroySprite(sprite); sContestResults->data->confettiCount--; diff --git a/src/graphics.c b/src/graphics.c index 09779eab7..d8991c535 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -471,11 +471,11 @@ const u8 gContestSliderHeart_Gfx[] = INCBIN_U8("graphics/contest/slider_heart.4b const u32 gUnknownGfx_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.4bpp.lz"); const u32 gUnknownPal_C19470[] = INCBIN_U32("graphics/unknown/unknown_C19470.gbapal.lz"); -const u32 gContestResults_Gfx[] = INCBIN_U32("graphics/contest/results_screen.4bpp.lz"); -const u32 gUnknown_08C19EEC[] = INCBIN_U32("graphics/contest/misc_2_tilemap_1.bin.lz"); -const u32 gUnknown_08C1A000[] = INCBIN_U32("graphics/contest/misc_2_tilemap_2.bin.lz"); -const u32 gUnknown_08C1A12C[] = INCBIN_U32("graphics/contest/misc_2_tilemap_3.bin.lz"); -const u32 gContestResults_Pal[] = INCBIN_U32("graphics/contest/results_screen.gbapal.lz"); +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"); +const u32 gContestResults_Bg_Tilemap[] = INCBIN_U32("graphics/contest/results_screen/bg.bin.lz"); +const u32 gContestResults_Pal[] = INCBIN_U32("graphics/contest/results_screen/tiles.gbapal.lz"); const u32 gBattleAnimSpriteGfx_Impact[] = INCBIN_U32("graphics/battle_anims/sprites/impact.4bpp.lz"); const u32 gBattleAnimSpritePal_Impact[] = INCBIN_U32("graphics/battle_anims/sprites/impact.gbapal.lz"); @@ -1296,17 +1296,17 @@ const u8 gBagMenuHMIcon_Gfx[] = INCBIN_U8("graphics/interface/hm.4bpp"); // contest results screen -const u16 gNormalContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_normal.bin"); -const u16 gSuperContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_super.bin"); -const u16 gHyperContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_hyper.bin"); -const u16 gMasterContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_master.bin"); -const u16 gLinkContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_link.bin"); -const u16 gCoolContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_cool.bin"); -const u16 gBeautyContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_beauty.bin"); -const u16 gCuteContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_cute.bin"); -const u16 gSmartContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_smart.bin"); -const u16 gToughContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen_tough.bin"); -const u16 gContestResults_Tilemap[] = INCBIN_U16("graphics/contest/results_screen.bin"); +const u16 gContestResultsTitle_Normal_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_normal.bin"); +const u16 gContestResultsTitle_Super_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_super.bin"); +const u16 gContestResultsTitle_Hyper_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_hyper.bin"); +const u16 gContestResultsTitle_Master_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_master.bin"); +const u16 gContestResultsTitle_Link_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_link.bin"); +const u16 gContestResultsTitle_Cool_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_cool.bin"); +const u16 gContestResultsTitle_Beauty_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_beauty.bin"); +const u16 gContestResultsTitle_Cute_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_cute.bin"); +const u16 gContestResultsTitle_Smart_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_smart.bin"); +const u16 gContestResultsTitle_Tough_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title_tough.bin"); +const u16 gContestResultsTitle_Tilemap[] = INCBIN_U16("graphics/contest/results_screen/title.bin"); // pokenav