Fix Pokemon Fakematch

This commit is contained in:
PokeCodec 2020-09-09 15:59:34 -04:00
parent d541002ab6
commit a32f631fe6

View file

@ -6808,19 +6808,16 @@ static bool8 ShouldSkipFriendshipChange(void)
return FALSE; return FALSE;
} }
#define FORCE_SIGNED(x)(-(x * (-1))) #define MAGIC_NUMBER 0xA3
static void sub_806F160(struct Unknown_806F160_Struct* structPtr) static void sub_806F160(struct Unknown_806F160_Struct* structPtr)
{ {
u16 i, j; 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]; structPtr->templates[i] = gUnknown_08329D98[i];
for (j = 0; j < structPtr->field_1; j++) 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->frameImages[i * structPtr->field_1 + j].data = &structPtr->byteArrays[i][j * 0x800];
} }
structPtr->templates[i].images = &structPtr->frameImages[i * structPtr->field_1]; 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) static void sub_806F1FC(struct Unknown_806F160_Struct* structPtr)
{ {
u16 i, j; 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; structPtr->templates[i] = gUnknown_08329F28;
for (j = 0; j < structPtr->field_1; j++) for (j = 0; j < structPtr->field_1; j++)
@ -6882,7 +6879,7 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1)
} }
else 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)); 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 else
{ {
structPtr->magic = 0xA3; structPtr->magic = MAGIC_NUMBER;
gUnknown_020249B4[id] = structPtr; gUnknown_020249B4[id] = structPtr;
} }
@ -6943,12 +6940,12 @@ void sub_806F47C(u8 id)
{ {
struct Unknown_806F160_Struct *structPtr; struct Unknown_806F160_Struct *structPtr;
id %= 2; id &= 1;
structPtr = gUnknown_020249B4[id]; structPtr = gUnknown_020249B4[id];
if (structPtr == NULL) if (structPtr == NULL)
return; return;
if (structPtr->magic != 0xA3) if (structPtr->magic != MAGIC_NUMBER)
{ {
memset(structPtr, 0, sizeof(struct Unknown_806F160_Struct)); memset(structPtr, 0, sizeof(struct Unknown_806F160_Struct));
} }
@ -6972,15 +6969,13 @@ void sub_806F47C(u8 id)
u8 *sub_806F4F8(u8 id, u8 arg1) u8 *sub_806F4F8(u8 id, u8 arg1)
{ {
struct Unknown_806F160_Struct *structPtr = gUnknown_020249B4[id % 2]; struct Unknown_806F160_Struct *structPtr = gUnknown_020249B4[id % 2];
if (structPtr->magic != 0xA3) if (structPtr->magic != MAGIC_NUMBER)
{ {
return NULL; return NULL;
} }
else
{ if (arg1 >= structPtr->field_0_0)
if (arg1 >= FORCE_SIGNED(structPtr->field_0_0)) arg1 = 0;
arg1 = 0;
return structPtr->byteArrays[arg1]; return structPtr->byteArrays[arg1];
}
} }