summaryrefslogtreecommitdiff
path: root/src/pokemon.c
diff options
context:
space:
mode:
authorPikalaxALT <PikalaxALT@users.noreply.github.com>2020-09-09 16:27:24 -0400
committerGitHub <noreply@github.com>2020-09-09 16:27:24 -0400
commitd260943249387a5d25cbb60886b6c8aa72e3f24f (patch)
tree7e326cc3ea683c03827e7715fa7ef1836e87671d /src/pokemon.c
parent8f6d6b933e081d6e7a35b52bd36da9d11952145b (diff)
parent7f1827767c27c6b696a9cd1a8c15b2b31a125b78 (diff)
Merge pull request #1182 from PokeCodec/PokemonLogicFix
Fix more fakematches
Diffstat (limited to 'src/pokemon.c')
-rw-r--r--src/pokemon.c41
1 files changed, 18 insertions, 23 deletions
diff --git a/src/pokemon.c b/src/pokemon.c
index 2440f183e..a0e655d1e 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -70,7 +70,7 @@ EWRAM_DATA u8 gEnemyPartyCount = 0;
EWRAM_DATA struct Pokemon gPlayerParty[PARTY_SIZE] = {0};
EWRAM_DATA struct Pokemon gEnemyParty[PARTY_SIZE] = {0};
EWRAM_DATA struct SpriteTemplate gMultiuseSpriteTemplate = {0};
-EWRAM_DATA struct Unknown_806F160_Struct *gUnknown_020249B4[2] = {NULL};
+EWRAM_DATA struct Unknown_806F160_Struct *gUnknown_020249B4[2] = {NULL, NULL};
// const rom data
#include "data/battle_moves.h"
@@ -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++)
@@ -6861,7 +6858,7 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1)
structPtr->field_0_0 = 7;
structPtr->field_0_1 = 7;
structPtr->field_1 = 4;
- structPtr->field_3_0 = 1;
+ structPtr->size = 1;
structPtr->field_3_1 = 2;
break;
case 0:
@@ -6869,12 +6866,12 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1)
structPtr->field_0_0 = 4;
structPtr->field_0_1 = 4;
structPtr->field_1 = 4;
- structPtr->field_3_0 = 1;
+ structPtr->size = 1;
structPtr->field_3_1 = 0;
break;
}
- structPtr->bytes = AllocZeroed(structPtr->field_3_0 * 0x800 * 4 * structPtr->field_0_0);
+ structPtr->bytes = AllocZeroed(structPtr->size * 0x800 * 4 * structPtr->field_0_0);
structPtr->byteArrays = AllocZeroed(structPtr->field_0_0 * 32);
if (structPtr->bytes == NULL || structPtr->byteArrays == NULL)
{
@@ -6882,8 +6879,8 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1)
}
else
{
- for (i = 0; i < FORCE_SIGNED(structPtr->field_0_0); i++)
- structPtr->byteArrays[i] = structPtr->bytes + (structPtr->field_3_0 * (i << 0xD));
+ for (i = 0; i < structPtr->field_0_0; i++)
+ structPtr->byteArrays[i] = structPtr->bytes + (structPtr->size * (i << 0xD));
}
structPtr->templates = AllocZeroed(sizeof(struct SpriteTemplate) * structPtr->field_0_0);
@@ -6902,8 +6899,8 @@ struct Unknown_806F160_Struct *sub_806F2AC(u8 id, u8 arg1)
case 2:
sub_806F1FC(structPtr);
break;
- case 0:
case 1:
+ case 0:
default:
sub_806F160(structPtr);
break;
@@ -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];
}