diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mori_debug_menu.c | 2 | ||||
-rw-r--r-- | src/pokeblock.c | 45 | ||||
-rw-r--r-- | src/pokeblock_feed.c | 1015 | ||||
-rw-r--r-- | src/use_pokeblock.c | 266 | ||||
-rw-r--r-- | src/wild_encounter.c | 2 |
5 files changed, 1142 insertions, 188 deletions
diff --git a/src/mori_debug_menu.c b/src/mori_debug_menu.c index 273191192..4eadaa78b 100644 --- a/src/mori_debug_menu.c +++ b/src/mori_debug_menu.c @@ -134,7 +134,7 @@ s8 MoriDebugMenu_PokeblockCase(void) s32 loopCounter; for (loopCounter = 0; loopCounter <= 39; loopCounter++) - sub_810CA6C(loopCounter); + PokeblockClearIfExists(loopCounter); CloseMenu(); return 1; diff --git a/src/pokeblock.c b/src/pokeblock.c index 775280f6e..029bb066f 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -25,7 +25,6 @@ #include "sound.h" #include "songs.h" #include "safari_zone.h" -#include "use_pokeblock.h" #include "event_data.h" #include "pokeblock.h" @@ -582,7 +581,7 @@ static void sub_810BDAC(bool8 flag) v0 = ((i % 3) << 6) + 0x1a1 + (i / 3) * 6; if (gUnknown_02039248.unk0 + gUnknown_02039248.unk1 != gUnknown_02039248.unk2) { - if (sub_810CA9C(&gSaveBlock1.pokeblocks[gUnknown_02039248.unk0 + gUnknown_02039248.unk1], i + 1) > 0) + if (GetPokeblockData(&gSaveBlock1.pokeblocks[gUnknown_02039248.unk0 + gUnknown_02039248.unk1], i + 1) > 0) { gBGTilemapBuffers[2][v0] = (i << 12) + 23; gBGTilemapBuffers[2][v0 + 32] = (i << 12) + 24; @@ -894,7 +893,7 @@ static void sub_810C5EC(u8 taskId) static void sub_810C610(u8 taskId) { MenuZeroFillWindowRect(7, 6, 13, 11); - sub_810CA6C((gUnknown_02039248.unk0 + gUnknown_02039248.unk1)); + PokeblockClearIfExists((gUnknown_02039248.unk0 + gUnknown_02039248.unk1)); StringExpandPlaceholders(gStringVar4, gContestStatsText_WasThrownAway); DisplayItemMessageOnField(taskId, gStringVar4, sub_810C704, 0); sub_810BC98(); @@ -942,9 +941,9 @@ static void sub_810C748(u8 taskId) static void sub_810C788(u8 taskId) { - s16 v0 = sub_810CAE4(GetNature(&gEnemyParty[0]), &gSaveBlock1.pokeblocks[gScriptItemId]); + s16 v0 = PokeblockGetGain(GetNature(&gEnemyParty[0]), &gSaveBlock1.pokeblocks[gScriptItemId]); StringCopy(gBattleTextBuff1, gPokeblockNames[gSaveBlock1.pokeblocks[gScriptItemId].color]); - sub_810CA6C(gScriptItemId); + PokeblockClearIfExists(gScriptItemId); gScriptItemId = gSaveBlock1.pokeblocks[gScriptItemId].color << 8; if (v0 == 0) { @@ -967,7 +966,7 @@ static void sub_810C854(u8 taskId) SafariZoneActivatePokeblockFeeder(gScriptItemId); StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1.pokeblocks[gScriptItemId].color]); gScriptResult = gScriptItemId; - sub_810CA6C(gScriptItemId); + PokeblockClearIfExists(gScriptItemId); BeginNormalPaletteFade(-1, 0, 0, 16, 0); gTasks[taskId].func = sub_810C2C8; } @@ -1024,10 +1023,10 @@ u8 sub_810C9B0(struct Pokeblock *pokeblock) { u8 contestStat; u8 maxRating; - u8 rating = sub_810CA9C(pokeblock, 1); + u8 rating = GetPokeblockData(pokeblock, 1); for (contestStat=1; contestStat<5; contestStat++) { - maxRating = sub_810CA9C(pokeblock, contestStat + 1); + maxRating = GetPokeblockData(pokeblock, contestStat + 1); if (rating < maxRating) { rating = maxRating; @@ -1038,7 +1037,7 @@ u8 sub_810C9B0(struct Pokeblock *pokeblock) u8 sub_810C9E8(struct Pokeblock *pokeblock) { - u8 feel = sub_810CA9C(pokeblock, 6); + u8 feel = GetPokeblockData(pokeblock, 6); if (feel > 99) feel = 99; return feel; @@ -1068,7 +1067,7 @@ bool8 sub_810CA34(struct Pokeblock *pokeblock) return TRUE; } -bool8 sub_810CA6C(u8 pokeblockIdx) +bool8 PokeblockClearIfExists(u8 pokeblockIdx) { if (gSaveBlock1.pokeblocks[pokeblockIdx].color == 0) { @@ -1078,33 +1077,33 @@ bool8 sub_810CA6C(u8 pokeblockIdx) return TRUE; } -s16 sub_810CA9C(const struct Pokeblock *pokeblock, u8 field) +s16 GetPokeblockData(const struct Pokeblock *pokeblock, u8 field) { - if (field == 0) + if (field == PBLOCK_COLOR) return pokeblock->color; - if (field == 1) + if (field == PBLOCK_SPICY) return pokeblock->spicy; - if (field == 2) + if (field == PBLOCK_DRY) return pokeblock->dry; - if (field == 3) + if (field == PBLOCK_SWEET) return pokeblock->sweet; - if (field == 4) + if (field == PBLOCK_BITTER) return pokeblock->bitter; - if (field == 5) + if (field == PBLOCK_SOUR) return pokeblock->sour; - if (field == 6) + if (field == PBLOCK_FEEL) return pokeblock->feel; return 0; } -s16 sub_810CAE4(u8 nature, const struct Pokeblock *pokeblock) +s16 PokeblockGetGain(u8 nature, const struct Pokeblock *pokeblock) { u8 flavor; s16 curGain; s16 totalGain = 0; for (flavor=0; flavor<5; flavor++) { - curGain = sub_810CA9C(pokeblock, flavor + 1); + curGain = GetPokeblockData(pokeblock, flavor + 1); if (curGain > 0) { totalGain += curGain * gPokeblockFlavorCompatibilityTable[5 * nature + flavor]; @@ -1113,9 +1112,9 @@ s16 sub_810CAE4(u8 nature, const struct Pokeblock *pokeblock) return totalGain; } -void sub_810CB44(struct Pokeblock *pokeblock, u8 *dest) +void PokeblockCopyName(struct Pokeblock *pokeblock, u8 *dest) { - u8 color = sub_810CA9C(pokeblock, 0); + u8 color = GetPokeblockData(pokeblock, PBLOCK_COLOR); StringCopy(dest, gPokeblockNames[color]); } @@ -1124,7 +1123,7 @@ bool8 sub_810CB68(u8 nature, u8 *dest) u8 flavor; for (flavor=0; flavor<5; flavor++) { - if (sub_810CAE4(nature, &gUnknown_083F7F9C[flavor]) > 0) + if (PokeblockGetGain(nature, &gUnknown_083F7F9C[flavor]) > 0) { StringCopy(dest, gPokeblockNames[flavor + 1]); return TRUE; diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c new file mode 100644 index 000000000..8dc2f47de --- /dev/null +++ b/src/pokeblock_feed.c @@ -0,0 +1,1015 @@ +#include "global.h" +#include "task.h" +#include "palette.h" +#include "main.h" +#include "menu_helpers.h" +#include "text.h" +#include "text_window.h" +#include "menu.h" +#include "rom4.h" +#include "decompress.h" +#include "data2.h" +#include "sprite.h" +#include "item_use.h" +#include "pokeblock.h" +#include "party_menu.h" +#include "strings.h" +#include "string_util.h" +#include "m4a.h" +#include "field_effect.h" +#include "sound.h" +#include "trig.h" + +extern u8 ewram[]; +extern struct MusicPlayerInfo gMPlay_BGM; +extern u8 gPokeblockMonID; +extern s16 gPokeblockGain; + +extern const u8 gPokeblockRed_Pal[]; +extern const u8 gPokeblockBlue_Pal[]; +extern const u8 gPokeblockPink_Pal[]; +extern const u8 gPokeblockGreen_Pal[]; +extern const u8 gPokeblockYellow_Pal[]; +extern const u8 gPokeblockPurple_Pal[]; +extern const u8 gPokeblockIndigo_Pal[]; +extern const u8 gPokeblockBrown_Pal[]; +extern const u8 gPokeblockLiteBlue_Pal[]; +extern const u8 gPokeblockOlive_Pal[]; +extern const u8 gPokeblockGray_Pal[]; +extern const u8 gPokeblockBlack_Pal[]; +extern const u8 gPokeblockWhite_Pal[]; +extern const u8 gPokeblockGold_Pal[]; +extern const u8 gPokeblock_Gfx[]; +extern const u8 gBattleTerrainTiles_Building[]; +extern const u8 gUnknown_08E782FC[]; +extern const u8 gBattleTerrainPalette_BattleTower[]; +extern const struct CompressedSpriteSheet gUnknown_083F7F74; +extern const struct CompressedSpritePalette gUnknown_083F7F7C; + +bool8 sub_8040A3C(u16 species); + +// this file's functions +static void sub_8147B04(void); +static void sub_81481DC(void); +static void sub_814825C(void); +static u8 sub_81480B4(void); +static u8 CreatePokeblockSprite(void); +static u8 PokeblockFeed_CreatePokeSprite(struct Pokemon* mon); +static bool8 sub_8147B20(struct Pokemon* mon); +static void LaunchPokeblockFeedTask(u8); +static void sub_8148044(u8); +static void sub_8148078(struct Sprite* sprite); +static void Task_PrintAtePokeblockText(u8 taskID); +static void Task_PaletteFadeToReturn(u8 taskID); +static void SetPokeblockFeedSpritePal(u8); +static void sub_8148108(u8, bool8); +static bool8 sub_8148540(void); +static bool8 sub_81485CC(void); +static bool8 FreePokeSpriteMatrix(void); +void sub_8148710(void); +static void SpriteCB_ThrownPokeblock(struct Sprite* sprite); +static void sub_814862C(void); + +// EWRAM +EWRAM_DATA static struct CompressedSpritePalette sPokeblockFeedSpritePal = {0}; + +// IWRAM common +struct Sprite* gPokeblockFeedPokeSprite; +u16 gPokeblockFeedMonSpecies; +bool8 gPokeblockMonNotFlipped; +u8 gPokeblockFeedMonSpriteID; +u8 gPokeblockFeedMonNature; +u16 gUnknown_03005F34; +u8 gPokeblockFeedUnused0; +u8 gUnknown_03005F3C; +u8 gUnknown_03005F40; +struct Sprite gPokeblockFeedPokeSpriteCopy; +u16 gUnknown_03005F94; +s16 gUnknown_03005FA0[24]; + +// rodata + +static const u8 sNatureToMonPokeblockAnim[][2] = +{ + { 0, 0 }, // HARDY + { 3, 0 }, // LONELY + { 4, 1 }, // BRAVE + { 5, 0 }, // ADAMANT + { 10, 0 }, // NAUGHTY + { 13, 0 }, // BOLD + { 15, 0 }, // DOCILE + { 16, 2 }, // RELAXED + { 18, 0 }, // IMPISH + { 19, 0 }, // LAX + { 20, 0 }, // TIMID + { 25, 0 }, // HASTY + { 27, 3 }, // SERIOUS + { 28, 0 }, // JOLLY + { 29, 0 }, // NAIVE + { 33, 4 }, // MODEST + { 36, 0 }, // MILD + { 37, 0 }, // QUIET + { 39, 0 }, // BASHFUL + { 42, 0 }, // RASH + { 45, 0 }, // CALM + { 46, 5 }, // GENTLE + { 47, 6 }, // SASSY + { 48, 0 }, // CAREFUL + { 53, 0 }, // QUIRKY +}; + +static const s16 sMonPokeblockAnims[][10] = +{ + // HARDY + { 0, 4, 0, 8, 24, 0, 0, 0, 12, 0}, + { 0, 4, 0, 16, 24, 0, 0, 0, 12, 0}, + { 0, 4, 0, 32, 32, 0, 0, 0, 16, 1}, + + // LONELY + { 0, 3, 6, 0, 48, 0, 0, 0, 24, 1}, + + // BRAVE + { 64, 16, -24, 0, 32, 0, 0, 0, 0, 1}, + + // ADAMANT + { 0, 4, 8, 0, 16, 0, -8, 0, 0, 0}, + { 0, 0, 0, 0, 16, 0, 0, 0, 0, 0}, + { 0, 4, 8, 0, 16, 0, -8, 0, 0, 0}, + { 0, 0, 0, 0, 16, 0, 0, 0, 0, 0}, + { 0, 4, -16, 0, 4, 0, 16, 0, 0, 1}, + + // NAUGHTY + { 0, 3, 6, 0, 12, 0, 0, 0, 6, 0}, + { 0, 3, -6, 0, 12, 0, 0, 0, 6, 0}, + { 0, 16, 16, 0, 45, 1, 0, 0, 0, 1}, + + // BOLD + { 0, 16, 0, 24, 32, 0, 0, 0, 16, 0}, + { 0, 16, 0, 23, 32, 0, 0, 0, 16, 1}, + + // DOCILE + { 0, 0, 0, 0, 80, 0, 0, 0, 0, 1}, + + // RELAXED + { 0, 2, 8, 0, 32, 0, 0, 0, 0, 0}, + { 0, 2, -8, 0, 32, 0, 0, 0, 0, 1}, + + // IMPISH + { 0, 32, 2, 1, 48, 1, 0, 0, 24, 1}, + + // LAX + { 0, 2, 16, 16, 128, 0, 0, 0, 0, 1}, + + // TIMID + { 0, 2, -8, 0, 48, 0, -24, 0, 0, 0}, + { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0}, + { 64, 32, 2, 0, 36, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0}, + { 0, 2, 8, 0, 48, 0, 24, 0, 0, 1}, + + // HASTY + { 64, 24, 16, 0, 32, 0, 0, 0, 0, 0}, + { 0, 28, 2, 1, 32, 1, 0, 0, 16, 1}, + + // SERIOUS + { 0, 0, 0, 0, 32, 0, 0, 0, 0, 1}, + + // JOLLY + { 64, 16, -16, 2, 48, 0, 0, 0, 32, 1}, + + // NAIVE + { 0, 12, -8, 4, 24, 0, 8, 0, 12, 0}, + { 0, 12, 8, 8, 24, 0, -16, 0, 12, 0}, + { 0, 12, -8, 16, 24, 0, 16, 0, 12, 0}, + { 0, 12, 8, 28, 24, 0, -8, 0, 12, 1}, + + // MODEST + { 0, 0, 0, 0, 8, 0, 0, 0, 0, 0}, + { 64, 16, -4, 0, 32, 0, 0, 0, 0, 0}, + { 0, 0, 0, 0, 8, 0, 0, 0, 0, 1}, + + // MILD + { 128, 4, 0, 8, 64, 0, 0, 0, 0, 1}, + + // QUIET + { 0, 2, 16, 0, 48, 0, 0, 0, 0, 0}, + { 128, 2, 16, 0, 48, 0, 0, 0, 0, 1}, + + // BASHFUL + { 0, 2, -4, 0, 48, 0, -48, 0, 0, 0}, + { 0, 0, 0, 0, 80, 0, 0, 0, 0, 0}, + { 0, 2, 8, 0, 24, 0, 48, 0, 0, 1}, + + // RASH + { 64, 4, 64, 58, 52, 0, -88, 0, 0, 0}, + { 0, 0, 0, 0, 80, 0, 0, 0, 0, 0}, + { 0, 24, 80, 0, 32, 0, 88, 0, 0, 1}, + + // CALM + { 0, 2, 16, 4, 64, 0, 0, 0, 0, 1}, + + // GENTLE + { 0, 0, 0, 0, 32, 0, 0, 0, 0, 1}, + + // SASSY + { 0, 0, 0, 0, 42, 0, 0, 0, 0, 1}, + + // CAREFUL + { 0, 4, 0, 8, 24, 0, 0, 0, 12, 0}, + { 0, 0, 0, 0, 12, 0, 0, 0, 0, 0}, + { 0, 4, 0, 12, 24, 0, 0, 0, 12, 0}, + { 0, 0, 0, 0, 12, 0, 0, 0, 0, 0}, + { 0, 4, 0, 4, 24, 0, 0, 0, 12, 1}, + + // QUIRKY + { 0, 4, 16, 12, 64, 0, 0, 0, 0, 0}, + { 0, -4, 16, 12, 64, 0, 0, 0, 0, 1}, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411E90[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411EA0[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 12, 1), + AFFINEANIMCMD_FRAME(0, 0, 0, 30), + AFFINEANIMCMD_FRAME(0, 0, -12, 1), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411EC0[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0, 0, 12, 1), + AFFINEANIMCMD_FRAME(0, 0, 0, 28), + AFFINEANIMCMD_FRAME(0, 0, -4, 3), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411EE8[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 32), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411F08[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 32), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 16), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411F30[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411F50[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411F78[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 32), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411F98[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 32), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 8), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411FC0[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 24), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 4), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8411FE0[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -1, 4), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 24), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 4), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8412008[] = +{ + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, -12, 2), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8412028[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 1, 24), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 16), + AFFINEANIMCMD_FRAME(0x0, 0x0, -12, 2), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_8412050[] = +{ + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411EA0, + sSpriteAffineAnim_8411EE8, + sSpriteAffineAnim_8411F30, + sSpriteAffineAnim_8411F78, + sSpriteAffineAnim_8411FC0, + sSpriteAffineAnim_8412008, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411EC0, + sSpriteAffineAnim_8411F08, + sSpriteAffineAnim_8411F50, + sSpriteAffineAnim_8411F98, + sSpriteAffineAnim_8411FE0, + sSpriteAffineAnim_8412028, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, + sSpriteAffineAnim_8411E90, +}; + +static const u8* const sPokeblocksPals[] = +{ + gPokeblockRed_Pal, + gPokeblockBlue_Pal, + gPokeblockPink_Pal, + gPokeblockGreen_Pal, + gPokeblockYellow_Pal, + gPokeblockPurple_Pal, + gPokeblockIndigo_Pal, + gPokeblockBrown_Pal, + gPokeblockLiteBlue_Pal, + gPokeblockOlive_Pal, + gPokeblockGray_Pal, + gPokeblockBlack_Pal, + gPokeblockWhite_Pal, + gPokeblockGold_Pal +}; + +static const union AffineAnimCmd sSpriteAffineAnim_84120DC[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84120EC[] = +{ + sSpriteAffineAnim_84120DC +}; + +static const union AffineAnimCmd sSpriteAffineAnim_84120F0[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 16, 1), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_8412148[] = +{ + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 8, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, 0, 8), + AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), + AFFINEANIMCMD_FRAME(0x0, 0x0, -16, 1), + AFFINEANIMCMD_FRAME(-0x100, 0x100, 0, 0), + AFFINEANIMCMD_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121A0[] = +{ + sSpriteAffineAnim_84120DC +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121A4[] = +{ + sSpriteAffineAnim_84120F0 +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_84121A8[] = +{ + sSpriteAffineAnim_8412148 +}; + +static const struct OamData sThrownPokeblockOamData = +{ + .y = 0, + .affineMode = 3, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 1, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sThrownPokeblockSpriteAnim[] = +{ + ANIMCMD_FRAME(0, 0), + ANIMCMD_END +}; + +static const union AnimCmd *const sThrownPokeblockAnimTable[] = +{ + sThrownPokeblockSpriteAnim, +}; + +static const union AffineAnimCmd sSpriteAffineAnim_84121C0[] = +{ + AFFINEANIMCMD_FRAME(0x100, 0x100, 0, 0), + AFFINEANIMCMD_FRAME(-8, -8, 0, 1), + AFFINEANIMCMD_JUMP(1) +}; + +static const union AffineAnimCmd *const sThrownPokeblockAffineAnimTable[] = +{ + sSpriteAffineAnim_84121C0 +}; + +static const struct CompressedSpriteSheet sUnknown_084121DC = +{ + gPokeblock_Gfx, 0x20, 14818 +}; + +static const struct SpriteTemplate sThrownPokeblockSpriteTemplate = +{ + .tileTag = 14818, + .paletteTag = 14818, + .oam = &sThrownPokeblockOamData, + .anims = sThrownPokeblockAnimTable, + .images = NULL, + .affineAnims = sThrownPokeblockAffineAnimTable, + .callback = SpriteCB_ThrownPokeblock +}; + +// code + +static void CB2_PokeblockFeed(void) +{ + AnimateSprites(); + BuildOamBuffer(); + RunTasks(); + UpdatePaletteFade(); +} + +static void VBlankCB_PokeblockFeed(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); +} + +static bool8 TransitionToPokeblockFeedScene(void) +{ + switch (gMain.state) + { + case 0: + sub_80F9438(); + sub_80F9368(); + sub_8147B04(); + gMain.state++; + break; + case 1: + ResetPaletteFade(); + gPaletteFade.bufferTransferDisabled = 1; + gMain.state++; + break; + case 2: + ResetSpriteData(); + gMain.state++; + break; + case 3: + FreeAllSpritePalettes(); + gMain.state++; + break; + case 4: + SetUpWindowConfig(&gWindowConfig_81E6E50); + gMain.state++; + break; + case 5: + MultistepInitMenuWindowBegin(&gWindowConfig_81E6E50); + gMain.state++; + break; + case 6: + if (MultistepInitMenuWindowContinue()) + { + ewram[0x1FFFF] = 0; + gMain.state++; + } + break; + case 7: + if (sub_8147B20(&gPlayerParty[gPokeblockMonID])) + { + gMain.state++; + } + break; + case 8: + ewram[0x1FFFD] = sub_81480B4(); + gMain.state++; + break; + case 9: + ewram[0x1FFFE] = PokeblockFeed_CreatePokeSprite(&gPlayerParty[gPokeblockMonID]); + gMain.state++; + break; + case 10: + MenuDrawTextWindow(0, 14, 29, 19); + gMain.state++; + break; + case 11: + if (sub_8055870() != 1) + { + gMain.state++; + } + break; + case 12: + { + u16 savedIME = REG_IME; + REG_IME = 0; + REG_IE |= 1; + REG_IME = savedIME; + REG_DISPSTAT |= 8; + SetVBlankCallback(VBlankCB_PokeblockFeed); + gMain.state++; + } + case 13: + BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); + gPaletteFade.bufferTransferDisabled = 0; + SetMainCallback2(CB2_PokeblockFeed); + return TRUE; + } + return FALSE; +} + +void CB2_PreparePokeblockFeedScene(void) +{ + while (1) + { + if (TransitionToPokeblockFeedScene() == 1) + { + LaunchPokeblockFeedTask(1); + break; + } + if (sub_80F9344() == 1) + break; + } +} + +static void sub_8147B04(void) +{ + REG_BG1CNT = 0x1D02l; + REG_DISPCNT = 0x1340; +} + +static bool8 sub_8147B20(struct Pokemon* mon) +{ + u16 species; + u32 PiD, TiD; + switch (ewram[0x1FFFF]) + { + case 0: + species = GetMonData(mon, MON_DATA_SPECIES2); + PiD = GetMonData(mon, MON_DATA_PERSONALITY); + HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, 0x2000000, gUnknown_081FAF4C[1], species, PiD); + ewram[0x1FFFF]++; + break; + case 1: + { + const struct CompressedSpritePalette* palette; + + species = GetMonData(mon, MON_DATA_SPECIES2); + PiD = GetMonData(mon, MON_DATA_PERSONALITY); + TiD = GetMonData(mon, MON_DATA_OT_ID); + palette = sub_80409C8(species, TiD, PiD); + LoadCompressedObjectPalette(palette); + GetMonSpriteTemplate_803C56C(palette->tag, 1); + ewram[0x1FFFF]++; + } + break; + case 2: + LoadCompressedObjectPic(&gUnknown_083F7F74); + ewram[0x1FFFF]++; + break; + case 3: + LoadCompressedObjectPalette(&gUnknown_083F7F7C); + ewram[0x1FFFF]++; + break; + case 4: + LoadCompressedObjectPic(&sUnknown_084121DC); + ewram[0x1FFFF]++; + break; + case 5: + SetPokeblockFeedSpritePal(gScriptItemId); + LoadCompressedObjectPalette(&sPokeblockFeedSpritePal); + ewram[0x1FFFF]++; + break; + case 6: + LZDecompressVram(gBattleTerrainTiles_Building, (void*)(VRAM)); + ewram[0x1FFFF]++; + break; + case 7: + LZDecompressVram(gUnknown_08E782FC, (void*)(VRAM + 0xE800)); + ewram[0x1FFFF]++; + break; + case 8: + LoadCompressedPalette(gBattleTerrainPalette_BattleTower, 0x20, 0x60); + ewram[0x1FFFF] = 0; + return TRUE; + } + return FALSE; +} + +static void SetPokeblockFeedSpritePal(u8 pkbID) +{ + u8 color = GetPokeblockData(&gSaveBlock1.pokeblocks[pkbID], PBLOCK_COLOR); + sPokeblockFeedSpritePal.data = sPokeblocksPals[color - 1]; + sPokeblockFeedSpritePal.tag = 0x39E2; +} + +static void sub_8147CC8(u8 taskID) +{ + if (!gPaletteFade.active) + { + switch (gTasks[taskID].data[0]) + { + case 0: + gUnknown_03005F3C = 0; + gUnknown_03005F94 = 0; + sub_81481DC(); + break; + case 255: + sub_8148108(ewram[0x1FFFD], gTasks[taskID].data[1]); + break; + case 269: + ewram[0x1FFFC] = CreatePokeblockSprite(); + break; + case 281: + sub_8148044(ewram[0x1FFFE]); + break; + case 297: + gTasks[taskID].func = Task_PrintAtePokeblockText; + return; + } + if (gUnknown_03005F94 < gUnknown_03005F34) + sub_814825C(); + else if (gUnknown_03005F94 == gUnknown_03005F34) + gTasks[taskID].data[0] = 254; + + gUnknown_03005F94++; + gTasks[taskID].data[0]++; + } +} + +static void LaunchPokeblockFeedTask(u8 a0) +{ + u8 taskID = CreateTask(sub_8147CC8, 0); + gTasks[taskID].data[0] = 0; + gTasks[taskID].data[1] = a0; +} + +static void Task_WaitForAtePokeblockText(u8 taskID) +{ + if (MenuUpdateWindowText() == 1) + gTasks[taskID].func = Task_PaletteFadeToReturn; +} + +static void Task_PrintAtePokeblockText(u8 taskID) +{ + struct Pokemon* mon = &gPlayerParty[gPokeblockMonID]; + struct Pokeblock* pokeblock = &gSaveBlock1.pokeblocks[gScriptItemId]; + + gPokeblockGain = PokeblockGetGain(GetNature(mon), pokeblock); + GetMonNickname(mon, gStringVar1); + PokeblockCopyName(pokeblock, gStringVar2); + + if (gPokeblockGain == 0) + StringExpandPlaceholders(gStringVar4, gContestStatsText_NormallyAte); + else if (gPokeblockGain > 0) + StringExpandPlaceholders(gStringVar4, gContestStatsText_HappilyAte); + else + StringExpandPlaceholders(gStringVar4, gContestStatsText_DisdainfullyAte); + + MenuPrintMessage(gStringVar4, 1, 15); + gTasks[taskID].func = Task_WaitForAtePokeblockText; +} + +static void Task_ReturnAfterPaletteFade(u8 taskID) +{ + if (!gPaletteFade.active) + { + m4aMPlayVolumeControl(&gMPlay_BGM, -1, 256); + SetMainCallback2(gMain.savedCallback); + DestroyTask(taskID); + } +} + +static void Task_PaletteFadeToReturn(u8 taskID) +{ + BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); + gTasks[taskID].func = Task_ReturnAfterPaletteFade; +} + +static u8 PokeblockFeed_CreatePokeSprite(struct Pokemon* mon) +{ + u16 species = GetMonData(mon, MON_DATA_SPECIES2); + u8 spriteID = CreateSprite(&gUnknown_02024E8C, 48, 80, 2); + + gPokeblockFeedMonSpecies = species; + gPokeblockFeedMonSpriteID = spriteID; + gPokeblockFeedMonNature = GetNature(mon); + gSprites[spriteID].data2 = species; + gSprites[spriteID].callback = SpriteCallbackDummy; + gPokeblockMonNotFlipped = 1; + if (!sub_8040A3C(species)) + { + gSprites[spriteID].affineAnims = sSpriteAffineAnimTable_84120EC; + gSprites[spriteID].oam.affineMode = 3; + CalcCenterToCornerVec(&gSprites[spriteID], gSprites[spriteID].oam.shape, gSprites[spriteID].oam.size, gSprites[spriteID].oam.affineMode); + gPokeblockMonNotFlipped = 0; + } + return spriteID; +} + +static void sub_8148044(u8 spriteID) +{ + gSprites[spriteID].pos1.x = 48; + gSprites[spriteID].pos1.y = 80; + gSprites[spriteID].data0 = -8; + gSprites[spriteID].data1 = 1; + gSprites[spriteID].callback = sub_8148078; +} + +static void sub_8148078(struct Sprite* sprite) +{ + sprite->pos1.x += 4; + sprite->pos1.y += sprite->data0; + sprite->data0 += sprite->data1; + if (sprite->data0 == 0) + PlayCry1(sprite->data2, 0); + if (sprite->data0 == 9) + sprite->callback = SpriteCallbackDummy; +} + +static u8 sub_81480B4(void) +{ + u8 spriteID = sub_810BA50(188, 100, 2); + gSprites[spriteID].oam.affineMode = 1; + gSprites[spriteID].affineAnims = sSpriteAffineAnimTable_84121A0; + gSprites[spriteID].callback = SpriteCallbackDummy; + InitSpriteAffineAnim(&gSprites[spriteID]); + return spriteID; +} + +static void sub_8148108(u8 spriteID, bool8 a1) +{ + FreeOamMatrix(gSprites[spriteID].oam.matrixNum); + gSprites[spriteID].oam.affineMode = 3; + if (!a1) + gSprites[spriteID].affineAnims = sSpriteAffineAnimTable_84121A4; + else + gSprites[spriteID].affineAnims = sSpriteAffineAnimTable_84121A8; + InitSpriteAffineAnim(&gSprites[spriteID]); +} + +static u8 CreatePokeblockSprite(void) +{ + u8 spriteID = CreateSprite(&sThrownPokeblockSpriteTemplate, 174, 84, 1); + gSprites[spriteID].data0 = -12; + gSprites[spriteID].data1 = 1; + return spriteID; +} + +static void SpriteCB_ThrownPokeblock(struct Sprite* sprite) +{ + sprite->pos1.x -= 4; + sprite->pos1.y += sprite->data0; + sprite->data0 += sprite->data1; + if (sprite->data0 == 10) + DestroySprite(sprite); +} + +static void sub_81481DC(void) +{ + u8 animID, i; + + gUnknown_03005F34 = 1; + animID = sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][0]; + for (i = 0; i < 8; i++, animID++) + { + gUnknown_03005F34 += sMonPokeblockAnims[animID][4]; + if (sMonPokeblockAnims[animID][9] == 1) + break; + } +} + +static void sub_814825C(void) +{ + switch (gUnknown_03005F3C) + { + case 0: + gUnknown_03005F40 = sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][0]; + gPokeblockFeedPokeSprite = &gSprites[gPokeblockFeedMonSpriteID]; + gPokeblockFeedPokeSpriteCopy = *gPokeblockFeedPokeSprite; + gUnknown_03005F3C = 10; + break; + case 1 ... 9: + break; + case 10: + sub_8148540(); + if (sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] != 0) + { + gPokeblockFeedPokeSprite->oam.affineMode = 3; + gPokeblockFeedPokeSprite->oam.matrixNum = 0; + gPokeblockFeedPokeSprite->affineAnims = sSpriteAffineAnimTable_8412050; + InitSpriteAffineAnim(gPokeblockFeedPokeSprite); + } + gUnknown_03005F3C = 50; + case 50: + if (sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] != 0) + { + if (gPokeblockMonNotFlipped == 0) + StartSpriteAffineAnim(gPokeblockFeedPokeSprite, sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1] + 10); + else + StartSpriteAffineAnim(gPokeblockFeedPokeSprite, sNatureToMonPokeblockAnim[gPokeblockFeedMonNature][1]); + } + gUnknown_03005F3C = 60; + break; + case 60: + if (sub_81485CC() == 1) + { + if (gUnknown_03005FA0[9] == 0) + { + gUnknown_03005F40++; + sub_8148540(); + gUnknown_03005F3C = 60; + } + else + { + FreeOamMatrix(gPokeblockFeedPokeSprite->oam.matrixNum); + gUnknown_03005F3C = 70; + } + } + break; + case 70: + FreePokeSpriteMatrix(); + gUnknown_03005F40 = 0; + gUnknown_03005F3C = 0; + break; + case 71 ... 90: + break; + } +} + +static bool8 sub_8148540(void) +{ + u8 i; + for (i = 0; i < 10; i++) + gUnknown_03005FA0[i] = sMonPokeblockAnims[gUnknown_03005F40][i]; + if (gUnknown_03005FA0[4] == 0) + return TRUE; + else + { + gUnknown_03005FA0[10] = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2]); + gUnknown_03005FA0[11] = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3]); + gUnknown_03005FA0[12] = gUnknown_03005FA0[4]; + gUnknown_03005FA0[13] = gPokeblockFeedPokeSprite->pos2.x; + gUnknown_03005FA0[14] = gPokeblockFeedPokeSprite->pos2.y; + sub_8148710(); + gUnknown_03005FA0[4] = gUnknown_03005FA0[12]; + sub_814862C(); + gUnknown_03005FA0[4] = gUnknown_03005FA0[12]; + return FALSE; + } +} + +#define ewram1D000 ((u16 *)(ewram + 0x1D000)) +#define ewram1D400 ((u16 *)(ewram + 0x1D400)) + +static bool8 sub_81485CC(void) +{ + u16 var = gUnknown_03005FA0[12] - gUnknown_03005FA0[4]; + + gPokeblockFeedPokeSprite->pos2.x = ewram1D000[var]; + gPokeblockFeedPokeSprite->pos2.y = ewram1D400[var]; + + if (--gUnknown_03005FA0[4] == 0) + return TRUE; + else + return FALSE; +} + +static bool8 FreePokeSpriteMatrix(void) +{ + FreeSpriteOamMatrix(gPokeblockFeedPokeSprite); + return FALSE; +} + +static void sub_814862C(void) +{ + u16 i; + u16 r8 = gUnknown_03005FA0[8]; + u16 r7 = gUnknown_03005FA0[12] - r8; + s16 var3 = gUnknown_03005FA0[13] + gUnknown_03005FA0[6]; + s16 r9 = gUnknown_03005FA0[14] + gUnknown_03005FA0[7]; + + for (i = 0; i < r7 - 1; i++) + { + s16* r3 = &ewram1D000[r8 + i]; + s16 r1 = *r3 - (var3); + + s16* r5 = &ewram1D400[r8 + i]; + s16 r4 = *r5 - r9; + + *r3 -= r1 * (i + 1) / r7; + *r5 -= r4 * (i + 1) / r7; + } + + ewram1D000[(r8 + r7) - 1] = var3; + ewram1D400[(r8 + r7) - 1] = r9; +} + +void sub_8148710(void) +{ + bool8 var_24 = FALSE; + s16 r8 = gUnknown_03005FA0[13] - gUnknown_03005FA0[10]; + s16 r7 = gUnknown_03005FA0[14] - gUnknown_03005FA0[11]; + while (1) + { + u16 r5; + u16 r4; + u16 var; + + var = abs(gUnknown_03005FA0[5]); + r5 = var + gUnknown_03005FA0[3]; + gUnknown_03005FA0[3] = r5; + + if (gUnknown_03005FA0[2] < 0) + var_24 = TRUE; + + r4 = gUnknown_03005FA0[12] - gUnknown_03005FA0[4]; + + if (gUnknown_03005FA0[4] == 0) + break; + + if (!var_24) + { + ewram1D000[r4] = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2] + r5 / 256) + r8; + ewram1D400[r4] = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3] + r5 / 256) + r7; + } + else + { + ewram1D000[r4] = Sin(gUnknown_03005FA0[0], gUnknown_03005FA0[2] - r5 / 256) + r8; + ewram1D400[r4] = Cos(gUnknown_03005FA0[0], gUnknown_03005FA0[3] - r5 / 256) + r7; + } + + gUnknown_03005FA0[0] += gUnknown_03005FA0[1]; + gUnknown_03005FA0[0] &= 0xFF; + gUnknown_03005FA0[4]--; + } +} diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c index 3aa2f1fa5..0c8f59959 100644 --- a/src/use_pokeblock.c +++ b/src/use_pokeblock.c @@ -1,5 +1,6 @@ // // Created by Scott Norton on 5/31/17. +// Modified by Dizzy Egg on 8/15/17. // #include "global.h" @@ -16,8 +17,6 @@ #include "sound.h" #include "songs.h" #include "pokeblock.h" -#include "pokeblock_feed.h" -#include "use_pokeblock.h" #define GFX_TAG_CONDITIONUPDOWN 0 @@ -29,7 +28,7 @@ const u16 ConditionUpDownPalette[] = INCBIN_U16("graphics/misc/condition_up_down const u32 ConditionUpDownTiles[] = INCBIN_U32("graphics/misc/condition_up_down.4bpp"); #endif -const u32 gUnknown_08406118[] = { +static const u32 sContestStatsMonData[] = { MON_DATA_COOL, MON_DATA_TOUGH, MON_DATA_SMART, @@ -37,11 +36,11 @@ const u32 gUnknown_08406118[] = { MON_DATA_BEAUTY }; -const u8 gUnknown_0840612C[] = { +static const u8 gUnknown_0840612C[] = { 0, 4, 3, 2, 1 }; -const u8 *const gUnknown_08406134[] = { +static const u8 *const sContextStatNames[] = { OtherText_Coolness, OtherText_Toughness, OtherText_Smartness, @@ -49,18 +48,18 @@ const u8 *const gUnknown_08406134[] = { OtherText_Beauty }; -const struct SpriteSheet gSpriteSheet_ConditionUpDown = { +static const struct SpriteSheet gSpriteSheet_ConditionUpDown = { (u8 *)ConditionUpDownTiles, sizeof ConditionUpDownTiles, GFX_TAG_CONDITIONUPDOWN }; -const struct SpritePalette gSpritePalette_ConditionUpDown = { +static const struct SpritePalette gSpritePalette_ConditionUpDown = { ConditionUpDownPalette, GFX_TAG_CONDITIONUPDOWN }; -const s16 gUnknown_08406158[][2] = { +static const s16 gUnknown_08406158[][2] = { {0x9c, 0x1e}, {0x75, 0x35}, {0x75, 0x70}, @@ -68,28 +67,28 @@ const s16 gUnknown_08406158[][2] = { {0xc5, 0x35} }; -const struct OamData gOamData_840616C = { +static const struct OamData gOamData_840616C = { .shape = 1, .size = 2, .priority = 1 }; -const union AnimCmd gSpriteAnim_8406174[] = { +static const union AnimCmd gSpriteAnim_8406174[] = { ANIMCMD_FRAME(0, 5), ANIMCMD_END }; -const union AnimCmd gSpriteAnim_840617C[] = { +static const union AnimCmd gSpriteAnim_840617C[] = { ANIMCMD_FRAME(8, 5), ANIMCMD_END }; -const union AnimCmd *const gSpriteAnimTable_8406184[] = { +static const union AnimCmd *const gSpriteAnimTable_8406184[] = { gSpriteAnim_8406174, gSpriteAnim_840617C }; -const struct SpriteTemplate gSpriteTemplate_840618C = { +static const struct SpriteTemplate gSpriteTemplate_840618C = { GFX_TAG_CONDITIONUPDOWN, GFX_TAG_CONDITIONUPDOWN, &gOamData_840616C, @@ -99,47 +98,44 @@ const struct SpriteTemplate gSpriteTemplate_840618C = { SpriteCallbackDummy }; -asm(".text\n" - ".include \"constants/gba_constants.inc\""); - static EWRAM_DATA struct UnkPokenavStruct_Sub1 *gUnknown_02039304 = NULL; static EWRAM_DATA MainCallback gUnknown_02039308 = NULL; static EWRAM_DATA struct Pokeblock *gUnknown_0203930C = NULL; -EWRAM_DATA u8 gUnknown_02039310 = 0; -EWRAM_DATA s16 gUnknown_02039312 = 0; +EWRAM_DATA u8 gPokeblockMonID = 0; +EWRAM_DATA s16 gPokeblockGain = 0; extern u16 gKeyRepeatStartDelay; extern u16 gScriptItemId; // FIXME: remove after merge of #349 Pokeblock -void launch_c3_walk_stairs_and_run_once(void (*const)(void)); -void sub_81361E4(void); -void sub_813622C(void); -void sub_8136244(void); -void sub_8136264(void); -void sub_8136294(void); -void sub_81365A0(void); -void sub_81365C8(void); -void sub_8136638(void); -void sub_81368A4(void); +static void launch_c3_walk_stairs_and_run_once(void (*const)(void)); +static void sub_81361E4(void); +static void sub_813622C(void); +static void sub_8136244(void); +static void sub_8136264(void); +static void sub_8136294(void); +static void sub_81365A0(void); +static void sub_81365C8(void); +static void sub_8136638(void); +static void sub_81368A4(void); void sub_8089668(void); -void sub_8136B44(void); -u8 sub_81370E4(u8); -void sub_8136BB8(void); -s8 sub_8136C40(void); -bool8 sub_8137058(void); -void sub_8136D60(void); -void sub_8136808(void); -void sub_8136D8C(void); -u8 sub_81370A4(u8); -void sub_81369CC(void); -void sub_8136EF0(void); -void sub_8137138(void); -void sub_8136C6C(void); -bool8 sub_8136D00(void); -void sub_8136DC0(u8 *, u8, s16); -void sub_8136DA0(const u8 *); -void sub_8136F74(struct Pokeblock *, struct Pokemon *); -void sub_81371DC(struct Sprite *); +static void sub_8136B44(void); +static u8 sub_81370E4(u8); +static void sub_8136BB8(void); +static s8 sub_8136C40(void); +static bool8 sub_8137058(void); +static void sub_8136D60(void); +static void sub_8136808(void); +static void sub_8136D8C(void); +static u8 sub_81370A4(u8); +static void sub_81369CC(void); +static void sub_8136EF0(void); +static void sub_8137138(void); +static void sub_8136C6C(void); +static bool8 sub_8136D00(void); +static void Pokeblock_BufferEnhancedStatText(u8 *, u8, s16); +static void Pokeblock_MenuWindowTextPrint(const u8 *); +static void sub_8136F74(struct Pokeblock *, struct Pokemon *); +static void sub_81371DC(struct Sprite *); void sub_8136130(struct Pokeblock *pokeblock, MainCallback callback) { @@ -151,18 +147,18 @@ void sub_8136130(struct Pokeblock *pokeblock, MainCallback callback) SetMainCallback2(sub_8136244); } -void sub_8136174(void) +static void sub_8136174(void) { gUnknown_02039304->pokeblock = gUnknown_0203930C; gUnknown_02039304->callback = gUnknown_02039308; - gUnknown_02039310 = sub_81370E4(gUnknown_02039310); - gUnknown_02039304->unk56 = gUnknown_02039310 < 4 ? 0 : 1; + gPokeblockMonID = sub_81370E4(gPokeblockMonID); + gUnknown_02039304->unk56 = gPokeblockMonID < 4 ? 0 : 1; gUnknown_083DFEC4->unkD162[0] = 2; launch_c3_walk_stairs_and_run_once(sub_8136294); SetMainCallback2(sub_81361E4); } -void sub_81361E4(void) +static void sub_81361E4(void) { gUnknown_02039304->unk0(); AnimateSprites(); @@ -176,7 +172,7 @@ void sub_81361E4(void) } } -void sub_813622C(void) +static void sub_813622C(void) { sub_81368A4(); AnimateSprites(); @@ -184,7 +180,7 @@ void sub_813622C(void) UpdatePaletteFade(); } -void sub_8136244(void) +static void sub_8136244(void) { gUnknown_02039304->unk0(); AnimateSprites(); @@ -192,7 +188,7 @@ void sub_8136244(void) UpdatePaletteFade(); } -void sub_8136264(void) +static void sub_8136264(void) { LoadOam(); ProcessSpriteCopyRequests(); @@ -201,13 +197,13 @@ void sub_8136264(void) sub_8089668(); } -void launch_c3_walk_stairs_and_run_once(void (*const func)(void)) +static void launch_c3_walk_stairs_and_run_once(void (*const func)(void)) { gUnknown_02039304->unk0 = func; gUnknown_02039304->unk50 = 0; } -void sub_8136294(void) +static void sub_8136294(void) { bool32 c1LinkRelatedActive; switch (gUnknown_02039304->unk50) @@ -346,7 +342,7 @@ void sub_8136294(void) } } -void sub_81365A0(void) +static void sub_81365A0(void) { while (!gUnknown_02039304->unk55) { @@ -354,7 +350,7 @@ void sub_81365A0(void) } } -void sub_81365C8(void) +static void sub_81365C8(void) { switch (gUnknown_02039304->unk50) { @@ -374,7 +370,7 @@ void sub_81365C8(void) } } -void sub_8136638(void) +static void sub_8136638(void) { switch (gUnknown_02039304->unk50) { @@ -464,12 +460,12 @@ void sub_8136638(void) } } -void sub_8136808(void) +static void sub_8136808(void) { switch (gUnknown_02039304->unk50) { case 0: - gUnknown_02039310 = sub_81370A4(gUnknown_083DFEC4->unk87DC); + gPokeblockMonID = sub_81370A4(gUnknown_083DFEC4->unk87DC); gUnknown_02039308 = gUnknown_02039304->callback; gUnknown_0203930C = gUnknown_02039304->pokeblock; BeginNormalPaletteFade(-1, 0, 0, 16, 0); @@ -479,18 +475,18 @@ void sub_8136808(void) if (!gPaletteFade.active) { gMain.savedCallback = sub_8136174; - SetMainCallback2(sub_8147ADC); + SetMainCallback2(CB2_PreparePokeblockFeedScene); } break; } } -void sub_81368A4(void) +static void sub_81368A4(void) { switch (gUnknown_02039304->unk50) { case 0: - if (gUnknown_083DFEC4->unk87DC != gUnknown_02039310) + if (gUnknown_083DFEC4->unk87DC != gPokeblockMonID) { sub_80F5060(gUnknown_02039304->unk56); gUnknown_02039304->unk50++; @@ -538,7 +534,7 @@ void sub_81368A4(void) } } -void sub_81369CC(void) +static void sub_81369CC(void) { switch (gUnknown_02039304->unk50) { @@ -578,14 +574,14 @@ void sub_81369CC(void) case 5: if (gMain.newKeys & (A_BUTTON | B_BUTTON) && !sub_8136D00()) { - sub_810CA6C((u8)gScriptItemId); + PokeblockClearIfExists((u8)gScriptItemId); launch_c3_walk_stairs_and_run_once(sub_8136B44); } break; } } -void sub_8136B44(void) +static void sub_8136B44(void) { switch (gUnknown_02039304->unk50) { @@ -609,7 +605,7 @@ void sub_8136B44(void) } } -void sub_8136BB8(void) +static void sub_8136BB8(void) { GetMonData(&gPlayerParty[sub_81370A4(gUnknown_083DFEC4->unk87DC)], MON_DATA_NICKNAME, gUnknown_02039304->stringBuffer); StringGetEnd10(gUnknown_02039304->stringBuffer); @@ -621,7 +617,7 @@ void sub_8136BB8(void) MoveMenuCursor(0); } -s8 sub_8136C40(void) +static s8 sub_8136C40(void) { s8 retval = ProcessMenuInputNoWrap(); if ((u8)(retval + 1) < 3) @@ -632,124 +628,68 @@ s8 sub_8136C40(void) return retval; } -void sub_8136C6C(void) +static void sub_8136C6C(void) { BasicInitMenuWindow(&gWindowConfig_81E709C); MenuDrawTextWindow(0, 16, 29, 19); for (gUnknown_02039304->unk53 = 0; gUnknown_02039304->unk53 < 5 && gUnknown_02039304->unk61[gUnknown_02039304->unk53] == 0; gUnknown_02039304->unk53++); if (gUnknown_02039304->unk53 < 5) { - sub_8136DC0(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, gUnknown_02039304->unk61[gUnknown_02039304->unk53]); + Pokeblock_BufferEnhancedStatText(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, gUnknown_02039304->unk61[gUnknown_02039304->unk53]); } else { - sub_8136DC0(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, 0); + Pokeblock_BufferEnhancedStatText(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, 0); } - sub_8136DA0(gUnknown_02039304->stringBuffer); + Pokeblock_MenuWindowTextPrint(gUnknown_02039304->stringBuffer); } -#ifdef NONMATCHING -bool8 sub_8136D00(void) +static bool8 sub_8136D00(void) { while (1) { - if (++gUnknown_02039304->unk53 >= 5) + gUnknown_02039304->unk53++; + if (gUnknown_02039304->unk53 < 5) { - break; + if (gUnknown_02039304->unk61[gUnknown_02039304->unk53] != 0) + break; } - if (gUnknown_02039304->unk61[gUnknown_02039304->unk53] != 0) + else { - sub_8136DC0(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, gUnknown_02039304->unk61[gUnknown_02039304->unk53]); - sub_8136DA0(gUnknown_02039304->stringBuffer); - return TRUE; + gUnknown_02039304->unk53 = 5; + return FALSE; } } - gUnknown_02039304->unk53 = 5; - return FALSE; + Pokeblock_BufferEnhancedStatText(gUnknown_02039304->stringBuffer, gUnknown_02039304->unk53, gUnknown_02039304->unk61[gUnknown_02039304->unk53]); + Pokeblock_MenuWindowTextPrint(gUnknown_02039304->stringBuffer); + return TRUE; } -#else -__attribute__((naked)) -bool8 sub_8136D00(void) -{ - asm_unified("\tpush {r4,r5,lr}\n" - "\tldr r4, _08136D30 @ =gUnknown_02039304\n" - "\tadds r3, r4, 0\n" - "\tmovs r5, 0x5\n" - "_08136D08:\n" - "\tldr r0, [r3]\n" - "\tadds r0, 0x53\n" - "\tldrb r1, [r0]\n" - "\tadds r1, 0x1\n" - "\tstrb r1, [r0]\n" - "\tldr r2, [r3]\n" - "\tadds r1, r2, 0\n" - "\tadds r1, 0x53\n" - "\tldrb r0, [r1]\n" - "\tcmp r0, 0x4\n" - "\tbhi _08136D34\n" - "\tadds r0, r2, 0\n" - "\tadds r0, 0x61\n" - "\tldrb r1, [r1]\n" - "\tadds r0, r1\n" - "\tldrb r0, [r0]\n" - "\tcmp r0, 0\n" - "\tbne _08136D3A\n" - "\tb _08136D08\n" - "\t.align 2, 0\n" - "_08136D30: .4byte gUnknown_02039304\n" - "_08136D34:\n" - "\tstrb r5, [r1]\n" - "\tmovs r0, 0\n" - "\tb _08136D5A\n" - "_08136D3A:\n" - "\tldr r2, [r4]\n" - "\tadds r0, r2, 0\n" - "\tadds r0, 0x10\n" - "\tadds r1, r2, 0\n" - "\tadds r1, 0x53\n" - "\tldrb r1, [r1]\n" - "\tadds r2, 0x61\n" - "\tadds r2, r1\n" - "\tldrb r2, [r2]\n" - "\tbl sub_8136DC0\n" - "\tldr r0, [r4]\n" - "\tadds r0, 0x10\n" - "\tbl sub_8136DA0\n" - "\tmovs r0, 0x1\n" - "_08136D5A:\n" - "\tpop {r4,r5}\n" - "\tpop {r1}\n" - "\tbx r1"); -} -#endif -void sub_8136D60(void) +static void sub_8136D60(void) { BasicInitMenuWindow(&gWindowConfig_81E709C); MenuDrawTextWindow(0, 16, 29, 19); MenuPrint(gOtherText_WontEat, 1, 17); } -void sub_8136D8C(void) +static void sub_8136D8C(void) { MenuZeroFillScreen(); BasicInitMenuWindow(&gWindowConfig_81E7080); } -void sub_8136DA0(const u8 *message) +static void Pokeblock_MenuWindowTextPrint(const u8 *message) { MenuDrawTextWindow(0, 16, 29, 19); MenuPrint(message, 1, 17); } #ifdef NONMATCHING -void sub_8136DC0(u8 *dest, u8 a1, s16 a2) +static void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 statID, s16 a2) { - u16 v0 = a2; if (a2 != 0) { - if ((v0 = max(a2, 0)) == 0); - StringCopy(dest, gUnknown_08406134[a1]); + StringCopy(dest, sContextStatNames[statID]); StringAppend(dest, gOtherText_WasEnhanced); } else @@ -759,7 +699,7 @@ void sub_8136DC0(u8 *dest, u8 a1, s16 a2) } #else __attribute__((naked)) -void sub_8136DC0(u8 *dest, u8 a1, s16 a2) +static void Pokeblock_BufferEnhancedStatText(u8 *dest, u8 a1, s16 a2) { asm_unified("\tpush {r4,lr}\n" "\tadds r4, r0, 0\n" @@ -775,7 +715,7 @@ void sub_8136DC0(u8 *dest, u8 a1, s16 a2) "\tmovs r0, 0\n" "_08136DD8:\n" "\tlsls r0, 16\n" - "\tldr r1, _08136DF4 @ =gUnknown_08406134\n" + "\tldr r1, _08136DF4 @ =sContextStatNames\n" "\tlsls r0, r3, 2\n" "\tadds r0, r1\n" "\tldr r1, [r0]\n" @@ -786,7 +726,7 @@ void sub_8136DC0(u8 *dest, u8 a1, s16 a2) "\tbl StringAppend\n" "\tb _08136E04\n" "\t.align 2, 0\n" - "_08136DF4: .4byte gUnknown_08406134\n" + "_08136DF4: .4byte sContextStatNames\n" "_08136DF8: .4byte gOtherText_WasEnhanced\n" "_08136DFC:\n" "\tldr r1, _08136E0C @ =gOtherText_NothingChanged\n" @@ -801,16 +741,16 @@ void sub_8136DC0(u8 *dest, u8 a1, s16 a2) } #endif -void sub_8136E10(struct Pokemon *pokemon, u8 *data) +static void Pokeblock_GetMonContestStats(struct Pokemon *pokemon, u8 *data) { u16 i; for (i=0; i<5; i++) { - data[i] = GetMonData(pokemon, gUnknown_08406118[i]); + data[i] = GetMonData(pokemon, sContestStatsMonData[i]); } } -void sub_8136E40(struct Pokeblock *pokeblock, struct Pokemon *pokemon) +static void sub_8136E40(struct Pokeblock *pokeblock, struct Pokemon *pokemon) { u16 i; s16 cstat; @@ -820,14 +760,14 @@ void sub_8136E40(struct Pokeblock *pokeblock, struct Pokemon *pokemon) sub_8136F74(pokeblock, pokemon); for (i=0; i<5; i++) { - data = GetMonData(pokemon, gUnknown_08406118[i]); + data = GetMonData(pokemon, sContestStatsMonData[i]); cstat = data + gUnknown_02039304->unk66[i]; if (cstat < 0) cstat = 0; if (cstat > 255) cstat = 255; data = cstat; - SetMonData(pokemon, gUnknown_08406118[i], &data); + SetMonData(pokemon, sContestStatsMonData[i], &data); } cstat = (u8)GetMonData(pokemon, MON_DATA_SHEEN); cstat = cstat + pokeblock->feel; @@ -838,21 +778,21 @@ void sub_8136E40(struct Pokeblock *pokeblock, struct Pokemon *pokemon) } } -void sub_8136EF0(void) +static void sub_8136EF0(void) { u16 i; struct Pokemon *pokemon = gPlayerParty; pokemon += gUnknown_083DFEC4->unk893c[gUnknown_083DFEC4->unk87DC].partyIdx; - sub_8136E10(pokemon, gUnknown_02039304->unk57); + Pokeblock_GetMonContestStats(pokemon, gUnknown_02039304->unk57); sub_8136E40(gUnknown_02039304->pokeblock, pokemon); - sub_8136E10(pokemon, gUnknown_02039304->unk5c); + Pokeblock_GetMonContestStats(pokemon, gUnknown_02039304->unk5c); for (i=0; i<5; i++) { gUnknown_02039304->unk61[i] = gUnknown_02039304->unk5c[i] - gUnknown_02039304->unk57[i]; } } -void sub_8136F74(struct Pokeblock *pokeblock, struct Pokemon *pokemon) +static void sub_8136F74(struct Pokeblock *pokeblock, struct Pokemon *pokemon) { s8 direction; s8 i; @@ -864,9 +804,9 @@ void sub_8136F74(struct Pokeblock *pokeblock, struct Pokemon *pokemon) gUnknown_02039304->unk66[2] = pokeblock->bitter; gUnknown_02039304->unk66[3] = pokeblock->sweet; gUnknown_02039304->unk66[4] = pokeblock->dry; - if (gUnknown_02039312 > 0) + if (gPokeblockGain > 0) direction = 1; - else if (gUnknown_02039312 < 0) + else if (gPokeblockGain < 0) direction = -1; else return; @@ -884,7 +824,7 @@ void sub_8136F74(struct Pokeblock *pokeblock, struct Pokemon *pokemon) } } -bool8 sub_8137058(void) +static bool8 sub_8137058(void) { struct Pokemon *pokemon = gPlayerParty; pokemon += gUnknown_083DFEC4->unk893c[gUnknown_083DFEC4->unk87DC].partyIdx; @@ -893,7 +833,7 @@ bool8 sub_8137058(void) return FALSE; } -u8 sub_81370A4(u8 a0) +static u8 sub_81370A4(u8 a0) { u8 i; for (i=0; i<PARTY_SIZE; i++) @@ -908,7 +848,7 @@ u8 sub_81370A4(u8 a0) return 0; } -u8 sub_81370E4(u8 a0) +static u8 sub_81370E4(u8 a0) { u8 ct; u8 i; @@ -927,7 +867,7 @@ u8 sub_8137124(u8 a0) return sub_81370A4(a0); } -void sub_8137138(void) +static void sub_8137138(void) { u16 flavor; u8 spriteidx; @@ -951,7 +891,7 @@ void sub_8137138(void) } } -void sub_81371DC(struct Sprite *sprite) +static void sub_81371DC(struct Sprite *sprite) { if (sprite->data0 <= 5) sprite->pos2.y -= 2; diff --git a/src/wild_encounter.c b/src/wild_encounter.c index 96f47c067..7001c2eaa 100644 --- a/src/wild_encounter.c +++ b/src/wild_encounter.c @@ -3161,7 +3161,7 @@ static u8 PickWildMonNature(void) } for (i = 0; i < 25; i++) { - if (sub_810CAE4(natures[i], safariPokeblock) > 0) + if (PokeblockGetGain(natures[i], safariPokeblock) > 0) return natures[i]; } } |