summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGriffinR <griffin.g.richards@gmail.com>2020-08-12 11:44:39 -0400
committerGriffinR <griffin.g.richards@gmail.com>2020-08-12 18:39:15 -0400
commitf6efbe38bfd7365ffdace6e82f5160563473efd7 (patch)
treeaf98ab582fb672d95393bd58c04fa46c8b0333a5 /src
parent4f615b65e686c0958517fdd7c87cb0b6b29c1653 (diff)
Clean up use_pokeblock doc, some menu_specialized
Diffstat (limited to 'src')
-rw-r--r--src/menu_specialized.c427
-rw-r--r--src/pokenav_conditions_1.c4
-rw-r--r--src/pokenav_conditions_2.c24
-rw-r--r--src/use_pokeblock.c162
4 files changed, 310 insertions, 307 deletions
diff --git a/src/menu_specialized.c b/src/menu_specialized.c
index 05ff97edb..cdaa32a98 100644
--- a/src/menu_specialized.c
+++ b/src/menu_specialized.c
@@ -34,13 +34,13 @@ EWRAM_DATA static u8 sUnknown_0203CF48[3] = {0};
EWRAM_DATA static struct ListMenuItem *sUnknown_0203CF4C = NULL;
static void sub_81D1E7C(s32 itemIndex, bool8 onInit, struct ListMenu *list);
-static void sub_81D24A4(struct UnknownStruct_81D1ED4 *a0);
-static void sub_81D2634(struct UnknownStruct_81D1ED4 *a0);
+static void sub_81D24A4(struct ConditionGraph *a0);
+static void sub_81D2634(struct ConditionGraph *a0);
static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list);
static void nullsub_79(void);
-static void sub_81D3408(struct Sprite *sprite);
+static void SetNextConditionSparkle(struct Sprite *sprite);
static void SpriteCB_ConditionSparkle(struct Sprite *sprite);
-static void sub_81D35E8(struct Sprite *sprite);
+static void ShowAllConditionSparkles(struct Sprite *sprite);
static const struct WindowTemplate sUnknown_086253E8[] =
{
@@ -80,7 +80,7 @@ static const u8 sPlayerNameTextColors[] =
static const u8 sEmptyItemName[] = _("");
-static const struct ScanlineEffectParams sUnknown_08625404 =
+static const struct ScanlineEffectParams sConditionGraphScanline =
{
.dmaDest = (void*)REG_ADDR_WIN0H,
.dmaControl = SCANLINE_EFFECT_DMACNT_32BIT,
@@ -320,11 +320,11 @@ void sub_81D1EC0(void)
Free(sUnknown_0203CF4C);
}
-void sub_81D1ED4(struct UnknownStruct_81D1ED4 *a0)
+void sub_81D1ED4(struct ConditionGraph *a0)
{
u8 i, j;
- for (j = 0; j < 5; j++)
+ for (j = 0; j < FLAVOR_COUNT; j++)
{
for (i = 0; i < 10; i++)
{
@@ -346,7 +346,7 @@ void sub_81D1ED4(struct UnknownStruct_81D1ED4 *a0)
a0->unk352 = 0;
}
-void sub_81D1F84(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2)
+void sub_81D1F84(struct ConditionGraph *graph, struct UnknownSubStruct_81D1ED4 *arg1, struct UnknownSubStruct_81D1ED4 *arg2)
{
u16 i, j;
s32 r5, r6;
@@ -357,30 +357,30 @@ void sub_81D1F84(struct UnknownStruct_81D1ED4 *arg0, struct UnknownSubStruct_81D
r6 = ((arg2[i].unk0 - arg1[i].unk0) << 8) / 10;
for (j = 0; j < 9; j++)
{
- arg0->unk64[j][i].unk0 = (r5 >> 8) + ((r5 >> 7) & 1);
+ graph->unk64[j][i].unk0 = (r5 >> 8) + ((r5 >> 7) & 1);
r5 += r6;
}
- arg0->unk64[j][i].unk0 = arg2[i].unk0;
+ graph->unk64[j][i].unk0 = arg2[i].unk0;
r5 = arg1[i].unk2 << 8;
r6 = ((arg2[i].unk2 - arg1[i].unk2) << 8) / 10;
for (j = 0; j < 9; j++)
{
- arg0->unk64[j][i].unk2 = (r5 >> 8) + ((r5 >> 7) & 1);
+ graph->unk64[j][i].unk2 = (r5 >> 8) + ((r5 >> 7) & 1);
r5 += r6;
}
- arg0->unk64[j][i].unk2 = arg2[i].unk2;
+ graph->unk64[j][i].unk2 = arg2[i].unk2;
}
- arg0->unk352 = 0;
+ graph->unk352 = 0;
}
-bool32 sub_81D2074(struct UnknownStruct_81D1ED4 *a0)
+bool32 TransitionConditionGraph(struct ConditionGraph *graph)
{
- if (a0->unk352 < 10)
+ if (graph->unk352 < 10)
{
- sub_81D2230(a0);
- return (++a0->unk352 != 10);
+ sub_81D2230(graph);
+ return (++graph->unk352 != 10);
}
else
{
@@ -388,48 +388,48 @@ bool32 sub_81D2074(struct UnknownStruct_81D1ED4 *a0)
}
}
-void sub_81D20AC(struct UnknownStruct_81D1ED4 *a0)
+void sub_81D20AC(struct ConditionGraph *a0)
{
a0->unk355 = 0;
}
-bool8 sub_81D20BC(struct UnknownStruct_81D1ED4 *arg0)
+bool8 sub_81D20BC(struct ConditionGraph *graph)
{
struct ScanlineEffectParams params;
- switch (arg0->unk355)
+ switch (graph->unk355)
{
case 0:
ScanlineEffect_Clear();
- arg0->unk355++;
+ graph->unk355++;
return TRUE;
case 1:
- params = sUnknown_08625404;
+ params = sConditionGraphScanline;
ScanlineEffect_SetParams(params);
- arg0->unk355++;
+ graph->unk355++;
return FALSE;
default:
return FALSE;
}
}
-void sub_81D2108(struct UnknownStruct_81D1ED4 *arg0)
+void sub_81D2108(struct ConditionGraph *graph)
{
u16 i;
- if (arg0->unk354 == 0)
+ if (graph->unk354 == 0)
return;
- sub_81D24A4(arg0);
- sub_81D2634(arg0);
+ sub_81D24A4(graph);
+ sub_81D2634(graph);
for (i = 0; i < 66; i++)
{
- gScanlineEffectRegBuffers[1][(i + 55) * 2] = gScanlineEffectRegBuffers[0][(i + 55) * 2] = (arg0->unk140[i][0] << 8) | (arg0->unk140[i][1]);
- gScanlineEffectRegBuffers[1][(i + 55) * 2 + 1] = gScanlineEffectRegBuffers[0][(i + 55) * 2 + 1] = (arg0->unk248[i][0] << 8) | (arg0->unk248[i][1]);
+ gScanlineEffectRegBuffers[1][(i + 55) * 2] = gScanlineEffectRegBuffers[0][(i + 55) * 2] = (graph->unk140[i][0] << 8) | (graph->unk140[i][1]);
+ gScanlineEffectRegBuffers[1][(i + 55) * 2 + 1] = gScanlineEffectRegBuffers[0][(i + 55) * 2 + 1] = (graph->unk248[i][0] << 8) | (graph->unk248[i][1]);
}
- arg0->unk354 = 0;
+ graph->unk354 = 0;
}
void sub_81D21DC(u8 bg)
@@ -442,24 +442,24 @@ void sub_81D21DC(u8 bg)
// Unset the WINOUT flag for the bg.
flags = (WINOUT_WIN01_BG_ALL | WINOUT_WIN01_OBJ) & ~(1 << bg);
- SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, 0xF0));
- SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE(0, 0x9B));
- SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(0x38, 0x79));
- SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(0x38, 0x79));
+ SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE( 0, DISPLAY_WIDTH));
+ SetGpuReg(REG_OFFSET_WIN1H, WIN_RANGE( 0, 155));
+ SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(56, 121));
+ SetGpuReg(REG_OFFSET_WIN1V, WIN_RANGE(56, 121));
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);
}
-void sub_81D2230(struct UnknownStruct_81D1ED4 *arg0)
+void sub_81D2230(struct ConditionGraph *graph)
{
u16 i;
- for (i = 0; i < 5; i++)
- arg0->unk12C[i] = arg0->unk64[arg0->unk352][i];
+ for (i = 0; i < FLAVOR_COUNT; i++)
+ graph->unk12C[i] = graph->unk64[graph->unk352][i];
- arg0->unk354 = 1;
+ graph->unk354 = 1;
}
-static void sub_81D2278(struct UnknownStruct_81D1ED4 *arg0, 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 *ptr;
@@ -510,8 +510,8 @@ static void sub_81D2278(struct UnknownStruct_81D1ED4 *arg0, u16 *arg1, struct Un
break;
}
- arg0->unk350 = r10 + i;
- arg1 += (arg0->unk350 - 56) * 2;
+ graph->unk350 = r10 + i;
+ arg1 += (graph->unk350 - 56) * 2;
for (; i < r8; i++)
{
arg1[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
@@ -536,8 +536,8 @@ static void sub_81D2278(struct UnknownStruct_81D1ED4 *arg0, u16 *arg1, struct Un
arg1 += 2;
}
- arg0->unk350 = r10 + i;
- arg5 += (arg0->unk350 - 56) * 2;
+ graph->unk350 = r10 + i;
+ arg5 += (graph->unk350 - 56) * 2;
for (; i < r8; i++)
{
arg5[arg4] = (r4 >> 10) + ((r4 >> 9) & 1) + arg4;
@@ -549,7 +549,7 @@ static void sub_81D2278(struct UnknownStruct_81D1ED4 *arg0, u16 *arg1, struct Un
}
else
{
- arg0->unk350 = r10;
+ graph->unk350 = r10;
arg1 += (r10 - 56) * 2;
arg5 += (r10 - 56) * 2;
arg1[1] = arg2->unk0 + 1;
@@ -561,87 +561,87 @@ static void sub_81D2278(struct UnknownStruct_81D1ED4 *arg0, u16 *arg1, struct Un
ptr[arg4] = arg4 + var_30;
}
-static void sub_81D24A4(struct UnknownStruct_81D1ED4 *arg0)
+static void sub_81D24A4(struct ConditionGraph *graph)
{
u16 i, r6, varMax;
- if (arg0->unk12C[0].unk2 < arg0->unk12C[1].unk2)
+ if (graph->unk12C[0].unk2 < graph->unk12C[1].unk2)
{
- r6 = arg0->unk12C[0].unk2;
- sub_81D2278(arg0, arg0->unk140[0], &arg0->unk12C[0], &arg0->unk12C[1], 1, NULL);
+ r6 = graph->unk12C[0].unk2;
+ sub_81D2278(graph, graph->unk140[0], &graph->unk12C[0], &graph->unk12C[1], 1, NULL);
}
else
{
- r6 = arg0->unk12C[1].unk2;
- sub_81D2278(arg0, arg0->unk140[0], &arg0->unk12C[1], &arg0->unk12C[0], 0, NULL);
+ r6 = graph->unk12C[1].unk2;
+ sub_81D2278(graph, graph->unk140[0], &graph->unk12C[1], &graph->unk12C[0], 0, NULL);
}
- sub_81D2278(arg0, arg0->unk140[0], &arg0->unk12C[1], &arg0->unk12C[2], 1, NULL);
+ sub_81D2278(graph, graph->unk140[0], &graph->unk12C[1], &graph->unk12C[2], 1, NULL);
- i = (arg0->unk12C[2].unk2 <= arg0->unk12C[3].unk2);
- sub_81D2278(arg0, arg0->unk140[0], &arg0->unk12C[2], &arg0->unk12C[3], i, arg0->unk248[0]);
+ 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]);
for (i = 56; i < r6; i++)
{
- arg0->unk140[i - 56][0] = 0;
- arg0->unk140[i - 56][1] = 0;
+ graph->unk140[i - 56][0] = 0;
+ graph->unk140[i - 56][1] = 0;
}
- for (i = arg0->unk12C[0].unk2; i <= arg0->unk350; i++)
- arg0->unk140[i - 56][0] = 155;
+ for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++)
+ graph->unk140[i - 56][0] = 155;
- varMax = max(arg0->unk350, arg0->unk12C[2].unk2);
+ varMax = max(graph->unk350, graph->unk12C[2].unk2);
for (i = varMax + 1; i < 122; i++)
{
- arg0->unk140[i - 56][0] = 0;
- arg0->unk140[i - 56][1] = 0;
+ graph->unk140[i - 56][0] = 0;
+ graph->unk140[i - 56][1] = 0;
}
for (i = 56; i < 122; i++)
{
- if (arg0->unk140[i - 56][0] == 0 && arg0->unk140[i - 56][1] != 0)
- arg0->unk140[i - 56][0] = 155;
+ if (graph->unk140[i - 56][0] == 0 && graph->unk140[i - 56][1] != 0)
+ graph->unk140[i - 56][0] = 155;
}
}
-static void sub_81D2634(struct UnknownStruct_81D1ED4 *arg0)
+static void sub_81D2634(struct ConditionGraph *graph)
{
s32 i, r6, varMax;
- if (arg0->unk12C[0].unk2 < arg0->unk12C[4].unk2)
+ if (graph->unk12C[0].unk2 < graph->unk12C[4].unk2)
{
- r6 = arg0->unk12C[0].unk2;
- sub_81D2278(arg0, arg0->unk248[0], &arg0->unk12C[0], &arg0->unk12C[4], 0, NULL);
+ r6 = graph->unk12C[0].unk2;
+ sub_81D2278(graph, graph->unk248[0], &graph->unk12C[0], &graph->unk12C[4], 0, NULL);
}
else
{
- r6 = arg0->unk12C[4].unk2;
- sub_81D2278(arg0, arg0->unk248[0], &arg0->unk12C[4], &arg0->unk12C[0], 1, NULL);
+ r6 = graph->unk12C[4].unk2;
+ sub_81D2278(graph, graph->unk248[0], &graph->unk12C[4], &graph->unk12C[0], 1, NULL);
}
- sub_81D2278(arg0, arg0->unk248[0], &arg0->unk12C[4], &arg0->unk12C[3], 0, NULL);
+ sub_81D2278(graph, graph->unk248[0], &graph->unk12C[4], &graph->unk12C[3], 0, NULL);
for (i = 56; i < r6; i++)
{
- arg0->unk140[i + 10][0] = 0;
- arg0->unk140[i + 10][1] = 0;
+ graph->unk140[i + 10][0] = 0;
+ graph->unk140[i + 10][1] = 0;
}
- for (i = arg0->unk12C[0].unk2; i <= arg0->unk350; i++)
- arg0->unk140[i + 10][1] = 155;
+ for (i = graph->unk12C[0].unk2; i <= graph->unk350; i++)
+ graph->unk140[i + 10][1] = 155;
- varMax = max(arg0->unk350, arg0->unk12C[3].unk2 + 1);
+ varMax = max(graph->unk350, graph->unk12C[3].unk2 + 1);
for (i = varMax; i < 122; i++)
{
- arg0->unk140[i + 10][0] = 0;
- arg0->unk140[i + 10][1] = 0;
+ graph->unk140[i + 10][0] = 0;
+ graph->unk140[i + 10][1] = 0;
}
for (i = 0; i < 66; i++)
{
- if (arg0->unk248[i][0] >= arg0->unk248[i][1])
+ if (graph->unk248[i][0] >= graph->unk248[i][1])
{
- arg0->unk248[i][1] = 0;
- arg0->unk248[i][0] = 0;
+ graph->unk248[i][1] = 0;
+ graph->unk248[i][0] = 0;
}
}
}
@@ -985,7 +985,7 @@ void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId
{
u16 i;
- // In this and the below 2 functions, numMons can be passed as the number of menu selections (which includes Cancel)
+ // In this and the below 2 functions, numMons is passed as the number of menu selections (which includes Cancel)
// To indicate that the Cancel needs to be subtracted they pass an additional bool
// Unclear why they didn't just subtract 1 when it gets passed instead
if (!excludesCancel)
@@ -1020,7 +1020,7 @@ void GetConditionMenuMonNameAndLocString(u8 *locationDst, u8 *nameDst, u16 boxId
}
}
-void GetConditionMenuMonConditions(struct UnknownStruct_81D1ED4 *arg0, u8 *sheen, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel)
+void GetConditionMenuMonConditions(struct ConditionGraph *graph, u8 *sheen, u16 boxId, u16 monId, u16 partyId, u16 id, u16 numMons, bool8 excludesCancel)
{
u16 i;
@@ -1029,25 +1029,25 @@ void GetConditionMenuMonConditions(struct UnknownStruct_81D1ED4 *arg0, u8 *sheen
if (partyId != numMons)
{
- arg0->unk0[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
- arg0->unk0[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
- arg0->unk0[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
- arg0->unk0[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
- arg0->unk0[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
+ graph->unk0[id][0] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_COOL, NULL);
+ graph->unk0[id][1] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_TOUGH, NULL);
+ graph->unk0[id][2] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_SMART, NULL);
+ graph->unk0[id][3] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_CUTE, NULL);
+ graph->unk0[id][4] = GetBoxOrPartyMonData(boxId, monId, MON_DATA_BEAUTY, NULL);
sheen[id] = (GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) != 0xFF)
? GetBoxOrPartyMonData(boxId, monId, MON_DATA_SHEEN, NULL) / 29u
: 9;
- sub_81D2754(arg0->unk0[id], arg0->unk14[id]);
+ sub_81D2754(graph->unk0[id], graph->unk14[id]);
}
else
{
for (i = 0; i < FLAVOR_COUNT; i++)
{
- arg0->unk0[id][i] = 0;
- arg0->unk14[id][i].unk0 = 155;
- arg0->unk14[id][i].unk2 = 91;
+ graph->unk0[id][i] = 0;
+ graph->unk14[id][i].unk0 = 155;
+ graph->unk14[id][i].unk2 = 91;
}
}
}
@@ -1068,38 +1068,38 @@ void GetConditionMenuMonGfx(void *tilesDst, void *palDst, u16 boxId, u16 monId,
}
}
-bool8 sub_81D312C(s16 *var)
+bool8 MoveConditionMonOnscreen(s16 *x)
{
- *var += 24;
- if (*var > 0)
- *var = 0;
+ *x += 24;
+ if (*x > 0)
+ *x = 0;
- return (*var != 0);
+ return (*x != 0);
}
-bool8 sub_81D3150(s16 *var)
+bool8 MoveConditionMonOffscreen(s16 *x)
{
- *var -= 24;
- if (*var < -80)
- *var = -80;
+ *x -= 24;
+ if (*x < -80)
+ *x = -80;
- return (*var != -80);
+ return (*x != -80);
}
-bool8 sub_81D3178(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1)
+bool8 TryUpdateConditionMonTransitionOn(struct ConditionGraph *graph, s16 *x)
{
- bool8 var1 = sub_81D2074(arg0);
- bool8 var2 = sub_81D312C(arg1);
+ bool8 graphUpdating = TransitionConditionGraph(graph);
+ bool8 monUpdating = MoveConditionMonOnscreen(x);
- return ((var1 != 0) || (var2 != 0));
+ return (graphUpdating || monUpdating);
}
-bool8 sub_81D31A4(struct UnknownStruct_81D1ED4 *arg0, s16 *arg1)
+bool8 TryUpdateConditionMonTransitionOff(struct ConditionGraph *graph, s16 *x)
{
- bool8 var1 = sub_81D2074(arg0);
- bool8 var2 = sub_81D3150(arg1);
+ bool8 graphUpdating = TransitionConditionGraph(graph);
+ bool8 monUpdating = MoveConditionMonOffscreen(x);
- return ((var1 != 0) || (var2 != 0));
+ return (graphUpdating || monUpdating);
}
static const u32 sConditionPokeball_Gfx[] = INCBIN_U32("graphics/pokenav/condition/pokeball.4bpp");
@@ -1107,7 +1107,7 @@ static const u32 sConditionPokeballPlaceholder_Gfx[] = INCBIN_U32("graphics/poke
static const u16 sConditionSparkle_Gfx[] = INCBIN_U16("graphics/pokenav/condition/sparkle.gbapal");
static const u32 sConditionSparkle_Pal[] = INCBIN_U32("graphics/pokenav/condition/sparkle.4bpp");
-static const struct OamData sOamData_8625A20 =
+static const struct OamData sOam_ConditionMonPic =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -1124,7 +1124,7 @@ static const struct OamData sOamData_8625A20 =
.affineParam = 0
};
-static const struct OamData sOamData_8625A28 =
+static const struct OamData sOam_ConditionSelectionIcon =
{
.y = 0,
.affineMode = ST_OAM_AFFINE_OFF,
@@ -1141,41 +1141,41 @@ static const struct OamData sOamData_8625A28 =
.affineParam = 0
};
-static const union AnimCmd sSpriteAnim_8625A30[] =
+static const union AnimCmd sAnim_ConditionSelectionIcon_Selected[] =
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END
};
-static const union AnimCmd sSpriteAnim_8625A38[] =
+static const union AnimCmd sAnim_ConditionSelectionIcon_Unselected[] =
{
ANIMCMD_FRAME(4, 5),
ANIMCMD_END
};
-static const union AnimCmd *const sSpriteAnimTable_8625A40[] =
+static const union AnimCmd *const sAnims_ConditionSelectionIcon[] =
{
- sSpriteAnim_8625A30,
- sSpriteAnim_8625A38
+ sAnim_ConditionSelectionIcon_Selected,
+ sAnim_ConditionSelectionIcon_Unselected
};
// Just loads the generic data, up to the caller to load the actual sheet/pal for the specific mon
void LoadConditionMonPicTemplate(struct SpriteSheet *sheet, struct SpriteTemplate *template, struct SpritePalette *pal)
{
- struct SpriteSheet dataSheet = {NULL, 0x800, TAG_SPMENU_CONDITION_MON};
+ struct SpriteSheet dataSheet = {NULL, 0x800, TAG_CONDITION_MON};
struct SpriteTemplate dataTemplate =
{
- .tileTag = TAG_SPMENU_CONDITION_MON,
- .paletteTag = TAG_SPMENU_CONDITION_MON,
- .oam = &sOamData_8625A20,
+ .tileTag = TAG_CONDITION_MON,
+ .paletteTag = TAG_CONDITION_MON,
+ .oam = &sOam_ConditionMonPic,
.anims = gDummySpriteAnimTable,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy,
};
- struct SpritePalette dataPal = {NULL, TAG_SPMENU_CONDITION_MON};
+ struct SpritePalette dataPal = {NULL, TAG_CONDITION_MON};
*sheet = dataSheet;
*template = dataTemplate;
@@ -1188,25 +1188,26 @@ void LoadConditionSelectionIcons(struct SpriteSheet *sheets, struct SpriteTempla
struct SpriteSheet dataSheets[] =
{
- {sConditionPokeball_Gfx, 0x100, TAG_SPMENU_CONDITION_BALL},
- {sConditionPokeballPlaceholder_Gfx, 0x20, TAG_SPMENU_CONDITION_BALL_PLACEHOLDER},
- {gPokenavConditionCancel_Gfx, 0x100, TAG_SPMENU_CONDITION_CANCEL},
+ {sConditionPokeball_Gfx, 0x100, TAG_CONDITION_BALL},
+ {sConditionPokeballPlaceholder_Gfx, 0x20, TAG_CONDITION_BALL_PLACEHOLDER},
+ {gPokenavConditionCancel_Gfx, 0x100, TAG_CONDITION_CANCEL},
{},
};
struct SpritePalette dataPals[] =
{
- {gPokenavConditionCancel_Pal, TAG_SPMENU_CONDITION_BALL},
- {gPokenavConditionCancel_Pal + 16, TAG_SPMENU_CONDITION_CANCEL},
+ {gPokenavConditionCancel_Pal, TAG_CONDITION_BALL},
+ {gPokenavConditionCancel_Pal + 16, TAG_CONDITION_CANCEL},
{},
};
+ // Tag is overwritten for the other selection icons
struct SpriteTemplate dataTemplate =
{
- .tileTag = TAG_SPMENU_CONDITION_BALL,
- .paletteTag = TAG_SPMENU_CONDITION_BALL,
- .oam = &sOamData_8625A28,
- .anims = sSpriteAnimTable_8625A40,
+ .tileTag = TAG_CONDITION_BALL,
+ .paletteTag = TAG_CONDITION_BALL,
+ .oam = &sOam_ConditionSelectionIcon,
+ .anims = sAnims_ConditionSelectionIcon,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy,
@@ -1221,30 +1222,37 @@ void LoadConditionSelectionIcons(struct SpriteSheet *sheets, struct SpriteTempla
*(pals++) = dataPals[i];
}
+#define sSparkleId data[0]
+#define sDelayTimer data[1]
+#define sNumExtraSparkles data[2]
+#define sCurSparkleId data[3]
+#define sMonSpriteId data[4]
+#define sNextSparkleSpriteId data[5]
+
void LoadConditionSparkle(struct SpriteSheet *sheet, struct SpritePalette *pal)
{
- struct SpriteSheet dataSheet = {sConditionSparkle_Pal, 0x380, TAG_SPMENU_CONDITION_SPARKLE};
- struct SpritePalette dataPal = {sConditionSparkle_Gfx, TAG_SPMENU_CONDITION_SPARKLE};
+ struct SpriteSheet dataSheet = {sConditionSparkle_Pal, 0x380, TAG_CONDITION_SPARKLE};
+ struct SpritePalette dataPal = {sConditionSparkle_Gfx, TAG_CONDITION_SPARKLE};
*sheet = dataSheet;
*pal = dataPal;
}
-static void sub_81D32D4(struct Sprite *sprite)
+static void SpriteCB_ConditionSparkle_DoNextAfterDelay(struct Sprite *sprite)
{
- if (++sprite->data[1] > 60)
+ if (++sprite->sDelayTimer > 60)
{
- sprite->data[1] = 0;
- sub_81D3408(sprite);
+ sprite->sDelayTimer = 0;
+ SetNextConditionSparkle(sprite);
}
}
-static void sub_81D32F4(struct Sprite *sprite)
+static void SpriteCB_ConditionSparkle_WaitForAllAnim(struct Sprite *sprite)
{
if (sprite->animEnded)
{
- sprite->data[1] = 0;
- sprite->callback = sub_81D32D4;
+ sprite->sDelayTimer = 0;
+ sprite->callback = SpriteCB_ConditionSparkle_DoNextAfterDelay;
}
}
@@ -1274,31 +1282,19 @@ static const union AnimCmd sAnim_ConditionSparkle[] =
static const union AnimCmd *const sAnims_ConditionSparkle[] =
{
- sAnim_ConditionSparkle,
- sAnim_ConditionSparkle + 2,
-};
-
-// unused
-static const union AnimCmd *const sSpriteAnimTable_8625B00[] =
-{
- sAnim_ConditionSparkle + 4,
- sAnim_ConditionSparkle + 6,
-};
-
-// unused
-static const union AnimCmd *const sSpriteAnimTable_8625B08[] =
-{
- sAnim_ConditionSparkle + 8,
- sAnim_ConditionSparkle + 10,
+ &sAnim_ConditionSparkle[0], // Only this entry is used
+ &sAnim_ConditionSparkle[2],
+ &sAnim_ConditionSparkle[4],
+ &sAnim_ConditionSparkle[6],
+ &sAnim_ConditionSparkle[8], // Here below OOB, will crash if used
+ &sAnim_ConditionSparkle[10],
+ &sAnim_ConditionSparkle[12],
};
-// unused
-static const union AnimCmd *const *const sUnknown_08625B10 = sSpriteAnimTable_8625B08;
-
static const struct SpriteTemplate sSpriteTemplate_ConditionSparkle =
{
- .tileTag = TAG_SPMENU_CONDITION_SPARKLE,
- .paletteTag = TAG_SPMENU_CONDITION_SPARKLE,
+ .tileTag = TAG_CONDITION_SPARKLE,
+ .paletteTag = TAG_CONDITION_SPARKLE,
.oam = &sOam_ConditionSparkle,
.anims = sAnims_ConditionSparkle,
.images = NULL,
@@ -1306,37 +1302,37 @@ static const struct SpriteTemplate sSpriteTemplate_ConditionSparkle =
.callback = SpriteCB_ConditionSparkle,
};
-static const s16 gUnknown_08625B2C[][2] =
-{
- {0, -35},
- {20, -28},
- {33, -10},
- {33, 10},
- {20, 28},
- {0, 35},
- {-20, 28},
- {-33, 10},
- {-33, -10},
- {-20, -28},
+static const s16 sConditionSparkleCoords[MAX_CONDITION_SPARKLES][2] =
+{
+ { 0, -35},
+ { 20, -28},
+ { 33, -10},
+ { 33, 10},
+ { 20, 28},
+ { 0, 35},
+ {-20, 28},
+ {-33, 10},
+ {-33, -10},
+ {-20, -28},
};
-static void sub_81D3314(struct Sprite *sprite)
+static void SetConditionSparklePosition(struct Sprite *sprite)
{
- struct Sprite *sprite2 = &gSprites[sprite->data[4]];
+ struct Sprite *mon = &gSprites[sprite->sMonSpriteId];
- if (sprite2 != NULL)
+ if (mon != NULL)
{
- sprite->pos1.x = sprite2->pos1.x + sprite2->pos2.x + gUnknown_08625B2C[sprite->data[0]][0];
- sprite->pos1.y = sprite2->pos1.y + sprite2->pos2.y + gUnknown_08625B2C[sprite->data[0]][1];
+ sprite->pos1.x = mon->pos1.x + mon->pos2.x + sConditionSparkleCoords[sprite->sSparkleId][0];
+ sprite->pos1.y = mon->pos1.y + mon->pos2.y + sConditionSparkleCoords[sprite->sSparkleId][1];
}
else
{
- sprite->pos1.x = gUnknown_08625B2C[sprite->data[0]][0] + 40;
- sprite->pos1.y = gUnknown_08625B2C[sprite->data[0]][1] + 104;
+ sprite->pos1.x = sConditionSparkleCoords[sprite->sSparkleId][0] + 40;
+ sprite->pos1.y = sConditionSparkleCoords[sprite->sSparkleId][1] + 104;
}
}
-static void sub_81D338C(u8 arg0, u8 arg1, struct Sprite **sprites)
+static void InitConditionSparkles(u8 count, bool8 allowFirstShowAll, struct Sprite **sprites)
{
u16 i;
@@ -1344,35 +1340,34 @@ static void sub_81D338C(u8 arg0, u8 arg1, struct Sprite **sprites)
{
if (sprites[i] != NULL)
{
- sprites[i]->data[0] = i;
- sprites[i]->data[1] = (i * 16) + 1;
- sprites[i]->data[2] = arg0;
- sprites[i]->data[3] = i;
- if (arg1 == 0 || arg0 != 9)
+ sprites[i]->sSparkleId = i;
+ sprites[i]->sDelayTimer = (i * 16) + 1;
+ sprites[i]->sNumExtraSparkles = count;
+ sprites[i]->sCurSparkleId = i;
+ if (!allowFirstShowAll || count != MAX_CONDITION_SPARKLES - 1)
{
sprites[i]->callback = SpriteCB_ConditionSparkle;
}
else
{
- sub_81D3314(sprites[i]);
- sub_81D35E8(sprites[i]);
- sprites[i]->callback = sub_81D32F4;
+ SetConditionSparklePosition(sprites[i]);
+ ShowAllConditionSparkles(sprites[i]);
+ sprites[i]->callback = SpriteCB_ConditionSparkle_WaitForAllAnim;
sprites[i]->invisible = FALSE;
}
}
}
}
-static void sub_81D3408(struct Sprite *sprite)
+static void SetNextConditionSparkle(struct Sprite *sprite)
{
u16 i;
- u8 id = sprite->data[5];
-
- for (i = 0; i < sprite->data[2] + 1; i++)
+ u8 id = sprite->sNextSparkleSpriteId;
+ for (i = 0; i < sprite->sNumExtraSparkles + 1; i++)
{
- gSprites[id].data[1] = (gSprites[id].data[0] * 16) + 1;
+ gSprites[id].sDelayTimer = (gSprites[id].sSparkleId * 16) + 1;
gSprites[id].callback = SpriteCB_ConditionSparkle;
- id = gSprites[id].data[5];
+ id = gSprites[id].sNextSparkleSpriteId;
}
}
@@ -1396,9 +1391,9 @@ void CreateConditionSparkleSprites(struct Sprite **sprites, u8 monSpriteId, u8 _
{
sprites[i] = &gSprites[spriteId];
sprites[i]->invisible = TRUE;
- sprites[i]->data[4] = monSpriteId;
+ sprites[i]->sMonSpriteId = monSpriteId;
if (i != 0)
- sprites[i - 1]->data[5] = spriteId;
+ sprites[i - 1]->sNextSparkleSpriteId = spriteId;
else
firstSpriteId = spriteId;
}
@@ -1408,8 +1403,8 @@ void CreateConditionSparkleSprites(struct Sprite **sprites, u8 monSpriteId, u8 _
}
}
- sprites[count]->data[5] = firstSpriteId;
- sub_81D338C(count, 1, sprites);
+ sprites[count]->sNextSparkleSpriteId = firstSpriteId;
+ InitConditionSparkles(count, TRUE, sprites);
}
void DestroyConditionSparkleSprites(struct Sprite **sprites)
@@ -1433,35 +1428,38 @@ void DestroyConditionSparkleSprites(struct Sprite **sprites)
void FreeConditionSparkles(struct Sprite **sprites)
{
DestroyConditionSparkleSprites(sprites);
- FreeSpriteTilesByTag(TAG_SPMENU_CONDITION_SPARKLE);
- FreeSpritePaletteByTag(TAG_SPMENU_CONDITION_SPARKLE);
+ FreeSpriteTilesByTag(TAG_CONDITION_SPARKLE);
+ FreeSpritePaletteByTag(TAG_CONDITION_SPARKLE);
}
static void SpriteCB_ConditionSparkle(struct Sprite *sprite)
{
- if (sprite->data[1] != 0)
+ // Delay, then do sparkle anim
+ if (sprite->sDelayTimer != 0)
{
- if (--sprite->data[1] != 0)
+ if (--sprite->sDelayTimer != 0)
return;
SeekSpriteAnim(sprite, 0);
sprite->invisible = FALSE;
}
- sub_81D3314(sprite);
+ SetConditionSparklePosition(sprite);
+
+ // Set up next sparkle
if (sprite->animEnded)
{
sprite->invisible = TRUE;
- if (sprite->data[3] == sprite->data[2])
+ if (sprite->sCurSparkleId == sprite->sNumExtraSparkles)
{
- if (sprite->data[3] == 9)
+ if (sprite->sCurSparkleId == MAX_CONDITION_SPARKLES - 1)
{
- sub_81D35E8(sprite);
- sprite->callback = sub_81D32F4;
+ ShowAllConditionSparkles(sprite);
+ sprite->callback = SpriteCB_ConditionSparkle_WaitForAllAnim;
}
else
{
- sprite->callback = sub_81D32D4;
+ sprite->callback = SpriteCB_ConditionSparkle_DoNextAfterDelay;
}
}
else
@@ -1471,18 +1469,25 @@ static void SpriteCB_ConditionSparkle(struct Sprite *sprite)
}
}
-static void sub_81D35E8(struct Sprite *sprite)
+static void ShowAllConditionSparkles(struct Sprite *sprite)
{
- u8 i, id = sprite->data[5];
+ u8 i, id = sprite->sNextSparkleSpriteId;
- for (i = 0; i < sprite->data[2] + 1; i++)
+ for (i = 0; i < sprite->sNumExtraSparkles + 1; i++)
{
SeekSpriteAnim(&gSprites[id], 0);
gSprites[id].invisible = FALSE;
- id = gSprites[id].data[5];
+ id = gSprites[id].sNextSparkleSpriteId;
}
}
+#undef sSparkleId
+#undef sDelayTimer
+#undef sNumExtraSparkles
+#undef sCurSparkleId
+#undef sMonSpriteId
+#undef sNextSparkleSpriteId
+
static const u8 *const sLvlUpStatStrings[NUM_STATS] =
{
gText_MaxHP,
diff --git a/src/pokenav_conditions_1.c b/src/pokenav_conditions_1.c
index 84e2a9682..84e761533 100644
--- a/src/pokenav_conditions_1.c
+++ b/src/pokenav_conditions_1.c
@@ -25,7 +25,7 @@ struct PokenavSub11
u8 fill2[0x6320 - 0x6308];
u8 unk6320[3][24];
u8 unk6368[3][64];
- struct UnknownStruct_81D1ED4 unk6428;
+ struct ConditionGraph unk6428;
u8 unk6780[3];
u8 unk6783[3];
s8 unk6786;
@@ -546,7 +546,7 @@ u16 sub_81CDC60(void)
return unkPtr->unk2;
}
-struct UnknownStruct_81D1ED4 *sub_81CDC70(void)
+struct ConditionGraph *sub_81CDC70(void)
{
struct PokenavSub11 *structPtr = GetSubstructPtr(11);
return &structPtr->unk6428;
diff --git a/src/pokenav_conditions_2.c b/src/pokenav_conditions_2.c
index 764d5c63f..cd1ca0aa5 100644
--- a/src/pokenav_conditions_2.c
+++ b/src/pokenav_conditions_2.c
@@ -323,7 +323,7 @@ u32 sub_81CDE94(s32 state)
sub_81CEE74(TRUE);
return LT_INC_AND_PAUSE;
case 20:
- if (!sub_81D3178(sub_81CDC70(), &structPtr->unk1814))
+ if (!TryUpdateConditionMonTransitionOn(sub_81CDC70(), &structPtr->unk1814))
{
ResetConditionSparkleSprites(structPtr->unk28e0);
if (sub_81CDD5C() == TRUE || sub_81CDC60() != sub_81CDC50())
@@ -348,7 +348,7 @@ u32 sub_81CE2D0(s32 state)
DestroyConditionSparkleSprites(structPtr->unk28e0);
return 1;
case 1:
- if (sub_81D31A4(sub_81CDC70(), &structPtr->unk1814))
+ if (TryUpdateConditionMonTransitionOff(sub_81CDC70(), &structPtr->unk1814))
return 2;
sub_81CEE74(FALSE);
return 1;
@@ -373,7 +373,7 @@ u32 sub_81CE2D0(s32 state)
u32 sub_81CE37C(s32 state)
{
struct Pokenav7Struct *structPtr = GetSubstructPtr(0xC);
- struct UnknownStruct_81D1ED4 *unkPtr = sub_81CDC70();
+ struct ConditionGraph *unkPtr = sub_81CDC70();
switch (state)
{
@@ -388,10 +388,10 @@ u32 sub_81CE37C(s32 state)
DestroyConditionSparkleSprites(structPtr->unk28e0);
return 1;
case 3:
- sub_81D2074(unkPtr);
+ TransitionConditionGraph(unkPtr);
return 1;
case 4:
- if (!sub_81D3150(&structPtr->unk1814))
+ if (!MoveConditionMonOffscreen(&structPtr->unk1814))
{
sub_81CED30(sub_81CDC84());
return 1;
@@ -412,7 +412,7 @@ u32 sub_81CE37C(s32 state)
return 2;
case 9:
unkPtr = sub_81CDC70();
- if (!sub_81D3178(unkPtr, &structPtr->unk1814))
+ if (!TryUpdateConditionMonTransitionOn(unkPtr, &structPtr->unk1814))
{
ResetConditionSparkleSprites(structPtr->unk28e0);
if (sub_81CDD5C() != TRUE && sub_81CDC60() == sub_81CDC50())
@@ -459,7 +459,7 @@ u32 sub_81CE4D8(s32 state)
return 1;
return 2;
case 8:
- if (!sub_81D3178(sub_81CDC70(), &structPtr->unk1814))
+ if (!TryUpdateConditionMonTransitionOn(sub_81CDC70(), &structPtr->unk1814))
{
ResetConditionSparkleSprites(structPtr->unk28e0);
CreateConditionSparkleSprites(structPtr->unk28e0, structPtr->unk1816, sub_81CDDB0());
@@ -488,7 +488,7 @@ u32 sub_81CE5E4(s32 state)
DestroyConditionSparkleSprites(structPtr->unk28e0);
return 1;
case 3:
- if (!sub_81D31A4(sub_81CDC70(), &structPtr->unk1814))
+ if (!TryUpdateConditionMonTransitionOff(sub_81CDC70(), &structPtr->unk1814))
return 1;
return 2;
case 4:
@@ -834,7 +834,7 @@ void sub_81CED30(u8 var)
void sub_81CEE44(void)
{
- struct UnknownStruct_81D1ED4 *unk = sub_81CDC70();
+ struct ConditionGraph *unk = sub_81CDC70();
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
@@ -857,17 +857,17 @@ void sub_81CEE74(bool8 showBg)
void sub_81CEE90(void)
{
- struct UnknownStruct_81D1ED4 *unk = sub_81CDC70();
+ struct ConditionGraph *unk = sub_81CDC70();
u8 id = sub_81CDC84();
gUnknown_030012BC = id;
sub_81D1F84(unk, unk->unk14[3], unk->unk14[id]);
- sub_81D2074(unk);
+ TransitionConditionGraph(unk);
}
void sub_81CEEC8(void)
{
- struct UnknownStruct_81D1ED4 *unk = sub_81CDC70();
+ struct ConditionGraph *unk = sub_81CDC70();
if (sub_81CDD5C() || sub_81CDC60() != sub_81CDC50() - 1)
sub_81D1F84(unk, unk->unk14[sub_81CDC84()], unk->unk14[3]);
diff --git a/src/use_pokeblock.c b/src/use_pokeblock.c
index 30d531514..ebb237d54 100644
--- a/src/use_pokeblock.c
+++ b/src/use_pokeblock.c
@@ -54,21 +54,21 @@ struct UsePokeblockSession
struct Pokemon *mon;
u8 stringBuffer[64];
u8 mainState;
- u8 unused_1;
+ u8 unused1;
u8 timer;
u8 statId;
u8 numEnhancements;
- u8 unused_2;
+ u8 unused2;
bool8 monInTopHalf;
- u8 conditionsPreBlock[FLAVOR_COUNT];
- u8 conditionsPostBlock[FLAVOR_COUNT];
+ u8 conditionsBeforeBlock[FLAVOR_COUNT];
+ u8 conditionsAfterBlock[FLAVOR_COUNT];
u8 enhancements[FLAVOR_COUNT];
s16 pokeblockStatBoosts[FLAVOR_COUNT];
u8 numSelections; // num in party + 1 (for Cancel)
u8 curSelection;
bool8 (*loadNewSelection)(void);
u8 helperState;
- u8 unused_3;
+ u8 unused3;
u8 natureText[34];
};
@@ -85,30 +85,30 @@ struct UsePokeblockMenuPokemon
struct UsePokeblockMenu
{
- /*0x0000*/ u8 filler0[4]; // unused
- /*0x0000*/ u16 partyPalettes[PARTY_SIZE][0x40];
- /*0x0304*/ u8 partySheets[NUM_SELECTIONS_LOADED][0x2000];
- /*0x6304*/ u8 filler_6304[0x1000]; // unused?
- /*0x7304*/ u8 tilemapBuffer[BG_SCREEN_SIZE + 2];
- /*0x7B06*/ u8 selectionIconSpriteIds[PARTY_SIZE + 1];
- /*0x7B0E*/ s16 curMonXOffset;
- /*0x7B10*/ u8 curMonSpriteId;
- /*0x7B12*/ u16 curMonPalette;
- /*0x7B12*/ u16 curMonSheet;
- /*0x7B12*/ u8 *curMonTileStart;
- /*0x7B1C*/ struct Sprite *sparkles[MAX_CONDITION_SPARKLES];
- /*0x7B44*/ struct Sprite *condition[2];
- /*0x7B4C*/ u8 field_7B4C;
- /*0x7B4D*/ u8 locationStrings[NUM_SELECTIONS_LOADED][24]; // Gets an "in party" or "in box #" string that never gets printed
- /*0x7B95*/ u8 monNameStrings[NUM_SELECTIONS_LOADED][64];
- /*0x7C58*/ struct UnknownStruct_81D1ED4 field_7C58;
- /*0x7FB0*/ u8 numSparkles[NUM_SELECTIONS_LOADED];
- /*0x7FB3*/ s8 curLoadId;
- /*0x7FB4*/ s8 nextLoadId;
- /*0x7FB5*/ s8 prevLoadId;
- /*0x7FB6*/ s8 toLoadId;
- /*0x7FB8*/ struct UsePokeblockMenuPokemon party[PARTY_SIZE];
- /*0x7FD0*/ struct UsePokeblockSession info;
+ u32 unused;
+ u16 partyPalettes[PARTY_SIZE][0x40];
+ u8 partySheets[NUM_SELECTIONS_LOADED][0x2000];
+ u8 unusedBuffer[0x1000];
+ u8 tilemapBuffer[BG_SCREEN_SIZE + 2];
+ u8 selectionIconSpriteIds[PARTY_SIZE + 1];
+ s16 curMonXOffset;
+ u8 curMonSpriteId;
+ u16 curMonPalette;
+ u16 curMonSheet;
+ u8 *curMonTileStart;
+ struct Sprite *sparkles[MAX_CONDITION_SPARKLES];
+ struct Sprite *condition[2];
+ u8 toLoadSelection;
+ u8 locationStrings[NUM_SELECTIONS_LOADED][24]; // Gets an "in party" or "in box #" string that never gets printed
+ u8 monNameStrings[NUM_SELECTIONS_LOADED][64];
+ struct ConditionGraph graph;
+ u8 numSparkles[NUM_SELECTIONS_LOADED];
+ s8 curLoadId;
+ s8 nextLoadId;
+ s8 prevLoadId;
+ s8 toLoadId;
+ struct UsePokeblockMenuPokemon party[PARTY_SIZE];
+ struct UsePokeblockSession info;
};
static void SetUsePokeblockCallback(void (*func)(void));
@@ -120,7 +120,7 @@ static void CB2_ShowUsePokeblockMenuForResults(void);
static void ShowUsePokeblockMenuForResults(void);
static void LoadPartyInfo(void);
static void LoadAndCreateSelectionIcons(void);
-static u8 GetNumNonEggPartyMons(u8);
+static u8 GetSelectionIdFromPartyId(u8);
static bool8 LoadConditionTitle(void);
static bool8 LoadUsePokeblockMenuGfx(void);
static void UpdateMonPic(u8);
@@ -170,13 +170,13 @@ static EWRAM_DATA u8 *sGraph_Gfx = NULL;
static EWRAM_DATA u8 *sMonFrame_TilemapPtr = NULL;
static EWRAM_DATA struct UsePokeblockMenu *sMenu = NULL;
-static const u32 sMonFrame_Pal[] = INCBIN_U32("graphics/pokeblock/use_screen/mon_frame_pal.bin"); // TODO: convert to .pal
+static const u32 sMonFrame_Pal[] = INCBIN_U32("graphics/pokeblock/use_screen/mon_frame_pal.bin");
static const u32 sMonFrame_Gfx[] = INCBIN_U32("graphics/pokeblock/use_screen/mon_frame.4bpp");
static const u32 sMonFrame_Tilemap[] = INCBIN_U32("graphics/pokeblock/use_screen/mon_frame.bin");
static const u32 sGraphData_Tilemap[] = INCBIN_U32("graphics/pokeblock/use_screen/graph_data.bin");
-// For some reason the condition/flavors aren't listed in order in this file
-// Normally they would go Cool/Spicy, Beauty/Dry, Cute/Sweet, Smart/Bitter, Tough/Sour
+// 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)
static const u32 sMonDataConditions[FLAVOR_COUNT] =
{
MON_DATA_COOL,
@@ -370,19 +370,19 @@ static const struct OamData sOam_Condition =
.paletteNum = 0,
};
-static const union AnimCmd gSpriteAnim_085DFD7C[] =
+static const union AnimCmd sAnim_Condition_0[] =
{
ANIMCMD_FRAME(0, 5),
ANIMCMD_END
};
-static const union AnimCmd gSpriteAnim_085DFD84[] =
+static const union AnimCmd sAnim_Condition_1[] =
{
ANIMCMD_FRAME(32, 5),
ANIMCMD_END
};
-static const union AnimCmd gSpriteAnim_085DFD8C[] =
+static const union AnimCmd sAnim_Condition_2[] =
{
ANIMCMD_FRAME(64, 5),
ANIMCMD_END
@@ -390,9 +390,9 @@ static const union AnimCmd gSpriteAnim_085DFD8C[] =
static const union AnimCmd *const sAnims_Condition[] =
{
- gSpriteAnim_085DFD7C,
- gSpriteAnim_085DFD84,
- gSpriteAnim_085DFD8C
+ sAnim_Condition_0,
+ sAnim_Condition_1,
+ sAnim_Condition_2
};
static const struct SpriteTemplate sSpriteTemplate_Condition =
@@ -429,7 +429,7 @@ static void CB2_ReturnAndChooseMonToGivePokeblock(void)
sInfo = &sMenu->info;
sInfo->pokeblock = sPokeblock;
sInfo->exitCallback = sExitCallback;
- gPokeblockMonId = GetNumNonEggPartyMons(gPokeblockMonId);
+ gPokeblockMonId = GetSelectionIdFromPartyId(gPokeblockMonId);
sInfo->monInTopHalf = (gPokeblockMonId <= PARTY_SIZE / 2) ? FALSE : TRUE;
SetUsePokeblockCallback(LoadUsePokeblockMenu);
SetMainCallback2(CB2_ReturnToUsePokeblockMenu);
@@ -470,7 +470,7 @@ static void VBlankCB_UsePokeblockMenu(void)
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
- sub_81D2108(&sMenu->field_7C58);
+ sub_81D2108(&sMenu->graph);
ScanlineEffect_InitHBlankDmaTransfer();
}
@@ -486,7 +486,7 @@ static void LoadUsePokeblockMenu(void)
{
case 0:
sMenu->curMonSpriteId = 0xFF;
- sub_81D1ED4(&sMenu->field_7C58);
+ sub_81D1ED4(&sMenu->graph);
sInfo->mainState++;
break;
case 1:
@@ -529,26 +529,26 @@ static void LoadUsePokeblockMenu(void)
sInfo->mainState++;
break;
case 9:
- if (!sub_81D312C(&sMenu->curMonXOffset))
+ if (!MoveConditionMonOnscreen(&sMenu->curMonXOffset))
sInfo->mainState++;
break;
case 10:
sInfo->mainState++;
break;
case 11:
- sub_81D2754(sMenu->field_7C58.unk0[0], sMenu->field_7C58.unk14[0]);
- sub_81D20AC(&sMenu->field_7C58);
+ sub_81D2754(sMenu->graph.unk0[0], sMenu->graph.unk14[0]);
+ sub_81D20AC(&sMenu->graph);
sInfo->mainState++;
break;
case 12:
- if (!sub_81D20BC(&sMenu->field_7C58))
+ if (!sub_81D20BC(&sMenu->graph))
{
- sub_81D1F84(&sMenu->field_7C58, sMenu->field_7C58.unk14[0], sMenu->field_7C58.unk14[0]);
+ sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[0], sMenu->graph.unk14[0]);
sInfo->mainState++;
}
break;
case 13:
- sub_81D2230(&sMenu->field_7C58);
+ sub_81D2230(&sMenu->graph);
sInfo->mainState++;
break;
case 14:
@@ -782,13 +782,13 @@ static void ShowPokeblockResults(void)
break;
case 2:
CalculateConditionEnhancements();
- sub_81D2754(sInfo->conditionsPostBlock, sMenu->field_7C58.unk14[3]);
- sub_81D1F84(&sMenu->field_7C58, sMenu->field_7C58.unk14[sMenu->curLoadId], sMenu->field_7C58.unk14[3]);
+ sub_81D2754(sInfo->conditionsAfterBlock, sMenu->graph.unk14[3]);
+ sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[sMenu->curLoadId], sMenu->graph.unk14[3]);
LoadAndCreateUpDownSprites();
sInfo->mainState++;
break;
case 3:
- var = sub_81D2074(&sMenu->field_7C58);
+ var = TransitionConditionGraph(&sMenu->graph);
if (!var)
{
CalculateNumAdditionalSparkles(GetPartyIdFromSelectionId(sMenu->info.curSelection));
@@ -995,7 +995,7 @@ static void GetMonConditions(struct Pokemon *mon, u8 *data)
data[i] = GetMonData(mon, sMonDataConditions[i]);
}
-static void UpdateMonConditions(struct Pokeblock *pokeblock, struct Pokemon *mon)
+static void AddPokeblockToConditions(struct Pokeblock *pokeblock, struct Pokemon *mon)
{
u16 i;
s16 cstat;
@@ -1031,11 +1031,11 @@ static void CalculateConditionEnhancements(void)
struct Pokemon *mon = gPlayerParty;
mon += sMenu->party[sMenu->info.curSelection].monId;
- GetMonConditions(mon, sInfo->conditionsPreBlock);
- UpdateMonConditions(sInfo->pokeblock, mon);
- GetMonConditions(mon, sInfo->conditionsPostBlock);
+ GetMonConditions(mon, sInfo->conditionsBeforeBlock);
+ AddPokeblockToConditions(sInfo->pokeblock, mon);
+ GetMonConditions(mon, sInfo->conditionsAfterBlock);
for (i = 0; i < FLAVOR_COUNT; i++)
- sInfo->enhancements[i] = sInfo->conditionsPostBlock[i] - sInfo->conditionsPreBlock[i];
+ sInfo->enhancements[i] = sInfo->conditionsAfterBlock[i] - sInfo->conditionsBeforeBlock[i];
}
static void CalculatePokeblockEffectiveness(struct Pokeblock *pokeblock, struct Pokemon *mon)
@@ -1097,18 +1097,17 @@ static u8 GetPartyIdFromSelectionId(u8 selectionId)
return 0;
}
-// TODO: Update
-static u8 GetNumNonEggPartyMons(u8 partyCount)
+// Eggs are not viewable on the condition screen, so count how many are skipped over to reach the party id
+static u8 GetSelectionIdFromPartyId(u8 partyId)
{
u8 i, numEggs;
-
- for (i = 0, numEggs = 0; i < partyCount; i++)
+ for (i = 0, numEggs = 0; i < partyId; i++)
{
if (GetMonData(&gPlayerParty[i], MON_DATA_IS_EGG))
numEggs++;
}
- return partyCount - numEggs;
+ return partyId - numEggs;
}
// Unused
@@ -1204,7 +1203,7 @@ static void LoadMonInfo(s16 partyId, u8 loadId)
bool8 excludesCancel = FALSE; // whether or not numSelections excludes Cancel from the count
GetConditionMenuMonNameAndLocString(sMenu->locationStrings[loadId], sMenu->monNameStrings[loadId], boxId, monId, partyId, numSelections, excludesCancel);
- GetConditionMenuMonConditions(&sMenu->field_7C58, sMenu->numSparkles, boxId, monId, partyId, loadId, numSelections, excludesCancel);
+ GetConditionMenuMonConditions(&sMenu->graph, sMenu->numSparkles, boxId, monId, partyId, loadId, numSelections, excludesCancel);
GetConditionMenuMonGfx(sMenu->partySheets[loadId], sMenu->partyPalettes[loadId], boxId, monId, partyId, numSelections, excludesCancel);
}
@@ -1226,8 +1225,8 @@ static void UpdateMonPic(u8 loadId)
sMenu->curMonSpriteId = spriteId;
if (spriteId == MAX_SPRITES)
{
- FreeSpriteTilesByTag(TAG_SPMENU_CONDITION_MON);
- FreeSpritePaletteByTag(TAG_SPMENU_CONDITION_MON);
+ FreeSpriteTilesByTag(TAG_CONDITION_MON);
+ FreeSpritePaletteByTag(TAG_CONDITION_MON);
sMenu->curMonSpriteId = 0xFF;
}
else
@@ -1277,7 +1276,7 @@ static void LoadAndCreateSelectionIcons(void)
}
// Fill placeholder icons for remaining (empty) party slots
- spriteTemplate.tileTag = TAG_SPMENU_CONDITION_BALL_PLACEHOLDER;
+ spriteTemplate.tileTag = TAG_CONDITION_BALL_PLACEHOLDER;
for (; i < PARTY_SIZE; i++)
{
spriteId = CreateSprite(&spriteTemplate, 230, (i * 20) + 8, 0);
@@ -1293,7 +1292,7 @@ static void LoadAndCreateSelectionIcons(void)
}
// Add cancel selection icon at bottom
- spriteTemplate.tileTag = TAG_SPMENU_CONDITION_CANCEL;
+ spriteTemplate.tileTag = TAG_CONDITION_CANCEL;
spriteTemplate.callback = SpriteCB_SelectionIconCancel;
spriteId = CreateSprite(&spriteTemplate, 222, (i * 20) + 8, 0);
if (spriteId != MAX_SPRITES)
@@ -1420,10 +1419,7 @@ static void UpdateSelection(bool8 up)
else
newLoadId = sMenu->nextLoadId;
- sub_81D1F84(
- &sMenu->field_7C58,
- sMenu->field_7C58.unk14[sMenu->curLoadId],
- sMenu->field_7C58.unk14[newLoadId]);
+ sub_81D1F84(&sMenu->graph, sMenu->graph.unk14[sMenu->curLoadId], sMenu->graph.unk14[newLoadId]);
if (sMenu->info.curSelection == sMenu->info.numSelections - 1)
startedOnMon = FALSE; // moving off of Cancel
@@ -1442,7 +1438,7 @@ static void UpdateSelection(bool8 up)
? sMenu->info.numSelections - 1
: sMenu->info.curSelection - 1;
- sMenu->field_7B4C = (sMenu->info.curSelection == 0)
+ sMenu->toLoadSelection = (sMenu->info.curSelection == 0)
? sMenu->info.numSelections - 1
: sMenu->info.curSelection - 1;
}
@@ -1458,7 +1454,7 @@ static void UpdateSelection(bool8 up)
? sMenu->info.curSelection + 1
: 0;
- sMenu->field_7B4C = (sMenu->info.curSelection < sMenu->info.numSelections - 1)
+ sMenu->toLoadSelection = (sMenu->info.curSelection < sMenu->info.numSelections - 1)
? sMenu->info.curSelection + 1
: 0;
}
@@ -1491,9 +1487,10 @@ static bool8 LoadNewSelection_CancelToMon(void)
sMenu->info.helperState++;
break;
case 2:
- if (!sub_81D3178(&sMenu->field_7C58, &sMenu->curMonXOffset))
+ if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset))
{
- LoadMonInfo(sMenu->field_7B4C, sMenu->toLoadId);
+ // Load the new adjacent pokemon (not the one being shown)
+ LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
sMenu->info.helperState++;
}
break;
@@ -1517,7 +1514,7 @@ static bool8 LoadNewSelection_MonToCancel(void)
switch (sMenu->info.helperState)
{
case 0:
- if (!sub_81D31A4(&sMenu->field_7C58, &sMenu->curMonXOffset))
+ if (!TryUpdateConditionMonTransitionOff(&sMenu->graph, &sMenu->curMonXOffset))
sMenu->info.helperState++;
break;
case 1:
@@ -1525,7 +1522,7 @@ static bool8 LoadNewSelection_MonToCancel(void)
sMenu->info.helperState++;
break;
case 2:
- LoadMonInfo(sMenu->field_7B4C, sMenu->toLoadId);
+ LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
sMenu->info.helperState++;
break;
case 3:
@@ -1541,8 +1538,8 @@ static bool8 LoadNewSelection_MonToMon(void)
switch (sMenu->info.helperState)
{
case 0:
- sub_81D2074(&sMenu->field_7C58);
- if (!sub_81D3150(&sMenu->curMonXOffset))
+ TransitionConditionGraph(&sMenu->graph);
+ if (!MoveConditionMonOffscreen(&sMenu->curMonXOffset))
{
UpdateMonPic(sMenu->curLoadId);
sMenu->info.helperState++;
@@ -1553,9 +1550,10 @@ static bool8 LoadNewSelection_MonToMon(void)
sMenu->info.helperState++;
break;
case 2:
- if (!sub_81D3178(&sMenu->field_7C58, &sMenu->curMonXOffset))
+ if (!TryUpdateConditionMonTransitionOn(&sMenu->graph, &sMenu->curMonXOffset))
{
- LoadMonInfo(sMenu->field_7B4C, sMenu->toLoadId);
+ // Load the new adjacent pokemon (not the one being shown)
+ LoadMonInfo(sMenu->toLoadSelection, sMenu->toLoadId);
sMenu->info.helperState++;
}
break;
@@ -1590,9 +1588,9 @@ static void SpriteCB_SelectionIconPokeball(struct Sprite *sprite)
static void SpriteCB_SelectionIconCancel(struct Sprite *sprite)
{
if (sMenu->info.curSelection == sMenu->info.numSelections - 1)
- sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_SPMENU_CONDITION_BALL);
+ sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_BALL);
else
- sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_SPMENU_CONDITION_CANCEL);
+ sprite->oam.paletteNum = IndexOfSpritePaletteTag(TAG_CONDITION_CANCEL);
}
// Calculate the max id for sparkles/stars that appear around the pokemon on the condition screen