From a32f631fe63c93e3a5dd26bc5332188f5f696060 Mon Sep 17 00:00:00 2001 From: PokeCodec <67983839+PokeCodec@users.noreply.github.com> Date: Wed, 9 Sep 2020 15:59:34 -0400 Subject: [PATCH] Fix Pokemon Fakematch --- src/pokemon.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/pokemon.c b/src/pokemon.c index 29f0f6dfc..813c327e3 100644 --- a/src/pokemon.c +++ b/src/pokemon.c @@ -6808,19 +6808,16 @@ static bool8 ShouldSkipFriendshipChange(void) return FALSE; } -#define FORCE_SIGNED(x)(-(x * (-1))) +#define MAGIC_NUMBER 0xA3 static void sub_806F160(struct Unknown_806F160_Struct* structPtr) { u16 i, j; - for (i = 0; i < FORCE_SIGNED(structPtr->field_0_0); i++) + for (i = 0; i < structPtr->field_0_0; i++) { structPtr->templates[i] = gUnknown_08329D98[i]; for (j = 0; j < structPtr->field_1; j++) { - #ifndef NONMATCHING - asm(""); - #endif structPtr->frameImages[i * structPtr->field_1 + j].data = &structPtr->byteArrays[i][j * 0x800]; } structPtr->templates[i].images = &structPtr->frameImages[i * structPtr->field_1]; @@ -6830,7 +6827,7 @@ static void sub_806F160(struct Unknown_806F160_Struct* structPtr) static void sub_806F1FC(struct Unknown_806F160_Struct* structPtr) { u16 i, j; - for (i = 0; i < FORCE_SIGNED(structPtr->field_0_0); i++) + for (i = 0; i < structPtr->field_0_0; i++) { structPtr->templates[i] = gUnknown_08329F28; for (j = 0; j < structPtr->field_1; j++) @@ -6882,7 +6879,7 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1) } else { - for (i = 0; i < FORCE_SIGNED(structPtr->field_0_0); i++) + for (i = 0; i < structPtr->field_0_0; i++) structPtr->byteArrays[i] = structPtr->bytes + (structPtr->field_3_0 * (i << 0xD)); } @@ -6932,7 +6929,7 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1) } else { - structPtr->magic = 0xA3; + structPtr->magic = MAGIC_NUMBER; gUnknown_020249B4[id] = structPtr; } @@ -6943,12 +6940,12 @@ void sub_806F47C(u8 id) { struct Unknown_806F160_Struct *structPtr; - id %= 2; + id &= 1; structPtr = gUnknown_020249B4[id]; if (structPtr == NULL) return; - if (structPtr->magic != 0xA3) + if (structPtr->magic != MAGIC_NUMBER) { memset(structPtr, 0, sizeof(struct Unknown_806F160_Struct)); } @@ -6972,15 +6969,13 @@ void sub_806F47C(u8 id) u8 *sub_806F4F8(u8 id, u8 arg1) { struct Unknown_806F160_Struct *structPtr = gUnknown_020249B4[id % 2]; - if (structPtr->magic != 0xA3) + if (structPtr->magic != MAGIC_NUMBER) { return NULL; } - else - { - if (arg1 >= FORCE_SIGNED(structPtr->field_0_0)) - arg1 = 0; + + if (arg1 >= structPtr->field_0_0) + arg1 = 0; - return structPtr->byteArrays[arg1]; - } + return structPtr->byteArrays[arg1]; }