From 475bb8a624b095002da00152b5a5f2ea67c55804 Mon Sep 17 00:00:00 2001 From: TheXaman <48356183+TheXaman@users.noreply.github.com> Date: Sun, 24 Oct 2021 16:31:19 +0200 Subject: [PATCH] added preEvolutions to the EvoScreen! --- graphics/pokedex/HGSS_tilemap_evo_screen.bin | Bin 1344 -> 1344 bytes include/strings.h | 1 + src/pokedex.c | 108 +++++++++++++++++-- src/strings.c | 1 + 4 files changed, 102 insertions(+), 8 deletions(-) diff --git a/graphics/pokedex/HGSS_tilemap_evo_screen.bin b/graphics/pokedex/HGSS_tilemap_evo_screen.bin index e7407faf7628b66172d24557d59dc387a2914607..bf66d4046358737f3f19cd5a674edb9f041274ba 100644 GIT binary patch delta 42 xcmX@Wb%1L^2cz}Gg_0B3@l0GNHQ9q{$K(b^4t7@tHz0JKJdsg-^ESpVW&lOk4e0;? delta 60 zcmX@Wb%1L^2cylzg_0B3@l0GN#pp2cpy9+{d|-OA6(f{U#mL9*&fo@wu9GJ+s&C%L H*u@M0o2?WW diff --git a/include/strings.h b/include/strings.h index 920af7e7a6..032370e5b7 100644 --- a/include/strings.h +++ b/include/strings.h @@ -605,6 +605,7 @@ extern const u8 gText_Dex_OWN[]; extern const u8 gText_EVO_Buttons_PE[]; extern const u8 gText_EVO_Buttons_Decapped_PE[]; extern const u8 gText_EVO_Name[]; +extern const u8 gText_EVO_PreEvo[]; extern const u8 gText_EVO_FRIENDSHIP[]; extern const u8 gText_EVO_FRIENDSHIP_DAY[]; extern const u8 gText_EVO_FRIENDSHIP_NIGHT[]; diff --git a/src/pokedex.c b/src/pokedex.c index 57649cb796..43385e22de 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -214,6 +214,7 @@ struct PokedexView u8 numLevelUpMoves; //HGSS_Ui u8 numTMHMMoves; //HGSS_Ui u8 numTutorMoves; //HGSS_Ui + u8 numPreEvolutions; //HGSS_Ui u16 selectedMonSpriteId; s16 pokeBallRotationStep; s16 pokeBallRotationBackup; @@ -368,6 +369,7 @@ static void Task_HandleEvolutionScreenInput(u8 taskId); static void Task_SwitchScreensFromEvolutionScreen(u8 taskId); static void Task_ExitEvolutionScreen(u8 taskId); static u8 PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 depth, u8 depth_i); +static u8 PrintPreEvolutions(u8 taskId, u16 species); //Stat bars on scrolling screens static void TryDestroyStatBars(void); static void TryDestroyStatBarsBg(void); @@ -7315,11 +7317,12 @@ static void Task_LoadEvolutionScreen(u8 taskId) //Icon FreeMonIconPalettes(); //Free space for new pallete LoadMonIconPalette(NationalPokedexNumToSpecies(sPokedexListItem->dexNum)); //Loads pallete for current mon + PrintPreEvolutions(taskId, NationalPokedexNumToSpecies(sPokedexListItem->dexNum)); #ifndef POKEMON_EXPANSION - gTasks[taskId].data[4] = CreateMonIcon(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), SpriteCB_MonIcon, 18, 31, 4, 0, TRUE); //Create pokemon sprite + gTasks[taskId].data[4] = CreateMonIcon(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), SpriteCB_MonIcon, 18 + 32*sPokedexView->numPreEvolutions, 31, 4, 0, TRUE); //Create pokemon sprite #endif #ifdef POKEMON_EXPANSION - gTasks[taskId].data[4] = CreateMonIcon(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), SpriteCB_MonIcon, 18, 31, 4, 0); //Create pokemon sprite + gTasks[taskId].data[4] = CreateMonIcon(NationalPokedexNumToSpecies(sPokedexListItem->dexNum), SpriteCB_MonIcon, 18 + 32*sPokedexView->numPreEvolutions, 31, 4, 0); //Create pokemon sprite EvoFormsPage_PrintAToggleUpdownEvos(); //HGSS_Ui Navigation buttons #endif gSprites[gTasks[taskId].data[4]].oam.priority = 0; @@ -7329,7 +7332,7 @@ static void Task_LoadEvolutionScreen(u8 taskId) case 4: //Print evo info and icons gTasks[taskId].data[3] = 0; - PrintEvolutionTargetSpeciesAndMethod(taskId, NationalPokedexNumToSpecies(sPokedexListItem->dexNum), 0, 0); + PrintEvolutionTargetSpeciesAndMethod(taskId, NationalPokedexNumToSpecies(sPokedexListItem->dexNum), 0, sPokedexView->numPreEvolutions); gMain.state++; break; case 5: @@ -7464,19 +7467,108 @@ static void CreateCaughtBallEvolutionScreen(u16 targetSpecies, u8 x, u8 y, u16 u { bool8 owned = GetSetPokedexFlag(SpeciesToNationalPokedexNum(targetSpecies), FLAG_GET_CAUGHT); if (owned) - BlitBitmapToWindow(0, sCaughtBall_Gfx, x, y, 8, 16); + BlitBitmapToWindow(0, sCaughtBall_Gfx, x, y-1, 8, 16); else { //FillWindowPixelRect(0, PIXEL_FILL(0), x, y, 8, 16); //not sure why this was even here - PrintInfoScreenTextSmall(gText_OneDash, x+1, y); + PrintInfoScreenTextSmall(gText_OneDash, x+1, y-1); } } +static void HandlePreEvolutionSpeciesPrint(u8 taskId, u16 preSpecies, u16 species, u8 base_x, u8 base_y, u8 base_y_offset, u8 base_i) +{ + bool8 seen = GetSetPokedexFlag(SpeciesToNationalPokedexNum(preSpecies), FLAG_GET_SEEN); + + StringCopy(gStringVar1, gSpeciesNames[species]); //evolution mon name + if (seen || !HGSS_HIDE_UNSEEN_EVOLUTION_NAMES) + StringCopy(gStringVar2, gSpeciesNames[preSpecies]); //evolution mon name + else + StringCopy(gStringVar2, gText_ThreeQuestionMarks); //show questionmarks instead of name + + StringExpandPlaceholders(gStringVar3, gText_EVO_PreEvo); //evolution mon name + PrintInfoScreenTextSmall(gStringVar3, base_x, base_y + base_y_offset*base_i); //evolution mon name + + if(base_i < 3) + { + LoadMonIconPalette(preSpecies); //Loads pallete for current mon + #ifndef POKEMON_EXPANSION + gTasks[taskId].data[4+base_i] = CreateMonIcon(preSpecies, SpriteCB_MonIcon, 18 + 32*base_i, 31, 4, 0, TRUE); //Create pokemon sprite + #endif + #ifdef POKEMON_EXPANSION + gTasks[taskId].data[4+base_i] = CreateMonIcon(preSpecies, SpriteCB_MonIcon, 18 + 32*base_i, 31, 4, 0); //Create pokemon sprite + #endif + gSprites[gTasks[taskId].data[4+base_i]].oam.priority = 0; + } +} + +static u8 PrintPreEvolutions(u8 taskId, u16 species) +{ + u16 i; + u16 j; + + u8 base_x = 13; + u8 base_x_offset = 54; + u8 base_y = 51; + u8 base_y_offset = 9; + u8 base_i = 0; + u8 depth_x = 16; + + u16 preEvolutionOne = 0; + u16 preEvolutionTwo = 0; + u8 numPreEvolutions = 0; + + //Calculate previous evolution + for (i = 0; i < NUM_SPECIES; i++) + { + for (j = 0; j < EVOS_PER_MON; j++) + { + if (gEvolutionTable[i][j].targetSpecies == species) + { + preEvolutionOne = i; + numPreEvolutions += 1; + break; + } + } + } + + //Calculate if previous evolution also has a previous evolution + if (numPreEvolutions != 0) + { + for (i = 0; i < NUM_SPECIES; i++) + { + for (j = 0; j < EVOS_PER_MON; j++) + { + if (gEvolutionTable[i][j].targetSpecies == preEvolutionOne) + { + preEvolutionTwo = i; + numPreEvolutions += 1; + CreateCaughtBallEvolutionScreen(preEvolutionTwo, base_x - 9, base_y + base_y_offset*0, 0); + HandlePreEvolutionSpeciesPrint(taskId, preEvolutionTwo, preEvolutionOne, base_x, base_y, base_y_offset, 0); + break; + } + } + } + } + + //Print ball and name + if (preEvolutionOne != 0) + { + CreateCaughtBallEvolutionScreen(preEvolutionOne, base_x - 9, base_y + base_y_offset*(numPreEvolutions - 1), 0); + HandlePreEvolutionSpeciesPrint(taskId, preEvolutionOne, species, base_x, base_y, base_y_offset, numPreEvolutions - 1); + } + + //vertical line + FillWindowPixelRect(0, PIXEL_FILL(5), 33 + 32*numPreEvolutions, 18, 1, 32); //PIXEL_FILL(15) for black + + sPokedexView->numPreEvolutions = numPreEvolutions; + + return numPreEvolutions; +} #define EVO_SCREEN_LVL_DIGITS 2 static u8 PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 depth, u8 depth_i) { - int i; + u16 i; #ifdef POKEMON_EXPANSION - int j; + u16 j; const struct MapHeader *mapHeader; #endif u16 targetSpecies = 0; @@ -7526,7 +7618,7 @@ static u8 PrintEvolutionTargetSpeciesAndMethod(u8 taskId, u16 species, u8 depth, if (times == 0 && depth == 0) { StringExpandPlaceholders(gStringVar4, gText_EVO_NONE); - PrintInfoScreenTextSmall(gStringVar4, base_x-7, base_y + base_y_offset*base_i); + PrintInfoScreenTextSmall(gStringVar4, base_x-7, base_y + base_y_offset*depth_i); } //If there are evolutions find out which and print them 1 by 1 diff --git a/src/strings.c b/src/strings.c index 849bc1f630..678e187c6c 100644 --- a/src/strings.c +++ b/src/strings.c @@ -1891,6 +1891,7 @@ const u8 gText_Dex_OWN[] = _("OWN"); const u8 gText_EVO_Buttons_PE[] = _("{A_BUTTON}FORMS"); const u8 gText_EVO_Buttons_Decapped_PE[] = _("{A_BUTTON}Forms"); const u8 gText_EVO_Name[] = _("{STR_VAR_3}:"); +const u8 gText_EVO_PreEvo[] = _("{STR_VAR_1} evolves from {STR_VAR_2}"); const u8 gText_EVO_FRIENDSHIP[] = _("LvlUp, high friendship"); const u8 gText_EVO_FRIENDSHIP_DAY[] = _("LvlUp, high friendship, day"); const u8 gText_EVO_FRIENDSHIP_NIGHT[] = _("Lvlup, high friendship, night");