Skip to content

Commit

Permalink
Merge branch 'upcoming' into _RHH/pr/upcoming/braces
Browse files Browse the repository at this point in the history
  • Loading branch information
Bassoonian authored Jan 30, 2024
2 parents 83711f7 + a64e1c6 commit 2e74bf7
Show file tree
Hide file tree
Showing 362 changed files with 13,292 additions and 18,067 deletions.
11 changes: 11 additions & 0 deletions charmap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ UP_ARROW = 79
DOWN_ARROW = 7A
LEFT_ARROW = 7B
RIGHT_ARROW = 7C
@ Case-fixing/unfixing chars
@ These are 1-2 pixel spaces in vanilla.
@ 7D collides with 'ヲ' in JP,
@ but that kana is practically unused in JP text.
FIXED_CASE = 7D
UNFIX_CASE = 7E

SUPER_E = 84
'<' = 85
'>' = 86
Expand Down Expand Up @@ -347,6 +354,10 @@ ARCHIE = FD 0A
MAXIE = FD 0B
KYOGRE = FD 0C
GROUDON = FD 0D
@ Like STR_VAR_X, but prepends CHAR_FIXED_CASE
STR_VAR_1_FIXED = FD 82
STR_VAR_2_FIXED = FD 83
STR_VAR_3_FIXED = FD 84

@ battle string placeholders

Expand Down
2 changes: 2 additions & 0 deletions data/battle_scripts_1.s
Original file line number Diff line number Diff line change
Expand Up @@ -5966,6 +5966,7 @@ BattleScript_PrintFullBox::

BattleScript_ActionSwitch::
hpthresholds2 BS_ATTACKER
copybyte sSAVED_BATTLER, gBattlerAttacker
printstring STRINGID_RETURNMON
jumpifbattletype BATTLE_TYPE_DOUBLE, BattleScript_PursuitSwitchDmgSetMultihit
setmultihit 1
Expand All @@ -5983,6 +5984,7 @@ BattleScript_DoSwitchOut::
switchoutabilities BS_ATTACKER
updatedynamax
waitstate
copybyte gBattlerAttacker, sSAVED_BATTLER
returnatktoball
waitstate
drawpartystatussummary BS_ATTACKER
Expand Down
1 change: 1 addition & 0 deletions data/maps/DewfordTown/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ DewfordTown_EventScript_OldRodFisherman::
DewfordTown_EventScript_GiveOldRod::
msgbox DewfordTown_Text_GiveYouOneOfMyRods, MSGBOX_DEFAULT
giveitem ITEM_OLD_ROD
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
setflag FLAG_RECEIVED_OLD_ROD
msgbox DewfordTown_Text_ThrowInFishingAdvice, MSGBOX_DEFAULT
release
Expand Down
1 change: 1 addition & 0 deletions data/maps/MauvilleCity/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ MauvilleCity_EventScript_Wattson::
goto_if_set FLAG_GOT_BASEMENT_KEY_FROM_WATTSON, MauvilleCity_EventScript_BegunNewMauville
msgbox MauvilleCity_Text_WattsonNeedFavorTakeKey, MSGBOX_DEFAULT
giveitem ITEM_BASEMENT_KEY
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
setflag FLAG_GOT_BASEMENT_KEY_FROM_WATTSON
msgbox MauvilleCity_Text_WattsonWontBeChallenge, MSGBOX_DEFAULT
release
Expand Down
2 changes: 2 additions & 0 deletions data/maps/MauvilleCity_BikeShop/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ MauvilleCity_BikeShop_EventScript_YesFar::
MauvilleCity_BikeShop_EventScript_GetMachBike::
msgbox MauvilleCity_BikeShop_Text_ChoseMachBike, MSGBOX_DEFAULT
giveitem ITEM_MACH_BIKE
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
goto MauvilleCity_BikeShop_EventScript_ComeBackToSwitchBikes
end

MauvilleCity_BikeShop_EventScript_GetAcroBike::
msgbox MauvilleCity_BikeShop_Text_ChoseAcroBike, MSGBOX_DEFAULT
giveitem ITEM_ACRO_BIKE
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
goto MauvilleCity_BikeShop_EventScript_ComeBackToSwitchBikes
end

Expand Down
3 changes: 2 additions & 1 deletion data/maps/MauvilleCity_House2/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@ MauvilleCity_House2_EventScript_AskToTradeForHarborMail::

MauvilleCity_House2_EventScript_AcceptTrade::
msgbox MauvilleCity_House2_Text_IllTradeYouCoinCase, MSGBOX_DEFAULT
removeitem ITEM_HARBOR_MAIL
giveitem ITEM_COIN_CASE
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
removeitem ITEM_HARBOR_MAIL
setflag FLAG_RECEIVED_COIN_CASE
goto MauvilleCity_House2_EventScript_ReceivedCoinCase
end
Expand Down
1 change: 1 addition & 0 deletions data/maps/MossdeepCity_House3/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ MossdeepCity_House3_EventScript_SuperRodFisherman::
goto_if_eq VAR_RESULT, NO, MossdeepCity_House3_EventScript_DeclineSuperRod
msgbox MossdeepCity_House3_Text_SuperRodIsSuper, MSGBOX_DEFAULT
giveitem ITEM_SUPER_ROD
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
setflag FLAG_RECEIVED_SUPER_ROD
msgbox MossdeepCity_House3_Text_TryDroppingRodInWater, MSGBOX_DEFAULT
release
Expand Down
1 change: 1 addition & 0 deletions data/maps/MtChimney/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ MtChimney_EventScript_MeteoriteMachine::
goto_if_eq VAR_RESULT, NO, MtChimney_EventScript_LeaveMeteoriteAlone
msgbox MtChimney_Text_PlayerRemovedMeteorite, MSGBOX_DEFAULT
giveitem ITEM_METEORITE
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
setflag FLAG_RECEIVED_METEORITE
releaseall
end
Expand Down
1 change: 1 addition & 0 deletions data/maps/Route104_PrettyPetalFlowerShop/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Route104_PrettyPetalFlowerShop_EventScript_WailmerPailGirl::
Route104_PrettyPetalFlowerShop_EventScript_GiveWailmerPail::
msgbox Route104_PrettyPetalFlowerShop_Text_YouCanHaveThis, MSGBOX_DEFAULT
giveitem ITEM_WAILMER_PAIL
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
msgbox Route104_PrettyPetalFlowerShop_Text_WailmerPailExplanation, MSGBOX_DEFAULT
setflag FLAG_RECEIVED_WAILMER_PAIL
release
Expand Down
1 change: 1 addition & 0 deletions data/maps/Route113_GlassWorkshop/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Route113_GlassWorkshop_EventScript_GlassWorker::
goto_if_eq VAR_GLASS_WORKSHOP_STATE, 1, Route113_GlassWorkshop_EventScript_ExplainSootSack
msgbox Route113_GlassWorkshop_Text_GoCollectAshWithThis, MSGBOX_DEFAULT
giveitem ITEM_SOOT_SACK
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
setvar VAR_GLASS_WORKSHOP_STATE, 1
msgbox Route113_GlassWorkshop_Text_ExplainSootSack, MSGBOX_DEFAULT
release
Expand Down
1 change: 1 addition & 0 deletions data/maps/Route118/scripts.inc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Route118_EventScript_GoodRodFisherman::
Route118_EventScript_ReceiveGoodRod::
msgbox Route118_Text_IdenticalMindsTakeThis, MSGBOX_DEFAULT
giveitem ITEM_GOOD_ROD
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
setflag FLAG_RECEIVED_GOOD_ROD
msgbox Route118_Text_TryYourLuckFishing, MSGBOX_DEFAULT
release
Expand Down
1 change: 1 addition & 0 deletions data/scripts/contest_hall.inc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LilycoveCity_ContestLobby_EventScript_ReceptionWelcome::
LilycoveCity_ContestLobby_EventScript_GivePokeblockCase::
msgbox LilycoveCity_ContestLobby_Text_ReceptionDontHavePokeblockCase, MSGBOX_DEFAULT
giveitem ITEM_POKEBLOCK_CASE
goto_if_eq VAR_RESULT, FALSE, Common_EventScript_ShowBagIsFull
setflag FLAG_RECEIVED_POKEBLOCK_CASE
msgbox LilycoveCity_ContestLobby_Text_NowThatWeveClearedThatUp, MSGBOX_DEFAULT
return
Expand Down
8 changes: 4 additions & 4 deletions data/text/pc_transfer.inc
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
gText_PkmnTransferredSomeonesPC::
.string "{STR_VAR_2} was transferred to\n"
.string "{STR_VAR_2_FIXED} was transferred to\n"
.string "SOMEONE'S PC.\p"
.string "It was placed in \n"
.string "BOX “{STR_VAR_1}.”$"

gText_PkmnTransferredLanettesPC::
.string "{STR_VAR_2} was transferred to\n"
.string "{STR_VAR_2_FIXED} was transferred to\n"
.string "LANETTE'S PC.\p"
.string "It was placed in \n"
.string "BOX “{STR_VAR_1}.”$"

gText_PkmnTransferredSomeonesPCBoxFull::
.string "BOX “{STR_VAR_3}” on\n"
.string "SOMEONE'S PC was full.\p"
.string "{STR_VAR_2} was transferred to\n"
.string "{STR_VAR_2_FIXED} was transferred to\n"
.string "BOX “{STR_VAR_1}.”$"

gText_PkmnTransferredLanettesPCBoxFull::
.string "BOX “{STR_VAR_3}” on\n"
.string "LANETTE'S PC was full.\p"
.string "{STR_VAR_2} was transferred to\n"
.string "{STR_VAR_2_FIXED} was transferred to\n"
.string "BOX “{STR_VAR_1}.”$"

gText_NoMoreRoomForPokemon::
Expand Down
6 changes: 3 additions & 3 deletions data/text/save.inc
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ gText_AlreadySavedFile::
.string "Is it okay to overwrite it?$"

gText_SavingDontTurnOff::
.string "SAVING…\n"
.fixstr "SAVING…\n"
.string "DON'T TURN OFF THE POWER.$"

gText_PlayerSavedGame::
.string "{PLAYER} saved the game.$"

gText_DifferentSaveFile::
.string "WARNING!\p"
.string "{FIXED_CASE}WARNING!{UNFIX_CASE}\p"
.string "There is a different game file that\n"
.string "is already saved.\p"
.string "If you save now, the other file's\n"
Expand All @@ -29,5 +29,5 @@ gText_SaveError::
.string "backup memory.$"

gText_SavingDontTurnOffPower::
.string "SAVING…\n"
.fixstr "SAVING…\n"
.string "DON'T TURN OFF THE POWER.$"
7 changes: 7 additions & 0 deletions gflib/characters.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@
#define CHAR_DOWN_ARROW 0x7A
#define CHAR_LEFT_ARROW 0x7B
#define CHAR_RIGHT_ARROW 0x7C
// Case-fixing characters
#define CHAR_FIXED_CASE 0x7D
#define CHAR_UNFIX_CASE 0x7E
//
#define CHAR_SUPER_E 0x84
#define CHAR_LESS_THAN 0x85
Expand Down Expand Up @@ -262,6 +265,10 @@
#define PLACEHOLDER_ID_MAXIE 0xB
#define PLACEHOLDER_ID_KYOGRE 0xC
#define PLACEHOLDER_ID_GROUDON 0xD
// Fixed-case placeholders
// These behave the same as their (id & 0x7F),
// but prepend CHAR_FIXED_CASE
#define PLACEHOLDER_FIXED_MASK 0x80

// battle placeholders are located in battle_message.h

Expand Down
76 changes: 74 additions & 2 deletions gflib/string_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,29 @@ static const s32 sPowersOfTen[] =
1000000000,
};

// Tries to determine whether `str` is safe to prepend a ctrl char to
// gStringVarX are always safe, as well as stack allocated IWRAM
// (if `length mod 4` is 1 or 2)
bool32 IsStringAddrSafe(u8 *str, u32 length)
{
if (((u32)str) >> 24 == 3)
return (str >= gStackBase && (length & 3) && (length & 3) <= 2);
return (str >= gStringVar1 && str < sUnknownStringVar);
}

u8 *StringCopy_Nickname(u8 *dest, const u8 *src)
{
u8 i;
u32 i;
u32 limit = POKEMON_NAME_LENGTH;

if (DECAP_ENABLED && !DECAP_NICKNAMES)
{
if (IsStringAddrSafe(dest, limit) && *src != CHAR_FIXED_CASE)
*dest++ = CHAR_FIXED_CASE;
else if (*src == CHAR_FIXED_CASE)
*dest++ = *src++;
}

for (i = 0; i < limit; i++)
{
dest[i] = src[i];
Expand All @@ -48,6 +66,9 @@ u8 *StringGet_Nickname(u8 *str)
u8 i;
u32 limit = POKEMON_NAME_LENGTH;

if (DECAP_ENABLED && !DECAP_NICKNAMES && *str == CHAR_FIXED_CASE)
str++;

for (i = 0; i < limit; i++)
if (str[i] == EOS)
return &str[i];
Expand All @@ -61,6 +82,9 @@ u8 *StringCopy_PlayerName(u8 *dest, const u8 *src)
s32 i;
s32 limit = PLAYER_NAME_LENGTH;

if (DECAP_ENABLED && !DECAP_NICKNAMES && IsStringAddrSafe(dest, limit) && *src != CHAR_FIXED_CASE)
*dest++ = CHAR_FIXED_CASE;

for (i = 0; i < limit; i++)
{
dest[i] = src[i];
Expand All @@ -75,6 +99,10 @@ u8 *StringCopy_PlayerName(u8 *dest, const u8 *src)

u8 *StringCopy(u8 *dest, const u8 *src)
{
// If `src` is mirrored, prepend fixed-case char
if (DECAP_ENABLED && DECAP_MIRRORING && IsMirrorPtr(src) && *src != CHAR_FIXED_CASE)
*dest++ = CHAR_FIXED_CASE;

while (*src != EOS)
{
*dest = *src;
Expand Down Expand Up @@ -124,6 +152,14 @@ u16 StringLength(const u8 *str)

s32 StringCompare(const u8 *str1, const u8 *str2)
{
// Ignore leading fixed-case char
if (DECAP_ENABLED)
{
if (*str1 == CHAR_FIXED_CASE)
str1++;
if (*str2 == CHAR_FIXED_CASE)
str2++;
}
while (*str1 == *str2)
{
if (*str1 == EOS)
Expand All @@ -137,6 +173,14 @@ s32 StringCompare(const u8 *str1, const u8 *str2)

s32 StringCompareN(const u8 *str1, const u8 *str2, u32 n)
{
// Ignore leading fixed-case char
if (DECAP_ENABLED)
{
if (*str1 == CHAR_FIXED_CASE)
str1++;
if (*str2 == CHAR_FIXED_CASE)
str2++;
}
while (*str1 == *str2)
{
if (*str1 == EOS)
Expand Down Expand Up @@ -335,6 +379,7 @@ u8 *ConvertIntToHexStringN(u8 *dest, s32 value, enum StringConvertMode mode, u8

u8 *StringExpandPlaceholders(u8 *dest, const u8 *src)
{
bool32 fixedCase = FALSE;
for (;;)
{
u8 c = *src++;
Expand All @@ -345,7 +390,20 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src)
{
case PLACEHOLDER_BEGIN:
placeholderId = *src++;
expandedString = GetExpandedPlaceholder(placeholderId);
if (DECAP_ENABLED)
{
// Handle fixed-case versions of placeholders
if (!fixedCase && (placeholderId & PLACEHOLDER_FIXED_MASK || placeholderId == PLACEHOLDER_ID_PLAYER))
{
*dest++ = CHAR_FIXED_CASE;
expandedString = GetExpandedPlaceholder(placeholderId & ~PLACEHOLDER_FIXED_MASK);
dest = StringExpandPlaceholders(dest, expandedString);
*dest++ = CHAR_UNFIX_CASE;
*dest = EOS;
break;
}
}
expandedString = GetExpandedPlaceholder(placeholderId & ~PLACEHOLDER_FIXED_MASK);
dest = StringExpandPlaceholders(dest, expandedString);
break;
case EXT_CTRL_CODE_BEGIN:
Expand All @@ -372,8 +430,19 @@ u8 *StringExpandPlaceholders(u8 *dest, const u8 *src)
}
break;
case EOS:
if (DECAP_ENABLED && fixedCase)
*dest++ = CHAR_UNFIX_CASE;
*dest = EOS;
return dest;
#if DECAP_ENABLED
case CHAR_UNFIX_CASE:
fixedCase = FALSE;
*dest++ = c;
break;
case CHAR_FIXED_CASE:
fixedCase = TRUE;
// fallthrough
#endif
case CHAR_PROMPT_SCROLL:
case CHAR_PROMPT_CLEAR:
case CHAR_NEWLINE:
Expand Down Expand Up @@ -700,6 +769,9 @@ static const u8 *SkipExtCtrlCode(const u8 *s)
s += GetExtCtrlCodeLength(*s);
}

while (DECAP_ENABLED && (*s == CHAR_FIXED_CASE || *s == CHAR_UNFIX_CASE))
s++;

return s;
}

Expand Down
1 change: 1 addition & 0 deletions gflib/string_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ enum StringConvertMode
STR_CONV_MODE_LEADING_ZEROS
};

bool32 IsStringAddrSafe(u8 *ptr, u32 length);
u8 *StringCopy_Nickname(u8 *dest, const u8 *src);
u8 *StringGet_Nickname(u8 *str);
u8 *StringCopy_PlayerName(u8 *dest, const u8 *src);
Expand Down
Loading

0 comments on commit 2e74bf7

Please sign in to comment.