diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/battle_7.c | 50 | ||||
-rw-r--r-- | src/battle_anim.c | 4 | ||||
-rw-r--r-- | src/battle_party_menu.c | 57 | ||||
-rw-r--r-- | src/berry_tag_screen.c | 4 | ||||
-rw-r--r-- | src/choose_party.c | 1071 | ||||
-rw-r--r-- | src/credits.c | 6 | ||||
-rw-r--r-- | src/data/.clang-format | 22 | ||||
-rw-r--r-- | src/data/text/font0_widths.h | 39 | ||||
-rw-r--r-- | src/data/text/font1_widths.h | 35 | ||||
-rw-r--r-- | src/data/text/font3_widths.h | 39 | ||||
-rw-r--r-- | src/data/text/font4_widths.h | 35 | ||||
-rw-r--r-- | src/data/text/type1_map.h | 249 | ||||
-rw-r--r-- | src/data/text/type3_map.h | 130 | ||||
-rw-r--r-- | src/decompress.c | 64 | ||||
-rwxr-xr-x | src/field_effect.c | 3 | ||||
-rw-r--r-- | src/intro.c | 18 | ||||
-rw-r--r-- | src/item.c | 5 | ||||
-rw-r--r-- | src/money.c | 4 | ||||
-rw-r--r-- | src/party_menu.c | 22 | ||||
-rw-r--r-- | src/pokeball.c | 1193 | ||||
-rw-r--r-- | src/pokedex.c | 10 | ||||
-rw-r--r-- | src/pokemon_3.c | 8 | ||||
-rw-r--r-- | src/script_pokemon_util_80C4BF0.c | 29 | ||||
-rw-r--r-- | src/script_pokemon_util_80F99CC.c | 3 | ||||
-rw-r--r-- | src/starter_choose.c | 4 | ||||
-rw-r--r-- | src/text.c | 14 | ||||
-rw-r--r-- | src/title_screen.c | 6 | ||||
-rw-r--r-- | src/wallclock.c | 2 |
28 files changed, 2978 insertions, 148 deletions
diff --git a/src/battle_7.c b/src/battle_7.c index a2990018e..a93237608 100644 --- a/src/battle_7.c +++ b/src/battle_7.c @@ -55,21 +55,21 @@ extern void (*gAnimScriptCallback)(void); extern u8 gAnimScriptActive; extern const u8 *const gBattleAnims_Unknown1[]; extern const u8 *const gBattleAnims_Unknown2[]; -extern const struct SpriteSheet gTrainerFrontPicTable[]; +extern const struct CompressedSpriteSheet gTrainerFrontPicTable[]; extern const struct MonCoords gTrainerFrontPicCoords[]; -extern const struct SpritePalette gTrainerFrontPicPaletteTable[]; +extern const struct CompressedSpritePalette gTrainerFrontPicPaletteTable[]; extern const u8 gSubstituteDollTilemap[]; extern const u8 gSubstituteDollGfx[]; extern const u8 gSubstituteDollPal[]; -extern const struct SpriteSheet gUnknown_081FAF24; +extern const struct CompressedSpriteSheet gUnknown_081FAF24; extern const struct SpriteTemplate gSpriteTemplate_81FAF34; extern void (*const gOpponentBufferCommands[])(void); -extern const struct SpriteSheet gUnknown_0820A47C; -extern const struct SpriteSheet gUnknown_0820A484; -extern const struct SpriteSheet gUnknown_0820A48C[]; -extern const struct SpriteSheet gUnknown_0820A49C[]; -extern const struct SpriteSheet gUnknown_0820A4AC; -extern const struct SpriteSheet gUnknown_0820A4B4[]; +extern const struct CompressedSpriteSheet gUnknown_0820A47C; +extern const struct CompressedSpriteSheet gUnknown_0820A484; +extern const struct CompressedSpriteSheet gUnknown_0820A48C[]; +extern const struct CompressedSpriteSheet gUnknown_0820A49C[]; +extern const struct CompressedSpriteSheet gUnknown_0820A4AC; +extern const struct CompressedSpriteSheet gUnknown_0820A4B4[]; extern const struct SpritePalette gUnknown_0820A4D4[]; extern const u8 gUnknown_08D09C48[]; @@ -84,10 +84,8 @@ extern u8 sub_8078874(u8); extern u8 sub_8077F68(u8); extern u8 sub_8077F7C(u8); extern void sub_8094958(void); -extern const u16 *pokemon_get_pal(struct Pokemon *); extern void sub_80105DC(struct Sprite *); extern void move_anim_start_t2(); -extern const u16 *species_and_otid_get_pal(); void sub_80315E8(u8); u8 sub_803163C(u8); @@ -283,7 +281,7 @@ void sub_8031794(struct Pokemon *pkmn, u8 b) u32 otId; u8 var; u16 paletteOffset; - const u16 *palette; + const u8 *lzPaletteData; personalityValue = GetMonData(pkmn, MON_DATA_PERSONALITY); if (ewram17800[b].unk2 == 0) @@ -308,16 +306,16 @@ void sub_8031794(struct Pokemon *pkmn, u8 b) r7); paletteOffset = 0x100 + b * 16; if (ewram17800[b].unk2 == 0) - palette = pokemon_get_pal(pkmn); + lzPaletteData = pokemon_get_pal(pkmn); else - palette = species_and_otid_get_pal(species, otId, personalityValue); - sub_800D238(palette, ewram); + lzPaletteData = species_and_otid_get_pal(species, otId, personalityValue); + sub_800D238(lzPaletteData, ewram); LoadPalette(ewram, paletteOffset, 0x20); LoadPalette(ewram, 0x80 + b * 16, 0x20); if (species == SPECIES_CASTFORM) { paletteOffset = 0x100 + b * 16; - sub_800D238(palette, ewram + 0x16400); + sub_800D238(lzPaletteData, ewram + 0x16400); LoadPalette(ewram + 0x16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); } if (ewram17800[b].unk2 != 0) @@ -335,7 +333,7 @@ void sub_80318FC(struct Pokemon *pkmn, u8 b) u32 otId; u8 var; u16 paletteOffset; - const u16 *palette; + const u8 *lzPaletteData; personalityValue = GetMonData(pkmn, MON_DATA_PERSONALITY); if (ewram17800[b].unk2 == 0) @@ -360,16 +358,16 @@ void sub_80318FC(struct Pokemon *pkmn, u8 b) r7); paletteOffset = 0x100 + b * 16; if (ewram17800[b].unk2 == 0) - palette = pokemon_get_pal(pkmn); + lzPaletteData = pokemon_get_pal(pkmn); else - palette = species_and_otid_get_pal(species, otId, personalityValue); - sub_800D238(palette, ewram); + lzPaletteData = species_and_otid_get_pal(species, otId, personalityValue); + sub_800D238(lzPaletteData, ewram); LoadPalette(ewram, paletteOffset, 0x20); LoadPalette(ewram, 0x80 + b * 16, 0x20); if (species == SPECIES_CASTFORM) { paletteOffset = 0x100 + b * 16; - sub_800D238(palette, ewram + 0x16400); + sub_800D238(lzPaletteData, ewram + 0x16400); LoadPalette(ewram + 0x16400 + gBattleMonForms[b] * 32, paletteOffset, 0x20); } if (ewram17800[b].unk2 != 0) @@ -390,7 +388,7 @@ void nullsub_9(u16 unused) void sub_8031A6C(u16 a, u8 b) { u8 status; - struct SpriteSheet spriteSheet; + struct CompressedSpriteSheet spriteSheet; status = GetBankIdentity(b); DecompressPicFromTable_2( @@ -624,7 +622,7 @@ void sub_8031FC4(u8 a, u8 b, bool8 c) u32 personalityValue; u32 otId; u8 r10; - const u16 *palette; + const u8 *lzPaletteData; if (c) { @@ -697,14 +695,14 @@ void sub_8031FC4(u8 a, u8 b, bool8 c) dst = (void *)(VRAM + 0x10000 + gSprites[gObjectBankIDs[a]].oam.tileNum * 32); DmaCopy32(3, src, dst, 0x800); paletteOffset = 0x100 + a * 16; - palette = species_and_otid_get_pal(species, otId, personalityValue); - sub_800D238(palette, ewram); + lzPaletteData = species_and_otid_get_pal(species, otId, personalityValue); + sub_800D238(lzPaletteData, ewram); LoadPalette(ewram, paletteOffset, 32); if (species == SPECIES_CASTFORM) { u16 *paletteSrc = (u16 *)(ewram + 0x16400); - sub_800D238(palette, paletteSrc); + sub_800D238(lzPaletteData, paletteSrc); LoadPalette(paletteSrc + gBattleMonForms[b] * 16, paletteOffset, 32); } BlendPalette(paletteOffset, 16, 6, 0x7FFF); diff --git a/src/battle_anim.c b/src/battle_anim.c index cc856d5cd..55ede1788 100644 --- a/src/battle_anim.c +++ b/src/battle_anim.c @@ -58,8 +58,8 @@ extern struct MusicPlayerInfo gMPlay_SE2; extern const u16 gUnknown_081C7160[]; extern const u8 *const gBattleAnims_Moves[]; -extern const struct SpriteSheet gBattleAnimPicTable[]; -extern const struct SpritePalette gBattleAnimPaletteTable[]; +extern const struct CompressedSpriteSheet gBattleAnimPicTable[]; +extern const struct CompressedSpritePalette gBattleAnimPaletteTable[]; extern const struct BattleAnimBackground gBattleAnimBackgroundTable[]; static void RunAnimScriptCommand(void); diff --git a/src/battle_party_menu.c b/src/battle_party_menu.c index 96b68adba..cf572642e 100644 --- a/src/battle_party_menu.c +++ b/src/battle_party_menu.c @@ -18,30 +18,43 @@ #include "task.h" #include "text.h" -#define DATA_COUNT (6) - extern u8 ewram[]; - -struct Unk201B000 -{ - //u8 filler0[0x260]; - struct Pokemon unk0[6]; - u8 filler258[1]; - u8 unk259; - u8 filler25A[6]; - u8 unk260; - u8 unk261; - u8 filler262[2]; - s16 unk264[DATA_COUNT * 2]; // This may be a union - u8 filler27C[2]; - s16 unk27E; - s16 unk280; - s16 unk282; -}; - -#define ewram1B000 (*(struct Unk201B000 *)(ewram + 0x1B000)) #define UNK_201606C_ARRAY (ewram + 0x1606C) // lazy define but whatever. +extern u8 IsLinkDoubleBattle(void); +extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *); +extern void LoadHeldItemIconGraphics(void); +extern void CreateHeldItemIcons_806DC34(); +extern u8 sub_806BD58(u8, u8); +extern void PartyMenuPrintMonsLevelOrStatus(void); +extern void PrintPartyMenuMonNicknames(void); +extern void PartyMenuTryPrintMonsHP(void); +extern void nullsub_13(void); +extern void PartyMenuDrawHPBars(void); +extern u8 sub_806B58C(u8); +extern u8 GetItemEffectType(); +extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); +extern u16 sub_806BD80(); +extern u8 sub_806CA38(); +extern void sub_806D5A4(void); +extern void sub_802E414(void); +extern void sub_80A6DCC(void); +extern void sub_806AF4C(); +extern u8 sub_80F9344(void); +extern u8 sub_806B124(void); +extern void sub_806C994(); +extern void sub_806BF74(); +extern void sub_806AEDC(void); +extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); +extern void sub_806E7D0(u8, const struct PartyPopupMenu *); +extern u8 *sub_8040D08(); +extern void sub_8040B8C(void); +extern void sub_806E6F0(); +extern void sub_806D538(); +extern void nullsub_14(); +extern void OpenPartyMenu(); +extern u8 sub_803FBBC(void); + extern u16 gScriptItemId; extern u8 gPlayerPartyCount; extern u8 gNoOfAllBanks; @@ -562,7 +575,7 @@ static void Task_8095330(u8 taskId) } } -static void Task_809535C(u8 taskId) +static void Task_809535C(void) { gPaletteFade.bufferTransferDisabled = TRUE; sub_806AF4C(1, 0xFF, SetUpBattlePokemonMenu, 5); diff --git a/src/berry_tag_screen.c b/src/berry_tag_screen.c index 5647d4593..116ca2cca 100644 --- a/src/berry_tag_screen.c +++ b/src/berry_tag_screen.c @@ -38,8 +38,8 @@ extern struct BerryTagStatus gUnknown_0203932E; extern u16 gScriptItemId; extern u16 gUnknown_030041B4; -extern const struct SpriteSheet gUnknown_083C1F74; -extern const struct SpritePalette gUnknown_083C1F7C; +extern const struct CompressedSpriteSheet gUnknown_083C1F74; +extern const struct CompressedSpritePalette gUnknown_083C1F7C; extern u8 *gUnknown_0841192C[]; diff --git a/src/choose_party.c b/src/choose_party.c new file mode 100644 index 000000000..63e9c8477 --- /dev/null +++ b/src/choose_party.c @@ -0,0 +1,1071 @@ +#include "global.h" +#include "decoration.h" +#include "field_fadetransition.h" +#include "main.h" +#include "menu.h" +#include "name_string_util.h" +#include "palette.h" +#include "party_menu.h" +#include "pokemon.h" +#include "pokemon_summary_screen.h" +#include "rom4.h" +#include "script.h" +#include "songs.h" +#include "sound.h" +#include "strings.h" +#include "string_util.h" +#include "task.h" +#include "text.h" + +struct UnknownPokemonStruct2 +{ + /*0x00*/ u16 species; + /*0x02*/ u16 heldItem; + /*0x04*/ u8 nickname[11]; + /*0x0F*/ u8 level; + /*0x10*/ u16 hp; + /*0x12*/ u16 maxhp; + /*0x14*/ u32 status; + /*0x18*/ u32 personality; + /*0x1C*/ u8 gender; + /*0x1D*/ u8 language; +}; + +extern u8 gSelectedOrderFromParty[]; +extern u8 gPlayerPartyCount; +extern u8 gLastFieldPokeMenuOpened; +extern u8 gUnknown_020384F0; +extern struct UnknownPokemonStruct2 gUnknown_02023A00[]; +extern u8 gUnknown_0202E8F6; +extern struct Pokemon gUnknown_030042FC[]; +extern const u16 gBattleTowerBanlist[]; + +extern void OpenPartyMenu(); +extern void TryCreatePartyMenuMonIcon(u8, u8, struct Pokemon *); +extern void LoadHeldItemIconGraphics(void); +extern void CreateHeldItemIcons_806DC34(); +extern u8 sub_806BD58(u8, u8); +extern void PartyMenuPrintMonsLevelOrStatus(void); +extern void PrintPartyMenuMonNicknames(void); +extern void sub_806BC3C(u8, u8); +extern u8 sub_806B58C(u8); +extern void sub_806D538(); +extern u16 sub_806BE38(); +extern u8 sub_806CA38(); +extern void sub_808B5B4(); +extern TaskFunc PartyMenuGetPopupMenuFunc(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, u8); +extern u8 sub_806B124(); +extern void sub_806C994(); +extern void sub_806C658(); +extern void sub_806AEDC(void); +extern void sub_806AF4C(); +extern void ShowPokemonSummaryScreen(struct Pokemon *, u8, u8, void (*)(void), int); +extern void sub_806C890(); +extern void sub_806D5A4(); +extern void sub_806B908(void); +extern void CreateMonIcon_806D99C(int, u8, int, struct UnknownPokemonStruct2 *); +extern void sub_806D50C(int, u8); +extern void CreatePartyMenuMonIcon(); +extern void CreateHeldItemIcon_806DCD4(int, u8, int); +extern u8 GetMonStatusAndPokerus(); +extern void PartyMenuPrintHP(); +extern void PartyMenuPutStatusTilemap(u8, int, u8); +extern void PartyMenuPrintLevel(); +extern void PartyMenuPutNicknameTilemap(); +extern void PrintPartyMenuMonNickname(); +extern void PartyMenuDrawHPBar(); +extern bool8 sub_80F9344(void); +extern void sub_806D4AC(); +extern void sub_806D3B4(); +extern void PartyMenuDoPrintLevel(u8, u8, u8); +extern void PartyMenuDoDrawHPBar(u8, u8, u16, u16); +extern void PartyMenuDoPutNicknameTilemap(u16, u8, u8, u8, const u8 *); +extern void box_print(u8, int, const u8 *); +extern void sub_806BCE8(void); +extern void sub_806E750(u8, const struct PartyPopupMenu *, const struct PartyMenuItem *, int); +extern u16 sub_806BD80(); +extern void sub_806BF74(); + +static void ClearPartySelection(void); +static bool8 IsMonAllowedInBattleTower(struct Pokemon *); +static void sub_812238C(u8); +static void sub_8122450(u8); +static void sub_81224A8(u8); +static void sub_8122728(u8); +static void BattleTowerEntryMenuCallback_Exit(u8); +static void sub_81228E8(u8); +static void sub_8122950(u8); +static void sub_81229B8(void); +static void sub_8122AB8(u8); +static void sub_8122B10(u8); +static void sub_8122C18(u8); +static void Task_DaycareStorageMenu8122EAC(u8); +void sub_8123138(u8); +static void sub_8123170(u8); +static void sub_81231AC(void); + +void sub_8121E10(void) +{ + ClearPartySelection(); + ewram1B000.unk263 = 0; + OpenPartyMenu(4, 0); +} + +void sub_8121E34(void) +{ + ClearPartySelection(); + ewram1B000.unk263 = 1; + OpenPartyMenu(4, 0); +} + +static void ClearPartySelection(void) +{ + u8 i; + + for (i = 0; i < 3; i++) + gSelectedOrderFromParty[i] = 0; +} + +bool8 sub_8121E78(void) +{ + u8 i; + + switch (ewram1B000_alt.unk264) + { + case 0: + if (ewram1B000_alt.unk266 < gPlayerPartyCount) + { + TryCreatePartyMenuMonIcon(ewram1B000_alt.unk260, ewram1B000_alt.unk266, &gPlayerParty[ewram1B000_alt.unk266]); + ewram1B000_alt.unk266++; + } + else + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + if (sub_806BD58(ewram1B000_alt.unk260, ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + else + { + ewram1B000_alt.unk266++; + } + break; + case 4: + PartyMenuPrintMonsLevelOrStatus(); + ewram1B000_alt.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + ewram1B000_alt.unk264++; + break; + case 6: + for (i = 0; i < gPlayerPartyCount; i++) + { + u8 j; + + for (j = 0; j < 3; j++) + { + if (gSelectedOrderFromParty[j] == i + 1) + { + sub_806BC3C(i, j * 14 + 0x1C); + break; + } + } + if (j == 3) + { + if (IsMonAllowedInBattleTower(&gPlayerParty[i]) == TRUE) + sub_806BC3C(i, 0x70); + else + sub_806BC3C(i, 0x7E); + } + } + ewram1B000_alt.unk264++; + break; + case 7: + if (sub_806B58C(ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264 = 0; + return TRUE; + } + else + { + ewram1B000_alt.unk266++; + } + break; + } + return FALSE; +} + +#ifdef NONMATCHING +static bool8 IsMonAllowedInBattleTower(struct Pokemon *pkmn) +{ + u16 r3; + s32 i; + + if (GetMonData(pkmn, MON_DATA_IS_EGG)) + return FALSE; + + if (ewram1B000.unk263 == 0) + { + if (GetMonData(pkmn, MON_DATA_HP) == 0) + return FALSE; + else + return TRUE; + } + + if ((gSaveBlock2.filler_A8.var_4AC & 1) == 0 + && GetMonData(pkmn, MON_DATA_LEVEL) > 50) + return FALSE; + + r3 = GetMonData(pkmn, MON_DATA_SPECIES); + // Can't stop the compiler from optimizing out the first index + for (i = 0; gBattleTowerBanlist[i] != 0xFFFF; i++) + { + if (gBattleTowerBanlist[i] == r3) + return FALSE; + } + return TRUE; +} +#else +__attribute__((naked)) +static bool8 IsMonAllowedInBattleTower(struct Pokemon *pkmn) +{ + asm_unified( + "push {r4,lr}\n\ + adds r4, r0, 0\n\ + movs r1, 0x2D\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + bne _0812207C\n\ + ldr r0, _08122058 @ =0x0201b000\n\ + ldr r1, _0812205C @ =0x00000263\n\ + adds r0, r1\n\ + ldrb r0, [r0]\n\ + cmp r0, 0\n\ + bne _08122060\n\ + adds r0, r4, 0\n\ + movs r1, 0x39\n\ + bl GetMonData\n\ + cmp r0, 0\n\ + beq _0812207C\n\ + b _081220B6\n\ + .align 2, 0\n\ +_08122058: .4byte 0x0201b000\n\ +_0812205C: .4byte 0x00000263\n\ +_08122060:\n\ + ldr r0, _08122080 @ =gSaveBlock2\n\ + ldr r1, _08122084 @ =0x00000554\n\ + adds r0, r1\n\ + ldrb r1, [r0]\n\ + movs r0, 0x1\n\ + ands r0, r1\n\ + cmp r0, 0\n\ + bne _08122088\n\ + adds r0, r4, 0\n\ + movs r1, 0x38\n\ + bl GetMonData\n\ + cmp r0, 0x32\n\ + bls _08122088\n\ +_0812207C:\n\ + movs r0, 0\n\ + b _081220B8\n\ + .align 2, 0\n\ +_08122080: .4byte gSaveBlock2\n\ +_08122084: .4byte 0x00000554\n\ +_08122088:\n\ + adds r0, r4, 0\n\ + movs r1, 0xB\n\ + bl GetMonData\n\ + lsls r0, 16\n\ + lsrs r3, r0, 16\n\ + ldr r1, _081220C0 @ =gBattleTowerBanlist\n\ + movs r0, 0\n\ + lsls r0, 1\n\ + adds r2, r0, r1\n\ + ldrh r0, [r2]\n\ + ldr r1, _081220C4 @ =0x0000ffff\n\ + cmp r0, r1\n\ + beq _081220B6\n\ + adds r4, r1, 0\n\ + adds r1, r2, 0\n\ +_081220A8:\n\ + ldrh r0, [r1]\n\ + cmp r0, r3\n\ + beq _0812207C\n\ + adds r1, 0x2\n\ + ldrh r0, [r1]\n\ + cmp r0, r4\n\ + bne _081220A8\n\ +_081220B6:\n\ + movs r0, 0x1\n\ +_081220B8:\n\ + pop {r4}\n\ + pop {r1}\n\ + bx r1\n\ + .align 2, 0\n\ +_081220C0: .4byte gBattleTowerBanlist\n\ +_081220C4: .4byte 0x0000ffff\n" + ); +} +#endif + +static u8 sub_81220C8(void) +{ + u8 i; + + if (ewram1B000.unk263 == 0) + return 0xFF; + if (gSelectedOrderFromParty[2] == 0) + return 0x11; + for (i = 0; i < 2; i++) + { + u8 j; + + ewram1B000.unk282 = GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[i]], MON_DATA_SPECIES); + ewram1B000.unk280 = GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[i]], MON_DATA_HELD_ITEM); + for (j = i + 1; j < 3; j++) + { + if (ewram1B000.unk282 == GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[j]], MON_DATA_SPECIES)) + return 0x12; + if (ewram1B000.unk280 != 0 && ewram1B000.unk280 == GetMonData(&gUnknown_030042FC[gSelectedOrderFromParty[j]], MON_DATA_HELD_ITEM)) + return 0x13; + } + } + return 0xFF; +} + +//------------------------------------------------------------------------------ +// Battle Tower Entry Menu +//------------------------------------------------------------------------------ + +static void BattleTowerEntryMenuCallback_Summary(u8); +static void BattleTowerEntryMenuCallback_Enter(u8); +static void BattleTowerEntryMenuCallback_NoEntry(u8); +static void BattleTowerEntryMenuCallback_Exit(u8); + +static const struct PartyMenuItem sBattleTowerEntryMenuItems[] = +{ + {OtherText_Summary, BattleTowerEntryMenuCallback_Summary}, + {OtherText_Enter2, BattleTowerEntryMenuCallback_Enter}, + {OtherText_NoEntry, BattleTowerEntryMenuCallback_NoEntry}, + {gUnknownText_Exit, BattleTowerEntryMenuCallback_Exit}, +}; + +static const u8 gUnknown_084017D0[] = {1, 0, 3}; +static const u8 gUnknown_084017D3[] = {2, 0, 3}; +static const u8 gUnknown_084017D6[] = {0, 3}; + +static const struct PartyPopupMenu sBattleTowerEntryMenu[] = +{ + {ARRAY_COUNT(gUnknown_084017D0), 9, gUnknown_084017D0}, + {ARRAY_COUNT(gUnknown_084017D3), 9, gUnknown_084017D3}, + {ARRAY_COUNT(gUnknown_084017D6), 9, gUnknown_084017D6}, +}; + + +static bool8 IsPartyMemberAlreadySelected(u8 partyMember) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == partyMember) + return TRUE; + } + return FALSE; +} + +static void sub_81221F8(u8 taskId) +{ + sub_806D538(5, 1); + if (IsMonAllowedInBattleTower(&gPlayerParty[gLastFieldPokeMenuOpened]) == TRUE) + { + if (IsPartyMemberAlreadySelected(gLastFieldPokeMenuOpened + 1) == TRUE) + { + gTasks[taskId].data[4] = 1; + sub_806E750(1, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + } + else + { + gTasks[taskId].data[4] = 0; + sub_806E750(0, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + } + } + else + { + gTasks[taskId].data[4] = 2; + sub_806E750(2, sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, 0); + } +} + +void sub_81222B0(u8 taskId) +{ + if (!gPaletteFade.active) + { + switch (sub_806BE38(taskId)) + { + case 1: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = sub_806CA38(taskId); + if (gLastFieldPokeMenuOpened != 6) + { + GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); + sub_81221F8(taskId); + gTasks[taskId].func = sub_812238C; + } + else + { + gTasks[taskId].func = sub_81224A8; + } + sub_808B5B4(taskId); + break; + case 2: + PlaySE(SE_SELECT); + ClearPartySelection(); + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + break; + } + } +} + +// Handle input +static void sub_812238C(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gMain.newAndRepeatedKeys & 0x40) + { + if (GetMenuCursorPos() != 0) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + return; + } + if (gMain.newAndRepeatedKeys & 0x80) + { + if (GetMenuCursorPos() != 3) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + return; + } + if (gMain.newKeys & A_BUTTON) + { + TaskFunc popupMenuFunc; + + PlaySE(SE_SELECT); + popupMenuFunc = PartyMenuGetPopupMenuFunc( + gTasks[taskId].data[4], + sBattleTowerEntryMenu, + sBattleTowerEntryMenuItems, + GetMenuCursorPos()); + popupMenuFunc(taskId); + return; + } + if (gMain.newKeys & B_BUTTON) + { + BattleTowerEntryMenuCallback_Exit(taskId); + return; + } + } +} + +// Return from menu? +static void sub_8122450(u8 taskId) +{ + if (!gPaletteFade.active) + { + SetMainCallback2(gMain.savedCallback); + DestroyTask(taskId); + } +} + +// Wait for A or B press +static void sub_8122480(u8 taskId) +{ + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + BattleTowerEntryMenuCallback_Exit(taskId); +} + +static void sub_81224A8(u8 taskId) +{ + u8 val = sub_81220C8(); + + if (val != 0xFF) + { + sub_806D538(val, 0); + gTasks[taskId].func = sub_8122480; + } + else + { + if (gSelectedOrderFromParty[0] != 0) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + } + else + { + PlaySE(SE_HAZURE); + sub_806D538(14, 0); + gTasks[taskId].func = sub_8122480; + } + } +} + +// CB2 for menu? +static void sub_8122530(void) +{ + while (1) + { + if (sub_806B124() == 1) + { + sub_806C994(ewram1B000.unk260, gUnknown_020384F0); + sub_806C658(ewram1B000.unk260, 0); + GetMonNickname(&gPlayerParty[gUnknown_020384F0], gStringVar1); + gLastFieldPokeMenuOpened = gUnknown_020384F0; + sub_81221F8(ewram1B000.unk260); + SetMainCallback2(sub_806AEDC); + break; + } + if (sub_80F9344() == 1) + break; + } +} + +static void sub_81225A4(void) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + sub_806AF4C(4, 0xFF, sub_812238C, 5); + SetMainCallback2(sub_8122530); +} + +// Wait for fade, then show summary screen +static void sub_81225D4(u8 taskId) +{ + if (!gPaletteFade.active) + { + u8 r4 = gSprites[gTasks[taskId].data[3] >> 8].data0; + + DestroyTask(taskId); + ewram1B000.unk262 = 1; + ShowPokemonSummaryScreen(gPlayerParty, r4, gPlayerPartyCount - 1, sub_81225A4, 0); + } +} + +// Summary callback? +static void BattleTowerEntryMenuCallback_Summary(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_81225D4; +} + +static void BattleTowerEntryMenuCallback_Enter(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == 0) + { + gSelectedOrderFromParty[i] = gLastFieldPokeMenuOpened + 1; + sub_806BC3C(gLastFieldPokeMenuOpened, i * 14 + 0x1C); + if (i == 2) + sub_806C890(taskId); + BattleTowerEntryMenuCallback_Exit(taskId); + return; + } + } + PlaySE(SE_HAZURE); + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D5A4(); + sub_806E834(gOtherText_NoMoreThreePoke, 1); + gTasks[taskId].func = sub_8122728; +} + +static void sub_8122728(u8 taskId) +{ + if (gUnknown_0202E8F6 == 1) + return; + + if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) + { + MenuZeroFillWindowRect(0, 14, 29, 19); + HandleDestroyMenuCursors(); + BattleTowerEntryMenuCallback_Exit(taskId); + } +} + +static void BattleTowerEntryMenuCallback_NoEntry(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gSelectedOrderFromParty[i] == gLastFieldPokeMenuOpened + 1) + { + gSelectedOrderFromParty[i] = 0; + switch (i) + { + case 0: + gSelectedOrderFromParty[0] = gSelectedOrderFromParty[1]; + gSelectedOrderFromParty[1] = gSelectedOrderFromParty[2]; + gSelectedOrderFromParty[2] = 0; + break; + case 1: + gSelectedOrderFromParty[1] = gSelectedOrderFromParty[2]; + gSelectedOrderFromParty[2] = 0; + break; + } + break; // exit loop + } + } + sub_806BC3C(gLastFieldPokeMenuOpened, 0x70); + if (gSelectedOrderFromParty[0] != 0) + sub_806BC3C(gSelectedOrderFromParty[0] - 1, 0x1C); + if (gSelectedOrderFromParty[1] != 0) + sub_806BC3C(gSelectedOrderFromParty[1] - 1, 0x2A); + BattleTowerEntryMenuCallback_Exit(taskId); +} + +static void sub_81227FC(u8 taskId) +{ + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D538(0, 0); + gTasks[taskId].func = sub_81222B0; +} + +static void BattleTowerEntryMenuCallback_Exit(u8 taskId) +{ + PlaySE(SE_SELECT); + sub_81227FC(taskId); +} + +bool8 sub_8122854(void) +{ + switch (ewram1B000_alt.unk264) + { + case 0: + sub_81228E8(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + sub_8122950(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + sub_81229B8(); + ewram1B000_alt.unk264++; + break; + case 4: + sub_806B908(); + return TRUE; + } + return FALSE; +} + +static void sub_81228E8(u8 a) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + CreatePartyMenuMonIcon(a, i, 3, &gPlayerParty[i]); + if (gUnknown_02023A00[i].species != 0) + { + CreateMonIcon_806D99C(a, i + 3, 3, &gUnknown_02023A00[i]); + sub_806D50C(a, i + 3); + } + } +} + +static void sub_8122950(u8 a) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + { + u16 item = GetMonData(&gPlayerParty[i], MON_DATA_HELD_ITEM); + + CreateHeldItemIcon_806DCD4(a, i, item); + } + if (gUnknown_02023A00[i].species != 0) + CreateHeldItemIcon_806DCD4(a, i + 3, gUnknown_02023A00[i].heldItem); + } +} + +static void sub_81229B8(void) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (GetMonData(&gPlayerParty[i], MON_DATA_SPECIES) != 0) + { + u8 status; + + PartyMenuPrintHP(i, 3, &gPlayerParty[i]); + status = GetMonStatusAndPokerus(&gPlayerParty[i]); + if (status != 0 && status != 6) + PartyMenuPutStatusTilemap(i, 3, status - 1); + else + PartyMenuPrintLevel(i, 3, &gPlayerParty[i]); + PartyMenuPutNicknameTilemap(i, 3, &gPlayerParty[i]); + PrintPartyMenuMonNickname(i, 3, &gPlayerParty[i]); + PartyMenuDrawHPBar(i, 3, &gPlayerParty[i]); + } + } +} + +void sub_8122A48(u8 taskId) +{ + if (!gPaletteFade.active) + { + gTasks[taskId].data[0] = 30; + sub_806D4AC(taskId, gUnknown_02023A00[0].species, 0); + sub_806D4AC(taskId, gUnknown_02023A00[1].species, 1); + sub_806D4AC(taskId, gUnknown_02023A00[2].species, 2); + gTasks[taskId].func = sub_8122AB8; + ewram1B000.unk261 = 1; + } +} + +static void sub_8122AB8(u8 taskId) +{ + sub_806D3B4(taskId, gUnknown_02023A00[1].species, gUnknown_02023A00[2].species); + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].func = sub_8122B10; + ewram1B000.unk261 = 2; + PlaySE(SE_W231); + } +} + +static void sub_8122B10(u8 taskId) +{ + u8 i; + + for (i = 0; i < 3; i++) + { + if (gUnknown_02023A00[i].species != 0) + { + u8 r2; + + PartyMenuDoPrintHP(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); + if (gUnknown_02023A00[i].hp == 0) + r2 = 7; + else + r2 = pokemon_ailments_get_primary(gUnknown_02023A00[i].status); + if (r2 != 0) + PartyMenuPutStatusTilemap(i + 3, 3, r2 - 1); + else + PartyMenuDoPrintLevel(i + 3, 3, gUnknown_02023A00[i].level); + PartyMenuDoPutNicknameTilemap(gUnknown_02023A00[i].species, gUnknown_02023A00[i].gender, 3, i + 3, gUnknown_02023A00[i].nickname); + StringCopy(gStringVar1, gUnknown_02023A00[i].nickname); + StringGetEnd10(gStringVar1); + SanitizeNameString(gStringVar1); + box_print(i + 3, 3, gStringVar1); + PartyMenuDoDrawHPBar(i + 3, 3, gUnknown_02023A00[i].hp, gUnknown_02023A00[i].maxhp); + } + } + gTasks[taskId].func = sub_8122C18; + gTasks[taskId].data[0] = 0; +} + +static void sub_8122C18(u8 taskId) +{ + gTasks[taskId].data[0]++; + if (gTasks[taskId].data[0] == 256) + { + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8122450; + } +} + +// Exactly the same as sub_8121E78 except for case 6 +bool8 unref_sub_8122C60(void) +{ + switch (ewram1B000_alt.unk264) + { + case 0: + if (ewram1B000_alt.unk266 < gPlayerPartyCount) + { + TryCreatePartyMenuMonIcon(ewram1B000_alt.unk260, ewram1B000_alt.unk266, &gPlayerParty[ewram1B000_alt.unk266]); + ewram1B000_alt.unk266++; + } + else + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + break; + case 1: + LoadHeldItemIconGraphics(); + ewram1B000_alt.unk264++; + break; + case 2: + CreateHeldItemIcons_806DC34(ewram1B000_alt.unk260); + ewram1B000_alt.unk264++; + break; + case 3: + if (sub_806BD58(ewram1B000_alt.unk260, ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264++; + } + else + { + ewram1B000_alt.unk266++; + } + break; + case 4: + PartyMenuPrintMonsLevelOrStatus(); + ewram1B000_alt.unk264++; + break; + case 5: + PrintPartyMenuMonNicknames(); + ewram1B000_alt.unk264++; + break; + case 6: + sub_806BCE8(); + ewram1B000_alt.unk264++; + break; + case 7: + if (sub_806B58C(ewram1B000_alt.unk266) == 1) + { + ewram1B000_alt.unk266 = 0; + ewram1B000_alt.unk264 = 0; + return TRUE; + } + else + { + ewram1B000_alt.unk266++; + } + break; + } + return FALSE; +} + +//------------------------------------------------------------------------------ +// Daycare Pokemon Storage Menu +//------------------------------------------------------------------------------ + +static void DaycareStorageMenuCallback_Store(u8); +static void DaycareStorageMenuCallback_Summary(u8); +static void DaycareStorageMenuCallback_Exit(u8); + +static const struct PartyMenuItem sDaycareStorageMenuItems[] = +{ + {OtherText_Store, DaycareStorageMenuCallback_Store}, + {OtherText_Summary, DaycareStorageMenuCallback_Summary}, + {gUnknownText_Exit, DaycareStorageMenuCallback_Exit}, +}; + +static const u8 gUnknown_08401808[] = {0, 1, 2}; +static const u8 gUnknown_0840180B[] = {1, 2}; + +static const struct PartyPopupMenu sDaycareStorageMenus[] = +{ + {ARRAY_COUNT(gUnknown_08401808), 9, gUnknown_08401808}, + {ARRAY_COUNT(gUnknown_0840180B), 9, gUnknown_0840180B}, +}; + +static void sub_8122D94(u8 taskId) +{ + if (!GetMonData(&gPlayerParty[gLastFieldPokeMenuOpened], MON_DATA_IS_EGG)) + { + gTasks[taskId].data[4] = 0; + sub_806E750(0, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); + } + else + { + gTasks[taskId].data[4] = 1; + sub_806E750(1, sDaycareStorageMenus, sDaycareStorageMenuItems, 0); + } +} + +void sub_8122E0C(u8 taskId) +{ + if (!gPaletteFade.active) + { + switch (sub_806BD80(taskId)) + { + case 1: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = sub_806CA38(taskId); + GetMonNickname(&gPlayerParty[gLastFieldPokeMenuOpened], gStringVar1); + sub_8122D94(taskId); + gTasks[taskId].func = Task_DaycareStorageMenu8122EAC; + break; + case 2: + PlaySE(SE_SELECT); + gLastFieldPokeMenuOpened = 0xFF; + gSpecialVar_0x8004 = 0xFF; + sub_8123138(taskId); + break; + } + } +} + +static void Task_DaycareStorageMenu8122EAC(u8 taskId) +{ + if (!gPaletteFade.active) + { + if (gMain.newAndRepeatedKeys & 0x40) + { + if (GetMenuCursorPos() != 0) + { + PlaySE(SE_SELECT); + MoveMenuCursor(-1); + } + return; + } + if (gMain.newAndRepeatedKeys & 0x80) + { + if (GetMenuCursorPos() != 3) + { + PlaySE(SE_SELECT); + MoveMenuCursor(1); + } + return; + } + if (gMain.newKeys & A_BUTTON) + { + TaskFunc popupMenuFunc; + + PlaySE(SE_SELECT); + popupMenuFunc = PartyMenuGetPopupMenuFunc( + gTasks[taskId].data[4], + sDaycareStorageMenus, + sDaycareStorageMenuItems, + GetMenuCursorPos()); + popupMenuFunc(taskId); + return; + } + if (gMain.newKeys & B_BUTTON) + { + DaycareStorageMenuCallback_Exit(taskId); + return; + } + } +} + +static void DaycareStorageMenuCallback_Store(u8 taskId) +{ + gSpecialVar_0x8004 = gLastFieldPokeMenuOpened; + sub_8123138(taskId); +} + +static void sub_8122F90(void) +{ + while (1) + { + if (sub_806B124() == 1) + { + sub_806C994(ewram1B000.unk260, gUnknown_020384F0); + sub_806BF74(ewram1B000.unk260, 0); + GetMonNickname(&gPlayerParty[gUnknown_020384F0], gStringVar1); + gLastFieldPokeMenuOpened = gUnknown_020384F0; + sub_8122D94(ewram1B000.unk260); + SetMainCallback2(sub_806AEDC); + break; + } + if (sub_80F9344() == 1) + break; + } +} + +static void sub_8123004(void) +{ + gPaletteFade.bufferTransferDisabled = TRUE; + sub_806AF4C(6, 0xFF, Task_DaycareStorageMenu8122EAC, 5); + SetMainCallback2(sub_8122F90); +} + +static void sub_8123034(u8 taskId) +{ + if (!gPaletteFade.active) + { + u8 r4 = gSprites[gTasks[taskId].data[3] >> 8].data0; + + DestroyTask(taskId); + ewram1B000.unk262 = 1; + ShowPokemonSummaryScreen(gPlayerParty, r4, gPlayerPartyCount - 1, sub_8123004, 0); + } +} + +static void DaycareStorageMenuCallback_Summary(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8123034; +} + +static void DaycareStorageMenuCallback_Exit(u8 taskId) +{ + PlaySE(SE_SELECT); + MenuZeroFillWindowRect(20, 10, 29, 19); + HandleDestroyMenuCursors(); + sub_806D538(15, 0); + gTasks[taskId].func = sub_8122E0C; +} + +void sub_8123138(u8 taskId) +{ + BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); + gTasks[taskId].func = sub_8123170; +} + +static void sub_8123170(u8 taskId) +{ + if (!gPaletteFade.active) + { + gFieldCallback = sub_81231AC; + SetMainCallback2(c2_exit_to_overworld_2_switch); + DestroyTask(taskId); + } +} + +// Do these last two functions really belong in here? + +static void sub_81231C4(u8); + +void sub_81231AC(void) +{ + pal_fill_black(); + CreateTask(sub_81231C4, 10); +} + +static void sub_81231C4(u8 taskId) +{ + if (sub_807D770() == TRUE) + { + DestroyTask(taskId); + ScriptContext2_Disable(); + EnableBothScriptContexts(); + } +} diff --git a/src/credits.c b/src/credits.c index a7d6191e6..8ec126a41 100644 --- a/src/credits.c +++ b/src/credits.c @@ -1495,7 +1495,7 @@ void spritecb_81454E0(struct Sprite *sprite) { static u8 sub_81456B4(u16 species, u16 x, u16 y, u16 position) { u32 personality; - const u16 *palette; + const u8 *lzPaletteData; u8 spriteId; u8 spriteId2; @@ -1527,8 +1527,8 @@ static u8 sub_81456B4(u16 species, u16 x, u16 y, u16 position) 1 ); - palette = species_and_otid_get_pal(species, 0, 0xFFFF); - LoadCompressedPalette(palette, 0x100 + (position * 16), 0x20); + lzPaletteData = species_and_otid_get_pal(species, 0, 0xFFFF); + LoadCompressedPalette(lzPaletteData, 0x100 + (position * 16), 0x20); sub_8143648(position, position); spriteId = CreateSprite(&gUnknown_02024E8C, x, y, 0); diff --git a/src/data/.clang-format b/src/data/.clang-format new file mode 100644 index 000000000..036aa7d76 --- /dev/null +++ b/src/data/.clang-format @@ -0,0 +1,22 @@ +BasedOnStyle: LLVM +AllowShortFunctionsOnASingleLine: None +BreakBeforeBraces: Allman +ColumnLimit: 0 +UseTab: Never +IndentWidth: 4 +TabWidth: 4 +AlignAfterOpenBracket: DontAlign +Cpp11BracedListStyle: false +BreakStringLiterals: false +IndentCaseLabels: false +IncludeCategories: + - Regex: '^"gba/types\.h"$' + Priority: -4 + - Regex: '^"global\.h"$' + Priority: -3 + - Regex: '^"gba/gba\.h"$' + Priority: -2 + - Regex: '^"gba/' + Priority: -1 + - Regex: '.\*' + Priority: 1 diff --git a/src/data/text/font0_widths.h b/src/data/text/font0_widths.h new file mode 100644 index 000000000..ff102ecec --- /dev/null +++ b/src/data/text/font0_widths.h @@ -0,0 +1,39 @@ +#if REVISION >= 1 +static const u8 sFont0Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 4, 8, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 8, + 8, 8, 8, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 7, 7, 8, 8, 4, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 5, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#else +static const u8 sFont0Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 5, 8, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, + 7, 7, 7, 8, 8, 8, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 3, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 8, 7, 7, 8, 8, 6, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 7, 7, 7, 8, 6, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#endif diff --git a/src/data/text/font1_widths.h b/src/data/text/font1_widths.h new file mode 100644 index 000000000..05b4da130 --- /dev/null +++ b/src/data/text/font1_widths.h @@ -0,0 +1,35 @@ +#if REVISION >= 1 +static const u8 sFont1Widths[] = { + 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 5, 5, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 8, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 8, 4, 5, 5, 5, 5, 4, 8, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 6, 6, + 8, 7, 3, 5, 3, 3, 5, 4, 3, 6, 6, 6, 7, 7, 8, 5, + 5, 5, 3, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 4, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 6, 7, 6, 6, 7, 6, + 7, 7, 7, 6, 7, 6, 7, 6, 7, 6, 6, 7, 6, 6, 3, 3, + 5, 5, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, +}; +#else +static const u8 sFont1Widths[] = { + 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 5, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 8, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 8, 4, 5, 5, 5, 5, 4, 8, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, + 8, 7, 6, 5, 3, 3, 5, 4, 3, 6, 6, 6, 7, 7, 8, 5, + 5, 5, 3, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 4, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 6, 7, 6, 6, 7, 6, + 7, 7, 7, 6, 7, 6, 7, 6, 7, 6, 6, 7, 6, 6, 3, 3, + 5, 5, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, +}; +#endif diff --git a/src/data/text/font3_widths.h b/src/data/text/font3_widths.h new file mode 100644 index 000000000..d84cbdf73 --- /dev/null +++ b/src/data/text/font3_widths.h @@ -0,0 +1,39 @@ +#if REVISION >= 1 +static const u8 sFont3Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 4, 8, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 8, + 8, 8, 8, 8, 8, 8, 3, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 7, 7, 8, 8, 4, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 5, 6, 6, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#else +static const u8 sFont3Widths[] = { + 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 8, 6, 6, 6, 6, 6, 4, 8, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 4, 8, 8, 8, 7, 8, 8, 4, 6, 6, 4, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 6, 7, 8, 7, 7, 8, 8, 4, + 7, 8, 8, 8, 8, 8, 7, 8, 7, 7, 7, 7, 7, 7, 8, 7, + 7, 7, 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, + 7, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 3, 6, 3, 5, 3, + 6, 6, 6, 3, 3, 6, 6, 6, 3, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 4, 5, 6, + 3, 6, 6, 6, 6, 6, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7, + 3, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 1, 1, +}; +#endif diff --git a/src/data/text/font4_widths.h b/src/data/text/font4_widths.h new file mode 100644 index 000000000..bfa30b8e1 --- /dev/null +++ b/src/data/text/font4_widths.h @@ -0,0 +1,35 @@ +#if REVISION >= 1 +static const u8 sFont4Widths[] = { + 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 7, 5, 5, 5, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 8, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 8, 4, 5, 5, 5, 5, 4, 8, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 8, 5, 6, 6, + 8, 7, 3, 5, 3, 3, 5, 4, 3, 6, 6, 6, 7, 7, 8, 5, + 5, 5, 3, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 4, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 6, 7, 6, 6, 7, 6, + 7, 7, 7, 6, 7, 6, 7, 6, 7, 6, 6, 7, 6, 6, 3, 3, + 5, 5, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, +}; +#else +static const u8 sFont4Widths[] = { + 5, 3, 8, 8, 8, 8, 8, 8, 8, 4, 5, 4, 4, 8, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 5, 8, 8, 8, 8, 8, 4, 8, 8, + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 6, 6, 6, 5, + 6, 5, 5, 5, 5, 5, 5, 5, 5, 4, 8, 4, 4, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 8, 4, 5, 5, 5, 5, 4, 8, + 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, + 8, 7, 6, 5, 3, 3, 5, 4, 3, 6, 6, 6, 7, 7, 8, 5, + 5, 5, 3, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 4, 5, 5, 5, 5, 4, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 4, 4, 5, 3, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, + 5, 5, 5, 5, 6, 6, 7, 7, 7, 7, 6, 7, 6, 6, 7, 6, + 7, 7, 7, 6, 7, 6, 7, 6, 7, 6, 6, 7, 6, 6, 3, 3, + 5, 5, 5, 5, 3, 3, 5, 5, 5, 5, 5, 5, +}; +#endif diff --git a/src/data/text/type1_map.h b/src/data/text/type1_map.h new file mode 100644 index 000000000..ff22e560a --- /dev/null +++ b/src/data/text/type1_map.h @@ -0,0 +1,249 @@ +static const u8 sFontType1Map[] = { + 0xD4, 0xD4, + 0xD4, 0x31, + 0xD4, 0x32, + 0xD4, 0x33, + 0xD4, 0x34, + 0xD4, 0x35, + 0xD4, 0x36, + 0xD4, 0x37, + 0xD4, 0x38, + 0xD4, 0x39, + 0xD4, 0x3A, + 0xD4, 0x3B, + 0xD4, 0x3C, + 0xD4, 0x3D, + 0xD4, 0x3E, + 0xD4, 0x3F, + 0xD4, 0x40, + 0xD4, 0x41, + 0xD4, 0x42, + 0xD4, 0x43, + 0xD4, 0x44, + 0xD4, 0x45, + 0xD4, 0x46, + 0xD4, 0x47, + 0xD4, 0x48, + 0xD4, 0x49, + 0xD4, 0x4A, + 0xD4, 0x4B, + 0xD4, 0x4C, + 0xD4, 0x4D, + 0xD4, 0x4E, + 0xD4, 0x4F, + 0xD4, 0x50, + 0xD4, 0x51, + 0xD4, 0x52, + 0xD4, 0x53, + 0xD4, 0x54, + 0xD4, 0x55, + 0xD4, 0x56, + 0xD4, 0x57, + 0xD4, 0x58, + 0xD4, 0x59, + 0xD4, 0x5A, + 0xD4, 0x5B, + 0xD4, 0x5C, + 0xD4, 0x5D, + 0xD4, 0x5E, + 0xD4, 0x31, + 0xD4, 0x32, + 0xD4, 0x33, + 0xD4, 0x34, + 0xD4, 0x35, + 0xD4, 0x60, + 0xD4, 0x61, + 0xD4, 0x62, + 0x65, 0x36, + 0x65, 0x37, + 0x65, 0x38, + 0x65, 0x39, + 0x65, 0x3A, + 0x65, 0x3B, + 0x65, 0x3C, + 0x65, 0x3D, + 0x65, 0x3E, + 0x65, 0x3F, + 0x65, 0x40, + 0x65, 0x41, + 0x65, 0x42, + 0x65, 0x43, + 0x65, 0x44, + 0x65, 0x4A, + 0x65, 0x4B, + 0x65, 0x4C, + 0x65, 0x4D, + 0x65, 0x4E, + 0x64, 0x4A, + 0x64, 0x4B, + 0x64, 0x4C, + 0x64, 0x4D, + 0x64, 0x4E, + 0xD4, 0x5F, + 0xD4, 0x00, + 0xD4, 0x01, + 0xD4, 0x02, + 0xD4, 0x03, + 0xD4, 0x04, + 0xD4, 0x05, + 0xD4, 0x06, + 0xD4, 0x07, + 0xD4, 0x08, + 0xD4, 0x09, + 0xD4, 0x0A, + 0xD4, 0x0B, + 0xD4, 0x0C, + 0xD4, 0x0D, + 0xD4, 0x0E, + 0xD4, 0x0F, + 0xD4, 0x10, + 0xD4, 0x11, + 0xD4, 0x12, + 0xD4, 0x13, + 0xD4, 0x14, + 0xD4, 0x15, + 0xD4, 0x16, + 0xD4, 0x17, + 0xD4, 0x18, + 0xD4, 0x19, + 0xD4, 0x1A, + 0xD4, 0x1B, + 0xD4, 0x4D, + 0xD4, 0x1C, + 0xD4, 0x1D, + 0xD4, 0x1E, + 0xD4, 0x1F, + 0xD4, 0x20, + 0xD4, 0x21, + 0xD4, 0x22, + 0xD4, 0x23, + 0xD4, 0x24, + 0xD4, 0x25, + 0xD4, 0x58, + 0xD4, 0x26, + 0xD4, 0x27, + 0xD4, 0x28, + 0xD4, 0x29, + 0xD4, 0x2A, + 0xD4, 0x2B, + 0xD4, 0x69, + 0xD4, 0x30, + 0xD4, 0x6A, + 0xD4, 0x6B, + 0xD4, 0x74, + 0xD4, 0x2D, + 0xD4, 0x2E, + 0xD4, 0x2F, + 0x65, 0x05, + 0x65, 0x06, + 0x65, 0x07, + 0x65, 0x08, + 0x65, 0x09, + 0x65, 0x0A, + 0x65, 0x0B, + 0x65, 0x0C, + 0x65, 0x0D, + 0x65, 0x0E, + 0x65, 0x0F, + 0x65, 0x10, + 0x65, 0x11, + 0x65, 0x12, + 0x65, 0x13, + 0x65, 0x19, + 0x65, 0x1A, + 0x65, 0x1B, + 0x65, 0x4D, + 0x65, 0x1C, + 0x64, 0x19, + 0x64, 0x1A, + 0x64, 0x1B, + 0x64, 0x4D, + 0x64, 0x1C, + 0xD4, 0x2C, + 0xD4, 0x76, + 0xD4, 0x77, + 0xD4, 0x78, + 0xD4, 0x79, + 0xD4, 0x7A, + 0xD4, 0x7B, + 0xD4, 0x7C, + 0xD4, 0x7D, + 0xD4, 0x7E, + 0xD4, 0x7F, + 0xD4, 0x67, + 0xD4, 0x66, + 0xD4, 0x68, + 0xD4, 0x63, + 0xD4, 0xD2, + 0xD4, 0xD3, + 0xD4, 0xD0, + 0xD4, 0xD1, + 0xD4, 0xCE, + 0xD4, 0xCF, + 0xD4, 0x6F, + 0xD4, 0x75, + 0xD4, 0x70, + 0xD4, 0x72, + 0xD4, 0x71, + 0xD4, 0x73, + 0xD4, 0x80, + 0xD4, 0x81, + 0xD4, 0x82, + 0xD4, 0x83, + 0xD4, 0x84, + 0xD4, 0x85, + 0xD4, 0x86, + 0xD4, 0x87, + 0xD4, 0x88, + 0xD4, 0x89, + 0xD4, 0x8A, + 0xD4, 0x8B, + 0xD4, 0x8C, + 0xD4, 0x8D, + 0xD4, 0x8E, + 0xD4, 0x8F, + 0xD4, 0x90, + 0xD4, 0x91, + 0xD4, 0x92, + 0xD4, 0x93, + 0xD4, 0x94, + 0xD4, 0x95, + 0xD4, 0x96, + 0xD4, 0x97, + 0xD4, 0x98, + 0xD4, 0x99, + 0xD4, 0x9A, + 0xD4, 0x9B, + 0xD4, 0x9C, + 0xD4, 0x9D, + 0xD4, 0x9E, + 0xD4, 0x9F, + 0xD4, 0xA0, + 0xD4, 0xA1, + 0xD4, 0xA2, + 0xD4, 0xA3, + 0xD4, 0xA4, + 0xD4, 0xA5, + 0xD4, 0xA6, + 0xD4, 0xA7, + 0xD4, 0xA8, + 0xD4, 0xA9, + 0xD4, 0xAA, + 0xD4, 0xAB, + 0xD4, 0xAC, + 0xD4, 0xAD, + 0xD4, 0xAE, + 0xD4, 0xAF, + 0xD4, 0xB0, + 0xD4, 0xB1, + 0xD4, 0xB2, + 0xD4, 0xB3, + 0xD4, 0x6D, + 0xD4, 0xD5, + 0xD4, 0xD6, + 0xD4, 0xD7, + 0xD4, 0xD8, + 0xD4, 0xD9, + 0xD4, 0xDA, + 0xD4, 0xDB, +}; diff --git a/src/data/text/type3_map.h b/src/data/text/type3_map.h new file mode 100644 index 000000000..cb3694b39 --- /dev/null +++ b/src/data/text/type3_map.h @@ -0,0 +1,130 @@ +static const u8 sFontType3Map[] = { + 0x00, 0x10, + 0x01, 0x10, + 0x02, 0x10, + 0x03, 0x10, + 0x04, 0x11, + 0x05, 0x11, + 0x06, 0x11, + 0x07, 0x11, + 0x08, 0x12, + 0x09, 0x12, + 0x0A, 0x12, + 0x0B, 0x12, + 0x0C, 0x13, + 0x0D, 0x13, + 0x0E, 0x13, + 0x0F, 0x13, + 0x00, 0x14, + 0x01, 0x14, + 0x02, 0x14, + 0x03, 0x14, + 0x04, 0x15, + 0x05, 0x15, + 0x06, 0x15, + 0x07, 0x15, + 0x08, 0x16, + 0x09, 0x16, + 0x0A, 0x16, + 0x0B, 0x16, + 0x0C, 0x17, + 0x0D, 0x17, + 0x0E, 0x17, + 0x0F, 0x17, + 0x00, 0x18, + 0x01, 0x18, + 0x02, 0x18, + 0x03, 0x18, + 0x04, 0x19, + 0x05, 0x19, + 0x06, 0x19, + 0x07, 0x19, + 0x08, 0x1A, + 0x09, 0x1A, + 0x0A, 0x1A, + 0x0B, 0x1A, + 0x0C, 0x1B, + 0x0D, 0x1B, + 0x0E, 0x1B, + 0x0F, 0x1B, + 0x00, 0x1C, + 0x01, 0x1C, + 0x02, 0x1C, + 0x03, 0x1C, + 0x04, 0x1D, + 0x05, 0x1D, + 0x06, 0x1D, + 0x07, 0x1D, + 0x08, 0x1E, + 0x09, 0x1E, + 0x0A, 0x1E, + 0x0B, 0x1E, + 0x0C, 0x1F, + 0x0D, 0x1F, + 0x0E, 0x1F, + 0x0F, 0x1F, + 0x20, 0x24, + 0x20, 0x24, + 0x21, 0x24, + 0x21, 0x24, + 0x20, 0x24, + 0x20, 0x24, + 0x21, 0x24, + 0x21, 0x24, + 0x22, 0x25, + 0x22, 0x25, + 0x23, 0x25, + 0x23, 0x25, + 0x22, 0x25, + 0x22, 0x25, + 0x23, 0x25, + 0x23, 0x25, + 0x20, 0x24, + 0x20, 0x24, + 0x21, 0x24, + 0x21, 0x24, + 0x20, 0x24, + 0x20, 0x24, + 0x21, 0x24, + 0x21, 0x24, + 0x22, 0x25, + 0x22, 0x25, + 0x23, 0x25, + 0x23, 0x25, + 0x22, 0x25, + 0x22, 0x25, + 0x23, 0x25, + 0x23, 0x25, + 0x20, 0x26, + 0x20, 0x26, + 0x21, 0x26, + 0x21, 0x26, + 0x20, 0x26, + 0x20, 0x26, + 0x21, 0x26, + 0x21, 0x26, + 0x22, 0x27, + 0x22, 0x27, + 0x23, 0x27, + 0x23, 0x27, + 0x22, 0x27, + 0x22, 0x27, + 0x23, 0x27, + 0x23, 0x27, + 0x20, 0x26, + 0x20, 0x26, + 0x21, 0x26, + 0x21, 0x26, + 0x20, 0x26, + 0x20, 0x26, + 0x21, 0x26, + 0x21, 0x26, + 0x22, 0x27, + 0x22, 0x27, + 0x23, 0x27, + 0x23, 0x27, + 0x22, 0x27, + 0x22, 0x27, + 0x23, 0x27, + 0x23, 0x27, +}; diff --git a/src/decompress.c b/src/decompress.c index 1d38447b5..d7f7087a7 100644 --- a/src/decompress.c +++ b/src/decompress.c @@ -16,57 +16,57 @@ void LZDecompressVram(const void *src, void *dest) LZ77UnCompVram(src, dest); } -void LoadCompressedObjectPic(const struct SpriteSheet *a) +void LoadCompressedObjectPic(const struct CompressedSpriteSheet *src) { - struct SpriteSheet spriteSheet; + struct SpriteSheet dest; - LZ77UnCompWram(a->data, (void *)WRAM); - spriteSheet.data = (void *)WRAM; - spriteSheet.size = a->size; - spriteSheet.tag = a->tag; - LoadSpriteSheet(&spriteSheet); + LZ77UnCompWram(src->data, (void *)WRAM); + dest.data = (void *)WRAM; + dest.size = src->size; + dest.tag = src->tag; + LoadSpriteSheet(&dest); } -void LoadCompressedObjectPicOverrideBuffer(const struct SpriteSheet *a, void *buffer) +void LoadCompressedObjectPicOverrideBuffer(const struct CompressedSpriteSheet *src, void *buffer) { - struct SpriteSheet spriteSheet; + struct SpriteSheet dest; - LZ77UnCompWram(a->data, buffer); - spriteSheet.data = buffer; - spriteSheet.size = a->size; - spriteSheet.tag = a->tag; - LoadSpriteSheet(&spriteSheet); + LZ77UnCompWram(src->data, buffer); + dest.data = buffer; + dest.size = src->size; + dest.tag = src->tag; + LoadSpriteSheet(&dest); } -void LoadCompressedObjectPalette(const struct SpritePalette *a) +void LoadCompressedObjectPalette(const struct CompressedSpritePalette *src) { - struct SpritePalette spritePalette; + struct SpritePalette dest; - LZ77UnCompWram(a->data, (void *)WRAM); - spritePalette.data = (void *)WRAM; - spritePalette.tag = a->tag; - LoadSpritePalette(&spritePalette); + LZ77UnCompWram(src->data, (void *)WRAM); + dest.data = (void *)WRAM; + dest.tag = src->tag; + LoadSpritePalette(&dest); } -void LoadCompressedObjectPaletteOverrideBuffer(const struct SpritePalette *a, void *buffer) +void LoadCompressedObjectPaletteOverrideBuffer(const struct CompressedSpritePalette *a, void *buffer) { - struct SpritePalette spritePalette; + struct SpritePalette dest; LZ77UnCompWram(a->data, buffer); - spritePalette.data = buffer; - spritePalette.tag = a->tag; - LoadSpritePalette(&spritePalette); + dest.data = buffer; + dest.tag = a->tag; + LoadSpritePalette(&dest); } -void DecompressPicFromTable_2(const struct SpriteSheet *a, u8 b, u8 c, void *d, void *e, s32 species) +void DecompressPicFromTable_2(const struct CompressedSpriteSheet *src, u8 b, u8 c, void *d, void *buffer, s32 species) { if (species > SPECIES_EGG) - LZ77UnCompWram(gMonFrontPicTable[0].data, e); + LZ77UnCompWram(gMonFrontPicTable[0].data, buffer); else - LZ77UnCompWram(a->data, e); + LZ77UnCompWram(src->data, buffer); } -void HandleLoadSpecialPokePic(const struct SpriteSheet *spriteSheet, u32 b, u32 c, u32 d, void *dest, s32 species, u32 g) +void HandleLoadSpecialPokePic(const struct CompressedSpriteSheet *src, u32 b, u32 c, u32 d, void *dest, s32 species, u32 g) { u32 frontOrBack; @@ -76,10 +76,10 @@ void HandleLoadSpecialPokePic(const struct SpriteSheet *spriteSheet, u32 b, u32 else frontOrBack = 1; // frontPic - LoadSpecialPokePic(spriteSheet, b, c, d, dest, species, g, frontOrBack); + LoadSpecialPokePic(src, b, c, d, dest, species, g, frontOrBack); } -void LoadSpecialPokePic(const struct SpriteSheet *spriteSheet, u32 b, u32 c, u32 d, void *dest, s32 species, u32 g, u32 frontOrBack) +void LoadSpecialPokePic(const struct CompressedSpriteSheet *src, u32 b, u32 c, u32 d, void *dest, s32 species, u32 g, u32 frontOrBack) { u8 frontOrBack8 = frontOrBack; @@ -101,7 +101,7 @@ void LoadSpecialPokePic(const struct SpriteSheet *spriteSheet, u32 b, u32 c, u32 else if (species > SPECIES_EGG) // is species unknown? draw the ? icon LZ77UnCompWram(gMonFrontPicTable[0].data, dest); else - LZ77UnCompWram(spriteSheet->data, dest); + LZ77UnCompWram(src->data, dest); DrawSpindaSpots(species, g, dest, frontOrBack8); } diff --git a/src/field_effect.c b/src/field_effect.c index 9591bb6a0..a7f0e4129 100755 --- a/src/field_effect.c +++ b/src/field_effect.c @@ -657,7 +657,8 @@ u8 CreateMonSprite_PicBox(u16 species, s16 x, s16 y, u8 subpriority) u8 CreateMonSprite_FieldMove(u16 species, u32 d, u32 g, s16 x, s16 y, u8 subpriority) { - const struct SpritePalette *spritePalette; + const struct CompressedSpritePalette *spritePalette; + HandleLoadSpecialPokePic(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, (u32)gUnknown_081FAF4C[3] /* this is actually u8* or something, pointing to ewram */, gUnknown_081FAF4C[3], species, g); spritePalette = sub_80409C8(species, d, g); LoadCompressedObjectPalette(spritePalette); diff --git a/src/intro.c b/src/intro.c index f13bd04e6..396f5e5df 100644 --- a/src/intro.c +++ b/src/intro.c @@ -31,7 +31,7 @@ extern struct GcmbStruct gMultibootProgramStruct; extern u16 gSaveFileStatus; extern u8 gReservedSpritePaletteCount; extern const u8 gInterfaceGfx_PokeBall[]; -extern const u16 gInterfacePal_PokeBall[]; +extern const u8 gInterfacePal_PokeBall[]; extern const u8 gIntroCopyright_Gfx[]; extern const u16 gIntroCopyright_Pal[]; extern const u16 gIntroCopyright_Tilemap[]; @@ -411,12 +411,12 @@ static const struct SpriteTemplate gSpriteTemplate_840AFF0 = .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_813DA64, }; -const struct SpriteSheet gUnknown_0840B008[] = +const struct CompressedSpriteSheet gUnknown_0840B008[] = { {gIntroTiles, 0x1400, 2000}, {NULL}, }; -const struct SpriteSheet gUnknown_0840B018[] = +const struct CompressedSpriteSheet gUnknown_0840B018[] = { {gIntro1EonTiles, 0x400, 2002}, {NULL}, @@ -738,17 +738,17 @@ static const struct SpriteTemplate gSpriteTemplate_840B1F4 = .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_813EDFC, }; -const struct SpriteSheet gIntro3PokeballGfx_Table[] = +const struct CompressedSpriteSheet gIntro3PokeballGfx_Table[] = { {gInterfaceGfx_PokeBall, 0x100, 2002}, {NULL}, }; -const struct SpriteSheet gIntro3MiscGfx_Table[] = +const struct CompressedSpriteSheet gIntro3MiscGfx_Table[] = { {gIntro3MiscTiles, 0xa00, 2003}, {NULL}, }; -const struct SpritePalette gInterfacePokeballPal_Table[] = +const struct CompressedSpritePalette gInterfacePokeballPal_Table[] = { {gInterfacePal_PokeBall, 2002}, {NULL}, @@ -1772,15 +1772,15 @@ void sub_813CE30(u16 scrX, u16 scrY, u16 zoom, u16 alpha) static u16 sub_813CE88(u16 species, s16 x, s16 y, u16 d, u8 front) { - const u16 *pal; + const u8 *lzPaletteData; u8 spriteId; if (front) LoadSpecialPokePic(&gMonFrontPicTable[species], gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, 0x2000000, gUnknown_0840B5A0[d], species, 0, 1); else LoadSpecialPokePic(&gMonBackPicTable[species], gMonBackPicCoords[species].coords, gMonBackPicCoords[species].y_offset, 0x2000000, gUnknown_0840B5A0[d], species, 0, 0); - pal = species_and_otid_get_pal(species, 0, 0xFFFF); - LoadCompressedPalette(pal, 0x100 + d * 0x10, 0x20); + lzPaletteData = species_and_otid_get_pal(species, 0, 0xFFFF); + LoadCompressedPalette(lzPaletteData, 0x100 + d * 0x10, 0x20); sub_8143648(d, d); spriteId = CreateSprite(&gUnknown_02024E8C, x, y, (d + 1) * 4); gSprites[spriteId].oam.paletteNum = d; diff --git a/src/item.c b/src/item.c index 920670e8f..2eb013490 100644 --- a/src/item.c +++ b/src/item.c @@ -1,5 +1,6 @@ #include "global.h" #include "item.h" +#include "items.h" #include "berry.h" #include "string_util.h" #include "strings.h" @@ -28,9 +29,9 @@ static void CompactPCItems(void); void CopyItemName(u16 itemId, u8 *string) { - if (itemId == 0xAF) + if (itemId == ITEM_ENIGMA_BERRY) { - StringCopy(string, GetBerryInfo(0x2B)->name); + StringCopy(string, GetBerryInfo(0x2B)->name); // berry 0x2b = enigma berry StringAppend(string, gOtherText_Berry2); } else diff --git a/src/money.c b/src/money.c index de0730951..ab4508a39 100644 --- a/src/money.c +++ b/src/money.c @@ -10,8 +10,8 @@ extern u16 gSpecialVar_0x8005; extern u8 gUnknown_02038734; -extern const struct SpriteSheet gUnknown_083CF584; -extern const struct SpritePalette gUnknown_083CF58C; +extern const struct CompressedSpriteSheet gUnknown_083CF584; +extern const struct CompressedSpritePalette gUnknown_083CF58C; extern const struct SpriteTemplate gSpriteTemplate_83CF56C; bool8 IsEnoughMoney(u32 budget, u32 cost) diff --git a/src/party_menu.c b/src/party_menu.c index be0db4dc4..49805505b 100644 --- a/src/party_menu.c +++ b/src/party_menu.c @@ -23,6 +23,14 @@ #include "string_util.h" #include "strings.h" #include "task.h" +#include "sprite.h" +#include "palette.h" +#include "event_data.h" +#include "main.h" +#include "item.h" +#include "battle_interface.h" +#include "species.h" +#include "party_menu.h" #define DATA_COUNT (6) @@ -33,19 +41,6 @@ struct Unk2001000 u8 unk2; }; -struct Unk201B000 -{ - u8 filler0[0x260]; - u8 unk260; - u8 unk261; - u8 filler262[2]; - s16 unk264[DATA_COUNT * 2]; // This may be a union - u8 filler27C[2]; - s16 unk27E; - s16 unk280; - s16 unk282; -}; - struct Unk201C000 { /*0x00*/ struct Pokemon *pokemon; @@ -74,7 +69,6 @@ struct UnknownStruct5 extern u8 ewram[]; #define ewram01000 (*(struct Unk2001000 *)(ewram + 0x01000)) -#define ewram1B000 (*(struct Unk201B000 *)(ewram + 0x1B000)) #define ewram1C000 (*(struct Unk201C000 *)(ewram + 0x1C000)) #define ewram1F000 (*(struct Unk201F000 *)(ewram + 0x1F000)) diff --git a/src/pokeball.c b/src/pokeball.c new file mode 100644 index 000000000..ee3b95678 --- /dev/null +++ b/src/pokeball.c @@ -0,0 +1,1193 @@ +#include "global.h" +#include "gba/m4a_internal.h" +#include "battle.h" +#include "decompress.h" +#include "graphics.h" +#include "m4a.h" +#include "main.h" +#include "pokeball.h" +#include "pokemon.h" +#include "rom_8077ABC.h" +#include "songs.h" +#include "sound.h" +#include "sprite.h" +#include "task.h" +#include "trig.h" +#include "util.h" + +extern struct MusicPlayerInfo gMPlay_BGM; +extern u16 gBattleTypeFlags; +extern u8 gBankTarget; +extern u8 gActiveBank; +extern u16 gBattlePartyID[]; +extern u8 gObjectBankIDs[]; +extern u8 gDoingBattleAnim; +extern u8 gHealthboxIDs[]; + +#define GFX_TAG_POKEBALL 55000 +#define GFX_TAG_GREATBALL 55001 +#define GFX_TAG_SAFARIBALL 55002 +#define GFX_TAG_ULTRABALL 55003 +#define GFX_TAG_MASTERBALL 55004 +#define GFX_TAG_NETBALL 55005 +#define GFX_TAG_DIVEBALL 55006 +#define GFX_TAG_NESTBALL 55007 +#define GFX_TAG_REPEATBALL 55008 +#define GFX_TAG_TIMERBALL 55009 +#define GFX_TAG_LUXURYBALL 55010 +#define GFX_TAG_PREMIERBALL 55011 + +static const struct CompressedSpriteSheet sBallSpriteSheets[] = +{ + {gInterfaceGfx_PokeBall, 384, GFX_TAG_POKEBALL}, + {gInterfaceGfx_GreatBall, 384, GFX_TAG_GREATBALL}, + {gInterfaceGfx_SafariBall, 384, GFX_TAG_SAFARIBALL}, + {gInterfaceGfx_UltraBall, 384, GFX_TAG_ULTRABALL}, + {gInterfaceGfx_MasterBall, 384, GFX_TAG_MASTERBALL}, + {gInterfaceGfx_NetBall, 384, GFX_TAG_NETBALL}, + {gInterfaceGfx_DiveBall, 384, GFX_TAG_DIVEBALL}, + {gInterfaceGfx_NestBall, 384, GFX_TAG_NESTBALL}, + {gInterfaceGfx_RepeatBall, 384, GFX_TAG_REPEATBALL}, + {gInterfaceGfx_TimerBall, 384, GFX_TAG_TIMERBALL}, + {gInterfaceGfx_LuxuryBall, 384, GFX_TAG_LUXURYBALL}, + {gInterfaceGfx_PremierBall, 384, GFX_TAG_PREMIERBALL}, +}; + +static const struct CompressedSpritePalette sBallSpritePalettes[] = +{ + {gInterfacePal_PokeBall, GFX_TAG_POKEBALL}, + {gInterfacePal_GreatBall, GFX_TAG_GREATBALL}, + {gInterfacePal_SafariBall, GFX_TAG_SAFARIBALL}, + {gInterfacePal_UltraBall, GFX_TAG_ULTRABALL}, + {gInterfacePal_MasterBall, GFX_TAG_MASTERBALL}, + {gInterfacePal_NetBall, GFX_TAG_NETBALL}, + {gInterfacePal_DiveBall, GFX_TAG_DIVEBALL}, + {gInterfacePal_NestBall, GFX_TAG_NESTBALL}, + {gInterfacePal_RepeatBall, GFX_TAG_REPEATBALL}, + {gInterfacePal_TimerBall, GFX_TAG_TIMERBALL}, + {gInterfacePal_LuxuryBall, GFX_TAG_LUXURYBALL}, + {gInterfacePal_PremierBall, GFX_TAG_PREMIERBALL}, +}; + +static const struct OamData sBallOamData = +{ + .y = 0, + .affineMode = 3, + .objMode = 0, + .mosaic = 0, + .bpp = 0, + .shape = 0, + .x = 0, + .matrixNum = 0, + .size = 1, + .tileNum = 0, + .priority = 2, + .paletteNum = 0, + .affineParam = 0, +}; + +static const union AnimCmd sBallAnimSeq3[] = +{ + ANIMCMD_FRAME(0, 5), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sBallAnimSeq5[] = +{ + ANIMCMD_FRAME(4, 1), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sBallAnimSeq4[] = +{ + ANIMCMD_FRAME(8, 5), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sBallAnimSeq6[] = +{ + ANIMCMD_FRAME(12, 1), + ANIMCMD_JUMP(0), +}; + +static const union AnimCmd sBallAnimSeq0[] = +{ + ANIMCMD_FRAME(0, 1), + ANIMCMD_END, +}; + +static const union AnimCmd sBallAnimSeq1[] = +{ + ANIMCMD_FRAME(4, 5), + ANIMCMD_FRAME(8, 5), + ANIMCMD_END, +}; + +static const union AnimCmd sBallAnimSeq2[] = +{ + ANIMCMD_FRAME(4, 5), + ANIMCMD_FRAME(0, 5), + ANIMCMD_END, +}; + +static const union AnimCmd *const sBallAnimSequences[] = +{ + sBallAnimSeq0, + sBallAnimSeq1, + sBallAnimSeq2, + + // unused? + sBallAnimSeq3, + sBallAnimSeq4, + sBallAnimSeq5, + sBallAnimSeq6, +}; + +static const union AffineAnimCmd sBallAffineAnimSeq0[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 0, 1), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sBallAffineAnimSeq1[] = +{ + AFFINEANIMCMD_FRAME(0, 0, -3, 1), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sBallAffineAnimSeq2[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 3, 1), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd sBallAffineAnimSeq3[] = +{ + AFFINEANIMCMD_FRAME(256, 256, 0, 0), + AFFINEANIMCMD_END, +}; + +static const union AffineAnimCmd sBallAffineAnimSeq4[] = +{ + AFFINEANIMCMD_FRAME(0, 0, 25, 1), + AFFINEANIMCMD_JUMP(0), +}; + +static const union AffineAnimCmd *const sBallAffineAnimSequences[] = +{ + sBallAffineAnimSeq0, + sBallAffineAnimSeq1, + sBallAffineAnimSeq2, + sBallAffineAnimSeq3, + sBallAffineAnimSeq4, +}; + +static void objc_0804ABD4(struct Sprite *sprite); +const struct SpriteTemplate gBallSpriteTemplates[] = +{ + { + .tileTag = GFX_TAG_POKEBALL, + .paletteTag = GFX_TAG_POKEBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_GREATBALL, + .paletteTag = GFX_TAG_GREATBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_SAFARIBALL, + .paletteTag = GFX_TAG_SAFARIBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_ULTRABALL, + .paletteTag = GFX_TAG_ULTRABALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_MASTERBALL, + .paletteTag = GFX_TAG_MASTERBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_NETBALL, + .paletteTag = GFX_TAG_NETBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_DIVEBALL, + .paletteTag = GFX_TAG_DIVEBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_NESTBALL, + .paletteTag = GFX_TAG_NESTBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_REPEATBALL, + .paletteTag = GFX_TAG_REPEATBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_TIMERBALL, + .paletteTag = GFX_TAG_TIMERBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_LUXURYBALL, + .paletteTag = GFX_TAG_LUXURYBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, + { + .tileTag = GFX_TAG_PREMIERBALL, + .paletteTag = GFX_TAG_PREMIERBALL, + .oam = &sBallOamData, + .anims = sBallAnimSequences, + .images = NULL, + .affineAnims = sBallAffineAnimSequences, + .callback = objc_0804ABD4, + }, +}; + +extern u32 ball_number_to_ball_processing_index(u16); // not sure of return type +extern void sub_80786EC(); +extern bool8 sub_8078718(struct Sprite *); +extern u8 sub_814086C(u8, u8, int, int, u8); +extern u8 sub_8141314(u8, u8, int, u8); + +static void sub_8046464(u8); +static void sub_80466E8(struct Sprite *); +static void sub_80466F4(struct Sprite *); +static void sub_8046760(struct Sprite *); +static void sub_80467F8(struct Sprite *); +static void sub_804684C(struct Sprite *); +static void sub_8046944(struct Sprite *); +static void sub_8046984(struct Sprite *); +static void sub_8046C78(struct Sprite *); +static void sub_8046E7C(struct Sprite *); +static void sub_8046E9C(struct Sprite *); +static void sub_8046FBC(struct Sprite *); +static void sub_8047074(struct Sprite *); +static void sub_80470C4(struct Sprite *); +static void sub_8047230(struct Sprite *); +static void sub_8047254(struct Sprite *); +static void sub_80473D0(struct Sprite *); +static void sub_804748C(struct Sprite *); +static void sub_8047638(struct Sprite *); +static void sub_80476E0(struct Sprite *); +static void sub_8047754(struct Sprite *); +static void sub_804780C(struct Sprite *); +static void sub_8047830(struct Sprite *); +static void oamc_804BEB4(struct Sprite *); +static u16 sub_8047978(u8); + +u8 sub_8046400(u16 a, u8 b) +{ + u8 taskId; + + gDoingBattleAnim = 1; + ewram17810[gActiveBank].unk0_3 = 1; + taskId = CreateTask(sub_8046464, 5); + gTasks[taskId].data[1] = a; + gTasks[taskId].data[2] = b; + gTasks[taskId].data[3] = gActiveBank; + return 0; +} + +static void sub_8046464(u8 taskId) +{ + bool8 sp0 = FALSE; + u16 r8; + u8 r5; + u16 ball; + u8 r4; + u8 spriteId; + + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[0]++; + return; + } + r8 = gTasks[taskId].data[2]; + r5 = gTasks[taskId].data[3]; + if (GetBankSide(r5) != 0) + ball = GetMonData(&gEnemyParty[gBattlePartyID[r5]], MON_DATA_POKEBALL); + else + ball = GetMonData(&gPlayerParty[gBattlePartyID[r5]], MON_DATA_POKEBALL); + r4 = ball_number_to_ball_processing_index(ball); + sub_80478DC(r4); + spriteId = CreateSprite(&gBallSpriteTemplates[r4], 32, 80, 0x1D); + gSprites[spriteId].data0 = 0x80; + gSprites[spriteId].data1 = 0; + gSprites[spriteId].data7 = r8; + switch (r8) + { + case 0xFF: + gBankTarget = r5; + gSprites[spriteId].pos1.x = 24; + gSprites[spriteId].pos1.y = 68; + gSprites[spriteId].callback = sub_8047074; + break; + case 0xFE: + gSprites[spriteId].pos1.x = sub_8077ABC(r5, 0); + gSprites[spriteId].pos1.y = sub_8077ABC(r5, 1) + 24; + gBankTarget = r5; + gSprites[spriteId].data0 = 0; + gSprites[spriteId].callback = sub_8047254; + break; + default: + gBankTarget = GetBankByPlayerAI(1); + sp0 = TRUE; + break; + } + gSprites[spriteId].data6 = gBankTarget; + if (!sp0) + { + DestroyTask(taskId); + return; + } + gSprites[spriteId].data0 = 0x22; + gSprites[spriteId].data2 = sub_8077ABC(gBankTarget, 0); + gSprites[spriteId].data4 = sub_8077ABC(gBankTarget, 1) - 16; + gSprites[spriteId].data5 = -40; + sub_80786EC(&gSprites[spriteId]); + gSprites[spriteId].oam.affineParam = taskId; + gTasks[taskId].data[4] = gBankTarget; + gTasks[taskId].func = TaskDummy; + PlaySE(SE_NAGERU); +} + +static void objc_0804ABD4(struct Sprite *sprite) +{ + if (sub_8078718(sprite)) + { + u8 taskId = sprite->oam.affineParam; + u8 r5 = gTasks[taskId].data[4]; + u8 r8 = gTasks[taskId].data[2]; + u32 r4; // not sure of this type + + StartSpriteAnim(sprite, 1); + sprite->affineAnimPaused = TRUE; + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.x = 0; + sprite->pos2.y = 0; + sprite->data5 = 0; + r4 = ball_number_to_ball_processing_index(sub_8047978(r5)); + sub_814086C(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, r4); + sprite->data0 = sub_8141314(0, r5, 14, r4); + sprite->data6 = r5; + sprite->data7 = r8; + DestroyTask(taskId); + sprite->callback = sub_80466E8; + } +} + +static void sub_80466E8(struct Sprite *sprite) +{ + sprite->callback = sub_80466F4; +} + +static void sub_80466F4(struct Sprite *sprite) +{ + sprite->data5++; + if (sprite->data5 == 10) + { + sprite->data5 = 0; + sprite->callback = sub_8046760; + StartSpriteAffineAnim(&gSprites[gObjectBankIDs[sprite->data6]], 2); + AnimateSprite(&gSprites[gObjectBankIDs[sprite->data6]]); + gSprites[gObjectBankIDs[sprite->data6]].data1 = 0; + } +} + +static void sub_8046760(struct Sprite *sprite) +{ + sprite->data5++; + if (sprite->data5 == 11) + PlaySE(SE_SUIKOMU); + if (gSprites[gObjectBankIDs[sprite->data6]].affineAnimEnded) + { + StartSpriteAnim(sprite, 2); + gSprites[gObjectBankIDs[sprite->data6]].invisible = TRUE; + sprite->data5 = 0; + sprite->callback = sub_80467F8; + } + else + { + gSprites[gObjectBankIDs[sprite->data6]].data1 += 0x60; + gSprites[gObjectBankIDs[sprite->data6]].pos2.y = -gSprites[gObjectBankIDs[sprite->data6]].data1 >> 8; + } +} + +static void sub_80467F8(struct Sprite *sprite) +{ + if (sprite->animEnded) + { + sprite->data5++; + if (sprite->data5 == 1) + { + sprite->data3 = 0; + sprite->data4 = 32; + sprite->data5 = 0; + sprite->pos1.y += Cos(0, 32); + sprite->pos2.y = -Cos(0, sprite->data4); + sprite->callback = sub_804684C; + } + } +} + +static void sub_804684C(struct Sprite *sprite) +{ + bool8 r5 = FALSE; + + switch (sprite->data3 & 0xFF) + { + case 0: + sprite->pos2.y = -Cos(sprite->data5, sprite->data4); + sprite->data5 += 4 + (sprite->data3 >> 8); + if (sprite->data5 >= 64) + { + sprite->data4 -= 10; + sprite->data3 += 0x101; + if (sprite->data3 >> 8 == 4) + r5 = TRUE; + switch (sprite->data3 >> 8) + { + case 1: + PlaySE(SE_KON); + break; + case 2: + PlaySE(SE_KON2); + break; + case 3: + PlaySE(SE_KON3); + break; + default: + PlaySE(SE_KON4); + break; + } + } + break; + case 1: + sprite->pos2.y = -Cos(sprite->data5, sprite->data4); + sprite->data5 -= 4 + (sprite->data3 >> 8); + if (sprite->data5 <= 0) + { + sprite->data5 = 0; + sprite->data3 &= 0xFF00; + } + break; + } + if (r5) + { + sprite->data3 = 0; + sprite->pos1.y += Cos(64, 32); + sprite->pos2.y = 0; + if (sprite->data7 == 0) + { + sprite->callback = sub_8046C78; + } + else + { + sprite->callback = sub_8046944; + sprite->data4 = 1; + sprite->data5 = 0; + } + } +} + +static void sub_8046944(struct Sprite *sprite) +{ + sprite->data3++; + if (sprite->data3 == 31) + { + sprite->data3 = 0; + sprite->affineAnimPaused = TRUE; + StartSpriteAffineAnim(sprite, 1); + sprite->callback = sub_8046984; + PlaySE(SE_BOWA); + } +} + +static void sub_8046984(struct Sprite *sprite) +{ + switch (sprite->data3 & 0xFF) + { + case 0: + case 2: + sprite->pos2.x += sprite->data4; + sprite->data5 += sprite->data4; + sprite->affineAnimPaused = FALSE; + if (sprite->data5 > 3 || sprite->data5 < -3) + { + sprite->data3++; + sprite->data5 = 0; + } + break; + case 1: + sprite->data5++; + if (sprite->data5 == 1) + { + sprite->data5 = 0; + sprite->data4 = -sprite->data4; + sprite->data3++; + sprite->affineAnimPaused = FALSE; + if (sprite->data4 < 0) + ChangeSpriteAffineAnim(sprite, 2); + else + ChangeSpriteAffineAnim(sprite, 1); + } + else + { + sprite->affineAnimPaused = TRUE; + } + break; + case 3: + sprite->data3 += 0x100; + if (sprite->data3 >> 8 == sprite->data7) + { + sprite->callback = sub_8046C78; + } + else + { + if (sprite->data7 == 4 && sprite->data3 >> 8 == 3) + { + sprite->callback = sub_8046E7C; + sprite->affineAnimPaused = TRUE; + } + else + { + sprite->data3++; + sprite->affineAnimPaused = TRUE; + } + } + break; + case 4: + default: + sprite->data5++; + if (sprite->data5 == 31) + { + sprite->data5 = 0; + sprite->data3 &= 0xFF00; + StartSpriteAffineAnim(sprite, 3); + if (sprite->data4 < 0) + StartSpriteAffineAnim(sprite, 2); + else + StartSpriteAffineAnim(sprite, 1); + PlaySE(SE_BOWA); + } + break; + } +} + +static void sub_8046AD0(u8 taskId) +{ + u8 r6 = gTasks[taskId].data[2]; + u8 r3 = gTasks[taskId].data[1]; + u16 species = gTasks[taskId].data[0]; + + switch (gTasks[taskId].data[15]) + { + case 0: + default: + if (gTasks[taskId].data[8] < 3) + gTasks[taskId].data[8]++; + else + gTasks[taskId].data[15] = r6 + 1; + break; + case 1: + PlayCry1(species, r3); + DestroyTask(taskId); + break; + case 2: + StopCryAndClearCrySongs(); + gTasks[taskId].data[10] = 3; + gTasks[taskId].data[15] = 20; + break; + case 20: + if (gTasks[taskId].data[10] != 0) + { + gTasks[taskId].data[10]--; + break; + } + PlayCry4(species, r3, 1); + DestroyTask(taskId); + break; + case 3: + gTasks[taskId].data[10] = 6; + gTasks[taskId].data[15] = 30; + break; + case 30: + if (gTasks[taskId].data[10] != 0) + { + gTasks[taskId].data[10]--; + break; + } + gTasks[taskId].data[15]++; + // fall through + case 31: + if (!IsCryPlayingOrClearCrySongs()) + { + StopCryAndClearCrySongs(); + gTasks[taskId].data[10] = 3; + gTasks[taskId].data[15]++; + } + break; + case 32: + if (gTasks[taskId].data[10] != 0) + { + gTasks[taskId].data[10]--; + break; + } + PlayCry4(species, r3, 0); + DestroyTask(taskId); + break; + } +} + +static void sub_8046C78(struct Sprite *sprite) +{ + u8 r5 = sprite->data6; + u32 r4; // not sure of this type + + StartSpriteAnim(sprite, 1); + r4 = ball_number_to_ball_processing_index(sub_8047978(r5)); + sub_814086C(sprite->pos1.x, sprite->pos1.y - 5, 1, 0x1C, r4); + sprite->data0 = sub_8141314(1, sprite->data6, 14, r4); + sprite->callback = sub_8046E9C; + if (gMain.inBattle) + { + struct Pokemon *pkmn; + u16 species; + s8 r8; + u16 r4_2; + u8 taskId; + + if (GetBankSide(r5) != 0) + { + pkmn = &gEnemyParty[gBattlePartyID[r5]]; + r8 = 25; + } + else + { + pkmn = &gPlayerParty[gBattlePartyID[r5]]; + r8 = -25; + } + species = GetMonData(pkmn, MON_DATA_SPECIES); + if ((r5 == GetBankByPlayerAI(0) || r5 == GetBankByPlayerAI(1)) + && IsDoubleBattle() && ewram17840.unk9_0) + { + if (gBattleTypeFlags & BATTLE_TYPE_MULTI) + { + if (IsBGMPlaying()) + m4aMPlayStop(&gMPlay_BGM); + } + else + { + m4aMPlayVolumeControl(&gMPlay_BGM, 0xFFFF, 128); + } + } + if (!IsDoubleBattle() || !ewram17840.unk9_0) + r4_2 = 0; + else if (r5 == GetBankByPlayerAI(0) || r5 == GetBankByPlayerAI(1)) + r4_2 = 1; + else + r4_2 = 2; + taskId = CreateTask(sub_8046AD0, 3); + gTasks[taskId].data[0] = species; + gTasks[taskId].data[1] = r8; + gTasks[taskId].data[2] = r4_2; + gTasks[taskId].data[15] = 0; + } + StartSpriteAffineAnim(&gSprites[gObjectBankIDs[sprite->data6]], 1); + AnimateSprite(&gSprites[gObjectBankIDs[sprite->data6]]); + gSprites[gObjectBankIDs[sprite->data6]].data1 = 0x1000; +} + +static void sub_8046E7C(struct Sprite *sprite) +{ + sprite->animPaused = TRUE; + sprite->callback = sub_8046FBC; + sprite->data3 = 0; + sprite->data4 = 0; + sprite->data5 = 0; +} + +static void sub_8046E9C(struct Sprite *sprite) +{ + bool8 r7 = FALSE; + u8 r4 = sprite->data6; + + gSprites[gObjectBankIDs[r4]].invisible = FALSE; + if (sprite->animEnded) + sprite->invisible = TRUE; + if (gSprites[gObjectBankIDs[r4]].affineAnimEnded) + { + StartSpriteAffineAnim(&gSprites[gObjectBankIDs[r4]], 0); + r7 = TRUE; + } + else + { + gSprites[gObjectBankIDs[r4]].data1 -= 288; + gSprites[gObjectBankIDs[r4]].pos2.y = gSprites[gObjectBankIDs[r4]].data1 >> 8; + } + if (sprite->animEnded && r7) + { + s32 i; + u32 r3; + + gSprites[gObjectBankIDs[r4]].pos2.y = 0; + gDoingBattleAnim = 0; + ewram17810[r4].unk0_3 = 0; + FreeSpriteOamMatrix(sprite); + DestroySprite(sprite); + for (r3 = 0, i = 0; i < 4; i++) + { + if (ewram17810[i].unk0_3 == 0) + r3++; + } + if (r3 == 4) + { + for (i = 0; i < 12; i++) + sub_804794C(i); + } + } +} + +static void sub_8046FBC(struct Sprite *sprite) +{ + u8 r7 = sprite->data6; + + sprite->data4++; + if (sprite->data4 == 40) + { + return; + } + else if (sprite->data4 == 95) + { + gDoingBattleAnim = 0; + m4aMPlayAllStop(); + PlaySE(BGM_FANFA5); + } + else if (sprite->data4 == 315) + { + FreeOamMatrix(gSprites[gObjectBankIDs[sprite->data6]].oam.matrixNum); + DestroySprite(&gSprites[gObjectBankIDs[sprite->data6]]); + DestroySpriteAndFreeResources(sprite); + if (gMain.inBattle) + ewram17810[r7].unk0_3 = 0; + } +} + +static void sub_8047074(struct Sprite *sprite) +{ + sprite->data0 = 25; + sprite->data2 = sub_8077ABC(sprite->data6, 2); + sprite->data4 = sub_8077ABC(sprite->data6, 3) + 24; + sprite->data5 = -30; + sprite->oam.affineParam = sprite->data6; + sub_80786EC(sprite); + sprite->callback = sub_80470C4; +} + +#define HIBYTE(x) (((x) >> 8) & 0xFF) + +static void sub_80470C4(struct Sprite *sprite) +{ + u32 r6; + u32 r7; + + if (HIBYTE(sprite->data7) >= 35 && HIBYTE(sprite->data7) < 80) + { + s16 r4; + + if ((sprite->oam.affineParam & 0xFF00) == 0) + { + r6 = sprite->data1 & 1; + r7 = sprite->data2 & 1; + sprite->data1 = ((sprite->data1 / 3) & ~1) | r6; + sprite->data2 = ((sprite->data2 / 3) & ~1) | r7; + StartSpriteAffineAnim(sprite, 4); + } + r4 = sprite->data0; + sub_8078B5C(sprite); + sprite->data7 += sprite->data6 / 3; + sprite->pos2.y += Sin(HIBYTE(sprite->data7), sprite->data5); + sprite->oam.affineParam += 0x100; + if ((sprite->oam.affineParam >> 8) % 3 != 0) + sprite->data0 = r4; + else + sprite->data0 = r4 - 1; + if (HIBYTE(sprite->data7) >= 80) + { + r6 = sprite->data1 & 1; + r7 = sprite->data2 & 1; + sprite->data1 = ((sprite->data1 * 3) & ~1) | r6; + sprite->data2 = ((sprite->data2 * 3) & ~1) | r7; + } + } + else + { + if (sub_8078718(sprite)) + { + sprite->pos1.x += sprite->pos2.x; + sprite->pos1.y += sprite->pos2.y; + sprite->pos2.y = 0; + sprite->pos2.x = 0; + sprite->data6 = sprite->oam.affineParam & 0xFF; + sprite->data0 = 0; + if (IsDoubleBattle() && ewram17840.unk9_0 + && sprite->data6 == GetBankByPlayerAI(2)) + sprite->callback = sub_8047230; + else + sprite->callback = sub_8046C78; + StartSpriteAffineAnim(sprite, 0); + } + } +} + +static void sub_8047230(struct Sprite *sprite) +{ + if (sprite->data0++ > 24) + { + sprite->data0 = 0; + sprite->callback = sub_8046C78; + } +} + +static void sub_8047254(struct Sprite *sprite) +{ + sprite->data0++; + if (sprite->data0 > 15) + { + sprite->data0 = 0; + if (IsDoubleBattle() && ewram17840.unk9_0 + && sprite->data6 == GetBankByPlayerAI(3)) + sprite->callback = sub_8047230; + else + sprite->callback = sub_8046C78; + } +} + +static u8 sub_80472B0(u8 a, u8 b, u8 c, u8 d) +{ + return sub_814086C(a, b, c, d, 0); +} + +static u8 sub_80472D8(u8 a, u8 b, u32 c) +{ + return sub_8141314(a, b, c, 0); +} + +void CreatePokeballSprite(u8 a, u8 b, u8 x, u8 y, u8 e, u8 f, u8 g, u32 h) +{ + u8 spriteId; + + LoadCompressedObjectPic(&sBallSpriteSheets[0]); + LoadCompressedObjectPalette(&sBallSpritePalettes[0]); + spriteId = CreateSprite(&gBallSpriteTemplates[0], x, y, f); + gSprites[spriteId].data0 = a; + gSprites[spriteId].data5 = gSprites[a].pos1.x; + gSprites[spriteId].data6 = gSprites[a].pos1.y; + gSprites[a].pos1.x = x; + gSprites[a].pos1.y = y; + gSprites[spriteId].data1 = g; + gSprites[spriteId].data2 = b; + gSprites[spriteId].data3 = h; + gSprites[spriteId].data4 = h >> 16; + gSprites[spriteId].oam.priority = e; + gSprites[spriteId].callback = sub_80473D0; + gSprites[a].invisible = TRUE; +} + +static void sub_80473D0(struct Sprite *sprite) +{ + if (sprite->data1 == 0) + { + u8 r5; + u8 r7 = sprite->data0; + u8 r8 = sprite->data2; + u32 r4 = (u16)sprite->data3 | ((u16)sprite->data4 << 16); + + if (sprite->subpriority != 0) + r5 = sprite->subpriority - 1; + else + r5 = 0; + StartSpriteAnim(sprite, 1); + sub_80472B0(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r5); + sprite->data1 = sub_80472D8(1, r8, r4); + sprite->callback = sub_804748C; + gSprites[r7].invisible = FALSE; + StartSpriteAffineAnim(&gSprites[r7], 1); + AnimateSprite(&gSprites[r7]); + gSprites[r7].data1 = 0x1000; + sprite->data7 = 0; + } + else + { + sprite->data1--; + } +} + +static void sub_804748C(struct Sprite *sprite) +{ + bool8 r12 = FALSE; + bool8 r6 = FALSE; + u8 r3 = sprite->data0; + u16 var1; + u16 var2; + + if (sprite->animEnded) + sprite->invisible = TRUE; + if (gSprites[r3].affineAnimEnded) + { + StartSpriteAffineAnim(&gSprites[r3], 0); + r12 = TRUE; + } + var1 = (sprite->data5 - sprite->pos1.x) * sprite->data7 / 128 + sprite->pos1.x; + var2 = (sprite->data6 - sprite->pos1.y) * sprite->data7 / 128 + sprite->pos1.y; + gSprites[r3].pos1.x = var1; + gSprites[r3].pos1.y = var2; + if (sprite->data7 < 128) + { + s16 sine = -(gSineTable[(u8)sprite->data7] / 8); + + sprite->data7 += 4; + gSprites[r3].pos2.x = sine; + gSprites[r3].pos2.y = sine; + } + else + { + gSprites[r3].pos1.x = sprite->data5; + gSprites[r3].pos1.y = sprite->data6; + gSprites[r3].pos2.x = 0; + gSprites[r3].pos2.y = 0; + r6 = TRUE; + } + if (sprite->animEnded && r12 && r6) + DestroySpriteAndFreeResources(sprite); +} + +u8 sub_8047580(u8 a, u8 b, u8 x, u8 y, u8 e, u8 f, u8 g, u32 h) +{ + u8 spriteId; + + LoadCompressedObjectPic(&sBallSpriteSheets[0]); + LoadCompressedObjectPalette(&sBallSpritePalettes[0]); + spriteId = CreateSprite(&gBallSpriteTemplates[0], x, y, f); + gSprites[spriteId].data0 = a; + gSprites[spriteId].data1 = g; + gSprites[spriteId].data2 = b; + gSprites[spriteId].data3 = h; + gSprites[spriteId].data4 = h >> 16; + gSprites[spriteId].oam.priority = e; + gSprites[spriteId].callback = sub_8047638; + return spriteId; +} + +static void sub_8047638(struct Sprite *sprite) +{ + if (sprite->data1 == 0) + { + u8 r6; + u8 r7 = sprite->data0; + u8 r8 = sprite->data2; + u32 r5 = (u16)sprite->data3 | ((u16)sprite->data4 << 16); + + if (sprite->subpriority != 0) + r6 = sprite->subpriority - 1; + else + r6 = 0; + StartSpriteAnim(sprite, 1); + sub_80472B0(sprite->pos1.x, sprite->pos1.y - 5, sprite->oam.priority, r6); + sprite->data1 = sub_80472D8(1, r8, r5); + sprite->callback = sub_80476E0; + StartSpriteAffineAnim(&gSprites[r7], 2); + AnimateSprite(&gSprites[r7]); + gSprites[r7].data1 = 0; + } + else + { + sprite->data1--; + } +} + +static void sub_80476E0(struct Sprite *sprite) +{ + u8 r1; + + sprite->data5++; + if (sprite->data5 == 11) + PlaySE(SE_SUIKOMU); + r1 = sprite->data0; + if (gSprites[r1].affineAnimEnded) + { + StartSpriteAnim(sprite, 2); + gSprites[r1].invisible = TRUE; + sprite->data5 = 0; + sprite->callback = sub_8047754; + } + else + { + gSprites[r1].data1 += 96; + gSprites[r1].pos2.y = -gSprites[r1].data1 >> 8; + } +} + +static void sub_8047754(struct Sprite *sprite) +{ + if (sprite->animEnded) + sprite->callback = SpriteCallbackDummy; +} + +void obj_delete_and_free_associated_resources_(struct Sprite *sprite) +{ + DestroySpriteAndFreeResources(sprite); +} + +void sub_804777C(u8 a) +{ + struct Sprite *sprite = &gSprites[gHealthboxIDs[a]]; + + sprite->data0 = 5; + sprite->data1 = 0; + sprite->pos2.x = 0x73; + sprite->pos2.y = 0; + sprite->callback = sub_8047830; + if (GetBankSide(a) != 0) + { + sprite->data0 = -sprite->data0; + sprite->data1 = -sprite->data1; + sprite->pos2.x = -sprite->pos2.x; + sprite->pos2.y = -sprite->pos2.y; + } + gSprites[sprite->data5].callback(&gSprites[sprite->data5]); + if (GetBankIdentity(a) == 2) + sprite->callback = sub_804780C; +} + +static void sub_804780C(struct Sprite *sprite) +{ + sprite->data1++; + if (sprite->data1 == 20) + { + sprite->data1 = 0; + sprite->callback = sub_8047830; + } +} + +static void sub_8047830(struct Sprite *sprite) +{ + sprite->pos2.x -= sprite->data0; + sprite->pos2.y -= sprite->data1; + if (sprite->pos2.x == 0 && sprite->pos2.y == 0) + sprite->callback = SpriteCallbackDummy; +} + +void sub_8047858(u8 a) +{ + u8 spriteId; + + spriteId = CreateInvisibleSpriteWithCallback(oamc_804BEB4); + gSprites[spriteId].data0 = 1; + gSprites[spriteId].data1 = gHealthboxIDs[a]; + gSprites[spriteId].callback = oamc_804BEB4; +} + +static void oamc_804BEB4(struct Sprite *sprite) +{ + u8 r1 = sprite->data1; + + gSprites[r1].pos2.y = sprite->data0; + sprite->data0 = -sprite->data0; + sprite->data2++; + if (sprite->data2 == 21) + { + gSprites[r1].pos2.x = 0; + gSprites[r1].pos2.y = 0; + DestroySprite(sprite); + } +} + +void sub_80478DC(u8 a) +{ + u16 var; + + if (GetSpriteTileStartByTag(sBallSpriteSheets[a].tag) == 0xFFFF) + { + LoadCompressedObjectPic(&sBallSpriteSheets[a]); + LoadCompressedObjectPalette(&sBallSpritePalettes[a]); + } + switch (a) + { + case 6: + case 10: + case 11: + break; + default: + var = GetSpriteTileStartByTag(sBallSpriteSheets[a].tag); + LZDecompressVram(gUnknown_08D030D0, (void *)(VRAM + 0x10100 + var * 32)); + break; + } +} + +void sub_804794C(u8 a) +{ + FreeSpriteTilesByTag(sBallSpriteSheets[a].tag); + FreeSpritePaletteByTag(sBallSpritePalettes[a].tag); +} + +static u16 sub_8047978(u8 a) +{ + if (GetBankSide(a) == 0) + return GetMonData(&gPlayerParty[gBattlePartyID[a]], MON_DATA_POKEBALL); + else + return GetMonData(&gEnemyParty[gBattlePartyID[a]], MON_DATA_POKEBALL); +} diff --git a/src/pokedex.c b/src/pokedex.c index 8674c3d2b..17ae9a597 100644 --- a/src/pokedex.c +++ b/src/pokedex.c @@ -162,7 +162,7 @@ extern const u8 gUnknown_08E96ACC[]; extern const u8 gUnknown_08E96B58[]; extern const u16 gPokedexMenu_Pal[]; extern const u16 gPokedexMenu2_Pal[]; -extern const struct SpriteSheet gTrainerFrontPicTable[]; +extern const struct CompressedSpriteSheet gTrainerFrontPicTable[]; extern const struct MonCoords gTrainerFrontPicCoords[]; extern const struct PokedexEntry gPokedexEntries[]; extern const u8 gPokedexMenuSearch_Gfx[]; @@ -493,7 +493,7 @@ static const struct SpriteTemplate gSpriteTemplate_83A05B4 = .affineAnims = gDummySpriteAffineAnimTable, .callback = sub_808F168, }; -static const struct SpriteSheet gUnknown_083A05CC[] = +static const struct CompressedSpriteSheet gUnknown_083A05CC[] = { {gPokedexMenu2_Gfx, 0x1F00, 0x1000}, {NULL, 0, 0}, @@ -3921,7 +3921,7 @@ static void sub_8090B8C(u8 taskId) u32 otId; u32 personality; u8 paletteNum; - const u16 *palette; + const u8 *lzPaletteData; REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; CpuCopy16(gUnknown_08D00524, (void *)(VRAM + 0xC000), 0x1000); @@ -3930,8 +3930,8 @@ static void sub_8090B8C(u8 taskId) otId = ((u16)gTasks[taskId].data[13] << 16) | (u16)gTasks[taskId].data[12]; personality = ((u16)gTasks[taskId].data[15] << 16) | (u16)gTasks[taskId].data[14]; paletteNum = gSprites[gTasks[taskId].data[3]].oam.paletteNum; - palette = species_and_otid_get_pal(species, otId, personality); - LoadCompressedPalette(palette, 0x100 | paletteNum * 16, 32); + lzPaletteData = species_and_otid_get_pal(species, otId, personality); + LoadCompressedPalette(lzPaletteData, 0x100 | paletteNum * 16, 32); DestroyTask(taskId); } } diff --git a/src/pokemon_3.c b/src/pokemon_3.c index ef9a1698d..cb8eb2a46 100644 --- a/src/pokemon_3.c +++ b/src/pokemon_3.c @@ -1172,7 +1172,7 @@ void current_map_music_set__default_for_battle(u16 song) PlayNewMapMusic(sub_8040728()); } -const u16 *pokemon_get_pal(struct Pokemon *mon) +const u8 *pokemon_get_pal(struct Pokemon *mon) { u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); @@ -1186,7 +1186,7 @@ const u16 *pokemon_get_pal(struct Pokemon *mon) //Extracts the lower 16 bits of a 32-bit number #define LOHALF(n) ((n) & 0xFFFF) -const u16 *species_and_otid_get_pal(u16 species, u32 otId, u32 personality) +const u8 *species_and_otid_get_pal(u16 species, u32 otId, u32 personality) { u32 shinyValue; @@ -1200,7 +1200,7 @@ const u16 *species_and_otid_get_pal(u16 species, u32 otId, u32 personality) return gMonPaletteTable[species].data; } -const struct SpritePalette *sub_8040990(struct Pokemon *mon) +const struct CompressedSpritePalette *sub_8040990(struct Pokemon *mon) { u16 species = GetMonData(mon, MON_DATA_SPECIES2, 0); u32 otId = GetMonData(mon, MON_DATA_OT_ID, 0); @@ -1208,7 +1208,7 @@ const struct SpritePalette *sub_8040990(struct Pokemon *mon) return sub_80409C8(species, otId, personality); } -const struct SpritePalette *sub_80409C8(u16 species, u32 otId , u32 personality) +const struct CompressedSpritePalette *sub_80409C8(u16 species, u32 otId , u32 personality) { u32 shinyValue; diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index fb72be527..cbca07011 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -31,7 +31,7 @@ extern struct SpriteTemplate gUnknown_02024E8C; extern u8 gContestPlayerMonIndex; extern u8 gIsLinkContest; extern u8 gPlayerPartyCount; -extern u8 gBufferedMoves[]; +extern u8 gSelectedOrderFromParty[]; extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; @@ -407,7 +407,7 @@ u8 sub_80C5044(void) void ShowContestEntryMonPic(void) { - struct SpritePalette *paletteData; + const struct CompressedSpritePalette *palette; u32 var1, var2; u16 species; u8 spriteId; @@ -425,13 +425,18 @@ void ShowContestEntryMonPic(void) taskId = CreateTask(sub_80C5190, 0x50); gTasks[taskId].data[0] = 0; gTasks[taskId].data[1] = species; - HandleLoadSpecialPokePic((struct SpriteSheet *)&gMonFrontPicTable[species].data, - gMonFrontPicCoords[species].coords, gMonFrontPicCoords[species].y_offset, - (u32)gUnknown_081FAF4C[0], gUnknown_081FAF4C[1], species, var1); - paletteData = (struct SpritePalette *) sub_80409C8(species, var2, var1); - LoadCompressedObjectPalette(paletteData); + HandleLoadSpecialPokePic( + &gMonFrontPicTable[species], + gMonFrontPicCoords[species].coords, + gMonFrontPicCoords[species].y_offset, + (u32)gUnknown_081FAF4C[0], + gUnknown_081FAF4C[1], + species, + var1); + palette = sub_80409C8(species, var2, var1); + LoadCompressedObjectPalette(palette); GetMonSpriteTemplate_803C56C(species, 1); - gUnknown_02024E8C.paletteTag = paletteData->tag; + gUnknown_02024E8C.paletteTag = palette->tag; spriteId = CreateSprite(&gUnknown_02024E8C, 0x78, 0x40, 0); gTasks[taskId].data[2] = spriteId; gTasks[taskId].data[3] = left; @@ -648,7 +653,7 @@ void sub_80C5568(void) void sub_80C5580(void) { - u8 var = gBufferedMoves[0]; + u8 var = gSelectedOrderFromParty[0]; switch(var) { @@ -671,7 +676,7 @@ void ChooseBattleTowerPlayerParty(void) void SetBattleTowerPlayerParty(void) { - u8 var = gBufferedMoves[0]; + u8 var = gSelectedOrderFromParty[0]; switch(var) { @@ -697,8 +702,8 @@ void ReducePlayerPartyToThree(void) // copy the selected pokemon according to the order. for(i = 0; i < 3; i++) - if(gBufferedMoves[i]) // as long as the order keeps going (did the player select 1 mon? 2? 3?), do not stop - party[i] = gPlayerParty[gBufferedMoves[i] - 1]; // index is 0 based, not literal + if(gSelectedOrderFromParty[i]) // as long as the order keeps going (did the player select 1 mon? 2? 3?), do not stop + party[i] = gPlayerParty[gSelectedOrderFromParty[i] - 1]; // index is 0 based, not literal // delete the last 3 pokemon CpuFill32(0, gPlayerParty, sizeof gPlayerParty); diff --git a/src/script_pokemon_util_80F99CC.c b/src/script_pokemon_util_80F99CC.c index 606cd9dd4..2b48cc0d8 100644 --- a/src/script_pokemon_util_80F99CC.c +++ b/src/script_pokemon_util_80F99CC.c @@ -3,6 +3,7 @@ #include "choose_party.h" #include "contest.h" #include "data2.h" +#include "party_menu.h" #include "field_fadetransition.h" #include "palette.h" #include "party_menu.h" @@ -16,6 +17,8 @@ #include "task.h" #include "text.h" + + extern u8 gPlayerPartyCount; extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; diff --git a/src/starter_choose.c b/src/starter_choose.c index f30be8e08..c838f2dc0 100644 --- a/src/starter_choose.c +++ b/src/starter_choose.c @@ -172,12 +172,12 @@ static const union AffineAnimCmd *const gSpriteAffineAnimTable_83F7790[] = { gSpriteAffineAnim_83F7774, }; -static const struct SpriteSheet gUnknown_083F7794[] = +static const struct CompressedSpriteSheet gUnknown_083F7794[] = { {gBirchBallarrow_Gfx, 0x0800, 0x1000}, {NULL}, }; -static const struct SpriteSheet gUnknown_083F77A4[] = +static const struct CompressedSpriteSheet gUnknown_083F77A4[] = { {gBirchCircle_Gfx, 0x0800, 0x1001}, {NULL}, diff --git a/src/text.c b/src/text.c index 02cafea48..b27084b86 100644 --- a/src/text.c +++ b/src/text.c @@ -218,12 +218,14 @@ static const u8 sFont1JapaneseGlyphs[] = INCBIN_U8("graphics/fonts/font1_jpn.1bp static const u8 sBrailleGlyphs[] = INCBIN_U8("graphics/fonts/font6_braille.1bpp"); static const u32 sDownArrowTiles[] = INCBIN_U32("graphics/fonts/down_arrow.4bpp"); -#include "fonts/type1_map.h" -#include "fonts/type3_map.h" -#include "fonts/font1_widths.h" -#include "fonts/font4_widths.h" -#include "fonts/font0_widths.h" -#include "fonts/font3_widths.h" +// clang-format off +#include "data/text/type1_map.h" +#include "data/text/type3_map.h" +#include "data/text/font1_widths.h" +#include "data/text/font4_widths.h" +#include "data/text/font0_widths.h" +#include "data/text/font3_widths.h" +// clang-format on const u16 gUnknownPalette_81E6692[] = INCBIN_U16("graphics/fonts/unknown_81E6692.gbapal"); const u16 gFontDefaultPalette[] = INCBIN_U16("graphics/fonts/default.gbapal"); diff --git a/src/title_screen.c b/src/title_screen.c index 12c31d10a..dd06956c3 100644 --- a/src/title_screen.c +++ b/src/title_screen.c @@ -152,7 +152,7 @@ static const struct SpriteTemplate sVersionBannerRightSpriteTemplate = .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallback_VersionBannerRight, }; -static const struct SpriteSheet gUnknown_08393EFC[] = +static const struct CompressedSpriteSheet gUnknown_08393EFC[] = { {gVersionTiles, 0x1000, 1000}, {NULL}, @@ -234,7 +234,7 @@ static const struct SpriteTemplate sStartCopyrightBannerSpriteTemplate = .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallback_PressStartCopyrightBanner, }; -static const struct SpriteSheet gUnknown_08393F8C[] = +static const struct CompressedSpriteSheet gUnknown_08393F8C[] = { {gTitleScreenPressStart_Gfx, 0x520, 1001}, {NULL}, @@ -279,7 +279,7 @@ static const struct SpriteTemplate sPokemonLogoShineSpriteTemplate = .affineAnims = gDummySpriteAffineAnimTable, .callback = SpriteCallback_PokemonLogoShine, }; -static const struct SpriteSheet sPokemonLogoShineSpriteSheet[] = +static const struct CompressedSpriteSheet sPokemonLogoShineSpriteSheet[] = { {sLogoShineTiles, 0x800, 1002}, {NULL}, diff --git a/src/wallclock.c b/src/wallclock.c index efc7dd42a..8db13dc2d 100644 --- a/src/wallclock.c +++ b/src/wallclock.c @@ -24,7 +24,7 @@ extern u16 gMiscClockFemale_Pal[]; //-------------------------------------------------- static const u8 ClockGfx_Misc[] = INCBIN_U8("graphics/misc/clock_misc.4bpp.lz"); -static const struct SpriteSheet gUnknown_083F7A90[] = +static const struct CompressedSpriteSheet gUnknown_083F7A90[] = { {ClockGfx_Misc, 0x2000, 0x1000}, {NULL}, |