diff --git a/src/pokedex.c b/src/pokedex.c index 3d458fcb2..080548553 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -3869,14 +3869,17 @@ static void HighlightScreenSelectBarItem(u8 selectedScreen, u16 unused) for (i = 0; i < SCREEN_COUNT; i++) { u8 row = (i * 7) + 1; - u16 newPalette = 0x4000; + u16 newPalette; - if (i == selectedScreen) - newPalette = 0x2000; + do + { + newPalette = 0x4000; + if (i == selectedScreen) + newPalette = 0x2000; + } while (0); for (j = 0; j < 7; j++) { - j++;j--; ptr[row + j] = (ptr[row + j] % 0x1000) | newPalette; ptr[row + j + 0x20] = (ptr[row + j + 0x20] % 0x1000) | newPalette; } @@ -3895,14 +3898,16 @@ static void HighlightSubmenuScreenSelectBarItem(u8 a, u16 b) u8 row = i * 7 + 1; u32 newPalette; - if (i == a || i == 3) - newPalette = 0x2000; - else - newPalette = 0x4000; + do + { + if (i == a || i == 3) + newPalette = 0x2000; + else + newPalette = 0x4000; + } while (0); for (j = 0; j < 7; j++) { - j++;j--; ptr[row + j] = (ptr[row + j] % 0x1000) | newPalette; ptr[row + j + 0x20] = (ptr[row + j + 0x20] % 0x1000) | newPalette; } @@ -4162,11 +4167,12 @@ static void PrintMonHeight(u16 height, u8 left, u8 top) PrintInfoScreenText(buffer, left, top); } -#ifdef NONMATCHING -// This doesn't match because gcc manages to avoid using the stack -// to store local variables. static void PrintMonWeight(u16 weight, u8 left, u8 top) { +#ifndef NONMATCHING + asm("":::"r9"); +{ +#endif u8 buffer[16]; bool8 output; u8 i = 0; @@ -4222,226 +4228,10 @@ static void PrintMonWeight(u16 weight, u8 left, u8 top) buffer[i++] = CHAR_PERIOD; buffer[i++] = EOS; PrintInfoScreenText(buffer, left, top); -} -#else -__attribute__((naked)) -static void PrintMonWeight(u16 weight, u8 left, u8 top) -{ - asm(".syntax unified\n\ - push {r4-r7,lr}\n\ - mov r7, r10\n\ - mov r6, r9\n\ - mov r5, r8\n\ - push {r5-r7}\n\ - sub sp, 0x14\n\ - lsls r0, 16\n\ - lsrs r0, 16\n\ - lsls r1, 24\n\ - lsrs r1, 24\n\ - mov r10, r1\n\ - lsls r2, 24\n\ - lsrs r2, 24\n\ - str r2, [sp, 0x10]\n\ - ldr r5, =0x000186a0\n\ - muls r0, r5\n\ - ldr r1, =0x000011b8\n\ - bl __divsi3\n\ - adds r7, r0, 0\n\ - movs r1, 0xA\n\ - bl __umodsi3\n\ - cmp r0, 0x4\n\ - bls _080C0494\n\ - adds r7, 0xA\n\ -_080C0494:\n\ - movs r0, 0\n\ - mov r8, r0\n\ - mov r4, sp\n\ - adds r0, r7, 0\n\ - adds r1, r5, 0\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - strb r0, [r4]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0xA1\n\ - bne _080C04C0\n\ - movs r6, 0x1\n\ - mov r1, sp\n\ - movs r0, 0x77\n\ - strb r0, [r1]\n\ - b _080C04C6\n\ - .pool\n\ -_080C04C0:\n\ - movs r1, 0x1\n\ - mov r8, r1\n\ - movs r6, 0x1\n\ -_080C04C6:\n\ - ldr r1, =0x000186a0\n\ - adds r0, r7, 0\n\ - bl __umodsi3\n\ - adds r7, r0, 0\n\ - mov r4, sp\n\ - adds r4, 0x1\n\ - ldr r1, =0x00002710\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - strb r0, [r4]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0xA1\n\ - bne _080C0504\n\ - mov r2, r8\n\ - cmp r2, 0\n\ - bne _080C0504\n\ - adds r1, r6, 0\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - add r1, sp\n\ - movs r0, 0x77\n\ - strb r0, [r1]\n\ - b _080C050E\n\ - .pool\n\ -_080C0504:\n\ - movs r3, 0x1\n\ - mov r8, r3\n\ - adds r0, r6, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ -_080C050E:\n\ - ldr r1, =0x00002710\n\ - adds r0, r7, 0\n\ - bl __umodsi3\n\ - adds r7, r0, 0\n\ - mov r0, sp\n\ - adds r4, r0, r6\n\ - movs r1, 0xFA\n\ - lsls r1, 2\n\ - adds r0, r7, 0\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - strb r0, [r4]\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - cmp r0, 0xA1\n\ - bne _080C054C\n\ - mov r1, r8\n\ - cmp r1, 0\n\ - bne _080C054C\n\ - adds r1, r6, 0\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - add r1, sp\n\ - movs r0, 0x77\n\ - strb r0, [r1]\n\ - b _080C0552\n\ - .pool\n\ -_080C054C:\n\ - adds r0, r6, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ -_080C0552:\n\ - movs r1, 0xFA\n\ - lsls r1, 2\n\ - adds r0, r7, 0\n\ - bl __umodsi3\n\ - adds r7, r0, 0\n\ - adds r1, r6, 0\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r5, r6, 0\n\ - mov r2, sp\n\ - adds r4, r2, r1\n\ - adds r0, r7, 0\n\ - movs r1, 0x64\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - movs r3, 0\n\ - mov r9, r3\n\ - strb r0, [r4]\n\ - adds r0, r7, 0\n\ - movs r1, 0x64\n\ - bl __umodsi3\n\ - adds r7, r0, 0\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r1, r6, 0\n\ - mov r2, sp\n\ - adds r0, r2, r5\n\ - movs r3, 0xAD\n\ - mov r8, r3\n\ - mov r2, r8\n\ - strb r2, [r0]\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r5, r6, 0\n\ - mov r3, sp\n\ - adds r4, r3, r1\n\ - adds r0, r7, 0\n\ - movs r1, 0xA\n\ - bl __udivsi3\n\ - adds r0, 0xA1\n\ - strb r0, [r4]\n\ - adds r0, r5, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r1, r6, 0\n\ - mov r2, sp\n\ - adds r0, r2, r5\n\ - mov r3, r9\n\ - strb r3, [r0]\n\ - adds r0, r1, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r2, r6, 0\n\ - add r1, sp\n\ - movs r0, 0xE0\n\ - strb r0, [r1]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r3, r6, 0\n\ - mov r0, sp\n\ - adds r1, r0, r2\n\ - movs r0, 0xD6\n\ - strb r0, [r1]\n\ - adds r0, r3, 0x1\n\ - lsls r0, 24\n\ - lsrs r6, r0, 24\n\ - adds r2, r6, 0\n\ - mov r0, sp\n\ - adds r1, r0, r3\n\ - movs r0, 0xE7\n\ - strb r0, [r1]\n\ - adds r0, r2, 0x1\n\ - lsls r0, 24\n\ - lsrs r0, 24\n\ - mov r3, sp\n\ - adds r1, r3, r2\n\ - mov r2, r8\n\ - strb r2, [r1]\n\ - adds r1, r3, r0\n\ - movs r0, 0xFF\n\ - strb r0, [r1]\n\ - mov r0, sp\n\ - mov r1, r10\n\ - ldr r2, [sp, 0x10]\n\ - bl PrintInfoScreenText\n\ - add sp, 0x14\n\ - pop {r3-r5}\n\ - mov r8, r3\n\ - mov r9, r4\n\ - mov r10, r5\n\ - pop {r4-r7}\n\ - pop {r0}\n\ - bx r0\n\ - .syntax divided\n"); +#ifndef NONMATCHING } #endif +} const u8 *GetPokedexCategoryName(u16 dexNum) // unused { diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index a0c8d8e2d..5079edb37 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -937,62 +937,24 @@ void Pokeblock_MenuWindowTextPrint(const u8 *message) AddTextPrinterParameterized(2, 1, gStringVar4, 0, 1, 0, NULL); } -// This function is a joke. -#ifdef NONMATCHING void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) { - if (a2 != 0) + switch (a2) { + case 1 ... 32767: + a2 = 0; + // fallthrough + case -32768 ... -1: + if (a2) + dest[(u16)a2] += 0; // something you can't imagine StringCopy(dest, sContestStatNames[statId]); StringAppend(dest, gText_WasEnhanced); - } - else - { + break; + case 0: StringCopy(dest, gText_NothingChanged); + break; } } -#else -NAKED -void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statId, s16 a2) -{ - asm(".syntax unified\n\ -push {r4,lr}\n\ - adds r4, r0, 0\n\ - lsls r1, 24\n\ - lsrs r3, r1, 24\n\ - lsls r2, 16\n\ - lsrs r0, r2, 16\n\ - asrs r2, 16\n\ - cmp r2, 0\n\ - beq _08167010\n\ - cmp r2, 0\n\ - ble _08166FEC\n\ - movs r0, 0\n\ -_08166FEC:\n\ - lsls r0, 16\n\ - ldr r1, =sContestStatNames\n\ - lsls r0, r3, 2\n\ - adds r0, r1\n\ - ldr r1, [r0]\n\ - adds r0, r4, 0\n\ - bl StringCopy\n\ - ldr r1, =gText_WasEnhanced\n\ - adds r0, r4, 0\n\ - bl StringAppend\n\ - b _08167018\n\ - .pool\n\ -_08167010:\n\ - ldr r1, =gText_NothingChanged\n\ - adds r0, r4, 0\n\ - bl StringCopy\n\ -_08167018:\n\ - pop {r4}\n\ - pop {r0}\n\ - bx r0\n\ - .pool\n\ - .syntax divided\n"); -} -#endif void Pokeblock_GetMonContestStats(struct Pokemon *mon, u8 *data) {