Document pokedex.c

This commit is contained in:
GriffinR 2020-03-08 13:24:22 -04:00
parent c805c4cc6f
commit 31b0cbe9b4
29 changed files with 3668 additions and 3304 deletions

View File

@ -1,2 +1,2 @@
gUnusedPokedexU8 gUnusedPokedexU8
gUnknown_030060B4 gPokedexVBlankCB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

File diff suppressed because it is too large Load Diff

View File

@ -3282,25 +3282,24 @@ extern const u32 gBattleTerrainPalette_StadiumDrake[];
extern const u32 gBattleTerrainPalette_StadiumWallace[]; extern const u32 gBattleTerrainPalette_StadiumWallace[];
// pokedex // pokedex
extern const u32 gPokedexMenu2_Gfx[]; extern const u32 gPokedexInterface_Gfx[];
extern const u16 gPokedexText_Pal[]; extern const u16 gPokedexBgHoenn_Pal[];
extern const u32 gPokedexMenu_Gfx[]; extern const u32 gPokedexMenu_Gfx[];
extern const u8 gPokedexTilemap_Main[]; extern const u8 gPokedexList_Tilemap[];
extern const u8 gPokedexTilemap_MainUnderlay[]; extern const u8 gPokedexListUnderlay_Tilemap[];
extern const u8 gPokedexTilemap_StartMenu1[]; extern const u8 gPokedexStartMenuMain_Tilemap[];
extern const u8 gPokedexTilemap_StartMenu2[]; extern const u8 gPokedexStartMenuSearchResults_Tilemap[];
extern const u16 gPokedexHoennBg_Pal[]; extern const u16 gPokedexSearchResults_Pal[];
extern const u16 gPokedexText_Pal[]; extern const u16 gPokedexBgNational_Pal[];
extern const u16 gPokedexNationalBg_Pal[]; extern const u8 gPokedexInfoScreen_Tilemap[];
extern const u8 gPokedexTilemap_DescriptionScreen[]; extern const u8 gPokedexCryScreen_Tilemap[];
extern const u8 gPokedexTilemap_CryScreen[]; extern const u8 gPokedexSizeScreen_Tilemap[];
extern const u8 gPokedexTilemap_SizeScreen[]; extern const u8 gPokedexScreenSelectBarMain_Tilemap[];
extern const u8 gPokedexTilemap_ScreenSelectBar1[]; extern const u8 gPokedexScreenSelectBarSubmenu_Tilemap[];
extern const u8 gPokedexTilemap_ScreenSelectBar2[]; extern const u16 gPokedexCaughtScreen_Pal[];
extern const u16 gPokedexCaughtScreenFade_Pal[];
extern const u32 gPokedexSearchMenu_Gfx[]; extern const u32 gPokedexSearchMenu_Gfx[];
extern const u32 gPokedexSearch2_Tilemap[]; extern const u32 gPokedexSearchMenuHoenn_Tilemap[];
extern const u32 gPokedexSearch1_Tilemap[]; extern const u32 gPokedexSearchMenuNational_Tilemap[];
extern const u16 gPokedexSearchMenu_Pal[]; extern const u16 gPokedexSearchMenu_Pal[];
// berry tag screen // berry tag screen

View File

@ -2,11 +2,7 @@
#define GUARD_POKEDEX_H #define GUARD_POKEDEX_H
extern u8 gUnusedPokedexU8; extern u8 gUnusedPokedexU8;
extern void (*gUnknown_030060B4)(void); extern void (*gPokedexVBlankCB)(void);
#define KANTO_DEX_COUNT 151
#define HOENN_DEX_COUNT 202
#define NATIONAL_DEX_COUNT 386
enum enum
{ {
@ -39,12 +35,12 @@ void ResetPokedex(void);
u16 GetPokedexHeightWeight(u16 dexNum, u8 data); u16 GetPokedexHeightWeight(u16 dexNum, u8 data);
u16 GetNationalPokedexCount(u8); u16 GetNationalPokedexCount(u8);
u16 GetHoennPokedexCount(u8); u16 GetHoennPokedexCount(u8);
u8 CreateDexDisplayMonDataTask(u16 dexNum, u32 trainerId, u32 personality); u8 DisplayCaughtMonDexPage(u16 dexNum, u32 otId, u32 personality);
s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId); s8 GetSetPokedexFlag(u16 nationalNum, u8 caseId);
u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16); u16 CreateMonSpriteFromNationalDexNumber(u16, s16, s16, u16);
bool16 HasAllHoennMons(void); bool16 HasAllHoennMons(void);
void ResetPokedexScrollPositions(void); void ResetPokedexScrollPositions(void);
bool16 HasAllMons(void); bool16 HasAllMons(void);
void CB2_Pokedex(void); void CB2_OpenPokedex(void);
#endif // GUARD_POKEDEX_H #endif // GUARD_POKEDEX_H

View File

@ -3,8 +3,8 @@
struct CryRelatedStruct struct CryRelatedStruct
{ {
u16 unk0; u16 unk0; // Assigned to val that's never read
u8 unk2; u8 unk2; // Never read
u8 paletteNo; u8 paletteNo;
u8 xPos; u8 xPos;
u8 yPos; u8 yPos;
@ -12,10 +12,10 @@ struct CryRelatedStruct
extern u8 gDexCryScreenState; extern u8 gDexCryScreenState;
bool8 sub_8145354(struct CryRelatedStruct*, u8); bool8 LoadCryWaveformWindow(struct CryRelatedStruct*, u8);
void sub_814545C(u8); void UpdateCryWaveformWindow(u8);
void sub_8145534(u16); void CryScreenPlayButton(u16);
bool8 sub_8145850(struct CryRelatedStruct*, u8); bool8 LoadCryMeter(struct CryRelatedStruct*, u8);
void sub_8145914(void); void FreeCryScreen(void);
#endif #endif

View File

@ -10263,7 +10263,7 @@ static void Cmd_displaydexinfo(void)
if (!gPaletteFade.active) if (!gPaletteFade.active)
{ {
FreeAllWindowBuffers(); FreeAllWindowBuffers();
gBattleCommunication[TASK_ID] = CreateDexDisplayMonDataTask(SpeciesToNationalPokedexNum(species), gBattleCommunication[TASK_ID] = DisplayCaughtMonDexPage(SpeciesToNationalPokedexNum(species),
gBattleMons[gBattlerTarget].otId, gBattleMons[gBattlerTarget].otId,
gBattleMons[gBattlerTarget].personality); gBattleMons[gBattlerTarget].personality);
gBattleCommunication[0]++; gBattleCommunication[0]++;

View File

@ -23,6 +23,7 @@
#include "constants/vars.h" #include "constants/vars.h"
#include "event_data.h" #include "event_data.h"
#include "random.h" #include "random.h"
#include "constants/species.h"
enum enum
{ {

View File

@ -1257,32 +1257,27 @@ const u16 gFrontierPassMapCursor_Pal[] = INCBIN_U16("graphics/frontier_pass/map_
const u16 gFrontierPassMedalsSilver_Pal[] = INCBIN_U16("graphics/frontier_pass/silver.gbapal"); const u16 gFrontierPassMedalsSilver_Pal[] = INCBIN_U16("graphics/frontier_pass/silver.gbapal");
const u16 gFrontierPassMedalsGold_Pal[] = INCBIN_U16("graphics/frontier_pass/gold.gbapal"); const u16 gFrontierPassMedalsGold_Pal[] = INCBIN_U16("graphics/frontier_pass/gold.gbapal");
const u16 gPokedexText_Pal[] = INCBIN_U16("graphics/pokedex/text.gbapal"); // Pokedex
const u16 gPokedexBgHoenn_Pal[] = INCBIN_U16("graphics/pokedex/bg_hoenn.gbapal");
const u16 gPokedexCaughtScreenFade_Pal[] = INCBIN_U16("graphics/pokedex/fade.gbapal"); const u16 gPokedexCaughtScreen_Pal[] = INCBIN_U16("graphics/pokedex/caught_screen.gbapal");
const u16 gPokedexSearchResults_Pal[] = INCBIN_U16("graphics/pokedex/search_results_bg.gbapal");
const u16 gPokedexHoennBg_Pal[] = INCBIN_U16("graphics/pokedex/hoenn_bg.gbapal"); const u16 gPokedexBgNational_Pal[] = INCBIN_U16("graphics/pokedex/bg_national.gbapal");
const u16 gPokedexNationalBg_Pal[] = INCBIN_U16("graphics/pokedex/national_bg.gbapal");
const u32 gPokedexMenu_Gfx[] = INCBIN_U32("graphics/pokedex/menu.4bpp.lz"); const u32 gPokedexMenu_Gfx[] = INCBIN_U32("graphics/pokedex/menu.4bpp.lz");
const u32 gPokedexMenu2_Gfx[] = INCBIN_U32("graphics/pokedex/menu2.4bpp.lz"); const u32 gPokedexInterface_Gfx[] = INCBIN_U32("graphics/pokedex/interface.4bpp.lz");
const u32 gUnused_PokedexNoBall[] = INCBIN_U32("graphics/pokedex/noball_unused.4bpp.lz"); const u32 gUnused_PokedexNoBall[] = INCBIN_U32("graphics/pokedex/noball_unused.4bpp.lz");
const u32 gPokedexStartMenuMain_Tilemap[] = INCBIN_U32("graphics/pokedex/start_menu_main.bin.lz");
const u32 gPokedexTilemap_StartMenu1[] = INCBIN_U32("graphics/pokedex/tilemap1.bin.lz"); const u32 gPokedexStartMenuSearchResults_Tilemap[] = INCBIN_U32("graphics/pokedex/start_menu_search_results.bin.lz");
const u32 gPokedexTilemap_StartMenu2[] = INCBIN_U32("graphics/pokedex/tilemap2.bin.lz"); const u32 gPokedexList_Tilemap[] = INCBIN_U32("graphics/pokedex/list.bin.lz");
const u32 gPokedexTilemap_Main[] = INCBIN_U32("graphics/pokedex/tilemap3.bin.lz"); const u32 gPokedexListUnderlay_Tilemap[] = INCBIN_U32("graphics/pokedex/list_underlay.bin.lz");
const u32 gPokedexTilemap_MainUnderlay[] = INCBIN_U32("graphics/pokedex/tilemap4.bin.lz"); const u32 gPokedexSizeScreen_Tilemap[] = INCBIN_U32("graphics/pokedex/size_screen.bin.lz");
const u32 gPokedexTilemap_SizeScreen[] = INCBIN_U32("graphics/pokedex/tilemap5.bin.lz"); const u32 gPokedexScreenSelectBarMain_Tilemap[] = INCBIN_U32("graphics/pokedex/screen_select_bar_main.bin.lz");
const u32 gPokedexTilemap_ScreenSelectBar1[] = INCBIN_U32("graphics/pokedex/tilemap6.bin.lz"); const u32 gPokedexScreenSelectBarSubmenu_Tilemap[] = INCBIN_U32("graphics/pokedex/screen_select_bar_submenu.bin.lz");
const u32 gPokedexTilemap_ScreenSelectBar2[] = INCBIN_U32("graphics/pokedex/tilemap7.bin.lz"); const u32 gPokedexInfoScreen_Tilemap[] = INCBIN_U32("graphics/pokedex/info_screen.bin.lz");
const u32 gPokedexTilemap_DescriptionScreen[] = INCBIN_U32("graphics/pokedex/tilemap8.bin.lz"); const u32 gPokedexCryScreen_Tilemap[] = INCBIN_U32("graphics/pokedex/cry_screen.bin.lz");
const u32 gPokedexTilemap_CryScreen[] = INCBIN_U32("graphics/pokedex/tilemap9.bin.lz");
const u16 gPokedexSearchMenu_Pal[] = INCBIN_U16("graphics/pokedex/search_menu.gbapal"); const u16 gPokedexSearchMenu_Pal[] = INCBIN_U16("graphics/pokedex/search_menu.gbapal");
const u32 gPokedexSearchMenu_Gfx[] = INCBIN_U32("graphics/pokedex/search_menu.4bpp.lz"); const u32 gPokedexSearchMenu_Gfx[] = INCBIN_U32("graphics/pokedex/search_menu.4bpp.lz");
const u32 gPokedexSearch1_Tilemap[] = INCBIN_U32("graphics/pokedex/search1.bin.lz"); const u32 gPokedexSearchMenuNational_Tilemap[] = INCBIN_U32("graphics/pokedex/search_menu_national.bin.lz");
const u32 gPokedexSearch2_Tilemap[] = INCBIN_U32("graphics/pokedex/search2.bin.lz"); const u32 gPokedexSearchMenuHoenn_Tilemap[] = INCBIN_U32("graphics/pokedex/search_menu_hoenn.bin.lz");
const u16 gSummaryScreenPowAcc_Tilemap[] = INCBIN_U16("graphics/interface/powacc_tilemap.bin"); const u16 gSummaryScreenPowAcc_Tilemap[] = INCBIN_U16("graphics/interface/powacc_tilemap.bin");

File diff suppressed because it is too large Load Diff

View File

@ -66,7 +66,7 @@ struct PokeDexAreaScreen
/*0x6E0*/ u16 numAreaMarkerSprites; /*0x6E0*/ u16 numAreaMarkerSprites;
/*0x6E2*/ u16 unk6E2; /*0x6E2*/ u16 unk6E2;
/*0x6E4*/ u16 unk6E4; /*0x6E4*/ u16 unk6E4;
/*0x6E8*/ u8 *errno; /*0x6E8*/ u8 *screenSwitchState;
/*0x6EC*/ struct RegionMap regionMap; /*0x6EC*/ struct RegionMap regionMap;
/*0xF70*/ u8 charBuffer[0x40]; /*0xF70*/ u8 charBuffer[0x40];
/*0xFB0*/ struct Sprite * areaUnknownSprites[3]; /*0xFB0*/ struct Sprite * areaUnknownSprites[3];
@ -83,11 +83,11 @@ static u16 GetRegionMapSectionId(u8, u8);
static bool8 MapHasMon(const struct WildPokemonHeader *, u16); static bool8 MapHasMon(const struct WildPokemonHeader *, u16);
static bool8 MonListHasMon(const struct WildPokemonInfo *, u16, u16); static bool8 MonListHasMon(const struct WildPokemonInfo *, u16, u16);
static void DoAreaGlow(void); static void DoAreaGlow(void);
static void Task_PokedexAreaScreen_0(u8); static void Task_ShowPokedexAreaScreen(u8);
static void CreateAreaMarkerSprites(void); static void CreateAreaMarkerSprites(void);
static void LoadAreaUnknownGraphics(void); static void LoadAreaUnknownGraphics(void);
static void CreateAreaUnknownSprites(void); static void CreateAreaUnknownSprites(void);
static void Task_PokedexAreaScreen_1(u8); static void Task_HandlePokedexAreaScreenInput(u8);
static void sub_813D6B4(void); static void sub_813D6B4(void);
static void DestroyAreaMarkerSprites(void); static void DestroyAreaMarkerSprites(void);
@ -637,21 +637,23 @@ static void DoAreaGlow(void)
} }
} }
void ShowPokedexAreaScreen(u16 species, u8 *errno) #define tState data[0]
void ShowPokedexAreaScreen(u16 species, u8 *screenSwitchState)
{ {
u8 taskId; u8 taskId;
sPokedexAreaScreen = AllocZeroed(sizeof(*sPokedexAreaScreen)); sPokedexAreaScreen = AllocZeroed(sizeof(*sPokedexAreaScreen));
sPokedexAreaScreen->species = species; sPokedexAreaScreen->species = species;
sPokedexAreaScreen->errno = errno; sPokedexAreaScreen->screenSwitchState = screenSwitchState;
errno[0] = 0; screenSwitchState[0] = 0;
taskId = CreateTask(Task_PokedexAreaScreen_0, 0); taskId = CreateTask(Task_ShowPokedexAreaScreen, 0);
gTasks[taskId].data[0] = 0; gTasks[taskId].tState = 0;
} }
static void Task_PokedexAreaScreen_0(u8 taskId) static void Task_ShowPokedexAreaScreen(u8 taskId)
{ {
switch (gTasks[taskId].data[0]) switch (gTasks[taskId].tState)
{ {
case 0: case 0:
ResetSpriteData(); ResetSpriteData();
@ -702,21 +704,21 @@ static void Task_PokedexAreaScreen_0(u8 taskId)
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON); SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON);
break; break;
case 11: case 11:
gTasks[taskId].func = Task_PokedexAreaScreen_1; gTasks[taskId].func = Task_HandlePokedexAreaScreenInput;
gTasks[taskId].data[0] = 0; gTasks[taskId].tState = 0;
return; return;
} }
gTasks[taskId].data[0]++; gTasks[taskId].tState++;
} }
static void Task_PokedexAreaScreen_1(u8 taskId) static void Task_HandlePokedexAreaScreenInput(u8 taskId)
{ {
DoAreaGlow(); DoAreaGlow();
switch (gTasks[taskId].data[0]) switch (gTasks[taskId].tState)
{ {
default: default:
gTasks[taskId].data[0] = 0; gTasks[taskId].tState = 0;
// fall through // fall through
case 0: case 0:
if (gPaletteFade.active) if (gPaletteFade.active)
@ -737,13 +739,13 @@ static void Task_PokedexAreaScreen_1(u8 taskId)
return; return;
break; break;
case 2: case 2:
BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB(0, 0, 0)); BeginNormalPaletteFade(0xFFFFFFEB, 0, 0, 16, RGB_BLACK);
break; break;
case 3: case 3:
if (gPaletteFade.active) if (gPaletteFade.active)
return; return;
DestroyAreaMarkerSprites(); DestroyAreaMarkerSprites();
sPokedexAreaScreen->errno[0] = gTasks[taskId].data[1]; sPokedexAreaScreen->screenSwitchState[0] = gTasks[taskId].data[1];
sub_813D6B4(); sub_813D6B4();
DestroyTask(taskId); DestroyTask(taskId);
sub_81C4EB4(); sub_81C4EB4();
@ -751,7 +753,7 @@ static void Task_PokedexAreaScreen_1(u8 taskId)
return; return;
} }
gTasks[taskId].data[0]++; gTasks[taskId].tState++;
} }
static void sub_813D6B4(void) static void sub_813D6B4(void)

View File

@ -29,14 +29,14 @@ struct PokedexCryScreen
u8 unk1B; u8 unk1B;
}; };
static void sub_8145588(u16); static void PlayCryScreenCry(u16);
static void sub_81455A8(void); static void sub_81455A8(void);
static void sub_814560C(void); static void DrawWaveformFlatline(void);
static void sub_8145648(u8); static void sub_8145648(u8);
static void sub_81456A8(u8, u8); static void DrawWaveformSegment(u8, u8);
static void sub_8145814(u8); static void sub_8145814(u8);
static void sub_8145824(u8, s16, u8); static void sub_8145824(u8, s16, u8);
static void sub_814596C(struct Sprite *); static void SpriteCB_CryMeterNeedle(struct Sprite *);
static void sub_8145B24(s8); static void sub_8145B24(s8);
// IWRAM common // IWRAM common
@ -47,12 +47,12 @@ static EWRAM_DATA struct PokedexCryScreen *sDexCryScreen = NULL;
static EWRAM_DATA u8 *sCryWaveformWindowTiledata = NULL; static EWRAM_DATA u8 *sCryWaveformWindowTiledata = NULL;
static EWRAM_DATA struct PokedexCryVolumeMeter *sCryVolumeMeter = NULL; static EWRAM_DATA struct PokedexCryVolumeMeter *sCryVolumeMeter = NULL;
const u16 CryMeterNeedlePalette[] = INCBIN_U16("graphics/pokedex/cry_meter_needle.gbapal"); static const u16 sCryMeterNeedle_Pal[] = INCBIN_U16("graphics/pokedex/cry_meter_needle.gbapal");
const u8 CryMeterNeedleTiles[] = INCBIN_U8("graphics/pokedex/cry_meter_needle.4bpp"); static const u8 sCryMeterNeedle_Gfx[] = INCBIN_U8("graphics/pokedex/cry_meter_needle.4bpp");
const u16 gUnknown_085B8378[] = INCBIN_U16("graphics/pokedex/cry_meter_map.bin"); static const u16 sCryMeter_Tilemap[] = INCBIN_U16("graphics/pokedex/cry_meter_map.bin"); // Unused
const u16 gUnknown_085B8418[] = INCBIN_U16("graphics/pokedex/cry_meter.gbapal"); static const u16 sCryMeter_Pal[] = INCBIN_U16("graphics/pokedex/cry_meter.gbapal");
const u8 gUnknown_085B8438[] = INCBIN_U8("graphics/pokedex/cry_meter.4bpp.lz"); static const u8 sCryMeter_Gfx[] = INCBIN_U8("graphics/pokedex/cry_meter.4bpp.lz");
const u16 gUnknown_085B8770[][72] = const u16 gUnknown_085B8770[][72] =
{ {
@ -139,8 +139,8 @@ const u16 gUnknown_085B8770[][72] =
} }
}; };
const u16 gUnknown_085B8BF0[] = INCBIN_U16("graphics/pokedex/85B8C10.gbapal"); static const u16 sCryScreenBg_Pal[] = INCBIN_U16("graphics/pokedex/85B8C10.gbapal");
const u8 gUnknown_085B8C10[] = INCBIN_U8("graphics/pokedex/85B8C10.4bpp"); static const u8 sCryScreenBg_Gfx[] = INCBIN_U8("graphics/pokedex/85B8C10.4bpp");
const u8 gUnknown_085B8C30[] = {0xF0, 0x0F}; const u8 gUnknown_085B8C30[] = {0xF0, 0x0F};
const u8 gUnknown_085B8C32[][16] = const u8 gUnknown_085B8C32[][16] =
@ -154,18 +154,18 @@ const u8 gUnknown_085B8C32[][16] =
} }
}; };
const union AnimCmd gSpriteAnim_85B8C54[] = static const union AnimCmd sSpriteAnim_CryMeterNeedle[] =
{ {
ANIMCMD_FRAME(0, 30), ANIMCMD_FRAME(0, 30),
ANIMCMD_END ANIMCMD_END
}; };
const union AnimCmd *const gSpriteAnimTable_85B8C5C[] = static const union AnimCmd *const sSpriteAnimTable_CryMeterNeedle[] =
{ {
gSpriteAnim_85B8C54 sSpriteAnim_CryMeterNeedle
}; };
const struct OamData gOamData_85B8C60 = static const struct OamData sOamData_CryMeterNeedle =
{ {
.y = 160, .y = 160,
.affineMode = ST_OAM_AFFINE_NORMAL, .affineMode = ST_OAM_AFFINE_NORMAL,
@ -179,33 +179,33 @@ const struct OamData gOamData_85B8C60 =
.paletteNum = 0, .paletteNum = 0,
}; };
const struct SpriteTemplate gUnknown_085B8C68 = static const struct SpriteTemplate sCryMeterNeedleSpriteTemplate =
{ {
0x2000, .tileTag = 0x2000,
0x2000, .paletteTag = 0x2000,
&gOamData_85B8C60, .oam = &sOamData_CryMeterNeedle,
gSpriteAnimTable_85B8C5C, .anims = sSpriteAnimTable_CryMeterNeedle,
NULL, .images = NULL,
gDummySpriteAffineAnimTable, .affineAnims = gDummySpriteAffineAnimTable,
sub_814596C .callback = SpriteCB_CryMeterNeedle
}; };
const struct SpriteSheet gCryMeterNeedleSpriteSheets[] = static const struct SpriteSheet sCryMeterNeedleSpriteSheets[] =
{ {
{CryMeterNeedleTiles, 0x800, 0x2000}, {sCryMeterNeedle_Gfx, 0x800, 0x2000},
{} {}
}; };
const struct SpritePalette gCryMeterNeedleSpritePalettes[] = static const struct SpritePalette sCryMeterNeedleSpritePalettes[] =
{ {
{CryMeterNeedlePalette, 0x2000}, {sCryMeterNeedle_Pal, 0x2000},
{} {}
}; };
bool8 sub_8145354(struct CryRelatedStruct *arg0, u8 windowId) bool8 LoadCryWaveformWindow(struct CryRelatedStruct *arg0, u8 windowId)
{ {
u8 i; u8 i;
u8 retVal = FALSE; u8 finished = FALSE;
switch (gDexCryScreenState) switch (gDexCryScreenState)
{ {
@ -225,27 +225,27 @@ bool8 sub_8145354(struct CryRelatedStruct *arg0, u8 windowId)
sDexCryScreen->unk11 = 0; sDexCryScreen->unk11 = 0;
sub_8145824(windowId, -8 * arg0->xPos, 1); sub_8145824(windowId, -8 * arg0->xPos, 1);
for (i = 0; i < 224; i++) for (i = 0; i < 224; i++)
CopyToWindowPixelBuffer(windowId, gUnknown_085B8C10, TILE_SIZE_4BPP, i); CopyToWindowPixelBuffer(windowId, sCryScreenBg_Gfx, TILE_SIZE_4BPP, i);
gDexCryScreenState++; gDexCryScreenState++;
break; break;
case 1: case 1:
for (i = 0; i < sDexCryScreen->unk16 * 8; i++) for (i = 0; i < sDexCryScreen->unk16 * 8; i++)
sub_81456A8(i, 0); DrawWaveformSegment(i, 0);
gDexCryScreenState++; gDexCryScreenState++;
break; break;
case 2: case 2:
sub_8145814(windowId); sub_8145814(windowId);
LoadPalette(gUnknown_085B8BF0, arg0->paletteNo * 16, 32); LoadPalette(sCryScreenBg_Pal, arg0->paletteNo * 16, 32);
retVal = TRUE; finished = TRUE;
break; break;
} }
return retVal; return finished;
} }
void sub_814545C(u8 windowId) void UpdateCryWaveformWindow(u8 windowId)
{ {
u8 var0; u8 var0;
@ -259,15 +259,15 @@ void sub_814545C(u8 windowId)
sDexCryScreen->unk1A--; sDexCryScreen->unk1A--;
if (!sDexCryScreen->unk1A) if (!sDexCryScreen->unk1A)
{ {
sub_8145588(sDexCryScreen->species); PlayCryScreenCry(sDexCryScreen->species);
sub_814560C(); DrawWaveformFlatline();
return; return;
} }
} }
if (sDexCryScreen->unk10 == 0) if (sDexCryScreen->unk10 == 0)
{ {
sub_814560C(); DrawWaveformFlatline();
return; return;
} }
@ -279,7 +279,7 @@ void sub_814545C(u8 windowId)
{ {
if (!IsCryPlaying()) if (!IsCryPlaying())
{ {
sub_814560C(); DrawWaveformFlatline();
sDexCryScreen->unk10 = 0; sDexCryScreen->unk10 = 0;
return; return;
} }
@ -289,12 +289,12 @@ void sub_814545C(u8 windowId)
} }
var0 = 2 * (sDexCryScreen->unk10 - 1); var0 = 2 * (sDexCryScreen->unk10 - 1);
sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 2, sDexCryScreen->unk0[var0]); DrawWaveformSegment(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 2, sDexCryScreen->unk0[var0]);
sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 1, sDexCryScreen->unk0[var0 + 1]); DrawWaveformSegment(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 1, sDexCryScreen->unk0[var0 + 1]);
sDexCryScreen->unk10++; sDexCryScreen->unk10++;
} }
void sub_8145534(u16 species) void CryScreenPlayButton(u16 species)
{ {
if (gMPlayInfo_BGM.status & MUSICPLAYER_STATUS_PAUSE && !sDexCryScreen->unk1A) if (gMPlayInfo_BGM.status & MUSICPLAYER_STATUS_PAUSE && !sDexCryScreen->unk1A)
{ {
@ -309,13 +309,13 @@ void sub_8145534(u16 species)
} }
else else
{ {
sub_8145588(species); PlayCryScreenCry(species);
} }
} }
} }
} }
static void sub_8145588(u16 species) static void PlayCryScreenCry(u16 species)
{ {
PlayCry2(species, 0, 0x7d, 10); PlayCry2(species, 0, 0x7d, 10);
sDexCryScreen->unk10 = 1; sDexCryScreen->unk10 = 1;
@ -333,14 +333,14 @@ static void sub_81455A8(void)
baseBuffer = gSoundInfo.pcmBuffer + (gSoundInfo.pcmDmaPeriod + 1 - gPcmDmaCounter) * gSoundInfo.pcmSamplesPerVBlank; baseBuffer = gSoundInfo.pcmBuffer + (gSoundInfo.pcmDmaPeriod + 1 - gPcmDmaCounter) * gSoundInfo.pcmSamplesPerVBlank;
buffer = baseBuffer + 0x630; buffer = baseBuffer + 0x630;
for (i = 0; i < 16; i++) for (i = 0; i < ARRAY_COUNT(sDexCryScreen->unk0); i++)
sDexCryScreen->unk0[i] = buffer[i * 2] * 2; sDexCryScreen->unk0[i] = buffer[i * 2] * 2;
} }
static void sub_814560C(void) static void DrawWaveformFlatline(void)
{ {
sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 2, 0); DrawWaveformSegment(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 2, 0);
sub_81456A8(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 1, 0); DrawWaveformSegment(sDexCryScreen->unk16 * 8 + sDexCryScreen->unk11 - 1, 0);
} }
static void sub_8145648(u8 windowId) static void sub_8145648(u8 windowId)
@ -352,10 +352,10 @@ static void sub_8145648(u8 windowId)
sDexCryScreen->unk11 += 2; sDexCryScreen->unk11 += 2;
offset = (sDexCryScreen->unk11 / 8 + sDexCryScreen->unk16 + 1) % 32; offset = (sDexCryScreen->unk11 / 8 + sDexCryScreen->unk16 + 1) % 32;
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
CopyToWindowPixelBuffer(windowId, gUnknown_085B8C10, TILE_SIZE_4BPP, offset + (i * TILE_SIZE_4BPP)); CopyToWindowPixelBuffer(windowId, sCryScreenBg_Gfx, TILE_SIZE_4BPP, offset + (i * TILE_SIZE_4BPP));
} }
static void sub_81456A8(u8 a0, u8 a1) static void DrawWaveformSegment(u8 a0, u8 a1)
{ {
u8 sp0; u8 sp0;
u8 r6; u8 r6;
@ -408,9 +408,9 @@ static void sub_8145824(u8 windowId, s16 arg1, u8 arg2)
} }
} }
bool8 sub_8145850(struct CryRelatedStruct *arg0, u8 windowId) bool8 LoadCryMeter(struct CryRelatedStruct *arg0, u8 windowId)
{ {
int retVal = FALSE; bool8 finished = FALSE;
switch (gDexCryScreenState) switch (gDexCryScreenState)
{ {
@ -418,25 +418,25 @@ bool8 sub_8145850(struct CryRelatedStruct *arg0, u8 windowId)
if (!sCryVolumeMeter) if (!sCryVolumeMeter)
sCryVolumeMeter = AllocZeroed(sizeof(*sCryVolumeMeter)); sCryVolumeMeter = AllocZeroed(sizeof(*sCryVolumeMeter));
CopyToWindowPixelBuffer(windowId, gUnknown_085B8438, 0, 0); CopyToWindowPixelBuffer(windowId, sCryMeter_Gfx, 0, 0);
LoadPalette(gUnknown_085B8418, arg0->paletteNo * 16, 32); LoadPalette(sCryMeter_Pal, arg0->paletteNo * 16, 32);
gDexCryScreenState++; gDexCryScreenState++;
break; break;
case 1: case 1:
LoadSpriteSheets(gCryMeterNeedleSpriteSheets); LoadSpriteSheets(sCryMeterNeedleSpriteSheets);
LoadSpritePalettes(gCryMeterNeedleSpritePalettes); LoadSpritePalettes(sCryMeterNeedleSpritePalettes);
sCryVolumeMeter->needleSpriteId = CreateSprite(&gUnknown_085B8C68, 40 + arg0->xPos * 8, 56 + arg0->yPos * 8, 1); sCryVolumeMeter->needleSpriteId = CreateSprite(&sCryMeterNeedleSpriteTemplate, 40 + arg0->xPos * 8, 56 + arg0->yPos * 8, 1);
sCryVolumeMeter->unk0 = 0x20; sCryVolumeMeter->unk0 = 32;
sCryVolumeMeter->unk1 = 0x20; sCryVolumeMeter->unk1 = 32;
sCryVolumeMeter->unk2 = 0; sCryVolumeMeter->unk2 = 0;
retVal = TRUE; finished = TRUE;
break; break;
} }
return retVal; return finished;
} }
void sub_8145914(void) void FreeCryScreen(void)
{ {
FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[sCryVolumeMeter->needleSpriteId].oam.paletteNum)); FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[sCryVolumeMeter->needleSpriteId].oam.paletteNum));
DestroySprite(gSprites + sCryVolumeMeter->needleSpriteId); DestroySprite(gSprites + sCryVolumeMeter->needleSpriteId);
@ -444,7 +444,7 @@ void sub_8145914(void)
FREE_AND_SET_NULL(sCryVolumeMeter); FREE_AND_SET_NULL(sCryVolumeMeter);
} }
static void sub_814596C(struct Sprite *sprite) static void SpriteCB_CryMeterNeedle(struct Sprite *sprite)
{ {
u16 i; u16 i;
s8 r3; s8 r3;
@ -458,29 +458,29 @@ static void sub_814596C(struct Sprite *sprite)
gSprites[sCryVolumeMeter->needleSpriteId].oam.affineParam = 0; gSprites[sCryVolumeMeter->needleSpriteId].oam.affineParam = 0;
switch (sDexCryScreen->unk10) switch (sDexCryScreen->unk10)
{ {
case 0: case 0:
sCryVolumeMeter->unk1 = 0x20; sCryVolumeMeter->unk1 = 32;
if (sCryVolumeMeter->unk0 > 0) if (sCryVolumeMeter->unk0 > 0)
{ {
if (sCryVolumeMeter->unk2 != 1) if (sCryVolumeMeter->unk2 != 1)
sCryVolumeMeter->unk2--; sCryVolumeMeter->unk2--;
} }
else else
sCryVolumeMeter->unk2 = 5; sCryVolumeMeter->unk2 = 5;
break; break;
case 2: case 2:
r3 = 0; r3 = 0;
for (i = 0; i < 16; i++) for (i = 0; i < ARRAY_COUNT(sDexCryScreen->unk0); i++)
{ {
if (r3 < sDexCryScreen->unk0[i]) if (r3 < sDexCryScreen->unk0[i])
r3 = sDexCryScreen->unk0[i]; r3 = sDexCryScreen->unk0[i];
} }
sub_8145B24(r3 * 0xd0 / 0x100); sub_8145B24(r3 * 0xd0 / 0x100);
break; break;
case 6: case 6:
var0 = &sDexCryScreen->unk0[10]; var0 = &sDexCryScreen->unk0[10];
sub_8145B24(*var0 * 0xd0 / 0x100); sub_8145B24(*var0 * 0xd0 / 0x100);
break; break;
} }
if (sCryVolumeMeter->unk0 == sCryVolumeMeter->unk1) if (sCryVolumeMeter->unk0 == sCryVolumeMeter->unk1)
@ -512,7 +512,7 @@ static void sub_814596C(struct Sprite *sprite)
ObjAffineSet(&affine, &matrix, 1, 2); ObjAffineSet(&affine, &matrix, 1, 2);
SetOamMatrix(0, matrix.a, matrix.b, matrix.c, matrix.d); SetOamMatrix(0, matrix.a, matrix.b, matrix.c, matrix.d);
x = gSineTable[((sCryVolumeMeter->unk0 + 0x7F) & 0xFF)]; x = gSineTable[((sCryVolumeMeter->unk0 + 0x7F) & 0xFF)];
y = gSineTable[((sCryVolumeMeter->unk0 + 0x7F) & 0xFF) + 0x40]; y = gSineTable[((sCryVolumeMeter->unk0 + 0x7F) & 0xFF) + 64];
sprite->pos2.x = x * 24 / 256; sprite->pos2.x = x * 24 / 256;
sprite->pos2.y = y * 24 / 256; sprite->pos2.y = y * 24 / 256;
} }

View File

@ -603,7 +603,7 @@ static bool8 StartMenuPokedexCallback(void)
PlayRainStoppingSoundEffect(); PlayRainStoppingSoundEffect();
RemoveExtraStartMenuWindows(); RemoveExtraStartMenuWindows();
CleanupOverworldWindowsAndTilemaps(); CleanupOverworldWindowsAndTilemaps();
SetMainCallback2(CB2_Pokedex); SetMainCallback2(CB2_OpenPokedex);
return TRUE; return TRUE;
} }