From 07c28823900e52b09278798bc854afc46d15690e Mon Sep 17 00:00:00 2001 From: Slawter666 <38655737+Slawter666@users.noreply.github.com> Date: Thu, 6 Sep 2018 00:47:29 +0100 Subject: [PATCH] Move starter_choose data to C --- data/starter_choose.s | 159 ------------------- ld_script.txt | 2 +- src/starter_choose.c | 347 ++++++++++++++++++++++++++++++++++++++---- 3 files changed, 315 insertions(+), 193 deletions(-) delete mode 100644 data/starter_choose.s diff --git a/data/starter_choose.s b/data/starter_choose.s deleted file mode 100644 index 92b95d80c..000000000 --- a/data/starter_choose.s +++ /dev/null @@ -1,159 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - .include "include/constants/species.h" - - .section .rodata - - .align 2 -gBirchBagGrassPal:: @ 85B0A00 - .incbin "graphics/misc/birch_bag.gbapal" - .incbin "graphics/misc/birch_grass.gbapal" - - .align 2 -gBirchBallarrow_Pal:: @ 85B0A40 - .incbin "graphics/misc/birch_ballarrow.gbapal" - - .align 2 -gBirchCircle_Pal:: @ 85B0A60 - .incbin "graphics/misc/birch_circle.gbapal" - - .align 2 -gBirchBagTilemap:: @ 85B0A80 - .incbin "graphics/misc/birch_bag_map.bin.lz" - - .align 2 -gBirchGrassTilemap:: @ 85B0C0C - .incbin "graphics/misc/birch_grass_map.bin.lz" - - .align 2 -gBirchHelpGfx:: @ 85B0E04 - .incbin "graphics/misc/birch_help.4bpp.lz" - - .align 2 -gUnknown_085B18AC:: @ 85B18AC - .incbin "graphics/misc/birch_ballarrow.4bpp.lz" - - .align 2 -gUnknown_085B1BCC:: @ 85B1BCC - .incbin "graphics/misc/birch_circle.4bpp.lz" - - .align 2 -gUnknown_085B1DCC:: @ 85B1DCC - window_template 0x00, 0x03, 0x0f, 0x18, 0x04, 0x0e, 0x0200 - null_window_template - - .align 2 -gUnknown_085B1DDC:: @ 85B1DDC - window_template 0x00, 0x18, 0x09, 0x05, 0x04, 0x0e, 0x0260 - - .align 2 -gUnknown_085B1DE4:: @ 85B1DE4 - window_template 0x00, 0x00, 0x00, 0x0d, 0x04, 0x0e, 0x0274 - -sPokeballCoords:: @ 85B1DEC - .byte 0x3c, 0x40, 0x78, 0x58, 0xb4, 0x40 - -gStarterChoose_LabelCoords:: @ 85B1DF2 - .byte 0x00, 0x09, 0x10, 0x0a, 0x08, 0x04 - -sStarterMon:: @ 85B1DF8 - .2byte SPECIES_TREECKO - .2byte SPECIES_TORCHIC - .2byte SPECIES_MUDKIP - - .align 2 -gUnknown_085B1E00:: @ 85B1E00 - .4byte 0x000001f8, 0x00003072, 0x00001063 - -gUnknown_085B1E0C:: @ 85B1E0C - .byte 0x00, 0x01, 0x03 - - .align 2 -gOamData_85B1E10:: @ 85B1E10 - .2byte 0x00a0, 0x8000, 0x0400, 0x0000 - - .align 2 -gOamData_85B1E18:: @ 85B1E18 - .2byte 0x00a0, 0x8000, 0x0400, 0x0000 - - .align 2 -gOamData_85B1E20:: @ 85B1E20 - .2byte 0x03a0, 0xc000, 0x0400, 0x0000 - -gUnknown_085B1E28:: @ 85B1E28 - .byte 0x3c, 0x20, 0x78, 0x38, 0xb4, 0x20, 0x00, 0x00 - - .align 2 -gSpriteAnim_85B1E30:: @ 85B1E30 - .2byte 0x0030, 0x001e, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_85B1E38:: @ 85B1E38 - .2byte 0x0000, 0x001e, 0xffff, 0x0000 - - .align 2 -gSpriteAnim_85B1E40:: @ 85B1E40 - .2byte 0x0010, 0x0004, 0x0000, 0x0004, 0x0020, 0x0004, 0x0000, 0x0004, 0x0010, 0x0004, 0x0000, 0x0004, 0x0020, 0x0004, 0x0000, 0x0004 - .2byte 0x0000, 0x0020, 0x0010, 0x0008, 0x0000, 0x0008, 0x0020, 0x0008, 0x0000, 0x0008, 0x0010, 0x0008, 0x0000, 0x0008, 0x0020, 0x0008 - .2byte 0x0000, 0x0008, 0xfffe, 0x0000 - - .align 2 -gSpriteAnim_85B1E88:: @ 85B1E88 - .2byte 0x0000, 0x0008, 0xffff, 0x0000 - - .align 2 -gSpriteAnimTable_85B1E90:: @ 85B1E90 - .4byte gSpriteAnim_85B1E30 - - .align 2 -gSpriteAnimTable_85B1E94:: @ 85B1E94 - .4byte gSpriteAnim_85B1E38 - .4byte gSpriteAnim_85B1E40 - - .align 2 -gSpriteAnimTable_85B1E9C:: @ 85B1E9C - .4byte gSpriteAnim_85B1E88 - - .align 2 -gSpriteAffineAnim_85B1EA0:: @ 85B1EA0 - .2byte 0x0010, 0x0010, 0x0000, 0x0000, 0x0010, 0x0010, 0x0f00, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gSpriteAffineAnim_85B1EB8:: @ 85B1EB8 - .2byte 0x0014, 0x0014, 0x0000, 0x0000, 0x0014, 0x0014, 0x0f00, 0x0000, 0x7fff, 0x0000, 0x0000, 0x0000 - - .align 2 -gUnknown_085B1ED0:: @ 85B1ED0 - .4byte gSpriteAffineAnim_85B1EA0 - - .align 2 -gSpriteAffineAnimTable_85B1ED4:: @ 85B1ED4 - .4byte gSpriteAffineAnim_85B1EB8 - - .align 2 -gUnknown_085B1ED8:: @ 85B1ED8 - obj_tiles gUnknown_085B18AC, 0x0800, 0x1000 - null_obj_tiles - - .align 2 -gUnknown_085B1EE8:: @ 85B1EE8 - obj_tiles gUnknown_085B1BCC, 0x0800, 0x1001 - null_obj_tiles - - .align 2 -gUnknown_085B1EF8:: @ 85B1EF8 - obj_pal gBirchBallarrow_Pal, 0x1000 - obj_pal gBirchCircle_Pal, 0x1001 - null_obj_pal - - .align 2 -sSpriteTemplate_Hand:: @ 85B1F10 - spr_template 0x1000, 0x1000, gOamData_85B1E10, gSpriteAnimTable_85B1E90, NULL, gDummySpriteAffineAnimTable, sub_81346DC - - .align 2 -sSpriteTemplate_PokeBall:: @ 85B1F28 - spr_template 0x1000, 0x1000, gOamData_85B1E18, gSpriteAnimTable_85B1E94, NULL, gDummySpriteAffineAnimTable, sub_813473C - - .align 2 -gUnknown_085B1F40:: @ 85B1F40 - spr_template 0x1001, 0x1001, gOamData_85B1E20, gSpriteAnimTable_85B1E9C, NULL, gSpriteAffineAnimTable_85B1ED4, StarterPokemonSpriteCallback diff --git a/ld_script.txt b/ld_script.txt index 668cf7c5a..94e7f7580 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -475,7 +475,7 @@ SECTIONS { data/contest_painting.o(.rodata); src/battle_ai_script_commands.o(.rodata); src/trader.o(.rodata); - data/starter_choose.o(.rodata); + src/starter_choose.o(.rodata); src/wallclock.o(.rodata); src/pokeblock.o(.rodata); src/fldeff_flash.o(.rodata); diff --git a/src/starter_choose.c b/src/starter_choose.c index c1e7eea40..71784b016 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -1,26 +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 "menu.h" +#include "palette.h" +#include "pokedex.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 "decompress.h" -#include "menu.h" -#include "sound.h" -#include "constants/songs.h" -#include "event_data.h" -#include "pokedex.h" -#include "data2.h" -#include "international_string_util.h" -#include "trig.h" -#include "scanline_effect.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 @@ -32,23 +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]; - // this file's functions static void MainCallback2_StarterChoose(void); static void sub_8134604(void); @@ -62,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)