summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDizzyEggg <jajkodizzy@wp.pl>2019-04-02 13:35:52 +0200
committerhuderlem <huderlem@gmail.com>2019-04-02 16:28:38 -0500
commitbaa187665b102b0210ecd7296aaaf0de512d3e87 (patch)
treedda624acf585ee44f10740b20745a8aa2a489592 /src
parent2745cdc7d26e84d7efc5349519a494610390e130 (diff)
Document a bit of script menu and battle anims
Diffstat (limited to 'src')
-rw-r--r--src/ghost.c106
-rw-r--r--src/mauville_old_man.c2
-rw-r--r--src/menu.c14
-rw-r--r--src/script_menu.c107
-rwxr-xr-xsrc/script_pokemon_util_80F87D8.c2
5 files changed, 116 insertions, 115 deletions
diff --git a/src/ghost.c b/src/ghost.c
index 998be0caa..97b86aa76 100644
--- a/src/ghost.c
+++ b/src/ghost.c
@@ -87,7 +87,7 @@ const union AffineAnimCmd *const gUnknown_08596D54[] =
gUnknown_08596D44,
};
-const struct SpriteTemplate gUnknown_08596D58 =
+const struct SpriteTemplate gShadowBallSpriteTemplate =
{
.tileTag = ANIM_TAG_SHADOW_BALL,
.paletteTag = ANIM_TAG_SHADOW_BALL,
@@ -261,20 +261,20 @@ static void sub_81116E8(struct Sprite *sprite)
AnimTranslateLinear(sprite);
sprite->pos2.x += Sin(sprite->data[5], 10);
sprite->pos2.y += Cos(sprite->data[5], 15);
-
+
r2 = sprite->data[5];
sprite->data[5] = (sprite->data[5] + 5) & 0xFF;
r0 = sprite->data[5];
-
+
if (r2 == 0 || r2 > 196)
{
if (r0 > 0)
PlaySE(SE_W109);
}
-
+
if (sprite->data[6] == 0)
{
- sprite->invisible = TRUE;
+ sprite->invisible = TRUE;
sprite->callback = DestroyAnimSpriteAndDisableBlend;
}
else
@@ -283,18 +283,18 @@ static void sub_81116E8(struct Sprite *sprite)
static void sub_8111764(struct Sprite *sprite)
{
-
- s16 r0;
+
+ s16 r0;
if (sprite->data[6] > 0xFF)
{
if (++sprite->data[6] == 0x10d)
sprite->data[6] = 0;
return;
}
-
+
r0 = sprite->data[7];
sprite->data[7]++;
-
+
if ((r0 & 0xFF) == 0)
{
sprite->data[7] &= 0xff00;
@@ -392,16 +392,16 @@ static void sub_811196C(u8 taskId)
}
}
-// Spins a sprite towards the target, pausing in the middle.
-// Used in Shadow Ball.
+// Spins a sprite towards the target, pausing in the middle.
+// Used in Shadow Ball.
// arg 0: duration step 1 (attacker -> center)
// arg 1: duration step 2 (spin center)
// arg 2: duration step 3 (center -> target)
static void InitAnimShadowBall(struct Sprite *sprite)
{
- u16 r5, r6;
- r5 = sprite->pos1.x;
- r6 = sprite->pos1.y;
+ s16 oldPosX = sprite->pos1.x;
+ s16 oldPosY = sprite->pos1.y;
+
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2);
sprite->pos1.y = GetBattlerSpriteCoord(gBattleAnimAttacker, 3);
sprite->data[0] = 0;
@@ -410,8 +410,8 @@ static void InitAnimShadowBall(struct Sprite *sprite)
sprite->data[3] = gBattleAnimArgs[2];
sprite->data[4] = sprite->pos1.x << 4;
sprite->data[5] = sprite->pos1.y << 4;
- sprite->data[6] = (((s16)r5 - sprite->pos1.x) << 4) / (gBattleAnimArgs[0] << 1);
- sprite->data[7] = (((s16)r6 - sprite->pos1.y) << 4) / (gBattleAnimArgs[0] << 1);
+ sprite->data[6] = ((oldPosX - sprite->pos1.x) << 4) / (gBattleAnimArgs[0] << 1);
+ sprite->data[7] = ((oldPosY - sprite->pos1.y) << 4) / (gBattleAnimArgs[0] << 1);
sprite->callback = AnimShadowBallStep;
}
@@ -465,50 +465,57 @@ static void sub_8111B9C(struct Sprite *sprite)
sprite->callback = sub_8111BB4;
}
-static void sub_8111BB4(struct Sprite *sprite) {
-
- s8 r5 = FALSE;
+static void sub_8111BB4(struct Sprite *sprite)
+{
+ bool8 r5 = FALSE;
bool8 r6 = FALSE;
- if(sprite->animEnded)
+
+ if (sprite->animEnded)
{
- if(!(sprite->invisible))
- sprite->invisible=TRUE;
- switch(sprite->data[0])
+ if (!sprite->invisible)
+ sprite->invisible = TRUE;
+
+ switch (sprite->data[0])
{
- case 0:
- if((sprite->data[1]) != 2)
- break;
- goto loc_08111C06;
- case 1:
- if((sprite->data[1]) == 4)
- r5 = TRUE;
- break;
- default:
- r6 = TRUE;
+ default:
+ r6 = TRUE;
+ break;
+ case 0:
+ if (sprite->data[1] == 2)
+ r5 = TRUE;
+ break;
+ case 1:
+ if (sprite->data[1] == 4)
+ r5 = TRUE;
+ break;
}
- if(r5)
+
+ if (r5)
{
- loc_08111C06:
sprite->invisible ^= 1;
sprite->data[2]++;
sprite->data[1] = 0;
- if(sprite->data[2] == 5)
+ if (sprite->data[2] == 5)
{
sprite->data[2] = 0;
sprite->data[0]++;
}
}
- else if(r6)
+ else if (r6)
+ {
DestroyAnimSprite(sprite);
+ }
else
+ {
sprite->data[1]++;
+ }
}
}
void sub_8111C50(u8 taskId)
{
struct Task *task;
-
+
task = &gTasks[taskId];
task->data[0] = CloneBattlerSpriteWithBlend(1);
if (task->data[0] < 0)
@@ -523,7 +530,7 @@ void sub_8111C50(u8 taskId)
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(task->data[2], task->data[3]));
gSprites[task->data[0]].data[0] = 80;
- if (GetBattlerSide(gBattleAnimTarget) == 0)
+ if (GetBattlerSide(gBattleAnimTarget) == B_SIDE_PLAYER)
{
gSprites[task->data[0]].data[1] = -144;
gSprites[task->data[0]].data[2] = 112;
@@ -573,6 +580,7 @@ static void sub_8111D78(u8 taskId)
break;
case 2:
DestroyAnimVisualTask(taskId);
+ break;
}
}
@@ -595,7 +603,7 @@ static void sub_8111E78(u8 taskId)
switch (task->data[15])
{
case 0:
- task->data[14] = AllocSpritePalette(0x2771);
+ task->data[14] = AllocSpritePalette(ANIM_TAG_BENT_SPOON);
if (task->data[14] == 0xFF || task->data[14] == 0xF)
{
DestroyAnimVisualTask(taskId);
@@ -605,7 +613,7 @@ static void sub_8111E78(u8 taskId)
task->data[0] = CloneBattlerSpriteWithBlend(1);
if (task->data[0] < 0)
{
- FreeSpritePaletteByTag(0x2771);
+ FreeSpritePaletteByTag(ANIM_TAG_BENT_SPOON);
DestroyAnimVisualTask(taskId);
}
else
@@ -698,14 +706,14 @@ static void sub_81120DC(u8 taskId)
static void sub_8112170(u8 taskId)
{
struct Task *task = &gTasks[taskId];
- u8 position = GetBattlerSpriteBGPriorityRank(gBattleAnimTarget);
+ u8 rank = GetBattlerSpriteBGPriorityRank(gBattleAnimTarget);
switch (task->data[15])
{
case 0:
gScanlineEffect.state = 3;
task->data[14] = GetAnimBattlerSpriteId(1);
- if (position == 1)
+ if (rank == 1)
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG1_ON);
else
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
@@ -714,12 +722,12 @@ static void sub_8112170(u8 taskId)
BlendPalette(task->data[4], 16, 0, RGB(13, 0, 15));
break;
case 2:
- gSprites[task->data[14]].invisible = 1;
+ gSprites[task->data[14]].invisible = TRUE;
obj_delete_but_dont_free_vram(&gSprites[task->data[0]]);
- FreeSpritePaletteByTag(0x2771);
+ FreeSpritePaletteByTag(ANIM_TAG_BENT_SPOON);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
SetGpuReg(REG_OFFSET_BLDALPHA, 0);
- if (position == 1)
+ if (rank == 1)
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG1_ON);
else
SetGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_BG2_ON);
@@ -886,7 +894,7 @@ static void sub_81125E0(u8 taskId)
}
}
}
-
+
if (task->data[10])
task->data[10]--;
else if (task->data[6])
@@ -1081,7 +1089,7 @@ static void sub_8112ACC(struct Sprite *sprite)
if (sprite->data[0] == 0)
{
SetGpuReg(REG_OFFSET_BLDCNT, (BLDCNT_EFFECT_BLEND | BLDCNT_TGT2_ALL));
- SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(0x10, 0));
+ SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(16, 0));
sprite->data[0]++;
sprite->data[1] = 0;
sprite->data[2] = 0;
@@ -1120,7 +1128,7 @@ static void sub_8112B78(struct Sprite *sprite)
sprite->pos2.x = Sin(sprite->data[0], 12);
if (GetBattlerSide(gBattleAnimAttacker) != B_SIDE_PLAYER)
sprite->pos2.x = -sprite->pos2.x;
-
+
sprite->data[0] = (sprite->data[0] + 6) & 0xFF;
sprite->data[1] += 0x100;
sprite->pos2.y = -(sprite->data[1] >> 8);
diff --git a/src/mauville_old_man.c b/src/mauville_old_man.c
index ddd3f931e..8bb9cb6e4 100644
--- a/src/mauville_old_man.c
+++ b/src/mauville_old_man.c
@@ -1193,7 +1193,7 @@ static void Task_StoryListMenu(u8 taskId) // Task_StoryListMenu
gSpecialVar_Result = 1;
sSelectedStory = selection;
}
- sub_80E2A78(sStorytellerWindowId);
+ ClearToTransparentAndRemoveWindow(sStorytellerWindowId);
DestroyTask(taskId);
EnableBothScriptContexts();
break;
diff --git a/src/menu.c b/src/menu.c
index 958788b25..80d440771 100644
--- a/src/menu.c
+++ b/src/menu.c
@@ -1661,16 +1661,14 @@ void CreateYesNoMenu(const struct WindowTemplate *window, u16 baseTileNum, u8 pa
InitMenuInUpperLeftCornerPlaySoundWhenAPressed(sYesNoWindowId, 2, initialCursorPos);
}
-void sub_81997AC(u8 windowId, u8 a4, u8 a6, u8 a7, const struct MenuAction *strs)
+void PrintMenuGridTable(u8 windowId, u8 optionWidth, u8 horizontalCount, u8 verticalCount, const struct MenuAction *strs)
{
- u32 i;
- u32 j;
- for (i = 0; i < a7; i++)
+ u32 i, j;
+
+ for (i = 0; i < verticalCount; i++)
{
- for (j = 0; j < a6; j++)
- {
- AddTextPrinterParameterized(windowId, 1, strs[(i * a6) + j].text, (a4 * j) + 8, (i * 16) + 1, 0xFF, NULL);
- }
+ for (j = 0; j < horizontalCount; j++)
+ AddTextPrinterParameterized(windowId, 1, strs[(i * horizontalCount) + j].text, (optionWidth * j) + 8, (i * 16) + 1, 0xFF, NULL);
}
CopyWindowToVram(windowId, 2);
}
diff --git a/src/script_menu.c b/src/script_menu.c
index c7523a370..082253e35 100644
--- a/src/script_menu.c
+++ b/src/script_menu.c
@@ -1183,7 +1183,7 @@ static void Task_HandleMultichoiceInput(u8 taskId)
{
gSpecialVar_Result = selection;
}
- sub_80E2A78(tWindowId);
+ ClearToTransparentAndRemoveWindow(tWindowId);
DestroyTask(taskId);
EnableBothScriptContexts();
}
@@ -1219,8 +1219,6 @@ bool8 IsScriptActive(void)
static void Task_HandleYesNoInput(u8 taskId)
{
- u8 left, top;
-
if (gTasks[taskId].tRight < 5)
{
gTasks[taskId].tRight++;
@@ -1229,9 +1227,9 @@ static void Task_HandleYesNoInput(u8 taskId)
switch (Menu_ProcessInputNoWrapClearOnChoose())
{
- case -2:
+ case MENU_NOTHING_CHOSEN:
return;
- case -1:
+ case MENU_B_PRESSED:
case 1:
PlaySE(SE_SELECT);
gSpecialVar_Result = 0;
@@ -1247,8 +1245,6 @@ static void Task_HandleYesNoInput(u8 taskId)
bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPress, u8 columnCount)
{
- u8 bottom = 0;
-
if (FuncIsActiveTask(Task_HandleMultichoiceGridInput) == TRUE)
{
return FALSE;
@@ -1256,10 +1252,8 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPr
else
{
u8 taskId;
- u8 unk2;
- int width;
- int i;
- u8 newWidth;
+ u8 rowCount, newWidth;
+ int i, width;
gSpecialVar_Result = 0xFF;
width = 0;
@@ -1272,15 +1266,15 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPr
newWidth = convert_pixel_width_to_tile_width(width);
left = sub_80E2D5C(left, columnCount * newWidth);
- unk2 = gMultichoiceLists[multichoiceId].count / columnCount;
+ rowCount = gMultichoiceLists[multichoiceId].count / columnCount;
taskId = CreateTask(Task_HandleMultichoiceGridInput, 80);
gTasks[taskId].tIgnoreBPress = ignoreBPress;
- gTasks[taskId].tWindowId = CreateWindowFromRect(left, top, columnCount * newWidth, unk2 * 2);
+ gTasks[taskId].tWindowId = CreateWindowFromRect(left, top, columnCount * newWidth, rowCount * 2);
SetStandardWindowBorderStyle(gTasks[taskId].tWindowId, 0);
- sub_81997AC(gTasks[taskId].tWindowId, newWidth * 8, columnCount, unk2, gMultichoiceLists[multichoiceId].list);
- sub_8199944(gTasks[taskId].tWindowId, newWidth * 8, columnCount, unk2, 0);
+ PrintMenuGridTable(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, gMultichoiceLists[multichoiceId].list);
+ sub_8199944(gTasks[taskId].tWindowId, newWidth * 8, columnCount, rowCount, 0);
CopyWindowToVram(gTasks[taskId].tWindowId, 3);
return TRUE;
}
@@ -1291,23 +1285,24 @@ static void Task_HandleMultichoiceGridInput(u8 taskId)
s16 *data = gTasks[taskId].data;
s8 selection = Menu_ProcessInputGridLayout();
- if (selection != -2)
+ switch (selection)
{
- if (selection == -1)
- {
- if (tIgnoreBPress)
- return;
- PlaySE(SE_SELECT);
- gSpecialVar_Result = 0x7F;
- }
- else
- {
- gSpecialVar_Result = selection;
- }
- sub_80E2A78(tWindowId);
- DestroyTask(taskId);
- EnableBothScriptContexts();
+ case MENU_NOTHING_CHOSEN:
+ return;
+ case MENU_B_PRESSED:
+ if (tIgnoreBPress)
+ return;
+ PlaySE(SE_SELECT);
+ gSpecialVar_Result = 0x7F;
+ break;
+ default:
+ gSpecialVar_Result = selection;
+ break;
}
+
+ ClearToTransparentAndRemoveWindow(tWindowId);
+ DestroyTask(taskId);
+ EnableBothScriptContexts();
}
#undef tWindowId
@@ -1564,7 +1559,7 @@ static void Task_PokemonPicWindow(u8 taskId)
task->tState++;
break;
case 3:
- sub_80E2A78(task->tWindowId);
+ ClearToTransparentAndRemoveWindow(task->tWindowId);
DestroyTask(taskId);
break;
}
@@ -1628,7 +1623,7 @@ u8 CreateWindowFromRect(u8 x, u8 y, u8 width, u8 height)
return windowId;
}
-void sub_80E2A78(u8 windowId)
+void ClearToTransparentAndRemoveWindow(u8 windowId)
{
ClearStdWindowAndFrameToTransparent(windowId, TRUE);
RemoveWindow(windowId);
@@ -1638,30 +1633,30 @@ static void sub_80E2A94(u8 multichoiceId)
{
switch (multichoiceId)
{
- case 77:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBAC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 76:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BB9C[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 78:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBBC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 79:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBCC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 75:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBEC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
- case 74:
- FillWindowPixelBuffer(0, PIXEL_FILL(1));
- AddTextPrinterParameterized2(0, 1, gUnknown_0858BBE0[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
- break;
+ case 77:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBAC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 76:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BB9C[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 78:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBBC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 79:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBCC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 75:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBEC[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
+ case 74:
+ FillWindowPixelBuffer(0, PIXEL_FILL(1));
+ AddTextPrinterParameterized2(0, 1, gUnknown_0858BBE0[Menu_GetCursorPos()], 0, NULL, 2, 1, 3);
+ break;
}
}
diff --git a/src/script_pokemon_util_80F87D8.c b/src/script_pokemon_util_80F87D8.c
index 7e4c14531..ece030395 100755
--- a/src/script_pokemon_util_80F87D8.c
+++ b/src/script_pokemon_util_80F87D8.c
@@ -395,7 +395,7 @@ static void sub_80F8EE8(u8 taskId)
task->data[0]++;
break;
case 4:
- sub_80E2A78(gTasks[taskId].data[5]);
+ ClearToTransparentAndRemoveWindow(gTasks[taskId].data[5]);
DestroyTask(taskId);
break;
}