From e6eb71727599d9fe6514e072234cc26f0b21375b Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Tue, 25 Jun 2024 22:09:08 +0200 Subject: [PATCH 1/5] UB fix ClockwiseWipe_TopRight --- src/battle_transition.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/battle_transition.c b/src/battle_transition.c index 704670d14..8a23dfe5d 100644 --- a/src/battle_transition.c +++ b/src/battle_transition.c @@ -1230,7 +1230,11 @@ static bool8 ClockwiseWipe_Init(struct Task *task) static bool8 ClockwiseWipe_TopRight(struct Task *task) { sTransitionData->vblankDma = FALSE; +#ifdef UBFIX + InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sTransitionData->tWipeEndX, 0, 1, 1); +#else InitBlackWipe(sTransitionData->data, DISPLAY_WIDTH / 2, DISPLAY_HEIGHT / 2, sTransitionData->tWipeEndX, -1, 1, 1); +#endif do { gScanlineEffectRegBuffers[0][sTransitionData->tWipeCurrY] = WIN_RANGE(DISPLAY_WIDTH / 2, sTransitionData->tWipeCurrX + 1); From d61220569d5e27c48c32b66bdc03ea431f22f243 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Thu, 27 Jun 2024 16:13:17 +0200 Subject: [PATCH 2/5] fix for potential UB in CameraObjectReset2 --- src/event_object_movement.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 43a5d86fe..184081294 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2453,7 +2453,15 @@ u8 CameraObjectGetFollowedObjectId(void) void CameraObjectReset2(void) { +#ifdef UBFIX + struct Sprite* cameraObject = FindCameraObject(); + + if (cameraObject == NULL) + return; + cameraObject->data[1] = 2; +#else FindCameraObject()->data[1] = 2; +#endif } u8 CopySprite(struct Sprite *sprite, s16 x, s16 y, u8 subpriority) From 588e164e67e50a780d2fae592295aa75f304a4b1 Mon Sep 17 00:00:00 2001 From: abcboy101 <16735361+abcboy101@users.noreply.github.com> Date: Fri, 9 Aug 2024 20:19:38 -0400 Subject: [PATCH 3/5] Decode unused JP text --- src/battle_script_commands.c | 4 ++-- src/mon_markings.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c index 5d52c85f4..67f90a370 100644 --- a/src/battle_script_commands.c +++ b/src/battle_script_commands.c @@ -813,8 +813,8 @@ static const u8 sBallCatchBonuses[] = [ITEM_SAFARI_BALL - ITEM_ULTRA_BALL] = 15 }; -// unknown unused data -static const u32 sUnused = 0xFF7EAE60; +// unused +ALIGNED(4) static const u8 sJPText_Turn[] = _("ターン"); static void Cmd_attackcanceler(void) { diff --git a/src/mon_markings.c b/src/mon_markings.c index e26ae9443..1500be959 100644 --- a/src/mon_markings.c +++ b/src/mon_markings.c @@ -19,7 +19,7 @@ static struct Sprite *CreateMarkingComboSprite(u16, u16, const u16 *, u16); static const u16 sMonMarkings_Pal[] = INCBIN_U16("graphics/misc/mon_markings.gbapal"); static const u16 sMonMarkings_Gfx[] = INCBIN_U16("graphics/misc/mon_markings.4bpp"); -static const u8 sUnused[] = {0x09, 0x50, 0x13, 0x02, 0xFF}; +static const u8 sJPText_Confirm[] = _("けってい"); static const struct OamData sOamData_MenuWindow = { From 466a69a6e034c9726811bc2ad810cff66d2947f5 Mon Sep 17 00:00:00 2001 From: cawtds <38510667+cawtds@users.noreply.github.com> Date: Sat, 10 Aug 2024 20:41:21 +0200 Subject: [PATCH 4/5] Update src/event_object_movement.c Co-authored-by: GriffinR --- src/event_object_movement.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/event_object_movement.c b/src/event_object_movement.c index 184081294..b55faee3f 100644 --- a/src/event_object_movement.c +++ b/src/event_object_movement.c @@ -2453,15 +2453,12 @@ u8 CameraObjectGetFollowedObjectId(void) void CameraObjectReset2(void) { + struct Sprite *cameraObject = FindCameraObject(); #ifdef UBFIX - struct Sprite* cameraObject = FindCameraObject(); - if (cameraObject == NULL) return; - cameraObject->data[1] = 2; -#else - FindCameraObject()->data[1] = 2; #endif + cameraObject->data[1] = 2; } u8 CopySprite(struct Sprite *sprite, s16 x, s16 y, u8 subpriority) From 6319b453bc994d0736498c5b5191f71645a2df32 Mon Sep 17 00:00:00 2001 From: abcboy101 <16735361+abcboy101@users.noreply.github.com> Date: Sat, 24 Aug 2024 22:19:28 -0400 Subject: [PATCH 5/5] Update link_rfu_2.c --- src/link_rfu_2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/link_rfu_2.c b/src/link_rfu_2.c index 885af4dd3..43614712d 100644 --- a/src/link_rfu_2.c +++ b/src/link_rfu_2.c @@ -1831,7 +1831,7 @@ static void ReceiveRfuLinkPlayers(const struct SioInfo *sioInfo) // Could be relocated to top of file, but would also require relocating assert strings static const char sASCII_PokemonSioInfo[] = "PokemonSioInfo"; -static const u8 sText_Akito[] = _(" あきと"); // Presumably "Akito Mori", one of Game Freak's programmers +ALIGNED(4) static const u8 sText_Akito[] = _("あきと"); // Presumably "Akito Mori", one of Game Freak's programmers static const char sASCII_LinkLossDisconnect[] = "LINK LOSS DISCONNECT!"; static const char sASCII_LinkLossRecoveryNow[] = "LINK LOSS RECOVERY NOW"; ALIGNED(4) static const char sASCII_30Spaces[] = {" "};