Merge branch 'master' into doc-overworld

This commit is contained in:
GriffinR
2020-07-23 10:31:52 -04:00
committed by GitHub
14 changed files with 1090 additions and 1155 deletions
+4 -3
View File
@@ -127,7 +127,8 @@ void SetReadFlash1(u16 *dest)
}
}
void ReadFlash_Core(u8 *src, u8 *dest, u32 size)
// Using volatile here to make sure the flash memory will ONLY be read as bytes, to prevent any compiler optimizations.
void ReadFlash_Core(vu8 *src, u8 *dest, u32 size)
{
while (size-- != 0)
{
@@ -142,7 +143,7 @@ void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size)
u16 readFlash_Core_Buffer[0x40];
u16 *funcSrc;
u16 *funcDest;
void (*readFlash_Core)(u8 *, u8 *, u32);
void (*readFlash_Core)(vu8 *, u8 *, u32);
REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8;
@@ -164,7 +165,7 @@ void ReadFlash(u16 sectorNum, u32 offset, u8 *dest, u32 size)
i--;
}
readFlash_Core = (void (*)(u8 *, u8 *, u32))((s32)readFlash_Core_Buffer + 1);
readFlash_Core = (void (*)(vu8 *, u8 *, u32))((s32)readFlash_Core_Buffer + 1);
src = FLASH_BASE + (sectorNum << gFlash->sector.shift) + offset;
+6 -79
View File
@@ -624,98 +624,24 @@ void AnimTask_RotateAuroraRingColors(u8 taskId)
gTasks[taskId].func = AnimTask_RotateAuroraRingColors_Step;
}
#ifdef NONMATCHING
static void AnimTask_RotateAuroraRingColors_Step(u8 taskId)
{
int i;
u16 palIndex;
u16 *palPtr1;
u16 *palPtr2;
u16 rgbBuffer;
if (++gTasks[taskId].data[10] == 3)
{
u16 tempPlt;
gTasks[taskId].data[10] = 0;
palIndex = gTasks[taskId].data[2] + 1;
palPtr1 = &gPlttBufferFaded[palIndex];
rgbBuffer = *palPtr1;
palPtr2 = &palPtr1[1];
for (i = 0; i < 7; i++)
palPtr1[i] = palPtr2[i];
gPlttBufferFaded[palIndex + 7] = rgbBuffer;
tempPlt = gPlttBufferFaded[palIndex];
for (i = 1; i < 8; i++)
gPlttBufferFaded[palIndex + i - 1] = gPlttBufferFaded[palIndex + i];
gPlttBufferFaded[palIndex + 7] = tempPlt;
}
if (++gTasks[taskId].data[11] == gTasks[taskId].data[0])
DestroyAnimVisualTask(taskId);
}
#else
NAKED
static void AnimTask_RotateAuroraRingColors_Step(u8 taskId)
{
asm_unified("push {r4-r7,lr}\n\
lsls r0, 24\n\
lsrs r4, r0, 24\n\
ldr r1, =gTasks\n\
lsls r0, r4, 2\n\
adds r0, r4\n\
lsls r0, 3\n\
adds r2, r0, r1\n\
ldrh r0, [r2, 0x1C]\n\
adds r0, 0x1\n\
strh r0, [r2, 0x1C]\n\
lsls r0, 16\n\
asrs r0, 16\n\
mov r12, r1\n\
cmp r0, 0x3\n\
bne _081075BE\n\
movs r0, 0\n\
strh r0, [r2, 0x1C]\n\
ldrh r0, [r2, 0xC]\n\
adds r0, 0x1\n\
lsls r0, 16\n\
lsrs r5, r0, 16\n\
ldr r1, =gPlttBufferFaded\n\
lsls r0, r5, 1\n\
adds r0, r1\n\
ldrh r6, [r0]\n\
adds r7, r1, 0\n\
adds r3, r0, 0x2\n\
movs r1, 0x6\n\
adds r2, r0, 0\n\
_081075A8:\n\
ldrh r0, [r3]\n\
strh r0, [r2]\n\
adds r3, 0x2\n\
adds r2, 0x2\n\
subs r1, 0x1\n\
cmp r1, 0\n\
bge _081075A8\n\
adds r0, r5, 0x7\n\
lsls r0, 1\n\
adds r0, r7\n\
strh r6, [r0]\n\
_081075BE:\n\
lsls r0, r4, 2\n\
adds r0, r4\n\
lsls r0, 3\n\
add r0, r12\n\
ldrh r1, [r0, 0x1E]\n\
adds r1, 0x1\n\
strh r1, [r0, 0x1E]\n\
lsls r1, 16\n\
asrs r1, 16\n\
movs r2, 0x8\n\
ldrsh r0, [r0, r2]\n\
cmp r1, r0\n\
bne _081075DE\n\
adds r0, r4, 0\n\
bl DestroyAnimVisualTask\n\
_081075DE:\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.pool\n");
}
#endif
// For animating undulating beam attacks (e.g. Flamethrower, Hydro Pump, Signal Beam)
static void AnimToTargetInSinWave(struct Sprite *sprite)
@@ -822,6 +748,7 @@ static void AnimHydroCannonBeam(struct Sprite *sprite)
if (GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_PLAYER_LEFT || GetBattlerPosition(gBattleAnimAttacker) == B_POSITION_OPPONENT_LEFT)
gBattleAnimArgs[0] *= -1;
}
if ((gBattleAnimArgs[5] & 0xFF00) == 0)
animType = TRUE;
else
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -8127,7 +8127,7 @@ static void DoFlaggedGroundEffects(struct ObjectEvent *objEvent, struct Sprite *
{
u8 i;
if (ObjectEventIsFarawayIslandMew(objEvent) == TRUE && !sub_81D4A58(objEvent))
if (ObjectEventIsFarawayIslandMew(objEvent) == TRUE && !ShouldMewShakeGrass(objEvent))
return;
for (i = 0; i < ARRAY_COUNT(sGroundEffectFuncs); i++, flags >>= 1)
+106 -85
View File
@@ -10,15 +10,15 @@
#include "constants/maps.h"
#include "constants/metatile_behaviors.h"
static u8 sub_81D4890(u8);
static bool8 sub_81D4C14(struct ObjectEvent*, u8);
static u8 sub_81D4C9C(struct ObjectEvent*, u8);
static u8 sub_81D4C58(struct ObjectEvent*, u8);
static u8 sub_81D4CE0(struct ObjectEvent*, u8);
static u8 sub_81D4D24(u8);
static bool8 CanMewWalkToCoords(s16, s16);
static u8 GetValidMewMoveDirection(u8);
static bool8 ShouldMewMoveNorth(struct ObjectEvent*, u8);
static bool8 ShouldMewMoveSouth(struct ObjectEvent*, u8);
static bool8 ShouldMewMoveEast(struct ObjectEvent*, u8);
static bool8 ShouldMewMoveWest(struct ObjectEvent*, u8);
static u8 GetRandomMewDirectionCandidate(u8);
static bool8 CanMewMoveToCoords(s16, s16);
static EWRAM_DATA u8 sUnknown_0203CF50 = 0;
static EWRAM_DATA u8 sGrassSpriteId = 0;
static s16 sPlayerToMewDeltaX;
static s16 sPlayerToMewDeltaY;
@@ -29,10 +29,10 @@ extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[];
static const s16 sFarawayIslandRockCoords[4][2] =
{
{21, 16},
{25, 16},
{16, 17},
{20, 20},
{14 + 7, 9 + 7},
{18 + 7, 9 + 7},
{ 9 + 7, 10 + 7},
{13 + 7, 13 + 7},
};
static u8 GetMewObjectEventId(void)
@@ -42,10 +42,12 @@ static u8 GetMewObjectEventId(void)
return objectEventId;
}
// When the player enters Faraway Island interior it begins a "hide and seek" minigame where Mew disappears into the grass
// This function returns the direction Mew will take a step, and is run every time the player takes a step
u32 GetMewMoveDirection(void)
{
u8 i;
int skip;
int mewSafeFromTrap;
struct ObjectEvent *mew = &gObjectEvents[GetMewObjectEventId()];
sPlayerToMewDeltaX = gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x - mew->currentCoords.x;
@@ -53,43 +55,47 @@ u32 GetMewMoveDirection(void)
for (i = 0; i < ARRAY_COUNT(sMewDirectionCandidates); i++)
sMewDirectionCandidates[i] = DIR_NONE;
// Player hasn't moved (just facing new direction), don't move
if (gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x == gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x
&& gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.y == gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y)
{
return DIR_NONE;
}
// Mew is invisible except for every 8th step
if (VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % 8 == 0)
mew->invisible = 0;
mew->invisible = FALSE;
else
mew->invisible = 1;
mew->invisible = TRUE;
// Mew will stay in place for 1 step after its visible
if (VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % 9 == 0)
return DIR_NONE;
// Below loop is for Mew to try to avoid getting trapped between the player and a rock
for (i = 0; i < ARRAY_COUNT(sFarawayIslandRockCoords); i++)
{
if (gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x == sFarawayIslandRockCoords[i][0])
{
skip = 0;
mewSafeFromTrap = FALSE;
if (gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.y < sFarawayIslandRockCoords[i][1])
{
if (mew->currentCoords.y <= sFarawayIslandRockCoords[i][1])
skip = 1;
mewSafeFromTrap = TRUE;
}
else
{
if (mew->currentCoords.y >= sFarawayIslandRockCoords[i][1])
skip = 1;
mewSafeFromTrap = TRUE;
}
if (!skip)
if (!mewSafeFromTrap)
{
if (sPlayerToMewDeltaX > 0)
{
if (mew->currentCoords.x + 1 == gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x)
{
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
if (CanMewMoveToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
return DIR_EAST;
}
}
@@ -97,7 +103,7 @@ u32 GetMewMoveDirection(void)
{
if (mew->currentCoords.x - 1 == gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x)
{
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
if (CanMewMoveToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
return DIR_WEST;
}
}
@@ -106,12 +112,12 @@ u32 GetMewMoveDirection(void)
{
if (sPlayerToMewDeltaY > 0)
{
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
return DIR_NORTH;
}
else
{
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
return DIR_SOUTH;
}
}
@@ -120,25 +126,25 @@ u32 GetMewMoveDirection(void)
if (gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.y == sFarawayIslandRockCoords[i][1])
{
skip = 0;
mewSafeFromTrap = FALSE;
if (gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.x < sFarawayIslandRockCoords[i][0])
{
if (mew->currentCoords.x <= sFarawayIslandRockCoords[i][0])
skip = 1;
mewSafeFromTrap = TRUE;
}
else
{
if (mew->currentCoords.x >= sFarawayIslandRockCoords[i][0])
skip = 1;
mewSafeFromTrap = TRUE;
}
if (!skip)
if (!mewSafeFromTrap)
{
if (sPlayerToMewDeltaY > 0)
{
if (mew->currentCoords.y + 1 == gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.y)
{
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
return DIR_SOUTH;
}
}
@@ -146,7 +152,7 @@ u32 GetMewMoveDirection(void)
{
if (mew->currentCoords.y - 1 == gObjectEvents[gPlayerAvatar.objectEventId].previousCoords.y)
{
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
return DIR_NORTH;
}
}
@@ -155,12 +161,12 @@ u32 GetMewMoveDirection(void)
{
if (sPlayerToMewDeltaX > 0)
{
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
if (CanMewMoveToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
return DIR_WEST;
}
else
{
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
if (CanMewMoveToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
return DIR_EAST;
}
}
@@ -168,92 +174,101 @@ u32 GetMewMoveDirection(void)
}
}
if (sub_81D4C14(mew, 0))
// Check if Mew can move in any direction without getting closer to the player
// If so load into sMewDirectionCandidates
// If Mew can move in two of the checked directions, choose one randomly
if (ShouldMewMoveNorth(mew, 0))
{
if (sub_81D4C58(mew, 1))
return sub_81D4D24(2);
else if (sub_81D4CE0(mew, 1))
return sub_81D4D24(2);
if (ShouldMewMoveEast(mew, 1))
return GetRandomMewDirectionCandidate(2);
else if (ShouldMewMoveWest(mew, 1))
return GetRandomMewDirectionCandidate(2);
else
return DIR_NORTH;
}
if (sub_81D4C9C(mew, 0))
if (ShouldMewMoveSouth(mew, 0))
{
if (sub_81D4C58(mew, 1))
return sub_81D4D24(2);
else if (sub_81D4CE0(mew, 1))
return sub_81D4D24(2);
if (ShouldMewMoveEast(mew, 1))
return GetRandomMewDirectionCandidate(2);
else if (ShouldMewMoveWest(mew, 1))
return GetRandomMewDirectionCandidate(2);
else
return DIR_SOUTH;
}
if (sub_81D4C58(mew, 0))
if (ShouldMewMoveEast(mew, 0))
{
if (sub_81D4C14(mew, 1))
return sub_81D4D24(2);
else if (sub_81D4C9C(mew, 1))
return sub_81D4D24(2);
if (ShouldMewMoveNorth(mew, 1))
return GetRandomMewDirectionCandidate(2);
else if (ShouldMewMoveSouth(mew, 1))
return GetRandomMewDirectionCandidate(2);
else
return DIR_EAST;
}
if (sub_81D4CE0(mew, 0))
if (ShouldMewMoveWest(mew, 0))
{
if (sub_81D4C14(mew, 1))
return sub_81D4D24(2);
else if (sub_81D4C9C(mew, 1))
return sub_81D4D24(2);
if (ShouldMewMoveNorth(mew, 1))
return GetRandomMewDirectionCandidate(2);
else if (ShouldMewMoveSouth(mew, 1))
return GetRandomMewDirectionCandidate(2);
else
return DIR_WEST;
}
// If this point is reached, Mew cannot move without getting closer to the player
// Avoid player on same Y, try move North/South
if (sPlayerToMewDeltaY == 0)
{
if (gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y > mew->currentCoords.y)
{
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
return DIR_NORTH;
}
if (gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y < mew->currentCoords.y)
{
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
return DIR_SOUTH;
}
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
return DIR_NORTH;
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
return DIR_SOUTH;
}
// Avoid player on same X, try move West/East
if (sPlayerToMewDeltaX == 0)
{
if (gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x > mew->currentCoords.x)
{
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
if (CanMewMoveToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
return DIR_WEST;
}
if (gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x < mew->currentCoords.x)
{
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
if (CanMewMoveToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
return DIR_EAST;
}
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
if (CanMewMoveToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
return DIR_EAST;
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
if (CanMewMoveToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
return DIR_WEST;
}
return sub_81D4890(DIR_NONE);
// Can't avoid player on axis, move any valid direction
return GetValidMewMoveDirection(DIR_NONE);
}
static bool8 CanMewWalkToCoords(s16 x, s16 y)
// Mew can move to any Tall/Long Grass metatile the player isn't currently on
static bool8 CanMewMoveToCoords(s16 x, s16 y)
{
if (gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.x == x
&& gObjectEvents[gPlayerAvatar.objectEventId].currentCoords.y == y)
@@ -264,7 +279,8 @@ static bool8 CanMewWalkToCoords(s16 x, s16 y)
return MetatileBehavior_IsPokeGrass(MapGridGetMetatileBehaviorAt(x, y));
}
static u8 sub_81D4890(u8 ignoredDir)
// Last ditch effort to move, clear move candidates and try all directions again
static u8 GetValidMewMoveDirection(u8 ignoredDir)
{
u8 i;
u8 count = 0;
@@ -273,25 +289,25 @@ static u8 sub_81D4890(u8 ignoredDir)
for (i = 0; i < ARRAY_COUNT(sMewDirectionCandidates); i++)
sMewDirectionCandidates[i] = DIR_NONE;
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1) == TRUE && ignoredDir != DIR_NORTH)
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y - 1) == TRUE && ignoredDir != DIR_NORTH)
{
sMewDirectionCandidates[count] = DIR_NORTH;
count++;
}
if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_EAST)
if (CanMewMoveToCoords(mew->currentCoords.x + 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_EAST)
{
sMewDirectionCandidates[count] = DIR_EAST;
count++;
}
if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1) == TRUE && ignoredDir != DIR_SOUTH)
if (CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y + 1) == TRUE && ignoredDir != DIR_SOUTH)
{
sMewDirectionCandidates[count] = DIR_SOUTH;
count++;
}
if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_WEST)
if (CanMewMoveToCoords(mew->currentCoords.x - 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_WEST)
{
sMewDirectionCandidates[count] = DIR_WEST;
count++;
@@ -341,7 +357,9 @@ bool8 IsMewPlayingHideAndSeek(void)
return FALSE;
}
bool8 sub_81D4A58(struct ObjectEvent *objectEvent)
// Every 4th step Mew will shake the grass it steps into
// Otherwise its movement leaves grass undisturbed
bool8 ShouldMewShakeGrass(struct ObjectEvent *objectEvent)
{
if (VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) != 0xFFFF
&& VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % 4 == 0)
@@ -350,22 +368,25 @@ bool8 sub_81D4A58(struct ObjectEvent *objectEvent)
return FALSE;
}
void sub_81D4A90(void)
void SetMewAboveGrass(void)
{
s16 x;
s16 y;
u8 spriteId;
struct ObjectEvent *mew = &gObjectEvents[GetMewObjectEventId()];
mew->invisible = 0;
mew->invisible = FALSE;
if (gSpecialVar_0x8004 == 1)
{
// For after battle where Mew should still be present (e.g. if ran from battle)
mew->fixedPriority = 1;
gSprites[mew->spriteId].subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
gSprites[mew->spriteId].subpriority = 1;
}
else
{
// Mew emerging from grass when found
// Also do field effect for grass shaking as it emerges
VarSet(VAR_FARAWAY_ISLAND_STEP_COUNTER, 0xFFFF);
mew->fixedPriority = 1;
gSprites[mew->spriteId].subspriteMode = SUBSPRITES_IGNORE_PRIORITY;
@@ -378,10 +399,10 @@ void sub_81D4A90(void)
x = mew->currentCoords.x;
y = mew->currentCoords.y;
SetSpritePosToOffsetMapCoords(&x, &y, 8, 8);
sUnknown_0203CF50 = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_LONG_GRASS], x, y, gSprites[mew->spriteId].subpriority - 1);
if (sUnknown_0203CF50 != MAX_SPRITES)
sGrassSpriteId = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[FLDEFFOBJ_LONG_GRASS], x, y, gSprites[mew->spriteId].subpriority - 1);
if (sGrassSpriteId != MAX_SPRITES)
{
struct Sprite *sprite = &gSprites[sUnknown_0203CF50];
struct Sprite *sprite = &gSprites[sGrassSpriteId];
sprite->coordOffsetEnabled = 1;
sprite->oam.priority = 2;
sprite->callback = SpriteCallbackDummy;
@@ -389,15 +410,15 @@ void sub_81D4A90(void)
}
}
void sub_81D4BEC(void)
void DestroyMewEmergingGrassSprite(void)
{
if (sUnknown_0203CF50 != MAX_SPRITES)
DestroySprite(&gSprites[sUnknown_0203CF50]);
if (sGrassSpriteId != MAX_SPRITES)
DestroySprite(&gSprites[sGrassSpriteId]);
}
static bool8 sub_81D4C14(struct ObjectEvent *mew, u8 index)
static bool8 ShouldMewMoveNorth(struct ObjectEvent *mew, u8 index)
{
if (sPlayerToMewDeltaY > 0 && CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
if (sPlayerToMewDeltaY > 0 && CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
{
sMewDirectionCandidates[index] = DIR_NORTH;
return TRUE;
@@ -406,9 +427,9 @@ static bool8 sub_81D4C14(struct ObjectEvent *mew, u8 index)
return FALSE;
}
static u8 sub_81D4C58(struct ObjectEvent *mew, u8 index)
static bool8 ShouldMewMoveEast(struct ObjectEvent *mew, u8 index)
{
if (sPlayerToMewDeltaX < 0 && CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
if (sPlayerToMewDeltaX < 0 && CanMewMoveToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
{
sMewDirectionCandidates[index] = DIR_EAST;
return TRUE;
@@ -417,9 +438,9 @@ static u8 sub_81D4C58(struct ObjectEvent *mew, u8 index)
return FALSE;
}
static u8 sub_81D4C9C(struct ObjectEvent *mew, u8 index)
static bool8 ShouldMewMoveSouth(struct ObjectEvent *mew, u8 index)
{
if (sPlayerToMewDeltaY < 0 && CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
if (sPlayerToMewDeltaY < 0 && CanMewMoveToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
{
sMewDirectionCandidates[index] = DIR_SOUTH;
return TRUE;
@@ -428,9 +449,9 @@ static u8 sub_81D4C9C(struct ObjectEvent *mew, u8 index)
return FALSE;
}
static u8 sub_81D4CE0(struct ObjectEvent *mew, u8 index)
static bool8 ShouldMewMoveWest(struct ObjectEvent *mew, u8 index)
{
if (sPlayerToMewDeltaX > 0 && CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
if (sPlayerToMewDeltaX > 0 && CanMewMoveToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
{
sMewDirectionCandidates[index] = DIR_WEST;
return TRUE;
@@ -439,7 +460,7 @@ static u8 sub_81D4CE0(struct ObjectEvent *mew, u8 index)
return FALSE;
}
static u8 sub_81D4D24(u8 mod)
static u8 GetRandomMewDirectionCandidate(u8 numDirections)
{
return sMewDirectionCandidates[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % mod];
return sMewDirectionCandidates[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % numDirections];
}
+4 -6
View File
@@ -77,11 +77,9 @@ static void DrawTextOption(void);
static void DrawOptionMenuTexts(void);
static void sub_80BB154(void);
// EWRAM vars
EWRAM_DATA static bool8 sArrowPressed = FALSE;
// const rom data
static const u16 sUnknown_0855C604[] = INCBIN_U16("graphics/misc/option_menu_text.gbapal");
static const u16 sOptionMenuText_Pal[] = INCBIN_U16("graphics/misc/option_menu_text.gbapal");
// note: this is only used in the Japanese release
static const u8 sEqualSignGfx[] = INCBIN_U8("graphics/misc/option_menu_equals_sign.4bpp");
@@ -141,7 +139,7 @@ static const struct BgTemplate sOptionMenuBgTemplates[] =
}
};
static const u16 sUnknown_0855C6A0[] = {0x7E51};
static const u16 sOptionMenuBg_Pal[] = {RGB(17, 18, 31)};
// code
static void MainCB2(void)
@@ -209,12 +207,12 @@ void CB2_InitOptionMenu(void)
gMain.state++;
break;
case 4:
LoadPalette(sUnknown_0855C6A0, 0, sizeof(sUnknown_0855C6A0));
LoadPalette(sOptionMenuBg_Pal, 0, sizeof(sOptionMenuBg_Pal));
LoadPalette(GetWindowFrameTilesPal(gSaveBlock2Ptr->optionsWindowFrameType)->pal, 0x70, 0x20);
gMain.state++;
break;
case 5:
LoadPalette(sUnknown_0855C604, 0x10, sizeof(sUnknown_0855C604));
LoadPalette(sOptionMenuText_Pal, 16, sizeof(sOptionMenuText_Pal));
gMain.state++;
break;
case 6:
+34 -34
View File
@@ -128,7 +128,7 @@ struct PokemonStorageSystemData
u16 field_B0[528 / 2];
u16 field_2C0;
u16 field_2C2;
u8 field_2C4;
u8 field_2C4; // Unused
u8 field_2C5;
u8 showPartyMenuState;
u8 unk_02C7;
@@ -136,21 +136,21 @@ struct PokemonStorageSystemData
bool8 unk_02C9;
s16 newCurrBoxId;
u16 bg2_X;
s16 field_2CE;
s16 wallpaperScrollSpeed;
u16 field_2D0;
u8 field_2D2;
u8 field_2D3;
u8 field_2D4;
u16 field_2D6;
s16 field_2D8;
u16 field_2DA;
u16 field_2DC;
u16 field_2DE;
u16 field_2E0;
u8 field_2D3; // Written to, but never read.
u8 field_2D4; // Written to, but never read.
u16 field_2D6; // Written to, but never read.
s16 field_2D8; // Written to, but never read.
u16 field_2DA; // Written to, but never read.
u16 field_2DC; // Written to, but never read.
u16 field_2DE; // Written to, but never read.
u16 field_2E0; // Written to, but never read.
u8 filler[22];
u8 field_2F8[1024];
u8 field_6F8;
u8 field_6F9;
u8 field_6F9; // Written to, but never read.
u8 field_6FA;
s8 field_6FB;
u16 field_6FC[16];
@@ -160,14 +160,14 @@ struct PokemonStorageSystemData
struct Sprite *field_728[2];
struct Sprite *field_730[2];
u32 field_738;
u8 field_73C[80];
u16 field_78C;
u8 field_73C[80]; // Unused
u16 field_78C; // Written to, but never read.
s16 wallpaperSetId;
s16 wallpaperId;
u16 field_792[360];
u8 wallpaperChangeState;
u8 field_A63;
u8 field_A64;
u8 boxScrollDestination;
s8 field_A65;
u8 *wallpaperTiles;
struct Sprite *movingMonSprite;
@@ -189,12 +189,12 @@ struct PokemonStorageSystemData
u8 field_C68;
s8 field_C69;
u8 field_C6A;
u8 field_C6B;
u8 field_C6B; // Written to, but never read.
struct WindowTemplate menuWindow;
struct StorageMenu menuItems[7];
u8 menuItemsCount;
u8 menuWidth;
u8 field_CAE;
u8 field_CAE; // Written to, but never read.
u16 field_CB0;
struct Sprite *field_CB4;
struct Sprite *field_CB8;
@@ -247,7 +247,7 @@ struct PokemonStorageSystemData
u16 field_2176[8];
u8 field_2186;
u8 field_2187;
u8 field_2188;
u8 pokemonSummaryScreenMode;
union
{
struct Pokemon *mon;
@@ -262,13 +262,13 @@ struct PokemonStorageSystemData
struct UnkStorageStruct field_2204[3];
u16 movingItem;
u16 field_2236;
u8 field_2238;
u8 field_2238; // Unused
u16 field_223A;
u16 *field_223C;
struct Sprite *cursorMonSprite;
u16 field_2244[0x40];
u8 field_22C4[0x800];
u8 field_2AC4[0x1800];
u8 field_2AC4[0x1800]; // Unused
u8 field_42C4[0x800];
u8 field_4AC4[0x1000];
u8 field_5AC4[0x800];
@@ -658,7 +658,7 @@ static void SetBoxSpeciesAndPersonalities(u8 boxId);
static void sub_80CB9D0(struct Sprite *sprite, u16 partyId);
static void sub_80CC370(u8 taskId);
static void sub_80CCB50(u8 boxId);
static s8 sub_80CC644(u8 boxId);
static s8 DetermineBoxScrollDirection(u8 boxId);
static void sub_80CCA3C(const void *tilemap, s8 direction, u8 arg2);
static s16 sub_80CD00C(const u8 *string);
static bool8 MonPlaceChange_Shift(void);
@@ -3879,7 +3879,7 @@ static void Cb_ChangeScreen(u8 taskId)
boxMons = sPSSData->field_218C.box;
monIndex = sPSSData->field_2187;
maxMonIndex = sPSSData->field_2186;
mode = sPSSData->field_2188;
mode = sPSSData->pokemonSummaryScreenMode;
FreePSSData();
if (mode == PSS_MODE_NORMAL && boxMons == &gUnknown_02039D14.box)
ShowPokemonSummaryScreenSet40EF(mode, boxMons, monIndex, maxMonIndex, Cb2_ReturnToPSS);
@@ -5276,9 +5276,9 @@ static void sub_80CC370(u8 taskId)
static void SetUpScrollToBox(u8 boxId)
{
s8 direction = sub_80CC644(boxId);
s8 direction = DetermineBoxScrollDirection(boxId);
sPSSData->field_2CE = (direction > 0) ? 6 : -6;
sPSSData->wallpaperScrollSpeed = (direction > 0) ? 6 : -6;
sPSSData->field_2D3 = (direction > 0) ? 1 : 2;
sPSSData->field_2D0 = 32;
sPSSData->field_2D4 = boxId;
@@ -5288,7 +5288,7 @@ static void SetUpScrollToBox(u8 boxId)
sPSSData->field_2DC = (direction <= 0) ? 5 : 0;
sPSSData->field_2DE = 0;
sPSSData->field_2E0 = 2;
sPSSData->field_A64 = boxId;
sPSSData->boxScrollDestination = boxId;
sPSSData->field_A65 = direction;
sPSSData->field_A63 = 0;
}
@@ -5300,21 +5300,21 @@ static bool8 ScrollToBox(void)
switch (sPSSData->field_A63)
{
case 0:
LoadWallpaperGfx(sPSSData->field_A64, sPSSData->field_A65);
LoadWallpaperGfx(sPSSData->boxScrollDestination, sPSSData->field_A65);
sPSSData->field_A63++;
case 1:
if (!WaitForWallpaperGfxLoad())
return TRUE;
sub_80CB4CC(sPSSData->field_A64, sPSSData->field_A65);
sub_80CCCFC(sPSSData->field_A64, sPSSData->field_A65);
sub_80CB4CC(sPSSData->boxScrollDestination, sPSSData->field_A65);
sub_80CCCFC(sPSSData->boxScrollDestination, sPSSData->field_A65);
sub_80CD0B8(sPSSData->field_A65);
break;
case 2:
var = sub_80CB584();
if (sPSSData->field_2D0 != 0)
{
sPSSData->bg2_X += sPSSData->field_2CE;
sPSSData->bg2_X += sPSSData->wallpaperScrollSpeed;
if (--sPSSData->field_2D0 != 0)
return TRUE;
sub_80CCEE0();
@@ -5327,7 +5327,7 @@ static bool8 ScrollToBox(void)
return TRUE;
}
static s8 sub_80CC644(u8 boxId)
static s8 DetermineBoxScrollDirection(u8 boxId)
{
u8 i;
u8 currentBox = StorageGetCurrentBox();
@@ -5735,7 +5735,7 @@ static void sub_80CD210(struct Sprite *sprite)
sprite->data[0] = 3;
break;
case 3:
sprite->pos1.x -= sPSSData->field_2CE;
sprite->pos1.x -= sPSSData->wallpaperScrollSpeed;
if (sprite->pos1.x < 73 || sprite->pos1.x > 247)
sprite->invisible = TRUE;
if (--sprite->data[1] == 0)
@@ -5746,7 +5746,7 @@ static void sub_80CD210(struct Sprite *sprite)
}
break;
case 4:
sprite->pos1.x -= sPSSData->field_2CE;
sprite->pos1.x -= sPSSData->wallpaperScrollSpeed;
break;
}
}
@@ -6632,21 +6632,21 @@ static void sub_80CE7E8(void)
sPSSData->field_218C.mon = &gUnknown_02039D14;
sPSSData->field_2187 = 0;
sPSSData->field_2186 = 0;
sPSSData->field_2188 = 0;
sPSSData->pokemonSummaryScreenMode = PSS_MODE_NORMAL;
}
else if (sBoxCursorArea == CURSOR_AREA_IN_PARTY)
{
sPSSData->field_218C.mon = gPlayerParty;
sPSSData->field_2187 = sBoxCursorPosition;
sPSSData->field_2186 = CountPartyMons() - 1;
sPSSData->field_2188 = 0;
sPSSData->pokemonSummaryScreenMode = PSS_MODE_NORMAL;
}
else
{
sPSSData->field_218C.box = GetBoxedMonPtr(StorageGetCurrentBox(), 0);
sPSSData->field_2187 = sBoxCursorPosition;
sPSSData->field_2186 = IN_BOX_COUNT - 1;
sPSSData->field_2188 = 2;
sPSSData->pokemonSummaryScreenMode = PSS_MODE_BOX;
}
}