From a8f6fb4cfa9693b631972018fbe6330fa8dda37c Mon Sep 17 00:00:00 2001 From: PCG06 Date: Sat, 24 Feb 2024 16:49:41 +0530 Subject: [PATCH] Imperial vs Metric system PR: https://github.com/rh-hideout/pokeemerald-expansion/pull/4183/ --- include/config.h | 17 +- include/constants/pokedex.h | 20 +++ include/pokedex.h | 1 + include/strings.h | 2 + src/battle_script_commands.c | 5 +- src/battle_util.c | 4 +- src/pokedex.c | 303 +++++++++++++++++++++++++++-------- src/pokedex_plus_hgss.c | 106 +----------- src/pokemon_size_record.c | 8 +- src/strings.c | 2 + 10 files changed, 278 insertions(+), 190 deletions(-) diff --git a/include/config.h b/include/config.h index 9d183e00186d..aed616ea396b 100755 --- a/include/config.h +++ b/include/config.h @@ -34,16 +34,6 @@ #define LOG_HANDLER (LOG_HANDLER_MGBA_PRINT) #endif -#define ENGLISH - -#ifdef ENGLISH -#define UNITS_IMPERIAL -#define CHAR_DEC_SEPARATOR CHAR_PERIOD // Period is used as a decimal separator only in the UK and the US. -#else -#define UNITS_METRIC -#define CHAR_DEC_SEPARATOR CHAR_COMMA -#endif - // Uncomment to fix some identified minor bugs #define BUGFIX @@ -77,4 +67,11 @@ #define EXPANSION_INTRO TRUE // If TRUE, a custom RHH intro will play after the vanilla copyright screen. #define POKEDEX_PLUS_HGSS TRUE // If TRUE, enables the custom HGSS style Pokedex. +// Measurement system constants to be used for UNITS +#define UNITS_IMPERIAL 0 // Inches, feet, pounds +#define UNITS_METRIC 1 // meters, kilograms + +#define UNITS UNITS_IMPERIAL +#define CHAR_DEC_SEPARATOR CHAR_PERIOD // CHAR_PERIOD is used as a decimal separator only in the UK and the US. The rest of the world uses CHAR_COMMA. + #endif // GUARD_CONFIG_H diff --git a/include/constants/pokedex.h b/include/constants/pokedex.h index 83cbab378cb2..17b22fb467bd 100755 --- a/include/constants/pokedex.h +++ b/include/constants/pokedex.h @@ -1284,4 +1284,24 @@ enum { #define HOENN_DEX_COUNT (HOENN_DEX_DEOXYS + 1) +#define DECAGRAMS_IN_POUND 4536 +#define CM_PER_INCH 2.54 +#define CM_PER_INCH_FACTOR (CM_PER_INCH * 100) +#define INCHES_IN_FOOT 12 +#define INCHES_IN_ONE_AND_HALF_FOOT (INCHES_IN_FOOT * 1.5) +#define INCHES_IN_FOOT_FACTOR (INCHES_IN_FOOT * 10) + +#define WEIGHT_HEIGHT_STR_LEN 16 +#define WEIGHT_HEIGHT_STR_MEM (WEIGHT_HEIGHT_STR_LEN * sizeof(u8)) + +#define DEX_HEADER_X 96 +#define DEX_Y_TOP 57 +#define DEX_Y_BOTTOM 73 +#define DEX_MEASUREMENT_X 129 + +#define DEX_HGSS_HEADER_X_PADDING 59 +#define DEX_HGSS_Y_TOP_PADDING 7 +#define DEX_HGSS_Y_BOTTOM_PADDING 4 +#define DEX_HGSS_MEASUREMENT_X_PADDING 51 + #endif // GUARD_CONSTANTS_POKEDEX_H diff --git a/include/pokedex.h b/include/pokedex.h index a28024898172..e86330a86dd6 100755 --- a/include/pokedex.h +++ b/include/pokedex.h @@ -43,5 +43,6 @@ bool16 HasAllHoennMons(void); void ResetPokedexScrollPositions(void); bool16 HasAllMons(void); void CB2_OpenPokedex(void); +void PrintMonMeasurements(u16 species, u32 owned); #endif // GUARD_POKEDEX_H diff --git a/include/strings.h b/include/strings.h index 88ba2231cf37..1fc3b4fbae06 100755 --- a/include/strings.h +++ b/include/strings.h @@ -548,7 +548,9 @@ extern const u8 gText_PokedexRegistration[]; extern const u8 gText_NumberClear01[]; extern const u8 gText_5MarksPokemon[]; extern const u8 gText_UnkHeight[]; +extern const u8 gText_UnkHeightMetric[]; extern const u8 gText_UnkWeight[]; +extern const u8 gText_UnkWeightMetric[]; extern const u8 gText_HTHeight[]; extern const u8 gText_WTWeight[]; extern const u8 gText_SearchingPleaseWait[]; diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index a170b36e17c9..aae7b78bce28 100755 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -95,6 +95,8 @@ #define MEMBERS_7(a, b, c, d, e, f, g) a; b; c; d; e; f; g; #define MEMBERS_8(a, b, c, d, e, f, g, h) a; b; c; d; e; f; g; h; +extern const struct PokedexEntry gPokedexEntries[]; + extern struct Evolution gEvolutionTable[][EVOS_PER_MON]; extern const u8 *const gBattleScriptsForMoveEffects[]; @@ -14919,6 +14921,7 @@ static void Cmd_handleballthrow(void) { u32 odds, i; u8 catchRate; + u16 species; gLastThrownBall = gLastUsedItem; gBallToDisplay = gLastThrownBall; @@ -15031,7 +15034,7 @@ static void Cmd_handleballthrow(void) ballMultiplier = 400; break; case ITEM_HEAVY_BALL: - i = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[gBattlerTarget].species), 1); + i = gPokedexEntries[SanitizeSpeciesId(species)].weight; if (B_HEAVY_BALL_MODIFIER >= GEN_7) { if (i < 1000) diff --git a/src/battle_util.c b/src/battle_util.c index ef4af34460fb..05ba94b9d8cb 100755 --- a/src/battle_util.c +++ b/src/battle_util.c @@ -68,6 +68,7 @@ extern const u8 *const gBattleScriptsForMoveEffects[]; extern const u8 *const gBattlescriptsForRunningByItem[]; extern const u8 *const gBattlescriptsForUsingItem[]; extern const u8 *const gBattlescriptsForSafariActions[]; +extern const struct PokedexEntry gPokedexEntries[]; static const u8 sPkblToEscapeFactor[][3] = { { @@ -8744,7 +8745,8 @@ u32 GetMoveSlot(u16 *moves, u32 move) u32 GetBattlerWeight(u32 battler) { u32 i; - u32 weight = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(gBattleMons[battler].species), 1); + u16 species; + u32 weight = gPokedexEntries[SanitizeSpeciesId(species)].weight; u32 ability = GetBattlerAbility(battler); u32 holdEffect = GetBattlerHoldEffect(battler, TRUE); diff --git a/src/pokedex.c b/src/pokedex.c index 45ca55478e6d..7f9a51c5a7e5 100755 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -275,8 +275,19 @@ static void Task_HandleCaughtMonPageInput(u8); static void Task_ExitCaughtMonPage(u8); static void SpriteCB_SlideCaughtMonToCenter(struct Sprite *sprite); static void PrintMonInfo(u32 num, u32, u32 owned, u32 newEntry); -static void PrintMonHeight(u16 height, u8 left, u8 top); -static void PrintMonWeight(u16 weight, u8 left, u8 top); +static u32 GetMeasurementTextPositions(u32 textElement); +static void PrintUnknownMonMeasurements(void); +static u8* GetUnknownMonHeightString(void); +static u8* GetUnknownMonWeightString(void); +static u8* ReplaceDecimalSeparator(const u8* originalString); +static void PrintOwnedMonMeasurements(u16 species); +static void PrintOwnedMonHeight(u16 species); +static void PrintOwnedMonWeight(u16 species); +static u8* ConvertMonHeightToImperialString(u32 height); +static u8* ConvertMonHeightToMetricString(u32 height); +static u8* ConvertMonWeightToImperialString(u32 weight); +static u8* ConvertMonWeightToMetricString(u32 weight); +static u8* ConvertMeasurementToMetricString(u16 num, u32* index); static void ResetOtherVideoRegisters(u16); static u8 PrintCryScreenSpeciesName(u8, u16, u8, u8); static void PrintDecimalNum(u8 windowId, u16 num, u8 left, u8 top); @@ -4125,6 +4136,7 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) { u8 str[0x10]; u8 str2[0x30]; + u16 species; u16 natNum; const u8 *name; const u8 *category; @@ -4171,132 +4183,287 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) category = gText_5MarksPokemon; } PrintInfoScreenText(category, 0x64, 0x29); - PrintInfoScreenText(gText_HTHeight, 0x60, 0x39); - PrintInfoScreenText(gText_WTWeight, 0x60, 0x49); + PrintMonMeasurements(species,owned); + if (owned) + description = gPokedexEntries[num].description; + else + description = sExpandedPlaceholder_PokedexDescription; + PrintInfoScreenText(description, GetStringCenterAlignXOffset(FONT_NORMAL, description, DISPLAY_WIDTH), 95); +} + +void PrintMonMeasurements(u16 species, u32 owned) +{ + u32 x = GetMeasurementTextPositions(DEX_HEADER_X); + u32 yTop = GetMeasurementTextPositions(DEX_Y_TOP); + u32 yBottom = GetMeasurementTextPositions(DEX_Y_BOTTOM); + + PrintInfoScreenText(gText_HTHeight, x, yTop); + PrintInfoScreenText(gText_WTWeight, x, yBottom); + if (owned) + PrintOwnedMonMeasurements(species); + else + PrintUnknownMonMeasurements(); +} + +static u32 GetMeasurementTextPositions(u32 textElement) +{ + if (!POKEDEX_PLUS_HGSS) + return textElement; + + switch(textElement) { - PrintMonHeight(gPokedexEntries[num].height, 0x81, 0x39); - PrintMonWeight(gPokedexEntries[num].weight, 0x81, 0x49); + case DEX_HEADER_X: + return (DEX_HEADER_X + DEX_HGSS_HEADER_X_PADDING); + case DEX_Y_TOP: + return (DEX_Y_TOP + DEX_HGSS_Y_TOP_PADDING); + case DEX_Y_BOTTOM: + return (DEX_Y_BOTTOM + DEX_HGSS_Y_BOTTOM_PADDING); + default: + case DEX_MEASUREMENT_X: + return (DEX_MEASUREMENT_X + DEX_HGSS_MEASUREMENT_X_PADDING); } +} + +static void PrintUnknownMonMeasurements(void) +{ + u8* heightString = GetUnknownMonHeightString(); + u8* weightString = GetUnknownMonWeightString(); + + u32 x = GetMeasurementTextPositions(DEX_MEASUREMENT_X); + u32 yTop = GetMeasurementTextPositions(DEX_Y_TOP); + u32 yBottom = GetMeasurementTextPositions(DEX_Y_BOTTOM); + + PrintInfoScreenText(heightString, x, yTop); + PrintInfoScreenText(weightString, x, yBottom); + + Free(heightString); + Free(weightString); +} + +static u8* GetUnknownMonHeightString(void) +{ + if (UNITS == UNITS_IMPERIAL) + return ReplaceDecimalSeparator(gText_UnkHeight); else + return ReplaceDecimalSeparator(gText_UnkHeightMetric); +} + +static u8* GetUnknownMonWeightString(void) +{ + if (UNITS == UNITS_IMPERIAL) + return ReplaceDecimalSeparator(gText_UnkWeight); + else + return ReplaceDecimalSeparator(gText_UnkWeightMetric); +} + +static u8* ReplaceDecimalSeparator(const u8* originalString) +{ + bool32 replaced = FALSE; + u32 length = StringLength(originalString), i; + u8* modifiedString = Alloc(WEIGHT_HEIGHT_STR_MEM); + + for (i = 0; i < length; i++) { - PrintInfoScreenText(gText_UnkHeight, 0x81, 0x39); - PrintInfoScreenText(gText_UnkWeight, 0x81, 0x49); + if ((originalString[i] != CHAR_PERIOD) || replaced) + { + modifiedString[i] = originalString[i]; + continue; + } + + modifiedString[i] = CHAR_DEC_SEPARATOR; + replaced = TRUE; } - if (owned) - description = gPokedexEntries[num].description; + modifiedString[length] = EOS; + return modifiedString; +} + +static void PrintOwnedMonMeasurements(u16 species) +{ + PrintOwnedMonHeight(species); + PrintOwnedMonWeight(species); +} + +static void PrintOwnedMonHeight(u16 species) +{ + u32 height = gPokedexEntries[SanitizeSpeciesId(species)].height; + u8* heightString; + + u32 x = GetMeasurementTextPositions(DEX_MEASUREMENT_X); + u32 yTop = GetMeasurementTextPositions(DEX_Y_TOP); + + if (UNITS == UNITS_IMPERIAL) + heightString = ConvertMonHeightToImperialString(height); else - description = sExpandedPlaceholder_PokedexDescription; - PrintInfoScreenText(description, GetStringCenterAlignXOffset(FONT_NORMAL, description, DISPLAY_WIDTH), 95); + heightString = ConvertMonHeightToMetricString(height); + + PrintInfoScreenText(heightString, x, yTop); + Free(heightString); } -static void PrintMonHeight(u16 height, u8 left, u8 top) +static void PrintOwnedMonWeight(u16 species) { - u8 buffer[16]; - u32 inches, feet; - u8 i = 0; + u32 weight = gPokedexEntries[SanitizeSpeciesId(species)].weight; + u8* weightString; + u32 x = GetMeasurementTextPositions(DEX_MEASUREMENT_X); + u32 yBottom = GetMeasurementTextPositions(DEX_Y_BOTTOM); + + if (UNITS == UNITS_IMPERIAL) + weightString = ConvertMonWeightToImperialString(weight); + else + weightString = ConvertMonWeightToMetricString(weight); + + PrintInfoScreenText(weightString, x, yBottom); + Free(weightString); +} - inches = (height * 10000) / 254; +static u8* ConvertMonHeightToImperialString(u32 height) +{ + u8* heightString = Alloc(WEIGHT_HEIGHT_STR_MEM); + u32 inches, feet, index = 0; + + inches = (height * 10000) / CM_PER_INCH_FACTOR; if (inches % 10 >= 5) inches += 10; - feet = inches / 120; - inches = (inches - (feet * 120)) / 10; + feet = inches / INCHES_IN_FOOT_FACTOR; + inches = (inches - (feet * INCHES_IN_FOOT_FACTOR)) / 10; - buffer[i++] = EXT_CTRL_CODE_BEGIN; - buffer[i++] = EXT_CTRL_CODE_CLEAR_TO; + heightString[index++] = EXT_CTRL_CODE_BEGIN; + heightString[index++] = EXT_CTRL_CODE_CLEAR_TO; if (feet / 10 == 0) { - buffer[i++] = 18; - buffer[i++] = feet + CHAR_0; + heightString[index++] = INCHES_IN_ONE_AND_HALF_FOOT; + heightString[index++] = feet + CHAR_0; } else { - buffer[i++] = 12; - buffer[i++] = feet / 10 + CHAR_0; - buffer[i++] = (feet % 10) + CHAR_0; + heightString[index++] = INCHES_IN_FOOT; + heightString[index++] = feet / 10 + CHAR_0; + heightString[index++] = (feet % 10) + CHAR_0; } - buffer[i++] = CHAR_SGL_QUOTE_RIGHT; - buffer[i++] = (inches / 10) + CHAR_0; - buffer[i++] = (inches % 10) + CHAR_0; - buffer[i++] = CHAR_DBL_QUOTE_RIGHT; - buffer[i++] = EOS; - PrintInfoScreenText(buffer, left, top); + heightString[index++] = CHAR_SGL_QUOTE_RIGHT; + heightString[index++] = (inches / 10) + CHAR_0; + heightString[index++] = (inches % 10) + CHAR_0; + heightString[index++] = CHAR_DBL_QUOTE_RIGHT; + heightString[index++] = EOS; + + return heightString; } -static void PrintMonWeight(u16 weight, u8 left, u8 top) +static u8* ConvertMonHeightToMetricString(u32 height) { - u8 buffer[16]; - bool8 output; - u8 i; - u32 lbs = (weight * 100000) / 4536; + u32 index = 0; + u8* heightString = ConvertMeasurementToMetricString(height, &index); + + heightString[index++] = CHAR_m; + heightString[index++] = EOS; + return heightString; +} + +static u8* ConvertMonWeightToImperialString(u32 weight) +{ + u8* weightString = Alloc(WEIGHT_HEIGHT_STR_MEM); + bool32 output = FALSE; + u32 index = 0, lbs = (weight * 100000) / DECAGRAMS_IN_POUND; if (lbs % 10u >= 5) lbs += 10; - i = 0; - output = FALSE; - if ((buffer[i] = (lbs / 100000) + CHAR_0) == CHAR_0 && !output) + if ((weightString[index] = (lbs / 100000) + CHAR_0) == CHAR_0 && !output) { - buffer[i++] = CHAR_SPACER; + weightString[index++] = CHAR_SPACER; } else { output = TRUE; - i++; + index++; } lbs %= 100000; - if ((buffer[i] = (lbs / 10000) + CHAR_0) == CHAR_0 && !output) + if ((weightString[index] = (lbs / 10000) + CHAR_0) == CHAR_0 && !output) { - buffer[i++] = CHAR_SPACER; + weightString[index++] = CHAR_SPACER; } else { output = TRUE; - i++; + index++; } lbs %= 10000; - if ((buffer[i] = (lbs / 1000) + CHAR_0) == CHAR_0 && !output) + if ((weightString[index] = (lbs / 1000) + CHAR_0) == CHAR_0 && !output) { - buffer[i++] = CHAR_SPACER; + weightString[index++] = CHAR_SPACER; } else { output = TRUE; - i++; + index++; } lbs %= 1000; - buffer[i++] = (lbs / 100) + CHAR_0; + weightString[index++] = (lbs / 100) + CHAR_0; lbs %= 100; - buffer[i++] = CHAR_PERIOD; - buffer[i++] = (lbs / 10) + CHAR_0; - buffer[i++] = CHAR_SPACE; - buffer[i++] = CHAR_l; - buffer[i++] = CHAR_b; - buffer[i++] = CHAR_s; - buffer[i++] = CHAR_PERIOD; - buffer[i++] = EOS; - PrintInfoScreenText(buffer, left, top); + weightString[index++] = CHAR_DEC_SEPARATOR; + weightString[index++] = (lbs / 10) + CHAR_0; + weightString[index++] = CHAR_SPACE; + weightString[index++] = CHAR_l; + weightString[index++] = CHAR_b; + weightString[index++] = CHAR_s; + weightString[index++] = CHAR_PERIOD; + weightString[index++] = EOS; + + return weightString; } -const u8 *GetPokedexCategoryName(u16 dexNum) // unused +static u8* ConvertMonWeightToMetricString(u32 weight) { - return gPokedexEntries[dexNum].categoryName; + u32 index = 0; + u8* weightString = ConvertMeasurementToMetricString(weight, &index); + + weightString[index++] = CHAR_k; + weightString[index++] = CHAR_g; + weightString[index++] = CHAR_PERIOD; + weightString[index++] = EOS; + return weightString; } -u16 GetPokedexHeightWeight(u16 dexNum, u8 data) +static u8* ConvertMeasurementToMetricString(u16 num, u32* index) { - switch (data) + u8* string = Alloc(WEIGHT_HEIGHT_STR_MEM); + bool32 outputted = FALSE; + u32 result; + + result = num / 1000; + if (result == 0) { - case 0: // height - return gPokedexEntries[dexNum].height; - case 1: // weight - return gPokedexEntries[dexNum].weight; - default: - return 1; + string[(*index)++] = CHAR_SPACER; + outputted = FALSE; } + else + { + string[(*index)++] = CHAR_0 + result; + outputted = TRUE; + } + + result = (num % 1000) / 100; + if (result == 0 && !outputted) + { + string[(*index)++] = CHAR_SPACER; + outputted = FALSE; + } + else + { + string[(*index)++] = CHAR_0 + result; + outputted = TRUE; + } + + string[(*index)++] = CHAR_0 + ((num % 1000) % 100) / 10; + string[(*index)++] = CHAR_DEC_SEPARATOR; + string[(*index)++] = CHAR_0 + ((num % 1000) % 100) % 10; + string[(*index)++] = CHAR_SPACE; + + return string; } s8 GetSetPokedexFlag(u16 nationalDexNo, u8 caseID) diff --git a/src/pokedex_plus_hgss.c b/src/pokedex_plus_hgss.c index c6eb53d3fbb0..ab2abfdb64f1 100644 --- a/src/pokedex_plus_hgss.c +++ b/src/pokedex_plus_hgss.c @@ -544,8 +544,6 @@ static void Task_HandleCaughtMonPageInput(u8); static void Task_ExitCaughtMonPage(u8); static void SpriteCB_SlideCaughtMonToCenter(struct Sprite *sprite); static void PrintMonInfo(u32 num, u32, u32 owned, u32 newEntry); -static void PrintMonHeight(u16 height, u8 left, u8 top); -static void PrintMonWeight(u16 weight, u8 left, u8 top); static void ResetOtherVideoRegisters(u16); static u8 PrintCryScreenSpeciesName(u8, u16, u8, u8); static void PrintDecimalNum(u8 windowId, u16 num, u8 left, u8 top); @@ -4509,18 +4507,7 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) category = gText_5MarksPokemon; } PrintInfoScreenText(category, 123, 31); - PrintInfoScreenText(gText_HTHeight, 155, 64); - PrintInfoScreenText(gText_WTWeight, 155, 77); - if (owned) - { - PrintMonHeight(gPokedexEntries[num].height, 180, 64); - PrintMonWeight(gPokedexEntries[num].weight, 180, 77); - } - else - { - PrintInfoScreenText(gText_UnkHeight, 180, 64); - PrintInfoScreenText(gText_UnkWeight, 180, 77); - } + PrintMonMeasurements(species,owned); if (owned) { description = gPokedexEntries[num].description; @@ -4534,97 +4521,6 @@ static void PrintMonInfo(u32 num, u32 value, u32 owned, u32 newEntry) PrintCurrentSpeciesTypeInfo(newEntry, species); } -static void PrintMonHeight(u16 height, u8 left, u8 top) -{ - u8 buffer[16]; - u32 inches, feet; - u8 i = 0; - - inches = (height * 10000) / 254; - if (inches % 10 >= 5) - inches += 10; - feet = inches / 120; - inches = (inches - (feet * 120)) / 10; - - buffer[i++] = EXT_CTRL_CODE_BEGIN; - buffer[i++] = EXT_CTRL_CODE_CLEAR_TO; - if (feet / 10 == 0) - { - buffer[i++] = 18; - buffer[i++] = feet + CHAR_0; - } - else - { - buffer[i++] = 12; - buffer[i++] = feet / 10 + CHAR_0; - buffer[i++] = (feet % 10) + CHAR_0; - } - buffer[i++] = CHAR_SGL_QUOTE_RIGHT; - buffer[i++] = (inches / 10) + CHAR_0; - buffer[i++] = (inches % 10) + CHAR_0; - buffer[i++] = CHAR_DBL_QUOTE_RIGHT; - buffer[i++] = EOS; - PrintInfoScreenText(buffer, left, top); -} - -static void PrintMonWeight(u16 weight, u8 left, u8 top) -{ - u8 buffer[16]; - bool8 output; - u8 i; - u32 lbs = (weight * 100000) / 4536; - - if (lbs % 10u >= 5) - lbs += 10; - i = 0; - output = FALSE; - - if ((buffer[i] = (lbs / 100000) + CHAR_0) == CHAR_0 && !output) - { - buffer[i++] = CHAR_SPACER; - } - else - { - output = TRUE; - i++; - } - - lbs %= 100000; - if ((buffer[i] = (lbs / 10000) + CHAR_0) == CHAR_0 && !output) - { - buffer[i++] = CHAR_SPACER; - } - else - { - output = TRUE; - i++; - } - - lbs %= 10000; - if ((buffer[i] = (lbs / 1000) + CHAR_0) == CHAR_0 && !output) - { - buffer[i++] = CHAR_SPACER; - } - else - { - output = TRUE; - i++; - } - - lbs %= 1000; - buffer[i++] = (lbs / 100) + CHAR_0; - lbs %= 100; - buffer[i++] = CHAR_PERIOD; - buffer[i++] = (lbs / 10) + CHAR_0; - buffer[i++] = CHAR_SPACE; - buffer[i++] = CHAR_l; - buffer[i++] = CHAR_b; - buffer[i++] = CHAR_s; - buffer[i++] = CHAR_PERIOD; - buffer[i++] = EOS; - PrintInfoScreenText(buffer, left, top); -} - // Unused in the English version, used to print height/weight in versions which use metric system. static void UNUSED PrintDecimalNum(u8 windowId, u16 num, u8 left, u8 top) { diff --git a/src/pokemon_size_record.c b/src/pokemon_size_record.c index bc2ffe1aea68..efa50e984f32 100755 --- a/src/pokemon_size_record.c +++ b/src/pokemon_size_record.c @@ -9,6 +9,8 @@ #define DEFAULT_MAX_SIZE 0x8000 // was 0x8100 in Ruby/Sapphire +extern const struct PokedexEntry gPokedexEntries[]; + struct UnknownStruct { u16 unk0; @@ -47,8 +49,6 @@ static const u8 sGiftRibbonsMonDataIds[GIFT_RIBBONS_COUNT - 4] = extern const u8 gText_DecimalPoint[]; extern const u8 gText_Marco[]; -#define CM_PER_INCH 2.54 - static u32 GetMonSizeHash(struct Pokemon *pkmn) { u16 personality = GetMonData(pkmn, MON_DATA_PERSONALITY); @@ -84,7 +84,7 @@ static u32 GetMonSize(u16 species, u16 b) u32 height; u32 var; - height = GetPokedexHeightWeight(SpeciesToNationalPokedexNum(species), 0); + height = gPokedexEntries[SanitizeSpeciesId(species)].height; var = TranslateBigMonSizeTableIndex(b); unk0 = sBigMonSizeTable[var].unk0; unk2 = sBigMonSizeTable[var].unk2; @@ -95,10 +95,8 @@ static u32 GetMonSize(u16 species, u16 b) static void FormatMonSizeRecord(u8 *string, u32 size) { -#ifdef UNITS_IMPERIAL //Convert size from centimeters to inches size = (f64)(size * 10) / (CM_PER_INCH * 10); -#endif string = ConvertIntToDecimalStringN(string, size / 10, STR_CONV_MODE_LEFT_ALIGN, 8); string = StringAppend(string, gText_DecimalPoint); diff --git a/src/strings.c b/src/strings.c index f330198def86..a9a90d7a9d18 100755 --- a/src/strings.c +++ b/src/strings.c @@ -100,7 +100,9 @@ const u8 gText_DefaultNameHalie[] = _("Halie"); const u8 gText_ThisIsAPokemon[] = _("This is what we call a “Pokémon.”{PAUSE 96}\p"); const u8 gText_5MarksPokemon[] = _("????? Pokémon"); const u8 gText_UnkHeight[] = _("{CLEAR_TO 0x0C}??'??”"); +const u8 gText_UnkHeightMetric[] = _("???.? m"); const u8 gText_UnkWeight[] = _("????.? lbs."); +const u8 gText_UnkWeightMetric[] = _("???.? kg."); const u8 gText_EmptyPkmnCategory[] = _(" Pokémon"); // Unused const u8 gText_EmptyHeight[] = _("{CLEAR_TO 0x0C} ' ”"); // Unused const u8 gText_EmptyWeight[] = _(" . lbs."); // Unused