diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_interface.c | 17 | ||||
-rw-r--r-- | src/berry_blender.c | 2 | ||||
-rw-r--r-- | src/decoration.c | 2 | ||||
-rw-r--r-- | src/diploma.c | 4 | ||||
-rw-r--r-- | src/egg_hatch.c | 2 | ||||
-rw-r--r-- | src/hall_of_fame.c | 9 | ||||
-rw-r--r-- | src/naming_screen.c | 2177 | ||||
-rw-r--r-- | src/palette.c | 1 | ||||
-rw-r--r-- | src/pokeblock.c | 2 | ||||
-rw-r--r-- | src/pokeblock_feed.c | 2 | ||||
-rw-r--r-- | src/pokemon_3.c | 11 | ||||
-rw-r--r-- | src/pokemon_animation.c | 5658 | ||||
-rw-r--r-- | src/pokemon_summary_screen.c | 4 | ||||
-rw-r--r-- | src/save_failed_screen.c | 2 |
14 files changed, 7863 insertions, 30 deletions
diff --git a/src/battle_interface.c b/src/battle_interface.c index 6a6bf00a2..885f9857f 100644 --- a/src/battle_interface.c +++ b/src/battle_interface.c @@ -20,6 +20,7 @@ #include "international_string_util.h" #include "safari_zone.h" #include "battle_anim.h" +#include "constants/rgb.h" struct TestingBar { @@ -555,13 +556,13 @@ enum PAL_STATUS_BRN }; -static const u16 sStatusIconPalettes[] = +static const u16 sStatusIconColors[] = { - 0x6198, // PAL_STATUS_PSN - 0xEF7, // PAL_STATUS_PAR - 0x4694, // PAL_STATUS_SLP - 0x72D1, // PAL_STATUS_FRZ - 0x29DC // PAL_STATUS_BRN + RGB(24, 12, 24), // PAL_STATUS_PSN + RGB(23, 23, 3), // PAL_STATUS_PAR + RGB(20, 20, 17), // PAL_STATUS_SLP + RGB(17, 22, 28), // PAL_STATUS_FRZ + RGB(28, 14, 10) // PAL_STATUS_BRN }; static const struct WindowTemplate sHealthboxWindowTemplate = {0, 0, 0, 8, 2, 0, 0}; // width = 8, height = 2 @@ -2071,7 +2072,7 @@ static void UpdateStatusIconInHealthbox(u8 healthboxSpriteId) pltAdder = gSprites[healthboxSpriteId].oam.paletteNum * 16; pltAdder += bank + 12; - FillPalette(sStatusIconPalettes[statusPalId], pltAdder + 0x100, 2); + FillPalette(sStatusIconColors[statusPalId], pltAdder + 0x100, 2); CpuCopy16(gPlttBufferUnfaded + 0x100 + pltAdder, (void*)(OBJ_PLTT + pltAdder * 2), 2); CpuCopy32(statusGfxPtr, (void*)(OBJ_VRAM0 + (gSprites[healthboxSpriteId].oam.tileNum + tileNumAdder) * 32), 96); if (IsDoubleBattle() == TRUE || GetBankSide(bank) == SIDE_OPPONENT) @@ -2575,7 +2576,7 @@ static u8* AddTextPrinterAndCreateWindowOnHealthbox(const u8 *str, u32 x, u32 y, color.bgColor = 1; color.shadowColor = 3; - AddTextPrinterParametrized2(winId, 0, x, y, 0, 0, &color, -1, str); + AddTextPrinterParameterized2(winId, 0, x, y, 0, 0, &color, -1, str); *windowId = winId; return (u8*)(GetWindowAttribute(winId, WINDOW_TILE_DATA)); diff --git a/src/berry_blender.c b/src/berry_blender.c index 51580b50b..c7f465967 100644 --- a/src/berry_blender.c +++ b/src/berry_blender.c @@ -3602,7 +3602,7 @@ static void Blender_AddTextPrinter(u8 windowId, const u8 *string, u8 x, u8 y, s3 FillWindowPixelBuffer(windowId, txtColor.fgColor | (txtColor.fgColor << 4)); } - AddTextPrinterParametrized2(windowId, 1, x, y, letterSpacing, 1, &txtColor, speed, string); + AddTextPrinterParameterized2(windowId, 1, x, y, letterSpacing, 1, &txtColor, speed, string); } static bool32 Blender_PrintText(s16 *textState, const u8 *string, s32 textSpeed) diff --git a/src/decoration.c b/src/decoration.c index c539091c8..a9777c86f 100644 --- a/src/decoration.c +++ b/src/decoration.c @@ -500,7 +500,7 @@ void sub_8126B80(u8 taskId) void sub_8126C08(void) { FillWindowPixelBuffer(0, 0x11); - AddTextPrinterParametrized(0, 1, sSecretBasePCMenuItemDescriptions[sSecretBasePCMenuCursorPos], 0, 0, 2, 1, 3); + AddTextPrinterParameterized(0, 1, sSecretBasePCMenuItemDescriptions[sSecretBasePCMenuCursorPos], 0, 0, 2, 1, 3); } void SecretBasePC_Decorate(u8 taskId) diff --git a/src/diploma.c b/src/diploma.c index fedc10bd0..24e5e9727 100644 --- a/src/diploma.c +++ b/src/diploma.c @@ -17,7 +17,7 @@ extern int decompress_and_copy_tile_data_to_vram(u8 bg_id, void *src, int size, extern bool8 free_temp_tile_data_buffers_if_possible(void); extern void sub_80861E8(void); // rom4 extern bool16 sub_80C0944(void); -extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, u8 *str); +extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor *color, s8 speed, u8 *str); extern u16 gUnknown_0860F074[]; @@ -215,5 +215,5 @@ static void PrintDiplomaText(u8 *text, u8 var1, u8 var2) .shadowColor = 3, }; - AddTextPrinterParametrized2(0, 1, var1, var2, 0, 0, &color, -1, text); + AddTextPrinterParameterized2(0, 1, var1, var2, 0, 0, &color, -1, text); } diff --git a/src/egg_hatch.c b/src/egg_hatch.c index 37f2b2e19..435886638 100644 --- a/src/egg_hatch.c +++ b/src/egg_hatch.c @@ -866,7 +866,7 @@ static void EggHatchPrintMessage(u8 windowId, u8* string, u8 x, u8 y, u8 speed) sEggHatchData->textColor.fgColor = 0; sEggHatchData->textColor.bgColor = 5; sEggHatchData->textColor.shadowColor = 6; - AddTextPrinterParametrized2(windowId, 1, x, y, 0, 0, &sEggHatchData->textColor, speed, string); + AddTextPrinterParameterized2(windowId, 1, x, y, 0, 0, &sEggHatchData->textColor, speed, string); } u8 GetEggStepsToSubtract(void) diff --git a/src/hall_of_fame.c b/src/hall_of_fame.c index 3e70e22fa..d002f210f 100644 --- a/src/hall_of_fame.c +++ b/src/hall_of_fame.c @@ -25,6 +25,7 @@ #include "random.h" #include "event_data.h" #include "overworld.h" +#include "new_menu_helpers.h" struct HallofFameMon { @@ -53,7 +54,6 @@ static EWRAM_DATA struct HofGfx *sHofGfxPtr = NULL; extern bool8 gHasHallOfFameRecords; extern u32 gUnknown_0203BCD4; -extern u8 gDecompressionBuffer[]; extern struct MusicPlayerInfo gMPlayInfo_BGM; extern MainCallback gGameContinueCallback; extern u32 gDamagedSaveSectors; @@ -82,7 +82,6 @@ extern const u8 gContestConfetti_Gfx[]; extern const u8 gContestConfetti_Pal[]; extern void sub_81973C4(u8, u8); -extern u16 AddTextPrinterParametrized(u8 windowId, u8 fontId, const u8 *str, u8 speed, void ( *callback)(u16, struct TextPrinter *), u8 fgColor, u8 bgColor, u8 shadowColor); extern void sub_8175620(void); extern u8 TrySavingData(u8); extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16); @@ -540,7 +539,7 @@ static void Task_Hof_InitTeamSaveData(u8 taskId) *lastSavedTeam = *sHofMonPtr; sub_81973C4(0, 0); - AddTextPrinterParametrized(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized(0, 1, gText_SavingDontTurnOffPower, 0, NULL, 2, 1, 3); CopyWindowToVram(0, 3); gTasks[taskId].func = Task_Hof_TrySaveData; } @@ -747,7 +746,7 @@ static void Task_Hof_WaitAndPrintPlayerInfo(u8 taskId) FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 0x20, 0x20); HallOfFame_PrintPlayerInfo(1, 2); sub_81973C4(0, 0); - AddTextPrinterParametrized(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized(0, 1, gText_LeagueChamp, 0, NULL, 2, 1, 3); CopyWindowToVram(0, 3); gTasks[taskId].func = Task_Hof_ExitOnKeyPressed; } @@ -1116,7 +1115,7 @@ static void Task_HofPC_PrintDataIsCorrupted(u8 taskId) { sub_8198180(gText_UnkCtrlF800Exit, 8, 1); sub_81973C4(0, 0); - AddTextPrinterParametrized(0, 1, gText_HOFCorrupted, 0, NULL, 2, 1, 3); + AddTextPrinterParameterized(0, 1, gText_HOFCorrupted, 0, NULL, 2, 1, 3); CopyWindowToVram(0, 3); gTasks[taskId].func = Task_HofPC_ExitOnButtonPress; } diff --git a/src/naming_screen.c b/src/naming_screen.c new file mode 100644 index 000000000..7139b5c90 --- /dev/null +++ b/src/naming_screen.c @@ -0,0 +1,2177 @@ +#include "global.h" +#include "naming_screen.h" +#include "malloc.h" +#include "palette.h" +#include "task.h" +#include "sprite.h" +#include "string_util.h" +#include "new_menu_helpers.h" +#include "window.h" +#include "bg.h" +#include "gpu_regs.h" +#include "pokemon.h" +#include "field_specials.h" +#include "field_player_avatar.h" +#include "field_map_obj.h" +#include "event_data.h" +#include "constants/vars.h" +#include "constants/songs.h" +#include "pokemon_storage_system.h" +#include "sound.h" +#include "trig.h" +#include "field_effect.h" +#include "pokemon_icon.h" +#include "data2.h" +#include "strings.h" +#include "menu.h" +#include "text_window.h" +#include "overworld.h" +#include "constants/map_objects.h" + +EWRAM_DATA static struct NamingScreenData *gNamingScreenData = NULL; +extern u16 gKeyRepeatStartDelay; + +// extern graphics +extern const u16 gNamingScreenMenu_Pal[]; +extern const u8 gNamingScreenMenu_Gfx[]; +extern const u8 gUnknown_08DD4544[]; +extern const u8 gUnknown_08DD4620[]; +extern const u8 gUnknown_08DD46E0[]; +extern const u8 gUnknown_08DD47A0[]; +extern const u8 gNamingScreenRWindow_Gfx[]; +extern const u8 gNamingScreenKeyboardButton_Gfx[]; +extern const u8 gNamingScreenROptions_Gfx[]; +extern const u8 gNamingScreenCursor_Gfx[]; +extern const u8 gNamingScreenRightPointingTriangleTiles[]; +extern const u8 gNamingScreenUnderscoreTiles[]; + +// extern text +extern const u8 gExpandedPlaceholder_Empty[]; +extern const u8 gText_PkmnTransferredSomeonesPC[]; +extern const u8 gText_PkmnTransferredLanettesPC[]; +extern const u8 gText_PkmnBoxSomeonesPCFull[]; +extern const u8 gText_PkmnBoxLanettesPCFull[]; +extern const u8 gText_MoveOkBack[]; +extern const u8 gText_YourName[]; +extern const u8 gText_BoxName[]; +extern const u8 gText_PkmnsNickname[]; +extern const u8 gText_TellHimTheWords[]; +extern const u8 gUnknown_0862B88D[]; +extern const u8 gUnknown_0862B8AE[]; +extern const u8 gUnknown_0862B8CF[]; +extern const u8 gUnknown_0862B8F0[]; +extern const u8 gUnknown_0862B911[]; +extern const u8 gUnknown_0862B932[]; +extern const u8 gUnknown_0862B953[]; +extern const u8 gUnknown_0862B974[]; +extern const u8 gUnknown_0862B995[]; +extern const u8 gUnknown_0862B9AE[]; +extern const u8 gUnknown_0862B9C7[]; +extern const u8 gUnknown_0862B9E0[]; + + +// start of .rodata +static const u8 gSpriteImage_858BBF8[] = INCBIN_U8("graphics/naming_screen/pc_icon/0.4bpp"); +static const u8 gSpriteImage_858BCB8[] = INCBIN_U8("graphics/naming_screen/pc_icon/1.4bpp"); +static const u16 gUnknown_0858BD78[] = INCBIN_U16("graphics/naming_screen/0.gbapal"); +static const u16 gUnknown_0858BD98[] = INCBIN_U16("graphics/naming_screen/1.gbapal"); + +static const u8 *const gUnknown_0858BDB8[] = +{ + gText_PkmnTransferredSomeonesPC, + gText_PkmnTransferredLanettesPC, + gText_PkmnBoxSomeonesPCFull, + gText_PkmnBoxLanettesPCFull +}; + +static const u8 gUnknown_0858BDC8[] = _("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!"); + +static const struct BgTemplate gUnknown_0858BE00[] = +{ + { + .bg = 0, + .charBaseIndex = 0, + .mapBaseIndex = 30, + .priority = 0 + }, + { + .bg = 1, + .charBaseIndex = 2, + .mapBaseIndex = 29, + .priority = 1 + }, + { + .bg = 2, + .charBaseIndex = 2, + .mapBaseIndex = 28, + .priority = 2 + }, + { + .bg = 3, + .charBaseIndex = 3, + .mapBaseIndex = 31, + .priority = 3 + } +}; + +static const struct WindowTemplate gUnknown_0858BE10[] = { + { 0x01, 0x03, 0x0A, 0x13, 0x08, 0x0A, 0x030 }, + { 0x02, 0x03, 0x0A, 0x13, 0x08, 0x0A, 0x0C8 }, + { 0x03, 0x08, 0x06, 0x11, 0x02, 0x0A, 0x030 }, + { 0x03, 0x08, 0x04, 0x11, 0x02, 0x0A, 0x052 }, + { 0x00, 0x00, 0x00, 0x1E, 0x02, 0x0B, 0x074 }, + DUMMY_WIN_TEMPLATE +}; + +static const u8 gUnknown_0858BE40[] = __("abcdef .ghijkl ,mnopqrs tuvwxyz ABCDEF .GHIJKL ,MNOPQRS TUVWXYZ 01234 56789 !?♂♀/- …“”‘’ "); + +static const u8 gUnknown_0858BEA0[] = { 8, 8, 6 }; +static const u8 gUnknown_0858BEA3[] = { 0, 12, 24, 56, 68, 80, 92, 123, 0, 12, 24, 56, 68, 80, 92, 123, 0, 22, 44, 66, 88, 110, 0, 0 }; + +// forward declarations +static const struct NamingScreenTemplate *const sNamingScreenTemplates[]; +static const struct SubspriteTable gUnknown_0858C050[]; +static const struct SubspriteTable gUnknown_0858C058[]; +static const struct SubspriteTable gUnknown_0858C070[]; +static const struct SubspriteTable gUnknown_0858C078[]; +static const struct SpriteTemplate gUnknown_0858C0C0; +static const struct SpriteTemplate gUnknown_0858C0D8; +static const struct SpriteTemplate gUnknown_0858C0F0; +static const struct SpriteTemplate gUnknown_0858C108; +static const struct SpriteTemplate gUnknown_0858C120; +static const struct SpriteTemplate gUnknown_0858C138; +static const struct SpriteTemplate sSpriteTemplate_InputArrow; +static const struct SpriteTemplate sSpriteTemplate_Underscore; +static const struct SpriteTemplate gUnknown_0858C180; +static const u8* const gUnknown_0858C198[][4]; +static const struct SpriteSheet gUnknown_0858C1C8[]; +static const struct SpritePalette gUnknown_0858C230[]; + +static void C2_NamingScreen(void); +static void NamingScreen_Init(void); +static void NamingScreen_InitBGs(void); +static void sub_80E3194(void); +static void sub_80E31B0(u8 taskId); +static bool8 MainState_BeginFadeIn(void); +static bool8 MainState_WaitFadeIn(void); +static bool8 MainState_HandleInput(void); +static bool8 MainState_MoveToOKButton(void); +static bool8 MainState_6(void); +static bool8 MainState_BeginFadeInOut(void); +static bool8 MainState_WaitFadeOutAndExit(void); +static void DisplaySentToPCMessage(void); +static bool8 sub_80E3604(void); +static bool8 MainState_StartPageSwap(void); +static bool8 MainState_WaitPageSwap(void); +static void StartPageSwapAnim(void); +static void Task_HandlePageSwapAnim(u8); +static bool8 IsPageSwapAnimNotInProgress(void); +static void sub_80E3948(u8, u8, u8); +static void Task_80E39BC(u8); +static u16 sub_80E3A74(u8); +static void sub_80E3AE8(u8); +static void sub_80E3B10(struct Task *, u8, u8); +static void sub_80E3CC8(void); +static void CursorInit(void); +static void SetCursorPos(s16, s16); +static void GetCursorPos(s16 *x, s16 *y); +static void MoveCursorToOKButton(void); +static void sub_80E3E3C(u8); +static void sub_80E3E94(u8); +static u8 IsCursorAnimFinished(void); +static u8 GetCurrentPageColumnCount(void); +static void CreatePageSwitcherSprites(void); +static void sub_80E4050(void); +static void sub_80E41B8(u8, struct Sprite *, struct Sprite *); +static void CreateBackOkSprites(void); +static void CreateUnderscoreSprites(void); +static void CreateInputTargetIcon(void); +static u8 HandleKeyboardEvent(void); +static u8 sub_80E45E0(void); +static u8 GetInputEvent(void); +static void SetInputState(u8); +static void sub_80E4964(void); +static u8 GetTextCaretPosition(void); +static void DeleteTextCharacter(void); +static bool8 sub_80E4B54(void); +static void AddTextCharacter(u8); +static void sub_80E4BE4(void); +static void choose_name_or_words_screen_load_bg_tile_patterns(void); +static void sub_80E4CB8(void); +static void choose_name_or_words_screen_apply_bg_pals(void); +static void sub_80E4CF8(u8, const void *); +static void nullsub_10(u8, u8); +static void sub_80E4D10(void); +static void sub_80E4DE4(u8, u8); +static void sub_80E4E5C(void); +static void sub_80E4EF0(void); +static void sub_80E4F58(void); +static void NamingScreen_TurnOffScreen(void); +static void NamingScreen_InitDisplayMode(void); +static void VBlankCB_NamingScreen(void); +static void sub_80E501C(void); +static bool8 sub_80E503C(u8); + +void DoNamingScreen(u8 templateNum, u8 *destBuffer, u16 monSpecies, u16 monGender, u32 monPersonality, MainCallback returnCallback) +{ + gNamingScreenData = Alloc(sizeof(struct NamingScreenData)); + if (!gNamingScreenData) + { + SetMainCallback2(returnCallback); + } + else + { + gNamingScreenData->templateNum = templateNum; + gNamingScreenData->monSpecies = monSpecies; + gNamingScreenData->monGender = monGender; + gNamingScreenData->monPersonality = monPersonality; + gNamingScreenData->destBuffer = destBuffer; + gNamingScreenData->returnCallback = returnCallback; + + if (templateNum == 0) + StartTimer1(); + + SetMainCallback2(C2_NamingScreen); + } +} + +static void C2_NamingScreen(void) +{ + switch (gMain.state) + { + case 0: + NamingScreen_TurnOffScreen(); + NamingScreen_Init(); + gMain.state++; + break; + case 1: + NamingScreen_InitBGs(); + gMain.state++; + break; + case 2: + ResetPaletteFade(); + gMain.state++; + break; + case 3: + ResetSpriteData(); + FreeAllSpritePalettes(); + gMain.state++; + break; + case 4: + ResetTasks(); + gMain.state++; + break; + case 5: + choose_name_or_words_screen_apply_bg_pals(); + gMain.state++; + break; + case 6: + choose_name_or_words_screen_load_bg_tile_patterns(); + gMain.state++; + break; + case 7: + sub_80E3CC8(); + UpdatePaletteFade(); + sub_80E501C(); + gMain.state++; + break; + default: + sub_80E4CB8(); + sub_80E3194(); + break; + } +} + +static void NamingScreen_Init(void) +{ + gNamingScreenData->state = 0; + gNamingScreenData->bg1vOffset = 0; + gNamingScreenData->bg2vOffset = 0; + gNamingScreenData->bg1Priority = BGCNT_PRIORITY(1); + gNamingScreenData->bg2Priority = BGCNT_PRIORITY(2); + gNamingScreenData->bgToReveal = 0; + gNamingScreenData->bgToHide = 1; + gNamingScreenData->template = sNamingScreenTemplates[gNamingScreenData->templateNum]; + gNamingScreenData->currentPage = gNamingScreenData->template->initialPage; + gNamingScreenData->inputCharBaseXPos = (240 - gNamingScreenData->template->maxChars * 8) / 2 + 6; + if (gNamingScreenData->templateNum == 4) + gNamingScreenData->inputCharBaseXPos += 11; + gNamingScreenData->keyRepeatStartDelayCopy = gKeyRepeatStartDelay; + memset(gNamingScreenData->textBuffer, 0xFF, sizeof(gNamingScreenData->textBuffer)); + if (gNamingScreenData->template->copyExistingString != 0) + StringCopy(gNamingScreenData->textBuffer, gNamingScreenData->destBuffer); + gKeyRepeatStartDelay = 16; +} + +static void sub_80E2FA4(void) +{ + u8 i; + for (i = 0; i < MAX_SPRITES; i++) + { + if (gSprites[i].inUse) + gSprites[i].invisible = FALSE; + } + sub_80E3E3C(0); +} + +static void NamingScreen_InitBGs(void) +{ + u8 i; + + DmaClearLarge16(3, (void *)VRAM, VRAM_SIZE, 0x1000); + DmaClear32(3, (void *)OAM, OAM_SIZE); + DmaClear16(3, (void *)PLTT, PLTT_SIZE); + + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0); + ResetBgsAndClearDma3BusyFlags(0); + InitBgsFromTemplates(0, gUnknown_0858BE00, 4); + + ChangeBgX(0, 0, 0); + ChangeBgY(0, 0, 0); + ChangeBgX(1, 0, 0); + ChangeBgY(1, 0, 0); + ChangeBgX(2, 0, 0); + ChangeBgY(2, 0, 0); + ChangeBgX(3, 0, 0); + ChangeBgY(3, 0, 0); + + sub_81971D0(); + sub_8197200(); + + for (i = 0; i < 5; i++) + gNamingScreenData->windows[i] = AddWindow(&gUnknown_0858BE10[i]); + + SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP | DISPCNT_OBJ_ON); + SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_BG1 | BLDCNT_TGT2_BG2); + SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0xC, 0x8)); + + SetBgTilemapBuffer(1, gNamingScreenData->tilemapBuffer1); + SetBgTilemapBuffer(2, gNamingScreenData->tilemapBuffer2); + SetBgTilemapBuffer(3, gNamingScreenData->tilemapBuffer3); + + FillBgTilemapBufferRect_Palette0(1, 0, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(2, 0, 0, 0, 0x20, 0x20); + FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 0x20, 0x20); +} + +static void sub_80E3194(void) +{ + CreateTask(sub_80E31B0, 2); + SetMainCallback2(sub_80E4F58); +} + +static void sub_80E31B0(u8 taskId) +{ + switch (gNamingScreenData->state) + { + case 0: + MainState_BeginFadeIn(); + sub_80E2FA4(); + NamingScreen_InitDisplayMode(); + break; + case 1: + MainState_WaitFadeIn(); + break; + case 2: + MainState_HandleInput(); + break; + case 3: + MainState_MoveToOKButton(); + MainState_HandleInput(); + break; + case 4: + MainState_StartPageSwap(); + break; + case 5: + MainState_WaitPageSwap(); + break; + case 6: + MainState_6(); + break; + case 7: + sub_80E3604(); + break; + case 8: + MainState_BeginFadeInOut(); + break; + case 9: + MainState_WaitFadeOutAndExit(); + break; + } +} + +static const u8 gUnknown_0858BEBB[] = { 0, 2, 1 }; +static const u8 gUnknown_0858BEBE[] = { 1, 0, 2 }; +static const u8 gUnknown_0858BEC1[] = { 2, 1, 0 }; + +static u8 sub_80E3244(u8 a1) +{ + return gUnknown_0858BEBB[a1]; +} + +static u8 sub_80E3254(void) +{ + return gUnknown_0858BEBE[gNamingScreenData->currentPage]; +} + +static u8 sub_80E3274(void) +{ + return gUnknown_0858BEC1[gNamingScreenData->currentPage]; +} + +static bool8 MainState_BeginFadeIn(void) +{ + sub_80E4CF8(3, gUnknown_08DD4544); + gNamingScreenData->currentPage = 1; + sub_80E4CF8(2, gUnknown_08DD46E0); + sub_80E4CF8(1, gUnknown_08DD4620); + sub_80E4DE4(gNamingScreenData->windows[1], 0); + sub_80E4DE4(gNamingScreenData->windows[0], 1); + nullsub_10(2, 0); + nullsub_10(1, 1); + sub_80E4D10(); + sub_80E4964(); + sub_80E4EF0(); + CopyBgTilemapBufferToVram(1); + CopyBgTilemapBufferToVram(2); + CopyBgTilemapBufferToVram(3); + BlendPalettes(-1, 16, 0); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); + gNamingScreenData->state++; + return FALSE; +} + +static bool8 MainState_WaitFadeIn(void) +{ + if (!gPaletteFade.active) + { + SetInputState(INPUT_STATE_ENABLED); + sub_80E3E94(1); + gNamingScreenData->state++; + } + return FALSE; +} + +static bool8 MainState_HandleInput(void) +{ + return HandleKeyboardEvent(); +} + +static bool8 MainState_MoveToOKButton(void) +{ + if (IsCursorAnimFinished()) + { + SetInputState(INPUT_STATE_ENABLED); + MoveCursorToOKButton(); + gNamingScreenData->state = MAIN_STATE_HANDLE_INPUT; + } + return FALSE; +} + +static bool8 MainState_6(void) +{ + sub_80E4BE4(); + SetInputState(INPUT_STATE_DISABLED); + sub_80E3E94(0); + sub_80E3948(3, 0, 1); + if (gNamingScreenData->templateNum == NAMING_SCREEN_CAUGHT_MON && + CalculatePlayerPartyCount() >= 6) + { + DisplaySentToPCMessage(); + gNamingScreenData->state = MAIN_STATE_UPDATE_SENT_TO_PC_MESSAGE; + return FALSE; + } + else + { + gNamingScreenData->state = MAIN_STATE_BEGIN_FADE_OUT; + return TRUE; //Exit the naming screen + } +} + +static bool8 MainState_BeginFadeInOut(void) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gNamingScreenData->state++; + return FALSE; +} + +static bool8 MainState_WaitFadeOutAndExit(void) +{ + if (!gPaletteFade.active) + { + if (gNamingScreenData->templateNum == NAMING_SCREEN_PLAYER) + SeedRngAndSetTrainerId(); + SetMainCallback2(gNamingScreenData->returnCallback); + DestroyTask(FindTaskIdByFunc(sub_80E31B0)); + FreeAllWindowBuffers(); + FREE_AND_SET_NULL(gNamingScreenData); + } + return FALSE; +} + +static void DisplaySentToPCMessage(void) +{ + u8 stringToDisplay = 0; + + if (!sub_813B260()) + { + StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); + StringCopy(gStringVar2, gNamingScreenData->destBuffer); + } + else + { + StringCopy(gStringVar1, GetBoxNamePtr(VarGet(VAR_STORAGE_UNKNOWN))); + StringCopy(gStringVar2, gNamingScreenData->destBuffer); + StringCopy(gStringVar3, GetBoxNamePtr(get_unknown_box_id())); + stringToDisplay = 2; + } + + if (FlagGet(FLAG_SYS_PC_LANETTE)) + stringToDisplay++; + + StringExpandPlaceholders(gStringVar4, gUnknown_0858BDB8[stringToDisplay]); + sub_81973C4(0, 0); + gTextFlags.flag_0 = TRUE; + AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), 0, 2, 1, 3); + CopyWindowToVram(0, 3); +} + +static bool8 sub_80E3604(void) +{ + RunTextPrinters(); + + if (!IsTextPrinterActive(0) && (gMain.newKeys & A_BUTTON)) + gNamingScreenData->state = MAIN_STATE_BEGIN_FADE_OUT; + + return FALSE; +} + +static bool8 MainState_StartPageSwap(void) +{ + SetInputState(INPUT_STATE_DISABLED); + sub_80E4050(); + StartPageSwapAnim(); + sub_80E3E3C(1); + sub_80E3948(0, 0, 1); + PlaySE(SE_WIN_OPEN); + gNamingScreenData->state = MAIN_STATE_WAIT_PAGE_SWAP; + return FALSE; +} + +static bool8 MainState_WaitPageSwap(void) +{ + s16 cursorX; + s16 cursorY; + bool32 var3; + + if (IsPageSwapAnimNotInProgress()) + { + + GetCursorPos(&cursorX, &cursorY); + var3 = (cursorX == GetCurrentPageColumnCount()); + + gNamingScreenData->state = MAIN_STATE_HANDLE_INPUT; + gNamingScreenData->currentPage++; + gNamingScreenData->currentPage %= 3; + + if (var3) + { + cursorX = GetCurrentPageColumnCount(); + } + else + { + if (cursorX >= GetCurrentPageColumnCount()) + cursorX = GetCurrentPageColumnCount() - 1; + } + + SetCursorPos(cursorX, cursorY); + sub_80E4E5C(); + SetInputState(INPUT_STATE_ENABLED); + sub_80E3E3C(0); + } + return FALSE; +} + +//-------------------------------------------------- +// Page Swap +//-------------------------------------------------- + +#define tState data[0] +#define tFrameCount data[1] + +static bool8 PageSwapAnimState_Init(struct Task *); +static bool8 PageSwapAnimState_1(struct Task *); +static bool8 PageSwapAnimState_2(struct Task *); +static bool8 PageSwapAnimState_Done(struct Task *); + +static bool8 (*const sPageSwapAnimStateFuncs[])(struct Task *) = +{ + PageSwapAnimState_Init, + PageSwapAnimState_1, + PageSwapAnimState_2, + PageSwapAnimState_Done, +}; + +static void StartPageSwapAnim(void) +{ + u8 taskId; + + taskId = CreateTask(Task_HandlePageSwapAnim, 0); + Task_HandlePageSwapAnim(taskId); +} + +static void Task_HandlePageSwapAnim(u8 taskId) +{ + while (sPageSwapAnimStateFuncs[gTasks[taskId].tState](&gTasks[taskId]) != 0); +} + +static bool8 IsPageSwapAnimNotInProgress(void) +{ + if (FindTaskIdByFunc(Task_HandlePageSwapAnim) == 0xFF) + return TRUE; + else + return FALSE; +} + +static bool8 PageSwapAnimState_Init(struct Task *task) +{ + gNamingScreenData->bg1vOffset = 0; + gNamingScreenData->bg2vOffset = 0; + task->tState++; + return 0; +} + +static bool8 PageSwapAnimState_1(struct Task *task) +{ + u16 *const arr[] = + { + &gNamingScreenData->bg2vOffset, + &gNamingScreenData->bg1vOffset + }; + + task->tFrameCount += 4; + *arr[gNamingScreenData->bgToReveal] = Sin(task->tFrameCount, 40); + *arr[gNamingScreenData->bgToHide] = Sin((task->tFrameCount + 128) & 0xFF, 40); + if (task->tFrameCount >= 64) + { + u8 temp = gNamingScreenData->bg1Priority; //Why u8 and not u16? + + gNamingScreenData->bg1Priority = gNamingScreenData->bg2Priority; + gNamingScreenData->bg2Priority = temp; + task->tState++; + } + return 0; +} + +static bool8 PageSwapAnimState_2(struct Task *task) +{ + u16 *const arr[] = + { + &gNamingScreenData->bg2vOffset, + &gNamingScreenData->bg1vOffset + }; + + task->tFrameCount += 4; + *arr[gNamingScreenData->bgToReveal] = Sin(task->tFrameCount, 40); + *arr[gNamingScreenData->bgToHide] = Sin((task->tFrameCount + 128) & 0xFF, 40); + if (task->tFrameCount >= 128) + { + u8 temp = gNamingScreenData->bgToReveal; + + gNamingScreenData->bgToReveal = gNamingScreenData->bgToHide; + gNamingScreenData->bgToHide = temp; + task->tState++; + } + return 0; +} + +static bool8 PageSwapAnimState_Done(struct Task *task) +{ + DestroyTask(FindTaskIdByFunc(Task_HandlePageSwapAnim)); + return 0; +} + +#undef tState +#undef tFrameCount + +//-------------------------------------------------- +// +//-------------------------------------------------- + +static void sub_80E3920(void) +{ + u8 taskId; + + taskId = CreateTask(Task_80E39BC, 3); + gTasks[taskId].data[0] = 3; +} + +static void sub_80E3948(u8 a, u8 b, u8 c) +{ + struct Task *task = &gTasks[FindTaskIdByFunc(Task_80E39BC)]; + + if (a == task->data[0] && c == 0) + { + task->data[1] = b; + task->data[2] = 1; + return; + } + if (a == 3 && task->data[1] == 0 && c == 0) + return; + if (task->data[0] != 3) + sub_80E3AE8(task->data[0]); + sub_80E3B10(task, a, b); +} + +static void Task_80E39BC(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + if (task->data[0] == 3 || task->data[2] == 0) + return; + MultiplyInvertedPaletteRGBComponents(sub_80E3A74(task->data[0]), task->data[3], task->data[3], task->data[3]); + if (task->data[5] != 0) + { + task->data[5]--; + if (task->data[5] != 0) + return; + } + task->data[5] = 2; + if (task->data[4] >= 0) + { + if (task->data[3] < 14) + { + task->data[3] += task->data[4]; + task->data[6] += task->data[4]; + } + else + { + task->data[3] = 16; + task->data[6]++; + } + } + else + { + task->data[3] += task->data[4]; + task->data[6] += task->data[4]; + } + + if (task->data[3] == 16 && task->data[6] == 22) + { + task->data[4] = -4; + } + else if (task->data[3] == 0) + { + task->data[2] = task->data[1]; + task->data[4] = 2; + task->data[6] = 0; + } +} + +static u16 sub_80E3A74(u8 a) +{ + const u16 arr[] = + { + IndexOfSpritePaletteTag(4) * 16 + 0x10E, + IndexOfSpritePaletteTag(6) * 16 + 0x10E, + IndexOfSpritePaletteTag(7) * 16 + 0x10E, + IndexOfSpritePaletteTag(7) * 16 + 0x101, + }; + + return arr[a]; +} + +static void sub_80E3AE8(u8 a) +{ + u16 index = sub_80E3A74(a); + + gPlttBufferFaded[index] = gPlttBufferUnfaded[index]; +} + +static void sub_80E3B10(struct Task *task, u8 b, u8 c) +{ + task->data[0] = b; + task->data[1] = c; + task->data[2] = 1; + task->data[3] = 4; + task->data[4] = 2; + task->data[5] = 0; + task->data[6] = 4; +} + +static void sub_80E3B30(struct Sprite *sprite) +{ + if (sprite->animEnded) + StartSpriteAnim(sprite, 0); + sprite->invisible = (sprite->data[4] & 0xFF); + if (sprite->data[0] == GetCurrentPageColumnCount()) + sprite->invisible = TRUE; + if (sprite->invisible || (sprite->data[4] & 0xFF00) == 0 + || sprite->data[0] != sprite->data[2] || sprite->data[1] != sprite->data[3]) + { + sprite->data[5] = 0; + sprite->data[6] = 2; + sprite->data[7] = 2; + } + sprite->data[7]--; + if (sprite->data[7] == 0) + { + sprite->data[5] += sprite->data[6]; + if (sprite->data[5] == 16 || sprite->data[5] == 0) + sprite->data[6] = -sprite->data[6]; + sprite->data[7] = 2; + } + if ((sprite->data[4] & 0xFF00) != 0) + { + s8 gb = sprite->data[5]; + s8 r = sprite->data[5] >> 1; + u16 index = IndexOfSpritePaletteTag(5) * 16 + 0x0101; + + MultiplyInvertedPaletteRGBComponents(index, r, gb, gb); + } +} + +static void sub_80E3C20(struct Sprite *sprite) +{ + const s16 arr[] = {0, -4, -2, -1}; + + if (sprite->data[0] == 0 || --sprite->data[0] == 0) + { + sprite->data[0] = 8; + sprite->data[1] = (sprite->data[1] + 1) & 3; + } + sprite->pos2.x = arr[sprite->data[1]]; +} + +static void sub_80E3C6C(struct Sprite *sprite) +{ + const s16 arr[] = {2, 3, 2, 1}; + u8 var; + + var = GetTextCaretPosition(); + if (var != (u8)sprite->data[0]) + { + sprite->pos2.y = 0; + sprite->data[1] = 0; + sprite->data[2] = 0; + } + else + { + sprite->pos2.y = arr[sprite->data[1]]; + sprite->data[2]++; + if (sprite->data[2] > 8) + { + sprite->data[1] = (sprite->data[1] + 1) & 3; + sprite->data[2] = 0; + } + } +} + +//-------------------------------------------------- +// Cursor +//-------------------------------------------------- + +static void sub_80E3CC8(void) +{ + CursorInit(); + CreatePageSwitcherSprites(); + CreateBackOkSprites(); + CreateUnderscoreSprites(); + CreateInputTargetIcon(); +} + +static void CursorInit(void) +{ + gNamingScreenData->cursorSpriteId = CreateSprite(&gUnknown_0858C138, 38, 88, 1); + sub_80E3E3C(1); + gSprites[gNamingScreenData->cursorSpriteId].oam.priority = 1; + gSprites[gNamingScreenData->cursorSpriteId].oam.objMode = 1; + gSprites[gNamingScreenData->cursorSpriteId].data[6] = 1; + gSprites[gNamingScreenData->cursorSpriteId].data[6] = 2; + SetCursorPos(0, 0); +} + +static void SetCursorPos(s16 x, s16 y) +{ + struct Sprite *cursorSprite = &gSprites[gNamingScreenData->cursorSpriteId]; + + if (x < gUnknown_0858BEA0[sub_80E3274()]) + cursorSprite->pos1.x = gUnknown_0858BEA3[x + sub_80E3274() * 8] + 38; + else + cursorSprite->pos1.x = 0; + + cursorSprite->pos1.y = y * 16 + 88; + cursorSprite->data[2] = cursorSprite->data[0]; + cursorSprite->data[3] = cursorSprite->data[1]; + cursorSprite->data[0] = x; + cursorSprite->data[1] = y; +} + +static void GetCursorPos(s16 *x, s16 *y) +{ + struct Sprite *cursorSprite = &gSprites[gNamingScreenData->cursorSpriteId]; + + *x = cursorSprite->data[0]; + *y = cursorSprite->data[1]; +} + +static void MoveCursorToOKButton(void) +{ + SetCursorPos(GetCurrentPageColumnCount(), 2); +} + +static void sub_80E3E3C(u8 a) +{ + gSprites[gNamingScreenData->cursorSpriteId].data[4] &= -256; + gSprites[gNamingScreenData->cursorSpriteId].data[4] |= a; + StartSpriteAnim(&gSprites[gNamingScreenData->cursorSpriteId], 0); +} + +static void sub_80E3E94(u8 a) +{ + gSprites[gNamingScreenData->cursorSpriteId].data[4] &= 0xFF; + gSprites[gNamingScreenData->cursorSpriteId].data[4] |= a << 8; +} + +static void sub_80E3ED8(void) +{ + StartSpriteAnim(&gSprites[gNamingScreenData->cursorSpriteId], 1); +} + +static bool8 IsCursorAnimFinished(void) +{ + return gSprites[gNamingScreenData->cursorSpriteId].animEnded; +} + +enum +{ + KEY_ROLE_CHAR, + KEY_ROLE_PAGE, + KEY_ROLE_BACKSPACE, + KEY_ROLE_OK, +}; + +static const u8 sKeyRoles[] = {KEY_ROLE_PAGE, KEY_ROLE_BACKSPACE, KEY_ROLE_OK}; + +static u8 GetKeyRoleAtCursorPos(void) +{ + s16 cursorX; + s16 cursorY; + + GetCursorPos(&cursorX, &cursorY); + if (cursorX < GetCurrentPageColumnCount()) + return KEY_ROLE_CHAR; + else + return sKeyRoles[cursorY]; +} + +static u8 GetCurrentPageColumnCount(void) +{ + return gUnknown_0858BEA0[sub_80E3274()]; +} + +static void CreatePageSwitcherSprites(void) +{ + u8 spriteId1; + u8 spriteId2; + u8 spriteId3; + + spriteId1 = CreateSprite(&gUnknown_0858C0C0, 0xCC, 0x58, 0); + gNamingScreenData->selectBtnFrameSpriteId = spriteId1; + SetSubspriteTables(&gSprites[spriteId1], gUnknown_0858C050); + gSprites[spriteId1].invisible = TRUE; + + spriteId2 = CreateSprite(&gUnknown_0858C0F0, 0xCC, 0x54, 1); + gSprites[spriteId1].data[6] = spriteId2; + SetSubspriteTables(&gSprites[spriteId2], gUnknown_0858C058); + gSprites[spriteId2].invisible = TRUE; + + spriteId3 = CreateSprite(&gUnknown_0858C0D8, 0xCC, 0x53, 2); + gSprites[spriteId3].oam.priority = 1; + gSprites[spriteId1].data[7] = spriteId3; + gSprites[spriteId3].invisible = TRUE; +} + +static void sub_80E4050(void) +{ + struct Sprite *sprite = &gSprites[gNamingScreenData->selectBtnFrameSpriteId]; + + sprite->data[0] = 2; + sprite->data[1] = gNamingScreenData->currentPage; +} + +static u8 sub_80E40AC(struct Sprite *); +static u8 sub_80E4100(struct Sprite *); +static u8 sub_80E4104(struct Sprite *); +static u8 sub_80E4178(struct Sprite *); + +static u8 (*const gUnknown_0858BEE8[])(struct Sprite *) = +{ + sub_80E40AC, + sub_80E4100, + sub_80E4104, + sub_80E4178, +}; + +static void sub_80E4084(struct Sprite *sprite) +{ + while (gUnknown_0858BEE8[sprite->data[0]](sprite) != 0); +} + +static u8 sub_80E40AC(struct Sprite *sprite) +{ + struct Sprite *sprite1 = &gSprites[sprite->data[6]]; + struct Sprite *sprite2 = &gSprites[sprite->data[7]]; + + sub_80E41B8(sub_80E3244(gNamingScreenData->currentPage), sprite1, sprite2); + sprite->data[0]++; + return 0; +} + +static u8 sub_80E4100(struct Sprite *sprite) +{ + return 0; +} + +static u8 sub_80E4104(struct Sprite *sprite) +{ + struct Sprite *r4 = &gSprites[sprite->data[6]]; + struct Sprite *r5 = &gSprites[sprite->data[7]]; + + r4->pos2.y++; + if (r4->pos2.y > 7) + { + sprite->data[0]++; + r4->pos2.y = -4; + r4->invisible = TRUE; + sub_80E41B8(sub_80E3244(((u8)sprite->data[1] + 1) % 3), r4, r5); + } + return 0; +} + +static u8 sub_80E4178(struct Sprite *sprite) +{ + struct Sprite *r2 = &gSprites[sprite->data[6]]; + + r2->invisible = FALSE; + r2->pos2.y++; + if (r2->pos2.y >= 0) + { + r2->pos2.y = 0; + sprite->data[0] = 1; + } + return 0; +} + +static const u16 gUnknown_0858BEF8[] = {1, 3, 2}; +static const u16 gUnknown_0858BEFE[] = {4, 6, 5}; + +static void sub_80E41B8(u8 a, struct Sprite *b, struct Sprite *c) +{ + c->oam.paletteNum = IndexOfSpritePaletteTag(gUnknown_0858BEF8[a]); + b->sheetTileStart = GetSpriteTileStartByTag(gUnknown_0858BEFE[a]); + b->subspriteTableNum = a; +} + +// + +static void CreateBackOkSprites(void) +{ + u8 spriteId; + + spriteId = CreateSprite(&gUnknown_0858C108, 0xCC, 0x74, 0); + SetSubspriteTables(&gSprites[spriteId], gUnknown_0858C070); + gSprites[spriteId].invisible = TRUE; + + spriteId = CreateSprite(&gUnknown_0858C120, 0xCC, 0x8C, 0); + SetSubspriteTables(&gSprites[spriteId], gUnknown_0858C070); + gSprites[spriteId].invisible = TRUE; +} + +static void CreateUnderscoreSprites(void) +{ + u8 spriteId; + s16 xPos; + u8 i; + + xPos = gNamingScreenData->inputCharBaseXPos - 5; + spriteId = CreateSprite(&sSpriteTemplate_InputArrow, xPos, 0x38, 0); + gSprites[spriteId].oam.priority = 3; + gSprites[spriteId].invisible = TRUE; + xPos = gNamingScreenData->inputCharBaseXPos; + for (i = 0; i < gNamingScreenData->template->maxChars; i++, xPos += 8) + { + spriteId = CreateSprite(&sSpriteTemplate_Underscore, xPos + 3, 0x3C, 0); + gSprites[spriteId].oam.priority = 3; + gSprites[spriteId].data[0] = i; + gSprites[spriteId].invisible = TRUE; + } +} + +//-------------------------------------------------- +// Icon creation (the thing you're naming or giving input to) +//-------------------------------------------------- + +static void TaskDummy2(void); +static void NamingScreen_CreatePlayerIcon(void); +static void NamingScreen_CreatePCIcon(void); +static void NamingScreen_CreateMonIcon(void); +static void NamingScreen_CreateWandaDadIcon(void); + +static void (*const sIconFunctions[])(void) = +{ + TaskDummy2, + NamingScreen_CreatePlayerIcon, + NamingScreen_CreatePCIcon, + NamingScreen_CreateMonIcon, + NamingScreen_CreateWandaDadIcon, +}; + +static void CreateInputTargetIcon(void) +{ + sIconFunctions[gNamingScreenData->template->iconFunction](); +} + +static void TaskDummy2(void) +{ + +} + +static void NamingScreen_CreatePlayerIcon(void) +{ + u8 rivalGfxId; + u8 spriteId; + + rivalGfxId = GetRivalAvatarGraphicsIdByStateIdAndGender(0, gNamingScreenData->monSpecies); + spriteId = AddPseudoFieldObject(rivalGfxId, SpriteCallbackDummy, 0x38, 0x25, 0); + gSprites[spriteId].oam.priority = 3; + StartSpriteAnim(&gSprites[spriteId], 4); +} + +static void NamingScreen_CreatePCIcon(void) +{ + u8 spriteId; + + spriteId = CreateSprite(&gUnknown_0858C180, 0x38, 0x29, 0); + SetSubspriteTables(&gSprites[spriteId], gUnknown_0858C078); + gSprites[spriteId].oam.priority = 3; +} + +static void NamingScreen_CreateMonIcon(void) +{ + u8 spriteId; + + sub_80D2F04(); + spriteId = CreateMonIcon(gNamingScreenData->monSpecies, SpriteCallbackDummy, 0x38, 0x28, 0, gNamingScreenData->monPersonality, 1); + gSprites[spriteId].oam.priority = 3; +} + +static void NamingScreen_CreateWandaDadIcon(void) +{ + u8 spriteId; + + spriteId = AddPseudoFieldObject(MAP_OBJ_GFX_MAN_1, SpriteCallbackDummy, 0x38, 0x25, 0); + gSprites[spriteId].oam.priority = 3; + StartSpriteAnim(&gSprites[spriteId], 4); +} + +//-------------------------------------------------- +// Keyboard handling +//-------------------------------------------------- + +static bool8 KeyboardKeyHandler_Character(u8); +static bool8 KeyboardKeyHandler_Page(u8); +static bool8 KeyboardKeyHandler_Backspace(u8); +static bool8 KeyboardKeyHandler_OK(u8); + +static bool8 (*const sKeyboardKeyHandlers[])(u8) = +{ + KeyboardKeyHandler_Character, + KeyboardKeyHandler_Page, + KeyboardKeyHandler_Backspace, + KeyboardKeyHandler_OK, +}; + +static bool8 HandleKeyboardEvent(void) +{ + u8 event = GetInputEvent(); + u8 keyRole = GetKeyRoleAtCursorPos(); + + if (event == KBEVENT_PRESSED_SELECT) + { + return sub_80E45E0(); + } + else if (event == KBEVENT_PRESSED_B) + { + DeleteTextCharacter(); + return FALSE; + } + else if (event == KBEVENT_PRESSED_START) + { + MoveCursorToOKButton(); + return FALSE; + } + else + { + return sKeyboardKeyHandlers[keyRole](event); + } +} + +static bool8 KeyboardKeyHandler_Character(u8 event) +{ + sub_80E3948(3, 0, 0); + if (event == KBEVENT_PRESSED_A) + { + bool8 var = sub_80E4B54(); + + sub_80E3ED8(); + if (var) + { + SetInputState(INPUT_STATE_2); + gNamingScreenData->state = MAIN_STATE_MOVE_TO_OK_BUTTON; + } + } + return FALSE; +} + +static bool8 KeyboardKeyHandler_Page(u8 event) +{ + sub_80E3948(0, 1, 0); + if (event == KBEVENT_PRESSED_A) + return sub_80E45E0(); + else + return FALSE; +} + +static bool8 KeyboardKeyHandler_Backspace(u8 event) +{ + sub_80E3948(1, 1, 0); + if (event == KBEVENT_PRESSED_A) + DeleteTextCharacter(); + return FALSE; +} + +static bool8 KeyboardKeyHandler_OK(u8 event) +{ + sub_80E3948(2, 1, 0); + if (event == KBEVENT_PRESSED_A) + { + PlaySE(SE_SELECT); + gNamingScreenData->state = MAIN_STATE_6; + return TRUE; + } + else + return FALSE; +} + +static bool8 sub_80E45E0(void) +{ + gNamingScreenData->state = MAIN_STATE_START_PAGE_SWAP; + return TRUE; +} + +//-------------------------------------------------- +// Input handling +//-------------------------------------------------- + +enum +{ + FNKEY_CASE, + FNKEY_BACK, + FNKEY_OK, +}; + +#define tState data[0] +#define tKeyboardEvent data[1] +#define tKbFunctionKey data[2] + + +static void InputState_Disabled(struct Task *); +static void InputState_Enabled(struct Task *); +static void InputState_2(struct Task *); + +static void (*const sInputStateFuncs[])(struct Task *) = +{ + InputState_Disabled, + InputState_Enabled, + InputState_2, +}; + +static void Task_HandleInput(u8); +static void HandleDpadMovement(struct Task *); + +static void InputInit(void) +{ + CreateTask(Task_HandleInput, 1); +} + +static u8 GetInputEvent(void) +{ + u8 taskId = FindTaskIdByFunc(Task_HandleInput); + + return gTasks[taskId].tKeyboardEvent; +} + +static void SetInputState(u8 state) +{ + u8 taskId = FindTaskIdByFunc(Task_HandleInput); + + gTasks[taskId].tState = state; +} + +static void Task_HandleInput(u8 taskId) +{ + sInputStateFuncs[gTasks[taskId].tState](&gTasks[taskId]); +} + +static void InputState_Disabled(struct Task *task) +{ + task->tKeyboardEvent = 0; +} + +static void InputState_Enabled(struct Task *task) +{ + task->tKeyboardEvent = 0; + + if (gMain.newKeys & A_BUTTON) + task->tKeyboardEvent = KBEVENT_PRESSED_A; + else if (gMain.newKeys & B_BUTTON) + task->tKeyboardEvent = KBEVENT_PRESSED_B; + else if (gMain.newKeys & SELECT_BUTTON) + task->tKeyboardEvent = KBEVENT_PRESSED_SELECT; + else if (gMain.newKeys & START_BUTTON) + task->tKeyboardEvent = KBEVENT_PRESSED_START; + else + HandleDpadMovement(task); +} + +static void InputState_2(struct Task *task) +{ + task->tKeyboardEvent = 0; +} + +static void HandleDpadMovement(struct Task *task) +{ + const s16 sDpadDeltaX[] = + { + 0, //none + 0, //up + 0, //down + -1, //left + 1 //right + }; + + const s16 sDpadDeltaY[] = + { + 0, //none + -1, //up + 1, //down + 0, //left + 0 //right + }; + + const s16 s4RowTo3RowTableY[] = {0, 1, 1, 2}; + const s16 gUnknown_0858BF50[] = {0, 0, 3}; + + s16 cursorX; + s16 cursorY; + u16 dpadDir; + s16 prevCursorX; + + GetCursorPos(&cursorX, &cursorY); + dpadDir = 0; + if (gMain.newAndRepeatedKeys & DPAD_UP) + dpadDir = 1; + if (gMain.newAndRepeatedKeys & DPAD_DOWN) + dpadDir = 2; + if (gMain.newAndRepeatedKeys & DPAD_LEFT) + dpadDir = 3; + if (gMain.newAndRepeatedKeys & DPAD_RIGHT) + dpadDir = 4; + + //Get new cursor position + prevCursorX = cursorX; + cursorX += sDpadDeltaX[dpadDir]; + cursorY += sDpadDeltaY[dpadDir]; + + //Wrap cursor position in the X direction + if (cursorX < 0) + cursorX = GetCurrentPageColumnCount(); + if (cursorX > GetCurrentPageColumnCount()) + cursorX = 0; + + //Handle cursor movement in X direction + if (sDpadDeltaX[dpadDir] != 0) + { + if (cursorX == GetCurrentPageColumnCount()) + { + //We are now on the last column + task->tKbFunctionKey = cursorY; + cursorY = s4RowTo3RowTableY[cursorY]; + } + else if (prevCursorX == GetCurrentPageColumnCount()) + { + if (cursorY == 1) + cursorY = task->tKbFunctionKey; + else + cursorY = gUnknown_0858BF50[cursorY]; + } + } + + if (cursorX == GetCurrentPageColumnCount()) + { + //There are only 3 keys on the last column, unlike the others, + //so wrap Y accordingly + if (cursorY < 0) + cursorY = 2; + if (cursorY > 2) + cursorY = 0; + if (cursorY == 0) + task->tKbFunctionKey = FNKEY_BACK; + else if (cursorY == 2) + task->tKbFunctionKey = FNKEY_OK; + } + else + { + if (cursorY < 0) + cursorY = 3; + if (cursorY > 3) + cursorY = 0; + } + SetCursorPos(cursorX, cursorY); +} + +#undef tState +#undef tKeyboardEvent +#undef tKbFunctionKey + +static void sub_80E4894(void) +{ + FillWindowPixelBuffer(gNamingScreenData->windows[3], 0x11); + PrintTextOnWindow(gNamingScreenData->windows[3], 1, gNamingScreenData->template->title, 8, 1, 0, 0); + PutWindowTilemap(gNamingScreenData->windows[3]); +} + +static void sub_80E48E8(void) +{ + u8 buffer[0x20]; + + StringCopy(buffer, gSpeciesNames[gNamingScreenData->monSpecies]); + StringAppendN(buffer, gNamingScreenData->template->title, 15); + FillWindowPixelBuffer(gNamingScreenData->windows[3], 0x11); + PrintTextOnWindow(gNamingScreenData->windows[3], 1, buffer, 8, 1, 0, 0); + PutWindowTilemap(gNamingScreenData->windows[3]); +} + +static void (*const gUnknown_0858BF58[])(void) = +{ + sub_80E4894, + sub_80E4894, + sub_80E48E8, + sub_80E48E8, + sub_80E4894, +}; + +static void sub_80E4964(void) +{ + gUnknown_0858BF58[gNamingScreenData->templateNum](); +} + +static void TaskDummy3(void); +static void sub_80E49BC(void); + +static void (*const gUnknown_0858BF6C[])(void) = +{ + TaskDummy3, + sub_80E49BC, +}; + +static void sub_80E498C(void) +{ + gUnknown_0858BF6C[gNamingScreenData->template->addGenderIcon](); +} + +static void TaskDummy3(void) +{ + +} + +static const struct TextColor sGenderColors[2] = +{ + {0, 9, 8}, + {0, 5, 4} +}; + +static void sub_80E49BC(void) +{ + u8 genderSymbol[2]; + bool8 isFemale = FALSE; + + StringCopy(genderSymbol, gText_MaleSymbol); + + if (gNamingScreenData->monGender != MON_GENDERLESS) + { + if (gNamingScreenData->monGender == MON_FEMALE) + { + StringCopy(genderSymbol, gText_FemaleSymbol); + isFemale = TRUE; + } + box_print(gNamingScreenData->windows[2], 1, 0x68, 1, &sGenderColors[isFemale], -1, genderSymbol); + } +} + +static u8 GetCharAtKeyboardPos(s16 a, s16 b) +{ + return gUnknown_0858BE40[a + b * 8 + sub_80E3274() * 32]; +} + + +static u8 GetTextCaretPosition(void) +{ + u8 i; + + for (i = 0; i < gNamingScreenData->template->maxChars; i++) + { + if (gNamingScreenData->textBuffer[i] == EOS) + return i; + } + return gNamingScreenData->template->maxChars - 1; +} + +static u8 GetPreviousTextCaretPosition(void) +{ + s8 i; + + for (i = gNamingScreenData->template->maxChars - 1; i > 0; i--) + { + if (gNamingScreenData->textBuffer[i] != EOS) + return i; + } + return 0; +} + +static void DeleteTextCharacter(void) +{ + u8 index; + u8 var2; + + index = GetPreviousTextCaretPosition(); + gNamingScreenData->textBuffer[index] = 0; + sub_80E4D10(); + CopyBgTilemapBufferToVram(3); + gNamingScreenData->textBuffer[index] = EOS; + var2 = GetKeyRoleAtCursorPos(); + if (var2 == 0 || var2 == 2) + sub_80E3948(1, 0, 1); + PlaySE(SE_BOWA); +} + +static bool8 sub_80E4B54(void) +{ + s16 x; + s16 y; + + GetCursorPos(&x, &y); + AddTextCharacter(GetCharAtKeyboardPos(x, y)); + sub_80E4D10(); + CopyBgTilemapBufferToVram(3); + PlaySE(SE_SELECT); + + if (GetPreviousTextCaretPosition() != gNamingScreenData->template->maxChars - 1) + return FALSE; + else + return TRUE; +} + +static void AddTextCharacter(u8 ch) +{ + u8 index = GetTextCaretPosition(); + + gNamingScreenData->textBuffer[index] = ch; +} + +static void sub_80E4BE4(void) +{ + u8 i; + + for (i = 0; i < gNamingScreenData->template->maxChars; i++) + { + if (gNamingScreenData->textBuffer[i] != CHAR_SPACE && gNamingScreenData->textBuffer[i] != EOS) + { + StringCopyN(gNamingScreenData->destBuffer, gNamingScreenData->textBuffer, gNamingScreenData->template->maxChars + 1); + break; + } + } +} + +static void choose_name_or_words_screen_load_bg_tile_patterns(void) +{ + LZ77UnCompWram(gNamingScreenMenu_Gfx, gNamingScreenData->tileBuffer); + LoadBgTiles(1, gNamingScreenData->tileBuffer, 0x600, 0); + LoadBgTiles(2, gNamingScreenData->tileBuffer, 0x600, 0); + LoadBgTiles(3, gNamingScreenData->tileBuffer, 0x600, 0); + LoadSpriteSheets(gUnknown_0858C1C8); + LoadSpritePalettes(gUnknown_0858C230); +} + +static void sub_80E4CB8(void) +{ + InputInit(); + sub_80E3920(); +} + +static void choose_name_or_words_screen_apply_bg_pals(void) +{ + LoadPalette(gNamingScreenMenu_Pal, 0, 0xC0); + LoadPalette(gUnknown_0858BD78, 0xA0, sizeof(gUnknown_0858BD78)); + LoadPalette(stdpal_get(2), 0xB0, 0x20); +} + +static void sub_80E4CF8(u8 bg, const void *src) +{ + CopyToBgTilemapBuffer(bg, src, 0, 0); +} + +static void nullsub_10(u8 a1, u8 a2) +{ + +} + +static void sub_80E4D10(void) +{ + u8 i; + u8 temp[2]; + u16 unk2; + u8 maxChars = gNamingScreenData->template->maxChars; + u16 unk = gNamingScreenData->inputCharBaseXPos - 0x40; + + FillWindowPixelBuffer(gNamingScreenData->windows[2], 0x11); + + for (i = 0; i < maxChars; i++) + { + temp[0] = gNamingScreenData->textBuffer[i]; + temp[1] = gExpandedPlaceholder_Empty[0]; + unk2 = (sub_80E503C(temp[0]) == 1) ? 2 : 0; + + PrintTextOnWindow(gNamingScreenData->windows[2], 1, temp, i * 8 + unk + unk2, 1, 0xFF, NULL); + } + + sub_80E498C(); + CopyWindowToVram(gNamingScreenData->windows[2], 2); + PutWindowTilemap(gNamingScreenData->windows[2]); +} + +static const struct AlignedTextColor sUnkColor1 = +{ + 13, 1, 2 +}; + +static const struct AlignedTextColor sUnkColor2 = +{ + 14, 1, 2 +}; + +static const struct AlignedTextColor sUnkColor3 = +{ + 15, 1, 2 +}; + +static const u8 sFillValues[3] = +{ + 0xEE, 0xDD, 0xFF +}; + +static const struct AlignedTextColor *const sUnkColors[3] = +{ + &sUnkColor2, + &sUnkColor1, + &sUnkColor3 +}; + +static void sub_80E4DE4(u8 window, u8 a1) +{ + u8 i; + + FillWindowPixelBuffer(window, sFillValues[a1]); + + for (i = 0; i < 4; i++) + { + box_print(window, 1, 0, i * 16 + 1, sUnkColors[a1], 0, gUnknown_0858C198[a1][i]); + } + + PutWindowTilemap(window); +} + +static const u8 *const gUnknown_0858BF98[] = +{ + gUnknown_08DD4620, + gUnknown_08DD46E0, + gUnknown_08DD47A0 +}; + +static void sub_80E4E5C(void) +{ + u8 unk1; + u8 unk2; + u8 unk3; + u8 bg1Priority = GetGpuReg(REG_OFFSET_BG1CNT) & 3; + u8 bg2Priority = GetGpuReg(REG_OFFSET_BG2CNT) & 3; + + if (bg1Priority > bg2Priority) + { + unk1 = 1; + unk2 = 1; + unk3 = gNamingScreenData->windows[0]; + } + else + { + unk1 = 2; + unk2 = 2; + unk3 = gNamingScreenData->windows[1]; + } + + sub_80E4CF8(unk1, gUnknown_0858BF98[gNamingScreenData->currentPage]); + sub_80E4DE4(unk3, sub_80E3254()); + nullsub_10(unk1, sub_80E3254()); + CopyBgTilemapBufferToVram(unk2); +} + +static void sub_80E4EF0(void) +{ + const struct TextColor color[] = { 15, 1, 2 }; + + FillWindowPixelBuffer(gNamingScreenData->windows[4], 0xFF); + box_print(gNamingScreenData->windows[4], 0, 2, 1, color, 0, gText_MoveOkBack); + PutWindowTilemap(gNamingScreenData->windows[4]); + CopyWindowToVram(gNamingScreenData->windows[4], 3); +} + +static void sub_80E4F58(void) +{ + RunTasks(); + AnimateSprites(); + BuildOamBuffer(); + UpdatePaletteFade(); +} + +static void NamingScreen_TurnOffScreen(void) +{ + SetVBlankCallback(NULL); + SetHBlankCallback(NULL); +} + +static void NamingScreen_InitDisplayMode(void) +{ + SetVBlankCallback(VBlankCB_NamingScreen); +} + +static void VBlankCB_NamingScreen(void) +{ + LoadOam(); + ProcessSpriteCopyRequests(); + TransferPlttBuffer(); + SetGpuReg(REG_OFFSET_BG1VOFS, gNamingScreenData->bg1vOffset); + SetGpuReg(REG_OFFSET_BG2VOFS, gNamingScreenData->bg2vOffset); + SetGpuReg(REG_OFFSET_BG1CNT, GetGpuReg(REG_OFFSET_BG1CNT) & 0xFFFC); + SetGpuRegBits(REG_OFFSET_BG1CNT, gNamingScreenData->bg1Priority); + SetGpuReg(REG_OFFSET_BG2CNT, GetGpuReg(REG_OFFSET_BG2CNT) & 0xFFFC); + SetGpuRegBits(REG_OFFSET_BG2CNT, gNamingScreenData->bg2Priority); +} + +static void sub_80E501C(void) +{ + ShowBg(0); + ShowBg(1); + ShowBg(2); + ShowBg(3); +} + +static bool8 sub_80E503C(u8 character) +{ + u8 i; + + for (i = 0; gUnknown_0858BDC8[i] != EOS; i++) + { + if (character == gUnknown_0858BDC8[i]) + return FALSE; + } + return FALSE; +} + +static void sub_80E5074(void) +{ + DoNamingScreen(0, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, sub_8086194); +} + +static void sub_80E509C(void) +{ + DoNamingScreen(1, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, sub_8086194); +} + +static void sub_80E50C4(void) +{ + DoNamingScreen(2, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, sub_8086194); +} + +static void sub_80E50EC(void) +{ + DoNamingScreen(3, gSaveBlock2Ptr->playerName, gSaveBlock2Ptr->playerGender, 0, 0, sub_8086194); +} + +//-------------------------------------------------- +// Forward-declared variables +//-------------------------------------------------- + +static const struct NamingScreenTemplate playerNamingScreenTemplate = +{ + .copyExistingString = 0, + .maxChars = 7, + .iconFunction = 1, + .addGenderIcon = 0, + .initialPage = 1, + .unused = 35, + .title = gText_YourName, +}; + +static const struct NamingScreenTemplate pcBoxNamingTemplate = +{ + .copyExistingString = 0, + .maxChars = 8, + .iconFunction = 2, + .addGenderIcon = 0, + .initialPage = 1, + .unused = 19, + .title = gText_BoxName, +}; + +static const struct NamingScreenTemplate monNamingScreenTemplate = +{ + .copyExistingString = 0, + .maxChars = 10, + .iconFunction = 3, + .addGenderIcon = 1, + .initialPage = 1, + .unused = 35, + .title = gText_PkmnsNickname, +}; + +static const struct NamingScreenTemplate wandaWordsScreenTemplate = +{ + .copyExistingString = 1, + .maxChars = 15, + .iconFunction = 4, + .addGenderIcon = 0, + .initialPage = 1, + .unused = 11, + .title = gText_TellHimTheWords, +}; + +static const struct NamingScreenTemplate *const sNamingScreenTemplates[] = +{ + &playerNamingScreenTemplate, + &pcBoxNamingTemplate, + &monNamingScreenTemplate, + &monNamingScreenTemplate, + &wandaWordsScreenTemplate, +}; + +const struct OamData gOamData_858BFEC = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 0, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +const struct OamData gOamData_858BFF4 = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +const struct OamData gOamData_858BFFC = +{ + .y = 0, + .affineMode = 0, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 1, + .x = 0, + .matrixNum = 0, + .size = 2, + .tileNum = 0, + .priority = 0, + .paletteNum = 0, + .affineParam = 0, +}; + +static const struct Subsprite gUnknown_0858C004[] = +{ + {-20, -16, 1, 1, 0, 1}, + { 12, -16, 0, 0, 4, 1}, + {-20, -8, 1, 1, 5, 1}, + { 12, -8, 0, 0, 9, 1}, + {-20, 0, 1, 1, 10, 1}, + { 12, 0, 0, 0, 14, 1}, + {-20, 8, 1, 1, 15, 1}, + { 12, 8, 0, 0, 19, 1} +}; + +static const struct Subsprite gUnknown_0858C024[] = +{ + {-12, -4, 1, 0, 0, 1}, + { 4, -4, 0, 0, 2, 1} +}; + +static const struct Subsprite gUnknown_0858C02C[] = +{ + {-20, -12, 1, 1, 0, 1}, + { 12, -12, 0, 0, 4, 1}, + {-20, -4, 1, 1, 5, 1}, + { 12, -4, 0, 0, 9, 1}, + {-20, 4, 1, 1, 10, 1}, + { 12, 4, 0, 0, 14, 1} +}; + +static const struct Subsprite gUnknown_0858C044[] = +{ + {-8, -12, 1, 0, 0, 3}, + {-8, -4, 1, 0, 2, 3}, + {-8, 4, 1, 0, 4, 3} +}; + +static const struct SubspriteTable gUnknown_0858C050[] = +{ + {ARRAY_COUNT(gUnknown_0858C004), gUnknown_0858C004} +}; + +static const struct SubspriteTable gUnknown_0858C058[] = +{ + {ARRAY_COUNT(gUnknown_0858C024), gUnknown_0858C024}, + {ARRAY_COUNT(gUnknown_0858C024), gUnknown_0858C024}, + {ARRAY_COUNT(gUnknown_0858C024), gUnknown_0858C024} +}; + +static const struct SubspriteTable gUnknown_0858C070[] = +{ + {ARRAY_COUNT(gUnknown_0858C02C), gUnknown_0858C02C} +}; + +static const struct SubspriteTable gUnknown_0858C078[] = +{ + {ARRAY_COUNT(gUnknown_0858C044), gUnknown_0858C044} +}; + +static const struct SpriteFrameImage gUnknown_0858C080[] = +{ + {gSpriteImage_858BBF8, sizeof(gSpriteImage_858BBF8)}, + {gSpriteImage_858BCB8, sizeof(gSpriteImage_858BCB8)}, +}; + +static const union AnimCmd gSpriteAnim_858C090[] = +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_JUMP(0) +}; + +static const union AnimCmd gSpriteAnim_858C098[] = +{ + ANIMCMD_FRAME(4, 8), + ANIMCMD_FRAME(8, 8), + ANIMCMD_END +}; + +static const union AnimCmd gSpriteAnim_858C0A4[] = +{ + ANIMCMD_FRAME(0, 2), + ANIMCMD_FRAME(1, 2), + ANIMCMD_JUMP(0) +}; + +static const union AnimCmd *const gSpriteAnimTable_858C0B0[] = +{ + gSpriteAnim_858C090 +}; + +static const union AnimCmd *const gSpriteAnimTable_858C0B4[] = +{ + gSpriteAnim_858C090, + gSpriteAnim_858C098 +}; + +static const union AnimCmd *const gSpriteAnimTable_858C0BC[] = +{ + gSpriteAnim_858C0A4 +}; + +static const struct SpriteTemplate gUnknown_0858C0C0 = +{ + .tileTag = 0x0002, + .paletteTag = 0x0004, + .oam = &gOamData_858BFEC, + .anims = gSpriteAnimTable_858C0B0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80E4084 +}; + +static const struct SpriteTemplate gUnknown_0858C0D8 = +{ + .tileTag = 0x0003, + .paletteTag = 0x0001, + .oam = &gOamData_858BFFC, + .anims = gSpriteAnimTable_858C0B0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +static const struct SpriteTemplate gUnknown_0858C0F0 = +{ + .tileTag = 0x0004, + .paletteTag = 0x0004, + .oam = &gOamData_858BFEC, + .anims = gSpriteAnimTable_858C0B0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +static const struct SpriteTemplate gUnknown_0858C108 = +{ + .tileTag = 0x0000, + .paletteTag = 0x0006, + .oam = &gOamData_858BFEC, + .anims = gSpriteAnimTable_858C0B0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +static const struct SpriteTemplate gUnknown_0858C120 = +{ + .tileTag = 0x0001, + .paletteTag = 0x0007, + .oam = &gOamData_858BFEC, + .anims = gSpriteAnimTable_858C0B0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +static const struct SpriteTemplate gUnknown_0858C138 = +{ + .tileTag = 0x0007, + .paletteTag = 0x0005, + .oam = &gOamData_858BFF4, + .anims = gSpriteAnimTable_858C0B4, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80E3B30 +}; + +static const struct SpriteTemplate sSpriteTemplate_InputArrow = +{ + .tileTag = 0x000A, + .paletteTag = 0x0003, + .oam = &gOamData_858BFEC, + .anims = gSpriteAnimTable_858C0B0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80E3C20 +}; + +static const struct SpriteTemplate sSpriteTemplate_Underscore = +{ + .tileTag = 0x000B, + .paletteTag = 0x0003, + .oam = &gOamData_858BFEC, + .anims = gSpriteAnimTable_858C0B0, + .images = NULL, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = sub_80E3C6C +}; + +static const struct SpriteTemplate gUnknown_0858C180 = +{ + .tileTag = 0xFFFF, + .paletteTag = 0x0000, + .oam = &gOamData_858BFEC, + .anims = gSpriteAnimTable_858C0BC, + .images = gUnknown_0858C080, + .affineAnims = gDummySpriteAffineAnimTable, + .callback = SpriteCallbackDummy +}; + +static const u8* const gUnknown_0858C198[][4] = +{ + { + gUnknown_0862B88D, + gUnknown_0862B8AE, + gUnknown_0862B8CF, + gUnknown_0862B8F0 + }, + { + gUnknown_0862B911, + gUnknown_0862B932, + gUnknown_0862B953, + gUnknown_0862B974 + }, + { + gUnknown_0862B995, + gUnknown_0862B9AE, + gUnknown_0862B9C7, + gUnknown_0862B9E0 + }, +}; + +static const struct SpriteSheet gUnknown_0858C1C8[] = +{ + {gNamingScreenRWindow_Gfx + 0x280, 0x1E0, 0x0000}, + {gNamingScreenRWindow_Gfx + 0x460, 0x1E0, 0x0001}, + {gNamingScreenRWindow_Gfx, 0x280, 0x0002}, + {gNamingScreenKeyboardButton_Gfx + 0x20, 0x100, 0x0003}, + {gNamingScreenROptions_Gfx, 0x060, 0x0004}, + {gNamingScreenROptions_Gfx + 0xA0, 0x060, 0x0005}, + {gNamingScreenROptions_Gfx + 0x140, 0x060, 0x0006}, + {gNamingScreenCursor_Gfx, 0x080, 0x0007}, + {gNamingScreenCursor_Gfx + 0xA0, 0x080, 0x0008}, + {gNamingScreenCursor_Gfx + 0x140, 0x080, 0x0009}, + {gNamingScreenRightPointingTriangleTiles, 0x020, 0x000A}, + {gNamingScreenUnderscoreTiles, 0x020, 0x000B}, + {NULL} +}; + +static const struct SpritePalette gUnknown_0858C230[] = +{ + {gNamingScreenMenu_Pal, 0x0000}, + {gNamingScreenMenu_Pal + 0x10, 0x0001}, + {gNamingScreenMenu_Pal + 0x20, 0x0002}, + {gNamingScreenMenu_Pal + 0x30, 0x0003}, + {gNamingScreenMenu_Pal + 0x40, 0x0004}, + {gNamingScreenMenu_Pal + 0x50, 0x0005}, + {gNamingScreenMenu_Pal + 0x40, 0x0006}, + {gNamingScreenMenu_Pal + 0x40, 0x0007}, + {NULL} +}; diff --git a/src/palette.c b/src/palette.c index d7b6ad479..cc2046b14 100644 --- a/src/palette.c +++ b/src/palette.c @@ -4,6 +4,7 @@ #include "decompress.h" #include "gpu_regs.h" #include "task.h" +#include "constants/rgb.h" enum { diff --git a/src/pokeblock.c b/src/pokeblock.c index 573eed52b..1a4ce3155 100644 --- a/src/pokeblock.c +++ b/src/pokeblock.c @@ -583,7 +583,7 @@ static void HandleInitWindows(void) static void PrintOnPokeblockWindow(u8 windowId, const u8 *string, s32 x) { - AddTextPrinterParametrized2(windowId, 1, x, 1, 0, 0, &sTextColorInPokeblockMenu, 0, string); + AddTextPrinterParameterized2(windowId, 1, x, 1, 0, 0, &sTextColorInPokeblockMenu, 0, string); } static void PutPokeblockInfoText(void) diff --git a/src/pokeblock_feed.c b/src/pokeblock_feed.c index b26da118c..d899e54f1 100644 --- a/src/pokeblock_feed.c +++ b/src/pokeblock_feed.c @@ -792,7 +792,7 @@ static void Task_HandleMonAtePokeblock(u8 taskId) StringExpandPlaceholders(gStringVar4, gText_Var1DisdainfullyAteVar2); gTextFlags.flag_0 = 1; - AddTextPrinterParametrized(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3); + AddTextPrinterParameterized(0, 1, gStringVar4, GetPlayerTextSpeed(), NULL, 2, 1, 3); gTasks[taskId].func = Task_WaitForAtePokeblockText; } diff --git a/src/pokemon_3.c b/src/pokemon_3.c index 95ec4b6a2..7ffb2f36a 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -74,8 +74,6 @@ extern u8 GetFrontierOpponentClass(u16 trainerId); extern u8 pokemon_order_func(u8 bankPartyId); extern void GetFrontierTrainerName(u8* dest, u16 trainerId); extern void sub_81C488C(u8); -extern void sub_817F578(struct Sprite*, u8 frontAnimId); -extern u8 GetSpeciesBackAnimId(u16 species); static void sub_806E6CC(u8 taskId); @@ -1508,7 +1506,7 @@ static void Task_PokemonSummaryAnimateAfterDelay(u8 taskId) { if (--gTasks[taskId].data[3] == 0) { - sub_817F578(READ_PTR_FROM_TASK(taskId, 0), gTasks[taskId].data[2]); + StartMonSummaryAnimation(READ_PTR_FROM_TASK(taskId, 0), gTasks[taskId].data[2]); sub_81C488C(0xFF); DestroyTask(taskId); } @@ -1523,7 +1521,6 @@ void BattleAnimateFrontSprite(struct Sprite* sprite, u16 species, bool8 noCry, u } extern void SpriteCallbackDummy_2(struct Sprite*); -extern void sub_817F60C(struct Sprite*); void DoMonFrontSpriteAnimation(struct Sprite* sprite, u16 species, bool8 noCry, u8 arg3) { @@ -1580,11 +1577,11 @@ void PokemonSummaryDoMonAnimation(struct Sprite* sprite, u16 species, bool8 oneF gTasks[taskId].data[2] = gMonFrontAnimIdsTable[species - 1]; gTasks[taskId].data[3] = gMonAnimationDelayTable[species - 1]; sub_81C488C(taskId); - sub_817F60C(sprite); + SetSpriteCB_MonAnimDummy(sprite); } else { - sub_817F578(sprite, gMonFrontAnimIdsTable[species - 1]); + StartMonSummaryAnimation(sprite, gMonFrontAnimIdsTable[species - 1]); } } @@ -1603,7 +1600,7 @@ void BattleAnimateBackSprite(struct Sprite* sprite, u16 species) } else { - LaunchAnimationTaskForBackSprite(sprite, GetSpeciesBackAnimId(species)); + LaunchAnimationTaskForBackSprite(sprite, GetSpeciesBackAnimSet(species)); sprite->callback = SpriteCallbackDummy_2; } } diff --git a/src/pokemon_animation.c b/src/pokemon_animation.c new file mode 100644 index 000000000..2bd4e3ef9 --- /dev/null +++ b/src/pokemon_animation.c @@ -0,0 +1,5658 @@ +#include "global.h" +#include "pokemon.h" +#include "sprite.h" +#include "pokemon_animation.h" +#include "trig.h" +#include "task.h" +#include "blend_palette.h" +#include "constants/rgb.h" + +struct UnkAnimStruct +{ + u16 field_0; + s16 field_2; + s16 field_4; + s16 field_6; + s16 field_8; +}; + +extern u16 gBattlePartyID[]; + +// this file's functions +static void pokemonanimfunc_00(struct Sprite *sprite); +static void pokemonanimfunc_01(struct Sprite *sprite); +static void pokemonanimfunc_02(struct Sprite *sprite); +static void pokemonanimfunc_03(struct Sprite *sprite); +static void pokemonanimfunc_04(struct Sprite *sprite); +static void pokemonanimfunc_05(struct Sprite *sprite); +static void pokemonanimfunc_06(struct Sprite *sprite); +static void pokemonanimfunc_07(struct Sprite *sprite); +static void pokemonanimfunc_08(struct Sprite *sprite); +static void pokemonanimfunc_09(struct Sprite *sprite); +static void pokemonanimfunc_0A(struct Sprite *sprite); +static void pokemonanimfunc_0B(struct Sprite *sprite); +static void pokemonanimfunc_0C(struct Sprite *sprite); +static void pokemonanimfunc_0D(struct Sprite *sprite); +static void pokemonanimfunc_0E(struct Sprite *sprite); +static void pokemonanimfunc_0F(struct Sprite *sprite); +static void pokemonanimfunc_10(struct Sprite *sprite); +static void pokemonanimfunc_11(struct Sprite *sprite); +static void pokemonanimfunc_12(struct Sprite *sprite); +static void pokemonanimfunc_13(struct Sprite *sprite); +static void pokemonanimfunc_14(struct Sprite *sprite); +static void pokemonanimfunc_15(struct Sprite *sprite); +static void pokemonanimfunc_16(struct Sprite *sprite); +static void pokemonanimfunc_17(struct Sprite *sprite); +static void pokemonanimfunc_18(struct Sprite *sprite); +static void pokemonanimfunc_19(struct Sprite *sprite); +static void pokemonanimfunc_1A(struct Sprite *sprite); +static void pokemonanimfunc_1B(struct Sprite *sprite); +static void pokemonanimfunc_1C(struct Sprite *sprite); +static void pokemonanimfunc_1D(struct Sprite *sprite); +static void pokemonanimfunc_1E(struct Sprite *sprite); +static void pokemonanimfunc_1F(struct Sprite *sprite); +static void pokemonanimfunc_20(struct Sprite *sprite); +static void pokemonanimfunc_21(struct Sprite *sprite); +static void pokemonanimfunc_22(struct Sprite *sprite); +static void pokemonanimfunc_23(struct Sprite *sprite); +static void pokemonanimfunc_24(struct Sprite *sprite); +static void pokemonanimfunc_25(struct Sprite *sprite); +static void pokemonanimfunc_26(struct Sprite *sprite); +static void pokemonanimfunc_27(struct Sprite *sprite); +static void pokemonanimfunc_28(struct Sprite *sprite); +static void pokemonanimfunc_29(struct Sprite *sprite); +static void pokemonanimfunc_2A(struct Sprite *sprite); +static void pokemonanimfunc_2B(struct Sprite *sprite); +static void pokemonanimfunc_2C(struct Sprite *sprite); +static void pokemonanimfunc_2D(struct Sprite *sprite); +static void pokemonanimfunc_2E(struct Sprite *sprite); +static void pokemonanimfunc_2F(struct Sprite *sprite); +static void pokemonanimfunc_30(struct Sprite *sprite); +static void pokemonanimfunc_31(struct Sprite *sprite); +static void pokemonanimfunc_32(struct Sprite *sprite); +static void pokemonanimfunc_33(struct Sprite *sprite); +static void pokemonanimfunc_34(struct Sprite *sprite); +static void pokemonanimfunc_35(struct Sprite *sprite); +static void pokemonanimfunc_36(struct Sprite *sprite); +static void pokemonanimfunc_37(struct Sprite *sprite); +static void pokemonanimfunc_38(struct Sprite *sprite); +static void pokemonanimfunc_39(struct Sprite *sprite); +static void pokemonanimfunc_3A(struct Sprite *sprite); +static void pokemonanimfunc_3B(struct Sprite *sprite); +static void pokemonanimfunc_3C(struct Sprite *sprite); +static void pokemonanimfunc_3D(struct Sprite *sprite); +static void pokemonanimfunc_3E(struct Sprite *sprite); +static void pokemonanimfunc_3F(struct Sprite *sprite); +static void pokemonanimfunc_40(struct Sprite *sprite); +static void pokemonanimfunc_41(struct Sprite *sprite); +static void pokemonanimfunc_42(struct Sprite *sprite); +static void pokemonanimfunc_43(struct Sprite *sprite); +static void pokemonanimfunc_44(struct Sprite *sprite); +static void pokemonanimfunc_45(struct Sprite *sprite); +static void pokemonanimfunc_46(struct Sprite *sprite); +static void pokemonanimfunc_47(struct Sprite *sprite); +static void pokemonanimfunc_48(struct Sprite *sprite); +static void pokemonanimfunc_49(struct Sprite *sprite); +static void pokemonanimfunc_4A(struct Sprite *sprite); +static void pokemonanimfunc_4B(struct Sprite *sprite); +static void pokemonanimfunc_4C(struct Sprite *sprite); +static void pokemonanimfunc_4D(struct Sprite *sprite); +static void pokemonanimfunc_4E(struct Sprite *sprite); +static void pokemonanimfunc_4F(struct Sprite *sprite); +static void pokemonanimfunc_50(struct Sprite *sprite); +static void pokemonanimfunc_51(struct Sprite *sprite); +static void pokemonanimfunc_52(struct Sprite *sprite); +static void pokemonanimfunc_53(struct Sprite *sprite); +static void pokemonanimfunc_54(struct Sprite *sprite); +static void pokemonanimfunc_55(struct Sprite *sprite); +static void pokemonanimfunc_56(struct Sprite *sprite); +static void pokemonanimfunc_57(struct Sprite *sprite); +static void pokemonanimfunc_58(struct Sprite *sprite); +static void pokemonanimfunc_59(struct Sprite *sprite); +static void pokemonanimfunc_5A(struct Sprite *sprite); +static void pokemonanimfunc_5B(struct Sprite *sprite); +static void pokemonanimfunc_5C(struct Sprite *sprite); +static void pokemonanimfunc_5D(struct Sprite *sprite); +static void pokemonanimfunc_5E(struct Sprite *sprite); +static void pokemonanimfunc_5F(struct Sprite *sprite); +static void pokemonanimfunc_60(struct Sprite *sprite); +static void pokemonanimfunc_61(struct Sprite *sprite); +static void pokemonanimfunc_62(struct Sprite *sprite); +static void pokemonanimfunc_63(struct Sprite *sprite); +static void pokemonanimfunc_64(struct Sprite *sprite); +static void pokemonanimfunc_65(struct Sprite *sprite); +static void pokemonanimfunc_66(struct Sprite *sprite); +static void pokemonanimfunc_67(struct Sprite *sprite); +static void pokemonanimfunc_68(struct Sprite *sprite); +static void pokemonanimfunc_69(struct Sprite *sprite); +static void pokemonanimfunc_6A(struct Sprite *sprite); +static void pokemonanimfunc_6B(struct Sprite *sprite); +static void pokemonanimfunc_6C(struct Sprite *sprite); +static void pokemonanimfunc_6D(struct Sprite *sprite); +static void pokemonanimfunc_6E(struct Sprite *sprite); +static void pokemonanimfunc_6F(struct Sprite *sprite); +static void pokemonanimfunc_70(struct Sprite *sprite); +static void pokemonanimfunc_71(struct Sprite *sprite); +static void pokemonanimfunc_72(struct Sprite *sprite); +static void pokemonanimfunc_73(struct Sprite *sprite); +static void pokemonanimfunc_74(struct Sprite *sprite); +static void pokemonanimfunc_75(struct Sprite *sprite); +static void pokemonanimfunc_76(struct Sprite *sprite); +static void pokemonanimfunc_77(struct Sprite *sprite); +static void pokemonanimfunc_78(struct Sprite *sprite); +static void pokemonanimfunc_79(struct Sprite *sprite); +static void pokemonanimfunc_7A(struct Sprite *sprite); +static void pokemonanimfunc_7B(struct Sprite *sprite); +static void pokemonanimfunc_7C(struct Sprite *sprite); +static void pokemonanimfunc_7D(struct Sprite *sprite); +static void pokemonanimfunc_7E(struct Sprite *sprite); +static void pokemonanimfunc_7F(struct Sprite *sprite); +static void pokemonanimfunc_80(struct Sprite *sprite); +static void pokemonanimfunc_81(struct Sprite *sprite); +static void pokemonanimfunc_82(struct Sprite *sprite); +static void pokemonanimfunc_83(struct Sprite *sprite); +static void pokemonanimfunc_84(struct Sprite *sprite); +static void pokemonanimfunc_85(struct Sprite *sprite); +static void pokemonanimfunc_86(struct Sprite *sprite); +static void pokemonanimfunc_87(struct Sprite *sprite); +static void pokemonanimfunc_88(struct Sprite *sprite); +static void pokemonanimfunc_89(struct Sprite *sprite); +static void pokemonanimfunc_8A(struct Sprite *sprite); +static void pokemonanimfunc_8B(struct Sprite *sprite); +static void pokemonanimfunc_8C(struct Sprite *sprite); +static void pokemonanimfunc_8D(struct Sprite *sprite); +static void pokemonanimfunc_8E(struct Sprite *sprite); +static void pokemonanimfunc_8F(struct Sprite *sprite); +static void pokemonanimfunc_90(struct Sprite *sprite); +static void pokemonanimfunc_91(struct Sprite *sprite); +static void pokemonanimfunc_92(struct Sprite *sprite); +static void pokemonanimfunc_93(struct Sprite *sprite); +static void pokemonanimfunc_94(struct Sprite *sprite); +static void pokemonanimfunc_95(struct Sprite *sprite); +static void pokemonanimfunc_96(struct Sprite *sprite); + +static void SpriteCB_SetDummyOnAnimEnd(struct Sprite *sprite); + +#define STRUCT_COUNT 4 + +// IWRAM bss +static IWRAM_DATA struct UnkAnimStruct sUnknown_03001240[STRUCT_COUNT]; +static IWRAM_DATA u8 sUnknown_03001270; +static IWRAM_DATA bool32 sUnknown_03001274; + +// const rom data +static const u8 sSpeciesToBackAnimSet[] = +{ + 0x00, // SPECIES_NONE + 0x13, // SPECIES_BULBASAUR + 0x02, // SPECIES_IVYSAUR + 0x08, // SPECIES_VENUSAUR + 0x12, // SPECIES_CHARMANDER + 0x15, // SPECIES_CHARMELEON + 0x17, // SPECIES_CHARIZARD + 0x12, // SPECIES_SQUIRTLE + 0x12, // SPECIES_WARTORTLE + 0x19, // SPECIES_BLASTOISE + 0x02, // SPECIES_CATERPIE + 0x13, // SPECIES_METAPOD + 0x11, // SPECIES_BUTTERFREE + 0x02, // SPECIES_WEEDLE + 0x13, // SPECIES_KAKUNA + 0x01, // SPECIES_BEEDRILL + 0x0f, // SPECIES_PIDGEY + 0x15, // SPECIES_PIDGEOTTO + 0x0f, // SPECIES_PIDGEOT + 0x0a, // SPECIES_RATTATA + 0x0a, // SPECIES_RATICATE + 0x0f, // SPECIES_SPEAROW + 0x15, // SPECIES_FEAROW + 0x0f, // SPECIES_EKANS + 0x09, // SPECIES_ARBOK + 0x16, // SPECIES_PIKACHU + 0x16, // SPECIES_RAICHU + 0x12, // SPECIES_SANDSHREW + 0x10, // SPECIES_SANDSLASH + 0x12, // SPECIES_NIDORAN_F + 0x15, // SPECIES_NIDORINA + 0x09, // SPECIES_NIDOQUEEN + 0x12, // SPECIES_NIDORAN_M + 0x15, // SPECIES_NIDORINO + 0x09, // SPECIES_NIDOKING + 0x13, // SPECIES_CLEFAIRY + 0x13, // SPECIES_CLEFABLE + 0x10, // SPECIES_VULPIX + 0x01, // SPECIES_NINETALES + 0x13, // SPECIES_JIGGLYPUFF + 0x06, // SPECIES_WIGGLYTUFF + 0x11, // SPECIES_ZUBAT + 0x09, // SPECIES_GOLBAT + 0x02, // SPECIES_ODDISH + 0x02, // SPECIES_GLOOM + 0x14, // SPECIES_VILEPLUME + 0x02, // SPECIES_PARAS + 0x08, // SPECIES_PARASECT + 0x0a, // SPECIES_VENONAT + 0x11, // SPECIES_VENOMOTH + 0x09, // SPECIES_DIGLETT + 0x09, // SPECIES_DUGTRIO + 0x10, // SPECIES_MEOWTH + 0x0f, // SPECIES_PERSIAN + 0x02, // SPECIES_PSYDUCK + 0x14, // SPECIES_GOLDUCK + 0x10, // SPECIES_MANKEY + 0x10, // SPECIES_PRIMEAPE + 0x15, // SPECIES_GROWLITHE + 0x15, // SPECIES_ARCANINE + 0x12, // SPECIES_POLIWAG + 0x09, // SPECIES_POLIWHIRL + 0x0e, // SPECIES_POLIWRATH + 0x14, // SPECIES_ABRA + 0x14, // SPECIES_KADABRA + 0x0d, // SPECIES_ALAKAZAM + 0x15, // SPECIES_MACHOP + 0x09, // SPECIES_MACHOKE + 0x09, // SPECIES_MACHAMP + 0x0b, // SPECIES_BELLSPROUT + 0x0b, // SPECIES_WEEPINBELL + 0x0b, // SPECIES_VICTREEBEL + 0x02, // SPECIES_TENTACOOL + 0x02, // SPECIES_TENTACRUEL + 0x0e, // SPECIES_GEODUDE + 0x08, // SPECIES_GRAVELER + 0x08, // SPECIES_GOLEM + 0x17, // SPECIES_PONYTA + 0x15, // SPECIES_RAPIDASH + 0x02, // SPECIES_SLOWPOKE + 0x13, // SPECIES_SLOWBRO + 0x0f, // SPECIES_MAGNEMITE + 0x0f, // SPECIES_MAGNETON + 0x02, // SPECIES_FARFETCHD + 0x0f, // SPECIES_DODUO + 0x15, // SPECIES_DODRIO + 0x13, // SPECIES_SEEL + 0x02, // SPECIES_DEWGONG + 0x0b, // SPECIES_GRIMER + 0x0c, // SPECIES_MUK + 0x13, // SPECIES_SHELLDER + 0x0f, // SPECIES_CLOYSTER + 0x01, // SPECIES_GASTLY + 0x01, // SPECIES_HAUNTER + 0x14, // SPECIES_GENGAR + 0x09, // SPECIES_ONIX + 0x13, // SPECIES_DROWZEE + 0x14, // SPECIES_HYPNO + 0x0a, // SPECIES_KRABBY + 0x09, // SPECIES_KINGLER + 0x15, // SPECIES_VOLTORB + 0x15, // SPECIES_ELECTRODE + 0x02, // SPECIES_EXEGGCUTE + 0x10, // SPECIES_EXEGGUTOR + 0x15, // SPECIES_CUBONE + 0x10, // SPECIES_MAROWAK + 0x02, // SPECIES_HITMONLEE + 0x0f, // SPECIES_HITMONCHAN + 0x02, // SPECIES_LICKITUNG + 0x06, // SPECIES_KOFFING + 0x06, // SPECIES_WEEZING + 0x0e, // SPECIES_RHYHORN + 0x0e, // SPECIES_RHYDON + 0x12, // SPECIES_CHANSEY + 0x0b, // SPECIES_TANGELA + 0x12, // SPECIES_KANGASKHAN + 0x13, // SPECIES_HORSEA + 0x11, // SPECIES_SEADRA + 0x11, // SPECIES_GOLDEEN + 0x11, // SPECIES_SEAKING + 0x13, // SPECIES_STARYU + 0x19, // SPECIES_STARMIE + 0x14, // SPECIES_MR_MIME + 0x0f, // SPECIES_SCYTHER + 0x13, // SPECIES_JYNX + 0x16, // SPECIES_ELECTABUZZ + 0x17, // SPECIES_MAGMAR + 0x0e, // SPECIES_PINSIR + 0x0e, // SPECIES_TAUROS + 0x10, // SPECIES_MAGIKARP + 0x09, // SPECIES_GYARADOS + 0x19, // SPECIES_LAPRAS + 0x05, // SPECIES_DITTO + 0x12, // SPECIES_EEVEE + 0x19, // SPECIES_VAPOREON + 0x16, // SPECIES_JOLTEON + 0x17, // SPECIES_FLAREON + 0x01, // SPECIES_PORYGON + 0x13, // SPECIES_OMANYTE + 0x13, // SPECIES_OMASTAR + 0x13, // SPECIES_KABUTO + 0x15, // SPECIES_KABUTOPS + 0x15, // SPECIES_AERODACTYL + 0x13, // SPECIES_SNORLAX + 0x19, // SPECIES_ARTICUNO + 0x16, // SPECIES_ZAPDOS + 0x17, // SPECIES_MOLTRES + 0x02, // SPECIES_DRATINI + 0x0f, // SPECIES_DRAGONAIR + 0x09, // SPECIES_DRAGONITE + 0x0d, // SPECIES_MEWTWO + 0x12, // SPECIES_MEW + 0x12, // SPECIES_CHIKORITA + 0x02, // SPECIES_BAYLEEF + 0x09, // SPECIES_MEGANIUM + 0x12, // SPECIES_CYNDAQUIL + 0x15, // SPECIES_QUILAVA + 0x17, // SPECIES_TYPHLOSION + 0x15, // SPECIES_TOTODILE + 0x15, // SPECIES_CROCONAW + 0x09, // SPECIES_FERALIGATR + 0x12, // SPECIES_SENTRET + 0x10, // SPECIES_FURRET + 0x11, // SPECIES_HOOTHOOT + 0x0f, // SPECIES_NOCTOWL + 0x0a, // SPECIES_LEDYBA + 0x11, // SPECIES_LEDIAN + 0x0a, // SPECIES_SPINARAK + 0x02, // SPECIES_ARIADOS + 0x0f, // SPECIES_CROBAT + 0x0b, // SPECIES_CHINCHOU + 0x16, // SPECIES_LANTURN + 0x12, // SPECIES_PICHU + 0x13, // SPECIES_CLEFFA + 0x13, // SPECIES_IGGLYBUFF + 0x13, // SPECIES_TOGEPI + 0x11, // SPECIES_TOGETIC + 0x12, // SPECIES_NATU + 0x14, // SPECIES_XATU + 0x12, // SPECIES_MAREEP + 0x13, // SPECIES_FLAAFFY + 0x16, // SPECIES_AMPHAROS + 0x11, // SPECIES_BELLOSSOM + 0x12, // SPECIES_MARILL + 0x13, // SPECIES_AZUMARILL + 0x02, // SPECIES_SUDOWOODO + 0x10, // SPECIES_POLITOED + 0x11, // SPECIES_HOPPIP + 0x11, // SPECIES_SKIPLOOM + 0x11, // SPECIES_JUMPLUFF + 0x10, // SPECIES_AIPOM + 0x13, // SPECIES_SUNKERN + 0x02, // SPECIES_SUNFLORA + 0x11, // SPECIES_YANMA + 0x0b, // SPECIES_WOOPER + 0x02, // SPECIES_QUAGSIRE + 0x14, // SPECIES_ESPEON + 0x14, // SPECIES_UMBREON + 0x12, // SPECIES_MURKROW + 0x13, // SPECIES_SLOWKING + 0x01, // SPECIES_MISDREAVUS + 0x14, // SPECIES_UNOWN + 0x0b, // SPECIES_WOBBUFFET + 0x14, // SPECIES_GIRAFARIG + 0x08, // SPECIES_PINECO + 0x09, // SPECIES_FORRETRESS + 0x0f, // SPECIES_DUNSPARCE + 0x05, // SPECIES_GLIGAR + 0x09, // SPECIES_STEELIX + 0x15, // SPECIES_SNUBBULL + 0x09, // SPECIES_GRANBULL + 0x0d, // SPECIES_QWILFISH + 0x15, // SPECIES_SCIZOR + 0x13, // SPECIES_SHUCKLE + 0x15, // SPECIES_HERACROSS + 0x0f, // SPECIES_SNEASEL + 0x13, // SPECIES_TEDDIURSA + 0x09, // SPECIES_URSARING + 0x17, // SPECIES_SLUGMA + 0x17, // SPECIES_MAGCARGO + 0x0a, // SPECIES_SWINUB + 0x08, // SPECIES_PILOSWINE + 0x02, // SPECIES_CORSOLA + 0x02, // SPECIES_REMORAID + 0x05, // SPECIES_OCTILLERY + 0x0f, // SPECIES_DELIBIRD + 0x02, // SPECIES_MANTINE + 0x15, // SPECIES_SKARMORY + 0x09, // SPECIES_HOUNDOUR + 0x09, // SPECIES_HOUNDOOM + 0x19, // SPECIES_KINGDRA + 0x15, // SPECIES_PHANPY + 0x0e, // SPECIES_DONPHAN + 0x01, // SPECIES_PORYGON2 + 0x13, // SPECIES_STANTLER + 0x02, // SPECIES_SMEARGLE + 0x0f, // SPECIES_TYROGUE + 0x07, // SPECIES_HITMONTOP + 0x02, // SPECIES_SMOOCHUM + 0x08, // SPECIES_ELEKID + 0x17, // SPECIES_MAGBY + 0x02, // SPECIES_MILTANK + 0x13, // SPECIES_BLISSEY + 0x16, // SPECIES_RAIKOU + 0x17, // SPECIES_ENTEI + 0x19, // SPECIES_SUICUNE + 0x0e, // SPECIES_LARVITAR + 0x09, // SPECIES_PUPITAR + 0x0e, // SPECIES_TYRANITAR + 0x19, // SPECIES_LUGIA + 0x17, // SPECIES_HO_OH + 0x18, // SPECIES_CELEBI + 0x00, // SPECIES_OLD_UNOWN_B + 0x00, // SPECIES_OLD_UNOWN_C + 0x00, // SPECIES_OLD_UNOWN_D + 0x00, // SPECIES_OLD_UNOWN_E + 0x00, // SPECIES_OLD_UNOWN_F + 0x00, // SPECIES_OLD_UNOWN_G + 0x00, // SPECIES_OLD_UNOWN_H + 0x00, // SPECIES_OLD_UNOWN_I + 0x00, // SPECIES_OLD_UNOWN_J + 0x00, // SPECIES_OLD_UNOWN_K + 0x00, // SPECIES_OLD_UNOWN_L + 0x00, // SPECIES_OLD_UNOWN_M + 0x00, // SPECIES_OLD_UNOWN_N + 0x00, // SPECIES_OLD_UNOWN_O + 0x00, // SPECIES_OLD_UNOWN_P + 0x00, // SPECIES_OLD_UNOWN_Q + 0x00, // SPECIES_OLD_UNOWN_R + 0x00, // SPECIES_OLD_UNOWN_S + 0x00, // SPECIES_OLD_UNOWN_T + 0x00, // SPECIES_OLD_UNOWN_U + 0x00, // SPECIES_OLD_UNOWN_V + 0x00, // SPECIES_OLD_UNOWN_W + 0x00, // SPECIES_OLD_UNOWN_X + 0x00, // SPECIES_OLD_UNOWN_Y + 0x00, // SPECIES_OLD_UNOWN_Z + 0x10, // SPECIES_TREECKO + 0x15, // SPECIES_GROVYLE + 0x09, // SPECIES_SCEPTILE + 0x12, // SPECIES_TORCHIC + 0x10, // SPECIES_COMBUSKEN + 0x17, // SPECIES_BLAZIKEN + 0x02, // SPECIES_MUDKIP + 0x12, // SPECIES_MARSHTOMP + 0x19, // SPECIES_SWAMPERT + 0x12, // SPECIES_POOCHYENA + 0x08, // SPECIES_MIGHTYENA + 0x0f, // SPECIES_ZIGZAGOON + 0x15, // SPECIES_LINOONE + 0x0b, // SPECIES_WURMPLE + 0x08, // SPECIES_SILCOON + 0x11, // SPECIES_BEAUTIFLY + 0x08, // SPECIES_CASCOON + 0x0f, // SPECIES_DUSTOX + 0x02, // SPECIES_LOTAD + 0x10, // SPECIES_LOMBRE + 0x10, // SPECIES_LUDICOLO + 0x13, // SPECIES_SEEDOT + 0x09, // SPECIES_NUZLEAF + 0x14, // SPECIES_SHIFTRY + 0x0a, // SPECIES_NINCADA + 0x01, // SPECIES_NINJASK + 0x14, // SPECIES_SHEDINJA + 0x12, // SPECIES_TAILLOW + 0x15, // SPECIES_SWELLOW + 0x13, // SPECIES_SHROOMISH + 0x15, // SPECIES_BRELOOM + 0x07, // SPECIES_SPINDA + 0x11, // SPECIES_WINGULL + 0x11, // SPECIES_PELIPPER + 0x03, // SPECIES_SURSKIT + 0x11, // SPECIES_MASQUERAIN + 0x19, // SPECIES_WAILMER + 0x19, // SPECIES_WAILORD + 0x13, // SPECIES_SKITTY + 0x12, // SPECIES_DELCATTY + 0x01, // SPECIES_KECLEON + 0x13, // SPECIES_BALTOY + 0x14, // SPECIES_CLAYDOL + 0x0e, // SPECIES_NOSEPASS + 0x17, // SPECIES_TORKOAL + 0x01, // SPECIES_SABLEYE + 0x0b, // SPECIES_BARBOACH + 0x09, // SPECIES_WHISCASH + 0x04, // SPECIES_LUVDISC + 0x0f, // SPECIES_CORPHISH + 0x15, // SPECIES_CRAWDAUNT + 0x03, // SPECIES_FEEBAS + 0x19, // SPECIES_MILOTIC + 0x04, // SPECIES_CARVANHA + 0x15, // SPECIES_SHARPEDO + 0x13, // SPECIES_TRAPINCH + 0x01, // SPECIES_VIBRAVA + 0x0f, // SPECIES_FLYGON + 0x0e, // SPECIES_MAKUHITA + 0x0e, // SPECIES_HARIYAMA + 0x15, // SPECIES_ELECTRIKE + 0x09, // SPECIES_MANECTRIC + 0x0e, // SPECIES_NUMEL + 0x17, // SPECIES_CAMERUPT + 0x13, // SPECIES_SPHEAL + 0x09, // SPECIES_SEALEO + 0x09, // SPECIES_WALREIN + 0x0a, // SPECIES_CACNEA + 0x08, // SPECIES_CACTURNE + 0x0f, // SPECIES_SNORUNT + 0x0f, // SPECIES_GLALIE + 0x13, // SPECIES_LUNATONE + 0x13, // SPECIES_SOLROCK + 0x10, // SPECIES_AZURILL + 0x10, // SPECIES_SPOINK + 0x14, // SPECIES_GRUMPIG + 0x12, // SPECIES_PLUSLE + 0x12, // SPECIES_MINUN + 0x09, // SPECIES_MAWILE + 0x14, // SPECIES_MEDITITE + 0x14, // SPECIES_MEDICHAM + 0x11, // SPECIES_SWABLU + 0x11, // SPECIES_ALTARIA + 0x12, // SPECIES_WYNAUT + 0x01, // SPECIES_DUSKULL + 0x01, // SPECIES_DUSCLOPS + 0x18, // SPECIES_ROSELIA + 0x02, // SPECIES_SLAKOTH + 0x10, // SPECIES_VIGOROTH + 0x08, // SPECIES_SLAKING + 0x0b, // SPECIES_GULPIN + 0x0b, // SPECIES_SWALOT + 0x0e, // SPECIES_TROPIUS + 0x13, // SPECIES_WHISMUR + 0x09, // SPECIES_LOUDRED + 0x0d, // SPECIES_EXPLOUD + 0x13, // SPECIES_CLAMPERL + 0x11, // SPECIES_HUNTAIL + 0x11, // SPECIES_GOREBYSS + 0x14, // SPECIES_ABSOL + 0x01, // SPECIES_SHUPPET + 0x01, // SPECIES_BANETTE + 0x0b, // SPECIES_SEVIPER + 0x15, // SPECIES_ZANGOOSE + 0x02, // SPECIES_RELICANTH + 0x15, // SPECIES_ARON + 0x09, // SPECIES_LAIRON + 0x0e, // SPECIES_AGGRON + 0x11, // SPECIES_CASTFORM + 0x11, // SPECIES_VOLBEAT + 0x11, // SPECIES_ILLUMISE + 0x0c, // SPECIES_LILEEP + 0x0b, // SPECIES_CRADILY + 0x0f, // SPECIES_ANORITH + 0x09, // SPECIES_ARMALDO + 0x14, // SPECIES_RALTS + 0x14, // SPECIES_KIRLIA + 0x14, // SPECIES_GARDEVOIR + 0x09, // SPECIES_BAGON + 0x09, // SPECIES_SHELGON + 0x08, // SPECIES_SALAMENCE + 0x0f, // SPECIES_BELDUM + 0x15, // SPECIES_METANG + 0x09, // SPECIES_METAGROSS + 0x09, // SPECIES_REGIROCK + 0x09, // SPECIES_REGICE + 0x09, // SPECIES_REGISTEEL + 0x19, // SPECIES_KYOGRE + 0x17, // SPECIES_GROUDON + 0x0d, // SPECIES_RAYQUAZA + 0x01, // SPECIES_LATIAS + 0x01, // SPECIES_LATIOS + 0x11, // SPECIES_JIRACHI + 0x14, // SPECIES_DEOXYS + 0x11, // SPECIES_CHIMECHO +}; + +static const u8 sUnknown_0860AA64[][2] = +{ + {0, 5}, + {1, 1}, + {0, 15}, + {1, 4}, + {0, 2}, + {1, 2}, + {0, 2}, + {1, 2}, + {0, 2}, + {1, 2}, + {0, 2}, + {1, 2}, + {0, 2}, + {0, 0xFF} +}; + +static const u8 sUnknown_0860AA80[][2] = +{ + {6, 30}, + {0xFE, 15}, + {6, 30}, + {0xFF, 0} +}; + +static void (* const sMonAnimFunctions[])(struct Sprite *sprite) = +{ + pokemonanimfunc_00, + pokemonanimfunc_01, + pokemonanimfunc_02, + pokemonanimfunc_03, + pokemonanimfunc_04, + pokemonanimfunc_05, + pokemonanimfunc_06, + pokemonanimfunc_07, + pokemonanimfunc_08, + pokemonanimfunc_09, + pokemonanimfunc_0A, + pokemonanimfunc_0B, + pokemonanimfunc_0C, + pokemonanimfunc_0D, + pokemonanimfunc_0E, + pokemonanimfunc_0F, + pokemonanimfunc_10, + pokemonanimfunc_11, + pokemonanimfunc_12, + pokemonanimfunc_13, + pokemonanimfunc_14, + pokemonanimfunc_15, + pokemonanimfunc_16, + pokemonanimfunc_17, + pokemonanimfunc_18, + pokemonanimfunc_19, + pokemonanimfunc_1A, + pokemonanimfunc_1B, + pokemonanimfunc_1C, + pokemonanimfunc_1D, + pokemonanimfunc_1E, + pokemonanimfunc_1F, + pokemonanimfunc_20, + pokemonanimfunc_21, + pokemonanimfunc_22, + pokemonanimfunc_23, + pokemonanimfunc_24, + pokemonanimfunc_25, + pokemonanimfunc_26, + pokemonanimfunc_27, + pokemonanimfunc_28, + pokemonanimfunc_29, + pokemonanimfunc_2A, + pokemonanimfunc_2B, + pokemonanimfunc_2C, + pokemonanimfunc_2D, + pokemonanimfunc_2E, + pokemonanimfunc_2F, + pokemonanimfunc_30, + pokemonanimfunc_31, + pokemonanimfunc_32, + pokemonanimfunc_33, + pokemonanimfunc_34, + pokemonanimfunc_35, + pokemonanimfunc_36, + pokemonanimfunc_37, + pokemonanimfunc_38, + pokemonanimfunc_39, + pokemonanimfunc_3A, + pokemonanimfunc_3B, + pokemonanimfunc_3C, + pokemonanimfunc_3D, + pokemonanimfunc_3E, + pokemonanimfunc_3F, + pokemonanimfunc_40, + pokemonanimfunc_41, + pokemonanimfunc_42, + pokemonanimfunc_43, + pokemonanimfunc_44, + pokemonanimfunc_45, + pokemonanimfunc_46, + pokemonanimfunc_47, + pokemonanimfunc_48, + pokemonanimfunc_49, + pokemonanimfunc_4A, + pokemonanimfunc_4B, + pokemonanimfunc_4C, + pokemonanimfunc_4D, + pokemonanimfunc_4E, + pokemonanimfunc_4F, + pokemonanimfunc_50, + pokemonanimfunc_51, + pokemonanimfunc_52, + pokemonanimfunc_53, + pokemonanimfunc_54, + pokemonanimfunc_55, + pokemonanimfunc_56, + pokemonanimfunc_57, + pokemonanimfunc_58, + pokemonanimfunc_59, + pokemonanimfunc_5A, + pokemonanimfunc_5B, + pokemonanimfunc_5C, + pokemonanimfunc_5D, + pokemonanimfunc_5E, + pokemonanimfunc_5F, + pokemonanimfunc_60, + pokemonanimfunc_61, + pokemonanimfunc_62, + pokemonanimfunc_63, + pokemonanimfunc_64, + pokemonanimfunc_65, + pokemonanimfunc_66, + pokemonanimfunc_67, + pokemonanimfunc_68, + pokemonanimfunc_69, + pokemonanimfunc_6A, + pokemonanimfunc_6B, + pokemonanimfunc_6C, + pokemonanimfunc_6D, + pokemonanimfunc_6E, + pokemonanimfunc_6F, + pokemonanimfunc_70, + pokemonanimfunc_71, + pokemonanimfunc_72, + pokemonanimfunc_73, + pokemonanimfunc_74, + pokemonanimfunc_75, + pokemonanimfunc_76, + pokemonanimfunc_77, + pokemonanimfunc_78, + pokemonanimfunc_79, + pokemonanimfunc_7A, + pokemonanimfunc_7B, + pokemonanimfunc_7C, + pokemonanimfunc_7D, + pokemonanimfunc_7E, + pokemonanimfunc_7F, + pokemonanimfunc_80, + pokemonanimfunc_81, + pokemonanimfunc_82, + pokemonanimfunc_83, + pokemonanimfunc_84, + pokemonanimfunc_85, + pokemonanimfunc_86, + pokemonanimfunc_87, + pokemonanimfunc_88, + pokemonanimfunc_89, + pokemonanimfunc_8A, + pokemonanimfunc_8B, + pokemonanimfunc_8C, + pokemonanimfunc_8D, + pokemonanimfunc_8E, + pokemonanimfunc_8F, + pokemonanimfunc_90, + pokemonanimfunc_91, + pokemonanimfunc_92, + pokemonanimfunc_93, + pokemonanimfunc_94, + pokemonanimfunc_95, + pokemonanimfunc_96 +}; + +// counting from Id 1, because 0 in sSpeciesToBackAnimSet is used for mons with no back animation +static const u8 sBackAnimationIds[] = +{ + 0x60, 0x5f, 0x02, // 1 + 0x5e, 0x03, 0x46, // 2 + 0x6d, 0x3e, 0x6e, // 3 + 0x6f, 0x70, 0x3f, // 4 + 0x71, 0x13, 0x72, // 5 + 0x6c, 0x6b, 0x3a, // 6 + 0x64, 0x14, 0x4f, // 7 + 0x5d, 0x0f, 0x4c, // 8 + 0x61, 0x57, 0x58, // 9 + 0x67, 0x66, 0x59, // 0xA + 0x74, 0x73, 0x5a, // 0xB + 0x75, 0x76, 0x5b, // 0xC + 0x77, 0x78, 0x65, // 0xD + 0x63, 0x5c, 0x62, // 0xE + 0x6a, 0x69, 0x68, // 0xF + 0x7b, 0x7a, 0x79, // 0x10 + 0x7e, 0x7d, 0x7c, // 0x11 + 0x81, 0x80, 0x7f, // 0x12 + 0x84, 0x82, 0x83, // 0x13 + 0x85, 0x86, 0x87, // 0x14 + 0x88, 0x89, 0x8a, // 0x15 + 0x8b, 0x8c, 0x8d, // 0x16 + 0x8e, 0x8f, 0x90, // 0x17 + 0x91, 0x92, 0x93, // 0x18 + 0x94, 0x95, 0x96, // 0x19 +}; + +static const u8 sBackAnimNatureModTable[] = +{ + 0x00, // NATURE_HARDY + 0x02, // NATURE_LONELY + 0x00, // NATURE_BRAVE + 0x00, // NATURE_ADAMANT + 0x00, // NATURE_NAUGHTY + 0x01, // NATURE_BOLD + 0x01, // NATURE_DOCILE + 0x01, // NATURE_RELAXED + 0x00, // NATURE_IMPISH + 0x01, // NATURE_LAX + 0x02, // NATURE_TIMID + 0x00, // NATURE_HASTY + 0x01, // NATURE_SERIOUS + 0x00, // NATURE_JOLLY + 0x00, // NATURE_NAIVE + 0x02, // NATURE_MODEST + 0x02, // NATURE_MILD + 0x02, // NATURE_QUIET + 0x02, // NATURE_BASHFUL + 0x01, // NATURE_RASH + 0x01, // NATURE_CALM + 0x02, // NATURE_GENTLE + 0x01, // NATURE_SASSY + 0x02, // NATURE_CAREFUL + 0x01, // NATURE_QUIRKY +}; + +static const union AffineAnimCmd sSpriteAffineAnim_860AD48[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMDTYPE_END +}; + +static const union AffineAnimCmd sSpriteAffineAnim_860AD58[] = +{ + AFFINEANIMCMD_FRAME(-256, 256, 0, 0), + AFFINEANIMCMDTYPE_END +}; + +static const union AffineAnimCmd *const sSpriteAffineAnimTable_860AD68[] = +{ + sSpriteAffineAnim_860AD48, + sSpriteAffineAnim_860AD58 +}; + +// code +static void MonAnimDummySpriteCallback(struct Sprite *sprite) +{ +} + +static void sub_817F3F0(struct Sprite *sprite, u16 index, s16 amplitudeX, s16 amplitudeY) +{ + s16 xAdder, yAdder; + + amplitudeX *= -1; + amplitudeY *= -1; + + xAdder = Cos(index, amplitudeX) - Sin(index, amplitudeY); + yAdder = Cos(index, amplitudeY) + Sin(index, amplitudeX); + + amplitudeX *= -1; + amplitudeY *= -1; + + sprite->pos2.x = xAdder + amplitudeX; + sprite->pos2.y = yAdder + amplitudeY; +} + +u8 GetSpeciesBackAnimSet(u16 species) +{ + if (sSpeciesToBackAnimSet[species] != 0) + return sSpeciesToBackAnimSet[species] - 1; + else + return 0; +} + +#define tState data[0] +#define tPtrLO data[1] +#define tPtrHI data[2] +#define tAnimId data[3] +#define tSaved0 data[4] +#define tSaved2 data[5] + +static void Task_HandleMonAnimation(u8 taskId) +{ + u32 i; + struct Sprite *sprite = (struct Sprite*)(u32)((gTasks[taskId].tPtrLO << 0x10) | (gTasks[taskId].tPtrHI)); + + if (gTasks[taskId].tState == 0) + { + gTasks[taskId].tSaved0 = sprite->data[0]; + gTasks[taskId].tSaved2 = sprite->data[2]; + sprite->data[1] = 1; + sprite->data[0] = 0; + + for (i = 2; i < ARRAY_COUNT(sprite->data); i++) + sprite->data[i] = 0; + + sprite->callback = sMonAnimFunctions[gTasks[taskId].tAnimId]; + sUnknown_03001274 = FALSE; + + gTasks[taskId].tState++; + } + if (sprite->callback == SpriteCallbackDummy) + { + sprite->data[0] = gTasks[taskId].tSaved0; + sprite->data[2] = gTasks[taskId].tSaved2; + sprite->data[1] = 0; + + DestroyTask(taskId); + } +} + +void LaunchAnimationTaskForFrontSprite(struct Sprite *sprite, u8 frontAnimId) +{ + u8 taskId = CreateTask(Task_HandleMonAnimation, 128); + gTasks[taskId].tPtrLO = (u32)(sprite) >> 0x10; + gTasks[taskId].tPtrHI = (u32)(sprite); + gTasks[taskId].tAnimId = frontAnimId; +} + +void StartMonSummaryAnimation(struct Sprite *sprite, u8 frontAnimId) +{ + sUnknown_03001274 = TRUE; + sprite->callback = sMonAnimFunctions[frontAnimId]; +} + +void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimSet) +{ + u8 nature, taskId, animId, bank; + + taskId = CreateTask(Task_HandleMonAnimation, 128); + gTasks[taskId].tPtrLO = (u32)(sprite) >> 0x10; + gTasks[taskId].tPtrHI = (u32)(sprite); + + bank = sprite->data[0]; + nature = GetNature(&gPlayerParty[gBattlePartyID[bank]]); + + animId = 3 * backAnimSet + sBackAnimNatureModTable[nature]; + gTasks[taskId].tAnimId = sBackAnimationIds[animId]; +} + +#undef tState +#undef tPtrLO +#undef tPtrHI +#undef tAnimId +#undef tSaved0 +#undef tSaved2 + +void SetSpriteCB_MonAnimDummy(struct Sprite *sprite) +{ + sprite->callback = MonAnimDummySpriteCallback; +} + +static void SetAffineData(struct Sprite *sprite, s16 xScale, s16 yScale, u16 rotation) +{ + u8 matrixNum; + struct ObjAffineSrcData affineSrcData; + struct OamMatrix dest; + + affineSrcData.xScale = xScale; + affineSrcData.yScale = yScale; + affineSrcData.rotation = rotation; + + matrixNum = sprite->oam.matrixNum; + + ObjAffineSet(&affineSrcData, &dest, 1, 2); + gOamMatrices[matrixNum].a = dest.a; + gOamMatrices[matrixNum].b = dest.b; + gOamMatrices[matrixNum].c = dest.c; + gOamMatrices[matrixNum].d = dest.d; +} + +static void HandleStartAffineAnim(struct Sprite *sprite) +{ + sprite->oam.affineMode = 3; + sprite->affineAnims = sSpriteAffineAnimTable_860AD68; + + if (sUnknown_03001274 == TRUE) + InitSpriteAffineAnim(sprite); + + if (!sprite->data[1]) + StartSpriteAffineAnim(sprite, 1); + else + StartSpriteAffineAnim(sprite, 0); + + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); + sprite->affineAnimPaused = 1; +} + +static void HandleSetAffineData(struct Sprite *sprite, s16 xScale, s16 yScale, u16 rotation) +{ + if (!sprite->data[1]) + { + xScale *= -1; + rotation *= -1; + } + + SetAffineData(sprite, xScale, yScale, rotation); +} + +static void sub_817F70C(struct Sprite *sprite) +{ + if (!sprite->data[1]) + sprite->pos2.x *= -1; +} + +static bool32 sub_817F724(u8 id) +{ + if (id >= STRUCT_COUNT) + { + return FALSE; + } + else + { + sUnknown_03001240[id].field_6 = 0; + sUnknown_03001240[id].field_0 = 0; + sUnknown_03001240[id].field_4 = 1; + sUnknown_03001240[id].field_2 = 0; + sUnknown_03001240[id].field_8 = 0; + return TRUE; + } +} + +static u8 sub_817F758(void) +{ + sUnknown_03001270 = (sUnknown_03001270 + 1) % STRUCT_COUNT; + sub_817F724(sUnknown_03001270); + return sUnknown_03001270; +} + +static void sub_817F77C(struct Sprite *sprite) +{ + sprite->oam.affineMode = 1; + CalcCenterToCornerVec(sprite, sprite->oam.shape, sprite->oam.size, sprite->oam.affineMode); + + if (sUnknown_03001274 == TRUE) + { + if (!sprite->data[1]) + sprite->hFlip = 1; + else + sprite->hFlip = 0; + + FreeOamMatrix(sprite->oam.matrixNum); + sprite->oam.matrixNum |= (sprite->hFlip << 3); + sprite->oam.affineMode = 0; + } +} + +static void pokemonanimfunc_01(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 40) + { + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 var = (sprite->data[2] * 512 / 40) % 256; + + sprite->data[4] = Sin(var, 32) + 256; + sprite->data[5] = Cos(var, 32) + 256; + HandleSetAffineData(sprite, sprite->data[4], sprite->data[5], 0); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_02(struct Sprite *sprite) +{ + if (sprite->data[2] > 40) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + } + else + { + s8 sign; + if (!(sprite->data[2] & 1)) + sign = 1; + else + sign = -1; + + sprite->pos2.x = Sin((sprite->data[2] * 128 / 40) % 256, 6) * sign; + } + + sprite->data[2]++; +} + +static void sub_817F8FC(struct Sprite *sprite) +{ + sub_817F70C(sprite); + + if (sprite->data[2] > sprite->data[0]) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + } + else + { + sprite->pos2.x = Sin((sprite->data[2] * 384 / sprite->data[0]) % 256, 6); + } + + sprite->data[2]++; + sub_817F70C(sprite); +} + +static void pokemonanimfunc_03(struct Sprite *sprite) +{ + sprite->data[0] = 40; + sub_817F8FC(sprite); + sprite->callback = sub_817F8FC; +} + +static void sub_817F978(struct Sprite *sprite) +{ + sub_817F70C(sprite); + + if (sprite->data[2] > sprite->data[0]) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.y = 0; + } + else + { + sprite->pos2.y = -(Sin((sprite->data[2] * 384 / sprite->data[0]) % 256, 6)); + } + + sprite->data[2]++; + sub_817F70C(sprite); +} + +static void pokemonanimfunc_04(struct Sprite *sprite) +{ + sprite->data[0] = 40; + sub_817F978(sprite); + sprite->callback = sub_817F978; +} + +#ifdef NONMATCHING +static void sub_817F9F4(struct Sprite *sprite) +{ + s32 counter = sprite->data[2]; + + if (counter > 384) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + else + { + s32 divCounter = counter / 128; + + switch (divCounter) + { + case 0: + case 1: + sprite->pos2.y = -(Sin(counter % 128, sprite->data[0] * 2)); + break; + case 2: + case 3: + sprite->pos2.y = -(Sin(counter - 256, sprite->data[0] * 3)); + break; + } + } + + sprite->data[2] += 12; +} + +#else +__attribute__((naked)) +static void sub_817F9F4(struct Sprite *sprite) +{ + asm(".syntax unified\n\ + push {r4,lr}\n\ + adds r4, r0, 0\n\ + movs r0, 0x32\n\ + ldrsh r1, [r4, r0]\n\ + movs r0, 0xC0\n\ + lsls r0, 1\n\ + cmp r1, r0\n\ + ble _0817FA14\n\ + ldr r0, =SpriteCB_SetDummyOnAnimEnd\n\ + str r0, [r4, 0x1C]\n\ + movs r0, 0\n\ + strh r0, [r4, 0x24]\n\ + b _0817FA5E\n\ + .pool\n\ +_0817FA14:\n\ + adds r0, r1, 0\n\ + cmp r1, 0\n\ + bge _0817FA1C\n\ + adds r0, 0x7F\n\ +_0817FA1C:\n\ + asrs r2, r0, 7\n\ + lsls r0, r2, 16\n\ + asrs r0, 16\n\ + cmp r0, 0\n\ + blt _0817FA60\n\ + cmp r0, 0x1\n\ + ble _0817FA48\n\ + cmp r0, 0x3\n\ + bgt _0817FA60\n\ + ldr r2, =0xffffff00\n\ + adds r1, r2\n\ + lsls r0, r1, 16\n\ + asrs r0, 16\n\ + movs r1, 0x2E\n\ + ldrsh r2, [r4, r1]\n\ + lsls r1, r2, 1\n\ + adds r1, r2\n\ + lsls r1, 16\n\ + b _0817FA56\n\ + .pool\n\ +_0817FA48:\n\ + lsls r0, r2, 7\n\ + subs r0, r1, r0\n\ + lsls r0, 16\n\ + asrs r0, 16\n\ + movs r2, 0x2E\n\ + ldrsh r1, [r4, r2]\n\ + lsls r1, 17\n\ +_0817FA56:\n\ + asrs r1, 16\n\ + bl Sin\n\ + negs r0, r0\n\ +_0817FA5E:\n\ + strh r0, [r4, 0x26]\n\ +_0817FA60:\n\ + ldrh r0, [r4, 0x32]\n\ + adds r0, 0xC\n\ + strh r0, [r4, 0x32]\n\ + pop {r4}\n\ + pop {r0}\n\ + bx r0\n\ + .syntax divided"); +} + +#endif // NONMATCHING + +static void pokemonanimfunc_1E(struct Sprite *sprite) +{ + sprite->data[0] = 4; + sub_817F9F4(sprite); + sprite->callback = sub_817F9F4; +} + +static void pokemonanimfunc_06(struct Sprite *sprite) +{ + s32 counter = sprite->data[2]; + + if (counter > 768) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + else + { + s16 divCounter = counter / 128; + + switch (divCounter) + { + case 0: + case 1: + sprite->pos2.x = 0; + break; + case 2: + counter = 0; + break; + case 3: + sprite->pos2.x = -(counter % 128 * 8) / 128; + break; + case 4: + sprite->pos2.x = (counter % 128) / 8 - 8; + break; + case 5: + sprite->pos2.x = -(counter % 128 * 8) / 128 + 8; + break; + } + + sprite->pos2.y = -(Sin(counter % 128, 8)); + } + + sprite->data[2] += 12; +} + +static void pokemonanimfunc_09(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 40) + { + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 index = (sprite->data[2] * 256 / 40) % 256; + + if (sprite->data[2] % 2 == 0) + { + sprite->data[4] = Sin(index, 32) + 256; + sprite->data[5] = Sin(index, 32) + 256; + } + else + { + sprite->data[4] = Sin(index, 8) + 256; + sprite->data[5] = Sin(index, 8) + 256; + } + + HandleSetAffineData(sprite, sprite->data[4], sprite->data[5], 0); + } + + sprite->data[2]++; +} + +static const s8 sUnknown_0860AD70[][3] = +{ + {-1, -1, 6}, + {2, 0, 6}, + {-2, 2, 6}, + {2, 0, 6}, + {-2, -2, 6}, + {2, 0, 6}, + {-2, 2, 6}, + {2, 0, 6}, + {-1, -1, 6}, + {0, 0, 0}, +}; + +static void sub_817FC20(struct Sprite *sprite) +{ + sub_817F70C(sprite); + + if (sprite->data[2] == 0) + sprite->data[3] = 0; + + if (sUnknown_0860AD70[sprite->data[3]][2] == sprite->data[2]) + { + if (sUnknown_0860AD70[sprite->data[3]][2] == 0) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[3]++; + sprite->data[2] = 0; + } + } + + if (sUnknown_0860AD70[sprite->data[3]][2] == 0) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->pos2.x += sUnknown_0860AD70[sprite->data[3]][0]; + sprite->pos2.y += sUnknown_0860AD70[sprite->data[3]][1]; + sprite->data[2]++; + sub_817F70C(sprite); + } +} + +static void pokemonanimfunc_0A(struct Sprite *sprite) +{ + sub_817FC20(sprite); + sprite->callback = sub_817FC20; +} + +static void sub_817FCDC(struct Sprite *sprite) +{ + s32 counter = sprite->data[2]; + + if (counter > 2304) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + } + else + { + sprite->pos2.x = Sin(counter % 256, sprite->data[7]); + } + + sprite->data[2] += sprite->data[0]; +} + +static void pokemonanimfunc_0F(struct Sprite *sprite) +{ + sprite->data[0] = 60; + sprite->data[7] = 3; + sub_817FCDC(sprite); + sprite->callback = sub_817FCDC; +} + +static void sub_817FD44(struct Sprite *sprite) +{ + s32 counter = sprite->data[2]; + + if (counter > 2304) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.y = 0; + } + else + { + sprite->pos2.y = Sin(counter % 256, 3); + } + + sprite->data[2] += sprite->data[0]; +} + +static void pokemonanimfunc_10(struct Sprite *sprite) +{ + sprite->data[0] = 60; + sub_817FD44(sprite); + sprite->callback = sub_817FD44; +} + +static void pokemonanimfunc_11(struct Sprite *sprite) +{ + if (sprite->data[2] > 512) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + else + { + s8 sign; + s32 index, amplitude; + + if (!(sprite->data[2] & 1)) + sign = 1; + else + sign = -1; + + amplitude = Sin(sprite->data[2] / 4, 8); + index = sprite->data[2] % 256; + + sprite->pos2.y = Sin(index, amplitude) * sign; + sprite->pos2.x = Cos(index, amplitude) * sign; + } + + sprite->data[2] += 9; +} + +static void sub_817FE30(struct Sprite *sprite) +{ + s16 id = sprite->data[0]; + + if (sUnknown_03001240[id].field_0 != 0) + { + sUnknown_03001240[id].field_0--; + } + else + { + if (sprite->data[2] == 0 && sUnknown_03001240[id].field_8 == 0) + { + HandleStartAffineAnim(sprite); + sUnknown_03001240[id].field_8++; + } + + if (sprite->data[2] > sUnknown_03001240[id].field_6) + { + HandleSetAffineData(sprite, 256, 256, 0); + + if (sUnknown_03001240[id].field_4 > 1) + { + sUnknown_03001240[id].field_4--; + sUnknown_03001240[id].field_0 = 10; + sprite->data[2] = 0; + } + else + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + } + else + { + sprite->data[6] = Sin(sprite->data[2] % 256, 4096); + HandleSetAffineData(sprite, 256, 256, sprite->data[6]); + } + + sprite->data[2] += 16; + } +} + +static void pokemonanimfunc_12(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 512; + sUnknown_03001240[id].field_0 = 0; + sub_817FE30(sprite); + sprite->callback = sub_817FE30; +} + +static void sub_817FF3C(struct Sprite *sprite) +{ + u8 id = sprite->data[0]; + + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > sUnknown_03001240[id].field_0) + { + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[6] = (65536 / sUnknown_03001240[id].field_8) * sprite->data[2]; + HandleSetAffineData(sprite, 256, 256, sprite->data[6]); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_1F(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_0 = 60; + sUnknown_03001240[id].field_8 = 20; + sub_817FF3C(sprite); + sprite->callback = sub_817FF3C; +} + +static void sub_817FFF0(struct Sprite *sprite) +{ + u8 id = sprite->data[0]; + + sub_817F70C(sprite); + + if (sprite->data[2] > sUnknown_03001240[id].field_6) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 index = (sprite->data[2] + 192) % 256; + + sprite->pos2.x = -(Cos(index, sUnknown_03001240[id].field_8 * 2)); + sprite->pos2.y = Sin(index, sUnknown_03001240[id].field_8) + sUnknown_03001240[id].field_8; + } + + sprite->data[2] += sUnknown_03001240[id].field_2; + sub_817F70C(sprite); +} + +static void pokemonanimfunc_14(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 512; + sUnknown_03001240[id].field_8 = 6; + sUnknown_03001240[id].field_2 = 24; + sub_817FFF0(sprite); + sprite->callback = sub_817FFF0; +} + +static void pokemonanimfunc_15(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + + if (sprite->data[2] > 128) + { + BlendPalette(sprite->data[7], 0x10, 0, RGB_BLACK); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[6] = Sin(sprite->data[2], 16); + BlendPalette(sprite->data[7], 0x10, sprite->data[6], RGB_BLACK); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_16(struct Sprite *sprite) +{ + s16 index1 = 0, index2 = 0; + + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 40) + { + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + index2 = (sprite->data[2] * 128) / 40; + + if (sprite->data[2] >= 10 && sprite->data[2] <= 29) + { + sprite->data[7] += 51; + index1 = 0xFF & sprite->data[7]; + } + + if (sprite->data[1] == 0) + sprite->data[4] = (Sin(index2, 40) - 256) + Sin(index1, 16); + else + sprite->data[4] = (256 - Sin(index2, 40)) - Sin(index1, 16); + + sprite->data[5] = Sin(index2, 16) + 256; + SetAffineData(sprite, sprite->data[4], sprite->data[5], 0); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_17(struct Sprite *sprite) +{ + s16 posY = 0, index1 = 0, index2 = 0; + + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 40) + { + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.y = posY; + } + else + { + index2 = (sprite->data[2] * 128) / 40; + + if (sprite->data[2] >= 10 && sprite->data[2] <= 29) + { + sprite->data[7] += 51; + index1 = 0xFF & sprite->data[7]; + } + + if (sprite->data[1] == 0) + sprite->data[4] = -(Sin(index2, 16)) - 256; + else + sprite->data[4] = Sin(index2, 16) + 256; + + sprite->data[5] = (256 - Sin(index2, 40)) - Sin(index1, 8); + + if (sprite->data[5] != 256) + posY = (256 - sprite->data[5]) / 8; + + sprite->pos2.y = -(posY); + SetAffineData(sprite, sprite->data[4], sprite->data[5], 0); + } + + sprite->data[2]++; +} + +static void sub_818031C(struct Sprite *sprite) +{ + u8 index = sprite->data[2]; + u8 var7 = sprite->data[6]; + u8 var5 = sUnknown_0860AA80[sprite->data[5]][0]; + u8 var6 = sUnknown_0860AA80[sprite->data[5]][1]; + u8 amplitude = 0; + + if (var5 != 0xFE) + amplitude = (var6 - var7) * var5 / var6; + else + amplitude = 0; + + if (var5 == 0xFF) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.y = 0; + } + else + { + sprite->pos2.y = Sin(index, amplitude); + + if (var7 == var6) + { + sprite->data[5]++; + sprite->data[6] = 0; + } + else + { + sprite->data[2] += sprite->data[0]; + sprite->data[6]++; + } + } +} + +static void pokemonanimfunc_19(struct Sprite *sprite) +{ + sprite->data[0] = 48; + sub_818031C(sprite); + sprite->callback = sub_818031C; +} + +static void pokemonanimfunc_1A(struct Sprite *sprite) +{ + u8 counter = 0; + + sub_817F70C(sprite); + counter = sprite->data[2]; + + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 35) + { + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + } + else + { + s16 index = ((counter - 10) * 128) / 20; + + if (counter < 10) + HandleSetAffineData(sprite, 256, 256, counter / 2 * 512); + else if (counter >= 10 && counter <= 29) + sprite->pos2.x = -(Sin(index, 5)); + else + HandleSetAffineData(sprite, 256, 256, (35 - counter) / 2 * 1024); + } + + sprite->data[2]++; + sub_817F70C(sprite); +} + +static void pokemonanimfunc_1B(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 100) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.y = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 index = (sprite->data[2] * 256) / 100; + sprite->pos2.y = Sin(index, 10); + HandleSetAffineData(sprite, 256, 256, Sin(index, 3276)); + } + + sprite->data[2]++; +} + +static void sub_81804F8(struct Sprite *sprite) +{ + s32 var = 0; + s16 index = 0; + + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 100) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.y = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + index = (sprite->data[2] * 256) / 100; + var = (sprite->data[2] * 512) / 100; + var &= 0xFF; + sprite->pos2.y = Sin(index, sprite->data[0]); + HandleSetAffineData(sprite, 256, 256, Sin(var, 3276)); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_1C(struct Sprite *sprite) +{ + sprite->data[0] = 10; + sub_81804F8(sprite); + sprite->callback = sub_81804F8; +} + +static void sub_81805B0(struct Sprite *sprite) +{ + s32 var = 0; + s16 index = 0; + + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 100) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.y = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + index = (sprite->data[2] * 256) / 100; + var = (sprite->data[2] * 512) / 100; + var &= 0xFF; + sprite->pos2.y = -(Sin(index / 2, sprite->data[0] * 2)); + HandleSetAffineData(sprite, 256, 256, Sin(var, 3276)); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_18(struct Sprite *sprite) +{ + sprite->data[0] = 5; + sub_81805B0(sprite); + sprite->callback = sub_81805B0; +} + +static void pokemonanimfunc_1D(struct Sprite *sprite) +{ + s32 var; + s16 index = 0; + + sub_817F70C(sprite); + var = 0; + + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + if (sprite->data[2] > 100) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.x = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 toDiv = 100; + + index = (sprite->data[2] * 256) / toDiv; + var = (sprite->data[2] * 512) / toDiv; + var &= 0xFF; + sprite->pos2.x = Sin(index, 8); + HandleSetAffineData(sprite, 256, 256, Sin(var, 3276)); + } + + sprite->data[2]++; + sub_817F70C(sprite); +} + +static void sub_8180714(struct Sprite *sprite) +{ + s16 posY = 0; + + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[3] = 0; + } + + sub_817F70C(sprite); + + if (sprite->data[2] > sprite->data[0] * 3) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.y = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 yScale = Sin(sprite->data[4], 32) + 256; + + if (sprite->data[2] > sprite->data[0] && sprite->data[2] < sprite->data[0] * 2) + sprite->data[3] += (128 / sprite->data[0]); + if (yScale > 256) + posY = (256 - yScale) / 8; + + sprite->pos2.y = -(Sin(sprite->data[3], 10)) - posY; + HandleSetAffineData(sprite, 256 - Sin(sprite->data[4], 32), yScale, 0); + sprite->data[2]++; + sprite->data[4] = (sprite->data[4] + 128 / sprite->data[0]) & 0xFF; + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_00(struct Sprite *sprite) +{ + sprite->data[0] = 16; + sub_8180714(sprite); + sprite->callback = sub_8180714; +} + +static void sub_8180828(struct Sprite *sprite) +{ + s16 posY = 0; + + if (sprite->data[2] > (128 / sprite->data[6]) * sprite->data[7]) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.y = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 yScale = Sin(sprite->data[4], 32) + 256; + + if (yScale > 256) + posY = (256 - yScale) / 8; + + sprite->pos2.y = -(posY); + HandleSetAffineData(sprite, Sin(sprite->data[4], 48) + 256, yScale, 0); + sprite->data[2]++; + sprite->data[4] = (sprite->data[4] + sprite->data[6]) & 0xFF; + } +} + +static void pokemonanimfunc_13(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[7] = 3; + sprite->data[6] = 8; + } + + sub_8180828(sprite); +} + +static const s8 sUnknown_0860AD8E[][8][3] = +{ + { + {0, 8, 8}, + {8, -8, 12}, + {-8, 8, 12}, + {8, -8, 12}, + {-8, 8, 12}, + {8, -8, 12}, + {-8, 0, 12}, + {0, 0, 0} + }, + { + {0, 8, 16}, + {8, -8, 24}, + {-8, 8, 24}, + {8, -8, 24}, + {-8, 8, 24}, + {8, -8, 24}, + {-8, 0, 24}, + {0, 0, 0} + }, +}; + +static void sub_8180900(struct Sprite *sprite) +{ + s16 var; + u8 structId; + s8 r9; + s16 r10; + s16 r7; + u32 arrId; + + sub_817F70C(sprite); + structId = sprite->data[0]; + var = sUnknown_03001240[structId].field_6; + r9 = sUnknown_0860AD8E[sUnknown_03001240[structId].field_8][sprite->data[4]][0]; + r10 = sUnknown_0860AD8E[sUnknown_03001240[structId].field_8][sprite->data[4]][1] - r9; + arrId = sUnknown_03001240[structId].field_8; + r7 = sprite->data[3]; + + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + } + + if (sUnknown_0860AD8E[arrId][sprite->data[4]][2] == 0) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + u16 rotation; + + sprite->pos2.y = -(Sin(r7 * 128 / sUnknown_0860AD8E[arrId][sprite->data[4]][2], 10)); + sprite->pos2.x = (r10 * r7 / sUnknown_0860AD8E[arrId][sprite->data[4]][2]) + r9; + + rotation = -(var * sprite->pos2.x) / 8; + HandleSetAffineData(sprite, 256, 256, rotation); + + if (r7 == sUnknown_0860AD8E[arrId][sprite->data[4]][2]) + { + sprite->data[4]++; + sprite->data[3] = 0; + } + else + { + sprite->data[3]++; + } + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_05(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + sUnknown_03001240[id].field_6 = 4096; + sUnknown_03001240[id].field_8 = sprite->data[6]; + sub_8180900(sprite); + sprite->callback = sub_8180900; +} + +static void pokemonanimfunc_20(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + + if (sprite->data[2] > 128) + { + BlendPalette(sprite->data[7], 0x10, 0, RGB(31, 22, 0)); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[6] = Sin(sprite->data[2], 12); + BlendPalette(sprite->data[7], 0x10, sprite->data[6], RGB(31, 22, 0)); + } + + sprite->data[2] += 2; +} + +static void pokemonanimfunc_21(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + + if (sprite->data[2] > 128) + { + BlendPalette(sprite->data[7], 0x10, 0, RGB_RED); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[6] = Sin(sprite->data[2], 12); + BlendPalette(sprite->data[7], 0x10, sprite->data[6], RGB_RED); + } + + sprite->data[2] += 2; +} + +static void pokemonanimfunc_22(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + + if (sprite->data[2] > 128) + { + BlendPalette(sprite->data[7], 0x10, 0, RGB_BLUE); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[6] = Sin(sprite->data[2], 12); + BlendPalette(sprite->data[7], 0x10, sprite->data[6], RGB_BLUE); + } + + sprite->data[2] += 2; +} + +static void pokemonanimfunc_23(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + + if (sprite->data[2] > 128) + { + BlendPalette(sprite->data[7], 0x10, 0, RGB_YELLOW); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[6] = Sin(sprite->data[2], 12); + BlendPalette(sprite->data[7], 0x10, sprite->data[6], RGB_YELLOW); + } + + sprite->data[2] += 2; +} + +static void pokemonanimfunc_24(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + + if (sprite->data[2] > 128) + { + BlendPalette(sprite->data[7], 0x10, 0, RGB(24, 0, 24)); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[6] = Sin(sprite->data[2], 12); + BlendPalette(sprite->data[7], 0x10, sprite->data[6], RGB(24, 0, 24)); + } + + sprite->data[2] += 2; +} + +static void sub_8180CB4(struct Sprite *sprite); +static void sub_8180CE8(struct Sprite *sprite); +static void sub_8180D44(struct Sprite *sprite); +static void sub_8180DC0(struct Sprite *sprite); +static void sub_8180E28(struct Sprite *sprite); + +static void pokemonanimfunc_25(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->callback = sub_8180CB4; +} + +static void sub_8180CB4(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (++sprite->pos2.x > 7) + { + sprite->pos2.x = 8; + sprite->data[7] = 2; + sprite->callback = sub_8180CE8; + } + sub_817F70C(sprite); +} + +static void sub_8180CE8(struct Sprite *sprite) +{ + sub_817F70C(sprite); + + sprite->pos2.x -= sprite->data[7]; + sprite->data[7]++; + if (sprite->pos2.x <= 0) + { + s16 subResult; + u8 var = sprite->data[7]; + sprite->data[6] = 0; + subResult = sprite->pos2.x; + + do + { + subResult -= var; + sprite->data[6]++; + var++; + } + while (subResult > -8); + + sprite->data[5] = 1; + sprite->callback = sub_8180D44; + } + + sub_817F70C(sprite); +} + +static void sub_8180D44(struct Sprite *sprite) +{ + u8 rotation; + + sub_817F70C(sprite); + sprite->pos2.x -= sprite->data[7]; + sprite->data[7]++; + rotation = (sprite->data[5] * 6) / sprite->data[6]; + + if (++sprite->data[5] > sprite->data[6]) + sprite->data[5] = sprite->data[6]; + + HandleSetAffineData(sprite, 256, 256, rotation * 256); + + if (sprite->pos2.x < -8) + { + sprite->pos2.x = -8; + sprite->data[4] = 2; + sprite->data[3] = 0; + sprite->data[2] = rotation; + sprite->callback = sub_8180DC0; + } + + sub_817F70C(sprite); +} + +static void sub_8180DC0(struct Sprite *sprite) +{ + sub_817F70C(sprite); + + if (sprite->data[3] > 11) + { + sprite->data[2] -= 2; + if (sprite->data[2] < 0) + sprite->data[2] = 0; + + HandleSetAffineData(sprite, 256, 256, sprite->data[2] << 8); + if (sprite->data[2] == 0) + sprite->callback = sub_8180E28; + } + else + { + sprite->pos2.x += sprite->data[4]; + sprite->data[4] *= -1; + sprite->data[3]++; + } + + sub_817F70C(sprite); +} + +static void sub_8180E28(struct Sprite *sprite) +{ + sub_817F70C(sprite); + + sprite->pos2.x += 2; + if (sprite->pos2.x > 0) + { + sprite->pos2.x = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + + sub_817F70C(sprite); +} + +static void sub_8180E78(struct Sprite *sprite); +static void sub_8180ED0(struct Sprite *sprite); +static void sub_8180F2C(struct Sprite *sprite); + +static void pokemonanimfunc_26(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->data[3] = 0; + sprite->callback = sub_8180E78; +} + +static void sub_8180E78(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x++; + sprite->pos2.y--; + + if (sprite->pos2.x % 2 == 0 && sprite->data[3] <= 0) + sprite->data[3] = 10; + if (sprite->pos2.x > 7) + { + sprite->pos2.x = 8; + sprite->pos2.y = -8; + sprite->data[4] = 0; + sprite->callback = sub_8180ED0; + } + + sub_817F70C(sprite); +} + +static void sub_8180ED0(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x = Cos(sprite->data[4], 16) - 8; + sprite->pos2.y = Sin(sprite->data[4], 16) - 8; + + if (sprite->data[4] > 63) + { + sprite->data[2] = 160; + sprite->data[3] = 10; + sprite->callback = sub_8180F2C; + } + sprite->data[4] += 8; + if (sprite->data[4] > 64) + sprite->data[4] = 64; + + sub_817F70C(sprite); +} + +static void sub_8180F2C(struct Sprite *sprite) +{ + sub_817F70C(sprite); + + if (sprite->data[3] > 0) + { + sprite->data[3]--; + } + else + { + u32 rotation; + + sprite->pos2.x = Cos(sprite->data[2], 5) - 4; + sprite->pos2.y = -(Sin(sprite->data[2], 5)) + 4; + sprite->data[2] -= 4; + rotation = sprite->data[2] - 32; + HandleSetAffineData(sprite, 256, 256, rotation * 512); + + if (sprite->data[2] <= 32) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_27(struct Sprite *sprite) +{ + if (sprite->data[3] > 0) + { + sprite->data[3]--; + } + else + { + sprite->data[4] = (sprite->data[4] == 0) ? 1 : 0; + sprite->invisible = sprite->data[4]; + if (++sprite->data[2] > 19) + { + sprite->invisible = 0; + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + sprite->data[3] = 2; + } +} + +static void sub_8181024(struct Sprite *sprite); +static void sub_8181068(struct Sprite *sprite); +static void sub_81810C4(struct Sprite *sprite); + +static void pokemonanimfunc_28(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->callback = sub_8181024; +} + +static void sub_8181024(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x--; + sprite->pos2.y++; + + if (sprite->pos2.x <= -16) + { + sprite->pos2.x = -16; + sprite->pos2.y = 16; + sprite->callback = sub_8181068; + sprite->data[2] = 160; + } + + sub_817F70C(sprite); +} + +static void sub_8181068(struct Sprite *sprite) +{ + u32 rotation; + + sub_817F70C(sprite); + sprite->data[2] -= 4; + sprite->pos2.x = Cos(sprite->data[2], 22); + sprite->pos2.y = -(Sin(sprite->data[2], 22)); + rotation = sprite->data[2] - 32; + HandleSetAffineData(sprite, 256, 256, rotation * 512); + + if (sprite->data[2] <= 32) + sprite->callback = sub_81810C4; + + sub_817F70C(sprite); +} + +static void sub_81810C4(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x--; + sprite->pos2.y++; + + if (sprite->pos2.x <= 0) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + + sub_817F70C(sprite); +} + +static void sub_8181110(struct Sprite *sprite); +static void sub_8181144(struct Sprite *sprite); +static void sub_81811A4(struct Sprite *sprite); + +static void pokemonanimfunc_29(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->callback = sub_8181110; +} + +static void sub_8181110(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x++; + sprite->pos2.y--; + + if (sprite->pos2.x > 15) + { + sprite->data[2] = 0; + sprite->callback = sub_8181144; + } + + sub_817F70C(sprite); +} + +static void sub_8181144(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->data[2] += 16; + + if (sprite->pos2.x <= -16) + { + sprite->pos2.x = -16; + sprite->pos2.y = 16; + sprite->data[2] = 0; + sprite->callback = sub_81811A4; + } + else + { + sprite->pos2.x -= 2; + sprite->pos2.y += 2; + } + + HandleSetAffineData(sprite, 256, 256, sprite->data[2] << 8); + sub_817F70C(sprite); +} + +static void sub_81811A4(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x++; + sprite->pos2.y--;; + + if (sprite->pos2.x >= 0) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + + sub_817F70C(sprite); +} + +static void sub_8181214(struct Sprite *sprite); + +static void pokemonanimfunc_2A(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + sUnknown_03001240[id].field_2 = 2; + sub_8181214(sprite); + sprite->callback = sub_8181214; +} + +static void sub_8181214(struct Sprite *sprite) +{ + if (sUnknown_03001240[sprite->data[0]].field_0 != 0) + { + sUnknown_03001240[sprite->data[0]].field_0--; + } + else + { + sub_817F70C(sprite); + if (sprite->data[2] == 0) + { + sprite->data[2]++; + HandleStartAffineAnim(sprite); + sprite->data[7] = sUnknown_03001240[sprite->data[0]].field_2; + sprite->data[3] = -1; + sprite->data[4] = -1; + sprite->data[5] = 0; + sprite->data[6] = 0; + } + + sprite->pos2.x += (sprite->data[7] * 2 * sprite->data[3]); + sprite->pos2.y += (sprite->data[7] * sprite->data[4]); + sprite->data[6] += 8; + if (sprite->pos2.x <= -16 || sprite->pos2.x >= 16) + { + sprite->pos2.x = sprite->data[3] * 16; + sprite->data[3] *= -1; + sprite->data[5]++; + } + else if (sprite->pos2.y <= -16 || sprite->pos2.y >= 16) + { + sprite->pos2.y = sprite->data[4] * 16; + sprite->data[4] *= -1; + sprite->data[5]++; + } + + if (sprite->data[5] > 5 && sprite->pos2.x <= 0) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + if (sUnknown_03001240[sprite->data[0]].field_4 > 1) + { + sUnknown_03001240[sprite->data[0]].field_4--; + sprite->data[5] = 0; + sprite->data[6] = 0; + sUnknown_03001240[sprite->data[0]].field_0 = 10; + } + else + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + } + + HandleSetAffineData(sprite, 256, 256, sprite->data[6] << 8); + sub_817F70C(sprite); + } +} + +static void sub_8181370(struct Sprite *sprite); + +static void pokemonanimfunc_2B(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->data[6] = 0; + sprite->data[7] = 0; + sprite->callback = sub_8181370; +} + +static void sub_8181370(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->data[6] += 4; + sprite->pos2.x = -(Sin(sprite->data[6], 16)); + sprite->pos2.y = -(Sin((sprite->data[6] * 2) & 0xFF, 8)); + if (sprite->data[6] > 192 && sprite->data[7] == 1) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->data[7]++; + } + else if (sprite->data[6] > 64 && sprite->data[7] == 0) + { + HandleSetAffineData(sprite, -256, 256, 0); + sprite->data[7]++; + } + + if (sprite->data[6] > 255) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + sub_817F70C(sprite); +} + +static void pokemonanimfunc_2C(struct Sprite *sprite) +{ + if (++sprite->data[2] == 1) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[6] = 0; + sprite->data[5] = 0; + sprite->data[4] = 0; + } + + if (sUnknown_0860AA64[sprite->data[6]][1] == 0xFF) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + if (sprite->data[4] == 1) + { + if (sUnknown_0860AA64[sprite->data[6]][0] != 0) + BlendPalette(sprite->data[7], 0x10, 0x10, RGB_YELLOW); + else + BlendPalette(sprite->data[7], 0x10, 0, RGB_YELLOW); + + sprite->data[4] = 0; + } + + if (sUnknown_0860AA64[sprite->data[6]][1] == sprite->data[5]) + { + sprite->data[4] = 1; + sprite->data[5] = 0; + sprite->data[6]++; + } + else + { + sprite->data[5]++; + } + } +} + +static void sub_81814D4(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + sub_817F70C(sprite); + if (sprite->data[2] > sUnknown_03001240[sprite->data[0]].field_8) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.x = 0; + if (sUnknown_03001240[sprite->data[0]].field_4 > 1) + { + sUnknown_03001240[sprite->data[0]].field_4--; + sprite->data[2] = 0; + } + else + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + } + else + { + s16 index = (sprite->data[2] * 256) / sUnknown_03001240[sprite->data[0]].field_8; + sprite->pos2.x = -(Sin(index, 10)); + HandleSetAffineData(sprite, 256, 256, Sin(index, 3276)); + } + + sprite->data[2]++; + sub_817F70C(sprite); +} + +static void pokemonanimfunc_2D(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + sUnknown_03001240[id].field_8 = 50; + sub_81814D4(sprite); + sprite->callback = sub_81814D4; +} + +static void sub_81815D4(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + HandleStartAffineAnim(sprite); + + sub_817F70C(sprite); + if (sprite->data[2] > sUnknown_03001240[sprite->data[0]].field_8) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.x = 0; + if (sUnknown_03001240[sprite->data[0]].field_4 > 1) + { + sUnknown_03001240[sprite->data[0]].field_4--; + sprite->data[2] = 0; + } + else + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + } + else + { + s16 index = (sprite->data[2] * 256) / sUnknown_03001240[sprite->data[0]].field_8; + sprite->pos2.x = -(Sin(index, 10)); + HandleSetAffineData(sprite, 256, 256, -(Sin(index, 3276))); + } + + sprite->data[2]++; + sub_817F70C(sprite); +} + +static void pokemonanimfunc_2E(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + sUnknown_03001240[id].field_8 = 50; + sub_81815D4(sprite); + sprite->callback = sub_81815D4; +} + +static void sub_8181708(struct Sprite *sprite); +static void sub_8181770(struct Sprite *sprite); +static void sub_8181794(struct Sprite *sprite); + +static void pokemonanimfunc_2F(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->data[6] = -(14 * sprite->centerToCornerVecX / 10); + sprite->data[7] = 128; + sprite->callback = sub_8181708; +} + +static void sub_8181708(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->data[7]--; + sprite->pos2.x = Cos(sprite->data[7], sprite->data[6]) + sprite->data[6]; + + sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6] += 0)); // dummy += 0 is needed to match + + HandleSetAffineData(sprite, 256, 256, (sprite->data[7] - 128) << 8); + if (sprite->data[7] <= 120) + { + sprite->data[7] = 120; + sprite->data[3] = 0; + sprite->callback = sub_8181770; + } + + sub_817F70C(sprite); +} + +static void sub_8181770(struct Sprite *sprite) +{ + if (sprite->data[3] == 20) + { + sprite->callback = sub_8181794; + sprite->data[3] = 0; + } + + sprite->data[3]++; +} + +static void sub_8181794(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->data[7] += 2; + sprite->pos2.x = Cos(sprite->data[7], sprite->data[6]) + sprite->data[6]; + + sprite->pos2.y = -(Sin(sprite->data[7], sprite->data[6] += 0)); // dummy += 0 is needed to match + + HandleSetAffineData(sprite, 256, 256, (sprite->data[7] - 128) << 8); + if (sprite->data[7] >= 128) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + HandleSetAffineData(sprite, 256, 256, 0); + sprite->data[2] = 0; + sub_817F77C(sprite); + sprite->callback = pokemonanimfunc_10; + } + + sub_817F70C(sprite); +} + +static void sub_8181810(struct Sprite *sprite) +{ + if (sUnknown_03001240[sprite->data[0]].field_0 != 0) + { + sUnknown_03001240[sprite->data[0]].field_0--; + } + else + { + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[4] = 0; + sprite->data[5] = 0; + sprite->data[2] = 1; + } + + if (sprite->data[5] == 0) + { + sprite->data[7] = Sin(sprite->data[4], 256); + sprite->pos2.y = Sin(sprite->data[4], 16); + sprite->data[6] = Sin(sprite->data[4], 32); + HandleSetAffineData(sprite, 256 - sprite->data[6], 256 + sprite->data[7], 0); + if (sprite->data[4] == 128) + { + sprite->data[4] = 0; + sprite->data[5] = 1; + } + } + else if (sprite->data[5] == 1) + { + sprite->data[7] = Sin(sprite->data[4], 32); + sprite->pos2.y = -(Sin(sprite->data[4], 8)); + sprite->data[6] = Sin(sprite->data[4], 128); + HandleSetAffineData(sprite, 256 + sprite->data[6], 256 - sprite->data[7], 0); + if (sprite->data[4] == 128) + { + if (sUnknown_03001240[sprite->data[0]].field_4 > 1) + { + sUnknown_03001240[sprite->data[0]].field_4--; + sUnknown_03001240[sprite->data[0]].field_0 = 10; + sprite->data[4] = 0; + sprite->data[5] = 0; + } + else + { + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + } + } + + sprite->data[4] += sUnknown_03001240[sprite->data[0]].field_6; + } +} + +static void pokemonanimfunc_30(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + sUnknown_03001240[id].field_6 = 4; + sub_8181810(sprite); + sprite->callback = sub_8181810; +} + +static void pokemonanimfunc_31(struct Sprite *sprite) +{ + s32 counter = sprite->data[2]; + sub_817F70C(sprite); + if (counter > 512) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + else + { + switch (sprite->data[2] / 128) + { + case 0: + sprite->pos2.x = -(counter % 128 * 8) / 128; + break; + case 1: + sprite->pos2.x = (counter % 128 / 16) - 8; + break; + case 2: + sprite->pos2.x = (counter % 128 / 16); + break; + case 3: + sprite->pos2.x = -(counter % 128 * 8) / 128 + 8; + break; + } + + sprite->pos2.y = -(Sin(counter % 128, 8)); + } + + sprite->data[2] += 12; + sub_817F70C(sprite); +} + +static void sub_8181ABC(struct Sprite *sprite); +static void sub_8181B4C(struct Sprite *sprite); +static void sub_8181C2C(struct Sprite *sprite); + +static void pokemonanimfunc_32(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + sUnknown_03001240[id].field_8 = -1; + HandleStartAffineAnim(sprite); + sprite->data[3] = 0; + sub_8181ABC(sprite); + sprite->callback = sub_8181ABC; +} + +static void sub_8181ABC(struct Sprite *sprite) +{ + if (sUnknown_03001240[sprite->data[0]].field_0 != 0) + { + sUnknown_03001240[sprite->data[0]].field_0--; + } + else + { + s32 counter; + + sub_817F70C(sprite); + counter = sprite->data[2]; + if (sprite->data[2] > 128) + { + sprite->data[2] = 0; + sprite->callback = sub_8181B4C; + } + else + { + s32 var = 8 * sUnknown_03001240[sprite->data[0]].field_8; + sprite->pos2.x = var * (counter % 128) / 128; + sprite->pos2.y = -(Sin(counter % 128, 8)); + sprite->data[2] += 12; + } + + sub_817F70C(sprite); + } +} + +static void sub_8181B4C(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] > 48) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.y = 0; + sprite->data[2] = 0; + sprite->callback = sub_8181C2C; + } + else + { + s16 yDelta; + s16 yScale = Sin(sprite->data[4], 64) + 256; + if (sprite->data[2] >= 16 && sprite->data[2] <= 31) + { + sprite->data[3] += 8; + sprite->pos2.x -= sUnknown_03001240[sprite->data[0]].field_8; + } + + yDelta = 0; + if (yScale > 256) + yDelta = (256 - yScale) / 8; + + sprite->pos2.y = -(Sin(sprite->data[3], 20)) - yDelta; + HandleSetAffineData(sprite, 256 - Sin(sprite->data[4], 32), yScale, 0); + sprite->data[2]++; + sprite->data[4] += 8; + sprite->data[4] &= 0xFF; + } + + sub_817F70C(sprite); +} + +static void sub_8181C2C(struct Sprite *sprite) +{ + s32 counter; + + sub_817F70C(sprite); + counter = sprite->data[2]; + if (counter > 128) + { + if (sUnknown_03001240[sprite->data[0]].field_4 > 1) + { + sUnknown_03001240[sprite->data[0]].field_4--; + sUnknown_03001240[sprite->data[0]].field_0 = 10; + sprite->data[3] = 0; + sprite->data[2] = 0; + sprite->data[4] = 0; + sprite->callback = sub_8181ABC; + } + else + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + else + { + register s32 var asm("r4") = sUnknown_03001240[sprite->data[0]].field_8; + + sprite->pos2.x = (var << 3) * (counter % 128) / 128 - (sUnknown_03001240[sprite->data[0]].field_8 * 8); + sprite->pos2.y = -(Sin(counter % 128, 8)); + } + + sprite->data[2] += 12; + sub_817F70C(sprite); +} + +static void sub_8181CE8(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + } + + sub_817F70C(sprite); + if (sprite->data[7] > 254) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + HandleSetAffineData(sprite, 256, 256, 0); + if (sUnknown_03001240[sprite->data[0]].field_4 > 1) + { + sUnknown_03001240[sprite->data[0]].field_4--; + sprite->data[2] = 0; + sprite->data[7] = 0; + } + else + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + + sub_817F70C(sprite); + } + else + { + u16 rotation; + + sprite->pos2.x = -(Sin(sprite->data[7], 16)); + rotation = Sin(sprite->data[7], 32); + HandleSetAffineData(sprite, 256, 256, rotation << 8); + sprite->data[7] += sUnknown_03001240[sprite->data[0]].field_6; + sub_817F70C(sprite); + } +} + +static void pokemonanimfunc_33(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + sUnknown_03001240[id].field_6 = 4; + sub_8181CE8(sprite); + sprite->callback = sub_8181CE8; +} + +static void pokemonanimfunc_34(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + } + + sub_817F70C(sprite); + if (sprite->data[7] > 254) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sub_817F70C(sprite); + } + else + { + u16 rotation; + + sprite->pos2.x = -(Sin(sprite->data[7], 16)); + sprite->pos2.y = -(Sin(sprite->data[7] % 128, 16)); + rotation = Sin(sprite->data[7], 32); + HandleSetAffineData(sprite, 256, 256, rotation << 8); + sprite->data[7] += 8; + sub_817F70C(sprite); + } +} + +static void pokemonanimfunc_35(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + sprite->data[7] = 0; + + if (sprite->data[2] == sprite->data[7]) + { + sprite->data[7] = 0; + sprite->data[2]++; + sprite->invisible = 0; + } + else + { + sprite->data[7]++; + sprite->invisible = 1; + } + + if (sprite->data[2] > 10) + { + sprite->invisible = 0; + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } +} + +static void sub_8181F14(struct Sprite *sprite); +static void sub_8181F50(struct Sprite *sprite); +static void sub_8181FC0(struct Sprite *sprite); + +static void pokemonanimfunc_36(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->data[7] = 0; + sprite->callback = sub_8181F14; +} + +static void sub_8181F14(struct Sprite *sprite) +{ + if (sprite->data[7] > 31) + { + sprite->data[7] = 32; + sprite->data[2] = 0; + sprite->callback = sub_8181F50; + } + else + { + sprite->data[7] += 4; + } + + HandleSetAffineData(sprite, 256, 256, sprite->data[7] << 8); +} + +static void sub_8181F50(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] > 512) + { + sprite->callback = sub_8181FC0; + sprite->data[6] = 0; + } + else + { + sprite->pos2.x = -(sprite->data[2] * 16) / 512; + sprite->pos2.y = -(Sin(sprite->data[2] % 128, 4)); + sprite->data[2] += 12; + } + + sub_817F70C(sprite); +} + +static void sub_8181FC0(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->data[7] -= 2; + if (sprite->data[7] < 0) + { + sprite->data[7] = 0; + sprite->pos2.x = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->pos2.x = -(Sin(sprite->data[7] * 2, 16)); + } + + HandleSetAffineData(sprite, 256, 256, sprite->data[7] << 8); + sub_817F70C(sprite); +} + +static void pokemonanimfunc_37(struct Sprite *sprite) +{ + u16 rotation; + + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + } + + sub_817F70C(sprite); + if (sprite->data[7] > 255) + { + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data[7] = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[7] += 16; + sprite->pos2.x = -(Sin(sprite->data[7] % 128, 8)); + sprite->pos2.y = -(Sin(sprite->data[7] % 128, 8)); + } + + rotation = Sin(sprite->data[7] % 128, 16); + HandleSetAffineData(sprite, 256, 256, rotation << 8); + sub_817F70C(sprite); +} + +static void sub_81820FC(struct Sprite *sprite); +static void sub_818216C(struct Sprite *sprite); +static void sub_81821CC(struct Sprite *sprite); +static void sub_8182248(struct Sprite *sprite); + +static void pokemonanimfunc_38(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->data[7] = 0; + sprite->data[4] = 0; + sprite->callback = sub_81820FC; +} + +static void sub_81820FC(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[7] > 24) + { + if (++sprite->data[4] > 4) + { + sprite->data[4] = 0; + sprite->callback = sub_818216C; + } + } + else + { + sprite->data[7] += 2; + sprite->pos2.x = Sin(sprite->data[7], 8); + sprite->pos2.y = -(Sin(sprite->data[7], 8)); + } + + HandleSetAffineData(sprite, 256, 256, -(sprite->data[7]) << 8); + sub_817F70C(sprite); +} + +static void sub_818216C(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[7] > 32) + { + sprite->data[6] = 1; + sprite->callback = sub_81821CC; + } + else + { + sprite->data[7] += 2; + sprite->pos2.x = Sin(sprite->data[7], 8); + sprite->pos2.y = -(Sin(sprite->data[7], 8)); + } + + HandleSetAffineData(sprite, 256, 256, -(sprite->data[7]) << 8); + sub_817F70C(sprite); +} + +static void sub_81821CC(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->data[7] += (sprite->data[6] * 4); + if (sprite->data[5] > 9) + { + sprite->data[7] = 32; + sprite->callback = sub_8182248; + } + + sprite->pos2.x = Sin(sprite->data[7], 8); + sprite->pos2.y = -(Sin(sprite->data[7], 8)); + if (sprite->data[7] <= 28 || sprite->data[7] >= 36) + { + sprite->data[6] *= -1; + sprite->data[5]++; + } + + HandleSetAffineData(sprite, 256, 256, -(sprite->data[7]) << 8); + sub_817F70C(sprite); +} + +static void sub_8182248(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[7] <= 0) + { + sprite->data[7] = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[7] -= 2; + sprite->pos2.x = Sin(sprite->data[7], 8); + sprite->pos2.y = -(Sin(sprite->data[7], 8)); + } + + HandleSetAffineData(sprite, 256, 256, -(sprite->data[7]) << 8); + sub_817F70C(sprite); +} + +static void pokemonanimfunc_39(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] > 40) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + } + else + { + s8 sign; + if (!(sprite->data[2] & 1)) + sign = 1; + else + sign = -1; + + if ((sprite->data[2] % 4) / 2 == 0) + { + sprite->pos2.x = Sin((sprite->data[2] * 128 / 40) % 256, 16) * sign; + sprite->pos2.y = -(sprite->pos2.x); + } + else + { + sprite->pos2.x = -(Sin((sprite->data[2] * 128 / 40) % 256, 16)) * sign; + sprite->pos2.y = sprite->pos2.x; + } + } + + sprite->data[2]++; + sub_817F70C(sprite); +} + +static void pokemonanimfunc_3A(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[5] = 0; + sprite->data[6] = 0; + sprite->data[7] = 0; + sprite->data[2]++; + } + + if (sprite->data[6] > 0) + { + sprite->data[6]--; + if (sprite->data[5] != 3) + { + s16 scale = (8 * sprite->data[6]) / 20; + scale = Sin(sprite->data[7] - scale, 64); + HandleSetAffineData(sprite, 256 - scale, 256 - scale, 0); + } + } + else + { + s16 var; + + if (sprite->data[5] == 3) + { + if (sprite->data[7] > 63) + { + sprite->data[7] = 64; + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + var = Cos(sprite->data[7], 64); + } + else + { + var = Sin(sprite->data[7], 64); + if (sprite->data[7] > 63) + { + sprite->data[5] = 3; + sprite->data[6] = 10; + sprite->data[7] = 0; + } + else + { + if (var > 48 && sprite->data[5] == 1) + { + sprite->data[5] = 2; + sprite->data[6] = 20; + } + else if (var > 16 && sprite->data[5] == 0) + { + sprite->data[5] = 1; + sprite->data[6] = 20; + } + } + } + + sprite->data[7] += 2; + HandleSetAffineData(sprite, 256 - var, 256 - var, 0); + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_3B(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + } + + if (sprite->data[7] > 512) + { + sprite->pos2.y = 0; + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 yScale; + + sprite->pos2.y = Sin(sprite->data[7] % 256, 8); + sprite->data[7] += 8; + yScale = Sin(sprite->data[7] % 128, 96); + HandleSetAffineData(sprite, 256, yScale + 256, 0); + } +} + +static void pokemonanimfunc_3C(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + } + + if (sprite->data[7] > 256) + { + sprite->pos2.y = 0; + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 yScale; + + sprite->pos2.y = Sin(sprite->data[7], 16); + sprite->data[7] += 4; + yScale = Sin((sprite->data[7] % 64) * 2, 128); + HandleSetAffineData(sprite, 256, yScale + 256, 0); + } +} + +static void sub_81825F8(struct Sprite *sprite); +static void sub_8182648(struct Sprite *sprite); +static void sub_81826F8(struct Sprite *sprite); + +static void pokemonanimfunc_3D(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->callback = sub_81825F8; + sprite->data[7] = 0; +} + +static void sub_81825F8(struct Sprite *sprite) +{ + s16 yScale; + + sprite->data[7] += 8; + if (sprite->data[7] > 63) + { + sprite->data[7] = 0; + sprite->data[6] = 0; + sprite->callback = sub_8182648; + yScale = Sin(64, 128); // 128 * 1 = 128 + } + else + { + yScale = Sin(sprite->data[7], 128); + } + + HandleSetAffineData(sprite, 256, 256 + yScale, 0); +} + +static void sub_8182648(struct Sprite *sprite) +{ + s16 yScale; + + sprite->data[7] += 4; + if (sprite->data[7] > 95) + { + yScale = Cos(0, 128); // 128 * (-1) = -128 + sprite->data[7] = 0; + sprite->data[6]++; + } + else + { + s16 sign, index; + + sprite->pos2.y = -(sprite->data[6] * 4) - Sin(sprite->data[7], 8); + if (sprite->data[7] > 63) + { + sign = -1; + index = sprite->data[7] - 64; + } + else + { + sign = 1; + index = 0; + } + + yScale = Cos((index * 2) + sprite->data[7], 128) * sign; + } + + HandleSetAffineData(sprite, 256, 256 + yScale, 0); + if (sprite->data[6] == 3) + { + sprite->data[7] = 0; + sprite->callback = sub_81826F8; + } +} + +static void sub_81826F8(struct Sprite *sprite) +{ + s16 yScale; + + sprite->data[7] += 8; + yScale = Cos(sprite->data[7], 128); + sprite->pos2.y = -(Cos(sprite->data[7], 12)); + if (sprite->data[7] > 63) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.y = 0; + HandleSetAffineData(sprite, 256, 256, 0); + } + + HandleSetAffineData(sprite, 256, 256 + yScale, 0); +} + +static void sub_8182764(struct Sprite *sprite) +{ + if (sprite->data[7] > sprite->data[5]) + { + sprite->pos2.x = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + HandleSetAffineData(sprite, 256, 256, 0); + } + else + { + s16 xScale; + + sprite->pos2.x = Sin(sprite->data[7] % 256, sprite->data[4]); + sprite->data[7] += sprite->data[6]; + xScale = Sin(sprite->data[7] % 128, 96); + HandleSetAffineData(sprite, 256 + xScale, 256, 0); + } +} + +static void pokemonanimfunc_3E(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + sprite->data[6] = 8; + sprite->data[5] = 512; + sprite->data[4] = 8; + } + + sub_8182764(sprite); +} + +static void sub_8182830(struct Sprite *sprite) +{ + if (sprite->data[7] > sprite->data[5]) + { + sprite->pos2.x = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + HandleSetAffineData(sprite, 256, 256, 0); + } + else + { + s16 xScale; + + sprite->pos2.x = Sin(sprite->data[7] % 256, sprite->data[4]); + sprite->data[7] += sprite->data[6]; + xScale = Sin((sprite->data[7] % 64) * 2, 128); + HandleSetAffineData(sprite, 256 + xScale, 256, 0); + } +} + +static void pokemonanimfunc_3F(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + sprite->data[6] = 4; + sprite->data[5] = 256; + sprite->data[4] = 16; + } + + sub_8182830(sprite); +} + +static void pokemonanimfunc_40(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + } + + if (sprite->data[7] > 512) + { + sprite->pos2.x = 0; + sub_817F77C(sprite); + HandleSetAffineData(sprite, 256, 256, 0); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 scale; + + sprite->pos2.x = Sin(sprite->data[7] % 256, 8); + sprite->data[7] += 8; + scale = Sin(sprite->data[7] % 128, 96); + HandleSetAffineData(sprite, 256 + scale, 256 + scale, 0); + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_41(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + } + + if (sprite->data[7] > 512) + { + sprite->pos2.x = 0; + sub_817F77C(sprite); + HandleSetAffineData(sprite, 256, 256, 0); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 scale; + + sprite->pos2.x = -(Sin((sprite->data[7] % 256) / 2, 16)); + sprite->data[7] += 8; + scale = -(Sin((sprite->data[7] % 256) / 2, 64)); + HandleSetAffineData(sprite, 256 + scale, 256 + scale, 0); + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_42(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + } + + if (sprite->data[7] > 512) + { + sprite->pos2.x = 0; + sub_817F77C(sprite); + HandleSetAffineData(sprite, 256, 256, 0); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + s16 scale; + + sprite->pos2.x = -(Sin(sprite->data[7] % 256 , 8)); + sprite->data[7] += 8; + scale = Sin((sprite->data[7] % 256) / 2, 96); + HandleSetAffineData(sprite, 256 + scale, 256 + scale, 0); + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_43(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] > 2048) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->data[6] = 0; + } + else + { + s16 caseVar = (sprite->data[2] / 512) % 4; + switch (caseVar) + { + case 0: + sprite->pos2.x = -(sprite->data[2] % 512 * 16) / 512; + break; + case 1: + sprite->pos2.x = (sprite->data[2] % 512 / 32) - 16; + break; + case 2: + sprite->pos2.x = (sprite->data[2] % 512) / 32; + break; + case 3: + sprite->pos2.x = -(sprite->data[2] % 512 * 16) / 512 + 16; + break; + } + + sprite->pos2.y = -(Sin(sprite->data[2] % 128, 4)); + sprite->data[2] += 24; + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_44(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] == 0) + { + sprite->data[6] = 0; + sprite->data[7] = 64; + sprite->data[2]++; + } + + sprite->data[7] += 8; + if (sprite->data[6] == 4) + { + if (sprite->data[7] > 63) + { + sprite->data[7] = 0; + sprite->data[6]++; + } + } + else + { + if (sprite->data[7] > 127) + { + sprite->data[7] = 0; + sprite->data[6]++; + } + } + + switch (sprite->data[6]) + { + case 1: + sprite->pos2.x = -(Cos(sprite->data[7], 8)); + sprite->pos2.y = Sin(sprite->data[7], 8) - 8; + break; + case 2: + sprite->pos2.x = Sin(sprite->data[7] + 128, 8) + 8; + sprite->pos2.y = -(Cos(sprite->data[7], 8)); + break; + case 3: + sprite->pos2.x = Cos(sprite->data[7], 8); + sprite->pos2.y = Sin(sprite->data[7] + 128, 8) + 8; + break; + case 0: + case 4: + sprite->pos2.x = Sin(sprite->data[7], 8) - 8; + sprite->pos2.y = Cos(sprite->data[7], 8); + break; + default: + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + break; + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_45(struct Sprite *sprite) +{ + sprite->data[0] = 32; + sub_8180714(sprite); + sprite->callback = sub_8180714; +} + +static void pokemonanimfunc_46(struct Sprite *sprite) +{ + sprite->data[0] = 80; + sub_817F8FC(sprite); + sprite->callback = sub_817F8FC; +} + +static void pokemonanimfunc_47(struct Sprite *sprite) +{ + sprite->data[0] = 80; + sub_817F978(sprite); + sprite->callback = sub_817F978; +} + +static void pokemonanimfunc_48(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 2048; + sUnknown_03001240[id].field_8 = sprite->data[6]; + sub_8180900(sprite); + sprite->callback = sub_8180900; +} + +static void pokemonanimfunc_49(struct Sprite *sprite) +{ + sprite->data[6] = 1; + pokemonanimfunc_05(sprite); +} + +static void pokemonanimfunc_4A(struct Sprite *sprite) +{ + sprite->data[6] = 1; + pokemonanimfunc_48(sprite); +} + +static void pokemonanimfunc_4B(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + sprite->data[0] = 0; + + if (sprite->data[0] <= 0) + { + sub_817FC20(sprite); + sprite->data[0] = 1; + } + else + { + sprite->data[0]--; + } +} + +static void pokemonanimfunc_4C(struct Sprite *sprite) +{ + sprite->data[0] = 30; + sprite->data[7] = 3; + sub_817FCDC(sprite); + sprite->callback = sub_817FCDC; +} + +static void pokemonanimfunc_4D(struct Sprite *sprite) +{ + sprite->data[0] = 30; + sub_817FD44(sprite); + sprite->callback = sub_817FD44; +} + +static void pokemonanimfunc_4E(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 1024; + sUnknown_03001240[id].field_0 = 0; + sUnknown_03001240[id].field_4 = 2; + sub_817FE30(sprite); + sprite->callback = sub_817FE30; +} + +static void pokemonanimfunc_4F(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 512; + sUnknown_03001240[id].field_8 = 3; + sUnknown_03001240[id].field_2 = 12; + sub_817FFF0(sprite); + sprite->callback = sub_817FFF0; +} + +static void pokemonanimfunc_50(struct Sprite *sprite) +{ + sprite->data[0] = 24; + sub_818031C(sprite); + sprite->callback = sub_818031C; +} + +static void pokemonanimfunc_51(struct Sprite *sprite) +{ + sprite->data[0] = 5; + sub_81804F8(sprite); + sprite->callback = sub_81804F8; +} + +static void pokemonanimfunc_52(struct Sprite *sprite) +{ + sprite->data[0] = 3; + sub_817F9F4(sprite); + sprite->callback = sub_817F9F4; +} + +static void pokemonanimfunc_53(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_0 = 60; + sUnknown_03001240[id].field_8 = 30; + sub_817FF3C(sprite); + sprite->callback = sub_817FF3C; +} + +static void pokemonanimfunc_54(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_2 = 1; + sUnknown_03001240[id].field_4 = 2; + sub_8181214(sprite); + sprite->callback = sub_8181214; +} + +static void pokemonanimfunc_55(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 4; + sUnknown_03001240[id].field_4 = 2; + sub_8181810(sprite); + sprite->callback = sub_8181810; +} + +static void pokemonanimfunc_56(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_8 = 1; + sUnknown_03001240[id].field_4 = 2; + HandleStartAffineAnim(sprite); + sprite->data[3] = 0; + sub_8181ABC(sprite); + sprite->callback = sub_8181ABC; +} + +static void pokemonanimfunc_07(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 2; + sub_8181CE8(sprite); + sprite->callback = sub_8181CE8; +} + +static void pokemonanimfunc_08(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 4; + sUnknown_03001240[id].field_4 = 2; + sub_8181CE8(sprite); + sprite->callback = sub_8181CE8; +} + +static void pokemonanimfunc_0B(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_8 = 100; + sub_81814D4(sprite); + sprite->callback = sub_81814D4; +} + +static void pokemonanimfunc_0C(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_8 = 50; + sUnknown_03001240[id].field_4 = 2; + sub_81814D4(sprite); + sprite->callback = sub_81814D4; +} + +static void pokemonanimfunc_0D(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_8 = 100; + sub_81815D4(sprite); + sprite->callback = sub_81815D4; +} + +static void pokemonanimfunc_0E(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_8 = 50; + sUnknown_03001240[id].field_4 = 2; + sub_81815D4(sprite); + sprite->callback = sub_81815D4; +} + +static void sub_8183140(struct Sprite *sprite) +{ + s32 counter = sprite->data[2]; + if (counter > 2304) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.y = 0; + } + else + { + sprite->pos2.y = Sin((counter + 192) % 256, sprite->data[7]) + sprite->data[7]; + } + + sprite->data[2] += sprite->data[0]; +} + +static void pokemonanimfunc_57(struct Sprite *sprite) +{ + sprite->data[0] = 60; + sprite->data[7] = 3; + sub_8183140(sprite); + sprite->callback = sub_8183140; +} + +static void pokemonanimfunc_58(struct Sprite *sprite) +{ + sprite->data[0] = 30; + sprite->data[7] = 3; + sub_8183140(sprite); + sprite->callback = sub_8183140; +} + +static void pokemonanimfunc_59(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] > 2048) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->data[6] = 0; + } + else + { + s16 divCase = (sprite->data[2] / 512) % 4; + switch (divCase) + { + case 0: + sprite->pos2.x = (sprite->data[2] % 512) / 32; + break; + case 2: + sprite->pos2.x = -(sprite->data[2] % 512 * 16) / 512; + break; + case 1: + sprite->pos2.x = -(sprite->data[2] % 512 * 16) / 512 + 16; + break; + case 3: + sprite->pos2.x = (sprite->data[2] % 512) / 32 - 16; + break; + } + + sprite->pos2.y = Sin(sprite->data[2] % 128, 4); + sprite->data[2] += 24; + } + + sub_817F70C(sprite); +} + +static void sub_81832C8(struct Sprite *sprite) +{ + s16 index1 = 0, index2 = 0; + + if (sprite->data[5] > sprite->data[6]) + { + sprite->pos2.y = 0; + sprite->data[5] = 0; + HandleSetAffineData(sprite, 256, 256, 0); + if (sprite->data[4] <= 1) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[4]--; + sprite->data[7] = 0; + } + } + else + { + u8 amplitude, cmpVal1, cmpVal2; + s16 xScale, yScale; + + index2 = (sprite->data[5] * 128) / sprite->data[6]; + cmpVal1 = sprite->data[6] / 4; + cmpVal2 = cmpVal1 * 3; + if (sprite->data[5] >= cmpVal1 && sprite->data[5] < cmpVal2) + { + sprite->data[7] += 51; + index1 = sprite->data[7] & 0xFF; + } + + if (sprite->data[1] == 0) + xScale = -256 - Sin(index2, 16); + else + xScale = 256 + Sin(index2, 16); + + amplitude = sprite->data[3]; + yScale = 256 - Sin(index2, amplitude) - Sin(index1, amplitude / 5); + SetAffineData(sprite, xScale, yScale, 0); + sprite->data[5]++; + } +} + +static void pokemonanimfunc_5A(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 1; + sprite->data[6] = 40; + sprite->data[3] = 40; + sprite->data[5] = 0; + sprite->data[7] = 0; + } + + sub_81832C8(sprite); +} + +static void sub_8183418(struct Sprite *sprite) +{ + s16 index1 = 0, index2; + + if (sprite->data[5] > sprite->data[6]) + { + sprite->data[5] = 0; + HandleSetAffineData(sprite, 256, 256, 0); + if (sprite->data[4] <= 1) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[4]--; + sprite->data[7] = 0; + } + } + else + { + u8 amplitude, cmpVal1, cmpVal2; + s16 xScale; + + index2 = (sprite->data[5] * 128) / sprite->data[6]; + cmpVal1 = sprite->data[6] / 4; + cmpVal2 = cmpVal1 * 3; + if (sprite->data[5] >= cmpVal1 && sprite->data[5] < cmpVal2) + { + sprite->data[7] += 51; + index1 = sprite->data[7] & 0xFF; + } + + amplitude = sprite->data[3]; + + if (sprite->data[1] == 0) + xScale = -256 + Sin(index2, amplitude) + Sin(index1, amplitude / 5 * 2); + else + xScale = 256 - Sin(index2, amplitude) - Sin(index1, amplitude / 5 * 2); + + SetAffineData(sprite, xScale, 256, 0); + sprite->data[5]++; + } +} + +static void pokemonanimfunc_5B(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 1; + sprite->data[6] = 40; + sprite->data[3] = 40; + sprite->data[5] = 0; + sprite->data[7] = 0; + } + + sub_8183418(sprite); +} + +static void sub_8183574(struct Sprite *sprite) +{ + u8 var6, var7; + u8 var8 = sprite->data[2]; + u8 var9 = sprite->data[6]; + u8 var5 = sUnknown_0860AA80[sprite->data[5]][0]; + u8 var2 = var5; + if (var5 != 0xFF) + var5 = sprite->data[7]; + else + var5 = 0xFF; // needed to match + + var6 = sUnknown_0860AA80[sprite->data[5]][1]; + var7 = 0; + if (var2 != 0xFE) + var7 = (var6 - var9) * var5 / var6; + + if (var5 == 0xFF) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.y = 0; + } + else + { + sprite->pos2.y = Sin((var8 + 192) % 256, var7) + var7; + if (var9 == var6) + { + sprite->data[5]++; + sprite->data[6] = 0; + } + else + { + sprite->data[2] += sprite->data[0]; + sprite->data[6]++; + } + } +} + +static void pokemonanimfunc_5C(struct Sprite *sprite) +{ + sprite->data[0] = 40; + sprite->data[7] = 6; + sub_8183574(sprite); + sprite->callback = sub_8183574; +} + +static void pokemonanimfunc_5D(struct Sprite *sprite) +{ + sprite->data[0] = 70; + sprite->data[7] = 6; + sub_817FCDC(sprite); + sprite->callback = sub_817FCDC; +} + +static void pokemonanimfunc_5E(struct Sprite *sprite) +{ + sprite->data[0] = 20; + sub_817F8FC(sprite); + sprite->callback = sub_817F8FC; +} + +static void pokemonanimfunc_5F(struct Sprite *sprite) +{ + if (sprite->data[2] > 40) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + } + else + { + s8 sign; + if (!(sprite->data[2] & 1)) + sign = 1; + else + sign = -1; + + sprite->pos2.x = Sin((sprite->data[2] * 128 / 40) % 256, 9) * sign; + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_60(struct Sprite *sprite) +{ + if (sprite->data[2] > 40) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + } + else + { + s8 sign; + if (!(sprite->data[2] & 1)) + sign = 1; + else + sign = -1; + + sprite->pos2.x = Sin((sprite->data[2] * 128 / 40) % 256, 12) * sign; + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_61(struct Sprite *sprite) +{ + sprite->data[0] = 70; + sprite->data[7] = 6; + sub_8183140(sprite); + sprite->callback = sub_8183140; +} + +static void pokemonanimfunc_62(struct Sprite *sprite) +{ + sprite->data[0] = 24; + sprite->data[7] = 6; + sub_8183574(sprite); + sprite->callback = sub_8183574; +} + +static void pokemonanimfunc_63(struct Sprite *sprite) +{ + sprite->data[0] = 56; + sprite->data[7] = 9; + sub_8183574(sprite); + sprite->callback = sub_8183574; +} + +static void pokemonanimfunc_64(struct Sprite *sprite) +{ + u8 id = sprite->data[0] = sub_817F758(); + + sUnknown_03001240[id].field_6 = 1024; + sUnknown_03001240[id].field_8 = 6; + sUnknown_03001240[id].field_2 = 24; + sub_817FFF0(sprite); + sprite->callback = sub_817FFF0; +} + +static void sub_81837DC(struct Sprite *sprite) +{ + s16 index1 = 0, index2 = 0; + if (sprite->data[5] > sprite->data[6]) + { + sprite->pos2.y = 0; + sprite->data[5] = 0; + HandleSetAffineData(sprite, 256, 256, 0); + if (sprite->data[4] <= 1) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[4]--; + sprite->data[7] = 0; + } + } + else + { + u8 amplitude, cmpVal1, cmpVal2; + s16 xScale, yScale; + + index2 = (sprite->data[5] * 128) / sprite->data[6]; + cmpVal1 = sprite->data[6] / 4; + cmpVal2 = cmpVal1 * 3; + if (sprite->data[5] >= cmpVal1 && sprite->data[5] < cmpVal2) + { + sprite->data[7] += 51; + index1 = sprite->data[7] & 0xFF; + } + + amplitude = sprite->data[3]; + + if (sprite->data[1] == 0) + xScale = Sin(index2, amplitude) + (Sin(index1, amplitude / 5 * 2) - 256); + else + xScale = 256 - Sin(index1, amplitude / 5 * 2) - Sin(index2, amplitude); + + yScale = 256 - Sin(index1, amplitude / 5) - Sin(index2, amplitude); + SetAffineData(sprite, xScale, yScale, 0); + sprite->data[5]++; + } +} + +static void pokemonanimfunc_65(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 1; + sprite->data[6] = 40; + sprite->data[3] = 40; + sprite->data[5] = 0; + sprite->data[7] = 0; + } + + sub_81837DC(sprite); +} + +static void pokemonanimfunc_66(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] > 2048) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->data[6] = 0; + } + else + { + s16 divCase = (sprite->data[2] / 512) % 4; + switch (divCase) + { + case 0: + sprite->pos2.x = (sprite->data[2] % 512) / 32; + break; + case 2: + sprite->pos2.x = -(sprite->data[2] % 512 * 16) / 512; + break; + case 1: + sprite->pos2.x = -(sprite->data[2] % 512 * 16) / 512 + 16; + break; + case 3: + sprite->pos2.x = (sprite->data[2] % 512) / 32 - 16; + break; + } + + sprite->pos2.y = Sin(sprite->data[2] % 128, 4); + sprite->data[2] += 48; + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_67(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] > 2048) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->data[6] = 0; + } + else + { + s16 divCase = (sprite->data[2] / 512) % 4; + switch (divCase) + { + case 0: + sprite->pos2.x = (sprite->data[2] % 512) / 32; + break; + case 2: + sprite->pos2.x = -(sprite->data[2] % 512 * 16) / 512; + break; + case 1: + sprite->pos2.x = -(sprite->data[2] % 512 * 16) / 512 + 16; + break; + case 3: + sprite->pos2.x = (sprite->data[2] % 512) / 32 - 16; + break; + } + + sprite->pos2.y = Sin(sprite->data[2] % 96, 4); + sprite->data[2] += 64; + } + + sub_817F70C(sprite); +} + +static const s8 sUnknown_0860ADBE[][3] = +{ +// x y timer + {1, 1, 12}, + {-2, 0, 12}, + {1, -1, 12}, + {0, 0, 0} +}; + +static void sub_8183B4C(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] == 0) + sprite->data[3] = 0; + + if (sUnknown_0860ADBE[sprite->data[3]][2] / sprite->data[5] == sprite->data[2]) + { + sprite->data[3]++; + sprite->data[2] = 0; + } + + if (sUnknown_0860ADBE[sprite->data[3]][2] / sprite->data[5] == 0) + { + if (--sprite->data[6] == 0) + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + else + sprite->data[2] = 0; + } + else + { + s32 amplitude = sprite->data[5]; + sprite->pos2.x += (sUnknown_0860ADBE[sprite->data[3]][0] * amplitude); + sprite->pos2.y += (sUnknown_0860ADBE[sprite->data[3]][1] * sprite->data[5]); // what's the point of the var if you're not reusing it? + sprite->data[2]++; + sub_817F70C(sprite); + } +} + +static void pokemonanimfunc_68(struct Sprite *sprite) +{ + sprite->data[5] = 1; + sprite->data[6] = 1; + sub_8183B4C(sprite); + sprite->callback = sub_8183B4C; +} + +static void pokemonanimfunc_69(struct Sprite *sprite) +{ + sprite->data[5] = 2; + sprite->data[6] = 1; + sub_8183B4C(sprite); + sprite->callback = sub_8183B4C; +} + +static void pokemonanimfunc_6A(struct Sprite *sprite) +{ + sprite->data[5] = 2; + sprite->data[6] = 2; + sub_8183B4C(sprite); + sprite->callback = sub_8183B4C; +} + +static void sub_8183C6C(struct Sprite *sprite) +{ + if (sprite->data[7] > 255) + { + if (sprite->data[5] <= 1) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + HandleSetAffineData(sprite, 256, 256, 0); + } + else + { + sprite->data[5]--; + sprite->data[7] = 0; + } + } + else + { + s16 scale; + + sprite->data[7] += sprite->data[6]; + if (sprite->data[7] > 256) + sprite->data[7] = 256; + + scale = Sin(sprite->data[7] / 2, 64); + HandleSetAffineData(sprite, 256 - scale, 256 - scale, 0); + } +} + +static void pokemonanimfunc_6B(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + sprite->data[6] = 4; + sprite->data[5] = 1; + } + + sub_8183C6C(sprite); + sub_817F70C(sprite); +} + +static void pokemonanimfunc_6C(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + sprite->data[6] = 8; + sprite->data[5] = 2; + } + + sub_8183C6C(sprite); + sub_817F70C(sprite); +} + +static void pokemonanimfunc_6D(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + sprite->data[6] = 8; + sprite->data[5] = 512; + sprite->data[4] = 16; + } + + sub_8182764(sprite); +} + +static void pokemonanimfunc_6E(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + sprite->data[6] = 4; + sprite->data[5] = 256; + sprite->data[4] = 16; + } + + sub_8182764(sprite); +} + +static void pokemonanimfunc_6F(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + sprite->data[6] = 8; + sprite->data[5] = 512; + sprite->data[4] = 16; + } + + sub_8182830(sprite); +} + +static void pokemonanimfunc_70(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[2]++; + sprite->data[7] = 0; + sprite->data[6] = 8; + sprite->data[5] = 512; + sprite->data[4] = 8; + } + + sub_8182830(sprite); +} + +static void pokemonanimfunc_71(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[7] = 5; + sprite->data[6] = 8; + } + + sub_8180828(sprite); +} + +static void pokemonanimfunc_72(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[7] = 3; + sprite->data[6] = 4; + } + + sub_8180828(sprite); +} + +static void pokemonanimfunc_73(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 1; + sprite->data[6] = 30; + sprite->data[3] = 60; + sprite->data[7] = 0; + } + + sub_81832C8(sprite); +} + +static void pokemonanimfunc_74(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 2; + sprite->data[6] = 20; + sprite->data[3] = 70; + sprite->data[7] = 0; + } + + sub_81832C8(sprite); +} + +static void pokemonanimfunc_75(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 2; + sprite->data[6] = 20; + sprite->data[3] = 70; + sprite->data[5] = 0; + sprite->data[7] = 0; + } + + sub_8183418(sprite); +} + +static void pokemonanimfunc_76(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 1; + sprite->data[6] = 30; + sprite->data[3] = 60; + sprite->data[5] = 0; + sprite->data[7] = 0; + } + + sub_8183418(sprite); +} + +static void pokemonanimfunc_77(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 2; + sprite->data[6] = 20; + sprite->data[3] = 70; + sprite->data[5] = 0; + sprite->data[7] = 0; + } + + sub_81837DC(sprite); +} + +static void pokemonanimfunc_78(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + HandleStartAffineAnim(sprite); + sprite->data[4] = 1; + sprite->data[6] = 30; + sprite->data[3] = 60; + sprite->data[5] = 0; + sprite->data[7] = 0; + } + + sub_81837DC(sprite); +} + +static void sub_8183FA8(struct Sprite *sprite) +{ + if (sprite->data[7] > 255) + { + if (sprite->data[6] <= 1) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + else + { + sprite->data[7] %= 256; + sprite->data[6]--; + } + } + else + { + sprite->pos2.x = -(Sin(sprite->data[7], sprite->data[5])); + sprite->pos2.y = Sin((sprite->data[7] + 192) % 256, sprite->data[4]); + if (sprite->pos2.y > 0) + sprite->pos2.y *= -1; + + sprite->pos2.y += sprite->data[4]; + sprite->data[7] += sprite->data[3]; + } +} + +static void pokemonanimfunc_79(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 1; + sprite->data[7] = 0; + sprite->data[5] = 12; + sprite->data[4] = 12; + sprite->data[3] = 4; + } + + sub_8183FA8(sprite); +} + +static void pokemonanimfunc_7A(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 1; + sprite->data[7] = 0; + sprite->data[5] = 12; + sprite->data[4] = 12; + sprite->data[3] = 6; + } + + sub_8183FA8(sprite); +} + +static void pokemonanimfunc_7B(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 2; + sprite->data[7] = 0; + sprite->data[5] = 12; + sprite->data[4] = 12; + sprite->data[3] = 8; + } + + sub_8183FA8(sprite); +} + +static void sub_81840C4(struct Sprite *sprite) +{ + if (sprite->data[7] > 256) + { + if (sprite->data[6] <= sprite->data[4]) + { + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[4]++; + sprite->data[7] = 0; + } + + sprite->pos2.x = 0; + sprite->pos2.y = 0; + } + else + { + s16 posX; + + if (sprite->data[7] > 159) + { + if (sprite->data[7] > 256) + sprite->data[7] = 256; + + sprite->pos2.y = -(Sin(sprite->data[7] % 256, 8)); + } + else if (sprite->data[7] > 95) + { + sprite->pos2.y = Sin(96, 6) - Sin((sprite->data[7] - 96) * 2, 4); + } + else + { + sprite->pos2.y = Sin(sprite->data[7], 6); + } + + posX = -(Sin(sprite->data[7] / 2, sprite->data[5])); + if (sprite->data[4] % 2 == 0) + posX *= -1; + + sprite->pos2.x = posX; + sprite->data[7] += sprite->data[3]; + } +} + +static void pokemonanimfunc_7C(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 2; + sprite->data[7] = 0; + sprite->data[5] = 16; + sprite->data[4] = 1; + sprite->data[3] = 4; + } + + sub_81840C4(sprite); +} + +static void pokemonanimfunc_7D(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 2; + sprite->data[7] = 0; + sprite->data[5] = 16; + sprite->data[4] = 1; + sprite->data[3] = 6; + } + + sub_81840C4(sprite); +} + +static void pokemonanimfunc_7E(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 3; + sprite->data[7] = 0; + sprite->data[5] = 16; + sprite->data[4] = 1; + sprite->data[3] = 8; + } + + sub_81840C4(sprite); +} + +static void pokemonanimfunc_7F(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 1; + sprite->data[7] = 0; + sprite->data[5] = 4; + sprite->data[4] = 6; + sprite->data[3] = 4; + } + + sub_8183FA8(sprite); +} + +static void pokemonanimfunc_80(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 1; + sprite->data[7] = 0; + sprite->data[5] = 4; + sprite->data[4] = 6; + sprite->data[3] = 6; + } + + sub_8183FA8(sprite); +} + +static void pokemonanimfunc_81(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[2] = 1; + sprite->data[6] = 2; + sprite->data[7] = 0; + sprite->data[5] = 4; + sprite->data[4] = 6; + sprite->data[3] = 8; + } + + sub_8183FA8(sprite); +} + +static void sub_8184290(struct Sprite *sprite) +{ + u16 index = Sin((sprite->data[2] * 128) / sprite->data[7], sprite->data[5]); + sprite->data[6] = -(index << 8); + sub_817F3F0(sprite, index, sprite->data[4], 0); + HandleSetAffineData(sprite, 256, 256, sprite->data[6]); +} + +static void pokemonanimfunc_82(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[7] = 60; + sprite->data[5] = 8; + sprite->data[4] = -32; + sprite->data[3] = 1; + sprite->data[0] = 0; + } + + if (sprite->data[2] > sprite->data[7]) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data[0]++; + if (sprite->data[3] <= sprite->data[0]) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + return; + } + else + { + sprite->data[2] = 0; + } + } + else + { + sub_8184290(sprite); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_83(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[7] = 90; + sprite->data[5] = 8; + sprite->data[4] = -32; + sprite->data[3] = 1; + sprite->data[0] = 0; + } + + if (sprite->data[2] > sprite->data[7]) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data[0]++; + if (sprite->data[3] <= sprite->data[0]) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + return; + } + else + { + sprite->data[2] = 0; + } + } + else + { + sub_8184290(sprite); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_84(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->data[7] = 30; + sprite->data[5] = 8; + sprite->data[4] = -32; + sprite->data[3] = 2; + sprite->data[0] = 0; + } + + if (sprite->data[2] > sprite->data[7]) + { + HandleSetAffineData(sprite, 256, 256, 0); + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data[0]++; + if (sprite->data[3] <= sprite->data[0]) + { + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + return; + } + else + { + sprite->data[2] = 0; + } + } + else + { + sub_8184290(sprite); + } + + sprite->data[2]++; +} + +static void sub_8184468(struct Sprite *sprite) +{ + if (sprite->data[2] > sprite->data[7]) + { + sprite->pos2.y = 0; + HandleSetAffineData(sprite, 256, 256, 0); + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + u8 posY_unsigned; + s8 posY_signed; + s32 posY; + s16 index = (u16)(sprite->data[2] % sprite->data[6] * 256) / sprite->data[6] % 256; + if (sprite->data[2] % 2 == 0) + { + sprite->data[4] = Sin(index, 32) + 256; + sprite->data[5] = Sin(index, 32) + 256; + posY_unsigned = Sin(index, 32); + posY_signed = posY_unsigned; + } + else + { + sprite->data[4] = Sin(index, 8) + 256; + sprite->data[5] = Sin(index, 8) + 256; + posY_unsigned = Sin(index, 8); + posY_signed = posY_unsigned; + } + + posY = posY_signed; + if (posY < 0) + posY += 7; + sprite->pos2.y = (u32)(posY) >> 3; + HandleSetAffineData(sprite, sprite->data[4], sprite->data[5], 0); + } + + sprite->data[2]++; +} + +static void pokemonanimfunc_85(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->pos2.y += 2; + sprite->data[6] = 40; + sprite->data[7] = 80; + } + + sub_8184468(sprite); +} + +static void pokemonanimfunc_86(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->pos2.y += 2; + sprite->data[6] = 40; + sprite->data[7] = 40; + } + + sub_8184468(sprite); +} + +static void pokemonanimfunc_87(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + HandleStartAffineAnim(sprite); + sprite->pos2.y += 2; + sprite->data[6] = 80; + sprite->data[7] = 80; + } + + sub_8184468(sprite); +} + +static void sub_8184610(struct Sprite *sprite); +static void sub_8184640(struct Sprite *sprite); +static void sub_8184678(struct Sprite *sprite); +static void sub_81846B8(struct Sprite *sprite); + +static void sub_81845D4(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x -= sprite->data[2]; + if (sprite->pos2.x <= -sprite->data[6]) + { + sprite->pos2.x = -sprite->data[6]; + sprite->data[7] = 2; + sprite->callback = sub_8184610; + } + + sub_817F70C(sprite); +} + +static void sub_8184610(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x += sprite->data[7]; + sprite->data[7]++; + if (sprite->pos2.x >= 0) + sprite->callback = sub_8184640; + + sub_817F70C(sprite); +} + +static void sub_8184640(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x += sprite->data[7]; + sprite->data[7]++; + if (sprite->pos2.x > sprite->data[6]) + { + sprite->pos2.x = sprite->data[6]; + sprite->callback = sub_8184678; + } + + sub_817F70C(sprite); +} + +static void sub_8184678(struct Sprite *sprite) +{ + sub_817F70C(sprite); + if (sprite->data[3] >= sprite->data[5]) + { + sprite->callback = sub_81846B8; + } + else + { + sprite->pos2.x += sprite->data[4]; + sprite->data[4] *= -1; + sprite->data[3]++; + } + + sub_817F70C(sprite); +} + +static void sub_81846B8(struct Sprite *sprite) +{ + sub_817F70C(sprite); + sprite->pos2.x -= 2; + if (sprite->pos2.x <= 0) + { + sprite->pos2.x = 0; + sub_817F77C(sprite); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + + sub_817F70C(sprite); +} + +static void pokemonanimfunc_88(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->data[7] = 4; + sprite->data[6] = 12; + sprite->data[5] = 16; + sprite->data[4] = 4; + sprite->data[3] = 0; + sprite->data[2] = 2; + sprite->callback = sub_81845D4; +} + +static void pokemonanimfunc_89(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->data[7] = 2; + sprite->data[6] = 8; + sprite->data[5] = 12; + sprite->data[4] = 2; + sprite->data[3] = 0; + sprite->data[2] = 1; + sprite->callback = sub_81845D4; +} + +static void pokemonanimfunc_8A(struct Sprite *sprite) +{ + HandleStartAffineAnim(sprite); + sprite->data[7] = 0; + sprite->data[6] = 6; + sprite->data[5] = 6; + sprite->data[4] = 2; + sprite->data[3] = 0; + sprite->data[2] = 1; + sprite->callback = sub_81845D4; +} + +static void sub_8184770(struct Sprite *sprite) +{ + sprite->pos2.x = sprite->data[1]; + if (sprite->data[0] > 1) + { + sprite->data[1] *= -1; + sprite->data[0] = 0; + } + else + { + sprite->data[0]++; + } +} + +struct YellowBlendStruct +{ + u8 field_0; + u8 field_1; +}; + +static const struct YellowBlendStruct sUnknown_0860ADCC[] = +{ + {0, 1}, + {1, 2}, + {0, 15}, + {1, 1}, + {0, 15}, + {1, 1}, + {0, 15}, + {1, 1}, + {0, 1}, + {1, 1}, + {0, 1}, + {1, 1}, + {0, 1}, + {1, 1}, + {0, 1}, + {1, 1}, + {0, 1}, + {1, 1}, + {0, 1}, + {0, 0xFF} +}; + +static const struct YellowBlendStruct sUnknown_0860AE1C[] = +{ + {0, 5}, + {1, 1}, + {0, 15}, + {1, 4}, + {0, 2}, + {1, 2}, + {0, 2}, + {1, 2}, + {0, 2}, + {1, 2}, + {0, 2}, + {1, 2}, + {0, 2}, + {0, 0xFF} +}; + +static const struct YellowBlendStruct sUnknown_0860AE54[] = +{ + {0, 1}, + {1, 1}, + {0, 20}, + {1, 1}, + {0, 20}, + {1, 1}, + {0, 20}, + {1, 1}, + {0, 1}, + {0, 0xFF} +}; + +static const struct YellowBlendStruct *const sUnknown_0860AE7C[] = +{ + sUnknown_0860ADCC, + sUnknown_0860AE1C, + sUnknown_0860AE54 +}; + +static void BackAnimBlendYellow(struct Sprite *sprite) +{ + const struct YellowBlendStruct *array = sUnknown_0860AE7C[sprite->data[3]]; + sub_8184770(sprite); + if (array[sprite->data[6]].field_1 == 0xFF) + { + sprite->pos2.x = 0; + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + if (sprite->data[4] == 1) + { + if (array[sprite->data[6]].field_0 != 0) + BlendPalette(sprite->data[7], 0x10, 0x10, RGB_YELLOW); + else + BlendPalette(sprite->data[7], 0x10, 0, RGB_YELLOW); + + sprite->data[4] = 0; + } + + if (array[sprite->data[6]].field_1 == sprite->data[5]) + { + sprite->data[4] = 1; + sprite->data[5] = 0; + sprite->data[6]++; + } + else + { + sprite->data[5]++; + } + } +} + +static void pokemonanimfunc_8B(struct Sprite *sprite) +{ + if (++sprite->data[2] == 1) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[6] = 0; + sprite->data[5] = 0; + sprite->data[4] = 0; + sprite->data[3] = 0; + } + + BackAnimBlendYellow(sprite); +} + +static void pokemonanimfunc_8C(struct Sprite *sprite) +{ + if (++sprite->data[2] == 1) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[6] = 0; + sprite->data[5] = 0; + sprite->data[4] = 0; + sprite->data[3] = 1; + } + + BackAnimBlendYellow(sprite); +} + +static void pokemonanimfunc_8D(struct Sprite *sprite) +{ + if (++sprite->data[2] == 1) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[6] = 0; + sprite->data[5] = 0; + sprite->data[4] = 0; + sprite->data[3] = 2; + } + + BackAnimBlendYellow(sprite); +} + +static void BackAnimBlend(struct Sprite *sprite) +{ + static const u16 sColors[] = + { + RGB_RED, RGB_GREEN, RGB_BLUE, RGB_BLACK + }; + + if (sprite->data[2] > 127) + { + BlendPalette(sprite->data[7], 0x10, 0, RGB_RED); + sprite->callback = SpriteCB_SetDummyOnAnimEnd; + } + else + { + sprite->data[6] = Sin(sprite->data[2], 12); + BlendPalette(sprite->data[7], 0x10, sprite->data[6], sColors[sprite->data[1]]); + } +} + +static void sub_8184934(struct Sprite *sprite) +{ + if (sprite->data[3] < sprite->data[4]) + { + sub_817F70C(sprite); + if (sprite->data[5] > sprite->data[0]) + { + if (++sprite->data[3] < sprite->data[4]) + sprite->data[5] = 0; + + sprite->pos2.x = 0; + } + else + { + s8 sign = 1 - (sprite->data[3] % 2 * 2); + sprite->pos2.x = sign * Sin((sprite->data[5] * 384 / sprite->data[0]) % 256, 6); + sprite->data[5]++; + } + + sub_817F70C(sprite); + } +} + +static void pokemonanimfunc_8E(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 10; + sprite->data[5] = 0; + sprite->data[4] = 2; + sprite->data[3] = 0; + sprite->data[1] = 0; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void pokemonanimfunc_8F(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 20; + sprite->data[5] = 0; + sprite->data[4] = 1; + sprite->data[3] = 0; + sprite->data[1] = 0; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void pokemonanimfunc_90(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 80; + sprite->data[5] = 0; + sprite->data[4] = 1; + sprite->data[3] = 0; + sprite->data[1] = 0; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void pokemonanimfunc_91(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 10; + sprite->data[5] = 0; + sprite->data[4] = 2; + sprite->data[3] = 0; + sprite->data[1] = 1; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void pokemonanimfunc_92(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 20; + sprite->data[5] = 0; + sprite->data[4] = 1; + sprite->data[3] = 0; + sprite->data[1] = 1; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void pokemonanimfunc_93(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 80; + sprite->data[5] = 0; + sprite->data[4] = 1; + sprite->data[3] = 0; + sprite->data[1] = 1; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void pokemonanimfunc_94(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 10; + sprite->data[5] = 0; + sprite->data[4] = 2; + sprite->data[3] = 0; + sprite->data[1] = 2; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void pokemonanimfunc_95(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 20; + sprite->data[5] = 0; + sprite->data[4] = 1; + sprite->data[3] = 0; + sprite->data[1] = 2; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void pokemonanimfunc_96(struct Sprite *sprite) +{ + if (sprite->data[2] == 0) + { + sprite->data[7] = (sprite->oam.paletteNum * 16) + 256; + sprite->data[0] = 80; + sprite->data[5] = 0; + sprite->data[4] = 1; + sprite->data[3] = 0; + sprite->data[1] = 2; + } + + if (sprite->data[2] % 2 == 0) + BackAnimBlend(sprite); + + if (sprite->data[2] >= (128 - sprite->data[0] * sprite->data[4]) / 2) + sub_8184934(sprite); + + sprite->data[2]++; +} + +static void SpriteCB_SetDummyOnAnimEnd(struct Sprite *sprite) +{ + if (sprite->animEnded) + sprite->callback = SpriteCallbackDummy; +} diff --git a/src/pokemon_summary_screen.c b/src/pokemon_summary_screen.c index a900badd1..4affd830d 100644 --- a/src/pokemon_summary_screen.c +++ b/src/pokemon_summary_screen.c @@ -162,7 +162,7 @@ extern struct BattleMove gBattleMoves[]; extern u32 ChangeBgX(u8 bg, u32 value, u8 op); extern void sub_8199C30(u8 a, u8 b, u8 c, u8 d, u8 e, u8 f); -extern void AddTextPrinterParametrized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str); +extern void AddTextPrinterParameterized2(u8 windowId, u8 fontId, u8 x, u8 y, u8 letterSpacing, u8 lineSpacing, struct TextColor* colors, s8 speed, u8 *str); extern s32 GetStringCenterAlignXOffset(u8 fontId, u8 *str, s32 totalWidth); extern s32 GetStringRightAlignXOffset(u8 fontId, u8 *str, s32 totalWidth); extern bool8 sub_81A6BF4(); @@ -2557,7 +2557,7 @@ void sub_81C2554() void sub_81C25A4(u8 a, u8 *b, u8 c, u8 d, u8 e, u8 f) { - AddTextPrinterParametrized2(a, 1, c, d, 0, e, &gUnknown_0861CD2C[f], 0, b); + AddTextPrinterParameterized2(a, 1, c, d, 0, e, &gUnknown_0861CD2C[f], 0, b); } void sub_81C25E8() diff --git a/src/save_failed_screen.c b/src/save_failed_screen.c index 8764daa5f..95897e721 100644 --- a/src/save_failed_screen.c +++ b/src/save_failed_screen.c @@ -173,7 +173,7 @@ static void SaveFailedScreenTextPrint(u8 *text, u8 var1, u8 var2) color.fgColor = 0; color.bgColor = 15; color.shadowColor = 3; - AddTextPrinterParametrized2(gSaveFailedWindowIds[TEXT_WIN_ID], 1, var1 * 8, var2 * 8 + 1, 0, 0, &color, 0, text); + AddTextPrinterParameterized2(gSaveFailedWindowIds[TEXT_WIN_ID], 1, var1 * 8, var2 * 8 + 1, 0, 0, &color, 0, text); } void DoSaveFailedScreen(u8 saveType) |