mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-26 03:34:15 +01:00
Merge pull request #1265 from Kurausukun/berry_crush
fakematch fixes, begin documenting Berry Crush (based on #1187)
This commit is contained in:
commit
15c2856b24
5
Makefile
5
Makefile
@ -63,13 +63,14 @@ ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN)
|
||||
|
||||
ifeq ($(MODERN),0)
|
||||
CC1 := tools/agbcc/bin/agbcc$(EXE)
|
||||
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm
|
||||
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm -g
|
||||
ROM := pokeemerald.gba
|
||||
OBJ_DIR := build/emerald
|
||||
LIBPATH := -L ../../tools/agbcc/lib
|
||||
else
|
||||
CC1 = $(shell $(CC) --print-prog-name=cc1) -quiet
|
||||
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast
|
||||
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mcpu=arm7tdmi -fno-toplevel-reorder -Wno-pointer-to-int-cast -g
|
||||
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -Wno-pointer-to-int-cast -g
|
||||
ROM := pokeemerald_modern.gba
|
||||
OBJ_DIR := build/modern
|
||||
LIBPATH := -L "$(dir $(shell $(CC) -mthumb -print-file-name=libgcc.a))" -L "$(dir $(shell $(CC) -mthumb -print-file-name=libc.a))"
|
||||
|
@ -585,7 +585,11 @@ struct BattleSpriteData
|
||||
struct MonSpritesGfx
|
||||
{
|
||||
void* firstDecompressed; // ptr to the decompressed sprite of the first pokemon
|
||||
void* sprites[4];
|
||||
union
|
||||
{
|
||||
void* ptr[4];
|
||||
u8* byte[4];
|
||||
} sprites;
|
||||
struct SpriteTemplate templates[4];
|
||||
struct SpriteFrameImage field_74[4][4];
|
||||
u8 field_F4[0x80];
|
||||
|
@ -195,15 +195,10 @@ struct ObjectEvent
|
||||
/*0x0C*/ struct Coords16 initialCoords;
|
||||
/*0x10*/ struct Coords16 currentCoords;
|
||||
/*0x14*/ struct Coords16 previousCoords;
|
||||
/*0x18*/ u8 facingDirection:4; // current direction?
|
||||
/*0x18*/ u8 movementDirection:4;
|
||||
/*0x19*/ union __attribute__((packed)) {
|
||||
u8 as_byte;
|
||||
struct __attribute__((packed)) {
|
||||
u8 x:4;
|
||||
u8 y:4;
|
||||
} ALIGNED(1) as_nybbles;
|
||||
} ALIGNED(1) range;
|
||||
/*0x18*/ u16 facingDirection:4; // current direction?
|
||||
u16 movementDirection:4;
|
||||
u16 rangeX:4;
|
||||
u16 rangeY:4;
|
||||
/*0x1A*/ u8 fieldEffectSpriteId;
|
||||
/*0x1B*/ u8 warpArrowSpriteId;
|
||||
/*0x1C*/ u8 movementActionId;
|
||||
|
@ -624,8 +624,8 @@ static void RecordLastUsedMoveByTarget(void)
|
||||
{
|
||||
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == gLastMoves[gBattlerTarget])
|
||||
break;
|
||||
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] != gLastMoves[gBattlerTarget] // HACK: This redundant condition is a hack to make the asm match.
|
||||
&& BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == MOVE_NONE)
|
||||
|
||||
if (BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] == MOVE_NONE)
|
||||
{
|
||||
BATTLE_HISTORY->usedMoves[gBattlerTarget].moves[i] = gLastMoves[gBattlerTarget];
|
||||
break;
|
||||
|
@ -2290,7 +2290,7 @@ void AnimTask_TransformMon(u8 taskId)
|
||||
else
|
||||
position = GetBattlerPosition(gBattleAnimAttacker);
|
||||
|
||||
src = gMonSpritesGfxPtr->sprites[position] + (gBattleMonForms[gBattleAnimAttacker] << 11);
|
||||
src = gMonSpritesGfxPtr->sprites.ptr[position] + (gBattleMonForms[gBattleAnimAttacker] << 11);
|
||||
dest = animBg.bgTiles;
|
||||
CpuCopy32(src, dest, 0x800);
|
||||
LoadBgTiles(1, animBg.bgTiles, 0x800, animBg.tilesOffset);
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include "constants/battle_anim.h"
|
||||
#include "battle_interface.h"
|
||||
#include "main.h"
|
||||
#include "dma3.h"
|
||||
#include "malloc.h"
|
||||
#include "graphics.h"
|
||||
#include "random.h"
|
||||
@ -567,7 +568,7 @@ void BattleLoadOpponentMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
|
||||
otId = GetMonData(mon, MON_DATA_OT_ID);
|
||||
position = GetBattlerPosition(battlerId);
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
|
||||
gMonSpritesGfxPtr->sprites[position],
|
||||
gMonSpritesGfxPtr->sprites.ptr[position],
|
||||
species, currentPersonality);
|
||||
|
||||
paletteOffset = 0x100 + battlerId * 16;
|
||||
@ -623,13 +624,13 @@ void BattleLoadPlayerMonSpriteGfx(struct Pokemon *mon, u8 battlerId)
|
||||
if (sub_80688F8(1, battlerId) == 1 || gBattleSpritesDataPtr->battlerData[battlerId].transformSpecies != SPECIES_NONE)
|
||||
{
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species],
|
||||
gMonSpritesGfxPtr->sprites[position],
|
||||
gMonSpritesGfxPtr->sprites.ptr[position],
|
||||
species, currentPersonality);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleLoadSpecialPokePic(&gMonBackPicTable[species],
|
||||
gMonSpritesGfxPtr->sprites[position],
|
||||
gMonSpritesGfxPtr->sprites.ptr[position],
|
||||
species, currentPersonality);
|
||||
}
|
||||
|
||||
@ -671,7 +672,7 @@ void DecompressTrainerFrontPic(u16 frontPicId, u8 battlerId)
|
||||
{
|
||||
u8 position = GetBattlerPosition(battlerId);
|
||||
DecompressPicFromTable_2(&gTrainerFrontPicTable[frontPicId],
|
||||
gMonSpritesGfxPtr->sprites[position],
|
||||
gMonSpritesGfxPtr->sprites.ptr[position],
|
||||
SPECIES_NONE);
|
||||
LoadCompressedSpritePalette(&gTrainerFrontPicPaletteTable[frontPicId]);
|
||||
}
|
||||
@ -680,7 +681,7 @@ void DecompressTrainerBackPic(u16 backPicId, u8 battlerId)
|
||||
{
|
||||
u8 position = GetBattlerPosition(battlerId);
|
||||
DecompressPicFromTable_2(&gTrainerBackPicTable[backPicId],
|
||||
gMonSpritesGfxPtr->sprites[position],
|
||||
gMonSpritesGfxPtr->sprites.ptr[position],
|
||||
SPECIES_NONE);
|
||||
LoadCompressedPalette(gTrainerBackPicPaletteTable[backPicId].data,
|
||||
0x100 + 16 * battlerId, 0x20);
|
||||
@ -920,7 +921,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform
|
||||
otId = gContestResources->moveAnim->otId;
|
||||
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies],
|
||||
gMonSpritesGfxPtr->sprites[0],
|
||||
gMonSpritesGfxPtr->sprites.ptr[0],
|
||||
targetSpecies,
|
||||
gContestResources->moveAnim->targetPersonality);
|
||||
}
|
||||
@ -939,7 +940,7 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform
|
||||
otId = GetMonData(&gPlayerParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);
|
||||
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[targetSpecies],
|
||||
gMonSpritesGfxPtr->sprites[position],
|
||||
gMonSpritesGfxPtr->sprites.ptr[position],
|
||||
targetSpecies,
|
||||
gTransformedPersonalities[battlerAtk]);
|
||||
}
|
||||
@ -949,14 +950,14 @@ void HandleSpeciesGfxDataChange(u8 battlerAtk, u8 battlerDef, bool8 notTransform
|
||||
otId = GetMonData(&gEnemyParty[gBattlerPartyIndexes[battlerAtk]], MON_DATA_OT_ID);
|
||||
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[targetSpecies],
|
||||
gMonSpritesGfxPtr->sprites[position],
|
||||
gMonSpritesGfxPtr->sprites.ptr[position],
|
||||
targetSpecies,
|
||||
gTransformedPersonalities[battlerAtk]);
|
||||
}
|
||||
}
|
||||
|
||||
src = gMonSpritesGfxPtr->sprites[position];
|
||||
dst = (void *)(VRAM + 0x10000 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32);
|
||||
src = gMonSpritesGfxPtr->sprites.ptr[position];
|
||||
dst = (void *)(OBJ_VRAM0 + gSprites[gBattlerSpriteIds[battlerAtk]].oam.tileNum * 32);
|
||||
DmaCopy32(3, src, dst, 0x800);
|
||||
paletteOffset = 0x100 + battlerAtk * 16;
|
||||
lzPaletteData = GetMonSpritePalFromSpeciesAndPersonality(targetSpecies, otId, personalityValue);
|
||||
@ -996,18 +997,15 @@ void BattleLoadSubstituteOrMonSpriteGfx(u8 battlerId, bool8 loadMonSprite)
|
||||
position = GetBattlerPosition(battlerId);
|
||||
|
||||
if (IsContest())
|
||||
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[position]);
|
||||
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites.ptr[position]);
|
||||
else if (GetBattlerSide(battlerId) != B_SIDE_PLAYER)
|
||||
LZDecompressVram(gSubstituteDollGfx, gMonSpritesGfxPtr->sprites[position]);
|
||||
LZDecompressVram(gSubstituteDollGfx, gMonSpritesGfxPtr->sprites.ptr[position]);
|
||||
else
|
||||
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites[position]);
|
||||
LZDecompressVram(gSubstituteDollTilemap, gMonSpritesGfxPtr->sprites.ptr[position]);
|
||||
|
||||
for (i = 1; i < 4; i++)
|
||||
{
|
||||
u8 (*ptr)[4][0x800] = gMonSpritesGfxPtr->sprites[position];
|
||||
ptr++;ptr--; // Needed to match.
|
||||
|
||||
DmaCopy32Defvars(3, (*ptr)[0], (*ptr)[i], 0x800);
|
||||
Dma3CopyLarge32_(gMonSpritesGfxPtr->sprites.ptr[position], &gMonSpritesGfxPtr->sprites.byte[position][0x800 * i], 0x800);
|
||||
}
|
||||
|
||||
palOffset = (battlerId * 16) + 0x100;
|
||||
@ -1247,12 +1245,12 @@ void AllocateMonSpritesGfx(void)
|
||||
|
||||
for (i = 0; i < MAX_BATTLERS_COUNT; i++)
|
||||
{
|
||||
gMonSpritesGfxPtr->sprites[i] = gMonSpritesGfxPtr->firstDecompressed + (i * 0x2000);
|
||||
gMonSpritesGfxPtr->sprites.ptr[i] = gMonSpritesGfxPtr->firstDecompressed + (i * 0x2000);
|
||||
*(gMonSpritesGfxPtr->templates + i) = gUnknown_08329D98[i];
|
||||
|
||||
for (j = 0; j < 4; j++)
|
||||
{
|
||||
gMonSpritesGfxPtr->field_74[i][j].data = gMonSpritesGfxPtr->sprites[i] + (j * 0x800);
|
||||
gMonSpritesGfxPtr->field_74[i][j].data = gMonSpritesGfxPtr->sprites.ptr[i] + (j * 0x800);
|
||||
gMonSpritesGfxPtr->field_74[i][j].size = 0x800;
|
||||
}
|
||||
|
||||
@ -1274,10 +1272,10 @@ void FreeMonSpritesGfx(void)
|
||||
|
||||
FREE_AND_SET_NULL(gMonSpritesGfxPtr->barFontGfx);
|
||||
FREE_AND_SET_NULL(gMonSpritesGfxPtr->firstDecompressed);
|
||||
gMonSpritesGfxPtr->sprites[0] = NULL;
|
||||
gMonSpritesGfxPtr->sprites[1] = NULL;
|
||||
gMonSpritesGfxPtr->sprites[2] = NULL;
|
||||
gMonSpritesGfxPtr->sprites[3] = NULL;
|
||||
gMonSpritesGfxPtr->sprites.ptr[0] = NULL;
|
||||
gMonSpritesGfxPtr->sprites.ptr[1] = NULL;
|
||||
gMonSpritesGfxPtr->sprites.ptr[2] = NULL;
|
||||
gMonSpritesGfxPtr->sprites.ptr[3] = NULL;
|
||||
FREE_AND_SET_NULL(gMonSpritesGfxPtr);
|
||||
}
|
||||
|
||||
|
@ -586,7 +586,7 @@ void sub_8118FBC(int bgId, u8 arg1, u8 arg2, u8 battlerPosition, u8 arg4, u8 *ar
|
||||
int i, j;
|
||||
u8 battler = GetBattlerAtPosition(battlerPosition);
|
||||
int offset = tilesOffset;
|
||||
CpuCopy16(gMonSpritesGfxPtr->sprites[battlerPosition] + BG_SCREEN_SIZE * gBattleMonForms[battler], arg5, BG_SCREEN_SIZE);
|
||||
CpuCopy16(gMonSpritesGfxPtr->sprites.ptr[battlerPosition] + BG_SCREEN_SIZE * gBattleMonForms[battler], arg5, BG_SCREEN_SIZE);
|
||||
LoadBgTiles(bgId, arg5, 0x1000, tilesOffset);
|
||||
for (i = arg2; i < arg2 + 8; i++)
|
||||
{
|
||||
@ -604,7 +604,7 @@ void unref_sub_8119094(u8 arg0, u8 arg1, u8 battlerPosition, u8 arg3, u8 arg4, u
|
||||
{
|
||||
int i, j, offset;
|
||||
|
||||
DmaCopy16(3, gMonSpritesGfxPtr->sprites[battlerPosition] + BG_SCREEN_SIZE * arg3, (void *)BG_SCREEN_ADDR(0) + arg5, BG_SCREEN_SIZE);
|
||||
DmaCopy16(3, gMonSpritesGfxPtr->sprites.ptr[battlerPosition] + BG_SCREEN_SIZE * arg3, (void *)BG_SCREEN_ADDR(0) + arg5, BG_SCREEN_SIZE);
|
||||
offset = (arg5 >> 5) - (arg7 << 9);
|
||||
for (i = arg1; i < arg1 + 8; i++)
|
||||
{
|
||||
|
@ -2765,7 +2765,7 @@ static void SpriteCB_AnimFaintOpponent(struct Sprite *sprite)
|
||||
}
|
||||
else // Erase bottom part of the sprite to create a smooth illusion of mon falling down.
|
||||
{
|
||||
u8 *dst = (u8 *)gMonSpritesGfxPtr->sprites[GetBattlerPosition(sprite->sBattler)] + (gBattleMonForms[sprite->sBattler] << 11) + (sprite->data[3] << 8);
|
||||
u8* dst = gMonSpritesGfxPtr->sprites.byte[GetBattlerPosition(sprite->sBattler)] + (gBattleMonForms[sprite->sBattler] << 11) + (sprite->data[3] << 8);
|
||||
|
||||
for (i = 0; i < 0x100; i++)
|
||||
*(dst++) = 0;
|
||||
|
@ -2288,8 +2288,7 @@ static const u8* TryGetStatusString(u8 *src)
|
||||
statusPtr = status;
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
if (*src == EOS)
|
||||
break;
|
||||
if (*src == EOS) break; // one line required to match -g
|
||||
*statusPtr = *src;
|
||||
src++;
|
||||
statusPtr++;
|
||||
|
@ -4666,19 +4666,16 @@ static void Cmd_jumpifcantswitch(void)
|
||||
}
|
||||
else if (gBattleTypeFlags & BATTLE_TYPE_INGAME_PARTNER)
|
||||
{
|
||||
#ifndef NONMATCHING
|
||||
asm("":::"r5");
|
||||
#endif // NONMATCHING
|
||||
if (GetBattlerSide(gActiveBattler) == B_SIDE_OPPONENT)
|
||||
party = gEnemyParty;
|
||||
else
|
||||
party = gPlayerParty;
|
||||
|
||||
i = 0;
|
||||
lastMonId = 0;
|
||||
if (gActiveBattler & 2)
|
||||
i = 3;
|
||||
lastMonId = 3;
|
||||
|
||||
for (lastMonId = i + 3; i < lastMonId; i++)
|
||||
for (i = lastMonId; i < lastMonId + 3; i++)
|
||||
{
|
||||
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
|
||||
@ -4687,7 +4684,7 @@ static void Cmd_jumpifcantswitch(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == lastMonId)
|
||||
if (i == lastMonId + 3)
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
|
||||
else
|
||||
gBattlescriptCurrInstr += 6;
|
||||
@ -4700,18 +4697,18 @@ static void Cmd_jumpifcantswitch(void)
|
||||
{
|
||||
party = gPlayerParty;
|
||||
|
||||
i = 0;
|
||||
lastMonId = 0;
|
||||
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gActiveBattler)) == TRUE)
|
||||
i = 3;
|
||||
lastMonId = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
party = gEnemyParty;
|
||||
|
||||
if (gActiveBattler == 1)
|
||||
i = 0;
|
||||
lastMonId = 0;
|
||||
else
|
||||
i = 3;
|
||||
lastMonId = 3;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -4721,12 +4718,12 @@ static void Cmd_jumpifcantswitch(void)
|
||||
else
|
||||
party = gPlayerParty;
|
||||
|
||||
i = 0;
|
||||
lastMonId = 0;
|
||||
if (GetLinkTrainerFlankId(GetBattlerMultiplayerId(gActiveBattler)) == TRUE)
|
||||
i = 3;
|
||||
lastMonId = 3;
|
||||
}
|
||||
|
||||
for (lastMonId = i + 3; i < lastMonId; i++)
|
||||
for (i = lastMonId; i < lastMonId + 3; i++)
|
||||
{
|
||||
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
|
||||
@ -4735,7 +4732,7 @@ static void Cmd_jumpifcantswitch(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == lastMonId)
|
||||
if (i == lastMonId + 3)
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
|
||||
else
|
||||
gBattlescriptCurrInstr += 6;
|
||||
@ -4744,11 +4741,11 @@ static void Cmd_jumpifcantswitch(void)
|
||||
{
|
||||
party = gEnemyParty;
|
||||
|
||||
i = 0;
|
||||
lastMonId = 0;
|
||||
if (gActiveBattler == B_POSITION_OPPONENT_RIGHT)
|
||||
i = 3;
|
||||
lastMonId = 3;
|
||||
|
||||
for (lastMonId = i + 3; i < lastMonId; i++)
|
||||
for (i = lastMonId; i < lastMonId + 3; i++)
|
||||
{
|
||||
if (GetMonData(&party[i], MON_DATA_SPECIES) != SPECIES_NONE
|
||||
&& !GetMonData(&party[i], MON_DATA_IS_EGG)
|
||||
@ -4757,7 +4754,7 @@ static void Cmd_jumpifcantswitch(void)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == lastMonId)
|
||||
if (i == lastMonId + 3)
|
||||
gBattlescriptCurrInstr = T1_READ_PTR(gBattlescriptCurrInstr + 2);
|
||||
else
|
||||
gBattlescriptCurrInstr += 6;
|
||||
@ -5035,14 +5032,9 @@ static void Cmd_openpartyscreen(void)
|
||||
hitmarkerFaintBits = gHitMarker >> 0x1C;
|
||||
|
||||
gBattlerFainted = 0;
|
||||
while (1)
|
||||
{
|
||||
if (gBitTable[gBattlerFainted] & hitmarkerFaintBits)
|
||||
break;
|
||||
if (gBattlerFainted >= gBattlersCount)
|
||||
break;
|
||||
while (!(gBitTable[gBattlerFainted] & hitmarkerFaintBits)
|
||||
&& gBattlerFainted < gBattlersCount)
|
||||
gBattlerFainted++;
|
||||
}
|
||||
|
||||
if (gBattlerFainted == gBattlersCount)
|
||||
gBattlescriptCurrInstr = jumpPtr;
|
||||
|
@ -1564,8 +1564,7 @@ static s32 TrainerIdToRematchTableId(const struct RematchTrainer *table, u16 tra
|
||||
{
|
||||
for (j = 0; j < REMATCHES_COUNT; j++)
|
||||
{
|
||||
if (table[i].trainerIds[j] == 0)
|
||||
break;
|
||||
if (table[i].trainerIds[j] == 0) break; // one line required to match -g
|
||||
if (table[i].trainerIds[j] == trainerId)
|
||||
return i;
|
||||
}
|
||||
|
@ -354,11 +354,7 @@ static void GenerateOpponentMons(void)
|
||||
{
|
||||
u16 trainerId;
|
||||
s32 i, j, k;
|
||||
#ifndef NONMATCHING
|
||||
register const u16 *monSet asm("r9"); // Fix me. Compiler insists on moving that variable into stack.
|
||||
#else
|
||||
const u16 *monSet;
|
||||
#endif
|
||||
const u16 *monSet;
|
||||
u16 species[FRONTIER_PARTY_SIZE];
|
||||
u16 heldItems[FRONTIER_PARTY_SIZE];
|
||||
s32 monId = 0;
|
||||
@ -379,7 +375,8 @@ static void GenerateOpponentMons(void)
|
||||
} while (i != gSaveBlock2Ptr->frontier.curChallengeBattleNum);
|
||||
|
||||
gTrainerBattleOpponent_A = trainerId;
|
||||
while (gFacilityTrainers[gTrainerBattleOpponent_A].monSet[monId] != 0xFFFF)
|
||||
monSet = gFacilityTrainers[gTrainerBattleOpponent_A].monSet;
|
||||
while (monSet[monId] != 0xFFFF)
|
||||
monId++;
|
||||
if (monId > 8)
|
||||
break;
|
||||
|
@ -1956,10 +1956,7 @@ static bool8 Phase2_Ripple_Func2(struct Task *task)
|
||||
for (i = 0; i < 160; i++, r4 += r8)
|
||||
{
|
||||
s16 var = r4 >> 8;
|
||||
|
||||
var++;
|
||||
var--;
|
||||
gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var, r3);
|
||||
gScanlineEffectRegBuffers[0][i] = sTransitionStructPtr->field_16 + Sin(var & 0xffff, r3);
|
||||
}
|
||||
|
||||
if (++task->tData3 == 81)
|
||||
|
@ -148,7 +148,7 @@ struct BerryCrushGame
|
||||
u32 (* unk4)(struct BerryCrushGame *, u8 *);
|
||||
u8 unk8;
|
||||
u8 unk9;
|
||||
u8 unkA;
|
||||
u8 mainTask;
|
||||
u8 unkB;
|
||||
u8 unkC;
|
||||
u8 unkD;
|
||||
@ -188,10 +188,10 @@ struct BerryCrushGame
|
||||
u8 unk31C0[0x1000];
|
||||
};
|
||||
|
||||
static void sub_8020F74(void);
|
||||
static void sub_8020F88(void);
|
||||
static void sub_8020FA0(u8);
|
||||
void sub_8020FC4(struct BerryCrushGame *);
|
||||
static void VBlankCB(void);
|
||||
static void MainCB(void);
|
||||
static void MainTask(u8);
|
||||
static void ParseName_Options(struct BerryCrushGame *);
|
||||
void sub_8022BEC(u16, u8, u8 *);
|
||||
static void BerryCrush_SetPaletteFadeParams(u8 *, bool8, u32, s8, u8, u8, u16);
|
||||
static int sub_8021450(struct BerryCrushGame *);
|
||||
@ -232,7 +232,7 @@ static u32 sub_8024444(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1
|
||||
static u32 sub_8024508(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1);
|
||||
static u32 sub_8024568(__attribute__((unused)) struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1);
|
||||
|
||||
static EWRAM_DATA struct BerryCrushGame *gUnknown_02022C90 = NULL;
|
||||
static EWRAM_DATA struct BerryCrushGame *gBerryCrushGame = NULL;
|
||||
|
||||
static const u8 gUnknown_082F325C[] = { 1, 2, 4, 8, 16, 32, 64, 128 };
|
||||
static const u8 gUnknown_082F3264[] = { 0, 1, 2, 3, 5, 0, 0, 0 };
|
||||
@ -805,22 +805,21 @@ static const u8 gUnknown_082F4434[][4] =
|
||||
static const u8 gUnknown_082F4444[] = {5, 7, 9, 12};
|
||||
static const u8 gUnknown_082F4448[] = {3, 7, 15, 31};
|
||||
|
||||
|
||||
struct BerryCrushGame *sub_8020C00(void)
|
||||
struct BerryCrushGame * GetBerryCrushGame(void)
|
||||
{
|
||||
return gUnknown_02022C90;
|
||||
return gBerryCrushGame;
|
||||
}
|
||||
|
||||
u32 sub_8020C0C(MainCallback callback)
|
||||
u32 QuitBerryCrush(MainCallback callback)
|
||||
{
|
||||
if (!gUnknown_02022C90)
|
||||
if (!gBerryCrushGame)
|
||||
return 2;
|
||||
|
||||
if (!callback)
|
||||
callback = gUnknown_02022C90->unk0;
|
||||
callback = gBerryCrushGame->unk0;
|
||||
|
||||
DestroyTask(gUnknown_02022C90->unkA);
|
||||
FREE_AND_SET_NULL(gUnknown_02022C90);
|
||||
DestroyTask(gBerryCrushGame->mainTask);
|
||||
FREE_AND_SET_NULL(gBerryCrushGame);
|
||||
SetMainCallback2(callback);
|
||||
if (callback == CB2_ReturnToField)
|
||||
{
|
||||
@ -857,8 +856,8 @@ void StartBerryCrush(MainCallback callback)
|
||||
return;
|
||||
}
|
||||
|
||||
gUnknown_02022C90 = AllocZeroed(sizeof(*gUnknown_02022C90));
|
||||
if (!gUnknown_02022C90)
|
||||
gBerryCrushGame = AllocZeroed(sizeof(*gBerryCrushGame));
|
||||
if (!gBerryCrushGame)
|
||||
{
|
||||
SetMainCallback2(callback);
|
||||
Rfu.unk_10 = 0;
|
||||
@ -867,110 +866,110 @@ void StartBerryCrush(MainCallback callback)
|
||||
return;
|
||||
}
|
||||
|
||||
gUnknown_02022C90->unk0 = callback;
|
||||
gUnknown_02022C90->unk8 = multiplayerId;
|
||||
gUnknown_02022C90->unk9 = playerCount;
|
||||
sub_8020FC4(gUnknown_02022C90);
|
||||
gUnknown_02022C90->unk12 = 1;
|
||||
gUnknown_02022C90->unkE = 1;
|
||||
gUnknown_02022C90->unkF = 6;
|
||||
BerryCrush_SetPaletteFadeParams(gUnknown_02022C90->unk36, 1, -1, 0, 16, 0, 0);
|
||||
sub_8022BEC(4, 1, gUnknown_02022C90->unk36);
|
||||
SetMainCallback2(sub_8020F88);
|
||||
gUnknown_02022C90->unkA = CreateTask(sub_8020FA0, 8);
|
||||
gBerryCrushGame->unk0 = callback;
|
||||
gBerryCrushGame->unk8 = multiplayerId;
|
||||
gBerryCrushGame->unk9 = playerCount;
|
||||
ParseName_Options(gBerryCrushGame);
|
||||
gBerryCrushGame->unk12 = 1;
|
||||
gBerryCrushGame->unkE = 1;
|
||||
gBerryCrushGame->unkF = 6;
|
||||
BerryCrush_SetPaletteFadeParams(gBerryCrushGame->unk36, 1, -1, 0, 16, 0, 0);
|
||||
sub_8022BEC(4, 1, gBerryCrushGame->unk36);
|
||||
SetMainCallback2(MainCB);
|
||||
gBerryCrushGame->mainTask = CreateTask(MainTask, 8);
|
||||
gTextFlags.autoScroll = 0;
|
||||
}
|
||||
|
||||
static void sub_8020D8C(void)
|
||||
static void GetBerryFromBag(void)
|
||||
{
|
||||
if (gSpecialVar_ItemId < FIRST_BERRY_INDEX || gSpecialVar_ItemId > LAST_BERRY_INDEX + 1)
|
||||
gSpecialVar_ItemId = ITEM_CHERI_BERRY;
|
||||
else
|
||||
RemoveBagItem(gSpecialVar_ItemId, 1);
|
||||
|
||||
gUnknown_02022C90->unk68.as_four_players.others[gUnknown_02022C90->unk8].unk0 = gSpecialVar_ItemId - FIRST_BERRY_INDEX;
|
||||
gUnknown_02022C90->unkE = 1;
|
||||
gUnknown_02022C90->unkF = 9;
|
||||
BerryCrush_SetPaletteFadeParams(gUnknown_02022C90->unk36, 0, -1, 0, 16, 0, 0);
|
||||
sub_8022BEC(4, 1, gUnknown_02022C90->unk36);
|
||||
gUnknown_02022C90->unkA = CreateTask(sub_8020FA0, 8);
|
||||
SetMainCallback2(sub_8020F88);
|
||||
gBerryCrushGame->unk68.as_four_players.others[gBerryCrushGame->unk8].unk0 = gSpecialVar_ItemId - FIRST_BERRY_INDEX;
|
||||
gBerryCrushGame->unkE = 1;
|
||||
gBerryCrushGame->unkF = 9;
|
||||
BerryCrush_SetPaletteFadeParams(gBerryCrushGame->unk36, 0, -1, 0, 16, 0, 0);
|
||||
sub_8022BEC(4, 1, gBerryCrushGame->unk36);
|
||||
gBerryCrushGame->mainTask = CreateTask(MainTask, 8);
|
||||
SetMainCallback2(MainCB);
|
||||
}
|
||||
|
||||
void sub_8020E1C(void)
|
||||
static void BerryCrush_SetupMainTask(void)
|
||||
{
|
||||
DestroyTask(gUnknown_02022C90->unkA);
|
||||
ChooseBerryForMachine(sub_8020D8C);
|
||||
DestroyTask(gBerryCrushGame->mainTask);
|
||||
ChooseBerryForMachine(GetBerryFromBag);
|
||||
}
|
||||
|
||||
static void sub_8020E3C(void)
|
||||
static void BerryCrush_SetVBlankCB(void)
|
||||
{
|
||||
SetVBlankCallback(sub_8020F74);
|
||||
SetVBlankCallback(VBlankCB);
|
||||
}
|
||||
|
||||
void sub_8020E4C(void)
|
||||
static void BerryCrush_InitVBlankCB(void)
|
||||
{
|
||||
SetVBlankCallback(NULL);
|
||||
}
|
||||
|
||||
void sub_8020E58(void)
|
||||
static void BerryCrush_SaveResults(void)
|
||||
{
|
||||
u32 var0, var1;
|
||||
|
||||
var0 = gUnknown_02022C90->unk68.as_four_players.unk00.unk04;
|
||||
var0 = gBerryCrushGame->unk68.as_four_players.unk00.unk04;
|
||||
var0 = Q_24_8(var0);
|
||||
var0 = MathUtil_Div32(var0, Q_24_8(60));
|
||||
var1 = gUnknown_02022C90->unk68.as_four_players.unk00.unk0A;
|
||||
var1 = gBerryCrushGame->unk68.as_four_players.unk00.unk0A;
|
||||
var1 = Q_24_8(var1);
|
||||
var1 = MathUtil_Div32(var1, var0) & 0xFFFF;
|
||||
gUnknown_02022C90->unk16 = var1;
|
||||
switch (gUnknown_02022C90->unk9)
|
||||
gBerryCrushGame->unk16 = var1;
|
||||
switch (gBerryCrushGame->unk9)
|
||||
{
|
||||
case 2:
|
||||
if (gUnknown_02022C90->unk16 > gSaveBlock2Ptr->berryCrush.berryCrushResults[0])
|
||||
if (gBerryCrushGame->unk16 > gSaveBlock2Ptr->berryCrush.berryCrushResults[0])
|
||||
{
|
||||
gUnknown_02022C90->unk25_1 = 1;
|
||||
gSaveBlock2Ptr->berryCrush.berryCrushResults[0] = gUnknown_02022C90->unk16;
|
||||
gBerryCrushGame->unk25_1 = 1;
|
||||
gSaveBlock2Ptr->berryCrush.berryCrushResults[0] = gBerryCrushGame->unk16;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
if (gUnknown_02022C90->unk16 > gSaveBlock2Ptr->berryCrush.berryCrushResults[1])
|
||||
if (gBerryCrushGame->unk16 > gSaveBlock2Ptr->berryCrush.berryCrushResults[1])
|
||||
{
|
||||
gUnknown_02022C90->unk25_1 = 1;
|
||||
gSaveBlock2Ptr->berryCrush.berryCrushResults[1] = gUnknown_02022C90->unk16;
|
||||
gBerryCrushGame->unk25_1 = 1;
|
||||
gSaveBlock2Ptr->berryCrush.berryCrushResults[1] = gBerryCrushGame->unk16;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
if (gUnknown_02022C90->unk16 > gSaveBlock2Ptr->berryCrush.berryCrushResults[2])
|
||||
if (gBerryCrushGame->unk16 > gSaveBlock2Ptr->berryCrush.berryCrushResults[2])
|
||||
{
|
||||
gUnknown_02022C90->unk25_1 = 1;
|
||||
gSaveBlock2Ptr->berryCrush.berryCrushResults[2] = gUnknown_02022C90->unk16;
|
||||
gBerryCrushGame->unk25_1 = 1;
|
||||
gSaveBlock2Ptr->berryCrush.berryCrushResults[2] = gBerryCrushGame->unk16;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
if (gUnknown_02022C90->unk16 > gSaveBlock2Ptr->berryCrush.berryCrushResults[3])
|
||||
if (gBerryCrushGame->unk16 > gSaveBlock2Ptr->berryCrush.berryCrushResults[3])
|
||||
{
|
||||
gUnknown_02022C90->unk25_1 = 1;
|
||||
gSaveBlock2Ptr->berryCrush.berryCrushResults[3] = gUnknown_02022C90->unk16;
|
||||
gBerryCrushGame->unk25_1 = 1;
|
||||
gSaveBlock2Ptr->berryCrush.berryCrushResults[3] = gBerryCrushGame->unk16;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
gUnknown_02022C90->unk1C = gUnknown_02022C90->unk68.as_four_players.unk00.unk00;
|
||||
if (GiveBerryPowder(gUnknown_02022C90->unk1C))
|
||||
gBerryCrushGame->unk1C = gBerryCrushGame->unk68.as_four_players.unk00.unk00;
|
||||
if (GiveBerryPowder(gBerryCrushGame->unk1C))
|
||||
return;
|
||||
|
||||
gUnknown_02022C90->unk25_0 = 1;
|
||||
gBerryCrushGame->unk25_0 = 1;
|
||||
}
|
||||
|
||||
static void sub_8020F74(void)
|
||||
static void VBlankCB(void)
|
||||
{
|
||||
TransferPlttBuffer();
|
||||
LoadOam();
|
||||
ProcessSpriteCopyRequests();
|
||||
}
|
||||
|
||||
static void sub_8020F88(void)
|
||||
static void MainCB(void)
|
||||
{
|
||||
RunTasks();
|
||||
RunTextPrinters();
|
||||
@ -978,12 +977,12 @@ static void sub_8020F88(void)
|
||||
BuildOamBuffer();
|
||||
}
|
||||
|
||||
static void sub_8020FA0(u8 taskId)
|
||||
static void MainTask(u8 taskId)
|
||||
{
|
||||
if (gUnknown_02022C90->unk4)
|
||||
gUnknown_02022C90->unk4(gUnknown_02022C90, gUnknown_02022C90->unk36);
|
||||
if (gBerryCrushGame->unk4)
|
||||
gBerryCrushGame->unk4(gBerryCrushGame, gBerryCrushGame->unk36);
|
||||
|
||||
sub_8021450(gUnknown_02022C90);
|
||||
sub_8021450(gBerryCrushGame);
|
||||
}
|
||||
|
||||
#define PLAYER_UNK14(game, i) \
|
||||
@ -992,11 +991,11 @@ static void sub_8020FA0(u8 taskId)
|
||||
+ offsetof(struct BerryCrushGame_68_x, unk30) \
|
||||
+ sizeof(struct BerryCrushGame_Player) * (i))
|
||||
|
||||
void sub_8020FC4(struct BerryCrushGame *arg0)
|
||||
static void ParseName_Options(struct BerryCrushGame *arg0)
|
||||
{
|
||||
u8 i;
|
||||
u8 i = 0;
|
||||
|
||||
for (i = 0; i < arg0->unk9; i++)
|
||||
for (; i < arg0->unk9; i++)
|
||||
StringCopy(PLAYER_UNK14(arg0, i), gLinkPlayers[i].name);
|
||||
for (; i < 5; i++)
|
||||
{
|
||||
@ -1018,13 +1017,14 @@ void sub_8020FC4(struct BerryCrushGame *arg0)
|
||||
}
|
||||
}
|
||||
|
||||
int sub_802104C(void)
|
||||
// TODO: Everything from here on is likely in separate files.
|
||||
s32 InitBerryCrushDisplay(void)
|
||||
{
|
||||
struct BerryCrushGame *var0 = sub_8020C00();
|
||||
if (!var0)
|
||||
struct BerryCrushGame *game = GetBerryCrushGame();
|
||||
if (!game)
|
||||
return -1;
|
||||
|
||||
switch (var0->unkC)
|
||||
switch (game->unkC)
|
||||
{
|
||||
case 0:
|
||||
SetVBlankCallback(NULL);
|
||||
@ -1046,9 +1046,9 @@ int sub_802104C(void)
|
||||
case 3:
|
||||
ResetBgsAndClearDma3BusyFlags(0);
|
||||
InitBgsFromTemplates(0, gUnknown_082F32C8, ARRAY_COUNT(gUnknown_082F32C8));
|
||||
SetBgTilemapBuffer(1, var0->unk1C0);
|
||||
SetBgTilemapBuffer(2, var0->unk21C0);
|
||||
SetBgTilemapBuffer(3, var0->unk31C0);
|
||||
SetBgTilemapBuffer(1, game->unk1C0);
|
||||
SetBgTilemapBuffer(2, game->unk21C0);
|
||||
SetBgTilemapBuffer(3, game->unk31C0);
|
||||
ChangeBgX(0, 0, 0);
|
||||
ChangeBgY(0, 0, 0);
|
||||
ChangeBgX(2, 0, 0);
|
||||
@ -1077,8 +1077,8 @@ int sub_802104C(void)
|
||||
|
||||
InitStandardTextBoxWindows();
|
||||
InitTextBoxGfxAndPrinters();
|
||||
sub_8022588(var0);
|
||||
sub_8022600(var0);
|
||||
sub_8022588(game);
|
||||
sub_8022600(game);
|
||||
gPaletteFade.bufferTransferDisabled = TRUE;
|
||||
break;
|
||||
case 7:
|
||||
@ -1086,7 +1086,7 @@ int sub_802104C(void)
|
||||
CopyToBgTilemapBuffer(1, gBerryCrushGrinderTopTilemap, 0, 0);
|
||||
CopyToBgTilemapBuffer(2, gBerryCrushContainerCapTilemap, 0, 0);
|
||||
CopyToBgTilemapBuffer(3, gBerryCrushBackgroundTilemap, 0, 0);
|
||||
sub_80226D0(var0);
|
||||
sub_80226D0(game);
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
CopyBgTilemapBufferToVram(2);
|
||||
CopyBgTilemapBufferToVram(3);
|
||||
@ -1094,7 +1094,7 @@ int sub_802104C(void)
|
||||
case 8:
|
||||
LoadWirelessStatusIndicatorSpriteGfx();
|
||||
CreateWirelessStatusIndicatorSprite(0, 0);
|
||||
sub_8022730(var0);
|
||||
sub_8022730(game);
|
||||
SetGpuReg(REG_OFFSET_BG1VOFS, -gSpriteCoordOffsetY);
|
||||
ChangeBgX(1, 0, 0);
|
||||
ChangeBgY(1, 0, 0);
|
||||
@ -1107,18 +1107,18 @@ int sub_802104C(void)
|
||||
ShowBg(2);
|
||||
ShowBg(3);
|
||||
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
|
||||
sub_8020E3C();
|
||||
var0->unkC = 0;
|
||||
BerryCrush_SetVBlankCB();
|
||||
game->unkC = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
var0->unkC++;
|
||||
game->unkC++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int sub_802130C(void)
|
||||
{
|
||||
struct BerryCrushGame *var0 = sub_8020C00();
|
||||
struct BerryCrushGame *var0 = GetBerryCrushGame();
|
||||
if (!var0)
|
||||
return -1;
|
||||
|
||||
@ -1768,22 +1768,15 @@ void sub_8022600(struct BerryCrushGame *r6)
|
||||
void sub_80226D0(struct BerryCrushGame *r6)
|
||||
{
|
||||
u8 r5 = 0;
|
||||
const u32 *r0 = gUnknown_08DE3FD4;
|
||||
#ifndef NONMATCHING // r4, r5, r6 register roulette
|
||||
register u8 *r4 asm("r4") = gDecompressionBuffer;
|
||||
register u32 r0_ asm("r0");
|
||||
#else
|
||||
u8 *r4 = gDecompressionBuffer;
|
||||
u32 r0_;
|
||||
#endif
|
||||
u8 * r4;
|
||||
|
||||
LZ77UnCompWram(r0, r4);
|
||||
for (; r5 < r6->unk9; ++r5)
|
||||
LZ77UnCompWram(gUnknown_08DE3FD4, gDecompressionBuffer); // required for matching
|
||||
|
||||
for (r4 = gDecompressionBuffer; r5 < r6->unk9; ++r5)
|
||||
{
|
||||
r0_ = r6->unk138.unkC[r5]->unk0;
|
||||
CopyToBgTilemapBufferRect(
|
||||
3,
|
||||
&r4[r0_ * 40],
|
||||
&r4[r6->unk138.unkC[r5]->unk0 * 40],
|
||||
r6->unk138.unkC[r5]->unk1,
|
||||
r6->unk138.unkC[r5]->unk2,
|
||||
10,
|
||||
@ -1956,7 +1949,7 @@ void sub_8022B28(struct Sprite *sprite)
|
||||
|
||||
void sub_8022BEC(u16 r5, u8 r4, u8 *r7)
|
||||
{
|
||||
struct BerryCrushGame *r6 = sub_8020C00();
|
||||
struct BerryCrushGame *r6 = GetBerryCrushGame();
|
||||
|
||||
if (r5 > 25)
|
||||
r5 = 0;
|
||||
@ -2093,7 +2086,7 @@ static u32 sub_8022D14(struct BerryCrushGame *r7, u8 *r5)
|
||||
|
||||
static u32 sub_8022E1C(struct BerryCrushGame *r4, __attribute__((unused)) u8 *r1)
|
||||
{
|
||||
if (sub_802104C() != 0)
|
||||
if (InitBerryCrushDisplay() != 0)
|
||||
sub_8022BEC(r4->unkE, 0, r4->unk36);
|
||||
return 0;
|
||||
}
|
||||
@ -2151,7 +2144,7 @@ static u32 sub_8022EAC(struct BerryCrushGame *r4, u8 *r5)
|
||||
static u32 sub_8022F04(struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1)
|
||||
{
|
||||
r0->unk4 = NULL;
|
||||
SetMainCallback2(sub_8020E1C);
|
||||
SetMainCallback2(BerryCrush_SetupMainTask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2937,7 +2930,7 @@ static u32 sub_8023CAC(struct BerryCrushGame *r7, __attribute__((unused)) u8 *r1
|
||||
r7->unk10 = 0;
|
||||
break;
|
||||
case 7:
|
||||
sub_8020E58();
|
||||
BerryCrush_SaveResults();
|
||||
sub_8022BEC(18, 1, NULL);
|
||||
r7->unk12 = 11;
|
||||
r7->unkC = 0;
|
||||
@ -3205,7 +3198,7 @@ static u32 sub_8024508(struct BerryCrushGame *r5, __attribute__((unused)) u8 *r1
|
||||
|
||||
static u32 sub_8024568(__attribute__((unused)) struct BerryCrushGame *r0, __attribute__((unused)) u8 *r1)
|
||||
{
|
||||
sub_8020C0C(NULL);
|
||||
QuitBerryCrush(NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -3118,9 +3118,9 @@ static u8 CreateContestantSprite(u16 species, u32 otId, u32 personality, u32 ind
|
||||
species = SanitizeSpecies(species);
|
||||
|
||||
if (index == gContestPlayerMonIndex)
|
||||
HandleLoadSpecialPokePic_2(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites[0], species, personality);
|
||||
HandleLoadSpecialPokePic_2(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites.ptr[0], species, personality);
|
||||
else
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites[0], species, personality);
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonBackPicTable[species], gMonSpritesGfxPtr->sprites.ptr[0], species, personality);
|
||||
|
||||
LoadCompressedPalette(GetMonSpritePalFromSpeciesAndPersonality(species, otId, personality), 0x120, 0x20);
|
||||
SetMultiuseSpriteTemplateToPokemon(species, 0);
|
||||
|
@ -368,19 +368,19 @@ static void InitContestMonPixels(u16 species, u8 whichSprite)
|
||||
{
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(
|
||||
&gMonFrontPicTable[species],
|
||||
gMonSpritesGfxPtr->sprites[1],
|
||||
gMonSpritesGfxPtr->sprites.ptr[1],
|
||||
species,
|
||||
gContestPaintingWinner->personality);
|
||||
_InitContestMonPixels(gMonSpritesGfxPtr->sprites[1], gContestPaintingMonPalette, (void *)gContestMonPixels);
|
||||
_InitContestMonPixels(gMonSpritesGfxPtr->sprites.ptr[1], gContestPaintingMonPalette, (void *)gContestMonPixels);
|
||||
}
|
||||
else
|
||||
{
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(
|
||||
&gMonBackPicTable[species],
|
||||
gMonSpritesGfxPtr->sprites[0],
|
||||
gMonSpritesGfxPtr->sprites.ptr[0],
|
||||
species,
|
||||
gContestPaintingWinner->personality);
|
||||
_InitContestMonPixels(gMonSpritesGfxPtr->sprites[0], gContestPaintingMonPalette, (void *)gContestMonPixels);
|
||||
_InitContestMonPixels(gMonSpritesGfxPtr->sprites.ptr[0], gContestPaintingMonPalette, (void *)gContestMonPixels);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -875,7 +875,7 @@ static void Task_ShowWinnerMonBanner(u8 taskId)
|
||||
{
|
||||
HandleLoadSpecialPokePic_2(
|
||||
&gMonFrontPicTable[species],
|
||||
gMonSpritesGfxPtr->sprites[1],
|
||||
gMonSpritesGfxPtr->sprites.ptr[1],
|
||||
species,
|
||||
personality);
|
||||
}
|
||||
@ -883,7 +883,7 @@ static void Task_ShowWinnerMonBanner(u8 taskId)
|
||||
{
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(
|
||||
&gMonFrontPicTable[species],
|
||||
gMonSpritesGfxPtr->sprites[1],
|
||||
gMonSpritesGfxPtr->sprites.ptr[1],
|
||||
species,
|
||||
personality);
|
||||
}
|
||||
@ -2547,9 +2547,9 @@ void ShowContestEntryMonPic(void)
|
||||
gTasks[taskId].data[0] = 0;
|
||||
gTasks[taskId].data[1] = species;
|
||||
if (gSpecialVar_0x8006 == gContestPlayerMonIndex)
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality);
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[1], species, personality);
|
||||
else
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality);
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[1], species, personality);
|
||||
|
||||
palette = GetMonSpritePalStructFromOtIdPersonality(species, otId, personality);
|
||||
LoadCompressedSpritePalette(palette);
|
||||
|
@ -625,10 +625,7 @@ static u8 GetEggMoves(struct Pokemon *pokemon, u16 *eggMoves)
|
||||
for (i = 0; i < EGG_MOVES_ARRAY_COUNT; i++)
|
||||
{
|
||||
if (gEggMoves[eggMoveIdx + i] > EGG_MOVES_SPECIES_OFFSET)
|
||||
{
|
||||
// TODO: the curly braces around this if statement are required for a matching build.
|
||||
break;
|
||||
}
|
||||
|
||||
eggMoves[i] = gEggMoves[eggMoveIdx + i];
|
||||
numEggMoves++;
|
||||
|
@ -434,7 +434,7 @@ static u8 EggHatchCreateMonSprite(u8 a0, u8 switchID, u8 pokeID, u16* speciesLoc
|
||||
u16 species = GetMonData(mon, MON_DATA_SPECIES);
|
||||
u32 pid = GetMonData(mon, MON_DATA_PERSONALITY);
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species],
|
||||
gMonSpritesGfxPtr->sprites[(a0 * 2) + 1],
|
||||
gMonSpritesGfxPtr->sprites.ptr [(a0 * 2) + 1],
|
||||
species, pid);
|
||||
LoadCompressedSpritePalette(GetMonSpritePalStruct(mon));
|
||||
*speciesLoc = species;
|
||||
|
@ -1233,8 +1233,8 @@ static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template,
|
||||
objectEvent->previousCoords.y = y;
|
||||
objectEvent->currentElevation = template->elevation;
|
||||
objectEvent->previousElevation = template->elevation;
|
||||
objectEvent->range.as_nybbles.x = template->movementRangeX;
|
||||
objectEvent->range.as_nybbles.y = template->movementRangeY;
|
||||
objectEvent->rangeX = template->movementRangeX;
|
||||
objectEvent->rangeY = template->movementRangeY;
|
||||
objectEvent->trainerType = template->trainerType;
|
||||
objectEvent->mapNum = mapNum;
|
||||
objectEvent->trainerRange_berryTreeId = template->trainerRange_berryTreeId;
|
||||
@ -1243,13 +1243,13 @@ static u8 InitObjectEventStateFromTemplate(struct ObjectEventTemplate *template,
|
||||
SetObjectEventDynamicGraphicsId(objectEvent);
|
||||
if (gRangedMovementTypes[objectEvent->movementType])
|
||||
{
|
||||
if (objectEvent->range.as_nybbles.x == 0)
|
||||
if (objectEvent->rangeX == 0)
|
||||
{
|
||||
objectEvent->range.as_nybbles.x++;
|
||||
objectEvent->rangeX++;
|
||||
}
|
||||
if (objectEvent->range.as_nybbles.y == 0)
|
||||
if (objectEvent->rangeY == 0)
|
||||
{
|
||||
objectEvent->range.as_nybbles.y++;
|
||||
objectEvent->rangeY++;
|
||||
}
|
||||
}
|
||||
return objectEventId;
|
||||
@ -1296,22 +1296,19 @@ static bool8 GetAvailableObjectEventId(u16 localId, u8 mapNum, u8 mapGroup, u8 *
|
||||
{
|
||||
u8 i = 0;
|
||||
|
||||
for (i = 0; i < OBJECT_EVENTS_COUNT; i++)
|
||||
for (i = 0; i < OBJECT_EVENTS_COUNT && gObjectEvents[i].active; i++)
|
||||
{
|
||||
if (!gObjectEvents[i].active)
|
||||
break;
|
||||
if (gObjectEvents[i].localId == localId && gObjectEvents[i].mapNum == mapNum && gObjectEvents[i].mapGroup == mapGroup)
|
||||
return TRUE;
|
||||
}
|
||||
if (i >= OBJECT_EVENTS_COUNT)
|
||||
return TRUE;
|
||||
*objectEventId = i;
|
||||
do
|
||||
for (; i < OBJECT_EVENTS_COUNT; i++)
|
||||
{
|
||||
if (gObjectEvents[i].active && gObjectEvents[i].localId == localId && gObjectEvents[i].mapNum == mapNum && gObjectEvents[i].mapGroup == mapGroup)
|
||||
return TRUE;
|
||||
i++;
|
||||
} while (i < OBJECT_EVENTS_COUNT);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -4759,19 +4756,19 @@ static bool8 IsCoordOutsideObjectEventMovementRange(struct ObjectEvent *objectEv
|
||||
s16 top;
|
||||
s16 bottom;
|
||||
|
||||
if (objectEvent->range.as_nybbles.x != 0)
|
||||
if (objectEvent->rangeX != 0)
|
||||
{
|
||||
left = objectEvent->initialCoords.x - objectEvent->range.as_nybbles.x;
|
||||
right = objectEvent->initialCoords.x + objectEvent->range.as_nybbles.x;
|
||||
left = objectEvent->initialCoords.x - objectEvent->rangeX;
|
||||
right = objectEvent->initialCoords.x + objectEvent->rangeX;
|
||||
if (left > x || right < x)
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (objectEvent->range.as_nybbles.y != 0)
|
||||
if (objectEvent->rangeY != 0)
|
||||
{
|
||||
top = objectEvent->initialCoords.y - objectEvent->range.as_nybbles.y;
|
||||
bottom = objectEvent->initialCoords.y + objectEvent->range.as_nybbles.y;
|
||||
top = objectEvent->initialCoords.y - objectEvent->rangeY;
|
||||
bottom = objectEvent->initialCoords.y + objectEvent->rangeY;
|
||||
if (top > y || bottom < y)
|
||||
{
|
||||
return TRUE;
|
||||
|
@ -255,7 +255,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo,
|
||||
trainerId = GetMonData(mon, MON_DATA_OT_ID);
|
||||
personality = GetMonData(mon, MON_DATA_PERSONALITY);
|
||||
DecompressPicFromTable_2(&gMonFrontPicTable[currSpecies],
|
||||
gMonSpritesGfxPtr->sprites[1],
|
||||
gMonSpritesGfxPtr->sprites.ptr[1],
|
||||
currSpecies);
|
||||
pokePal = GetMonSpritePalStructFromOtIdPersonality(currSpecies, trainerId, personality);
|
||||
LoadCompressedPalette(pokePal->data, 0x110, 0x20);
|
||||
@ -270,7 +270,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo,
|
||||
|
||||
// postEvo sprite
|
||||
DecompressPicFromTable_2(&gMonFrontPicTable[speciesToEvolve],
|
||||
gMonSpritesGfxPtr->sprites[3],
|
||||
gMonSpritesGfxPtr->sprites.ptr[3],
|
||||
speciesToEvolve);
|
||||
pokePal = GetMonSpritePalStructFromOtIdPersonality(speciesToEvolve, trainerId, personality);
|
||||
LoadCompressedPalette(pokePal->data, 0x120, 0x20);
|
||||
@ -347,7 +347,7 @@ static void CB2_EvolutionSceneLoadGraphics(void)
|
||||
gReservedSpritePaletteCount = 4;
|
||||
|
||||
DecompressPicFromTable_2(&gMonFrontPicTable[postEvoSpecies],
|
||||
gMonSpritesGfxPtr->sprites[3],
|
||||
gMonSpritesGfxPtr->sprites.ptr[3],
|
||||
postEvoSpecies);
|
||||
pokePal = GetMonSpritePalStructFromOtIdPersonality(postEvoSpecies, trainerId, personality);
|
||||
|
||||
@ -419,7 +419,7 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void)
|
||||
u32 trainerId = GetMonData(Mon, MON_DATA_OT_ID);
|
||||
u32 personality = GetMonData(Mon, MON_DATA_PERSONALITY);
|
||||
DecompressPicFromTable_2(&gMonFrontPicTable[postEvoSpecies],
|
||||
gMonSpritesGfxPtr->sprites[3],
|
||||
gMonSpritesGfxPtr->sprites.ptr[3],
|
||||
postEvoSpecies);
|
||||
pokePal = GetMonSpritePalStructFromOtIdPersonality(postEvoSpecies, trainerId, personality);
|
||||
LoadCompressedPalette(pokePal->data, 0x120, 0x20);
|
||||
@ -483,7 +483,7 @@ void TradeEvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, u8 preEvoSpri
|
||||
sEvoStructPtr->preEvoSpriteID = preEvoSpriteID;
|
||||
|
||||
DecompressPicFromTable_2(&gMonFrontPicTable[speciesToEvolve],
|
||||
gMonSpritesGfxPtr->sprites[1],
|
||||
gMonSpritesGfxPtr->sprites.ptr[1],
|
||||
speciesToEvolve);
|
||||
|
||||
pokePal = GetMonSpritePalStructFromOtIdPersonality(speciesToEvolve, trainerId, personality);
|
||||
|
@ -342,10 +342,6 @@ void PlayerStep(u8 direction, u16 newKeys, u16 heldKeys)
|
||||
|
||||
static bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent *playerObjEvent, u8 direction)
|
||||
{
|
||||
u8 r5 = direction;
|
||||
u8 r6 = direction;
|
||||
r6++; r6--;
|
||||
|
||||
if (ObjectEventIsMovementOverridden(playerObjEvent)
|
||||
&& !ObjectEventClearHeldMovementIfFinished(playerObjEvent))
|
||||
{
|
||||
@ -357,13 +353,13 @@ static bool8 TryInterruptObjectEventSpecialAnim(struct ObjectEvent *playerObjEve
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
if (playerObjEvent->movementDirection != r5)
|
||||
if (playerObjEvent->movementDirection != direction)
|
||||
{
|
||||
ObjectEventClearHeldMovement(playerObjEvent);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (!sub_808B028(r6))
|
||||
if (!sub_808B028(direction))
|
||||
{
|
||||
ObjectEventClearHeldMovement(playerObjEvent);
|
||||
return FALSE;
|
||||
@ -2085,7 +2081,7 @@ static void sub_808D094(u8 taskId)
|
||||
sub_808D074(object->facingDirection);
|
||||
data[1] = 0;
|
||||
data[2] = 1;
|
||||
data[3] = (u16)(sprite->pos1.y + sprite->pos2.y) * 16;
|
||||
data[3] = (u16)(sprite->pos1.y + sprite->pos2.y) << 4;
|
||||
sprite->pos2.y = 0;
|
||||
CameraObjectReset2();
|
||||
object->fixedPriority = TRUE;
|
||||
|
@ -227,17 +227,15 @@ bool8 SetUpFieldMove_Cut(void)
|
||||
y = gPlayerFacingPosition.y + sHyperCutStruct[i].y;
|
||||
tileCuttable = TRUE;
|
||||
|
||||
j = 0;
|
||||
do
|
||||
for (j = 0; j < 2; ++j)
|
||||
{
|
||||
if (sHyperCutStruct[i].unk2[j] == 0)
|
||||
break;
|
||||
if (sHyperCutStruct[i].unk2[j] == 0) break; // one line required to match -g
|
||||
if (cutTiles[(u8)(sHyperCutStruct[i].unk2[j] - 1)] == FALSE)
|
||||
{
|
||||
tileCuttable = FALSE;
|
||||
break;
|
||||
}
|
||||
} while (++j <= 1);
|
||||
}
|
||||
|
||||
if (tileCuttable == TRUE)
|
||||
{
|
||||
|
@ -880,89 +880,82 @@ s32 GetBoxOrPartyMonData(u16 boxId, u16 monId, s32 request, u8 *dst)
|
||||
// Gets the name/gender/level string for the condition menu
|
||||
static u8 *GetConditionMenuMonString(u8 *dst, u16 boxId, u16 monId)
|
||||
{
|
||||
u16 species, level, gender;
|
||||
u16 box, mon, species, level, gender;
|
||||
struct BoxPokemon *boxMon;
|
||||
u8 *str;
|
||||
|
||||
box = boxId;
|
||||
mon = monId;
|
||||
*(dst++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(dst++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
|
||||
*(dst++) = TEXT_COLOR_BLUE;
|
||||
*(dst++) = TEXT_COLOR_TRANSPARENT;
|
||||
*(dst++) = TEXT_COLOR_LIGHT_BLUE;
|
||||
if (GetBoxOrPartyMonData(boxId, monId, MON_DATA_IS_EGG, NULL))
|
||||
{
|
||||
if (GetBoxOrPartyMonData(box, mon, MON_DATA_IS_EGG, NULL))
|
||||
return StringCopyPadded(dst, gText_EggNickname, 0, 12);
|
||||
GetBoxOrPartyMonData(box, mon, MON_DATA_NICKNAME, dst);
|
||||
StringGetEnd10(dst);
|
||||
species = GetBoxOrPartyMonData(box, mon, MON_DATA_SPECIES, NULL);
|
||||
if (box == TOTAL_BOXES_COUNT) // Party mon.
|
||||
{
|
||||
level = GetMonData(&gPlayerParty[mon], MON_DATA_LEVEL);
|
||||
gender = GetMonGender(&gPlayerParty[mon]);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetBoxOrPartyMonData(boxId, monId, MON_DATA_NICKNAME, dst);
|
||||
StringGetEnd10(dst);
|
||||
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES, NULL);
|
||||
if (boxId == TOTAL_BOXES_COUNT) // Party mon.
|
||||
{
|
||||
level = GetMonData(&gPlayerParty[monId], MON_DATA_LEVEL);
|
||||
gender = GetMonGender(&gPlayerParty[monId]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Needed to match, feel free to remove.
|
||||
boxId++;boxId--;
|
||||
monId++;monId--;
|
||||
|
||||
boxMon = GetBoxedMonPtr(boxId, monId);
|
||||
gender = GetBoxMonGender(boxMon);
|
||||
level = GetLevelFromBoxMonExp(boxMon);
|
||||
}
|
||||
|
||||
if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(dst, gSpeciesNames[species]))
|
||||
gender = MON_GENDERLESS;
|
||||
|
||||
for (str = dst; *str != EOS; str++)
|
||||
;
|
||||
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_SKIP;
|
||||
*(str++) = 60;
|
||||
|
||||
switch (gender)
|
||||
{
|
||||
default:
|
||||
*(str++) = CHAR_SPACE;
|
||||
break;
|
||||
case MON_MALE:
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_COLOR;
|
||||
*(str++) = TEXT_COLOR_RED;
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_SHADOW;
|
||||
*(str++) = TEXT_COLOR_LIGHT_RED;
|
||||
*(str++) = CHAR_MALE;
|
||||
break;
|
||||
case MON_FEMALE:
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_COLOR;
|
||||
*(str++) = TEXT_COLOR_GREEN;
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_SHADOW;
|
||||
*(str++) = TEXT_COLOR_LIGHT_GREEN;
|
||||
*(str++) = CHAR_FEMALE;
|
||||
break;
|
||||
}
|
||||
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
|
||||
*(str++) = TEXT_COLOR_BLUE;
|
||||
*(str++) = TEXT_COLOR_TRANSPARENT;
|
||||
*(str++) = TEXT_COLOR_LIGHT_BLUE;
|
||||
*(str++) = CHAR_SLASH;
|
||||
*(str++) = CHAR_EXTRA_SYMBOL;
|
||||
*(str++) = CHAR_LV_2;
|
||||
str = ConvertIntToDecimalStringN(str, level, STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||
*(str++) = CHAR_SPACE;
|
||||
*str = EOS;
|
||||
|
||||
return str;
|
||||
boxMon = GetBoxedMonPtr(box, mon);
|
||||
gender = GetBoxMonGender(boxMon);
|
||||
level = GetLevelFromBoxMonExp(boxMon);
|
||||
}
|
||||
|
||||
if ((species == SPECIES_NIDORAN_F || species == SPECIES_NIDORAN_M) && !StringCompare(dst, gSpeciesNames[species]))
|
||||
gender = MON_GENDERLESS;
|
||||
|
||||
for (str = dst; *str != EOS; str++)
|
||||
;
|
||||
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_SKIP;
|
||||
*(str++) = 60;
|
||||
|
||||
switch (gender)
|
||||
{
|
||||
default:
|
||||
*(str++) = CHAR_SPACE;
|
||||
break;
|
||||
case MON_MALE:
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_COLOR;
|
||||
*(str++) = TEXT_COLOR_RED;
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_SHADOW;
|
||||
*(str++) = TEXT_COLOR_LIGHT_RED;
|
||||
*(str++) = CHAR_MALE;
|
||||
break;
|
||||
case MON_FEMALE:
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_COLOR;
|
||||
*(str++) = TEXT_COLOR_GREEN;
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_SHADOW;
|
||||
*(str++) = TEXT_COLOR_LIGHT_GREEN;
|
||||
*(str++) = CHAR_FEMALE;
|
||||
break;
|
||||
}
|
||||
|
||||
*(str++) = EXT_CTRL_CODE_BEGIN;
|
||||
*(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
|
||||
*(str++) = TEXT_COLOR_BLUE;
|
||||
*(str++) = TEXT_COLOR_TRANSPARENT;
|
||||
*(str++) = TEXT_COLOR_LIGHT_BLUE;
|
||||
*(str++) = CHAR_SLASH;
|
||||
*(str++) = CHAR_EXTRA_SYMBOL;
|
||||
*(str++) = CHAR_LV_2;
|
||||
str = ConvertIntToDecimalStringN(str, level, STR_CONV_MODE_LEFT_ALIGN, 3);
|
||||
*(str++) = CHAR_SPACE;
|
||||
*str = EOS;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
// Buffers the string in src to dest up to n chars. If src is less than n chars, fill with spaces
|
||||
@ -983,6 +976,8 @@ static u8 *BufferConditionMenuSpacedStringN(u8 *dst, const u8 *src, s16 n)
|
||||
void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId, u16 monId, u16 partyId, u16 numMons, bool8 excludesCancel)
|
||||
{
|
||||
u16 i;
|
||||
u16 box = boxId;
|
||||
u16 mon = monId;
|
||||
|
||||
// In this and the below 2 functions, numMons is passed as the number of menu selections (which includes Cancel)
|
||||
// To indicate that the Cancel needs to be subtracted they pass an additional bool
|
||||
@ -992,21 +987,16 @@ void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId
|
||||
|
||||
if (partyId != numMons)
|
||||
{
|
||||
GetConditionMenuMonString(nameDst, boxId, monId);
|
||||
GetConditionMenuMonString(nameDst, box, mon);
|
||||
locationDst[0] = EXT_CTRL_CODE_BEGIN;
|
||||
locationDst[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
|
||||
locationDst[2] = TEXT_COLOR_BLUE;
|
||||
locationDst[3] = TEXT_COLOR_TRANSPARENT;
|
||||
locationDst[4] = TEXT_COLOR_LIGHT_BLUE;
|
||||
if (boxId == TOTAL_BOXES_COUNT) // Party mon.
|
||||
{
|
||||
if (box == TOTAL_BOXES_COUNT) // Party mon.
|
||||
BufferConditionMenuSpacedStringN(&locationDst[5], gText_InParty, 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
boxId++;boxId--; // Again...Someone fix this maybe?
|
||||
BufferConditionMenuSpacedStringN(&locationDst[5], GetBoxNamePtr(boxId), 8);
|
||||
}
|
||||
BufferConditionMenuSpacedStringN(&locationDst[5], GetBoxNamePtr(box), 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2908,7 +2908,14 @@ static void ZeroObjectEvent(struct ObjectEvent *objEvent)
|
||||
memset(objEvent, 0, sizeof(struct ObjectEvent));
|
||||
}
|
||||
|
||||
static void SpawnLinkPlayerObjectEvent(u8 linkPlayerId, s16 x, s16 y, u8 a4)
|
||||
// Note: Emerald reuses the direction and range variables during Link mode
|
||||
// as special gender and direction values. The types and placement
|
||||
// conflict with the usual Event Object struct, thus the definitions.
|
||||
#define linkGender(obj) obj->singleMovementActive
|
||||
// not even one can reference *byte* aligned bitfield members...
|
||||
#define linkDirection(obj) ((u8*)obj)[offsetof(typeof(*obj), fieldEffectSpriteId) - 1] // -> rangeX
|
||||
|
||||
static void SpawnLinkPlayerObjectEvent(u8 linkPlayerId, s16 x, s16 y, u8 gender)
|
||||
{
|
||||
u8 objEventId = GetFirstInactiveObjectEventId();
|
||||
struct LinkPlayerObjectEvent *linkPlayerObjEvent = &gLinkPlayerObjectEvents[linkPlayerId];
|
||||
@ -2923,8 +2930,8 @@ static void SpawnLinkPlayerObjectEvent(u8 linkPlayerId, s16 x, s16 y, u8 a4)
|
||||
linkPlayerObjEvent->movementMode = MOVEMENT_MODE_FREE;
|
||||
|
||||
objEvent->active = 1;
|
||||
objEvent->singleMovementActive = a4;
|
||||
objEvent->range.as_byte = 2;
|
||||
linkGender(objEvent) = gender;
|
||||
linkDirection(objEvent) = DIR_NORTH;
|
||||
objEvent->spriteId = 64;
|
||||
|
||||
InitLinkPlayerObjectEventPos(objEvent, x, y);
|
||||
@ -2941,13 +2948,13 @@ static void InitLinkPlayerObjectEventPos(struct ObjectEvent *objEvent, s16 x, s1
|
||||
ObjectEventUpdateZCoord(objEvent);
|
||||
}
|
||||
|
||||
static void sub_80877DC(u8 linkPlayerId, u8 a2)
|
||||
static void sub_80877DC(u8 linkPlayerId, u8 dir)
|
||||
{
|
||||
if (gLinkPlayerObjectEvents[linkPlayerId].active)
|
||||
{
|
||||
u8 objEventId = gLinkPlayerObjectEvents[linkPlayerId].objEventId;
|
||||
struct ObjectEvent *objEvent = &gObjectEvents[objEventId];
|
||||
objEvent->range.as_byte = a2;
|
||||
linkDirection(objEvent) = dir;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2982,7 +2989,7 @@ static u8 GetLinkPlayerFacingDirection(u8 linkPlayerId)
|
||||
{
|
||||
u8 objEventId = gLinkPlayerObjectEvents[linkPlayerId].objEventId;
|
||||
struct ObjectEvent *objEvent = &gObjectEvents[objEventId];
|
||||
return objEvent->range.as_byte;
|
||||
return linkDirection(objEvent);
|
||||
}
|
||||
|
||||
static u8 GetLinkPlayerElevation(u8 linkPlayerId)
|
||||
@ -3067,10 +3074,10 @@ static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayer
|
||||
{
|
||||
s16 x, y;
|
||||
|
||||
objEvent->range.as_byte = FlipVerticalAndClearForced(a3, objEvent->range.as_byte);
|
||||
ObjectEventMoveDestCoords(objEvent, objEvent->range.as_byte, &x, &y);
|
||||
linkDirection(objEvent) = FlipVerticalAndClearForced(a3, linkDirection(objEvent));
|
||||
ObjectEventMoveDestCoords(objEvent, linkDirection(objEvent), &x, &y);
|
||||
|
||||
if (LinkPlayerDetectCollision(linkPlayerObjEvent->objEventId, objEvent->range.as_byte, x, y))
|
||||
if (LinkPlayerDetectCollision(linkPlayerObjEvent->objEventId, linkDirection(objEvent), x, y))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@ -3085,7 +3092,7 @@ static bool8 FacingHandler_DpadMovement(struct LinkPlayerObjectEvent *linkPlayer
|
||||
|
||||
static bool8 FacingHandler_ForcedFacingChange(struct LinkPlayerObjectEvent *linkPlayerObjEvent, struct ObjectEvent *objEvent, u8 a3)
|
||||
{
|
||||
objEvent->range.as_byte = FlipVerticalAndClearForced(a3, objEvent->range.as_byte);
|
||||
linkDirection(objEvent) = FlipVerticalAndClearForced(a3, linkDirection(objEvent));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -3099,7 +3106,7 @@ static void MovementStatusHandler_TryAdvanceScript(struct LinkPlayerObjectEvent
|
||||
{
|
||||
objEvent->directionSequenceIndex--;
|
||||
linkPlayerObjEvent->movementMode = MOVEMENT_MODE_FROZEN;
|
||||
MoveCoords(objEvent->range.as_byte, &objEvent->initialCoords.x, &objEvent->initialCoords.y);
|
||||
MoveCoords(linkDirection(objEvent), &objEvent->initialCoords.x, &objEvent->initialCoords.y);
|
||||
if (!objEvent->directionSequenceIndex)
|
||||
{
|
||||
ShiftStillObjectEventCoords(objEvent);
|
||||
@ -3160,14 +3167,14 @@ static void CreateLinkPlayerSprite(u8 linkPlayerId, u8 gameVersion)
|
||||
{
|
||||
case VERSION_FIRE_RED:
|
||||
case VERSION_LEAF_GREEN:
|
||||
objEvent->spriteId = AddPseudoObjectEvent(GetFRLGAvatarGraphicsIdByGender(objEvent->singleMovementActive), SpriteCB_LinkPlayer, 0, 0, 0);
|
||||
objEvent->spriteId = AddPseudoObjectEvent(GetFRLGAvatarGraphicsIdByGender(linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0);
|
||||
break;
|
||||
case VERSION_RUBY:
|
||||
case VERSION_SAPPHIRE:
|
||||
objEvent->spriteId = AddPseudoObjectEvent(GetRSAvatarGraphicsIdByGender(objEvent->singleMovementActive), SpriteCB_LinkPlayer, 0, 0, 0);
|
||||
objEvent->spriteId = AddPseudoObjectEvent(GetRSAvatarGraphicsIdByGender(linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0);
|
||||
break;
|
||||
case VERSION_EMERALD:
|
||||
objEvent->spriteId = AddPseudoObjectEvent(GetRivalAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, objEvent->singleMovementActive), SpriteCB_LinkPlayer, 0, 0, 0);
|
||||
objEvent->spriteId = AddPseudoObjectEvent(GetRivalAvatarGraphicsIdByStateIdAndGender(PLAYER_AVATAR_STATE_NORMAL, linkGender(objEvent)), SpriteCB_LinkPlayer, 0, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3188,9 +3195,9 @@ static void SpriteCB_LinkPlayer(struct Sprite *sprite)
|
||||
sprite->oam.priority = ZCoordToPriority(objEvent->previousElevation);
|
||||
|
||||
if (linkPlayerObjEvent->movementMode == MOVEMENT_MODE_FREE)
|
||||
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(objEvent->range.as_byte));
|
||||
StartSpriteAnim(sprite, GetFaceDirectionAnimNum(linkDirection(objEvent)));
|
||||
else
|
||||
StartSpriteAnimIfDifferent(sprite, GetMoveDirectionAnimNum(objEvent->range.as_byte));
|
||||
StartSpriteAnimIfDifferent(sprite, GetMoveDirectionAnimNum(linkDirection(objEvent)));
|
||||
|
||||
UpdateObjectEventSpriteVisibility(sprite, 0);
|
||||
if (objEvent->triggerGroundEffectsOnMove)
|
||||
|
@ -1963,19 +1963,17 @@ static u8 CanMonLearnTMTutor(struct Pokemon *mon, u16 item, u8 tutor)
|
||||
|
||||
if (item >= ITEM_TM01_FOCUS_PUNCH)
|
||||
{
|
||||
if (CanMonLearnTMHM(mon, item - ITEM_TM01_FOCUS_PUNCH))
|
||||
move = ItemIdToBattleMoveId(item);
|
||||
else
|
||||
if (!CanMonLearnTMHM(mon, item - ITEM_TM01_FOCUS_PUNCH))
|
||||
return CANNOT_LEARN_MOVE;
|
||||
do {} while (0); // :morphon:
|
||||
}
|
||||
else if (CanLearnTutorMove(GetMonData(mon, MON_DATA_SPECIES), tutor) == FALSE)
|
||||
{
|
||||
return CANNOT_LEARN_MOVE;
|
||||
else
|
||||
move = ItemIdToBattleMoveId(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
move = GetTutorMove(tutor);
|
||||
if (!CanLearnTutorMove(GetMonData(mon, MON_DATA_SPECIES), tutor))
|
||||
return CANNOT_LEARN_MOVE;
|
||||
else
|
||||
move = GetTutorMove(tutor);
|
||||
}
|
||||
|
||||
if (MonKnowsMove(mon, move) == TRUE)
|
||||
|
@ -646,7 +646,7 @@ static bool8 LoadMonAndSceneGfx(struct Pokemon *mon)
|
||||
case 0:
|
||||
species = GetMonData(mon, MON_DATA_SPECIES2);
|
||||
personality = GetMonData(mon, MON_DATA_PERSONALITY);
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality);
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[1], species, personality);
|
||||
sPokeblockFeed->loadGfxState++;
|
||||
break;
|
||||
case 1:
|
||||
|
@ -5597,8 +5597,8 @@ u16 SpeciesToCryId(u16 species)
|
||||
void sub_806D544(u16 species, u32 personality, u8 *dest)
|
||||
{
|
||||
if (species == SPECIES_SPINDA
|
||||
&& dest != gMonSpritesGfxPtr->sprites[0]
|
||||
&& dest != gMonSpritesGfxPtr->sprites[2])
|
||||
&& dest != gMonSpritesGfxPtr->sprites.ptr[0]
|
||||
&& dest != gMonSpritesGfxPtr->sprites.ptr[2])
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < 4; i++)
|
||||
|
@ -3858,18 +3858,18 @@ static u8 LoadMonGfxAndSprite(struct Pokemon *mon, s16 *state)
|
||||
if (gMain.inBattle)
|
||||
{
|
||||
if (sub_80688F8(3, sMonSummaryScreen->curMonIndex))
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites[1], summary->species2, summary->pid);
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites.ptr[1], summary->species2, summary->pid);
|
||||
else
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites[1], summary->species2, summary->pid);
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites.ptr[1], summary->species2, summary->pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gMonSpritesGfxPtr != NULL)
|
||||
{
|
||||
if (sMonSummaryScreen->monList.mons == gPlayerParty || sMonSummaryScreen->mode == PSS_MODE_BOX || sMonSummaryScreen->unk40EF == TRUE)
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites[1], summary->species2, summary->pid);
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites.ptr[1], summary->species2, summary->pid);
|
||||
else
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites[1], summary->species2, summary->pid);
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[summary->species2], gMonSpritesGfxPtr->sprites.ptr[1], summary->species2, summary->pid);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1100,16 +1100,9 @@ const u8 *MatchCall_GetOverrideFlavorText(u32 idx, u32 offset)
|
||||
{
|
||||
if (sCheckPageOverrides[i].idx == idx)
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
if (i + 1 >= ARRAY_COUNT(sCheckPageOverrides))
|
||||
break;
|
||||
if (sCheckPageOverrides[i + 1].idx != idx)
|
||||
break;
|
||||
if (!FlagGet(sCheckPageOverrides[i + 1].flag))
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
for (; i + 1 < ARRAY_COUNT(sCheckPageOverrides) &&
|
||||
sCheckPageOverrides[i + 1].idx == idx &&
|
||||
FlagGet(sCheckPageOverrides[i + 1].flag); i++);
|
||||
return sCheckPageOverrides[i].flavorTexts[offset];
|
||||
}
|
||||
}
|
||||
|
@ -2724,9 +2724,9 @@ static void LoadTradeMonPic(u8 whichParty, u8 state)
|
||||
personality = GetMonData(mon, MON_DATA_PERSONALITY);
|
||||
|
||||
if (whichParty == TRADE_PLAYER)
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[1], species, personality);
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[1], species, personality);
|
||||
else
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites[whichParty * 2 + 1], species, personality);
|
||||
HandleLoadSpecialPokePic_DontHandleDeoxys(&gMonFrontPicTable[species], gMonSpritesGfxPtr->sprites.ptr[whichParty * 2 + 1], species, personality);
|
||||
|
||||
LoadCompressedSpritePalette(GetMonSpritePalStruct(mon));
|
||||
sTradeData->monSpecies[whichParty] = species;
|
||||
@ -3659,7 +3659,7 @@ static bool8 AnimateTradeSequenceCable(void)
|
||||
case 65:
|
||||
if (gSprites[sTradeData->unk_D3].callback == SpriteCallbackDummy)
|
||||
{
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]);
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites.ptr[3], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]);
|
||||
sTradeData->state++;
|
||||
}
|
||||
break;
|
||||
@ -4174,7 +4174,7 @@ static bool8 AnimateTradeSequenceWireless(void)
|
||||
case 65:
|
||||
if (gSprites[sTradeData->unk_D3].callback == SpriteCallbackDummy)
|
||||
{
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites[3], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]);
|
||||
HandleLoadSpecialPokePic_2(&gMonFrontPicTable[sTradeData->monSpecies[TRADE_PARTNER]], gMonSpritesGfxPtr->sprites.ptr[3], sTradeData->monSpecies[TRADE_PARTNER], sTradeData->monPersonalities[TRADE_PARTNER]);
|
||||
sTradeData->state++;
|
||||
}
|
||||
break;
|
||||
|
@ -377,15 +377,15 @@ static u8 CheckPathBetweenTrainerAndPlayer(struct ObjectEvent *trainerObj, u8 ap
|
||||
}
|
||||
|
||||
// preserve mapobj_unk_19 before clearing.
|
||||
unk19_temp = trainerObj->range.as_nybbles.x;
|
||||
unk19b_temp = trainerObj->range.as_nybbles.y;
|
||||
trainerObj->range.as_nybbles.x = 0;
|
||||
trainerObj->range.as_nybbles.y = 0;
|
||||
unk19_temp = trainerObj->rangeX;
|
||||
unk19b_temp = trainerObj->rangeY;
|
||||
trainerObj->rangeX = 0;
|
||||
trainerObj->rangeY = 0;
|
||||
|
||||
collision = GetCollisionAtCoords(trainerObj, x, y, direction);
|
||||
|
||||
trainerObj->range.as_nybbles.x = unk19_temp;
|
||||
trainerObj->range.as_nybbles.y = unk19b_temp;
|
||||
trainerObj->rangeX = unk19_temp;
|
||||
trainerObj->rangeY = unk19b_temp;
|
||||
if (collision == 4)
|
||||
return approachDistance;
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
#include "dma3.h"
|
||||
#include "pokeblock.h"
|
||||
#include "malloc.h"
|
||||
#include "decompress.h"
|
||||
@ -1240,8 +1241,7 @@ static void UpdateMonPic(u8 loadId)
|
||||
}
|
||||
else
|
||||
{
|
||||
do {} while(0); // Only needed to match, feel free to remove.
|
||||
DmaCopy16Defvars(3, sMenu->partySheets[loadId], sMenu->curMonTileStart, 0x800);
|
||||
Dma3CopyLarge16_(sMenu->partySheets[loadId], sMenu->curMonTileStart, 0x800);
|
||||
LoadPalette(sMenu->partyPalettes[loadId], sMenu->curMonPalette, 32);
|
||||
}
|
||||
}
|
||||
|
@ -173,14 +173,12 @@ static void sub_81D9C90(u8 *array, s32 arg1, s32 arg2)
|
||||
{
|
||||
var1 = (array[0] & 0x80) >> 7;
|
||||
|
||||
var1++; var1--; // needed to match
|
||||
|
||||
for (j = arg1 - 1; j >= 0; j--)
|
||||
{
|
||||
var2 = array[j] & 0x80;
|
||||
var2 = (array[j] & 0x80) >> 7;
|
||||
array[j] <<= 1;
|
||||
array[j] |= var1;
|
||||
var1 = var2 >> 7;
|
||||
var1 = var2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user