From 43c48d95c269e2024afb6ef72da4e2ff4f2ce339 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 6 Jul 2020 17:22:37 -0400 Subject: [PATCH] Document starter_choose.c --- ...h_ballarrow.png => pokeball_selection.png} | Bin .../{birch_circle.png => starter_circle.png} | Bin include/starter_choose.h | 1 + include/strings.h | 3 + src/battle_factory_screen.c | 7 +- src/starter_choose.c | 289 +++++++++--------- 6 files changed, 151 insertions(+), 149 deletions(-) rename graphics/misc/{birch_ballarrow.png => pokeball_selection.png} (100%) rename graphics/misc/{birch_circle.png => starter_circle.png} (100%) diff --git a/graphics/misc/birch_ballarrow.png b/graphics/misc/pokeball_selection.png similarity index 100% rename from graphics/misc/birch_ballarrow.png rename to graphics/misc/pokeball_selection.png diff --git a/graphics/misc/birch_circle.png b/graphics/misc/starter_circle.png similarity index 100% rename from graphics/misc/birch_circle.png rename to graphics/misc/starter_circle.png diff --git a/include/starter_choose.h b/include/starter_choose.h index 535e272b7..7a4f6e967 100644 --- a/include/starter_choose.h +++ b/include/starter_choose.h @@ -5,6 +5,7 @@ extern const u16 gBirchBagGrassPal[2][16]; extern const u32 gBirchBagTilemap[]; extern const u32 gBirchGrassTilemap[]; extern const u32 gBirchHelpGfx[]; +extern const u32 gPokeballSelection_Gfx[]; u16 GetStarterPokemon(u16 chosenStarterId); void CB2_ChooseStarter(void); diff --git a/include/strings.h b/include/strings.h index 5720598ad..b9101bceb 100644 --- a/include/strings.h +++ b/include/strings.h @@ -374,6 +374,9 @@ extern const u8 gText_DefaultNameTerra[]; extern const u8 gText_DefaultNameLucy[]; extern const u8 gText_DefaultNameHalie[]; +extern const u8 gText_BirchInTrouble[]; +extern const u8 gText_ConfirmStarterChoice[]; + // mystery event menu text extern const u8 gText_EventSafelyLoaded[]; extern const u8 gText_LoadErrorEndingSession[]; diff --git a/src/battle_factory_screen.c b/src/battle_factory_screen.c index de2f3a10c..d3a5d566a 100644 --- a/src/battle_factory_screen.c +++ b/src/battle_factory_screen.c @@ -24,6 +24,7 @@ #include "pokedex.h" #include "util.h" #include "trainer_pokemon_sprites.h" +#include "starter_choose.h" #include "constants/battle_frontier.h" #include "constants/songs.h" #include "constants/rgb.h" @@ -132,8 +133,6 @@ struct FactorySwapMonsStruct bool8 unk30; }; -extern const u32 gUnknown_085B18AC[]; - // This file's functions. static void sub_819A44C(struct Sprite *sprite); static void CB2_InitSelectScreen(void); @@ -263,7 +262,7 @@ static const struct SpriteSheet gUnknown_086103BC[] = static const struct CompressedSpriteSheet gUnknown_086103E4[] = { - {gUnknown_085B18AC, 0x800, TAG_TILE_64}, + {gPokeballSelection_Gfx, 0x800, TAG_TILE_64}, {}, }; @@ -616,7 +615,7 @@ static const struct SpriteSheet gUnknown_08610650[] = static const struct CompressedSpriteSheet gUnknown_086106A0[] = { - {gUnknown_085B18AC, 0x800, TAG_TILE_64}, + {gPokeballSelection_Gfx, 0x800, TAG_TILE_64}, {}, }; diff --git a/src/starter_choose.c b/src/starter_choose.c index dbdb1a8b3..6295e33ca 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -14,6 +14,7 @@ #include "sound.h" #include "sprite.h" #include "starter_choose.h" +#include "strings.h" #include "task.h" #include "text.h" #include "text_window.h" @@ -27,54 +28,45 @@ #define STARTER_MON_COUNT 3 // Position of the sprite of the selected starter Pokemon -#define STARTER_PKMN_POS_X 120 +#define STARTER_PKMN_POS_X (DISPLAY_WIDTH / 2) #define STARTER_PKMN_POS_Y 64 -// text -extern const u8 gText_BirchInTrouble[]; -extern const u8 gText_ConfirmStarterChoice[]; +#define TAG_POKEBALL_SELECT 0x1000 +#define TAG_STARTER_CIRCLE 0x1001 -// this file's functions -static void MainCallback2_StarterChoose(void); -static void sub_8134604(void); -static void Task_StarterChoose1(u8 taskId); -static void Task_StarterChoose2(u8 taskId); -static void Task_StarterChoose3(u8 taskId); -static void Task_StarterChoose4(u8 taskId); -static void Task_StarterChoose5(u8 taskId); -static void Task_StarterChoose6(u8 taskId); +static void CB2_StarterChoose(void); +static void ClearStarterLabel(void); +static void Task_StarterChoose(u8 taskId); +static void Task_HandleStarterChooseInput(u8 taskId); +static void Task_WaitForStarterSprite(u8 taskId); +static void Task_AskConfirmStarter(u8 taskId); +static void Task_HandleConfirmStarterInput(u8 taskId); +static void Task_DeclineStarter(u8 taskId); static void Task_MoveStarterChooseCursor(u8 taskId); -static void sub_8134668(u8 taskId); +static void Task_CreateStarterLabel(u8 taskId); static void CreateStarterPokemonLabel(u8 selection); static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y); -void sub_81346DC(struct Sprite *sprite); -void sub_813473C(struct Sprite *sprite); -void StarterPokemonSpriteCallback(struct Sprite *sprite); +static void SpriteCB_SelectionHand(struct Sprite *sprite); +static void SpriteCB_Pokeball(struct Sprite *sprite); +static void SpriteCB_StarterPokemon(struct Sprite *sprite); -static u16 sStarterChooseWindowId; +static u16 sStarterLabelWindowId; -// .rodata const u16 gBirchBagGrassPal[][16] = { INCBIN_U16("graphics/misc/birch_bag.gbapal"), INCBIN_U16("graphics/misc/birch_grass.gbapal"), }; -const u16 gBirchBallarrow_Pal[] = INCBIN_U16("graphics/misc/birch_ballarrow.gbapal"); - -const u16 gBirchCircle_Pal[] = INCBIN_U16("graphics/misc/birch_circle.gbapal"); - +static const u16 sPokeballSelection_Pal[] = INCBIN_U16("graphics/misc/pokeball_selection.gbapal"); +static const u16 sStarterCircle_Pal[] = INCBIN_U16("graphics/misc/starter_circle.gbapal"); const u32 gBirchBagTilemap[] = INCBIN_U32("graphics/misc/birch_bag_map.bin.lz"); - const u32 gBirchGrassTilemap[] = INCBIN_U32("graphics/misc/birch_grass_map.bin.lz"); +const u32 gBirchHelpGfx[] = INCBIN_U32("graphics/misc/birch_help.4bpp.lz"); // Birch bag and grass combined +const u32 gPokeballSelection_Gfx[] = INCBIN_U32("graphics/misc/pokeball_selection.4bpp.lz"); +static const u32 sStarterCircle_Gfx[] = INCBIN_U32("graphics/misc/starter_circle.4bpp.lz"); -const u32 gBirchHelpGfx[] = INCBIN_U32("graphics/misc/birch_help.4bpp.lz"); - -const u32 gUnknown_085B18AC[] = INCBIN_U32("graphics/misc/birch_ballarrow.4bpp.lz"); - -const u32 gUnknown_085B1BCC[] = INCBIN_U32("graphics/misc/birch_circle.4bpp.lz"); - -static const struct WindowTemplate gUnknown_085B1DCC[] = +static const struct WindowTemplate sWindowTemplates[] = { { .bg = 0, @@ -88,7 +80,7 @@ static const struct WindowTemplate gUnknown_085B1DCC[] = DUMMY_WIN_TEMPLATE, }; -static const struct WindowTemplate gUnknown_085B1DDC = +static const struct WindowTemplate sWindowTemplate_ConfirmStarter = { .bg = 0, .tilemapLeft = 24, @@ -99,7 +91,7 @@ static const struct WindowTemplate gUnknown_085B1DDC = .baseBlock = 0x0260 }; -static const struct WindowTemplate gUnknown_085B1DE4 = +static const struct WindowTemplate sWindowTemplate_StarterLabel = { .bg = 0, .tilemapLeft = 0, @@ -117,7 +109,7 @@ static const u8 sPokeballCoords[STARTER_MON_COUNT][2] = {180, 64}, }; -static const u8 sStarterLabelCoords[][2] = +static const u8 sStarterLabelCoords[STARTER_MON_COUNT][2] = { {0, 9}, {16, 10}, @@ -131,7 +123,7 @@ static const u16 sStarterMon[STARTER_MON_COUNT] = SPECIES_MUDKIP, }; -static const struct BgTemplate gUnknown_085B1E00[3] = +static const struct BgTemplate sBgTemplates[3] = { { .bg = 0, @@ -164,7 +156,7 @@ static const struct BgTemplate gUnknown_085B1E00[3] = static const u8 sTextColors[] = {TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GREY}; -static const struct OamData gOamData_85B1E10 = +static const struct OamData sOam_Hand = { .y = 160, .affineMode = ST_OAM_AFFINE_OFF, @@ -181,7 +173,7 @@ static const struct OamData gOamData_85B1E10 = .affineParam = 0, }; -static const struct OamData gOamData_85B1E18 = +static const struct OamData sOam_Pokeball = { .y = 160, .affineMode = ST_OAM_AFFINE_OFF, @@ -198,7 +190,7 @@ static const struct OamData gOamData_85B1E18 = .affineParam = 0, }; -static const struct OamData gOamData_85B1E20 = +static const struct OamData sOam_StarterCircle = { .y = 160, .affineMode = ST_OAM_AFFINE_DOUBLE, @@ -222,19 +214,19 @@ static const u8 sCursorCoords[][2] = {180, 32}, }; -static const union AnimCmd gSpriteAnim_85B1E30[] = +static const union AnimCmd sAnim_Hand[] = { ANIMCMD_FRAME(48, 30), ANIMCMD_END, }; -static const union AnimCmd gSpriteAnim_85B1E38[] = +static const union AnimCmd sAnim_Pokeball_Still[] = { ANIMCMD_FRAME(0, 30), ANIMCMD_END, }; -static const union AnimCmd gSpriteAnim_85B1E40[] = +static const union AnimCmd sAnim_Pokeball_Moving[] = { ANIMCMD_FRAME(16, 4), ANIMCMD_FRAME(0, 4), @@ -256,109 +248,109 @@ static const union AnimCmd gSpriteAnim_85B1E40[] = ANIMCMD_JUMP(0), }; -static const union AnimCmd gSpriteAnim_85B1E88[] = +static const union AnimCmd sAnim_StarterCircle[] = { ANIMCMD_FRAME(0, 8), ANIMCMD_END, }; -static const union AnimCmd * const gSpriteAnimTable_85B1E90[] = +static const union AnimCmd * const sAnims_Hand[] = { - gSpriteAnim_85B1E30, + sAnim_Hand, }; -static const union AnimCmd * const gSpriteAnimTable_85B1E94[] = +static const union AnimCmd * const sAnims_Pokeball[] = { - gSpriteAnim_85B1E38, - gSpriteAnim_85B1E40, + sAnim_Pokeball_Still, + sAnim_Pokeball_Moving, }; -static const union AnimCmd * const gSpriteAnimTable_85B1E9C[] = +static const union AnimCmd * const sAnims_StarterCircle[] = { - gSpriteAnim_85B1E88, + sAnim_StarterCircle, }; -static const union AffineAnimCmd gSpriteAffineAnim_85B1EA0[] = +static const union AffineAnimCmd sAffineAnim_StarterPokemon[] = { AFFINEANIMCMD_FRAME(16, 16, 0, 0), AFFINEANIMCMD_FRAME(16, 16, 0, 15), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd gSpriteAffineAnim_85B1EB8[] = +static const union AffineAnimCmd sAffineAnim_StarterCircle[] = { AFFINEANIMCMD_FRAME(20, 20, 0, 0), AFFINEANIMCMD_FRAME(20, 20, 0, 15), AFFINEANIMCMD_END, }; -static const union AffineAnimCmd * const gUnknown_085B1ED0 = {gSpriteAffineAnim_85B1EA0}; -static const union AffineAnimCmd * const gSpriteAffineAnimTable_85B1ED4[] = {gSpriteAffineAnim_85B1EB8}; +static const union AffineAnimCmd * const sAffineAnims_StarterPokemon = {sAffineAnim_StarterPokemon}; +static const union AffineAnimCmd * const sAffineAnims_StarterCircle[] = {sAffineAnim_StarterCircle}; -static const struct CompressedSpriteSheet gUnknown_085B1ED8[] = +static const struct CompressedSpriteSheet sSpriteSheet_PokeballSelect[] = { { - .data = gUnknown_085B18AC, + .data = gPokeballSelection_Gfx, .size = 0x0800, - .tag = 0x1000 + .tag = TAG_POKEBALL_SELECT }, {} }; -static const struct CompressedSpriteSheet gUnknown_085B1EE8[] = +static const struct CompressedSpriteSheet sSpriteSheet_StarterCircle[] = { { - .data = gUnknown_085B1BCC, + .data = sStarterCircle_Gfx, .size = 0x0800, - .tag = 0x1001 + .tag = TAG_STARTER_CIRCLE }, {} }; -static const struct SpritePalette gUnknown_085B1EF8[] = +static const struct SpritePalette sSpritePalettes_StarterChoose[] = { { - .data = gBirchBallarrow_Pal, - .tag = 0x1000 + .data = sPokeballSelection_Pal, + .tag = TAG_POKEBALL_SELECT }, { - .data = gBirchCircle_Pal, - .tag = 0x1001 + .data = sStarterCircle_Pal, + .tag = TAG_STARTER_CIRCLE }, {}, }; static const struct SpriteTemplate sSpriteTemplate_Hand = { - .tileTag = 0x1000, - .paletteTag = 0x1000, - .oam = &gOamData_85B1E10, - .anims = gSpriteAnimTable_85B1E90, + .tileTag = TAG_POKEBALL_SELECT, + .paletteTag = TAG_POKEBALL_SELECT, + .oam = &sOam_Hand, + .anims = sAnims_Hand, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_81346DC + .callback = SpriteCB_SelectionHand }; -static const struct SpriteTemplate sSpriteTemplate_PokeBall = +static const struct SpriteTemplate sSpriteTemplate_Pokeball = { - .tileTag = 0x1000, - .paletteTag = 0x1000, - .oam = &gOamData_85B1E18, - .anims = gSpriteAnimTable_85B1E94, + .tileTag = TAG_POKEBALL_SELECT, + .paletteTag = TAG_POKEBALL_SELECT, + .oam = &sOam_Pokeball, + .anims = sAnims_Pokeball, .images = NULL, .affineAnims = gDummySpriteAffineAnimTable, - .callback = sub_813473C + .callback = SpriteCB_Pokeball }; -static const struct SpriteTemplate gUnknown_085B1F40 = +static const struct SpriteTemplate sSpriteTemplate_StarterCircle = { - .tileTag = 0x1001, - .paletteTag = 0x1001, - .oam = &gOamData_85B1E20, - .anims = gSpriteAnimTable_85B1E9C, + .tileTag = TAG_STARTER_CIRCLE, + .paletteTag = TAG_STARTER_CIRCLE, + .oam = &sOam_StarterCircle, + .anims = sAnims_StarterCircle, .images = NULL, - .affineAnims = gSpriteAffineAnimTable_85B1ED4, - .callback = StarterPokemonSpriteCallback + .affineAnims = sAffineAnims_StarterCircle, + .callback = SpriteCB_StarterPokemon }; // .text @@ -376,10 +368,15 @@ static void VblankCB_StarterChoose(void) TransferPlttBuffer(); } +// Data for Task_StarterChoose #define tStarterSelection data[0] #define tPkmnSpriteId data[1] #define tCircleSpriteId data[2] +// Data for sSpriteTemplate_Pokeball +#define sTaskId data[0] +#define sBallId data[1] + void CB2_ChooseStarter(void) { u16 savedIme; @@ -412,8 +409,8 @@ void CB2_ChooseStarter(void) LZ77UnCompVram(gBirchGrassTilemap, (void *)(BG_SCREEN_ADDR(7))); ResetBgsAndClearDma3BusyFlags(0); - InitBgsFromTemplates(0, gUnknown_085B1E00, ARRAY_COUNT(gUnknown_085B1E00)); - InitWindows(gUnknown_085B1DCC); + InitBgsFromTemplates(0, sBgTemplates, ARRAY_COUNT(sBgTemplates)); + InitWindows(sWindowTemplates); DeactivateAllTextPrinters(); LoadUserWindowBorderGfx(0, 0x2A8, 0xD0); @@ -427,17 +424,17 @@ void CB2_ChooseStarter(void) LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20); LoadPalette(gBirchBagGrassPal, 0, 0x40); - LoadCompressedSpriteSheet(&gUnknown_085B1ED8[0]); - LoadCompressedSpriteSheet(&gUnknown_085B1EE8[0]); - LoadSpritePalettes(gUnknown_085B1EF8); + LoadCompressedSpriteSheet(&sSpriteSheet_PokeballSelect[0]); + LoadCompressedSpriteSheet(&sSpriteSheet_StarterCircle[0]); + LoadSpritePalettes(sSpritePalettes_StarterChoose); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, RGB_BLACK); EnableInterrupts(DISPSTAT_VBLANK); SetVBlankCallback(VblankCB_StarterChoose); - SetMainCallback2(MainCallback2_StarterChoose); + SetMainCallback2(CB2_StarterChoose); - SetGpuReg(REG_OFFSET_WININ, 0x3F); - SetGpuReg(REG_OFFSET_WINOUT, 0x1F); + SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR); + SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ); SetGpuReg(REG_OFFSET_WIN0H, 0); SetGpuReg(REG_OFFSET_WIN0V, 0); SetGpuReg(REG_OFFSET_BLDCNT, BLDCNT_TGT1_BG1 | BLDCNT_TGT1_BG2 | BLDCNT_TGT1_BG3 | BLDCNT_TGT1_OBJ | BLDCNT_TGT1_BD | BLDCNT_EFFECT_DARKEN); @@ -449,7 +446,7 @@ void CB2_ChooseStarter(void) ShowBg(2); ShowBg(3); - taskId = CreateTask(Task_StarterChoose1, 0); + taskId = CreateTask(Task_StarterChoose, 0); gTasks[taskId].tStarterSelection = 1; // Create hand sprite @@ -457,22 +454,22 @@ void CB2_ChooseStarter(void) gSprites[spriteId].data[0] = taskId; // Create three Pokeball sprites - spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[0][0], sPokeballCoords[0][1], 2); - gSprites[spriteId].data[0] = taskId; - gSprites[spriteId].data[1] = 0; + spriteId = CreateSprite(&sSpriteTemplate_Pokeball, sPokeballCoords[0][0], sPokeballCoords[0][1], 2); + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sBallId = 0; - spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[1][0], sPokeballCoords[1][1], 2); - gSprites[spriteId].data[0] = taskId; - gSprites[spriteId].data[1] = 1; + spriteId = CreateSprite(&sSpriteTemplate_Pokeball, sPokeballCoords[1][0], sPokeballCoords[1][1], 2); + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sBallId = 1; - spriteId = CreateSprite(&sSpriteTemplate_PokeBall, sPokeballCoords[2][0], sPokeballCoords[2][1], 2); - gSprites[spriteId].data[0] = taskId; - gSprites[spriteId].data[1] = 2; + spriteId = CreateSprite(&sSpriteTemplate_Pokeball, sPokeballCoords[2][0], sPokeballCoords[2][1], 2); + gSprites[spriteId].sTaskId = taskId; + gSprites[spriteId].sBallId = 2; - sStarterChooseWindowId = 0xFF; + sStarterLabelWindowId = 0xFF; } -static void MainCallback2_StarterChoose(void) +static void CB2_StarterChoose(void) { RunTasks(); AnimateSprites(); @@ -481,71 +478,71 @@ static void MainCallback2_StarterChoose(void) UpdatePaletteFade(); } -static void Task_StarterChoose1(u8 taskId) +static void Task_StarterChoose(u8 taskId) { CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection); DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x2A8, 0xD); AddTextPrinterParameterized(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL); PutWindowTilemap(0); ScheduleBgCopyTilemapToVram(0); - gTasks[taskId].func = Task_StarterChoose2; + gTasks[taskId].func = Task_HandleStarterChooseInput; } -static void Task_StarterChoose2(u8 taskId) +static void Task_HandleStarterChooseInput(u8 taskId) { u8 selection = gTasks[taskId].tStarterSelection; - if (gMain.newKeys & A_BUTTON) + if (JOY_NEW(A_BUTTON)) { u8 spriteId; - sub_8134604(); + ClearStarterLabel(); // Create white circle background - spriteId = CreateSprite(&gUnknown_085B1F40, sPokeballCoords[selection][0], sPokeballCoords[selection][1], 1); + spriteId = CreateSprite(&sSpriteTemplate_StarterCircle, sPokeballCoords[selection][0], sPokeballCoords[selection][1], 1); gTasks[taskId].tCircleSpriteId = spriteId; // Create Pokemon sprite spriteId = CreatePokemonFrontSprite(GetStarterPokemon(gTasks[taskId].tStarterSelection), sPokeballCoords[selection][0], sPokeballCoords[selection][1]); - gSprites[spriteId].affineAnims = &gUnknown_085B1ED0; - gSprites[spriteId].callback = StarterPokemonSpriteCallback; + gSprites[spriteId].affineAnims = &sAffineAnims_StarterPokemon; + gSprites[spriteId].callback = SpriteCB_StarterPokemon; gTasks[taskId].tPkmnSpriteId = spriteId; - gTasks[taskId].func = Task_StarterChoose3; + gTasks[taskId].func = Task_WaitForStarterSprite; } - else if ((gMain.newKeys & DPAD_LEFT) && selection > 0) + else if (JOY_NEW(DPAD_LEFT) && selection > 0) { gTasks[taskId].tStarterSelection--; gTasks[taskId].func = Task_MoveStarterChooseCursor; } - else if ((gMain.newKeys & DPAD_RIGHT) && selection < (STARTER_MON_COUNT - 1)) + else if (JOY_NEW(DPAD_RIGHT) && selection < STARTER_MON_COUNT - 1) { gTasks[taskId].tStarterSelection++; gTasks[taskId].func = Task_MoveStarterChooseCursor; } } -static void Task_StarterChoose3(u8 taskId) +static void Task_WaitForStarterSprite(u8 taskId) { if (gSprites[gTasks[taskId].tCircleSpriteId].affineAnimEnded && - gSprites[gTasks[taskId].tCircleSpriteId].pos1.x == STARTER_PKMN_POS_X && - gSprites[gTasks[taskId].tCircleSpriteId].pos1.y == STARTER_PKMN_POS_Y) + gSprites[gTasks[taskId].tCircleSpriteId].pos1.x == STARTER_PKMN_POS_X && + gSprites[gTasks[taskId].tCircleSpriteId].pos1.y == STARTER_PKMN_POS_Y) { - gTasks[taskId].func = Task_StarterChoose4; + gTasks[taskId].func = Task_AskConfirmStarter; } } -static void Task_StarterChoose4(u8 taskId) +static void Task_AskConfirmStarter(u8 taskId) { PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0); FillWindowPixelBuffer(0, PIXEL_FILL(1)); AddTextPrinterParameterized(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL); ScheduleBgCopyTilemapToVram(0); - CreateYesNoMenu(&gUnknown_085B1DDC, 0x2A8, 0xD, 0); - gTasks[taskId].func = Task_StarterChoose5; + CreateYesNoMenu(&sWindowTemplate_ConfirmStarter, 0x2A8, 0xD, 0); + gTasks[taskId].func = Task_HandleConfirmStarterInput; } -static void Task_StarterChoose5(u8 taskId) +static void Task_HandleConfirmStarterInput(u8 taskId) { u8 spriteId; @@ -558,7 +555,7 @@ static void Task_StarterChoose5(u8 taskId) SetMainCallback2(gMain.savedCallback); break; case 1: // NO - case -1: // B button + case MENU_B_PRESSED: PlaySE(SE_SELECT); spriteId = gTasks[taskId].tPkmnSpriteId; FreeOamMatrix(gSprites[spriteId].oam.matrixNum); @@ -567,14 +564,14 @@ static void Task_StarterChoose5(u8 taskId) spriteId = gTasks[taskId].tCircleSpriteId; FreeOamMatrix(gSprites[spriteId].oam.matrixNum); DestroySprite(&gSprites[spriteId]); - gTasks[taskId].func = Task_StarterChoose6; + gTasks[taskId].func = Task_DeclineStarter; break; } } -static void Task_StarterChoose6(u8 taskId) +static void Task_DeclineStarter(u8 taskId) { - gTasks[taskId].func = Task_StarterChoose1; + gTasks[taskId].func = Task_StarterChoose; } static void CreateStarterPokemonLabel(u8 selection) @@ -589,20 +586,20 @@ static void CreateStarterPokemonLabel(u8 selection) CopyMonCategoryText(SpeciesToNationalPokedexNum(species), categoryText); speciesName = gSpeciesNames[species]; - winTemplate = gUnknown_085B1DE4; + winTemplate = sWindowTemplate_StarterLabel; winTemplate.tilemapLeft = sStarterLabelCoords[selection][0]; winTemplate.tilemapTop = sStarterLabelCoords[selection][1]; - sStarterChooseWindowId = AddWindow(&winTemplate); - FillWindowPixelBuffer(sStarterChooseWindowId, PIXEL_FILL(0)); + sStarterLabelWindowId = AddWindow(&winTemplate); + FillWindowPixelBuffer(sStarterLabelWindowId, PIXEL_FILL(0)); width = GetStringCenterAlignXOffset(7, categoryText, 0x68); - AddTextPrinterParameterized3(sStarterChooseWindowId, 7, width, 1, sTextColors, 0, categoryText); + AddTextPrinterParameterized3(sStarterLabelWindowId, 7, width, 1, sTextColors, 0, categoryText); width = GetStringCenterAlignXOffset(1, speciesName, 0x68); - AddTextPrinterParameterized3(sStarterChooseWindowId, 1, width, 0x11, sTextColors, 0, speciesName); + AddTextPrinterParameterized3(sStarterLabelWindowId, 1, width, 17, sTextColors, 0, speciesName); - PutWindowTilemap(sStarterChooseWindowId); + PutWindowTilemap(sStarterLabelWindowId); ScheduleBgCopyTilemapToVram(0); labelLeft = sStarterLabelCoords[selection][0] * 8 - 4; @@ -613,12 +610,12 @@ static void CreateStarterPokemonLabel(u8 selection) SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(labelTop, labelBottom)); } -static void sub_8134604(void) +static void ClearStarterLabel(void) { - FillWindowPixelBuffer(sStarterChooseWindowId, PIXEL_FILL(0)); - ClearWindowTilemap(sStarterChooseWindowId); - RemoveWindow(sStarterChooseWindowId); - sStarterChooseWindowId = 0xFF; + FillWindowPixelBuffer(sStarterLabelWindowId, PIXEL_FILL(0)); + ClearWindowTilemap(sStarterLabelWindowId); + RemoveWindow(sStarterLabelWindowId); + sStarterLabelWindowId = 0xFF; SetGpuReg(REG_OFFSET_WIN0H, 0); SetGpuReg(REG_OFFSET_WIN0V, 0); ScheduleBgCopyTilemapToVram(0); @@ -626,14 +623,14 @@ static void sub_8134604(void) static void Task_MoveStarterChooseCursor(u8 taskId) { - sub_8134604(); - gTasks[taskId].func = sub_8134668; + ClearStarterLabel(); + gTasks[taskId].func = Task_CreateStarterLabel; } -static void sub_8134668(u8 taskId) +static void Task_CreateStarterLabel(u8 taskId) { CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection); - gTasks[taskId].func = Task_StarterChoose2; + gTasks[taskId].func = Task_HandleStarterChooseInput; } static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y) @@ -645,25 +642,27 @@ static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y) return spriteId; } -void sub_81346DC(struct Sprite *sprite) +static void SpriteCB_SelectionHand(struct Sprite *sprite) { + // Float up and down above selected pokeball sprite->pos1.x = sCursorCoords[gTasks[sprite->data[0]].tStarterSelection][0]; sprite->pos1.y = sCursorCoords[gTasks[sprite->data[0]].tStarterSelection][1]; sprite->pos2.y = Sin(sprite->data[1], 8); sprite->data[1] = (u8)(sprite->data[1]) + 4; } -void sub_813473C(struct Sprite *sprite) +static void SpriteCB_Pokeball(struct Sprite *sprite) { - if (gTasks[sprite->data[0]].tStarterSelection == sprite->data[1]) + // Animate pokeball if currently selected + if (gTasks[sprite->sTaskId].tStarterSelection == sprite->sBallId) StartSpriteAnimIfDifferent(sprite, 1); else StartSpriteAnimIfDifferent(sprite, 0); } -void StarterPokemonSpriteCallback(struct Sprite *sprite) +static void SpriteCB_StarterPokemon(struct Sprite *sprite) { - //Move sprite to upper center of screen + // Move sprite to upper center of screen if (sprite->pos1.x > STARTER_PKMN_POS_X) sprite->pos1.x -= 4; if (sprite->pos1.x < STARTER_PKMN_POS_X)