summaryrefslogtreecommitdiff
path: root/src/starter_choose.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/starter_choose.c')
-rw-r--r--src/starter_choose.c370
1 files changed, 323 insertions, 47 deletions
diff --git a/src/starter_choose.c b/src/starter_choose.c
index b55b0fbc5..179d9a05a 100644
--- a/src/starter_choose.c
+++ b/src/starter_choose.c
@@ -1,25 +1,27 @@
#include "global.h"
-#include "starter_choose.h"
-#include "palette.h"
-#include "sprite.h"
-#include "pokemon.h"
-#include "task.h"
#include "bg.h"
+#include "data2.h"
+#include "decompress.h"
+#include "event_data.h"
#include "gpu_regs.h"
+#include "international_string_util.h"
#include "main.h"
-#include "window.h"
-#include "text.h"
-#include "text_window.h"
-#include "decompress.h"
#include "menu.h"
-#include "sound.h"
-#include "constants/songs.h"
-#include "event_data.h"
+#include "palette.h"
#include "pokedex.h"
-#include "data2.h"
-#include "international_string_util.h"
-#include "trig.h"
+#include "pokemon.h"
#include "scanline_effect.h"
+#include "sound.h"
+#include "sprite.h"
+#include "starter_choose.h"
+#include "task.h"
+#include "text.h"
+#include "text_window.h"
+#include "trainer_pokemon_sprites.h"
+#include "trig.h"
+#include "window.h"
+#include "constants/songs.h"
+#include "constants/species.h"
#define STARTER_MON_COUNT 3
@@ -31,29 +33,6 @@
extern const u8 gText_BirchInTrouble[];
extern const u8 gText_ConfirmStarterChoice[];
-extern const u16 sStarterMon[STARTER_MON_COUNT];
-extern const struct BgTemplate gUnknown_085B1E00[3];
-extern const struct WindowTemplate gUnknown_085B1DCC[];
-extern const struct WindowTemplate gUnknown_085B1DDC;
-extern const struct CompressedSpriteSheet gUnknown_085B1ED8[];
-extern const struct CompressedSpriteSheet gUnknown_085B1EE8[];
-extern const struct SpritePalette gUnknown_085B1EF8[];
-extern const struct SpriteTemplate sSpriteTemplate_PokeBall;
-extern const struct SpriteTemplate sSpriteTemplate_Hand;
-extern const struct SpriteTemplate gUnknown_085B1F40;
-extern const union AffineAnimCmd *const gUnknown_085B1ED0;
-extern const u8 sPokeballCoords[STARTER_MON_COUNT][2];
-extern const struct WindowTemplate gUnknown_085B1DE4;
-extern const u8 gStarterChoose_LabelCoords[][2];
-extern const u8 gUnknown_085B1E0C[];
-extern const u8 gUnknown_085B1E28[][2];
-
-extern void clear_scheduled_bg_copies_to_vram(void);
-extern void dp13_810BB8C(void);
-extern void do_scheduled_bg_tilemap_copies_to_vram(void);
-extern u16 sub_818D820(u16);
-extern u8 sub_818D3E4(u16 species, u32 trainerId, u32 personality, u8 flags, s16 x, s16 y, u8, u16);
-
// this file's functions
static void MainCallback2_StarterChoose(void);
static void sub_8134604(void);
@@ -67,10 +46,307 @@ static void Task_MoveStarterChooseCursor(u8 taskId);
static void sub_8134668(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 IWRAM_DATA u16 sStarterChooseWindowId;
+// .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");
+
+const u8 gBirchBagTilemap[] = INCBIN_U8("graphics/misc/birch_bag_map.bin.lz");
+
+const u8 gBirchGrassTilemap[] = INCBIN_U8("graphics/misc/birch_grass_map.bin.lz");
+
+const u8 gBirchHelpGfx[] = INCBIN_U8("graphics/misc/birch_help.4bpp.lz");
+
+const u8 gUnknown_085B18AC[] = INCBIN_U8("graphics/misc/birch_ballarrow.4bpp.lz");
+
+const u8 gUnknown_085B1BCC[] = INCBIN_U8("graphics/misc/birch_circle.4bpp.lz");
+
+static const struct WindowTemplate gUnknown_085B1DCC[] =
+{
+ {
+ .priority = 0,
+ .tilemapLeft = 3,
+ .tilemapTop = 15,
+ .width = 24,
+ .height = 4,
+ .paletteNum = 14,
+ .baseBlock = 0x0200
+ },
+ DUMMY_WIN_TEMPLATE,
+};
+
+static const struct WindowTemplate gUnknown_085B1DDC =
+{
+ .priority = 0,
+ .tilemapLeft = 24,
+ .tilemapTop = 9,
+ .width = 5,
+ .height = 4,
+ .paletteNum = 14,
+ .baseBlock = 0x0260
+};
+
+static const struct WindowTemplate gUnknown_085B1DE4 =
+{
+ .priority = 0,
+ .tilemapLeft = 0,
+ .tilemapTop = 0,
+ .width = 13,
+ .height = 4,
+ .paletteNum = 14,
+ .baseBlock = 0x0274
+};
+
+static const u8 sPokeballCoords[STARTER_MON_COUNT][2] =
+{
+ {0x3c, 0x40},
+ {0x78, 0x58},
+ {0xb4, 0x40},
+};
+
+static const u8 gStarterChoose_LabelCoords[][2] =
+{
+ {0x00, 0x09},
+ {0x10, 0x0a},
+ {0x08, 0x04},
+};
+
+static const u16 sStarterMon[STARTER_MON_COUNT] =
+{
+ SPECIES_TREECKO,
+ SPECIES_TORCHIC,
+ SPECIES_MUDKIP,
+};
+
+static const struct BgTemplate gUnknown_085B1E00[3] =
+{
+ {
+ .bg = 0,
+ .charBaseIndex = 2,
+ .mapBaseIndex = 31,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 0,
+ .baseTile = 0
+ },
+ {
+ .bg = 2,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 7,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 3,
+ .baseTile = 0
+ },
+ {
+ .bg = 3,
+ .charBaseIndex = 0,
+ .mapBaseIndex = 6,
+ .screenSize = 0,
+ .paletteMode = 0,
+ .priority = 1,
+ .baseTile = 0
+ },
+};
+
+static const u8 gUnknown_085B1E0C[] = {0x00, 0x01, 0x03};
+
+static const struct OamData gOamData_85B1E10 =
+{
+ .y = 160,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 0,
+ .affineParam = 0,
+};
+
+static const struct OamData gOamData_85B1E18 =
+{
+ .y = 160,
+ .affineMode = 0,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 2,
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 0,
+ .affineParam = 0,
+};
+
+static const struct OamData gOamData_85B1E20 =
+{
+ .y = 160,
+ .affineMode = 3,
+ .objMode = 0,
+ .mosaic = 0,
+ .bpp = 0,
+ .shape = 0,
+ .x = 0,
+ .matrixNum = 0,
+ .size = 3,
+ .tileNum = 0,
+ .priority = 1,
+ .paletteNum = 0,
+ .affineParam = 0,
+};
+
+static const u8 gUnknown_085B1E28[][2] =
+{
+ {0x3c, 0x20},
+ {0x78, 0x38},
+ {0xb4, 0x20},
+};
+
+static const union AnimCmd gSpriteAnim_85B1E30[] =
+{
+ ANIMCMD_FRAME(48, 30),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gSpriteAnim_85B1E38[] =
+{
+ ANIMCMD_FRAME(0, 30),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd gSpriteAnim_85B1E40[] =
+{
+ ANIMCMD_FRAME(16, 4),
+ ANIMCMD_FRAME(0, 4),
+ ANIMCMD_FRAME(32, 4),
+ ANIMCMD_FRAME(0, 4),
+ ANIMCMD_FRAME(16, 4),
+ ANIMCMD_FRAME(0, 4),
+ ANIMCMD_FRAME(32, 4),
+ ANIMCMD_FRAME(0, 4),
+ ANIMCMD_FRAME(0, 32),
+ ANIMCMD_FRAME(16, 8),
+ ANIMCMD_FRAME(0, 8),
+ ANIMCMD_FRAME(32, 8),
+ ANIMCMD_FRAME(0, 8),
+ ANIMCMD_FRAME(16, 8),
+ ANIMCMD_FRAME(0, 8),
+ ANIMCMD_FRAME(32, 8),
+ ANIMCMD_FRAME(0, 8),
+ ANIMCMD_JUMP(0),
+};
+
+static const union AnimCmd gSpriteAnim_85B1E88[] =
+{
+ ANIMCMD_FRAME(0, 8),
+ ANIMCMD_END,
+};
+
+static const union AnimCmd * const gSpriteAnimTable_85B1E90[] =
+{
+ gSpriteAnim_85B1E30,
+};
+
+static const union AnimCmd * const gSpriteAnimTable_85B1E94[] =
+{
+ gSpriteAnim_85B1E38,
+ gSpriteAnim_85B1E40,
+};
+
+static const union AnimCmd * const gSpriteAnimTable_85B1E9C[] =
+{
+ gSpriteAnim_85B1E88,
+};
+
+static const union AffineAnimCmd gSpriteAffineAnim_85B1EA0[] =
+{
+ AFFINEANIMCMD_FRAME(16, 16, 0, 0),
+ AFFINEANIMCMD_FRAME(16, 16, 0, 15),
+ AFFINEANIMCMD_END,
+};
+
+static const union AffineAnimCmd gSpriteAffineAnim_85B1EB8[] =
+{
+ 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 struct CompressedSpriteSheet gUnknown_085B1ED8[] =
+{
+ gUnknown_085B18AC, 0x0800, 0x1000,
+ NULL,
+};
+
+static const struct CompressedSpriteSheet gUnknown_085B1EE8[] =
+{
+ gUnknown_085B1BCC, 0x0800, 0x1001,
+ NULL,
+};
+
+static const struct SpritePalette gUnknown_085B1EF8[] =
+{
+ gBirchBallarrow_Pal, 0x1000,
+ gBirchCircle_Pal, 0x1001,
+ NULL,
+};
+
+static const struct SpriteTemplate sSpriteTemplate_Hand =
+{
+ .tileTag = 0x1000,
+ .paletteTag = 0x1000,
+ .oam = &gOamData_85B1E10,
+ .anims = gSpriteAnimTable_85B1E90,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_81346DC
+};
+
+static const struct SpriteTemplate sSpriteTemplate_PokeBall =
+{
+ .tileTag = 0x1000,
+ .paletteTag = 0x1000,
+ .oam = &gOamData_85B1E18,
+ .anims = gSpriteAnimTable_85B1E94,
+ .images = NULL,
+ .affineAnims = gDummySpriteAffineAnimTable,
+ .callback = sub_813473C
+};
+
+static const struct SpriteTemplate gUnknown_085B1F40 =
+{
+ .tileTag = 0x1001,
+ .paletteTag = 0x1001,
+ .oam = &gOamData_85B1E20,
+ .anims = gSpriteAnimTable_85B1E9C,
+ .images = NULL,
+ .affineAnims = gSpriteAffineAnimTable_85B1ED4,
+ .callback = StarterPokemonSpriteCallback
+};
+
+// .text
u16 GetStarterPokemon(u16 chosenStarterId)
{
if (chosenStarterId > STARTER_MON_COUNT)
@@ -132,7 +408,7 @@ void CB2_ChooseStarter(void)
ResetSpriteData();
ResetPaletteFade();
FreeAllSpritePalettes();
- dp13_810BB8C();
+ ResetAllPicSprites();
LoadPalette(GetOverworldTextboxPalettePtr(), 0xE0, 0x20);
LoadPalette(gBirchBagGrassPal, 0, 0x40);
@@ -194,7 +470,7 @@ static void Task_StarterChoose1(u8 taskId)
{
CreateStarterPokemonLabel(gTasks[taskId].tStarterSelection);
SetWindowBorderStyle(0, FALSE, 0x2A8, 0xD);
- PrintTextOnWindow(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL);
+ AddTextPrinterParameterized(0, 1, gText_BirchInTrouble, 0, 1, 0, NULL);
PutWindowTilemap(0);
schedule_bg_copy_tilemap_to_vram(0);
gTasks[taskId].func = Task_StarterChoose2;
@@ -248,7 +524,7 @@ static void Task_StarterChoose4(u8 taskId)
{
PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0);
FillWindowPixelBuffer(0, 0x11);
- PrintTextOnWindow(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL);
+ AddTextPrinterParameterized(0, 1, gText_ConfirmStarterChoice, 0, 1, 0, NULL);
schedule_bg_copy_tilemap_to_vram(0);
CreateYesNoMenu(&gUnknown_085B1DDC, 0x2A8, 0xD, 0);
gTasks[taskId].func = Task_StarterChoose5;
@@ -258,12 +534,12 @@ static void Task_StarterChoose5(u8 taskId)
{
u8 spriteId;
- switch (ProcessMenuInputNoWrap_())
+ switch (Menu_ProcessInputNoWrap_())
{
case 0: // YES
// Return the starter choice and exit.
gSpecialVar_Result = gTasks[taskId].tStarterSelection;
- dp13_810BB8C();
+ ResetAllPicSprites();
SetMainCallback2(gMain.savedCallback);
break;
case 1: // NO
@@ -271,7 +547,7 @@ static void Task_StarterChoose5(u8 taskId)
PlaySE(SE_SELECT);
spriteId = gTasks[taskId].tPkmnSpriteId;
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
- sub_818D820(spriteId);
+ FreeAndDestroyMonPicSprite(spriteId);
spriteId = gTasks[taskId].tCircleSpriteId;
FreeOamMatrix(gSprites[spriteId].oam.matrixNum);
@@ -306,10 +582,10 @@ static void CreateStarterPokemonLabel(u8 selection)
FillWindowPixelBuffer(sStarterChooseWindowId, 0);
width = GetStringCenterAlignXOffset(7, text, 0x68);
- box_print(sStarterChooseWindowId, 7, width, 1, gUnknown_085B1E0C, 0, text);
+ AddTextPrinterParameterized3(sStarterChooseWindowId, 7, width, 1, gUnknown_085B1E0C, 0, text);
width = GetStringCenterAlignXOffset(1, speciesName, 0x68);
- box_print(sStarterChooseWindowId, 1, width, 0x11, gUnknown_085B1E0C, 0, speciesName);
+ AddTextPrinterParameterized3(sStarterChooseWindowId, 1, width, 0x11, gUnknown_085B1E0C, 0, speciesName);
PutWindowTilemap(sStarterChooseWindowId);
schedule_bg_copy_tilemap_to_vram(0);
@@ -349,7 +625,7 @@ static u8 CreatePokemonFrontSprite(u16 species, u8 x, u8 y)
{
u8 spriteId;
- spriteId = sub_818D3E4(species, 8, 0, 1, x, y, 0xE, 0xFFFF);
+ spriteId = CreatePicSprite2(species, 8, 0, 1, x, y, 0xE, 0xFFFF);
gSprites[spriteId].oam.priority = 0;
return spriteId;
}