summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/braille_puzzles.c72
-rw-r--r--src/cable_car.c19
-rw-r--r--src/event_object_movement.c53
-rwxr-xr-xsrc/faraway_island.c131
-rwxr-xr-xsrc/field_effect_helpers.c2
-rw-r--r--src/field_weather.c13
-rw-r--r--src/field_weather_effect.c1889
-rw-r--r--src/ghost.c106
-rw-r--r--src/link_rfu.c2
-rw-r--r--src/mauville_old_man.c2
-rw-r--r--src/menu.c66
-rwxr-xr-xsrc/mevent2.c94
-rw-r--r--src/mevent_801BAAC.c8
-rw-r--r--src/mevent_client.c291
-rw-r--r--src/mevent_scripts.c191
-rw-r--r--src/mevent_server.c295
-rw-r--r--src/mevent_server_helpers.c211
-rw-r--r--src/mystery_gift.c56
-rw-r--r--src/naming_screen.c10
-rw-r--r--src/overworld.c4
-rw-r--r--src/pokemon.c362
-rw-r--r--src/pokemon_icon.c886
-rw-r--r--src/scrcmd.c6
-rw-r--r--src/script.c6
-rw-r--r--src/script_menu.c107
-rwxr-xr-xsrc/script_pokemon_util_80F87D8.c2
-rw-r--r--src/util.c4
27 files changed, 2815 insertions, 2073 deletions
diff --git a/src/braille_puzzles.c b/src/braille_puzzles.c
index 07b941f11..659f8682e 100644
--- a/src/braille_puzzles.c
+++ b/src/braille_puzzles.c
@@ -25,42 +25,42 @@ EWRAM_DATA static u8 sBraillePuzzleCallbackFlag = 0;
static const u8 gRegicePathCoords[][2] =
{
- {0x04, 0x15},
- {0x05, 0x15},
- {0x06, 0x15},
- {0x07, 0x15},
- {0x08, 0x15},
- {0x09, 0x15},
- {0x0a, 0x15},
- {0x0b, 0x15},
- {0x0c, 0x15},
- {0x0c, 0x16},
- {0x0c, 0x17},
- {0x0d, 0x17},
- {0x0d, 0x18},
- {0x0d, 0x19},
- {0x0d, 0x1a},
- {0x0d, 0x1b},
- {0x0c, 0x1b},
- {0x0c, 0x1c},
- {0x04, 0x1d},
- {0x05, 0x1d},
- {0x06, 0x1d},
- {0x07, 0x1d},
- {0x08, 0x1d},
- {0x09, 0x1d},
- {0x0a, 0x1d},
- {0x0b, 0x1d},
- {0x0c, 0x1d},
- {0x04, 0x1c},
- {0x04, 0x1b},
- {0x03, 0x1b},
- {0x03, 0x1a},
- {0x03, 0x19},
- {0x03, 0x18},
- {0x03, 0x17},
- {0x04, 0x17},
- {0x04, 0x16},
+ {4, 21},
+ {5, 21},
+ {6, 21},
+ {7, 21},
+ {8, 21},
+ {9, 21},
+ {10, 21},
+ {11, 21},
+ {12, 21},
+ {12, 22},
+ {12, 23},
+ {13, 23},
+ {13, 24},
+ {13, 25},
+ {13, 26},
+ {13, 27},
+ {12, 27},
+ {12, 28},
+ {4, 29},
+ {5, 29},
+ {6, 29},
+ {7, 29},
+ {8, 29},
+ {9, 29},
+ {10, 29},
+ {11, 29},
+ {12, 29},
+ {4, 28},
+ {4, 27},
+ {3, 27},
+ {3, 26},
+ {3, 25},
+ {3, 24},
+ {3, 23},
+ {4, 23},
+ {4, 22},
};
void SealedChamberShakingEffect(u8);
diff --git a/src/cable_car.c b/src/cable_car.c
index 4e6980c4e..d44c9a241 100644
--- a/src/cable_car.c
+++ b/src/cable_car.c
@@ -428,13 +428,12 @@ static void sub_81503E4(u8 taskId)
case WEATHER_ASH:
if (gWeatherPtr->sprites.s2.ashSprites[0] != NULL && gWeatherPtr->sprites.s2.ashSprites[0]->oam.priority != 0)
{
- for (; i < 20; i++)
+ for (; i < NUM_ASH_SPRITES; i++)
{
- if (gWeatherPtr->sprites.s2.ashSprites[i] != NULL)
- {
+ if (gWeatherPtr->sprites.s2.ashSprites[i])
gWeatherPtr->sprites.s2.ashSprites[i]->oam.priority = 0;
- }
}
+
sCableCar->state = 2;
}
break;
@@ -445,12 +444,10 @@ static void sub_81503E4(u8 taskId)
}
else if (sCableCar->timer >= sCableCar->unk4 + 8)
{
- for (; i < 20; i++)
+ for (; i < NUM_ASH_SPRITES; i++)
{
- if (gWeatherPtr->sprites.s2.ashSprites[i] != NULL)
- {
- gWeatherPtr->sprites.s2.ashSprites[i]->invisible ^= TRUE;
- }
+ if (gWeatherPtr->sprites.s2.ashSprites[i])
+ gWeatherPtr->sprites.s2.ashSprites[i]->invisible ^= 1;
}
}
break;
@@ -466,9 +463,7 @@ static void sub_81503E4(u8 taskId)
break;
case 3:
if (!gPaletteFade.active)
- {
sCableCar->state = 0xFF;
- }
break;
case 0xFF:
SetVBlankCallback(NULL);
@@ -557,7 +552,7 @@ static void sub_8150664(u8 taskId)
if (sCableCar->timer < sCableCar->unk4)
gSpriteCoordOffsetX = (gSpriteCoordOffsetX + 247) % 248;
else
- gWeatherPtr->unknown_6FC = (gWeatherPtr->unknown_6FC + 247) % 248;
+ gWeatherPtr->ashBaseSpritesX = (gWeatherPtr->ashBaseSpritesX + 247) % 248;
}
static void CableCarVblankCallback(void)
diff --git a/src/event_object_movement.c b/src/event_object_movement.c
index 30dffd8d7..45b721f56 100644
--- a/src/event_object_movement.c
+++ b/src/event_object_movement.c
@@ -1949,7 +1949,7 @@ void EventObjectSetGraphicsId(struct EventObject *eventObject, u8 graphicsId)
sprite->oam.paletteNum = paletteSlot;
eventObject->inanimate = graphicsInfo->inanimate;
eventObject->graphicsId = graphicsId;
- sub_8093038(eventObject->currentCoords.x, eventObject->currentCoords.y, &sprite->pos1.x, &sprite->pos1.y);
+ SetSpritePosToMapCoords(eventObject->currentCoords.x, eventObject->currentCoords.y, &sprite->pos1.x, &sprite->pos1.y);
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
sprite->pos1.x += 8;
@@ -2253,7 +2253,7 @@ void sub_808EB08(struct EventObject *eventObject, s16 x, s16 y)
sprite = &gSprites[eventObject->spriteId];
graphicsInfo = GetEventObjectGraphicsInfo(eventObject->graphicsId);
SetEventObjectCoords(eventObject, x, y);
- sub_8093038(eventObject->currentCoords.x, eventObject->currentCoords.y, &sprite->pos1.x, &sprite->pos1.y);
+ SetSpritePosToMapCoords(eventObject->currentCoords.x, eventObject->currentCoords.y, &sprite->pos1.x, &sprite->pos1.y);
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
sprite->pos1.x += 8;
@@ -4414,8 +4414,8 @@ bool8 CopyablePlayerMovement_GoSpeed0(struct EventObject *eventObject, struct Sp
direction = playerDirection;
if (EventObjectIsFarawayIslandMew(eventObject))
{
- direction = sub_81D427C();
- if (direction == 0)
+ direction = GetMewMoveDirection();
+ if (direction == DIR_NONE)
{
direction = playerDirection;
direction = state_to_direction(gInitialMovementTypeFacingDirections[eventObject->movementType], eventObject->directionSequenceIndex, direction);
@@ -5024,44 +5024,37 @@ static void MoveCoordsInDirection(u32 dir, s16 *x, s16 *y, s16 deltaX, s16 delta
*y -= dy2;
}
-void sub_8092FF0(s16 x, s16 y, s16 *dest_x, s16 *dest_y)
+void sub_8092FF0(s16 x, s16 y, s16 *destX, s16 *destY)
{
- *dest_x = (x - gSaveBlock1Ptr->pos.x) << 4;
- *dest_y = (y - gSaveBlock1Ptr->pos.y) << 4;
- *dest_x -= gTotalCameraPixelOffsetX;
- *dest_y -= gTotalCameraPixelOffsetY;
+ *destX = (x - gSaveBlock1Ptr->pos.x) << 4;
+ *destY = (y - gSaveBlock1Ptr->pos.y) << 4;
+ *destX -= gTotalCameraPixelOffsetX;
+ *destY -= gTotalCameraPixelOffsetY;
}
-void sub_8093038(s16 x, s16 y, s16 *dest_x, s16 *dest_y)
+void SetSpritePosToMapCoords(s16 mapX, s16 mapY, s16 *destX, s16 *destY)
{
- s16 dx;
- s16 dy;
-
- dx = -gTotalCameraPixelOffsetX - gFieldCamera.x;
- dy = -gTotalCameraPixelOffsetY - gFieldCamera.y;
+ s16 dx = -gTotalCameraPixelOffsetX - gFieldCamera.x;
+ s16 dy = -gTotalCameraPixelOffsetY - gFieldCamera.y;
if (gFieldCamera.x > 0)
- {
- dx += 0x10;
- }
+ dx += 1 << 4;
+
if (gFieldCamera.x < 0)
- {
- dx -= 0x10;
- }
+ dx -= 1 << 4;
+
if (gFieldCamera.y > 0)
- {
- dy += 0x10;
- }
+ dy += 1 << 4;
+
if (gFieldCamera.y < 0)
- {
- dy -= 0x10;
- }
- *dest_x = ((x - gSaveBlock1Ptr->pos.x) << 4) + dx;
- *dest_y = ((y - gSaveBlock1Ptr->pos.y) << 4) + dy;
+ dy -= 1 << 4;
+
+ *destX = ((mapX - gSaveBlock1Ptr->pos.x) << 4) + dx;
+ *destY = ((mapY - gSaveBlock1Ptr->pos.y) << 4) + dy;
}
void sub_80930E0(s16 *x, s16 *y, s16 dx, s16 dy)
{
- sub_8093038(*x, *y, x, y);
+ SetSpritePosToMapCoords(*x, *y, x, y);
*x += dx;
*y += dy;
}
diff --git a/src/faraway_island.c b/src/faraway_island.c
index 1c8dff14e..6a835a02b 100755
--- a/src/faraway_island.c
+++ b/src/faraway_island.c
@@ -17,12 +17,13 @@ static u8 sub_81D4C9C(struct EventObject*, u8);
static u8 sub_81D4C58(struct EventObject*, u8);
static u8 sub_81D4CE0(struct EventObject*, u8);
static u8 sub_81D4D24(u8);
-static bool8 sub_81D4834(s16, s16);
+static bool8 CanMewWalkToCoords(s16, s16);
-extern u8 gUnknown_0203CF50;
-extern s16 gUnknown_030012F8;
-extern s16 gUnknown_030012FA;
-extern u8 gUnknown_030012FC[4];
+static EWRAM_DATA u8 sUnknown_0203CF50 = 0;
+
+static s16 sPlayerToMewDeltaX;
+static s16 sPlayerToMewDeltaY;
+static u8 sMewDirectionCandidates[4];
extern const struct SpritePalette gFieldEffectObjectPaletteInfo1;
extern const struct SpriteTemplate *const gFieldEffectObjectTemplatePointers[];
@@ -35,23 +36,23 @@ static const s16 sFarawayIslandRockCoords[4][2] =
{20, 20},
};
-static u8 sub_81D4258(void)
+static u8 GetMewEventObjectId(void)
{
u8 eventObjectId;
TryGetEventObjectIdByLocalIdAndMap(1, gSaveBlock1Ptr->location.mapNum, gSaveBlock1Ptr->location.mapGroup, &eventObjectId);
return eventObjectId;
}
-u32 sub_81D427C(void)
+u32 GetMewMoveDirection(void)
{
u8 i;
int skip;
- struct EventObject *mew = &gEventObjects[sub_81D4258()];
+ struct EventObject *mew = &gEventObjects[GetMewEventObjectId()];
- gUnknown_030012F8 = gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x - mew->currentCoords.x;
- gUnknown_030012FA = gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y - mew->currentCoords.y;
- for (i = 0; i < ARRAY_COUNT(gUnknown_030012FC); i++)
- gUnknown_030012FC[i] = DIR_NONE;
+ sPlayerToMewDeltaX = gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x - mew->currentCoords.x;
+ sPlayerToMewDeltaY = gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y - mew->currentCoords.y;
+ for (i = 0; i < ARRAY_COUNT(sMewDirectionCandidates); i++)
+ sMewDirectionCandidates[i] = DIR_NONE;
if (gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x == gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.x
&& gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y == gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.y)
@@ -85,33 +86,33 @@ u32 sub_81D427C(void)
if (!skip)
{
- if (gUnknown_030012F8 > 0)
+ if (sPlayerToMewDeltaX > 0)
{
if (mew->currentCoords.x + 1 == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x)
{
- if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
+ if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
return DIR_EAST;
}
}
- else if (gUnknown_030012F8 < 0)
+ else if (sPlayerToMewDeltaX < 0)
{
if (mew->currentCoords.x - 1 == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x)
{
- if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
+ if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
return DIR_WEST;
}
}
if (mew->currentCoords.x == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.x)
{
- if (gUnknown_030012FA > 0)
+ if (sPlayerToMewDeltaY > 0)
{
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
return DIR_NORTH;
}
else
{
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
return DIR_SOUTH;
}
}
@@ -134,33 +135,33 @@ u32 sub_81D427C(void)
if (!skip)
{
- if (gUnknown_030012FA > 0)
+ if (sPlayerToMewDeltaY > 0)
{
if (mew->currentCoords.y + 1 == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y)
{
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
return DIR_SOUTH;
}
}
- else if (gUnknown_030012FA < 0)
+ else if (sPlayerToMewDeltaY < 0)
{
if (mew->currentCoords.y - 1 == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y)
{
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
return DIR_NORTH;
}
}
if (mew->currentCoords.y == gEventObjects[gPlayerAvatar.eventObjectId].previousCoords.y)
{
- if (gUnknown_030012F8 > 0)
+ if (sPlayerToMewDeltaX > 0)
{
- if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
+ if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
return DIR_WEST;
}
else
{
- if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
+ if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
return DIR_EAST;
}
}
@@ -208,52 +209,52 @@ u32 sub_81D427C(void)
return DIR_WEST;
}
- if (gUnknown_030012FA == 0)
+ if (sPlayerToMewDeltaY == 0)
{
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.y > mew->currentCoords.y)
{
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
return DIR_NORTH;
}
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.y < mew->currentCoords.y)
{
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
return DIR_SOUTH;
}
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
return DIR_NORTH;
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
return DIR_SOUTH;
}
- if (gUnknown_030012F8 == 0)
+ if (sPlayerToMewDeltaX == 0)
{
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.x > mew->currentCoords.x)
{
- if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
+ if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
return DIR_WEST;
}
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.x < mew->currentCoords.x)
{
- if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
+ if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
return DIR_EAST;
}
- if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
+ if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
return DIR_EAST;
- if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
+ if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
return DIR_WEST;
}
return sub_81D4890(DIR_NONE);
}
-static bool8 sub_81D4834(s16 x, s16 y)
+static bool8 CanMewWalkToCoords(s16 x, s16 y)
{
if (gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.x == x
&& gEventObjects[gPlayerAvatar.eventObjectId].currentCoords.y == y)
@@ -268,39 +269,39 @@ static u8 sub_81D4890(u8 ignoredDir)
{
u8 i;
u8 count = 0;
- struct EventObject *mew = &gEventObjects[sub_81D4258()];
+ struct EventObject *mew = &gEventObjects[GetMewEventObjectId()];
- for (i = 0; i < ARRAY_COUNT(gUnknown_030012FC); i++)
- gUnknown_030012FC[i] = DIR_NONE;
+ for (i = 0; i < ARRAY_COUNT(sMewDirectionCandidates); i++)
+ sMewDirectionCandidates[i] = DIR_NONE;
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1) == TRUE && ignoredDir != DIR_NORTH)
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1) == TRUE && ignoredDir != DIR_NORTH)
{
- gUnknown_030012FC[count] = DIR_NORTH;
+ sMewDirectionCandidates[count] = DIR_NORTH;
count++;
}
- if (sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_EAST)
+ if (CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_EAST)
{
- gUnknown_030012FC[count] = DIR_EAST;
+ sMewDirectionCandidates[count] = DIR_EAST;
count++;
}
- if (sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1) == TRUE && ignoredDir != DIR_SOUTH)
+ if (CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1) == TRUE && ignoredDir != DIR_SOUTH)
{
- gUnknown_030012FC[count] = DIR_SOUTH;
+ sMewDirectionCandidates[count] = DIR_SOUTH;
count++;
}
- if (sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_WEST)
+ if (CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y) == TRUE && ignoredDir != DIR_WEST)
{
- gUnknown_030012FC[count] = DIR_WEST;
+ sMewDirectionCandidates[count] = DIR_WEST;
count++;
}
if (count > 1)
- return gUnknown_030012FC[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % count];
+ return sMewDirectionCandidates[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % count];
else
- return gUnknown_030012FC[0];
+ return sMewDirectionCandidates[0];
}
void UpdateFarawayIslandStepCounter(void)
@@ -355,7 +356,7 @@ void sub_81D4A90(void)
s16 x;
s16 y;
u8 spriteId;
- struct EventObject *mew = &gEventObjects[sub_81D4258()];
+ struct EventObject *mew = &gEventObjects[GetMewEventObjectId()];
mew->invisible = 0;
if (gSpecialVar_0x8004 == 1)
@@ -378,10 +379,10 @@ void sub_81D4A90(void)
x = mew->currentCoords.x;
y = mew->currentCoords.y;
sub_80930E0(&x, &y, 8, 8);
- gUnknown_0203CF50 = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[15], x, y, gSprites[mew->spriteId].subpriority - 1);
- if (gUnknown_0203CF50 != MAX_SPRITES)
+ sUnknown_0203CF50 = CreateSpriteAtEnd(gFieldEffectObjectTemplatePointers[15], x, y, gSprites[mew->spriteId].subpriority - 1);
+ if (sUnknown_0203CF50 != MAX_SPRITES)
{
- struct Sprite *sprite = &gSprites[gUnknown_0203CF50];
+ struct Sprite *sprite = &gSprites[sUnknown_0203CF50];
sprite->coordOffsetEnabled = 1;
sprite->oam.priority = 2;
sprite->callback = SpriteCallbackDummy;
@@ -391,15 +392,15 @@ void sub_81D4A90(void)
void sub_81D4BEC(void)
{
- if (gUnknown_0203CF50 != MAX_SPRITES)
- DestroySprite(&gSprites[gUnknown_0203CF50]);
+ if (sUnknown_0203CF50 != MAX_SPRITES)
+ DestroySprite(&gSprites[sUnknown_0203CF50]);
}
static bool8 sub_81D4C14(struct EventObject *mew, u8 index)
{
- if (gUnknown_030012FA > 0 && sub_81D4834(mew->currentCoords.x, mew->currentCoords.y - 1))
+ if (sPlayerToMewDeltaY > 0 && CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y - 1))
{
- gUnknown_030012FC[index] = DIR_NORTH;
+ sMewDirectionCandidates[index] = DIR_NORTH;
return TRUE;
}
@@ -408,9 +409,9 @@ static bool8 sub_81D4C14(struct EventObject *mew, u8 index)
static u8 sub_81D4C58(struct EventObject *mew, u8 index)
{
- if (gUnknown_030012F8 < 0 && sub_81D4834(mew->currentCoords.x + 1, mew->currentCoords.y))
+ if (sPlayerToMewDeltaX < 0 && CanMewWalkToCoords(mew->currentCoords.x + 1, mew->currentCoords.y))
{
- gUnknown_030012FC[index] = DIR_EAST;
+ sMewDirectionCandidates[index] = DIR_EAST;
return TRUE;
}
@@ -419,9 +420,9 @@ static u8 sub_81D4C58(struct EventObject *mew, u8 index)
static u8 sub_81D4C9C(struct EventObject *mew, u8 index)
{
- if (gUnknown_030012FA < 0 && sub_81D4834(mew->currentCoords.x, mew->currentCoords.y + 1))
+ if (sPlayerToMewDeltaY < 0 && CanMewWalkToCoords(mew->currentCoords.x, mew->currentCoords.y + 1))
{
- gUnknown_030012FC[index] = DIR_SOUTH;
+ sMewDirectionCandidates[index] = DIR_SOUTH;
return TRUE;
}
@@ -430,9 +431,9 @@ static u8 sub_81D4C9C(struct EventObject *mew, u8 index)
static u8 sub_81D4CE0(struct EventObject *mew, u8 index)
{
- if (gUnknown_030012F8 > 0 && sub_81D4834(mew->currentCoords.x - 1, mew->currentCoords.y))
+ if (sPlayerToMewDeltaX > 0 && CanMewWalkToCoords(mew->currentCoords.x - 1, mew->currentCoords.y))
{
- gUnknown_030012FC[index] = DIR_WEST;
+ sMewDirectionCandidates[index] = DIR_WEST;
return TRUE;
}
@@ -441,5 +442,5 @@ static u8 sub_81D4CE0(struct EventObject *mew, u8 index)
static u8 sub_81D4D24(u8 mod)
{
- return gUnknown_030012FC[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % mod];
+ return sMewDirectionCandidates[VarGet(VAR_FARAWAY_ISLAND_STEP_COUNTER) % mod];
}
diff --git a/src/field_effect_helpers.c b/src/field_effect_helpers.c
index 3f75fbb84..c715da25d 100755
--- a/src/field_effect_helpers.c
+++ b/src/field_effect_helpers.c
@@ -191,7 +191,7 @@ void ShowWarpArrowSprite(u8 spriteId, u8 direction, s16 x, s16 y)
sprite = &gSprites[spriteId];
if (sprite->invisible || sprite->data[0] != x || sprite->data[1] != y)
{
- sub_8093038(x, y, &x2, &y2);
+ SetSpritePosToMapCoords(x, y, &x2, &y2);
sprite = &gSprites[spriteId];
sprite->pos1.x = x2 + 8;
sprite->pos1.y = y2 + 8;
diff --git a/src/field_weather.c b/src/field_weather.c
index 9913e9a61..814e85ef4 100644
--- a/src/field_weather.c
+++ b/src/field_weather.c
@@ -91,7 +91,7 @@ static const struct WeatherCallbacks sWeatherFuncs[] =
{
{None_Init, None_Main, None_Init, None_Finish},
{Clouds_InitVars, Clouds_Main, Clouds_InitAll, Clouds_Finish},
- {Weather2_InitVars, Weather2_Main, Weather2_InitAll, Weather2_Finish},
+ {Sunny_InitVars, Sunny_Main, Sunny_InitAll, Sunny_Finish},
{LightRain_InitVars, LightRain_Main, LightRain_InitAll, LightRain_Finish},
{Snow_InitVars, Snow_Main, Snow_InitAll, Snow_Finish},
{MedRain_InitVars, Rain_Main, MedRain_InitAll, Rain_Finish},
@@ -167,15 +167,15 @@ void StartWeather(void)
gWeatherPtr->altGammaSpritePalIndex = index;
gWeatherPtr->weatherPicSpritePalIndex = AllocSpritePalette(0x1201);
gWeatherPtr->rainSpriteCount = 0;
- gWeatherPtr->unknown_6D8 = 0;
+ gWeatherPtr->curRainSpriteIndex = 0;
gWeatherPtr->cloudSpritesCreated = 0;
gWeatherPtr->snowflakeSpriteCount = 0;
gWeatherPtr->ashSpritesCreated = 0;
gWeatherPtr->fog1SpritesCreated = 0;
gWeatherPtr->fog2SpritesCreated = 0;
- gWeatherPtr->sandstormSprites1Created = 0;
- gWeatherPtr->sandstormSprites2Created = 0;
- gWeatherPtr->unknown_72E = 0;
+ gWeatherPtr->sandstormSpritesCreated = 0;
+ gWeatherPtr->sandstormSwirlSpritesCreated = 0;
+ gWeatherPtr->bubblesSpritesCreated = 0;
gWeatherPtr->lightenedFogSpritePalsCount = 0;
Weather_SetBlendCoeffs(16, 0);
gWeatherPtr->currWeather = 0;
@@ -234,7 +234,8 @@ static void Task_WeatherMain(u8 taskId)
{
if (gWeatherPtr->currWeather != gWeatherPtr->nextWeather)
{
- if (!sWeatherFuncs[gWeatherPtr->currWeather].finish() && gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_OUT)
+ if (!sWeatherFuncs[gWeatherPtr->currWeather].finish()
+ && gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_SCREEN_FADING_OUT)
{
// Finished cleaning up previous weather. Now transition to next weather.
sWeatherFuncs[gWeatherPtr->nextWeather].initVars();
diff --git a/src/field_weather_effect.c b/src/field_weather_effect.c
index 1468f7ca0..8fca02707 100644
--- a/src/field_weather_effect.c
+++ b/src/field_weather_effect.c
@@ -1,4 +1,5 @@
#include "global.h"
+#include "battle_anim.h"
#include "event_object_movement.h"
#include "field_weather.h"
#include "overworld.h"
@@ -12,16 +13,13 @@
#include "trig.h"
#include "gpu_regs.h"
-// This file's functions.
-void sub_80AC6B4(struct Sprite *);
-
// EWRAM
EWRAM_DATA static u8 gCurrentAlternatingWeather = 0;
EWRAM_DATA static u16 gUnusedWeatherRelated = 0;
// CONST
-const u16 gUnknown_0854C290[] = INCBIN_U16("graphics/weather/1.gbapal");
-const u16 gUnknown_0854C2B0[] = INCBIN_U16("graphics/weather/2.gbapal");
+const u16 gCloudsWeatherPalette[] = INCBIN_U16("graphics/weather/cloud.gbapal");
+const u16 gSandstormWeatherPalette[] = INCBIN_U16("graphics/weather/sandstorm.gbapal");
const u8 gWeatherFog2Tiles[] = INCBIN_U8("graphics/weather/fog2.4bpp");
const u8 gWeatherFog1Tiles[] = INCBIN_U8("graphics/weather/fog1.4bpp");
const u8 gWeatherCloudTiles[] = INCBIN_U8("graphics/weather/cloud.4bpp");
@@ -32,20 +30,35 @@ const u8 gWeatherAshTiles[] = INCBIN_U8("graphics/weather/ash.4bpp");
const u8 gWeatherRainTiles[] = INCBIN_U8("graphics/weather/rain.4bpp");
const u8 gWeatherSandstormTiles[] = INCBIN_U8("graphics/weather/sandstorm.4bpp");
-static const struct Coords16 gUnknown_0854FB50[] =
+//------------------------------------------------------------------------------
+// Clouds
+//------------------------------------------------------------------------------
+
+static void CreateCloudSprites(void);
+static void DestroyCloudSprites(void);
+static void UpdateCloudSprite(struct Sprite *);
+
+// The clouds are positioned on the map's grid.
+// These coordinates are for the lower half of Route 120.
+static const struct Coords16 sCloudSpriteMapCoords[] =
{
{ 0, 66},
{ 5, 73},
{10, 78},
};
-static const struct SpriteSheet sCloudSpriteSheet = {gWeatherCloudTiles, sizeof(gWeatherCloudTiles), 0x1200};
+static const struct SpriteSheet sCloudSpriteSheet =
+{
+ .data = gWeatherCloudTiles,
+ .size = sizeof(gWeatherCloudTiles),
+ .tag = 0x1200
+};
-static const struct OamData gOamData_839A9DC =
+static const struct OamData sCloudSpriteOamData =
{
.y = 0,
.affineMode = 0,
- .objMode = 1,
+ .objMode = ST_OAM_OBJ_BLEND,
.mosaic = 0,
.bpp = 0,
.shape = SPRITE_SHAPE(64x64),
@@ -58,32 +71,28 @@ static const struct OamData gOamData_839A9DC =
.affineParam = 0,
};
-static const union AnimCmd gSpriteAnim_839A9E4[] =
+static const union AnimCmd sCloudSpriteAnimCmd[] =
{
ANIMCMD_FRAME(0, 16),
ANIMCMD_END,
};
-static const union AnimCmd *const gSpriteAnimTable_839A9EC[] =
+static const union AnimCmd *const sCloudSpriteAnimCmds[] =
{
- gSpriteAnim_839A9E4,
+ sCloudSpriteAnimCmd,
};
static const struct SpriteTemplate sCloudSpriteTemplate =
{
- .tileTag = 4608,
- .paletteTag = 4609,
- .oam = &gOamData_839A9DC,
- .anims = gSpriteAnimTable_839A9EC,
+ .tileTag = 0x1200,
+ .paletteTag = 0x1201,
+ .oam = &sCloudSpriteOamData,
+ .anims = sCloudSpriteAnimCmds,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_80AC6B4,
+ .callback = UpdateCloudSprite,
};
-//------------------------------------------------------------------------------
-// Clouds
-//------------------------------------------------------------------------------
-
void Clouds_InitVars(void)
{
gWeatherPtr->gammaTargetIndex = 0;
@@ -101,8 +110,6 @@ void Clouds_InitAll(void)
Clouds_Main();
}
-void CreateCloudSprites(void);
-
void Clouds_Main(void)
{
switch (gWeatherPtr->initStep)
@@ -125,8 +132,6 @@ void Clouds_Main(void)
}
}
-void sub_807E0A0(void);
-
bool8 Clouds_Finish(void)
{
switch (gWeatherPtr->finishStep)
@@ -138,7 +143,7 @@ bool8 Clouds_Finish(void)
case 1:
if (Weather_UpdateBlend())
{
- sub_807E0A0();
+ DestroyCloudSprites();
gWeatherPtr->finishStep++;
}
return TRUE;
@@ -146,49 +151,45 @@ bool8 Clouds_Finish(void)
return FALSE;
}
-//------------------------------------------------------------------------------
-// Weather 2
-//------------------------------------------------------------------------------
-
-void Weather2_InitVars(void)
+void Sunny_InitVars(void)
{
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
}
-void Weather2_InitAll(void)
+void Sunny_InitAll(void)
{
- Weather2_InitVars();
+ Sunny_InitVars();
}
-void Weather2_Main(void)
+void Sunny_Main(void)
{
}
-bool8 Weather2_Finish(void)
+bool8 Sunny_Finish(void)
{
- return 0;
+ return FALSE;
}
-void CreateCloudSprites(void)
+static void CreateCloudSprites(void)
{
u16 i;
+ u8 spriteId;
+ struct Sprite *sprite;
if (gWeatherPtr->cloudSpritesCreated == TRUE)
return;
+
LoadSpriteSheet(&sCloudSpriteSheet);
- LoadCustomWeatherSpritePalette(gUnknown_0854C290);
- for (i = 0; i < 3; i++)
+ LoadCustomWeatherSpritePalette(gCloudsWeatherPalette);
+ for (i = 0; i < NUM_CLOUD_SPRITES; i++)
{
- u8 spriteId = CreateSprite(&sCloudSpriteTemplate, 0, 0, 0xFF);
-
+ spriteId = CreateSprite(&sCloudSpriteTemplate, 0, 0, 0xFF);
if (spriteId != MAX_SPRITES)
{
- struct Sprite *sprite;
-
gWeatherPtr->sprites.s1.cloudSprites[i] = &gSprites[spriteId];
sprite = gWeatherPtr->sprites.s1.cloudSprites[i];
- sub_8093038(gUnknown_0854FB50[i].x + 7, gUnknown_0854FB50[i].y + 7, &sprite->pos1.x, &sprite->pos1.y);
+ SetSpritePosToMapCoords(sCloudSpriteMapCoords[i].x + 7, sCloudSpriteMapCoords[i].y + 7, &sprite->pos1.x, &sprite->pos1.y);
sprite->coordOffsetEnabled = TRUE;
}
else
@@ -196,28 +197,32 @@ void CreateCloudSprites(void)
gWeatherPtr->sprites.s1.cloudSprites[i] = NULL;
}
}
+
gWeatherPtr->cloudSpritesCreated = TRUE;
}
-void sub_807E0A0(void)
+static void DestroyCloudSprites(void)
{
u16 i;
- if (gWeatherPtr->cloudSpritesCreated == FALSE)
+ if (!gWeatherPtr->cloudSpritesCreated)
return;
- for (i = 0; i < 3; i++)
+
+ for (i = 0; i < NUM_CLOUD_SPRITES; i++)
{
if (gWeatherPtr->sprites.s1.cloudSprites[i] != NULL)
DestroySprite(gWeatherPtr->sprites.s1.cloudSprites[i]);
}
+
FreeSpriteTilesByTag(0x1200);
gWeatherPtr->cloudSpritesCreated = FALSE;
}
-void sub_80AC6B4(struct Sprite *sprite)
+static void UpdateCloudSprite(struct Sprite *sprite)
{
+ // Move 1 pixel left every 2 frames.
sprite->data[0] = (sprite->data[0] + 1) & 1;
- if (sprite->data[0] != 0)
+ if (sprite->data[0])
sprite->pos1.x--;
}
@@ -225,6 +230,8 @@ void sub_80AC6B4(struct Sprite *sprite)
// Drought
//------------------------------------------------------------------------------
+static void UpdateDroughtBlend(u8);
+
void Drought_InitVars(void)
{
gWeatherPtr->initStep = 0;
@@ -276,14 +283,12 @@ void Drought_Main(void)
bool8 Drought_Finish(void)
{
- return 0;
+ return FALSE;
}
-void task50_0807B6D4(u8);
-
-void sub_80AC81C(void)
+void StartDroughtWeatherBlend(void)
{
- CreateTask(task50_0807B6D4, 0x50);
+ CreateTask(UpdateDroughtBlend, 0x50);
}
#define tState data[0]
@@ -291,7 +296,7 @@ void sub_80AC81C(void)
#define tBlendDelay data[2]
#define tWinRange data[3]
-void task50_0807B6D4(u8 taskId)
+static void UpdateDroughtBlend(u8 taskId)
{
struct Task *task = &gTasks[taskId];
@@ -350,14 +355,128 @@ void task50_0807B6D4(u8 taskId)
// Light Rain
//------------------------------------------------------------------------------
+static void LoadRainSpriteSheet(void);
+static bool8 CreateRainSprite(void);
+static void UpdateRainSprite(struct Sprite *sprite);
+static bool8 UpdateVisibleRainSprites(void);
+static void DestroyRainSprites(void);
+
+static const struct Coords16 sRainSpriteCoords[] =
+{
+ { 0, 0},
+ { 0, 160},
+ { 0, 64},
+ {144, 224},
+ {144, 128},
+ { 32, 32},
+ { 32, 192},
+ { 32, 96},
+ { 72, 128},
+ { 72, 32},
+ { 72, 192},
+ {216, 96},
+ {216, 0},
+ {104, 160},
+ {104, 64},
+ {104, 224},
+ {144, 0},
+ {144, 160},
+ {144, 64},
+ { 32, 224},
+ { 32, 128},
+ { 72, 32},
+ { 72, 192},
+ { 48, 96},
+};
+
+static const struct OamData sRainSpriteOamData =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = SPRITE_SHAPE(16x32),
+ .x = 0,
+ .matrixNum = 0,
+ .size = SPRITE_SIZE(16x32),
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 2,
+ .affineParam = 0,
+};
+
+static const union AnimCmd sRainSpriteFallAnimCmd[] =
+{
+ ANIMCMD_FRAME(0, 16),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd sRainSpriteSplashAnimCmd[] =
+{
+ ANIMCMD_FRAME(8, 3),
+ ANIMCMD_FRAME(32, 2),
+ ANIMCMD_FRAME(40, 2),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd sRainSpriteHeavySplashAnimCmd[] =
+{
+ ANIMCMD_FRAME(8, 3),
+ ANIMCMD_FRAME(16, 3),
+ ANIMCMD_FRAME(24, 4),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd *const sRainSpriteAnimCmds[] =
+{
+ sRainSpriteFallAnimCmd,
+ sRainSpriteSplashAnimCmd,
+ sRainSpriteHeavySplashAnimCmd,
+};
+
+static const struct SpriteTemplate sRainSpriteTemplate =
+{
+ .tileTag = 4614,
+ .paletteTag = 0x1200,
+ .oam = &sRainSpriteOamData,
+ .anims = sRainSpriteAnimCmds,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = UpdateRainSprite,
+};
+
+// Q28.4 fixed-point format values
+static const s16 sRainSpriteMovement[][2] =
+{
+ {-0x68, 0xD0},
+ {-0xA0, 0x140},
+};
+
+// First byte is the number of frames a raindrop falls before it splashes.
+// Second byte is the maximum number of frames a raindrop can "wait" before
+// it appears and starts falling. (This is only for the initial raindrop spawn.)
+static const u16 sRainSpriteFallingDurations[][2] =
+{
+ {18, 7},
+ {12, 10},
+};
+
+static const struct SpriteSheet sRainSpriteSheet =
+{
+ .data = gWeatherRainTiles,
+ .size = sizeof(gWeatherRainTiles),
+ .tag = 0x1206,
+};
+
void LightRain_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = FALSE;
- gWeatherPtr->unknown_6D6 = 0;
- gWeatherPtr->unknown_6DB = 8;
- gWeatherPtr->unknown_6DC = 0;
- gWeatherPtr->unknown_6D9 = 10;
+ gWeatherPtr->rainSpriteVisibleCounter = 0;
+ gWeatherPtr->rainSpriteVisibleDelay = 8;
+ gWeatherPtr->isHeavyRain = 0;
+ gWeatherPtr->targetRainSpriteCount = 10;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
SetRainStrengthFromSoundEffect(SE_T_KOAME);
@@ -366,14 +485,10 @@ void LightRain_InitVars(void)
void LightRain_InitAll(void)
{
LightRain_InitVars();
- while (gWeatherPtr->weatherGfxLoaded == FALSE)
+ while (!gWeatherPtr->weatherGfxLoaded)
LightRain_Main();
}
-void LoadRainSpriteSheet(void);
-u8 CreateRainSprite(void);
-u8 sub_807E8E8(void);
-
void LightRain_Main(void)
{
switch (gWeatherPtr->initStep)
@@ -383,11 +498,11 @@ void LightRain_Main(void)
gWeatherPtr->initStep++;
break;
case 1:
- if (CreateRainSprite() == 0)
+ if (!CreateRainSprite())
gWeatherPtr->initStep++;
break;
case 2:
- if (sub_807E8E8() == FALSE)
+ if (!UpdateVisibleRainSprites())
{
gWeatherPtr->weatherGfxLoaded = TRUE;
gWeatherPtr->initStep++;
@@ -396,8 +511,6 @@ void LightRain_Main(void)
}
}
-void DestroyRainSprites(void);
-
bool8 LightRain_Finish(void)
{
switch (gWeatherPtr->finishStep)
@@ -412,12 +525,12 @@ bool8 LightRain_Finish(void)
}
else
{
- gWeatherPtr->unknown_6D9 = 0;
+ gWeatherPtr->targetRainSpriteCount = 0;
gWeatherPtr->finishStep++;
}
// fall through
case 1:
- if (sub_807E8E8() == FALSE)
+ if (!UpdateVisibleRainSprites())
{
DestroyRainSprites();
gWeatherPtr->finishStep++;
@@ -428,66 +541,74 @@ bool8 LightRain_Finish(void)
return FALSE;
}
-// defined below
-extern const s16 gUnknown_0839AABC[][2];
-extern const u16 gUnknown_0839AAC4[][2];
+#define tCounter data[0]
+#define tRandom data[1]
+#define tPosX data[2]
+#define tPosY data[3]
+#define tState data[4]
+#define tActive data[5]
+#define tWaiting data[6]
-void sub_807E4EC(struct Sprite *sprite)
+static void StartRainSpriteFall(struct Sprite *sprite)
{
- u32 randVal;
- u16 r6;
- s32 r4;
- s32 r0;
+ u32 rand;
+ u16 numFallingFrames;
+ int tileX;
+ int tileY;
+
+ if (sprite->tRandom == 0)
+ sprite->tRandom = 361;
- if (sprite->data[1] == 0)
- sprite->data[1] = 361;
- randVal = sprite->data[1] * 1103515245 + 12345;
- sprite->data[1] = ((randVal & 0x7FFF0000) >> 16) % 600;
+ // Standard RNG sequence.
+ rand = sprite->tRandom * 1103515245 + 12345;
+ sprite->tRandom = ((rand & 0x7FFF0000) >> 16) % 600;
- r6 = gUnknown_0839AAC4[gWeatherPtr->unknown_6DC][0];
+ numFallingFrames = sRainSpriteFallingDurations[gWeatherPtr->isHeavyRain][0];
- r4 = sprite->data[1] % 30;
- sprite->data[2] = r4 * 8; // useless assignment
+ tileX = sprite->tRandom % 30;
+ sprite->tPosX = tileX * 8; // Useless assignment, leftover from before fixed-point values were used
- r0 = sprite->data[1] / 30;
- sprite->data[3] = r0 * 8; // useless assignment
+ tileY = sprite->tRandom / 30;
+ sprite->tPosY = tileY * 8; // Useless assignment, leftover from before fixed-point values were used
- sprite->data[2] = r4;
- sprite->data[2] <<= 7;
+ sprite->tPosX = tileX;
+ sprite->tPosX <<= 7; // This is tileX * 8, using a fixed-point value with 4 decimal places
- sprite->data[3] = r0;
- sprite->data[3] <<= 7;
+ sprite->tPosY = tileY;
+ sprite->tPosY <<= 7; // This is tileX * 8, using a fixed-point value with 4 decimal places
- sprite->data[2] -= gUnknown_0839AABC[gWeatherPtr->unknown_6DC][0] * r6;
- sprite->data[3] -= gUnknown_0839AABC[gWeatherPtr->unknown_6DC][1] * r6;
+ // "Rewind" the rain sprites, from their ending position.
+ sprite->tPosX -= sRainSpriteMovement[gWeatherPtr->isHeavyRain][0] * numFallingFrames;
+ sprite->tPosY -= sRainSpriteMovement[gWeatherPtr->isHeavyRain][1] * numFallingFrames;
StartSpriteAnim(sprite, 0);
- sprite->data[4] = 0;
+ sprite->tState = 0;
sprite->coordOffsetEnabled = FALSE;
- sprite->data[0] = r6;
+ sprite->tCounter = numFallingFrames;
}
-void sub_807E5C0(struct Sprite *sprite)
+static void UpdateRainSprite(struct Sprite *sprite)
{
- if (sprite->data[4] == 0)
+ if (sprite->tState == 0)
{
- sprite->data[2] += gUnknown_0839AABC[gWeatherPtr->unknown_6DC][0];
- sprite->data[3] += gUnknown_0839AABC[gWeatherPtr->unknown_6DC][1];
- sprite->pos1.x = sprite->data[2] >> 4;
- sprite->pos1.y = sprite->data[3] >> 4;
+ // Raindrop is in its "falling" motion.
+ sprite->tPosX += sRainSpriteMovement[gWeatherPtr->isHeavyRain][0];
+ sprite->tPosY += sRainSpriteMovement[gWeatherPtr->isHeavyRain][1];
+ sprite->pos1.x = sprite->tPosX >> 4;
+ sprite->pos1.y = sprite->tPosY >> 4;
- if (sprite->data[5] != 0
+ if (sprite->tActive
&& (sprite->pos1.x >= -8 && sprite->pos1.x <= 248)
&& sprite->pos1.y >= -16 && sprite->pos1.y <= 176)
sprite->invisible = FALSE;
else
sprite->invisible = TRUE;
- sprite->data[0]--;
- if (sprite->data[0] == 0)
+ if (--sprite->tCounter == 0)
{
- StartSpriteAnim(sprite, gWeatherPtr->unknown_6DC + 1);
- sprite->data[4] = 1;
+ // Make raindrop splash on the ground
+ StartSpriteAnim(sprite, gWeatherPtr->isHeavyRain + 1);
+ sprite->tState = 1;
sprite->pos1.x -= gSpriteCoordOffsetX;
sprite->pos1.y -= gSpriteCoordOffsetY;
sprite->coordOffsetEnabled = TRUE;
@@ -495,363 +616,126 @@ void sub_807E5C0(struct Sprite *sprite)
}
else if (sprite->animEnded)
{
+ // The splashing animation ended.
sprite->invisible = TRUE;
- sub_807E4EC(sprite);
+ StartRainSpriteFall(sprite);
}
}
-void sub_807E6C4(struct Sprite *sprite)
+static void WaitRainSprite(struct Sprite *sprite)
{
- if (sprite->data[0] == 0)
+ if (sprite->tCounter == 0)
{
- sub_807E4EC(sprite);
- sprite->callback = sub_807E5C0;
+ StartRainSpriteFall(sprite);
+ sprite->callback = UpdateRainSprite;
}
else
{
- sprite->data[0]--;
+ sprite->tCounter--;
}
}
-void sub_807E6F0(struct Sprite *sprite, u16 b)
+static void InitRainSpriteMovement(struct Sprite *sprite, u16 val)
{
- u16 r8 = gUnknown_0839AAC4[gWeatherPtr->unknown_6DC][0];
- u16 r6 = b / (gUnknown_0839AAC4[gWeatherPtr->unknown_6DC][1] + r8);
- u16 r4 = b % (gUnknown_0839AAC4[gWeatherPtr->unknown_6DC][1] + r8);
+ u16 numFallingFrames = sRainSpriteFallingDurations[gWeatherPtr->isHeavyRain][0];
+ u16 numAdvanceRng = val / (sRainSpriteFallingDurations[gWeatherPtr->isHeavyRain][1] + numFallingFrames);
+ u16 frameVal = val % (sRainSpriteFallingDurations[gWeatherPtr->isHeavyRain][1] + numFallingFrames);
+
+ while (--numAdvanceRng != 0xFFFF)
+ StartRainSpriteFall(sprite);
- while (--r6 != 0xFFFF)
- sub_807E4EC(sprite);
- if (r4 < r8)
+ if (frameVal < numFallingFrames)
{
- while (--r4 != 0xFFFF)
- sub_807E5C0(sprite);
- sprite->data[6] = 0;
+ while (--frameVal != 0xFFFF)
+ UpdateRainSprite(sprite);
+
+ sprite->tWaiting = 0;
}
else
{
- sprite->data[0] = r4 - r8;
+ sprite->tCounter = frameVal - numFallingFrames;
sprite->invisible = TRUE;
- sprite->data[6] = 1;
+ sprite->tWaiting = 1;
}
}
-extern const struct SpriteSheet sRainSpriteSheet; // defined below
-
-void LoadRainSpriteSheet(void)
+static void LoadRainSpriteSheet(void)
{
LoadSpriteSheet(&sRainSpriteSheet);
}
-static const struct Coords16 sRainSpriteCoords[] =
-{
- { 0, 0},
- { 0, 160},
- { 0, 64},
- {144, 224},
- {144, 128},
- { 32, 32},
- { 32, 192},
- { 32, 96},
- { 72, 128},
- { 72, 32},
- { 72, 192},
- {216, 96},
- {216, 0},
- {104, 160},
- {104, 64},
- {104, 224},
- {144, 0},
- {144, 160},
- {144, 64},
- { 32, 224},
- { 32, 128},
- { 72, 32},
- { 72, 192},
- { 48, 96},
-};
-
-static const struct OamData gOamData_839AA68 =
-{
- .y = 0,
- .affineMode = 0,
- .objMode = 0,
- .mosaic = 0,
- .bpp = 0,
- .shape = SPRITE_SHAPE(16x32),
- .x = 0,
- .matrixNum = 0,
- .size = SPRITE_SIZE(16x32),
- .tileNum = 0,
- .priority = 1,
- .paletteNum = 2,
- .affineParam = 0,
-};
-
-static const union AnimCmd gSpriteAnim_839AA70[] =
-{
- ANIMCMD_FRAME(0, 16),
- ANIMCMD_JUMP(0),
-};
-
-static const union AnimCmd gSpriteAnim_839AA78[] =
-{
- ANIMCMD_FRAME(8, 3),
- ANIMCMD_FRAME(32, 2),
- ANIMCMD_FRAME(40, 2),
- ANIMCMD_END,
-};
-
-static const union AnimCmd gSpriteAnim_839AA88[] =
-{
- ANIMCMD_FRAME(8, 3),
- ANIMCMD_FRAME(16, 3),
- ANIMCMD_FRAME(24, 4),
- ANIMCMD_END,
-};
-
-static const union AnimCmd *const gSpriteAnimTable_839AA98[] =
-{
- gSpriteAnim_839AA70,
- gSpriteAnim_839AA78,
- gSpriteAnim_839AA88,
-};
-
-static const struct SpriteTemplate sRainSpriteTemplate =
-{
- .tileTag = 4614,
- .paletteTag = 4608,
- .oam = &gOamData_839AA68,
- .anims = gSpriteAnimTable_839AA98,
- .images = NULL,
- .affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_807E5C0,
-};
-
-const s16 gUnknown_0839AABC[][2] =
-{
- {-104, 208},
- {-160, 320},
-};
-
-const u16 gUnknown_0839AAC4[][2] =
-{
- {18, 7},
- {12, 10},
-};
-
-static const struct SpriteSheet sRainSpriteSheet = {gWeatherRainTiles, sizeof(gWeatherRainTiles), 0x1206};
-
-static const struct OamData gOamData_839AAD4 =
-{
- .y = 0,
- .affineMode = 0,
- .objMode = 0,
- .mosaic = 0,
- .bpp = 0,
- .shape = SPRITE_SHAPE(8x8),
- .x = 0,
- .matrixNum = 0,
- .size = SPRITE_SIZE(8x8),
- .tileNum = 0,
- .priority = 1,
- .paletteNum = 0,
- .affineParam = 0,
-};
-
-static const struct SpriteFrameImage gSpriteImageTable_839AADC[] =
-{
- {gWeatherSnow1Tiles, sizeof(gWeatherSnow1Tiles)},
- {gWeatherSnow2Tiles, sizeof(gWeatherSnow2Tiles)},
-};
-
-static const union AnimCmd gSpriteAnim_839AAEC[] =
-{
- ANIMCMD_FRAME(0, 16),
- ANIMCMD_END,
-};
-
-static const union AnimCmd gSpriteAnim_839AAF4[] =
-{
- ANIMCMD_FRAME(1, 16),
- ANIMCMD_END,
-};
-
-static const union AnimCmd *const gSpriteAnimTable_839AAFC[] =
-{
- gSpriteAnim_839AAEC,
- gSpriteAnim_839AAF4,
-};
-
-void sub_807ED48(struct Sprite *);
-static const struct SpriteTemplate sSnowflakeSpriteTemplate =
-{
- .tileTag = 0xFFFF,
- .paletteTag = 4608,
- .oam = &gOamData_839AAD4,
- .anims = gSpriteAnimTable_839AAFC,
- .images = gSpriteImageTable_839AADC,
- .affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_807ED48,
-};
-
-// unused data
-static const u16 unusedData_839AB1C[] = {0, 6, 6, 12, 18, 42, 300, 300};
-
-static const struct OamData gOamData_839AB2C =
-{
- .y = 0,
- .affineMode = 0,
- .objMode = 1,
- .mosaic = 0,
- .bpp = 0,
- .shape = SPRITE_SHAPE(64x64),
- .x = 0,
- .matrixNum = 0,
- .size = SPRITE_SIZE(64x64),
- .tileNum = 0,
- .priority = 2,
- .paletteNum = 0,
- .affineParam = 0,
-};
-
-static const union AnimCmd gSpriteAnim_839AB34[] =
+static bool8 CreateRainSprite(void)
{
- ANIMCMD_FRAME(0, 16),
- ANIMCMD_END,
-};
-
-static const union AnimCmd gSpriteAnim_839AB3C[] =
-{
- ANIMCMD_FRAME(32, 16),
- ANIMCMD_END,
-};
-
-static const union AnimCmd gSpriteAnim_839AB44[] =
-{
- ANIMCMD_FRAME(64, 16),
- ANIMCMD_END,
-};
-
-static const union AnimCmd gSpriteAnim_839AB4C[] =
-{
- ANIMCMD_FRAME(96, 16),
- ANIMCMD_END,
-};
-
-static const union AnimCmd gSpriteAnim_839AB54[] =
-{
- ANIMCMD_FRAME(128, 16),
- ANIMCMD_END,
-};
-
-static const union AnimCmd gSpriteAnim_839AB5C[] =
-{
- ANIMCMD_FRAME(160, 16),
- ANIMCMD_END,
-};
-
-static const union AnimCmd *const gSpriteAnimTable_839AB64[] =
-{
- gSpriteAnim_839AB34,
- gSpriteAnim_839AB3C,
- gSpriteAnim_839AB44,
- gSpriteAnim_839AB4C,
- gSpriteAnim_839AB54,
- gSpriteAnim_839AB5C,
-};
-
-static const union AffineAnimCmd gSpriteAffineAnim_839AB7C[] =
-{
- AFFINEANIMCMD_FRAME(0x200, 0x200, 0, 0),
- AFFINEANIMCMD_END,
-};
-
-static const union AffineAnimCmd *const gSpriteAffineAnimTable_839AB8C[] =
-{
- gSpriteAffineAnim_839AB7C,
-};
-
-static void Fog1SpriteCallback(struct Sprite *);
-static const struct SpriteTemplate sFog1SpriteTemplate =
-{
- .tileTag = 4609,
- .paletteTag = 4608,
- .oam = &gOamData_839AB2C,
- .anims = gSpriteAnimTable_839AB64,
- .images = NULL,
- .affineAnims = gSpriteAffineAnimTable_839AB8C,
- .callback = Fog1SpriteCallback,
-};
-
-bool8 CreateRainSprite(void)
-{
- u8 spriteNum;
+ u8 spriteIndex;
u8 spriteId;
- if (gWeatherPtr->rainSpriteCount == 24)
+ if (gWeatherPtr->rainSpriteCount == MAX_RAIN_SPRITES)
return FALSE;
- spriteNum = gWeatherPtr->rainSpriteCount;
+ spriteIndex = gWeatherPtr->rainSpriteCount;
spriteId = CreateSpriteAtEnd(&sRainSpriteTemplate,
- sRainSpriteCoords[spriteNum].x, sRainSpriteCoords[spriteNum].y, 78);
+ sRainSpriteCoords[spriteIndex].x, sRainSpriteCoords[spriteIndex].y, 78);
+
if (spriteId != MAX_SPRITES)
{
- gSprites[spriteId].data[5] = 0;
- gSprites[spriteId].data[1] = spriteNum * 145;
- while (gSprites[spriteId].data[1] >= 600)
- gSprites[spriteId].data[1] -= 600;
- sub_807E4EC(&gSprites[spriteId]);
- sub_807E6F0(&gSprites[spriteId], spriteNum * 9);
+ gSprites[spriteId].tActive = 0;
+ gSprites[spriteId].tRandom = spriteIndex * 145;
+ while (gSprites[spriteId].tRandom >= 600)
+ gSprites[spriteId].tRandom -= 600;
+
+ StartRainSpriteFall(&gSprites[spriteId]);
+ InitRainSpriteMovement(&gSprites[spriteId], spriteIndex * 9);
gSprites[spriteId].invisible = TRUE;
- gWeatherPtr->sprites.s1.rainSprites[spriteNum] = &gSprites[spriteId];
+ gWeatherPtr->sprites.s1.rainSprites[spriteIndex] = &gSprites[spriteId];
}
else
{
- gWeatherPtr->sprites.s1.rainSprites[spriteNum] = NULL;
+ gWeatherPtr->sprites.s1.rainSprites[spriteIndex] = NULL;
}
- if (++gWeatherPtr->rainSpriteCount == 24)
+ if (++gWeatherPtr->rainSpriteCount == MAX_RAIN_SPRITES)
{
u16 i;
-
- for (i = 0; i < 24; i++)
+ for (i = 0; i < MAX_RAIN_SPRITES; i++)
{
- if (gWeatherPtr->sprites.s1.rainSprites[i] != NULL)
+ if (gWeatherPtr->sprites.s1.rainSprites[i])
{
- if (gWeatherPtr->sprites.s1.rainSprites[i]->data[6] == 0)
- gWeatherPtr->sprites.s1.rainSprites[i]->callback = sub_807E5C0;
+ if (!gWeatherPtr->sprites.s1.rainSprites[i]->tWaiting)
+ gWeatherPtr->sprites.s1.rainSprites[i]->callback = UpdateRainSprite;
else
- gWeatherPtr->sprites.s1.rainSprites[i]->callback = sub_807E6C4;
+ gWeatherPtr->sprites.s1.rainSprites[i]->callback = WaitRainSprite;
}
}
+
return FALSE;
}
+
return TRUE;
}
-bool8 sub_807E8E8(void)
+static bool8 UpdateVisibleRainSprites(void)
{
- if (gWeatherPtr->unknown_6D8 == gWeatherPtr->unknown_6D9)
+ if (gWeatherPtr->curRainSpriteIndex == gWeatherPtr->targetRainSpriteCount)
return FALSE;
- if (++gWeatherPtr->unknown_6D6 > gWeatherPtr->unknown_6DB)
+ if (++gWeatherPtr->rainSpriteVisibleCounter > gWeatherPtr->rainSpriteVisibleDelay)
{
- gWeatherPtr->unknown_6D6 = 0;
- if (gWeatherPtr->unknown_6D8 < gWeatherPtr->unknown_6D9)
+ gWeatherPtr->rainSpriteVisibleCounter = 0;
+ if (gWeatherPtr->curRainSpriteIndex < gWeatherPtr->targetRainSpriteCount)
{
- gWeatherPtr->sprites.s1.rainSprites[gWeatherPtr->unknown_6D8++]->data[5] = 1;
+ gWeatherPtr->sprites.s1.rainSprites[gWeatherPtr->curRainSpriteIndex++]->tActive = 1;
}
else
{
- gWeatherPtr->unknown_6D8--;
- gWeatherPtr->sprites.s1.rainSprites[gWeatherPtr->unknown_6D8]->data[5] = 0;
- gWeatherPtr->sprites.s1.rainSprites[gWeatherPtr->unknown_6D8]->invisible = TRUE;
+ gWeatherPtr->curRainSpriteIndex--;
+ gWeatherPtr->sprites.s1.rainSprites[gWeatherPtr->curRainSpriteIndex]->tActive = 0;
+ gWeatherPtr->sprites.s1.rainSprites[gWeatherPtr->curRainSpriteIndex]->invisible = TRUE;
}
}
return TRUE;
}
-void DestroyRainSprites(void)
+static void DestroyRainSprites(void)
{
u16 i;
@@ -864,43 +748,50 @@ void DestroyRainSprites(void)
FreeSpriteTilesByTag(0x1206);
}
+#undef tCounter
+#undef tRandom
+#undef tPosX
+#undef tPosY
+#undef tState
+#undef tActive
+#undef tWaiting
+
//------------------------------------------------------------------------------
// Snow
//------------------------------------------------------------------------------
+static void UpdateSnowflakeSprite(struct Sprite *);
+static bool8 UpdateVisibleSnowflakeSprites(void);
+static bool8 CreateSnowflakeSprite(void);
+static bool8 DestroySnowflakeSprite(void);
+static void InitSnowflakeSpriteMovement(struct Sprite *);
+
void Snow_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = FALSE;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
- gWeatherPtr->unknown_6E5 = 16;
- gWeatherPtr->unknown_6E0 = 0;
+ gWeatherPtr->targetSnowflakeSpriteCount = 16;
+ gWeatherPtr->snowflakeVisibleCounter = 0;
}
-void Snow_Main(void);
-void sub_807ED48(struct Sprite *);
-
void Snow_InitAll(void)
{
+ u16 i;
+
Snow_InitVars();
while (gWeatherPtr->weatherGfxLoaded == FALSE)
{
- u16 i;
-
Snow_Main();
for (i = 0; i < gWeatherPtr->snowflakeSpriteCount; i++)
- {
- sub_807ED48(gWeatherPtr->sprites.s1.snowflakeSprites[i]);
- }
+ UpdateSnowflakeSprite(gWeatherPtr->sprites.s1.snowflakeSprites[i]);
}
}
-u8 snowflakes_progress(void);
-
void Snow_Main(void)
{
- if (gWeatherPtr->initStep == 0 && snowflakes_progress() == FALSE)
+ if (gWeatherPtr->initStep == 0 && !UpdateVisibleSnowflakeSprites())
{
gWeatherPtr->weatherGfxLoaded = TRUE;
gWeatherPtr->initStep++;
@@ -912,143 +803,211 @@ bool8 Snow_Finish(void)
switch (gWeatherPtr->finishStep)
{
case 0:
- gWeatherPtr->unknown_6E5 = 0;
- gWeatherPtr->unknown_6E0 = 0;
+ gWeatherPtr->targetSnowflakeSpriteCount = 0;
+ gWeatherPtr->snowflakeVisibleCounter = 0;
gWeatherPtr->finishStep++;
// fall through
case 1:
- if (snowflakes_progress() == FALSE)
+ if (!UpdateVisibleSnowflakeSprites())
{
gWeatherPtr->finishStep++;
return FALSE;
}
return TRUE;
}
+
return FALSE;
}
-bool8 CreateSnowflakeSprite(void);
-bool8 RemoveSnowflakeSprite(void);
-
-bool8 snowflakes_progress(void)
+static bool8 UpdateVisibleSnowflakeSprites(void)
{
- if (gWeatherPtr->snowflakeSpriteCount == gWeatherPtr->unknown_6E5)
+ if (gWeatherPtr->snowflakeSpriteCount == gWeatherPtr->targetSnowflakeSpriteCount)
return FALSE;
- gWeatherPtr->unknown_6E0++;
- if (gWeatherPtr->unknown_6E0 > 36)
+ if (++gWeatherPtr->snowflakeVisibleCounter > 36)
{
- gWeatherPtr->unknown_6E0 = 0;
- if (gWeatherPtr->snowflakeSpriteCount < gWeatherPtr->unknown_6E5)
+ gWeatherPtr->snowflakeVisibleCounter = 0;
+ if (gWeatherPtr->snowflakeSpriteCount < gWeatherPtr->targetSnowflakeSpriteCount)
CreateSnowflakeSprite();
else
- RemoveSnowflakeSprite();
+ DestroySnowflakeSprite();
}
- return (gWeatherPtr->snowflakeSpriteCount != gWeatherPtr->unknown_6E5);
+
+ return gWeatherPtr->snowflakeSpriteCount != gWeatherPtr->targetSnowflakeSpriteCount;
}
-void sub_807EC40(struct Sprite *);
+static const struct OamData sSnowflakeSpriteOamData =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = SPRITE_SHAPE(8x8),
+ .x = 0,
+ .matrixNum = 0,
+ .size = SPRITE_SIZE(8x8),
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 0,
+ .affineParam = 0,
+};
-bool8 CreateSnowflakeSprite(void)
+static const struct SpriteFrameImage sSnowflakeSpriteImages[] =
{
- u8 spriteId = CreateSpriteAtEnd(&sSnowflakeSpriteTemplate, 0, 0, 78);
+ {gWeatherSnow1Tiles, sizeof(gWeatherSnow1Tiles)},
+ {gWeatherSnow2Tiles, sizeof(gWeatherSnow2Tiles)},
+};
+
+static const union AnimCmd sSnowflakeAnimCmd0[] =
+{
+ ANIMCMD_FRAME(0, 16),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd sSnowflakeAnimCmd1[] =
+{
+ ANIMCMD_FRAME(1, 16),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd *const sSnowflakeAnimCmds[] =
+{
+ sSnowflakeAnimCmd0,
+ sSnowflakeAnimCmd1,
+};
+
+static const struct SpriteTemplate sSnowflakeSpriteTemplate =
+{
+ .tileTag = 0xFFFF,
+ .paletteTag = 0x1200,
+ .oam = &sSnowflakeSpriteOamData,
+ .anims = sSnowflakeAnimCmds,
+ .images = sSnowflakeSpriteImages,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = UpdateSnowflakeSprite,
+};
+#define tPosY data[0]
+#define tDeltaY data[1]
+#define tWaveDelta data[2]
+#define tWaveIndex data[3]
+#define tSnowflakeId data[4]
+#define tFallCounter data[5]
+#define tFallDuration data[6]
+#define tDeltaY2 data[7]
+
+static bool8 CreateSnowflakeSprite(void)
+{
+ u8 spriteId = CreateSpriteAtEnd(&sSnowflakeSpriteTemplate, 0, 0, 78);
if (spriteId == MAX_SPRITES)
return FALSE;
- gSprites[spriteId].data[4] = gWeatherPtr->snowflakeSpriteCount;
- sub_807EC40(&gSprites[spriteId]);
+
+ gSprites[spriteId].tSnowflakeId = gWeatherPtr->snowflakeSpriteCount;
+ InitSnowflakeSpriteMovement(&gSprites[spriteId]);
gSprites[spriteId].coordOffsetEnabled = TRUE;
gWeatherPtr->sprites.s1.snowflakeSprites[gWeatherPtr->snowflakeSpriteCount++] = &gSprites[spriteId];
return TRUE;
}
-bool8 RemoveSnowflakeSprite(void)
+static bool8 DestroySnowflakeSprite(void)
{
- if (gWeatherPtr->snowflakeSpriteCount != 0)
+ if (gWeatherPtr->snowflakeSpriteCount)
{
DestroySprite(gWeatherPtr->sprites.s1.snowflakeSprites[--gWeatherPtr->snowflakeSpriteCount]);
return TRUE;
}
+
return FALSE;
}
-void sub_807EC40(struct Sprite *sprite)
+static void InitSnowflakeSpriteMovement(struct Sprite *sprite)
{
- u16 r4 = ((sprite->data[4] * 5) & 7) * 30 + (Random() % 30);
- u16 r6;
+ u16 rand;
+ u16 x = ((sprite->tSnowflakeId * 5) & 7) * 30 + (Random() % 30);
sprite->pos1.y = -3 - (gSpriteCoordOffsetY + sprite->centerToCornerVecY);
- sprite->pos1.x = r4 - (gSpriteCoordOffsetX + sprite->centerToCornerVecX);
- sprite->data[0] = sprite->pos1.y * 128;
+ sprite->pos1.x = x - (gSpriteCoordOffsetX + sprite->centerToCornerVecX);
+ sprite->tPosY = sprite->pos1.y * 128;
sprite->pos2.x = 0;
- r6 = Random();
- sprite->data[1] = (r6 & 3) * 5 + 64;
- sprite->data[7] = (r6 & 3) * 5 + 64;
- StartSpriteAnim(sprite, (r6 & 1) ? 0 : 1);
- sprite->data[3] = 0;
- sprite->data[2] = ((r6 & 3) == 0) ? 2 : 1;
- sprite->data[6] = (r6 & 0x1F) + 210;
- sprite->data[5] = 0;
+ rand = Random();
+ sprite->tDeltaY = (rand & 3) * 5 + 64;
+ sprite->tDeltaY2 = sprite->tDeltaY;
+ StartSpriteAnim(sprite, (rand & 1) ? 0 : 1);
+ sprite->tWaveIndex = 0;
+ sprite->tWaveDelta = ((rand & 3) == 0) ? 2 : 1;
+ sprite->tFallDuration = (rand & 0x1F) + 210;
+ sprite->tFallCounter = 0;
}
-void sub_807ECEC(struct Sprite *sprite)
+static void WaitSnowflakeSprite(struct Sprite *sprite)
{
if (gWeatherPtr->unknown_6E2 > 18)
{
sprite->invisible = FALSE;
- sprite->callback = sub_807ED48;
- sprite->pos1.y = 0xFA - (gSpriteCoordOffsetY + sprite->centerToCornerVecY);
- sprite->data[0] = sprite->pos1.y * 128;
+ sprite->callback = UpdateSnowflakeSprite;
+ sprite->pos1.y = 250 - (gSpriteCoordOffsetY + sprite->centerToCornerVecY);
+ sprite->tPosY = sprite->pos1.y * 128;
gWeatherPtr->unknown_6E2 = 0;
}
}
-void sub_807ED48(struct Sprite *sprite)
+static void UpdateSnowflakeSprite(struct Sprite *sprite)
{
- s16 r3;
- s16 r2;
+ s16 x;
+ s16 y;
- sprite->data[0] += sprite->data[1];
- sprite->pos1.y = sprite->data[0] >> 7;
- sprite->data[3] = (sprite->data[3] + sprite->data[2]) & 0xFF;
- sprite->pos2.x = gSineTable[sprite->data[3]] / 64;
+ sprite->tPosY += sprite->tDeltaY;
+ sprite->pos1.y = sprite->tPosY >> 7;
+ sprite->tWaveIndex += sprite->tWaveDelta;
+ sprite->tWaveIndex &= 0xFF;
+ sprite->pos2.x = gSineTable[sprite->tWaveIndex] / 64;
- r3 = (sprite->pos1.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX) & 0x1FF;
- if (r3 & 0x100)
- r3 |= -0x100; // hmm... what is this?
- if (r3 < -3)
+ x = (sprite->pos1.x + sprite->centerToCornerVecX + gSpriteCoordOffsetX) & 0x1FF;
+ if (x & 0x100)
+ x |= -0x100;
+
+ if (x < -3)
sprite->pos1.x = 242 - (gSpriteCoordOffsetX + sprite->centerToCornerVecX);
- else if (r3 > 242)
+ else if (x > 242)
sprite->pos1.x = -3 - (gSpriteCoordOffsetX + sprite->centerToCornerVecX);
- r2 = (sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY) & 0xFF;
- if (r2 > 163 && r2 < 171)
+ y = (sprite->pos1.y + sprite->centerToCornerVecY + gSpriteCoordOffsetY) & 0xFF;
+ if (y > 163 && y < 171)
{
sprite->pos1.y = 250 - (gSpriteCoordOffsetY + sprite->centerToCornerVecY);
- sprite->data[0] = sprite->pos1.y * 128;
- sprite->data[5] = 0;
- sprite->data[6] = 220;
+ sprite->tPosY = sprite->pos1.y * 128;
+ sprite->tFallCounter = 0;
+ sprite->tFallDuration = 220;
}
- else if (r2 > 242 && r2 < 250)
+ else if (y > 242 && y < 250)
{
sprite->pos1.y = 163;
- sprite->data[0] = sprite->pos1.y * 128;
- sprite->data[5] = 0;
- sprite->data[6] = 220;
+ sprite->tPosY = sprite->pos1.y * 128;
+ sprite->tFallCounter = 0;
+ sprite->tFallDuration = 220;
sprite->invisible = TRUE;
- sprite->callback = sub_807ECEC;
+ sprite->callback = WaitSnowflakeSprite;
}
- sprite->data[5]++;
- if (sprite->data[5] == sprite->data[6])
+ if (++sprite->tFallCounter == sprite->tFallDuration)
{
- sub_807EC40(sprite);
+ InitSnowflakeSpriteMovement(sprite);
sprite->pos1.y = 250;
sprite->invisible = TRUE;
- sprite->callback = sub_807ECEC;
+ sprite->callback = WaitSnowflakeSprite;
}
}
+#undef tPosY
+#undef tDeltaY
+#undef tWaveDelta
+#undef tWaveIndex
+#undef tSnowflakeId
+#undef tFallCounter
+#undef tFallDuration
+#undef tDeltaY2
+
//------------------------------------------------------------------------------
// Medium Rain
//------------------------------------------------------------------------------
@@ -1057,19 +1016,17 @@ void MedRain_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = FALSE;
- gWeatherPtr->unknown_6D6 = 0;
- gWeatherPtr->unknown_6DB = 4;
- gWeatherPtr->unknown_6DC = 0;
- gWeatherPtr->unknown_6D9 = 16;
+ gWeatherPtr->rainSpriteVisibleCounter = 0;
+ gWeatherPtr->rainSpriteVisibleDelay = 4;
+ gWeatherPtr->isHeavyRain = 0;
+ gWeatherPtr->targetRainSpriteCount = 16;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment
- gWeatherPtr->unknown_6ED = 0;
+ gWeatherPtr->thunderTriggered = 0;
SetRainStrengthFromSoundEffect(SE_T_AME);
}
-void Rain_Main(void);
-
void MedRain_InitAll(void)
{
MedRain_InitVars();
@@ -1081,14 +1038,17 @@ void MedRain_InitAll(void)
// Heavy Rain
//------------------------------------------------------------------------------
+static void UpdateThunderSound(void);
+static void SetThunderCounter(u16);
+
void HeavyRain_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = FALSE;
- gWeatherPtr->unknown_6D6 = 0;
- gWeatherPtr->unknown_6DB = 4;
- gWeatherPtr->unknown_6DC = 1;
- gWeatherPtr->unknown_6D9 = 24;
+ gWeatherPtr->rainSpriteVisibleCounter = 0;
+ gWeatherPtr->rainSpriteVisibleDelay = 4;
+ gWeatherPtr->isHeavyRain = 1;
+ gWeatherPtr->targetRainSpriteCount = 24;
gWeatherPtr->gammaTargetIndex = 3;
gWeatherPtr->gammaStepDelay = 20;
gWeatherPtr->weatherGfxLoaded = FALSE; // duplicate assignment
@@ -1102,9 +1062,6 @@ void HeavyRain_InitAll(void)
Rain_Main();
}
-void UpdateThunderSound(void);
-void SetThunderCounter(u16);
-
void Rain_Main(void)
{
UpdateThunderSound();
@@ -1115,20 +1072,19 @@ void Rain_Main(void)
gWeatherPtr->initStep++;
break;
case 1:
- if (CreateRainSprite())
- break;
- gWeatherPtr->initStep++;
+ if (!CreateRainSprite())
+ gWeatherPtr->initStep++;
break;
case 2:
- if (sub_807E8E8())
- break;
- gWeatherPtr->weatherGfxLoaded = TRUE;
- gWeatherPtr->initStep++;
+ if (!UpdateVisibleRainSprites())
+ {
+ gWeatherPtr->weatherGfxLoaded = TRUE;
+ gWeatherPtr->initStep++;
+ }
break;
case 3:
- if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_CHANGING_WEATHER)
- break;
- gWeatherPtr->initStep = 6;
+ if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_CHANGING_WEATHER)
+ gWeatherPtr->initStep = 6;
break;
case 4:
gWeatherPtr->unknown_6EA = 1;
@@ -1136,9 +1092,8 @@ void Rain_Main(void)
gWeatherPtr->initStep++;
// fall through
case 5:
- if (--gWeatherPtr->unknown_6E6 != 0)
- break;
- gWeatherPtr->initStep++;
+ if (--gWeatherPtr->unknown_6E6 == 0)
+ gWeatherPtr->initStep++;
break;
case 6:
gWeatherPtr->unknown_6EA = 1;
@@ -1153,57 +1108,60 @@ void Rain_Main(void)
sub_80ABC48(19);
if (gWeatherPtr->unknown_6EB == 0 && gWeatherPtr->unknown_6EC == 1)
SetThunderCounter(20);
+
gWeatherPtr->unknown_6E6 = (Random() % 3) + 6;
gWeatherPtr->initStep++;
break;
case 9:
- if (--gWeatherPtr->unknown_6E6 != 0)
- break;
- sub_80ABC48(3);
- gWeatherPtr->unknown_6EA = 1;
- if (--gWeatherPtr->unknown_6EC != 0)
- {
- gWeatherPtr->unknown_6E6 = (Random() % 16) + 60;
- gWeatherPtr->initStep = 10;
- }
- else if (gWeatherPtr->unknown_6EB == 0)
- {
- gWeatherPtr->initStep = 4;
- }
- else
+ if (--gWeatherPtr->unknown_6E6 == 0)
{
- gWeatherPtr->initStep = 11;
+ sub_80ABC48(3);
+ gWeatherPtr->unknown_6EA = 1;
+ if (--gWeatherPtr->unknown_6EC != 0)
+ {
+ gWeatherPtr->unknown_6E6 = (Random() % 16) + 60;
+ gWeatherPtr->initStep = 10;
+ }
+ else if (gWeatherPtr->unknown_6EB == 0)
+ {
+ gWeatherPtr->initStep = 4;
+ }
+ else
+ {
+ gWeatherPtr->initStep = 11;
+ }
}
break;
case 10:
- if (--gWeatherPtr->unknown_6E6 != 0)
- break;
- gWeatherPtr->initStep = 8;
+ if (--gWeatherPtr->unknown_6E6 == 0)
+ gWeatherPtr->initStep = 8;
break;
case 11:
gWeatherPtr->unknown_6E6 = (Random() % 16) + 60;
gWeatherPtr->initStep++;
break;
case 12:
- if (--gWeatherPtr->unknown_6E6 != 0)
- break;
- SetThunderCounter(100);
- sub_80ABC48(19);
- // Why use "% 16" everywhere else and "& 0xF" here. So dumb.
- gWeatherPtr->unknown_6E6 = (Random() & 0xF) + 30;
- gWeatherPtr->initStep++;
+ if (--gWeatherPtr->unknown_6E6 == 0)
+ {
+ SetThunderCounter(100);
+ sub_80ABC48(19);
+ gWeatherPtr->unknown_6E6 = (Random() & 0xF) + 30;
+ gWeatherPtr->initStep++;
+ }
break;
case 13:
- if (--gWeatherPtr->unknown_6E6 != 0)
- break;
- sub_80ABC7C(19, 3, 5);
- gWeatherPtr->initStep++;
+ if (--gWeatherPtr->unknown_6E6 == 0)
+ {
+ sub_80ABC7C(19, 3, 5);
+ gWeatherPtr->initStep++;
+ }
break;
case 14:
- if (gWeatherPtr->palProcessingState != WEATHER_PAL_STATE_IDLE)
- break;
- gWeatherPtr->unknown_6EA = 1;
- gWeatherPtr->initStep = 4;
+ if (gWeatherPtr->palProcessingState == WEATHER_PAL_STATE_IDLE)
+ {
+ gWeatherPtr->unknown_6EA = 1;
+ gWeatherPtr->initStep = 4;
+ }
break;
}
}
@@ -1218,51 +1176,56 @@ bool8 Rain_Finish(void)
// fall through
case 1:
Rain_Main();
- if (gWeatherPtr->unknown_6EA != 0)
+ if (gWeatherPtr->unknown_6EA)
{
if (gWeatherPtr->nextWeather == WEATHER_RAIN_LIGHT
|| gWeatherPtr->nextWeather == WEATHER_RAIN_MED
|| gWeatherPtr->nextWeather == WEATHER_RAIN_HEAVY)
return FALSE;
- gWeatherPtr->unknown_6D9 = 0;
+
+ gWeatherPtr->targetRainSpriteCount = 0;
gWeatherPtr->finishStep++;
}
break;
case 2:
- if (sub_807E8E8())
- break;
- DestroyRainSprites();
- gWeatherPtr->unknown_6ED = 0;
- gWeatherPtr->finishStep++;
- return FALSE;
+ if (!UpdateVisibleRainSprites())
+ {
+ DestroyRainSprites();
+ gWeatherPtr->thunderTriggered = 0;
+ gWeatherPtr->finishStep++;
+ return FALSE;
+ }
+ break;
default:
return FALSE;
}
return TRUE;
}
-void SetThunderCounter(u16 max)
+static void SetThunderCounter(u16 max)
{
- if (gWeatherPtr->unknown_6ED == 0)
+ if (gWeatherPtr->thunderTriggered == 0)
{
gWeatherPtr->thunderCounter = Random() % max;
- gWeatherPtr->unknown_6ED = 1;
+ gWeatherPtr->thunderTriggered = 1;
}
}
-void UpdateThunderSound(void)
+static void UpdateThunderSound(void)
{
- if (gWeatherPtr->unknown_6ED == 1)
+ if (gWeatherPtr->thunderTriggered == 1)
{
if (gWeatherPtr->thunderCounter == 0)
{
if (IsSEPlaying())
return;
+
if (Random() & 1)
PlaySE(SE_T_KAMI);
else
PlaySE(SE_T_KAMI2);
- gWeatherPtr->unknown_6ED = 0;
+
+ gWeatherPtr->thunderTriggered = 0;
}
else
{
@@ -1275,6 +1238,95 @@ void UpdateThunderSound(void)
// Fog 1
//------------------------------------------------------------------------------
+// unused data
+static const u16 unusedData_839AB1C[] = {0, 6, 6, 12, 18, 42, 300, 300};
+
+static const struct OamData gOamData_839AB2C =
+{
+ .y = 0,
+ .affineMode = 0,
+ .objMode = 1,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = SPRITE_SHAPE(64x64),
+ .x = 0,
+ .matrixNum = 0,
+ .size = SPRITE_SIZE(64x64),
+ .tileNum = 0,
+ .priority = 2,
+ .paletteNum = 0,
+ .affineParam = 0,
+};
+
+static const union AnimCmd gSpriteAnim_839AB34[] =
+{
+ ANIMCMD_FRAME(0, 16),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gSpriteAnim_839AB3C[] =
+{
+ ANIMCMD_FRAME(32, 16),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gSpriteAnim_839AB44[] =
+{
+ ANIMCMD_FRAME(64, 16),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gSpriteAnim_839AB4C[] =
+{
+ ANIMCMD_FRAME(96, 16),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gSpriteAnim_839AB54[] =
+{
+ ANIMCMD_FRAME(128, 16),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gSpriteAnim_839AB5C[] =
+{
+ ANIMCMD_FRAME(160, 16),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd *const gSpriteAnimTable_839AB64[] =
+{
+ gSpriteAnim_839AB34,
+ gSpriteAnim_839AB3C,
+ gSpriteAnim_839AB44,
+ gSpriteAnim_839AB4C,
+ gSpriteAnim_839AB54,
+ gSpriteAnim_839AB5C,
+};
+
+static const union AffineAnimCmd gSpriteAffineAnim_839AB7C[] =
+{
+ AFFINEANIMCMD_FRAME(0x200, 0x200, 0, 0),
+ AFFINEANIMCMD_END,
+};
+
+static const union AffineAnimCmd *const gSpriteAffineAnimTable_839AB8C[] =
+{
+ gSpriteAffineAnim_839AB7C,
+};
+
+static void Fog1SpriteCallback(struct Sprite *);
+static const struct SpriteTemplate sFog1SpriteTemplate =
+{
+ .tileTag = 0x1201,
+ .paletteTag = 0x1200,
+ .oam = &gOamData_839AB2C,
+ .anims = gSpriteAnimTable_839AB64,
+ .images = NULL,
+ .affineAnims = gSpriteAffineAnimTable_839AB8C,
+ .callback = Fog1SpriteCallback,
+};
+
void Fog1_Main(void);
static void CreateFog1Sprites(void);
static void DestroyFog1Sprites(void);
@@ -1287,8 +1339,8 @@ void Fog1_InitVars(void)
gWeatherPtr->gammaStepDelay = 20;
if (gWeatherPtr->fog1SpritesCreated == 0)
{
- gWeatherPtr->unknown_6F0 = 0;
- gWeatherPtr->unknown_6F2 = 0;
+ gWeatherPtr->fog1ScrollCounter = 0;
+ gWeatherPtr->fog1ScrollOffset = 0;
gWeatherPtr->fog1ScrollPosX = 0;
Weather_SetBlendCoeffs(0, 16);
}
@@ -1303,11 +1355,11 @@ void Fog1_InitAll(void)
void Fog1_Main(void)
{
- gWeatherPtr->fog1ScrollPosX = (gSpriteCoordOffsetX - gWeatherPtr->unknown_6F2) & 0xFF;
- if (++gWeatherPtr->unknown_6F0 > 3)
+ gWeatherPtr->fog1ScrollPosX = (gSpriteCoordOffsetX - gWeatherPtr->fog1ScrollOffset) & 0xFF;
+ if (++gWeatherPtr->fog1ScrollCounter > 3)
{
- gWeatherPtr->unknown_6F0 = 0;
- gWeatherPtr->unknown_6F2++;
+ gWeatherPtr->fog1ScrollCounter = 0;
+ gWeatherPtr->fog1ScrollOffset++;
}
switch (gWeatherPtr->initStep)
{
@@ -1331,12 +1383,13 @@ void Fog1_Main(void)
bool8 Fog1_Finish(void)
{
- gWeatherPtr->fog1ScrollPosX = (gSpriteCoordOffsetX - gWeatherPtr->unknown_6F2) & 0xFF;
- if (++gWeatherPtr->unknown_6F0 > 3)
+ gWeatherPtr->fog1ScrollPosX = (gSpriteCoordOffsetX - gWeatherPtr->fog1ScrollOffset) & 0xFF;
+ if (++gWeatherPtr->fog1ScrollCounter > 3)
{
- gWeatherPtr->unknown_6F0 = 0;
- gWeatherPtr->unknown_6F2++;
+ gWeatherPtr->fog1ScrollCounter = 0;
+ gWeatherPtr->fog1ScrollOffset++;
}
+
switch (gWeatherPtr->finishStep)
{
case 0:
@@ -1344,9 +1397,8 @@ bool8 Fog1_Finish(void)
gWeatherPtr->finishStep++;
break;
case 1:
- if (!Weather_UpdateBlend())
- break;
- gWeatherPtr->finishStep++;
+ if (Weather_UpdateBlend())
+ gWeatherPtr->finishStep++;
break;
case 2:
DestroyFog1Sprites();
@@ -1358,15 +1410,15 @@ bool8 Fog1_Finish(void)
return TRUE;
}
-#define sprColumn data[0]
+#define tSpriteColumn data[0]
static void Fog1SpriteCallback(struct Sprite *sprite)
{
sprite->pos2.y = (u8)gSpriteCoordOffsetY;
- sprite->pos1.x = gWeatherPtr->fog1ScrollPosX + 32 + sprite->sprColumn * 64;
- if (sprite->pos1.x > 0x10F)
+ sprite->pos1.x = gWeatherPtr->fog1ScrollPosX + 32 + sprite->tSpriteColumn * 64;
+ if (sprite->pos1.x > 271)
{
- sprite->pos1.x = 480 + gWeatherPtr->fog1ScrollPosX - (4 - sprite->sprColumn) * 64;
+ sprite->pos1.x = 480 + gWeatherPtr->fog1ScrollPosX - (4 - sprite->tSpriteColumn) * 64;
sprite->pos1.x &= 0x1FF;
}
}
@@ -1374,21 +1426,24 @@ static void Fog1SpriteCallback(struct Sprite *sprite)
static void CreateFog1Sprites(void)
{
u16 i;
+ u8 spriteId;
+ struct Sprite *sprite;
if (!gWeatherPtr->fog1SpritesCreated)
{
- struct SpriteSheet fog1SpriteSheet = {gWeatherFog1Tiles, sizeof(gWeatherFog1Tiles), 0x1201};
-
+ struct SpriteSheet fog1SpriteSheet = {
+ .data = gWeatherFog1Tiles,
+ .size = sizeof(gWeatherFog1Tiles),
+ .tag = 0x1201,
+ };
LoadSpriteSheet(&fog1SpriteSheet);
- for (i = 0; i < 20; i++)
+ for (i = 0; i < NUM_FOG1_SPRITES; i++)
{
- u8 spriteId = CreateSpriteAtEnd(&sFog1SpriteTemplate, 0, 0, 0xFF);
-
+ spriteId = CreateSpriteAtEnd(&sFog1SpriteTemplate, 0, 0, 0xFF);
if (spriteId != MAX_SPRITES)
{
- struct Sprite *sprite = &gSprites[spriteId];
-
- sprite->sprColumn = i % 5;
+ sprite = &gSprites[spriteId];
+ sprite->tSpriteColumn = i % 5;
sprite->pos1.x = (i % 5) * 64 + 32;
sprite->pos1.y = (i / 5) * 64 + 32;
gWeatherPtr->sprites.s2.fog1Sprites[i] = sprite;
@@ -1398,36 +1453,38 @@ static void CreateFog1Sprites(void)
gWeatherPtr->sprites.s2.fog1Sprites[i] = NULL;
}
}
+
gWeatherPtr->fog1SpritesCreated = TRUE;
}
}
-#undef sprColumn
-
static void DestroyFog1Sprites(void)
{
u16 i;
if (gWeatherPtr->fog1SpritesCreated)
{
- for (i = 0; i < 20; i++)
+ for (i = 0; i < NUM_FOG1_SPRITES; i++)
{
if (gWeatherPtr->sprites.s2.fog1Sprites[i] != NULL)
DestroySprite(gWeatherPtr->sprites.s2.fog1Sprites[i]);
}
+
FreeSpriteTilesByTag(0x1201);
gWeatherPtr->fog1SpritesCreated = 0;
}
}
+#undef tSpriteColumn
+
//------------------------------------------------------------------------------
// Volcanic ash
//------------------------------------------------------------------------------
-void Ash_Main(void);
-void LoadAshSpriteSheet(void);
-void CreateAshSprites(void);
-void DestroyAshSprites(void);
+static void LoadAshSpriteSheet(void);
+static void CreateAshSprites(void);
+static void DestroyAshSprites(void);
+static void UpdateAshSprite(struct Sprite *);
void Ash_InitVars(void)
{
@@ -1439,7 +1496,7 @@ void Ash_InitVars(void)
if (!gWeatherPtr->ashSpritesCreated)
{
Weather_SetBlendCoeffs(0, 16);
- SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(64, 63)); // Those aren't even valid coefficients!
+ SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(64, 63)); // These aren't valid blend coefficients!
}
}
@@ -1452,9 +1509,10 @@ void Ash_InitAll(void)
void Ash_Main(void)
{
- gWeatherPtr->unknown_6FC = gSpriteCoordOffsetX & 0x1FF;
- while (gWeatherPtr->unknown_6FC > 0xEF)
- gWeatherPtr->unknown_6FC -= 0xF0;
+ gWeatherPtr->ashBaseSpritesX = gSpriteCoordOffsetX & 0x1FF;
+ while (gWeatherPtr->ashBaseSpritesX >= 240)
+ gWeatherPtr->ashBaseSpritesX -= 240;
+
switch (gWeatherPtr->initStep)
{
case 0:
@@ -1464,14 +1522,16 @@ void Ash_Main(void)
case 1:
if (!gWeatherPtr->ashSpritesCreated)
CreateAshSprites();
+
Weather_SetTargetBlendCoeffs(16, 0, 1);
gWeatherPtr->initStep++;
break;
case 2:
- if (!Weather_UpdateBlend())
- break;
- gWeatherPtr->weatherGfxLoaded = TRUE;
- gWeatherPtr->initStep++;
+ if (Weather_UpdateBlend())
+ {
+ gWeatherPtr->weatherGfxLoaded = TRUE;
+ gWeatherPtr->initStep++;
+ }
break;
default:
Weather_UpdateBlend();
@@ -1488,10 +1548,11 @@ bool8 Ash_Finish(void)
gWeatherPtr->finishStep++;
break;
case 1:
- if (!Weather_UpdateBlend())
- break;
- DestroyAshSprites();
- gWeatherPtr->finishStep++;
+ if (Weather_UpdateBlend())
+ {
+ DestroyAshSprites();
+ gWeatherPtr->finishStep++;
+ }
break;
case 2:
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
@@ -1503,14 +1564,19 @@ bool8 Ash_Finish(void)
return TRUE;
}
-static const struct SpriteSheet sAshSpriteSheet = {gWeatherAshTiles, sizeof(gWeatherAshTiles), 0x1202};
+static const struct SpriteSheet sAshSpriteSheet =
+{
+ .data = gWeatherAshTiles,
+ .size = sizeof(gWeatherAshTiles),
+ .tag = 0x1202,
+};
-void LoadAshSpriteSheet(void)
+static void LoadAshSpriteSheet(void)
{
LoadSpriteSheet(&sAshSpriteSheet);
}
-const struct OamData gOamData_839ABB8 =
+static const struct OamData sAshSpriteOamData =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -1524,48 +1590,52 @@ const struct OamData gOamData_839ABB8 =
.paletteNum = 15,
};
-const union AnimCmd gSpriteAnim_839ABC0[] =
+static const union AnimCmd sAshSpriteAnimCmd0[] =
{
ANIMCMD_FRAME(0, 60),
ANIMCMD_FRAME(64, 60),
ANIMCMD_JUMP(0),
};
-const union AnimCmd *const gSpriteAnimTable_839ABCC[] =
+static const union AnimCmd *const sAshSpriteAnimCmds[] =
{
- gSpriteAnim_839ABC0,
+ sAshSpriteAnimCmd0,
};
-void sub_807FAA8(struct Sprite *);
static const struct SpriteTemplate sAshSpriteTemplate =
{
.tileTag = 4610,
- .paletteTag = 4608,
- .oam = &gOamData_839ABB8,
- .anims = gSpriteAnimTable_839ABCC,
+ .paletteTag = 0x1200,
+ .oam = &sAshSpriteOamData,
+ .anims = sAshSpriteAnimCmds,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = sub_807FAA8,
+ .callback = UpdateAshSprite,
};
-void CreateAshSprites(void)
+#define tOffsetY data[0]
+#define tCounterY data[1]
+#define tSpriteColumn data[2]
+#define tSpriteRow data[3]
+
+static void CreateAshSprites(void)
{
u8 i;
+ u8 spriteId;
+ struct Sprite *sprite;
if (!gWeatherPtr->ashSpritesCreated)
{
- for (i = 0; i < 20; i++)
+ for (i = 0; i < NUM_ASH_SPRITES; i++)
{
- u8 spriteId = CreateSpriteAtEnd(&sAshSpriteTemplate, 0, 0, 0x4E);
-
+ spriteId = CreateSpriteAtEnd(&sAshSpriteTemplate, 0, 0, 0x4E);
if (spriteId != MAX_SPRITES)
{
- struct Sprite *sprite = &gSprites[spriteId];
-
- sprite->data[1] = 0;
- sprite->data[2] = (u8)(i % 5);
- sprite->data[3] = (u8)(i / 5);
- sprite->data[0] = sprite->data[3] * 64 + 32;
+ sprite = &gSprites[spriteId];
+ sprite->tCounterY = 0;
+ sprite->tSpriteColumn = (u8)(i % 5);
+ sprite->tSpriteRow = (u8)(i / 5);
+ sprite->tOffsetY = sprite->tSpriteRow * 64 + 32;
gWeatherPtr->sprites.s2.ashSprites[i] = sprite;
}
else
@@ -1573,69 +1643,79 @@ void CreateAshSprites(void)
gWeatherPtr->sprites.s2.ashSprites[i] = NULL;
}
}
+
gWeatherPtr->ashSpritesCreated = TRUE;
}
}
-void DestroyAshSprites(void)
+static void DestroyAshSprites(void)
{
u16 i;
if (gWeatherPtr->ashSpritesCreated)
{
- for (i = 0; i < 20; i++)
+ for (i = 0; i < NUM_ASH_SPRITES; i++)
{
if (gWeatherPtr->sprites.s2.ashSprites[i] != NULL)
DestroySprite(gWeatherPtr->sprites.s2.ashSprites[i]);
}
+
FreeSpriteTilesByTag(0x1202);
gWeatherPtr->ashSpritesCreated = FALSE;
}
}
-void sub_807FAA8(struct Sprite *sprite)
+static void UpdateAshSprite(struct Sprite *sprite)
{
- sprite->data[1]++;
- if (sprite->data[1] > 5)
+ if (++sprite->tCounterY > 5)
{
- sprite->data[1] = 0;
- sprite->data[0]++;
+ sprite->tCounterY = 0;
+ sprite->tOffsetY++;
}
- sprite->pos1.y = gSpriteCoordOffsetY + sprite->data[0];
- sprite->pos1.x = gWeatherPtr->unknown_6FC + 32 + sprite->data[2] * 64;
+
+ sprite->pos1.y = gSpriteCoordOffsetY + sprite->tOffsetY;
+ sprite->pos1.x = gWeatherPtr->ashBaseSpritesX + 32 + sprite->tSpriteColumn * 64;
if (sprite->pos1.x > 271)
{
- sprite->pos1.x = gWeatherPtr->unknown_6FC + 0x1E0 - (4 - sprite->data[2]) * 64;
+ sprite->pos1.x = gWeatherPtr->ashBaseSpritesX + 480 - (4 - sprite->tSpriteColumn) * 64;
sprite->pos1.x &= 0x1FF;
}
}
+#undef tOffsetY
+#undef tCounterY
+#undef tSpriteColumn
+#undef tSpriteRow
+
//------------------------------------------------------------------------------
// Fog 2
//------------------------------------------------------------------------------
+static void UpdateFog2Movement(void);
+static void CreateFog2Sprites(void);
+static void DestroyFog2Sprites(void);
+static void UpdateFog2Sprite(struct Sprite *);
+
void Fog2_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = 0;
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
- gWeatherPtr->unknown_6F0 = 0;
- gWeatherPtr->unknown_6F2 = 1;
- if (gWeatherPtr->fog2SpritesCreated == 0)
- {
- gWeatherPtr->unknown_71C = 0;
- gWeatherPtr->unknown_71E = 0;
- gWeatherPtr->unknown_720 = 0;
- gWeatherPtr->unknown_722 = 0;
- gWeatherPtr->unknown_718 = 0;
- gWeatherPtr->unknown_71A = 0;
+ gWeatherPtr->fog1ScrollCounter = 0;
+ gWeatherPtr->fog1ScrollOffset = 1;
+ if (!gWeatherPtr->fog2SpritesCreated)
+ {
+ gWeatherPtr->fog2ScrollXCounter = 0;
+ gWeatherPtr->fog2ScrollYCounter = 0;
+ gWeatherPtr->fog2XOffset = 0;
+ gWeatherPtr->fog2YOffset = 0;
+ gWeatherPtr->fog2BaseSpritesX = 0;
+ gWeatherPtr->fog2PosY = 0;
Weather_SetBlendCoeffs(0, 16);
}
}
-void Fog2_Main(void);
-
void Fog2_InitAll(void)
{
Fog2_InitVars();
@@ -1643,12 +1723,9 @@ void Fog2_InitAll(void)
Fog2_Main();
}
-void sub_807FC9C(void);
-void CreateFog2Sprites(void);
-
void Fog2_Main(void)
{
- sub_807FC9C();
+ UpdateFog2Movement();
switch (gWeatherPtr->initStep)
{
case 0:
@@ -1668,11 +1745,9 @@ void Fog2_Main(void)
}
}
-void DestroyFog2Sprites(void);
-
bool8 Fog2_Finish(void)
{
- sub_807FC9C();
+ UpdateFog2Movement();
switch (gWeatherPtr->finishStep)
{
case 0:
@@ -1694,57 +1769,32 @@ bool8 Fog2_Finish(void)
return TRUE;
}
-void sub_807FC9C(void)
+static void UpdateFog2Movement(void)
{
- if (++gWeatherPtr->unknown_71C > 2)
+ if (++gWeatherPtr->fog2ScrollXCounter > 2)
{
- gWeatherPtr->unknown_720++;
- gWeatherPtr->unknown_71C = 0;
+ gWeatherPtr->fog2XOffset++;
+ gWeatherPtr->fog2ScrollXCounter = 0;
}
- if (++gWeatherPtr->unknown_71E > 4)
+ if (++gWeatherPtr->fog2ScrollYCounter > 4)
{
- gWeatherPtr->unknown_722++;
- gWeatherPtr->unknown_71E = 0;
+ gWeatherPtr->fog2YOffset++;
+ gWeatherPtr->fog2ScrollYCounter = 0;
}
- gWeatherPtr->unknown_718 = (gSpriteCoordOffsetX - gWeatherPtr->unknown_720) & 0xFF;
- gWeatherPtr->unknown_71A = gSpriteCoordOffsetY + gWeatherPtr->unknown_722;
+ gWeatherPtr->fog2BaseSpritesX = (gSpriteCoordOffsetX - gWeatherPtr->fog2XOffset) & 0xFF;
+ gWeatherPtr->fog2PosY = gSpriteCoordOffsetY + gWeatherPtr->fog2YOffset;
}
-extern const struct SpriteTemplate sFog2SpriteTemplate; // defined below
-
-void CreateFog2Sprites(void)
+static const struct SpriteSheet gFog2SpriteSheet =
{
- u16 i;
-
- if (!gWeatherPtr->fog2SpritesCreated)
- {
- struct SpriteSheet fog2SpriteSheet = {gWeatherFog2Tiles, sizeof(gWeatherFog2Tiles), 0x1203};
-
- LoadSpriteSheet(&fog2SpriteSheet);
- for (i = 0; i < 20; i++)
- {
- u8 spriteId = CreateSpriteAtEnd(&sFog2SpriteTemplate, 0, (i / 5) * 64, 0xFF);
-
- if (spriteId != MAX_SPRITES)
- {
- struct Sprite *sprite = &gSprites[spriteId];
-
- sprite->data[0] = i % 5;
- sprite->data[1] = i / 5;
- gWeatherPtr->sprites.s2.fog2Sprites[i] = sprite;
- }
- else
- {
- gWeatherPtr->sprites.s2.fog2Sprites[i] = NULL;
- }
- }
- gWeatherPtr->fog2SpritesCreated = TRUE;
- }
-}
+ .data = gWeatherFog2Tiles,
+ .size = sizeof(gWeatherFog2Tiles),
+ .tag = 0x1203,
+};
-const struct OamData gOamData_839ABF0 =
+static const struct OamData sFog2SpriteOamData =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -1758,103 +1808,146 @@ const struct OamData gOamData_839ABF0 =
.paletteNum = 0,
};
-const union AnimCmd gSpriteAnim_839ABF8[] =
+static const union AnimCmd sFog2SpriteAnimCmd0[] =
{
ANIMCMD_FRAME(0, 16),
ANIMCMD_END,
};
-const union AnimCmd *const gSpriteAnimTable_839AC00[] =
+static const union AnimCmd *const sFog2SpriteAnimCmds[] =
{
- gSpriteAnim_839ABF8,
+ sFog2SpriteAnimCmd0,
};
-void Fog2SpriteCallback(struct Sprite *);
-const struct SpriteTemplate sFog2SpriteTemplate =
+static const struct SpriteTemplate sFog2SpriteTemplate =
{
- .tileTag = 4611,
- .paletteTag = 4608,
- .oam = &gOamData_839ABF0,
- .anims = gSpriteAnimTable_839AC00,
+ .tileTag = 0x1203,
+ .paletteTag = 0x1200,
+ .oam = &sFog2SpriteOamData,
+ .anims = sFog2SpriteAnimCmds,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = Fog2SpriteCallback,
+ .callback = UpdateFog2Sprite,
};
-void DestroyFog2Sprites(void)
+#define tSpriteColumn data[0]
+#define tSpriteRow data[1]
+
+static void CreateFog2Sprites(void)
+{
+ u16 i;
+ struct SpriteSheet fog2SpriteSheet;
+ u8 spriteId;
+ struct Sprite *sprite;
+
+ if (!gWeatherPtr->fog2SpritesCreated)
+ {
+ fog2SpriteSheet = gFog2SpriteSheet;
+ LoadSpriteSheet(&fog2SpriteSheet);
+ for (i = 0; i < NUM_FOG2_SPRITES; i++)
+ {
+ spriteId = CreateSpriteAtEnd(&sFog2SpriteTemplate, 0, (i / 5) * 64, 0xFF);
+ if (spriteId != MAX_SPRITES)
+ {
+ sprite = &gSprites[spriteId];
+ sprite->tSpriteColumn = i % 5;
+ sprite->tSpriteRow = i / 5;
+ gWeatherPtr->sprites.s2.fog2Sprites[i] = sprite;
+ }
+ else
+ {
+ gWeatherPtr->sprites.s2.fog2Sprites[i] = NULL;
+ }
+ }
+
+ gWeatherPtr->fog2SpritesCreated = TRUE;
+ }
+}
+
+static void DestroyFog2Sprites(void)
{
u16 i;
if (gWeatherPtr->fog2SpritesCreated)
{
- for (i = 0; i < 20; i++)
+ for (i = 0; i < NUM_FOG2_SPRITES; i++)
{
- if (gWeatherPtr->sprites.s2.fog2Sprites[i] != NULL)
+ if (gWeatherPtr->sprites.s2.fog2Sprites[i])
DestroySprite(gWeatherPtr->sprites.s2.fog2Sprites[i]);
}
+
FreeSpriteTilesByTag(0x1203);
gWeatherPtr->fog2SpritesCreated = FALSE;
}
}
-void Fog2SpriteCallback(struct Sprite *sprite)
+static void UpdateFog2Sprite(struct Sprite *sprite)
{
- sprite->pos2.y = gWeatherPtr->unknown_71A;
- sprite->pos1.x = gWeatherPtr->unknown_718 + 32 + sprite->data[0] * 64;
+ sprite->pos2.y = gWeatherPtr->fog2PosY;
+ sprite->pos1.x = gWeatherPtr->fog2BaseSpritesX + 32 + sprite->tSpriteColumn * 64;
if (sprite->pos1.x > 271)
{
- sprite->pos1.x = gWeatherPtr->unknown_718 + 0x1E0 - (4 - sprite->data[0]) * 64;
+ sprite->pos1.x = gWeatherPtr->fog2BaseSpritesX + 480 - (4 - sprite->tSpriteColumn) * 64;
sprite->pos1.x &= 0x1FF;
}
}
+#undef tSpriteColumn
+#undef tSpriteRow
+
//------------------------------------------------------------------------------
// Sandstorm
//------------------------------------------------------------------------------
+static void UpdateSandstormWaveIndex(void);
+static void UpdateSandstormMovement(void);
+static void CreateSandstormSprites(void);
+static void CreateSwirlSandstormSprites(void);
+static void DestroySandstormSprites(void);
+static void UpdateSandstormSprite(struct Sprite *);
+static void WaitSandSwirlSpriteEntrance(struct Sprite *);
+static void UpdateSandstormSwirlSprite(struct Sprite *);
+
+#define MIN_SANDSTORM_WAVE_INDEX 0x20
+
void Sandstorm_InitVars(void)
{
gWeatherPtr->initStep = 0;
gWeatherPtr->weatherGfxLoaded = 0;
gWeatherPtr->gammaTargetIndex = 0;
gWeatherPtr->gammaStepDelay = 20;
- if (gWeatherPtr->sandstormSprites1Created == 0)
+ if (!gWeatherPtr->sandstormSpritesCreated)
{
- gWeatherPtr->unknown_704 = gWeatherPtr->unknown_708 = 0;
- gWeatherPtr->unknown_712 = 8;
- gWeatherPtr->unknown_714 = 0;
+ gWeatherPtr->sandstormXOffset = gWeatherPtr->sandstormYOffset = 0;
+ gWeatherPtr->sandstormWaveIndex = 8;
+ gWeatherPtr->sandstormWaveCounter = 0;
// Dead code. How does the compiler not optimize this out?
- if (gWeatherPtr->unknown_712 > 0x5F)
- gWeatherPtr->unknown_712 = 0x80 - gWeatherPtr->unknown_712;
+ if (gWeatherPtr->sandstormWaveIndex >= 0x80 - MIN_SANDSTORM_WAVE_INDEX)
+ gWeatherPtr->sandstormWaveIndex = 0x80 - gWeatherPtr->sandstormWaveIndex;
+
Weather_SetBlendCoeffs(0, 16);
}
}
-void Sandstorm_Main(void);
-
void Sandstorm_InitAll(void)
{
Sandstorm_InitVars();
- while (gWeatherPtr->weatherGfxLoaded == FALSE)
+ while (!gWeatherPtr->weatherGfxLoaded)
Sandstorm_Main();
}
-void sub_808002C(void);
-void sub_8080064(void);
-void CreateSandstormSprites_1(void);
-void CreateSandstormSprites_2(void);
-
void Sandstorm_Main(void)
{
- sub_8080064();
- sub_808002C();
- if (gWeatherPtr->unknown_712 > 0x5F)
- gWeatherPtr->unknown_712 = 32;
+ UpdateSandstormMovement();
+ UpdateSandstormWaveIndex();
+ if (gWeatherPtr->sandstormWaveIndex >= 0x80 - MIN_SANDSTORM_WAVE_INDEX)
+ gWeatherPtr->sandstormWaveIndex = MIN_SANDSTORM_WAVE_INDEX;
+
switch (gWeatherPtr->initStep)
{
case 0:
- CreateSandstormSprites_1();
- CreateSandstormSprites_2();
+ CreateSandstormSprites();
+ CreateSwirlSandstormSprites();
gWeatherPtr->initStep++;
break;
case 1:
@@ -1862,20 +1955,19 @@ void Sandstorm_Main(void)
gWeatherPtr->initStep++;
break;
case 2:
- if (!Weather_UpdateBlend())
- break;
- gWeatherPtr->weatherGfxLoaded = TRUE;
- gWeatherPtr->initStep++;
+ if (Weather_UpdateBlend())
+ {
+ gWeatherPtr->weatherGfxLoaded = TRUE;
+ gWeatherPtr->initStep++;
+ }
break;
}
}
-void sub_80800E4(void);
-
bool8 Sandstorm_Finish(void)
{
- sub_8080064();
- sub_808002C();
+ UpdateSandstormMovement();
+ UpdateSandstormWaveIndex();
switch (gWeatherPtr->finishStep)
{
case 0:
@@ -1883,64 +1975,66 @@ bool8 Sandstorm_Finish(void)
gWeatherPtr->finishStep++;
break;
case 1:
- if (!Weather_UpdateBlend())
- break;
- gWeatherPtr->finishStep++;
+ if (Weather_UpdateBlend())
+ gWeatherPtr->finishStep++;
break;
case 2:
- sub_80800E4();
+ DestroySandstormSprites();
gWeatherPtr->finishStep++;
break;
default:
return FALSE;
}
+
return TRUE;
}
-void sub_808002C(void)
+static void UpdateSandstormWaveIndex(void)
{
- if (gWeatherPtr->unknown_714++ > 4)
+ if (gWeatherPtr->sandstormWaveCounter++ > 4)
{
- gWeatherPtr->unknown_712++;
- gWeatherPtr->unknown_714 = 0;
+ gWeatherPtr->sandstormWaveIndex++;
+ gWeatherPtr->sandstormWaveCounter = 0;
}
}
-void sub_8080064(void)
+static void UpdateSandstormMovement(void)
{
- gWeatherPtr->unknown_704 -= gSineTable[gWeatherPtr->unknown_712] * 4;
- gWeatherPtr->unknown_708 -= gSineTable[gWeatherPtr->unknown_712];
- gWeatherPtr->unknown_70E = (gSpriteCoordOffsetX + (gWeatherPtr->unknown_704 >> 8)) & 0xFF;
- gWeatherPtr->unknown_710 = gSpriteCoordOffsetY + (gWeatherPtr->unknown_708 >> 8);
+ gWeatherPtr->sandstormXOffset -= gSineTable[gWeatherPtr->sandstormWaveIndex] * 4;
+ gWeatherPtr->sandstormYOffset -= gSineTable[gWeatherPtr->sandstormWaveIndex];
+ gWeatherPtr->sandstormBaseSpritesX = (gSpriteCoordOffsetX + (gWeatherPtr->sandstormXOffset >> 8)) & 0xFF;
+ gWeatherPtr->sandstormPosY = gSpriteCoordOffsetY + (gWeatherPtr->sandstormYOffset >> 8);
}
-void sub_80800E4(void)
+static void DestroySandstormSprites(void)
{
u16 i;
- if (gWeatherPtr->sandstormSprites1Created)
+ if (gWeatherPtr->sandstormSpritesCreated)
{
- for (i = 0; i < 20; i++)
+ for (i = 0; i < NUM_SANDSTORM_SPRITES; i++)
{
- if (gWeatherPtr->sprites.s2.sandstormSprites1[i] != NULL)
+ if (gWeatherPtr->sprites.s2.sandstormSprites1[i])
DestroySprite(gWeatherPtr->sprites.s2.sandstormSprites1[i]);
}
- gWeatherPtr->sandstormSprites1Created = FALSE;
+
+ gWeatherPtr->sandstormSpritesCreated = FALSE;
FreeSpriteTilesByTag(0x1204);
}
- if (gWeatherPtr->sandstormSprites2Created)
+ if (gWeatherPtr->sandstormSwirlSpritesCreated)
{
- for (i = 0; i < 5; i++)
+ for (i = 0; i < NUM_SWIRL_SANDSTORM_SPRITES; i++)
{
if (gWeatherPtr->sprites.s2.sandstormSprites2[i] != NULL)
DestroySprite(gWeatherPtr->sprites.s2.sandstormSprites2[i]);
}
- gWeatherPtr->sandstormSprites2Created = FALSE;
+
+ gWeatherPtr->sandstormSwirlSpritesCreated = FALSE;
}
}
-const struct OamData gOamData_839AC1C =
+static const struct OamData sSandstormSpriteOamData =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -1954,142 +2048,162 @@ const struct OamData gOamData_839AC1C =
.paletteNum = 0,
};
-const union AnimCmd gSpriteAnim_839AC24[] =
+static const union AnimCmd sSandstormSpriteAnimCmd0[] =
{
ANIMCMD_FRAME(0, 3),
ANIMCMD_END,
};
-const union AnimCmd gSpriteAnim_839AC2C[] =
+static const union AnimCmd sSandstormSpriteAnimCmd1[] =
{
ANIMCMD_FRAME(64, 3),
ANIMCMD_END,
};
-const union AnimCmd *const gSpriteAnimTable_839AC34[] =
+static const union AnimCmd *const sSandstormSpriteAnimCmds[] =
{
- gSpriteAnim_839AC24,
- gSpriteAnim_839AC2C,
+ sSandstormSpriteAnimCmd0,
+ sSandstormSpriteAnimCmd1,
};
-void SandstormSpriteCallback1(struct Sprite *);
-const struct SpriteTemplate sSandstormSpriteTemplate =
+static const struct SpriteTemplate sSandstormSpriteTemplate =
{
- .tileTag = 4612,
- .paletteTag = 4609,
- .oam = &gOamData_839AC1C,
- .anims = gSpriteAnimTable_839AC34,
+ .tileTag = 0x1204,
+ .paletteTag = 0x1201,
+ .oam = &sSandstormSpriteOamData,
+ .anims = sSandstormSpriteAnimCmds,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = SandstormSpriteCallback1,
+ .callback = UpdateSandstormSprite,
};
-static const struct SpriteSheet sSandstormSpriteSheet = {gWeatherSandstormTiles, sizeof(gWeatherSandstormTiles), 0x1204};
+static const struct SpriteSheet sSandstormSpriteSheet =
+{
+ .data = gWeatherSandstormTiles,
+ .size = sizeof(gWeatherSandstormTiles),
+ .tag = 0x1204,
+};
+
+// Regular sandstorm sprites
+#define tSpriteColumn data[0]
+#define tSpriteRow data[1]
-void CreateSandstormSprites_1(void)
+// Swirly sandstorm sprites
+#define tRadius data[0]
+#define tWaveIndex data[1]
+#define tRadiusCounter data[2]
+#define tEntranceDelay data[3]
+
+static void CreateSandstormSprites(void)
{
u16 i;
+ u8 spriteId;
- if (!gWeatherPtr->sandstormSprites1Created)
+ if (!gWeatherPtr->sandstormSpritesCreated)
{
LoadSpriteSheet(&sSandstormSpriteSheet);
- LoadCustomWeatherSpritePalette(gUnknown_0854C2B0);
- for (i = 0; i < 20; i++)
+ LoadCustomWeatherSpritePalette(gSandstormWeatherPalette);
+ for (i = 0; i < NUM_SANDSTORM_SPRITES; i++)
{
- u8 spriteId = CreateSpriteAtEnd(&sSandstormSpriteTemplate, 0, (i / 5) * 64, 1);
-
+ spriteId = CreateSpriteAtEnd(&sSandstormSpriteTemplate, 0, (i / 5) * 64, 1);
if (spriteId != MAX_SPRITES)
{
gWeatherPtr->sprites.s2.sandstormSprites1[i] = &gSprites[spriteId];
- gWeatherPtr->sprites.s2.sandstormSprites1[i]->data[0] = i % 5;
- gWeatherPtr->sprites.s2.sandstormSprites1[i]->data[1] = i / 5;
+ gWeatherPtr->sprites.s2.sandstormSprites1[i]->tSpriteColumn = i % 5;
+ gWeatherPtr->sprites.s2.sandstormSprites1[i]->tSpriteRow = i / 5;
}
else
{
gWeatherPtr->sprites.s2.sandstormSprites1[i] = NULL;
}
}
- gWeatherPtr->sandstormSprites1Created = TRUE;
+
+ gWeatherPtr->sandstormSpritesCreated = TRUE;
}
}
-const u16 gUnknown_0839AC5C[] = {0, 120, 80, 160, 40, 0};
-
-void SandstormSpriteCallback2(struct Sprite *);
+static const u16 sSwirlEntranceDelays[] = {0, 120, 80, 160, 40, 0};
-void CreateSandstormSprites_2(void)
+static void CreateSwirlSandstormSprites(void)
{
u16 i;
+ u8 spriteId;
- if (!gWeatherPtr->sandstormSprites2Created)
+ if (!gWeatherPtr->sandstormSwirlSpritesCreated)
{
- for (i = 0; i < 5; i++)
+ for (i = 0; i < NUM_SWIRL_SANDSTORM_SPRITES; i++)
{
- u8 spriteId = CreateSpriteAtEnd(&sSandstormSpriteTemplate, i * 48 + 24, 208, 1);
-
+ spriteId = CreateSpriteAtEnd(&sSandstormSpriteTemplate, i * 48 + 24, 208, 1);
if (spriteId != MAX_SPRITES)
{
gWeatherPtr->sprites.s2.sandstormSprites2[i] = &gSprites[spriteId];
gWeatherPtr->sprites.s2.sandstormSprites2[i]->oam.size = 2;
- gWeatherPtr->sprites.s2.sandstormSprites2[i]->data[1] = i * 51;
- gWeatherPtr->sprites.s2.sandstormSprites2[i]->data[0] = 8;
- gWeatherPtr->sprites.s2.sandstormSprites2[i]->data[2] = 0;
- gWeatherPtr->sprites.s2.sandstormSprites2[i]->data[4] = 0x6730;
- gWeatherPtr->sprites.s2.sandstormSprites2[i]->data[3] = gUnknown_0839AC5C[i];
+ gWeatherPtr->sprites.s2.sandstormSprites2[i]->tSpriteRow = i * 51;
+ gWeatherPtr->sprites.s2.sandstormSprites2[i]->tRadius = 8;
+ gWeatherPtr->sprites.s2.sandstormSprites2[i]->tRadiusCounter = 0;
+ gWeatherPtr->sprites.s2.sandstormSprites2[i]->data[4] = 0x6730; // unused value
+ gWeatherPtr->sprites.s2.sandstormSprites2[i]->tEntranceDelay = sSwirlEntranceDelays[i];
StartSpriteAnim(gWeatherPtr->sprites.s2.sandstormSprites2[i], 1);
CalcCenterToCornerVec(gWeatherPtr->sprites.s2.sandstormSprites2[i], 0, 2, 0);
- gWeatherPtr->sprites.s2.sandstormSprites2[i]->callback = SandstormSpriteCallback2;
+ gWeatherPtr->sprites.s2.sandstormSprites2[i]->callback = WaitSandSwirlSpriteEntrance;
}
else
{
gWeatherPtr->sprites.s2.sandstormSprites2[i] = NULL;
}
- gWeatherPtr->sandstormSprites2Created = TRUE;
+
+ gWeatherPtr->sandstormSwirlSpritesCreated = TRUE;
}
}
}
-void SandstormSpriteCallback1(struct Sprite *sprite)
+static void UpdateSandstormSprite(struct Sprite *sprite)
{
- sprite->pos2.y = gWeatherPtr->unknown_710;
- sprite->pos1.x = gWeatherPtr->unknown_70E + 32 + sprite->data[0] * 64;
+ sprite->pos2.y = gWeatherPtr->sandstormPosY;
+ sprite->pos1.x = gWeatherPtr->sandstormBaseSpritesX + 32 + sprite->tSpriteColumn * 64;
if (sprite->pos1.x > 271)
{
- sprite->pos1.x = gWeatherPtr->unknown_70E + 0x1E0 - (4 - sprite->data[0]) * 64;
+ sprite->pos1.x = gWeatherPtr->sandstormBaseSpritesX + 480 - (4 - sprite->tSpriteColumn) * 64;
sprite->pos1.x &= 0x1FF;
}
}
-void SandstormSpriteCallback3(struct Sprite *);
-
-void SandstormSpriteCallback2(struct Sprite *sprite)
+static void WaitSandSwirlSpriteEntrance(struct Sprite *sprite)
{
- if (--sprite->data[3] == -1)
- sprite->callback = SandstormSpriteCallback3;
+ if (--sprite->tEntranceDelay == -1)
+ sprite->callback = UpdateSandstormSwirlSprite;
}
-void SandstormSpriteCallback3(struct Sprite *sprite)
+static void UpdateSandstormSwirlSprite(struct Sprite *sprite)
{
- u32 x;
- u32 y;
+ u32 x, y;
if (--sprite->pos1.y < -48)
{
sprite->pos1.y = 208;
- sprite->data[0] = 4;
+ sprite->tRadius = 4;
}
- x = sprite->data[0] * gSineTable[sprite->data[1]];
- y = sprite->data[0] * gSineTable[sprite->data[1] + 64];
+
+ x = sprite->tRadius * gSineTable[sprite->tWaveIndex];
+ y = sprite->tRadius * gSineTable[sprite->tWaveIndex + 0x40];
sprite->pos2.x = x >> 8;
sprite->pos2.y = y >> 8;
- sprite->data[1] = (sprite->data[1] + 10) & 0xFF;
- if (++sprite->data[2] > 8)
+ sprite->tWaveIndex = (sprite->tWaveIndex + 10) & 0xFF;
+ if (++sprite->tRadiusCounter > 8)
{
- sprite->data[2] = 0;
- sprite->data[0]++;
+ sprite->tRadiusCounter = 0;
+ sprite->tRadius++;
}
}
+#undef tSpriteColumn
+#undef tSpriteRow
+
+#undef tRadius
+#undef tWaveIndex
+#undef tRadiusCounter
+#undef tEntranceDelay
+
//------------------------------------------------------------------------------
// Shade
//------------------------------------------------------------------------------
@@ -2116,165 +2230,172 @@ bool8 Shade_Finish(void)
}
//------------------------------------------------------------------------------
-// Weather 14
+// Bubbles
//------------------------------------------------------------------------------
-const u8 gUnknown_0839AC68[] = {40, 90, 60, 90, 2, 60, 40, 30};
+static void CreateBubbleSprite(u16);
+static void DestroyBubbleSprites(void);
+static void UpdateBubbleSprite(struct Sprite *);
-const struct SpriteSheet gWeatherBubbleSpriteSheet = {gWeatherBubbleTiles, sizeof(gWeatherBubbleTiles), 0x1205};
+static const u8 sBubbleStartDelays[] = {40, 90, 60, 90, 2, 60, 40, 30};
+
+static const struct SpriteSheet sWeatherBubbleSpriteSheet =
+{
+ .data = gWeatherBubbleTiles,
+ .size = sizeof(gWeatherBubbleTiles),
+ .tag = 0x1205,
+};
+
+static const s16 sBubbleStartCoords[][2] =
+{
+ {120, 160},
+ {376, 160},
+ { 40, 140},
+ {296, 140},
+ {180, 130},
+ {436, 130},
+ { 60, 160},
+ {436, 160},
+ {220, 180},
+ {476, 180},
+ { 10, 90},
+ {266, 90},
+ {256, 160},
+};
void Bubbles_InitVars(void)
{
Fog1_InitVars();
- if (gWeatherPtr->unknown_72E == 0)
+ if (!gWeatherPtr->bubblesSpritesCreated)
{
- LoadSpriteSheet(&gWeatherBubbleSpriteSheet);
- gWeatherPtr->unknown_728 = 0;
- gWeatherPtr->unknown_726 = gUnknown_0839AC68[0];
- gWeatherPtr->unknown_72A = 0;
- gWeatherPtr->unknown_72C = 0;
+ LoadSpriteSheet(&sWeatherBubbleSpriteSheet);
+ gWeatherPtr->bubblesDelayIndex = 0;
+ gWeatherPtr->bubblesDelayCounter = sBubbleStartDelays[0];
+ gWeatherPtr->bubblesCoordsIndex = 0;
+ gWeatherPtr->bubblesSpriteCount = 0;
}
}
-void Bubbles_Main(void);
-
void Bubbles_InitAll(void)
{
Bubbles_InitVars();
- while (gWeatherPtr->weatherGfxLoaded == FALSE)
+ while (!gWeatherPtr->weatherGfxLoaded)
Bubbles_Main();
}
-void sub_8080588(u16);
-
void Bubbles_Main(void)
{
Fog1_Main();
- if (++gWeatherPtr->unknown_726 > gUnknown_0839AC68[gWeatherPtr->unknown_728])
+ if (++gWeatherPtr->bubblesDelayCounter > sBubbleStartDelays[gWeatherPtr->bubblesDelayIndex])
{
- gWeatherPtr->unknown_726 = 0;
- if (++gWeatherPtr->unknown_728 > 7)
- gWeatherPtr->unknown_728 = 0;
- sub_8080588(gWeatherPtr->unknown_72A);
- if (++gWeatherPtr->unknown_72A > 12)
- gWeatherPtr->unknown_72A = 0;
+ gWeatherPtr->bubblesDelayCounter = 0;
+ if (++gWeatherPtr->bubblesDelayIndex > ARRAY_COUNT(sBubbleStartDelays) - 1)
+ gWeatherPtr->bubblesDelayIndex = 0;
+
+ CreateBubbleSprite(gWeatherPtr->bubblesCoordsIndex);
+ if (++gWeatherPtr->bubblesCoordsIndex > ARRAY_COUNT(sBubbleStartCoords) - 1)
+ gWeatherPtr->bubblesCoordsIndex = 0;
}
}
-void sub_8080610(void);
-
bool8 Bubbles_Finish(void)
{
if (!Fog1_Finish())
{
- sub_8080610();
+ DestroyBubbleSprites();
return FALSE;
}
+
return TRUE;
}
-const s16 gUnknown_0839AC78[][2] =
-{
- {120, 160},
- {376, 160},
- { 40, 140},
- {296, 140},
- {180, 130},
- {436, 130},
- { 60, 160},
- {436, 160},
- {220, 180},
- {476, 180},
- { 10, 90},
- {266, 90},
- {256, 160},
-};
-
-const union AnimCmd gSpriteAnim_839ACAC[] =
+static const union AnimCmd sBubbleSpriteAnimCmd0[] =
{
ANIMCMD_FRAME(0, 16),
ANIMCMD_FRAME(1, 16),
ANIMCMD_END,
};
-const union AnimCmd *const gSpriteAnimTable_839ACB8[] =
+static const union AnimCmd *const sBubbleSpriteAnimCmds[] =
{
- gSpriteAnim_839ACAC,
+ sBubbleSpriteAnimCmd0,
};
-extern const struct OamData gUnknown_08524904;
-
-void unc_0807DAB4(struct Sprite *);
-const struct SpriteTemplate gSpriteTemplate_839ACBC =
+static const struct SpriteTemplate sBubbleSpriteTemplate =
{
- .tileTag = 4613,
- .paletteTag = 4608,
+ .tileTag = 0x1205,
+ .paletteTag = 0x1200,
.oam = &gUnknown_08524904,
- .anims = gSpriteAnimTable_839ACB8,
+ .anims = sBubbleSpriteAnimCmds,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
- .callback = unc_0807DAB4,
+ .callback = UpdateBubbleSprite,
};
-void sub_8080588(u16 a)
-{
- s16 x = gUnknown_0839AC78[a][0];
- s16 y = gUnknown_0839AC78[a][1] - gSpriteCoordOffsetY;
- u8 spriteId = CreateSpriteAtEnd(
- &gSpriteTemplate_839ACBC,
- x,
- y,
- 0);
+#define tScrollXCounter data[0]
+#define tScrollXDir data[1]
+#define tCounter data[2]
+static void CreateBubbleSprite(u16 coordsIndex)
+{
+ s16 x = sBubbleStartCoords[coordsIndex][0];
+ s16 y = sBubbleStartCoords[coordsIndex][1] - gSpriteCoordOffsetY;
+ u8 spriteId = CreateSpriteAtEnd(&sBubbleSpriteTemplate, x, y, 0);
if (spriteId != MAX_SPRITES)
{
gSprites[spriteId].oam.priority = 1;
gSprites[spriteId].coordOffsetEnabled = TRUE;
- gSprites[spriteId].data[0] = 0;
- gSprites[spriteId].data[1] = 0;
- gSprites[spriteId].data[2] = 0;
- gWeatherPtr->unknown_72C++;
+ gSprites[spriteId].tScrollXCounter = 0;
+ gSprites[spriteId].tScrollXDir = 0;
+ gSprites[spriteId].tCounter = 0;
+ gWeatherPtr->bubblesSpriteCount++;
}
}
-void sub_8080610(void)
+static void DestroyBubbleSprites(void)
{
u16 i;
- if (gWeatherPtr->unknown_72C != 0)
+ if (gWeatherPtr->bubblesSpriteCount)
{
- for (i = 0; i < 64; i++)
+ for (i = 0; i < MAX_SPRITES; i++)
{
- if (gSprites[i].template == &gSpriteTemplate_839ACBC)
+ if (gSprites[i].template == &sBubbleSpriteTemplate)
DestroySprite(&gSprites[i]);
}
+
FreeSpriteTilesByTag(0x1205);
- gWeatherPtr->unknown_72C = 0;
+ gWeatherPtr->bubblesSpriteCount = 0;
}
}
-void unc_0807DAB4(struct Sprite *sprite)
+static void UpdateBubbleSprite(struct Sprite *sprite)
{
- ++sprite->data[0];
- if (++sprite->data[0] > 8) // double increment
+ ++sprite->tScrollXCounter;
+ if (++sprite->tScrollXCounter > 8) // double increment
{
- sprite->data[0] = 0;
- if (sprite->data[1] == 0)
+ sprite->tScrollXCounter = 0;
+ if (sprite->tScrollXDir == 0)
{
if (++sprite->pos2.x > 4)
- sprite->data[1] = 1;
+ sprite->tScrollXDir = 1;
}
else
{
if (--sprite->pos2.x <= 0)
- sprite->data[1] = 0;
+ sprite->tScrollXDir = 0;
}
}
+
sprite->pos1.y -= 3;
- if (++sprite->data[2] > 0x77)
+ if (++sprite->tCounter >= 120)
DestroySprite(sprite);
}
+#undef tScrollXCounter
+#undef tScrollXDir
+#undef tCounter
+
//------------------------------------------------------------------------------
// Unused function.
diff --git a/src/ghost.c b/src/ghost.c
index 998be0caa..97b86aa76 100644
--- a/src/ghost.c
+++ b/src/ghost.c
@@ -87,7 +87,7 @@ const union AffineAnimCmd *const gUnknown_08596D54[] =
gUnknown_08596D44,
};
-const struct SpriteTemplate gUnknown_08596D58 =
+const struct SpriteTemplate gShadowBallSpriteTemplate =
{
.tileTag = ANIM_TAG_SHADOW_BALL,
.paletteTag = ANIM_TAG_SHADOW_BALL,
@@ -261,20 +261,20 @@ static void sub_81116E8(struct Sprite *sprite)
AnimTranslateLinear(sprite);
sprite->pos2.x += Sin(sprite->data[5], 10);
sprite->pos2.y += Cos(sprite->data[5], 15);
-
+
r2 = sprite->data[5];
sprite->data[5] = (sprite->data[5] + 5) & 0xFF;
r0 = sprite->data[5];
-
+
if (r2 == 0 || r2 > 196)
{
if (r0 > 0)
PlaySE(SE_W109);
}
-
+
if (sprite->data[6] == 0)
{
- sprite->invisible = TRUE;
+ sprite->invisible = TRUE;
sprite->callback = DestroyAnimSpriteAndDisableBlend;
}
else
@@ -283,18 +283,18 @@ static void sub_81116E8(struct Sprite *sprite)
static void sub_8111764(struct Sprite *sprite)
{
-
- s16 r0;
+
+ s16 r0;
if (sprite->data[6] > 0xFF)
{
if (++sprite->data[6] == 0x10d)
sprite->data[6] = 0;
return;
}
-
+
r0 = sprite->data[7];
sprite->data[7]++;
-
+
if ((r0 & 0xFF) == 0)
{
sprite->data[7] &= 0xff00;
@@ -392,16 +392,16 @@ static void sub_811196C(u8 taskId)
}
}
-// Spins a sprite towards the target, pausing in the middle.
-// Used in Shadow Ball.
+// Spins a sprite towards the target, pausing in the middle.
+// Used in Shadow Ball.
// arg 0: duration step 1 (attacker -> center)
// arg 1: duration step 2 (spin center)
// arg 2: duration step 3 (center -> target)
static void InitAnimShadowBall(struct Sprite *sprite)
{
- u16 r5, r6;
- r5 = sprite->pos1.x;
- r6 = sprite->pos1.y;
+ s16 oldPosX = sprite->pos1.x;
+ s16 oldPosY = sprite->pos1.y;
+
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3);
sprite->data[0] = 0;
@@ -410,8 +410,8 @@ static void InitAnimShadowBall(struct Sprite *sprite)
sprite->data[3] = gBattleAnimArgs[2];
sprite->data[4] = sprite->pos1.x << 4;
sprite->data[5] = sprite->pos1.y << 4;
- sprite->data[6] = (((s16)r5 - sprite->pos1.x) << 4) / (gBattleAnimArgs[0] << 1);
- sprite->data[7] = (((s16)r6 - sprite->pos1.y) << 4) / (gBattleAnimArgs[0] << 1);
+ sprite->data[6] = ((oldPosX - sprite->pos1.x) << 4) / (gBattleAnimArgs[0] << 1);
+ sprite->data[7] = ((oldPosY - sprite->pos1.y) << 4) / (gBattleAnimArgs[0] << 1);
sprite->callback = AnimShadowBallStep;
}
@@ -465,50 +465,57 @@ static void sub_8111B9C(struct Sprite *sprite)
sprite->callback = sub_8111BB4;
}
-static void sub_8111BB4(struct Sprite *sprite) {
-
- s8 r5 = FALSE;
+static void sub_8111BB4(struct Sprite *sprite)
+{
+ bool8 r5 = FALSE;
bool8 r6 = FALSE;
- if(sprite->animEnded)
+
+ if (sprite->animEnded)
{
- if(!(sprite->invisible))
- sprite->invisible=TRUE;
- switch(sprite->data[0])
+ if (!sprite->invisible)
+ sprite->invisible = TRUE;
+
+ switch (sprite->data[0])
{
- case 0:
- if((sprite->data[1]) != 2)
- break;
- goto loc_08111C06;
- case 1:
- if((sprite->data[1]) == 4)
- r5 = TRUE;
- break;
- default:
- r6 = TRUE;
+ default:
+ r6 = TRUE;
+ break;
+ case 0:
+ if (sprite->data[1] == 2)
+ r5 = TRUE;
+ break;
+ case 1:
+ if (sprite->data[1] == 4)
+ r5 = TRUE;
+ break;
}
- if(r5)
+
+ if (r5)
{
- loc_08111C06:
sprite->invisible ^= 1;
sprite->data[2]++;
sprite->data[1] = 0;
- if(sprite->data[2] == 5)
+ if (sprite->data[2] == 5)
{
sprite->data[2] = 0;
sprite->data[0]++;
}
}
- else if(r6)
+ else if (r6)
+ {
DestroyAnimSprite(sprite);
+ }
else
+ {
sprite->data[1]++;
+ }
}
}
void sub_8111C50(u8 taskId)
{
struct Task *task;
-
+
task = &gTasks[taskId];
task->data[0] = CloneBattlerSpriteWithBlend(1);
if (task->data[0] < 0)
@@ -523,7 +530,7 @@ void sub_8111C50(u8 taskId)
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[2], task->data[3]));
gSprites[task->data[0]].data[0] = 80;
- if (GetBattlerSide(gBattleAnimTarget) == 0)
+ if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
{
gSprites[task->data[0]].data[1] = -144;
gSprites[task->data[0]].data[2] = 112;
@@ -573,6 +580,7 @@ static void sub_8111D78(u8 taskId)
break;
case 2:
DestroyAnimVisualTask(taskId);
+ break;
}
}
@@ -595,7 +603,7 @@ static void sub_8111E78(u8 taskId)
switch (task->data[15])
{
case 0:
- task->data[14] = AllocSpritePalette(0x2771);
+ task->data[14] = AllocSpritePalette(ANIM_TAG_BENT_SPOON);
if (task->data[14] == 0xFF || task->data[14] == 0xF)
{
DestroyAnimVisualTask(taskId);
@@ -605,7 +613,7 @@ static void sub_8111E78(u8 taskId)
task->data[0] = CloneBattlerSpriteWithBlend(1);
if (task->data[0] < 0)
{
- FreeSpritePaletteByTag(0x2771);
+ FreeSpritePaletteByTag(ANIM_TAG_BENT_SPOON);
DestroyAnimVisualTask(taskId);
}
else
@@ -698,14 +706,14 @@ static void sub_81120DC(u8 taskId)
static void sub_8112170(u8 taskId)
{
struct Task *task = &gTasks[taskId];
- u8 position = GetBattlerSpriteBGPriorityRank(gBattleAnimTarget);
+ u8 rank = GetBattlerSpriteBGPriorityRank(gBattleAnimTarget);
switch (task->data[15])
{
case 0:
gScanlineEffect.state = 3;
task->data[14] = GetAnimBattlerSpriteId(1);
- if (position == 1)
+ if (rank == 1)
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG1_ON);
else
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
@@ -714,12 +722,12 @@ static void sub_8112170(u8 taskId)
BlendPalette(task->data[4], 16, 0, RGB(13, 0, 15));
break;
case 2:
- gSprites[task->data[14]].invisible = 1;
+ gSprites[task->data[14]].invisible = TRUE;
obj_delete_but_dont_free_vram(&gSprites[task->data[0]]);
- FreeSpritePaletteByTag(0x2771);
+ FreeSpritePaletteByTag(ANIM_TAG_BENT_SPOON);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
- if (position == 1)
+ if (rank == 1)
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG1_ON);
else
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
@@ -886,7 +894,7 @@ static void sub_81125E0(u8 taskId)
}
}
}
-
+
if (task->data[10])
task->data[10]--;
else if (task->data[6])
@@ -1081,7 +1089,7 @@ static void sub_8112ACC(struct Sprite *sprite)
if (sprite->data[0] == 0)
{
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
- SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0));
+ SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
sprite->data[0]++;
sprite->data[1] = 0;
sprite->data[2] = 0;
@@ -1120,7 +1128,7 @@ static void sub_8112B78(struct Sprite *sprite)
sprite->pos2.x = Sin(sprite->data[0], 12);
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
sprite->pos2.x = -sprite->pos2.x;
-
+
sprite->data[0] = (sprite->data[0] + 6) & 0xFF;
sprite->data[1] += 0x100;
sprite->pos2.y = -(sprite->data[1] >> 8);
diff --git a/src/link_rfu.c b/src/link_rfu.c
index 1e4c9c7e6..7c55df783 100644
--- a/src/link_rfu.c
+++ b/src/link_rfu.c
@@ -3674,7 +3674,7 @@ void sub_8010168(void)
gUnknown_03005000.unk_00 = sub_8010148;
}
-void sub_8010198(void)
+void LinkRfu_FatalError(void)
{
sub_800D630();
gUnknown_03005000.unk_ce4 = 1;
diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c
index ddd3f931e..8bb9cb6e4 100644
--- a/src/mauville_old_man.c
+++ b/src/mauville_old_man.c
@@ -1193,7 +1193,7 @@ static void Task_StoryListMenu(u8 taskId) // Task_StoryListMenu
gSpecialVar_Result = 1;
sSelectedStory = selection;
}
- sub_80E2A78(sStorytellerWindowId);
+ ClearToTransparentAndRemoveWindow(sStorytellerWindowId);
DestroyTask(taskId);
EnableBothScriptContexts();
break;
diff --git a/src/menu.c b/src/menu.c
index 958788b25..b766b1b86 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -43,8 +43,8 @@ struct Menu
u8 fontId;
u8 optionWidth;
u8 optionHeight;
- u8 horizontalCount;
- u8 verticalCount;
+ u8 columns;
+ u8 rows;
bool8 APressMuted;
};
@@ -1283,8 +1283,8 @@ u8 sub_8198F58(u8 windowId, u8 fontId, u8 left, u8 top, u8 a4, u8 cursorHeight,
sMenu.fontId = fontId;
sMenu.optionWidth = a4;
sMenu.optionHeight = cursorHeight;
- sMenu.horizontalCount = a6;
- sMenu.verticalCount = a7;
+ sMenu.columns = a6;
+ sMenu.rows = a7;
pos = a9;
@@ -1308,16 +1308,16 @@ void sub_8199060(u8 oldCursorPos, u8 newCursorPos)
{
u8 cursorWidth = GetMenuCursorDimensionByFont(sMenu.fontId, 0);
u8 cursorHeight = GetMenuCursorDimensionByFont(sMenu.fontId, 1);
- u8 xPos = (oldCursorPos % sMenu.horizontalCount) * sMenu.optionWidth + sMenu.left;
- u8 yPos = (oldCursorPos / sMenu.horizontalCount) * sMenu.optionHeight + sMenu.top;
+ u8 xPos = (oldCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left;
+ u8 yPos = (oldCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top;
FillWindowPixelRect(sMenu.windowId,
PIXEL_FILL(1),
xPos,
yPos,
cursorWidth,
cursorHeight);
- xPos = (newCursorPos % sMenu.horizontalCount) * sMenu.optionWidth + sMenu.left;
- yPos = (newCursorPos / sMenu.horizontalCount) * sMenu.optionHeight + sMenu.top;
+ xPos = (newCursorPos % sMenu.columns) * sMenu.optionWidth + sMenu.left;
+ yPos = (newCursorPos / sMenu.columns) * sMenu.optionHeight + sMenu.top;
AddTextPrinterParameterized(sMenu.windowId,
sMenu.fontId,
gText_SelectorArrow3,
@@ -1333,13 +1333,13 @@ u8 sub_8199134(s8 deltaX, s8 deltaY)
if (deltaX != 0)
{
- if ((sMenu.cursorPos % sMenu.horizontalCount) + deltaX < 0)
+ if ((sMenu.cursorPos % sMenu.columns) + deltaX < 0)
{
- sMenu.cursorPos += sMenu.horizontalCount - 1;
+ sMenu.cursorPos += sMenu.columns - 1;
}
- else if ((sMenu.cursorPos % sMenu.horizontalCount) + deltaX >= sMenu.horizontalCount)
+ else if ((sMenu.cursorPos % sMenu.columns) + deltaX >= sMenu.columns)
{
- sMenu.cursorPos = (sMenu.cursorPos / sMenu.horizontalCount) * sMenu.horizontalCount;
+ sMenu.cursorPos = (sMenu.cursorPos / sMenu.columns) * sMenu.columns;
}
else
{
@@ -1349,17 +1349,17 @@ u8 sub_8199134(s8 deltaX, s8 deltaY)
if (deltaY != 0)
{
- if ((sMenu.cursorPos / sMenu.horizontalCount) + deltaY < 0)
+ if ((sMenu.cursorPos / sMenu.columns) + deltaY < 0)
{
- sMenu.cursorPos += sMenu.horizontalCount * (sMenu.verticalCount - 1);
+ sMenu.cursorPos += sMenu.columns * (sMenu.rows - 1);
}
- else if ((sMenu.cursorPos / sMenu.horizontalCount) + deltaY >= sMenu.verticalCount)
+ else if ((sMenu.cursorPos / sMenu.columns) + deltaY >= sMenu.rows)
{
- sMenu.cursorPos -= sMenu.horizontalCount * (sMenu.verticalCount - 1);
+ sMenu.cursorPos -= sMenu.columns * (sMenu.rows - 1);
}
else
{
- sMenu.cursorPos += (sMenu.horizontalCount * deltaY);
+ sMenu.cursorPos += (sMenu.columns * deltaY);
}
}
@@ -1381,8 +1381,8 @@ u8 sub_81991F8(s8 deltaX, s8 deltaY)
if (deltaX != 0)
{
- if (((sMenu.cursorPos % sMenu.horizontalCount) + deltaX >= 0) &&
- ((sMenu.cursorPos % sMenu.horizontalCount) + deltaX < sMenu.horizontalCount))
+ if (((sMenu.cursorPos % sMenu.columns) + deltaX >= 0) &&
+ ((sMenu.cursorPos % sMenu.columns) + deltaX < sMenu.columns))
{
sMenu.cursorPos += deltaX;
}
@@ -1390,10 +1390,10 @@ u8 sub_81991F8(s8 deltaX, s8 deltaY)
if (deltaY != 0)
{
- if (((sMenu.cursorPos / sMenu.horizontalCount) + deltaY >= 0) &&
- ((sMenu.cursorPos / sMenu.horizontalCount) + deltaY < sMenu.verticalCount))
+ if (((sMenu.cursorPos / sMenu.columns) + deltaY >= 0) &&
+ ((sMenu.cursorPos / sMenu.columns) + deltaY < sMenu.rows))
{
- sMenu.cursorPos += (sMenu.horizontalCount * deltaY);
+ sMenu.cursorPos += (sMenu.columns * deltaY);
}
}
@@ -1661,16 +1661,14 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sYesNoWindowId, 2, initialCursorPos);
}
-void sub_81997AC(u8 windowId, u8 a4, u8 a6, u8 a7, const struct MenuAction *strs)
+void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 columns, u8 rows, const struct MenuAction *strs)
{
- u32 i;
- u32 j;
- for (i = 0; i < a7; i++)
+ u32 i, j;
+
+ for (i = 0; i < rows; i++)
{
- for (j = 0; j < a6; j++)
- {
- AddTextPrinterParameterized(windowId, 1, strs[(i * a6) + j].text, (a4 * j) + 8, (i * 16) + 1, 0xFF, NULL);
- }
+ for (j = 0; j < columns; j++)
+ AddTextPrinterParameterized(windowId, 1, strs[(i * columns) + j].text, (optionWidth * j) + 8, (i * 16) + 1, 0xFF, NULL);
}
CopyWindowToVram(windowId, 2);
}
@@ -1706,20 +1704,20 @@ void sub_819983C(u8 windowId, u8 a4, u8 itemCount, u8 itemCount2, const struct M
CopyWindowToVram(windowId, 2);
}
-u8 sub_8199944(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, u8 initialCursorPos)
+u8 sub_8199944(u8 windowId, u8 optionWidth, u8 columns, u8 rows, u8 initialCursorPos)
{
s32 pos;
sMenu.left = 0;
sMenu.top = 1;
sMenu.minCursorPos = 0;
- sMenu.maxCursorPos = (horizontalCount * verticalCount) - 1;
+ sMenu.maxCursorPos = (columns * rows) - 1;
sMenu.windowId = windowId;
sMenu.fontId = 1;
sMenu.optionWidth = optionWidth;
sMenu.optionHeight = 16;
- sMenu.horizontalCount = horizontalCount;
- sMenu.verticalCount = verticalCount;
+ sMenu.columns = columns;
+ sMenu.rows = rows;
pos = initialCursorPos;
diff --git a/src/mevent2.c b/src/mevent2.c
index 4174c4055..f36e5d06b 100755
--- a/src/mevent2.c
+++ b/src/mevent2.c
@@ -15,8 +15,8 @@ static EWRAM_DATA bool32 gUnknown_02022C70 = FALSE;
static void sub_801B180(void);
static void s_DestroyWonderNews(void);
-static bool32 sub_801B114(const struct MEventBuffer_3120_Sub *data);
-static bool32 sub_801B2CC(const struct MEventBuffer_32E0_Sub *data);
+static bool32 sub_801B114(const struct WonderNews *data);
+static bool32 sub_801B2CC(const struct WonderCard *data);
static void sub_801B330(void);
static void sub_801B368(void);
static void sub_801B9F8(void);
@@ -29,14 +29,14 @@ void sub_801AFD8(void)
sub_811F8BC();
}
-struct MEventBuffer_3120_Sub *sav1_get_mevent_buffer_0(void)
+struct WonderNews *GetSavedWonderNews(void)
{
- return &gSaveBlock1Ptr->unk_322C.buffer_000.data;
+ return &gSaveBlock1Ptr->unk_322C.wonderNews.data;
}
-struct MEventBuffer_32E0_Sub *sav1_get_mevent_buffer_1(void)
+struct WonderCard *GetSavedWonderCard(void)
{
- return &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ return &gSaveBlock1Ptr->unk_322C.wonderCard.data;
}
struct MEventBuffer_3430_Sub *sav1_get_mevent_buffer_2(void)
@@ -59,28 +59,28 @@ void DestroyWonderNews(void)
s_DestroyWonderNews();
}
-bool32 sub_801B078(const struct MEventBuffer_3120_Sub *src)
+bool32 sub_801B078(const struct WonderNews *src)
{
if (!sub_801B114(src))
return FALSE;
s_DestroyWonderNews();
- gSaveBlock1Ptr->unk_322C.buffer_000.data = *src;
- gSaveBlock1Ptr->unk_322C.buffer_000.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_000.data, sizeof(struct MEventBuffer_3120_Sub));
+ gSaveBlock1Ptr->unk_322C.wonderNews.data = *src;
+ gSaveBlock1Ptr->unk_322C.wonderNews.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderNews.data, sizeof(struct WonderNews));
return TRUE;
}
bool32 ValidateReceivedWonderNews(void)
{
- if (CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_000.data, sizeof(struct MEventBuffer_3120_Sub)) != gSaveBlock1Ptr->unk_322C.buffer_000.crc)
+ if (CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderNews.data, sizeof(struct WonderNews)) != gSaveBlock1Ptr->unk_322C.wonderNews.crc)
return FALSE;
- if (!sub_801B114(&gSaveBlock1Ptr->unk_322C.buffer_000.data))
+ if (!sub_801B114(&gSaveBlock1Ptr->unk_322C.wonderNews.data))
return FALSE;
return TRUE;
}
-static bool32 sub_801B114(const struct MEventBuffer_3120_Sub *data)
+static bool32 sub_801B114(const struct WonderNews *data)
{
if (data->unk_00 == 0)
return FALSE;
@@ -90,7 +90,7 @@ static bool32 sub_801B114(const struct MEventBuffer_3120_Sub *data)
bool32 WonderNews_Test_Unk_02(void)
{
- const struct MEventBuffer_3120_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_000.data;
+ const struct WonderNews *data = &gSaveBlock1Ptr->unk_322C.wonderNews.data;
if (data->unk_02 == 0)
return FALSE;
@@ -99,8 +99,8 @@ bool32 WonderNews_Test_Unk_02(void)
static void s_DestroyWonderNews(void)
{
- CpuFill32(0, sav1_get_mevent_buffer_0(), sizeof(gSaveBlock1Ptr->unk_322C.buffer_000.data));
- gSaveBlock1Ptr->unk_322C.buffer_000.crc = 0;
+ CpuFill32(0, GetSavedWonderNews(), sizeof(gSaveBlock1Ptr->unk_322C.wonderNews.data));
+ gSaveBlock1Ptr->unk_322C.wonderNews.crc = 0;
}
static void sub_801B180(void)
@@ -111,12 +111,12 @@ static void sub_801B180(void)
bool32 sub_801B1A4(const u8 *src)
{
- const u8 *r5 = (const u8 *)&gSaveBlock1Ptr->unk_322C.buffer_000.data;
+ const u8 *r5 = (const u8 *)&gSaveBlock1Ptr->unk_322C.wonderNews.data;
u32 i;
if (!ValidateReceivedWonderNews())
return FALSE;
- for (i = 0; i < sizeof(struct MEventBuffer_3120_Sub); i++)
+ for (i = 0; i < sizeof(struct WonderNews); i++)
{
if (r5[i] != src[i])
return FALSE;
@@ -136,35 +136,35 @@ void DestroyWonderCard(void)
ClearEReaderTrainer(&gSaveBlock2Ptr->frontier.ereaderTrainer);
}
-bool32 sub_801B21C(const struct MEventBuffer_32E0_Sub *data)
+bool32 sub_801B21C(const struct WonderCard *data)
{
struct MEventBuffer_3430_Sub *r2;
- struct MEventBuffer_32E0_Sub *r1;
+ struct WonderCard *r1;
if (!sub_801B2CC(data))
return FALSE;
DestroyWonderCard();
- memcpy(&gSaveBlock1Ptr->unk_322C.buffer_1c0.data, data, sizeof(struct MEventBuffer_32E0_Sub));
- gSaveBlock1Ptr->unk_322C.buffer_1c0.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub));
+ memcpy(&gSaveBlock1Ptr->unk_322C.wonderCard.data, data, sizeof(struct WonderCard));
+ gSaveBlock1Ptr->unk_322C.wonderCard.crc = CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderCard.data, sizeof(struct WonderCard));
r2 = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
- r1 = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ r1 = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
r2->unk_06 = r1->unk_02;
return TRUE;
}
bool32 ValidateReceivedWonderCard(void)
{
- if (gSaveBlock1Ptr->unk_322C.buffer_1c0.crc != CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub)))
+ if (gSaveBlock1Ptr->unk_322C.wonderCard.crc != CalcCRC16WithTable((void *)&gSaveBlock1Ptr->unk_322C.wonderCard.data, sizeof(struct WonderCard)))
return FALSE;
- if (!sub_801B2CC(&gSaveBlock1Ptr->unk_322C.buffer_1c0.data))
+ if (!sub_801B2CC(&gSaveBlock1Ptr->unk_322C.wonderCard.data))
return FALSE;
- if (!sub_80991F8())
+ if (!ValidateSavedRamScript())
return FALSE;
return TRUE;
}
-static bool32 sub_801B2CC(const struct MEventBuffer_32E0_Sub *data)
+static bool32 sub_801B2CC(const struct WonderCard *data)
{
if (data->unk_00 == 0)
return FALSE;
@@ -182,7 +182,7 @@ static bool32 sub_801B2CC(const struct MEventBuffer_32E0_Sub *data)
bool32 WonderCard_Test_Unk_08_6(void)
{
- const struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ const struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
if (data->unk_08_6 == 0)
return FALSE;
@@ -191,8 +191,8 @@ bool32 WonderCard_Test_Unk_08_6(void)
static void sub_801B330(void)
{
- CpuFill32(0, &gSaveBlock1Ptr->unk_322C.buffer_1c0.data, sizeof(struct MEventBuffer_32E0_Sub));
- gSaveBlock1Ptr->unk_322C.buffer_1c0.crc = 0;
+ CpuFill32(0, &gSaveBlock1Ptr->unk_322C.wonderCard.data, sizeof(struct WonderCard));
+ gSaveBlock1Ptr->unk_322C.wonderCard.crc = 0;
}
static void sub_801B368(void)
@@ -204,12 +204,12 @@ static void sub_801B368(void)
u16 GetWonderCardFlagID(void)
{
if (ValidateReceivedWonderCard())
- return gSaveBlock1Ptr->unk_322C.buffer_1c0.data.unk_00;
+ return gSaveBlock1Ptr->unk_322C.wonderCard.data.unk_00;
return 0;
}
-void sub_801B3C0(struct MEventBuffer_32E0_Sub *buffer)
+void WonderCard_ResetInternalReceivedFlag(struct WonderCard *buffer)
{
if (buffer->unk_08_6 == 1)
buffer->unk_08_6 = 0;
@@ -299,11 +299,11 @@ static bool32 sub_801B4A4(const u16 *data)
static int sub_801B4CC(void)
{
- struct MEventBuffer_32E0_Sub *data;
+ struct WonderCard *data;
if (!ValidateReceivedWonderCard())
return 0;
- data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
if (data->unk_08_0 != 1)
return 0;
@@ -312,7 +312,7 @@ static int sub_801B4CC(void)
bool32 sub_801B508(const u16 *data)
{
- struct MEventBuffer_32E0_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ struct WonderCard *buffer = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
int size = buffer->unk_09;
int i;
if (!sub_801B4A4(data))
@@ -355,9 +355,9 @@ void sub_801B580(struct MEventStruct_Unk1442CC *data, bool32 a1)
if (ValidateReceivedWonderCard())
{
- data->unk_14 = sav1_get_mevent_buffer_1()->unk_00;
+ data->unk_14 = GetSavedWonderCard()->unk_00;
data->unk_20 = *sav1_get_mevent_buffer_2();
- data->unk_44 = sav1_get_mevent_buffer_1()->unk_09;
+ data->unk_44 = GetSavedWonderCard()->unk_09;
}
else
{
@@ -399,7 +399,7 @@ bool32 sub_801B6A0(const struct MEventStruct_Unk1442CC *data, bool32 a1)
return TRUE;
}
-u32 sub_801B6EC(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, void *unused)
+u32 sub_801B6EC(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, const void *unused)
{
if (a1->unk_14 == 0)
return 0;
@@ -410,7 +410,7 @@ u32 sub_801B6EC(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, void *un
return 2;
}
-u32 sub_801B708(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, void *unused)
+u32 sub_801B708(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, const void *unused)
{
int r4 = a1->unk_44 - sub_801B438(&a1->unk_20, a1->unk_44);
if (r4 == 0)
@@ -422,7 +422,7 @@ u32 sub_801B708(const u16 *a0, const struct MEventStruct_Unk1442CC *a1, void *un
return 2;
}
-bool32 sub_801B748(const struct MEventStruct_Unk1442CC *a0, const u16 *a1)
+bool32 MEventStruct_Unk1442CC_CompareField_unk_16(const struct MEventStruct_Unk1442CC *a0, const u16 *a1)
{
int i;
for (i = 0; i < 4; i++)
@@ -439,7 +439,7 @@ static int sub_801B770(const struct MEventStruct_Unk1442CC *a0)
return sub_801B438(&a0->unk_20, a0->unk_44);
}
-u16 sub_801B784(const struct MEventStruct_Unk1442CC *a0, u32 command)
+u16 MEventStruct_Unk1442CC_GetValueNFrom_unk_20(const struct MEventStruct_Unk1442CC *a0, u32 command)
{
switch (command)
{
@@ -461,7 +461,7 @@ u16 sub_801B784(const struct MEventStruct_Unk1442CC *a0, u32 command)
static void sub_801B7D8(u32 command)
{
- struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
if (data->unk_08_0 == 2)
{
u16 *dest = NULL;
@@ -495,7 +495,7 @@ u16 mevent_081445C0(u32 command)
{
case 0:
{
- struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
if (data->unk_08_0 == 2)
{
struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
@@ -505,7 +505,7 @@ u16 mevent_081445C0(u32 command)
}
case 1:
{
- struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
if (data->unk_08_0 == 2)
{
struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
@@ -515,7 +515,7 @@ u16 mevent_081445C0(u32 command)
}
case 2:
{
- struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
if (data->unk_08_0 == 2)
{
struct MEventBuffer_3430_Sub *buffer = &gSaveBlock1Ptr->unk_322C.buffer_310.data;
@@ -525,14 +525,14 @@ u16 mevent_081445C0(u32 command)
}
case 3:
{
- struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
if (data->unk_08_0 == 1)
return sub_801B4CC();
break;
}
case 4:
{
- struct MEventBuffer_32E0_Sub *data = &gSaveBlock1Ptr->unk_322C.buffer_1c0.data;
+ struct WonderCard *data = &gSaveBlock1Ptr->unk_322C.wonderCard.data;
if (data->unk_08_0 == 1)
return data->unk_09;
break;
@@ -557,7 +557,7 @@ bool32 sub_801B94C(u16 a0)
if (!ValidateReceivedWonderCard())
return FALSE;
- if (gSaveBlock1Ptr->unk_322C.buffer_1c0.data.unk_00 != a0)
+ if (gSaveBlock1Ptr->unk_322C.wonderCard.data.unk_00 != a0)
return FALSE;
gUnknown_02022C70 = TRUE;
diff --git a/src/mevent_801BAAC.c b/src/mevent_801BAAC.c
index 24a999f69..62240af98 100644
--- a/src/mevent_801BAAC.c
+++ b/src/mevent_801BAAC.c
@@ -35,7 +35,7 @@ struct UnkStruct_203F3C8_02DC
struct UnkStruct_203F3C8
{
- /*0000*/ struct MEventBuffer_32E0_Sub unk_0000;
+ /*0000*/ struct WonderCard unk_0000;
/*014c*/ struct MEventBuffer_3430_Sub unk_014C;
/*0170*/ const struct UnkStruct_8467FB8 * unk_0170;
/*0174*/ u8 unk_0174;
@@ -150,7 +150,7 @@ const struct UnkStruct_8467FB8 gUnknown_082F1D60[8] = {
{1, 0, 0, 7, gWonderCardBgGfx8, gWonderCardBgTilemap8, gWonderCardBgPal8}
};
-bool32 InitWonderCardResources(struct MEventBuffer_32E0_Sub * r5, struct MEventBuffer_3430_Sub * r6)
+bool32 InitWonderCardResources(struct WonderCard * r5, struct MEventBuffer_3430_Sub * r6)
{
if (r5 == NULL || r6 == NULL)
return FALSE;
@@ -465,7 +465,7 @@ void sub_801C61C(void)
struct UnkStruct_203F3CC
{
- /*0000*/ struct MEventBuffer_3120_Sub unk_0000;
+ /*0000*/ struct WonderNews unk_0000;
/*01bc*/ const struct UnkStruct_8467FB8 * unk_01BC;
/*01c0*/ u8 unk_01C0_0:1;
u8 unk_01C0_1:7;
@@ -542,7 +542,7 @@ const struct UnkStruct_8467FB8 gUnknown_082F24C8[] = {
{1, 0, 0, 0, gWonderNewsGfx8, gWonderNewsTilemap8, gWonderNewsPal8}
};
-bool32 InitWonderNewsResources(const struct MEventBuffer_3120_Sub * a0)
+bool32 InitWonderNewsResources(const struct WonderNews * a0)
{
if (a0 == NULL)
return FALSE;
diff --git a/src/mevent_client.c b/src/mevent_client.c
new file mode 100644
index 000000000..ec8908af2
--- /dev/null
+++ b/src/mevent_client.c
@@ -0,0 +1,291 @@
+#include "global.h"
+#include "alloc.h"
+#include "decompress.h"
+#include "overworld.h"
+#include "script.h"
+#include "battle_tower.h"
+#include "mevent.h"
+#include "mystery_event_script.h"
+#include "mevent_client.h"
+
+EWRAM_DATA struct mevent_client * s_mevent_client_ptr = NULL;
+
+static void mevent_client_init(struct mevent_client *, u32, u32);
+static u32 mevent_client_exec(struct mevent_client *);
+static void mevent_client_free_resources(struct mevent_client *);
+
+extern const struct mevent_client_cmd gUnknown_082F2598[];
+
+void mevent_client_do_init(u32 arg)
+{
+ s_mevent_client_ptr = AllocZeroed(sizeof(struct mevent_client));
+ mevent_client_init(s_mevent_client_ptr, 1, 0);
+ s_mevent_client_ptr->unk_4C = arg;
+}
+
+u32 mevent_client_do_exec(u16 * a0)
+{
+ u32 result;
+ if (s_mevent_client_ptr == NULL)
+ return 6;
+ result = mevent_client_exec(s_mevent_client_ptr);
+ if (result == 6)
+ {
+ *a0 = s_mevent_client_ptr->param;
+ mevent_client_free_resources(s_mevent_client_ptr);
+ Free(s_mevent_client_ptr);
+ s_mevent_client_ptr = NULL;
+ }
+ return result;
+}
+
+void mevent_client_inc_flag(void)
+{
+ s_mevent_client_ptr->flag++;
+}
+
+void * mevent_client_get_buffer(void)
+{
+ return s_mevent_client_ptr->buffer;
+}
+
+void mevent_client_set_param(u32 a0)
+{
+ s_mevent_client_ptr->param = a0;
+}
+
+static void mevent_client_init(struct mevent_client * svr, u32 sendPlayerNo, u32 recvPlayerNo)
+{
+ svr->unk_00 = 0;
+ svr->mainseqno = 0;
+ svr->flag = 0;
+ svr->sendBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
+ svr->recvBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
+ svr->cmdBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
+ svr->buffer = AllocZeroed(0x40);
+ mevent_srv_sub_init(&svr->manager, sendPlayerNo, recvPlayerNo);
+}
+
+static void mevent_client_free_resources(struct mevent_client * svr)
+{
+ Free(svr->sendBuffer);
+ Free(svr->recvBuffer);
+ Free(svr->cmdBuffer);
+ Free(svr->buffer);
+}
+
+static void mevent_client_jmp_buffer(struct mevent_client * svr)
+{
+ memcpy(svr->cmdBuffer, svr->recvBuffer, ME_SEND_BUF_SIZE);
+ svr->cmdidx = 0;
+}
+
+static void mevent_client_send_word(struct mevent_client * svr, u32 ident, u32 word)
+{
+ CpuFill32(0, svr->sendBuffer, ME_SEND_BUF_SIZE);
+ *(u32 *)svr->sendBuffer = word;
+ mevent_srv_sub_init_send(&svr->manager, ident, svr->sendBuffer, sizeof(u32));
+}
+
+static u32 mainseq_0(struct mevent_client * svr)
+{
+ // init
+ memcpy(svr->cmdBuffer, gUnknown_082F2598, ME_SEND_BUF_SIZE);
+ svr->cmdidx = 0;
+ svr->mainseqno = 4;
+ svr->flag = 0;
+ return 0;
+}
+
+static u32 mainseq_1(struct mevent_client * svr)
+{
+ // done
+ return 6;
+}
+
+
+static u32 mainseq_2(struct mevent_client * svr)
+{
+ // do recv
+ if (mevent_srv_sub_recv(&svr->manager))
+ {
+ svr->mainseqno = 4;
+ svr->flag = 0;
+ }
+ return 1;
+}
+
+static u32 mainseq_3(struct mevent_client * svr)
+{
+ // do send
+ if (mevent_srv_sub_send(&svr->manager))
+ {
+ svr->mainseqno = 4;
+ svr->flag = 0;
+ }
+ return 1;
+}
+
+static u32 mainseq_4(struct mevent_client * svr)
+{
+ // process command
+ struct mevent_client_cmd * cmd = &svr->cmdBuffer[svr->cmdidx];
+ ++svr->cmdidx;
+ switch (cmd->instr)
+ {
+ case 0:
+ break;
+ case 1:
+ svr->param = cmd->parameter;
+ svr->mainseqno = 1;
+ svr->flag = 0;
+ break;
+ case 2:
+ mevent_srv_sub_init_recv(&svr->manager, cmd->parameter, svr->recvBuffer);
+ svr->mainseqno = 2;
+ svr->flag = 0;
+ break;
+ case 3:
+ svr->mainseqno = 3;
+ svr->flag = 0;
+ break;
+ case 20:
+ mevent_srv_sub_init_send(&svr->manager, 0x14, svr->sendBuffer, 0);
+ svr->mainseqno = 3;
+ svr->flag = 0;
+ break;
+ case 19:
+ mevent_client_send_word(svr, 0x12, GetGameStat(cmd->parameter));
+ svr->mainseqno = 3;
+ svr->flag = 0;
+ break;
+ case 6:
+ if (svr->param == 0)
+ mevent_client_jmp_buffer(svr);
+ break;
+ case 7:
+ if (svr->param == 1)
+ mevent_client_jmp_buffer(svr);
+ break;
+ case 4:
+ mevent_client_jmp_buffer(svr);
+ break;
+ case 5:
+ memcpy(svr->buffer, svr->recvBuffer, 0x40);
+ svr->mainseqno = 5;
+ svr->flag = 0;
+ return 2;
+ case 11:
+ memcpy(svr->buffer, svr->recvBuffer, 0x40);
+ svr->mainseqno = 5;
+ svr->flag = 0;
+ return 3;
+ case 12:
+ memcpy(svr->buffer, svr->recvBuffer, 0x40);
+ svr->mainseqno = 5;
+ svr->flag = 0;
+ return 5;
+ case 13:
+ svr->mainseqno = 5;
+ svr->flag = 0;
+ return 4;
+ case 8:
+ sub_801B580(svr->sendBuffer, svr->unk_4C);
+ mevent_srv_sub_init_send(&svr->manager, 0x11, svr->sendBuffer, sizeof(struct MEventStruct_Unk1442CC));
+ break;
+ case 14:
+ mevent_client_send_word(svr, 0x13, svr->param);
+ break;
+ case 10:
+ sub_801B21C(svr->recvBuffer);
+ break;
+ case 9:
+ if (!sub_801B1A4(svr->recvBuffer))
+ {
+ sub_801B078(svr->recvBuffer);
+ mevent_client_send_word(svr, 0x13, 0);
+ }
+ else
+ mevent_client_send_word(svr, 0x13, 1);
+ break;
+ case 15:
+ svr->mainseqno = 6;
+ svr->flag = 0;
+ break;
+ case 16:
+ sub_801B508(svr->recvBuffer);
+ break;
+ case 17:
+ InitRamScript_NoEventObject(svr->recvBuffer, 1000);
+ break;
+ case 18:
+ memcpy(&gSaveBlock2Ptr->frontier.ereaderTrainer, svr->recvBuffer, 0xbc);
+ ValidateEReaderTrainer();
+ break;
+ case 21:
+ memcpy(gDecompressionBuffer, svr->recvBuffer, ME_SEND_BUF_SIZE);
+ svr->mainseqno = 7;
+ svr->flag = 0;
+ break;
+ }
+
+ return 1;
+}
+
+static u32 mainseq_5(struct mevent_client * svr)
+{
+ // wait flag
+ if (svr->flag)
+ {
+ svr->mainseqno = 4;
+ svr->flag = 0;
+ }
+ return 1;
+}
+
+static u32 mainseq_6(struct mevent_client * svr)
+{
+ // ???
+ switch (svr->flag)
+ {
+ case 0:
+ sub_8153870(svr->recvBuffer);
+ ++svr->flag;
+ break;
+ case 1:
+ if (!sub_8153884(&svr->param))
+ {
+ svr->mainseqno = 4;
+ svr->flag = 0;
+ }
+ break;
+ }
+ return 1;
+}
+
+static u32 mainseq_7(struct mevent_client * svr)
+{
+ // exec arbitrary code
+ u32 (*func)(u32 *, struct SaveBlock2 *, struct SaveBlock1 *) = (void *)gDecompressionBuffer;
+ if (func(&svr->param, gSaveBlock2Ptr, gSaveBlock1Ptr) == 1)
+ {
+ svr->mainseqno = 4;
+ svr->flag = 0;
+ }
+ return 1;
+}
+
+static u32 mevent_client_exec(struct mevent_client * svr)
+{
+ u32 (*funcs[])(struct mevent_client *) = {
+ mainseq_0,
+ mainseq_1,
+ mainseq_2,
+ mainseq_3,
+ mainseq_4,
+ mainseq_5,
+ mainseq_6,
+ mainseq_7
+ };
+ return funcs[svr->mainseqno](svr);
+}
diff --git a/src/mevent_scripts.c b/src/mevent_scripts.c
new file mode 100644
index 000000000..41a5ddd51
--- /dev/null
+++ b/src/mevent_scripts.c
@@ -0,0 +1,191 @@
+#include "global.h"
+#include "mevent_client.h"
+#include "mevent_server.h"
+
+const u8 gText_CanceledReadingCard[] = _("Canceled reading\nthe Card.");
+
+
+const struct mevent_client_cmd gUnknown_082F2598[] = {
+ {.instr = 2, .parameter = 16},
+ {.instr = 4, .parameter = 0}
+};
+
+const struct mevent_client_cmd gUnknown_082F25A8[] = {
+ {.instr = 8, .parameter = 0},
+ {.instr = 3, .parameter = 0},
+ {.instr = 2, .parameter = 16},
+ {.instr = 4, .parameter = 0}
+};
+
+const struct mevent_client_cmd gUnknown_082F25C8[] = {
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 10}
+};
+
+const struct mevent_client_cmd gUnknown_082F25D8[] = {
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 11}
+};
+
+const struct mevent_client_cmd gUnknown_082F25E8[] = {
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 0}
+};
+
+const struct mevent_client_cmd gUnknown_082F25F8[] = {
+ {.instr = 2, .parameter = 22},
+ {.instr = 10, .parameter = 0},
+ {.instr = 2, .parameter = 25},
+ {.instr = 17, .parameter = 0},
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 2}
+};
+
+const struct mevent_client_cmd gUnknown_082F2628[] = {
+ {.instr = 2, .parameter = 23},
+ {.instr = 9, .parameter = 0},
+ {.instr = 3, .parameter = 0},
+ {.instr = 2, .parameter = 16},
+ {.instr = 4, .parameter = 0}
+};
+
+const struct mevent_client_cmd gUnknown_082F2650[] = {
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 7}
+};
+
+const struct mevent_client_cmd gUnknown_082F2660[] = {
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 3}
+};
+
+const struct mevent_client_cmd gUnknown_082F2670[] = {
+ {.instr = 13, .parameter = 0},
+ {.instr = 14, .parameter = 0},
+ {.instr = 3, .parameter = 0},
+ {.instr = 2, .parameter = 16},
+ {.instr = 4, .parameter = 0}
+};
+
+const struct mevent_client_cmd gUnknown_082F2698[] = {
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 9}
+};
+
+const struct mevent_client_cmd gUnknown_082F26A8[] = {
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 5}
+};
+
+const struct mevent_client_cmd gUnknown_082F26B8[] = {
+ {.instr = 2, .parameter = 21},
+ {.instr = 12, .parameter = 0},
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 14},
+ {.instr = 2, .parameter = 21},
+ {.instr = 12, .parameter = 0},
+ {.instr = 20, .parameter = 0},
+ {.instr = 1, .parameter = 13}
+};
+
+const struct mevent_cmd gUnknown_082F26F8[] = {
+ {.instr = 18, .flag = 0x10, .parameter = gUnknown_082F25C8},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x0a, .parameter = NULL},
+ {.instr = 18, .flag = 0x10, .parameter = gUnknown_082F25D8},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x0b, .parameter = NULL},
+ {.instr = 18, .flag = 0x10, .parameter = gUnknown_082F2698},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x09, .parameter = NULL}
+};
+
+const struct mevent_cmd gUnknown_082F2788[] = {
+ {.instr = 18, .flag = 0x20, .parameter = gUnknown_082F26B8},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 20, .flag = 0x1b, .parameter = gText_CanceledReadingCard},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x09, .parameter = NULL}
+};
+
+const struct mevent_cmd gUnknown_082F27D0[] = {
+ {.instr = 18, .flag = 0x10, .parameter = gUnknown_082F2650},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x07, .parameter = NULL}
+};
+
+const struct mevent_cmd gUnknown_082F2800[] = {
+ {.instr = 18, .flag = 0x28, .parameter = gUnknown_082F2628},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 14, .flag = 0x00, .parameter = NULL},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x13, .parameter = NULL},
+ {.instr = 8, .flag = 0x00, .parameter = NULL},
+ {.instr = 4, .flag = 0x01, .parameter = gUnknown_082F27D0},
+ {.instr = 18, .flag = 0x10, .parameter = gUnknown_082F2660},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x03, .parameter = NULL}
+};
+
+const struct mevent_cmd gUnknown_082F2884[] = {
+ {.instr = 18, .flag = 0x30, .parameter = gUnknown_082F25F8},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 13, .flag = 0x00, .parameter = NULL},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 15, .flag = 0x00, .parameter = NULL},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x02, .parameter = NULL}
+};
+
+const struct mevent_cmd gUnknown_082F28E4[] = {
+ {.instr = 18, .flag = 0x28, .parameter = gUnknown_082F2670},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x13, .parameter = NULL},
+ {.instr = 8, .flag = 0x00, .parameter = NULL},
+ {.instr = 4, .flag = 0x00, .parameter = gUnknown_082F2884},
+ {.instr = 3, .flag = 0x00, .parameter = gUnknown_082F2788}
+};
+
+const struct mevent_cmd gUnknown_082F292C[] = {
+ {.instr = 18, .flag = 0x10, .parameter = gUnknown_082F26A8},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x05, .parameter = NULL},
+ {.instr = 18, .flag = 0x10, .parameter = gUnknown_082F25E8},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x14, .parameter = NULL},
+ {.instr = 0, .flag = 0x00, .parameter = NULL}
+};
+
+const struct mevent_cmd s_mevent_wonder_news[] = {
+ {.instr = 27, .flag = 0x00, .parameter = NULL},
+ {.instr = 18, .flag = 0x20, .parameter = gUnknown_082F25A8},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x11, .parameter = NULL},
+ {.instr = 5, .flag = 0x00, .parameter = NULL},
+ {.instr = 30, .flag = 0x00, .parameter = NULL},
+ {.instr = 4, .flag = 0x00, .parameter = gUnknown_082F26F8},
+ {.instr = 3, .flag = 0x00, .parameter = gUnknown_082F2800}
+};
+
+const struct mevent_cmd s_mevent_wonder_card[] = {
+ {.instr = 26, .flag = 0x00, .parameter = NULL},
+ {.instr = 28, .flag = 0x00, .parameter = NULL},
+ {.instr = 18, .flag = 0x20, .parameter = gUnknown_082F25A8},
+ {.instr = 1, .flag = 0x00, .parameter = NULL},
+ {.instr = 2, .flag = 0x11, .parameter = NULL},
+ {.instr = 5, .flag = 0x00, .parameter = NULL},
+ {.instr = 6, .flag = 0x00, .parameter = NULL},
+ {.instr = 4, .flag = 0x00, .parameter = gUnknown_082F26F8},
+ {.instr = 7, .flag = 0x00, .parameter = NULL},
+ {.instr = 4, .flag = 0x02, .parameter = gUnknown_082F28E4},
+ {.instr = 4, .flag = 0x00, .parameter = gUnknown_082F2884},
+ {.instr = 3, .flag = 0x00, .parameter = gUnknown_082F292C}
+};
diff --git a/src/mevent_server.c b/src/mevent_server.c
new file mode 100644
index 000000000..06b10dd95
--- /dev/null
+++ b/src/mevent_server.c
@@ -0,0 +1,295 @@
+#include "global.h"
+#include "alloc.h"
+#include "script.h"
+#include "mevent.h"
+#include "mevent_server.h"
+#include "mevent_server_helpers.h"
+
+EWRAM_DATA struct mevent_srv_common * s_mevent_srv_common_ptr = NULL;
+
+static void mevent_srv_init_common(struct mevent_srv_common *, const void *, u32, u32);
+static void mevent_srv_free_resources(struct mevent_srv_common *);
+static u32 mevent_srv_exec_common(struct mevent_srv_common *);
+
+extern const struct mevent_cmd s_mevent_wonder_news[];
+extern const struct mevent_cmd s_mevent_wonder_card[];
+
+void mevent_srv_init_wnews(void)
+{
+ s_mevent_srv_common_ptr = AllocZeroed(sizeof(struct mevent_srv_common));
+ mevent_srv_init_common(s_mevent_srv_common_ptr, s_mevent_wonder_news, 0, 1);
+}
+
+void mevent_srv_new_wcard(void)
+{
+ s_mevent_srv_common_ptr = AllocZeroed(sizeof(struct mevent_srv_common));
+ mevent_srv_init_common(s_mevent_srv_common_ptr, s_mevent_wonder_card, 0, 1);
+}
+
+u32 mevent_srv_common_do_exec(u16 * a0)
+{
+ u32 result;
+ if (s_mevent_srv_common_ptr == NULL)
+ return 3;
+ result = mevent_srv_exec_common(s_mevent_srv_common_ptr);
+ if (result == 3)
+ {
+ *a0 = s_mevent_srv_common_ptr->param;
+ mevent_srv_free_resources(s_mevent_srv_common_ptr);
+ Free(s_mevent_srv_common_ptr);
+ s_mevent_srv_common_ptr = NULL;
+ }
+ return result;
+}
+
+static void mevent_srv_init_common(struct mevent_srv_common * svr, const void * cmdBuffer, u32 sendPlayerNo, u32 recvPlayerNo)
+{
+ svr->unk_00 = 0;
+ svr->mainseqno = 0;
+ svr->wonder_card = AllocZeroed(sizeof(struct WonderCard));
+ svr->wonder_news = AllocZeroed(sizeof(struct WonderNews));
+ svr->recvBuffer = AllocZeroed(ME_SEND_BUF_SIZE);
+ svr->mevent_unk1442cc = AllocZeroed(sizeof(struct MEventStruct_Unk1442CC));
+ svr->cmdBuffer = cmdBuffer;
+ svr->cmdidx = 0;
+ mevent_srv_sub_init(&svr->manager, sendPlayerNo, recvPlayerNo);
+}
+
+static void mevent_srv_free_resources(struct mevent_srv_common * svr)
+{
+ Free(svr->wonder_card);
+ Free(svr->wonder_news);
+ Free(svr->recvBuffer);
+ Free(svr->mevent_unk1442cc);
+}
+
+void mevent_srv_common_init_send(struct mevent_srv_common * svr, u32 ident, const void * src, u32 size)
+{
+ AGB_ASSERT(size <= ME_SEND_BUF_SIZE);
+ mevent_srv_sub_init_send(&svr->manager, ident, src, size);
+}
+
+static const void * mevent_first_if_not_null_else_second(const void * a0, const void * a1)
+{
+ if (a0 != NULL)
+ return a0;
+ else
+ return a1;
+}
+
+static u32 mevent_compare_pointers(const void * a0, const void * a1)
+{
+ if (a1 < a0)
+ return 0;
+ else if (a1 == a0)
+ return 1;
+ else
+ return 2;
+}
+
+static u32 common_mainseq_0(struct mevent_srv_common * svr)
+{
+ // start
+ svr->mainseqno = 4;
+ return 0;
+}
+
+static u32 common_mainseq_1(struct mevent_srv_common * svr)
+{
+ // done
+ return 3;
+}
+
+static u32 common_mainseq_2(struct mevent_srv_common * svr)
+{
+ // do recv
+ if (mevent_srv_sub_recv(&svr->manager))
+ svr->mainseqno = 4;
+ return 1;
+}
+
+static u32 common_mainseq_3(struct mevent_srv_common * svr)
+{
+ // do send
+ if (mevent_srv_sub_send(&svr->manager))
+ svr->mainseqno = 4;
+ return 1;
+}
+
+static u32 common_mainseq_4(struct mevent_srv_common * svr)
+{
+ // process command
+ const struct mevent_cmd * cmd = &svr->cmdBuffer[svr->cmdidx];
+ const void * ptr;
+ svr->cmdidx++;
+
+ switch (cmd->instr)
+ {
+ case 0:
+ // end
+ AGB_ASSERT(cmd->parameter == NULL);
+ svr->mainseqno = 1;
+ svr->param = cmd->flag;
+ break;
+ case 1:
+ // wait_send
+ svr->mainseqno = 3;
+ break;
+ case 2:
+ // receive
+ AGB_ASSERT(cmd->parameter == NULL);
+ mevent_srv_sub_init_recv(&svr->manager, cmd->flag, svr->recvBuffer);
+ svr->mainseqno = 2;
+ break;
+ case 3:
+ // jump
+ AGB_ASSERT(cmd->flag == FALSE);
+ svr->cmdidx = 0;
+ svr->cmdBuffer = cmd->parameter;
+ break;
+ case 5:
+ // get_1442CC
+ AGB_ASSERT(cmd->flag == FALSE);
+ AGB_ASSERT(cmd->parameter == NULL);
+ memcpy(svr->mevent_unk1442cc, svr->recvBuffer, sizeof(struct MEventStruct_Unk1442CC));
+ break;
+ case 6:
+ // check_header__pass_false
+ AGB_ASSERT(cmd->flag == FALSE);
+ AGB_ASSERT(cmd->parameter == NULL);
+ svr->param = sub_801B6A0(svr->mevent_unk1442cc, FALSE);
+ break;
+ case 30:
+ // check_header__pass_true
+ AGB_ASSERT(cmd->flag == FALSE);
+ AGB_ASSERT(cmd->parameter == NULL);
+ svr->param = sub_801B6A0(svr->mevent_unk1442cc, TRUE);
+ break;
+ case 4:
+ // jump_if_eq
+ if (svr->param == cmd->flag)
+ {
+ svr->cmdidx = 0;
+ svr->cmdBuffer = cmd->parameter;
+ }
+ break;
+ case 7:
+ // check_crc
+ AGB_ASSERT(cmd->flag == FALSE);
+ ptr = mevent_first_if_not_null_else_second(cmd->parameter, svr->wonder_card);
+ svr->param = sub_801B6EC(ptr, svr->mevent_unk1442cc, ptr);
+ break;
+ case 8:
+ // read_word
+ AGB_ASSERT(cmd->flag == FALSE);
+ AGB_ASSERT(cmd->parameter == NULL);
+ svr->param = *(u32 *)svr->recvBuffer;
+ break;
+ case 9:
+ AGB_ASSERT(cmd->flag == FALSE);
+ ptr = mevent_first_if_not_null_else_second(cmd->parameter, &svr->sendWord);
+ svr->param = sub_801B708(ptr, svr->mevent_unk1442cc, ptr);
+ break;
+ case 10:
+ AGB_ASSERT(cmd->parameter == NULL);
+ svr->param = MEventStruct_Unk1442CC_GetValueNFrom_unk_20(svr->mevent_unk1442cc, cmd->flag);
+ break;
+ case 11:
+ AGB_ASSERT(cmd->flag == FALSE);
+ svr->param = MEventStruct_Unk1442CC_CompareField_unk_16(svr->mevent_unk1442cc, cmd->parameter);
+ break;
+ case 12:
+ AGB_ASSERT(cmd->flag == FALSE);
+ svr->param = mevent_compare_pointers(cmd->parameter, *(void **)svr->recvBuffer);
+ break;
+ case 14:
+ AGB_ASSERT(cmd->flag == FALSE);
+ mevent_srv_common_init_send(svr, 0x17, mevent_first_if_not_null_else_second(cmd->parameter, svr->wonder_news), sizeof(struct WonderNews));
+ break;
+ case 13:
+ AGB_ASSERT(cmd->flag == FALSE);
+ mevent_srv_common_init_send(svr, 0x16, mevent_first_if_not_null_else_second(cmd->parameter, svr->wonder_card), sizeof(struct WonderCard));
+ break;
+ case 16:
+ AGB_ASSERT(cmd->flag == FALSE);
+ mevent_srv_common_init_send(svr, 0x18, mevent_first_if_not_null_else_second(cmd->parameter, &svr->sendWord), 4);
+ break;
+ case 15:
+ if (cmd->parameter == NULL)
+ mevent_srv_common_init_send(svr, 0x19, svr->sendBuffer1, svr->sendBuffer1Size);
+ else
+ mevent_srv_common_init_send(svr, 0x19, cmd->parameter, cmd->flag);
+ break;
+ case 18:
+ if (cmd->parameter == NULL)
+ mevent_srv_common_init_send(svr, 0x10, svr->sendBuffer2, svr->sendBuffer2Size);
+ else
+ mevent_srv_common_init_send(svr, 0x10, cmd->parameter, cmd->flag);
+ break;
+ case 19:
+ AGB_ASSERT(cmd->flag == FALSE);
+ mevent_srv_common_init_send(svr, 0x1a, cmd->parameter, 188);
+ break;
+ case 20:
+ mevent_srv_common_init_send(svr, 0x15, cmd->parameter, cmd->flag);
+ break;
+ case 17:
+ mevent_srv_common_init_send(svr, 0x1c, cmd->parameter, cmd->flag);
+ break;
+ case 22:
+ AGB_ASSERT(cmd->flag == FALSE);
+ memcpy(svr->wonder_card, cmd->parameter, 332);
+ break;
+ case 23:
+ AGB_ASSERT(cmd->flag == FALSE);
+ memcpy(svr->wonder_news, cmd->parameter, 444);
+ break;
+ case 21:
+ AGB_ASSERT(cmd->flag == FALSE);
+ svr->sendWord = *(u32 *)cmd->parameter;
+ break;
+ case 24:
+ svr->sendBuffer1 = cmd->parameter;
+ svr->sendBuffer1Size = cmd->flag;
+ break;
+ case 25:
+ svr->sendBuffer2 = cmd->parameter;
+ svr->sendBuffer2Size = cmd->flag;
+ break;
+ case 26:
+ AGB_ASSERT(cmd->flag == FALSE && cmd->parameter == NULL);
+ memcpy(svr->wonder_card, GetSavedWonderCard(), 332);
+ WonderCard_ResetInternalReceivedFlag(svr->wonder_card);
+ break;
+ case 27:
+ AGB_ASSERT(cmd->flag == FALSE && cmd->parameter == NULL);
+ memcpy(svr->wonder_news, GetSavedWonderNews(), 444);
+ break;
+ case 28:
+ AGB_ASSERT(cmd->flag == FALSE && cmd->parameter == NULL);
+ svr->sendBuffer1 = GetSavedRamScriptIfValid();
+ break;
+ case 29:
+ mevent_srv_common_init_send(svr, 0x1b, cmd->parameter, cmd->flag);
+ break;
+ }
+
+ return 1;
+}
+
+static u32 (*const func_tbl[])(struct mevent_srv_common *) = {
+ common_mainseq_0,
+ common_mainseq_1,
+ common_mainseq_2,
+ common_mainseq_3,
+ common_mainseq_4
+};
+
+static u32 mevent_srv_exec_common(struct mevent_srv_common * svr)
+{
+ u32 response;
+ AGB_ASSERT(svr->mainseqno < NELEMS(func_tbl));
+ response = func_tbl[svr->mainseqno](svr);
+ AGB_ASSERT(svr->mainseqno < NELEMS(func_tbl));
+ return response;
+}
diff --git a/src/mevent_server_helpers.c b/src/mevent_server_helpers.c
new file mode 100644
index 000000000..9d47ba745
--- /dev/null
+++ b/src/mevent_server_helpers.c
@@ -0,0 +1,211 @@
+#include "global.h"
+#include "alloc.h"
+#include "decompress.h"
+#include "util.h"
+#include "link.h"
+#include "link_rfu.h"
+#include "overworld.h"
+#include "script.h"
+#include "battle_tower.h"
+#include "mystery_event_script.h"
+#include "mevent.h"
+#include "mevent_server_helpers.h"
+
+static u32 mevent_receive_func(struct mevent_srv_sub *);
+static u32 mevent_send_func(struct mevent_srv_sub *);
+
+u32 mevent_srv_sub_recv(struct mevent_srv_sub * svr)
+{
+ return svr->recvFunc(svr);
+}
+
+u32 mevent_srv_sub_send(struct mevent_srv_sub * svr)
+{
+ return svr->sendFunc(svr);
+}
+
+void mevent_srv_sub_init(struct mevent_srv_sub * svr, u32 sendPlayerNo, u32 recvPlayerNo)
+{
+ svr->sendPlayerNo = sendPlayerNo;
+ svr->recvPlayerNo = recvPlayerNo;
+ svr->seqno = 0;
+ svr->sendCRC = 0;
+ svr->sendSize = 0;
+ svr->sendCounter = 0;
+ svr->recvCRC = 0;
+ svr->recvSize = 0;
+ svr->recvCounter = 0;
+ svr->sendBfr = NULL;
+ svr->recvBfr = NULL;
+ svr->sendFunc = mevent_send_func;
+ svr->recvFunc = mevent_receive_func;
+}
+
+void mevent_srv_sub_init_send(struct mevent_srv_sub * svr, u32 ident, const void * src, u32 size)
+{
+ svr->seqno = 0;
+ svr->sendIdent = ident;
+ svr->sendCounter = 0;
+ svr->sendCRC = 0;
+ if (size != 0)
+ svr->sendSize = size;
+ else
+ svr->sendSize = ME_SEND_BUF_SIZE;
+ svr->sendBfr = src;
+}
+
+void mevent_srv_sub_init_recv(struct mevent_srv_sub * svr, u32 ident, void * dest)
+{
+ svr->seqno = 0;
+ svr->recvIdent = ident;
+ svr->recvCounter = 0;
+ svr->recvCRC = 0;
+ svr->recvSize = 0;
+ svr->recvBfr = dest;
+}
+
+static void mevent_recv_block(u32 recv_idx, void * dest, size_t size)
+{
+ memcpy(dest, gBlockRecvBuffer[recv_idx], size);
+}
+
+static bool32 mevent_has_received(u32 recv_idx)
+{
+ if ((GetBlockReceivedStatus() >> recv_idx) & 1)
+ return TRUE;
+ else
+ return FALSE;
+}
+
+static void mevent_reset_recv(u32 recv_idx)
+{
+ ResetBlockReceivedFlag(recv_idx);
+}
+
+static bool32 mevent_receive_func(struct mevent_srv_sub * svr)
+{
+ struct send_recv_header header;
+
+ switch (svr->seqno)
+ {
+ case 0:
+ if (mevent_has_received(svr->recvPlayerNo))
+ {
+ mevent_recv_block(svr->recvPlayerNo, &header, sizeof(header));
+ svr->recvSize = header.size;
+ svr->recvCRC = header.crc;
+ if (svr->recvSize > ME_SEND_BUF_SIZE)
+ {
+ LinkRfu_FatalError();
+ return FALSE;
+ }
+ else if (svr->recvIdent != header.ident)
+ {
+ LinkRfu_FatalError();
+ return FALSE;
+ }
+ else
+ {
+ svr->recvCounter = 0;
+ mevent_reset_recv(svr->recvPlayerNo);
+ ++svr->seqno;
+ }
+ }
+ break;
+ case 1:
+ if (mevent_has_received(svr->recvPlayerNo))
+ {
+ size_t blocksiz = svr->recvCounter * 252;
+ if (svr->recvSize - blocksiz <= 252)
+ {
+ mevent_recv_block(svr->recvPlayerNo, svr->recvBfr + blocksiz, svr->recvSize - blocksiz);
+ ++svr->recvCounter;
+ ++svr->seqno;
+ }
+ else
+ {
+ mevent_recv_block(svr->recvPlayerNo, svr->recvBfr + blocksiz, 252);
+ ++svr->recvCounter;
+ }
+ mevent_reset_recv(svr->recvPlayerNo);
+ }
+ break;
+ case 2:
+ if (CalcCRC16WithTable(svr->recvBfr, svr->recvSize) != svr->recvCRC)
+ {
+ LinkRfu_FatalError();
+ return FALSE;
+ }
+ else
+ {
+ svr->seqno = 0;
+ return TRUE;
+ }
+ break;
+
+ }
+
+ return FALSE;
+}
+
+static bool32 mevent_send_func(struct mevent_srv_sub * svr)
+{
+ struct send_recv_header header;
+
+ switch (svr->seqno)
+ {
+ case 0:
+ if (IsLinkTaskFinished())
+ {
+ header.ident = svr->sendIdent;
+ header.size = svr->sendSize;
+ header.crc = CalcCRC16WithTable(svr->sendBfr, svr->sendSize);
+ svr->sendCRC = header.crc;
+ svr->sendCounter = 0;
+ SendBlock(0, &header, sizeof(header));
+ ++svr->seqno;
+ }
+ break;
+ case 1:
+ if (IsLinkTaskFinished())
+ {
+ if (mevent_has_received(svr->sendPlayerNo))
+ {
+ size_t blocksiz;
+ mevent_reset_recv(svr->sendPlayerNo);
+ blocksiz = 252 * svr->sendCounter;
+ if (svr->sendSize - blocksiz <= 252)
+ {
+ SendBlock(0, svr->sendBfr + blocksiz, svr->sendSize - blocksiz);
+ ++svr->sendCounter;
+ ++svr->seqno;
+ }
+ else
+ {
+ SendBlock(0, svr->sendBfr + blocksiz, 252);
+ ++svr->sendCounter;
+ }
+ }
+ }
+ break;
+ case 2:
+ if (IsLinkTaskFinished())
+ {
+ if (CalcCRC16WithTable(svr->sendBfr, svr->sendSize) != svr->sendCRC)
+ LinkRfu_FatalError();
+ else
+ ++svr->seqno;
+ }
+ break;
+ case 3:
+ if (mevent_has_received(svr->sendPlayerNo))
+ {
+ mevent_reset_recv(svr->sendPlayerNo);
+ svr->seqno = 0;
+ return TRUE;
+ }
+ break;
+ }
+
+ return FALSE;
+}
diff --git a/src/mystery_gift.c b/src/mystery_gift.c
index c8b3a9060..ab3df9020 100644
--- a/src/mystery_gift.c
+++ b/src/mystery_gift.c
@@ -25,7 +25,7 @@
#include "mevent_801BAAC.h"
#include "save.h"
#include "link.h"
-#include "mevent_server_ish.h"
+#include "mevent_client.h"
#include "event_data.h"
#include "link_rfu.h"
#include "mevent_news.h"
@@ -815,11 +815,11 @@ static bool32 HandleLoadWonderCardOrNews(u8 * state, bool32 cardOrNews)
case 0:
if (cardOrNews == 0)
{
- InitWonderCardResources(sav1_get_mevent_buffer_1(), sav1_get_mevent_buffer_2());
+ InitWonderCardResources(GetSavedWonderCard(), sav1_get_mevent_buffer_2());
}
else
{
- InitWonderNewsResources(sav1_get_mevent_buffer_0());
+ InitWonderNewsResources(GetSavedWonderNews());
}
(*state)++;
break;
@@ -1269,7 +1269,7 @@ void task00_mystery_gift(u8 taskId)
{
ClearScreenInBg0(TRUE);
data->state = 7;
- mevent_srv_ish_do_init(data->IsCardOrNews);
+ mevent_client_do_init(data->IsCardOrNews);
}
else if (gSpecialVar_Result == 5)
{
@@ -1282,7 +1282,7 @@ void task00_mystery_gift(u8 taskId)
data->state = 8;
break;
case 8:
- switch (mevent_srv_ish_do_exec(&data->curPromptWindowId))
+ switch (mevent_client_do_exec(&data->curPromptWindowId))
{
case 6:
task_add_05_task_del_08FA224_when_no_RfuFunc();
@@ -1290,8 +1290,8 @@ void task00_mystery_gift(u8 taskId)
data->state = 13;
break;
case 5:
- memcpy(data->buffer, mevent_srv_ish_get_buffer(), 0x40);
- mevent_srv_ish_inc_flag();
+ memcpy(data->buffer, mevent_client_get_buffer(), 0x40);
+ mevent_client_inc_flag();
break;
case 3:
data->state = 10;
@@ -1306,29 +1306,29 @@ void task00_mystery_gift(u8 taskId)
}
break;
case 9:
- switch ((u32)mevent_message_print_and_prompt_yes_no(&data->textState, &data->curPromptWindowId, FALSE, mevent_srv_ish_get_buffer()))
+ switch ((u32)mevent_message_print_and_prompt_yes_no(&data->textState, &data->curPromptWindowId, FALSE, mevent_client_get_buffer()))
{
case 0:
- mevent_srv_ish_set_param(0);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(0);
+ mevent_client_inc_flag();
data->state = 7;
break;
case 1:
- mevent_srv_ish_set_param(1);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(1);
+ mevent_client_inc_flag();
data->state = 7;
break;
case -1u:
- mevent_srv_ish_set_param(1);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(1);
+ mevent_client_inc_flag();
data->state = 7;
break;
}
break;
case 10:
- if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, mevent_srv_ish_get_buffer()))
+ if (MG_PrintTextOnWindow1AndWaitButton(&data->textState, mevent_client_get_buffer()))
{
- mevent_srv_ish_inc_flag();
+ mevent_client_inc_flag();
data->state = 7;
}
break;
@@ -1342,19 +1342,19 @@ void task00_mystery_gift(u8 taskId)
}
else
{
- mevent_srv_ish_set_param(0);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(0);
+ mevent_client_inc_flag();
data->state = 7;
}
break;
case 1:
- mevent_srv_ish_set_param(1);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(1);
+ mevent_client_inc_flag();
data->state = 7;
break;
case -1u:
- mevent_srv_ish_set_param(1);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(1);
+ mevent_client_inc_flag();
data->state = 7;
break;
}
@@ -1363,18 +1363,18 @@ void task00_mystery_gift(u8 taskId)
switch ((u32)mevent_message_print_and_prompt_yes_no(&data->textState, &data->curPromptWindowId, FALSE, gText_HaventReceivedCardsGift))
{
case 0:
- mevent_srv_ish_set_param(0);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(0);
+ mevent_client_inc_flag();
data->state = 7;
break;
case 1:
- mevent_srv_ish_set_param(1);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(1);
+ mevent_client_inc_flag();
data->state = 7;
break;
case -1u:
- mevent_srv_ish_set_param(1);
- mevent_srv_ish_inc_flag();
+ mevent_client_set_param(1);
+ mevent_client_inc_flag();
data->state = 7;
break;
}
diff --git a/src/naming_screen.c b/src/naming_screen.c
index 3b8ba037c..e43a259e7 100644
--- a/src/naming_screen.c
+++ b/src/naming_screen.c
@@ -449,7 +449,7 @@ static u8 sub_80E3274(void)
static bool8 MainState_BeginFadeIn(void)
{
sub_80E4CF8(3, gUnknown_08DD4544);
- gNamingScreenData->currentPage = 1;
+ gNamingScreenData->currentPage = PAGE_UPPER;
sub_80E4CF8(2, gUnknown_08DD46E0);
sub_80E4CF8(1, gUnknown_08DD4620);
sub_80E4DE4(gNamingScreenData->windows[1], 0);
@@ -1856,7 +1856,7 @@ static const struct NamingScreenTemplate playerNamingScreenTemplate =
.maxChars = 7,
.iconFunction = 1,
.addGenderIcon = 0,
- .initialPage = 1,
+ .initialPage = PAGE_UPPER,
.unused = 35,
.title = gText_YourName,
};
@@ -1867,7 +1867,7 @@ static const struct NamingScreenTemplate pcBoxNamingTemplate =
.maxChars = 8,
.iconFunction = 2,
.addGenderIcon = 0,
- .initialPage = 1,
+ .initialPage = PAGE_UPPER,
.unused = 19,
.title = gText_BoxName,
};
@@ -1878,7 +1878,7 @@ static const struct NamingScreenTemplate monNamingScreenTemplate =
.maxChars = 10,
.iconFunction = 3,
.addGenderIcon = 1,
- .initialPage = 1,
+ .initialPage = PAGE_UPPER,
.unused = 35,
.title = gText_PkmnsNickname,
};
@@ -1889,7 +1889,7 @@ static const struct NamingScreenTemplate wandaWordsScreenTemplate =
.maxChars = 15,
.iconFunction = 4,
.addGenderIcon = 0,
- .initialPage = 1,
+ .initialPage = PAGE_UPPER,
.unused = 11,
.title = gText_TellHimTheWords,
};
diff --git a/src/overworld.c b/src/overworld.c
index ce1e21ab1..9ed147c0a 100644
--- a/src/overworld.c
+++ b/src/overworld.c
@@ -2287,7 +2287,7 @@ static void SetKeyInterceptCallback(u16 (*func)(u32))
static void CheckRfuKeepAliveTimer(void)
{
if (gWirelessCommType != 0 && ++sRfuKeepAliveTimer > 60)
- sub_8010198();
+ LinkRfu_FatalError();
}
static void ResetAllTradingStates(void)
@@ -2960,7 +2960,7 @@ static void InitLinkPlayerEventObjectPos(struct EventObject *eventObj, s16 x, s1
eventObj->currentCoords.y = y;
eventObj->previousCoords.x = x;
eventObj->previousCoords.y = y;
- sub_8093038(x, y, &eventObj->initialCoords.x, &eventObj->initialCoords.y);
+ SetSpritePosToMapCoords(x, y, &eventObj->initialCoords.x, &eventObj->initialCoords.y);
eventObj->initialCoords.x += 8;
EventObjectUpdateZCoord(eventObj);
}
diff --git a/src/pokemon.c b/src/pokemon.c
index 7c26b4c22..a75701cb0 100644
--- a/src/pokemon.c
+++ b/src/pokemon.c
@@ -1810,419 +1810,63 @@ static const u8 sMonFrontAnimIdsTable[] =
[SPECIES_CHIMECHO - 1] = 0x1d,
};
-static const u8 sMonAnimationDelayTable[] =
-{
- [SPECIES_BULBASAUR - 1] = 0x00,
- [SPECIES_IVYSAUR - 1] = 0x00,
- [SPECIES_VENUSAUR - 1] = 0x00,
- [SPECIES_CHARMANDER - 1] = 0x00,
- [SPECIES_CHARMELEON - 1] = 0x00,
- [SPECIES_CHARIZARD - 1] = 0x00,
- [SPECIES_SQUIRTLE - 1] = 0x00,
- [SPECIES_WARTORTLE - 1] = 0x00,
+static const u8 sMonAnimationDelayTable[NUM_SPECIES - 1] =
+{
[SPECIES_BLASTOISE - 1] = 0x32,
- [SPECIES_CATERPIE - 1] = 0x00,
- [SPECIES_METAPOD - 1] = 0x00,
- [SPECIES_BUTTERFREE - 1] = 0x00,
[SPECIES_WEEDLE - 1] = 0x0a,
[SPECIES_KAKUNA - 1] = 0x14,
[SPECIES_BEEDRILL - 1] = 0x23,
- [SPECIES_PIDGEY - 1] = 0x00,
[SPECIES_PIDGEOTTO - 1] = 0x19,
- [SPECIES_PIDGEOT - 1] = 0x00,
- [SPECIES_RATTATA - 1] = 0x00,
- [SPECIES_RATICATE - 1] = 0x00,
- [SPECIES_SPEAROW - 1] = 0x00,
[SPECIES_FEAROW - 1] = 0x02,
[SPECIES_EKANS - 1] = 0x1e,
- [SPECIES_ARBOK - 1] = 0x00,
- [SPECIES_PIKACHU - 1] = 0x00,
- [SPECIES_RAICHU - 1] = 0x00,
- [SPECIES_SANDSHREW - 1] = 0x00,
- [SPECIES_SANDSLASH - 1] = 0x00,
[SPECIES_NIDORAN_F - 1] = 0x1c,
- [SPECIES_NIDORINA - 1] = 0x00,
- [SPECIES_NIDOQUEEN - 1] = 0x00,
- [SPECIES_NIDORAN_M - 1] = 0x00,
- [SPECIES_NIDORINO - 1] = 0x00,
[SPECIES_NIDOKING - 1] = 0x19,
- [SPECIES_CLEFAIRY - 1] = 0x00,
- [SPECIES_CLEFABLE - 1] = 0x00,
- [SPECIES_VULPIX - 1] = 0x00,
- [SPECIES_NINETALES - 1] = 0x00,
- [SPECIES_JIGGLYPUFF - 1] = 0x00,
- [SPECIES_WIGGLYTUFF - 1] = 0x00,
- [SPECIES_ZUBAT - 1] = 0x00,
- [SPECIES_GOLBAT - 1] = 0x00,
- [SPECIES_ODDISH - 1] = 0x00,
- [SPECIES_GLOOM - 1] = 0x00,
- [SPECIES_VILEPLUME - 1] = 0x00,
[SPECIES_PARAS - 1] = 0x0a,
[SPECIES_PARASECT - 1] = 0x2d,
[SPECIES_VENONAT - 1] = 0x14,
- [SPECIES_VENOMOTH - 1] = 0x00,
[SPECIES_DIGLETT - 1] = 0x19,
[SPECIES_DUGTRIO - 1] = 0x23,
[SPECIES_MEOWTH - 1] = 0x28,
[SPECIES_PERSIAN - 1] = 0x14,
- [SPECIES_PSYDUCK - 1] = 0x00,
- [SPECIES_GOLDUCK - 1] = 0x00,
[SPECIES_MANKEY - 1] = 0x14,
- [SPECIES_PRIMEAPE - 1] = 0x00,
[SPECIES_GROWLITHE - 1] = 0x1e,
[SPECIES_ARCANINE - 1] = 0x28,
- [SPECIES_POLIWAG - 1] = 0x00,
[SPECIES_POLIWHIRL - 1] = 0x05,
- [SPECIES_POLIWRATH - 1] = 0x00,
- [SPECIES_ABRA - 1] = 0x00,
- [SPECIES_KADABRA - 1] = 0x00,
- [SPECIES_ALAKAZAM - 1] = 0x00,
- [SPECIES_MACHOP - 1] = 0x00,
- [SPECIES_MACHOKE - 1] = 0x00,
- [SPECIES_MACHAMP - 1] = 0x00,
- [SPECIES_BELLSPROUT - 1] = 0x00,
[SPECIES_WEEPINBELL - 1] = 0x03,
- [SPECIES_VICTREEBEL - 1] = 0x00,
- [SPECIES_TENTACOOL - 1] = 0x00,
- [SPECIES_TENTACRUEL - 1] = 0x00,
- [SPECIES_GEODUDE - 1] = 0x00,
- [SPECIES_GRAVELER - 1] = 0x00,
- [SPECIES_GOLEM - 1] = 0x00,
- [SPECIES_PONYTA - 1] = 0x00,
- [SPECIES_RAPIDASH - 1] = 0x00,
- [SPECIES_SLOWPOKE - 1] = 0x00,
- [SPECIES_SLOWBRO - 1] = 0x00,
- [SPECIES_MAGNEMITE - 1] = 0x00,
- [SPECIES_MAGNETON - 1] = 0x00,
- [SPECIES_FARFETCHD - 1] = 0x00,
- [SPECIES_DODUO - 1] = 0x00,
- [SPECIES_DODRIO - 1] = 0x00,
- [SPECIES_SEEL - 1] = 0x00,
- [SPECIES_DEWGONG - 1] = 0x00,
- [SPECIES_GRIMER - 1] = 0x00,
[SPECIES_MUK - 1] = 0x2d,
[SPECIES_SHELLDER - 1] = 0x14,
- [SPECIES_CLOYSTER - 1] = 0x00,
- [SPECIES_GASTLY - 1] = 0x00,
[SPECIES_HAUNTER - 1] = 0x17,
- [SPECIES_GENGAR - 1] = 0x00,
- [SPECIES_ONIX - 1] = 0x00,
[SPECIES_DROWZEE - 1] = 0x30,
[SPECIES_HYPNO - 1] = 0x28,
- [SPECIES_KRABBY - 1] = 0x00,
- [SPECIES_KINGLER - 1] = 0x00,
- [SPECIES_VOLTORB - 1] = 0x00,
- [SPECIES_ELECTRODE - 1] = 0x00,
- [SPECIES_EXEGGCUTE - 1] = 0x00,
- [SPECIES_EXEGGUTOR - 1] = 0x00,
- [SPECIES_CUBONE - 1] = 0x00,
- [SPECIES_MAROWAK - 1] = 0x00,
- [SPECIES_HITMONLEE - 1] = 0x00,
[SPECIES_HITMONCHAN - 1] = 0x19,
- [SPECIES_LICKITUNG - 1] = 0x00,
- [SPECIES_KOFFING - 1] = 0x00,
- [SPECIES_WEEZING - 1] = 0x00,
- [SPECIES_RHYHORN - 1] = 0x00,
- [SPECIES_RHYDON - 1] = 0x00,
- [SPECIES_CHANSEY - 1] = 0x00,
- [SPECIES_TANGELA - 1] = 0x00,
- [SPECIES_KANGASKHAN - 1] = 0x00,
- [SPECIES_HORSEA - 1] = 0x00,
- [SPECIES_SEADRA - 1] = 0x00,
- [SPECIES_GOLDEEN - 1] = 0x00,
- [SPECIES_SEAKING - 1] = 0x00,
- [SPECIES_STARYU - 1] = 0x00,
- [SPECIES_STARMIE - 1] = 0x00,
- [SPECIES_MR_MIME - 1] = 0x00,
[SPECIES_SCYTHER - 1] = 0x0a,
- [SPECIES_JYNX - 1] = 0x00,
- [SPECIES_ELECTABUZZ - 1] = 0x00,
- [SPECIES_MAGMAR - 1] = 0x00,
- [SPECIES_PINSIR - 1] = 0x00,
[SPECIES_TAUROS - 1] = 0x0a,
- [SPECIES_MAGIKARP - 1] = 0x00,
- [SPECIES_GYARADOS - 1] = 0x00,
- [SPECIES_LAPRAS - 1] = 0x00,
- [SPECIES_DITTO - 1] = 0x00,
- [SPECIES_EEVEE - 1] = 0x00,
- [SPECIES_VAPOREON - 1] = 0x00,
- [SPECIES_JOLTEON - 1] = 0x00,
- [SPECIES_FLAREON - 1] = 0x00,
- [SPECIES_PORYGON - 1] = 0x00,
- [SPECIES_OMANYTE - 1] = 0x00,
- [SPECIES_OMASTAR - 1] = 0x00,
- [SPECIES_KABUTO - 1] = 0x00,
- [SPECIES_KABUTOPS - 1] = 0x00,
- [SPECIES_AERODACTYL - 1] = 0x00,
- [SPECIES_SNORLAX - 1] = 0x00,
- [SPECIES_ARTICUNO - 1] = 0x00,
- [SPECIES_ZAPDOS - 1] = 0x00,
- [SPECIES_MOLTRES - 1] = 0x00,
- [SPECIES_DRATINI - 1] = 0x00,
- [SPECIES_DRAGONAIR - 1] = 0x00,
- [SPECIES_DRAGONITE - 1] = 0x00,
- [SPECIES_MEWTWO - 1] = 0x00,
- [SPECIES_MEW - 1] = 0x00,
- [SPECIES_CHIKORITA - 1] = 0x00,
- [SPECIES_BAYLEEF - 1] = 0x00,
- [SPECIES_MEGANIUM - 1] = 0x00,
- [SPECIES_CYNDAQUIL - 1] = 0x00,
- [SPECIES_QUILAVA - 1] = 0x00,
[SPECIES_TYPHLOSION - 1] = 0x14,
- [SPECIES_TOTODILE - 1] = 0x00,
- [SPECIES_CROCONAW - 1] = 0x00,
[SPECIES_FERALIGATR - 1] = 0x05,
- [SPECIES_SENTRET - 1] = 0x00,
- [SPECIES_FURRET - 1] = 0x00,
- [SPECIES_HOOTHOOT - 1] = 0x00,
- [SPECIES_NOCTOWL - 1] = 0x00,
- [SPECIES_LEDYBA - 1] = 0x00,
- [SPECIES_LEDIAN - 1] = 0x00,
- [SPECIES_SPINARAK - 1] = 0x00,
- [SPECIES_ARIADOS - 1] = 0x00,
- [SPECIES_CROBAT - 1] = 0x00,
- [SPECIES_CHINCHOU - 1] = 0x00,
- [SPECIES_LANTURN - 1] = 0x00,
- [SPECIES_PICHU - 1] = 0x00,
- [SPECIES_CLEFFA - 1] = 0x00,
- [SPECIES_IGGLYBUFF - 1] = 0x00,
- [SPECIES_TOGEPI - 1] = 0x00,
- [SPECIES_TOGETIC - 1] = 0x00,
[SPECIES_NATU - 1] = 0x1e,
- [SPECIES_XATU - 1] = 0x00,
[SPECIES_MAREEP - 1] = 0x32,
- [SPECIES_FLAAFFY - 1] = 0x00,
[SPECIES_AMPHAROS - 1] = 0x0a,
- [SPECIES_BELLOSSOM - 1] = 0x00,
- [SPECIES_MARILL - 1] = 0x00,
- [SPECIES_AZUMARILL - 1] = 0x00,
- [SPECIES_SUDOWOODO - 1] = 0x00,
[SPECIES_POLITOED - 1] = 0x28,
- [SPECIES_HOPPIP - 1] = 0x00,
- [SPECIES_SKIPLOOM - 1] = 0x00,
- [SPECIES_JUMPLUFF - 1] = 0x00,
- [SPECIES_AIPOM - 1] = 0x00,
- [SPECIES_SUNKERN - 1] = 0x00,
- [SPECIES_SUNFLORA - 1] = 0x00,
- [SPECIES_YANMA - 1] = 0x00,
- [SPECIES_WOOPER - 1] = 0x00,
- [SPECIES_QUAGSIRE - 1] = 0x00,
- [SPECIES_ESPEON - 1] = 0x00,
- [SPECIES_UMBREON - 1] = 0x00,
- [SPECIES_MURKROW - 1] = 0x00,
- [SPECIES_SLOWKING - 1] = 0x00,
- [SPECIES_MISDREAVUS - 1] = 0x00,
- [SPECIES_UNOWN - 1] = 0x00,
- [SPECIES_WOBBUFFET - 1] = 0x00,
- [SPECIES_GIRAFARIG - 1] = 0x00,
- [SPECIES_PINECO - 1] = 0x00,
- [SPECIES_FORRETRESS - 1] = 0x00,
[SPECIES_DUNSPARCE - 1] = 0x0a,
- [SPECIES_GLIGAR - 1] = 0x00,
[SPECIES_STEELIX - 1] = 0x2d,
- [SPECIES_SNUBBULL - 1] = 0x00,
- [SPECIES_GRANBULL - 1] = 0x00,
[SPECIES_QWILFISH - 1] = 0x27,
[SPECIES_SCIZOR - 1] = 0x13,
- [SPECIES_SHUCKLE - 1] = 0x00,
- [SPECIES_HERACROSS - 1] = 0x00,
- [SPECIES_SNEASEL - 1] = 0x00,
- [SPECIES_TEDDIURSA - 1] = 0x00,
- [SPECIES_URSARING - 1] = 0x00,
- [SPECIES_SLUGMA - 1] = 0x00,
- [SPECIES_MAGCARGO - 1] = 0x00,
- [SPECIES_SWINUB - 1] = 0x00,
- [SPECIES_PILOSWINE - 1] = 0x00,
- [SPECIES_CORSOLA - 1] = 0x00,
- [SPECIES_REMORAID - 1] = 0x00,
[SPECIES_OCTILLERY - 1] = 0x14,
- [SPECIES_DELIBIRD - 1] = 0x00,
- [SPECIES_MANTINE - 1] = 0x00,
- [SPECIES_SKARMORY - 1] = 0x00,
- [SPECIES_HOUNDOUR - 1] = 0x00,
- [SPECIES_HOUNDOOM - 1] = 0x00,
- [SPECIES_KINGDRA - 1] = 0x00,
- [SPECIES_PHANPY - 1] = 0x00,
- [SPECIES_DONPHAN - 1] = 0x00,
- [SPECIES_PORYGON2 - 1] = 0x00,
- [SPECIES_STANTLER - 1] = 0x00,
- [SPECIES_SMEARGLE - 1] = 0x00,
- [SPECIES_TYROGUE - 1] = 0x00,
- [SPECIES_HITMONTOP - 1] = 0x00,
[SPECIES_SMOOCHUM - 1] = 0x28,
- [SPECIES_ELEKID - 1] = 0x00,
- [SPECIES_MAGBY - 1] = 0x00,
- [SPECIES_MILTANK - 1] = 0x00,
- [SPECIES_BLISSEY - 1] = 0x00,
- [SPECIES_RAIKOU - 1] = 0x00,
- [SPECIES_ENTEI - 1] = 0x00,
- [SPECIES_SUICUNE - 1] = 0x00,
- [SPECIES_LARVITAR - 1] = 0x00,
- [SPECIES_PUPITAR - 1] = 0x00,
[SPECIES_TYRANITAR - 1] = 0x0a,
[SPECIES_LUGIA - 1] = 0x14,
- [SPECIES_HO_OH - 1] = 0x00,
- [SPECIES_CELEBI - 1] = 0x00,
- [SPECIES_OLD_UNOWN_B - 1] = 0x00,
- [SPECIES_OLD_UNOWN_C - 1] = 0x00,
- [SPECIES_OLD_UNOWN_D - 1] = 0x00,
- [SPECIES_OLD_UNOWN_E - 1] = 0x00,
- [SPECIES_OLD_UNOWN_F - 1] = 0x00,
- [SPECIES_OLD_UNOWN_G - 1] = 0x00,
- [SPECIES_OLD_UNOWN_H - 1] = 0x00,
- [SPECIES_OLD_UNOWN_I - 1] = 0x00,
- [SPECIES_OLD_UNOWN_J - 1] = 0x00,
- [SPECIES_OLD_UNOWN_K - 1] = 0x00,
- [SPECIES_OLD_UNOWN_L - 1] = 0x00,
- [SPECIES_OLD_UNOWN_M - 1] = 0x00,
- [SPECIES_OLD_UNOWN_N - 1] = 0x00,
- [SPECIES_OLD_UNOWN_O - 1] = 0x00,
- [SPECIES_OLD_UNOWN_P - 1] = 0x00,
- [SPECIES_OLD_UNOWN_Q - 1] = 0x00,
- [SPECIES_OLD_UNOWN_R - 1] = 0x00,
- [SPECIES_OLD_UNOWN_S - 1] = 0x00,
- [SPECIES_OLD_UNOWN_T - 1] = 0x00,
- [SPECIES_OLD_UNOWN_U - 1] = 0x00,
- [SPECIES_OLD_UNOWN_V - 1] = 0x00,
- [SPECIES_OLD_UNOWN_W - 1] = 0x00,
- [SPECIES_OLD_UNOWN_X - 1] = 0x00,
- [SPECIES_OLD_UNOWN_Y - 1] = 0x00,
- [SPECIES_OLD_UNOWN_Z - 1] = 0x00,
- [SPECIES_TREECKO - 1] = 0x00,
- [SPECIES_GROVYLE - 1] = 0x00,
- [SPECIES_SCEPTILE - 1] = 0x00,
- [SPECIES_TORCHIC - 1] = 0x00,
- [SPECIES_COMBUSKEN - 1] = 0x00,
- [SPECIES_BLAZIKEN - 1] = 0x00,
- [SPECIES_MUDKIP - 1] = 0x00,
- [SPECIES_MARSHTOMP - 1] = 0x00,
- [SPECIES_SWAMPERT - 1] = 0x00,
- [SPECIES_POOCHYENA - 1] = 0x00,
- [SPECIES_MIGHTYENA - 1] = 0x00,
- [SPECIES_ZIGZAGOON - 1] = 0x00,
- [SPECIES_LINOONE - 1] = 0x00,
- [SPECIES_WURMPLE - 1] = 0x00,
- [SPECIES_SILCOON - 1] = 0x00,
- [SPECIES_BEAUTIFLY - 1] = 0x00,
- [SPECIES_CASCOON - 1] = 0x00,
- [SPECIES_DUSTOX - 1] = 0x00,
- [SPECIES_LOTAD - 1] = 0x00,
- [SPECIES_LOMBRE - 1] = 0x00,
- [SPECIES_LUDICOLO - 1] = 0x00,
- [SPECIES_SEEDOT - 1] = 0x00,
- [SPECIES_NUZLEAF - 1] = 0x00,
- [SPECIES_SHIFTRY - 1] = 0x00,
- [SPECIES_NINCADA - 1] = 0x00,
- [SPECIES_NINJASK - 1] = 0x00,
- [SPECIES_SHEDINJA - 1] = 0x00,
- [SPECIES_TAILLOW - 1] = 0x00,
- [SPECIES_SWELLOW - 1] = 0x00,
- [SPECIES_SHROOMISH - 1] = 0x00,
- [SPECIES_BRELOOM - 1] = 0x00,
- [SPECIES_SPINDA - 1] = 0x00,
- [SPECIES_WINGULL - 1] = 0x00,
- [SPECIES_PELIPPER - 1] = 0x00,
- [SPECIES_SURSKIT - 1] = 0x00,
- [SPECIES_MASQUERAIN - 1] = 0x00,
- [SPECIES_WAILMER - 1] = 0x00,
[SPECIES_WAILORD - 1] = 0x0a,
- [SPECIES_SKITTY - 1] = 0x00,
- [SPECIES_DELCATTY - 1] = 0x00,
[SPECIES_KECLEON - 1] = 0x1e,
- [SPECIES_BALTOY - 1] = 0x00,
- [SPECIES_CLAYDOL - 1] = 0x00,
- [SPECIES_NOSEPASS - 1] = 0x00,
- [SPECIES_TORKOAL - 1] = 0x00,
- [SPECIES_SABLEYE - 1] = 0x00,
- [SPECIES_BARBOACH - 1] = 0x00,
- [SPECIES_WHISCASH - 1] = 0x00,
- [SPECIES_LUVDISC - 1] = 0x00,
- [SPECIES_CORPHISH - 1] = 0x00,
- [SPECIES_CRAWDAUNT - 1] = 0x00,
- [SPECIES_FEEBAS - 1] = 0x00,
[SPECIES_MILOTIC - 1] = 0x2d,
- [SPECIES_CARVANHA - 1] = 0x00,
- [SPECIES_SHARPEDO - 1] = 0x00,
- [SPECIES_TRAPINCH - 1] = 0x00,
- [SPECIES_VIBRAVA - 1] = 0x00,
- [SPECIES_FLYGON - 1] = 0x00,
- [SPECIES_MAKUHITA - 1] = 0x00,
- [SPECIES_HARIYAMA - 1] = 0x00,
- [SPECIES_ELECTRIKE - 1] = 0x00,
- [SPECIES_MANECTRIC - 1] = 0x00,
- [SPECIES_NUMEL - 1] = 0x00,
- [SPECIES_CAMERUPT - 1] = 0x00,
[SPECIES_SPHEAL - 1] = 0x0f,
- [SPECIES_SEALEO - 1] = 0x00,
- [SPECIES_WALREIN - 1] = 0x00,
- [SPECIES_CACNEA - 1] = 0x00,
- [SPECIES_CACTURNE - 1] = 0x00,
[SPECIES_SNORUNT - 1] = 0x14,
- [SPECIES_GLALIE - 1] = 0x00,
- [SPECIES_LUNATONE - 1] = 0x00,
- [SPECIES_SOLROCK - 1] = 0x00,
- [SPECIES_AZURILL - 1] = 0x00,
- [SPECIES_SPOINK - 1] = 0x00,
[SPECIES_GRUMPIG - 1] = 0x0f,
- [SPECIES_PLUSLE - 1] = 0x00,
- [SPECIES_MINUN - 1] = 0x00,
- [SPECIES_MAWILE - 1] = 0x00,
- [SPECIES_MEDITITE - 1] = 0x00,
- [SPECIES_MEDICHAM - 1] = 0x00,
- [SPECIES_SWABLU - 1] = 0x00,
- [SPECIES_ALTARIA - 1] = 0x00,
[SPECIES_WYNAUT - 1] = 0x0f,
- [SPECIES_DUSKULL - 1] = 0x00,
[SPECIES_DUSCLOPS - 1] = 0x1e,
- [SPECIES_ROSELIA - 1] = 0x00,
- [SPECIES_SLAKOTH - 1] = 0x00,
- [SPECIES_VIGOROTH - 1] = 0x00,
- [SPECIES_SLAKING - 1] = 0x00,
- [SPECIES_GULPIN - 1] = 0x00,
- [SPECIES_SWALOT - 1] = 0x00,
- [SPECIES_TROPIUS - 1] = 0x00,
- [SPECIES_WHISMUR - 1] = 0x00,
- [SPECIES_LOUDRED - 1] = 0x00,
- [SPECIES_EXPLOUD - 1] = 0x00,
- [SPECIES_CLAMPERL - 1] = 0x00,
- [SPECIES_HUNTAIL - 1] = 0x00,
- [SPECIES_GOREBYSS - 1] = 0x00,
[SPECIES_ABSOL - 1] = 0x2d,
- [SPECIES_SHUPPET - 1] = 0x00,
- [SPECIES_BANETTE - 1] = 0x00,
- [SPECIES_SEVIPER - 1] = 0x00,
- [SPECIES_ZANGOOSE - 1] = 0x00,
- [SPECIES_RELICANTH - 1] = 0x00,
- [SPECIES_ARON - 1] = 0x00,
- [SPECIES_LAIRON - 1] = 0x00,
- [SPECIES_AGGRON - 1] = 0x00,
- [SPECIES_CASTFORM - 1] = 0x00,
- [SPECIES_VOLBEAT - 1] = 0x00,
- [SPECIES_ILLUMISE - 1] = 0x00,
- [SPECIES_LILEEP - 1] = 0x00,
- [SPECIES_CRADILY - 1] = 0x00,
- [SPECIES_ANORITH - 1] = 0x00,
- [SPECIES_ARMALDO - 1] = 0x00,
- [SPECIES_RALTS - 1] = 0x00,
- [SPECIES_KIRLIA - 1] = 0x00,
- [SPECIES_GARDEVOIR - 1] = 0x00,
- [SPECIES_BAGON - 1] = 0x00,
- [SPECIES_SHELGON - 1] = 0x00,
[SPECIES_SALAMENCE - 1] = 0x46,
- [SPECIES_BELDUM - 1] = 0x00,
- [SPECIES_METANG - 1] = 0x00,
- [SPECIES_METAGROSS - 1] = 0x00,
- [SPECIES_REGIROCK - 1] = 0x00,
- [SPECIES_REGICE - 1] = 0x00,
- [SPECIES_REGISTEEL - 1] = 0x00,
[SPECIES_KYOGRE - 1] = 0x3c,
- [SPECIES_GROUDON - 1] = 0x00,
[SPECIES_RAYQUAZA - 1] = 0x3c,
- [SPECIES_LATIAS - 1] = 0x00,
- [SPECIES_LATIOS - 1] = 0x00,
- [SPECIES_JIRACHI - 1] = 0x00,
- [SPECIES_DEOXYS - 1] = 0x00,
- [SPECIES_CHIMECHO - 1] = 0x00,
};
const u8 gPPUpGetMask[] = {0x03, 0x0c, 0x30, 0xc0}; // Masks for getting PP Up count, also PP Max values
@@ -5819,7 +5463,7 @@ u16 GetEvolutionTargetSpecies(struct Pokemon *mon, u8 type, u16 evolutionItem)
if (gEvolutionTable[species][i].param == heldItem)
{
heldItem = 0;
- SetMonData(mon, MON_DATA_HELD_ITEM, (u8 *)&heldItem);
+ SetMonData(mon, MON_DATA_HELD_ITEM, &heldItem);
targetSpecies = gEvolutionTable[species][i].targetSpecies;
}
break;
diff --git a/src/pokemon_icon.c b/src/pokemon_icon.c
index a5d3f8961..6a135875e 100644
--- a/src/pokemon_icon.c
+++ b/src/pokemon_icon.c
@@ -25,446 +25,446 @@ static u8 CreateMonIconSprite(struct MonIconSpriteTemplate *, s16, s16, u8);
const u8 *const gMonIconTable[] =
{
- gMonIcon_Bulbasaur,
- gMonIcon_Bulbasaur,
- gMonIcon_Ivysaur,
- gMonIcon_Venusaur,
- gMonIcon_Charmander,
- gMonIcon_Charmeleon,
- gMonIcon_Charizard,
- gMonIcon_Squirtle,
- gMonIcon_Wartortle,
- gMonIcon_Blastoise,
- gMonIcon_Caterpie,
- gMonIcon_Metapod,
- gMonIcon_Butterfree,
- gMonIcon_Weedle,
- gMonIcon_Kakuna,
- gMonIcon_Beedrill,
- gMonIcon_Pidgey,
- gMonIcon_Pidgeotto,
- gMonIcon_Pidgeot,
- gMonIcon_Rattata,
- gMonIcon_Raticate,
- gMonIcon_Spearow,
- gMonIcon_Fearow,
- gMonIcon_Ekans,
- gMonIcon_Arbok,
- gMonIcon_Pikachu,
- gMonIcon_Raichu,
- gMonIcon_Sandshrew,
- gMonIcon_Sandslash,
- gMonIcon_NidoranF,
- gMonIcon_Nidorina,
- gMonIcon_Nidoqueen,
- gMonIcon_NidoranM,
- gMonIcon_Nidorino,
- gMonIcon_Nidoking,
- gMonIcon_Clefairy,
- gMonIcon_Clefable,
- gMonIcon_Vulpix,
- gMonIcon_Ninetales,
- gMonIcon_Jigglypuff,
- gMonIcon_Wigglytuff,
- gMonIcon_Zubat,
- gMonIcon_Golbat,
- gMonIcon_Oddish,
- gMonIcon_Gloom,
- gMonIcon_Vileplume,
- gMonIcon_Paras,
- gMonIcon_Parasect,
- gMonIcon_Venonat,
- gMonIcon_Venomoth,
- gMonIcon_Diglett,
- gMonIcon_Dugtrio,
- gMonIcon_Meowth,
- gMonIcon_Persian,
- gMonIcon_Psyduck,
- gMonIcon_Golduck,
- gMonIcon_Mankey,
- gMonIcon_Primeape,
- gMonIcon_Growlithe,
- gMonIcon_Arcanine,
- gMonIcon_Poliwag,
- gMonIcon_Poliwhirl,
- gMonIcon_Poliwrath,
- gMonIcon_Abra,
- gMonIcon_Kadabra,
- gMonIcon_Alakazam,
- gMonIcon_Machop,
- gMonIcon_Machoke,
- gMonIcon_Machamp,
- gMonIcon_Bellsprout,
- gMonIcon_Weepinbell,
- gMonIcon_Victreebel,
- gMonIcon_Tentacool,
- gMonIcon_Tentacruel,
- gMonIcon_Geodude,
- gMonIcon_Graveler,
- gMonIcon_Golem,
- gMonIcon_Ponyta,
- gMonIcon_Rapidash,
- gMonIcon_Slowpoke,
- gMonIcon_Slowbro,
- gMonIcon_Magnemite,
- gMonIcon_Magneton,
- gMonIcon_Farfetchd,
- gMonIcon_Doduo,
- gMonIcon_Dodrio,
- gMonIcon_Seel,
- gMonIcon_Dewgong,
- gMonIcon_Grimer,
- gMonIcon_Muk,
- gMonIcon_Shellder,
- gMonIcon_Cloyster,
- gMonIcon_Gastly,
- gMonIcon_Haunter,
- gMonIcon_Gengar,
- gMonIcon_Onix,
- gMonIcon_Drowzee,
- gMonIcon_Hypno,
- gMonIcon_Krabby,
- gMonIcon_Kingler,
- gMonIcon_Voltorb,
- gMonIcon_Electrode,
- gMonIcon_Exeggcute,
- gMonIcon_Exeggutor,
- gMonIcon_Cubone,
- gMonIcon_Marowak,
- gMonIcon_Hitmonlee,
- gMonIcon_Hitmonchan,
- gMonIcon_Lickitung,
- gMonIcon_Koffing,
- gMonIcon_Weezing,
- gMonIcon_Rhyhorn,
- gMonIcon_Rhydon,
- gMonIcon_Chansey,
- gMonIcon_Tangela,
- gMonIcon_Kangaskhan,
- gMonIcon_Horsea,
- gMonIcon_Seadra,
- gMonIcon_Goldeen,
- gMonIcon_Seaking,
- gMonIcon_Staryu,
- gMonIcon_Starmie,
- gMonIcon_Mrmime,
- gMonIcon_Scyther,
- gMonIcon_Jynx,
- gMonIcon_Electabuzz,
- gMonIcon_Magmar,
- gMonIcon_Pinsir,
- gMonIcon_Tauros,
- gMonIcon_Magikarp,
- gMonIcon_Gyarados,
- gMonIcon_Lapras,
- gMonIcon_Ditto,
- gMonIcon_Eevee,
- gMonIcon_Vaporeon,
- gMonIcon_Jolteon,
- gMonIcon_Flareon,
- gMonIcon_Porygon,
- gMonIcon_Omanyte,
- gMonIcon_Omastar,
- gMonIcon_Kabuto,
- gMonIcon_Kabutops,
- gMonIcon_Aerodactyl,
- gMonIcon_Snorlax,
- gMonIcon_Articuno,
- gMonIcon_Zapdos,
- gMonIcon_Moltres,
- gMonIcon_Dratini,
- gMonIcon_Dragonair,
- gMonIcon_Dragonite,
- gMonIcon_Mewtwo,
- gMonIcon_Mew,
- gMonIcon_Chikorita,
- gMonIcon_Bayleef,
- gMonIcon_Meganium,
- gMonIcon_Cyndaquil,
- gMonIcon_Quilava,
- gMonIcon_Typhlosion,
- gMonIcon_Totodile,
- gMonIcon_Croconaw,
- gMonIcon_Feraligatr,
- gMonIcon_Sentret,
- gMonIcon_Furret,
- gMonIcon_Hoothoot,
- gMonIcon_Noctowl,
- gMonIcon_Ledyba,
- gMonIcon_Ledian,
- gMonIcon_Spinarak,
- gMonIcon_Ariados,
- gMonIcon_Crobat,
- gMonIcon_Chinchou,
- gMonIcon_Lanturn,
- gMonIcon_Pichu,
- gMonIcon_Cleffa,
- gMonIcon_Igglybuff,
- gMonIcon_Togepi,
- gMonIcon_Togetic,
- gMonIcon_Natu,
- gMonIcon_Xatu,
- gMonIcon_Mareep,
- gMonIcon_Flaaffy,
- gMonIcon_Ampharos,
- gMonIcon_Bellossom,
- gMonIcon_Marill,
- gMonIcon_Azumarill,
- gMonIcon_Sudowoodo,
- gMonIcon_Politoed,
- gMonIcon_Hoppip,
- gMonIcon_Skiploom,
- gMonIcon_Jumpluff,
- gMonIcon_Aipom,
- gMonIcon_Sunkern,
- gMonIcon_Sunflora,
- gMonIcon_Yanma,
- gMonIcon_Wooper,
- gMonIcon_Quagsire,
- gMonIcon_Espeon,
- gMonIcon_Umbreon,
- gMonIcon_Murkrow,
- gMonIcon_Slowking,
- gMonIcon_Misdreavus,
- gMonIcon_UnownA,
- gMonIcon_Wobbuffet,
- gMonIcon_Girafarig,
- gMonIcon_Pineco,
- gMonIcon_Forretress,
- gMonIcon_Dunsparce,
- gMonIcon_Gligar,
- gMonIcon_Steelix,
- gMonIcon_Snubbull,
- gMonIcon_Granbull,
- gMonIcon_Qwilfish,
- gMonIcon_Scizor,
- gMonIcon_Shuckle,
- gMonIcon_Heracross,
- gMonIcon_Sneasel,
- gMonIcon_Teddiursa,
- gMonIcon_Ursaring,
- gMonIcon_Slugma,
- gMonIcon_Magcargo,
- gMonIcon_Swinub,
- gMonIcon_Piloswine,
- gMonIcon_Corsola,
- gMonIcon_Remoraid,
- gMonIcon_Octillery,
- gMonIcon_Delibird,
- gMonIcon_Mantine,
- gMonIcon_Skarmory,
- gMonIcon_Houndour,
- gMonIcon_Houndoom,
- gMonIcon_Kingdra,
- gMonIcon_Phanpy,
- gMonIcon_Donphan,
- gMonIcon_Porygon2,
- gMonIcon_Stantler,
- gMonIcon_Smeargle,
- gMonIcon_Tyrogue,
- gMonIcon_Hitmontop,
- gMonIcon_Smoochum,
- gMonIcon_Elekid,
- gMonIcon_Magby,
- gMonIcon_Miltank,
- gMonIcon_Blissey,
- gMonIcon_Raikou,
- gMonIcon_Entei,
- gMonIcon_Suicune,
- gMonIcon_Larvitar,
- gMonIcon_Pupitar,
- gMonIcon_Tyranitar,
- gMonIcon_Lugia,
- gMonIcon_HoOh,
- gMonIcon_Celebi,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_QuestionMark,
- gMonIcon_Treecko,
- gMonIcon_Grovyle,
- gMonIcon_Sceptile,
- gMonIcon_Torchic,
- gMonIcon_Combusken,
- gMonIcon_Blaziken,
- gMonIcon_Mudkip,
- gMonIcon_Marshtomp,
- gMonIcon_Swampert,
- gMonIcon_Poochyena,
- gMonIcon_Mightyena,
- gMonIcon_Zigzagoon,
- gMonIcon_Linoone,
- gMonIcon_Wurmple,
- gMonIcon_Silcoon,
- gMonIcon_Beautifly,
- gMonIcon_Cascoon,
- gMonIcon_Dustox,
- gMonIcon_Lotad,
- gMonIcon_Lombre,
- gMonIcon_Ludicolo,
- gMonIcon_Seedot,
- gMonIcon_Nuzleaf,
- gMonIcon_Shiftry,
- gMonIcon_Nincada,
- gMonIcon_Ninjask,
- gMonIcon_Shedinja,
- gMonIcon_Taillow,
- gMonIcon_Swellow,
- gMonIcon_Shroomish,
- gMonIcon_Breloom,
- gMonIcon_Spinda,
- gMonIcon_Wingull,
- gMonIcon_Pelipper,
- gMonIcon_Surskit,
- gMonIcon_Masquerain,
- gMonIcon_Wailmer,
- gMonIcon_Wailord,
- gMonIcon_Skitty,
- gMonIcon_Delcatty,
- gMonIcon_Kecleon,
- gMonIcon_Baltoy,
- gMonIcon_Claydol,
- gMonIcon_Nosepass,
- gMonIcon_Torkoal,
- gMonIcon_Sableye,
- gMonIcon_Barboach,
- gMonIcon_Whiscash,
- gMonIcon_Luvdisc,
- gMonIcon_Corphish,
- gMonIcon_Crawdaunt,
- gMonIcon_Feebas,
- gMonIcon_Milotic,
- gMonIcon_Carvanha,
- gMonIcon_Sharpedo,
- gMonIcon_Trapinch,
- gMonIcon_Vibrava,
- gMonIcon_Flygon,
- gMonIcon_Makuhita,
- gMonIcon_Hariyama,
- gMonIcon_Electrike,
- gMonIcon_Manectric,
- gMonIcon_Numel,
- gMonIcon_Camerupt,
- gMonIcon_Spheal,
- gMonIcon_Sealeo,
- gMonIcon_Walrein,
- gMonIcon_Cacnea,
- gMonIcon_Cacturne,
- gMonIcon_Snorunt,
- gMonIcon_Glalie,
- gMonIcon_Lunatone,
- gMonIcon_Solrock,
- gMonIcon_Azurill,
- gMonIcon_Spoink,
- gMonIcon_Grumpig,
- gMonIcon_Plusle,
- gMonIcon_Minun,
- gMonIcon_Mawile,
- gMonIcon_Meditite,
- gMonIcon_Medicham,
- gMonIcon_Swablu,
- gMonIcon_Altaria,
- gMonIcon_Wynaut,
- gMonIcon_Duskull,
- gMonIcon_Dusclops,
- gMonIcon_Roselia,
- gMonIcon_Slakoth,
- gMonIcon_Vigoroth,
- gMonIcon_Slaking,
- gMonIcon_Gulpin,
- gMonIcon_Swalot,
- gMonIcon_Tropius,
- gMonIcon_Whismur,
- gMonIcon_Loudred,
- gMonIcon_Exploud,
- gMonIcon_Clamperl,
- gMonIcon_Huntail,
- gMonIcon_Gorebyss,
- gMonIcon_Absol,
- gMonIcon_Shuppet,
- gMonIcon_Banette,
- gMonIcon_Seviper,
- gMonIcon_Zangoose,
- gMonIcon_Relicanth,
- gMonIcon_Aron,
- gMonIcon_Lairon,
- gMonIcon_Aggron,
- gMonIcon_Castform,
- gMonIcon_Volbeat,
- gMonIcon_Illumise,
- gMonIcon_Lileep,
- gMonIcon_Cradily,
- gMonIcon_Anorith,
- gMonIcon_Armaldo,
- gMonIcon_Ralts,
- gMonIcon_Kirlia,
- gMonIcon_Gardevoir,
- gMonIcon_Bagon,
- gMonIcon_Shelgon,
- gMonIcon_Salamence,
- gMonIcon_Beldum,
- gMonIcon_Metang,
- gMonIcon_Metagross,
- gMonIcon_Regirock,
- gMonIcon_Regice,
- gMonIcon_Registeel,
- gMonIcon_Kyogre,
- gMonIcon_Groudon,
- gMonIcon_Rayquaza,
- gMonIcon_Latias,
- gMonIcon_Latios,
- gMonIcon_Jirachi,
- gMonIcon_Deoxys,
- gMonIcon_Chimecho,
- gMonIcon_Egg,
- gMonIcon_UnownB,
- gMonIcon_UnownC,
- gMonIcon_UnownD,
- gMonIcon_UnownE,
- gMonIcon_UnownF,
- gMonIcon_UnownG,
- gMonIcon_UnownH,
- gMonIcon_UnownI,
- gMonIcon_UnownJ,
- gMonIcon_UnownK,
- gMonIcon_UnownL,
- gMonIcon_UnownM,
- gMonIcon_UnownN,
- gMonIcon_UnownO,
- gMonIcon_UnownP,
- gMonIcon_UnownQ,
- gMonIcon_UnownR,
- gMonIcon_UnownS,
- gMonIcon_UnownT,
- gMonIcon_UnownU,
- gMonIcon_UnownV,
- gMonIcon_UnownW,
- gMonIcon_UnownX,
- gMonIcon_UnownY,
- gMonIcon_UnownZ,
- gMonIcon_UnownExclamationMark,
- gMonIcon_UnownQuestionMark,
+ [SPECIES_NONE] = gMonIcon_Bulbasaur,
+ [SPECIES_BULBASAUR] = gMonIcon_Bulbasaur,
+ [SPECIES_IVYSAUR] = gMonIcon_Ivysaur,
+ [SPECIES_VENUSAUR] = gMonIcon_Venusaur,
+ [SPECIES_CHARMANDER] = gMonIcon_Charmander,
+ [SPECIES_CHARMELEON] = gMonIcon_Charmeleon,
+ [SPECIES_CHARIZARD] = gMonIcon_Charizard,
+ [SPECIES_SQUIRTLE] = gMonIcon_Squirtle,
+ [SPECIES_WARTORTLE] = gMonIcon_Wartortle,
+ [SPECIES_BLASTOISE] = gMonIcon_Blastoise,
+ [SPECIES_CATERPIE] = gMonIcon_Caterpie,
+ [SPECIES_METAPOD] = gMonIcon_Metapod,
+ [SPECIES_BUTTERFREE] = gMonIcon_Butterfree,
+ [SPECIES_WEEDLE] = gMonIcon_Weedle,
+ [SPECIES_KAKUNA] = gMonIcon_Kakuna,
+ [SPECIES_BEEDRILL] = gMonIcon_Beedrill,
+ [SPECIES_PIDGEY] = gMonIcon_Pidgey,
+ [SPECIES_PIDGEOTTO] = gMonIcon_Pidgeotto,
+ [SPECIES_PIDGEOT] = gMonIcon_Pidgeot,
+ [SPECIES_RATTATA] = gMonIcon_Rattata,
+ [SPECIES_RATICATE] = gMonIcon_Raticate,
+ [SPECIES_SPEAROW] = gMonIcon_Spearow,
+ [SPECIES_FEAROW] = gMonIcon_Fearow,
+ [SPECIES_EKANS] = gMonIcon_Ekans,
+ [SPECIES_ARBOK] = gMonIcon_Arbok,
+ [SPECIES_PIKACHU] = gMonIcon_Pikachu,
+ [SPECIES_RAICHU] = gMonIcon_Raichu,
+ [SPECIES_SANDSHREW] = gMonIcon_Sandshrew,
+ [SPECIES_SANDSLASH] = gMonIcon_Sandslash,
+ [SPECIES_NIDORAN_F] = gMonIcon_NidoranF,
+ [SPECIES_NIDORINA] = gMonIcon_Nidorina,
+ [SPECIES_NIDOQUEEN] = gMonIcon_Nidoqueen,
+ [SPECIES_NIDORAN_M] = gMonIcon_NidoranM,
+ [SPECIES_NIDORINO] = gMonIcon_Nidorino,
+ [SPECIES_NIDOKING] = gMonIcon_Nidoking,
+ [SPECIES_CLEFAIRY] = gMonIcon_Clefairy,
+ [SPECIES_CLEFABLE] = gMonIcon_Clefable,
+ [SPECIES_VULPIX] = gMonIcon_Vulpix,
+ [SPECIES_NINETALES] = gMonIcon_Ninetales,
+ [SPECIES_JIGGLYPUFF] = gMonIcon_Jigglypuff,
+ [SPECIES_WIGGLYTUFF] = gMonIcon_Wigglytuff,
+ [SPECIES_ZUBAT] = gMonIcon_Zubat,
+ [SPECIES_GOLBAT] = gMonIcon_Golbat,
+ [SPECIES_ODDISH] = gMonIcon_Oddish,
+ [SPECIES_GLOOM] = gMonIcon_Gloom,
+ [SPECIES_VILEPLUME] = gMonIcon_Vileplume,
+ [SPECIES_PARAS] = gMonIcon_Paras,
+ [SPECIES_PARASECT] = gMonIcon_Parasect,
+ [SPECIES_VENONAT] = gMonIcon_Venonat,
+ [SPECIES_VENOMOTH] = gMonIcon_Venomoth,
+ [SPECIES_DIGLETT] = gMonIcon_Diglett,
+ [SPECIES_DUGTRIO] = gMonIcon_Dugtrio,
+ [SPECIES_MEOWTH] = gMonIcon_Meowth,
+ [SPECIES_PERSIAN] = gMonIcon_Persian,
+ [SPECIES_PSYDUCK] = gMonIcon_Psyduck,
+ [SPECIES_GOLDUCK] = gMonIcon_Golduck,
+ [SPECIES_MANKEY] = gMonIcon_Mankey,
+ [SPECIES_PRIMEAPE] = gMonIcon_Primeape,
+ [SPECIES_GROWLITHE] = gMonIcon_Growlithe,
+ [SPECIES_ARCANINE] = gMonIcon_Arcanine,
+ [SPECIES_POLIWAG] = gMonIcon_Poliwag,
+ [SPECIES_POLIWHIRL] = gMonIcon_Poliwhirl,
+ [SPECIES_POLIWRATH] = gMonIcon_Poliwrath,
+ [SPECIES_ABRA] = gMonIcon_Abra,
+ [SPECIES_KADABRA] = gMonIcon_Kadabra,
+ [SPECIES_ALAKAZAM] = gMonIcon_Alakazam,
+ [SPECIES_MACHOP] = gMonIcon_Machop,
+ [SPECIES_MACHOKE] = gMonIcon_Machoke,
+ [SPECIES_MACHAMP] = gMonIcon_Machamp,
+ [SPECIES_BELLSPROUT] = gMonIcon_Bellsprout,
+ [SPECIES_WEEPINBELL] = gMonIcon_Weepinbell,
+ [SPECIES_VICTREEBEL] = gMonIcon_Victreebel,
+ [SPECIES_TENTACOOL] = gMonIcon_Tentacool,
+ [SPECIES_TENTACRUEL] = gMonIcon_Tentacruel,
+ [SPECIES_GEODUDE] = gMonIcon_Geodude,
+ [SPECIES_GRAVELER] = gMonIcon_Graveler,
+ [SPECIES_GOLEM] = gMonIcon_Golem,
+ [SPECIES_PONYTA] = gMonIcon_Ponyta,
+ [SPECIES_RAPIDASH] = gMonIcon_Rapidash,
+ [SPECIES_SLOWPOKE] = gMonIcon_Slowpoke,
+ [SPECIES_SLOWBRO] = gMonIcon_Slowbro,
+ [SPECIES_MAGNEMITE] = gMonIcon_Magnemite,
+ [SPECIES_MAGNETON] = gMonIcon_Magneton,
+ [SPECIES_FARFETCHD] = gMonIcon_Farfetchd,
+ [SPECIES_DODUO] = gMonIcon_Doduo,
+ [SPECIES_DODRIO] = gMonIcon_Dodrio,
+ [SPECIES_SEEL] = gMonIcon_Seel,
+ [SPECIES_DEWGONG] = gMonIcon_Dewgong,
+ [SPECIES_GRIMER] = gMonIcon_Grimer,
+ [SPECIES_MUK] = gMonIcon_Muk,
+ [SPECIES_SHELLDER] = gMonIcon_Shellder,
+ [SPECIES_CLOYSTER] = gMonIcon_Cloyster,
+ [SPECIES_GASTLY] = gMonIcon_Gastly,
+ [SPECIES_HAUNTER] = gMonIcon_Haunter,
+ [SPECIES_GENGAR] = gMonIcon_Gengar,
+ [SPECIES_ONIX] = gMonIcon_Onix,
+ [SPECIES_DROWZEE] = gMonIcon_Drowzee,
+ [SPECIES_HYPNO] = gMonIcon_Hypno,
+ [SPECIES_KRABBY] = gMonIcon_Krabby,
+ [SPECIES_KINGLER] = gMonIcon_Kingler,
+ [SPECIES_VOLTORB] = gMonIcon_Voltorb,
+ [SPECIES_ELECTRODE] = gMonIcon_Electrode,
+ [SPECIES_EXEGGCUTE] = gMonIcon_Exeggcute,
+ [SPECIES_EXEGGUTOR] = gMonIcon_Exeggutor,
+ [SPECIES_CUBONE] = gMonIcon_Cubone,
+ [SPECIES_MAROWAK] = gMonIcon_Marowak,
+ [SPECIES_HITMONLEE] = gMonIcon_Hitmonlee,
+ [SPECIES_HITMONCHAN] = gMonIcon_Hitmonchan,
+ [SPECIES_LICKITUNG] = gMonIcon_Lickitung,
+ [SPECIES_KOFFING] = gMonIcon_Koffing,
+ [SPECIES_WEEZING] = gMonIcon_Weezing,
+ [SPECIES_RHYHORN] = gMonIcon_Rhyhorn,
+ [SPECIES_RHYDON] = gMonIcon_Rhydon,
+ [SPECIES_CHANSEY] = gMonIcon_Chansey,
+ [SPECIES_TANGELA] = gMonIcon_Tangela,
+ [SPECIES_KANGASKHAN] = gMonIcon_Kangaskhan,
+ [SPECIES_HORSEA] = gMonIcon_Horsea,
+ [SPECIES_SEADRA] = gMonIcon_Seadra,
+ [SPECIES_GOLDEEN] = gMonIcon_Goldeen,
+ [SPECIES_SEAKING] = gMonIcon_Seaking,
+ [SPECIES_STARYU] = gMonIcon_Staryu,
+ [SPECIES_STARMIE] = gMonIcon_Starmie,
+ [SPECIES_MR_MIME] = gMonIcon_Mrmime,
+ [SPECIES_SCYTHER] = gMonIcon_Scyther,
+ [SPECIES_JYNX] = gMonIcon_Jynx,
+ [SPECIES_ELECTABUZZ] = gMonIcon_Electabuzz,
+ [SPECIES_MAGMAR] = gMonIcon_Magmar,
+ [SPECIES_PINSIR] = gMonIcon_Pinsir,
+ [SPECIES_TAUROS] = gMonIcon_Tauros,
+ [SPECIES_MAGIKARP] = gMonIcon_Magikarp,
+ [SPECIES_GYARADOS] = gMonIcon_Gyarados,
+ [SPECIES_LAPRAS] = gMonIcon_Lapras,
+ [SPECIES_DITTO] = gMonIcon_Ditto,
+ [SPECIES_EEVEE] = gMonIcon_Eevee,
+ [SPECIES_VAPOREON] = gMonIcon_Vaporeon,
+ [SPECIES_JOLTEON] = gMonIcon_Jolteon,
+ [SPECIES_FLAREON] = gMonIcon_Flareon,
+ [SPECIES_PORYGON] = gMonIcon_Porygon,
+ [SPECIES_OMANYTE] = gMonIcon_Omanyte,
+ [SPECIES_OMASTAR] = gMonIcon_Omastar,
+ [SPECIES_KABUTO] = gMonIcon_Kabuto,
+ [SPECIES_KABUTOPS] = gMonIcon_Kabutops,
+ [SPECIES_AERODACTYL] = gMonIcon_Aerodactyl,
+ [SPECIES_SNORLAX] = gMonIcon_Snorlax,
+ [SPECIES_ARTICUNO] = gMonIcon_Articuno,
+ [SPECIES_ZAPDOS] = gMonIcon_Zapdos,
+ [SPECIES_MOLTRES] = gMonIcon_Moltres,
+ [SPECIES_DRATINI] = gMonIcon_Dratini,
+ [SPECIES_DRAGONAIR] = gMonIcon_Dragonair,
+ [SPECIES_DRAGONITE] = gMonIcon_Dragonite,
+ [SPECIES_MEWTWO] = gMonIcon_Mewtwo,
+ [SPECIES_MEW] = gMonIcon_Mew,
+ [SPECIES_CHIKORITA] = gMonIcon_Chikorita,
+ [SPECIES_BAYLEEF] = gMonIcon_Bayleef,
+ [SPECIES_MEGANIUM] = gMonIcon_Meganium,
+ [SPECIES_CYNDAQUIL] = gMonIcon_Cyndaquil,
+ [SPECIES_QUILAVA] = gMonIcon_Quilava,
+ [SPECIES_TYPHLOSION] = gMonIcon_Typhlosion,
+ [SPECIES_TOTODILE] = gMonIcon_Totodile,
+ [SPECIES_CROCONAW] = gMonIcon_Croconaw,
+ [SPECIES_FERALIGATR] = gMonIcon_Feraligatr,
+ [SPECIES_SENTRET] = gMonIcon_Sentret,
+ [SPECIES_FURRET] = gMonIcon_Furret,
+ [SPECIES_HOOTHOOT] = gMonIcon_Hoothoot,
+ [SPECIES_NOCTOWL] = gMonIcon_Noctowl,
+ [SPECIES_LEDYBA] = gMonIcon_Ledyba,
+ [SPECIES_LEDIAN] = gMonIcon_Ledian,
+ [SPECIES_SPINARAK] = gMonIcon_Spinarak,
+ [SPECIES_ARIADOS] = gMonIcon_Ariados,
+ [SPECIES_CROBAT] = gMonIcon_Crobat,
+ [SPECIES_CHINCHOU] = gMonIcon_Chinchou,
+ [SPECIES_LANTURN] = gMonIcon_Lanturn,
+ [SPECIES_PICHU] = gMonIcon_Pichu,
+ [SPECIES_CLEFFA] = gMonIcon_Cleffa,
+ [SPECIES_IGGLYBUFF] = gMonIcon_Igglybuff,
+ [SPECIES_TOGEPI] = gMonIcon_Togepi,
+ [SPECIES_TOGETIC] = gMonIcon_Togetic,
+ [SPECIES_NATU] = gMonIcon_Natu,
+ [SPECIES_XATU] = gMonIcon_Xatu,
+ [SPECIES_MAREEP] = gMonIcon_Mareep,
+ [SPECIES_FLAAFFY] = gMonIcon_Flaaffy,
+ [SPECIES_AMPHAROS] = gMonIcon_Ampharos,
+ [SPECIES_BELLOSSOM] = gMonIcon_Bellossom,
+ [SPECIES_MARILL] = gMonIcon_Marill,
+ [SPECIES_AZUMARILL] = gMonIcon_Azumarill,
+ [SPECIES_SUDOWOODO] = gMonIcon_Sudowoodo,
+ [SPECIES_POLITOED] = gMonIcon_Politoed,
+ [SPECIES_HOPPIP] = gMonIcon_Hoppip,
+ [SPECIES_SKIPLOOM] = gMonIcon_Skiploom,
+ [SPECIES_JUMPLUFF] = gMonIcon_Jumpluff,
+ [SPECIES_AIPOM] = gMonIcon_Aipom,
+ [SPECIES_SUNKERN] = gMonIcon_Sunkern,
+ [SPECIES_SUNFLORA] = gMonIcon_Sunflora,
+ [SPECIES_YANMA] = gMonIcon_Yanma,
+ [SPECIES_WOOPER] = gMonIcon_Wooper,
+ [SPECIES_QUAGSIRE] = gMonIcon_Quagsire,
+ [SPECIES_ESPEON] = gMonIcon_Espeon,
+ [SPECIES_UMBREON] = gMonIcon_Umbreon,
+ [SPECIES_MURKROW] = gMonIcon_Murkrow,
+ [SPECIES_SLOWKING] = gMonIcon_Slowking,
+ [SPECIES_MISDREAVUS] = gMonIcon_Misdreavus,
+ [SPECIES_UNOWN] = gMonIcon_UnownA,
+ [SPECIES_WOBBUFFET] = gMonIcon_Wobbuffet,
+ [SPECIES_GIRAFARIG] = gMonIcon_Girafarig,
+ [SPECIES_PINECO] = gMonIcon_Pineco,
+ [SPECIES_FORRETRESS] = gMonIcon_Forretress,
+ [SPECIES_DUNSPARCE] = gMonIcon_Dunsparce,
+ [SPECIES_GLIGAR] = gMonIcon_Gligar,
+ [SPECIES_STEELIX] = gMonIcon_Steelix,
+ [SPECIES_SNUBBULL] = gMonIcon_Snubbull,
+ [SPECIES_GRANBULL] = gMonIcon_Granbull,
+ [SPECIES_QWILFISH] = gMonIcon_Qwilfish,
+ [SPECIES_SCIZOR] = gMonIcon_Scizor,
+ [SPECIES_SHUCKLE] = gMonIcon_Shuckle,
+ [SPECIES_HERACROSS] = gMonIcon_Heracross,
+ [SPECIES_SNEASEL] = gMonIcon_Sneasel,
+ [SPECIES_TEDDIURSA] = gMonIcon_Teddiursa,
+ [SPECIES_URSARING] = gMonIcon_Ursaring,
+ [SPECIES_SLUGMA] = gMonIcon_Slugma,
+ [SPECIES_MAGCARGO] = gMonIcon_Magcargo,
+ [SPECIES_SWINUB] = gMonIcon_Swinub,
+ [SPECIES_PILOSWINE] = gMonIcon_Piloswine,
+ [SPECIES_CORSOLA] = gMonIcon_Corsola,
+ [SPECIES_REMORAID] = gMonIcon_Remoraid,
+ [SPECIES_OCTILLERY] = gMonIcon_Octillery,
+ [SPECIES_DELIBIRD] = gMonIcon_Delibird,
+ [SPECIES_MANTINE] = gMonIcon_Mantine,
+ [SPECIES_SKARMORY] = gMonIcon_Skarmory,
+ [SPECIES_HOUNDOUR] = gMonIcon_Houndour,
+ [SPECIES_HOUNDOOM] = gMonIcon_Houndoom,
+ [SPECIES_KINGDRA] = gMonIcon_Kingdra,
+ [SPECIES_PHANPY] = gMonIcon_Phanpy,
+ [SPECIES_DONPHAN] = gMonIcon_Donphan,
+ [SPECIES_PORYGON2] = gMonIcon_Porygon2,
+ [SPECIES_STANTLER] = gMonIcon_Stantler,
+ [SPECIES_SMEARGLE] = gMonIcon_Smeargle,
+ [SPECIES_TYROGUE] = gMonIcon_Tyrogue,
+ [SPECIES_HITMONTOP] = gMonIcon_Hitmontop,
+ [SPECIES_SMOOCHUM] = gMonIcon_Smoochum,
+ [SPECIES_ELEKID] = gMonIcon_Elekid,
+ [SPECIES_MAGBY] = gMonIcon_Magby,
+ [SPECIES_MILTANK] = gMonIcon_Miltank,
+ [SPECIES_BLISSEY] = gMonIcon_Blissey,
+ [SPECIES_RAIKOU] = gMonIcon_Raikou,
+ [SPECIES_ENTEI] = gMonIcon_Entei,
+ [SPECIES_SUICUNE] = gMonIcon_Suicune,
+ [SPECIES_LARVITAR] = gMonIcon_Larvitar,
+ [SPECIES_PUPITAR] = gMonIcon_Pupitar,
+ [SPECIES_TYRANITAR] = gMonIcon_Tyranitar,
+ [SPECIES_LUGIA] = gMonIcon_Lugia,
+ [SPECIES_HO_OH] = gMonIcon_HoOh,
+ [SPECIES_CELEBI] = gMonIcon_Celebi,
+ [SPECIES_OLD_UNOWN_B] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_C] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_D] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_E] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_F] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_G] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_H] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_I] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_J] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_K] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_L] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_M] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_N] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_O] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_P] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_Q] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_R] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_S] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_T] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_U] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_V] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_W] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_X] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_Y] = gMonIcon_QuestionMark,
+ [SPECIES_OLD_UNOWN_Z] = gMonIcon_QuestionMark,
+ [SPECIES_TREECKO] = gMonIcon_Treecko,
+ [SPECIES_GROVYLE] = gMonIcon_Grovyle,
+ [SPECIES_SCEPTILE] = gMonIcon_Sceptile,
+ [SPECIES_TORCHIC] = gMonIcon_Torchic,
+ [SPECIES_COMBUSKEN] = gMonIcon_Combusken,
+ [SPECIES_BLAZIKEN] = gMonIcon_Blaziken,
+ [SPECIES_MUDKIP] = gMonIcon_Mudkip,
+ [SPECIES_MARSHTOMP] = gMonIcon_Marshtomp,
+ [SPECIES_SWAMPERT] = gMonIcon_Swampert,
+ [SPECIES_POOCHYENA] = gMonIcon_Poochyena,
+ [SPECIES_MIGHTYENA] = gMonIcon_Mightyena,
+ [SPECIES_ZIGZAGOON] = gMonIcon_Zigzagoon,
+ [SPECIES_LINOONE] = gMonIcon_Linoone,
+ [SPECIES_WURMPLE] = gMonIcon_Wurmple,
+ [SPECIES_SILCOON] = gMonIcon_Silcoon,
+ [SPECIES_BEAUTIFLY] = gMonIcon_Beautifly,
+ [SPECIES_CASCOON] = gMonIcon_Cascoon,
+ [SPECIES_DUSTOX] = gMonIcon_Dustox,
+ [SPECIES_LOTAD] = gMonIcon_Lotad,
+ [SPECIES_LOMBRE] = gMonIcon_Lombre,
+ [SPECIES_LUDICOLO] = gMonIcon_Ludicolo,
+ [SPECIES_SEEDOT] = gMonIcon_Seedot,
+ [SPECIES_NUZLEAF] = gMonIcon_Nuzleaf,
+ [SPECIES_SHIFTRY] = gMonIcon_Shiftry,
+ [SPECIES_NINCADA] = gMonIcon_Nincada,
+ [SPECIES_NINJASK] = gMonIcon_Ninjask,
+ [SPECIES_SHEDINJA] = gMonIcon_Shedinja,
+ [SPECIES_TAILLOW] = gMonIcon_Taillow,
+ [SPECIES_SWELLOW] = gMonIcon_Swellow,
+ [SPECIES_SHROOMISH] = gMonIcon_Shroomish,
+ [SPECIES_BRELOOM] = gMonIcon_Breloom,
+ [SPECIES_SPINDA] = gMonIcon_Spinda,
+ [SPECIES_WINGULL] = gMonIcon_Wingull,
+ [SPECIES_PELIPPER] = gMonIcon_Pelipper,
+ [SPECIES_SURSKIT] = gMonIcon_Surskit,
+ [SPECIES_MASQUERAIN] = gMonIcon_Masquerain,
+ [SPECIES_WAILMER] = gMonIcon_Wailmer,
+ [SPECIES_WAILORD] = gMonIcon_Wailord,
+ [SPECIES_SKITTY] = gMonIcon_Skitty,
+ [SPECIES_DELCATTY] = gMonIcon_Delcatty,
+ [SPECIES_KECLEON] = gMonIcon_Kecleon,
+ [SPECIES_BALTOY] = gMonIcon_Baltoy,
+ [SPECIES_CLAYDOL] = gMonIcon_Claydol,
+ [SPECIES_NOSEPASS] = gMonIcon_Nosepass,
+ [SPECIES_TORKOAL] = gMonIcon_Torkoal,
+ [SPECIES_SABLEYE] = gMonIcon_Sableye,
+ [SPECIES_BARBOACH] = gMonIcon_Barboach,
+ [SPECIES_WHISCASH] = gMonIcon_Whiscash,
+ [SPECIES_LUVDISC] = gMonIcon_Luvdisc,
+ [SPECIES_CORPHISH] = gMonIcon_Corphish,
+ [SPECIES_CRAWDAUNT] = gMonIcon_Crawdaunt,
+ [SPECIES_FEEBAS] = gMonIcon_Feebas,
+ [SPECIES_MILOTIC] = gMonIcon_Milotic,
+ [SPECIES_CARVANHA] = gMonIcon_Carvanha,
+ [SPECIES_SHARPEDO] = gMonIcon_Sharpedo,
+ [SPECIES_TRAPINCH] = gMonIcon_Trapinch,
+ [SPECIES_VIBRAVA] = gMonIcon_Vibrava,
+ [SPECIES_FLYGON] = gMonIcon_Flygon,
+ [SPECIES_MAKUHITA] = gMonIcon_Makuhita,
+ [SPECIES_HARIYAMA] = gMonIcon_Hariyama,
+ [SPECIES_ELECTRIKE] = gMonIcon_Electrike,
+ [SPECIES_MANECTRIC] = gMonIcon_Manectric,
+ [SPECIES_NUMEL] = gMonIcon_Numel,
+ [SPECIES_CAMERUPT] = gMonIcon_Camerupt,
+ [SPECIES_SPHEAL] = gMonIcon_Spheal,
+ [SPECIES_SEALEO] = gMonIcon_Sealeo,
+ [SPECIES_WALREIN] = gMonIcon_Walrein,
+ [SPECIES_CACNEA] = gMonIcon_Cacnea,
+ [SPECIES_CACTURNE] = gMonIcon_Cacturne,
+ [SPECIES_SNORUNT] = gMonIcon_Snorunt,
+ [SPECIES_GLALIE] = gMonIcon_Glalie,
+ [SPECIES_LUNATONE] = gMonIcon_Lunatone,
+ [SPECIES_SOLROCK] = gMonIcon_Solrock,
+ [SPECIES_AZURILL] = gMonIcon_Azurill,
+ [SPECIES_SPOINK] = gMonIcon_Spoink,
+ [SPECIES_GRUMPIG] = gMonIcon_Grumpig,
+ [SPECIES_PLUSLE] = gMonIcon_Plusle,
+ [SPECIES_MINUN] = gMonIcon_Minun,
+ [SPECIES_MAWILE] = gMonIcon_Mawile,
+ [SPECIES_MEDITITE] = gMonIcon_Meditite,
+ [SPECIES_MEDICHAM] = gMonIcon_Medicham,
+ [SPECIES_SWABLU] = gMonIcon_Swablu,
+ [SPECIES_ALTARIA] = gMonIcon_Altaria,
+ [SPECIES_WYNAUT] = gMonIcon_Wynaut,
+ [SPECIES_DUSKULL] = gMonIcon_Duskull,
+ [SPECIES_DUSCLOPS] = gMonIcon_Dusclops,
+ [SPECIES_ROSELIA] = gMonIcon_Roselia,
+ [SPECIES_SLAKOTH] = gMonIcon_Slakoth,
+ [SPECIES_VIGOROTH] = gMonIcon_Vigoroth,
+ [SPECIES_SLAKING] = gMonIcon_Slaking,
+ [SPECIES_GULPIN] = gMonIcon_Gulpin,
+ [SPECIES_SWALOT] = gMonIcon_Swalot,
+ [SPECIES_TROPIUS] = gMonIcon_Tropius,
+ [SPECIES_WHISMUR] = gMonIcon_Whismur,
+ [SPECIES_LOUDRED] = gMonIcon_Loudred,
+ [SPECIES_EXPLOUD] = gMonIcon_Exploud,
+ [SPECIES_CLAMPERL] = gMonIcon_Clamperl,
+ [SPECIES_HUNTAIL] = gMonIcon_Huntail,
+ [SPECIES_GOREBYSS] = gMonIcon_Gorebyss,
+ [SPECIES_ABSOL] = gMonIcon_Absol,
+ [SPECIES_SHUPPET] = gMonIcon_Shuppet,
+ [SPECIES_BANETTE] = gMonIcon_Banette,
+ [SPECIES_SEVIPER] = gMonIcon_Seviper,
+ [SPECIES_ZANGOOSE] = gMonIcon_Zangoose,
+ [SPECIES_RELICANTH] = gMonIcon_Relicanth,
+ [SPECIES_ARON] = gMonIcon_Aron,
+ [SPECIES_LAIRON] = gMonIcon_Lairon,
+ [SPECIES_AGGRON] = gMonIcon_Aggron,
+ [SPECIES_CASTFORM] = gMonIcon_Castform,
+ [SPECIES_VOLBEAT] = gMonIcon_Volbeat,
+ [SPECIES_ILLUMISE] = gMonIcon_Illumise,
+ [SPECIES_LILEEP] = gMonIcon_Lileep,
+ [SPECIES_CRADILY] = gMonIcon_Cradily,
+ [SPECIES_ANORITH] = gMonIcon_Anorith,
+ [SPECIES_ARMALDO] = gMonIcon_Armaldo,
+ [SPECIES_RALTS] = gMonIcon_Ralts,
+ [SPECIES_KIRLIA] = gMonIcon_Kirlia,
+ [SPECIES_GARDEVOIR] = gMonIcon_Gardevoir,
+ [SPECIES_BAGON] = gMonIcon_Bagon,
+ [SPECIES_SHELGON] = gMonIcon_Shelgon,
+ [SPECIES_SALAMENCE] = gMonIcon_Salamence,
+ [SPECIES_BELDUM] = gMonIcon_Beldum,
+ [SPECIES_METANG] = gMonIcon_Metang,
+ [SPECIES_METAGROSS] = gMonIcon_Metagross,
+ [SPECIES_REGIROCK] = gMonIcon_Regirock,
+ [SPECIES_REGICE] = gMonIcon_Regice,
+ [SPECIES_REGISTEEL] = gMonIcon_Registeel,
+ [SPECIES_KYOGRE] = gMonIcon_Kyogre,
+ [SPECIES_GROUDON] = gMonIcon_Groudon,
+ [SPECIES_RAYQUAZA] = gMonIcon_Rayquaza,
+ [SPECIES_LATIAS] = gMonIcon_Latias,
+ [SPECIES_LATIOS] = gMonIcon_Latios,
+ [SPECIES_JIRACHI] = gMonIcon_Jirachi,
+ [SPECIES_DEOXYS] = gMonIcon_Deoxys,
+ [SPECIES_CHIMECHO] = gMonIcon_Chimecho,
+ [SPECIES_EGG] = gMonIcon_Egg,
+ [SPECIES_UNOWN_B] = gMonIcon_UnownB,
+ [SPECIES_UNOWN_C] = gMonIcon_UnownC,
+ [SPECIES_UNOWN_D] = gMonIcon_UnownD,
+ [SPECIES_UNOWN_E] = gMonIcon_UnownE,
+ [SPECIES_UNOWN_F] = gMonIcon_UnownF,
+ [SPECIES_UNOWN_G] = gMonIcon_UnownG,
+ [SPECIES_UNOWN_H] = gMonIcon_UnownH,
+ [SPECIES_UNOWN_I] = gMonIcon_UnownI,
+ [SPECIES_UNOWN_J] = gMonIcon_UnownJ,
+ [SPECIES_UNOWN_K] = gMonIcon_UnownK,
+ [SPECIES_UNOWN_L] = gMonIcon_UnownL,
+ [SPECIES_UNOWN_M] = gMonIcon_UnownM,
+ [SPECIES_UNOWN_N] = gMonIcon_UnownN,
+ [SPECIES_UNOWN_O] = gMonIcon_UnownO,
+ [SPECIES_UNOWN_P] = gMonIcon_UnownP,
+ [SPECIES_UNOWN_Q] = gMonIcon_UnownQ,
+ [SPECIES_UNOWN_R] = gMonIcon_UnownR,
+ [SPECIES_UNOWN_S] = gMonIcon_UnownS,
+ [SPECIES_UNOWN_T] = gMonIcon_UnownT,
+ [SPECIES_UNOWN_U] = gMonIcon_UnownU,
+ [SPECIES_UNOWN_V] = gMonIcon_UnownV,
+ [SPECIES_UNOWN_W] = gMonIcon_UnownW,
+ [SPECIES_UNOWN_X] = gMonIcon_UnownX,
+ [SPECIES_UNOWN_Y] = gMonIcon_UnownY,
+ [SPECIES_UNOWN_Z] = gMonIcon_UnownZ,
+ [SPECIES_UNOWN_EMARK] = gMonIcon_UnownExclamationMark,
+ [SPECIES_UNOWN_QMARK] = gMonIcon_UnownQuestionMark,
};
const u8 gMonIconPaletteIndices[] =
@@ -1138,7 +1138,7 @@ void sub_80D2EF8(struct Sprite *sprite)
void LoadMonIconPalettes(void)
{
u8 i;
- for (i = 0; i < 6; i++)
+ for (i = 0; i < ARRAY_COUNT(gMonIconPaletteTable); i++)
LoadSpritePalette(&gMonIconPaletteTable[i]);
}
@@ -1192,7 +1192,7 @@ void sub_80D3014(struct Sprite *sprite)
const u8* GetMonIconTiles(u16 species, bool32 extra)
{
const u8* iconSprite = gMonIconTable[species];
- if(species == SPECIES_DEOXYS && extra == TRUE)
+ if (species == SPECIES_DEOXYS && extra == TRUE)
{
iconSprite = (const u8*)(0x400 + (u32)iconSprite); //WTF?
}
@@ -1308,5 +1308,3 @@ void sub_80D32C8(struct Sprite *sprite, u8 animNum)
sprite->animDelayCounter = 0;
sprite->animCmdIndex = 0;
}
-
-
diff --git a/src/scrcmd.c b/src/scrcmd.c
index 314504600..125a57c01 100644
--- a/src/scrcmd.c
+++ b/src/scrcmd.c
@@ -281,7 +281,7 @@ bool8 ScrCmd_callstd_if(struct ScriptContext *ctx)
return FALSE;
}
-bool8 ScrCmd_gotoram(struct ScriptContext *ctx)
+bool8 ScrCmd_returnram(struct ScriptContext *ctx)
{
ScriptJump(ctx, gUnknown_020375C0);
return FALSE;
@@ -2215,9 +2215,9 @@ bool8 ScrCmd_checkmonobedience(struct ScriptContext *ctx)
return FALSE;
}
-bool8 ScrCmd_cmdCF(struct ScriptContext *ctx)
+bool8 ScrCmd_gotoram(struct ScriptContext *ctx)
{
- const u8* v1 = sub_8099244();
+ const u8* v1 = GetSavedRamScriptIfValid();
if (v1)
{
diff --git a/src/script.c b/src/script.c
index cb06300bf..27476dba3 100644
--- a/src/script.c
+++ b/src/script.c
@@ -386,7 +386,7 @@ const u8 *GetRamScript(u8 objectId, const u8 *script)
}
}
-bool32 sub_80991F8(void)
+bool32 ValidateSavedRamScript(void)
{
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
if (scriptData->magic != RAM_SCRIPT_MAGIC)
@@ -402,7 +402,7 @@ bool32 sub_80991F8(void)
return TRUE;
}
-u8 *sub_8099244(void)
+u8 *GetSavedRamScriptIfValid(void)
{
struct RamScriptData *scriptData = &gSaveBlock1Ptr->ramScript.data;
if (!ValidateReceivedWonderCard())
@@ -426,7 +426,7 @@ u8 *sub_8099244(void)
}
}
-void sub_80992A0(u8 *script, u16 scriptSize)
+void InitRamScript_NoEventObject(u8 *script, u16 scriptSize)
{
if (scriptSize > sizeof(gSaveBlock1Ptr->ramScript.data.script))
scriptSize = sizeof(gSaveBlock1Ptr->ramScript.data.script);
diff --git a/src/script_menu.c b/src/script_menu.c
index c7523a370..082253e35 100644
--- a/src/script_menu.c
+++ b/src/script_menu.c
@@ -1183,7 +1183,7 @@ static void Task_HandleMultichoiceInput(u8 taskId)
{
gSpecialVar_Result = selection;
}
- sub_80E2A78(tWindowId);
+ ClearToTransparentAndRemoveWindow(tWindowId);
DestroyTask(taskId);
EnableBothScriptContexts();
}
@@ -1219,8 +1219,6 @@ bool8 IsScriptActive(void)
static void Task_HandleYesNoInput(u8 taskId)
{
- u8 left, top;
-
if (gTasks[taskId].tRight < 5)
{
gTasks[taskId].tRight++;
@@ -1229,9 +1227,9 @@ static void Task_HandleYesNoInput(u8 taskId)
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
- case -2:
+ case MENU_NOTHING_CHOSEN:
return;
- case -1:
+ case MENU_B_PRESSED:
case 1:
PlaySE(SE_SELECT);
gSpecialVar_Result = 0;
@@ -1247,8 +1245,6 @@ static void Task_HandleYesNoInput(u8 taskId)
bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPress, u8 columnCount)
{
- u8 bottom = 0;
-
if (FuncIsActiveTask(Task_HandleMultichoiceGridInput) == TRUE)
{
return FALSE;
@@ -1256,10 +1252,8 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPr
else
{
u8 taskId;
- u8 unk2;
- int width;
- int i;
- u8 newWidth;
+ u8 rowCount, newWidth;
+ int i, width;
gSpecialVar_Result = 0xFF;
width = 0;
@@ -1272,15 +1266,15 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPr
newWidth = convert_pixel_width_to_tile_width(width);
left = sub_80E2D5C(left, columnCount * newWidth);
- unk2 = gMultichoiceLists[multichoiceId].count / columnCount;
+ rowCount = gMultichoiceLists[multichoiceId].count / columnCount;
taskId = CreateTask(Task_HandleMultichoiceGridInput, 80);
gTasks[taskId].tIgnoreBPress = ignoreBPress;
- gTasks[taskId].tWindowId = CreateWindowFromRect(left, top, columnCount * newWidth, unk2 * 2);
+ gTasks[taskId].tWindowId = CreateWindowFromRect(left, top, columnCount * newWidth, rowCount * 2);
SetStandardWindowBorderStyle(gTasks[taskId].tWindowId, 0);
- sub_81997AC(gTasks[taskId].tWindowId, newWidth * 8, columnCount, unk2, gMultichoiceLists[multichoiceId].list);
- sub_8199944(gTasks[taskId].tWindowId, newWidth * 8, columnCount, unk2, 0);
+ PrintMenuGridTable(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, gMultichoiceLists[multichoiceId].list);
+ sub_8199944(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, 0);
CopyWindowToVram(gTasks[taskId].tWindowId, 3);
return TRUE;
}
@@ -1291,23 +1285,24 @@ static void Task_HandleMultichoiceGridInput(u8 taskId)
s16 *data = gTasks[taskId].data;
s8 selection = Menu_ProcessInputGridLayout();
- if (selection != -2)
+ switch (selection)
{
- if (selection == -1)
- {
- if (tIgnoreBPress)
- return;
- PlaySE(SE_SELECT);
- gSpecialVar_Result = 0x7F;
- }
- else
- {
- gSpecialVar_Result = selection;
- }
- sub_80E2A78(tWindowId);
- DestroyTask(taskId);
- EnableBothScriptContexts();
+ case MENU_NOTHING_CHOSEN:
+ return;
+ case MENU_B_PRESSED:
+ if (tIgnoreBPress)
+ return;
+ PlaySE(SE_SELECT);
+ gSpecialVar_Result = 0x7F;
+ break;
+ default:
+ gSpecialVar_Result = selection;
+ break;
}
+
+ ClearToTransparentAndRemoveWindow(tWindowId);
+ DestroyTask(taskId);
+ EnableBothScriptContexts();
}
#undef tWindowId
@@ -1564,7 +1559,7 @@ static void Task_PokemonPicWindow(u8 taskId)
task->tState++;
break;
case 3:
- sub_80E2A78(task->tWindowId);
+ ClearToTransparentAndRemoveWindow(task->tWindowId);
DestroyTask(taskId);
break;
}
@@ -1628,7 +1623,7 @@ u8 CreateWindowFromRect(u8 x, u8 y, u8 width, u8 height)
return windowId;
}
-void sub_80E2A78(u8 windowId)
+void ClearToTransparentAndRemoveWindow(u8 windowId)
{
ClearStdWindowAndFrameToTransparent(windowId, TRUE);
RemoveWindow(windowId);
@@ -1638,30 +1633,30 @@ static void sub_80E2A94(u8 multichoiceId)
{
switch (multichoiceId)
{
- case 77:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBAC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 76:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BB9C[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 78:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBBC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 79:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBCC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 75:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBEC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 74:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBE0[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
+ case 77:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBAC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 76:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BB9C[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 78:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBBC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 79:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBCC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 75:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBEC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 74:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBE0[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
}
}
diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c
index 7e4c14531..ece030395 100755
--- a/src/script_pokemon_util_80F87D8.c
+++ b/src/script_pokemon_util_80F87D8.c
@@ -395,7 +395,7 @@ static void sub_80F8EE8(u8 taskId)
task->data[0]++;
break;
case 4:
- sub_80E2A78(gTasks[taskId].data[5]);
+ ClearToTransparentAndRemoveWindow(gTasks[taskId].data[5]);
DestroyTask(taskId);
break;
}
diff --git a/src/util.c b/src/util.c
index 47112774a..8aa54857a 100644
--- a/src/util.c
+++ b/src/util.c
@@ -218,7 +218,7 @@ int CountTrailingZeroBits(u32 value)
return 0;
}
-u16 CalcCRC16(u8 *data, s32 length)
+u16 CalcCRC16(const u8 *data, s32 length)
{
u16 i, j;
u16 crc = 0x1121;
@@ -237,7 +237,7 @@ u16 CalcCRC16(u8 *data, s32 length)
return ~crc;
}
-u16 CalcCRC16WithTable(u8 *data, u32 length)
+u16 CalcCRC16WithTable(const u8 *data, u32 length)
{
u16 i;
u16 crc = 0x1121;