Start pokenav conditions doc

This commit is contained in:
GriffinR 2021-11-09 20:02:12 -05:00
parent 43e942c3af
commit 343ac99049
10 changed files with 453 additions and 449 deletions

View File

Before

Width:  |  Height:  |  Size: 134 B

After

Width:  |  Height:  |  Size: 134 B

View File

@ -270,7 +270,9 @@
#define FRIENDSHIP_EVENT_FAINT_FIELD_PSN 7 #define FRIENDSHIP_EVENT_FAINT_FIELD_PSN 7
#define FRIENDSHIP_EVENT_FAINT_LARGE 8 // If opponent was >= 30 levels higher. See AdjustFriendshipOnBattleFaint #define FRIENDSHIP_EVENT_FAINT_LARGE 8 // If opponent was >= 30 levels higher. See AdjustFriendshipOnBattleFaint
#define MAX_FRIENDSHIP 0xFF #define MAX_FRIENDSHIP 255
#define MAX_SHEEN 255
#define MAX_CONDITION 255
#define MAX_PER_STAT_IVS 31 #define MAX_PER_STAT_IVS 31
#define MAX_IV_MASK 31 #define MAX_IV_MASK 31

View File

@ -6,7 +6,6 @@
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0
#define BSS_DATA __attribute__((section(".bss")))
#define IWRAM_DATA __attribute__((section("iwram_data"))) #define IWRAM_DATA __attribute__((section("iwram_data")))
#define EWRAM_DATA __attribute__((section("ewram_data"))) #define EWRAM_DATA __attribute__((section("ewram_data")))
#define UNUSED __attribute__((unused)) #define UNUSED __attribute__((unused))

View File

@ -7,14 +7,24 @@
#include "pokemon.h" #include "pokemon.h"
#include "constants/berry.h" #include "constants/berry.h"
#define TAG_CONDITION_MON 100 enum {
#define TAG_CONDITION_BALL 101 TAG_CONDITION_MON = 100,
#define TAG_CONDITION_CANCEL 102 TAG_CONDITION_BALL,
#define TAG_CONDITION_BALL_PLACEHOLDER 103 TAG_CONDITION_CANCEL,
#define TAG_CONDITION_SPARKLE 104 TAG_CONDITION_BALL_PLACEHOLDER,
TAG_CONDITION_SPARKLE,
TAG_CONDITION_MON_MARKINGS,
TAG_CONDITION_MARKINGS_MENU,
TAG_CONDITION_MARKINGS_MENU_2, // Used implicitly by CreateMonMarkingsMenuSprites
};
#define MAX_CONDITION_SPARKLES 10 #define MAX_CONDITION_SPARKLES 10
// The number of extra sparkles shown on a Pokémon's condition screen.
// All Pokémon start with 1, so the max here is MAX_CONDITION_SPARKLES - 1
#define GET_NUM_CONDITION_SPARKLES(sheen)((sheen) != MAX_SHEEN) ? (sheen) / ((u32)MAX_SHEEN / (MAX_CONDITION_SPARKLES - 1) + 1) : MAX_CONDITION_SPARKLES - 1;
// Window IDs for the Player PC Mailbox // Window IDs for the Player PC Mailbox
enum { enum {
MAILBOXWIN_TITLE, MAILBOXWIN_TITLE,
@ -29,17 +39,35 @@ struct UnknownSubStruct_81D1ED4
u16 unk2; u16 unk2;
}; };
#define CONDITION_GRAPH_CENTER_X 155
#define CONDITION_GRAPH_TOP_Y 56
#define CONDITION_GRAPH_BOTTOM_Y 121
#define CONDITION_GRAPH_HEIGHT (CONDITION_GRAPH_BOTTOM_Y - CONDITION_GRAPH_TOP_Y + 1)
#define CONDITION_GRAPH_UNK_1 10
#define CONDITION_GRAPH_UNK_2 9
#define CONDITION_GRAPH_UNK 91
// Equivalent to flavor and contest values, but in a different order.
enum {
CONDITION_COOL,
CONDITION_TOUGH,
CONDITION_SMART,
CONDITION_CUTE,
CONDITION_BEAUTY,
CONDITION_COUNT
};
struct ConditionGraph struct ConditionGraph
{ {
/*0x000*/ u8 stat[4][FLAVOR_COUNT]; /*0x000*/ u8 conditions[4][CONDITION_COUNT];
/*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][FLAVOR_COUNT]; /*0x014*/ struct UnknownSubStruct_81D1ED4 unk14[4][CONDITION_COUNT];
/*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[10][FLAVOR_COUNT]; /*0x064*/ struct UnknownSubStruct_81D1ED4 unk64[CONDITION_GRAPH_UNK_1][CONDITION_COUNT];
/*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[FLAVOR_COUNT]; /*0x12C*/ struct UnknownSubStruct_81D1ED4 unk12C[CONDITION_COUNT];
/*0x140*/ u16 unk140[66][2]; /*0x140*/ u16 scanlineRight[CONDITION_GRAPH_HEIGHT][2];
/*0x248*/ u16 unk248[66][2]; /*0x248*/ u16 scanlineLeft[CONDITION_GRAPH_HEIGHT][2];
/*0x350*/ u16 unk350; /*0x350*/ u16 unk350;
/*0x352*/ u16 unk352; /*0x352*/ u16 unk352;
/*0x354*/ u8 unk354; /*0x354*/ bool8 unk354;
/*0x355*/ u8 state; /*0x355*/ u8 state;
}; };
@ -49,13 +77,13 @@ u8 MailboxMenu_CreateList(struct PlayerPCItemPageStruct *page);
void MailboxMenu_AddScrollArrows(struct PlayerPCItemPageStruct *page); void MailboxMenu_AddScrollArrows(struct PlayerPCItemPageStruct *page);
void MailboxMenu_Free(void); void MailboxMenu_Free(void);
void MailboxMenu_RemoveWindow(u8 windowIdx); void MailboxMenu_RemoveWindow(u8 windowIdx);
void InitConditionGraphData(struct ConditionGraph *graph); void ConditionGraph_Init(struct ConditionGraph *graph);
void sub_81D2108(struct ConditionGraph *graph); void sub_81D2108(struct ConditionGraph *graph);
void SetConditionGraphIOWindows(u8 bg); void SetConditionGraphIOWindows(u8 bg);
void InitConditionGraphState(struct ConditionGraph *graph); void InitConditionGraphState(struct ConditionGraph *graph);
void sub_81D2230(struct ConditionGraph *graph); void sub_81D2230(struct ConditionGraph *graph);
bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph); bool8 SetupConditionGraphScanlineParams(struct ConditionGraph *graph);
bool32 TransitionConditionGraph(struct ConditionGraph *graph); bool8 TransitionConditionGraph(struct ConditionGraph *graph);
void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1); void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1);
void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2); void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2);
void MoveRelearnerPrintText(u8 *str); void MoveRelearnerPrintText(u8 *str);
@ -69,8 +97,8 @@ void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16
void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 partyId, u16 numMons, bool8 excludesCancel); void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId, u16 partyId, u16 numMons, bool8 excludesCancel);
bool8 MoveConditionMonOnscreen(s16 *x); bool8 MoveConditionMonOnscreen(s16 *x);
bool8 MoveConditionMonOffscreen(s16 *x); bool8 MoveConditionMonOffscreen(s16 *x);
bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x); bool8 ConditionGraph_UpdateMonEnter(struct ConditionGraph *graph, s16 *x);
bool8 TryUpdateConditionMonTransitionOff(struct ConditionGraph *graph, s16 *x); bool8 ConditionGraph_UpdateMonExit(struct ConditionGraph *graph, s16 *x);
void LoadConditionMonPicTemplate(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal); void LoadConditionMonPicTemplate(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal);
void LoadConditionSelectionIcons(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals); void LoadConditionSelectionIcons(struct SpriteSheet *sheets, struct SpriteTemplate * template, struct SpritePalette *pals);
void LoadConditionSparkle(struct SpriteSheet *sheet, struct SpritePalette *pal); void LoadConditionSparkle(struct SpriteSheet *sheet, struct SpritePalette *pal);

View File

@ -256,6 +256,14 @@ enum PartyConditionFuncIds
PARTY_CONDITION_FUNC_CLOSE_MARKINGS, PARTY_CONDITION_FUNC_CLOSE_MARKINGS,
}; };
enum
{
CONDITION_MON_0,
CONDITION_MON_1,
CONDITION_MON_2,
NUM_CONDITION_MONS
};
#define POKENAV_MENU_FUNC_EXIT -1 #define POKENAV_MENU_FUNC_EXIT -1
enum enum
@ -432,11 +440,11 @@ bool32 IsConditionMenuSearchMode(void);
struct ConditionGraph *GetConditionGraphDataPtr(void); struct ConditionGraph *GetConditionGraphDataPtr(void);
u16 GetConditionGraphCurrentMonIndex(void); u16 GetConditionGraphCurrentMonIndex(void);
u16 GetMonListCount(void); u16 GetMonListCount(void);
u8 GetMonSheen(void); u8 GetNumConditionMonSparkles(void);
bool32 SetConditionGraphData(u8 arg0); bool32 SetConditionGraphData(u8 mode);
u8 TryGetMonMarkId(void); u8 TryGetMonMarkId(void);
u8 *GetConditionMonNameBuffer(u8 id); u8 *GetConditionMonNameText(u8 id);
u8 *GetConditionMonLocationBuffer(u8 id); u8 *GetConditionMonLocationText(u8 id);
u16 GetConditionMonDataBuffer(void); u16 GetConditionMonDataBuffer(void);
void *GetConditionMonPicGfx(u8 id); void *GetConditionMonPicGfx(u8 id);
void *GetConditionMonPal(u8 id); void *GetConditionMonPal(u8 id);

View File

@ -31,14 +31,14 @@ extern const struct CompressedSpriteSheet gMonFrontPicTable[];
EWRAM_DATA static u8 sMailboxWindowIds[MAILBOXWIN_COUNT] = {0}; EWRAM_DATA static u8 sMailboxWindowIds[MAILBOXWIN_COUNT] = {0};
EWRAM_DATA static struct ListMenuItem *sMailboxList = NULL; EWRAM_DATA static struct ListMenuItem *sMailboxList = NULL;
static void MailboxMenu_MoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMenu *list); static void MailboxMenu_MoveCursorFunc(s32, bool8, struct ListMenu *);
static void sub_81D24A4(struct ConditionGraph *a0); static void sub_81D24A4(struct ConditionGraph *);
static void sub_81D2634(struct ConditionGraph *a0); static void sub_81D2634(struct ConditionGraph *);
static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list); static void MoveRelearnerCursorCallback(s32, bool8, struct ListMenu *);
static void nullsub_79(void); static void MoveRelearnerDummy(void);
static void SetNextConditionSparkle(struct Sprite *sprite); static void SetNextConditionSparkle(struct Sprite *);
static void SpriteCB_ConditionSparkle(struct Sprite *sprite); static void SpriteCB_ConditionSparkle(struct Sprite *);
static void ShowAllConditionSparkles(struct Sprite *sprite); static void ShowAllConditionSparkles(struct Sprite *);
static const struct WindowTemplate sWindowTemplates_MailboxMenu[MAILBOXWIN_COUNT] = static const struct WindowTemplate sWindowTemplates_MailboxMenu[MAILBOXWIN_COUNT] =
{ {
@ -80,46 +80,29 @@ static const u8 sEmptyItemName[] = _("");
static const struct ScanlineEffectParams sConditionGraphScanline = static const struct ScanlineEffectParams sConditionGraphScanline =
{ {
.dmaDest = (void*)REG_ADDR_WIN0H, .dmaDest = &REG_WIN0H,
.dmaControl = SCANLINE_EFFECT_DMACNT_32BIT, .dmaControl = SCANLINE_EFFECT_DMACNT_32BIT,
.initState = 1, .initState = 1,
}; };
static const u8 sUnknown_08625410[] = static const u8 sUnknown_08625410[MAX_CONDITION + 1] =
{ {
4, 4, 5, 6, 7, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13,
5, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 17,
6, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19,
7, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 21, 21, 21, 21, 21,
8, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23,
9, 9, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24,
10, 10, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26,
0xB, 0xB, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27,
0xC, 0xC, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28,
0xD, 0xD, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
0xD, 0xD, 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
0xE, 0xE, 0xE, 0xE, 30, 30, 30, 30, 30, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
0xF, 0xF, 0xF, 0xF, 31, 31, 31, 31, 31, 31, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 32, 32, 32, 32, 32, 32, 32, 32, 33, 33, 33, 33, 33, 33, 33, 33,
0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 33, 34, 34, 34, 34, 34,
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35
0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13,
0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15,
0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16,
0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17,
0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18,
0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19,
0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A,
0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B,
0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C,
0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D,
0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E,
0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F,
0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22,
0x23
}; };
@ -320,29 +303,29 @@ void MailboxMenu_Free(void)
Free(sMailboxList); Free(sMailboxList);
} }
void InitConditionGraphData(struct ConditionGraph *graph) void ConditionGraph_Init(struct ConditionGraph *graph)
{ {
u8 i, j; u8 i, j;
for (j = 0; j < FLAVOR_COUNT; j++) for (j = 0; j < CONDITION_COUNT; j++)
{ {
for (i = 0; i < 10; i++) for (i = 0; i < CONDITION_GRAPH_UNK_1; i++)
{ {
graph->unk64[i][j].unk0 = 0; graph->unk64[i][j].unk0 = 0;
graph->unk64[i][j].unk2 = 0; graph->unk64[i][j].unk2 = 0;
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
graph->stat[i][j] = 0; graph->conditions[i][j] = 0;
graph->unk14[i][j].unk0 = 155; graph->unk14[i][j].unk0 = CONDITION_GRAPH_CENTER_X;
graph->unk14[i][j].unk2 = 91; graph->unk14[i][j].unk2 = CONDITION_GRAPH_UNK;
} }
graph->unk12C[j].unk0 = 0; graph->unk12C[j].unk0 = 0;
graph->unk12C[j].unk2 = 0; graph->unk12C[j].unk2 = 0;
} }
graph->unk354 = 0; graph->unk354 = FALSE;
graph->unk352 = 0; graph->unk352 = 0;
} }
@ -351,11 +334,11 @@ void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *
u16 i, j; u16 i, j;
s32 r5, r6; s32 r5, r6;
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
{ {
r5 = arg1[i].unk0 << 8; r5 = arg1[i].unk0 << 8;
r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / 10; r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / CONDITION_GRAPH_UNK_1;
for (j = 0; j < 9; j++) for (j = 0; j < CONDITION_GRAPH_UNK_2; j++)
{ {
graph->unk64[j][i].unk0 = (r5 >> 8) + ((r5 >> 7) & 1); graph->unk64[j][i].unk0 = (r5 >> 8) + ((r5 >> 7) & 1);
r5 += r6; r5 += r6;
@ -363,8 +346,8 @@ void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *
graph->unk64[j][i].unk0 = arg2[i].unk0; graph->unk64[j][i].unk0 = arg2[i].unk0;
r5 = arg1[i].unk2 << 8; r5 = arg1[i].unk2 << 8;
r6 = ((arg2[i].unk2 - arg1[i].unk2) << 8) / 10; r6 = ((arg2[i].unk2 - arg1[i].unk2) << 8) / CONDITION_GRAPH_UNK_1;
for (j = 0; j < 9; j++) for (j = 0; j < CONDITION_GRAPH_UNK_2; j++)
{ {
graph->unk64[j][i].unk2 = (r5 >> 8) + ((r5 >> 7) & 1); graph->unk64[j][i].unk2 = (r5 >> 8) + ((r5 >> 7) & 1);
r5 += r6; r5 += r6;
@ -375,12 +358,12 @@ void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *
graph->unk352 = 0; graph->unk352 = 0;
} }
bool32 TransitionConditionGraph(struct ConditionGraph *graph) bool8 TransitionConditionGraph(struct ConditionGraph *graph)
{ {
if (graph->unk352 < 10) if (graph->unk352 < CONDITION_GRAPH_UNK_1)
{ {
sub_81D2230(graph); sub_81D2230(graph);
return (++graph->unk352 != 10); return (++graph->unk352 != CONDITION_GRAPH_UNK_1);
} }
else else
{ {
@ -417,35 +400,36 @@ void sub_81D2108(struct ConditionGraph *graph)
{ {
u16 i; u16 i;
if (graph->unk354 == 0) if (!graph->unk354)
return; return;
sub_81D24A4(graph); sub_81D24A4(graph);
sub_81D2634(graph); sub_81D2634(graph);
for (i = 0; i < 66; i++) for (i = 0; i < CONDITION_GRAPH_HEIGHT; i++)
{ {
gScanlineEffectRegBuffers[1][(i + 55) * 2] = gScanlineEffectRegBuffers[0][(i + 55) * 2] = (graph->unk140[i][0] << 8) | (graph->unk140[i][1]); gScanlineEffectRegBuffers[1][(i + 55) * 2] = gScanlineEffectRegBuffers[0][(i + 55) * 2] = (graph->scanlineRight[i][0] << 8) | (graph->scanlineRight[i][1]);
gScanlineEffectRegBuffers[1][(i + 55) * 2 + 1] = gScanlineEffectRegBuffers[0][(i + 55) * 2 + 1] = (graph->unk248[i][0] << 8) | (graph->unk248[i][1]); gScanlineEffectRegBuffers[1][(i + 55) * 2 + 1] = gScanlineEffectRegBuffers[0][(i + 55) * 2 + 1] = (graph->scanlineLeft[i][0] << 8) | (graph->scanlineLeft[i][1]);
} }
graph->unk354 = 0; graph->unk354 = FALSE;
} }
void SetConditionGraphIOWindows(u8 bg) void SetConditionGraphIOWindows(u8 bg)
{ {
u32 flags; u32 flags;
if (bg > 3) if (bg >= NUM_BACKGROUNDS)
bg = 0; bg = 0;
// Unset the WINOUT flag for the bg. // Unset the WINOUT flag for the bg.
flags = (WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ) & ~(1 << bg); flags = (WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ) & ~(1 << bg);
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE( 0, DISPLAY_WIDTH)); // Set limits for graph data
SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE( 0, 155)); SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE( 0, DISPLAY_WIDTH)); // Right side horizontal
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(56, 121)); SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE( 0, CONDITION_GRAPH_CENTER_X)); // Left side horizontal
SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(56, 121)); SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(CONDITION_GRAPH_TOP_Y, CONDITION_GRAPH_BOTTOM_Y)); // Right side vertical
SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(CONDITION_GRAPH_TOP_Y, CONDITION_GRAPH_BOTTOM_Y)); // Left side vertical
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR); SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ | WININ_WIN0_CLR | WININ_WIN1_BG_ALL | WININ_WIN1_OBJ | WININ_WIN1_CLR);
SetGpuReg(REG_OFFSET_WINOUT, flags); SetGpuReg(REG_OFFSET_WINOUT, flags);
} }
@ -453,19 +437,18 @@ void SetConditionGraphIOWindows(u8 bg)
void sub_81D2230(struct ConditionGraph *graph) void sub_81D2230(struct ConditionGraph *graph)
{ {
u16 i; u16 i;
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
graph->unk12C[i] = graph->unk64[graph->unk352][i]; graph->unk12C[i] = graph->unk64[graph->unk352][i];
graph->unk354 = 1; graph->unk354 = TRUE;
} }
static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownSubStruct_81D1ED4 *arg2, struct UnknownSubStruct_81D1ED4 *arg3, u8 arg4, u16 *arg5) static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownSubStruct_81D1ED4 *arg2, struct UnknownSubStruct_81D1ED4 *arg3, u8 arg4, u16 *arg5)
{ {
u16 i, r8, r10, r0, var_30; u16 i, r8, r10, r0, var_30;
u16 *ptr; u16 *ptr;
s32 r4, var_2C; s32 r4, var_2C = 0;
var_2C = 0;
if (arg2->unk2 < arg3->unk2) if (arg2->unk2 < arg3->unk2)
{ {
r10 = arg2->unk2; r10 = arg2->unk2;
@ -490,7 +473,7 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS
r8++; r8++;
if (arg5 == NULL) if (arg5 == NULL)
{ {
arg1 += (r10 - 56) * 2; arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2;
for (i = 0; i < r8; i++) for (i = 0; i < r8; i++)
{ {
arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
@ -502,16 +485,16 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS
} }
else if (var_2C > 0) else if (var_2C > 0)
{ {
arg5 += (r10 - 56) * 2; arg5 += (r10 - CONDITION_GRAPH_TOP_Y) * 2;
// Less readable than the other loops, but it has to be written this way to match. // Less readable than the other loops, but it has to be written this way to match.
for (i = 0; i < r8; arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4, r4 += var_2C, arg5 += 2, i++) for (i = 0; i < r8; arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4, r4 += var_2C, arg5 += 2, i++)
{ {
if (r4 >= (155 << 10)) if (r4 >= (CONDITION_GRAPH_CENTER_X << 10))
break; break;
} }
graph->unk350 = r10 + i; graph->unk350 = r10 + i;
arg1 += (graph->unk350 - 56) * 2; arg1 += (graph->unk350 - CONDITION_GRAPH_TOP_Y) * 2;
for (; i < r8; i++) for (; i < r8; i++)
{ {
arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
@ -523,13 +506,13 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS
} }
else if (var_2C < 0) else if (var_2C < 0)
{ {
arg1 += (r10 - 56) * 2; arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2;
for (i = 0; i < r8; i++) for (i = 0; i < r8; i++)
{ {
arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
if (r4 < (155 << 10)) if (r4 < (CONDITION_GRAPH_CENTER_X << 10))
{ {
arg1[arg4] = 155; arg1[arg4] = CONDITION_GRAPH_CENTER_X;
break; break;
} }
r4 += var_2C; r4 += var_2C;
@ -537,7 +520,7 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS
} }
graph->unk350 = r10 + i; graph->unk350 = r10 + i;
arg5 += (graph->unk350 - 56) * 2; arg5 += (graph->unk350 - CONDITION_GRAPH_TOP_Y) * 2;
for (; i < r8; i++) for (; i < r8; i++)
{ {
arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4; arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
@ -550,11 +533,11 @@ static void sub_81D2278(struct ConditionGraph *graph, u16 *arg1, struct UnknownS
else else
{ {
graph->unk350 = r10; graph->unk350 = r10;
arg1 += (r10 - 56) * 2; arg1 += (r10 - CONDITION_GRAPH_TOP_Y) * 2;
arg5 += (r10 - 56) * 2; arg5 += (r10 - CONDITION_GRAPH_TOP_Y) * 2;
arg1[1] = arg2->unk0 + 1; arg1[1] = arg2->unk0 + 1;
arg5[0] = arg3->unk0; arg5[0] = arg3->unk0;
arg5[1] = 155; arg5[1] = CONDITION_GRAPH_CENTER_X;
return; return;
} }
@ -568,38 +551,38 @@ static void sub_81D24A4(struct ConditionGraph *graph)
if (graph->unk12C[0].unk2 < graph->unk12C[1].unk2) if (graph->unk12C[0].unk2 < graph->unk12C[1].unk2)
{ {
r6 = graph->unk12C[0].unk2; r6 = graph->unk12C[0].unk2;
sub_81D2278(graph, graph->unk140[0], &graph->unk12C[0], &graph->unk12C[1], 1, NULL); sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[0], &graph->unk12C[1], 1, NULL);
} }
else else
{ {
r6 = graph->unk12C[1].unk2; r6 = graph->unk12C[1].unk2;
sub_81D2278(graph, graph->unk140[0], &graph->unk12C[1], &graph->unk12C[0], 0, NULL); sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[1], &graph->unk12C[0], 0, NULL);
} }
sub_81D2278(graph, graph->unk140[0], &graph->unk12C[1], &graph->unk12C[2], 1, NULL); sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[1], &graph->unk12C[2], 1, NULL);
i = (graph->unk12C[2].unk2 <= graph->unk12C[3].unk2); i = (graph->unk12C[2].unk2 <= graph->unk12C[3].unk2);
sub_81D2278(graph, graph->unk140[0], &graph->unk12C[2], &graph->unk12C[3], i, graph->unk248[0]); sub_81D2278(graph, graph->scanlineRight[0], &graph->unk12C[2], &graph->unk12C[3], i, graph->scanlineLeft[0]);
for (i = 56; i < r6; i++) for (i = CONDITION_GRAPH_TOP_Y; i < r6; i++)
{ {
graph->unk140[i - 56][0] = 0; graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = 0;
graph->unk140[i - 56][1] = 0; graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] = 0;
} }
for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++) for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++)
graph->unk140[i - 56][0] = 155; graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = CONDITION_GRAPH_CENTER_X;
varMax = max(graph->unk350, graph->unk12C[2].unk2); varMax = max(graph->unk350, graph->unk12C[2].unk2);
for (i = varMax + 1; i < 122; i++) for (i = varMax + 1; i <= CONDITION_GRAPH_BOTTOM_Y; i++)
{ {
graph->unk140[i - 56][0] = 0; graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = 0;
graph->unk140[i - 56][1] = 0; graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][1] = 0;
} }
for (i = 56; i < 122; i++) for (i = CONDITION_GRAPH_TOP_Y; i <= CONDITION_GRAPH_BOTTOM_Y; i++)
{ {
if (graph->unk140[i - 56][0] == 0 && graph->unk140[i - 56][1] != 0) if (graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] == 0 && graph->scanlineRight[i - 56][1] != 0)
graph->unk140[i - 56][0] = 155; graph->scanlineRight[i - CONDITION_GRAPH_TOP_Y][0] = CONDITION_GRAPH_CENTER_X;
} }
} }
@ -610,69 +593,69 @@ static void sub_81D2634(struct ConditionGraph *graph)
if (graph->unk12C[0].unk2 < graph->unk12C[4].unk2) if (graph->unk12C[0].unk2 < graph->unk12C[4].unk2)
{ {
r6 = graph->unk12C[0].unk2; r6 = graph->unk12C[0].unk2;
sub_81D2278(graph, graph->unk248[0], &graph->unk12C[0], &graph->unk12C[4], 0, NULL); sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[0], &graph->unk12C[4], 0, NULL);
} }
else else
{ {
r6 = graph->unk12C[4].unk2; r6 = graph->unk12C[4].unk2;
sub_81D2278(graph, graph->unk248[0], &graph->unk12C[4], &graph->unk12C[0], 1, NULL); sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[4], &graph->unk12C[0], 1, NULL);
} }
sub_81D2278(graph, graph->unk248[0], &graph->unk12C[4], &graph->unk12C[3], 0, NULL); sub_81D2278(graph, graph->scanlineLeft[0], &graph->unk12C[4], &graph->unk12C[3], 0, NULL);
for (i = 56; i < r6; i++) for (i = CONDITION_GRAPH_TOP_Y; i < r6; i++)
{ {
graph->unk140[i + 10][0] = 0; graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][0] = 0;
graph->unk140[i + 10][1] = 0; graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = 0;
} }
for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++) for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++)
graph->unk140[i + 10][1] = 155; graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = CONDITION_GRAPH_CENTER_X;
varMax = max(graph->unk350, graph->unk12C[3].unk2 + 1); varMax = max(graph->unk350, graph->unk12C[3].unk2 + 1);
for (i = varMax; i < 122; i++) for (i = varMax; i <= CONDITION_GRAPH_BOTTOM_Y; i++)
{ {
graph->unk140[i + 10][0] = 0; graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][0] = 0;
graph->unk140[i + 10][1] = 0; graph->scanlineRight[i + CONDITION_GRAPH_UNK_1][1] = 0;
} }
for (i = 0; i < 66; i++) for (i = 0; i < CONDITION_GRAPH_HEIGHT; i++)
{ {
if (graph->unk248[i][0] >= graph->unk248[i][1]) if (graph->scanlineLeft[i][0] >= graph->scanlineLeft[i][1])
{ {
graph->unk248[i][1] = 0; graph->scanlineLeft[i][1] = 0;
graph->unk248[i][0] = 0; graph->scanlineLeft[i][0] = 0;
} }
} }
} }
void sub_81D2754(u8 *arg0, struct UnknownSubStruct_81D1ED4 *arg1) void sub_81D2754(u8 *conditions, struct UnknownSubStruct_81D1ED4 *arg1)
{ {
u8 r2, r7; u8 r2, sinIdx;
s8 r12; s8 r12;
u16 i; u16 i;
r2 = sUnknown_08625410[*(arg0++)]; r2 = sUnknown_08625410[*(conditions++)];
arg1->unk0 = 155; arg1->unk0 = CONDITION_GRAPH_CENTER_X;
arg1->unk2 = 91 - r2; arg1->unk2 = CONDITION_GRAPH_UNK - r2;
r7 = 64; sinIdx = 64;
r12 = 0; r12 = 0;
for (i = 1; i < 5; i++) for (i = 1; i < CONDITION_COUNT; i++)
{ {
r7 += 51; sinIdx += 51;
if (--r12 < 0) if (--r12 < 0)
r12 = 4; r12 = 4;
if (r12 == 2) if (r12 == 2)
r7++; sinIdx++;
r2 = sUnknown_08625410[*(arg0++)]; r2 = sUnknown_08625410[*(conditions++)];
arg1[r12].unk0 = 155 + ((r2 * gSineTable[64 + r7]) >> 8); arg1[r12].unk0 = CONDITION_GRAPH_CENTER_X + ((r2 * gSineTable[64 + sinIdx]) >> 8);
arg1[r12].unk2 = 91 - ((r2 * gSineTable[r7]) >> 8); arg1[r12].unk2 = CONDITION_GRAPH_UNK - ((r2 * gSineTable[sinIdx]) >> 8);
if (r12 < 3 && (r2 != 32 || r12 != 2)) if (r12 < 3 && (r2 != 32 || r12 != 2))
arg1[r12].unk0 = 156 + ((r2 * gSineTable[64 + r7]) >> 8); arg1[r12].unk0 = CONDITION_GRAPH_CENTER_X + 1 + ((r2 * gSineTable[64 + sinIdx]) >> 8);
} }
} }
@ -685,10 +668,8 @@ void InitMoveRelearnerWindows(bool8 useContextWindow)
LoadUserWindowBorderGfx(0, 1, 0xE0); LoadUserWindowBorderGfx(0, 1, 0xE0);
LoadPalette(gStandardMenuPalette, 0xF0, 0x20); LoadPalette(gStandardMenuPalette, 0xF0, 0x20);
for (i = 0; i < 5; i++) for (i = 0; i < ARRAY_COUNT(sMoveRelearnerWindowTemplates) - 1; i++)
{
FillWindowPixelBuffer(i, PIXEL_FILL(1)); FillWindowPixelBuffer(i, PIXEL_FILL(1));
}
if (!useContextWindow) if (!useContextWindow)
{ {
@ -704,11 +685,11 @@ void InitMoveRelearnerWindows(bool8 useContextWindow)
PutWindowTilemap(3); PutWindowTilemap(3);
DrawStdFrameWithCustomTileAndPalette(2, 0, 1, 0xE); DrawStdFrameWithCustomTileAndPalette(2, 0, 1, 0xE);
DrawStdFrameWithCustomTileAndPalette(3, 0, 1, 0xE); DrawStdFrameWithCustomTileAndPalette(3, 0, 1, 0xE);
nullsub_79(); MoveRelearnerDummy();
ScheduleBgCopyTilemapToVram(1); ScheduleBgCopyTilemapToVram(1);
} }
static void nullsub_79(void) static void MoveRelearnerDummy(void)
{ {
} }
@ -720,13 +701,10 @@ u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices)
gMultiuseListMenuTemplate.items = items; gMultiuseListMenuTemplate.items = items;
if (numChoices < 6) if (numChoices < 6)
{
gMultiuseListMenuTemplate.maxShowed = numChoices; gMultiuseListMenuTemplate.maxShowed = numChoices;
}
else else
{
gMultiuseListMenuTemplate.maxShowed = 6; gMultiuseListMenuTemplate.maxShowed = 6;
}
return gMultiuseListMenuTemplate.maxShowed; return gMultiuseListMenuTemplate.maxShowed;
} }
@ -734,7 +712,7 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
{ {
s32 x; s32 x;
const struct BattleMove *move; const struct BattleMove *move;
u8 buffer[0x20]; u8 buffer[32];
const u8 *str; const u8 *str;
FillWindowPixelBuffer(0, PIXEL_FILL(1)); FillWindowPixelBuffer(0, PIXEL_FILL(1));
@ -1010,7 +988,7 @@ void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId
} }
} }
void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel) void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *numSparkles, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel)
{ {
u16 i; u16 i;
@ -1019,25 +997,23 @@ void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16
if (partyId != numMons) if (partyId != numMons)
{ {
graph->stat[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); graph->conditions[id][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
graph->stat[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); graph->conditions[id][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
graph->stat[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); graph->conditions[id][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
graph->stat[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); graph->conditions[id][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
graph->stat[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); graph->conditions[id][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF) numSparkles[id] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL));
? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u
: 9;
sub_81D2754(graph->stat[id], graph->unk14[id]); sub_81D2754(graph->conditions[id], graph->unk14[id]);
} }
else else
{ {
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
{ {
graph->stat[id][i] = 0; graph->conditions[id][i] = 0;
graph->unk14[id][i].unk0 = 155; graph->unk14[id][i].unk0 = CONDITION_GRAPH_CENTER_X;
graph->unk14[id][i].unk2 = 91; graph->unk14[id][i].unk2 = CONDITION_GRAPH_UNK;
} }
} }
} }
@ -1076,7 +1052,7 @@ bool8 MoveConditionMonOffscreen(s16 *x)
return (*x != -80); return (*x != -80);
} }
bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x) bool8 ConditionGraph_UpdateMonEnter(struct ConditionGraph *graph, s16 *x)
{ {
bool8 graphUpdating = TransitionConditionGraph(graph); bool8 graphUpdating = TransitionConditionGraph(graph);
bool8 monUpdating = MoveConditionMonOnscreen(x); bool8 monUpdating = MoveConditionMonOnscreen(x);
@ -1084,7 +1060,7 @@ bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x)
return (graphUpdating || monUpdating); return (graphUpdating || monUpdating);
} }
bool8 TryUpdateConditionMonTransitionOff(struct ConditionGraph *graph, s16 *x) bool8 ConditionGraph_UpdateMonExit(struct ConditionGraph *graph, s16 *x)
{ {
bool8 graphUpdating = TransitionConditionGraph(graph); bool8 graphUpdating = TransitionConditionGraph(graph);
bool8 monUpdating = MoveConditionMonOffscreen(x); bool8 monUpdating = MoveConditionMonOffscreen(x);

View File

@ -15,18 +15,18 @@
struct PokenavSub11 struct PokenavSub11
{ {
u32 monPal[3][0x20]; u32 monPal[NUM_CONDITION_MONS][0x20];
u8 fill[0x180]; u8 fill[0x180];
u32 monPicGfx[3][MON_PIC_SIZE]; u32 monPicGfx[NUM_CONDITION_MONS][MON_PIC_SIZE];
u8 searchMode; u8 searchMode;
s16 monIndex; s16 monIndex;
u32 (*callback)(struct PokenavSub11 *); u32 (*callback)(struct PokenavSub11 *);
u8 fill2[0x6320 - 0x6308]; u8 fill2[0x6320 - 0x6308];
u8 searchLocBuffer[3][24]; u8 locationText[NUM_CONDITION_MONS][24];
u8 nameBuffer[3][64]; u8 nameText[NUM_CONDITION_MONS][64];
struct ConditionGraph conditionData; struct ConditionGraph conditionData;
u8 sheen[3]; u8 numSparkles[NUM_CONDITION_MONS];
u8 monMarks[3]; u8 monMarks[NUM_CONDITION_MONS];
s8 mark; s8 mark;
s8 unk6787; s8 unk6787;
s8 unk6788; s8 unk6788;
@ -34,18 +34,17 @@ struct PokenavSub11
u8 state; u8 state;
}; };
void InitPartyConditionListParameters(void); static void InitPartyConditionListParameters(void);
void sub_81CD9F8(void); static void InitSearchResultsConditionList(void);
u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr); static u32 HandlePartyConditionInput(struct PokenavSub11 *);
u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr); static u32 GetConditionReturnCallback(struct PokenavSub11 *);
u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr); static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *);
u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr); static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *);
u8 SwitchConditionSummaryIndex(u8 moveUp); static u8 SwitchConditionSummaryIndex(bool8);
void CopyMonNameGenderLocation(s16 id, u8 arg1); static void CopyMonNameGenderLocation(s16, u8);
void GetMonConditionGraphData(s16 id, u8 arg1); static void GetMonConditionGraphData(s16, u8);
void ConditionGraphDrawMonPic(s16 id, u8 arg1); static void ConditionGraphDrawMonPic(s16, u8);
// code
bool32 PokenavCallback_Init_PartyCondition(void) bool32 PokenavCallback_Init_PartyCondition(void)
{ {
struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11)); struct PokenavSub11 *structPtr = AllocSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH, sizeof(struct PokenavSub11));
@ -53,7 +52,7 @@ bool32 PokenavCallback_Init_PartyCondition(void)
if (structPtr == NULL) if (structPtr == NULL)
return FALSE; return FALSE;
InitConditionGraphData(&structPtr->conditionData); ConditionGraph_Init(&structPtr->conditionData);
InitPartyConditionListParameters(); InitPartyConditionListParameters();
gKeyRepeatStartDelay = 20; gKeyRepeatStartDelay = 20;
structPtr->callback = HandlePartyConditionInput; structPtr->callback = HandlePartyConditionInput;
@ -67,8 +66,8 @@ bool32 PokenavCallback_Init_ConditionGraphFromSearch(void)
if (structPtr == NULL) if (structPtr == NULL)
return FALSE; return FALSE;
InitConditionGraphData(&structPtr->conditionData); ConditionGraph_Init(&structPtr->conditionData);
sub_81CD9F8(); InitSearchResultsConditionList();
gKeyRepeatStartDelay = 20; gKeyRepeatStartDelay = 20;
structPtr->callback = HandlePartyConditionInput; structPtr->callback = HandlePartyConditionInput;
return TRUE; return TRUE;
@ -81,7 +80,7 @@ u32 GetPartyConditionCallback(void)
return structPtr->callback(structPtr); return structPtr->callback(structPtr);
} }
u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr) static u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr)
{ {
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u32 ret = ConditionGraphHandleDpadInput(structPtr); u32 ret = ConditionGraphHandleDpadInput(structPtr);
@ -117,7 +116,7 @@ u32 HandlePartyConditionInput(struct PokenavSub11 *structPtr)
return ret; return ret;
} }
u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr) static u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr)
{ {
struct PokenavSub18 *monListPtr; struct PokenavSub18 *monListPtr;
u8 markings; u8 markings;
@ -143,7 +142,7 @@ u32 ConditionMenu_OpenMarkingsMenu(struct PokenavSub11 *structPtr)
return ret; return ret;
} }
u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr) static u32 GetConditionReturnCallback(struct PokenavSub11 *structPtr)
{ {
if (structPtr->searchMode == 0) if (structPtr->searchMode == 0)
return POKENAV_CONDITION_MENU; return POKENAV_CONDITION_MENU;
@ -160,7 +159,7 @@ void FreePartyConditionSubstruct1(void)
FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH); FreePokenavSubstruct(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
} }
u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr) static u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr)
{ {
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
u8 ret = 0; u8 ret = 0;
@ -170,7 +169,7 @@ u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr)
if (structPtr->searchMode == 0 || monListPtr->currIndex != 0) if (structPtr->searchMode == 0 || monListPtr->currIndex != 0)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ret = SwitchConditionSummaryIndex(1); ret = SwitchConditionSummaryIndex(TRUE);
} }
} }
else if (JOY_HELD(DPAD_DOWN)) else if (JOY_HELD(DPAD_DOWN))
@ -178,14 +177,14 @@ u8 ConditionGraphHandleDpadInput(struct PokenavSub11 *structPtr)
if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1) if (structPtr->searchMode == 0 || monListPtr->currIndex < monListPtr->listCount - 1)
{ {
PlaySE(SE_SELECT); PlaySE(SE_SELECT);
ret = SwitchConditionSummaryIndex(0); ret = SwitchConditionSummaryIndex(FALSE);
} }
} }
return ret; return ret;
} }
u8 SwitchConditionSummaryIndex(u8 moveUp) static u8 SwitchConditionSummaryIndex(u8 moveUp)
{ {
u16 r7; u16 r7;
bool8 wasNotLastMon, isNotLastMon; bool8 wasNotLastMon, isNotLastMon;
@ -235,28 +234,28 @@ bool32 LoadPartyConditionMenuGfx(void)
switch (structPtr->state) switch (structPtr->state)
{ {
case 0: case 0:
CopyMonNameGenderLocation(monListPtr->currIndex, 0); CopyMonNameGenderLocation(monListPtr->currIndex, CONDITION_MON_0);
break; break;
case 1: case 1:
GetMonConditionGraphData(monListPtr->currIndex, 0); GetMonConditionGraphData(monListPtr->currIndex, CONDITION_MON_0);
break; break;
case 2: case 2:
ConditionGraphDrawMonPic(monListPtr->currIndex, 0); ConditionGraphDrawMonPic(monListPtr->currIndex, CONDITION_MON_0);
break; break;
case 3: case 3:
if (monListPtr->listCount == 1) if (monListPtr->listCount == 1)
{ {
structPtr->mark = 0; structPtr->mark = CONDITION_MON_0;
structPtr->unk6787 = 0; structPtr->unk6787 = CONDITION_MON_0;
structPtr->unk6788 = 0; structPtr->unk6788 = CONDITION_MON_0;
structPtr->state = 0; structPtr->state = 0;
return TRUE; return TRUE;
} }
else else
{ {
structPtr->mark = 0; structPtr->mark = CONDITION_MON_0;
structPtr->unk6787 = 1; structPtr->unk6787 = CONDITION_MON_1;
structPtr->unk6788 = 2; structPtr->unk6788 = CONDITION_MON_2;
} }
break; break;
// These were probably ternaries just like cases 7-9, but couldn't match it any other way. // These were probably ternaries just like cases 7-9, but couldn't match it any other way.
@ -264,28 +263,28 @@ bool32 LoadPartyConditionMenuGfx(void)
var = monListPtr->currIndex + 1; var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount) if (var >= monListPtr->listCount)
var = 0; var = 0;
CopyMonNameGenderLocation(var, 1); CopyMonNameGenderLocation(var, CONDITION_MON_1);
break; break;
case 5: case 5:
var = monListPtr->currIndex + 1; var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount) if (var >= monListPtr->listCount)
var = 0; var = 0;
GetMonConditionGraphData(var, 1); GetMonConditionGraphData(var, CONDITION_MON_1);
break; break;
case 6: case 6:
var = monListPtr->currIndex + 1; var = monListPtr->currIndex + 1;
if (var >= monListPtr->listCount) if (var >= monListPtr->listCount)
var = 0; var = 0;
ConditionGraphDrawMonPic(var, 1); ConditionGraphDrawMonPic(var, CONDITION_MON_1);
break; break;
case 7: case 7:
CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); CopyMonNameGenderLocation((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2);
break; break;
case 8: case 8:
GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); GetMonConditionGraphData((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2);
break; break;
case 9: case 9:
ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, 2); ConditionGraphDrawMonPic((monListPtr->currIndex - 1 >= 0) ? monListPtr->currIndex - 1 : monListPtr->listCount - 1, CONDITION_MON_2);
structPtr->state = 0; structPtr->state = 0;
return TRUE; return TRUE;
} }
@ -326,15 +325,15 @@ u8 *CopyStringLeftAlignedToConditionData(u8 *dst, const u8 *src, s16 n)
return dst; return dst;
} }
u8 *CopyMonConditionNameGender(u8 *str, u16 id, bool8 arg3) static u8 *CopyConditionMonNameGender(u8 *str, u16 listId, bool8 arg3)
{ {
u16 boxId, monId, gender, species, level, lvlDigits; u16 boxId, monId, gender, species, level, lvlDigits;
struct BoxPokemon *boxMon; struct BoxPokemon *boxMon;
u8 *txtPtr, *str_; u8 *txtPtr, *str_;
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
boxId = monListPtr->monData[id].boxId; boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[id].monId; monId = monListPtr->monData[listId].monId;
*(str++) = EXT_CTRL_CODE_BEGIN; *(str++) = EXT_CTRL_CODE_BEGIN;
*(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; *(str++) = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
*(str++) = TEXT_COLOR_BLUE; *(str++) = TEXT_COLOR_BLUE;
@ -417,39 +416,39 @@ u8 *CopyMonConditionNameGender(u8 *str, u16 id, bool8 arg3)
return str_; return str_;
} }
void CopyMonNameGenderLocation(s16 id, u8 arg1) static void CopyMonNameGenderLocation(s16 listId, u8 loadId)
{ {
u16 boxId, i; u16 boxId, i;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
{ {
CopyMonConditionNameGender(structPtr->nameBuffer[arg1], id, FALSE); CopyConditionMonNameGender(structPtr->nameText[loadId], listId, FALSE);
boxId = monListPtr->monData[id].boxId; boxId = monListPtr->monData[listId].boxId;
structPtr->searchLocBuffer[arg1][0] = EXT_CTRL_CODE_BEGIN; structPtr->locationText[loadId][0] = EXT_CTRL_CODE_BEGIN;
structPtr->searchLocBuffer[arg1][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; structPtr->locationText[loadId][1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
structPtr->searchLocBuffer[arg1][2] = TEXT_COLOR_BLUE; structPtr->locationText[loadId][2] = TEXT_COLOR_BLUE;
structPtr->searchLocBuffer[arg1][3] = TEXT_COLOR_TRANSPARENT; structPtr->locationText[loadId][3] = TEXT_COLOR_TRANSPARENT;
structPtr->searchLocBuffer[arg1][4] = TEXT_COLOR_LIGHT_BLUE; structPtr->locationText[loadId][4] = TEXT_COLOR_LIGHT_BLUE;
if (boxId == TOTAL_BOXES_COUNT) if (boxId == TOTAL_BOXES_COUNT)
CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], gText_InParty, 8); CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], gText_InParty, BOX_NAME_LENGTH);
else else
CopyStringLeftAlignedToConditionData(&structPtr->searchLocBuffer[arg1][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH); CopyStringLeftAlignedToConditionData(&structPtr->locationText[loadId][5], GetBoxNamePtr(boxId), BOX_NAME_LENGTH);
} }
else else
{ {
for (i = 0; i < 12; i++) for (i = 0; i < 12; i++)
structPtr->nameBuffer[arg1][i] = CHAR_SPACE; structPtr->nameText[loadId][i] = CHAR_SPACE;
structPtr->nameBuffer[arg1][i] = EOS; structPtr->nameText[loadId][i] = EOS;
for (i = 0; i < 8; i++) for (i = 0; i < BOX_NAME_LENGTH; i++)
structPtr->searchLocBuffer[arg1][i] = CHAR_SPACE; structPtr->locationText[loadId][i] = CHAR_SPACE;
structPtr->searchLocBuffer[arg1][i] = EOS; structPtr->locationText[loadId][i] = EOS;
} }
} }
void InitPartyConditionListParameters(void) static void InitPartyConditionListParameters(void)
{ {
u16 i, count; u16 i, count;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
@ -475,62 +474,60 @@ void InitPartyConditionListParameters(void)
structPtr->state = 0; structPtr->state = 0;
} }
void sub_81CD9F8(void) static void InitSearchResultsConditionList(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
structPtr->searchMode = 1; structPtr->searchMode = 1;
structPtr->state = 0; structPtr->state = 0;
} }
void GetMonConditionGraphData(s16 id, u8 arg1) static void GetMonConditionGraphData(s16 listId, u8 loadId)
{ {
u16 boxId, monId, i; u16 boxId, monId, i;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (id != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) if (listId != (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
{ {
boxId = monListPtr->monData[id].boxId; boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[id].monId; monId = monListPtr->monData[listId].monId;
structPtr->conditionData.stat[arg1][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL); structPtr->conditionData.conditions[loadId][CONDITION_COOL] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
structPtr->conditionData.stat[arg1][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL); structPtr->conditionData.conditions[loadId][CONDITION_TOUGH] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
structPtr->conditionData.stat[arg1][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL); structPtr->conditionData.conditions[loadId][CONDITION_SMART] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
structPtr->conditionData.stat[arg1][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL); structPtr->conditionData.conditions[loadId][CONDITION_CUTE] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
structPtr->conditionData.stat[arg1][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL); structPtr->conditionData.conditions[loadId][CONDITION_BEAUTY] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
structPtr->sheen[arg1] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 255) structPtr->numSparkles[loadId] = GET_NUM_CONDITION_SPARKLES(GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL));
? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u structPtr->monMarks[loadId] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
: 9; sub_81D2754(structPtr->conditionData.conditions[loadId], structPtr->conditionData.unk14[loadId]);
structPtr->monMarks[arg1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_MARKINGS, NULL);
sub_81D2754(structPtr->conditionData.stat[arg1], structPtr->conditionData.unk14[arg1]);
} }
else else
{ {
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
{ {
structPtr->conditionData.stat[arg1][i] = 0; structPtr->conditionData.conditions[loadId][i] = 0;
structPtr->conditionData.unk14[arg1][i].unk0 = 155; structPtr->conditionData.unk14[loadId][i].unk0 = CONDITION_GRAPH_CENTER_X;
structPtr->conditionData.unk14[arg1][i].unk2 = 91; structPtr->conditionData.unk14[loadId][i].unk2 = CONDITION_GRAPH_UNK;
} }
} }
} }
void ConditionGraphDrawMonPic(s16 index, u8 arg1) static void ConditionGraphDrawMonPic(s16 listId, u8 loadId)
{ {
u16 boxId, monId, species; u16 boxId, monId, species;
u32 personality, tid; u32 personality, tid;
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST); struct PokenavSub18 *monListPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_LIST);
if (index == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1)) if (listId == (IsConditionMenuSearchMode() != 0 ? monListPtr->listCount : monListPtr->listCount - 1))
return; return;
boxId = monListPtr->monData[index].boxId; boxId = monListPtr->monData[listId].boxId;
monId = monListPtr->monData[index].monId; monId = monListPtr->monData[listId].monId;
species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL); species = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SPECIES2, NULL);
tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL); tid = GetBoxOrPartyMonData(boxId, monId, MON_DATA_OT_ID, NULL);
personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL); personality = GetBoxOrPartyMonData(boxId, monId, MON_DATA_PERSONALITY, NULL);
LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[arg1], species, personality, TRUE); LoadSpecialPokePic(&gMonFrontPicTable[species], structPtr->monPicGfx[loadId], species, personality, TRUE);
LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[arg1]); LZ77UnCompWram(GetMonSpritePalFromSpeciesAndPersonality(species, tid, personality), structPtr->monPal[loadId]);
} }
u16 GetMonListCount(void) u16 GetMonListCount(void)
@ -563,16 +560,16 @@ u8 sub_81CDC9C(void)
return structPtr->monIndex; return structPtr->monIndex;
} }
void *GetConditionMonPicGfx(u8 id) void *GetConditionMonPicGfx(u8 loadId)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->monPicGfx[id]; return structPtr->monPicGfx[loadId];
} }
void *GetConditionMonPal(u8 id) void *GetConditionMonPal(u8 loadId)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->monPal[id]; return structPtr->monPal[loadId];
} }
u8 sub_81CDCEC(void) u8 sub_81CDCEC(void)
@ -581,16 +578,16 @@ u8 sub_81CDCEC(void)
return structPtr->unk6789; return structPtr->unk6789;
} }
u8 *GetConditionMonNameBuffer(u8 id) u8 *GetConditionMonNameText(u8 loadId)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->nameBuffer[id]; return structPtr->nameText[loadId];
} }
u8 *GetConditionMonLocationBuffer(u8 id) u8 *GetConditionMonLocationText(u8 loadId)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->searchLocBuffer[id]; return structPtr->locationText[loadId];
} }
u16 GetConditionMonDataBuffer(void) u16 GetConditionMonDataBuffer(void)
@ -617,8 +614,8 @@ u8 TryGetMonMarkId(void)
return 0; return 0;
} }
u8 GetMonSheen(void) u8 GetNumConditionMonSparkles(void)
{ {
struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH); struct PokenavSub11 *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_CONDITION_GRAPH);
return structPtr->sheen[structPtr->mark]; return structPtr->numSparkles[structPtr->mark];
} }

View File

@ -15,22 +15,22 @@
#include "strings.h" #include "strings.h"
#include "text.h" #include "text.h"
u32 LoopedTask_TransitionMons(s32); static u32 LoopedTask_TransitionMons(s32);
u32 LoopedTask_ExitPartyConditionMenu(s32); static u32 LoopedTask_ExitPartyConditionMenu(s32);
u32 LoopedTask_MoveCursorNoTransition(s32); static u32 LoopedTask_MoveCursorNoTransition(s32);
u32 LoopedTask_SlideMonOut(s32); static u32 LoopedTask_SlideMonOut(s32);
u32 LoopedTask_OpenMonMarkingsWindow(s32); static u32 LoopedTask_OpenMonMarkingsWindow(s32);
u32 LoopedTask_CloseMonMarkingsWindow(s32); static u32 LoopedTask_CloseMonMarkingsWindow(s32);
BSS_DATA u8 gUnknown_030012BC; static u8 sUnknown_030012BC;
const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal"); const u16 gConditionGraphData_Pal[] = INCBIN_U16("graphics/pokenav/condition/graph_data.gbapal");
const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal"); const u16 gConditionText_Pal[] = INCBIN_U16("graphics/pokenav/condition/text.gbapal");
const u32 gUnknown_08623228[] = INCBIN_U32("graphics/pokenav/8623228.4bpp.lz"); static const u32 sUnknown_08623228[] = INCBIN_U32("graphics/pokenav/condition/graph_data.4bpp.lz");
const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz"); static const u32 sConditionGraph_Tilemap[] = INCBIN_U32("graphics/pokenav/862323C.bin.lz");
const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal"); static const u16 sConditionGraphMonMarkingsPal[] = INCBIN_U16("graphics/pokenav/8623338.gbapal");
const struct BgTemplate sPartyConditionBgTemplates[3] = static const struct BgTemplate sPartyConditionBgTemplates[3] =
{ {
{ {
.bg = 1, .bg = 1,
@ -61,7 +61,7 @@ const struct BgTemplate sPartyConditionBgTemplates[3] =
} }
}; };
const struct WindowTemplate sMonNameGenderWindowTemplate = static const struct WindowTemplate sMonNameGenderWindowTemplate =
{ {
.bg = 1, .bg = 1,
.tilemapLeft = 13, .tilemapLeft = 13,
@ -72,7 +72,7 @@ const struct WindowTemplate sMonNameGenderWindowTemplate =
.baseBlock = 2 .baseBlock = 2
}; };
const struct WindowTemplate sConditionGraphListIdWindowTemplate = static const struct WindowTemplate sConditionGraphListIdWindowTemplate =
{ {
.bg = 1, .bg = 1,
.tilemapLeft = 1, .tilemapLeft = 1,
@ -83,7 +83,7 @@ const struct WindowTemplate sConditionGraphListIdWindowTemplate =
.baseBlock = 0x36 .baseBlock = 0x36
}; };
const struct WindowTemplate sUnusedWindowTemplate1 = static const struct WindowTemplate sUnusedWindowTemplate1 =
{ {
.bg = 1, .bg = 1,
.tilemapLeft = 1, .tilemapLeft = 1,
@ -94,7 +94,7 @@ const struct WindowTemplate sUnusedWindowTemplate1 =
.baseBlock = 0x44 .baseBlock = 0x44
}; };
const struct WindowTemplate sUnusedWindowTemplate2 = static const struct WindowTemplate sUnusedWindowTemplate2 =
{ {
.bg = 1, .bg = 1,
.tilemapLeft = 13, .tilemapLeft = 13,
@ -105,7 +105,7 @@ const struct WindowTemplate sUnusedWindowTemplate2 =
.baseBlock = 0x44 .baseBlock = 0x44
}; };
const LoopedTask sPartyConditionLoopedTaskFuncs[] = static const LoopedTask sPartyConditionLoopedTaskFuncs[] =
{ {
[PARTY_CONDITION_FUNC_NONE] = NULL, [PARTY_CONDITION_FUNC_NONE] = NULL,
[PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons, [PARTY_CONDITION_FUNC_SLIDE_MON_IN] = LoopedTask_TransitionMons,
@ -132,26 +132,26 @@ struct Pokenav7Struct
u8 listIndexWindowId; u8 listIndexWindowId;
u8 unusedWindowId1; u8 unusedWindowId1;
u8 unusedWindowId2; u8 unusedWindowId2;
struct MonMarkingsMenu monMarks; struct MonMarkingsMenu marksMenu;
struct Sprite *monMarksSprite; struct Sprite *monMarksSprite;
struct Sprite *conditionSparkleSprites[MAX_CONDITION_SPARKLES]; struct Sprite *conditionSparkleSprites[MAX_CONDITION_SPARKLES];
u8 windowModeState; u8 windowModeState;
u8 filler2[0x38ac - 0x2909]; u8 filler2[0xFA3];
}; };
extern s8 GetMonMarkIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c extern s8 GetMonMarkIndex(void); // This function's declaration here is s8 vs. u8 in pokenav_conditions_1.c
u32 LoopedTask_OpenPartyConditionGraph(s32 state); static u32 LoopedTask_OpenPartyConditionGraph(s32 state);
u32 GetPartyConditionLoopedTaskActive(void); static u32 GetPartyConditionLoopedTaskActive(void);
void CreateConditionMonPic(u8 var); static void CreateConditionMonPic(u8 var);
void CreateMonMarkingsOrPokeballIndicators(void); static void CreateMonMarkingsOrPokeballIndicators(void);
void CopyUnusedConditionWindowsToVram(void); static void CopyUnusedConditionWindowsToVram(void);
bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2); static bool32 UpdateConditionGraphWindows(u8 a0, u16 a1, bool8 a2);
void sub_81CEE44(void); static void sub_81CEE44(void);
void DoConditionGraphTransition(void); static void DoConditionGraphTransition(void);
void sub_81CEEC8(void); static void sub_81CEEC8(void);
void sub_81CEE68(void); static void sub_81CEE68(void);
void ToggleBg2(bool8 showBg); static void ToggleGraphData(bool8 showBg);
// code // code
bool32 OpenPartyConditionMenu(void) bool32 OpenPartyConditionMenu(void)
@ -181,13 +181,13 @@ u32 IsPartyConditionLoopedTaskActive(void)
return structPtr->callback(); return structPtr->callback();
} }
u32 GetPartyConditionLoopedTaskActive(void) static u32 GetPartyConditionLoopedTaskActive(void)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
return IsLoopedTaskActive(structPtr->loopedTaskId); return IsLoopedTaskActive(structPtr->loopedTaskId);
} }
u32 LoopedTask_OpenPartyConditionGraph(s32 state) static u32 LoopedTask_OpenPartyConditionGraph(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
@ -213,7 +213,7 @@ u32 LoopedTask_OpenPartyConditionGraph(s32 state)
case 2: case 2:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
return LT_PAUSE; return LT_PAUSE;
DecompressAndCopyTileDataToVram(2, gUnknown_08623228, 0, 0, 0); DecompressAndCopyTileDataToVram(2, sUnknown_08623228, 0, 0, 0);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 3: case 3:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
@ -320,14 +320,14 @@ u32 LoopedTask_OpenPartyConditionGraph(s32 state)
return LT_PAUSE; return LT_PAUSE;
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 19: case 19:
ToggleBg2(TRUE); ToggleGraphData(TRUE);
return LT_INC_AND_PAUSE; return LT_INC_AND_PAUSE;
case 20: case 20:
if (!TryUpdateConditionMonTransitionOn(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) if (!ConditionGraph_UpdateMonEnter(GetConditionGraphDataPtr(), &structPtr->monTransitionX))
{ {
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount()) if (IsConditionMenuSearchMode() == TRUE || GetConditionGraphCurrentMonIndex() != GetMonListCount())
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles());
return LT_FINISH; return LT_FINISH;
} }
@ -337,7 +337,7 @@ u32 LoopedTask_OpenPartyConditionGraph(s32 state)
return LT_FINISH; return LT_FINISH;
} }
u32 LoopedTask_ExitPartyConditionMenu(s32 state) static u32 LoopedTask_ExitPartyConditionMenu(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
@ -348,9 +348,9 @@ u32 LoopedTask_ExitPartyConditionMenu(s32 state)
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 1: case 1:
if (TryUpdateConditionMonTransitionOff(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) if (ConditionGraph_UpdateMonExit(GetConditionGraphDataPtr(), &structPtr->monTransitionX))
return 2; return 2;
ToggleBg2(FALSE); ToggleGraphData(FALSE);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 2: case 2:
PokenavFadeScreen(0); PokenavFadeScreen(0);
@ -370,10 +370,10 @@ u32 LoopedTask_ExitPartyConditionMenu(s32 state)
return LT_FINISH; return LT_FINISH;
} }
u32 LoopedTask_TransitionMons(s32 state) static u32 LoopedTask_TransitionMons(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
struct ConditionGraph *unkPtr = GetConditionGraphDataPtr(); struct ConditionGraph *graph = GetConditionGraphDataPtr();
switch (state) switch (state)
{ {
@ -388,7 +388,7 @@ u32 LoopedTask_TransitionMons(s32 state)
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 3: case 3:
TransitionConditionGraph(unkPtr); TransitionConditionGraph(graph);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 4: case 4:
if (!MoveConditionMonOffscreen(&structPtr->monTransitionX)) if (!MoveConditionMonOffscreen(&structPtr->monTransitionX))
@ -411,14 +411,14 @@ u32 LoopedTask_TransitionMons(s32 state)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
return LT_PAUSE; return LT_PAUSE;
case 9: case 9:
unkPtr = GetConditionGraphDataPtr(); graph = GetConditionGraphDataPtr();
if (!TryUpdateConditionMonTransitionOn(unkPtr, &structPtr->monTransitionX)) if (!ConditionGraph_UpdateMonEnter(graph, &structPtr->monTransitionX))
{ {
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount()) if (IsConditionMenuSearchMode() != TRUE && GetConditionGraphCurrentMonIndex() == GetMonListCount())
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles());
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
return LT_PAUSE; return LT_PAUSE;
@ -427,7 +427,7 @@ u32 LoopedTask_TransitionMons(s32 state)
return LT_FINISH; return LT_FINISH;
} }
u32 LoopedTask_MoveCursorNoTransition(s32 state) static u32 LoopedTask_MoveCursorNoTransition(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
@ -459,10 +459,10 @@ u32 LoopedTask_MoveCursorNoTransition(s32 state)
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
return LT_PAUSE; return LT_PAUSE;
case 8: case 8:
if (!TryUpdateConditionMonTransitionOn(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) if (!ConditionGraph_UpdateMonEnter(GetConditionGraphDataPtr(), &structPtr->monTransitionX))
{ {
ResetConditionSparkleSprites(structPtr->conditionSparkleSprites); ResetConditionSparkleSprites(structPtr->conditionSparkleSprites);
CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetMonSheen()); CreateConditionSparkleSprites(structPtr->conditionSparkleSprites, structPtr->monPicSpriteId, GetNumConditionMonSparkles());
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
} }
return LT_PAUSE; return LT_PAUSE;
@ -471,7 +471,7 @@ u32 LoopedTask_MoveCursorNoTransition(s32 state)
return LT_FINISH; return LT_FINISH;
} }
u32 LoopedTask_SlideMonOut(s32 state) static u32 LoopedTask_SlideMonOut(s32 state)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
@ -488,7 +488,7 @@ u32 LoopedTask_SlideMonOut(s32 state)
DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites); DestroyConditionSparkleSprites(structPtr->conditionSparkleSprites);
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
case 3: case 3:
if (!TryUpdateConditionMonTransitionOff(GetConditionGraphDataPtr(), &structPtr->monTransitionX)) if (!ConditionGraph_UpdateMonExit(GetConditionGraphDataPtr(), &structPtr->monTransitionX))
return LT_INC_AND_CONTINUE; return LT_INC_AND_CONTINUE;
return LT_PAUSE; return LT_PAUSE;
case 4: case 4:
@ -509,7 +509,7 @@ u32 LoopedTask_SlideMonOut(s32 state)
return LT_FINISH; return LT_FINISH;
} }
u32 LoopedTask_OpenMonMarkingsWindow(s32 state) static u32 LoopedTask_OpenMonMarkingsWindow(s32 state)
{ {
switch (state) switch (state)
{ {
@ -528,7 +528,7 @@ u32 LoopedTask_OpenMonMarkingsWindow(s32 state)
return LT_FINISH; return LT_FINISH;
} }
u32 LoopedTask_CloseMonMarkingsWindow(s32 state) static u32 LoopedTask_CloseMonMarkingsWindow(s32 state)
{ {
switch (state) switch (state)
{ {
@ -555,7 +555,7 @@ static u8 *UnusedPrintNumberString(u8 *dst, u16 num)
return txtPtr; return txtPtr;
} }
bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode) static bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode)
{ {
u8 text[32]; u8 text[32];
const u8 *str; const u8 *str;
@ -571,23 +571,23 @@ bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode)
case 1: case 1:
if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE) if (GetConditionGraphCurrentMonIndex() != GetMonListCount() - 1 || IsConditionMenuSearchMode() == TRUE)
{ {
str = GetConditionMonNameBuffer(bufferIndex); str = GetConditionMonNameText(bufferIndex);
AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL); AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 1, 0, NULL);
} }
break; break;
case 2: case 2:
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
str = GetConditionMonLocationBuffer(bufferIndex); str = GetConditionMonLocationText(bufferIndex);
AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL); AddTextPrinterParameterized(structPtr->nameGenderWindowId, FONT_NORMAL, str, 0, 17, 0, NULL);
text[0] = EXT_CTRL_CODE_BEGIN; text[0] = EXT_CTRL_CODE_BEGIN;
text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW; text[1] = EXT_CTRL_CODE_COLOR_HIGHLIGHT_SHADOW;
text[2] = TEXT_COLOR_BLUE; text[2] = TEXT_COLOR_BLUE;
text[3] = TEXT_COLOR_TRANSPARENT; text[3] = TEXT_COLOR_TRANSPARENT;
text[4] = TEXT_COLOR_LIGHT_BLUE; text[4] = TEXT_COLOR_LIGHT_BLUE;
StringCopy(text + 5, gText_Number2); StringCopy(&text[5], gText_Number2);
AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL); AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 4, 1, 0, NULL);
ConvertIntToDecimalStringN(text + 5, GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4); ConvertIntToDecimalStringN(&text[5], GetConditionMonDataBuffer(), STR_CONV_MODE_RIGHT_ALIGN, 4);
AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL); AddTextPrinterParameterized(structPtr->listIndexWindowId, FONT_NORMAL, text, 28, 1, 0, NULL);
} }
break; break;
@ -624,7 +624,7 @@ bool32 UpdateConditionGraphWindows(u8 mode, u16 bufferIndex, bool8 winMode)
return FALSE; return FALSE;
} }
void CopyUnusedConditionWindowsToVram(void) static void CopyUnusedConditionWindowsToVram(void)
{ {
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
@ -643,9 +643,9 @@ void sub_81CE964(struct Sprite *sprite)
void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite) void HighlightCurrentPartyIndexPokeball(struct Sprite *sprite)
{ {
if (GetConditionGraphCurrentMonIndex() == GetMonListCount() - 1) if (GetConditionGraphCurrentMonIndex() == GetMonListCount() - 1)
sprite->oam.paletteNum = IndexOfSpritePaletteTag(0x65); sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_BALL);
else else
sprite->oam.paletteNum = IndexOfSpritePaletteTag(0x66); sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_CANCEL);
} }
void MonMarkingsCallback(struct Sprite *sprite) void MonMarkingsCallback(struct Sprite *sprite)
@ -653,7 +653,7 @@ void MonMarkingsCallback(struct Sprite *sprite)
StartSpriteAnim(sprite, TryGetMonMarkId()); StartSpriteAnim(sprite, TryGetMonMarkId());
} }
void CreateMonMarkingsOrPokeballIndicators(void) static void CreateMonMarkingsOrPokeballIndicators(void)
{ {
struct SpriteSheet sprSheets[4]; struct SpriteSheet sprSheets[4];
struct SpriteTemplate sprTemplate; struct SpriteTemplate sprTemplate;
@ -666,17 +666,17 @@ void CreateMonMarkingsOrPokeballIndicators(void)
LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals); LoadConditionSelectionIcons(sprSheets, &sprTemplate, sprPals);
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
structPtr->monMarks.baseTileTag = 0x6A; structPtr->marksMenu.baseTileTag = TAG_CONDITION_MARKINGS_MENU;
structPtr->monMarks.basePaletteTag = 0x6A; structPtr->marksMenu.basePaletteTag = TAG_CONDITION_MARKINGS_MENU;
InitMonMarkingsMenu(&structPtr->monMarks); InitMonMarkingsMenu(&structPtr->marksMenu);
BufferMonMarkingsMenuTiles(); BufferMonMarkingsMenuTiles();
sprite = CreateMonMarkingAllCombosSprite(0x69, 0x69, sConditionGraphMonMarkingsPal); sprite = CreateMonMarkingAllCombosSprite(TAG_CONDITION_MON_MARKINGS, TAG_CONDITION_MON_MARKINGS, sConditionGraphMonMarkingsPal);
sprite->oam.priority = 3; sprite->oam.priority = 3;
sprite->x = 192; sprite->x = 192;
sprite->y = 32; sprite->y = 32;
sprite->callback = MonMarkingsCallback; sprite->callback = MonMarkingsCallback;
structPtr->monMarksSprite = sprite; structPtr->monMarksSprite = sprite;
PokenavFillPalette(IndexOfSpritePaletteTag(0x69), 0); PokenavFillPalette(IndexOfSpritePaletteTag(TAG_CONDITION_MON_MARKINGS), 0);
} }
else else
{ {
@ -698,7 +698,7 @@ void CreateMonMarkingsOrPokeballIndicators(void)
} }
} }
sprTemplate.tileTag = 0x67; sprTemplate.tileTag = TAG_CONDITION_BALL_PLACEHOLDER;
sprTemplate.callback = SpriteCallbackDummy; sprTemplate.callback = SpriteCallbackDummy;
for (; i < 6; i++) for (; i < 6; i++)
{ {
@ -714,7 +714,7 @@ void CreateMonMarkingsOrPokeballIndicators(void)
} }
} }
sprTemplate.tileTag = 0x66; sprTemplate.tileTag = TAG_CONDITION_CANCEL;
sprTemplate.callback = HighlightCurrentPartyIndexPokeball; sprTemplate.callback = HighlightCurrentPartyIndexPokeball;
spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0); spriteId = CreateSprite(&sprTemplate, 222, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES) if (spriteId != MAX_SPRITES)
@ -742,28 +742,28 @@ void sub_81CEBF4(struct Pokenav7Struct *structPtr)
if (IsConditionMenuSearchMode() == TRUE) if (IsConditionMenuSearchMode() == TRUE)
{ {
DestroySprite(structPtr->monMarksSprite); DestroySprite(structPtr->monMarksSprite);
FreeSpriteTilesByTag(0x6A); FreeSpriteTilesByTag(TAG_CONDITION_MARKINGS_MENU);
FreeSpriteTilesByTag(0x69); FreeSpriteTilesByTag(TAG_CONDITION_MON_MARKINGS);
FreeSpritePaletteByTag(0x6A); FreeSpritePaletteByTag(TAG_CONDITION_MARKINGS_MENU);
FreeSpritePaletteByTag(0x69); FreeSpritePaletteByTag(TAG_CONDITION_MON_MARKINGS);
} }
else else
{ {
for (i = 0; i < 7; i++) for (i = 0; i < 7; i++)
DestroySprite(&gSprites[structPtr->partyPokeballSpriteIds[i]]); DestroySprite(&gSprites[structPtr->partyPokeballSpriteIds[i]]);
FreeSpriteTilesByTag(0x65); FreeSpriteTilesByTag(TAG_CONDITION_BALL);
FreeSpriteTilesByTag(0x66); FreeSpriteTilesByTag(TAG_CONDITION_CANCEL);
FreeSpriteTilesByTag(0x67); FreeSpriteTilesByTag(TAG_CONDITION_BALL_PLACEHOLDER);
FreeSpritePaletteByTag(0x65); FreeSpritePaletteByTag(TAG_CONDITION_BALL);
FreeSpritePaletteByTag(0x66); FreeSpritePaletteByTag(TAG_CONDITION_CANCEL);
} }
if (structPtr->monPicSpriteId != SPRITE_NONE) if (structPtr->monPicSpriteId != SPRITE_NONE)
{ {
DestroySprite(&gSprites[structPtr->monPicSpriteId]); DestroySprite(&gSprites[structPtr->monPicSpriteId]);
FreeSpriteTilesByTag(0x64); FreeSpriteTilesByTag(TAG_CONDITION_MON);
FreeSpritePaletteByTag(0x64); FreeSpritePaletteByTag(TAG_CONDITION_MON);
} }
} }
@ -795,7 +795,7 @@ void MonPicGfxSpriteCallback(struct Sprite *sprite)
sprite->x = structPtr->monTransitionX + 38; sprite->x = structPtr->monTransitionX + 38;
} }
void CreateConditionMonPic(u8 id) static void CreateConditionMonPic(u8 id)
{ {
struct SpriteTemplate sprTemplate; struct SpriteTemplate sprTemplate;
struct SpriteSheet sprSheet; struct SpriteSheet sprSheet;
@ -814,15 +814,15 @@ void CreateConditionMonPic(u8 id)
structPtr->monPicSpriteId = spriteId; structPtr->monPicSpriteId = spriteId;
if (spriteId == MAX_SPRITES) if (spriteId == MAX_SPRITES)
{ {
FreeSpriteTilesByTag(0x64); FreeSpriteTilesByTag(TAG_CONDITION_MON);
FreeSpritePaletteByTag(0x64); FreeSpritePaletteByTag(TAG_CONDITION_MON);
structPtr->monPicSpriteId = SPRITE_NONE; structPtr->monPicSpriteId = SPRITE_NONE;
} }
else else
{ {
structPtr->monPicSpriteId = spriteId; structPtr->monPicSpriteId = spriteId;
gSprites[structPtr->monPicSpriteId].callback = MonPicGfxSpriteCallback; gSprites[structPtr->monPicSpriteId].callback = MonPicGfxSpriteCallback;
structPtr->unk181C = (void*)(VRAM) + 0x10000 + (structPtr->monGfxTileStart * 32); structPtr->unk181C = (void*)VRAM + BG_VRAM_SIZE + (structPtr->monGfxTileStart * 32);
structPtr->monPalIndex = (structPtr->monPalIndex * 16) + 0x100; structPtr->monPalIndex = (structPtr->monPalIndex * 16) + 0x100;
} }
} }
@ -833,22 +833,22 @@ void CreateConditionMonPic(u8 id)
} }
} }
void sub_81CEE44(void) static void sub_81CEE44(void)
{ {
struct ConditionGraph *unk = GetConditionGraphDataPtr(); struct ConditionGraph *graph = GetConditionGraphDataPtr();
LoadOam(); LoadOam();
ProcessSpriteCopyRequests(); ProcessSpriteCopyRequests();
TransferPlttBuffer(); TransferPlttBuffer();
sub_81D2108(unk); sub_81D2108(graph);
ScanlineEffect_InitHBlankDmaTransfer(); ScanlineEffect_InitHBlankDmaTransfer();
} }
void sub_81CEE68(void) static void sub_81CEE68(void)
{ {
SetPokenavVBlankCallback(); SetPokenavVBlankCallback();
} }
void ToggleBg2(bool8 showBg) static void ToggleGraphData(bool8 showBg)
{ {
if (showBg) if (showBg)
ShowBg(2); ShowBg(2);
@ -856,17 +856,17 @@ void ToggleBg2(bool8 showBg)
HideBg(2); HideBg(2);
} }
void DoConditionGraphTransition(void) static void DoConditionGraphTransition(void)
{ {
struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr(); struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr();
u8 id = GetMonMarkIndex(); u8 id = GetMonMarkIndex();
gUnknown_030012BC = id; sUnknown_030012BC = id;
sub_81D1F84(conditionPtr, conditionPtr->unk14[3], conditionPtr->unk14[id]); sub_81D1F84(conditionPtr, conditionPtr->unk14[3], conditionPtr->unk14[id]);
TransitionConditionGraph(conditionPtr); TransitionConditionGraph(conditionPtr);
} }
void sub_81CEEC8(void) static void sub_81CEEC8(void)
{ {
struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr(); struct ConditionGraph *conditionPtr = GetConditionGraphDataPtr();
@ -879,7 +879,7 @@ u8 GetMonMarkingsData(void)
struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU); struct Pokenav7Struct *structPtr = GetSubstructPtr(POKENAV_SUBSTRUCT_MON_MARK_MENU);
if (IsConditionMenuSearchMode() == 1) if (IsConditionMenuSearchMode() == 1)
return structPtr->monMarks.markings; return structPtr->marksMenu.markings;
else else
return 0; return 0;
} }

View File

@ -314,10 +314,10 @@ static const struct SpriteTemplate sMatchCallBlueLightSpriteTemplate =
static const struct ScanlineEffectParams sPokenavMainMenuScanlineEffectParams = static const struct ScanlineEffectParams sPokenavMainMenuScanlineEffectParams =
{ {
(void *)REG_ADDR_WIN0H, &REG_WIN0H,
((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1,
1, 1,
0 0
}; };
static bool32 PlayerHasTrainerRematches(void) static bool32 PlayerHasTrainerRematches(void)

View File

@ -57,14 +57,14 @@ struct UsePokeblockSession
u8 mainState; u8 mainState;
u8 unused1; u8 unused1;
u8 timer; u8 timer;
u8 statId; u8 condition;
u8 numEnhancements; u8 numEnhancements;
u8 unused2; u8 unused2;
bool8 monInTopHalf; bool8 monInTopHalf;
u8 conditionsBeforeBlock[FLAVOR_COUNT]; u8 conditionsBeforeBlock[CONDITION_COUNT];
u8 conditionsAfterBlock[FLAVOR_COUNT]; u8 conditionsAfterBlock[CONDITION_COUNT];
u8 enhancements[FLAVOR_COUNT]; u8 enhancements[CONDITION_COUNT];
s16 pokeblockStatBoosts[FLAVOR_COUNT]; s16 pokeblockStatBoosts[CONDITION_COUNT];
u8 numSelections; // num in party + 1 (for Cancel) u8 numSelections; // num in party + 1 (for Cancel)
u8 curSelection; u8 curSelection;
bool8 (*loadNewSelection)(void); bool8 (*loadNewSelection)(void);
@ -142,7 +142,7 @@ static void LoadAndCreateUpDownSprites(void);
static void CalculateNumAdditionalSparkles(u8); static void CalculateNumAdditionalSparkles(u8);
static void PrintFirstEnhancement(void); static void PrintFirstEnhancement(void);
static bool8 TryPrintNextEnhancement(void); static bool8 TryPrintNextEnhancement(void);
static void BufferEnhancedStatText(u8 *, u8, s16); static void BufferEnhancedText(u8 *, u8, s16);
static void PrintMenuWindowText(const u8 *); static void PrintMenuWindowText(const u8 *);
static void CalculatePokeblockEffectiveness(struct Pokeblock *, struct Pokemon *); static void CalculatePokeblockEffectiveness(struct Pokeblock *, struct Pokemon *);
static void SpriteCB_UpDown(struct Sprite *); static void SpriteCB_UpDown(struct Sprite *);
@ -178,22 +178,22 @@ static const u32 sGraphData_Tilemap[] = INCBIN_U32("graphics/pokeblock/use_scree
// The condition/flavors aren't listed in their normal order in this file, they're listed as shown on the graph going counter-clockwise // The condition/flavors aren't listed in their normal order in this file, they're listed as shown on the graph going counter-clockwise
// Normally they would go Cool/Spicy, Beauty/Dry, Cute/Sweet, Smart/Bitter, Tough/Sour (also graph order, but clockwise) // Normally they would go Cool/Spicy, Beauty/Dry, Cute/Sweet, Smart/Bitter, Tough/Sour (also graph order, but clockwise)
static const u32 sMonDataConditions[FLAVOR_COUNT] = static const u32 sConditionToMonData[CONDITION_COUNT] =
{ {
MON_DATA_COOL, [CONDITION_COOL] = MON_DATA_COOL,
MON_DATA_TOUGH, [CONDITION_TOUGH] = MON_DATA_TOUGH,
MON_DATA_SMART, [CONDITION_SMART] = MON_DATA_SMART,
MON_DATA_CUTE, [CONDITION_CUTE] = MON_DATA_CUTE,
MON_DATA_BEAUTY [CONDITION_BEAUTY] = MON_DATA_BEAUTY
}; };
static const u8 sFlavors[FLAVOR_COUNT] = static const u8 sConditionToFlavor[CONDITION_COUNT] =
{ {
FLAVOR_SPICY, [CONDITION_COOL] = FLAVOR_SPICY,
FLAVOR_SOUR, [CONDITION_TOUGH] = FLAVOR_SOUR,
FLAVOR_BITTER, [CONDITION_SMART] = FLAVOR_BITTER,
FLAVOR_SWEET, [CONDITION_CUTE] = FLAVOR_SWEET,
FLAVOR_DRY [CONDITION_BEAUTY] = FLAVOR_DRY
}; };
static const u8 sNatureTextColors[] = static const u8 sNatureTextColors[] =
@ -286,13 +286,13 @@ static const struct WindowTemplate sUsePokeblockYesNoWinTemplate =
.baseBlock = 0x83 .baseBlock = 0x83
}; };
static const u8 *const sContestStatNames[] = static const u8 *const sConditionNames[CONDITION_COUNT] =
{ {
gText_Coolness, [CONDITION_COOL] = gText_Coolness,
gText_Toughness, [CONDITION_TOUGH] = gText_Toughness,
gText_Smartness, [CONDITION_SMART] = gText_Smartness,
gText_Cuteness, [CONDITION_CUTE] = gText_Cuteness,
gText_Beauty3 [CONDITION_BEAUTY] = gText_Beauty3
}; };
static const struct SpriteSheet sSpriteSheet_UpDown = static const struct SpriteSheet sSpriteSheet_UpDown =
@ -305,13 +305,13 @@ static const struct SpritePalette sSpritePalette_UpDown =
gUsePokeblockUpDown_Pal, TAG_UP_DOWN gUsePokeblockUpDown_Pal, TAG_UP_DOWN
}; };
static const s16 sUpDownCoordsOnGraph[FLAVOR_COUNT][2] = static const s16 sUpDownCoordsOnGraph[CONDITION_COUNT][2] =
{ {
{156, 36}, [CONDITION_COOL] = {156, 36},
{117, 59}, [CONDITION_TOUGH] = {117, 59},
{117, 118}, [CONDITION_SMART] = {117, 118},
{197, 118}, [CONDITION_CUTE] = {197, 118},
{197, 59} [CONDITION_BEAUTY] = {197, 59}
}; };
static const struct OamData sOam_UpDown = static const struct OamData sOam_UpDown =
@ -487,7 +487,7 @@ static void LoadUsePokeblockMenu(void)
{ {
case 0: case 0:
sMenu->curMonSpriteId = SPRITE_NONE; sMenu->curMonSpriteId = SPRITE_NONE;
InitConditionGraphData(&sMenu->graph); ConditionGraph_Init(&sMenu->graph);
sInfo->mainState++; sInfo->mainState++;
break; break;
case 1: case 1:
@ -537,7 +537,7 @@ static void LoadUsePokeblockMenu(void)
sInfo->mainState++; sInfo->mainState++;
break; break;
case 11: case 11:
sub_81D2754(sMenu->graph.stat[0], sMenu->graph.unk14[0]); sub_81D2754(sMenu->graph.conditions[0], sMenu->graph.unk14[0]);
InitConditionGraphState(&sMenu->graph); InitConditionGraphState(&sMenu->graph);
sInfo->mainState++; sInfo->mainState++;
break; break;
@ -767,8 +767,6 @@ static void ShowUsePokeblockMenuForResults(void)
static void ShowPokeblockResults(void) static void ShowPokeblockResults(void)
{ {
u8 var;
switch (sInfo->mainState) switch (sInfo->mainState)
{ {
case 0: case 0:
@ -789,8 +787,7 @@ static void ShowPokeblockResults(void)
sInfo->mainState++; sInfo->mainState++;
break; break;
case 3: case 3:
var = TransitionConditionGraph(&sMenu->graph); if (!TransitionConditionGraph(&sMenu->graph))
if (!var)
{ {
CalculateNumAdditionalSparkles(GetPartyIdFromSelectionId(sMenu->info.curSelection)); CalculateNumAdditionalSparkles(GetPartyIdFromSelectionId(sMenu->info.curSelection));
if (sMenu->info.curSelection != sMenu->info.numSelections - 1) if (sMenu->info.curSelection != sMenu->info.numSelections - 1)
@ -906,16 +903,16 @@ static void PrintFirstEnhancement(void)
DrawTextBorderOuter(WIN_TEXT, 151, 14); DrawTextBorderOuter(WIN_TEXT, 151, 14);
FillWindowPixelBuffer(WIN_TEXT, 17); FillWindowPixelBuffer(WIN_TEXT, 17);
for (sInfo->statId = 0; sInfo->statId < FLAVOR_COUNT; sInfo->statId++) for (sInfo->condition = 0; sInfo->condition < CONDITION_COUNT; sInfo->condition++)
{ {
if (sInfo->enhancements[sInfo->statId] != 0) if (sInfo->enhancements[sInfo->condition] != 0)
break; break;
} }
if (sInfo->statId < FLAVOR_COUNT) if (sInfo->condition < CONDITION_COUNT)
BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]); BufferEnhancedText(gStringVar4, sInfo->condition, sInfo->enhancements[sInfo->condition]);
else else
BufferEnhancedStatText(gStringVar4, sInfo->statId, 0); BufferEnhancedText(gStringVar4, sInfo->condition, 0);
PrintMenuWindowText(gStringVar4); PrintMenuWindowText(gStringVar4);
PutWindowTilemap(WIN_TEXT); PutWindowTilemap(WIN_TEXT);
@ -928,20 +925,20 @@ static bool8 TryPrintNextEnhancement(void)
while (1) while (1)
{ {
sInfo->statId++; sInfo->condition++;
if (sInfo->statId < FLAVOR_COUNT) if (sInfo->condition < CONDITION_COUNT)
{ {
if (sInfo->enhancements[sInfo->statId] != 0) if (sInfo->enhancements[sInfo->condition] != 0)
break; break;
} }
else else
{ {
sInfo->statId = FLAVOR_COUNT; sInfo->condition = CONDITION_COUNT;
return FALSE; return FALSE;
} }
} }
BufferEnhancedStatText(gStringVar4, sInfo->statId, sInfo->enhancements[sInfo->statId]); BufferEnhancedText(gStringVar4, sInfo->condition, sInfo->enhancements[sInfo->condition]);
PrintMenuWindowText(gStringVar4); PrintMenuWindowText(gStringVar4);
CopyWindowToVram(WIN_TEXT, COPYWIN_GFX); CopyWindowToVram(WIN_TEXT, COPYWIN_GFX);
@ -969,7 +966,7 @@ static void PrintMenuWindowText(const u8 *message)
AddTextPrinterParameterized(WIN_TEXT, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL); AddTextPrinterParameterized(WIN_TEXT, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL);
} }
static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement) static void BufferEnhancedText(u8 *dest, u8 condition, s16 enhancement)
{ {
switch (enhancement) switch (enhancement)
{ {
@ -979,7 +976,7 @@ static void BufferEnhancedStatText(u8 *dest, u8 statId, s16 enhancement)
case -32768 ... -1: // if < 0 case -32768 ... -1: // if < 0
if (enhancement) if (enhancement)
dest[(u16)enhancement] += 0; // something you can't imagine dest[(u16)enhancement] += 0; // something you can't imagine
StringCopy(dest, sContestStatNames[statId]); StringCopy(dest, sConditionNames[condition]);
StringAppend(dest, gText_WasEnhanced); StringAppend(dest, gText_WasEnhanced);
break; break;
case 0: case 0:
@ -992,36 +989,36 @@ static void GetMonConditions(struct Pokemon *mon, u8 *data)
{ {
u16 i; u16 i;
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
data[i] = GetMonData(mon, sMonDataConditions[i]); data[i] = GetMonData(mon, sConditionToMonData[i]);
} }
static void AddPokeblockToConditions(struct Pokeblock *pokeblock, struct Pokemon *mon) static void AddPokeblockToConditions(struct Pokeblock *pokeblock, struct Pokemon *mon)
{ {
u16 i; u16 i;
s16 cstat; s16 stat;
u8 data; u8 data;
if (GetMonData(mon, MON_DATA_SHEEN) != 255) if (GetMonData(mon, MON_DATA_SHEEN) != MAX_SHEEN)
{ {
CalculatePokeblockEffectiveness(pokeblock, mon); CalculatePokeblockEffectiveness(pokeblock, mon);
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
{ {
data = GetMonData(mon, sMonDataConditions[i]); data = GetMonData(mon, sConditionToMonData[i]);
cstat = data + sInfo->pokeblockStatBoosts[i]; stat = data + sInfo->pokeblockStatBoosts[i];
if (cstat < 0) if (stat < 0)
cstat = 0; stat = 0;
if (cstat > 255) if (stat > MAX_CONDITION)
cstat = 255; stat = MAX_CONDITION;
data = cstat; data = stat;
SetMonData(mon, sMonDataConditions[i], &data); SetMonData(mon, sConditionToMonData[i], &data);
} }
cstat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel; stat = (u8)(GetMonData(mon, MON_DATA_SHEEN)) + pokeblock->feel;
if (cstat > 255) if (stat > MAX_SHEEN)
cstat = 255; stat = MAX_SHEEN;
data = cstat; data = stat;
SetMonData(mon, MON_DATA_SHEEN, &data); SetMonData(mon, MON_DATA_SHEEN, &data);
} }
} }
@ -1035,19 +1032,19 @@ static void CalculateConditionEnhancements(void)
GetMonConditions(mon, sInfo->conditionsBeforeBlock); GetMonConditions(mon, sInfo->conditionsBeforeBlock);
AddPokeblockToConditions(sInfo->pokeblock, mon); AddPokeblockToConditions(sInfo->pokeblock, mon);
GetMonConditions(mon, sInfo->conditionsAfterBlock); GetMonConditions(mon, sInfo->conditionsAfterBlock);
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
sInfo->enhancements[i] = sInfo->conditionsAfterBlock[i] - sInfo->conditionsBeforeBlock[i]; sInfo->enhancements[i] = sInfo->conditionsAfterBlock[i] - sInfo->conditionsBeforeBlock[i];
} }
static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct Pokemon *mon) static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct Pokemon *mon)
{ {
s8 i, direction, taste; s8 i, direction, flavor;
sInfo->pokeblockStatBoosts[0] = pokeblock->spicy; sInfo->pokeblockStatBoosts[CONDITION_COOL] = pokeblock->spicy;
sInfo->pokeblockStatBoosts[1] = pokeblock->sour; sInfo->pokeblockStatBoosts[CONDITION_TOUGH] = pokeblock->sour;
sInfo->pokeblockStatBoosts[2] = pokeblock->bitter; sInfo->pokeblockStatBoosts[CONDITION_SMART] = pokeblock->bitter;
sInfo->pokeblockStatBoosts[3] = pokeblock->sweet; sInfo->pokeblockStatBoosts[CONDITION_CUTE] = pokeblock->sweet;
sInfo->pokeblockStatBoosts[4] = pokeblock->dry; sInfo->pokeblockStatBoosts[CONDITION_BEAUTY] = pokeblock->dry;
if (gPokeblockGain > 0) if (gPokeblockGain > 0)
direction = 1; direction = 1;
@ -1056,7 +1053,7 @@ static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct
else else
return; return;
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
{ {
s16 amount = sInfo->pokeblockStatBoosts[i]; s16 amount = sInfo->pokeblockStatBoosts[i];
s8 boost = amount / 10; s8 boost = amount / 10;
@ -1064,9 +1061,9 @@ static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct
if (amount % 10 >= 5) // round to the nearest if (amount % 10 >= 5) // round to the nearest
boost++; boost++;
taste = GetMonFlavorRelation(mon, sFlavors[i]); flavor = GetMonFlavorRelation(mon, sConditionToFlavor[i]);
if (taste == direction) if (flavor == direction)
sInfo->pokeblockStatBoosts[i] += boost * taste; sInfo->pokeblockStatBoosts[i] += boost * flavor;
} }
} }
@ -1075,7 +1072,7 @@ static bool8 IsSheenMaxed(void)
if (GetBoxOrPartyMonData(sMenu->party[sMenu->info.curSelection].boxId, if (GetBoxOrPartyMonData(sMenu->party[sMenu->info.curSelection].boxId,
sMenu->party[sMenu->info.curSelection].monId, sMenu->party[sMenu->info.curSelection].monId,
MON_DATA_SHEEN, MON_DATA_SHEEN,
NULL) == 255) NULL) == MAX_SHEEN)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -1125,7 +1122,7 @@ static void LoadAndCreateUpDownSprites(void)
LoadSpritePalette(&sSpritePalette_UpDown); LoadSpritePalette(&sSpritePalette_UpDown);
sInfo->numEnhancements = 0; sInfo->numEnhancements = 0;
for (i = 0; i < FLAVOR_COUNT; i++) for (i = 0; i < CONDITION_COUNT; i++)
{ {
if (sInfo->enhancements[i] != 0) if (sInfo->enhancements[i] != 0)
{ {
@ -1487,7 +1484,7 @@ static bool8 LoadNewSelection_CancelToMon(void)
sMenu->info.helperState++; sMenu->info.helperState++;
break; break;
case 2: case 2:
if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset)) if (!ConditionGraph_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset))
{ {
// Load the new adjacent pokemon (not the one being shown) // Load the new adjacent pokemon (not the one being shown)
LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId); LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
@ -1514,7 +1511,7 @@ static bool8 LoadNewSelection_MonToCancel(void)
switch (sMenu->info.helperState) switch (sMenu->info.helperState)
{ {
case 0: case 0:
if (!TryUpdateConditionMonTransitionOff(&sMenu->graph, &sMenu->curMonXOffset)) if (!ConditionGraph_UpdateMonExit(&sMenu->graph, &sMenu->curMonXOffset))
sMenu->info.helperState++; sMenu->info.helperState++;
break; break;
case 1: case 1:
@ -1550,7 +1547,7 @@ static bool8 LoadNewSelection_MonToMon(void)
sMenu->info.helperState++; sMenu->info.helperState++;
break; break;
case 2: case 2:
if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset)) if (!ConditionGraph_UpdateMonEnter(&sMenu->graph, &sMenu->curMonXOffset))
{ {
// Load the new adjacent pokemon (not the one being shown) // Load the new adjacent pokemon (not the one being shown)
LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId); LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
@ -1599,10 +1596,7 @@ static void SpriteCB_SelectionIconCancel(struct Sprite *sprite)
static void CalculateNumAdditionalSparkles(u8 monIndex) static void CalculateNumAdditionalSparkles(u8 monIndex)
{ {
u8 sheen = GetMonData(&gPlayerParty[monIndex], MON_DATA_SHEEN); u8 sheen = GetMonData(&gPlayerParty[monIndex], MON_DATA_SHEEN);
sMenu->numSparkles[sMenu->curLoadId] = GET_NUM_CONDITION_SPARKLES(sheen);
sMenu->numSparkles[sMenu->curLoadId] = (sheen != 255)
? sheen / (255 / (MAX_CONDITION_SPARKLES - 1) + 1)
: MAX_CONDITION_SPARKLES - 1;
} }
static void LoadConditionGfx(void) static void LoadConditionGfx(void)