Match some nonmatchings

This commit is contained in:
DizzyEggg 2024-10-31 11:52:35 +01:00
parent d6197d5176
commit cc3f1d1096
8 changed files with 50 additions and 96 deletions

View File

@ -14,13 +14,12 @@ typedef struct MissionText
} MissionText;
const u8 *GetCurrentMissionText(s16 index);
// TODO: this should probably be bool8 but can't get a match just yet
bool32 IsMazeCompleted(s16 mazeIndex);
bool8 IsMazeCompleted(s16 mazeIndex);
bool8 sub_8096F50(WonderMail *mail);
void sub_8097418(s16 index, bool32);
bool8 sub_8097504(s16 mazeIndex);
const u8 *sub_80975DC(u32);
const u8 *sub_80975DC(s16);
// These two are definitely bool8 but can't get them to match with it yet
//bool8 sub_8097384(s16);

View File

@ -105,7 +105,12 @@ static inline bool8 PokemonFlag1(PokemonStruct1 *mon)
static inline bool8 PokemonFlag2(PokemonStruct1 *mon)
{
return (((mon->unk0 >> 1) & 1));
return (((mon->unk0 >> (FLAG_ON_TEAM - 1)) & 1));
}
static inline void SetPokemonFlag2(PokemonStruct1 *mon)
{
mon->unk0 |= FLAG_ON_TEAM;
}
static inline bool8 IsMonTeamLeader(PokemonStruct1 *pokemon)

View File

@ -4,29 +4,25 @@
#include "dungeon.h"
#include "event_flag.h"
#include "code_80A26CC.h"
#include "code_80972F4.h"
ALIGNED(4) const char gMeetNinetalesText[] = "Meet Ninetales.";
ALIGNED(4) const char gAvoidCaptureText[] = "Avoid capture.";
ALIGNED(4) const char gFinalScenarioText[] = _("Defeat the final Pokémon.");
// Needed to match
static inline s16 Self(s16 a)
{
return a;
}
bool8 sub_8097504(s16 mazeIndex)
{
s32 mazeIndex_s32;
#ifndef NONMATCHING
register s32 mazeIndex_s32_1 asm("r1");
#else
s32 mazeIndex_s32_1;
#endif
s32 uVar3;
mazeIndex_s32 = mazeIndex;
mazeIndex_s32_1 = mazeIndex_s32;
if(mazeIndex_s32 < 17)
s32 mazeIndex_ = Self(mazeIndex);
if(mazeIndex < 17)
{
switch(mazeIndex_s32) {
switch(mazeIndex) {
case 2:
case 10:
case 11:
@ -55,9 +51,9 @@ bool8 sub_8097504(s16 mazeIndex)
}
else
{
if (mazeIndex_s32_1 > 22) return FALSE;
if (mazeIndex_s32_1 == 22) return FALSE;
if (mazeIndex_s32_1 == 21) return FALSE;
if (mazeIndex_ > 22) return FALSE;
if (mazeIndex_ == 22) return FALSE;
if (mazeIndex_ == 21) return FALSE;
uVar3 = 6;
}
@ -69,16 +65,9 @@ bool8 sub_8097504(s16 mazeIndex)
}
}
// TODO: this should probably be bool8 but can't get a match just yet
bool32 IsMazeCompleted(s16 mazeIndex)
bool8 IsMazeCompleted(s16 mazeIndex)
{
bool32 mazeCompletion;
mazeCompletion = GetScriptVarArrayValue(NULL, TRAINING_CONQUEST_LIST, mazeIndex);
if (mazeCompletion) {
mazeCompletion = TRUE;
}
return mazeCompletion;
return (GetScriptVarArrayValue(NULL, TRAINING_CONQUEST_LIST, mazeIndex) != 0);
}
void sub_80975A8(s16 param_1,u8 param_2)
@ -92,15 +81,14 @@ const u8 *sub_80975C4(s16 index)
return GetDungeonName1(sub_80A2728(index));
}
const u8 *sub_80975DC(u32 r0)
const u8 *sub_80975DC(s16 r0)
{
// TODO: slight hack but matches
r0 <<= 16;
if((0xffe90000 + r0) >> 16 < 2)
if(r0 == 23 || r0 == 24) {
if(ScriptVarScenarioEqual(SCENARIO_MAIN, 0xE, -1))
return gMeetNinetalesText;
else
return gAvoidCaptureText;
}
else
return gFinalScenarioText;
}

View File

@ -416,8 +416,7 @@ void sub_80277FC(void)
void sub_80278B4(void)
{
PokemonStruct1 *playerStruct;
PokemonStruct1 *pokeStruct1;
PokemonStruct1 *pokeStruct2;
PokemonStruct1 *newLeader;
u32 menuAction;
menuAction = 0;
@ -428,15 +427,7 @@ void sub_80278B4(void)
switch(menuAction) {
case FRIEND_AREA_ACTION_MENU_ACTION_JOIN_TEAM:
if (sub_808D750(sUnknown_203B2BC->targetPoke)) {
#ifdef NONMATCHING
pokeStruct1 = &gRecruitedPokemonRef->pokemon[sUnknown_203B2BC->targetPoke];
#else
register size_t offset asm("r1") = offsetof(unkStruct_203B45C, pokemon[sUnknown_203B2BC->targetPoke]);
PokemonStruct1* p = gRecruitedPokemonRef->pokemon;
size_t addr = offset + (size_t)p;
pokeStruct1 = (PokemonStruct1*)addr;
#endif
pokeStruct1->unk0 |= FLAG_ON_TEAM;
SetPokemonFlag2(&gRecruitedPokemonRef->pokemon[sUnknown_203B2BC->targetPoke]);
nullsub_104();
}
sub_808ED00();
@ -449,11 +440,11 @@ void sub_80278B4(void)
SetFriendAreaActionMenuState(FRIEND_AREA_ACTION_MENU_MAIN_2);
break;
case FRIEND_AREA_ACTION_MENU_ACTION_MAKE_LEADER:
pokeStruct2 = &gRecruitedPokemonRef->pokemon[sUnknown_203B2BC->targetPoke];
newLeader = &gRecruitedPokemonRef->pokemon[sUnknown_203B2BC->targetPoke];
playerStruct = GetPlayerPokemonStruct();
if (!pokeStruct2->isTeamLeader) {
if (!newLeader->isTeamLeader) {
playerStruct->isTeamLeader = FALSE;
pokeStruct2->isTeamLeader = TRUE;
newLeader->isTeamLeader = TRUE;
nullsub_104();
}
sub_808ED00();

View File

@ -21,13 +21,7 @@ static void sub_801C440(void);
bool8 CreateIQSkillListMenu(s16 species, u32 index, u32 a2)
{
#ifndef NONMATCHING
register s32 species_s32 asm("r4");
#else
s32 species_s32;
#endif
species_s32 = species;
s32 species_s32 = SpeciesId(species);
if (HasNoAvailIQSkills(species))
return FALSE;

View File

@ -912,9 +912,7 @@ s32 sub_80935B8(Move *moves, s32 index)
}
// this is so stupid but it works
#ifndef NONMATCHING
isNonTrivialLinkSequence++; isNonTrivialLinkSequence--;
#endif
ASM_MATCH_TRICK(isNonTrivialLinkSequence);
for (i = linkSequenceStart + 1; i < MAX_MON_MOVES; i++) {
Move *move = &moves[i];

View File

@ -464,8 +464,7 @@ void PartyListMenu_BuildYesNoMenu(void) {
void PartyListMenu_HandleMenu1(void)
{
PokemonStruct1 *playerPokemon;
PokemonStruct1 *pokeStruct;
PokemonStruct1 *pokeStruct2;
PokemonStruct1 *newLeader;
s32 choice;
choice = 0;
@ -475,17 +474,7 @@ void PartyListMenu_HandleMenu1(void)
switch(choice) {
case PARTY_LIST_MENU_JOIN_TEAM:
if (sub_808D750(sUnknown_203B2B8->pokeSpecies)) {
#ifdef NONMATCHING
pokeStruct = &sUnknown_203B2B8->pokeSpecies[gRecruitedPokemonRef->pokemon];
#else
register size_t offset asm("r1") = offsetof(unkStruct_203B45C, pokemon[sUnknown_203B2B8->pokeSpecies]);
PokemonStruct1* p = gRecruitedPokemonRef->pokemon;
size_t addr = offset + (size_t)p;
pokeStruct = (PokemonStruct1*)addr;
#endif
pokeStruct->unk0 |= FLAG_ON_TEAM;
SetPokemonFlag2(&sUnknown_203B2B8->pokeSpecies[gRecruitedPokemonRef->pokemon]);
nullsub_104();
}
sub_808ED00();
@ -498,12 +487,12 @@ void PartyListMenu_HandleMenu1(void)
SetPartyListMenuState(PARTY_LIST_STATE_STANDBY);
break;
case PARTY_LIST_MENU_MAKE_LEADER:
pokeStruct2 = &gRecruitedPokemonRef->pokemon[sUnknown_203B2B8->pokeSpecies];
newLeader = &gRecruitedPokemonRef->pokemon[sUnknown_203B2B8->pokeSpecies];
playerPokemon = GetPlayerPokemonStruct();
if (!pokeStruct2->isTeamLeader) {
if (!newLeader->isTeamLeader) {
playerPokemon->isTeamLeader = FALSE;
pokeStruct2->isTeamLeader = TRUE;
newLeader->isTeamLeader = TRUE;
nullsub_104();
}
sub_808ED00();

View File

@ -679,31 +679,21 @@ void GetPokemonLevelData(LevelData* a1, s16 _id, s32 level)
*a1 = gLevelCurrentData[level];
}
const u8* DecompressMoveID(const u8* a1, u16* moveID)
const u8* DecompressMoveID(const u8* src, u16* moveID)
{
u32 r1 = *a1++;
u32 r3;
if (r1 & 0x80) {
r3 = *a1++;
u32 byte0;
u32 byte1 = *src++;
// If move >= 127 which means it uses 2 bytes and not one
if (byte1 & 0x80) {
byte0 = *src++;
}
else {
r3 = r1;
r1 = 0;
byte0 = byte1;
byte1 = 0;
}
#ifdef NONMATCHING
// wrong order
r1 &= 0x7f;
r3 &= 0x7f;
*moveID = (r1 << 7) | r3;
#else
{
register u32 mask asm("r0") = 0x7f;
r3 &= mask;
r1 &= mask;
*moveID = (r1 << 7) | r3;
}
#endif
return a1;
*moveID = (byte0 & 0x7F) | ((byte1 & 0x7F) << 7);
return src;
}
s32 sub_808E0AC(u16* a1, s16 species, s32 a3, s32 IQPoints)
@ -711,9 +701,9 @@ s32 sub_808E0AC(u16* a1, s16 species, s32 a3, s32 IQPoints)
const u8* stream;
u16 moveID; // moveID
s32 count;
register s32 _species asm("r2"); // weird regalloc
s32 _species;
_species = (s16)species;
_species = SpeciesId(species);
count = 0;
if (species == MONSTER_DECOY) return 0;