From 4ccbc65f4bdf0bf53b9967018eb0ad653ce28446 Mon Sep 17 00:00:00 2001 From: Kaz Date: Thu, 28 May 2020 04:37:09 -0400 Subject: src/battle/anim/dark.c: Last function decompiled. src/battle_anim.c: Port some function matches. src/battle_controller_player.c: Port some function matches. src/use_pokeblock.c: A more likely yet still farfetched permutation for Pokeblock_BufferEnhancedStatText. --- src/use_pokeblock.c | 56 ++++++++--------------------------------------------- 1 file changed, 8 insertions(+), 48 deletions(-) (limited to 'src/use_pokeblock.c') diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index e13369c0b..eed092c96 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -40,7 +40,7 @@ static const u8 gUnknown_0840612C[] = { 0, 4, 3, 2, 1 }; -static const u8 *const sContextStatNames[] = { +static const u8 *const sContestStatNames[] = { OtherText_Coolness, OtherText_Toughness, OtherText_Smartness, @@ -683,12 +683,15 @@ static void Pokeblock_MenuWindowTextPrint(const u8 *message) Menu_PrintText(message, 1, 17); } -#ifdef NONMATCHING -static void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) { - if (a2 != 0) + if (a2) { - StringCopy(dest, sContextStatNames[statID]); + // This is is a joke. + // For absurd commentary on why this works, see battle/anim/water.c. + if (a2 > 0) a2 = 0; + if (a2 < 0) { u8 unk = -unk; } + StringCopy(dest, sContestStatNames[statId]); StringAppend(dest, gOtherText_WasEnhanced); } else @@ -696,49 +699,6 @@ static void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) StringCopy(dest, gOtherText_NothingChanged); } } -#else -NAKED -static void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 a1, s16 a2) -{ - asm_unified("\tpush {r4,lr}\n" - "\tadds r4, r0, 0\n" - "\tlsls r1, 24\n" - "\tlsrs r3, r1, 24\n" - "\tlsls r2, 16\n" - "\tlsrs r0, r2, 16\n" - "\tasrs r2, 16\n" - "\tcmp r2, 0\n" - "\tbeq _08136DFC\n" - "\tcmp r2, 0\n" - "\tble _08136DD8\n" - "\tmovs r0, 0\n" - "_08136DD8:\n" - "\tlsls r0, 16\n" - "\tldr r1, _08136DF4 @ =sContextStatNames\n" - "\tlsls r0, r3, 2\n" - "\tadds r0, r1\n" - "\tldr r1, [r0]\n" - "\tadds r0, r4, 0\n" - "\tbl StringCopy\n" - "\tldr r1, _08136DF8 @ =gOtherText_WasEnhanced\n" - "\tadds r0, r4, 0\n" - "\tbl StringAppend\n" - "\tb _08136E04\n" - "\t.align 2, 0\n" - "_08136DF4: .4byte sContextStatNames\n" - "_08136DF8: .4byte gOtherText_WasEnhanced\n" - "_08136DFC:\n" - "\tldr r1, _08136E0C @ =gOtherText_NothingChanged\n" - "\tadds r0, r4, 0\n" - "\tbl StringCopy\n" - "_08136E04:\n" - "\tpop {r4}\n" - "\tpop {r0}\n" - "\tbx r0\n" - "\t.align 2, 0\n" - "_08136E0C: .4byte gOtherText_NothingChanged"); -} -#endif static void Pokeblock_GetMonContestStats(struct Pokemon *pokemon, u8 *data) { -- cgit v1.2.3 From d673e589f63ebf56563558cc5a47f1414c289c8a Mon Sep 17 00:00:00 2001 From: Kaz Date: Thu, 28 May 2020 09:05:11 -0400 Subject: Further document agbcc's paremeter variable optimization goof. --- src/use_pokeblock.c | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src/use_pokeblock.c') diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index eed092c96..6adb39871 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -683,14 +683,33 @@ static void Pokeblock_MenuWindowTextPrint(const u8 *message) Menu_PrintText(message, 1, 17); } -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) +void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhanced) { - if (a2) + if (enhanced) { - // This is is a joke. - // For absurd commentary on why this works, see battle/anim/water.c. - if (a2 > 0) a2 = 0; - if (a2 < 0) { u8 unk = -unk; } + /* + This is is a joke. One of the most absurd matches-- which may be + more real than fake! For absurd commentary on why this works, see + battle/anim/water.c, which does the same thing. + */ + if (enhanced > 0) enhanced = 0; + if (enhanced < 0) + { + /* + While "u8 var = -var" works, enhanced is an uninitialized, so + it can also be "enhanced = -enhanced". But not only can it be + "enhanced = -enhanced", it can also be + + "enhanced = [any value]" + + Rather. This was tested with the numbers 1, 5, -2, etc. As for + what may have been in the original source, it makes more sense + if enhanced had been set here. Multiple enhancement types for + Pokeblocks? Stupid error handling? + */ + u8 unk = -unk; // matches + // enhanced = any value here; // matches + } StringCopy(dest, sContestStatNames[statId]); StringAppend(dest, gOtherText_WasEnhanced); } -- cgit v1.2.3 From 3d96e954c845659f5184e99856ddf61ce1375b2f Mon Sep 17 00:00:00 2001 From: Kaz Date: Tue, 18 Aug 2020 04:38:42 -0400 Subject: Review changes. Fixed taya_debug_window for good. --- src/use_pokeblock.c | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'src/use_pokeblock.c') diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 6adb39871..8fff9edee 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -687,29 +687,14 @@ void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhanced) { if (enhanced) { - /* - This is is a joke. One of the most absurd matches-- which may be - more real than fake! For absurd commentary on why this works, see - battle/anim/water.c, which does the same thing. - */ - if (enhanced > 0) enhanced = 0; + // This is a joke. + if (enhanced > 0) + enhanced = 0; + if (enhanced < 0) - { - /* - While "u8 var = -var" works, enhanced is an uninitialized, so - it can also be "enhanced = -enhanced". But not only can it be - "enhanced = -enhanced", it can also be - - "enhanced = [any value]" - - Rather. This was tested with the numbers 1, 5, -2, etc. As for - what may have been in the original source, it makes more sense - if enhanced had been set here. Multiple enhancement types for - Pokeblocks? Stupid error handling? - */ - u8 unk = -unk; // matches - // enhanced = any value here; // matches - } + // matches, but can also be a variety of values too + { u8 unk = -unk; } // see water.c for a similar behavior + StringCopy(dest, sContestStatNames[statId]); StringAppend(dest, gOtherText_WasEnhanced); } -- cgit v1.2.3