summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/battle_script_commands.c28
-rw-r--r--src/battle_tower.c8
-rw-r--r--src/dewford_trend.c38
-rw-r--r--src/pokedex.c10
-rw-r--r--src/pokemon.c41
-rw-r--r--src/pokemon_animation.c9
-rw-r--r--src/record_mixing.c44
7 files changed, 76 insertions, 102 deletions
diff --git a/src/battle_script_commands.c b/src/battle_script_commands.c
index 7ded6fcd8..e3405bc0c 100644
--- a/src/battle_script_commands.c
+++ b/src/battle_script_commands.c
@@ -7127,18 +7127,12 @@ static void Cmd_forcerandomswitch(void)
s32 i;
s32 battler1PartyId = 0;
s32 battler2PartyId = 0;
-
- #ifdef NONMATCHING
- s32 lastMonId = 0; // + 1
- #else
- register s32 lastMonId asm("r8") = 0; // + 1
- #endif // NONMATCHING
-
- s32 firstMonId = 0;
- s32 monsCount = 0;
+ s32 firstMonId;
+ s32 lastMonId = 0; // + 1
+ s32 monsCount;
struct Pokemon* party = NULL;
s32 validMons = 0;
- s32 minNeeded = 0;
+ s32 minNeeded;
if ((gBattleTypeFlags & BATTLE_TYPE_TRAINER))
{
@@ -7250,14 +7244,14 @@ static void Cmd_forcerandomswitch(void)
{
do
{
- i = Random() % monsCount;
- i += firstMonId;
- }
- while (i == battler2PartyId
- || i == battler1PartyId
- || GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE
+ do
+ {
+ i = Random() % monsCount;
+ i += firstMonId;
+ } while (i == battler2PartyId || i == battler1PartyId);
+ } while (GetMonData(&party[i], MON_DATA_SPECIES) == SPECIES_NONE
|| GetMonData(&party[i], MON_DATA_IS_EGG) == TRUE
- || GetMonData(&party[i], MON_DATA_HP) == 0);
+ || GetMonData(&party[i], MON_DATA_HP) == 0); // Should be one while loop, conjoined by an ||, but that doesn't match. Equivalent logic though
}
*(gBattleStruct->monToSwitchIntoId + gBattlerTarget) = i;
diff --git a/src/battle_tower.c b/src/battle_tower.c
index 0333c4397..e0ff3fe26 100644
--- a/src/battle_tower.c
+++ b/src/battle_tower.c
@@ -1447,7 +1447,7 @@ u8 GetFrontierOpponentClass(u16 trainerId)
}
else if (trainerId == TRAINER_FRONTIER_BRAIN)
{
- trainerClass = GetFrontierBrainTrainerClass();
+ return GetFrontierBrainTrainerClass(); // This sticks out like a sore thumb, but this is the only other way that matches. Maybe it SHOULD be assigned to ret, or all early returns. I don't know.
}
else if (trainerId == TRAINER_STEVEN_PARTNER)
{
@@ -1466,9 +1466,6 @@ u8 GetFrontierOpponentClass(u16 trainerId)
else
{
trainerClass = gFacilityClassToTrainerClass[gSaveBlock2Ptr->frontier.towerRecords[trainerId - TRAINER_RECORD_MIXING_FRIEND].facilityClass];
- #ifndef NONMATCHING
- asm("");
- #endif
}
}
else
@@ -1480,9 +1477,6 @@ u8 GetFrontierOpponentClass(u16 trainerId)
else
{
trainerClass = gFacilityClassToTrainerClass[gApprentices[gSaveBlock2Ptr->apprentices[trainerId - TRAINER_RECORD_MIXING_APPRENTICE].id].facilityClass];
- #ifndef NONMATCHING
- asm("");
- #endif
}
}
diff --git a/src/dewford_trend.c b/src/dewford_trend.c
index e3b98859c..ff1b09041 100644
--- a/src/dewford_trend.c
+++ b/src/dewford_trend.c
@@ -245,46 +245,46 @@ static bool8 sub_8122A58(struct EasyChatPair *a, struct EasyChatPair *b, u8 c)
{
case 0:
if (a->unk0_0 > b->unk0_0)
- return 1;
+ return TRUE;
if (a->unk0_0 < b->unk0_0)
- return 0;
+ return FALSE;
if (a->unk0_7 > b->unk0_7)
- return 1;
+ return TRUE;
if (a->unk0_7 < b->unk0_7)
- return 0;
+ return FALSE;
break;
case 1:
if (a->unk0_7 > b->unk0_7)
- return 1;
+ return TRUE;
if (a->unk0_7 < b->unk0_7)
- return 0;
+ return FALSE;
if (a->unk0_0 > b->unk0_0)
- return 1;
+ return TRUE;
if (a->unk0_0 < b->unk0_0)
- return 0;
+ return FALSE;
break;
case 2:
if (a->unk0_0 > b->unk0_0)
- return 1;
+ return TRUE;
if (a->unk0_0 < b->unk0_0)
- return 0;
+ return FALSE;
if (a->unk0_7 > b->unk0_7)
- return 1;
+ return TRUE;
if (a->unk0_7 < b->unk0_7)
- return 0;
+ return FALSE;
if (a->unk2 > b->unk2)
- return 1;
+ return TRUE;
if (a->unk2 < b->unk2)
- return 0;
+ return FALSE;
if (a->words[0] > b->words[0])
- return 1;
+ return TRUE;
if (a->words[0] < b->words[0])
- return 0;
+ return FALSE;
if (a->words[1] > b->words[1])
- return 1;
+ return TRUE;
if (a->words[1] < b->words[1])
- return 0;
- return 1;
+ return FALSE;
+ return TRUE;
}
return Random() & 1;
}
diff --git a/src/pokedex.c b/src/pokedex.c
index e49911891..edc324b6e 100644
--- a/src/pokedex.c
+++ b/src/pokedex.c
@@ -5453,8 +5453,8 @@ static void PrintSearchParameterText(u8 taskId)
const struct SearchOptionText *texts = sSearchOptions[gTasks[taskId].tMenuItem].texts;
const u16 *cursorPos = &gTasks[taskId].data[sSearchOptions[gTasks[taskId].tMenuItem].taskDataCursorPos];
const u16 *scrollOffset = &gTasks[taskId].data[sSearchOptions[gTasks[taskId].tMenuItem].taskDataScrollOffset];
- u16 i;
- u16 j;
+
+ u16 i, j;
ClearSearchParameterBoxText();
@@ -5543,8 +5543,7 @@ static bool8 SearchParamCantScrollUp(u8 taskId)
if (lastOption > MAX_SEARCH_PARAM_CURSOR_POS && *scrollOffset != 0)
return FALSE;
- else
- return TRUE;
+ return TRUE;
}
static bool8 SearchParamCantScrollDown(u8 taskId)
@@ -5555,8 +5554,7 @@ static bool8 SearchParamCantScrollDown(u8 taskId)
if (lastOption > MAX_SEARCH_PARAM_CURSOR_POS && *scrollOffset < lastOption - MAX_SEARCH_PARAM_CURSOR_POS)
return FALSE;
- else
- return TRUE;
+ return TRUE;
}
#define sTaskId data[0]
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];
}
diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c
index 37abb90e9..e63a2cef1 100644
--- a/src/pokemon_animation.c
+++ b/src/pokemon_animation.c
@@ -2884,13 +2884,10 @@ static void sub_8181C2C(struct Sprite *sprite)
}
else
{
- #ifndef NONMATCHING
- register s32 var asm("r4") = sUnknown_03001240[sprite->data[0]].field_8;
- #else
- s32 var = sUnknown_03001240[sprite->data[0]].field_8;
- #endif
- sprite->pos2.x = (var << 3) * (counter % 128) / 128 - (sUnknown_03001240[sprite->data[0]].field_8 * 8);
+ const s16 var = sUnknown_03001240[sprite->data[0]].field_8;
+
+ sprite->pos2.x = var * ((counter % 128) * 8) / 128 + 8 * -var; //Should be - 8 * var instead of + 8 * -var, but that doesn't match
sprite->pos2.y = -(Sin(counter % 128, 8));
}
diff --git a/src/record_mixing.c b/src/record_mixing.c
index 6c0a02d8c..b12b71697 100644
--- a/src/record_mixing.c
+++ b/src/record_mixing.c
@@ -713,17 +713,18 @@ static u8 sub_80E7A9C(struct DayCareMail *rmMail)
return rmMail->message.itemId;
}
-static void sub_80E7AA4(struct RecordMixingDayCareMail *src, size_t recordSize, u8 (*idxs)[2], u8 which0, u8 which1)
+static void ExchangeMail(struct RecordMixingDayCareMail *src, size_t recordSize, u8 (*idxs)[2], u8 which0, u8 which1)
{
struct DayCareMail buffer;
struct RecordMixingDayCareMail *mail1;
struct RecordMixingDayCareMail *mail2;
mail1 = (void *)src + recordSize * idxs[which0][0];
- memcpy(&buffer, &mail1->mail[idxs[which0][1]], sizeof(struct DayCareMail));
+ buffer = mail1->mail[idxs[which0][1]];
+
mail2 = (void *)src + recordSize * idxs[which1][0];
- memcpy(&mail1->mail[idxs[which0][1]], &mail2->mail[idxs[which1][1]], sizeof(struct DayCareMail));
- memcpy(&mail2->mail[idxs[which1][1]], &buffer, sizeof(struct DayCareMail));
+ mail1->mail[idxs[which0][1]] = mail2->mail[idxs[which1][1]];
+ mail2->mail[idxs[which1][1]] = buffer;
}
static void sub_80E7B2C(const u8 *src)
@@ -865,27 +866,22 @@ static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t r
}
else if (sp1c[i][0] == TRUE && sp1c[i][1] == TRUE)
{
- u32 var1, var2;
+ u8 mail1, mail2;
sp24[j][0] = i;
- var1 = sub_80E7A9C(&_src->mail[0]);
- var2 = sub_80E7A9C(&_src->mail[1]);
- if (!var1 && var2)
+ mail1 = sub_80E7A9C(&_src->mail[0]);
+ mail2 = sub_80E7A9C(&_src->mail[1]);
+ if (!(mail1 || mail2) || (mail1 && mail2)) //Logical (not bitwise) XOR. Should be ((mail1 || mail2) && !(mail1 && mail2)), but that doesn't match.
{
- #ifndef NONMATCHING
- register u8 one asm("r0") = 1; // boo, a fakematch
- sp24[j][1] = one;
- #else
- sp24[j][1] = 1;
- #endif
+ sp24[j][1] = Random2() % 2;
}
- else if ((var1 && var2) || (!var1 && !var2))
+ else if (mail1 && !mail2)
{
- sp24[j][1] = Random2() % 2;
+ sp24[j][1] = 0;
}
- else if (var1 && !var2)
+ else if (!mail1 && mail2)
{
- sp24[j][1] = 0;
+ sp24[j][1] = 1;
}
j++;
}
@@ -901,27 +897,27 @@ static void ReceiveDaycareMailData(struct RecordMixingDayCareMail *src, size_t r
switch (sp34)
{
case 2:
- sub_80E7AA4(src, recordSize, sp24, 0, 1);
+ ExchangeMail(src, recordSize, sp24, 0, 1);
break;
case 3:
which0 = gUnknown_0858CFB8[tableId][0];
which1 = gUnknown_0858CFB8[tableId][1];
- sub_80E7AA4(src, recordSize, sp24, which0, which1);
+ ExchangeMail(src, recordSize, sp24, which0, which1);
break;
case 4:
ptr = sp24;
which0 = gUnknown_0858CFBE[tableId][0];
which1 = gUnknown_0858CFBE[tableId][1];
- sub_80E7AA4(src, recordSize, ptr, which0, which1);
+ ExchangeMail(src, recordSize, ptr, which0, which1);
which0 = gUnknown_0858CFBE[tableId][2];
which1 = gUnknown_0858CFBE[tableId][3];
- sub_80E7AA4(src, recordSize, ptr, which0, which1);
+ ExchangeMail(src, recordSize, ptr, which0, which1);
break;
}
_src = (void *)src + which * recordSize;
- memcpy(&gSaveBlock1Ptr->daycare.mons[0].mail, &_src->mail[0], sizeof(struct DayCareMail));
- memcpy(&gSaveBlock1Ptr->daycare.mons[1].mail, &_src->mail[1], sizeof(struct DayCareMail));
+ gSaveBlock1Ptr->daycare.mons[0].mail = _src->mail[0];
+ gSaveBlock1Ptr->daycare.mons[1].mail = _src->mail[1];
SeedRng(oldSeed);
}