diff options
Diffstat (limited to 'src')
113 files changed, 7006 insertions, 2776 deletions
diff --git a/src/battle/anim/bug.c b/src/battle/anim/bug.c new file mode 100644 index 000000000..dbc0f75a5 --- /dev/null +++ b/src/battle/anim/bug.c @@ -0,0 +1,302 @@ +#include "global.h" +#include "battle_anim.h" +#include "contest.h" +#include "rom_8077ABC.h" +#include "trig.h" +// #include "util.h" + +extern s16 gBattleAnimArgs[]; +extern u8 gAnimBankAttacker; +extern u8 gAnimBankTarget; + +static void sub_80DCA38(struct Sprite *sprite); +static void sub_80DCAEC(struct Sprite *sprite); +static void sub_80DCB5C(struct Sprite *sprite); +static void sub_80DCBB4(struct Sprite *sprite); +void sub_80DCD78(struct Sprite *sprite); + +// used in Move_MEGAHORN +void sub_80DC824(struct Sprite *sprite) +{ + if (IsContest()) + { + StartSpriteAffineAnim(sprite, 2); + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + } + else if (!GetBankSide(gAnimBankTarget)) + { + StartSpriteAffineAnim(sprite, 1); + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + } + + sprite->pos1.x = sub_8077EE4(gAnimBankTarget, 2) + gBattleAnimArgs[0]; + sprite->pos1.y = sub_8077EE4(gAnimBankTarget, 3) + gBattleAnimArgs[1]; + sprite->data[0] = gBattleAnimArgs[4]; + + sprite->data[2] = GetBankPosition(gAnimBankTarget, 2) + gBattleAnimArgs[2]; + sprite->data[4] = GetBankPosition(gAnimBankTarget, 3) + gBattleAnimArgs[3]; + + sprite->callback = sub_8078B34; + StoreSpriteCallbackInData(sprite, DestroyAnimSprite); +} + +// used in Move_LEECH_LIFE +void sub_80DC8F4(struct Sprite *sprite) +{ + if (IsContest()) + { + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + StartSpriteAffineAnim(sprite, 2); + } + else if (!GetBankSide(gAnimBankTarget)) + { + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + } + + sprite->pos1.x = sub_8077EE4(gAnimBankTarget, 2) + gBattleAnimArgs[0]; + sprite->pos1.y = sub_8077EE4(gAnimBankTarget, 3) + gBattleAnimArgs[1]; + sprite->data[0] = gBattleAnimArgs[2]; + + sprite->data[2] = GetBankPosition(gAnimBankTarget, 2); + sprite->data[4] = GetBankPosition(gAnimBankTarget, 3); + + sprite->callback = sub_8078B34; + StoreSpriteCallbackInData(sprite, DestroyAnimSprite); +} + +// used in 2 moves: +// Move_STRING_SHOT, Move_SPIDER_WEB +void sub_80DC9A0(struct Sprite *sprite) +{ + if (IsContest()) + gBattleAnimArgs[2] /= 2; + + sub_80787B0(sprite, 1); + sprite->data[0] = gBattleAnimArgs[2]; + sprite->data[1] = sprite->pos1.x; + sprite->data[3] = sprite->pos1.y; + + if (!gBattleAnimArgs[4]) + { + sprite->data[2] = GetBankPosition(gAnimBankTarget, 2); + sprite->data[4] = GetBankPosition(gAnimBankTarget, 3); + } + else + { + sub_807A3FC(gAnimBankTarget, 1, &sprite->data[2], &sprite->data[4]); + } + + sub_8078BD4(sprite); + sprite->data[5] = gBattleAnimArgs[3]; + sprite->callback = sub_80DCA38; +} + +static void sub_80DCA38(struct Sprite *sprite) +{ + if (sub_8078B5C(sprite)) + { + DestroyAnimSprite(sprite); + return; + } + + sprite->pos2.x += Sin(sprite->data[6], sprite->data[5]); + sprite->data[6] = (sprite->data[6] + 13) & 0xFF; +} + +// used in Move_STRING_SHOT +void sub_80DCA70(struct Sprite *sprite) +{ + sub_807A3FC(gAnimBankTarget, 0, &sprite->pos1.x, &sprite->pos1.y); + if (GetBankSide(gAnimBankAttacker)) + sprite->pos1.x -= gBattleAnimArgs[0]; + else + sprite->pos1.x += gBattleAnimArgs[0]; + + sprite->pos1.y += gBattleAnimArgs[1]; + if (!GetBankSide(gAnimBankTarget)) + sprite->pos1.y += 8; + + sprite->callback = sub_80DCAEC; +} + +static void sub_80DCAEC(struct Sprite *sprite) +{ + if (++sprite->data[0] == 3) + { + sprite->data[0] = 0; + sprite->invisible ^= 1; + } + + if (++sprite->data[1] == 51) + { + DestroyAnimSprite(sprite); + } +} + +// used in Move_SPIDER_WEB +void sub_80DCB38(struct Sprite *sprite) +{ + REG_BLDCNT = 0x3F40; + REG_BLDALPHA = 16; + + sprite->data[0] = 16; + sprite->callback = sub_80DCB5C; +} + +static void sub_80DCB5C(struct Sprite *sprite) +{ + if (sprite->data[2] < 20) + { + sprite->data[2]++; + } + else if (sprite->data[1]++ & 1) + { + sprite->data[0]--; + REG_BLDALPHA = sprite->data[0] | ((16 - sprite->data[0]) << 8); + + if (sprite->data[0] == 0) + { + sprite->invisible = TRUE; + sprite->callback = sub_80DCBB4; + } + } +} + +static void sub_80DCBB4(struct Sprite *sprite) +{ + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + DestroyAnimSprite(sprite); +} + +// used in 3 moves: +// Move_POISON_STING, Move_TWINEEDLE, Move_SPIKE_CANNON +void sub_80DCBCC(struct Sprite *sprite) +{ + s16 lVarX, lVarY; + u16 rot; + + if (IsContest()) + { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + } + else + { + if (GetBankSide(gAnimBankAttacker)) + { + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + gBattleAnimArgs[1] = -gBattleAnimArgs[1]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + } + } + + if (!IsContest()) + { + if (GetBankSide(gAnimBankAttacker) == GetBankSide(gAnimBankTarget)) + { + if (GetBankIdentity(gAnimBankTarget) == 0 || GetBankIdentity(gAnimBankTarget) == 1) + { + s16 temp1, temp2; + + temp1 = gBattleAnimArgs[2]; + gBattleAnimArgs[2] = -temp1; + + temp2 = gBattleAnimArgs[0]; + gBattleAnimArgs[0] = -temp2; + } + } + } + + sub_80787B0(sprite, 1); + + lVarX = GetBankPosition(gAnimBankTarget, 2) + gBattleAnimArgs[2]; + lVarY = GetBankPosition(gAnimBankTarget, 3) + gBattleAnimArgs[3]; + rot = sub_80790F0(lVarX - sprite->pos1.x, lVarY - sprite->pos1.y); + rot += 0xC000; + sub_8078FDC(sprite, FALSE, 0x100, 0x100, rot); + + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[2] = lVarX; + sprite->data[4] = lVarY; + + sprite->callback = sub_8078B34; + StoreSpriteCallbackInData(sprite, DestroyAnimSprite); +} + +// used in 2 moves: +// Move_PIN_MISSILE, Move_ICICLE_SPEAR +void sub_80DCCFC(struct Sprite *sprite) +{ + sub_80787B0(sprite, 1); + + if (GetBankSide(gAnimBankAttacker)) + gBattleAnimArgs[2] = -gBattleAnimArgs[2]; + + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[2] = GetBankPosition(gAnimBankTarget, 2) + gBattleAnimArgs[2]; + sprite->data[4] = GetBankPosition(gAnimBankTarget, 3) + gBattleAnimArgs[3]; + sprite->data[5] = gBattleAnimArgs[5]; + sub_80786EC(sprite); + + sprite->callback = sub_80DCD78; + sprite->invisible = TRUE; +} + +void sub_80DCD78(struct Sprite *sprite) +{ + sprite->invisible = FALSE; + + if (sub_8078718(sprite)) + { + DestroyAnimSprite(sprite); + } + else + { + s16 tempData[8]; + u16 *data = sprite->data; + u16 x1 = sprite->pos1.x; + s16 x2 = sprite->pos2.x; + u16 y1 = sprite->pos1.y; + s16 y2 = sprite->pos2.y; + int i; + + for (i = 0; i < 8; i++) + tempData[i] = data[i]; + + x2 += x1; + y2 += y1; + + if (!sub_8078718(sprite)) + { + u16 rot = sub_80790F0(sprite->pos1.x + sprite->pos2.x - x2, + sprite->pos1.y + sprite->pos2.y - y2); + rot += 0xC000; + sub_8078FDC(sprite, FALSE, 0x100, 0x100, rot); + + for (i = 0; i < 8; i++) + data[i] = tempData[i]; + } + } +} + +void sub_80DCE40(struct Sprite *sprite) +{ + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 2); + sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 3) + 18; + } + else + { + sprite->pos1.x = GetBankPosition(gAnimBankTarget, 2); + sprite->pos1.y = GetBankPosition(gAnimBankTarget, 3) + 18; + } + + StoreSpriteCallbackInData(sprite, move_anim_8074EE0); + sprite->callback = sub_80785E4; +} diff --git a/src/battle/anim/dark.c b/src/battle/anim/dark.c new file mode 100755 index 000000000..8ceb00298 --- /dev/null +++ b/src/battle/anim/dark.c @@ -0,0 +1,138 @@ +#include "global.h" +#include "rom_8077ABC.h" +#include "trig.h" +#include "battle_anim.h" +#include "sound.h" +#include "scanline_effect.h" + +void sub_80DFE90(struct Sprite *sprite); + +void sub_80DFC9C(u8 taskId); +void sub_80DFD58(u8 taskId); + +extern s16 gBattleAnimArgs[]; +extern u8 gAnimBankAttacker; +extern u8 gAnimBankTarget; +extern u8 gObjectBankIDs[]; + +// used in Smoke Ball escape, Sky Attack, Feint Attack and Camouflage + +void sub_80DFC24(u8 taskId) +{ + int bank; + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + bank = gAnimBankAttacker; + gTasks[taskId].data[1] = 16; + REG_BLDALPHA = 16; + if (GetBankIdentity_permutated(bank) == 1) + REG_BLDCNT = 0x3F42; + else + REG_BLDCNT = 0x3F44; + gTasks[taskId].func = sub_80DFC9C; +} + +void sub_80DFC9C(u8 taskId) +{ + u8 r2 = gTasks[taskId].data[1] >> 8; + u8 r1 = gTasks[taskId].data[1]; + if (gTasks[taskId].data[2] == (u8)gTasks[taskId].data[0]) + { + r2++; + r1--; + gTasks[taskId].data[1] = (r2 << 8) | r1; + REG_BLDALPHA = (r2 << 8) | r1; + gTasks[taskId].data[2] = 0; + if (r2 == 16) + { + gSprites[gObjectBankIDs[gAnimBankAttacker]].invisible = 1; + DestroyAnimVisualTask(taskId); + } + } + else + gTasks[taskId].data[2]++; +} + +void sub_80DFD24(u8 taskId) +{ + gTasks[taskId].data[0] = gBattleAnimArgs[0]; + gTasks[taskId].data[1] = 0x1000; + gTasks[taskId].func = sub_80DFD58; + REG_BLDALPHA = 0x1000; +} + +void sub_80DFD58(u8 taskId) +{ + u8 r1 = gTasks[taskId].data[1] >> 8; + u8 r5 = gTasks[taskId].data[1]; + if (gTasks[taskId].data[2] == (u8)gTasks[taskId].data[0]) + { + r1--; + r5++; + gTasks[taskId].data[1] = (r1 << 8) | r5; + REG_BLDALPHA = (r1 << 8) | r5; + gTasks[taskId].data[2] = 0; + if (r1 == 0) + { + REG_BLDCNT = 0; + REG_BLDALPHA = 0; + DestroyAnimVisualTask(taskId); + } + } + else + gTasks[taskId].data[2]++; +} + +// unlike the above is only used in Feint Attack + +void sub_80DFDC0(u8 taskId) +{ + REG_BLDALPHA = 0x1000; + if (GetBankIdentity_permutated(gAnimBankAttacker) == 1) + REG_BLDCNT = 0x3F42; + else + REG_BLDCNT = 0x3F44; + DestroyAnimVisualTask(taskId); +} + +// unused sprite template's callback + +void sub_80DFE14(struct Sprite *sprite) +{ + sprite->data[1] = GetBankPosition(gAnimBankTarget, 2); + sprite->data[2] = GetBankPosition(gAnimBankAttacker, 2); + sprite->data[3] = GetBankPosition(gAnimBankTarget, 3); + sprite->data[4] = GetBankPosition(gAnimBankAttacker, 3); + sprite->data[0] = 0x7E; + sub_8078A5C(sprite); + sprite->data[3] = -sprite->data[1]; + sprite->data[4] = -sprite->data[2]; + sprite->data[6] = 0xFFD8; + sprite->callback = sub_80DFE90; + sub_80DFE90(sprite); +} + +void sub_80DFE90(struct Sprite *sprite) +{ + sprite->data[3] += sprite->data[1]; + sprite->data[4] += sprite->data[2]; + sprite->pos2.x = sprite->data[3] >> 8; + sprite->pos2.y = sprite->data[4] >> 8; + if (sprite->data[7] == 0) + { + sprite->data[3] += sprite->data[1]; + sprite->data[4] += sprite->data[2]; + sprite->pos2.x = sprite->data[3] >> 8; + sprite->pos2.y = sprite->data[4] >> 8; + sprite->data[0]--; + } + sprite->pos2.y += Sin(sprite->data[5], sprite->data[6]); + sprite->data[5] = (sprite->data[5] + 3) & 0xFF; + if (sprite->data[5] > 0x7F) + { + sprite->data[5] = 0; + sprite->data[6] += 20; + sprite->data[7]++; + } + if (--sprite->data[0] == 0) + DestroyAnimSprite(sprite); +} diff --git a/src/battle/anim/dragon.c b/src/battle/anim/dragon.c new file mode 100755 index 000000000..bf39e01c0 --- /dev/null +++ b/src/battle/anim/dragon.c @@ -0,0 +1,275 @@ +#include "global.h" +#include "rom_8077ABC.h" +#include "trig.h" +#include "battle_anim.h" +#include "sound.h" +#include "scanline_effect.h" + +void sub_80DF81C(struct Sprite *sprite); +void sub_80DFBD8(struct Sprite *sprite); + +void sub_80DF9F4(u8 taskId); + +void sub_80DFAB0(struct Task *task); + +extern s16 gBattleAnimArgs[]; +extern u8 gAnimBankAttacker; +extern u8 gAnimBankTarget; +extern u8 gBankAttacker; +extern u16 gBattle_BG1_X; +extern u16 gBattle_BG2_X; +extern u16 gUnknown_03000730[]; +extern u8 gObjectBankIDs[]; + +// Outrage + +void sub_80DF5A0(struct Sprite *sprite) +{ + sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 2); + sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 3); + if (GetBankSide(gAnimBankAttacker)) + { + sprite->pos1.x -= gBattleAnimArgs[0]; + gBattleAnimArgs[3] = -gBattleAnimArgs[3]; + gBattleAnimArgs[4] = -gBattleAnimArgs[4]; + } + else + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->data[0] = gBattleAnimArgs[2]; + sprite->data[1] = gBattleAnimArgs[3]; + sprite->data[3] = gBattleAnimArgs[4]; + sprite->data[5] = gBattleAnimArgs[5]; + sprite->invisible = 1; + StoreSpriteCallbackInData(sprite, move_anim_8074EE0); + sprite->callback = sub_8078504; +} + +// part of Dragon Breath + +void sub_80DF63C(struct Sprite *sprite) +{ + sub_8078650(sprite); + sprite->data[2] = GetBankPosition(gAnimBankTarget, 2); + sprite->data[4] = GetBankPosition(gAnimBankTarget, 3); + if (GetBankSide(gAnimBankAttacker)) + { + sprite->pos1.x -= gBattleAnimArgs[1]; + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->data[2] -= gBattleAnimArgs[2]; + sprite->data[4] += gBattleAnimArgs[3]; + } + else + { + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + sprite->data[2] += gBattleAnimArgs[2]; + sprite->data[4] += gBattleAnimArgs[3]; + StartSpriteAnim(sprite, 1); + } + sprite->data[0] = gBattleAnimArgs[4]; + sprite->callback = sub_8078B34; + StoreSpriteCallbackInData(sprite, move_anim_8074EE0); +} + +// Dragon Rage + +void sub_80DF6F0(struct Sprite *sprite) +{ + if (gBattleAnimArgs[0] == 0) + { + sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 0); + sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 1); + } + else + { + sprite->pos1.x = GetBankPosition(gAnimBankTarget, 0); + sprite->pos1.y = GetBankPosition(gAnimBankTarget, 1); + } + sub_807867C(sprite, gBattleAnimArgs[1]); + sprite->pos1.y += gBattleAnimArgs[2]; + sprite->callback = sub_8078600; + StoreSpriteCallbackInData(sprite, move_anim_8074EE0); +} + +// Dragon Breath init + +void sub_80DF760(struct Sprite *sprite) +{ + if (GetBankSide(gAnimBankAttacker)) + StartSpriteAffineAnim(sprite, 1); + sub_80DF63C(sprite); +} + +//next 2 tasks might be Dragon Dance orbs? + +void sub_80DF78C(struct Sprite *sprite) +{ + u16 r5; + u16 r0; + sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 2); + sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 3); + sprite->data[4] = 0; + sprite->data[5] = 1; + sprite->data[6] = gBattleAnimArgs[0]; + r5 = sub_807A100(gBankAttacker, 0); + r0 = sub_807A100(gBankAttacker, 1); + if (r5 > r0) + sprite->data[7] = r5 / 2; + else + sprite->data[7] = r0 / 2; + sprite->pos2.x = Cos(sprite->data[6], sprite->data[7]); + sprite->pos2.y = Sin(sprite->data[6], sprite->data[7]); + sprite->callback = sub_80DF81C; +} + +void sub_80DF81C(struct Sprite *sprite) +{ + switch (sprite->data[0]) + { + case 0: + sprite->data[6] = (sprite->data[6] - sprite->data[5]) & 0xFF; + sprite->pos2.x = Cos(sprite->data[6], sprite->data[7]); + sprite->pos2.y = Sin(sprite->data[6], sprite->data[7]); + if (++sprite->data[4] > 5) + { + sprite->data[4] = 0; + if (sprite->data[5] <= 15 && ++sprite->data[5] > 15) + sprite->data[5] = 16; + } + if (++sprite->data[3] > 0x3C) + { + sprite->data[3] = 0; + sprite->data[0]++; + } + break; + case 1: + sprite->data[6] = (sprite->data[6] - sprite->data[5]) & 0xFF; + if (sprite->data[7] <= 0x95 && (sprite->data[7] += 8) > 0x95) + sprite->data[7] = 0x96; + sprite->pos2.x = Cos(sprite->data[6], sprite->data[7]); + sprite->pos2.y = Sin(sprite->data[6], sprite->data[7]); + if (++sprite->data[4] > 5) + { + sprite->data[4] = 0; + if (sprite->data[5] <= 15 && ++sprite->data[5] > 15) + sprite->data[5] = 16; + } + if (++sprite->data[3] > 20) + DestroyAnimSprite(sprite); + break; + } +} + +// Dragon Dance scanline eff + +void sub_80DF924(u8 taskId) +{ + struct ScanlineEffectParams sp; + struct Task *task = &gTasks[taskId]; + u16 i; + u8 r1; + if (GetBankIdentity_permutated(gAnimBankAttacker) == 1) + { + sp.dmaDest = ®_BG1HOFS; + task->data[2] = gBattle_BG1_X; + } + else + { + sp.dmaDest = ®_BG2HOFS; + task->data[2] = gBattle_BG2_X; + } + sp.dmaControl = 0xA2600001; + sp.initState = 1; + sp.unused9 = 0; + r1 = sub_8077FC0(gAnimBankAttacker); + task->data[3] = r1 - 32; + task->data[4] = r1 + 32; + if (task->data[3] < 0) + task->data[3] = 0; + for(i = task->data[3];i <= task->data[4];i++) + { + gScanlineEffectRegBuffers[0][i] = task->data[2]; + gScanlineEffectRegBuffers[1][i] = task->data[2]; + } + ScanlineEffect_SetParams(sp); + task->func = sub_80DF9F4; +} + +void sub_80DF9F4(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + switch (task->data[0]) + { + case 0: + if (++task->data[7] > 1) + { + task->data[7] = 0; + if (++task->data[6] == 3) + task->data[0]++; + } + sub_80DFAB0(task); + break; + case 1: + if (++task->data[1] > 0x3C) + task->data[0]++; + sub_80DFAB0(task); + break; + case 2: + if (++task->data[7] > 1) + { + task->data[7] = 0; + if (--task->data[6] == 0) + task->data[0]++; + } + sub_80DFAB0(task); + break; + case 3: + gScanlineEffect.state = 3; + task->data[0]++; + break; + case 4: + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_80DFAB0(struct Task *task) +{ + u16 r3 = task->data[5]; + u16 i; + for (i = task->data[3]; i <= task->data[4]; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = ((gSineTable[r3] * task->data[6]) >> 7) + task->data[2]; + r3 = (r3 + 8) & 0xFF; + } + task->data[5] = (task->data[5] + 9) & 0xFF; +} + +// Overheat + +void sub_80DFB28(struct Sprite *sprite) +{ + int r6 = (gBattleAnimArgs[2] * 3) / 5; + int i; + sprite->pos1.x = GetBankPosition(gAnimBankAttacker, 2); + sprite->pos1.y = GetBankPosition(gAnimBankAttacker, 3) + gBattleAnimArgs[4]; + sprite->data[1] = Cos(gBattleAnimArgs[1], gBattleAnimArgs[2]); + sprite->data[2] = Sin(gBattleAnimArgs[1], r6); + sprite->pos1.x += sprite->data[1] * gBattleAnimArgs[0]; + sprite->pos1.y += sprite->data[2] * gBattleAnimArgs[0]; + sprite->data[3] = gBattleAnimArgs[3]; + sprite->callback = sub_80DFBD8; + for (i = 0; i <= 6; i++) + gUnknown_03000730[i] = sprite->data[i]; +} + +void sub_80DFBD8(struct Sprite *sprite) +{ + sprite->data[4] += sprite->data[1]; + sprite->data[5] += sprite->data[2]; + sprite->pos2.x = sprite->data[4] / 10; + sprite->pos2.y = sprite->data[5] / 10; + if (++sprite->data[0] > sprite->data[3]) + DestroyAnimSprite(sprite); +} diff --git a/src/battle/anim/draw.c b/src/battle/anim/draw.c index 3adb62e06..f9e505bf2 100755 --- a/src/battle/anim/draw.c +++ b/src/battle/anim/draw.c @@ -3,7 +3,7 @@ #include "trig.h" #include "battle_anim.h" #include "sound.h" -#include "unknown_task.h" +#include "scanline_effect.h" extern s16 gBattleAnimArgs[]; extern u8 gAnimBankAttacker; @@ -21,7 +21,8 @@ static void sub_80D0E8C(struct Sprite* sprite); void sub_80D0C88(u8 taskId) { struct Task* task = &gTasks[taskId]; - struct UnknownTaskStruct sp; + struct ScanlineEffectParams params; + s16 i; task->data[0] = sub_8077FC0(gAnimBankTarget) + 32; task->data[1] = 4; @@ -30,30 +31,31 @@ void sub_80D0C88(u8 taskId) task->data[4] = 0; task->data[5] = 0; task->data[15] = sub_807A100(gAnimBankTarget, 0); + if (GetBankIdentity_permutated(gAnimBankTarget) == 1) { task->data[6] = gBattle_BG1_X; - sp.dest = (u16 *)REG_ADDR_BG1HOFS; + params.dmaDest = (u16 *)REG_ADDR_BG1HOFS; } else { task->data[6] = gBattle_BG2_X; - sp.dest = (u16 *)REG_ADDR_BG2HOFS; + params.dmaDest = (u16 *)REG_ADDR_BG2HOFS; } for (i = task->data[0] - 0x40; i <= task->data[0];i++) { if (i >= 0) { - gUnknown_03004DE0[0][i] = task->data[6] + 0xF0; - gUnknown_03004DE0[1][i] = task->data[6] + 0xF0; + gScanlineEffectRegBuffers[0][i] = task->data[6] + 0xF0; + gScanlineEffectRegBuffers[1][i] = task->data[6] + 0xF0; } } - sp.control = 0xa2600001; - sp.unk8 = 1; - sp.unk9 = 0; - sub_80895F8(sp); + params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + params.initState = 1; + params.unused9 = 0; + ScanlineEffect_SetParams(params); task->func = sub_80D0D68; } @@ -91,13 +93,13 @@ void sub_80D0D68(u8 taskId) if (task->data[5] >= 0) { - gUnknown_03004DE0[0][task->data[5]] = task->data[6]; - gUnknown_03004DE0[1][task->data[5]] = task->data[6]; + gScanlineEffectRegBuffers[0][task->data[5]] = task->data[6]; + gScanlineEffectRegBuffers[1][task->data[5]] = task->data[6]; } if (++task->data[3] >= task->data[15]) { - gUnknown_03004DC0.unk15 = 3; + gScanlineEffect.unk15 = 3; DestroyAnimVisualTask(taskId); } } @@ -178,7 +180,7 @@ _080D0DE0:\n\ ldrsh r0, [r3, r1]\n\ cmp r0, 0\n\ blt _080D0E04\n\ - ldr r2, _080D0E28 @ =gUnknown_03004DE0\n\ + ldr r2, _080D0E28 @ =gScanlineEffectRegBuffers\n\ lsls r0, 1\n\ adds r0, r2\n\ ldrh r1, [r3, 0x14]\n\ @@ -202,7 +204,7 @@ _080D0E04:\n\ ldrsh r1, [r3, r2]\n\ cmp r0, r1\n\ blt _080D0E22\n\ - ldr r1, _080D0E2C @ =gUnknown_03004DC0\n\ + ldr r1, _080D0E2C @ =gScanlineEffect\n\ movs r0, 0x3\n\ strb r0, [r1, 0x15]\n\ adds r0, r4, 0\n\ @@ -212,8 +214,8 @@ _080D0E22:\n\ pop {r0}\n\ bx r0\n\ .align 2, 0\n\ -_080D0E28: .4byte gUnknown_03004DE0\n\ -_080D0E2C: .4byte gUnknown_03004DC0\n\ +_080D0E28: .4byte gScanlineEffectRegBuffers\n\ +_080D0E2C: .4byte gScanlineEffect\n\ .syntax divided\n"); } #endif diff --git a/src/battle/anim/poison.c b/src/battle/anim/poison.c new file mode 100644 index 000000000..f31c441fb --- /dev/null +++ b/src/battle/anim/poison.c @@ -0,0 +1,140 @@ +#include "global.h" +#include "battle_anim.h" +#include "rom_8077ABC.h" +#include "trig.h" + +extern s16 gBattleAnimArgs[]; +extern u8 gAnimBankAttacker; +extern u8 gAnimBankTarget; + +void sub_80D9DD4(struct Sprite *sprite); +void sub_80D9E78(struct Sprite *sprite); +void sub_80D9EE8(struct Sprite *sprite); +void sub_80D9FF0(struct Sprite *sprite); + +void sub_80D9D70(struct Sprite *sprite) +{ + if (!gBattleAnimArgs[3]) + StartSpriteAnim(sprite, 2); + + sub_80787B0(sprite, 1); + + sprite->data[0] = gBattleAnimArgs[2]; + sprite->data[2] = GetBankPosition(gAnimBankTarget, 2); + sprite->data[4] = GetBankPosition(gAnimBankTarget, 3); + sprite->data[5] = -30; + + sub_80786EC(sprite); + + sprite->callback = sub_80D9DD4; +} + +void sub_80D9DD4(struct Sprite *sprite) // same as sub_80D9E78 +{ + if (sub_8078718(sprite)) + DestroyAnimSprite(sprite); +} + +void sub_80D9DF0(struct Sprite *sprite) +{ + s16 l1, l2; + if (!gBattleAnimArgs[3]) + StartSpriteAnim(sprite, 2); + + sub_80787B0(sprite, 1); + sub_807A3FC(gAnimBankTarget, 1, &l1, &l2); + + if (GetBankSide(gAnimBankAttacker)) + gBattleAnimArgs[4] = -gBattleAnimArgs[4]; + + sprite->data[0] = gBattleAnimArgs[2]; + sprite->data[2] = l1 + gBattleAnimArgs[4]; + sprite->data[4] = l2 + gBattleAnimArgs[5]; + sprite->data[5] = -30; + + sub_80786EC(sprite); + + sprite->callback = sub_80D9E78; +} + +void sub_80D9E78(struct Sprite *sprite) // same as sub_80D9DD4 +{ + if (sub_8078718(sprite)) + DestroyAnimSprite(sprite); +} + +void sub_80D9E94(struct Sprite *sprite) +{ + sprite->data[0] = gBattleAnimArgs[2]; + sprite->data[1] = sprite->pos1.x; + sprite->data[2] = sprite->pos1.x + gBattleAnimArgs[0]; + sprite->data[3] = sprite->pos1.y; + sprite->data[4] = sprite->pos1.y + gBattleAnimArgs[1]; + + sub_8078A5C(sprite); + + sprite->data[5] = sprite->data[1] / gBattleAnimArgs[2]; + sprite->data[6] = sprite->data[2] / gBattleAnimArgs[2]; + + sprite->callback = sub_80D9EE8; +} + +void sub_80D9EE8(struct Sprite *sprite) +{ + sub_8078394(sprite); + + sprite->data[1] -= sprite->data[5]; + sprite->data[2] -= sprite->data[6]; + + if (!sprite->data[0]) + DestroyAnimSprite(sprite); +} + +void sub_80D9F14(struct Sprite *sprite) +{ + sub_807A3FC(gAnimBankTarget, TRUE, &sprite->pos1.x, &sprite->pos1.y); + + if (GetBankSide(gAnimBankAttacker)) + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + + sprite->data[0] = gBattleAnimArgs[4]; + sprite->data[2] = sprite->pos1.x + gBattleAnimArgs[2]; + sprite->data[4] = sprite->pos1.y + sprite->data[0]; + + sprite->callback = sub_8078B34; + StoreSpriteCallbackInData(sprite, DestroyAnimSprite); +} + +void sub_80D9F88(struct Sprite *sprite) +{ + if (!gBattleAnimArgs[2]) + { + sub_8078764(sprite, TRUE); + } + else + { + sub_807A3FC(gAnimBankTarget, TRUE, &sprite->pos1.x, &sprite->pos1.y); + + if (GetBankSide(gAnimBankAttacker)) + gBattleAnimArgs[0] = -gBattleAnimArgs[0]; + + sprite->pos1.x += gBattleAnimArgs[0]; + sprite->pos1.y += gBattleAnimArgs[1]; + } + + sprite->callback = sub_80D9FF0; +} + +void sub_80D9FF0(struct Sprite *sprite) +{ + sprite->data[0] = (sprite->data[0] + 0xB) & 0xFF; + sprite->pos2.x = Sin(sprite->data[0], 4); + sprite->data[1] += 0x30; + sprite->pos2.y = -(sprite->data[1] >> 8); + + if (sprite->affineAnimEnded) + DestroyAnimSprite(sprite); +}
\ No newline at end of file diff --git a/src/battle/anim/wisp_fire.c b/src/battle/anim/wisp_fire.c new file mode 100644 index 000000000..348ce6426 --- /dev/null +++ b/src/battle/anim/wisp_fire.c @@ -0,0 +1,196 @@ +#include "global.h" +#include "battle_anim.h" +#include "blend_palette.h" +#include "main.h" +#include "rom_8077ABC.h" +#include "task.h" +#include "trig.h" + +extern s16 gBattleAnimArgs[]; +extern u8 gAnimBankTarget; +extern u8 gAnimBankAttacker; + +extern u8 gObjectBankIDs[]; +extern s8 gUnknown_083D9794[16]; +extern s8 gUnknown_083D97A4[16]; + +void sub_80D5E4C(u8 taskId); + +void sub_80D5CC0(struct Sprite *sprite) +{ + if (!sprite->data[0]) + { + sprite->data[1] = gBattleAnimArgs[0]; + sprite->data[0] += 1; + } + + sprite->data[3] += 0xC0 * 2; + sprite->data[4] += 0xA0; + + sprite->pos2.x = Sin(sprite->data[1], sprite->data[3] >> 8); + sprite->pos2.y = Cos(sprite->data[1], sprite->data[4] >> 8); + + sprite->data[1] = (sprite->data[1] + 7) & 0xFF; + + if (gMain.inBattle) + { + if (sprite->data[1] < 64 || sprite->data[1] > 195) + sprite->oam.priority = sub_8079ED4(gAnimBankTarget); + else + sprite->oam.priority = sub_8079ED4(gAnimBankTarget) + 1; + } + else + { + if (sprite->data[1] < 64 || sprite->data[1] > 195) + sprite->subpriority = 0x1D; + else + sprite->subpriority = 0x1F; + } + + if (++sprite->data[2] > 0x14) + sprite->invisible ^= 1; + + if (sprite->data[2] == 0x1E) + DestroyAnimSprite(sprite); +} + +void sub_80D5DDC(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + task->data[12] = !GetBankSide(gAnimBankAttacker) ? 1 : -1; + task->data[13] = IsAnimBankSpriteVisible(gAnimBankTarget ^ 2) + 1; + task->data[14] = GetAnimBankSpriteId(1); + task->data[15] = GetAnimBankSpriteId(3); + + task->func = sub_80D5E4C; +} + +void sub_80D5E4C(u8 taskId) +{ + struct Task *task = &gTasks[taskId]; + + switch (task->data[0]) + { + case 0: + task->data[10] += task->data[12] * 2; + if (++task->data[1] >= 2) + { + task->data[1] = 0; + task->data[2]++; + if (task->data[2] & 1) + task->data[11] = 2; + else + task->data[11] = -2; + } + + for (task->data[3] = 0; task->data[3] < task->data[13]; task->data[3]++) + { + gSprites[task->data[task->data[3] + 14]].pos2.x = task->data[10] + task->data[11]; + } + + if (++task->data[9] == 16) + { + task->data[9] = 0; + task->data[0]++; + } + break; + case 1: + if (++task->data[1] >= 5) + { + task->data[1] = 0; + task->data[2]++; + + if (task->data[2] & 1) + task->data[11] = 2; + else + task->data[11] = -2; + } + + for (task->data[3] = 0; task->data[3] < task->data[13]; task->data[3]++) + { + gSprites[task->data[task->data[3] + 14]].pos2.x = task->data[10] + task->data[11]; + } + + if (++task->data[9] == 96) + { + task->data[9] = 0; + task->data[0]++; + } + break; + case 2: + task->data[10] -= task->data[12] * 2; + + if (++task->data[1] >= 2) + { + task->data[1] = 0; + task->data[2]++; + + if (task->data[2] & 1) + task->data[11] = 2; + else + task->data[11] = -2; + } + + for (task->data[3] = 0; task->data[3] < task->data[13]; task->data[3]++) + { + gSprites[task->data[task->data[3] + 14]].pos2.x = task->data[10] + task->data[11]; + } + + if (++task->data[9] == 16) + { + task->data[0]++; + } + break; + case 3: + for (task->data[3] = 0; task->data[3] < task->data[13]; task->data[3]++) + { + gSprites[task->data[task->data[3] + 14]].pos2.x = 0; + } + + DestroyAnimVisualTask(taskId); + break; + } +} + +void sub_80D6080(u8 taskId) +{ + struct Struct_sub_8078914 unk; + sub_8078914(&unk); + BlendPalette(unk.field_8 << 4, 16, gBattleAnimArgs[0], gBattleAnimArgs[1]); // u16 palOffset, u16 numEntries, u8 coeff, u16 blendColor + DestroyAnimVisualTask(taskId); +} + +void sub_80D60B4(u8 taskId) +{ + s8 unk; + u8 spriteId; + + if (gTasks[taskId].data[0] == 0) + { + gTasks[taskId].data[1] = gBattleAnimArgs[0]; + gTasks[taskId].data[2] = gBattleAnimArgs[1]; + gTasks[taskId].data[3] = gBattleAnimArgs[2]; + gTasks[taskId].data[4] = gBattleAnimArgs[3]; + } + gTasks[taskId].data[0]++; + + spriteId = gObjectBankIDs[gAnimBankTarget]; + + if (!gTasks[taskId].data[4]) + unk = gUnknown_083D9794[gTasks[taskId].data[0] % 10]; + else + unk = gUnknown_083D97A4[gTasks[taskId].data[0] % 10]; + + if (gTasks[taskId].data[3] == 1) + gSprites[spriteId].pos2.y = gBattleAnimArgs[1] * unk < 0 ? -(gBattleAnimArgs[1] * unk) : gBattleAnimArgs[1] * unk; + else + gSprites[spriteId].pos2.x = gBattleAnimArgs[1] * unk; + + if (gTasks[taskId].data[0] == gTasks[taskId].data[1]) + { + gSprites[spriteId].pos2.x = 0; + gSprites[spriteId].pos2.y = 0; + DestroyAnimVisualTask(taskId); + } +}
\ No newline at end of file diff --git a/src/battle/battle_2.c b/src/battle/battle_2.c index ae84e5585..990535b4e 100644 --- a/src/battle/battle_2.c +++ b/src/battle/battle_2.c @@ -34,7 +34,7 @@ #include "trainer.h" #include "trig.h" #include "tv.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "util.h" #include "constants/battle_move_effects.h" #include "constants/items.h" @@ -108,9 +108,9 @@ extern u16 gUnknown_02024DE8; extern u8 gActionSelectionCursor[]; extern u8 gMoveSelectionCursor[]; extern u8 gUnknown_02038470[]; -extern u16 gUnknown_030041B0; +extern u16 gBattle_BG3_X; extern u16 gBattle_BG1_Y; -extern u16 gUnknown_030041B8; +extern u16 gBattle_BG3_Y; extern struct Window gUnknown_030041D0; extern u16 gBattle_WIN1H; extern struct Window gUnknown_03004210; @@ -219,22 +219,22 @@ void InitBattle(void) REG_WINOUT = 0; gBattle_WIN0H = 0xF0; gBattle_WIN0V = 0x5051; - dp12_8087EA4(); + ScanlineEffect_Clear(); for (i = 0; i < 80; i++) { - gUnknown_03004DE0[0][i] = 0xF0; - gUnknown_03004DE0[1][i] = 0xF0; + gScanlineEffectRegBuffers[0][i] = 0xF0; + gScanlineEffectRegBuffers[1][i] = 0xF0; } for (i = 80; i < 160; i++) { asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter - gUnknown_03004DE0[0][i] = 0xFF10; - gUnknown_03004DE0[1][i] = 0xFF10; + gScanlineEffectRegBuffers[0][i] = 0xFF10; + gScanlineEffectRegBuffers[1][i] = 0xFF10; } - //sub_80895F8(gUnknown_081F9674.unk0, gUnknown_081F9674.unk4, gUnknown_081F9674.unk8); - sub_80895F8(gUnknown_081F9674); - SetUpWindowConfig(&gWindowConfig_81E6C58); + //ScanlineEffect_SetParams(gUnknown_081F9674.unk0, gUnknown_081F9674.unk4, gUnknown_081F9674.unk8); + ScanlineEffect_SetParams(gUnknown_081F9674); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C58); ResetPaletteFade(); gBattle_BG0_X = 0; gBattle_BG0_Y = 0; @@ -242,12 +242,12 @@ void InitBattle(void) gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 0; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; gBattleTerrain = BattleSetup_GetTerrain(); - InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6C58); - InitWindowFromConfig(&gUnknown_030041D0, &gWindowConfig_81E71D0); - InitWindowFromConfig(&gUnknown_03004250, &gWindowConfig_81E71EC); + Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6C58); + Text_InitWindowWithTemplate(&gUnknown_030041D0, &gWindowTemplate_81E71D0); + Text_InitWindowWithTemplate(&gUnknown_03004250, &gWindowTemplate_81E71EC); sub_800D6D4(); sub_800DAB8(); ResetSpriteData(); @@ -553,7 +553,7 @@ void sub_800F02C(void) gUnknown_02023A00[i].status = GetMonData(&gPlayerParty[i], MON_DATA_STATUS); gUnknown_02023A00[i].personality = GetMonData(&gPlayerParty[i], MON_DATA_PERSONALITY); gUnknown_02023A00[i].gender = GetMonGender(&gPlayerParty[i]); - StripExtCtrlCodes(nickname); + Text_StripExtCtrlCodes(nickname); gUnknown_02023A00[i].language = GetMonData(&gPlayerParty[i], MON_DATA_LANGUAGE); if (gUnknown_02023A00[i].language != 1) PadNameString(nickname, 0); @@ -898,7 +898,7 @@ void BattleMainCB2(void) { AnimateSprites(); BuildOamBuffer(); - sub_800374C(&gUnknown_03004210); + Text_UpdateWindowInBattle(&gUnknown_03004210); UpdatePaletteFade(); RunTasks(); } @@ -1064,8 +1064,8 @@ void sub_800FCFC(void) REG_BG1VOFS = gBattle_BG1_Y; REG_BG2HOFS = gBattle_BG2_X; REG_BG2VOFS = gBattle_BG2_Y; - REG_BG3HOFS = gUnknown_030041B0; - REG_BG3VOFS = gUnknown_030041B8; + REG_BG3HOFS = gBattle_BG3_X; + REG_BG3VOFS = gBattle_BG3_Y; REG_WIN0H = gBattle_WIN0H; REG_WIN0V = gBattle_WIN0V; REG_WIN1H = gBattle_WIN1H; @@ -1073,7 +1073,7 @@ void sub_800FCFC(void) LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); } void nullsub_36(struct Sprite *sprite) @@ -1197,20 +1197,20 @@ void c2_8011A1C(void) REG_WINOUT = 0; gBattle_WIN0H = 0xF0; gBattle_WIN0V = 0x5051; - dp12_8087EA4(); + ScanlineEffect_Clear(); for (i = 0; i < 80; i++) { - gUnknown_03004DE0[0][i] = 0xF0; - gUnknown_03004DE0[1][i] = 0xF0; + gScanlineEffectRegBuffers[0][i] = 0xF0; + gScanlineEffectRegBuffers[1][i] = 0xF0; } for (i = 80; i < 160; i++) { asm(""::"r"(i)); // Needed to stop the compiler from optimizing out the loop counter - gUnknown_03004DE0[0][i] = 0xFF10; - gUnknown_03004DE0[1][i] = 0xFF10; + gScanlineEffectRegBuffers[0][i] = 0xFF10; + gScanlineEffectRegBuffers[1][i] = 0xFF10; } - SetUpWindowConfig(&gWindowConfig_81E6C58); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C58); ResetPaletteFade(); gBattle_BG0_X = 0; gBattle_BG0_Y = 0; @@ -1218,12 +1218,12 @@ void c2_8011A1C(void) gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 0; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; - InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6C58); - InitWindowFromConfig(&gUnknown_030041D0, &gWindowConfig_81E71D0); - InitWindowFromConfig(&gUnknown_03004250, &gWindowConfig_81E71EC); + Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6C58); + Text_InitWindowWithTemplate(&gUnknown_030041D0, &gWindowTemplate_81E71D0); + Text_InitWindowWithTemplate(&gUnknown_03004250, &gWindowTemplate_81E71EC); sub_800D6D4(); LoadCompressedPalette(gUnknown_08D004E0, 0, 64); sub_800D74C(); diff --git a/src/battle/battle_4.c b/src/battle/battle_4.c index 5a20a8324..ae8f94130 100644 --- a/src/battle/battle_4.c +++ b/src/battle/battle_4.c @@ -93,7 +93,7 @@ extern u16 gChosenMove; //last used move in battle extern u8 gBankInMenu; extern u8 gActionForBanks[4]; extern u16 gUnknown_02024C2C[4]; //last used moves 2, used by sketch -extern u16 gUnknown_030041B0; +extern u16 gBattle_BG3_X; extern u16 gUnknown_02024C4C[4]; //last used moves by banks, another one extern u8 gCurrentTurnActionNumber; extern u16 gTrappingMoves[]; @@ -136,7 +136,7 @@ u16 GiveMoveToBattleMon(struct BattlePokemon *mon, u16 move); void IncrementGameStat(u8 index); u8 GetScaledHPFraction(s16 hp, s16 maxhp, u8 scale); u16 GetPokedexHeightWeight(u16 national_num, u8 heightweight); -u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5); +u8 MenuCursor_Create814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5); void DestroyMenuCursor(void); void sub_802BC6C(void); u8 sub_809FA30(void); @@ -155,7 +155,7 @@ u8 Overworld_GetMapTypeOfSaveblockLocation(void); u8 CalculatePlayerPartyCount(void); u16 Sqrt(u32 num); u8 sub_809070C(u16 nationalNum, u32 TiD, u32 PiD); //task prepare poke dex display -void sub_814A880(u8 a1, u8 a2); +void MenuCursor_SetPos814A880(u8 a1, u8 a2); u8 CheckMoveLimitations(u8 bank, u8 unusable_moves, u8 flags); bool8 IsLinkDoubleBattle(void); void sub_8094B6C(u8 bank, u8 partyID, u8 r2); @@ -10767,9 +10767,9 @@ void atk59_handlelearnnewmove(void) void sub_8023A80(void) { sub_802BBD4(0x18, 8, 0x1D, 0xD, 0); - InitWindow(&gUnknown_03004210, BattleText_YesNo, 0x100, 0x19, 0x9); - sub_8002F44(&gUnknown_03004210); - sub_814A5C0(0, 0xFFFF, 0xC, 0x2D9F, 0x20); + Text_InitWindow(&gUnknown_03004210, BattleText_YesNo, 0x100, 0x19, 0x9); + Text_PrintWindow8002F44(&gUnknown_03004210); + MenuCursor_Create814A5C0(0, 0xFFFF, 0xC, 0x2D9F, 0x20); } void sub_8023AD8(void) @@ -11714,9 +11714,9 @@ _08024AC4:\n\ str r0, [sp]\n\ adds r0, r4, 0\n\ movs r3, 0xC\n\ - bl InitWindow\n\ + bl Text_InitWindow\n\ adds r0, r4, 0\n\ - bl sub_8002F44\n\ + bl Text_PrintWindow8002F44\n\ ldr r1, _08024AEC @ =gSharedMem\n\ ldr r2, _08024AF0 @ =0x0001609c\n\ adds r1, r2\n\ @@ -11835,9 +11835,9 @@ _08024BC0:\n\ str r0, [sp]\n\ adds r0, r4, 0\n\ movs r3, 0xC\n\ - bl InitWindow\n\ + bl Text_InitWindow\n\ adds r0, r4, 0\n\ - bl sub_8002F44\n\ + bl Text_PrintWindow8002F44\n\ ldr r1, _08024BFC @ =gSharedMem\n\ ldr r0, _08024C00 @ =0x0001609c\n\ adds r1, r0\n\ @@ -17229,7 +17229,7 @@ static void atkF2_displaydexinfo(void) LZDecompressVram(gBattleTerrainTilemap_Building, (void*)(0x0600d000)); LoadCompressedPalette(gBattleTerrainPalette_BattleTower, 0x20, 0x60); REG_BG3CNT = 0x5a0b; - gUnknown_030041B0 = 0x100; + gBattle_BG3_X = 0x100; BeginNormalPaletteFade(0xfffc, 0, 0x10, 0, 0); gBattleCommunication[0]++; } @@ -17333,7 +17333,7 @@ _0802BC68: .4byte 0x00001025\n\ void sub_802BC6C(void) { - sub_814A880(0xC8, ((gBattleCommunication[1] << 28) + 1207959552) >> 24); //what could that be? + MenuCursor_SetPos814A880(0xC8, ((gBattleCommunication[1] << 28) + 1207959552) >> 24); //what could that be? } void nullsub_6(void) diff --git a/src/battle/battle_controller_linkopponent.c b/src/battle/battle_controller_linkopponent.c index 54181bc21..69306b725 100644 --- a/src/battle/battle_controller_linkopponent.c +++ b/src/battle/battle_controller_linkopponent.c @@ -1413,7 +1413,7 @@ void LinkOpponentHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; BufferStringBattle(*(u16 *)&gBattleBufferA[gActiveBank][2]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gBattleBankFunc[gActiveBank] = sub_8037C2C; } diff --git a/src/battle/battle_controller_linkpartner.c b/src/battle/battle_controller_linkpartner.c index 2c78d4a82..c86c337d9 100644 --- a/src/battle/battle_controller_linkpartner.c +++ b/src/battle/battle_controller_linkpartner.c @@ -1358,7 +1358,7 @@ void LinkPartnerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; BufferStringBattle(*(u16 *)&gBattleBufferA[gActiveBank][2]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gBattleBankFunc[gActiveBank] = sub_811DFA0; } diff --git a/src/battle/battle_controller_opponent.c b/src/battle/battle_controller_opponent.c index ab7b6944b..622e3e9f9 100644 --- a/src/battle/battle_controller_opponent.c +++ b/src/battle/battle_controller_opponent.c @@ -1407,7 +1407,7 @@ void OpponentHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; BufferStringBattle(*(u16 *)&gBattleBufferA[gActiveBank][2]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gBattleBankFunc[gActiveBank] = sub_80331D0; } diff --git a/src/battle/battle_controller_player.c b/src/battle/battle_controller_player.c index f992e3e51..a5f833b6c 100644 --- a/src/battle/battle_controller_player.c +++ b/src/battle/battle_controller_player.c @@ -67,9 +67,9 @@ extern u8 gUnknown_02024E68[]; extern struct SpriteTemplate gUnknown_02024E8C; extern u8 gAnimMoveTurn; extern u8 gUnknown_02038470[]; -extern u16 gUnknown_030041B0; +extern u16 gBattle_BG3_X; extern u16 gBattle_BG1_Y; -extern u16 gUnknown_030041B8; +extern u16 gBattle_BG3_Y; extern u16 gBattle_BG2_Y; extern u16 gBattle_BG2_X; extern u16 gBattle_BG0_X; @@ -744,9 +744,9 @@ void sub_802C68C(void) else gUnknown_03004344 = gMoveSelectionCursor[gActiveBank] + 1; sub_802E3B4(gUnknown_03004344, 27); - FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x37, 0x1C, 0x3A); - InitWindow(&gUnknown_03004210, BattleText_SwitchWhich, 0x290, 0x17, 0x37); - sub_8002F44(&gUnknown_03004210); + Text_FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x37, 0x1C, 0x3A); + Text_InitWindow(&gUnknown_03004210, BattleText_SwitchWhich, 0x290, 0x17, 0x37); + Text_PrintWindow8002F44(&gUnknown_03004210); gBattleBankFunc[gActiveBank] = sub_802CA60; } } @@ -853,9 +853,9 @@ void sub_802CA60(void) gBattleBankFunc[gActiveBank] = sub_802C68C; gMoveSelectionCursor[gActiveBank] = gUnknown_03004344; sub_802E3B4(gMoveSelectionCursor[gActiveBank], 0); - FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x37, 0x1C, 0x3A); - InitWindow(&gUnknown_03004210, BattleText_PP, 0x290, 0x17, 0x37); - sub_8002F44(&gUnknown_03004210); + Text_FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x37, 0x1C, 0x3A); + Text_InitWindow(&gUnknown_03004210, BattleText_PP, 0x290, 0x17, 0x37); + Text_PrintWindow8002F44(&gUnknown_03004210); sub_802E220(); sub_802E2D4(); } @@ -866,9 +866,9 @@ void sub_802CA60(void) sub_802E3B4(gMoveSelectionCursor[gActiveBank], 0); sub_802E12C(gMoveSelectionCursor[gActiveBank], BattleText_Format); gBattleBankFunc[gActiveBank] = sub_802C68C; - FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x37, 0x1C, 0x3A); - InitWindow(&gUnknown_03004210, BattleText_PP, 0x290, 0x17, 0x37); - sub_8002F44(&gUnknown_03004210); + Text_FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x37, 0x1C, 0x3A); + Text_InitWindow(&gUnknown_03004210, BattleText_PP, 0x290, 0x17, 0x37); + Text_PrintWindow8002F44(&gUnknown_03004210); sub_802E220(); sub_802E2D4(); } @@ -1557,13 +1557,13 @@ void sub_802E12C(s32 a, const u8 *b) StringCopy(gDisplayedStringBattle, b); StringAppend(gDisplayedStringBattle, gMoveNames[r4->moves[a]]); - InitWindow( + Text_InitWindow( &gUnknown_03004210, gDisplayedStringBattle, 0x300 + a * 20, (a & 1) ? 11 : 1, (a < 2) ? 0x37 : 0x39); - sub_8002F44(&gUnknown_03004210); + Text_PrintWindow8002F44(&gUnknown_03004210); } void sub_802E1B0(void) @@ -1572,7 +1572,7 @@ void sub_802E1B0(void) s32 i; gUnknown_03004348 = 0; - FillWindowRect(&gUnknown_03004210, 0x1016, 1, 0x37, 0x14, 0x3A); + Text_FillWindowRect(&gUnknown_03004210, 0x1016, 1, 0x37, 0x14, 0x3A); for (i = 0; i < 4; i++) { nullsub_7(i); @@ -1601,8 +1601,8 @@ void sub_802E220(void) str = ConvertIntToDecimalStringN(str, r4->pp[gMoveSelectionCursor[gActiveBank]], 1, 2); *str++ = CHAR_SLASH; ConvertIntToDecimalStringN(str, r4->unkC[gMoveSelectionCursor[gActiveBank]], 1, 2); - InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 0x2A2, 0x19, 0x37); - sub_8002F44(&gUnknown_03004210); + Text_InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 0x2A2, 0x19, 0x37); + Text_PrintWindow8002F44(&gUnknown_03004210); } } @@ -1613,8 +1613,8 @@ void sub_802E2D4(void) { if (gBattleBufferA[gActiveBank][2] == 1) { - FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x37, 0x1C, 0x3A); - InitWindow(&gUnknown_03004210, BattleText_ForgetMove, 0x290, 0x13, 0x37); + Text_FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x37, 0x1C, 0x3A); + Text_InitWindow(&gUnknown_03004210, BattleText_ForgetMove, 0x290, 0x13, 0x37); } else { @@ -1623,10 +1623,10 @@ void sub_802E2D4(void) str = StringCopy(str, BattleText_Format); StringCopy(str, gTypeNames[gBattleMoves[r4->moves[gMoveSelectionCursor[gActiveBank]]].type]); - FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x39, 0x1C, 0x3A); - InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 0x2C0, 0x17, 0x39); + Text_FillWindowRect(&gUnknown_03004210, 0x1016, 0x17, 0x39, 0x1C, 0x3A); + Text_InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 0x2C0, 0x17, 0x39); } - sub_8002F44(&gUnknown_03004210); + Text_PrintWindow8002F44(&gUnknown_03004210); } const u8 gUnknown_081FAE89[][2] = @@ -1652,7 +1652,7 @@ const u8 gUnknown_081FAE91[][2] = void sub_802E3B4(u8 a, int unused) { sub_814A958(0x48); - sub_814A880(gUnknown_081FAE89[a][0], gUnknown_081FAE89[a][1]); + MenuCursor_SetPos814A880(gUnknown_081FAE89[a][0], gUnknown_081FAE89[a][1]); } void nullsub_7(u8 a) @@ -1662,7 +1662,7 @@ void nullsub_7(u8 a) void sub_802E3E4(u8 a, int unused) { sub_814A958(0x2A); - sub_814A880(gUnknown_081FAE91[a][0], gUnknown_081FAE91[a][1]); + MenuCursor_SetPos814A880(gUnknown_081FAE91[a][0], gUnknown_081FAE91[a][1]); } void nullsub_8(u8 a) @@ -1697,7 +1697,7 @@ void b_link_standby_message(void) { gBattle_BG0_X = 0; gBattle_BG0_Y = 0; - sub_8002EB0(&gUnknown_03004210, BattleText_LinkStandby, 0x90, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, BattleText_LinkStandby, 0x90, 2, 15); } } @@ -2562,7 +2562,7 @@ void PlayerHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; BufferStringBattle(*(u16 *)&gBattleBufferA[gActiveBank][2]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 0x90, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 0x90, 2, 15); gBattleBankFunc[gActiveBank] = sub_802DF18; } @@ -2580,14 +2580,14 @@ void PlayerHandlecmd18(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 160; - FillWindowRect(&gUnknown_03004210, 10, 2, 15, 27, 18); - FillWindowRect(&gUnknown_03004210, 10, 2, 35, 16, 38); + Text_FillWindowRect(&gUnknown_03004210, 10, 2, 15, 27, 18); + Text_FillWindowRect(&gUnknown_03004210, 10, 2, 35, 16, 38); gBattleBankFunc[gActiveBank] = sub_802C098; - InitWindow(&gUnknown_03004210, BattleText_MenuOptions, 400, 18, 35); - sub_8002F44(&gUnknown_03004210); - sub_814A5C0(0, 0xFFFF, 12, 11679, 0); + Text_InitWindow(&gUnknown_03004210, BattleText_MenuOptions, 400, 18, 35); + Text_PrintWindow8002F44(&gUnknown_03004210); + MenuCursor_Create814A5C0(0, 0xFFFF, 12, 11679, 0); for (r4 = 0; r4 < 4; r4++) nullsub_8(r4); @@ -2595,8 +2595,8 @@ void PlayerHandlecmd18(void) sub_802E3E4(gActionSelectionCursor[gActiveBank], 0); StrCpyDecodeToDisplayedStringBattle(BattleText_OtherMenu); - InitWindow(&gUnknown_03004210, gDisplayedStringBattle, SUB_803037C_TILE_DATA_OFFSET, 2, 35); - sub_8002F44(&gUnknown_03004210); + Text_InitWindow(&gUnknown_03004210, gDisplayedStringBattle, SUB_803037C_TILE_DATA_OFFSET, 2, 35); + Text_PrintWindow8002F44(&gUnknown_03004210); } void PlayerHandlecmd19() @@ -2605,7 +2605,7 @@ void PlayerHandlecmd19() void PlayerHandlecmd20(void) { - sub_814A5C0(0, 0xFFFF, 12, 0x2D9F, 0); + MenuCursor_Create814A5C0(0, 0xFFFF, 12, 0x2D9F, 0); sub_80304A8(); gBattleBankFunc[gActiveBank] = sub_802C68C; } @@ -2619,8 +2619,8 @@ void sub_80304A8(void) sub_802E3B4(gMoveSelectionCursor[gActiveBank], 0); if (gBattleBufferA[gActiveBank][2] != 1) { - InitWindow(&gUnknown_03004210, BattleText_PP, 656, 23, 55); - sub_8002F44(&gUnknown_03004210); + Text_InitWindow(&gUnknown_03004210, BattleText_PP, 656, 23, 55); + Text_PrintWindow8002F44(&gUnknown_03004210); } sub_802E220(); sub_802E2D4(); diff --git a/src/battle/battle_controller_safari.c b/src/battle/battle_controller_safari.c index 0a629ba4d..a4b610752 100644 --- a/src/battle/battle_controller_safari.c +++ b/src/battle/battle_controller_safari.c @@ -453,7 +453,7 @@ void SafariHandlePrintString(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 0; BufferStringBattle(*(u16 *)&gBattleBufferA[gActiveBank][2]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gBattleBankFunc[gActiveBank] = sub_812B694; } @@ -472,13 +472,13 @@ void SafariHandlecmd18(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 160; gUnknown_03004210.paletteNum = 0; - FillWindowRect_DefaultPalette(&gUnknown_03004210, 10, 2, 15, 27, 18); - FillWindowRect_DefaultPalette(&gUnknown_03004210, 10, 2, 35, 16, 36); + Text_FillWindowRectDefPalette(&gUnknown_03004210, 10, 2, 15, 27, 18); + Text_FillWindowRectDefPalette(&gUnknown_03004210, 10, 2, 35, 16, 36); gBattleBankFunc[gActiveBank] = bx_battle_menu_t6_2; - InitWindow(&gUnknown_03004210, BattleText_MenuOptionsSafari, 400, 18, 35); - sub_8002F44(&gUnknown_03004210); - sub_814A5C0(0, 0xFFFF, 12, 11679, 0); + Text_InitWindow(&gUnknown_03004210, BattleText_MenuOptionsSafari, 400, 18, 35); + Text_PrintWindow8002F44(&gUnknown_03004210); + MenuCursor_Create814A5C0(0, 0xFFFF, 12, 11679, 0); for (i = 0; i < 4; i++) nullsub_8(i); @@ -486,8 +486,8 @@ void SafariHandlecmd18(void) sub_802E3E4(gActionSelectionCursor[gActiveBank], 0); StrCpyDecodeToDisplayedStringBattle(BattleText_PlayerMenu); - InitWindow(&gUnknown_03004210, gDisplayedStringBattle, SUB_812BB10_TILE_DATA_OFFSET, 2, 35); - sub_8002F44(&gUnknown_03004210); + Text_InitWindow(&gUnknown_03004210, gDisplayedStringBattle, SUB_812BB10_TILE_DATA_OFFSET, 2, 35); + Text_PrintWindow8002F44(&gUnknown_03004210); } void SafariHandlecmd19(void) diff --git a/src/battle/battle_controller_wally.c b/src/battle/battle_controller_wally.c index bd2b4a45b..6266d955c 100644 --- a/src/battle/battle_controller_wally.c +++ b/src/battle/battle_controller_wally.c @@ -1246,7 +1246,7 @@ void WallyHandlePrintString(void) if (*ptr == 2) DestroyMenuCursor(); BufferStringBattle(*ptr); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 0x90, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 0x90, 2, 15); gBattleBankFunc[gActiveBank] = sub_8137454; } @@ -1265,22 +1265,22 @@ void WallyHandlecmd18(void) gBattle_BG0_X = 0; gBattle_BG0_Y = 160; gUnknown_03004210.paletteNum = 0; - FillWindowRect_DefaultPalette(&gUnknown_03004210, 10, 2, 15, 27, 18); - FillWindowRect_DefaultPalette(&gUnknown_03004210, 10, 2, 35, 16, 36); + Text_FillWindowRectDefPalette(&gUnknown_03004210, 10, 2, 15, 27, 18); + Text_FillWindowRectDefPalette(&gUnknown_03004210, 10, 2, 35, 16, 36); gBattleBankFunc[gActiveBank] = sub_81372BC; - InitWindow(&gUnknown_03004210, BattleText_MenuOptions, 400, 18, 35); - sub_8002F44(&gUnknown_03004210); - sub_814A5C0(0, 0xFFFF, 12, 0x2D9F, 0); + Text_InitWindow(&gUnknown_03004210, BattleText_MenuOptions, 400, 18, 35); + Text_PrintWindow8002F44(&gUnknown_03004210); + MenuCursor_Create814A5C0(0, 0xFFFF, 12, 0x2D9F, 0); for (i = 0; i < 4; i++) nullsub_8(i); sub_802E3E4(0, 0); StrCpyDecodeToDisplayedStringBattle(BattleText_WallyMenu); #ifdef ENGLISH - InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 440, 2, 35); + Text_InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 440, 2, 35); #else - InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 444, 2, 35); + Text_InitWindow(&gUnknown_03004210, gDisplayedStringBattle, 444, 2, 35); #endif - sub_8002F44(&gUnknown_03004210); + Text_PrintWindow8002F44(&gUnknown_03004210); } void WallyHandlecmd19(void) diff --git a/src/battle/battle_party_menu.c b/src/battle/battle_party_menu.c index 7bce00d82..68a97c536 100644 --- a/src/battle/battle_party_menu.c +++ b/src/battle/battle_party_menu.c @@ -583,13 +583,13 @@ static void Task_HandlePopupMenuInput(u8 taskId) if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); return; } if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); return; } if (gMain.newKeys & A_BUTTON) @@ -598,7 +598,7 @@ static void Task_HandlePopupMenuInput(u8 taskId) func = PartyMenuGetPopupMenuFunc(gTasks[taskId].data[4], sBattlePartyPopupMenus, sBattlePartyMenuActions, - GetMenuCursorPos()); + Menu_GetCursorPos()); func(taskId); return; } @@ -723,7 +723,7 @@ static void Task_BattlePartyMenuShift(u8 taskId) static void Task_BattlePartyMenuCancel(u8 taskId) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); ClosePartyPopupMenu(gTasks[taskId].data[4], sBattlePartyPopupMenus); gTasks[taskId].data[4] = gTasks[taskId].data[5]; PrintPartyMenuPromptText(0, 0); diff --git a/src/battle/battle_records.c b/src/battle/battle_records.c index 97740e3da..4979760d7 100644 --- a/src/battle/battle_records.c +++ b/src/battle/battle_records.c @@ -202,7 +202,7 @@ static void PrintLinkBattleWinsLossesDraws(struct LinkBattleRecord *records) ConvertIntToDecimalStringN_DigitWidth6(gStringVar1, GetGameStat(GAME_STAT_LINK_BATTLE_WINS), STR_CONV_MODE_RIGHT_ALIGN, 4); ConvertIntToDecimalStringN_DigitWidth6(gStringVar2, GetGameStat(GAME_STAT_LINK_BATTLE_LOSSES), STR_CONV_MODE_RIGHT_ALIGN, 4); ConvertIntToDecimalStringN_DigitWidth6(gStringVar3, GetGameStat(GAME_STAT_LINK_BATTLE_DRAWS), STR_CONV_MODE_RIGHT_ALIGN, 4); - MenuPrint(gOtherText_WinRecord, 3, 3); + Menu_PrintText(gOtherText_WinRecord, 3, 3); } static void PrintLinkBattleRecord(struct LinkBattleRecord *record, u8 y) @@ -217,39 +217,39 @@ static void PrintLinkBattleRecord(struct LinkBattleRecord *record, u8 y) buffer[4] = 0x11; buffer[5] = 1; StringCopy(buffer + 6, gOtherText_SevenDashes); - MenuPrint(buffer, 3, y); + Menu_PrintText(buffer, 3, y); StringCopy(buffer + 6, gOtherText_FourDashes); - MenuPrint(buffer, 11, y); - MenuPrint(buffer, 17, y); - MenuPrint(buffer, 23, y); + Menu_PrintText(buffer, 11, y); + Menu_PrintText(buffer, 17, y); + Menu_PrintText(buffer, 23, y); } else { StringFillWithTerminator(gStringVar1, 8); StringCopyN(gStringVar1, record->name, 7); - MenuPrint(gStringVar1, 3, y); + Menu_PrintText(gStringVar1, 3, y); gStringVar1[0] = EXT_CTRL_CODE_BEGIN; gStringVar1[1] = 0x14; gStringVar1[2] = 6; ConvertIntToDecimalStringN(gStringVar1 + 3, record->wins, STR_CONV_MODE_RIGHT_ALIGN, 4); - MenuPrint(gStringVar1, 11, y); + Menu_PrintText(gStringVar1, 11, y); ConvertIntToDecimalStringN(gStringVar1 + 3, record->losses, STR_CONV_MODE_RIGHT_ALIGN, 4); - MenuPrint(gStringVar1, 17, y); + Menu_PrintText(gStringVar1, 17, y); ConvertIntToDecimalStringN(gStringVar1 + 3, record->draws, STR_CONV_MODE_RIGHT_ALIGN, 4); - MenuPrint(gStringVar1, 23, y); + Menu_PrintText(gStringVar1, 23, y); } } void ShowLinkBattleRecords(void) { s32 i; - MenuDrawTextWindow(1, 0, 28, 18); + Menu_DrawStdWindowFrame(1, 0, 28, 18); sub_8072BD8(gOtherText_BattleResults, 0, 1, 240); PrintLinkBattleWinsLossesDraws(gSaveBlock1.linkBattleRecords); #if ENGLISH - MenuPrint(gOtherText_WinLoseDraw, 12, 6); + Menu_PrintText(gOtherText_WinLoseDraw, 12, 6); #elif GERMAN - MenuPrint_PixelCoords(gOtherText_WinLoseDraw, 88, 48, 1); + Menu_PrintTextPixelCoords(gOtherText_WinLoseDraw, 88, 48, 1); #endif for (i = 0; i < 5; i++) @@ -285,11 +285,11 @@ static bool32 sub_8110494(u8 level) static void PrintWinStreak(const u8 *str, u16 streak, u8 left, u8 top) { - MenuPrint(str, left, top); + Menu_PrintText(str, left, top); if (streak > 9999) streak = 9999; sub_8072C14(gStringVar1, streak, 24, 1); - MenuPrint(gOtherText_WinStreak, left + 7, top); + Menu_PrintText(gOtherText_WinStreak, left + 7, top); } static void PrintRecordWinStreak(u8 level, u8 left, u8 top) @@ -320,10 +320,10 @@ static void PrintLastWinStreak(u8 level, u8 left, u8 top) void ShowBattleTowerRecords(void) { u16 i; - MenuDrawTextWindow(3, 1, 27, 17); + Menu_DrawStdWindowFrame(3, 1, 27, 17); sub_8072BD8(gOtherText_BattleTowerResults, 3, 2, 0xC8); - MenuPrint(gOtherText_Lv50, 5, 6); - MenuPrint(gOtherText_Lv100, 5, 12); + Menu_PrintText(gOtherText_Lv50, 5, 6); + Menu_PrintText(gOtherText_Lv100, 5, 12); for (i = 5; i < 26; i++) { sub_8071F60(CHAR_HYPHEN, i, 10); diff --git a/src/battle/battle_transition.c b/src/battle/battle_transition.c index 985f43945..f7cdc0694 100644 --- a/src/battle/battle_transition.c +++ b/src/battle/battle_transition.c @@ -13,12 +13,10 @@ #include "trainer.h" #include "field_camera.h" #include "ewram.h" -#include "unknown_task.h" +#include "scanline_effect.h" void sub_807DE10(void); -void dp12_8087EA4(void); - -extern u16 gUnknown_03005560[]; +void ScanlineEffect_Clear(void); extern const struct OamData gFieldOamData_32x32; @@ -672,9 +670,9 @@ static bool8 Phase2_Transition_Swirl_Func1(struct Task* task) u16 savedIME; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); BeginNormalPaletteFade(-1, 4, 0, 0x10, 0); - sub_811D6E8(gUnknown_03005560, TRANSITION_STRUCT.field_14, 0, 2, 0, 160); + sub_811D6E8(gScanlineEffectRegBuffers[1], TRANSITION_STRUCT.field_14, 0, 2, 0, 160); SetVBlankCallback(VBlankCB_Phase2_Transition_Swirl); SetHBlankCallback(HBlankCB_Phase2_Transition_Swirl); @@ -695,7 +693,7 @@ static bool8 Phase2_Transition_Swirl_Func2(struct Task* task) task->data[1] += 4; task->data[2] += 8; - sub_811D6E8(gUnknown_03004DE0[0], TRANSITION_STRUCT.field_14, task->data[1], 2, task->data[2], 160); + sub_811D6E8(gScanlineEffectRegBuffers[0], TRANSITION_STRUCT.field_14, task->data[1], 2, task->data[2], 160); if (!gPaletteFade.active) { @@ -711,12 +709,12 @@ static void VBlankCB_Phase2_Transition_Swirl(void) { VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } static void HBlankCB_Phase2_Transition_Swirl(void) { - u16 var = gUnknown_03004DE0[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1HOFS = var; REG_BG2HOFS = var; REG_BG3HOFS = var; @@ -732,10 +730,10 @@ static bool8 Phase2_Transition_Shuffle_Func1(struct Task* task) u16 savedIME; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); BeginNormalPaletteFade(-1, 4, 0, 0x10, 0); - memset(gUnknown_03005560, TRANSITION_STRUCT.field_16, 0x140); + memset(gScanlineEffectRegBuffers[1], TRANSITION_STRUCT.field_16, 0x140); SetVBlankCallback(VBlankCB_Phase2_Transition_Shuffle); SetHBlankCallback(HBlankCB_Phase2_Transition_Shuffle); @@ -764,7 +762,7 @@ static bool8 Phase2_Transition_Shuffle_Func2(struct Task* task) for (i = 0; i < 160; i++, r4 += 4224) { u16 var = r4 / 256; - gUnknown_03004DE0[0][i] = TRANSITION_STRUCT.field_16 + Sin(var, r3); + gScanlineEffectRegBuffers[0][i] = TRANSITION_STRUCT.field_16 + Sin(var, r3); } if (!gPaletteFade.active) @@ -778,12 +776,12 @@ static void VBlankCB_Phase2_Transition_Shuffle(void) { VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } static void HBlankCB_Phase2_Transition_Shuffle(void) { - u16 var = gUnknown_03004DE0[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1VOFS = var; REG_BG2VOFS = var; REG_BG3VOFS = var; @@ -800,7 +798,7 @@ static bool8 Phase2_Transition_BigPokeball_Func1(struct Task* task) u16 *dst1, *dst2; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); task->data[1] = 16; task->data[2] = 0; @@ -815,7 +813,7 @@ static bool8 Phase2_Transition_BigPokeball_Func1(struct Task* task) for (i = 0; i < 160; i++) { - gUnknown_03005560[i] = 240; + gScanlineEffectRegBuffers[1][i] = 240; } SetVBlankCallback(VBlankCB0_Phase2_Transition_BigPokeball); @@ -844,7 +842,7 @@ static bool8 Phase2_Transition_BigPokeball_Func2(struct Task* task) dst1[i * 32 + j] = *BigPokeballMap | 0xF000; } } - sub_811D6E8(gUnknown_03004DE0[0], 0, task->data[4], 132, task->data[5], 160); + sub_811D6E8(gScanlineEffectRegBuffers[0], 0, task->data[4], 132, task->data[5], 160); task->tState++; return TRUE; @@ -864,7 +862,7 @@ static bool8 Phase2_Transition_BigPokeball_Func3(struct Task* task) task->data[4] += 8; task->data[5] -= 256; - sub_811D6E8(gUnknown_03004DE0[0], 0, task->data[4], 132, task->data[5] >> 8, 160); + sub_811D6E8(gScanlineEffectRegBuffers[0], 0, task->data[4], 132, task->data[5] >> 8, 160); TRANSITION_STRUCT.VBlank_DMA++; return FALSE; @@ -884,7 +882,7 @@ static bool8 Phase2_Transition_BigPokeball_Func4(struct Task* task) task->data[4] += 8; task->data[5] -= 256; - sub_811D6E8(gUnknown_03004DE0[0], 0, task->data[4], 132, task->data[5] >> 8, 160); + sub_811D6E8(gScanlineEffectRegBuffers[0], 0, task->data[4], 132, task->data[5] >> 8, 160); TRANSITION_STRUCT.VBlank_DMA++; return FALSE; @@ -896,7 +894,7 @@ static bool8 Phase2_Transition_BigPokeball_Func5(struct Task* task) task->data[4] += 8; task->data[5] -= 256; - sub_811D6E8(gUnknown_03004DE0[0], 0, task->data[4], 132, task->data[5] >> 8, 160); + sub_811D6E8(gScanlineEffectRegBuffers[0], 0, task->data[4], 132, task->data[5] >> 8, 160); if (task->data[5] <= 0) { @@ -921,7 +919,7 @@ static bool8 Phase2_Transition_BigPokeball_Func6(struct Task* task) if (task->data[1] < 0) task->data[1] = 0; } - sub_811D764(gUnknown_03004DE0[0], 120, 80, task->data[1]); + sub_811D764(gScanlineEffectRegBuffers[0], 120, 80, task->data[1]); if (task->data[1] == 0) { DmaStop(0); @@ -943,7 +941,7 @@ static void Transition_BigPokeball_Vblank(void) DmaStop(0); VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_WININ = TRANSITION_STRUCT.WININ; REG_WINOUT = TRANSITION_STRUCT.WINOUT; REG_WIN0V = TRANSITION_STRUCT.WIN0V; @@ -954,13 +952,13 @@ static void Transition_BigPokeball_Vblank(void) static void VBlankCB0_Phase2_Transition_BigPokeball(void) { Transition_BigPokeball_Vblank(); - DmaSet(0, gUnknown_03005560, ®_BG0HOFS, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_BG0HOFS, 0xA2400001); } static void VBlankCB1_Phase2_Transition_BigPokeball(void) { Transition_BigPokeball_Vblank(); - DmaSet(0, gUnknown_03005560, ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } static void Phase2Task_Transition_PokeballsTrail(u8 taskID) @@ -1078,7 +1076,7 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func1(struct Task* task) u16 i; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); TRANSITION_STRUCT.WININ = 0; TRANSITION_STRUCT.WINOUT = 63; @@ -1087,7 +1085,7 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func1(struct Task* task) for (i = 0; i < 160; i++) { - gUnknown_03005560[i] = 0xF3F4; + gScanlineEffectRegBuffers[1][i] = 0xF3F4; } SetVBlankCallback(VBlankCB_Phase2_Transition_Clockwise_BlackFade); @@ -1104,7 +1102,7 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func2(struct Task* task) sub_811D8FC(TRANSITION_STRUCT.data, 120, 80, TRANSITION_STRUCT.data[4], -1, 1, 1); do { - gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] = (TRANSITION_STRUCT.data[2] + 1) | 0x7800; + gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] = (TRANSITION_STRUCT.data[2] + 1) | 0x7800; } while (!sub_811D978(TRANSITION_STRUCT.data, 1, 1)); TRANSITION_STRUCT.data[4] += 16; @@ -1132,7 +1130,7 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func3(struct Task* task) r1 = 120, r3 = TRANSITION_STRUCT.data[2] + 1; if (TRANSITION_STRUCT.data[5] >= 80) r1 = TRANSITION_STRUCT.data[2], r3 = 240; - gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] = (r3) | (r1 << 8); + gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] = (r3) | (r1 << 8); if (var != 0) break; var = sub_811D978(TRANSITION_STRUCT.data, 1, 1); @@ -1148,7 +1146,7 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func3(struct Task* task) { while (TRANSITION_STRUCT.data[3] < TRANSITION_STRUCT.data[5]) { - gUnknown_03004DE0[0][++TRANSITION_STRUCT.data[3]] = (r3) | (r1 << 8); + gScanlineEffectRegBuffers[0][++TRANSITION_STRUCT.data[3]] = (r3) | (r1 << 8); } } @@ -1163,7 +1161,7 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func4(struct Task* task) sub_811D8FC(TRANSITION_STRUCT.data, 120, 80, TRANSITION_STRUCT.data[4], 160, 1, 1); do { - gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] = (TRANSITION_STRUCT.data[2] << 8) | 0xF0; + gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] = (TRANSITION_STRUCT.data[2] << 8) | 0xF0; } while (!sub_811D978(TRANSITION_STRUCT.data, 1, 1)); TRANSITION_STRUCT.data[4] -= 16; @@ -1188,10 +1186,10 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func5(struct Task* task) while (1) { - r1 = gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] & 0xFF, r2 = TRANSITION_STRUCT.data[2]; + r1 = gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] & 0xFF, r2 = TRANSITION_STRUCT.data[2]; if (TRANSITION_STRUCT.data[5] <= 80) r2 = 120, r1 = TRANSITION_STRUCT.data[2]; - gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] = (r1) | (r2 << 8); + gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] = (r1) | (r2 << 8); r3 = 0; if (var != 0) break; @@ -1208,7 +1206,7 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func5(struct Task* task) { while (TRANSITION_STRUCT.data[3] > TRANSITION_STRUCT.data[5]) { - gUnknown_03004DE0[0][--TRANSITION_STRUCT.data[3]] = (r1) | (r2 << 8); + gScanlineEffectRegBuffers[0][--TRANSITION_STRUCT.data[3]] = (r1) | (r2 << 8); } } @@ -1228,7 +1226,7 @@ static bool8 Phase2_Transition_Clockwise_BlackFade_Func6(struct Task* task) r2 = 120, r3 = TRANSITION_STRUCT.data[2]; if (TRANSITION_STRUCT.data[2] >= 120) r2 = 0, r3 = 240; - gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] = (r3) | (r2 << 8); + gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] = (r3) | (r2 << 8); } while (!sub_811D978(TRANSITION_STRUCT.data, 1, 1)); @@ -1253,12 +1251,12 @@ static void VBlankCB_Phase2_Transition_Clockwise_BlackFade(void) DmaStop(0); VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA != 0) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_WININ = TRANSITION_STRUCT.WININ; REG_WINOUT = TRANSITION_STRUCT.WINOUT; REG_WIN0V = TRANSITION_STRUCT.WIN0V; - REG_WIN0H = gUnknown_03004DE0[1][0]; - DmaSet(0, gUnknown_03004DE0[1], ®_WIN0H, 0xA2400001); + REG_WIN0H = gScanlineEffectRegBuffers[1][0]; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } static void Phase2Task_Transition_Ripple(u8 taskID) @@ -1271,11 +1269,11 @@ static bool8 Phase2_Transition_Ripple_Func1(struct Task* task) u8 i; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); for (i = 0; i < 160; i++) { - gUnknown_03005560[i] = TRANSITION_STRUCT.field_16; + gScanlineEffectRegBuffers[1][i] = TRANSITION_STRUCT.field_16; } SetVBlankCallback(VBlankCB_Phase2_Transition_Ripple); @@ -1308,7 +1306,7 @@ static bool8 Phase2_Transition_Ripple_Func2(struct Task* task) // todo: fix the asm s16 var = r4 >> 8; asm(""); - gUnknown_03004DE0[0][i] = TRANSITION_STRUCT.field_16 + Sin(var, r3); + gScanlineEffectRegBuffers[0][i] = TRANSITION_STRUCT.field_16 + Sin(var, r3); asm(""); } @@ -1329,12 +1327,12 @@ static void VBlankCB_Phase2_Transition_Ripple(void) { VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); } static void HBlankCB_Phase2_Transition_Ripple(void) { - u16 var = gUnknown_03004DE0[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1VOFS = var; REG_BG2VOFS = var; REG_BG3VOFS = var; @@ -1350,7 +1348,7 @@ static bool8 Phase2_Transition_Wave_Func1(struct Task* task) u8 i; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); TRANSITION_STRUCT.WININ = 63; TRANSITION_STRUCT.WINOUT = 0; @@ -1359,7 +1357,7 @@ static bool8 Phase2_Transition_Wave_Func1(struct Task* task) for (i = 0; i < 160; i++) { - gUnknown_03004DE0[1][i] = 242; + gScanlineEffectRegBuffers[1][i] = 242; } SetVBlankCallback(VBlankCB_Phase2_Transition_Wave); @@ -1375,7 +1373,7 @@ static bool8 Phase2_Transition_Wave_Func2(struct Task* task) bool8 nextFunc; TRANSITION_STRUCT.VBlank_DMA = 0; - toStore = gUnknown_03004DE0[0]; + toStore = gScanlineEffectRegBuffers[0]; r5 = task->data[2]; task->data[2] += 16; task->data[1] += 8; @@ -1411,11 +1409,11 @@ static void VBlankCB_Phase2_Transition_Wave(void) DmaStop(0); VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA != 0) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_WININ = TRANSITION_STRUCT.WININ; REG_WINOUT = TRANSITION_STRUCT.WINOUT; REG_WIN0V = TRANSITION_STRUCT.WIN0V; - DmaSet(0, gUnknown_03004DE0[1], ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } #define tMugshotOpponentID data[13] @@ -1462,7 +1460,7 @@ static bool8 Phase2_Mugshot_Func1(struct Task* task) u8 i; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); Mugshots_CreateOpponentPlayerSprites(task); task->data[1] = 0; @@ -1474,7 +1472,7 @@ static bool8 Phase2_Mugshot_Func1(struct Task* task) for (i = 0; i < 160; i++) { - gUnknown_03004DE0[1][i] = 0xF0F1; + gScanlineEffectRegBuffers[1][i] = 0xF0F1; } SetVBlankCallback(VBlankCB0_Phase2_Mugshots); @@ -1519,7 +1517,7 @@ static bool8 Phase2_Mugshot_Func3(struct Task* task) TRANSITION_STRUCT.VBlank_DMA = 0; - toStore = gUnknown_03004DE0[0]; + toStore = gScanlineEffectRegBuffers[0]; r5 = task->data[1]; task->data[1] += 0x10; @@ -1565,7 +1563,7 @@ static bool8 Phase2_Mugshot_Func4(struct Task* task) TRANSITION_STRUCT.VBlank_DMA = 0; - for (i = 0, toStore = gUnknown_03004DE0[0]; i < 160; i++, toStore++) + for (i = 0, toStore = gScanlineEffectRegBuffers[0]; i < 160; i++, toStore++) { *toStore = 0xF0; } @@ -1608,8 +1606,8 @@ static bool8 Phase2_Mugshot_Func6(struct Task* task) TRANSITION_STRUCT.VBlank_DMA = 0; SetVBlankCallback(NULL); DmaStop(0); - memset(gUnknown_03004DE0[0], 0, 0x140); - memset(gUnknown_03004DE0[1], 0, 0x140); + memset(gScanlineEffectRegBuffers[0], 0, 0x140); + memset(gScanlineEffectRegBuffers[1], 0, 0x140); REG_WIN0H = 0xF0; REG_BLDY = 0; task->tState++; @@ -1642,15 +1640,15 @@ static bool8 Phase2_Mugshot_Func7(struct Task* task) { s16 index1 = 0x50 - i; s16 index2 = 0x50 + i; - if (gUnknown_03004DE0[0][index1] <= 15) + if (gScanlineEffectRegBuffers[0][index1] <= 15) { r6 = TRUE; - gUnknown_03004DE0[0][index1]++; + gScanlineEffectRegBuffers[0][index1]++; } - if (gUnknown_03004DE0[0][index2] <= 15) + if (gScanlineEffectRegBuffers[0][index2] <= 15) { r6 = TRUE; - gUnknown_03004DE0[0][index2]++; + gScanlineEffectRegBuffers[0][index2]++; } } } @@ -1678,7 +1676,7 @@ static bool8 Phase2_Mugshot_Func9(struct Task* task) TRANSITION_STRUCT.VBlank_DMA = 0; task->data[3]++; - memset(gUnknown_03004DE0[0], task->data[3], 0x140); + memset(gScanlineEffectRegBuffers[0], task->data[3], 0x140); if (task->data[3] > 15) task->tState++; @@ -1699,12 +1697,12 @@ static void VBlankCB0_Phase2_Mugshots(void) DmaStop(0); VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA != 0) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_BG0VOFS = TRANSITION_STRUCT.field_1C; REG_WININ = TRANSITION_STRUCT.WININ; REG_WINOUT = TRANSITION_STRUCT.WINOUT; REG_WIN0V = TRANSITION_STRUCT.WIN0V; - DmaSet(0, gUnknown_03004DE0[1], ®_WIN0H, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } static void VBlankCB1_Phase2_Mugshots(void) @@ -1712,9 +1710,9 @@ static void VBlankCB1_Phase2_Mugshots(void) DmaStop(0); VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA != 0) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_BLDCNT = TRANSITION_STRUCT.BLDCNT; - DmaSet(0, gUnknown_03004DE0[1], ®_BLDY, 0xA2400001); + DmaSet(0, gScanlineEffectRegBuffers[1], ®_BLDY, 0xA2400001); } static void HBlankCB_Phase2_Mugshots(void) @@ -1846,7 +1844,7 @@ static bool8 Phase2_Transition_Slice_Func1(struct Task* task) u16 i; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); task->data[2] = 256; task->data[3] = 1; @@ -1856,8 +1854,8 @@ static bool8 Phase2_Transition_Slice_Func1(struct Task* task) for (i = 0; i < 160; i++) { - gUnknown_03004DE0[1][i] = TRANSITION_STRUCT.field_14; - gUnknown_03004DE0[1][160 + i] = 0xF0; + gScanlineEffectRegBuffers[1][i] = TRANSITION_STRUCT.field_14; + gScanlineEffectRegBuffers[1][160 + i] = 0xF0; } REG_IE |= INTR_FLAG_HBLANK; @@ -1886,8 +1884,8 @@ static bool8 Phase2_Transition_Slice_Func2(struct Task* task) for (i = 0; i < 160; i++) { - u16* storeLoc1 = &gUnknown_03004DE0[0][i]; - u16* storeLoc2 = &gUnknown_03004DE0[0][i + 160]; + u16* storeLoc1 = &gScanlineEffectRegBuffers[0][i]; + u16* storeLoc2 = &gScanlineEffectRegBuffers[0][i + 160]; if (1 & i) { *storeLoc1 = TRANSITION_STRUCT.field_14 + task->data[1]; @@ -1923,13 +1921,13 @@ static void VBlankCB_Phase2_Transition_Slice(void) REG_WINOUT = TRANSITION_STRUCT.WINOUT; REG_WIN0V = TRANSITION_STRUCT.WIN0V; if (TRANSITION_STRUCT.VBlank_DMA) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 640); - DmaSet(0, &gUnknown_03004DE0[1][160], ®_WIN0H, 0xA2400001); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640); + DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); } static void HBlankCB_Phase2_Transition_Slice(void) { - u16 var = gUnknown_03004DE0[1][REG_VCOUNT]; + u16 var = gScanlineEffectRegBuffers[1][REG_VCOUNT]; REG_BG1HOFS = var; REG_BG2HOFS = var; REG_BG3HOFS = var; @@ -1945,7 +1943,7 @@ static bool8 Phase2_Transition_WhiteFade_Func1(struct Task* task) u16 i; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); TRANSITION_STRUCT.BLDCNT = 0xBF; TRANSITION_STRUCT.BLDY = 0; @@ -1955,8 +1953,8 @@ static bool8 Phase2_Transition_WhiteFade_Func1(struct Task* task) for (i = 0; i < 160; i++) { - gUnknown_03004DE0[1][i] = 0; - gUnknown_03004DE0[1][i + 160] = 0xF0; + gScanlineEffectRegBuffers[1][i] = 0; + gScanlineEffectRegBuffers[1][i + 160] = 0xF0; } REG_IE |= INTR_FLAG_HBLANK; @@ -2038,8 +2036,8 @@ static void VBlankCB0_Phase2_Transition_WhiteFade(void) REG_WINOUT = TRANSITION_STRUCT.WINOUT; REG_WIN0V = TRANSITION_STRUCT.field_6; if (TRANSITION_STRUCT.VBlank_DMA) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 640); - DmaSet(0, &gUnknown_03004DE0[1][160], ®_WIN0H, 0xA2400001); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 640); + DmaSet(0, &gScanlineEffectRegBuffers[1][160], ®_WIN0H, 0xA2400001); } static void VBlankCB1_Phase2_Transition_WhiteFade(void) @@ -2055,7 +2053,7 @@ static void VBlankCB1_Phase2_Transition_WhiteFade(void) static void HBlankCB_Phase2_Transition_WhiteFade(void) { - REG_BLDY = gUnknown_03004DE0[1][REG_VCOUNT]; + REG_BLDY = gScanlineEffectRegBuffers[1][REG_VCOUNT]; } static void sub_811CFD0(struct Sprite* sprite) @@ -2069,8 +2067,8 @@ static void sub_811CFD0(struct Sprite* sprite) else { u16 i; - u16* ptr1 = &gUnknown_03004DE0[0][sprite->pos1.y]; - u16* ptr2 = &gUnknown_03004DE0[0][sprite->pos1.y + 160]; + u16* ptr1 = &gScanlineEffectRegBuffers[0][sprite->pos1.y]; + u16* ptr2 = &gScanlineEffectRegBuffers[0][sprite->pos1.y + 160]; for (i = 0; i < 20; i++) { ptr1[i] = sprite->data[0] >> 8; @@ -2160,7 +2158,7 @@ static bool8 Phase2_Transition_Shards_Func1(struct Task* task) u16 i; sub_811D658(); - dp12_8087EA4(); + ScanlineEffect_Clear(); TRANSITION_STRUCT.WININ = 0x3F; TRANSITION_STRUCT.WINOUT = 0; @@ -2168,10 +2166,10 @@ static bool8 Phase2_Transition_Shards_Func1(struct Task* task) for (i = 0; i < 160; i++) { - gUnknown_03004DE0[0][i] = 0xF0; + gScanlineEffectRegBuffers[0][i] = 0xF0; } - CpuSet(gUnknown_03004DE0[0], gUnknown_03004DE0[1], 0xA0); + CpuSet(gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 0xA0); SetVBlankCallback(VBlankCB_Phase2_Transition_Shards); task->tState++; @@ -2200,8 +2198,8 @@ static bool8 Phase2_Transition_Shards_Func3(struct Task* task) for (i = 0, nextFunc = FALSE; i < 16; i++) { - s16 r3 = gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] >> 8; - s16 r4 = gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] & 0xFF; + s16 r3 = gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] >> 8; + s16 r4 = gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] & 0xFF; if (task->data[2] == 0) { if (r3 < TRANSITION_STRUCT.data[2]) @@ -2216,7 +2214,7 @@ static bool8 Phase2_Transition_Shards_Func3(struct Task* task) if (r4 <= r3) r4 = r3; } - gUnknown_03004DE0[0][TRANSITION_STRUCT.data[3]] = (r4) | (r3 << 8); + gScanlineEffectRegBuffers[0][TRANSITION_STRUCT.data[3]] = (r4) | (r3 << 8); if (nextFunc) { task->tState++; @@ -2263,12 +2261,12 @@ static void VBlankCB_Phase2_Transition_Shards(void) DmaStop(0); VBlankCB_BattleTransition(); if (TRANSITION_STRUCT.VBlank_DMA) - DmaCopy16(3, gUnknown_03004DE0[0], gUnknown_03004DE0[1], 320); + DmaCopy16(3, gScanlineEffectRegBuffers[0], gScanlineEffectRegBuffers[1], 320); REG_WININ = TRANSITION_STRUCT.WININ; REG_WINOUT = TRANSITION_STRUCT.WINOUT; REG_WIN0V = TRANSITION_STRUCT.WIN0V; - REG_WIN0H = gUnknown_03004DE0[1][0]; - DmaSet(0, gUnknown_03004DE0[1], ®_WIN0H, 0xA2400001); + REG_WIN0H = gScanlineEffectRegBuffers[1][0]; + DmaSet(0, gScanlineEffectRegBuffers[1], ®_WIN0H, 0xA2400001); } static void CreatePhase1Task(s16 a0, s16 a1, s16 a2, s16 a3, s16 a4) diff --git a/src/battle/reshow_battle_screen.c b/src/battle/reshow_battle_screen.c index 6a6d7a137..a78cb20df 100644 --- a/src/battle/reshow_battle_screen.c +++ b/src/battle/reshow_battle_screen.c @@ -3,7 +3,7 @@ #include "battle_anim.h" #include "palette.h" #include "main.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "text.h" #include "rom_8077ABC.h" #include "data2.h" @@ -15,9 +15,9 @@ extern u16 gBattle_BG2_Y; extern u16 gBattle_BG2_X; extern u16 gBattle_BG0_X; extern u16 gBattle_BG1_X; -extern u16 gUnknown_030041B0; +extern u16 gBattle_BG3_X; extern u16 gBattle_BG1_Y; -extern u16 gUnknown_030041B8; +extern u16 gBattle_BG3_Y; extern u16 gBattle_BG0_Y; extern u8 gReservedSpritePaletteCount; extern u8 gActionSelectionCursor[4]; @@ -77,18 +77,18 @@ static void CB2_ReshowBattleScreenAfterMenu(void) switch (gReshowState) { case 0: - dp12_8087EA4(); - SetUpWindowConfig(&gWindowConfig_81E6C58); + ScanlineEffect_Clear(); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C58); ResetPaletteFade(); - InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6C58); + Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6C58); gBattle_BG0_X = 0; gBattle_BG0_Y = 0; gBattle_BG1_X = 0; gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 0; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; break; case 1: { diff --git a/src/contest.c b/src/contest.c index c32719648..875fe4502 100644 --- a/src/contest.c +++ b/src/contest.c @@ -29,7 +29,7 @@ #include "task.h" #include "text.h" #include "tv.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "util.h" extern u8 AreMovesContestCombo(u16, u16); // I don't think this is a bool @@ -51,9 +51,9 @@ extern u8 gBanksBySide[]; extern u8 gObjectBankIDs[]; extern u8 gIsLinkContest; extern u8 gContestPlayerMonIndex; -extern u16 gUnknown_030041B0; +extern u16 gBattle_BG3_X; extern s16 gBattle_BG1_Y; -extern u16 gUnknown_030041B8; +extern u16 gBattle_BG3_Y; extern u16 gBattle_WIN1H; extern struct Window gUnknown_03004210; extern u16 gBattle_WIN0V; @@ -330,8 +330,8 @@ void ResetContestGpuRegs(void) gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 0; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; gBattle_WIN0H = 0; gBattle_WIN0V = 0; gBattle_WIN1H = 0; @@ -357,16 +357,16 @@ void LoadContestBgAfterMoveAnim(void) void SetUpContestWindow(void) { - SetUpWindowConfig(&gWindowConfig_81E6FD8); - InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6FD8); - InitWindowFromConfig(&gMenuWindow, &gWindowConfig_81E6FF4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6FD8); + Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6FD8); + Text_InitWindowWithTemplate(&gMenuWindow, &gWindowTemplate_81E6FF4); } void sub_80AB350(void) { u8 i; - LoadFontDefaultPalette(&gWindowConfig_81E6FD8); + LoadFontDefaultPalette(&gWindowTemplate_81E6FD8); FillPalette(0, 0, 2); for (i = 10; i < 14; i++) LoadPalette(gPlttBufferUnfaded + 241, 240 + i, 2); @@ -412,7 +412,7 @@ void CB2_StartContest(void) SetVBlankCallback(NULL); SetUpContestWindow(); ResetContestGpuRegs(); - dp12_8087EA4(); + ScanlineEffect_Clear(); ResetPaletteFade(); gPaletteFade.bufferTransferDisabled = TRUE; DmaClearLarge32(3, (void *)VRAM, VRAM_SIZE, 0x1000); @@ -626,8 +626,8 @@ void ContestVBlankCallback(void) REG_BG1VOFS = gBattle_BG1_Y; REG_BG2HOFS = gBattle_BG2_X; REG_BG2VOFS = gBattle_BG2_Y; - REG_BG3HOFS = gUnknown_030041B0; - REG_BG3VOFS = gUnknown_030041B8; + REG_BG3HOFS = gBattle_BG3_X; + REG_BG3VOFS = gBattle_BG3_Y; REG_WIN0H = gBattle_WIN0H; REG_WIN0V = gBattle_WIN0V; REG_WIN1H = gBattle_WIN1H; @@ -635,7 +635,7 @@ void ContestVBlankCallback(void) TransferPlttBuffer(); LoadOam(); ProcessSpriteCopyRequests(); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); } void sub_80ABB70(u8 taskId) @@ -651,13 +651,13 @@ void sub_80ABB70(u8 taskId) InsertStringDigit(gDisplayedStringBattle, sContest.turnNumber + 1); sub_80AF138(); StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].func = sub_80ABC3C; } void sub_80ABC3C(u8 taskId) { - if (sub_80037A0(&gMenuWindow) == 1) + if (Text_UpdateWindowInContest(&gMenuWindow) == 1) gTasks[taskId].func = sub_80ABC70; } @@ -686,7 +686,7 @@ void sub_80ABCDC(u8 taskId) gBattle_BG0_Y = 0xA0; gBattle_BG2_Y = 0xA0; - FillWindowRect_DefaultPalette( + Text_FillWindowRectDefPalette( &gUnknown_03004210, 0, gUnknown_083CA340[0][0], @@ -715,17 +715,17 @@ void sub_80ABCDC(u8 taskId) } r5 = StringCopy(r5, gMoveNames[move]); - sub_8002E4C( + Text_InitWindow8002E4C( &gUnknown_03004210, sp8, 776 + i * 20, gUnknown_083CA340[i][0] * 8 + 4, gUnknown_083CA340[i][1] * 8, 1); - sub_8002F44(&gUnknown_03004210); + Text_PrintWindow8002F44(&gUnknown_03004210); } - sub_814A5C0(0, 0xFFFF, 12, 0x2D9F, 72); + MenuCursor_Create814A5C0(0, 0xFFFF, 12, 0x2D9F, 72); sub_80AC0AC(sContest.playerMoveChoice); sub_80AEBEC(gContestMons[gContestPlayerMonIndex].moves[sContest.playerMoveChoice]); gTasks[taskId].func = sub_80ABEA0; @@ -757,7 +757,7 @@ void sub_80ABEA0(u8 taskId) sub_814A904(); PlaySE(SE_SELECT); sub_80AFFE0(FALSE); - FillWindowRect_DefaultPalette( + Text_FillWindowRectDefPalette( &gUnknown_03004210, 0, gUnknown_083CA340[0][0], @@ -771,7 +771,7 @@ void sub_80ABEA0(u8 taskId) InsertStringDigit(gDisplayedStringBattle, sContest.turnNumber + 1); sub_80AF138(); StringExpandPlaceholders(gStringVar4, gDisplayedStringBattle); - sub_8003460(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindowAndPrintText(&gMenuWindow, gStringVar4, 776, 1, 15); gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; gTasks[taskId].func = sub_80ABC70; @@ -809,7 +809,7 @@ void sub_80ABEA0(u8 taskId) void sub_80AC0AC(s8 a) { - sub_814A880(4, 88 + a * 16); + MenuCursor_SetPos814A880(4, 88 + a * 16); } void nullsub_17(s8 a) @@ -976,12 +976,12 @@ void sub_80AC2CC(u8 taskId) else StringCopy(gStringVar2, gUnknown_083CC330[sContestantStatus[r7].moveCategory]); StringExpandPlaceholders(gStringVar4, gUnknown_083CAFD7); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[0] = 6; } return; case 6: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) { sContest.unk1925E = 0; gTasks[taskId].data[0] = 7; @@ -1059,7 +1059,7 @@ void sub_80AC2CC(u8 taskId) } return; case 24: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) gTasks[taskId].data[0] = 23; return; case 48: @@ -1171,7 +1171,7 @@ void sub_80AC2CC(u8 taskId) } return; case 27: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) gTasks[taskId].data[0] = 28; return; case 28: @@ -1234,13 +1234,13 @@ void sub_80AC2CC(u8 taskId) sub_80AF138(); StringCopy(gStringVar1, gContestMons[r7].nickname); StringExpandPlaceholders(gStringVar4, ContestString_CantAppealNextTurn); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); } gTasks[taskId].data[0] = 52; } return; case 52: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) { if (!sContestantStatus[r7].unk15_6) gTasks[taskId].data[0] = 17; @@ -1254,11 +1254,11 @@ void sub_80AC2CC(u8 taskId) { sub_80AF138(); if (r4 == 1) - sub_8002EB0(&gMenuWindow, ContestString_WentOverWell, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, ContestString_WentOverWell, 776, 1, 15); else if (r4 == 2) - sub_8002EB0(&gMenuWindow, ContestString_WentOverVeryWell, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, ContestString_WentOverVeryWell, 776, 1, 15); else - sub_8002EB0(&gMenuWindow, ContestString_AppealComboExcellently, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, ContestString_AppealComboExcellently, 776, 1, 15); sub_80B1710(3); gTasks[taskId].data[10] = 0; gTasks[taskId].data[0] = 45; @@ -1268,7 +1268,7 @@ void sub_80AC2CC(u8 taskId) sub_80AF138(); StringCopy(gStringVar1, gContestMons[r7].nickname); StringExpandPlaceholders(gStringVar4, ContestString_JudgeExpectantly2); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); sub_80B1710(2); gTasks[taskId].data[10] = 0; gTasks[taskId].data[0] = 45; @@ -1282,7 +1282,7 @@ void sub_80AC2CC(u8 taskId) } return; case 15: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) { if (++gTasks[taskId].data[10] > 50) { @@ -1311,7 +1311,7 @@ void sub_80AC2CC(u8 taskId) sub_80AF138(); StringCopy(gStringVar1, gContestMons[r7].nickname); StringExpandPlaceholders(gStringVar4, ContestString_DissapointedRepeat); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[10] = 0; sub_80B1710(0); gTasks[taskId].data[0] = 46; @@ -1326,7 +1326,7 @@ void sub_80AC2CC(u8 taskId) gTasks[taskId].data[0] = 19; return; case 19: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) { sub_80AFBA0(sContestantStatus[r7].appeal2, -sContestantStatus[r7].unk18, r7); sContestantStatus[r7].appeal2 -= sContestantStatus[r7].unk18; @@ -1381,7 +1381,7 @@ void sub_80AC2CC(u8 taskId) StringExpandPlaceholders(gStringVar4, ContestString_WentOverGreat); else StringExpandPlaceholders(gStringVar4, ContestString_GotCrowdGoing); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[10] = 0; gTasks[taskId].data[11] = 0; if (r4 < 0) @@ -1400,7 +1400,7 @@ void sub_80AC2CC(u8 taskId) gTasks[taskId].data[10]++; break; case 1: - if (!sContest.unk1920B_0 && sub_80037A0(&gMenuWindow) != 0) + if (!sContest.unk1920B_0 && Text_UpdateWindowInContest(&gMenuWindow) != 0) { sub_80B1CBC(-1); gTasks[taskId].data[10]++; @@ -1431,7 +1431,7 @@ void sub_80AC2CC(u8 taskId) switch (gTasks[taskId].data[10]) { case 0: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) { sub_80B1EA8(1, 1); gTasks[taskId].data[10]++; @@ -1491,20 +1491,20 @@ void sub_80AC2CC(u8 taskId) StringCopy(gStringVar1, gContestMons[r7].nickname); StringCopy(gStringVar2, gMoveNames[sContestantStatus[r7].currMove]); StringExpandPlaceholders(gStringVar4, ContestString_CrowdWatches); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[0] = 58; return; case 58: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) { sub_80AF138(); StringExpandPlaceholders(gStringVar4, ContestString_Ignored2); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[0] = 59; } return; case 59: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) { sub_80AF138(); gTasks[taskId].data[0] = 55; @@ -1517,11 +1517,11 @@ void sub_80AC2CC(u8 taskId) StringCopy(gStringVar1, gContestMons[r7].nickname); StringCopy(gStringVar2, gMoveNames[sContestantStatus[r7].currMove]); StringExpandPlaceholders(gStringVar4, gUnknown_083CBF60); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[0] = 34; return; case 34: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) gTasks[taskId].data[0] = 55; return; case 55: @@ -1563,11 +1563,11 @@ void sub_80AC2CC(u8 taskId) sub_80AF138(); StringCopy(gStringVar1, gContestMons[r7].nickname); StringExpandPlaceholders(gStringVar4, gUnknown_083CB00D); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[0] = 32; return; case 32: - if (sub_80037A0(&gMenuWindow) != 0) + if (Text_UpdateWindowInContest(&gMenuWindow) != 0) gTasks[taskId].data[0] = 21; return; case 21: @@ -1734,13 +1734,13 @@ void sub_80ADB88(u8 taskId) sub_80AF138(); StringCopy(gStringVar1, gContestMons[gContestPlayerMonIndex].nickname); StringExpandPlaceholders(gStringVar4, gContestStandOutStrings[r4]); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].func = sub_80ADC10; } void sub_80ADC10(u8 taskId) { - if (sub_80037A0(&gMenuWindow) == 1) + if (Text_UpdateWindowInContest(&gMenuWindow) == 1) { gTasks[taskId].data[0] = 0; gTasks[taskId].func = sub_80ADC4C; @@ -1813,14 +1813,14 @@ void sub_80ADDA4(u8 taskId) sub_80BE23C(sContestantStatus[gContestPlayerMonIndex].prevMove); gUnknown_03005D28 = gRngValue; StringExpandPlaceholders(gStringVar4, gUnknown_083CB02C); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); gTasks[taskId].data[2] = 0; gTasks[taskId].func = sub_80ADE54; } void sub_80ADE54(u8 taskId) { - if (sub_80037A0(&gMenuWindow) == 1) + if (Text_UpdateWindowInContest(&gMenuWindow) == 1) { sub_80B2184(); gBattle_BG1_X = 0; @@ -1940,7 +1940,7 @@ void Contest_CreatePlayerMon(u8 partyIndex) s16 tough; StringCopy(name, gSaveBlock2.playerName); - StripExtCtrlCodes(name); + Text_StripExtCtrlCodes(name); if (gIsLinkContest & 1) { u8 temp = name[5]; @@ -1960,7 +1960,7 @@ void Contest_CreatePlayerMon(u8 partyIndex) StringGetEnd10(name); if (gIsLinkContest & 1) { - StripExtCtrlCodes(name); + Text_StripExtCtrlCodes(name); if (GetMonData(&gPlayerParty[partyIndex], MON_DATA_LANGUAGE) == LANGUAGE_JAPANESE) { name[5] = EOS; @@ -2121,7 +2121,7 @@ void sub_80AE514(void) for (i = 0; i < 4; i++) { - FillWindowRect_DefaultPalette( + Text_FillWindowRectDefPalette( &gUnknown_03004210, 0, gUnknown_083CA308[gUnknown_02038696[i]][0], @@ -2161,7 +2161,7 @@ void sub_80AE5D4(u8 p, u8 b) if ((gIsLinkContest & 1) && gLinkPlayers[p].language == LANGUAGE_JAPANESE) { StringCopy(str, gLinkPlayers[p].name); - sub_8004D04( + Text_InitWindow8004D04( &gUnknown_03004210, gDisplayedStringBattle, 592 + gUnknown_02038696[p] * 22, @@ -2172,7 +2172,7 @@ void sub_80AE5D4(u8 p, u8 b) else { StringCopy(str, gContestMons[p].trainerName); - sub_8003460( + Text_InitWindowAndPrintText( &gUnknown_03004210, gDisplayedStringBattle, 592 + gUnknown_02038696[p] * 22, @@ -2198,7 +2198,7 @@ void sub_80AE6E4(u8 a, u8 b) str = sub_80AE598(str, gContestMons[a].nickname, b); *str = EOS; - sub_8004D04( + Text_InitWindow8004D04( &gUnknown_03004210, gDisplayedStringBattle, 512 + gUnknown_02038696[a] * 20, @@ -2383,7 +2383,7 @@ void sub_80AEBEC(u16 a) s32 i; u8 numHearts; - FillWindowRect_DefaultPalette(&gUnknown_03004210, 0, 11, 31, 16, 34); + Text_FillWindowRectDefPalette(&gUnknown_03004210, 0, 11, 31, 16, 34); category = gContestMoves[a].contestCategory; if (category == CONTEST_CATEGORY_COOL) @@ -2432,13 +2432,13 @@ void sub_80AEBEC(u16 a) *(u16 *)(VRAM + 0xC82A + i * 2) = 0x5036; } - sub_8003460(&gUnknown_03004210, gContestEffectStrings[gContestMoves[a].effect], 868, 11, 35); - sub_8003460(&gUnknown_03004210, gUnknown_083CC5A2, 866, 16, 31); + Text_InitWindowAndPrintText(&gUnknown_03004210, gContestEffectStrings[gContestMoves[a].effect], 868, 11, 35); + Text_InitWindowAndPrintText(&gUnknown_03004210, gUnknown_083CC5A2, 866, 16, 31); } void sub_80AED58(void) { - FillWindowRect_DefaultPalette(&gUnknown_03004210, 0, 11, 35, 28, 40); + Text_FillWindowRectDefPalette(&gUnknown_03004210, 0, 11, 35, 28, 40); } // unused @@ -2614,7 +2614,7 @@ void sub_80AF120(void) void sub_80AF138(void) { - FillWindowRect_DefaultPalette(&gUnknown_03004210, 0, 1, 15, 17, 18); + Text_FillWindowRectDefPalette(&gUnknown_03004210, 0, 1, 15, 17, 18); } u16 GetChosenMove(u8 a) @@ -2656,7 +2656,7 @@ void sub_80AF1E4(u8 a, u8 b) else sub_80AE598(gDisplayedStringBattle, gMoveNames[sContestantStatus[a].currMove], r3); sub_80AF2A0(a); - sub_8003460( + Text_InitWindowAndPrintText( &gUnknown_03004210, gDisplayedStringBattle, 696 + a * 20, @@ -2674,7 +2674,7 @@ void unref_sub_80AF280(u8 a) void sub_80AF2A0(u8 a) { - FillWindowRect_DefaultPalette( + Text_FillWindowRectDefPalette( &gUnknown_03004210, 0, gUnknown_083CA318[a][0], @@ -2953,7 +2953,7 @@ void sub_80AF860(void) gBattle_BG0_Y = 0; gBattle_BG2_Y = 0; sub_80AF138(); - sub_8003460(&gMenuWindow, gUnknownText_LinkStandbyAndWinner, 776, 1, 15); + Text_InitWindowAndPrintText(&gMenuWindow, gUnknownText_LinkStandbyAndWinner, 776, 1, 15); } u8 unref_sub_80AF89C(s16 a, s16 b, u8 c, u8 d) @@ -4146,7 +4146,7 @@ void unref_sub_80B0CF4(void) for (i = 0; i < 4; i++) { - FillWindowRect_DefaultPalette( + Text_FillWindowRectDefPalette( &gUnknown_03004210, 0, gUnknown_083CA308[i][0], @@ -4175,7 +4175,7 @@ void sub_80B0D7C(void) for (i = 0; i < 4; i++) { - FillWindowRect_DefaultPalette( + Text_FillWindowRectDefPalette( &gUnknown_03004210, 0, gUnknown_083CA308[i][0], @@ -4193,7 +4193,7 @@ void sub_80B0D7C(void) r5++; } ConvertIntToDecimalStringN(sp8 + r5, r2, 0, 4); - sub_8003460( + Text_InitWindowAndPrintText( &gUnknown_03004210, sp8, 592 + gUnknown_02038696[i] * 22, @@ -4211,7 +4211,7 @@ void sub_80B0D7C(void) r5++; } ConvertIntToDecimalStringN(sp8 + r5, r2, 0, 4); - sub_8003460( + Text_InitWindowAndPrintText( &gUnknown_03004210, sp8, 512 + gUnknown_02038696[i] * 20, @@ -4484,7 +4484,7 @@ void sub_80B146C(u8 a, u8 b) StringCopy(gStringVar3, gText_Contest_Fear); StringExpandPlaceholders(gStringVar4, gUnknown_083CC188[b]); sub_80AF138(); - sub_8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); + Text_InitWindow8002EB0(&gMenuWindow, gStringVar4, 776, 1, 15); } void sub_80B157C(u8 p) @@ -4631,7 +4631,7 @@ void unref_sub_80B19D0(void) { u8 str[20]; StringCopy(str, gUnknown_083CC2EC); - sub_8003460(&gUnknown_03004210, str, 680, 0, 0); + Text_InitWindowAndPrintText(&gUnknown_03004210, str, 680, 0, 0); } s8 Contest_GetMoveExcitement(u16 move) diff --git a/src/crt0.s b/src/crt0.s new file mode 100644 index 000000000..049392be9 --- /dev/null +++ b/src/crt0.s @@ -0,0 +1,227 @@ + .include "constants/gba_constants.inc" + .include "constants/misc_constants.inc" + .include "constants/version.inc" + + .syntax unified + + .global Start + + .text + + .arm + +Start: @ 8000000 + b Init + + .include "asm/rom_header.inc" + +@ 80000C0 + .word 0 + + .global GPIOPortData +GPIOPortData: @ 80000C4 + .hword 0 + + .global GPIOPortDirection +GPIOPortDirection: @ 80000C6 + .hword 0 + + .global GPIOPortReadEnable +GPIOPortReadEnable: @ 80000C8 + .hword 0 + + .space 6 + +@ 80000D0 + +@ TODO: figure out what this data is + + .ifdef GERMAN + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte 0xFFFFFFFF + .4byte GAME_VERSION + .4byte GAME_LANGUAGE + .ifdef SAPPHIRE + .ascii "pokemon sapphire version" + .space 8 + .else + .ascii "pokemon ruby version" + .space 12 + .endif + .4byte gMonFrontPicTable + .4byte gMonBackPicTable + .4byte gMonPaletteTable + .4byte gMonShinyPaletteTable + .4byte gMonIconTable + .4byte gMonIconPaletteIndices + .4byte gMonIconPaletteTable + .4byte gSpeciesNames + .4byte gMoveNames + .4byte gDecorations + .4byte 0x1220 + .4byte 0x1340 + .4byte 0x18 + .4byte 0x938 + .4byte 0x3A8C + .4byte 0x46 + .4byte 0x836 + .4byte 0x84C + .4byte 0x182 + .4byte 0xA0A0A07 + .4byte 0xC060C0C + .4byte 0xC121006 + .4byte 0x8010B0F + .4byte 0xC + .4byte 0x890 + .4byte 0x3AC0 + .4byte 0x234 + .4byte 0x238 + .4byte 9 + .4byte 0xA + .4byte 0 + .4byte 8 + .4byte 0x556 + .4byte 0x557 + .4byte 0x312F + .4byte 0x311B + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0 + .4byte 0xFFFFFFFF + .endif + + .arm + .align 2, 0 + .global Init +Init: + mov r0, PSR_IRQ_MODE + msr cpsr_cf, r0 + ldr sp, sp_irq + mov r0, PSR_SYS_MODE + msr cpsr_cf, r0 + ldr sp, sp_sys + ldr r1, =INTR_VECTOR + adr r0, IntrMain + str r0, [r1] + ldr r1, =AgbMain + mov lr, pc + bx r1 + b Init + + .align 2, 0 +sp_sys: .word IWRAM_END - 0x1a0 +sp_irq: .word IWRAM_END - 0x60 + + .arm + .align 2, 0 + .global IntrMain +IntrMain: + mov r3, REG_BASE + add r3, r3, 0x200 + ldr r2, [r3, OFFSET_REG_IE - 0x200] + ldrh r1, [r3, OFFSET_REG_IME - 0x200] + mrs r0, spsr + stmdb sp!, {r0-r3,lr} + mov r0, 1 + strh r0, [r3, OFFSET_REG_IME - 0x200] + and r1, r2, r2, lsr 16 + mov r12, 0 + ands r0, r1, INTR_FLAG_SERIAL + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_TIMER3 + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_HBLANK + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_VBLANK + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_VCOUNT + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_TIMER0 + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_TIMER1 + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_TIMER2 + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_DMA0 + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_DMA1 + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_DMA2 + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_DMA3 + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_KEYPAD + bne IntrMain_FoundIntr + add r12, r12, 0x4 + ands r0, r1, INTR_FLAG_GAMEPAK + strbne r0, [r3, OFFSET_REG_SOUNDCNT_X - 0x200] +IntrMain_Loop: + bne IntrMain_Loop +IntrMain_FoundIntr: + strh r0, [r3, OFFSET_REG_IF - 0x200] + mov r1, INTR_FLAG_SERIAL | INTR_FLAG_TIMER3 | INTR_FLAG_HBLANK + bic r2, r2, r0 + and r1, r1, r2 + strh r1, [r3, OFFSET_REG_IE - 0x200] + mrs r3, cpsr + bic r3, r3, PSR_I_BIT | PSR_F_BIT | PSR_MODE_MASK + orr r3, r3, PSR_SYS_MODE + msr cpsr_cf, r3 + ldr r1, =gIntrTable + add r1, r1, r12 + ldr r0, [r1] + stmdb sp!, {lr} + adr lr, IntrMain_RetAddr + bx r0 +IntrMain_RetAddr: + ldmia sp!, {lr} + mrs r3, cpsr + bic r3, r3, PSR_I_BIT | PSR_F_BIT | PSR_MODE_MASK + orr r3, r3, PSR_I_BIT | PSR_IRQ_MODE + msr cpsr_cf, r3 + ldmia sp!, {r0-r3,lr} + strh r2, [r3, OFFSET_REG_IE - 0x200] + strh r1, [r3, OFFSET_REG_IME - 0x200] + msr spsr_cf, r0 + bx lr + + .pool + + .align 2, 0 @ Don't pad with nop. diff --git a/src/debug/matsuda_debug_menu.c b/src/debug/matsuda_debug_menu.c index 49fe6864b..1da337b04 100644 --- a/src/debug/matsuda_debug_menu.c +++ b/src/debug/matsuda_debug_menu.c @@ -14,7 +14,7 @@ #include "string_util.h" #include "task.h" #include "text.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "ewram.h" extern u8 gUnknown_0203856C; @@ -35,8 +35,8 @@ extern u16 gBattle_BG1_X; extern u16 gBattle_BG1_Y; extern u16 gBattle_BG2_X; extern u16 gBattle_BG2_Y; -extern u16 gUnknown_030041B0; -extern u16 gUnknown_030041B8; +extern u16 gBattle_BG3_X; +extern u16 gBattle_BG3_Y; extern struct Window gUnknown_03004210; extern u8 (*gCallback_03004AE8)(void); @@ -247,9 +247,9 @@ static const struct OamData gUnknown_083C9400 = u8 unref_sub_80A9B28(void) { - MenuZeroFillScreen(); - MenuDrawTextWindow(0, 0, 17, 18); - PrintMenuItems(1, 1, 7, gMatsudaDebugMenuActions); + Menu_EraseScreen(); + Menu_DrawStdWindowFrame(0, 0, 17, 18); + Menu_PrintItems(1, 1, 7, gMatsudaDebugMenuActions); InitMenu(0, 1, 1, 7, 0, 16); gCallback_03004AE8 = sub_80A9B78; return 0; @@ -257,7 +257,7 @@ u8 unref_sub_80A9B28(void) static bool8 sub_80A9B78(void) { - s8 choice = ProcessMenuInput(); + s8 choice = Menu_ProcessInput(); switch (choice) { @@ -449,8 +449,8 @@ static void sub_80A9F50(void) { REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP; REG_DISPCNT |= DISPCNT_OBJ_ON | DISPCNT_BG0_ON; - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitWindowFromConfig(&gMenuWindow, &gWindowConfig_81E6C3C); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + Text_InitWindowWithTemplate(&gMenuWindow, &gWindowTemplate_81E6C3C); REG_MOSAIC = 0; REG_BLDCNT = 0; REG_BLDALPHA = 0; @@ -463,8 +463,8 @@ static void sub_80A9F50(void) gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 0; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; } static void sub_80A9FE4(void) @@ -490,7 +490,7 @@ static void sub_80A9FE4(void) } } sub_80034D4((void *)VRAM, ptr); - LoadFontDefaultPalette(&gWindowConfig_81E6C3C); + LoadFontDefaultPalette(&gWindowTemplate_81E6C3C); } static void sub_80AA064(void) @@ -511,12 +511,12 @@ static void sub_80AA090(void) REG_BG1VOFS = gBattle_BG1_Y; REG_BG2HOFS = gBattle_BG2_X; REG_BG2VOFS = gBattle_BG2_Y; - REG_BG3HOFS = gUnknown_030041B0; - REG_BG3VOFS = gUnknown_030041B8; + REG_BG3HOFS = gBattle_BG3_X; + REG_BG3VOFS = gBattle_BG3_Y; LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); } static void sub_80AA10C(void) @@ -528,7 +528,7 @@ static void sub_80AA10C(void) gPaletteFade.bufferTransferDisabled = 1; SetVBlankCallback(0); sub_80A9F50(); - dp12_8087EA4(); + ScanlineEffect_Clear(); ResetPaletteFade(); ResetSpriteData(); ResetTasks(); @@ -546,7 +546,7 @@ static void sub_80AA10C(void) for (i = 0; i < 6; i++) { - sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList1[i], + Text_InitWindowAndPrintText(&gMenuWindow, gMatsudaDebugMenuTextList1[i], (0xA * i + 0x2A), gMatsudaDebugMenuContestTopLeft[i][0], gMatsudaDebugMenuContestTopLeft[i][1]); } @@ -555,8 +555,8 @@ static void sub_80AA10C(void) zero = 0; // it's possible this was some assignment that matsuda used to quickly edit and test things without changing whats passed to the later functions. sub_80AA5BC(zero); sub_80AA5E8(gSpecialVar_ContestRank); - sub_8003460(&gMenuWindow, gMatsudaDebugMenu_GoBackText, 0xD6, 0x12, 0x12); - sub_8003460(&gMenuWindow, gMatsudaDebugMenu_BattlePointsText, 0xDC, zero, 0xC); + Text_InitWindowAndPrintText(&gMenuWindow, gMatsudaDebugMenu_GoBackText, 0xD6, 0x12, 0x12); + Text_InitWindowAndPrintText(&gMenuWindow, gMatsudaDebugMenu_BattlePointsText, 0xDC, zero, 0xC); LoadSpriteSheet(gUnknown_083C92B4); LoadSpritePalette(gUnknown_083C92BC); sub_80AA280(3); @@ -573,71 +573,71 @@ void sub_80AA280(u8 var) // no? { u8 i; - FillWindowRect_DefaultPalette(&gMenuWindow, 0, 0, 0, 0x1E, 3); + Text_FillWindowRectDefPalette(&gMenuWindow, 0, 0, 0, 0x1E, 3); StringCopy(gSharedMem, gMatsudaDebugMenu_StartText); StringAppend(gSharedMem, gContestMons[var].trainerName); for (i = 0; i < 4; i++) { if (var == i) - sub_8003460(&gMenuWindow, gSharedMem, 10 * i + 2, gUnknown_083C926E[i][0], gUnknown_083C926E[i][1]); + Text_InitWindowAndPrintText(&gMenuWindow, gSharedMem, 10 * i + 2, gUnknown_083C926E[i][0], gUnknown_083C926E[i][1]); else - sub_8003460(&gMenuWindow, gContestMons[i].trainerName, 10 * i + 2, gUnknown_083C926E[i][0], gUnknown_083C926E[i][1]); + Text_InitWindowAndPrintText(&gMenuWindow, gContestMons[i].trainerName, 10 * i + 2, gUnknown_083C926E[i][0], gUnknown_083C926E[i][1]); } } static void sub_80AA340(u8 var) { ConvertIntToDecimalStringN(gSharedMem, gContestMons[var].cool, STR_CONV_MODE_RIGHT_ALIGN, 3); - sub_8003460(&gMenuWindow, gSharedMem, 0x66, gUnknown_083C9282[0], gUnknown_083C9282[1]); + Text_InitWindowAndPrintText(&gMenuWindow, gSharedMem, 0x66, gUnknown_083C9282[0], gUnknown_083C9282[1]); } static void sub_80AA388(u8 var) { ConvertIntToDecimalStringN(gSharedMem, gContestMons[var].cute, STR_CONV_MODE_RIGHT_ALIGN, 3); - sub_8003460(&gMenuWindow, gSharedMem, 0x6C, gUnknown_083C9282[2], gUnknown_083C9282[3]); + Text_InitWindowAndPrintText(&gMenuWindow, gSharedMem, 0x6C, gUnknown_083C9282[2], gUnknown_083C9282[3]); } static void sub_80AA3D0(u8 var) { ConvertIntToDecimalStringN(gSharedMem, gContestMons[var].beauty, STR_CONV_MODE_RIGHT_ALIGN, 3); - sub_8003460(&gMenuWindow, gSharedMem, 0x72, gUnknown_083C9282[4], gUnknown_083C9282[5]); + Text_InitWindowAndPrintText(&gMenuWindow, gSharedMem, 0x72, gUnknown_083C9282[4], gUnknown_083C9282[5]); } static void sub_80AA418(u8 var) { ConvertIntToDecimalStringN(gSharedMem, gContestMons[var].smart, STR_CONV_MODE_RIGHT_ALIGN, 3); - sub_8003460(&gMenuWindow, gSharedMem, 0x78, gUnknown_083C9282[6], gUnknown_083C9282[7]); + Text_InitWindowAndPrintText(&gMenuWindow, gSharedMem, 0x78, gUnknown_083C9282[6], gUnknown_083C9282[7]); } static void sub_80AA460(u8 var) { ConvertIntToDecimalStringN(gSharedMem, gContestMons[var].tough, STR_CONV_MODE_RIGHT_ALIGN, 3); - sub_8003460(&gMenuWindow, gSharedMem, 0x7E, gUnknown_083C9282[8], gUnknown_083C9282[9]); + Text_InitWindowAndPrintText(&gMenuWindow, gSharedMem, 0x7E, gUnknown_083C9282[8], gUnknown_083C9282[9]); } static void sub_80AA4A8(u8 var) { ConvertIntToDecimalStringN(gSharedMem, gContestMons[var].sheen, STR_CONV_MODE_RIGHT_ALIGN, 3); - sub_8003460(&gMenuWindow, gSharedMem, 0x84, gUnknown_083C9282[10], gUnknown_083C9282[11]); + Text_InitWindowAndPrintText(&gMenuWindow, gSharedMem, 0x84, gUnknown_083C9282[10], gUnknown_083C9282[11]); } static void sub_80AA4F0(u8 var1, u8 var2) { - FillWindowRect_DefaultPalette(&gMenuWindow, 0, gUnknown_083C928E[var2][0], gUnknown_083C928E[var2][1], gUnknown_083C928E[var2][0] + 7, gUnknown_083C928E[var2][1] + 1); - sub_8003460(&gMenuWindow, gMoveNames[gContestMons[var1].moves[var2]], 0x8A + var2 * 14, gUnknown_083C928E[var2][0], gUnknown_083C928E[var2][1]); + Text_FillWindowRectDefPalette(&gMenuWindow, 0, gUnknown_083C928E[var2][0], gUnknown_083C928E[var2][1], gUnknown_083C928E[var2][0] + 7, gUnknown_083C928E[var2][1] + 1); + Text_InitWindowAndPrintText(&gMenuWindow, gMoveNames[gContestMons[var1].moves[var2]], 0x8A + var2 * 14, gUnknown_083C928E[var2][0], gUnknown_083C928E[var2][1]); ConvertIntToDecimalStringN(gStringVar1, gContestMons[var1].moves[var2], STR_CONV_MODE_LEADING_ZEROS, 3); - sub_8003460(&gMenuWindow, gStringVar1, 0xFA + var2 * 6, gUnknown_083C928E[var2][0] + 7, gUnknown_083C928E[var2][1]); + Text_InitWindowAndPrintText(&gMenuWindow, gStringVar1, 0xFA + var2 * 6, gUnknown_083C928E[var2][0] + 7, gUnknown_083C928E[var2][1]); } static void sub_80AA5BC(u8 var) { - sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList2[var], 0xC2, 3, 0x12); + Text_InitWindowAndPrintText(&gMenuWindow, gMatsudaDebugMenuTextList2[var], 0xC2, 3, 0x12); } void sub_80AA5E8(u8 var) { - sub_8003460(&gMenuWindow, gMatsudaDebugMenuTextList3[var], 0xE8, 3, 4); + Text_InitWindowAndPrintText(&gMenuWindow, gMatsudaDebugMenuTextList3[var], 0xE8, 3, 4); } static void sub_80AA614(u8 var1, u8 var2) @@ -645,7 +645,7 @@ static void sub_80AA614(u8 var1, u8 var2) u16 var = sub_80AE770(var1, var2); ConvertIntToDecimalStringN(gSharedMem, var, STR_CONV_MODE_RIGHT_ALIGN, 3); - sub_8003460(&gMenuWindow, gSharedMem, 0xE2, 3, 0xC); + Text_InitWindowAndPrintText(&gMenuWindow, gSharedMem, 0xE2, 3, 0xC); } void sub_80AA658(u8 var) @@ -1075,10 +1075,10 @@ void unref_sub_80AB084(u8 *text) break; } } - SetUpWindowConfig(&gWindowConfig_81E6FD8); - InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6FD8); - LoadFontDefaultPalette(&gWindowConfig_81E6FD8); - sub_8003460(&gUnknown_03004210, text, 1, 9, 7); + Text_LoadWindowTemplate(&gWindowTemplate_81E6FD8); + Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6FD8); + LoadFontDefaultPalette(&gWindowTemplate_81E6FD8); + Text_InitWindowAndPrintText(&gUnknown_03004210, text, 1, 9, 7); } void sub_80AB184(void) diff --git a/src/debug/mori_debug_menu.c b/src/debug/mori_debug_menu.c index 83dba8b73..7b9a579a7 100644 --- a/src/debug/mori_debug_menu.c +++ b/src/debug/mori_debug_menu.c @@ -95,9 +95,9 @@ u8 MoriDebugMenu_SearchChild(u8 a1, u8 a2, u8 *ptr) StringAppend(localPtr, gUnknown_0839B24D); StringAppend(localPtr, gSpeciesNames[eggSpecies]); StringAppend(localPtr, gUnknown_0839B255); - MenuZeroFillScreen(); - MenuDrawTextWindow(0, 14, 30, 19); - MenuPrint(localPtr, 1, 15); + Menu_EraseScreen(); + Menu_DrawStdWindowFrame(0, 14, 30, 19); + Menu_PrintText(localPtr, 1, 15); gCallback_03004AE8 = sub_8083D4C; return 0; } @@ -179,7 +179,7 @@ u8 MoriDebugMenu_PokeblockCase(void) bool8 MoriDebugMenuProcessInput(void) { - s8 choice = ProcessMenuInput(); + s8 choice = Menu_ProcessInput(); switch (choice) { @@ -196,9 +196,9 @@ bool8 MoriDebugMenuProcessInput(void) s8 InitMoriDebugMenu(void) { - MenuZeroFillScreen(); - MenuDrawTextWindow(0, 0, 10, 19); - PrintMenuItems(1, 1, 9, gMoriDebugMenuActions); + Menu_EraseScreen(); + Menu_DrawStdWindowFrame(0, 0, 10, 19); + Menu_PrintItems(1, 1, 9, gMoriDebugMenuActions); InitMenu(0, 1, 1, 9, 0, 9); gCallback_03004AE8 = MoriDebugMenuProcessInput; return 0; diff --git a/src/debug/sound_check_menu.c b/src/debug/sound_check_menu.c index 968b047d9..05cbfc8f7 100644 --- a/src/debug/sound_check_menu.c +++ b/src/debug/sound_check_menu.c @@ -132,8 +132,8 @@ void CB2_StartSoundCheckMenu(void) ResetPaletteFade(); ResetTasks(); ResetSpriteData(); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); REG_WIN0H = WIN_RANGE(0, 0); REG_WIN0V = WIN_RANGE(0, 0); @@ -171,16 +171,16 @@ void Task_InitSoundCheckMenu(u8 taskId) if (!gPaletteFade.active) { - MenuDrawTextWindow(2, 0, 27, 3); - MenuDrawTextWindow(2, 5, 27, 10); - MenuDrawTextWindow(2, 12, 27, 17); - MenuPrint(soundcheckStr, 4, 1); - MenuPrint(abDescStr, 14, 1); - MenuPrint(bgmStr, 4, 6); - MenuPrint(upDownStr, 14, 6); - MenuPrint(seStr, 4, 13); - MenuPrint(upDownStr, 14, 13); - MenuPrint(driverStr, 14, 18); + Menu_DrawStdWindowFrame(2, 0, 27, 3); + Menu_DrawStdWindowFrame(2, 5, 27, 10); + Menu_DrawStdWindowFrame(2, 12, 27, 17); + Menu_PrintText(soundcheckStr, 4, 1); + Menu_PrintText(abDescStr, 14, 1); + Menu_PrintText(bgmStr, 4, 6); + Menu_PrintText(upDownStr, 14, 6); + Menu_PrintText(seStr, 4, 13); + Menu_PrintText(upDownStr, 14, 13); + Menu_PrintText(driverStr, 14, 18); gTasks[taskId].func = sub_80BA384; REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(1, 31); @@ -384,7 +384,7 @@ void PrintSoundNumber(u16 soundIndex, u16 x, u16 y) // PrintSoundNumber ? str[1] = divisorValue + CHAR_0; str[2] = ((soundIndex % 100) % 10) + CHAR_0; - MenuPrint(str, x, y); + Menu_PrintText(str, x, y); } void sub_80BA79C(const u8 *const string, u16 x, u16 y) @@ -400,7 +400,7 @@ void sub_80BA79C(const u8 *const string, u16 x, u16 y) for (i = 0; string[i] != EOS && i < 10; i++) str[i] = string[i]; - MenuPrint(str, x, y); + Menu_PrintText(str, x, y); } void Task_DrawDriverTestMenu(u8 taskId) // Task_DrawDriverTestMenu @@ -421,21 +421,21 @@ void Task_DrawDriverTestMenu(u8 taskId) // Task_DrawDriverTestMenu u8 stereoStr[] = _("すてれお‥‥‥‥"); // stereo REG_DISPCNT = 0x3140; - MenuDrawTextWindow(0, 0, 29, 19); - MenuPrint(bbackStr, 19, 4); - MenuPrint(aplayStr, 19, 2); - MenuPrint(voiceStr, 2, 1); - MenuPrint(volumeStr, 2, 3); - MenuPrint(panpotStr, 2, 5); - MenuPrint(pitchStr, 2, 7); - MenuPrint(lengthStr, 2, 9); - MenuPrint(releaseStr, 2, 11); - MenuPrint(progressStr, 2, 13); - MenuPrint(chorusStr, 2, 15); - MenuPrint(priorityStr, 2, 17); - MenuPrint(playingStr, 19, 16); - MenuPrint(reverseStr, 19, 14); - MenuPrint(stereoStr, 19, 12); + Menu_DrawStdWindowFrame(0, 0, 29, 19); + Menu_PrintText(bbackStr, 19, 4); + Menu_PrintText(aplayStr, 19, 2); + Menu_PrintText(voiceStr, 2, 1); + Menu_PrintText(volumeStr, 2, 3); + Menu_PrintText(panpotStr, 2, 5); + Menu_PrintText(pitchStr, 2, 7); + Menu_PrintText(lengthStr, 2, 9); + Menu_PrintText(releaseStr, 2, 11); + Menu_PrintText(progressStr, 2, 13); + Menu_PrintText(chorusStr, 2, 15); + Menu_PrintText(priorityStr, 2, 17); + Menu_PrintText(playingStr, 19, 16); + Menu_PrintText(reverseStr, 19, 14); + Menu_PrintText(stereoStr, 19, 12); REG_WIN0H = WIN_RANGE(0, DISPLAY_WIDTH); REG_WIN0V = WIN_RANGE(0, DISPLAY_HEIGHT); sDriverTestSelection = 0; @@ -465,7 +465,7 @@ void Task_ProcessDriverTestInput(u8 taskId) REG_DISPCNT = 0x7140; REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(1, 31); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); gTasks[taskId].func = Task_InitSoundCheckMenu; return; } @@ -627,8 +627,8 @@ void sub_80BAE10(u8 var1, u8 var2) u8 str1[] = _("▶"); u8 str2[] = _(" "); - MenuPrint(str2, gUnknown_083D0300[MULTI_DIM_ARR(var1, B_16, 0)], gUnknown_083D0300[MULTI_DIM_ARR(var1, B_16, 1)]); - MenuPrint(str1, gUnknown_083D0300[MULTI_DIM_ARR(var2, B_16, 0)], gUnknown_083D0300[MULTI_DIM_ARR(var2, B_16, 1)]); + Menu_PrintText(str2, gUnknown_083D0300[MULTI_DIM_ARR(var1, B_16, 0)], gUnknown_083D0300[MULTI_DIM_ARR(var1, B_16, 1)]); + Menu_PrintText(str1, gUnknown_083D0300[MULTI_DIM_ARR(var2, B_16, 0)], gUnknown_083D0300[MULTI_DIM_ARR(var2, B_16, 1)]); } void PrintSignedNumber(int n, u16 x, u16 y, u8 digits) @@ -677,7 +677,7 @@ void PrintSignedNumber(int n, u16 x, u16 y, u8 digits) n %= powersOfTen[i]; } - MenuPrint(str, x, y); + Menu_PrintText(str, x, y); } static const s8 gUnknown_083D03F8[5] = { 0x3F, 0x00, 0xC0, 0x7F, 0x80 }; @@ -689,10 +689,10 @@ void sub_80BAF84(u8 taskId) u8 playingStr[] = _("さいせいちゆう‥"); REG_DISPCNT = 0x3140; - MenuDrawTextWindow(0, 0, 29, 19); - MenuPrint(seStr, 3, 2); - MenuPrint(panStr, 3, 4); - MenuPrint(playingStr, 3, 8); + Menu_DrawStdWindowFrame(0, 0, 29, 19); + Menu_PrintText(seStr, 3, 2); + Menu_PrintText(panStr, 3, 4); + Menu_PrintText(playingStr, 3, 8); REG_WIN0H = WIN_RANGE(0, DISPLAY_WIDTH); REG_WIN0V = WIN_RANGE(0, DISPLAY_HEIGHT); sSoundTestParams[CRY_TEST_VOICE] = 1; @@ -739,7 +739,7 @@ void sub_80BB038(u8 taskId) REG_DISPCNT = 0x7140; REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(1, 31); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); gTasks[taskId].func = Task_InitSoundCheckMenu; return; } @@ -806,10 +806,10 @@ void sub_80BB1D4(void) switch (gUnknown_083D03F8[sSoundTestParams[CRY_TEST_PANPOT]]) { case 127: - MenuPrint(lrStr, 7, 4); + Menu_PrintText(lrStr, 7, 4); break; case -128: - MenuPrint(rlStr, 7, 4); + Menu_PrintText(rlStr, 7, 4); break; default: PrintSignedNumber(gUnknown_083D03F8[sSoundTestParams[CRY_TEST_PANPOT]], 7, 4, 3); @@ -1217,8 +1217,8 @@ void Task_InitCryTest(u8 taskId) struct CryRelatedStruct cryStruct, cryStruct2; u8 zero; - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); gSoundTestCryNum = 1; ResetSpriteData(); FreeAllSpritePalettes(); @@ -1247,7 +1247,7 @@ void Task_InitCryTest(u8 taskId) while (ShowPokedexCryScreen(&cryStruct2, 2) == FALSE) ; - MenuDrawTextWindow(0, 16, 5, 19); + Menu_DrawStdWindowFrame(0, 16, 5, 19); PrintCryNumber(); BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); REG_BG2HOFS = 0; @@ -1288,7 +1288,7 @@ void Task_ProcessCryTestInput(u8 taskId) REG_DISPCNT = 0x7140; REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(1, 31); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); gTasks[taskId].func = Task_InitSoundCheckMenu; DestroyCryMeterNeedleSprite(); } diff --git a/src/debug/unknown_debug_menu.c b/src/debug/unknown_debug_menu.c index a8c3ad16b..9cece924d 100644 --- a/src/debug/unknown_debug_menu.c +++ b/src/debug/unknown_debug_menu.c @@ -32,9 +32,9 @@ const struct MenuAction gUnknown_0842C29C[] = { int unref_sub_814A414(void) { - MenuZeroFillScreen(); - MenuDrawTextWindow(0, 0, 16, 18); - PrintMenuItems(2, 1, 8, gUnknown_0842C29C); + Menu_EraseScreen(); + Menu_DrawStdWindowFrame(0, 0, 16, 18); + Menu_PrintItems(2, 1, 8, gUnknown_0842C29C); InitMenu(0, 1, 1, 8, 0, 15); gCallback_03004AE8 = sub_814A464; return 0; @@ -42,7 +42,7 @@ int unref_sub_814A414(void) static u8 sub_814A464(void) { - s8 result = ProcessMenuInput(); + s8 result = Menu_ProcessInput(); if (result == -2) { return 0; diff --git a/src/easy_chat_1.c b/src/easy_chat_1.c index e5b6cf7c3..4b64846f9 100644 --- a/src/easy_chat_1.c +++ b/src/easy_chat_1.c @@ -14,10 +14,10 @@ #include "sprite.h" #include "string_util.h" #include "strings.h" -#include "unknown_task.h" +#include "scanline_effect.h" -extern const struct WindowConfig gWindowConfig_81E6D54; -extern const struct WindowConfig gWindowConfig_81E6DA8; +extern const struct WindowTemplate gWindowTemplate_81E6D54; +extern const struct WindowTemplate gWindowTemplate_81E6DA8; extern void sub_80546B8(void); @@ -43,7 +43,7 @@ const u16 gBerryMasterWifePhrases[][2] = // const pointer to gEasyChatStruct-> easy_chat might be two separate files. struct Shared1000 *const gEasyChatStruct = (struct Shared1000 *)(gSharedMem + 0x1000); -const struct UnknownTaskStruct gUnknown_083DB698 = +const struct ScanlineEffectParams gUnknown_083DB698 = { ®_BG3VOFS, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, @@ -297,20 +297,20 @@ void sub_80E62F8(void) SetVBlankCallback(0); ResetPaletteFade(); ResetSpriteData(); - dp12_8087EA4(); - remove_some_task(); + ScanlineEffect_Clear(); + ScanlineEffect_Stop(); sub_80EAD08(); - sub_80895F8(gUnknown_083DB698); + ScanlineEffect_SetParams(gUnknown_083DB698); FreeSpriteTileRanges(); FreeAllSpritePalettes(); break; case 1: - SetUpWindowConfig(&gWindowConfig_81E6DA8); + Text_LoadWindowTemplate(&gWindowTemplate_81E6DA8); break; case 2: - InitMenuWindow(&gWindowConfig_81E6D54); - InitMenuWindow(&gWindowConfig_81E6DA8); - MenuZeroFillScreen(); + InitMenuWindow(&gWindowTemplate_81E6D54); + InitMenuWindow(&gWindowTemplate_81E6DA8); + Menu_EraseScreen(); break; case 3: sub_80E6424(); @@ -655,7 +655,7 @@ void sub_80E6A6C(void) ProcessSpriteCopyRequests(); sub_80EAC5C(); TransferPlttBuffer(); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); } void sub_80E6A88(void) @@ -732,12 +732,12 @@ void sub_80E6BC0(void) { sub_80E91D4(2); DisplayYesNoMenu(23, 8, 1); - MoveMenuCursor(1); + Menu_MoveCursor(1); gEasyChatStruct->unk24++; } break; case 1: - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: sub_80E7D6C(); @@ -770,7 +770,7 @@ void sub_80E6C84(void) sub_80E8398(2); sub_80E91D4(3); DisplayYesNoMenu(23, 8, 0); - MoveMenuCursor(1); + Menu_MoveCursor(1); if (gEasyChatStruct->unk8 == 9 || gEasyChatStruct->unk8 == 4 || gEasyChatStruct->unk8 == 7 @@ -785,12 +785,12 @@ void sub_80E6C84(void) gEasyChatStruct->unk24++; break; case 1: - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: sub_80E91D4(4); DisplayYesNoMenu(23, 8, 0); - MoveMenuCursor(1); + Menu_MoveCursor(1); gEasyChatStruct->unk24++; break; case -1: @@ -800,7 +800,7 @@ void sub_80E6C84(void) } break; case 2: - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: gSpecialVar_Result = 0; @@ -813,7 +813,7 @@ void sub_80E6C84(void) } break; case 0xFF: - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); sub_80E81FC(); sub_80E682C(sub_80E6AC4); break; @@ -856,12 +856,12 @@ void sub_80E6D7C(void) sub_80E91D4(1); sub_80E9744(); DisplayYesNoMenu(23, 8, 0); - MoveMenuCursor(0); + Menu_MoveCursor(0); gEasyChatStruct->unk24++; } break; case 1: - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: gSpecialVar_Result = (sub_80E7FA8() != 0); @@ -883,7 +883,7 @@ void sub_80E6D7C(void) break; case -1: case 1: - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); sub_80E81FC(); if (gEasyChatStruct->unk8 == 6 && sub_80E7FA8() != 0) { @@ -1738,5 +1738,5 @@ void sub_80E81FC(void) { PlaySE(SE_SELECT); sub_80E95A4(); - MenuZeroFillWindowRect(0, 0, 29, 13); + Menu_EraseWindowRect(0, 0, 29, 13); } diff --git a/src/easy_chat_2.c b/src/easy_chat_2.c index fe3aa7cc9..dc8bddd5a 100644 --- a/src/easy_chat_2.c +++ b/src/easy_chat_2.c @@ -17,7 +17,7 @@ #include "strings.h" #include "strings2.h" #include "trig.h" -#include "unknown_task.h" +#include "scanline_effect.h" extern void sub_8095C8C(); extern void sub_809D104(void *, u16, u16, const void *, u16, u16, u16, u16); @@ -1064,17 +1064,17 @@ void sub_80E91B0(const u8 *a, u8 b, u8 c, u8 d) void sub_80E91D4(u8 a) { - BasicInitMenuWindow(&gWindowConfig_81E6DA8); + BasicInitMenuWindow(&gWindowTemplate_81E6DA8); if (a == 10) { - MenuZeroFillWindowRect(3, 14, 26, 19); + Menu_EraseWindowRect(3, 14, 26, 19); sub_80E9198(10); return; } if (sub_80E91A4() == 10) - MenuDrawTextWindow(3, 14, 26, 19); + Menu_DrawStdWindowFrame(3, 14, 26, 19); sub_80E9198(a); switch (a) @@ -1168,14 +1168,14 @@ void sub_80E9368(u8 a) break; } - BasicInitMenuWindow(&gWindowConfig_81E6D8C); + BasicInitMenuWindow(&gWindowTemplate_81E6D8C); gEasyChatStruct->unk9F8E[0] = EXT_CTRL_CODE_BEGIN; gEasyChatStruct->unk9F8E[1] = 5; gEasyChatStruct->unk9F8E[2] = 1; if (r4 != NULL) { sub_8072C74(gEasyChatStruct->unk9F8E + 3, r4, 240, 2); - MenuPrint(gEasyChatStruct->unk9F8E, 0, 0); + Menu_PrintText(gEasyChatStruct->unk9F8E, 0, 0); } else { @@ -1186,10 +1186,10 @@ void sub_80E9368(u8 a) str[2] = 0x10; str[3] = EOS; - MenuPrint(gEasyChatStruct->unk9F8E, 0, 0); - MenuPrint(gEasyChatStruct->unk9F8E, 28, 0); + Menu_PrintText(gEasyChatStruct->unk9F8E, 0, 0); + Menu_PrintText(gEasyChatStruct->unk9F8E, 28, 0); } - BasicInitMenuWindow(&gWindowConfig_81E6DA8); + BasicInitMenuWindow(&gWindowTemplate_81E6DA8); } void sub_80E948C(void) @@ -1219,7 +1219,7 @@ void sub_80E948C(void) void sub_80E95A4(void) { - BasicInitMenuWindow(&gWindowConfig_81E6D8C); + BasicInitMenuWindow(&gWindowTemplate_81E6D8C); switch (gEasyChatStruct->unk9) { case 4: @@ -1241,7 +1241,7 @@ void sub_80E95A4(void) sub_80E9620(3, 6); break; } - BasicInitMenuWindow(&gWindowConfig_81E6DA8); + BasicInitMenuWindow(&gWindowTemplate_81E6DA8); } void sub_80E9620(u16 a, u16 b) @@ -1259,7 +1259,7 @@ void sub_80E9620(u16 a, u16 b) { if (r10 >= gEasyChatStruct->unkA) { - MenuPrint(gUnknown_083DBEA8, r6, r7); + Menu_PrintText(gUnknown_083DBEA8, r6, r7); break; } if (gEasyChatStruct->unkC[r10] == 0xFFFF) @@ -1270,7 +1270,7 @@ void sub_80E9620(u16 a, u16 b) else { sub_80EB218(gEasyChatStruct->unk9E14, gEasyChatStruct->unkC[r10], 11); - MenuPrint(gEasyChatStruct->unk9E14, r6, r7); + Menu_PrintText(gEasyChatStruct->unk9E14, r6, r7); r6 += gEasyChatStruct->unk8C[i][j] + 11; } r10++; @@ -1281,7 +1281,7 @@ void sub_80E9620(u16 a, u16 b) void sub_80E9744(void) { - BasicInitMenuWindow(&gWindowConfig_81E6D8C); + BasicInitMenuWindow(&gWindowTemplate_81E6D8C); switch (gEasyChatStruct->unk9) { case 4: @@ -1303,7 +1303,7 @@ void sub_80E9744(void) sub_80E97C0(3, 6); break; } - BasicInitMenuWindow(&gWindowConfig_81E6DA8); + BasicInitMenuWindow(&gWindowTemplate_81E6DA8); } void sub_80E97C0(u16 a, u16 b) @@ -1337,7 +1337,7 @@ void sub_80E97C0(u16 a, u16 b) r2[2] = r1 * 8; r2[3] = EOS; - MenuPrint(gEasyChatStruct->unk9E6E, b, a); + Menu_PrintText(gEasyChatStruct->unk9E6E, b, a); a += 2; } @@ -1348,7 +1348,7 @@ void sub_80E98C4(void) u8 r1; u8 r3; - BasicInitMenuWindow(&gWindowConfig_81E6D8C); + BasicInitMenuWindow(&gWindowTemplate_81E6D8C); switch (gEasyChatStruct->unk9) { case 4: @@ -1378,15 +1378,15 @@ void sub_80E98C4(void) default: return; } - MenuFillWindowRectWithBlankTile(2, r1, 27, r3 * 2 + r1 - 1); - BasicInitMenuWindow(&gWindowConfig_81E6DA8); + Menu_BlankWindowRect(2, r1, 27, r3 * 2 + r1 - 1); + BasicInitMenuWindow(&gWindowTemplate_81E6DA8); } void sub_80E9940(u8 *a, u8 b) { u8 r4 = (b & 7); - MenuFillWindowRectWithBlankTile(2, r4 * 2, 31, r4 * 2 + 1); + Menu_BlankWindowRect(2, r4 * 2, 31, r4 * 2 + 1); sub_80E9A7C(a, b); sub_80E9A60(a, 2, r4 * 2); } @@ -1420,7 +1420,7 @@ const u8 *const gUnknown_083DBEAC[] = void sub_80E9974(void) { - BasicInitMenuWindow(&gWindowConfig_81E6D54); + BasicInitMenuWindow(&gWindowTemplate_81E6D54); if (gEasyChatStruct->unk26 == 0) { u16 i; @@ -1453,7 +1453,7 @@ void sub_80E9A4C(void) void sub_80E9A60(const u8 *a, u16 b, u16 c) { c &= 0xF; - MenuPrint(a, b, c); + Menu_PrintText(a, b, c); } void sub_80E9A7C(u8 *dest, u16 b) @@ -1479,7 +1479,7 @@ void sub_80E9AD4(void) { u16 i; - BasicInitMenuWindow(&gWindowConfig_81E6D54); + BasicInitMenuWindow(&gWindowTemplate_81E6D54); for (i = 0; i < 16; i++) sub_80E9C74(i); } @@ -1502,16 +1502,16 @@ void sub_80E9AF8(u16 a) for (i = 0; i < gEasyChatStruct->unk99A6[a]; i++) { if (sub_80EB2D4(gEasyChatStruct->unk9A2A[a][i]) == 7) - BasicInitMenuWindow(&gWindowConfig_81E6D70); + BasicInitMenuWindow(&gWindowTemplate_81E6D70); else - BasicInitMenuWindow(&gWindowConfig_81E6D54); + BasicInitMenuWindow(&gWindowTemplate_81E6D54); sub_80EB218(r8, gEasyChatStruct->unk9A2A[a][i], 9); sub_80E9A60(gEasyChatStruct->unk9E14, i * 11 + 4, a * 2); } } else { - BasicInitMenuWindow(&gWindowConfig_81E6D54); + BasicInitMenuWindow(&gWindowTemplate_81E6D54); for (i = 0; i < gEasyChatStruct->unk99A6[a]; i++) { sub_80EB218(r8, gEasyChatStruct->unk9A2A[a][i], 9); @@ -1523,7 +1523,7 @@ void sub_80E9AF8(u16 a) void sub_80E9C74(u16 a) { a &= 7; - MenuFillWindowRectWithBlankTile(0, a * 2, 29, a * 2 + 1); + Menu_BlankWindowRect(0, a * 2, 29, a * 2 + 1); } void sub_80E9C94(void) @@ -1562,7 +1562,7 @@ void sub_80E9D7C(void) u16 r4; u16 i; - BasicInitMenuWindow(&gWindowConfig_81E6D54); + BasicInitMenuWindow(&gWindowTemplate_81E6D54); if (gEasyChatStruct->unk1C0 < 0) { r6 = -gEasyChatStruct->unk1C0; @@ -2053,7 +2053,7 @@ void sub_80EAD08(void) u16 r2; u16 i; - r4 = gUnknown_03004DE0[gUnknown_03004DC0.srcBank]; + r4 = gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer]; r4 += 88; r2 = (gEasyChatStruct->unk1BA - 88) & 0xFF; diff --git a/src/engine/cable_club.c b/src/engine/cable_club.c index 3187de7ed..b12ee38ce 100644 --- a/src/engine/cable_club.c +++ b/src/engine/cable_club.c @@ -109,13 +109,13 @@ static void sub_8082CD4(u8 arg0, u8 arg1) static void sub_8082D18(u32 value) { ConvertIntToDecimalStringN(gStringVar1, value, STR_CONV_MODE_LEFT_ALIGN, 1); - MenuDrawTextWindow(18, 10, 28, 13); + Menu_DrawStdWindowFrame(18, 10, 28, 13); sub_8072BD8(gOtherText_PLink, 19, 11, 72); } static void sub_8082D4C() { - MenuZeroFillWindowRect(18, 10, 28, 13); + Menu_EraseWindowRect(18, 10, 28, 13); } static void sub_8082D60(u8 taskId, u8 arg1) @@ -790,7 +790,7 @@ static void sub_80839DC(u8 taskId) case 3: sub_8055588(); HideFieldMessageBox(); - MenuZeroFillScreen(); + Menu_EraseScreen(); DestroyTask(taskId); EnableBothScriptContexts(); break; diff --git a/src/engine/clear_save_data_menu.c b/src/engine/clear_save_data_menu.c index 12cde22a7..08fd5cd18 100644 --- a/src/engine/clear_save_data_menu.c +++ b/src/engine/clear_save_data_menu.c @@ -41,11 +41,11 @@ static void Task_InitMenu(u8 taskId) REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG3_ON | DISPCNT_OBJ_ON; SetVBlankCallback(VBlankCB_ClearSaveDataScreen); - MenuDrawTextWindow(2, 14, 27, 19); - MenuPrint(gSystemText_ClearAllSaveDataPrompt, 3, 15); + Menu_DrawStdWindowFrame(2, 14, 27, 19); + Menu_PrintText(gSystemText_ClearAllSaveDataPrompt, 3, 15); - MenuDrawTextWindow(2, 1, 8, 6); - PrintMenuItems(3, 2, 2, gMenuYesNoItems); + Menu_DrawStdWindowFrame(2, 1, 8, 6); + Menu_PrintItems(3, 2, 2, gMenuYesNoItems); InitMenu(0, 3, 2, 2, 1, 5); gTasks[taskId].func = Task_ProcessMenuInput; @@ -53,7 +53,7 @@ static void Task_InitMenu(u8 taskId) static void Task_ProcessMenuInput(u8 taskId) { - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: PlaySE(SE_SELECT); @@ -133,8 +133,8 @@ static u8 InitClearSaveDataScreen(void) ResetTasks(); ResetSpriteData(); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0xffff); ime = REG_IME; diff --git a/src/engine/link.c b/src/engine/link.c index 28323207c..34016d607 100644 --- a/src/engine/link.c +++ b/src/engine/link.c @@ -238,8 +238,8 @@ void LinkTestScreen(void) FreeAllSpritePalettes(); ResetTasks(); SetVBlankCallback(VBlankCB_LinkTest); - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow((struct WindowTemplate *)&gWindowTemplate_81E6CE4); ResetBlockSend(); gLinkType = 0x1111; OpenLink(); @@ -1236,9 +1236,9 @@ void CB2_LinkError(void) FillPalette(0, 0, 2); ResetTasks(); SetVBlankCallback(VBlankCB_LinkTest); - SetUpWindowConfig(&gWindowConfig_81E7198); - InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E7198); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E7198); + InitMenuWindow((struct WindowTemplate *)&gWindowTemplate_81E7198); + Menu_EraseScreen(); REG_BLDALPHA = 0; REG_BG0VOFS = 0; REG_BG0HOFS = 0; @@ -1260,7 +1260,7 @@ static void CB2_PrintErrorMessage(void) switch (gMain.state) { case 0: - MenuPrint_PixelCoords(gMultiText_LinkError, 20, 56, 1); + Menu_PrintTextPixelCoords(gMultiText_LinkError, 20, 56, 1); break; case 30: case 60: diff --git a/src/engine/main.c b/src/engine/main.c index 82a5fffb4..54a443e80 100644 --- a/src/engine/main.c +++ b/src/engine/main.c @@ -13,7 +13,7 @@ #include "rtc.h" #include "siirtc.h" #include "sound.h" -#include "unknown_task.h" +#include "scanline_effect.h" extern struct SoundInfo gSoundInfo; extern u32 IntrMain[]; @@ -83,6 +83,10 @@ static void WaitForVBlank(void); #define B_START_SELECT (B_BUTTON | START_BUTTON | SELECT_BUTTON) +#ifndef NDEBUG + #include <stdlib.h> // don't include if not needed. +#endif + void AgbMain() { RegisterRamReset(RESET_ALL); @@ -98,6 +102,14 @@ void AgbMain() gSoftResetDisabled = FALSE; +// In Fire Red, AGBPrintInit is called at this spot. For user convenience, I +// opt to initialize the print area here. It is up to the user where they choose +// to print stuff from, as anything else declared is NOT authoritative. +#ifndef NDEBUG + AGBPrintInit(); + __mb_cur_max = 1; // fix for AGBPrintf +#endif + if (gFlashMemoryPresent != TRUE) SetMainCallback2(NULL); @@ -350,7 +362,7 @@ void DoSoftReset(void) { REG_IME = 0; m4aSoundVSyncOff(); - remove_some_task(); + ScanlineEffect_Stop(); DmaStop(1); DmaStop(2); DmaStop(3); diff --git a/src/engine/main_menu.c b/src/engine/main_menu.c index 909b5676b..a0b8b7020 100644 --- a/src/engine/main_menu.c +++ b/src/engine/main_menu.c @@ -21,10 +21,10 @@ #include "task.h" #include "text.h" #include "title_screen.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "ewram.h" -#define BirchSpeechUpdateWindowText() ((u8)MenuUpdateWindowText_OverrideLineLength(24)) +#define BirchSpeechUpdateWindowText() ((u8)Menu_UpdateWindowTextOverrideLineLength(24)) extern struct PaletteFadeControl gPaletteFade; @@ -229,12 +229,12 @@ u32 InitMainMenu(u8 a1) ResetPaletteFade(); LoadPalette(gMainMenuPalette, 0, 32); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow((struct WindowTemplate *)&gWindowTemplate_81E6CE4); if (a1) BeginNormalPaletteFade(-1, 0, 0x10, 0, 0x0000); // fade to black @@ -293,7 +293,7 @@ void Task_MainMenuCheckSave(u8 taskId) gTasks[taskId].func = Task_MainMenuCheckRtc; break; case 2: - MenuDrawTextWindow(2, 14, 27, 19); + Menu_DrawStdWindowFrame(2, 14, 27, 19); MenuPrintMessage(gSaveFileDeletedMessage, 3, 15); REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(113, 159); @@ -301,7 +301,7 @@ void Task_MainMenuCheckSave(u8 taskId) gTasks[taskId].func = Task_MainMenuWaitForSaveErrorAck; break; case 255: - MenuDrawTextWindow(2, 14, 27, 19); + Menu_DrawStdWindowFrame(2, 14, 27, 19); MenuPrintMessage(gSaveFileCorruptMessage, 3, 15); REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(113, 159); @@ -319,7 +319,7 @@ void Task_MainMenuCheckSave(u8 taskId) gTasks[taskId].func = Task_MainMenuCheckRtc; break; case 4: - MenuDrawTextWindow(2, 14, 27, 19); + Menu_DrawStdWindowFrame(2, 14, 27, 19); MenuPrintMessage(gBoardNotInstalledMessage, 3, 15); REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(113, 159); @@ -331,11 +331,11 @@ void Task_MainMenuCheckSave(u8 taskId) void Task_MainMenuWaitForSaveErrorAck(u8 taskId) { - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { if (gMain.newKeys & A_BUTTON) { - MenuZeroFillWindowRect(2, 14, 27, 19); + Menu_EraseWindowRect(2, 14, 27, 19); gTasks[taskId].func = Task_MainMenuCheckRtc; } } @@ -359,7 +359,7 @@ void Task_MainMenuCheckRtc(u8 taskId) } else { - MenuDrawTextWindow(2, 14, 27, 19); + Menu_DrawStdWindowFrame(2, 14, 27, 19); MenuPrintMessage(gBatteryDryMessage, 3, 15); REG_WIN0H = WIN_RANGE(17, 223); REG_WIN0V = WIN_RANGE(113, 159); @@ -370,11 +370,11 @@ void Task_MainMenuCheckRtc(u8 taskId) void Task_MainMenuWaitForRtcErrorAck(u8 taskId) { - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { if ( gMain.newKeys & 1 ) { - MenuZeroFillWindowRect(2, 14, 27, 19); + Menu_EraseWindowRect(2, 14, 27, 19); gTasks[taskId].func = Task_MainMenuDraw; } } @@ -412,28 +412,28 @@ void Task_MainMenuDraw(u8 taskId) { case HAS_NO_SAVED_GAME: default: - MenuDrawTextWindow(1, 0, 28, 3); + Menu_DrawStdWindowFrame(1, 0, 28, 3); PrintMainMenuItem(gMainMenuString_NewGame, 2, 1); - MenuDrawTextWindow(1, 4, 28, 7); + Menu_DrawStdWindowFrame(1, 4, 28, 7); PrintMainMenuItem(gMainMenuString_Option, 2, 5); break; case HAS_SAVED_GAME: - MenuDrawTextWindow(1, 0, 28, 7); + Menu_DrawStdWindowFrame(1, 0, 28, 7); PrintMainMenuItem(gMainMenuString_Continue, 2, 1); - MenuDrawTextWindow(1, 8, 28, 11); + Menu_DrawStdWindowFrame(1, 8, 28, 11); PrintMainMenuItem(gMainMenuString_NewGame, 2, 9); - MenuDrawTextWindow(1, 12, 28, 15); + Menu_DrawStdWindowFrame(1, 12, 28, 15); PrintMainMenuItem(gMainMenuString_Option, 2, 13); PrintSaveFileInfo(); break; case HAS_MYSTERY_GIFT: - MenuDrawTextWindow(1, 0, 28, 7); + Menu_DrawStdWindowFrame(1, 0, 28, 7); PrintMainMenuItem(gMainMenuString_Continue, 2, 1); - MenuDrawTextWindow(1, 8, 28, 11); + Menu_DrawStdWindowFrame(1, 8, 28, 11); PrintMainMenuItem(gMainMenuString_NewGame, 2, 9); - MenuDrawTextWindow(1, 12, 28, 15); + Menu_DrawStdWindowFrame(1, 12, 28, 15); PrintMainMenuItem(gMainMenuString_MysteryEvents, 2, 13); - MenuDrawTextWindow(1, 16, 28, 19); + Menu_DrawStdWindowFrame(1, 16, 28, 19); PrintMainMenuItem(gMainMenuString_Option, 2, 0x11); PrintSaveFileInfo(); break; @@ -681,7 +681,7 @@ void PrintMainMenuItem(const u8 *text, u8 left, u8 top) buffer[29] = EOS; - MenuPrint(buffer, left, top); + Menu_PrintText(buffer, left, top); } void PrintSaveFileInfo(void) @@ -694,8 +694,8 @@ void PrintSaveFileInfo(void) void PrintPlayerName(void) { - MenuPrint(gMainMenuString_Player, 2, 3); - MenuPrint(gSaveBlock2.playerName, 9, 3); + Menu_PrintText(gMainMenuString_Player, 2, 3); + Menu_PrintText(gSaveBlock2.playerName, 9, 3); } void PrintPlayTime(void) @@ -704,15 +704,15 @@ void PrintPlayTime(void) u8 alignedPlayTime[32]; #if defined(ENGLISH) - MenuPrint(gMainMenuString_Time, 16, 3); + Menu_PrintText(gMainMenuString_Time, 16, 3); FormatPlayTime(playTime, gSaveBlock2.playTimeHours, gSaveBlock2.playTimeMinutes, 1); sub_8072C74(alignedPlayTime, playTime, 48, 1); - MenuPrint(alignedPlayTime, 22, 3); + Menu_PrintText(alignedPlayTime, 22, 3); #elif defined(GERMAN) - MenuPrint_PixelCoords(gMainMenuString_Time, 124, 24, TRUE); + Menu_PrintTextPixelCoords(gMainMenuString_Time, 124, 24, TRUE); FormatPlayTime(playTime, gSaveBlock2.playTimeHours, gSaveBlock2.playTimeMinutes, 1); sub_8072C74(alignedPlayTime, playTime, 40, 1); - MenuPrint(alignedPlayTime, 23, 3); + Menu_PrintText(alignedPlayTime, 23, 3); #endif } @@ -720,9 +720,9 @@ void PrintPokedexCount(void) { u8 buffer[16]; - MenuPrint(gMainMenuString_Pokedex, 2, 5); + Menu_PrintText(gMainMenuString_Pokedex, 2, 5); sub_8072C14(buffer, GetPokedexSeenCount(), 18, 0); - MenuPrint(buffer, 9, 5); + Menu_PrintText(buffer, 9, 5); } void PrintBadgeCount(void) @@ -730,12 +730,12 @@ void PrintBadgeCount(void) u8 buffer[16]; #if defined(ENGLISH) - MenuPrint(gMainMenuString_Badges, 16, 5); + Menu_PrintText(gMainMenuString_Badges, 16, 5); #elif defined(GERMAN) - MenuPrint_PixelCoords(gMainMenuString_Badges, 124, 40, TRUE); + Menu_PrintTextPixelCoords(gMainMenuString_Badges, 124, 40, TRUE); #endif ConvertIntToDecimalString(buffer, GetBadgeCount()); - MenuPrint_PixelCoords(buffer, 205, 40, 1); + Menu_PrintTextPixelCoords(buffer, 205, 40, 1); } #define tTrainerSpriteId data[2] @@ -750,8 +750,8 @@ void PrintBadgeCount(void) static void Task_NewGameSpeech1(u8 taskId) { - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow((struct WindowTemplate *)&gWindowTemplate_81E6CE4); REG_WIN0H = 0; REG_WIN0V = 0; REG_WININ = 0; @@ -763,7 +763,7 @@ static void Task_NewGameSpeech1(u8 taskId) LZ77UnCompVram(gUnknown_081E7834, (void *)(BG_VRAM + 0x3800)); LoadPalette(gUnknown_081E764C, 0, 0x40); LoadPalette(gUnknown_081E796C, 1, 0x10); - remove_some_task(); + ScanlineEffect_Stop(); ResetSpriteData(); FreeAllSpritePalettes(); AddBirchSpeechObjects(taskId); @@ -812,7 +812,7 @@ static void Task_NewGameSpeech3(u8 taskId) } else { - MenuDrawTextWindow(2, 13, 27, 18); + Menu_DrawStdWindowFrame(2, 13, 27, 18); //"Hi! Sorry to keep you waiting... //...But everyone calls me the POKEMON PROFESSOR." MenuPrintMessage(gBirchSpeech_Welcome, 3, 14); @@ -857,7 +857,7 @@ static void Task_NewGameSpeech7(u8 taskId) //Go on to next sentence after frame 95 if (gTasks[taskId].tFrameCounter > 95) { - MenuSetText(gSystemText_NewPara); + Menu_SetText(gSystemText_NewPara); gTasks[taskId].func = Task_NewGameSpeech8; } } @@ -886,7 +886,7 @@ static void Task_NewGameSpeech9(u8 taskId) { if (BirchSpeechUpdateWindowText()) { - MenuDrawTextWindow(2, 13, 27, 18); + Menu_DrawStdWindowFrame(2, 13, 27, 18); //"And you are?" MenuPrintMessage(gBirchSpeech_AndYouAre, 3, 14); gTasks[taskId].func = Task_NewGameSpeech10; @@ -962,7 +962,7 @@ static void Task_NewGameSpeech13(u8 taskId) static void Task_NewGameSpeech14(u8 taskId) { - MenuDrawTextWindow(2, 13, 27, 18); + Menu_DrawStdWindowFrame(2, 13, 27, 18); //"Are you a boy? Or are you a girl?" MenuPrintMessage(gBirchSpeech_AreYouBoyOrGirl, 3, 14); gTasks[taskId].func = Task_NewGameSpeech15; @@ -985,22 +985,22 @@ static void Task_NewGameSpeech16(u8 taskId) switch (GenderMenuProcessInput()) { case MALE: - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); gSaveBlock2.playerGender = MALE; - MenuZeroFillWindowRect(2, 4, 8, 9); + Menu_EraseWindowRect(2, 4, 8, 9); gTasks[taskId].func = Task_NewGameSpeech19; break; case FEMALE: - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); gSaveBlock2.playerGender = FEMALE; - MenuZeroFillWindowRect(2, 4, 8, 9); + Menu_EraseWindowRect(2, 4, 8, 9); gTasks[taskId].func = Task_NewGameSpeech19; break; } - cursorPos = GetMenuCursorPos(); + cursorPos = Menu_GetCursorPos(); if (cursorPos != gTasks[taskId].tGenderSelection) { @@ -1062,7 +1062,7 @@ static void Task_NewGameSpeech18(u8 taskId) static void Task_NewGameSpeech19(u8 taskId) { - MenuDrawTextWindow(2, 13, 27, 18); + Menu_DrawStdWindowFrame(2, 13, 27, 18); //"All right. What's your name?" MenuPrintMessage(gBirchSpeech_WhatsYourName, 3, 14); gTasks[taskId].func = Task_NewGameSpeech20; @@ -1088,9 +1088,9 @@ static void Task_NewGameSpeech21(u8 taskId) case 2: case 3: case 4: - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); - MenuZeroFillWindowRect(2, 1, 22, 12); + Menu_EraseWindowRect(2, 1, 22, 12); SetPresetPlayerName(selection); gTasks[taskId].func = Task_NewGameSpeech23; break; @@ -1100,9 +1100,9 @@ static void Task_NewGameSpeech21(u8 taskId) gTasks[taskId].func = Task_NewGameSpeech22; break; case -1: //B button - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); - MenuZeroFillWindowRect(2, 1, 22, 12); + Menu_EraseWindowRect(2, 1, 22, 12); gTasks[taskId].func = Task_NewGameSpeech14; //Go back to gender menu break; } @@ -1120,7 +1120,7 @@ static void Task_NewGameSpeech22(u8 taskId) static void Task_NewGameSpeech23(u8 taskId) { - MenuDrawTextWindow(2, 13, 27, 18); + Menu_DrawStdWindowFrame(2, 13, 27, 18); //"So it's (PLAYER)?" StringExpandPlaceholders(gStringVar4, gBirchSpeech_SoItsPlayer); MenuPrintMessage(gStringVar4, 3, 14); @@ -1139,11 +1139,11 @@ static void Task_NewGameSpeech24(u8 taskId) //Handle yes/no menu selection static void Task_NewGameSpeech25(u8 taskId) { - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: //YES PlaySE(SE_SELECT); - MenuZeroFillWindowRect(2, 1, 8, 7); + Menu_EraseWindowRect(2, 1, 8, 7); gSprites[gTasks[taskId].tTrainerSpriteId].oam.objMode = ST_OAM_OBJ_BLEND; StartSpriteFadeOut(taskId, 2); StartBackgroundFadeOut(taskId, 1); @@ -1152,7 +1152,7 @@ static void Task_NewGameSpeech25(u8 taskId) case -1: //B button case 1: //NO PlaySE(SE_SELECT); - MenuZeroFillWindowRect(2, 1, 8, 7); + Menu_EraseWindowRect(2, 1, 8, 7); gTasks[taskId].func = Task_NewGameSpeech14; //Go back to gender menu break; } @@ -1197,7 +1197,7 @@ static void Task_NewGameSpeech27(u8 taskId) StartSpriteFadeIn(taskId, 2); StartBackgroundFadeIn(taskId, 1); - MenuDrawTextWindow(2, 13, 27, 18); + Menu_DrawStdWindowFrame(2, 13, 27, 18); StringExpandPlaceholders(gStringVar4, gBirchSpeech_AhOkayYouArePlayer); //"Ah, okay! You're (PLAYER) who's moving... //...I get it now!" @@ -1267,7 +1267,7 @@ static void Task_NewGameSpeech29(u8 taskId) StartSpriteFadeIn(taskId, 2); StartBackgroundFadeIn(taskId, 1); - MenuDrawTextWindow(2, 13, 27, 18); + Menu_DrawStdWindowFrame(2, 13, 27, 18); MenuPrintMessage(gBirchSpeech_AreYouReady, 3, 14); gTasks[taskId].func = Task_NewGameSpeech30; } @@ -1368,13 +1368,13 @@ void CB_ContinueNewGameSpeechPart2() gTasks[taskId].tBGhofs = -60; - remove_some_task(); + ScanlineEffect_Stop(); ResetSpriteData(); FreeAllSpritePalettes(); AddBirchSpeechObjects(taskId); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow((struct WindowConfig *)&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow((struct WindowTemplate *)&gWindowTemplate_81E6CE4); if (gSaveBlock2.playerGender != MALE) { @@ -1661,33 +1661,33 @@ static void StartBackgroundFadeIn(u8 taskId, u8 interval) static void CreateGenderMenu(u8 left, u8 top) { u8 menuLeft, menuTop; - MenuDrawTextWindow(left, top, left + 6, top + 5); + Menu_DrawStdWindowFrame(left, top, left + 6, top + 5); menuLeft = left + 1; menuTop = top + 1; - PrintMenuItems(menuLeft, menuTop, 2, gUnknown_081E79B0); + Menu_PrintItems(menuLeft, menuTop, 2, gUnknown_081E79B0); InitMenu(0, menuLeft, menuTop, 2, 0, 5); } static s8 GenderMenuProcessInput(void) { - return ProcessMenuInputNoWrap(); + return Menu_ProcessInputNoWrap(); } static void CreateNameMenu(u8 left, u8 top) { - MenuDrawTextWindow(left, top, left + 10, top + 11); + Menu_DrawStdWindowFrame(left, top, left + 10, top + 11); if (gSaveBlock2.playerGender == MALE) - PrintMenuItems(left + 1, top + 1, 5, gMalePresetNames); + Menu_PrintItems(left + 1, top + 1, 5, gMalePresetNames); else - PrintMenuItems(left + 1, top + 1, 5, gFemalePresetNames); + Menu_PrintItems(left + 1, top + 1, 5, gFemalePresetNames); InitMenu(0, left + 1, top + 1, 5, 0, 9); } static s8 NameMenuProcessInput(void) { - return ProcessMenuInput(); + return Menu_ProcessInput(); } static void SetPresetPlayerName(u8 index) diff --git a/src/engine/menu.c b/src/engine/menu.c index 10988c1d7..86e20d0eb 100644 --- a/src/engine/menu.c +++ b/src/engine/menu.c @@ -24,13 +24,14 @@ struct Menu u8 columnXCoords[8]; }; -static void MultistepInitMenuWindowInternal(const struct WindowConfig *, u16); -static void InitMenuWindowInternal(const struct WindowConfig *, u16); -static bool8 sub_80723D4(void); +static void MultistepInitMenuWindowInternal(const struct WindowTemplate *, u16); +static void InitMenuWindowInternal(const struct WindowTemplate *, u16); +static bool8 IsGridCursorMovementClamped(void); static u8 sub_8072484(u8, u8, u8, u8, u8, u8, u32); static u8 sub_80724F4(u8, u8, u8, const struct MenuAction[], u8); static void sub_8072620(u8, u8, u8, const struct MenuAction[], u8); static void sub_8072D18(u8, u8); +static void RedrawMenuCursor(u8, u8); static struct Menu gMenu; @@ -52,10 +53,10 @@ const struct MenuAction gMenuYesNoItems[] = void CloseMenu(void) { PlaySE(SE_SELECT); - MenuZeroFillScreen(); + Menu_EraseScreen(); sub_8064E2C(); ScriptContext2_Disable(); - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); } void AppendToList(u8 *list, u8 *pindex, u32 value) @@ -64,22 +65,22 @@ void AppendToList(u8 *list, u8 *pindex, u32 value) (*pindex)++; } -void InitMenuWindow(const struct WindowConfig *winConfig) +void InitMenuWindow(const struct WindowTemplate *winTemplate) { - InitMenuWindowInternal(winConfig, 1); + InitMenuWindowInternal(winTemplate, 1); } -void MultistepInitMenuWindowBegin(const struct WindowConfig *winConfig) +void MultistepInitMenuWindowBegin(const struct WindowTemplate *winTemplate) { - MultistepInitMenuWindowInternal(winConfig, 1); + MultistepInitMenuWindowInternal(winTemplate, 1); } -static void MultistepInitMenuWindowInternal(const struct WindowConfig *winConfig, u16 tileOffset) +static void MultistepInitMenuWindowInternal(const struct WindowTemplate *winTemplate, u16 tileOffset) { gMenuMultistepInitState = 0; gMenuTextTileOffset = tileOffset; gMenuWindowPtr = &gMenuWindow; - InitWindowFromConfig(&gMenuWindow, winConfig); + Text_InitWindowWithTemplate(&gMenuWindow, winTemplate); } bool32 MultistepInitMenuWindowContinue(void) @@ -97,13 +98,13 @@ bool32 MultistepInitMenuWindowContinue(void) goto fail; goto next; case 3: - gMenuTextWindowContentTileOffset = SetTextWindowBaseTileNum(gMenuTextWindowTileOffset); + gMenuTextWindowContentTileOffset = TextWindow_SetBaseTileNum(gMenuTextWindowTileOffset); next: gMenuMultistepInitState++; return 0; case 4: - LoadTextWindowGraphics(gMenuWindowPtr); - gMenuMessageBoxContentTileOffset = SetMessageBoxBaseTileNum(gMenuTextWindowContentTileOffset); + TextWindow_LoadStdFrameGraphics(gMenuWindowPtr); + gMenuMessageBoxContentTileOffset = TextWindow_SetDlgFrameBaseTileNum(gMenuTextWindowContentTileOffset); return 1; default: fail: @@ -111,73 +112,74 @@ bool32 MultistepInitMenuWindowContinue(void) } } -static void InitMenuWindowInternal(const struct WindowConfig *winConfig, u16 tileOffset) +static void InitMenuWindowInternal(const struct WindowTemplate *winTemplate, u16 tileOffset) { gMenuWindowPtr = &gMenuWindow; - InitWindowFromConfig(&gMenuWindow, winConfig); + Text_InitWindowWithTemplate(&gMenuWindow, winTemplate); gMenuTextTileOffset = tileOffset; gMenuTextWindowTileOffset = InitWindowTileData(gMenuWindowPtr, gMenuTextTileOffset); - gMenuTextWindowContentTileOffset = SetTextWindowBaseTileNum(gMenuTextWindowTileOffset); - LoadTextWindowGraphics(gMenuWindowPtr); - gMenuMessageBoxContentTileOffset = SetMessageBoxBaseTileNum(gMenuTextWindowContentTileOffset); + gMenuTextWindowContentTileOffset = TextWindow_SetBaseTileNum(gMenuTextWindowTileOffset); + TextWindow_LoadStdFrameGraphics(gMenuWindowPtr); + gMenuMessageBoxContentTileOffset = TextWindow_SetDlgFrameBaseTileNum(gMenuTextWindowContentTileOffset); } -void unref_sub_8071DA4(struct WindowConfig *winConfig, u16 tileOffset) +void unref_sub_8071DA4(struct WindowTemplate *winTemplate, u16 tileOffset) { gMenuWindowPtr = &gMenuWindow; - InitWindowFromConfig(&gMenuWindow, winConfig); + Text_InitWindowWithTemplate(&gMenuWindow, winTemplate); gMenuTextWindowTileOffset = tileOffset; - gMenuTextWindowContentTileOffset = SetTextWindowBaseTileNum(gMenuTextWindowTileOffset); - LoadTextWindowGraphics(gMenuWindowPtr); - gMenuTextTileOffset = SetMessageBoxBaseTileNum(gMenuTextWindowContentTileOffset); + gMenuTextWindowContentTileOffset = TextWindow_SetBaseTileNum(gMenuTextWindowTileOffset); + TextWindow_LoadStdFrameGraphics(gMenuWindowPtr); + gMenuTextTileOffset = TextWindow_SetDlgFrameBaseTileNum(gMenuTextWindowContentTileOffset); gMenuMessageBoxContentTileOffset = InitWindowTileData(gMenuWindowPtr, gMenuTextTileOffset); } -void MenuLoadTextWindowGraphics_OverrideFrameType(u8 frameType) +void Menu_LoadStdFrameGraphicsOverrideStyle(u8 frameType) { - LoadTextWindowGraphics_OverrideFrameType(gMenuWindowPtr, frameType); + TextWindow_LoadStdFrameGraphicsOverrideStyle(gMenuWindowPtr, frameType); } -void MenuLoadTextWindowGraphics(void) +void Menu_LoadStdFrameGraphics(void) { - LoadTextWindowGraphics(gMenuWindowPtr); + TextWindow_LoadStdFrameGraphics(gMenuWindowPtr); } -void BasicInitMenuWindow(const struct WindowConfig *winConfig) +void BasicInitMenuWindow(const struct WindowTemplate *winTemplate) { - InitWindowFromConfig(gMenuWindowPtr, winConfig); + Text_InitWindowWithTemplate(gMenuWindowPtr, winTemplate); gMenuWindowPtr->tileDataStartOffset = gMenuTextTileOffset; } -void MenuPrint(const u8 *str, u8 left, u8 top) +// Prints +void Menu_PrintText(const u8 *str, u8 left, u8 top) { - sub_8003460(gMenuWindowPtr, str, gMenuTextTileOffset, left, top); + Text_InitWindowAndPrintText(gMenuWindowPtr, str, gMenuTextTileOffset, left, top); } -void MenuZeroFillWindowRect(u8 left, u8 top, u8 right, u8 bottom) +void Menu_EraseWindowRect(u8 left, u8 top, u8 right, u8 bottom) { - ZeroFillWindowRect(gMenuWindowPtr, left, top, right, bottom); + Text_EraseWindowRect(gMenuWindowPtr, left, top, right, bottom); } -void MenuFillWindowRectWithBlankTile(u8 left, u8 top, u8 right, u8 bottom) +void Menu_BlankWindowRect(u8 left, u8 top, u8 right, u8 bottom) { - FillWindowRectWithBlankTile(gMenuWindowPtr, left, top, right, bottom); + Text_BlankWindowRect(gMenuWindowPtr, left, top, right, bottom); } -void MenuZeroFillScreen(void) +void Menu_EraseScreen(void) { - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); } -void MenuDrawTextWindow(u8 left, u8 top, u8 right, u8 bottom) +void Menu_DrawStdWindowFrame(u8 left, u8 top, u8 right, u8 bottom) { - DrawTextWindow(gMenuWindowPtr, left, top, right, bottom); + TextWindow_DrawStdFrame(gMenuWindowPtr, left, top, right, bottom); } void sub_8071F40(const u8 *str) { - MenuDrawTextWindow(2, 14, 28, 19); - MenuPrint(str, 3, 15); + Menu_DrawStdWindowFrame(2, 14, 28, 19); + Menu_PrintText(str, 3, 15); } void sub_8071F60(u8 a1, u8 a2, u8 a3) @@ -187,50 +189,50 @@ void sub_8071F60(u8 a1, u8 a2, u8 a3) u16 unref_sub_8071F98(u8 x, u8 y) { - return GetWindowTilemapEntry(gMenuWindowPtr, x, y); + return Text_GetWindowTilemapEntry(gMenuWindowPtr, x, y); } void unref_sub_8071FBC(u16 a1, u8 a2, u8 a3, u8 a4, u8 a5) { - DrawWindowRect(gMenuWindowPtr, a1, a2, a3, a4, a5); + Text_FillWindowBorder(gMenuWindowPtr, a1, a2, a3, a4, a5); } -void MenuDisplayMessageBox(void) +void Menu_DisplayDialogueFrame(void) { - DisplayMessageBox(gMenuWindowPtr); + TextWindow_DisplayDialogueFrame(gMenuWindowPtr); } void MenuPrintMessage(const u8 *str, u8 left, u8 top) { - sub_8002EB0(gMenuWindowPtr, str, gMenuTextTileOffset, left, top); + Text_InitWindow8002EB0(gMenuWindowPtr, str, gMenuTextTileOffset, left, top); } void MenuPrintMessageDefaultCoords(const u8 *str) { - sub_8002EB0(gMenuWindowPtr, str, gMenuTextTileOffset, 2, 15); + Text_InitWindow8002EB0(gMenuWindowPtr, str, gMenuTextTileOffset, 2, 15); } -void MenuSetText(const u8 *str) +void Menu_SetText(const u8 *str) { - sub_8002E90(gMenuWindowPtr, str); + Text_SetWindowText(gMenuWindowPtr, str); } -u8 MenuUpdateWindowText(void) +u8 Menu_UpdateWindowText(void) { - return sub_80035AC(gMenuWindowPtr); + return Text_UpdateWindow(gMenuWindowPtr); } u8 unref_sub_8072098(void) { - return sub_8003418(gMenuWindowPtr); + return Text_PrintWindowSimple(gMenuWindowPtr); } -void sub_80720B0(void) +void Menu_ClearWindowText(void) { - ClearWindowTextLines(gMenuWindowPtr); + Text_ClearWindow(gMenuWindowPtr); } -u8 MoveMenuCursor(s8 delta) +u8 Menu_MoveCursor(s8 delta) { s32 newPos = gMenu.cursorPos + delta; @@ -245,7 +247,7 @@ u8 MoveMenuCursor(s8 delta) return gMenu.cursorPos; } -u8 MoveMenuCursorNoWrap(s8 delta) +u8 Menu_MoveCursorNoWrap(s8 delta) { s32 newPos = gMenu.cursorPos + delta; @@ -260,45 +262,45 @@ u8 MoveMenuCursorNoWrap(s8 delta) return gMenu.cursorPos; } -u8 GetMenuCursorPos(void) +u8 Menu_GetCursorPos(void) { return gMenu.cursorPos; } -s8 ProcessMenuInput(void) +s8 Menu_ProcessInput(void) { if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); if (gMenu.menu_field_7) - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); return gMenu.cursorPos; } if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); return -1; } if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); return -2; } else if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); return -2; } return -2; } -s8 ProcessMenuInputNoWrap(void) +s8 Menu_ProcessInputNoWrap(void) { u8 cursorPos = gMenu.cursorPos; @@ -306,31 +308,31 @@ s8 ProcessMenuInputNoWrap(void) { PlaySE(SE_SELECT); if (gMenu.menu_field_7) - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); return gMenu.cursorPos; } if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); return -1; } if (gMain.newKeys & DPAD_UP) { - if (cursorPos != MoveMenuCursorNoWrap(-1)) + if (cursorPos != Menu_MoveCursorNoWrap(-1)) PlaySE(SE_SELECT); return -2; } else if (gMain.newKeys & DPAD_DOWN) { - if (cursorPos != MoveMenuCursorNoWrap(1)) + if (cursorPos != Menu_MoveCursorNoWrap(1)) PlaySE(SE_SELECT); return -2; } - MoveMenuCursorNoWrap(0); + Menu_MoveCursorNoWrap(0); return -2; } @@ -353,11 +355,12 @@ u8 MoveMenuCursor3(s8 delta) return gMenu.cursorPos; } -u8 MoveMenuCursor4(s8 delta) +static u8 MoveMenuCursorGridLayout(s8 delta) { + // Don't move cursor if it is clamped if (gMenu.cursorPos + delta <= gMenu.maxCursorPos) { - if (sub_80723D4() == TRUE) + if (IsGridCursorMovementClamped() == TRUE) return gMenu.cursorPos; } else @@ -379,22 +382,35 @@ u8 MoveMenuCursor4(s8 delta) return gMenu.cursorPos; } -static bool8 sub_80723D4(void) +// Returns TRUE if the cursor is on an edge and cannot move in the pressed direction +static bool8 IsGridCursorMovementClamped(void) { - if ((gMain.newKeys & DPAD_UP) && gMenu.cursorPos < gMenu.width) - return TRUE; - - if ((gMain.newKeys & DPAD_DOWN) && gMenu.cursorPos >= (gMenu.maxCursorPos + 1) - gMenu.width) - return TRUE; - - if ((gMain.newKeys & DPAD_LEFT) - && ((gMenu.cursorPos - (gMenu.cursorPos % gMenu.width)) % gMenu.width == 1 // always false - || gMenu.cursorPos == 0 - || gMenu.cursorPos % gMenu.width == 0)) - return TRUE; - - if ((gMain.newKeys & DPAD_RIGHT) && gMenu.cursorPos % gMenu.width == gMenu.width - 1) - return TRUE; + if (gMain.newKeys & DPAD_UP) + { + // is cursor on first row? + if (gMenu.cursorPos < gMenu.width) + return TRUE; + } + if (gMain.newKeys & DPAD_DOWN) + { + // is cursor on last row? + if (gMenu.cursorPos >= gMenu.maxCursorPos + 1 - gMenu.width) + return TRUE; + } + if (gMain.newKeys & DPAD_LEFT) + { + // is cursor on first column? + if ((gMenu.cursorPos - gMenu.cursorPos % gMenu.width) % gMenu.width == 1 // always false + || gMenu.cursorPos == 0 // redundant + || gMenu.cursorPos % gMenu.width == 0) + return TRUE; + } + if (gMain.newKeys & DPAD_RIGHT) + { + // is cursor on last column? + if (gMenu.cursorPos % gMenu.width == gMenu.width - 1) + return TRUE; + } return FALSE; } @@ -465,7 +481,7 @@ static u8 sub_80724F4(u8 left, u8 top, u8 menuItemCount, const struct MenuAction totalWidth = (gMenu.columnXCoords[columnCount] + 1); right = left + totalWidth; - MenuDrawTextWindow(left, top, right, bottom); + Menu_DrawStdWindowFrame(left, top, right, bottom); } return maxWidth; @@ -501,7 +517,7 @@ static void sub_8072620(u8 left, u8 top, u8 menuItemCount, const struct MenuActi u8 row = 0; u8 j; for (j = 0; i + j < menuItemCount; j += columnCount, row++) - MenuPrint(menuItems[i + j].text, left + gMenu.columnXCoords[i % columnCount], top + 2 * row); + Menu_PrintText(menuItems[i + j].text, left + gMenu.columnXCoords[i % columnCount], top + 2 * row); } } @@ -513,93 +529,95 @@ void sub_807274C(u8 left, u8 top, u8 menuItemCount, u8 a4, const struct MenuActi sub_8072620(left + 1, top + 1, menuItemCount, menuItems, columnCount); } -s8 sub_80727CC(void) +s8 Menu_ProcessInputGridLayout(void) { if (gMain.newKeys & A_BUTTON) { if (gMenu.menu_field_7) - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); - return GetMenuCursorPos(); + return Menu_GetCursorPos(); } if (gMain.newKeys & B_BUTTON) { if (gMenu.menu_field_7) - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); return -1; } if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor4(-gMenu.width); + // Move up one whole row + MoveMenuCursorGridLayout(-gMenu.width); return -2; } else if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor4(gMenu.width); + // Move down one whole column + MoveMenuCursorGridLayout(gMenu.width); return -2; } else if (gMain.newKeys & DPAD_LEFT) { PlaySE(SE_SELECT); - MoveMenuCursor4(-1); + MoveMenuCursorGridLayout(-1); return -2; } else if (gMain.newKeys & DPAD_RIGHT) { PlaySE(SE_SELECT); - MoveMenuCursor4(1); + MoveMenuCursorGridLayout(1); return -2; } return -2; } -u8 sub_807288C(u8 column) +u8 Menu_GetColumnXCoord(u8 column) { return gMenu.columnXCoords[column]; } -void PrintMenuItems(u8 left, u8 top, u8 menuItemCount, const struct MenuAction menuItems[]) +void Menu_PrintItems(u8 left, u8 top, u8 menuItemCount, const struct MenuAction menuItems[]) { u8 i; for (i = 0; i < menuItemCount; i++) - MenuPrint(menuItems[i].text, left, top + 2 * i); + Menu_PrintText(menuItems[i].text, left, top + 2 * i); } -void PrintMenuItemsReordered(u8 left, u8 top, u8 menuItemCount, const struct MenuAction2 menuItems[], const u8 *order) +void Menu_PrintItemsReordered(u8 left, u8 top, u8 menuItemCount, const struct MenuAction2 menuItems[], const u8 *order) { u8 i; for (i = 0; i < menuItemCount; i++) - MenuPrint(menuItems[order[i]].text, left, top + 2 * i); + Menu_PrintText(menuItems[order[i]].text, left, top + 2 * i); } void InitYesNoMenu(u8 left, u8 top, u8 a3) { - PrintMenuItems(left + 1, top + 1, 2, gMenuYesNoItems); + Menu_PrintItems(left + 1, top + 1, 2, gMenuYesNoItems); InitMenu(0, left + 1, top + 1, 2, 0, a3); } void DisplayYesNoMenu(u8 left, u8 top, u32 a3) { - MenuDrawTextWindow(left, top, left + 6, top + 5); + Menu_DrawStdWindowFrame(left, top, left + 6, top + 5); InitYesNoMenu(left, top, 5); gMenu.menu_field_7 = a3 ? -1 : 0; } -s8 ProcessMenuInputNoWrap_(void) +s8 Menu_ProcessInputNoWrap_(void) { - return ProcessMenuInputNoWrap(); + return Menu_ProcessInputNoWrap(); } -u8 MenuPrint_PixelCoords(const u8 *text, u8 left, u16 top, u8 a4) +u8 Menu_PrintTextPixelCoords(const u8 *text, u8 left, u16 top, u8 a4) { - return sub_8004D04(gMenuWindowPtr, text, gMenuTextTileOffset, left, top, a4); + return Text_InitWindow8004D04(gMenuWindowPtr, text, gMenuTextTileOffset, left, top, a4); } u8 sub_8072A18(const u8 *text, u8 left, u16 top, u8 width, u32 a5) @@ -623,7 +641,7 @@ int sub_8072AB0(const u8 *str, u8 left, u16 top, u8 width, u8 height, u32 a6) height = (height + 7) / 8; if (newlineCount < height) - MenuFillWindowRectWithBlankTile(left, top + 2 * newlineCount, left + width - 1, height + top - 1); + Menu_BlankWindowRect(left, top + 2 * newlineCount, left + width - 1, height + top - 1); } #elif GERMAN __attribute__((naked)) @@ -700,7 +718,7 @@ _08072B0C:\n\ lsls r3, 24\n\ lsrs r3, 24\n\ adds r0, r5, 0\n\ - bl MenuFillWindowRectWithBlankTile\n\ + bl Menu_BlankWindowRect\n\ _08072B3E:\n\ add sp, 0x10\n\ pop {r4-r7}\n\ @@ -712,7 +730,7 @@ _08072B3E:\n\ void MenuPrint_RightAligned(const u8 *str, u8 left, u8 top) { - sub_8004D38(gMenuWindowPtr, str, gMenuTextTileOffset, left, top); + Text_InitWindow8004D38(gMenuWindowPtr, str, gMenuTextTileOffset, left, top); } void sub_8072B80(const u8 *a1, u8 a2, u8 a3, const u8 *a4) @@ -720,12 +738,12 @@ void sub_8072B80(const u8 *a1, u8 a2, u8 a3, const u8 *a4) u8 buffer[64]; u8 width = GetStringWidth(gMenuWindowPtr, a4); AlignString(gMenuWindowPtr, buffer, a1, width, 1); - sub_8003460(gMenuWindowPtr, buffer, gMenuTextTileOffset, a2, a3); + Text_InitWindowAndPrintText(gMenuWindowPtr, buffer, gMenuTextTileOffset, a2, a3); } void sub_8072BD8(const u8 *a1, u8 a2, u8 a3, u16 a4) { - sub_8004DB0(gMenuWindowPtr, a1, gMenuTextTileOffset, a2, a3, a4); + Text_InitWindow8004DB0(gMenuWindowPtr, a1, gMenuTextTileOffset, a2, a3, a4); } u8 *sub_8072C14(u8 *a1, s32 a2, u8 a3, u8 a4) @@ -748,19 +766,19 @@ u8 sub_8072CA4(const u8 *str) return GetStringWidth(gMenuWindowPtr, str); } -u8 sub_8072CBC() +u8 Menu_GetTextWindowPaletteNum(void) { - return sub_8004E24(gMenuWindowPtr); + return Text_GetWindowPaletteNum(gMenuWindowPtr); } -void sub_8072CD4(u8 *a1, u8 *a2, u8 *a3) +void Menu_GetTextColors(u8 *a1, u8 *a2, u8 *a3) { - sub_8004E28(gMenuWindowPtr, a1, a2, a3); + Text_GetTextColors(gMenuWindowPtr, a1, a2, a3); } -u32 MenuUpdateWindowText_OverrideLineLength(u8 lineLength) +u32 Menu_UpdateWindowTextOverrideLineLength(u8 lineLength) { - return sub_80037C8(gMenuWindowPtr, lineLength); + return Text_UpdateWindowOverrideLineLength(gMenuWindowPtr, lineLength); } struct Window *unref_sub_8072D0C(void) @@ -770,7 +788,7 @@ struct Window *unref_sub_8072D0C(void) static void sub_8072D18(u8 a1, u8 a2) { - sub_814A5C0(a1, 0xFFFF, 12, 11679, 8 * a2); + MenuCursor_Create814A5C0(a1, 0xFFFF, 12, 11679, 8 * a2); } u8 InitMenu(u8 cursorSubpriority, u8 left, u8 top, u8 numChoices, u8 cursorPos, u8 cursorWidth) @@ -792,14 +810,14 @@ u8 InitMenu(u8 cursorSubpriority, u8 left, u8 top, u8 numChoices, u8 cursorPos, pos = 0; gMenu.cursorPos = pos; - MoveMenuCursor(0); + Menu_MoveCursor(0); return pos; } -void RedrawMenuCursor(u8 a1, u8 a2) +static void RedrawMenuCursor(u8 x, u8 y) { - sub_814A880((a1 + 1) * 8, 8 * a2); + MenuCursor_SetPos814A880((x + 1) * 8, 8 * y); } void unref_sub_8072DC0() @@ -817,7 +835,7 @@ void sub_8072DDC(u8 a1) sub_8072DCC(8 * a1); } -void HandleDestroyMenuCursors(void) +void Menu_DestroyCursor(void) { DestroyMenuCursor(); } diff --git a/src/engine/menu_cursor.c b/src/engine/menu_cursor.c index 960d3cc87..35116d40b 100644 --- a/src/engine/menu_cursor.c +++ b/src/engine/menu_cursor.c @@ -3,13 +3,13 @@ #include "palette.h" #include "sprite.h" -EWRAM_DATA u16 gUnknown_0203A360[0x10] = {}; -EWRAM_DATA struct Subsprite gMenuCursorSubsprites[10] = {0}; -EWRAM_DATA u8 gUnknown_0203A3D0 = 0; -EWRAM_DATA u8 gUnknown_0203A3D1 = 0; -EWRAM_DATA u8 gUnknown_0203A3D2 = 0; -EWRAM_DATA u8 gUnknown_0203A3D3 = 0; -EWRAM_DATA u8 gUnknown_0203A3D4 = 0; +EWRAM_DATA static u16 gUnknown_0203A360[0x10] = {}; +EWRAM_DATA static struct Subsprite gMenuCursorSubsprites[10] = {0}; +EWRAM_DATA static u8 gUnknown_0203A3D0 = 0; +EWRAM_DATA static u8 gUnknown_0203A3D1 = 0; +EWRAM_DATA static u8 gUnknown_0203A3D2 = 0; +EWRAM_DATA static u8 gUnknown_0203A3D3 = 0; +EWRAM_DATA static u8 gUnknown_0203A3D4 = 0; #if ENGLISH #include "../src/data/menu_cursor_en.h" @@ -26,7 +26,7 @@ void sub_814A590(void) gUnknown_0203A3D4 = 0; } -u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5) +u8 MenuCursor_Create814A5C0(u8 subpriority, u16 paletteTag, u8 a3, u16 a4, u8 a5) { int v9; struct Sprite *v10; @@ -35,34 +35,34 @@ u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5) DestroyMenuCursor(); v9 = 1; - if (a2 == 0xFFFF) + if (paletteTag == 0xFFFF) { gUnknown_0203A360[a3 & 0xF] = a4; if (LoadSpritePalette(&gUnknown_0842F240) != 0xFF) { - a2 = 0xFFF0; + paletteTag = 0xFFF0; v9 = 0; } } LoadSpriteSheetDeferred(&gUnknown_0842F140[a3 & 0xF]); - gUnknown_0203A3D0 = CreateSprite(&gSpriteTemplate_842F250[v9], 0, 0xA0, a1); - gUnknown_0203A3D1 = CreateSprite(&gSpriteTemplate_842F250[2], 0, 0xA0, a1); + gUnknown_0203A3D0 = CreateSprite(&gSpriteTemplate_842F250[v9], 0, 160, subpriority); + gUnknown_0203A3D1 = CreateSprite(&gSpriteTemplate_842F250[2], 0, 160, subpriority); if (gUnknown_0203A3D0 != 0x40) { v10 = &gSprites[gUnknown_0203A3D0]; - if (a2 == 0xFFFF) + if (paletteTag == 0xFFFF) v10->oam.paletteNum = 0; else - v10->oam.paletteNum = IndexOfSpritePaletteTag(a2); + v10->oam.paletteNum = IndexOfSpritePaletteTag(paletteTag); } if (gUnknown_0203A3D1 != 0x40) { v10 = &gSprites[gUnknown_0203A3D1]; - if (a2 == 0xFFFF) + if (paletteTag == 0xFFFF) v10->oam.paletteNum = 0; else - v10->oam.paletteNum = IndexOfSpritePaletteTag(a2); + v10->oam.paletteNum = IndexOfSpritePaletteTag(paletteTag); if (!(REG_DISPCNT & (DISPCNT_WIN0_ON | DISPCNT_WIN1_ON))) *(u8 *)(REG_ADDR_WINOUT) |= 0x1F; @@ -75,12 +75,13 @@ u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5) return gUnknown_0203A3D0; } -u8 sub_814A758(u8 a1, u8 a2, u8 a3, u8 a4) +// unused +u8 sub_814A758(u8 subpriority, u8 a2, u8 a3, u8 a4) { u8 result; struct Sprite *spr; - result = sub_814A5C0(a1, 0, a3, 0, a4); + result = MenuCursor_Create814A5C0(subpriority, 0, a3, 0, a4); if (result != 0x40) { spr = &gSprites[gUnknown_0203A3D0]; @@ -128,7 +129,7 @@ void DestroyMenuCursor(void) return; } -void sub_814A880(u8 a1, u8 a2) +void MenuCursor_SetPos814A880(u8 a1, u8 a2) { struct Sprite *spr; @@ -685,49 +686,48 @@ void unref_sub_814ABE4(int a1) return; } -u8 CreateBlendedOutlineCursor(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5) +u8 CreateBlendedOutlineCursor(u8 subpriority, u16 paletteTag, u8 a3, u16 a4, u8 a5) { int v8; struct Sprite *spr; - u8 var1 = gUnknown_0203A3D2; - if (var1 != 0x40) - sub_814AD44(); + if (gUnknown_0203A3D2 != 0x40) + MenuCursor_Destroy814AD44(); v8 = 1; - if (a2 == 0xFFFF) + if (paletteTag == 0xFFFF) { gUnknown_0203A360[a3 & 0xF] = a4; if (LoadSpritePalette(&gUnknown_0842F248) != 0xFF ) { - a2 = 0xFFF1; + paletteTag = 0xFFF1; v8 = 0; } } LoadSpriteSheetDeferred(&gUnknown_0842F1C0[a3 & 0xF]); #if ENGLISH - gUnknown_0203A3D2 = CreateSprite(&gSpriteTemplate_842F298[v8], 0, 160, a1); + gUnknown_0203A3D2 = CreateSprite(&gSpriteTemplate_842F298[v8], 0, 160, subpriority); #elif GERMAN - gUnknown_0203A3D2 = CreateSprite(&gSpriteTemplate_842F298[v8], 0, 161, a1); + gUnknown_0203A3D2 = CreateSprite(&gSpriteTemplate_842F298[v8], 0, 161, subpriority); #endif if (gUnknown_0203A3D2 != 0x40) { spr = &gSprites[gUnknown_0203A3D2]; - if (a2 == 0xFFFF) + if (paletteTag == 0xFFFF) spr->oam.paletteNum = 0; else - spr->oam.paletteNum = IndexOfSpritePaletteTag(a2); + spr->oam.paletteNum = IndexOfSpritePaletteTag(paletteTag); } sub_814ADF4(a5); return gUnknown_0203A3D2; } -void sub_814AD44(void) +void MenuCursor_Destroy814AD44(void) { if (gUnknown_0203A3D2 != 0x40) { @@ -738,7 +738,7 @@ void sub_814AD44(void) return; } -void sub_814AD7C(u8 a1, u8 a2) +void MenuCursor_SetPos814AD7C(u8 a1, u8 a2) { struct Sprite *spr; if (gUnknown_0203A3D2 != 0x40) diff --git a/src/engine/mystery_event_menu.c b/src/engine/mystery_event_menu.c index b9c3d5ad8..b7b7c047e 100644 --- a/src/engine/mystery_event_menu.c +++ b/src/engine/mystery_event_menu.c @@ -45,9 +45,9 @@ void CB2_InitMysteryEventMenu(void) FreeAllSpritePalettes(); ResetTasks(); SetVBlankCallback(VBlankCB); - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); + Menu_EraseScreen(); REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON; REG_BLDCNT = 0; CreateTask(Task_DestroySelf, 0); @@ -86,7 +86,7 @@ static void CB2_MysteryEventMenu(void) switch (gMain.state) { case 0: - MenuDrawTextWindow(0, 14, 29, 19); + Menu_DrawStdWindowFrame(0, 14, 29, 19); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0x10, 0, 0); gMain.state++; break; @@ -97,7 +97,7 @@ static void CB2_MysteryEventMenu(void) gMain.state++; break; case 2: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { gMain.state++; gLinkType = 21761; @@ -119,7 +119,7 @@ static void CB2_MysteryEventMenu(void) } break; case 4: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) gMain.state++; break; #ifdef NONMATCHING @@ -135,8 +135,8 @@ static void CB2_MysteryEventMenu(void) { PlaySE(SE_SELECT); sub_8007F4C(); - MenuDrawTextWindow(6, 5, 23, 8); - MenuPrint(gSystemText_LoadingEvent, 7, 6); + Menu_DrawStdWindowFrame(6, 5, 23, 8); + Menu_PrintText(gSystemText_LoadingEvent, 7, 6); gMain.state++; } else if (gMain.newKeys & B_BUTTON) @@ -155,7 +155,7 @@ static void CB2_MysteryEventMenu(void) if (GetLinkPlayerDataExchangeStatusTimed() == 3) { sub_800832C(); - MenuZeroFillWindowRect(6, 5, 23, 8); + Menu_EraseWindowRect(6, 5, 23, 8); GetEventLoadMessage(gStringVar4, 1); MenuPrintMessageDefaultCoords(gStringVar4); gMain.state = 13; @@ -170,7 +170,7 @@ static void CB2_MysteryEventMenu(void) else { CloseLink(); - MenuZeroFillWindowRect(6, 5, 23, 8); + Menu_EraseWindowRect(6, 5, 23, 8); GetEventLoadMessage(gStringVar4, 1); MenuPrintMessageDefaultCoords(gStringVar4); gMain.state = 13; @@ -195,8 +195,8 @@ static void CB2_MysteryEventMenu(void) { PlaySE(SE_SELECT); sub_8007F4C(); - MenuDrawTextWindow(6, 5, 23, 8); - MenuPrint(gSystemText_LoadingEvent, 7, 6); + Menu_DrawStdWindowFrame(6, 5, 23, 8); + Menu_PrintText(gSystemText_LoadingEvent, 7, 6); gMain.state++; } else if (gMain.newKeys & B_BUTTON) @@ -219,7 +219,7 @@ static void CB2_MysteryEventMenu(void) if (GetLinkPlayerDataExchangeStatusTimed() == 3) { sub_800832C(); - MenuZeroFillWindowRect(6, 5, 23, 8); + Menu_EraseWindowRect(6, 5, 23, 8); GetEventLoadMessage(gStringVar4, 1); MenuPrintMessageDefaultCoords(gStringVar4); ptr = (u8 *)&gMain; @@ -245,7 +245,7 @@ static void CB2_MysteryEventMenu(void) else { CloseLink(); - MenuZeroFillWindowRect(6, 5, 23, 8); + Menu_EraseWindowRect(6, 5, 23, 8); label: GetEventLoadMessage(gStringVar4, 1); MenuPrintMessageDefaultCoords(gStringVar4); @@ -266,7 +266,7 @@ static void CB2_MysteryEventMenu(void) break; #endif case 7: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) gMain.state++; break; case 8: @@ -297,8 +297,8 @@ static void CB2_MysteryEventMenu(void) gMain.state++; break; case 13: - MenuZeroFillWindowRect(6, 5, 23, 8); - if (MenuUpdateWindowText()) + Menu_EraseWindowRect(6, 5, 23, 8); + if (Menu_UpdateWindowText()) { gMain.state++; gUnknown_02039338 = 0; @@ -326,7 +326,7 @@ static void CB2_MysteryEventMenu(void) if (!IsLinkMaster()) { CloseLink(); - MenuZeroFillWindowRect(6, 5, 23, 8); + Menu_EraseWindowRect(6, 5, 23, 8); GetEventLoadMessage(gStringVar4, 1); MenuPrintMessageDefaultCoords(gStringVar4); gMain.state = 13; diff --git a/src/engine/name_string_util.c b/src/engine/name_string_util.c index f1a935453..32e9358e1 100644 --- a/src/engine/name_string_util.c +++ b/src/engine/name_string_util.c @@ -7,7 +7,7 @@ void PadNameString(u8 *a1, u8 a2) { u8 i; - StripExtCtrlCodes(a1); + Text_StripExtCtrlCodes(a1); i = StringLength(a1); if (a2 == 0xFC) @@ -36,5 +36,5 @@ void SanitizeNameString(u8 *a1) if (StringLength(a1) < 6) ConvertInternationalString(a1, 1); else - StripExtCtrlCodes(a1); + Text_StripExtCtrlCodes(a1); } diff --git a/src/engine/naming_screen.c b/src/engine/naming_screen.c index 6f34fd678..6aa706893 100644 --- a/src/engine/naming_screen.c +++ b/src/engine/naming_screen.c @@ -323,8 +323,8 @@ static void NamingScreen_Init(void) static void NamingScreen_SetUpWindow(void) { - SetUpWindowConfig(&gWindowConfig_81E6E88); - InitMenuWindow(&gWindowConfig_81E6E88); + Text_LoadWindowTemplate(&gWindowTemplate_81E6E88); + InitMenuWindow(&gWindowTemplate_81E6E88); } static void NamingScreen_ResetObjects(void) @@ -501,7 +501,7 @@ static bool8 MainState_6(struct Task *task) static bool8 MainState_UpdateSentToPCMessage(struct Task *task) { - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) namingScreenDataPtr->state++; return FALSE; } @@ -1608,8 +1608,8 @@ static void DisplaySentToPCMessage(void) { StringCopy(gStringVar1, namingScreenDataPtr->destBuffer); StringExpandPlaceholders(gStringVar4, gOtherText_SentToPC); - BasicInitMenuWindow(&gWindowConfig_81E6E88); - MenuDisplayMessageBox(); + BasicInitMenuWindow(&gWindowTemplate_81E6E88); + Menu_DisplayDialogueFrame(); MenuPrintMessageDefaultCoords(gStringVar4); } @@ -1755,19 +1755,19 @@ static void (*const gUnknown_083CE310[][2])(void) = sub_80B7844, }; -static const struct WindowConfig *const gUnknown_083CE328[][2][2] = +static const struct WindowTemplate *const gUnknown_083CE328[][2][2] = { { - {&gWindowConfig_81E6EDC, &gWindowConfig_81E6EF8}, - {&gWindowConfig_81E6EA4, &gWindowConfig_81E6EC0}, + {&gWindowTemplate_81E6EDC, &gWindowTemplate_81E6EF8}, + {&gWindowTemplate_81E6EA4, &gWindowTemplate_81E6EC0}, }, { - {&gWindowConfig_81E6EA4, &gWindowConfig_81E6EC0}, - {&gWindowConfig_81E6F14, &gWindowConfig_81E6F30}, + {&gWindowTemplate_81E6EA4, &gWindowTemplate_81E6EC0}, + {&gWindowTemplate_81E6F14, &gWindowTemplate_81E6F30}, }, { - {&gWindowConfig_81E6F14, &gWindowConfig_81E6F30}, - {&gWindowConfig_81E6EDC, &gWindowConfig_81E6EF8}, + {&gWindowTemplate_81E6F14, &gWindowTemplate_81E6F30}, + {&gWindowTemplate_81E6EDC, &gWindowTemplate_81E6EF8}, }, }; @@ -1836,15 +1836,15 @@ static void PrintKeyboardCharacters(u8 page) //print letters on page s16 r5; for (i = 0, r5 = 9; i < 4; i++, r5 += 2) - MenuPrint(sKeyboardCharacters[page][i], 3, r5); + Menu_PrintText(sKeyboardCharacters[page][i], 3, r5); } static void sub_80B78A8(void) { - BasicInitMenuWindow(&gWindowConfig_81E6F4C); + BasicInitMenuWindow(&gWindowTemplate_81E6F4C); gUnknown_083CE358[namingScreenDataPtr->templateNum](); gUnknown_083CE368[namingScreenDataPtr->template->unk3](); - MenuPrint(namingScreenDataPtr->template->title, 9, 2); + Menu_PrintText(namingScreenDataPtr->template->title, 9, 2); } static void nullsub_61(void) @@ -1868,7 +1868,7 @@ static void sub_80B7924(void) { if ((s16)namingScreenDataPtr->unk40 == MON_FEMALE) genderSymbol[0] = 0xB6; //female symbol - MenuPrint(genderSymbol, 0x14, 4); + Menu_PrintText(genderSymbol, 0x14, 4); } } @@ -1884,8 +1884,8 @@ static void sub_80B7960(void) string[5] = 1; string += 6; StringCopy(string, namingScreenDataPtr->textBuffer); - BasicInitMenuWindow(&gWindowConfig_81E6F4C); - MenuPrint(gStringVar1, namingScreenDataPtr->unk2, 4); + BasicInitMenuWindow(&gWindowTemplate_81E6F4C); + Menu_PrintText(gStringVar1, namingScreenDataPtr->unk2, 4); } //-------------------------------------------------- diff --git a/src/engine/option_menu.c b/src/engine/option_menu.c index dfc49b035..1fc78efaa 100644 --- a/src/engine/option_menu.c +++ b/src/engine/option_menu.c @@ -3,12 +3,12 @@ #include "main.h" #include "menu.h" #include "palette.h" +#include "scanline_effect.h" #include "sprite.h" #include "strings2.h" #include "task.h" extern void SetPokemonCryStereo(u32 val); -extern void remove_some_task(void); //Task data enum { @@ -110,17 +110,17 @@ void CB2_InitOptionMenu(void) } case 1: ResetPaletteFade(); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); gMain.state++; break; case 2: - SetUpWindowConfig(&gWindowConfig_81E71B4); + Text_LoadWindowTemplate(&gWindowTemplate_81E71B4); gMain.state++; break; case 3: - MultistepInitMenuWindowBegin(&gWindowConfig_81E71B4); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E71B4); gMain.state++; break; case 4: @@ -173,17 +173,17 @@ void CB2_InitOptionMenu(void) gTasks[taskId].data[TD_BUTTONMODE] = gSaveBlock2.optionsButtonMode; gTasks[taskId].data[TD_FRAMETYPE] = gSaveBlock2.optionsWindowFrameType; - MenuDrawTextWindow(2, 0, 27, 3); - MenuDrawTextWindow(2, 4, 27, 19); + Menu_DrawStdWindowFrame(2, 0, 27, 3); + Menu_DrawStdWindowFrame(2, 4, 27, 19); - MenuPrint(gSystemText_OptionMenu, 4, 1); - MenuPrint(gSystemText_TextSpeed, 4, 5); - MenuPrint(gSystemText_BattleScene, 4, 7); - MenuPrint(gSystemText_BattleStyle, 4, 9); - MenuPrint(gSystemText_Sound, 4, 11); - MenuPrint(gSystemText_ButtonMode, 4, 13); - MenuPrint(gSystemText_Frame, 4, 15); - MenuPrint(gSystemText_Cancel, 4, 17); + Menu_PrintText(gSystemText_OptionMenu, 4, 1); + Menu_PrintText(gSystemText_TextSpeed, 4, 5); + Menu_PrintText(gSystemText_BattleScene, 4, 7); + Menu_PrintText(gSystemText_BattleStyle, 4, 9); + Menu_PrintText(gSystemText_Sound, 4, 11); + Menu_PrintText(gSystemText_ButtonMode, 4, 13); + Menu_PrintText(gSystemText_Frame, 4, 15); + Menu_PrintText(gSystemText_Cancel, 4, 17); TextSpeed_DrawChoices(gTasks[taskId].data[TD_TEXTSPEED]); BattleScene_DrawChoices(gTasks[taskId].data[TD_BATTLESCENE]); @@ -313,7 +313,7 @@ static void DrawOptionMenuChoice(const u8 *text, u8 x, u8 y, u8 style) dst[2] = style; dst[i] = EOS; - MenuPrint_PixelCoords(dst, x, y, 1); + Menu_PrintTextPixelCoords(dst, x, y, 1); } static u8 TextSpeed_ProcessInput(u8 selection) @@ -432,11 +432,11 @@ static u8 FrameType_ProcessInput(u8 selection) { if (gMain.newKeys & DPAD_RIGHT) { - if (selection <= 18) + if (selection < 19) selection++; else selection = 0; - MenuLoadTextWindowGraphics_OverrideFrameType(selection); + Menu_LoadStdFrameGraphicsOverrideStyle(selection); } if (gMain.newKeys & DPAD_LEFT) { @@ -444,7 +444,7 @@ static u8 FrameType_ProcessInput(u8 selection) selection--; else selection = 19; - MenuLoadTextWindowGraphics_OverrideFrameType(selection); + Menu_LoadStdFrameGraphicsOverrideStyle(selection); } return selection; } @@ -478,8 +478,8 @@ static void FrameType_DrawChoices(u8 selection) } text[i] = EOS; - MenuPrint(gSystemText_Type, 15, 15); - MenuPrint(text, 18, 15); + Menu_PrintText(gSystemText_Type, 15, 15); + Menu_PrintText(text, 18, 15); } #elif GERMAN __attribute__((naked)) @@ -536,7 +536,7 @@ _0808C380:\n\ mov r0, sp\n\ movs r1, 0xF\n\ movs r2, 0xF\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ add sp, 0x10\n\ pop {r4-r6}\n\ pop {r0}\n\ diff --git a/src/engine/record_mixing.c b/src/engine/record_mixing.c index c8e2e34d5..75ca92e6a 100644 --- a/src/engine/record_mixing.c +++ b/src/engine/record_mixing.c @@ -146,8 +146,8 @@ void Task_RecordMixing_Main(u8 taskId) { tState = 4; data[10] = sub_8083664(); - sub_80720B0(); - MenuPrint(gOtherText_MixingComplete, 2, 15); + Menu_ClearWindowText(); + Menu_PrintText(gOtherText_MixingComplete, 2, 15); data[8] = 0; } break; @@ -160,7 +160,7 @@ void Task_RecordMixing_Main(u8 taskId) if (!gTasks[data[10]].isActive) { sub_8055588(); - MenuZeroFillScreen(); + Menu_EraseScreen(); DestroyTask(taskId); EnableBothScriptContexts(); } @@ -176,8 +176,8 @@ void sub_80B95F0(u8 taskId) { case 0: sub_80B9A78(); - MenuDisplayMessageBox(); - MenuPrint(gOtherText_MixingRecordsWithFriend, 2, 15); + Menu_DisplayDialogueFrame(); + Menu_PrintText(gOtherText_MixingRecordsWithFriend, 2, 15); task->data[8] = 0x708; task->tState = 400; ClearLinkCallback_2(); diff --git a/src/engine/reset_rtc_screen.c b/src/engine/reset_rtc_screen.c index 67e146899..a8b49a8eb 100644 --- a/src/engine/reset_rtc_screen.c +++ b/src/engine/reset_rtc_screen.c @@ -13,7 +13,7 @@ #include "strings2.h" #include "task.h" #include "text.h" -#include "unknown_task.h" +#include "scanline_effect.h" struct ResetRtcStruct { @@ -267,7 +267,7 @@ void ResetRtcScreen_FreeCursorPalette(void) void ResetRtcScreen_HideChooseTimeWindow(void) { - MenuZeroFillWindowRect(3, 8, 25, 11); + Menu_EraseWindowRect(3, 8, 25, 11); } void ResetRtcScreen_PrintTime(u8 x, u8 y, u16 days, u8 hours, u8 minutes, u8 seconds) @@ -286,13 +286,13 @@ void ResetRtcScreen_PrintTime(u8 x, u8 y, u16 days, u8 hours, u8 minutes, u8 sec dest = ConvertIntToDecimalStringN(dest, minutes, STR_CONV_MODE_LEADING_ZEROS, 2); dest = StringCopy(dest, gUnknown_08376500); ConvertIntToDecimalStringN(dest, seconds, STR_CONV_MODE_LEADING_ZEROS, 2); - MenuPrint(gStringVar4, x, y); + Menu_PrintText(gStringVar4, x, y); } void ResetRtcScreen_ShowChooseTimeWindow(u16 days, u8 hours, u8 minutes, u8 seconds) { - MenuDrawTextWindow(3, 8, 25, 11); - MenuPrint(gOtherText_OK, 20, 9); + Menu_DrawStdWindowFrame(3, 8, 25, 11); + Menu_PrintText(gOtherText_OK, 20, 9); ResetRtcScreen_PrintTime(4, 9, days, hours, minutes, seconds); } @@ -438,13 +438,13 @@ void CB2_InitResetRtcScreen(void) ResetOamRange(0, 128); LoadOam(); - remove_some_task(); - dp12_8087EA4(); + ScanlineEffect_Stop(); + ScanlineEffect_Clear(); ResetSpriteData(); ResetTasks(); ResetPaletteFade(); - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); REG_DISPCNT = 4352; SetVBlankCallback(VBlankCB_ResetRtcScreen); SetMainCallback2(CB2_ResetRtcScreen); @@ -468,8 +468,8 @@ void VBlankCB_ResetRtcScreen(void) void ResetRtcScreen_ShowMessage(const u8 *str) { - MenuDisplayMessageBox(); - MenuPrint(str, 2, 15); + Menu_DisplayDialogueFrame(); + Menu_PrintText(str, 2, 15); } void Task_ShowResetRtcPrompt(u8 taskId) @@ -479,9 +479,9 @@ void Task_ShowResetRtcPrompt(u8 taskId) switch (data[0]) { case 0: - MenuZeroFillScreen(); - MenuDrawTextWindow(0, 0, 20, 10); - MenuPrint(gSystemText_PresentTime, 1, 1); + Menu_EraseScreen(); + Menu_DrawStdWindowFrame(0, 0, 20, 10); + Menu_PrintText(gSystemText_PresentTime, 1, 1); ResetRtcScreen_PrintTime( 1, 3, @@ -489,7 +489,7 @@ void Task_ShowResetRtcPrompt(u8 taskId) gLocalTime.hours, gLocalTime.minutes, gLocalTime.seconds); - MenuPrint(gSystemText_PreviousTime, 1, 5); + Menu_PrintText(gSystemText_PreviousTime, 1, 5); ResetRtcScreen_PrintTime( 1, 7, @@ -543,7 +543,7 @@ void Task_ResetRtcScreen(u8 taskId) case 2: if (gTasks[data[1]].isActive != TRUE) { - MenuZeroFillScreen(); + Menu_EraseScreen(); ResetRtcScreen_ShowMessage(gSystemText_PleaseResetTime); gLocalTime = gSaveBlock2.lastBerryTreeUpdate; data[1] = CreateTask(Task_ResetRtc_0, 80); diff --git a/src/engine/save_failed_screen.c b/src/engine/save_failed_screen.c index ba2d46546..64b84a2f7 100644 --- a/src/engine/save_failed_screen.c +++ b/src/engine/save_failed_screen.c @@ -120,11 +120,11 @@ static void CB2_SaveFailedScreen(void) ResetPaletteFade(); LoadPalette(&gBirchBagGrassPal, 0, sizeof(gBirchBagGrassPal)); LoadPalette(&gSaveFailedClockPal, 0x100, sizeof(gSaveFailedClockPal)); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); - MenuDrawTextWindow(13, CLOCK_WIN_TOP, 16, CLOCK_WIN_TOP + 3); // clock window - MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); // message window - MenuPrint(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); + Menu_DrawStdWindowFrame(13, CLOCK_WIN_TOP, 16, CLOCK_WIN_TOP + 3); // clock window + Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); // message window + Menu_PrintText(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1); BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, 0); ime = REG_IME; REG_IME = 0; @@ -158,22 +158,22 @@ static void CB2_WipeSave(void) { if (WipeSectors(gDamagedSaveSectors) != FALSE) { - MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); - MenuPrint(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1); + Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); + Menu_PrintText(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1); SetMainCallback2(CB2_GameplayCannotBeContinued); return; } - MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); - MenuPrint(gSystemText_CheckCompleteSaveAttempt, 2, MSG_WIN_TOP + 1); + Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); + Menu_PrintText(gSystemText_CheckCompleteSaveAttempt, 2, MSG_WIN_TOP + 1); HandleSavingData(gSaveFailedType); if (gDamagedSaveSectors != 0) { #ifdef BUGFIX_SAVEFAILEDSCREEN2 - MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); + Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); #endif - MenuPrint(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1); + Menu_PrintText(gSystemText_SaveFailedBackupCheck, 2, MSG_WIN_TOP + 1); } wipeTries++; @@ -181,19 +181,19 @@ static void CB2_WipeSave(void) if (wipeTries == 3) { - MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); - MenuPrint(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1); + Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); + Menu_PrintText(gSystemText_BackupDamagedGameContinue, 2, MSG_WIN_TOP + 1); SetMainCallback2(CB2_FadeAndReturnToTitleScreen); // called again below } else { - MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); + Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); // no callback exists, so the game cannot continue. if (gGameContinueCallback == 0) - MenuPrint(gSystemText_SaveCompletedGameEnd, 2, MSG_WIN_TOP + 1); + Menu_PrintText(gSystemText_SaveCompletedGameEnd, 2, MSG_WIN_TOP + 1); else // callback exists, so continue - MenuPrint(gSystemText_SaveCompletedPressA, 2, MSG_WIN_TOP + 1); + Menu_PrintText(gSystemText_SaveCompletedPressA, 2, MSG_WIN_TOP + 1); } SetMainCallback2(CB2_FadeAndReturnToTitleScreen); @@ -205,8 +205,8 @@ static void CB2_GameplayCannotBeContinued(void) if (gMain.newKeys & A_BUTTON) { - MenuDrawTextWindow(1, MSG_WIN_TOP, 28, 19); - MenuPrint(gSystemText_GameplayEnded, 2, MSG_WIN_TOP + 1); + Menu_DrawStdWindowFrame(1, MSG_WIN_TOP, 28, 19); + Menu_PrintText(gSystemText_GameplayEnded, 2, MSG_WIN_TOP + 1); SetVBlankCallback(VBlankCB); SetMainCallback2(CB2_FadeAndReturnToTitleScreen); } diff --git a/src/engine/save_menu_util.c b/src/engine/save_menu_util.c index 771cb72c7..2c5eb6afe 100644 --- a/src/engine/save_menu_util.c +++ b/src/engine/save_menu_util.c @@ -18,7 +18,7 @@ void HandleDrawSaveWindowInfo(s16 left, s16 top) if (FlagGet(FLAG_SYS_POKEDEX_GET)) { // print info + dex information. - MenuDrawTextWindow(left, top, left + width, top + 11); + Menu_DrawStdWindowFrame(left, top, left + width, top + 11); PrintSaveMapName(++left, ++top); // MAP NAME PrintSavePlayerName(left, top + 2); // PLAYER PrintSaveBadges(left, top + 4); // BADGES @@ -28,7 +28,7 @@ void HandleDrawSaveWindowInfo(s16 left, s16 top) else { // print everything besides dex. - MenuDrawTextWindow(left, top, left + width, top + 9); + Menu_DrawStdWindowFrame(left, top, left + width, top + 9); PrintSaveMapName(++left, ++top); // MAP NAME PrintSavePlayerName(left, top + 2); // PLAYER PrintSaveBadges(left, top + 4); // BADGES @@ -45,9 +45,9 @@ void HandleCloseSaveWindow(u16 left, u16 top) width = 13; if (FlagGet(FLAG_SYS_POKEDEX_GET)) - MenuZeroFillWindowRect(left, top, left + width, top + 11); + Menu_EraseWindowRect(left, top, left + width, top + 11); else - MenuZeroFillWindowRect(left, top, left + width, top + 9); + Menu_EraseWindowRect(left, top, left + width, top + 9); } /* @@ -62,7 +62,7 @@ u8 IsResizeSaveWindowEnabled(void) // i don't know what else to name it.. void PrintSavePlayerName(s16 x, s16 y) { - MenuPrint(gOtherText_Player, x, y); + Menu_PrintText(gOtherText_Player, x, y); MenuPrint_RightAligned(gSaveBlock2.playerName, x + 12, y); } @@ -71,14 +71,14 @@ void PrintSaveMapName(s16 x, s16 y) char name[32]; CopyMapName(name, gMapHeader.regionMapSectionId); - MenuPrint(name, x, y); + Menu_PrintText(name, x, y); } void PrintSaveBadges(s16 x, s16 y) { char badges[16]; - MenuPrint(gOtherText_Badges, x, y); + Menu_PrintText(gOtherText_Badges, x, y); ConvertIntToDecimalString(badges, GetBadgeCount()); MenuPrint_RightAligned(badges, x + 12, y); } @@ -87,7 +87,7 @@ void PrintSavePokedexCount(s16 x, s16 y) { char pokedex[16]; - MenuPrint(gOtherText_Pokedex, x, y); + Menu_PrintText(gOtherText_Pokedex, x, y); ConvertIntToDecimalStringN(pokedex, GetPokedexSeenCount(), 1, 3); MenuPrint_RightAligned(pokedex, x + 12, y); } @@ -96,7 +96,7 @@ void PrintSavePlayTime(s16 x, s16 y) { char playtime[16]; - MenuPrint(gOtherText_PlayTime, x, y); + Menu_PrintText(gOtherText_PlayTime, x, y); FormatPlayTime(playtime, gSaveBlock2.playTimeHours, gSaveBlock2.playTimeMinutes, 1); MenuPrint_RightAligned(playtime, x + 12, y); } diff --git a/src/engine/text.c b/src/engine/text.c index 1b158d979..fe18a6d79 100644 --- a/src/engine/text.c +++ b/src/engine/text.c @@ -12,16 +12,31 @@ enum WIN_STATE_END, WIN_STATE_BEGIN, WIN_STATE_NORMAL, - WIN_STATE_INTERRUPTIBLE_PAUSE, + WIN_STATE_CHAR_DELAY, WIN_STATE_PAUSE, WIN_STATE_WAIT_BUTTON, WIN_STATE_NEWLINE, WIN_STATE_PLACEHOLDER, - WIN_STATE_PARAGRAPH, - WIN_STATE_NEWLINE_WAIT, + WIN_STATE_WAIT_CLEAR, + WIN_STATE_WAIT_SCROLL, WIN_STATE_WAIT_SOUND, }; +enum +{ + TEXT_MODE_UNKNOWN0, + TEXT_MODE_MONOSPACE, + TEXT_MODE_UNKNOWN2, // variable width? +}; + +enum +{ + WAIT_TYPE_NORMAL, // allows the player to interrupt the text delay with A or B + WAIT_TYPE_BATTLE, // disables interrupting the text delay if in a link battle + WAIT_TYPE_AUTOSCROLL, // disables interrupting the text delay + WAIT_TYPE_CONTEST, // disables interrupting the text delay if in a link contest +}; + struct Font { u32 type; @@ -66,7 +81,7 @@ static u16 LoadFixedWidthFont_Font4Latin(struct Window *, u16); static u16 LoadFixedWidthFont_Braille(struct Window *, u16); static void MultistepLoadFont_LoadGlyph(struct Window *, u16, u8); static u8 sub_8002FA0(struct Window *, const u8 *); -static u8 InterpretText(struct Window *); +static u8 PrintNextChar(struct Window *); static u8 HandleExtCtrlCode(struct Window *); static u8 UpdateWindowText(struct Window *); static u8 DrawGlyph_TextMode0(struct Window *, u32); @@ -82,27 +97,27 @@ static void AddToCursorX(struct Window *, u8); static void AddToCursorY(struct Window *, u8); static void ClipLeft(struct Window *); static void ClipRight(struct Window *); -static void InitColors(struct Window *); -static void SetBackgroundColor(struct Window *, u8); -static void SetShadowColor(struct Window *, u8); -static void SetForegroundColor(struct Window *, u8); +static void SetWindowDefaultColors(struct Window *); +static void SetWindowBackgroundColor(struct Window *, u8); +static void SetWindowShadowColor(struct Window *, u8); +static void SetWindowForegroundColor(struct Window *, u8); static u8 GetTextDelay(struct Window *); -static bool8 PlayerCanInterruptWait(struct Window *); +static bool8 PlayerCanInterruptDelay(struct Window *); static void ScrollWindowTextLines(struct Window *); static void ScrollWindowTextLines_TextMode0(struct Window *); static void DoScroll_TextMode0(struct Window *, u16); -static void ScrollWindowTextLines_TextMode1(struct Window *); -static void DoScroll_TextMode1(struct Window *, u16); +static void ScrollWindowTextLines_TextModeMonospace(struct Window *); +static void DoScroll_TextModeMonospace(struct Window *, u16); static void ScrollWindowTextLines_TextMode2(struct Window *); static void DoScroll_TextMode2(struct Window *, u8); -void ClearWindowTextLines(struct Window *); +void Text_ClearWindow(struct Window *); static void ClearWindowTextLines_TextMode0_TextMode1(struct Window *, u8); static void ClearWindowTextLines_TextMode2(struct Window *, u8); static void TryEraseDownArrow(struct Window *); static u16 GetBlankTileNum(struct Window *); static u8 WaitWithDownArrow(struct Window *); static void DrawInitialDownArrow(struct Window *); -static void DrawMovingDownArrow(struct Window *); +static void UpdateDownArrowAnimation(struct Window *); static u16 GetCursorTileNum(struct Window *, u32, u32); static s32 DrawGlyphTiles(struct Window *, u32, u32); static void UpdateTilemap(struct Window *, u32); @@ -477,7 +492,7 @@ static const ShiftGlyphTileShadowedFunc sShiftGlyphTileShadowedFuncs[] = ShiftGlyphTile_ShadowedFont_Width8, }; -const struct WindowConfig gWindowConfig_81E6C3C = +const struct WindowTemplate gWindowTemplate_81E6C3C = { 0, // BG number 2, // BG character base block @@ -498,7 +513,7 @@ const struct WindowConfig gWindowConfig_81E6C3C = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6C58 = +const struct WindowTemplate gWindowTemplate_81E6C58 = { 0, // BG number 0, // BG character base block @@ -519,7 +534,7 @@ const struct WindowConfig gWindowConfig_81E6C58 = BG_SCREEN_ADDR(24), // tilemap }; -const struct WindowConfig gWindowConfig_81E6C74 = +const struct WindowTemplate gWindowTemplate_81E6C74 = { 0, // BG number 0, // BG character base block @@ -540,7 +555,7 @@ const struct WindowConfig gWindowConfig_81E6C74 = NULL, // tilemap }; -const struct WindowConfig gWindowConfig_81E6C90 = +const struct WindowTemplate gWindowTemplate_81E6C90 = { 0, // BG number 1, // BG character base block @@ -561,7 +576,7 @@ const struct WindowConfig gWindowConfig_81E6C90 = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E6CAC = +const struct WindowTemplate gWindowTemplate_81E6CAC = { 0, // BG number 0, // BG character base block @@ -582,7 +597,7 @@ const struct WindowConfig gWindowConfig_81E6CAC = NULL, // tilemap }; -const struct WindowConfig gWindowConfig_81E6CC8 = +const struct WindowTemplate gWindowTemplate_81E6CC8 = { 2, // BG number 2, // BG character base block @@ -603,7 +618,7 @@ const struct WindowConfig gWindowConfig_81E6CC8 = BG_SCREEN_ADDR(15), // tilemap }; -const struct WindowConfig gWindowConfig_81E6CE4 = +const struct WindowTemplate gWindowTemplate_81E6CE4 = { 0, // BG number 2, // BG character base block @@ -624,7 +639,7 @@ const struct WindowConfig gWindowConfig_81E6CE4 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6D00 = +const struct WindowTemplate gWindowTemplate_81E6D00 = { 0, // BG number 0, // BG character base block @@ -645,7 +660,7 @@ const struct WindowConfig gWindowConfig_81E6D00 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6D1C = +const struct WindowTemplate gWindowTemplate_81E6D1C = { 1, // BG number 0, // BG character base block @@ -666,7 +681,7 @@ const struct WindowConfig gWindowConfig_81E6D1C = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6D38 = +const struct WindowTemplate gWindowTemplate_81E6D38 = { 0, // BG number 0, // BG character base block @@ -687,7 +702,7 @@ const struct WindowConfig gWindowConfig_81E6D38 = NULL, // tilemap }; -const struct WindowConfig gWindowConfig_81E6D54 = +const struct WindowTemplate gWindowTemplate_81E6D54 = { 3, // BG number 3, // BG character base block @@ -708,7 +723,7 @@ const struct WindowConfig gWindowConfig_81E6D54 = BG_SCREEN_ADDR(15), // tilemap }; -const struct WindowConfig gWindowConfig_81E6D70 = +const struct WindowTemplate gWindowTemplate_81E6D70 = { 3, // BG number 3, // BG character base block @@ -729,7 +744,7 @@ const struct WindowConfig gWindowConfig_81E6D70 = BG_SCREEN_ADDR(15), // tilemap }; -const struct WindowConfig gWindowConfig_81E6D8C = +const struct WindowTemplate gWindowTemplate_81E6D8C = { 1, // BG number 0, // BG character base block @@ -750,7 +765,7 @@ const struct WindowConfig gWindowConfig_81E6D8C = BG_SCREEN_ADDR(14), // tilemap }; -const struct WindowConfig gWindowConfig_81E6DA8 = +const struct WindowTemplate gWindowTemplate_81E6DA8 = { 0, // BG number 0, // BG character base block @@ -771,7 +786,7 @@ const struct WindowConfig gWindowConfig_81E6DA8 = BG_SCREEN_ADDR(11), // tilemap }; -const struct WindowConfig WindowConfig_TrainerCard_Back_Values = +const struct WindowTemplate gWindowTemplate_TrainerCard_Back_Values = { 0, // BG number 2, // BG character base block @@ -792,7 +807,7 @@ const struct WindowConfig WindowConfig_TrainerCard_Back_Values = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig WindowConfig_TrainerCard_Back_Labels = +const struct WindowTemplate gWindowTemplate_TrainerCard_Back_Labels = { 0, // BG number 2, // BG character base block @@ -813,7 +828,7 @@ const struct WindowConfig WindowConfig_TrainerCard_Back_Labels = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E6DFC = +const struct WindowTemplate gWindowTemplate_81E6DFC = { 0, // BG number 2, // BG character base block @@ -834,7 +849,7 @@ const struct WindowConfig gWindowConfig_81E6DFC = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6E18 = +const struct WindowTemplate gWindowTemplate_81E6E18 = { 0, // BG number 2, // BG character base block @@ -855,7 +870,7 @@ const struct WindowConfig gWindowConfig_81E6E18 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6E34 = +const struct WindowTemplate gWindowTemplate_81E6E34 = { 1, // BG number 0, // BG character base block @@ -876,7 +891,7 @@ const struct WindowConfig gWindowConfig_81E6E34 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6E50 = +const struct WindowTemplate gWindowTemplate_81E6E50 = { 0, // BG number 2, // BG character base block @@ -897,7 +912,7 @@ const struct WindowConfig gWindowConfig_81E6E50 = BG_SCREEN_ADDR(28), // tilemap }; -const struct WindowConfig gWindowConfig_81E6E6C = +const struct WindowTemplate gWindowTemplate_81E6E6C = { 0, // BG number 2, // BG character base block @@ -918,7 +933,7 @@ const struct WindowConfig gWindowConfig_81E6E6C = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E6E88 = +const struct WindowTemplate gWindowTemplate_81E6E88 = { 0, // BG number 0, // BG character base block @@ -939,7 +954,7 @@ const struct WindowConfig gWindowConfig_81E6E88 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6EA4 = +const struct WindowTemplate gWindowTemplate_81E6EA4 = { 1, // BG number 0, // BG character base block @@ -960,7 +975,7 @@ const struct WindowConfig gWindowConfig_81E6EA4 = BG_SCREEN_ADDR(28), // tilemap }; -const struct WindowConfig gWindowConfig_81E6EC0 = +const struct WindowTemplate gWindowTemplate_81E6EC0 = { 2, // BG number 2, // BG character base block @@ -981,7 +996,7 @@ const struct WindowConfig gWindowConfig_81E6EC0 = BG_SCREEN_ADDR(29), // tilemap }; -const struct WindowConfig gWindowConfig_81E6EDC = +const struct WindowTemplate gWindowTemplate_81E6EDC = { 1, // BG number 0, // BG character base block @@ -1002,7 +1017,7 @@ const struct WindowConfig gWindowConfig_81E6EDC = BG_SCREEN_ADDR(28), // tilemap }; -const struct WindowConfig gWindowConfig_81E6EF8 = +const struct WindowTemplate gWindowTemplate_81E6EF8 = { 2, // BG number 2, // BG character base block @@ -1023,7 +1038,7 @@ const struct WindowConfig gWindowConfig_81E6EF8 = BG_SCREEN_ADDR(29), // tilemap }; -const struct WindowConfig gWindowConfig_81E6F14 = +const struct WindowTemplate gWindowTemplate_81E6F14 = { 1, // BG number 0, // BG character base block @@ -1044,7 +1059,7 @@ const struct WindowConfig gWindowConfig_81E6F14 = BG_SCREEN_ADDR(28), // tilemap }; -const struct WindowConfig gWindowConfig_81E6F30 = +const struct WindowTemplate gWindowTemplate_81E6F30 = { 2, // BG number 2, // BG character base block @@ -1065,7 +1080,7 @@ const struct WindowConfig gWindowConfig_81E6F30 = BG_SCREEN_ADDR(29), // tilemap }; -const struct WindowConfig gWindowConfig_81E6F4C = +const struct WindowTemplate gWindowTemplate_81E6F4C = { 3, // BG number 0, // BG character base block @@ -1086,7 +1101,7 @@ const struct WindowConfig gWindowConfig_81E6F4C = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E6F68 = +const struct WindowTemplate gWindowTemplate_81E6F68 = { 0, // BG number 2, // BG character base block @@ -1107,7 +1122,7 @@ const struct WindowConfig gWindowConfig_81E6F68 = BG_SCREEN_ADDR(13), // tilemap }; -const struct WindowConfig gWindowConfig_81E6F84 = +const struct WindowTemplate gWindowTemplate_81E6F84 = { 0, // BG number 2, // BG character base block @@ -1128,7 +1143,7 @@ const struct WindowConfig gWindowConfig_81E6F84 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E6FA0 = +const struct WindowTemplate gWindowTemplate_81E6FA0 = { 1, // BG number 0, // BG character base block @@ -1149,7 +1164,7 @@ const struct WindowConfig gWindowConfig_81E6FA0 = BG_SCREEN_ADDR(24), // tilemap }; -const struct WindowConfig gWindowConfig_81E6FBC = +const struct WindowTemplate gWindowTemplate_81E6FBC = { 0, // BG number 0, // BG character base block @@ -1170,7 +1185,7 @@ const struct WindowConfig gWindowConfig_81E6FBC = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E6FD8 = +const struct WindowTemplate gWindowTemplate_81E6FD8 = { 0, // BG number 0, // BG character base block @@ -1191,7 +1206,7 @@ const struct WindowConfig gWindowConfig_81E6FD8 = BG_SCREEN_ADDR(24), // tilemap }; -const struct WindowConfig gWindowConfig_81E6FF4 = +const struct WindowTemplate gWindowTemplate_81E6FF4 = { 0, // BG number 0, // BG character base block @@ -1212,7 +1227,7 @@ const struct WindowConfig gWindowConfig_81E6FF4 = BG_SCREEN_ADDR(24), // tilemap }; -const struct WindowConfig gWindowConfig_81E7010 = +const struct WindowTemplate gWindowTemplate_81E7010 = { 0, // BG number 0, // BG character base block @@ -1233,7 +1248,7 @@ const struct WindowConfig gWindowConfig_81E7010 = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E702C = +const struct WindowTemplate gWindowTemplate_81E702C = { 3, // BG number 2, // BG character base block @@ -1254,7 +1269,7 @@ const struct WindowConfig gWindowConfig_81E702C = BG_SCREEN_ADDR(15), // tilemap }; -const struct WindowConfig gWindowConfig_81E7048 = +const struct WindowTemplate gWindowTemplate_81E7048 = { 2, // BG number 2, // BG character base block @@ -1275,7 +1290,7 @@ const struct WindowConfig gWindowConfig_81E7048 = BG_SCREEN_ADDR(14), // tilemap }; -const struct WindowConfig gWindowConfig_81E7064 = +const struct WindowTemplate gWindowTemplate_81E7064 = { 2, // BG number 2, // BG character base block @@ -1296,7 +1311,7 @@ const struct WindowConfig gWindowConfig_81E7064 = BG_SCREEN_ADDR(14), // tilemap }; -const struct WindowConfig gWindowConfig_81E7080 = +const struct WindowTemplate gWindowTemplate_81E7080 = { 3, // BG number 0, // BG character base block @@ -1317,7 +1332,7 @@ const struct WindowConfig gWindowConfig_81E7080 = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E709C = +const struct WindowTemplate gWindowTemplate_81E709C = { 0, // BG number 0, // BG character base block @@ -1338,7 +1353,7 @@ const struct WindowConfig gWindowConfig_81E709C = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E70B8 = +const struct WindowTemplate gWindowTemplate_81E70B8 = { 2, // BG number 0, // BG character base block @@ -1359,7 +1374,7 @@ const struct WindowConfig gWindowConfig_81E70B8 = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E70D4 = +const struct WindowTemplate gWindowTemplate_81E70D4 = { 3, // BG number 0, // BG character base block @@ -1380,7 +1395,7 @@ const struct WindowConfig gWindowConfig_81E70D4 = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E70F0 = +const struct WindowTemplate gWindowTemplate_81E70F0 = { 0, // BG number 0, // BG character base block @@ -1401,7 +1416,7 @@ const struct WindowConfig gWindowConfig_81E70F0 = NULL, // tilemap }; -const struct WindowConfig gWindowConfig_81E710C = +const struct WindowTemplate gWindowTemplate_81E710C = { 0, // BG number 0, // BG character base block @@ -1422,7 +1437,7 @@ const struct WindowConfig gWindowConfig_81E710C = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E7128 = +const struct WindowTemplate gWindowTemplate_81E7128 = { 0, // BG number 2, // BG character base block @@ -1443,7 +1458,7 @@ const struct WindowConfig gWindowConfig_81E7128 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E7144 = +const struct WindowTemplate gWindowTemplate_81E7144 = { 0, // BG number 2, // BG character base block @@ -1464,7 +1479,7 @@ const struct WindowConfig gWindowConfig_81E7144 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E7160 = +const struct WindowTemplate gWindowTemplate_81E7160 = { 1, // BG number 1, // BG character base block @@ -1485,7 +1500,7 @@ const struct WindowConfig gWindowConfig_81E7160 = BG_SCREEN_ADDR(10), // tilemap }; -const struct WindowConfig gWindowConfig_81E717C = +const struct WindowTemplate gWindowTemplate_81E717C = { 0, // BG number 3, // BG character base block @@ -1506,7 +1521,7 @@ const struct WindowConfig gWindowConfig_81E717C = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E7198 = +const struct WindowTemplate gWindowTemplate_81E7198 = { 0, // BG number 2, // BG character base block @@ -1527,7 +1542,7 @@ const struct WindowConfig gWindowConfig_81E7198 = BG_SCREEN_ADDR(15), // tilemap }; -const struct WindowConfig gWindowConfig_81E71B4 = +const struct WindowTemplate gWindowTemplate_81E71B4 = { 0, // BG number 2, // BG character base block @@ -1548,7 +1563,7 @@ const struct WindowConfig gWindowConfig_81E71B4 = BG_SCREEN_ADDR(15), // tilemap }; -const struct WindowConfig gWindowConfig_81E71D0 = +const struct WindowTemplate gWindowTemplate_81E71D0 = { 1, // BG number 1, // BG character base block @@ -1569,7 +1584,7 @@ const struct WindowConfig gWindowConfig_81E71D0 = BG_SCREEN_ADDR(28), // tilemap }; -const struct WindowConfig gWindowConfig_81E71EC = +const struct WindowTemplate gWindowTemplate_81E71EC = { 2, // BG number 1, // BG character base block @@ -1590,7 +1605,7 @@ const struct WindowConfig gWindowConfig_81E71EC = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E7208 = +const struct WindowTemplate gWindowTemplate_81E7208 = { 0, // BG number 2, // BG character base block @@ -1611,7 +1626,7 @@ const struct WindowConfig gWindowConfig_81E7208 = BG_SCREEN_ADDR(28), // tilemap }; -const struct WindowConfig gWindowConfig_81E7224 = +const struct WindowTemplate gWindowTemplate_81E7224 = { 0, // BG number 0, // BG character base block @@ -1632,7 +1647,7 @@ const struct WindowConfig gWindowConfig_81E7224 = BG_SCREEN_ADDR(31), // tilemap }; -const struct WindowConfig gWindowConfig_81E7240 = +const struct WindowTemplate gWindowTemplate_81E7240 = { 1, // BG number 2, // BG character base block @@ -1653,7 +1668,7 @@ const struct WindowConfig gWindowConfig_81E7240 = BG_SCREEN_ADDR(30), // tilemap }; -const struct WindowConfig gWindowConfig_81E725C = +const struct WindowTemplate gWindowTemplate_81E725C = { 0, // BG number 0, // BG character base block @@ -1674,7 +1689,7 @@ const struct WindowConfig gWindowConfig_81E725C = NULL, // tilemap }; -const struct WindowConfig gWindowConfig_81E7278 = +const struct WindowTemplate gWindowTemplate_81E7278 = { 0, // BG number 0, // BG character base block @@ -1695,7 +1710,7 @@ const struct WindowConfig gWindowConfig_81E7278 = NULL, // tilemap }; -const struct WindowConfig gWindowConfig_81E7294 = +const struct WindowTemplate gWindowTemplate_81E7294 = { 0, // BG number 0, // BG character base block @@ -1716,32 +1731,32 @@ const struct WindowConfig gWindowConfig_81E7294 = NULL, // tilemap }; -static void UpdateBGRegs(const struct WindowConfig *winConfig) +static void UpdateBGRegs(const struct WindowTemplate *winTemplate) { - u8 bgNum = winConfig->bgNum; + u8 bgNum = winTemplate->bgNum; *gBGHOffsetRegs[bgNum] = 0; *gBGVOffsetRegs[bgNum] = 0; - *gBGControlRegs[bgNum] = winConfig->priority | (winConfig->screenBaseBlock << 8) | (winConfig->charBaseBlock << 2); + *gBGControlRegs[bgNum] = winTemplate->priority | (winTemplate->screenBaseBlock << 8) | (winTemplate->charBaseBlock << 2); } -static void ClearBGMem(const struct WindowConfig *winConfig) +static void ClearBGMem(const struct WindowTemplate *winTemplate) { - CpuFastFill(0, winConfig->tileData, 32); + CpuFastFill(0, winTemplate->tileData, 32); - if (winConfig->tilemap) - CpuFastFill(0, winConfig->tilemap, 0x800); + if (winTemplate->tilemap) + CpuFastFill(0, winTemplate->tilemap, 0x800); } -void LoadFontDefaultPalette(const struct WindowConfig *winConfig) +void LoadFontDefaultPalette(const struct WindowTemplate *winTemplate) { - LoadPalette(gFontDefaultPalette, 16 * winConfig->paletteNum, 32); + LoadPalette(gFontDefaultPalette, 16 * winTemplate->paletteNum, 32); } -void SetUpWindowConfig(const struct WindowConfig *winConfig) +void Text_LoadWindowTemplate(const struct WindowTemplate *winTemplate) { - UpdateBGRegs(winConfig); - ClearBGMem(winConfig); - LoadFontDefaultPalette(winConfig); + UpdateBGRegs(winTemplate); + ClearBGMem(winTemplate); + LoadFontDefaultPalette(winTemplate); } u16 InitWindowTileData(struct Window *win, u16 startOffset) @@ -1751,13 +1766,13 @@ u16 InitWindowTileData(struct Window *win, u16 startOffset) win->tileDataStartOffset = startOffset; retVal = 0; - switch (win->config->textMode) + switch (win->template->textMode) { - case 2: + case TEXT_MODE_UNKNOWN2: retVal = InitVariableWidthFontTileData(win, startOffset); break; - case 1: - switch (win->config->fontNum) + case TEXT_MODE_MONOSPACE: + switch (win->template->fontNum) { case 0: case 3: @@ -1789,7 +1804,7 @@ static u16 InitVariableWidthFontTileData(struct Window *win, u16 startOffset) win->tileDataOffset = 2; buffer = win->tileData + 32 * win->tileDataStartOffset; CpuFastFill(0, buffer, 32); - ApplyColors_UnshadowedFont(sBlankTile, (u32 *)(buffer + 32), win->config->foregroundColor, win->config->backgroundColor); + ApplyColors_UnshadowedFont(sBlankTile, (u32 *)(buffer + 32), win->template->foregroundColor, win->template->backgroundColor); return win->tileDataStartOffset + win->tileDataOffset + win->width * win->height; } @@ -1850,15 +1865,15 @@ u32 MultistepInitWindowTileData(struct Window *win, u16 startOffset) win->tileDataStartOffset = startOffset; retVal = 0; - switch (win->config->textMode) + switch (win->template->textMode) { - case 2: + case TEXT_MODE_UNKNOWN2: retVal = InitVariableWidthFontTileData(win, startOffset); break; - case 1: + case TEXT_MODE_MONOSPACE: retVal = 256; - if (win->config->fontNum == 0 - || win->config->fontNum == 3) + if (win->template->fontNum == 0 + || win->template->fontNum == 3) retVal *= 2; break; } @@ -1870,7 +1885,7 @@ bool32 MultistepLoadFont(void) { bool32 retVal = TRUE; - if (sMultistepLoadFont_Window->config->textMode == 1) + if (sMultistepLoadFont_Window->template->textMode == TEXT_MODE_MONOSPACE) { s32 i; @@ -1890,7 +1905,7 @@ static void MultistepLoadFont_LoadGlyph(struct Window *win, u16 startOffset, u8 { u8 *buffer; - switch (win->config->fontNum) + switch (win->template->fontNum) { case 0: case 3: @@ -1923,42 +1938,42 @@ void EmptyFunc(void) { } -void InitWindowFromConfig(struct Window *win, const struct WindowConfig *winConfig) +void Text_InitWindowWithTemplate(struct Window *win, const struct WindowTemplate *winTemplate) { *win = sDefaultWindow; - win->config = (struct WindowConfig *)winConfig; - win->textMode = winConfig->textMode; - win->spacing = winConfig->spacing; - win->fontNum = winConfig->fontNum; - win->paletteNum = winConfig->paletteNum; - win->tilemapLeft = winConfig->tilemapLeft; - win->tilemapTop = winConfig->tilemapTop; - win->width = winConfig->width; - win->height = winConfig->height; - win->tileData = winConfig->tileData; - win->tilemap = winConfig->tilemap; - InitColors(win); - SetBackgroundColor(win, winConfig->backgroundColor); - SetShadowColor(win, winConfig->shadowColor); - SetForegroundColor(win, winConfig->foregroundColor); -} - -void InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top) -{ - const struct WindowConfig *winConfig = win->config; - win->textMode = winConfig->textMode; - win->fontNum = winConfig->fontNum; + win->template = (struct WindowTemplate *)winTemplate; + win->textMode = winTemplate->textMode; + win->spacing = winTemplate->spacing; + win->fontNum = winTemplate->fontNum; + win->paletteNum = winTemplate->paletteNum; + win->tilemapLeft = winTemplate->tilemapLeft; + win->tilemapTop = winTemplate->tilemapTop; + win->width = winTemplate->width; + win->height = winTemplate->height; + win->tileData = winTemplate->tileData; + win->tilemap = winTemplate->tilemap; + SetWindowDefaultColors(win); + SetWindowBackgroundColor(win, winTemplate->backgroundColor); + SetWindowShadowColor(win, winTemplate->shadowColor); + SetWindowForegroundColor(win, winTemplate->foregroundColor); +} + +void Text_InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top) +{ + const struct WindowTemplate *winTemplate = win->template; + win->textMode = winTemplate->textMode; + win->fontNum = winTemplate->fontNum; win->language = GAME_LANGUAGE; - win->paletteNum = winConfig->paletteNum; + win->paletteNum = winTemplate->paletteNum; win->win_field_B = 0; win->win_field_C = 0; win->delayCounter = 0; - win->spacing = winConfig->spacing; + win->spacing = winTemplate->spacing; win->win_field_F = 0; - win->tilemapLeft = winConfig->tilemapLeft; - win->tilemapTop = winConfig->tilemapTop; - win->width = winConfig->width; - win->height = winConfig->height; + win->tilemapLeft = winTemplate->tilemapLeft; + win->tilemapTop = winTemplate->tilemapTop; + win->width = winTemplate->width; + win->height = winTemplate->height; win->text = text; win->textIndex = 0; win->tileDataStartOffset = tileDataStartOffset; @@ -1969,19 +1984,19 @@ void InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 win->cursorY = 0; win->state = WIN_STATE_BEGIN; win->downArrowCounter = 0; - win->tileData = winConfig->tileData; - win->tilemap = winConfig->tilemap; - InitColors(win); - SetBackgroundColor(win, winConfig->backgroundColor); - SetShadowColor(win, winConfig->shadowColor); - SetForegroundColor(win, winConfig->foregroundColor); + win->tileData = winTemplate->tileData; + win->tilemap = winTemplate->tilemap; + SetWindowDefaultColors(win); + SetWindowBackgroundColor(win, winTemplate->backgroundColor); + SetWindowShadowColor(win, winTemplate->shadowColor); + SetWindowForegroundColor(win, winTemplate->foregroundColor); } -void sub_8002E4C(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6) +void Text_InitWindow8002E4C(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6) { u8 val; - InitWindow(win, text, tileDataStartOffset, 0, 0); + Text_InitWindow(win, text, tileDataStartOffset, 0, 0); win->left = left; win->top = top; val = 0; @@ -1992,7 +2007,7 @@ void sub_8002E4C(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 ClipLeft(win); } -void sub_8002E90(struct Window *win, const u8 *text) +void Text_SetWindowText(struct Window *win, const u8 *text) { win->state = WIN_STATE_NORMAL; win->text = text; @@ -2003,15 +2018,15 @@ void sub_8002E90(struct Window *win, const u8 *text) win->delayCounter = 0; } -void sub_8002EB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top) +void Text_InitWindow8002EB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top) { gMain.watchedKeysMask = A_BUTTON | B_BUTTON; gMain.watchedKeysPressed = 0; - sWaitType = 0; + sWaitType = WAIT_TYPE_NORMAL; sLineLength = 26; - InitWindow(win, text, tileDataStartOffset, left, top); + Text_InitWindow(win, text, tileDataStartOffset, left, top); win->win_field_B = -1; - if (win->textMode == 0) + if (win->textMode == TEXT_MODE_UNKNOWN0) { u16 val = GetCursorTileNum(win, 0, 0); u8 *buffer = win->tileData + 32 * val; @@ -2021,9 +2036,9 @@ void sub_8002EB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 } } -u8 sub_8002F44(struct Window *win) +u8 Text_PrintWindow8002F44(struct Window *win) { - while (win->state) + while (win->state != WIN_STATE_END) { if (win->state == WIN_STATE_NEWLINE) { @@ -2038,7 +2053,7 @@ u8 sub_8002F44(struct Window *win) sub_8002FA0(win, GetExpandedPlaceholder(win->text[win->textIndex++])); } - InterpretText(win); + PrintNextChar(win); } return 1; } @@ -2048,11 +2063,12 @@ static u8 sub_8002FA0(struct Window *win, const u8 *text) u8 retVal; u8 savedLanguage = win->language; const u8 *savedText = win->text; + u16 savedTextIndex = win->textIndex; win->text = text; win->textIndex = 0; win->state = WIN_STATE_NORMAL; - retVal = sub_8002F44(win); + retVal = Text_PrintWindow8002F44(win); win->text = savedText; win->textIndex = savedTextIndex; win->state = WIN_STATE_NORMAL; @@ -2060,32 +2076,33 @@ static u8 sub_8002FA0(struct Window *win, const u8 *text) return retVal; } -static u8 InterpretText(struct Window *win) +static u8 PrintNextChar(struct Window *win) { u8 c = win->text[win->textIndex++]; + // Handle special control characters switch (c) { - case 0xFF: + case EOS: ClipRight(win); win->state = WIN_STATE_END; return 0; - case 0xFD: + case PLACEHOLDER_BEGIN: win->state = WIN_STATE_PLACEHOLDER; return 2; - case 0xFE: + case CHAR_NEWLINE: ClipRight(win); win->state = WIN_STATE_NEWLINE; return 2; - case 0xFB: + case CHAR_PROMPT_CLEAR: DrawInitialDownArrow(win); - win->state = WIN_STATE_PARAGRAPH; + win->state = WIN_STATE_WAIT_CLEAR; return 2; - case 0xFA: + case CHAR_PROMPT_SCROLL: DrawInitialDownArrow(win); - win->state = WIN_STATE_NEWLINE_WAIT; + win->state = WIN_STATE_WAIT_SCROLL; return 2; - case 0xFC: + case EXT_CTRL_CODE_BEGIN: return HandleExtCtrlCode(win); } @@ -2093,6 +2110,8 @@ static u8 InterpretText(struct Window *win) return 1; } +// Extended 0xFC control functions + static u8 HandleExtCtrlCode(struct Window *win) { return sExtCtrlCodeFuncs[win->text[win->textIndex++]](win); @@ -2105,27 +2124,27 @@ static u8 ExtCtrlCode_Nop(struct Window *win) static u8 ExtCtrlCode_ForegroundColor(struct Window *win) { - SetForegroundColor(win, win->text[win->textIndex++]); + SetWindowForegroundColor(win, win->text[win->textIndex++]); return 2; } static u8 ExtCtrlCode_BackgroundColor(struct Window *win) { - SetBackgroundColor(win, win->text[win->textIndex++]); + SetWindowBackgroundColor(win, win->text[win->textIndex++]); return 2; } static u8 ExtCtrlCode_ShadowColor(struct Window *win) { - SetShadowColor(win, win->text[win->textIndex++]); + SetWindowShadowColor(win, win->text[win->textIndex++]); return 2; } static u8 ExtCtrlCode_AllColors(struct Window *win) { - SetForegroundColor(win, win->text[win->textIndex++]); - SetBackgroundColor(win, win->text[win->textIndex++]); - SetShadowColor(win, win->text[win->textIndex++]); + SetWindowForegroundColor(win, win->text[win->textIndex++]); + SetWindowBackgroundColor(win, win->text[win->textIndex++]); + SetWindowShadowColor(win, win->text[win->textIndex++]); return 2; } @@ -2143,7 +2162,7 @@ static u8 ExtCtrlCode_Font(struct Window *win) static u8 ExtCtrlCode_DefaultFont(struct Window *win) { - win->fontNum = win->config->fontNum; + win->fontNum = win->template->fontNum; return 2; } @@ -2197,7 +2216,7 @@ static u8 ExtCtrlCode_SetCursorY(struct Window *win) static u8 ExtCtrlCode_ClearWindowTextLines(struct Window *win) { - ClearWindowTextLines(win); + Text_ClearWindow(win); return 2; } @@ -2211,7 +2230,7 @@ static u8 ExtCtrlCode_PlaySE(struct Window *win) static void DrawSpace(struct Window *win) { - if (win->textMode == 1 || (win->left + win->cursorX) & 7 || win->spacing <= 7) + if (win->textMode == TEXT_MODE_MONOSPACE || (win->left + win->cursorX) & 7 || win->spacing <= 7) { sPrintGlyphFuncs[win->textMode](win, 0); } @@ -2302,10 +2321,11 @@ static u8 ExtCtrlCode_Latin(struct Window *win) return 2; } -u8 sub_8003418(struct Window *win) +// Prints the window text without expanding any placeholders +u8 Text_PrintWindowSimple(struct Window *win) { u8 retVal = 1; - while (win->state) + while (win->state != WIN_STATE_END) { if (win->state == WIN_STATE_NEWLINE) { @@ -2315,7 +2335,7 @@ u8 sub_8003418(struct Window *win) ClipLeft(win); win->state = WIN_STATE_NORMAL; } - if (InterpretText(win) == 1) + if (PrintNextChar(win) == 1) { retVal = 0; break; @@ -2324,10 +2344,10 @@ u8 sub_8003418(struct Window *win) return retVal; } -u8 sub_8003460(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top) +u8 Text_InitWindowAndPrintText(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top) { - InitWindow(win, text, tileDataStartOffset, left, top); - return sub_8002F44(win); + Text_InitWindow(win, text, tileDataStartOffset, left, top); + return Text_PrintWindow8002F44(win); } u8 sub_8003490(struct Window *win, u8 c, u16 tileDataStartOffset, u8 left, u8 top) @@ -2336,48 +2356,51 @@ u8 sub_8003490(struct Window *win, u8 c, u16 tileDataStartOffset, u8 left, u8 to u8 text[2]; text[0] = c; text[1] = EOS; - InitWindow(win, text, tileDataStartOffset, left, top); - retVal = InterpretText(win); + Text_InitWindow(win, text, tileDataStartOffset, left, top); + retVal = PrintNextChar(win); ClipRight(win); return retVal; } void sub_80034D4(u8 *tileData, const u8 *text) { - sub_8004E3C(&gWindowConfig_81E6C74, tileData, text); + Text_InitWindow8004E3C(&gWindowTemplate_81E6C74, tileData, text); } u8 sub_80034EC(u8 *str) { - return GetStringWidthGivenWindowConfig((struct WindowConfig *)&gWindowConfig_81E6C74, str); + return Text_GetStringWidthFromWindowTemplate((struct WindowTemplate *)&gWindowTemplate_81E6C74, str); } u8 *sub_8003504(u8 *dest, s32 value, u8 alignAmount, u8 alignType) { - sTempWindow.config = (struct WindowConfig *)&gWindowConfig_81E6C74; - InitWindow(&sTempWindow, 0, 0, 0, 0); + sTempWindow.template = (struct WindowTemplate *)&gWindowTemplate_81E6C74; + Text_InitWindow(&sTempWindow, 0, 0, 0, 0); return AlignInt2(&sTempWindow, dest, value, alignAmount, alignType); } u8 *sub_8003558(u8 *dest, const u8 *src, u8 alignAmount, u8 alignType) { - sTempWindow.config = (struct WindowConfig *)&gWindowConfig_81E6C74; - InitWindow(&sTempWindow, src, 0, 0, 0); + sTempWindow.template = (struct WindowTemplate *)&gWindowTemplate_81E6C74; + Text_InitWindow(&sTempWindow, src, 0, 0, 0); return AlignString(&sTempWindow, dest, src, alignAmount, alignType); } -u8 sub_80035AC(struct Window *win) +// Updates the window text +// The text delay can be accelerated by holding the A button +u8 Text_UpdateWindow(struct Window *win) { - sWaitType = 0; + sWaitType = WAIT_TYPE_NORMAL; return UpdateWindowText(win); } +// Returns TRUE when all of the text has been printed. static u8 UpdateWindowText(struct Window *win) { switch (win->state) { case WIN_STATE_WAIT_BUTTON: - if (PlayerCanInterruptWait(win)) + if (PlayerCanInterruptDelay(win)) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { @@ -2385,48 +2408,56 @@ static u8 UpdateWindowText(struct Window *win) } else { - return 0; + return FALSE; } } else { win->delayCounter--; if (win->delayCounter) - return 0; + return FALSE; } win->state = WIN_STATE_NORMAL; - return 0; - case WIN_STATE_INTERRUPTIBLE_PAUSE: - if (PlayerCanInterruptWait(win) && (gMain.heldKeys & (A_BUTTON | B_BUTTON)) && gMain.watchedKeysPressed == TRUE) + return FALSE; + case WIN_STATE_CHAR_DELAY: + // Allow the player to speed up text by holding a button + if (PlayerCanInterruptDelay(win) + && (gMain.heldKeys & (A_BUTTON | B_BUTTON)) + && gMain.watchedKeysPressed == TRUE) { win->delayCounter = 0; win->state = WIN_STATE_NORMAL; break; } + // fall through case WIN_STATE_PAUSE: + // Wait for timer to expire, then continue printing if (win->delayCounter) { win->delayCounter--; if (win->delayCounter) - return 0; + return FALSE; } - win->state = WIN_STATE_NORMAL; break; - case WIN_STATE_PARAGRAPH: - if (!WaitWithDownArrow(win)) - return 0; - ClearWindowTextLines(win); - win->state = WIN_STATE_NORMAL; - BLOCK_CROSS_JUMP - return 0; - case WIN_STATE_NEWLINE_WAIT: - if (!WaitWithDownArrow(win)) - return 0; - ScrollWindowTextLines(win); - win->state = WIN_STATE_NORMAL; - BLOCK_CROSS_JUMP - return 0; + case WIN_STATE_WAIT_CLEAR: + // Erase the text once a button is pressed + if (WaitWithDownArrow(win)) + { + Text_ClearWindow(win); + win->state = WIN_STATE_NORMAL; + asm(""); + } + return FALSE; + case WIN_STATE_WAIT_SCROLL: + // Scroll the text once a button is pressed + if (WaitWithDownArrow(win)) + { + ScrollWindowTextLines(win); + win->state = WIN_STATE_NORMAL; + asm(""); + } + return FALSE; case WIN_STATE_PLACEHOLDER: win->textIndex++; win->state = WIN_STATE_NORMAL; @@ -2434,35 +2465,35 @@ static u8 UpdateWindowText(struct Window *win) case WIN_STATE_NEWLINE: ScrollWindowTextLines(win); win->state = WIN_STATE_NORMAL; - BLOCK_CROSS_JUMP - return 0; + asm(""); + return FALSE; case WIN_STATE_BEGIN: - ClearWindowTextLines(win); + Text_ClearWindow(win); break; case WIN_STATE_WAIT_SOUND: if (IsSEPlaying()) - return 0; + return FALSE; win->state = WIN_STATE_NORMAL; break; case WIN_STATE_END: - return 1; + return TRUE; // done printing text case WIN_STATE_NORMAL: break; default: win->state = WIN_STATE_END; - return 1; + return TRUE; } - InterpretText(win); + PrintNextChar(win); switch (win->state) { case WIN_STATE_END: - return 1; + return TRUE; // done printing text case WIN_STATE_WAIT_BUTTON: - case WIN_STATE_PARAGRAPH: - case WIN_STATE_NEWLINE_WAIT: - if (PlayerCanInterruptWait(win)) + case WIN_STATE_WAIT_CLEAR: + case WIN_STATE_WAIT_SCROLL: + if (PlayerCanInterruptDelay(win)) return 0; win->delayCounter = 60; break; @@ -2471,8 +2502,9 @@ static u8 UpdateWindowText(struct Window *win) case WIN_STATE_WAIT_SOUND: break; default: - win->state = WIN_STATE_INTERRUPTIBLE_PAUSE; + win->state = WIN_STATE_CHAR_DELAY; win->delayCounter = GetTextDelay(win); + break; } return 0; @@ -2484,45 +2516,45 @@ static u8 UpdateWindowText(struct Window *win) #define SUB_800374C_LINE_LENGTH 27 #endif -u8 sub_800374C(struct Window *win) +u8 Text_UpdateWindowInBattle(struct Window *win) { u8 retVal; - sWaitType = 1; + sWaitType = WAIT_TYPE_BATTLE; sLineLength = SUB_800374C_LINE_LENGTH; retVal = UpdateWindowText(win); sLineLength = 26; - sWaitType = 0; + sWaitType = WAIT_TYPE_NORMAL; return retVal; } -u8 sub_8003778(struct Window *win) +u8 Text_UpdateWindowAutoscroll(struct Window *win) { u8 retVal; - sWaitType = 2; + sWaitType = WAIT_TYPE_AUTOSCROLL; sLineLength = 26; retVal = UpdateWindowText(win); - sWaitType = 0; + sWaitType = WAIT_TYPE_NORMAL; return retVal; } -u8 sub_80037A0(struct Window *win) +u8 Text_UpdateWindowInContest(struct Window *win) { u8 retVal; - sWaitType = 3; + sWaitType = WAIT_TYPE_CONTEST; sLineLength = 17; retVal = UpdateWindowText(win); sLineLength = 26; return retVal; } -u32 sub_80037C8(struct Window *win, u8 lineLength) +u32 Text_UpdateWindowOverrideLineLength(struct Window *win, u8 lineLength) { u8 retVal; - sWaitType = 0; + sWaitType = WAIT_TYPE_NORMAL; sLineLength = lineLength; retVal = UpdateWindowText(win); sLineLength = 26; @@ -2757,14 +2789,14 @@ static void ApplyColors_ShadowedFont(const void *src, void *dest, u8 foreground, static void SetCursorX(struct Window *win, u8 x) { - if (win->textMode == 0 && ((win->left + win->cursorX) & 7)) + if (win->textMode == TEXT_MODE_UNKNOWN0 && ((win->left + win->cursorX) & 7)) win->tileDataOffset += 2; win->cursorX = x; } static void AddToCursorX(struct Window *win, u8 deltaX) { - if (win->textMode == 0) + if (win->textMode == TEXT_MODE_UNKNOWN0) { u8 x = win->cursorX; win->cursorX += deltaX; @@ -2779,7 +2811,7 @@ static void AddToCursorX(struct Window *win, u8 deltaX) static void AddToCursorY(struct Window *win, u8 deltaY) { - if (win->textMode == 0 && ((win->left + win->cursorX) & 7)) + if (win->textMode == TEXT_MODE_UNKNOWN0 && ((win->left + win->cursorX) & 7)) win->tileDataOffset += 2; win->cursorY += deltaY; } @@ -2788,11 +2820,11 @@ static void EraseAtCursor(struct Window *win) { switch (win->textMode) { - case 0: - case 2: + case TEXT_MODE_UNKNOWN0: + case TEXT_MODE_UNKNOWN2: DrawGlyphTiles(win, 0, 8); break; - case 1: + case TEXT_MODE_MONOSPACE: sWriteGlyphTilemapFuncs[win->fontNum](win, 0); break; } @@ -2801,7 +2833,8 @@ static void EraseAtCursor(struct Window *win) static void ClipLeft(struct Window *win) { u32 pixel = win->left & 7; - if (win->textMode != 1 && pixel) + + if (win->textMode != TEXT_MODE_MONOSPACE && pixel) { const u32 *masks = sGlyphMasks[8][pixel]; u32 outsideMask = masks[0]; @@ -2834,37 +2867,45 @@ static void ClipRight(struct Window *win) { register u8 cursorX asm("r0") = win->cursorX; u8 left = win->left; - u32 pixel = (cursorX + left) & 7; - if (win->textMode != 1 && pixel) + u32 pixelX = (cursorX + left) & 7; + + if (win->textMode != TEXT_MODE_MONOSPACE && pixelX != 0) { - const u32 *masks = sGlyphMasks[8 - pixel][pixel]; + const u32 *masks = sGlyphMasks[8 - pixelX][pixelX]; u32 insideMask = masks[0]; u32 outside = (sGlyphBuffer.background & ~insideMask); - u16 tileNum = GetCursorTileNum(win, 0, 0); - u32 *buffer = (u32 *)(win->tileData + 32 * tileNum); - buffer[0] = (buffer[0] & insideMask) | outside; - buffer[1] = (buffer[1] & insideMask) | outside; - buffer[2] = (buffer[2] & insideMask) | outside; - buffer[3] = (buffer[3] & insideMask) | outside; - buffer[4] = (buffer[4] & insideMask) | outside; - buffer[5] = (buffer[5] & insideMask) | outside; - buffer[6] = (buffer[6] & insideMask) | outside; - buffer[7] = (buffer[7] & insideMask) | outside; + u16 tileNum; + u32 *tileData; + + tileNum = GetCursorTileNum(win, 0, 0); + tileData = (u32 *)(win->tileData + 32 * tileNum); + + tileData[0] = (tileData[0] & insideMask) | outside; + tileData[1] = (tileData[1] & insideMask) | outside; + tileData[2] = (tileData[2] & insideMask) | outside; + tileData[3] = (tileData[3] & insideMask) | outside; + tileData[4] = (tileData[4] & insideMask) | outside; + tileData[5] = (tileData[5] & insideMask) | outside; + tileData[6] = (tileData[6] & insideMask) | outside; + tileData[7] = (tileData[7] & insideMask) | outside; + tileNum = GetCursorTileNum(win, 0, 1); - buffer = (u32 *)(win->tileData + 32 * tileNum); - buffer[0] = (buffer[0] & insideMask) | outside; - buffer[1] = (buffer[1] & insideMask) | outside; - buffer[2] = (buffer[2] & insideMask) | outside; - buffer[3] = (buffer[3] & insideMask) | outside; - buffer[4] = (buffer[4] & insideMask) | outside; - buffer[5] = (buffer[5] & insideMask) | outside; - buffer[6] = (buffer[6] & insideMask) | outside; - buffer[7] = (buffer[7] & insideMask) | outside; + tileData = (u32 *)(win->tileData + 32 * tileNum); + + tileData[0] = (tileData[0] & insideMask) | outside; + tileData[1] = (tileData[1] & insideMask) | outside; + tileData[2] = (tileData[2] & insideMask) | outside; + tileData[3] = (tileData[3] & insideMask) | outside; + tileData[4] = (tileData[4] & insideMask) | outside; + tileData[5] = (tileData[5] & insideMask) | outside; + tileData[6] = (tileData[6] & insideMask) | outside; + tileData[7] = (tileData[7] & insideMask) | outside; + UpdateTilemap(win, 1); } } -static void InitColors(struct Window *win) +static void SetWindowDefaultColors(struct Window *win) { u32 i; @@ -2876,7 +2917,7 @@ static void InitColors(struct Window *win) sGlyphBuffer.colors[i] = i; } -static void SetBackgroundColor(struct Window *win, u8 color) +static void SetWindowBackgroundColor(struct Window *win, u8 color) { u32 val1; u32 val2; @@ -2889,13 +2930,13 @@ static void SetBackgroundColor(struct Window *win, u8 color) sGlyphBuffer.background = val3; } -static void SetShadowColor(struct Window *win, u8 color) +static void SetWindowShadowColor(struct Window *win, u8 color) { win->shadowColor = color; sGlyphBuffer.colors[14] = color; } -static void SetForegroundColor(struct Window *win, u8 color) +static void SetWindowForegroundColor(struct Window *win, u8 color) { win->foregroundColor = color; sGlyphBuffer.colors[15] = color; @@ -2903,25 +2944,25 @@ static void SetForegroundColor(struct Window *win, u8 color) static u8 GetTextDelay(struct Window *win) { - if (!PlayerCanInterruptWait(win)) + if (!PlayerCanInterruptDelay(win)) return 3; return sTextSpeedDelays[gSaveBlock2.optionsTextSpeed]; } -static bool8 PlayerCanInterruptWait(struct Window *win) +static bool8 PlayerCanInterruptDelay(struct Window *win) { bool8 retVal = TRUE; switch (sWaitType) { - case 2: + case WAIT_TYPE_AUTOSCROLL: retVal = FALSE; break; - case 3: + case WAIT_TYPE_CONTEST: retVal = gIsLinkContest ? FALSE : TRUE; break; - case 1: + case WAIT_TYPE_BATTLE: retVal = (gBattleTypeFlags & BATTLE_TYPE_LINK) ? FALSE : TRUE; break; } @@ -2933,13 +2974,13 @@ static void ScrollWindowTextLines(struct Window *win) { switch (win->textMode) { - case 0: + case TEXT_MODE_UNKNOWN0: ScrollWindowTextLines_TextMode0(win); break; - case 1: - ScrollWindowTextLines_TextMode1(win); + case TEXT_MODE_MONOSPACE: + ScrollWindowTextLines_TextModeMonospace(win); break; - case 2: + case TEXT_MODE_UNKNOWN2: ScrollWindowTextLines_TextMode2(win); break; } @@ -2949,6 +2990,7 @@ static void ScrollWindowTextLines_TextMode0(struct Window *win) { if (win->cursorY == 0) { + // Advance to the next line win->tileDataOffset = 2 * sLineLength + 2; win->cursorX = 0; win->cursorY += 16; @@ -2959,7 +3001,7 @@ static void ScrollWindowTextLines_TextMode0(struct Window *win) win->tileDataOffset = 2 * sLineLength + 2; else win->tileDataOffset = 2; - win->win_field_C = win->win_field_C ^ 2; + win->win_field_C ^= 2; win->cursorX = 0; DoScroll_TextMode0(win, sLineLength); } @@ -2973,16 +3015,21 @@ static void DoScroll_TextMode0(struct Window *win, u16 lineLength) u16 fill; buffer += val1 + val2; fill = (win->paletteNum << 12) | GetBlankTileNum(win); + + // Move the bottom line up CpuCopy16(buffer + 64, buffer, lineLength * 2); CpuCopy16(buffer + 96, buffer + 32, lineLength * 2); + + // Clear the bottom line CpuFill16(fill, buffer + 64, lineLength * 2); CpuFill16(fill, buffer + 96, lineLength * 2); } -static void ScrollWindowTextLines_TextMode1(struct Window *win) +static void ScrollWindowTextLines_TextModeMonospace(struct Window *win) { if (win->cursorY == 0) { + // Advance to the next line win->cursorX = 0; win->cursorY += 16; } @@ -2990,17 +3037,21 @@ static void ScrollWindowTextLines_TextMode1(struct Window *win) { win->win_field_C ^= 2; win->cursorX = 0; - DoScroll_TextMode1(win, sLineLength); + DoScroll_TextModeMonospace(win, sLineLength); } } -static void DoScroll_TextMode1(struct Window *win, u16 lineLength) +static void DoScroll_TextModeMonospace(struct Window *win, u16 lineLength) { u16 *buffer = GetCursorTilemapPointer(win); u16 *dest = buffer - 32; u16 fill = (win->paletteNum << 12) | GetBlankTileNum(win); + + // Move the bottom line up CpuCopy16(buffer + 32, dest, lineLength * 2); CpuCopy16(buffer + 64, buffer, lineLength * 2); + + // Clear the bottom line CpuFill16(fill, buffer + 32, lineLength * 2); CpuFill16(fill, buffer + 64, lineLength * 2); } @@ -3009,6 +3060,7 @@ static void ScrollWindowTextLines_TextMode2(struct Window *win) { if (win->cursorY == 0) { + // Advance to the next line win->cursorX = 0; win->cursorY += 16; } @@ -3055,18 +3107,18 @@ static void DoScroll_TextMode2(struct Window *win, u8 lineLength) } } -void ClearWindowTextLines(struct Window *win) +void Text_ClearWindow(struct Window *win) { switch (win->textMode) { - case 0: + case TEXT_MODE_UNKNOWN0: ClearWindowTextLines_TextMode0_TextMode1(win, sLineLength); win->tileDataOffset = 2; break; - case 1: + case TEXT_MODE_MONOSPACE: ClearWindowTextLines_TextMode0_TextMode1(win, sLineLength); break; - case 2: + case TEXT_MODE_UNKNOWN2: ClearWindowTextLines_TextMode2(win, sLineLength); break; } @@ -3074,7 +3126,7 @@ void ClearWindowTextLines(struct Window *win) static void ClearWindowTextLines_TextMode0_TextMode1(struct Window *win, u8 lineLength) { - u8 i; + u8 x, y; u16 *buffer; u16 fill; @@ -3085,11 +3137,10 @@ static void ClearWindowTextLines_TextMode0_TextMode1(struct Window *win, u8 line buffer = GetCursorTilemapPointer(win); fill = GetBlankTileNum(win) | (win->paletteNum << 12); - for (i = 0; i < 4; i++) + for (y = 0; y < 4; y++) { - u8 j; - for (j = 0; j < lineLength; j++) - buffer[j] = fill; + for (x = 0; x < lineLength; x++) + buffer[x] = fill; buffer += 32; } } @@ -3114,13 +3165,13 @@ static void ClearWindowTextLines_TextMode2(struct Window *win, u8 lineLength) static void DrawDownArrow(struct Window *win) { - if (PlayerCanInterruptWait(win)) + if (PlayerCanInterruptDelay(win)) { const u32 *downArrowTiles = &sDownArrowTiles[((win->downArrowCounter & 0x0F00) >> 8) * 16]; switch (win->textMode) { - case 1: + case TEXT_MODE_MONOSPACE: { u8 *buffer; u16 tileNum = win->tileDataStartOffset + 254; @@ -3132,8 +3183,8 @@ static void DrawDownArrow(struct Window *win) WriteGlyphTilemap(win, tileNum, tileNum + 1); break; } - case 0: - case 2: + case TEXT_MODE_UNKNOWN0: + case TEXT_MODE_UNKNOWN2: { struct GlyphTileInfo glyphTileInfo; glyphTileInfo.textMode = win->textMode; @@ -3172,9 +3223,9 @@ static void DrawDownArrow(struct Window *win) static u8 WaitWithDownArrow(struct Window *win) { - u8 retVal = 1; + u8 retVal = TRUE; - if (!PlayerCanInterruptWait(win)) + if (!PlayerCanInterruptDelay(win)) { win->delayCounter--; if (!win->delayCounter) @@ -3183,8 +3234,8 @@ static u8 WaitWithDownArrow(struct Window *win) } else { - DrawMovingDownArrow(win); - retVal = 0; + UpdateDownArrowAnimation(win); + retVal = FALSE; } } else @@ -3196,8 +3247,8 @@ static u8 WaitWithDownArrow(struct Window *win) } else { - DrawMovingDownArrow(win); - retVal = 0; + UpdateDownArrowAnimation(win); + retVal = FALSE; } } @@ -3210,7 +3261,7 @@ static void DrawInitialDownArrow(struct Window *win) DrawDownArrow(win); } -static void DrawMovingDownArrow(struct Window *win) +static void UpdateDownArrowAnimation(struct Window *win) { u16 downArrowPos = (win->downArrowCounter & 0x0F00) >> 8; u16 wait = win->downArrowCounter & 0x000F; @@ -3237,31 +3288,37 @@ static void DrawMovingDownArrow(struct Window *win) static void TryEraseDownArrow(struct Window *win) { win->downArrowCounter = 0; - if (PlayerCanInterruptWait(win) == TRUE) + if (PlayerCanInterruptDelay(win) == TRUE) EraseAtCursor(win); } -u16 GetWindowTilemapEntry(struct Window *win, u8 x, u8 y) +// unused +u16 Text_GetWindowTilemapEntry(struct Window *win, u8 x, u8 y) { u16 *tilemap = win->tilemap; return tilemap[32 * y + x]; } -void DrawWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom) +// unused +void Text_FillWindowBorder(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom) { u8 i; u16 *buffer = &win->tilemap[top * 32]; + // Fill top border for (i = left; i <= right; i++) buffer[i] = tilemapEntry; for (i = top + 1; i < bottom - 1; i++) { buffer += 32; + // left border buffer[left] = tilemapEntry; + // right border buffer[right] = tilemapEntry; } + // Fill bottom border if (top != bottom) { buffer += 32; @@ -3270,37 +3327,39 @@ void DrawWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 ri } } +// unused void DrawWindowRect_DefaultPalette(struct Window *win, u16 tileNum, u8 left, u8 top, u8 right, u8 bottom) { - DrawWindowRect(win, (win->paletteNum << 12) | tileNum, left, top, right, bottom); + Text_FillWindowBorder(win, (win->paletteNum << 12) | tileNum, left, top, right, bottom); } -void FillWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom) +// Fills the whole window area with tilemapEntry +void Text_FillWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom) { u16 *buffer = &win->tilemap[top * 32]; while (top++ <= bottom) { - u8 j; - for (j = left; j <= right; j++) - buffer[j] = tilemapEntry; + u8 x; + for (x = left; x <= right; x++) + buffer[x] = tilemapEntry; buffer += 32; } } -void FillWindowRect_DefaultPalette(struct Window *win, u16 tileNum, u8 left, u8 top, u8 right, u8 bottom) +void Text_FillWindowRectDefPalette(struct Window *win, u16 tileNum, u8 left, u8 top, u8 right, u8 bottom) { - FillWindowRect(win, (win->paletteNum << 12) | tileNum, left, top, right, bottom); + Text_FillWindowRect(win, (win->paletteNum << 12) | tileNum, left, top, right, bottom); } -void ZeroFillWindowRect(struct Window *win, u8 left, u8 top, u8 right, u8 bottom) +void Text_EraseWindowRect(struct Window *win, u8 left, u8 top, u8 right, u8 bottom) { - FillWindowRect_DefaultPalette(win, 0, left, top, right, bottom); + Text_FillWindowRectDefPalette(win, 0, left, top, right, bottom); } -void FillWindowRectWithBlankTile(struct Window *win, u8 left, u8 top, u8 right, u8 bottom) +void Text_BlankWindowRect(struct Window *win, u8 left, u8 top, u8 right, u8 bottom) { u16 tileNum = GetBlankTileNum(win); - FillWindowRect_DefaultPalette(win, tileNum, left, top, right, bottom); + Text_FillWindowRectDefPalette(win, tileNum, left, top, right, bottom); } static u16 GetBlankTileNum(struct Window *win) @@ -3309,12 +3368,12 @@ static u16 GetBlankTileNum(struct Window *win) switch (win->textMode) { - case 0: + case TEXT_MODE_UNKNOWN0: break; - case 2: + case TEXT_MODE_UNKNOWN2: retVal++; break; - case 1: + case TEXT_MODE_MONOSPACE: switch (win->fontNum) { case 1: @@ -3451,7 +3510,7 @@ u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignT ConvertIntToDecimalString(temp, value); width = GetStringWidth(win, temp); dest = StringCopy(dest, temp); - dest[0] = 0xFC; + dest[0] = EXT_CTRL_CODE_BEGIN; dest[1] = 17; dest[2] = alignAmount - width; dest += 3; @@ -3462,7 +3521,7 @@ u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignT width = GetStringWidth(win, temp); if (alignAmount > width) { - dest[0] = 0xFC; + dest[0] = EXT_CTRL_CODE_BEGIN; dest[1] = 17; dest[2] = alignAmount - width; dest += 3; @@ -3474,7 +3533,7 @@ u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignT width = GetStringWidth(win, temp); if (alignAmount > width) { - dest[0] = 0xFC; + dest[0] = EXT_CTRL_CODE_BEGIN; dest[1] = 17; dest[2] = (alignAmount - width) / 2; dest += 3; @@ -3482,7 +3541,7 @@ u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignT dest = StringCopy(dest, temp); if (alignAmount > width) { - dest[0] = 0xFC; + dest[0] = EXT_CTRL_CODE_BEGIN; dest[1] = 17; dest[2] = (alignAmount - width) / 2; dest += 3; @@ -3500,7 +3559,7 @@ u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8 { case 0: dest = StringCopy(dest, src); - dest[0] = 0xFC; + dest[0] = EXT_CTRL_CODE_BEGIN; dest[1] = 19; dest[2] = alignAmount; dest += 3; @@ -3510,7 +3569,7 @@ u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8 width = GetStringWidth(win, src); if (alignAmount > width) { - dest[0] = 0xFC; + dest[0] = EXT_CTRL_CODE_BEGIN; dest[1] = 19; dest[2] = alignAmount - width; dest += 3; @@ -3521,7 +3580,7 @@ u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8 width = GetStringWidth(win, src); if (alignAmount > width) { - dest[0] = 0xFC; + dest[0] = EXT_CTRL_CODE_BEGIN; dest[1] = 19; dest[2] = (alignAmount - width) / 2; dest += 3; @@ -3529,7 +3588,7 @@ u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8 dest = StringCopy(dest, src); if (alignAmount > width) { - dest[0] = 0xFC; + dest[0] = EXT_CTRL_CODE_BEGIN; dest[1] = 19; dest[2] = alignAmount; dest += 3; @@ -3544,16 +3603,16 @@ u8 GetStringWidth(struct Window *win, const u8 *s) { u8 width = 0; u8 savedFontNum = win->fontNum; - u8 savedCharset = win->language; + u8 savedLanguage = win->language; u8 savedSpacing = win->spacing; s32 i = 0; - while (s[i] != 0xFF) + while (s[i] != EOS) { u8 c = s[i]; switch (c) { - case 0xFD: + case PLACEHOLDER_BEGIN: { u8 temp; i++; @@ -3563,7 +3622,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s) i++; break; } - case 0xFC: + case EXT_CTRL_CODE_BEGIN: i++; switch (s[i]) { @@ -3571,7 +3630,7 @@ u8 GetStringWidth(struct Window *win, const u8 *s) win->fontNum = s[i + 1]; break; case 7: - win->fontNum = win->config->fontNum; + win->fontNum = win->template->fontNum; break; case 0x11: width += s[i + 1]; @@ -3601,64 +3660,64 @@ u8 GetStringWidth(struct Window *win, const u8 *s) } win->spacing = savedSpacing; - win->language = savedCharset; + win->language = savedLanguage; win->fontNum = savedFontNum; return width; } -u8 sub_8004D04(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6) +u8 Text_InitWindow8004D04(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6) { - sub_8002E4C(win, text, tileDataStartOffset, left, top, a6); - return sub_8002F44(win); + Text_InitWindow8002E4C(win, text, tileDataStartOffset, left, top, a6); + return Text_PrintWindow8002F44(win); } -u8 sub_8004D38(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top) +u8 Text_InitWindow8004D38(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top) { u8 width = GetStringWidth(win, text); - InitWindow(win, text, tileDataStartOffset, left - ((u32)(width + 7) >> 3), top); + Text_InitWindow(win, text, tileDataStartOffset, left - ((u32)(width + 7) >> 3), top); EraseAtCursor(win); width &= 7; if (width) width = 8 - width; sub_80048D8(win, width, 0); - return sub_8002F44(win); + return Text_PrintWindow8002F44(win); } -u8 sub_8004DB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top, u16 a6) +u8 Text_InitWindow8004DB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top, u16 a6) { register u32 val asm("r5") = (u8)((a6 >> 1) - (GetStringWidth(win, text) >> 1)); left += (val >> 3); - InitWindow(win, text, tileDataStartOffset, left, top); + Text_InitWindow(win, text, tileDataStartOffset, left, top); EraseAtCursor(win); sub_80048D8(win, val & 7, 0); - return sub_8002F44(win); + return Text_PrintWindow8002F44(win); } -u8 sub_8004E24(struct Window *win) +u8 Text_GetWindowPaletteNum(struct Window *win) { return win->paletteNum; } -void sub_8004E28(struct Window *win, u8 *foreground, u8 *background, u8 *shadow) +void Text_GetTextColors(struct Window *win, u8 *foreground, u8 *background, u8 *shadow) { *foreground = win->foregroundColor; *background = win->backgroundColor; *shadow = win->shadowColor; } -void sub_8004E3C(const struct WindowConfig *winConfig, u8 *tileData, const u8 *text) +void Text_InitWindow8004E3C(const struct WindowTemplate *winTemplate, u8 *tileData, const u8 *text) { - sTempWindow.config = winConfig; - InitWindow(&sTempWindow, text, 0, 0, 0); + sTempWindow.template = winTemplate; + Text_InitWindow(&sTempWindow, text, 0, 0, 0); sTempWindow.tileData = tileData; - sub_8002F44(&sTempWindow); + Text_PrintWindow8002F44(&sTempWindow); } -u8 GetStringWidthGivenWindowConfig(const struct WindowConfig *winConfig, const u8 *s) +u8 Text_GetStringWidthFromWindowTemplate(const struct WindowTemplate *winTemplate, const u8 *s) { - sTempWindow.config = winConfig; - InitWindow(&sTempWindow, s, 0, 0, 0); + sTempWindow.template = winTemplate; + Text_InitWindow(&sTempWindow, s, 0, 0, 0); return GetStringWidth(&sTempWindow, s); } @@ -3668,11 +3727,11 @@ void ConvertInternationalString(u8 *s, u8 language) { u8 i; - StripExtCtrlCodes(s); + Text_StripExtCtrlCodes(s); i = StringLength(s); - s[i++] = 0xFC; + s[i++] = EXT_CTRL_CODE_BEGIN; s[i++] = 22; - s[i++] = 0xFF; + s[i++] = EOS; i--; @@ -3682,18 +3741,18 @@ void ConvertInternationalString(u8 *s, u8 language) i--; } - s[0] = 0xFC; + s[0] = EXT_CTRL_CODE_BEGIN; s[1] = 21; } } -void StripExtCtrlCodes(u8 *str) +void Text_StripExtCtrlCodes(u8 *str) { u16 srcIndex = 0; u16 destIndex = 0; - while (str[srcIndex] != 0xFF) + while (str[srcIndex] != EOS) { - if (str[srcIndex] == 0xFC) + if (str[srcIndex] == EXT_CTRL_CODE_BEGIN) { srcIndex++; srcIndex += GetExtCtrlCodeLength(str[srcIndex]); @@ -3703,12 +3762,12 @@ void StripExtCtrlCodes(u8 *str) str[destIndex++] = str[srcIndex++]; } } - str[destIndex] = 0xFF; + str[destIndex] = EOS; } static const u8 *SkipExtCtrlCode(const u8 *s) { - while (*s == 0xFC) + while (*s == EXT_CTRL_CODE_BEGIN) { s++; s += GetExtCtrlCodeLength(*s); @@ -3801,8 +3860,8 @@ u8 sub_8004FD0(struct Window *win, u8 *dest, const u8 *src, u16 tileDataStartOff if (endsWithoutNewline) newlineCount++; - sub_8002E4C(win, start, tileDataStartOffset, left, top, a8); - sub_8002F44(win); + Text_InitWindow8002E4C(win, start, tileDataStartOffset, left, top, a8); + Text_PrintWindow8002F44(win); return newlineCount; } @@ -3827,7 +3886,7 @@ static s32 DrawGlyphTile_UnshadowedFont(struct GlyphTileInfo *glyphTileInfo) if (glyphTileInfo->startPixel + glyphTileInfo->width > 8) { u32 mask2 = masks[1]; - if (glyphTileInfo->textMode == 2) + if (glyphTileInfo->textMode == TEXT_MODE_UNKNOWN2) { glyphBuffer->pixelRows[8] = buffer[8] & mask2; glyphBuffer->pixelRows[9] = buffer[9] & mask2; @@ -3867,7 +3926,7 @@ static s32 DrawGlyphTile_UnshadowedFont(struct GlyphTileInfo *glyphTileInfo) if (glyphTileInfo->startPixel + glyphTileInfo->width > 8) { - if (glyphTileInfo->textMode != 2) + if (glyphTileInfo->textMode != TEXT_MODE_UNKNOWN2) buffer += 8; buffer[8] = glyphBuffer->pixelRows[8]; buffer[9] = glyphBuffer->pixelRows[9]; @@ -4039,7 +4098,7 @@ static s32 DrawGlyphTile_ShadowedFont(struct GlyphTileInfo *glyphTileInfo) if (glyphTileInfo->startPixel + glyphTileInfo->width > 8) { u32 mask2 = masks[1]; - if (glyphTileInfo->textMode == 2) + if (glyphTileInfo->textMode == TEXT_MODE_UNKNOWN2) { glyphBuffer->pixelRows[8] = buffer[8] & mask2; glyphBuffer->pixelRows[9] = buffer[9] & mask2; @@ -4076,7 +4135,7 @@ static s32 DrawGlyphTile_ShadowedFont(struct GlyphTileInfo *glyphTileInfo) if (glyphTileInfo->startPixel + glyphTileInfo->width > 8) { - if (glyphTileInfo->textMode != 2) + if (glyphTileInfo->textMode != TEXT_MODE_UNKNOWN2) buffer += 8; buffer[8] = glyphBuffer->pixelRows[8]; buffer[9] = glyphBuffer->pixelRows[9]; @@ -4314,7 +4373,7 @@ static u16 GetCursorTileNum(struct Window *win, u32 xOffset, u32 yOffset) { u16 index; - if (win->textMode == 2) + if (win->textMode == TEXT_MODE_UNKNOWN2) index = win->tileDataStartOffset + win->tileDataOffset + (((win->top + win->cursorY) >> 3) + yOffset) * win->width diff --git a/src/engine/text_window.c b/src/engine/text_window.c index c001ddefc..ade349f4e 100644 --- a/src/engine/text_window.c +++ b/src/engine/text_window.c @@ -4,19 +4,22 @@ #include "palette.h" #include "text.h" -#define STD_MSG_BOX_LEFT 0 -#define STD_MSG_BOX_TOP 14 -#define STD_MSG_BOX_WIDTH 26 -#define STD_MSG_BOX_HEIGHT 4 +#define STD_WINDOW_PALETTE_NUM 14 + +// Dimensions (in tiles) of a field dialogue frame +#define STD_DLG_FRAME_LEFT 0 +#define STD_DLG_FRAME_TOP 14 +#define STD_DLG_FRAME_WIDTH 26 +#define STD_DLG_FRAME_HEIGHT 4 static void LoadTextWindowTiles(u8, void *); static void LoadTextWindowPalette(u8, u8); -static void DrawTextWindowInternal(u16 *dest, u16 baseTileNum, u8 left, u8 top, u8 right, u8 bottom); -static u16 GetMessageBoxTilemapEntry(u16 tilemapEntry, u8 x, u8 y, u8 width, u8 height); -static void DrawMessageBox(struct Window *win, u8 left, u8 top, u8 width, u8 height); +static void DrawStandardFrame(u16 *dest, u16 baseTileNum, u8 left, u8 top, u8 right, u8 bottom); +static u16 GetDialogueFrameTilemapEntry(u16 tilemapEntry, u8 x, u8 y, u8 width, u8 height); +static void DrawDialogueFrame(struct Window *win, u8 left, u8 top, u8 width, u8 height); static u16 sTextWindowBaseTileNum; -static u16 sMessageBoxBaseTileNum; +static u16 sDialogueFrameBaseTileNum; extern const u8 gTextWindowFrame1_Gfx[]; extern const u8 gTextWindowFrame2_Gfx[]; @@ -60,9 +63,9 @@ extern const u16 gTextWindowFrame18_Pal[]; extern const u16 gTextWindowFrame19_Pal[]; extern const u16 gTextWindowFrame20_Pal[]; -extern const u8 gMessageBox_Gfx[]; +extern const u8 gDialogueFrame_Gfx[]; -static const struct FrameGraphics gUnknown_083761F0[20] = +static const struct FrameGraphics sTextWindowFrameGraphics[20] = { {gTextWindowFrame1_Gfx, gTextWindowFrame1_Pal}, {gTextWindowFrame2_Gfx, gTextWindowFrame2_Pal}, @@ -86,7 +89,7 @@ static const struct FrameGraphics gUnknown_083761F0[20] = {gTextWindowFrame20_Gfx, gTextWindowFrame20_Pal}, }; -static const u16 gMessageBoxTilemap[5][7] = +static const u16 sDialogueFrameTilemap[5][7] = { {1, 3, 4, 4, 5, 6, 9}, {11, 9, 9, 9, 9, 0x040B, 9}, @@ -95,113 +98,124 @@ static const u16 gMessageBoxTilemap[5][7] = {0x0801, 0x0803, 0x0804, 0x0804, 0x0805, 0x0806, 9}, }; -u16 SetTextWindowBaseTileNum(u16 baseTileNum) +u16 TextWindow_SetBaseTileNum(u16 baseTileNum) { sTextWindowBaseTileNum = baseTileNum; return baseTileNum + 9; } -void LoadTextWindowGraphics(struct Window *win) +// Loads the tiles and palette of the window frame into VRAM using the selected frame type +void TextWindow_LoadStdFrameGraphics(struct Window *win) { - u8 *tileData = win->config->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum; + u8 *tileData = win->template->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum; LoadTextWindowTiles(gSaveBlock2.optionsWindowFrameType, tileData); - LoadTextWindowPalette(gSaveBlock2.optionsWindowFrameType, 0xE); + LoadTextWindowPalette(gSaveBlock2.optionsWindowFrameType, STD_WINDOW_PALETTE_NUM); } -void LoadTextWindowGraphics_OverridePalSlot(struct Window *win, u8 palSlot) +// Loads the tiles and palette of the window frame into VRAM with an alternate palette +void TextWindow_LoadStdFrameGraphicsOverridePal(struct Window *win, u8 palSlot) { - u8 *tileData = win->config->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum; + u8 *tileData = win->template->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum; LoadTextWindowTiles(gSaveBlock2.optionsWindowFrameType, tileData); LoadTextWindowPalette(gSaveBlock2.optionsWindowFrameType, palSlot); } -void LoadTextWindowGraphics_OverrideFrameType(struct Window *win, u8 frameType) +// Loads the tiles and palette of the window frame into VRAM with an alternate frame type +void TextWindow_LoadStdFrameGraphicsOverrideStyle(struct Window *win, u8 frameType) { - u8 *tileData = win->config->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum; + u8 *tileData = win->template->tileData + TILE_SIZE_4BPP * sTextWindowBaseTileNum; LoadTextWindowTiles(frameType, tileData); - LoadTextWindowPalette(frameType, 0xE); + LoadTextWindowPalette(frameType, STD_WINDOW_PALETTE_NUM); } -void DrawTextWindow(struct Window *win, u8 left, u8 top, u8 right, u8 bottom) +void TextWindow_DrawStdFrame(struct Window *win, u8 left, u8 top, u8 right, u8 bottom) { - DrawTextWindowInternal(win->config->tilemap, sTextWindowBaseTileNum, left, top, right, bottom); + DrawStandardFrame(win->template->tilemap, sTextWindowBaseTileNum, left, top, right, bottom); } -const struct FrameGraphics *GetTextWindowFrameGraphics(u8 frameType) +// Returns the tile data and palette for the specified frame type +const struct FrameGraphics *TextWindow_GetFrameGraphics(u8 frameType) { if (frameType > 19) - return &gUnknown_083761F0[0]; + return &sTextWindowFrameGraphics[0]; else - return &gUnknown_083761F0[frameType]; + return &sTextWindowFrameGraphics[frameType]; } static void LoadTextWindowTiles(u8 frameType, void *dest) { - const struct FrameGraphics *frameGraphics = GetTextWindowFrameGraphics(frameType); + const struct FrameGraphics *frameGraphics = TextWindow_GetFrameGraphics(frameType); CpuFastCopy(frameGraphics->tiles, dest, 9 * TILE_SIZE_4BPP); } static void LoadTextWindowPalette(u8 frameType, u8 palSlot) { - const struct FrameGraphics *frameGraphics = GetTextWindowFrameGraphics(frameType); + const struct FrameGraphics *frameGraphics = TextWindow_GetFrameGraphics(frameType); LoadPalette(frameGraphics->palette, 16 * palSlot, 0x20); } -static void DrawTextWindowInternal(u16 *dest, u16 baseTileNum, u8 left, u8 top, u8 right, u8 bottom) +// Draws a standard window frame +static void DrawStandardFrame(u16 *tilemap, u16 baseTileNum, u8 left, u8 top, u8 right, u8 bottom) { + u8 startX = min(left, right); + u8 endX = max(left, right); + u8 startY = min(top, bottom); + u8 endY = max(top, bottom); u8 x, y; - u8 startX, endX; - u8 startY, endY; - - startX = (left < right) ? left : right; - endX = (right > left) ? right : left; - - startY = (top < bottom) ? top : bottom; - endY = (bottom > top) ? bottom : top; - dest[32 * startY + startX] = baseTileNum | 0xE000; + // top left corner + tilemap[32 * startY + startX] = baseTileNum | (STD_WINDOW_PALETTE_NUM << 12); + // top border for (x = startX + 1; x < endX; x++) - dest[32 * startY + x] = (baseTileNum + 1) | 0xE000; + tilemap[32 * startY + x] = (baseTileNum + 1) | (STD_WINDOW_PALETTE_NUM << 12); - dest[32 * startY + endX] = (baseTileNum + 2) | 0xE000; + // top right corner + tilemap[32 * startY + endX] = (baseTileNum + 2) | (STD_WINDOW_PALETTE_NUM << 12); for (y = startY + 1; y < endY; y++) { - dest[32 * y + startX] = (baseTileNum + 3) | 0xE000; + // left border + tilemap[32 * y + startX] = (baseTileNum + 3) | (STD_WINDOW_PALETTE_NUM << 12); + // middle for (x = startX + 1; x < endX; x++) - dest[32 * y + x] = (baseTileNum + 4) | 0xE000; + tilemap[32 * y + x] = (baseTileNum + 4) | (STD_WINDOW_PALETTE_NUM << 12); - dest[32 * y + endX] = (baseTileNum + 5) | 0xE000; + // right border + tilemap[32 * y + endX] = (baseTileNum + 5) | (STD_WINDOW_PALETTE_NUM << 12); } - dest[32 * endY + startX] = (baseTileNum + 6) | 0xE000; + // bottom left corner + tilemap[32 * endY + startX] = (baseTileNum + 6) | (STD_WINDOW_PALETTE_NUM << 12); + // bottom border for (x = startX + 1; x < endX; x++) - dest[32 * endY + x] = (baseTileNum + 7) | 0xE000; + tilemap[32 * endY + x] = (baseTileNum + 7) | (STD_WINDOW_PALETTE_NUM << 12); - dest[32 * endY + endX] = (baseTileNum + 8) | 0xE000; + // bottom right corner + tilemap[32 * endY + endX] = (baseTileNum + 8) | (STD_WINDOW_PALETTE_NUM << 12); } -u16 SetMessageBoxBaseTileNum(u16 baseTileNum) +u16 TextWindow_SetDlgFrameBaseTileNum(u16 baseTileNum) { - sMessageBoxBaseTileNum = baseTileNum; + sDialogueFrameBaseTileNum = baseTileNum; return baseTileNum + 14; } void unref_sub_80651DC(struct Window *win, u8 *text) { - sub_8002EB0(win, text, sMessageBoxBaseTileNum + 14, 2, 15); + Text_InitWindow8002EB0(win, text, sDialogueFrameBaseTileNum + 14, 2, 15); } -void DisplayMessageBox(struct Window *win) +// Loads and draws a dialogue window frame +void TextWindow_DisplayDialogueFrame(struct Window *win) { - LoadMessageBoxTiles(win); - DrawStandardMessageBox(win); + TextWindow_LoadDialogueFrameTiles(win); + TextWindow_DrawDialogueFrame(win); } -static u16 GetMessageBoxTilemapEntry(u16 baseTilemapEntry, u8 x, u8 y, u8 width, u8 height) +static u16 GetDialogueFrameTilemapEntry(u16 baseTilemapEntry, u8 x, u8 y, u8 width, u8 height) { u16 tilemapEntry = 9; @@ -215,42 +229,47 @@ static u16 GetMessageBoxTilemapEntry(u16 baseTilemapEntry, u8 x, u8 y, u8 width, else if (x > 2) x = 3; - if (x <= 6 && y <= 4) - tilemapEntry = gMessageBoxTilemap[y][x]; + if (x < 7 && y < 5) + tilemapEntry = sDialogueFrameTilemap[y][x]; tilemapEntry += baseTilemapEntry; return tilemapEntry; } -static void DrawMessageBox(struct Window *win, u8 left, u8 top, u8 width, u8 height) +static void DrawDialogueFrame(struct Window *win, u8 left, u8 top, u8 width, u8 height) { - u8 i, j; - u16 tilemapEntry = (win->paletteNum << 12) | sMessageBoxBaseTileNum; - u16 *tilemap = win->config->tilemap; + u8 x, y; + u16 baseTilemapEntry = (win->paletteNum << 12) | sDialogueFrameBaseTileNum; + u16 *tilemap = win->template->tilemap; - for (i = 0; i < height + 2; i++) - for (j = 0; j < width + 6; j++) - tilemap[(left + j) + 32 * (top + i)] = (win->paletteNum << 12) | GetMessageBoxTilemapEntry(tilemapEntry, j, i, width, height); + for (y = 0; y < height + 2; y++) + { + for (x = 0; x < width + 6; x++) + tilemap[(left + x) + 32 * (top + y)] = (win->paletteNum << 12) | GetDialogueFrameTilemapEntry(baseTilemapEntry, x, y, width, height); + } } -void DrawStandardMessageBox(struct Window *win) +// Draws an alternate styled frame used for dialogue windows that appear on the overworld +void TextWindow_DrawDialogueFrame(struct Window *win) { - DrawMessageBox(win, STD_MSG_BOX_LEFT, STD_MSG_BOX_TOP, STD_MSG_BOX_WIDTH, STD_MSG_BOX_HEIGHT); + DrawDialogueFrame(win, STD_DLG_FRAME_LEFT, STD_DLG_FRAME_TOP, STD_DLG_FRAME_WIDTH, STD_DLG_FRAME_HEIGHT); } -void LoadMessageBoxTiles(struct Window *win) +// Loads the dialogue window frame tiles into VRAM +void TextWindow_LoadDialogueFrameTiles(struct Window *win) { - u8 *tileData = win->config->tileData; - CpuFastCopy(gMessageBox_Gfx, tileData + 32 * sMessageBoxBaseTileNum, 14 * TILE_SIZE_4BPP); + u8 *tileData = win->template->tileData; + CpuFastCopy(gDialogueFrame_Gfx, tileData + 32 * sDialogueFrameBaseTileNum, 14 * TILE_SIZE_4BPP); } -void ClearStandardMessageBox(struct Window *win) +// Erases a dialogue window frame +void TextWindow_EraseDialogueFrame(struct Window *win) { u8 i; - u16 *tilemap = win->config->tilemap + (STD_MSG_BOX_TOP * 32); + u16 *tilemap = win->template->tilemap + (STD_DLG_FRAME_TOP * 32); u16 tilemapEntry = win->paletteNum << 12; - for (i = 0; i < ((STD_MSG_BOX_HEIGHT + 2) * 32); i++) + for (i = 0; i < ((STD_DLG_FRAME_HEIGHT + 2) * 32); i++) tilemap[i] = tilemapEntry; } diff --git a/src/engine/trade.c b/src/engine/trade.c index 0bc589ff4..3a14adaca 100644 --- a/src/engine/trade.c +++ b/src/engine/trade.c @@ -141,7 +141,7 @@ struct TradeEwramStruct { }; static void sub_8047EC0(void); -static void sub_804AFB8(const struct WindowConfig *, u8 *, const u8 *, u8); +static void sub_804AFB8(const struct WindowTemplate *, u8 *, const u8 *, u8); static void sub_804ACD8(const u8 *, u8 *, u8); static void nullsub_5(u8, u8); static void sub_804AA88(void); @@ -1016,10 +1016,10 @@ void sub_8047CD8(void) static void sub_8047CE8(void) { u8 mpId; - sub_804AFB8(&gWindowConfig_81E725C, gUnknown_020296CC[0], gSaveBlock2.playerName, 0xC); + sub_804AFB8(&gWindowTemplate_81E725C, gUnknown_020296CC[0], gSaveBlock2.playerName, 0xC); mpId = GetMultiplayerId(); - sub_804AFB8(&gWindowConfig_81E725C, gUnknown_020296CC[3], gLinkPlayers[mpId ^ 1].name, 0xC); - sub_804AFB8(&gWindowConfig_81E725C, gUnknown_020296CC[6], gUnknown_0820C14C[0], 0x8); + sub_804AFB8(&gWindowTemplate_81E725C, gUnknown_020296CC[3], gLinkPlayers[mpId ^ 1].name, 0xC); + sub_804AFB8(&gWindowTemplate_81E725C, gUnknown_020296CC[6], gUnknown_0820C14C[0], 0x8); sub_804ACD8(gUnknown_0820C14C[1], gUnknown_020296CC[8], 0x14); nullsub_5(3, 0); } @@ -1087,12 +1087,12 @@ static void sub_8047EC0(void) ResetTasks(); sub_804A964(&gUnknown_03004824->unk_00c8, BG_SCREEN_ADDR(5)); SetVBlankCallback(sub_80489F4); - InitMenuWindow(&gWindowConfig_81E6CE4); - SetUpWindowConfig(&gWindowConfig_81E6F84); - InitWindowFromConfig(&gUnknown_03004824->window, &gWindowConfig_81E6F84); - gUnknown_03004824->unk_007a = SetTextWindowBaseTileNum(20); - LoadTextWindowGraphics(&gUnknown_03004824->window); - MenuZeroFillScreen(); + InitMenuWindow(&gWindowTemplate_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6F84); + Text_InitWindowWithTemplate(&gUnknown_03004824->window, &gWindowTemplate_81E6F84); + gUnknown_03004824->unk_007a = TextWindow_SetBaseTileNum(20); + TextWindow_LoadStdFrameGraphics(&gUnknown_03004824->window); + Menu_EraseScreen(); sub_809D51C(); gUnknown_03004824->unk_0075 = 0; gUnknown_03004824->unk_007b = 0; @@ -1157,7 +1157,7 @@ static void sub_8047EC0(void) break; case 6: CalculateEnemyPartyCount(); - FillWindowRect_DefaultPalette(&gUnknown_03004824->window, 0, 0, 0, 29, 19); + Text_FillWindowRectDefPalette(&gUnknown_03004824->window, 0, 0, 0, 29, 19); REG_DISPCNT = 0; gUnknown_03004824->partyCounts[0] = gPlayerPartyCount; gUnknown_03004824->partyCounts[1] = gEnemyPartyCount; @@ -1267,12 +1267,12 @@ static void sub_80484F4(void) ResetTasks(); sub_804A964(&gUnknown_03004824->unk_00c8, BG_SCREEN_ADDR(5)); SetVBlankCallback(sub_80489F4); - InitMenuWindow(&gWindowConfig_81E6CE4); - SetUpWindowConfig(&gWindowConfig_81E6F84); - InitWindowFromConfig(&gUnknown_03004824->window, &gWindowConfig_81E6F84); - gUnknown_03004824->unk_007a = SetTextWindowBaseTileNum(20); - LoadTextWindowGraphics(&gUnknown_03004824->window); - MenuZeroFillScreen(); + InitMenuWindow(&gWindowTemplate_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6F84); + Text_InitWindowWithTemplate(&gUnknown_03004824->window, &gWindowTemplate_81E6F84); + gUnknown_03004824->unk_007a = TextWindow_SetBaseTileNum(20); + TextWindow_LoadStdFrameGraphics(&gUnknown_03004824->window); + Menu_EraseScreen(); sub_809D51C(); gUnknown_03004824->unk_0075 = 0; gUnknown_03004824->unk_007b = 0; @@ -2096,8 +2096,8 @@ static void sub_8049680(void) PlaySE(SE_SELECT); if (gUnknown_03004824->tradeMenuCursorPosition < PARTY_SIZE) { - DrawTextWindow(&gUnknown_03004824->window, 18, 14, 28, 19); - PrintMenuItems(19, 15, 2, (const struct MenuAction *)gUnknown_0820C320); + TextWindow_DrawStdFrame(&gUnknown_03004824->window, 18, 14, 28, 19); + Menu_PrintItems(19, 15, 2, (const struct MenuAction *)gUnknown_0820C320); InitMenu(0, 19, 15, 2, 0, 9); gUnknown_03004824->unk_007b = 1; } @@ -2108,7 +2108,7 @@ static void sub_8049680(void) } else if (gUnknown_03004824->tradeMenuCursorPosition == 2 * PARTY_SIZE) { - DrawTextWindow(&gUnknown_03004824->window, 24, 14, 29, 19); + TextWindow_DrawStdFrame(&gUnknown_03004824->window, 24, 14, 29, 19); InitYesNoMenu(24, 14, 4); gUnknown_03004824->unk_007b = 4; sub_804ACD8(gUnknown_0820C14C[4], BG_CHAR_ADDR(4) + 32 * gUnknown_03004824->unk_007e, 20); @@ -2126,7 +2126,7 @@ static void sub_8049680(void) static void sub_8049804(void) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); sub_804A80C(); gUnknown_03004824->unk_007b = 0; gSprites[gUnknown_03004824->tradeMenuCursorSpriteIdx].invisible = FALSE; @@ -2138,17 +2138,17 @@ static void sub_8049860(void) if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - gUnknown_03004824->unk_007c = MoveMenuCursor(-1); + gUnknown_03004824->unk_007c = Menu_MoveCursor(-1); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - gUnknown_03004824->unk_007c = MoveMenuCursor(+1); + gUnknown_03004824->unk_007c = Menu_MoveCursor(+1); } if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - if (GetMenuCursorPos() == 0) + if (Menu_GetCursorPos() == 0) { BeginNormalPaletteFade(-1, 0, 0, 16, 0); gUnknown_03004824->unk_007b = 2; @@ -2239,17 +2239,17 @@ static void sub_8049AC0(void) if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - gUnknown_03004824->unk_007c = MoveMenuCursor(-1); + gUnknown_03004824->unk_007c = Menu_MoveCursor(-1); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - gUnknown_03004824->unk_007c = MoveMenuCursor(+1); + gUnknown_03004824->unk_007c = Menu_MoveCursor(+1); } if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - if (GetMenuCursorPos() == 0) + if (Menu_GetCursorPos() == 0) { sub_8049A20(); } @@ -2267,9 +2267,9 @@ static void sub_8049AC0(void) else if (gMain.newKeys & B_BUTTON) { sub_804AADC(3, 1); - if (GetMenuCursorPos() == 0) + if (Menu_GetCursorPos() == 0) { - gUnknown_03004824->unk_007c = MoveMenuCursor(+1); + gUnknown_03004824->unk_007c = Menu_MoveCursor(+1); } gUnknown_03004824->linkData[0] = 0xbbcc; Trade_SendData(gUnknown_03004824); @@ -2282,17 +2282,17 @@ static void sub_8049BC0(void) if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - gUnknown_03004824->unk_007c = MoveMenuCursor(-1); + gUnknown_03004824->unk_007c = Menu_MoveCursor(-1); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - gUnknown_03004824->unk_007c = MoveMenuCursor(+1); + gUnknown_03004824->unk_007c = Menu_MoveCursor(+1); } if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - if (GetMenuCursorPos() == 0) + if (Menu_GetCursorPos() == 0) { sub_804AA0C(4); gUnknown_03004824->linkData[0] = 0xeeaa; @@ -2337,7 +2337,7 @@ static void DisplayMessageAndContinueTask(void) gUnknown_03004824->unk_00b4++; if (gUnknown_03004824->unk_00b4 > 120) { - DrawTextWindow(&gUnknown_03004824->window, 24, 14, 29, 19); + TextWindow_DrawStdFrame(&gUnknown_03004824->window, 24, 14, 29, 19); InitYesNoMenu(24, 14, 4); gUnknown_03004824->unk_00b4 = 0; gUnknown_03004824->unk_007b = 3; @@ -2464,8 +2464,8 @@ static void sub_8049ED4(u8 a0) StoreSpriteCallbackInData(&gSprites[gUnknown_03004824->partyIcons[whichParty][whichPokemon]], sub_809D62C); gUnknown_03004824->unk_0080[a0] ++; sub_8078A34(&gSprites[gUnknown_03004824->partyIcons[whichParty][whichPokemon]]); - HandleDestroyMenuCursors(); - FillWindowRect_DefaultPalette(&gUnknown_03004824->window, 0, gUnknown_0820C330[whichParty][0], 0, gUnknown_0820C330[whichParty][1], 19); + Menu_DestroyCursor(); + Text_FillWindowRectDefPalette(&gUnknown_03004824->window, 0, gUnknown_0820C330[whichParty][0], 0, gUnknown_0820C330[whichParty][1], 19); sub_804A96C_alt(&gUnknown_03004824->unk_00c8, 15 * a0, 0, gTradePartyBoxTilemap, 15, 17, 0); if (whichParty == 0) { @@ -2491,10 +2491,10 @@ static void sub_8049ED4(u8 a0) string1[3] = 0xFC; string1[4] = 0x11; string1[5] = (64 - stringLength) / 2; - sub_8003460(&gUnknown_03004824->window, string1, gUnknown_03004824->unk_007a + whichParty * 6 * 32, gUnknown_0820C334[whichParty][0], gUnknown_0820C334[whichParty][1]); + Text_InitWindowAndPrintText(&gUnknown_03004824->window, string1, gUnknown_03004824->unk_007a + whichParty * 6 * 32, gUnknown_0820C334[whichParty][0], gUnknown_0820C334[whichParty][1]); sub_804A33C(string2, whichParty, whichPokemon); - sub_8003460(&gUnknown_03004824->window, gOtherText_Terminator2, gUnknown_03004824->unk_007a + whichParty * 6 * 32 + 32, gUnknown_0820C334[whichParty + 1][0], gUnknown_0820C334[whichParty + 1][1] + 1); - sub_8003460(&gUnknown_03004824->window, string2, gUnknown_03004824->unk_007a + whichParty * 6 * 32 + 38, gUnknown_0820C334[whichParty + 1][0], gUnknown_0820C334[whichParty + 1][1] + 1); + Text_InitWindowAndPrintText(&gUnknown_03004824->window, gOtherText_Terminator2, gUnknown_03004824->unk_007a + whichParty * 6 * 32 + 32, gUnknown_0820C334[whichParty + 1][0], gUnknown_0820C334[whichParty + 1][1] + 1); + Text_InitWindowAndPrintText(&gUnknown_03004824->window, string2, gUnknown_03004824->unk_007a + whichParty * 6 * 32 + 38, gUnknown_0820C334[whichParty + 1][0], gUnknown_0820C334[whichParty + 1][1] + 1); gUnknown_03004824->unk_0080[a0] ++; break; case 4: @@ -2692,7 +2692,7 @@ static void sub_8049ED4(u8 a0) "\tlsls r0, 2\n" "\tadds r0, r7\n" "\tbl sub_8078A34\n" - "\tbl HandleDestroyMenuCursors\n" + "\tbl Menu_DestroyCursor\n" "\tldr r3, _0804A09C @ =gUnknown_03004824\n" "\tldr r0, [r3]\n" "\tadds r0, 0x4\n" @@ -2708,7 +2708,7 @@ static void sub_8049ED4(u8 a0) "\tstr r1, [sp, 0x4]\n" "\tmovs r1, 0\n" "\tmovs r3, 0\n" - "\tbl FillWindowRect_DefaultPalette\n" + "\tbl Text_FillWindowRectDefPalette\n" "\tldr r1, _0804A09C @ =gUnknown_03004824\n" "\tldr r0, [r1]\n" "\tadds r0, 0xC8\n" @@ -2884,7 +2884,7 @@ static void sub_8049ED4(u8 a0) "\tldrb r1, [r1]\n" "\tstr r1, [sp]\n" "\tadd r1, sp, 0xC\n" - "\tbl sub_8003460\n" + "\tbl Text_InitWindowAndPrintText\n" "\tadd r7, sp, 0x34\n" "\tadds r0, r7, 0\n" "\tldr r1, [sp, 0x6C]\n" @@ -2910,7 +2910,7 @@ static void sub_8049ED4(u8 a0) "\tlsrs r4, 24\n" "\tstr r4, [sp]\n" "\tadds r3, r5, 0\n" - "\tbl sub_8003460\n" + "\tbl Text_InitWindowAndPrintText\n" "\tldr r0, _0804A22C @ =gUnknown_03004824\n" "\tldr r1, [r0]\n" "\tadds r0, r1, 0x4\n" @@ -2921,7 +2921,7 @@ static void sub_8049ED4(u8 a0) "\tstr r4, [sp]\n" "\tadds r1, r7, 0\n" "\tadds r3, r5, 0\n" - "\tbl sub_8003460\n" + "\tbl Text_InitWindowAndPrintText\n" "\tldr r2, _0804A22C @ =gUnknown_03004824\n" "\tldr r1, [r2]\n" "\tb _0804A28A\n" @@ -3010,7 +3010,7 @@ u8 sub_804A2B4(u8 *a0, u8 whichParty, u8 whichPokemon) GetMonGender(&gEnemyParty[whichPokemon]); GetMonData(&gEnemyParty[whichPokemon], MON_DATA_LEVEL); } - return GetStringWidthGivenWindowConfig(&gWindowConfig_81E7294, a0); + return Text_GetStringWidthFromWindowTemplate(&gWindowTemplate_81E7294, a0); } #ifdef NONMATCHING @@ -3067,8 +3067,8 @@ static void sub_804A41C(u8 whichParty) GetMonData(pokemon, MON_DATA_NICKNAME, nickname); StringCopy10(string + 6, nickname); GetMonGender(pokemon); - string[5] = (50 - GetStringWidthGivenWindowConfig(&gWindowConfig_81E7294, string + 6)) / 2; - sub_8003460(&gUnknown_03004824->window, string, gUnknown_03004824->unk_007a + 22 * 6 * whichParty + 22 * i, gTradeMonSpriteCoords[i + 6 * whichParty][0], gTradeMonSpriteCoords[i + 6 * whichParty][1]); + string[5] = (50 - Text_GetStringWidthFromWindowTemplate(&gWindowTemplate_81E7294, string + 6)) / 2; + Text_InitWindowAndPrintText(&gUnknown_03004824->window, string, gUnknown_03004824->unk_007a + 22 * 6 * whichParty + 22 * i, gTradeMonSpriteCoords[i + 6 * whichParty][0], gTradeMonSpriteCoords[i + 6 * whichParty][1]); } } #else @@ -3141,8 +3141,8 @@ static void sub_804A41C(u8 whichParty) "\tbl GetMonGender\n" "\tmov r1, sp\n" "\tadds r1, 0x22\n" - "\tldr r0, _0804A518 @ =gWindowConfig_81E7294\n" - "\tbl GetStringWidthGivenWindowConfig\n" + "\tldr r0, _0804A518 @ =gWindowTemplate_81E7294\n" + "\tbl Text_GetStringWidthFromWindowTemplate\n" "\tlsls r0, 24\n" "\tlsrs r0, 24\n" "\tmovs r1, 0x32\n" @@ -3177,7 +3177,7 @@ static void sub_804A41C(u8 whichParty) "\tldrb r1, [r1]\n" "\tstr r1, [sp]\n" "\tmov r1, r8\n" - "\tbl sub_8003460\n" + "\tbl Text_InitWindowAndPrintText\n" "\tadds r0, r6, 0x1\n" "\tlsls r0, 24\n" "\tlsrs r6, r0, 24\n" @@ -3198,7 +3198,7 @@ static void sub_804A41C(u8 whichParty) "\tbx r0\n" "\t.align 2, 0\n" "_0804A514: .4byte gEnemyParty\n" - "_0804A518: .4byte gWindowConfig_81E7294"); + "_0804A518: .4byte gWindowTemplate_81E7294"); } #endif @@ -3337,7 +3337,7 @@ static void sub_804A740(u8 whichParty) static void sub_804A80C(void) { - FillWindowRect_DefaultPalette(&gUnknown_03004824->window, 0, gUnknown_0820C330[1][0], 0, gUnknown_0820C330[1][1], 19); + Text_FillWindowRectDefPalette(&gUnknown_03004824->window, 0, gUnknown_0820C330[1][0], 0, gUnknown_0820C330[1][1], 19); sub_804A41C(1); } @@ -3345,7 +3345,7 @@ static void sub_804A840(u8 whichParty) { if (whichParty == 0) { - FillWindowRect_DefaultPalette(&gUnknown_03004824->window, 0, gUnknown_0820C330[0][0], 0, gUnknown_0820C330[0][1], 19); + Text_FillWindowRectDefPalette(&gUnknown_03004824->window, 0, gUnknown_0820C330[0][0], 0, gUnknown_0820C330[0][1], 19); sub_804A96C_alt(&gUnknown_03004824->unk_00c8, 0, 0, gTradePartyBoxTilemap, 15, 17, 0); sub_804A6DC(0); sub_804A41C(0); @@ -3354,8 +3354,8 @@ static void sub_804A840(u8 whichParty) } else { - HandleDestroyMenuCursors(); - FillWindowRect_DefaultPalette(&gUnknown_03004824->window, 0, gUnknown_0820C330[1][0], 0, gUnknown_0820C330[1][1], 19); + Menu_DestroyCursor(); + Text_FillWindowRectDefPalette(&gUnknown_03004824->window, 0, gUnknown_0820C330[1][0], 0, gUnknown_0820C330[1][1], 19); sub_804A96C_alt(&gUnknown_03004824->unk_00c8, 15, 0, gTradePartyBoxTilemap, 15, 17, 0); sub_804A6DC(1); sub_804A41C(1); @@ -3413,18 +3413,18 @@ static void sub_804A96C_alt(struct UnkStructD *arg0, u8 left, u8 top, const u16 static void sub_804A9F4(u8 unused) { - MenuZeroFillScreen(); + Menu_EraseScreen(); } static void sub_804AA00(u8 unused) { - MenuZeroFillScreen(); + Menu_EraseScreen(); } static void sub_804AA0C(u8 a0) { - DrawTextWindow(&gUnknown_03004824->window, gTradeMessageWindowRects[a0][0], gTradeMessageWindowRects[a0][1], gTradeMessageWindowRects[a0][2], gTradeMessageWindowRects[a0][3]); - sub_8003460(&gUnknown_03004824->window, gUnknown_0820C2F0[a0], 0x180 + gUnknown_03004824->unk_007a, gTradeMessageWindowRects[a0][0] + 1, gTradeMessageWindowRects[a0][1] + 1); + TextWindow_DrawStdFrame(&gUnknown_03004824->window, gTradeMessageWindowRects[a0][0], gTradeMessageWindowRects[a0][1], gTradeMessageWindowRects[a0][2], gTradeMessageWindowRects[a0][3]); + Text_InitWindowAndPrintText(&gUnknown_03004824->window, gUnknown_0820C2F0[a0], 0x180 + gUnknown_03004824->unk_007a, gTradeMessageWindowRects[a0][0] + 1, gTradeMessageWindowRects[a0][1] + 1); } static void sub_804AA88(void) @@ -3523,7 +3523,7 @@ static bool8 sub_804ABF8(void) static void sub_804ACD8(const u8 *src, u8 *dest, u8 a2) { - sub_804AFB8(&gWindowConfig_81E725C, dest, src, a2); + sub_804AFB8(&gWindowTemplate_81E725C, dest, src, a2); } #ifdef NONMATCHING @@ -3798,7 +3798,7 @@ static void sub_804AF84(void) gSaveBlock1.giftRibbons[i] = gUnknown_03004824->unk_00b5[i]; } -static void sub_804AFB8(const struct WindowConfig *windowConfig, u8 *dest, const u8 *src, u8 size) +static void sub_804AFB8(const struct WindowTemplate *windowConfig, u8 *dest, const u8 *src, u8 size) { u8 i; u8 *tileBuffer; @@ -3806,7 +3806,7 @@ static void sub_804AFB8(const struct WindowConfig *windowConfig, u8 *dest, const tileBuffer = gTileBuffer; CpuFill16(0, tileBuffer, size * 0x80); CpuFill16(0, tileBuffer + windowConfig->width * 0x20, size * 0x80); - sub_8004E3C(windowConfig, tileBuffer, src); + Text_InitWindow8004E3C(windowConfig, tileBuffer, src); for (i = 0; i < size; i ++) { CpuCopy16(&tileBuffer[32 * (i * 4)], &dest[32 * (i * 8)], 0x80); @@ -4028,11 +4028,11 @@ static void sub_804B41C(void) FreeAllSpritePalettes(); SetVBlankCallback(sub_804B210); sub_804B228(); - SetUpWindowConfig(&gWindowConfig_81E6F84); - InitWindowFromConfig(&gUnknown_03004828->window, &gWindowConfig_81E6F84); - gUnknown_03004828->textWindowBaseTileNum = SetTextWindowBaseTileNum(2); - LoadTextWindowGraphics(&gUnknown_03004828->window); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E6F84); + Text_InitWindowWithTemplate(&gUnknown_03004828->window, &gWindowTemplate_81E6F84); + gUnknown_03004828->textWindowBaseTileNum = TextWindow_SetBaseTileNum(2); + TextWindow_LoadStdFrameGraphics(&gUnknown_03004828->window); + Menu_EraseScreen(); gLinkType = 0x1144; gMain.state ++; LZDecompressVram(gUnknown_08D00000, (void *)VRAM); @@ -4182,22 +4182,22 @@ static __attribute__((naked)) void sub_804B41C(void) "\tldr r0, _0804B578 @ =sub_804B210\n" "\tbl SetVBlankCallback\n" "\tbl sub_804B228\n" - "\tldr r4, _0804B57C @ =gWindowConfig_81E6F84\n" + "\tldr r4, _0804B57C @ =gWindowTemplate_81E6F84\n" "\tadds r0, r4, 0\n" - "\tbl SetUpWindowConfig\n" + "\tbl Text_LoadWindowTemplate\n" "\tldr r0, [r6]\n" "\tadds r0, 0x4\n" "\tadds r1, r4, 0\n" - "\tbl InitWindowFromConfig\n" + "\tbl Text_InitWindowWithTemplate\n" "\tmovs r0, 0x2\n" - "\tbl SetTextWindowBaseTileNum\n" + "\tbl TextWindow_SetBaseTileNum\n" "\tldr r1, [r6]\n" "\tadds r1, 0x34\n" "\tstrb r0, [r1]\n" "\tldr r0, [r6]\n" "\tadds r0, 0x4\n" - "\tbl LoadTextWindowGraphics\n" - "\tbl MenuZeroFillScreen\n" + "\tbl TextWindow_LoadStdFrameGraphics\n" + "\tbl Menu_EraseScreen\n" "\tldr r1, _0804B580 @ =gLinkType\n" "\tldr r4, _0804B584 @ =0x00001144\n" "\tadds r0, r4, 0\n" @@ -4279,7 +4279,7 @@ static __attribute__((naked)) void sub_804B41C(void) "_0804B570: .4byte gUnknown_03004828\n" "_0804B574: .4byte gSharedMem + 0x1F000\n" "_0804B578: .4byte sub_804B210\n" - "_0804B57C: .4byte gWindowConfig_81E6F84\n" + "_0804B57C: .4byte gWindowTemplate_81E6F84\n" "_0804B580: .4byte gLinkType\n" "_0804B584: .4byte 0x00001144\n" "_0804B588: .4byte gMain\n" @@ -4531,11 +4531,11 @@ static void sub_804B790(void) FreeAllSpritePalettes(); SetVBlankCallback(sub_804B210); sub_804B228(); - SetUpWindowConfig(&gWindowConfig_81E717C); - InitWindowFromConfig(&gUnknown_03004828->window, &gWindowConfig_81E717C); - gUnknown_03004828->textWindowBaseTileNum = SetTextWindowBaseTileNum(2); - LoadTextWindowGraphics(&gUnknown_03004828->window); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E717C); + Text_InitWindowWithTemplate(&gUnknown_03004828->window, &gWindowTemplate_81E717C); + gUnknown_03004828->textWindowBaseTileNum = TextWindow_SetBaseTileNum(2); + TextWindow_LoadStdFrameGraphics(&gUnknown_03004828->window); + Menu_EraseScreen(); gLinkType = 0x1144; gUnknown_03004828->isLinkTrade = FALSE; gUnknown_03004828->unk_00b6 = 0; @@ -4733,7 +4733,7 @@ static void sub_804BBE8(u8 a0) for (i = 0; i < 0x280; i ++) buffer[i] |= 0x7000; DmaCopy16Defvars(3, gSharedMem, BG_SCREEN_ADDR(5), 0x500); - MenuZeroFillWindowRect(2, 15, 27, 18); + Menu_EraseWindowRect(2, 15, 27, 18); break; case 6: REG_DISPCNT = DISPCNT_MODE_1 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; @@ -4843,7 +4843,7 @@ static bool8 sub_804C29C(void) case 10: StringExpandPlaceholders(gStringVar4, gTradeText_WillBeSent); - sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gUnknown_03004828->unk_00c4 = 11; gUnknown_03004828->unk_00c0 = 0; break; @@ -4852,13 +4852,13 @@ static bool8 sub_804C29C(void) { gUnknown_03004828->unk_0102 = sub_8047580(gUnknown_03004828->pokePicSpriteIdxs[0], gSprites[gUnknown_03004828->pokePicSpriteIdxs[0]].oam.paletteNum, 0x78, 0x20, 0x2, 0x1, 0x14, 0xfffff); gUnknown_03004828->unk_00c4 ++; - ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); + Text_EraseWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); StringExpandPlaceholders(gStringVar4, gTradeText_ByeBye); - sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); } break; case 12: - if (gSprites[gUnknown_03004828->unk_0102].callback == SpriteCallbackDummy && sub_80035AC(&gUnknown_03004828->window) == TRUE) + if (gSprites[gUnknown_03004828->unk_0102].callback == SpriteCallbackDummy && Text_UpdateWindow(&gUnknown_03004828->window) == TRUE) { gUnknown_03004828->unk_0103 = CreateSprite(&gSpriteTemplate_821595C, 0x78, 0x20, 0); gSprites[gUnknown_03004828->unk_0103].callback = sub_804D738; @@ -5199,9 +5199,9 @@ static bool8 sub_804C29C(void) break; case 67: REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_OBJ_1D_MAP | DISPCNT_BG0_ON | DISPCNT_BG1_ON | DISPCNT_BG2_ON | DISPCNT_OBJ_ON; - ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); + Text_EraseWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); StringExpandPlaceholders(gStringVar4, gTradeText_SentOverPoke); - sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gUnknown_03004828->unk_00c4 ++; gUnknown_03004828->unk_00c0 = 0; break; @@ -5213,9 +5213,9 @@ static bool8 sub_804C29C(void) if (gUnknown_03004828->unk_00c0 == 0xf0) { gUnknown_03004828->unk_00c4 ++; - ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); + Text_EraseWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); StringExpandPlaceholders(gStringVar4, gTradeText_TakeGoodCare); - sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gUnknown_03004828->unk_00c0 = 0; } break; @@ -5536,9 +5536,9 @@ static void sub_804DC88(void) case 0: gUnknown_03004828 = &ewram_2010000.unk_0f000; gMain.state ++; - ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); + Text_EraseWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); StringExpandPlaceholders(gStringVar4, gOtherText_LinkStandby2); - sub_8003460(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindowAndPrintText(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); break; case 1: sub_80084A4(); @@ -5564,8 +5564,8 @@ static void sub_804DC88(void) break; case 2: gMain.state = 50; - ZeroFillWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); - sub_8003460(&gUnknown_03004828->window, gSystemText_Saving, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_EraseWindowRect(&gUnknown_03004828->window, 0, 0, 29, 19); + Text_InitWindowAndPrintText(&gUnknown_03004828->window, gSystemText_Saving, gUnknown_03004828->textWindowBaseTileNum, 2, 15); break; case 50: SetSecretBase2Field_9_AndHideBG(); diff --git a/src/engine/trainer_card.c b/src/engine/trainer_card.c index ffa4cbd08..ab43ac716 100644 --- a/src/engine/trainer_card.c +++ b/src/engine/trainer_card.c @@ -18,7 +18,7 @@ #include "string_util.h" #include "strings2.h" #include "task.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "util.h" #include "ewram.h" @@ -256,7 +256,7 @@ static void sub_8093254(void) ewram0_2.var_5 ^= 1; } if (ewram0_2.var_4) - DmaCopy16(3, &gUnknown_03004DE0[0], &gUnknown_03004DE0[1], 0x140); + DmaCopy16(3, &gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 0x140); } static void sub_80932AC(Callback callBack) @@ -565,8 +565,8 @@ void sub_80937A4() void sub_80937BC() { - SetUpWindowConfig(&WindowConfig_TrainerCard_Back_Values); - MultistepInitMenuWindowBegin(&WindowConfig_TrainerCard_Back_Values); + Text_LoadWindowTemplate(&gWindowTemplate_TrainerCard_Back_Values); + MultistepInitMenuWindowBegin(&gWindowTemplate_TrainerCard_Back_Values); } static void sub_80937D8() @@ -678,7 +678,7 @@ bool8 sub_8093980(struct Task *task) static void sub_80939A4(void) { CreateTask(sub_80939DC, 0); - BasicInitMenuWindow(&WindowConfig_TrainerCard_Back_Values); + BasicInitMenuWindow(&gWindowTemplate_TrainerCard_Back_Values); } static void sub_80939C0(void) @@ -700,7 +700,7 @@ static void sub_80939DC(u8 taskId) task->data[TD_0] ^= TRUE; } TrainerCard_Front_PrintPlayTime(buffer, task->data[TD_0]); - MenuPrint(buffer, 10, 12); + Menu_PrintText(buffer, 10, 12); } static void sub_8093A28(void) @@ -730,9 +730,9 @@ bool8 sub_8093AA0(struct Task *task) u32 i; ewram0_2.var_4 = FALSE; - dp12_8087EA4(); + ScanlineEffect_Clear(); for (i = 0; i < 0xA0; i++) - gUnknown_03004DE0[1][i] = -4; + gScanlineEffectRegBuffers[1][i] = -4; SetHBlankCallback(sub_8093D7C); ewram0_2.var_4 = TRUE; task->data[0]++; @@ -768,7 +768,7 @@ bool8 sub_8093AF0(struct Task *task) for (i = 0; i < r7; i++) { - gUnknown_03004DE0.filler0[i] = -4 - (u32)i; + gScanlineEffectRegBuffers.filler0[i] = -4 - (u32)i; } //_08093B74 for (; i < r9; i++) @@ -776,10 +776,10 @@ bool8 sub_8093AF0(struct Task *task) u16 var = r6 >> 16; r6 += r5; r5 -= sp0; - gUnknown_03004DE0.filler0[i] = -4 + var; + gScanlineEffectRegBuffers.filler0[i] = -4 + var; } for (; i < 160; i++) - gUnknown_03004DE0.filler0[i] = -4 + (u16)(r10 >> 16); + gScanlineEffectRegBuffers.filler0[i] = -4 + (u16)(r10 >> 16); ewram0_2.var_4 = 1; if (task->data[1] > 0x4A) task->data[0]++; @@ -840,7 +840,7 @@ _08093B18:\n\ movs r3, 0\n\ cmp r3, r7\n\ bcs _08093B74\n\ - ldr r2, _08093C04 @ =gUnknown_03004DE0\n\ + ldr r2, _08093C04 @ =gScanlineEffectRegBuffers\n\ mov r12, r2\n\ ldr r0, _08093C08 @ =0x0000fffc\n\ adds r4, r0, 0\n\ @@ -866,7 +866,7 @@ _08093B74:\n\ lsrs r7, r4, 16\n\ cmp r2, r0\n\ bge _08093BAE\n\ - ldr r0, _08093C04 @ =gUnknown_03004DE0\n\ + ldr r0, _08093C04 @ =gScanlineEffectRegBuffers\n\ mov r9, r0\n\ ldr r4, _08093C08 @ =0x0000fffc\n\ mov r12, r4\n\ @@ -894,7 +894,7 @@ _08093BAE:\n\ asrs r0, 16\n\ cmp r0, 0x9F\n\ bgt _08093BD4\n\ - ldr r4, _08093C04 @ =gUnknown_03004DE0\n\ + ldr r4, _08093C04 @ =gScanlineEffectRegBuffers\n\ ldr r0, _08093C08 @ =0x0000fffc\n\ adds r2, r1, r0\n\ _08093BBE:\n\ @@ -934,7 +934,7 @@ _08093BEA:\n\ .align 2, 0\n\ _08093BFC: .4byte gSharedMem\n\ _08093C00: .4byte 0xffff0000\n\ -_08093C04: .4byte gUnknown_03004DE0\n\ +_08093C04: .4byte gScanlineEffectRegBuffers\n\ _08093C08: .4byte 0x0000fffc\n\ .syntax divided\n"); } @@ -1000,7 +1000,7 @@ _08093C5C:\n\ movs r3, 0\n\ cmp r3, r7\n\ bcs _08093CB8\n\ - ldr r2, _08093D48 @ =gUnknown_03004DE0\n\ + ldr r2, _08093D48 @ =gScanlineEffectRegBuffers\n\ mov r12, r2\n\ ldr r0, _08093D4C @ =0x0000fffc\n\ adds r4, r0, 0\n\ @@ -1026,7 +1026,7 @@ _08093CB8:\n\ lsrs r7, r4, 16\n\ cmp r2, r0\n\ bge _08093CF2\n\ - ldr r0, _08093D48 @ =gUnknown_03004DE0\n\ + ldr r0, _08093D48 @ =gScanlineEffectRegBuffers\n\ mov r9, r0\n\ ldr r3, _08093D4C @ =0x0000fffc\n\ mov r12, r3\n\ @@ -1054,7 +1054,7 @@ _08093CF2:\n\ asrs r0, 16\n\ cmp r0, 0x9F\n\ bgt _08093D18\n\ - ldr r4, _08093D48 @ =gUnknown_03004DE0\n\ + ldr r4, _08093D48 @ =gScanlineEffectRegBuffers\n\ ldr r0, _08093D4C @ =0x0000fffc\n\ adds r2, r1, r0\n\ _08093D02:\n\ @@ -1094,7 +1094,7 @@ _08093D2E:\n\ .align 2, 0\n\ _08093D40: .4byte gSharedMem\n\ _08093D44: .4byte 0xffff0000\n\ -_08093D48: .4byte gUnknown_03004DE0\n\ +_08093D48: .4byte gScanlineEffectRegBuffers\n\ _08093D4C: .4byte 0x0000fffc\n\ .syntax divided\n"); } @@ -1113,7 +1113,7 @@ bool8 sub_8093D50(struct Task *task) void sub_8093D7C(void) { - u16 bgVOffset = gUnknown_03004DE0[1][REG_VCOUNT & 0xFF]; + u16 bgVOffset = gScanlineEffectRegBuffers[1][REG_VCOUNT & 0xFF]; REG_BG0VOFS = bgVOffset; REG_BG1VOFS = bgVOffset; @@ -1130,7 +1130,7 @@ static void sub_8093DAC(void) static void sub_8093DC8(void) { - MenuZeroFillScreen(); + Menu_EraseScreen(); sub_80940E4(); sub_8093F14(); sub_8093F80(); @@ -1141,7 +1141,7 @@ static void sub_8093DC8(void) static void sub_8093DEC(void) { - MenuZeroFillScreen(); + Menu_EraseScreen(); sub_80940E4(); sub_8093F48(); sub_8094188(); @@ -1317,12 +1317,12 @@ static void sub_8094140(void) { u8 *buffer; - BasicInitMenuWindow(&WindowConfig_TrainerCard_Back_Values); + BasicInitMenuWindow(&gWindowTemplate_TrainerCard_Back_Values); buffer = gStringVar1; StringCopy(buffer, ewram0_2.var_64.playerName); ConvertInternationalString(buffer, ewram0_2.language); - MenuPrint(buffer, 7, 5); + Menu_PrintText(buffer, 7, 5); TrainerCard_Front_PrintTrainerID(); TrainerCard_Front_PrintMoney(); @@ -1332,7 +1332,7 @@ static void sub_8094140(void) static void sub_8094188(void) { - BasicInitMenuWindow(&WindowConfig_TrainerCard_Back_Values); + BasicInitMenuWindow(&gWindowTemplate_TrainerCard_Back_Values); TrainerCard_Back_PrintName(); TrainerCard_Back_PrintHallOfFameTime_Label(); TrainerCard_Back_PrintLinkBattlesLabel(); @@ -1341,7 +1341,7 @@ static void sub_8094188(void) TrainerCard_Back_PrintLinkPokeblocks_Label(); TrainerCard_Back_PrintPokemonTrades_Label(); - BasicInitMenuWindow(&WindowConfig_TrainerCard_Back_Labels); + BasicInitMenuWindow(&gWindowTemplate_TrainerCard_Back_Labels); TrainerCard_Back_PrintHallOfFameTime(); TrainerCard_Back_PrintLinkBattles(); TrainerCard_Back_PrintBattleTower(); @@ -1355,7 +1355,7 @@ static void TrainerCard_Front_PrintTrainerID(void) u8 buffer[8]; ConvertIntToDecimalStringN(buffer, ewram0_2.var_64.trainerId, STR_CONV_MODE_LEADING_ZEROS, 5); - MenuPrint(buffer, 20, 2); + Menu_PrintText(buffer, 20, 2); } static void TrainerCard_Front_PrintMoney(void) @@ -1406,14 +1406,14 @@ static void sub_809429C(void) str[0] = 00; str++; str = StringCopy(str, ewram0_2.var_20[1]); - MenuPrint(gStringVar1, 2, 14); + Menu_PrintText(gStringVar1, 2, 14); str = gStringVar1; str = StringCopy(str, ewram0_2.var_20[2]); str[0] = 00; str++; str = StringCopy(str, ewram0_2.var_20[3]); - MenuPrint(gStringVar1, 2, 16); + Menu_PrintText(gStringVar1, 2, 16); } } @@ -1437,7 +1437,7 @@ static void TrainerCard_Back_PrintName(void) static void TrainerCard_Back_PrintHallOfFameTime_Label(void) { if (ewram0_2.var_8 != 0) - MenuPrint(gOtherText_FirstHOF, 3, 5); + Menu_PrintText(gOtherText_FirstHOF, 3, 5); } static void TrainerCard_Back_PrintHallOfFameTime(void) @@ -1459,7 +1459,7 @@ static void TrainerCard_Back_PrintHallOfFameTime(void) static void TrainerCard_Back_PrintLinkBattlesLabel(void) { if (ewram0_2.var_9 != 0) - MenuPrint(gOtherText_LinkCableBattles, 3, 7); + Menu_PrintText(gOtherText_LinkCableBattles, 3, 7); } static void TrainerCard_Back_PrintLinkBattles(void) @@ -1479,7 +1479,7 @@ static void TrainerCard_Back_PrintLinkBattles(void) static void TrainerCard_Back_PrintBattleTower_Label(void) { if (ewram0_2.var_a != 0) - MenuPrint(gOtherText_BattleTowerWinRecord, 3, 15); + Menu_PrintText(gOtherText_BattleTowerWinRecord, 3, 15); } static void TrainerCard_Back_PrintBattleTower(void) @@ -1489,17 +1489,17 @@ static void TrainerCard_Back_PrintBattleTower(void) if (ewram0_2.var_a != 0) { sub_8072C44(buffer, ewram0_2.var_64.battleTowerWins, 24, 1); - MenuPrint_PixelCoords(buffer, 112, 120, 0); + Menu_PrintTextPixelCoords(buffer, 112, 120, 0); sub_8072C44(buffer, ewram0_2.var_64.battleTowerLosses, 24, 1); - MenuPrint_PixelCoords(buffer, 149, 120, 0); + Menu_PrintTextPixelCoords(buffer, 149, 120, 0); } } static void TrainerCard_Back_PrintLinkContests_Label(void) { if (ewram0_2.var_b != 0) - MenuPrint(gOtherText_ContestRecord, 3, 13); + Menu_PrintText(gOtherText_ContestRecord, 3, 13); } static void TrainerCard_Back_PrintLinkContests(void) @@ -1516,7 +1516,7 @@ static void TrainerCard_Back_PrintLinkContests(void) static void TrainerCard_Back_PrintLinkPokeblocks_Label(void) { if (ewram0_2.var_c != 0) - MenuPrint(gOtherText_MixingRecord, 3, 11); + Menu_PrintText(gOtherText_MixingRecord, 3, 11); } static void TrainerCard_Back_PrintLinkPokeblocks(void) @@ -1533,7 +1533,7 @@ static void TrainerCard_Back_PrintLinkPokeblocks(void) static void TrainerCard_Back_PrintPokemonTrades_Label(void) { if (ewram0_2.var_d != 0) - MenuPrint(gOtherText_TradeRecord, 3, 9); + Menu_PrintText(gOtherText_TradeRecord, 3, 9); } static void TrainerCard_Back_PrintPokemonTrades(void) @@ -1553,5 +1553,5 @@ void unref_sub_8094588(u16 left, u16 top) if (gSaveBlock2.playerGender == FEMALE) text = gOtherText_Girl; - MenuPrint(text, left, top); + Menu_PrintText(text, left, top); } diff --git a/src/field/berry_tag_screen.c b/src/field/berry_tag_screen.c index 960a163c1..a05d9bf87 100644 --- a/src/field/berry_tag_screen.c +++ b/src/field/berry_tag_screen.c @@ -109,11 +109,11 @@ static bool8 sub_8146058(void) gMain.state += 1; break; case 3: - SetUpWindowConfig(&gWindowConfig_81E6E18); + Text_LoadWindowTemplate(&gWindowTemplate_81E6E18); gMain.state += 1; break; case 4: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6E18); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E6E18); gMain.state += 1; break; case 5: @@ -280,18 +280,18 @@ static void sub_81464E4(void) berryInfo = GetBerryInfo(gSpecialVar_ItemId + OFFSET_7B + 1); ConvertIntToDecimalStringN(gStringVar1, gSpecialVar_ItemId - FIRST_BERRY + 1, STR_CONV_MODE_LEADING_ZEROS, 2); - MenuPrint(gStringVar1, 12, 4); + Menu_PrintText(gStringVar1, 12, 4); #if ENGLISH - MenuPrint(berryInfo->name, 14, 4); + Menu_PrintText(berryInfo->name, 14, 4); #elif GERMAN StringCopy(buffer, berryInfo->name); StringAppend(buffer, gOtherText_Berry2); - MenuPrint(buffer, 14, 4); + Menu_PrintText(buffer, 14, 4); #endif - MenuPrint(berryInfo->description1, 4, 14); - MenuPrint(berryInfo->description2, 4, 16); + Menu_PrintText(berryInfo->description1, 4, 14); + Menu_PrintText(berryInfo->description2, 4, 16); #ifdef UNITS_IMPERIAL size = (berryInfo->size * 1000) / 254; @@ -301,7 +301,7 @@ static void sub_81464E4(void) sizeMajor = size / 100; #endif - MenuPrint(gOtherText_Size, 11, 7); + Menu_PrintText(gOtherText_Size, 11, 7); if (berryInfo->size != 0) { #ifdef UNITS_IMPERIAL @@ -311,18 +311,18 @@ static void sub_81464E4(void) ConvertIntToDecimalStringN(gStringVar1, berryInfo->size / 10, STR_CONV_MODE_LEFT_ALIGN, 2); ConvertIntToDecimalStringN(gStringVar2, berryInfo->size % 10, STR_CONV_MODE_LEFT_ALIGN, 2); #endif - MenuPrint(gContestStatsText_Unknown1, 16, 7); + Menu_PrintText(gContestStatsText_Unknown1, 16, 7); } else { - MenuPrint(gOtherText_ThreeQuestions2, 16, 7); + Menu_PrintText(gOtherText_ThreeQuestions2, 16, 7); } - MenuPrint(gOtherText_Firm, 11, 9); + Menu_PrintText(gOtherText_Firm, 11, 9); if (berryInfo->firmness != 0) - MenuPrint(gUnknown_0841192C[berryInfo->firmness - 1], 16, 9); + Menu_PrintText(gUnknown_0841192C[berryInfo->firmness - 1], 16, 9); else - MenuPrint(gOtherText_ThreeQuestions2, 16, 9); + Menu_PrintText(gOtherText_ThreeQuestions2, 16, 9); } static void sub_8146600(u8 berry) @@ -445,7 +445,7 @@ static void sub_8146810(s8 berry) static void sub_81468BC(void) { - MenuZeroFillWindowRect(0, 4, 29, 19); + Menu_EraseWindowRect(0, 4, 29, 19); sub_81464E4(); // center of berry sprite diff --git a/src/field/braille_puzzles.c b/src/field/braille_puzzles.c index 0d304714d..f11fb5fb3 100644 --- a/src/field/braille_puzzles.c +++ b/src/field/braille_puzzles.c @@ -161,7 +161,7 @@ void Task_BrailleWait(u8 taskId) case 1: if (BrailleWait_CheckButtonPress() != FALSE) { - MenuZeroFillScreen(); + Menu_EraseScreen(); PlaySE(SE_SELECT); data[0] = 2; } @@ -170,7 +170,7 @@ void Task_BrailleWait(u8 taskId) data[1] = data[1] - 1; if (data[1] == 0) { - MenuZeroFillScreen(); + Menu_EraseScreen(); data[0] = 3; data[1] = 30; } diff --git a/src/field/choose_party.c b/src/field/choose_party.c index 52763b911..1d6b6541a 100644 --- a/src/field/choose_party.c +++ b/src/field/choose_party.c @@ -319,19 +319,19 @@ static void sub_812238C(u8 taskId) { if (gMain.newAndRepeatedKeys & 0x40) { - if (GetMenuCursorPos() != 0) + if (Menu_GetCursorPos() != 0) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } return; } if (gMain.newAndRepeatedKeys & 0x80) { - if (GetMenuCursorPos() != 3) + if (Menu_GetCursorPos() != 3) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); } return; } @@ -344,7 +344,7 @@ static void sub_812238C(u8 taskId) gTasks[taskId].data[4], sBattleTowerEntryMenu, sBattleTowerEntryMenuItems, - GetMenuCursorPos()); + Menu_GetCursorPos()); popupMenuFunc(taskId); return; } @@ -462,8 +462,8 @@ static void BattleTowerEntryMenuCallback_Enter(u8 taskId) } } PlaySE(SE_HAZURE); - MenuZeroFillWindowRect(20, 10, 29, 19); - HandleDestroyMenuCursors(); + Menu_EraseWindowRect(20, 10, 29, 19); + Menu_DestroyCursor(); sub_806D5A4(); sub_806E834(gOtherText_NoMoreThreePoke, 1); gTasks[taskId].func = sub_8122728; @@ -476,8 +476,8 @@ static void sub_8122728(u8 taskId) if ((gMain.newKeys & A_BUTTON) || (gMain.newKeys & B_BUTTON)) { - MenuZeroFillWindowRect(0, 14, 29, 19); - HandleDestroyMenuCursors(); + Menu_EraseWindowRect(0, 14, 29, 19); + Menu_DestroyCursor(); BattleTowerEntryMenuCallback_Exit(taskId); } } @@ -516,8 +516,8 @@ static void BattleTowerEntryMenuCallback_NoEntry(u8 taskId) static void sub_81227FC(u8 taskId) { - MenuZeroFillWindowRect(20, 10, 29, 19); - HandleDestroyMenuCursors(); + Menu_EraseWindowRect(20, 10, 29, 19); + Menu_DestroyCursor(); PrintPartyMenuPromptText(0, 0); gTasks[taskId].func = HandleBattleTowerPartyMenu; } @@ -807,19 +807,19 @@ static void Task_DaycareStorageMenu8122EAC(u8 taskId) { if (gMain.newAndRepeatedKeys & 0x40) { - if (GetMenuCursorPos() != 0) + if (Menu_GetCursorPos() != 0) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } return; } if (gMain.newAndRepeatedKeys & 0x80) { - if (GetMenuCursorPos() != 3) + if (Menu_GetCursorPos() != 3) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); } return; } @@ -832,7 +832,7 @@ static void Task_DaycareStorageMenu8122EAC(u8 taskId) gTasks[taskId].data[4], sDaycareStorageMenus, sDaycareStorageMenuItems, - GetMenuCursorPos()); + Menu_GetCursorPos()); popupMenuFunc(taskId); return; } @@ -897,8 +897,8 @@ static void DaycareStorageMenuCallback_Summary(u8 taskId) static void DaycareStorageMenuCallback_Exit(u8 taskId) { PlaySE(SE_SELECT); - MenuZeroFillWindowRect(20, 10, 29, 19); - HandleDestroyMenuCursors(); + Menu_EraseWindowRect(20, 10, 29, 19); + Menu_DestroyCursor(); PrintPartyMenuPromptText(15, 0); gTasks[taskId].func = HandleDaycarePartyMenu; } diff --git a/src/field/coins.c b/src/field/coins.c index 91a4b508d..2c217e635 100644 --- a/src/field/coins.c +++ b/src/field/coins.c @@ -13,13 +13,13 @@ void UpdateCoinsWindow(s32 coins, u8 x, u8 y) void ShowCoinsWindow(u32 coins, u8 x, u8 y) { - MenuDrawTextWindow(x, y, x + 9, y + 3); + Menu_DrawStdWindowFrame(x, y, x + 9, y + 3); UpdateCoinsWindow(coins, x, y); } void HideCoinsWindow(u8 x, u8 y) { - MenuZeroFillWindowRect(x, y, x + 9, y + 3); + Menu_EraseWindowRect(x, y, x + 9, y + 3); } void PrintCoins(s32 coins, u8 b, u8 x, u8 y) @@ -46,7 +46,7 @@ void PrintCoins(s32 coins, u8 b, u8 x, u8 y) ptr[2] = (b - StringLength(string)) * 6; ptr += 3; StringCopy(ptr, string); - MenuPrint(gOtherText_Coins2, x, y); + Menu_PrintText(gOtherText_Coins2, x, y); } u16 GetCoins(void) diff --git a/src/field/daycare.c b/src/field/daycare.c index c28bc65ca..5811461ae 100644 --- a/src/field/daycare.c +++ b/src/field/daycare.c @@ -1741,7 +1741,7 @@ static void HandleDaycareLevelMenuInput(u8 taskId) if (gTasks[taskId].data[0] != 0) { gTasks[taskId].data[0] --; - MoveMenuCursor(-1); + Menu_MoveCursor(-1); PlaySE(SE_SELECT); } } @@ -1750,25 +1750,25 @@ static void HandleDaycareLevelMenuInput(u8 taskId) if (gTasks[taskId].data[0] != 2) { gTasks[taskId].data[0]++; - MoveMenuCursor(+1); + Menu_MoveCursor(+1); PlaySE(SE_SELECT); } } else if (gMain.newKeys & A_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); gLastFieldPokeMenuOpened = gSpecialVar_Result = gTasks[taskId].data[0]; DestroyTask(taskId); - MenuZeroFillWindowRect(15, 6, 29, 13); + Menu_EraseWindowRect(15, 6, 29, 13); EnableBothScriptContexts(); } else if (gMain.newKeys & B_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); gLastFieldPokeMenuOpened = gSpecialVar_Result = 2; DestroyTask(taskId); - MenuZeroFillWindowRect(15, 6, 29, 13); + Menu_EraseWindowRect(15, 6, 29, 13); EnableBothScriptContexts(); } } @@ -1776,11 +1776,11 @@ static void HandleDaycareLevelMenuInput(u8 taskId) void ShowDaycareLevelMenu(void) { u8 buffer[100]; - MenuDrawTextWindow(15, 6, 29, 13); + Menu_DrawStdWindowFrame(15, 6, 29, 13); GetDaycareLevelMenuText(&gSaveBlock1.daycare, buffer); - MenuPrint(buffer, 16, 7); + Menu_PrintText(buffer, 16, 7); GetDaycareLevelMenuLevelText(&gSaveBlock1.daycare, buffer); - MenuPrint_PixelCoords(buffer, 0xce, 0x38, TRUE); + Menu_PrintTextPixelCoords(buffer, 0xce, 0x38, TRUE); InitMenu(0, 16, 7, 3, 0, 13); CreateTask(HandleDaycareLevelMenuInput, 3); } diff --git a/src/field/decoration.c b/src/field/decoration.c index 87a9d8028..a6c0bd21f 100644 --- a/src/field/decoration.c +++ b/src/field/decoration.c @@ -1433,8 +1433,8 @@ extern u8 gUnknown_0815F399[]; void sub_80FE1DC(void) { sub_80FE2B4(); - MenuDrawTextWindow(0, 0, 10, 9); - PrintMenuItems(1, 1, 4, (const struct MenuAction *)gUnknown_083EC604); + Menu_DrawStdWindowFrame(0, 0, 10, 9); + Menu_PrintItems(1, 1, 4, (const struct MenuAction *)gUnknown_083EC604); InitMenu(0, 1, 1, 4, gUnknown_020388D4, 9); } @@ -1487,13 +1487,13 @@ void Task_DecorationPCProcessMenuInput(u8 taskId) if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); - gUnknown_020388D4 = MoveMenuCursor(-1); + gUnknown_020388D4 = Menu_MoveCursor(-1); sub_80FE394(); } if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - gUnknown_020388D4 = MoveMenuCursor(1); + gUnknown_020388D4 = Menu_MoveCursor(1); sub_80FE394(); } if (gMain.newKeys & A_BUTTON) @@ -1510,15 +1510,15 @@ void Task_DecorationPCProcessMenuInput(u8 taskId) void sub_80FE394(void) { - MenuFillWindowRectWithBlankTile(2, 15, 27, 18); - MenuPrint(gUnknown_083EC624[gUnknown_020388D4], 2, 15); + Menu_BlankWindowRect(2, 15, 27, 18); + Menu_PrintText(gUnknown_083EC624[gUnknown_020388D4], 2, 15); } void gpu_pal_decompress_alloc_tag_and_upload(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 10, 9); - MenuFillWindowRectWithBlankTile(2, 15, 27, 18); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 10, 9); + Menu_BlankWindowRect(2, 15, 27, 18); FreeSpritePaletteByTag(6); if (ewram_1f000.isPlayerRoom == 0) { @@ -1546,7 +1546,7 @@ void sub_80FE470(u8 decoCat, u8 left, u8 top, u8 palIdx) // PrintDecorationCateg { u8 *strptr; u8 v0; - v0 = sub_8072CBC(); + v0 = Menu_GetTextWindowPaletteNum(); // PALETTE {palIdx} strptr = gStringVar4; strptr[0] = EXT_CTRL_CODE_BEGIN; @@ -1561,13 +1561,13 @@ void sub_80FE470(u8 decoCat, u8 left, u8 top, u8 palIdx) // PrintDecorationCateg strptr[1] = 5; strptr[2] = v0; strptr[3] = EOS; - MenuPrint(gStringVar4, left, top); + Menu_PrintText(gStringVar4, left, top); } void sub_80FE528(u8 taskId) // PrintDecorationCategorySelectionMenuStrings { u8 decoCat; - MenuDrawTextWindow(0, 0, 14, 19); + Menu_DrawStdWindowFrame(0, 0, 14, 19); for (decoCat=0; decoCat<8; decoCat++) { if (ewram_1f000.isPlayerRoom == 1 && gTasks[taskId].data[11] == 0 && decoCat != DECORCAT_DOLL && decoCat != DECORCAT_CUSHION) @@ -1578,13 +1578,13 @@ void sub_80FE528(u8 taskId) // PrintDecorationCategorySelectionMenuStrings sub_80FE470(decoCat, 1, 2 * decoCat + 1, 255); // Unselectable } } - MenuPrint(gUnknownText_Exit, 1, 17); + Menu_PrintText(gUnknownText_Exit, 1, 17); } void sub_80FE5AC(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 29, 19); sub_80FE528(taskId); InitMenu(0, 1, 1, 9, gUnknown_020388F6, 13); gTasks[taskId].func = sub_80FE604; @@ -1597,15 +1597,15 @@ void sub_80FE604(u8 taskId) if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); } else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - gUnknown_020388F6 = GetMenuCursorPos(); + gUnknown_020388F6 = Menu_GetCursorPos(); if (gUnknown_020388F6 != 8) { gUnknown_020388D5 = sub_8134194(gUnknown_020388F6); @@ -1620,8 +1620,8 @@ void sub_80FE604(u8 taskId) gTasks[taskId].func = sub_80FE868; } else { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 14, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 14, 19); DisplayItemMessageOnField(taskId, gSecretBaseText_NoDecors, sub_80FE418, 0); } } else @@ -1649,12 +1649,12 @@ void sub_80FE728(u8 taskId) void sub_80FE758(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 14, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 14, 19); if (gTasks[taskId].data[11] != 2) { sub_80FE1DC(); - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); sub_80FE394(); gTasks[taskId].func = Task_DecorationPCProcessMenuInput; } else @@ -1677,18 +1677,18 @@ void sub_80FE7D4(u8 *dest, u8 decClass) void sub_80FE7EC(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 29, 19); sub_80FEC94(taskId); sub_80FECB8(gUnknown_020388F6); #if ENGLISH - MenuDrawTextWindow(15, 12, 29, 19); + Menu_DrawStdWindowFrame(15, 12, 29, 19); #elif GERMAN if ((gUnknown_020388F2 + gUnknown_020388F4) != gUnknown_020388D5) { - MenuDrawTextWindow(15, 12, 29, 19); + Menu_DrawStdWindowFrame(15, 12, 29, 19); } #endif @@ -1710,7 +1710,7 @@ void sub_80FE894(u8 taskId /*r8*/, s8 cursorVector /*r5*/, s8 bgVector /*r7*/) PlaySE(SE_SELECT); if (cursorVector != 0) { - gUnknown_020388F2 = MoveMenuCursor(cursorVector); + gUnknown_020388F2 = Menu_MoveCursor(cursorVector); } if (bgVector != 0) { @@ -1722,12 +1722,12 @@ void sub_80FE894(u8 taskId /*r8*/, s8 cursorVector /*r5*/, s8 bgVector /*r7*/) { if (v0) { - MenuDrawTextWindow(15, 12, 29, 19); + Menu_DrawStdWindowFrame(15, 12, 29, 19); } sub_80FECE0(gUnknown_020388F2 + gUnknown_020388F4); } else { - MenuZeroFillWindowRect(15, 12, 29, 19); + Menu_EraseWindowRect(15, 12, 29, 19); } } @@ -1757,7 +1757,7 @@ void sub_80FE948(u8 taskId) } if (gMain.newKeys & A_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); gUnknown_020388F5 = gUnknown_020388F2 + gUnknown_020388F4; if (gUnknown_020388F5 == gUnknown_020388D5) @@ -1769,7 +1769,7 @@ void sub_80FE948(u8 taskId) } } else if (gMain.newKeys & B_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); gUnknown_083EC634[gTasks[taskId].data[11]].noFunc(taskId); } @@ -1839,13 +1839,13 @@ void sub_80FEABC(u8 taskId, u8 dummy1) void sub_80FEC94(u8 taskId) { - MenuDrawTextWindow(0, 0, 14, 19); + Menu_DrawStdWindowFrame(0, 0, 14, 19); sub_80FEABC(taskId, 0); } void sub_80FECB8(u8 decoCat) { - MenuDrawTextWindow(15, 0, 29, 3); + Menu_DrawStdWindowFrame(15, 0, 29, 3); sub_80FE470(decoCat, 16, 1, 0xff); } @@ -1902,8 +1902,8 @@ _080FED26:\n\ void sub_80FED1C(void) { - MenuZeroFillWindowRect(15, 0, 29, 3); - MenuZeroFillWindowRect(15, 12, 29, 19); + Menu_EraseWindowRect(15, 0, 29, 3); + Menu_EraseWindowRect(15, 12, 29, 19); } void sub_80FED3C(u8 taskId) @@ -2005,8 +2005,8 @@ void sub_80FEF74(void) sub_80F9520(gUnknown_020388F7, 8); DestroyVerticalScrollIndicator(0); DestroyVerticalScrollIndicator(1); - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 14, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 14, 19); } bool8 sub_80FEFA4(void) @@ -2035,8 +2035,8 @@ void sub_80FEFF4(u8 taskId) void sub_80FF034(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 14, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 14, 19); sub_80FE5AC(taskId); } @@ -3128,7 +3128,7 @@ void sub_81000A0(u8 taskId) void sub_81000C4(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); sub_8100174(taskId); if (gDecorations[gUnknown_020388D0[gUnknown_020388F5]].permission != DECORPERM_SOLID_MAT) { @@ -3186,7 +3186,7 @@ void sub_8100248(u8 taskId) void sub_810026C(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); sub_810028C(taskId); } @@ -3341,7 +3341,7 @@ void sub_8100494(u8 taskId) void sub_810065C(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); gSprites[gUnknown_020391A8].data[7] = 0; gTasks[taskId].data[10] = 0; gTasks[taskId].func = sub_8100494; @@ -3723,7 +3723,7 @@ void sub_8100C88(u8 taskId) { DrawWholeMapView(); ScriptContext1_SetupScript(gUnknown_081A2F8A); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); gTasks[taskId].data[2] = 2; } break; @@ -3760,7 +3760,7 @@ bool8 sub_8100D38(u8 taskId) void SetUpPuttingAwayDecorationPlayerAvatar(void) { player_get_direction_lower_nybble(); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); gUnknown_020391A8 = gSprites[gUnknown_03004880.unk4].data[0]; sub_81016C8(); gUnknown_03004880.unk4 = CreateSprite(&gSpriteTemplate_83ECA88, 0x78, 0x50, 0); @@ -3790,7 +3790,7 @@ void sub_8100E70(u8 taskId) data[2] = 1; data[6] = 1; data[5] = 1; - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); } break; case 1: @@ -3810,7 +3810,7 @@ void sub_8100E70(u8 taskId) void sub_8100EEC(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); gSprites[gUnknown_020391A8].data[7] = 0; gSprites[gUnknown_020391A8].invisible = 0; gSprites[gUnknown_020391A8].callback = sub_8101698; @@ -4150,7 +4150,7 @@ void sub_810156C(u8 taskId) void sub_8101590(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); sub_81015B0(taskId); } @@ -4192,7 +4192,7 @@ void sub_8101648(u8 taskId) void sub_8101678(void) { pal_fill_black(); - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); sub_80FE220(); CreateTask(sub_8101648, 8); } @@ -4274,7 +4274,7 @@ void sub_8101824(u8 taskId) void sub_8101848(u8 taskId) { - MenuZeroFillWindowRect(20, 8, 26, 14); + Menu_EraseWindowRect(20, 8, 26, 14); sub_8109A30(gUnknown_020388D0[gUnknown_020388F5]); gUnknown_020388D0[gUnknown_020388F5] = DECOR_NONE; sub_80FF098(taskId); diff --git a/src/field/diploma.c b/src/field/diploma.c index 27601404c..978eca7eb 100644 --- a/src/field/diploma.c +++ b/src/field/diploma.c @@ -10,7 +10,7 @@ #include "strings2.h" #include "task.h" #include "text.h" -#include "unknown_task.h" +#include "scanline_effect.h" static void VBlankCB(void); static void MainCB2(void); @@ -62,14 +62,14 @@ void CB2_ShowDiploma(void) LZ77UnCompVram(gDiplomaTiles, (void *)VRAM); LZ77UnCompVram(gDiplomaTilemap, (void *)(VRAM + 0x3000)); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); ResetPaletteFade(); FreeAllSpritePalettes(); LoadPalette(gDiplomaPalettes, 0, 64); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); DisplayDiplomaText(); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); @@ -135,5 +135,5 @@ static void DisplayDiplomaText(void) REG_BG3HOFS = 0; StringCopy(gStringVar1, gOtherText_HoennDex); } - MenuPrint(gOtherText_DiplomaCertificationGameFreak, 6, 2); + Menu_PrintText(gOtherText_DiplomaCertificationGameFreak, 6, 2); }
\ No newline at end of file diff --git a/src/field/field_effect.c b/src/field/field_effect.c index 1fe238901..435978034 100644 --- a/src/field/field_effect.c +++ b/src/field/field_effect.c @@ -2435,8 +2435,8 @@ void sub_8088380(struct Task *task) IntrCallback callback; LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&callback); SetVBlankCallback(callback); - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); FreeResourcesAndDestroySprite(&gSprites[task->data[15]]); FieldEffectActiveListRemove(FLDEFF_FIELD_MOVE_SHOW_MON); DestroyTask(FindTaskIdByFunc(sub_8088120)); @@ -2558,8 +2558,8 @@ void sub_808862C(struct Task *task) CpuFill32(0, (void *)VRAM + bg0cnt, 0x800); LoadWordFromTwoHalfwords((u16 *)&task->data[13], (u32 *)&intrCallback); SetVBlankCallback(intrCallback); - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); FreeResourcesAndDestroySprite(&gSprites[task->data[15]]); FieldEffectActiveListRemove(FLDEFF_FIELD_MOVE_SHOW_MON); DestroyTask(FindTaskIdByFunc(sub_808847C)); diff --git a/src/field/field_message_box.c b/src/field/field_message_box.c index 35aac7ac9..5eec7a14b 100644 --- a/src/field/field_message_box.c +++ b/src/field/field_message_box.c @@ -19,8 +19,8 @@ static void PrintFieldMessageFromStringVar4(void); void InitFieldMessageBox(void) { sMessageBoxMode = FIELD_MESSAGE_BOX_HIDDEN; - SetMessageBoxBaseTileNum(gMenuTextWindowContentTileOffset); - InitWindowFromConfig(&gFieldMessageBoxWindow, &gWindowConfig_81E6CE4); + TextWindow_SetDlgFrameBaseTileNum(gMenuTextWindowContentTileOffset); + Text_InitWindowWithTemplate(&gFieldMessageBoxWindow, &gWindowTemplate_81E6CE4); } static void Task_FieldMessageBox(u8 taskId) @@ -29,22 +29,22 @@ static void Task_FieldMessageBox(u8 taskId) switch (task->data[0]) { case 0: - LoadMessageBoxTiles(&gFieldMessageBoxWindow); + TextWindow_LoadDialogueFrameTiles(&gFieldMessageBoxWindow); task->data[0]++; break; case 1: - DrawStandardMessageBox(&gFieldMessageBoxWindow); + TextWindow_DrawDialogueFrame(&gFieldMessageBoxWindow); task->data[0]++; break; case 2: switch (sMessageBoxMode) { case FIELD_MESSAGE_BOX_NORMAL: - if (!sub_80035AC(&gFieldMessageBoxWindow)) + if (!Text_UpdateWindow(&gFieldMessageBoxWindow)) return; break; case FIELD_MESSAGE_BOX_AUTO_SCROLL: - if (!sub_8003778(&gFieldMessageBoxWindow)) + if (!Text_UpdateWindowAutoscroll(&gFieldMessageBoxWindow)) return; break; } @@ -117,20 +117,20 @@ bool8 unref_sub_8064BD0(const u8 *message) static void PrintFieldMessage(const u8 *message) { StringExpandPlaceholders(gStringVar4, message); - sub_8002EB0(&gFieldMessageBoxWindow, gStringVar4, gMenuTextTileOffset, 2, 15); + Text_InitWindow8002EB0(&gFieldMessageBoxWindow, gStringVar4, gMenuTextTileOffset, 2, 15); CreateFieldMessageBoxTask(); } static void PrintFieldMessageFromStringVar4(void) { - sub_8002EB0(&gFieldMessageBoxWindow, gStringVar4, gMenuTextTileOffset, 2, 15); + Text_InitWindow8002EB0(&gFieldMessageBoxWindow, gStringVar4, gMenuTextTileOffset, 2, 15); CreateFieldMessageBoxTask(); } void HideFieldMessageBox(void) { DestroyFieldMessageBoxTask(); - ClearStandardMessageBox(&gFieldMessageBoxWindow); + TextWindow_EraseDialogueFrame(&gFieldMessageBoxWindow); sMessageBoxMode = FIELD_MESSAGE_BOX_HIDDEN; } @@ -150,6 +150,6 @@ bool8 IsFieldMessageBoxHidden(void) void unref_sub_8064CA0(void) { DestroyFieldMessageBoxTask(); - DrawStandardMessageBox(&gFieldMessageBoxWindow); + TextWindow_DrawDialogueFrame(&gFieldMessageBoxWindow); sMessageBoxMode = FIELD_MESSAGE_BOX_HIDDEN; } diff --git a/src/field/field_player_avatar.c b/src/field/field_player_avatar.c index d80076be4..9a29e2e92 100644 --- a/src/field/field_player_avatar.c +++ b/src/field/field_player_avatar.c @@ -1507,7 +1507,7 @@ u8 Fishing4(struct Task *task) { u32 randVal; - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); task->tStep++; task->tFrameCounter = 0; task->tNumDots = 0; @@ -1549,7 +1549,7 @@ u8 Fishing5(struct Task *task) } else { - MenuPrint(dot, task->tNumDots + 4, 15); + Menu_PrintText(dot, task->tNumDots + 4, 15); task->tNumDots++; } } @@ -1573,7 +1573,7 @@ u8 Fishing6(struct Task *task) u8 Fishing7(struct Task *task) { sub_805A954(); - MenuPrint(gOtherText_OhABite, 4, 17); + Menu_PrintText(gOtherText_OhABite, 4, 17); task->tStep++; task->tFrameCounter = 0; return 0; @@ -1624,7 +1624,7 @@ u8 Fishing10(struct Task *task) { sub_805A954(); MenuPrintMessageDefaultCoords(gOtherText_PokeOnHook); - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); task->tStep++; task->tFrameCounter = 0; return 0; @@ -1637,7 +1637,7 @@ u8 Fishing11(struct Task *task) if (task->tFrameCounter == 0) { - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { struct MapObject *playerMapObj = &gMapObjects[gPlayerAvatar.mapObjectId]; @@ -1647,7 +1647,7 @@ u8 Fishing11(struct Task *task) sub_8127F28(gMapObjects[gPlayerAvatar.mapObjectId].mapobj_unk_1A, 0, 0); gSprites[gPlayerAvatar.spriteId].pos2.x = 0; gSprites[gPlayerAvatar.spriteId].pos2.y = 0; - MenuZeroFillScreen(); + Menu_EraseScreen(); task->tFrameCounter++; return 0; } @@ -1688,7 +1688,7 @@ u8 Fishing13(struct Task *task) u8 Fishing14(struct Task *task) { sub_805A954(); - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); task->tStep++; return 0; } @@ -1713,12 +1713,12 @@ u8 Fishing15(struct Task *task) u8 Fishing16(struct Task *task) { - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { gPlayerAvatar.preventStep = FALSE; ScriptContext2_Disable(); UnfreezeMapObjects(); - MenuZeroFillScreen(); + Menu_EraseScreen(); sub_80BE97C(0); DestroyTask(FindTaskIdByFunc(Task_Fishing)); } diff --git a/src/field/field_region_map.c b/src/field/field_region_map.c index 73e101d8f..54091459f 100644 --- a/src/field/field_region_map.c +++ b/src/field/field_region_map.c @@ -50,13 +50,13 @@ void CB2_FieldInitRegionMap(void) InitRegionMap((void *)&ewram0_5.unk8, 0); CreateRegionMapPlayerIcon(0, 0); CreateRegionMapCursor(1, 1); - SetUpWindowConfig(&gWindowConfig_81E709C); - InitMenuWindow(&gWindowConfig_81E709C); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E709C); + InitMenuWindow(&gWindowTemplate_81E709C); + Menu_EraseScreen(); REG_BG0CNT = BGCNT_PRIORITY(0) | BGCNT_CHARBASE(0) | BGCNT_SCREENBASE(31) | BGCNT_16COLOR | BGCNT_TXT256x256; - MenuDrawTextWindow(21, 0, 29, 3); + Menu_DrawStdWindowFrame(21, 0, 29, 3); sub_8072BD8(gOtherText_Hoenn, 0x16, 1, 0x38); - MenuDrawTextWindow(16, 16, 29, 19); + Menu_DrawStdWindowFrame(16, 16, 29, 19); sub_813F0C8(); SetMainCallback2(CB2_FieldRegionMap); SetVBlankCallback(VBlankCB_FieldRegionMap); @@ -117,7 +117,7 @@ void sub_813EFDC(void) void sub_813F0C8(void) { - MenuFillWindowRectWithBlankTile(17, 17, 28, 18); + Menu_BlankWindowRect(17, 17, 28, 18); if (ewram0_5.unk8.unk16) - MenuPrint(ewram0_5.unk8.str, 17, 17); + Menu_PrintText(ewram0_5.unk8.str, 17, 17); } diff --git a/src/field/field_screen_effect.c b/src/field/field_screen_effect.c index a472d5a9c..61301c5a9 100644 --- a/src/field/field_screen_effect.c +++ b/src/field/field_screen_effect.c @@ -7,13 +7,13 @@ #include "script.h" #include "task.h" #include "text.h" -#include "unknown_task.h" +#include "scanline_effect.h" const static u16 gUnknown_0839ACDC[] = { 0xC8, 0x48, 0x38, 0x28, 0x18, 0x0 }; const s32 gMaxFlashLevel = 4; -const static struct UnknownTaskStruct gUnknown_0839ACEC = +const static struct ScanlineEffectParams gUnknown_0839ACEC = { (void *)REG_ADDR_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, @@ -64,18 +64,18 @@ static void sub_8081424(u8 taskId) switch (data[0]) { case 0: - sub_8081398(&gUnknown_03004DE0[gUnknown_03004DC0.srcBank][0], data[1], data[2], data[3]); + sub_8081398(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], data[1], data[2], data[3]); data[0] = 1; break; case 1: - sub_8081398(&gUnknown_03004DE0[gUnknown_03004DC0.srcBank][0], data[1], data[2], data[3]); + sub_8081398(gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer], data[1], data[2], data[3]); data[0] = 0; data[3] += data[5]; if (data[3] > data[4]) { if (data[6] == 1) { - remove_some_task(); + ScanlineEffect_Stop(); data[0] = 2; } else @@ -85,7 +85,7 @@ static void sub_8081424(u8 taskId) } break; case 2: - dp12_8087EA4(); + ScanlineEffect_Clear(); DestroyTask(taskId); break; } @@ -140,8 +140,8 @@ void sub_80815E0(u8 a1) { if (a1) { - sub_8081398(&gUnknown_03004DE0[0][0], 120, 80, gUnknown_0839ACDC[a1]); - CpuFastSet(&gUnknown_03004DE0[0], &gUnknown_03004DE0[1], 480); + sub_8081398(&gScanlineEffectRegBuffers[0][0], 120, 80, gUnknown_0839ACDC[a1]); + CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480); } } @@ -208,14 +208,14 @@ static void sub_80816A8(u8 taskId) REG_BLDALPHA = 1804; REG_WININ = 63; REG_WINOUT = 30; - sub_8081398(&gUnknown_03004DE0[0][0], data[2], data[3], 1); - CpuFastSet(&gUnknown_03004DE0[0], &gUnknown_03004DE0[1], 480); - //sub_80895F8(gUnknown_0839ACEC[0], gUnknown_0839ACEC[1], gUnknown_0839ACEC[2]); - sub_80895F8(gUnknown_0839ACEC); + sub_8081398(&gScanlineEffectRegBuffers[0][0], data[2], data[3], 1); + CpuFastSet(&gScanlineEffectRegBuffers[0], &gScanlineEffectRegBuffers[1], 480); + //ScanlineEffect_SetParams(gUnknown_0839ACEC[0], gUnknown_0839ACEC[1], gUnknown_0839ACEC[2]); + ScanlineEffect_SetParams(gUnknown_0839ACEC); data[0] = 1; break; case 1: - MenuFillWindowRectWithBlankTile(0, 0, 29, 19); + Menu_BlankWindowRect(0, 0, 29, 19); sub_808161C(data[1]); sub_8081534(data[2], data[3], 1, 160, 1, 2); data[0] = 2; @@ -264,8 +264,8 @@ static void sub_80816A8(u8 taskId) } break; case 5: - MenuZeroFillWindowRect(0, 0, 29, 19); - LoadFontDefaultPalette(&gWindowConfig_81E6CE4); + Menu_EraseWindowRect(0, 0, 29, 19); + LoadFontDefaultPalette(&gWindowTemplate_81E6CE4); REG_WIN0H = 255; REG_DISPCNT = data[6]; REG_BLDCNT = data[7]; diff --git a/src/field/field_specials.c b/src/field/field_specials.c index fc6f690a3..aade7cffd 100644 --- a/src/field/field_specials.c +++ b/src/field/field_specials.c @@ -1058,7 +1058,7 @@ static void sub_810E874(void) ScriptContext2_Enable(); if (gUnknown_0203925A > 5) { - MenuDrawTextWindow(0, 0, 8, 11); + Menu_DrawStdWindowFrame(0, 0, 8, 11); InitMenu(0, 1, 1, 5, 0, 7); gUnknown_0203925C = 0; sub_80F944C(); @@ -1067,12 +1067,12 @@ static void sub_810E874(void) } else { - MenuDrawTextWindow(0, 0, 8, 2 * gUnknown_0203925A + 1); + Menu_DrawStdWindowFrame(0, 0, 8, 2 * gUnknown_0203925A + 1); InitMenu(0, 1, 1, gUnknown_0203925A, 0, 7); } for (i = 0; i < 5 && gUnknown_03000760[i].var0 != 16; i ++) { - MenuPrint(gUnknown_083F8380[gUnknown_03000760[i].var0], 1, 2 * i + 1); + Menu_PrintText(gUnknown_083F8380[gUnknown_03000760[i].var0], 1, 2 * i + 1); } DisplayCurrentElevatorFloor(); CreateTask(sub_810E984, 8); @@ -1080,7 +1080,7 @@ static void sub_810E874(void) void DisplayCurrentElevatorFloor(void) { - MenuDrawTextWindow(20, 0, 29, 5); + Menu_DrawStdWindowFrame(20, 0, 29, 5); sub_8072BD8(gOtherText_NowOn, 21, 1, 64); sub_8072BD8(gUnknown_083F8380[gSpecialVar_0x8005], 21, 3, 64); } @@ -1091,15 +1091,15 @@ void sub_810E984(u8 taskId) if (gMain.newKeys == DPAD_UP && gUnknown_0203925B != 0) { gUnknown_0203925B--; - curMenuPos = GetMenuCursorPos(); - MoveMenuCursorNoWrap(-1); + curMenuPos = Menu_GetCursorPos(); + Menu_MoveCursorNoWrap(-1); sub_810EAC8(curMenuPos, DPAD_UP); } if (gMain.newKeys == DPAD_DOWN && gUnknown_0203925B != gUnknown_0203925A - 1) { gUnknown_0203925B++; - curMenuPos = GetMenuCursorPos(); - MoveMenuCursorNoWrap(+1); + curMenuPos = Menu_GetCursorPos(); + Menu_MoveCursorNoWrap(+1); sub_810EAC8(curMenuPos, DPAD_DOWN); } if (gMain.newKeys & A_BUTTON) @@ -1109,7 +1109,7 @@ void sub_810E984(u8 taskId) { gSpecialVar_Result = 0; PlaySE(SE_SELECT); - MenuZeroFillWindowRect(0, 0, 29, 12); + Menu_EraseWindowRect(0, 0, 29, 12); sub_810EC9C(taskId); } else @@ -1119,7 +1119,7 @@ void sub_810E984(u8 taskId) ShakeScreenInElevator(); FieldObjectTurnByLocalIdAndMap(gSpecialVar_LastTalked, gSaveBlock1.location.mapNum, gSaveBlock1.location.mapGroup, DIR_SOUTH); sub_810EEDC(); - MenuZeroFillScreen(); + Menu_EraseScreen(); DestroyTask(taskId); } } @@ -1128,7 +1128,7 @@ void sub_810E984(u8 taskId) gSpecialVar_Result = 0; PlaySE(SE_SELECT); sub_810EEDC(); - MenuZeroFillWindowRect(0, 0, 29, 12); + Menu_EraseWindowRect(0, 0, 29, 12); sub_810EC9C(taskId); } } @@ -1163,10 +1163,10 @@ bool8 sub_810EAC8(u8 prevMenuPos, u8 dpadInput) if (flag) { sub_810EB90(newPos, 5); - MenuFillWindowRectWithBlankTile(2, 1, 7, 10); + Menu_BlankWindowRect(2, 1, 7, 10); for (i=0; i<5 && gUnknown_03000760[newPos].var0 != 16; newPos++, i++) { - MenuPrint(gUnknown_083F8380[gUnknown_03000760[newPos].var0], 1, i * 2 + 1); + Menu_PrintText(gUnknown_083F8380[gUnknown_03000760[newPos].var0], 1, i * 2 + 1); } } return flag; @@ -1227,7 +1227,7 @@ bool8 sub_810EAC8(u8 prevMenuPos, u8 dpadInput) "\tmovs r1, 0x1\n" "\tmovs r2, 0x7\n" "\tmovs r3, 0xA\n" - "\tbl MenuFillWindowRectWithBlankTile\n" + "\tbl Menu_BlankWindowRect\n" "\tmovs r5, 0\n" "\tldr r2, _0810EB88 @ =gUnknown_03000760\n" "\tlsls r1, r4, 2\n" @@ -1249,7 +1249,7 @@ bool8 sub_810EAC8(u8 prevMenuPos, u8 dpadInput) "\tlsls r2, 24\n" "\tlsrs r2, 24\n" "\tmovs r1, 0x1\n" - "\tbl MenuPrint\n" + "\tbl Menu_PrintText\n" "\tadds r0, r4, 0x1\n" "\tlsls r0, 24\n" "\tlsrs r4, r0, 24\n" @@ -1539,7 +1539,7 @@ void ShowGlassWorkshopMenu(void) { u8 i; ScriptContext2_Enable(); - MenuDrawTextWindow(0, 0, 10, 11); + Menu_DrawStdWindowFrame(0, 0, 10, 11); InitMenu(0, 1, 1, 5, 0, 9); gUnknown_0203925C = 0; sub_80F944C(); @@ -1547,7 +1547,7 @@ void ShowGlassWorkshopMenu(void) sub_810F2B4(); for (i=0; i<5; i++) { - MenuPrint(gUnknown_083F83C0[i], 1, 2 * i + 1); + Menu_PrintText(gUnknown_083F83C0[i], 1, 2 * i + 1); } gUnknown_0203925B = 0; gUnknown_0203925A = ARRAY_COUNT(gUnknown_083F83C0); @@ -1560,33 +1560,33 @@ void sub_810F118(u8 taskId) if (gMain.newKeys == DPAD_UP && gUnknown_0203925B != 0) { gUnknown_0203925B--; - prevCursorPos = GetMenuCursorPos(); - MoveMenuCursorNoWrap(-1); + prevCursorPos = Menu_GetCursorPos(); + Menu_MoveCursorNoWrap(-1); sub_810F1F4(prevCursorPos, DPAD_UP); } if (gMain.newKeys == DPAD_DOWN && gUnknown_0203925B != gUnknown_0203925A - 1) { gUnknown_0203925B++; - prevCursorPos = GetMenuCursorPos(); - MoveMenuCursorNoWrap(1); + prevCursorPos = Menu_GetCursorPos(); + Menu_MoveCursorNoWrap(1); sub_810F1F4(prevCursorPos, DPAD_DOWN); } if (gMain.newKeys & A_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); gSpecialVar_Result = gUnknown_0203925B; PlaySE(SE_SELECT); sub_810EEDC(); - MenuZeroFillWindowRect(0, 0, 29, 12); + Menu_EraseWindowRect(0, 0, 29, 12); sub_810EC9C(taskId); } if (gMain.newKeys & B_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); gSpecialVar_Result = 0x7f; PlaySE(SE_SELECT); sub_810EEDC(); - MenuZeroFillWindowRect(0, 0, 29, 12); + Menu_EraseWindowRect(0, 0, 29, 12); sub_810EC9C(taskId); } } @@ -1621,10 +1621,10 @@ bool8 sub_810F1F4(u8 prevCursorPos, u8 dpadInput) if (flag) { GlassWorkshopUpdateScrollIndicators(newPos, 5); - MenuFillWindowRectWithBlankTile(2, 1, 9, 10); + Menu_BlankWindowRect(2, 1, 9, 10); for (i=0; i<5; newPos++, i++) { - MenuPrint(gUnknown_083F83C0[newPos], 1, 2 * i + 1); + Menu_PrintText(gUnknown_083F83C0[newPos], 1, 2 * i + 1); } } return flag; @@ -1683,7 +1683,7 @@ bool8 sub_810F1F4(u8 prevCursorPos, u8 dpadInput) "\tmovs r1, 0x1\n" "\tmovs r2, 0x9\n" "\tmovs r3, 0xA\n" - "\tbl MenuFillWindowRectWithBlankTile\n" + "\tbl Menu_BlankWindowRect\n" "\tmovs r5, 0\n" "\tldr r7, _0810F28C @ =gUnknown_083F83C0\n" "_0810F25C:\n" @@ -1695,7 +1695,7 @@ bool8 sub_810F1F4(u8 prevCursorPos, u8 dpadInput) "\tlsls r2, 24\n" "\tlsrs r2, 24\n" "\tmovs r1, 0x1\n" - "\tbl MenuPrint\n" + "\tbl Menu_PrintText\n" "\tadds r0, r4, 0x1\n" "\tlsls r0, 24\n" "\tlsrs r4, r0, 24\n" diff --git a/src/field/fldeff_softboiled.c b/src/field/fldeff_softboiled.c index a574232a8..3c64ec520 100644 --- a/src/field/fldeff_softboiled.c +++ b/src/field/fldeff_softboiled.c @@ -126,7 +126,7 @@ static void sub_8133E74(u8 taskId) { return; } - MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + Menu_EraseWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); PrintPartyMenuPromptText(3, 0); gTasks[taskId].func = HandlePartyMenuSwitchPokemonInput; } @@ -142,7 +142,7 @@ static void sub_8133EF8(void) { sub_806CCE4(); EWRAM_1B000_2.unk261 = 2; DestroySprite(&gSprites[EWRAM_1000.unk1]); - MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + Menu_EraseWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); PrintPartyMenuPromptText(0, 0); SwitchTaskToFollowupFunc(EWRAM_1000.unk0); } diff --git a/src/field/item_menu.c b/src/field/item_menu.c index e9b8b24d3..e0575af4c 100644 --- a/src/field/item_menu.c +++ b/src/field/item_menu.c @@ -33,7 +33,7 @@ #include "string_util.h" #include "task.h" #include "text.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "ewram.h" // External stuff @@ -397,7 +397,7 @@ static bool8 SetupBagMultistep(void) gMain.state++; break; case 1: - remove_some_task(); + ScanlineEffect_Stop(); gMain.state++; break; case 2: @@ -424,11 +424,11 @@ static bool8 SetupBagMultistep(void) gMain.state++; break; case 7: - SetUpWindowConfig(&gWindowConfig_81E6DFC); + Text_LoadWindowTemplate(&gWindowTemplate_81E6DFC); gMain.state++; break; case 8: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6DFC); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E6DFC); gMain.state++; break; case 9: @@ -1062,7 +1062,7 @@ void sub_80A4164(u8 *dest, u16 value, enum StringConvertMode mode, u8 digits) void sub_80A418C(u16 value, enum StringConvertMode mode, u8 c, u8 d, u8 digits) { sub_80A4164(gStringVar1, value, mode, digits); - MenuPrint(gStringVar1, c, d); + Menu_PrintText(gStringVar1, c, d); } static void sub_80A41D4(u8 taskId) @@ -1112,7 +1112,7 @@ static bool8 sub_80A42B0(u8 itemPos, int b) return TRUE; r5 = itemPos * 2 + 2; sub_8072C74(gStringVar1, gOtherText_CloseBag, 0x78, 0); - MenuPrint(gStringVar1, 14, r5); + Menu_PrintText(gStringVar1, 14, r5); ptr = gBGTilemapBuffers[2] + 14 + r5 * 32; ptr[0] = 0x4F; ptr[1] = 0x4F; @@ -1121,9 +1121,9 @@ static bool8 sub_80A42B0(u8 itemPos, int b) if (itemPos == 7) return TRUE; if ((b == 1 && r8->unk2 != 0) || b == 2) - MenuFillWindowRectWithBlankTile(14, r5 + 2, 29, 13); + Menu_BlankWindowRect(14, r5 + 2, 29, 13); else - MenuFillWindowRectWithBlankTile(14, r5 + 2, 29, 17); + Menu_BlankWindowRect(14, r5 + 2, 29, 17); return TRUE; } return FALSE; @@ -1148,7 +1148,7 @@ static void sub_80A4380(u16 a, int b, int c, int d) text = sub_8072C74(text, ItemId_GetItem(gCurrentBagPocketItemSlots[r4].itemId)->name, 0x66, 0); *text++ = CHAR_MULT_SIGN; sub_8072C14(text, gCurrentBagPocketItemSlots[r4].quantity, 0x78, 1); - MenuPrint(gStringVar1, 14, r5); + Menu_PrintText(gStringVar1, 14, r5); } } @@ -1173,7 +1173,7 @@ static void sub_80A444C(u16 a, int b, int c, int d) #else sub_8072C74(text, ItemId_GetItem(gCurrentBagPocketItemSlots[r4].itemId)->name, 0x63, 0); #endif - MenuPrint(gStringVar1, 14, r5); + Menu_PrintText(gStringVar1, 14, r5); if (gUnknown_02038558 != 0) { if (gCurrentBagPocketItemSlots[r4].itemId == gSaveBlock1.registeredItem) @@ -1240,7 +1240,7 @@ static void sub_80A4548(u16 a, int b, int c, int d) moveName = gMoveNames[ItemIdToBattleMoveId(gCurrentBagPocketItemSlots[r4].itemId)]; sub_8072C74(text, moveName, 0x78, 0); } - MenuPrint(gStringVar1, 14, sp10); + Menu_PrintText(gStringVar1, 14, sp10); } } #else @@ -1421,7 +1421,7 @@ _080A46AE:\n\ ldr r0, _080A46F8 @ =gStringVar1\n\ movs r1, 0xE\n\ ldr r2, [sp, 0x10]\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ mov r0, r8\n\ adds r0, 0x1\n\ lsls r0, 24\n\ @@ -1482,7 +1482,7 @@ static void sub_80A46FC(u16 a, int b, int c, int d) text = sub_80A425C(a, text, i); CopyItemName(gCurrentBagPocketItemSlots[r4].itemId, gStringVar2); sub_80A41E0(text, gCurrentBagPocketItemSlots[r4].itemId - 0x84, gStringVar2, gCurrentBagPocketItemSlots[r4].quantity, 3); - MenuPrint(gStringVar1, 14, r5); + Menu_PrintText(gStringVar1, 14, r5); } } @@ -1540,7 +1540,7 @@ static void ItemListMenu_InitDescription(s16 itemId) } if (r5 < 3) - MenuZeroFillWindowRect(0, 13 + r5 * 2, 13, 20); + Menu_EraseWindowRect(0, 13 + r5 * 2, 13, 20); } static void ItemListMenu_ChangeDescription(s16 itemId, int b) @@ -1551,20 +1551,20 @@ static void ItemListMenu_ChangeDescription(s16 itemId, int b) { if (b == 0) { - MenuZeroFillWindowRect(0, 13, 13, 20); - MenuPrint_PixelCoords(gOtherText_ReturnTo, 4, 0x68, 0); + Menu_EraseWindowRect(0, 13, 13, 20); + Menu_PrintTextPixelCoords(gOtherText_ReturnTo, 4, 0x68, 0); } else if (b == 1) { - MenuPrint_PixelCoords(gUnknown_0840E740[sReturnLocation], 4, 0x78, 0); + Menu_PrintTextPixelCoords(gUnknown_0840E740[sReturnLocation], 4, 0x78, 0); } } else { if (b == 0) - MenuZeroFillWindowRect(0, 13, 13, 20); + Menu_EraseWindowRect(0, 13, 13, 20); if (ItemId_CopyDescription(description, itemId, b)) - MenuPrint_PixelCoords(description, 4, 104 + b * 16, 0); + Menu_PrintTextPixelCoords(description, 4, 104 + b * 16, 0); } } @@ -1602,9 +1602,9 @@ static void sub_80A4A98(const u8 *text, u32 line) u8 buffer[100]; if (line == 0) - MenuZeroFillWindowRect(0, 13, 13, 20); + Menu_EraseWindowRect(0, 13, 13, 20); if (CopyTextLine(buffer, text, line)) - MenuPrint_PixelCoords(buffer, 4, 104 + line * 16, 0); + Menu_PrintTextPixelCoords(buffer, 4, 104 + line * 16, 0); } static void sub_80A4ADC(u8 taskId) @@ -1618,7 +1618,7 @@ static void sub_80A4ADC(u8 taskId) static void sub_80A4B14(s8 a, u8 b) { gBagPocketScrollStates[sCurrentBagPocket].scrollTop += a; - MoveMenuCursor(0); + Menu_MoveCursor(0); sub_80A73C0(); sub_80A763C(); sub_80A4ADC(b); @@ -1626,7 +1626,7 @@ static void sub_80A4B14(s8 a, u8 b) static void sub_80A4B58(s8 delta, u8 b) { - gBagPocketScrollStates[sCurrentBagPocket].cursorPos = MoveMenuCursor(delta); + gBagPocketScrollStates[sCurrentBagPocket].cursorPos = Menu_MoveCursor(delta); sub_80A73C0(); sub_80A4ADC(b); } @@ -1649,7 +1649,7 @@ static void sub_80A4BF0(u16 *a) if (gUnknown_02038564 == 4) { - MenuDrawTextWindow(0, 7, 13, 12); + Menu_DrawStdWindowFrame(0, 7, 13, 12); sub_80A4008(a, 1, 8, 12, 4); if (sub_80F9344() == TRUE && sReturnLocation == RETURN_TO_FIELD_5) { @@ -1665,7 +1665,7 @@ static void sub_80A4BF0(u16 *a) text = sub_80A4B90(gSpecialVar_ItemId); else text = sItemPopupMenuActions[sPopupMenuActionList[i]].text; - MenuPrint(text, 1 + (i / 2) * 6, 8 + (i % 2) * 2); + Menu_PrintText(text, 1 + (i / 2) * 6, 8 + (i % 2) * 2); } } if (sReturnLocation == RETURN_TO_FIELD_5) @@ -1676,10 +1676,10 @@ static void sub_80A4BF0(u16 *a) } else { - MenuDrawTextWindow(0, 5, 13, 12); + Menu_DrawStdWindowFrame(0, 5, 13, 12); sub_80A4008(a, 1, 6, 12, 6); for (i = 0; i < gUnknown_02038564; i++) - MenuPrint(sItemPopupMenuActions[sPopupMenuActionList[i]].text, 1 + (i / 3) * 6, 6 + (i % 3) * 2); + Menu_PrintText(sItemPopupMenuActions[sPopupMenuActionList[i]].text, 1 + (i / 3) * 6, 6 + (i % 3) * 2); InitMenu(0, 1, 6, gUnknown_02038564, 0, 1); sub_8072DCC(0x2F); } @@ -1690,7 +1690,7 @@ static void sub_80A4DA4(u16 *a) { sub_80A73FC(); sub_80A36B8(a, 0, 6, 13, 6); - MenuZeroFillWindowRect(0, 5, 13, 12); + Menu_EraseWindowRect(0, 5, 13, 12); sub_80A7590(); } @@ -1699,7 +1699,7 @@ static void sub_80A4DD8(u8 taskId, u8 b, u8 c, u8 d, u8 e, u8 digits) gTasks[taskId].data[1] = 1; gTasks[taskId].data[2] = b + 2; gTasks[taskId].data[3] = c + 1; - MenuDrawTextWindow(b, c, b + d, c + e); + Menu_DrawStdWindowFrame(b, c, b + d, c + e); sub_80A4008(gBGTilemapBuffers[1], b + 1, c + 1, d - 1, e - 1); sub_80A418C(1, 1, b + 2, c + 1, digits); } @@ -2539,7 +2539,7 @@ static void sub_80A57C4(void) r5 = 7; } sub_80A4008(gBGTilemapBuffers[1], 7, r5 + 1, 6, gUnknown_02038564 * 2); - MenuDrawTextWindow(6, r5, 13, gUnknown_02038564 * 2 + 1 + r5); + Menu_DrawStdWindowFrame(6, r5, 13, gUnknown_02038564 * 2 + 1 + r5); sub_80A7834(0, r5); InitMenu(0, 7, r5 + 1, gUnknown_02038564, 0, 6); } @@ -2553,7 +2553,7 @@ static void sub_80A5888(u8 taskId) if (sPopupMenuSelection != 0) { PlaySE(SE_SELECT); - sPopupMenuSelection = MoveMenuCursor(-1); + sPopupMenuSelection = Menu_MoveCursor(-1); } } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) @@ -2561,7 +2561,7 @@ static void sub_80A5888(u8 taskId) if (sPopupMenuSelection != gUnknown_02038564 - 1) { PlaySE(SE_SELECT); - sPopupMenuSelection = MoveMenuCursor(1); + sPopupMenuSelection = Menu_MoveCursor(1); } } else if (gMain.newKeys & A_BUTTON) @@ -2690,14 +2690,14 @@ static void sub_80A5C24(u8 taskId) void CleanUpItemMenuMessage(u8 taskId) { sub_80A36B8(gBGTilemapBuffers[1], 0, 0, 31, 31); - MenuZeroFillWindowRect(7, 7, 13, 12); - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(7, 7, 13, 12); + Menu_EraseWindowRect(0, 14, 29, 19); gTasks[taskId].func = sub_80A5C24; } void CleanUpOverworldMessage(u8 taskId) { - MenuZeroFillWindowRect(0, 13, 29, 19); + Menu_EraseWindowRect(0, 13, 29, 19); DestroyTask(taskId); sub_8064E2C(); ScriptContext2_Disable(); @@ -2760,7 +2760,7 @@ static void sub_80A5DA0(u16 itemId, u16 quantity) static void sub_80A5DF8(void) { sub_80A4DA4(gBGTilemapBuffers[1]); - MenuZeroFillWindowRect(7, 6, 11, 13); + Menu_EraseWindowRect(7, 6, 11, 13); sub_80A7528(4); } @@ -2857,7 +2857,7 @@ static void sub_80A6024(u8 taskId) if (gMain.newKeys & A_BUTTON) { sub_80A36B8(gBGTilemapBuffers[1], 0, 0, 31, 31); - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); gTasks[taskId].func = sub_80A6000; } } @@ -3008,7 +3008,7 @@ static void sub_80A640C(u8 taskId) static void sub_80A6444(u8 taskId) { sub_80A36B8(gBGTilemapBuffers[1], 0, 0, 31, 31); - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); gTasks[taskId].func = sub_80A640C; } @@ -3016,7 +3016,7 @@ static void sub_80A648C(u8 taskId) { gTasks[taskId].func = Task_BuyHowManyDialogueHandleInput; sub_80A4008(gBGTilemapBuffers[1], 1, 11, 12, 2); - MenuDrawTextWindow(0, 10, 13, 13); + Menu_DrawStdWindowFrame(0, 10, 13, 13); gTasks[taskId].data[1] = 1; gTasks[taskId].data[2] = 1; gTasks[taskId].data[3] = 11; @@ -3053,7 +3053,7 @@ static void sub_80A6574(u8 taskId) static void sub_80A65AC(u8 taskId) { - MenuZeroFillWindowRect(7, 6, 13, 12); + Menu_EraseWindowRect(7, 6, 13, 12); sub_80A36B8(gBGTilemapBuffers[1], 7, 6, 6, 6); CopyItemName(gSpecialVar_ItemId, gStringVar2); StringExpandPlaceholders(gStringVar4, gOtherText_SoldItem); @@ -3063,7 +3063,7 @@ static void sub_80A65AC(u8 taskId) static void sub_80A6618(u8 taskId) { - MenuZeroFillWindowRect(7, 6, 13, 12); + Menu_EraseWindowRect(7, 6, 13, 12); sub_80A36B8(gBGTilemapBuffers[1], 7, 6, 6, 6); BuyMenuPrintItemQuantityAndPrice(taskId); } @@ -3078,13 +3078,13 @@ static void Task_BuyHowManyDialogueHandleInput(u8 taskId) { if (sub_80A5350(taskId) == TRUE) { - MenuZeroFillWindowRect(6, 11, 12, 11); + Menu_EraseWindowRect(6, 11, 12, 11); BuyMenuDisplayMessage(gSpecialVar_ItemId, gTasks[taskId].data[1]); } else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - MenuZeroFillWindowRect(0, 10, 13, 13); + Menu_EraseWindowRect(0, 10, 13, 13); sub_80A36B8(gBGTilemapBuffers[1], 0, 10, 13, 3); ConvertIntToDecimalStringN(gStringVar1, ItemId_GetPrice(gSpecialVar_ItemId) / 2 * gTasks[taskId].data[1], STR_CONV_MODE_LEFT_ALIGN, 6); StringExpandPlaceholders(gStringVar4, gOtherText_CanPay); @@ -3110,8 +3110,8 @@ static void BuyMenuPrintItemQuantityAndPrice(u8 taskId) { sub_80A36B8(gBGTilemapBuffers[1], 0, 0, 31, 31); CloseMoneyWindow(0, 0); - MenuZeroFillWindowRect(0, 4, 13, 13); - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 4, 13, 13); + Menu_EraseWindowRect(0, 14, 29, 19); gTasks[taskId].func = sub_80A6760; } @@ -3229,7 +3229,7 @@ static void sub_80A6A84(u8 taskId) sub_80A4DA4(gBGTilemapBuffers[1]); CopyItemName(gSpecialVar_ItemId, gStringVar1); ConvertIntToDecimalStringN(gStringVar2, taskData[1], STR_CONV_MODE_LEFT_ALIGN, 3); - MenuZeroFillWindowRect(7, 6, 11, 13); + Menu_EraseWindowRect(7, 6, 11, 13); sub_80A7528(7); sub_80A3D5C(taskId); gTasks[taskId].func = sub_80A5E1C; @@ -3361,16 +3361,16 @@ static void sub_80A6DF0(u16 *a) { u8 r6 = (gUnknown_02038564 - 1) * 2; - MenuDrawTextWindow(7, 9 - r6, 13, 12); + Menu_DrawStdWindowFrame(7, 9 - r6, 13, 12); sub_80A4008(a, 8, 10 - r6, 5, r6 + 2); if (gUnknown_02038564 == 1) { - MenuPrint(sItemPopupMenuActions[sPopupMenuActionList[0]].text, 8, 10); + Menu_PrintText(sItemPopupMenuActions[sPopupMenuActionList[0]].text, 8, 10); } else { - MenuPrint(sItemPopupMenuActions[sPopupMenuActionList[0]].text, 8, 8); - MenuPrint(sItemPopupMenuActions[sPopupMenuActionList[1]].text, 8, 10); + Menu_PrintText(sItemPopupMenuActions[sPopupMenuActionList[0]].text, 8, 8); + Menu_PrintText(sItemPopupMenuActions[sPopupMenuActionList[1]].text, 8, 10); } InitMenu(0, 8, 10 - r6, gUnknown_02038564, 0, 5); sub_80A7528(2); @@ -3383,7 +3383,7 @@ static void sub_80A6EB8(u8 taskId) if (sPopupMenuSelection == 1) { PlaySE(SE_SELECT); - sPopupMenuSelection = MoveMenuCursor(-1); + sPopupMenuSelection = Menu_MoveCursor(-1); } } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) @@ -3391,7 +3391,7 @@ static void sub_80A6EB8(u8 taskId) if (sPopupMenuSelection + 1 < gUnknown_02038564) { PlaySE(SE_SELECT); - sPopupMenuSelection = MoveMenuCursor(1); + sPopupMenuSelection = Menu_MoveCursor(1); } } else if (gMain.newKeys & A_BUTTON) @@ -3559,7 +3559,7 @@ static void ItemListMenu_InitMenu(void) static void sub_80A73C0(void) { - sub_814AD7C(0x70, gBagPocketScrollStates[sCurrentBagPocket].cursorPos * 16 + 16); + MenuCursor_SetPos814AD7C(0x70, gBagPocketScrollStates[sCurrentBagPocket].cursorPos * 16 + 16); } static void sub_80A73F0(void) @@ -3569,8 +3569,8 @@ static void sub_80A73F0(void) static void sub_80A73FC(void) { - HandleDestroyMenuCursors(); - sub_814AD44(); + Menu_DestroyCursor(); + MenuCursor_Destroy814AD44(); } static void sub_80A740C(void) @@ -3669,7 +3669,7 @@ static void sub_80A756C(void) static void sub_80A7590(void) { - MenuZeroFillWindowRect(0, 13, 13, 20); + Menu_EraseWindowRect(0, 13, 13, 20); sub_80A756C(); } @@ -3748,7 +3748,7 @@ static void sub_80A7694(void) static void sub_80A76A0(void) { - MenuZeroFillWindowRect(14, 2, 29, 18); + Menu_EraseWindowRect(14, 2, 29, 18); sub_80A7678(); } @@ -3816,7 +3816,7 @@ static void sub_80A7768(void) const u8 *text = sItemPopupMenuActions[sPopupMenuActionList[r4->unk1 - 1]].text; int var = r4->unk1 - 1; - MenuPrint(text, 7, var * 2 + 1 + r4->unk3); + Menu_PrintText(text, 7, var * 2 + 1 + r4->unk3); } else { @@ -3828,7 +3828,7 @@ static void sub_80A7768(void) else text = sItemPopupMenuActions[sPopupMenuActionList[r4->unk1 - 1]].text; var = r4->unk1 - 1; - MenuPrint(text, (var >> 1) * 6 + 1, (var & 1) * 2 + 8); + Menu_PrintText(text, (var >> 1) * 6 + 1, (var & 1) * 2 + 8); } if (r4->unk1 == gUnknown_02038564) { diff --git a/src/field/item_use.c b/src/field/item_use.c index e1fdddce0..bd76db77e 100644 --- a/src/field/item_use.c +++ b/src/field/item_use.c @@ -123,7 +123,7 @@ void HandleDeniedItemUseMessage(u8 var1, u8 playerMenuStatus, const u8 *text) switch (playerMenuStatus) { case 0: // Item Menu - MenuZeroFillWindowRect(0, 13, 13, 20); + Menu_EraseWindowRect(0, 13, 13, 20); DisplayItemMessageOnField(var1, gStringVar4, CleanUpItemMenuMessage, 1); break; default: // Field @@ -312,7 +312,7 @@ void RunItemfinderResults(u8 taskId) void ExitItemfinder(u8 taskId) { - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); sub_8064E2C(); ScriptContext2_Disable(); DestroyTask(taskId); @@ -744,7 +744,7 @@ void ItemUseOutOfBattle_CoinCase(u8 taskId) if (!gTasks[taskId].data[2]) { - MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + Menu_EraseWindowRect(0, 0xD, 0xD, 0x14); DisplayItemMessageOnField(taskId, gStringVar4, CleanUpItemMenuMessage, 1); } else @@ -770,7 +770,7 @@ void ItemUseOutOfBattle_SSTicket(u8 taskId) { if (gTasks[taskId].data[2] == 0) { - MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + Menu_EraseWindowRect(0, 0xD, 0xD, 0x14); DisplayItemMessageOnField(taskId, gUnknown_083D61DC[ItemId_GetSecondaryId(gSpecialVar_ItemId)], sub_80C9BB8, 1); } else @@ -875,7 +875,7 @@ void ItemUseOutOfBattle_RareCandy(u8 taskId) void ItemUseOutOfBattle_TMHM(u8 taskId) { - MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + Menu_EraseWindowRect(0, 0xD, 0xD, 0x14); if (gSpecialVar_ItemId >= ITEM_HM01) DisplayItemMessageOnField(taskId, gOtherText_BootedHM, sub_80C9EE4, 1); // HM @@ -1022,7 +1022,7 @@ void ItemUseInBattle_PokeBall(u8 var) } else { - MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + Menu_EraseWindowRect(0, 0xD, 0xD, 0x14); DisplayItemMessageOnField(var, gOtherText_BoxIsFull, CleanUpItemMenuMessage, 1); } } @@ -1047,7 +1047,7 @@ void ItemUseInBattle_StatIncrease(u8 taskId) { u16 partyId = gBattlePartyID[gBankInMenu]; - MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + Menu_EraseWindowRect(0, 0xD, 0xD, 0x14); if (ExecuteTableBasedItemEffect_(&gPlayerParty[partyId], gSpecialVar_ItemId, partyId, 0) != FALSE) { @@ -1096,7 +1096,7 @@ void ItemUseInBattle_PPRecovery(u8 var) void unref_sub_80CA448(u8 var) { - MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + Menu_EraseWindowRect(0, 0xD, 0xD, 0x14); if (ExecuteTableBasedItemEffect__(0, gSpecialVar_ItemId, 0) == FALSE) { @@ -1113,7 +1113,7 @@ void unref_sub_80CA448(u8 var) void ItemUseInBattle_Escape(u8 taskId) { - MenuZeroFillWindowRect(0, 0xD, 0xD, 0x14); + Menu_EraseWindowRect(0, 0xD, 0xD, 0x14); if((gBattleTypeFlags & BATTLE_TYPE_TRAINER) == FALSE) { diff --git a/src/field/map_name_popup.c b/src/field/map_name_popup.c index 2e2dfc72e..49a470cc1 100644 --- a/src/field/map_name_popup.c +++ b/src/field/map_name_popup.c @@ -89,8 +89,8 @@ void HideMapNamePopup(void) { if (FuncIsActiveTask(Task_MapNamePopup)) { - MenuLoadTextWindowGraphics(); - MenuZeroFillWindowRect(0, 0, 13, 3); + Menu_LoadStdFrameGraphics(); + Menu_EraseWindowRect(0, 0, 13, 3); REG_BG0VOFS = 0; DestroyTask(sTaskId); } @@ -100,8 +100,8 @@ void DrawMapNamePopup(void) { u8 name[20]; - MenuLoadTextWindowGraphics_OverrideFrameType(0); + Menu_LoadStdFrameGraphicsOverrideStyle(0); GetMapSectionName(name, gMapHeader.regionMapSectionId, 0); - MenuDrawTextWindow(0, 0, 13, 3); + Menu_DrawStdWindowFrame(0, 0, 13, 3); sub_8072BD8(name, 1, 1, 0x60); } diff --git a/src/field/mauville_man.c b/src/field/mauville_man.c index 4db513f65..0a841eed1 100644 --- a/src/field/mauville_man.c +++ b/src/field/mauville_man.c @@ -345,7 +345,7 @@ void PrepareSongText(void) void ScrSpecial_PlayBardSong(void) { StartBardSong(gSpecialVar_0x8004); - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); ScriptContext1_Stop(); } @@ -858,8 +858,8 @@ static void Task_BardSong(u8 taskId) { case 0: // Initialize song PrepareSongText(); - InitWindowFromConfig(gMenuWindowPtr, &gWindowConfig_81E6CE4); - sub_8002EB0(gMenuWindowPtr, gStringVar4, 2, 4, 15); + Text_InitWindowWithTemplate(gMenuWindowPtr, &gWindowTemplate_81E6CE4); + Text_InitWindow8002EB0(gMenuWindowPtr, gStringVar4, 2, 4, 15); task->data[1] = 0; task->data[2] = 0; task->tCharIndex = 0; @@ -921,7 +921,7 @@ static void Task_BardSong(u8 taskId) } else if (gStringVar4[task->tCharIndex] == CHAR_SPACE) { - sub_8003418(gMenuWindowPtr); + Text_PrintWindowSimple(gMenuWindowPtr); task->tCharIndex++; task->tState = 2; task->data[2] = 0; @@ -941,7 +941,7 @@ static void Task_BardSong(u8 taskId) else if (gStringVar4[task->tCharIndex] == CHAR_SONG_WORD_SEPARATOR) { gStringVar4[task->tCharIndex] = CHAR_SPACE; // restore it back to a space - sub_8003418(gMenuWindowPtr); + Text_PrintWindowSimple(gMenuWindowPtr); task->tCharIndex++; task->data[2] = 0; } @@ -950,7 +950,7 @@ static void Task_BardSong(u8 taskId) switch (task->data[1]) { case 0: - sub_8003418(gMenuWindowPtr); + Text_PrintWindowSimple(gMenuWindowPtr); task->data[1]++; break; case 1: @@ -1219,7 +1219,7 @@ static void PrintStoryList(void) { s32 i; - MenuDrawTextWindow(0, 0, 25, 4 + GetFreeStorySlot() * 2); + Menu_DrawStdWindowFrame(0, 0, 25, 4 + GetFreeStorySlot() * 2); for (i = 0; i < 4; i++) { struct MauvilleManStoryteller *storyteller = &gSaveBlock1.mauvilleMan.storyteller; @@ -1227,9 +1227,9 @@ static void PrintStoryList(void) if (stat == 0) break; - MenuPrint(GetStoryTitleByStat(stat), 1, 2 + i * 2); + Menu_PrintText(GetStoryTitleByStat(stat), 1, 2 + i * 2); } - MenuPrint(gPCText_Cancel, 1, 2 + i * 2); + Menu_PrintText(gPCText_Cancel, 1, 2 + i * 2); } static u8 gUnknown_03000748; @@ -1247,7 +1247,7 @@ static void Task_StoryListMenu(u8 taskId) task->data[0]++; break; case 1: - selection = ProcessMenuInput(); + selection = Menu_ProcessInput(); if (selection == -2) break; if (selection == -1 || selection == GetFreeStorySlot()) @@ -1259,8 +1259,8 @@ static void Task_StoryListMenu(u8 taskId) gSpecialVar_Result = 1; gUnknown_03000748 = selection; } - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 25, 12); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 25, 12); DestroyTask(taskId); EnableBothScriptContexts(); break; diff --git a/src/field/menu_helpers.c b/src/field/menu_helpers.c index e3ef0c790..76f0d367e 100644 --- a/src/field/menu_helpers.c +++ b/src/field/menu_helpers.c @@ -135,7 +135,7 @@ void sub_80F9020(void) // display message box, fill box with tile if tile is not zero, print string static void PrintMessage(const u8 *str, u16 tile) { - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); if (tile) { sub_80A3FA0(&gBGTilemapBuffers[1][0], 2, 15, 26, 4, tile); @@ -145,7 +145,7 @@ static void PrintMessage(const u8 *str, u16 tile) static void sub_80F9090(u8 taskId) { - if (MenuUpdateWindowText() == TRUE) + if (Menu_UpdateWindowText() == TRUE) { gUnknown_0300074C(taskId); } @@ -160,7 +160,7 @@ void DisplayItemMessageOnField(u8 taskId, const u8 *str, TaskFunc callback, u16 static void Task_CallYesOrNoCallback(u8 taskId) { - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: PlaySE(SE_SELECT); @@ -196,7 +196,7 @@ static void PrintStringWithPalette(const u8 *str, u8 paletteNum, u8 left, u8 top StringCopy(gStringVar4, str); } - MenuPrint(gStringVar4, left, top); + Menu_PrintText(gStringVar4, left, top); } // unused @@ -209,7 +209,7 @@ void PrintNumberWithPalette(s32 value, u8 paletteNum, u8 n, u8 mode, u8 left, u8 } else { - MenuPrint(gStringVar1, left, top); + Menu_PrintText(gStringVar1, left, top); } } diff --git a/src/field/money.c b/src/field/money.c index d0f0ab1f6..b85ed8009 100644 --- a/src/field/money.c +++ b/src/field/money.c @@ -143,12 +143,12 @@ void PrintMoneyAmount(u32 amount, u8 size, u8 x, u8 y) if (stringWidth >= (size + 1) * 8) { - MenuPrint(buffer, x, y); + Menu_PrintText(buffer, x, y); } else { int xPlusOne = x + 1; - MenuPrint_PixelCoords(buffer, (xPlusOne + size) * 8 - stringWidth, y * 8, 1); + Menu_PrintTextPixelCoords(buffer, (xPlusOne + size) * 8 - stringWidth, y * 8, 1); } } @@ -275,7 +275,7 @@ void UpdateMoneyWindow(u32 amount, u8 x, u8 y) void OpenMoneyWindow(u32 amount, u8 x, u8 y) { - MenuDrawTextWindow(x, y, x + 13, y + 3); + Menu_DrawStdWindowFrame(x, y, x + 13, y + 3); UpdateMoneyWindow(amount, x, y); LoadCompressedObjectPic(gUnknown_083CF584); @@ -288,7 +288,7 @@ void CloseMoneyWindow(u8 x, u8 y) { DestroySpriteAndFreeResources(&gSprites[gUnknown_02038734]); FreeSpritePaletteByTag(SPRITE_TAG_MONEY); - MenuZeroFillWindowRect(x, y, x + 13, y + 3); + Menu_EraseWindowRect(x, y, x + 13, y + 3); } bool8 HasEnoughMoneyFor(void) diff --git a/src/field/overworld.c b/src/field/overworld.c index e239daec7..86b0a5dac 100644 --- a/src/field/overworld.c +++ b/src/field/overworld.c @@ -47,7 +47,7 @@ #include "tileset_anim.h" #include "time_events.h" #include "tv.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "wild_encounter.h" #ifdef SAPPHIRE @@ -142,7 +142,7 @@ const struct UCoords32 gUnknown_0821664C[] = { 1, -1}, }; -const struct UnknownTaskStruct gUnknown_08216694 = +const struct ScanlineEffectParams gUnknown_08216694 = { (void *)REG_ADDR_WIN0H, ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1, @@ -1410,7 +1410,7 @@ void VBlankCB_Field(void) { LoadOam(); ProcessSpriteCopyRequests(); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); sub_8057A58(); TransferPlttBuffer(); sub_8072E74(); @@ -1422,7 +1422,7 @@ void sub_8054814(void) if (val) { sub_80815E0(val); - sub_80895F8(gUnknown_08216694); + ScanlineEffect_SetParams(gUnknown_08216694); } } @@ -1456,8 +1456,8 @@ bool32 sub_805483C(u8 *a1) case 4: sub_8054814(); sub_8054C54(); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); (*a1)++; break; case 5: @@ -1522,8 +1522,8 @@ bool32 sub_805493C(u8 *a1, u32 a2) case 4: sub_8054814(); sub_8054C54(); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); (*a1)++; break; case 5: @@ -1612,8 +1612,8 @@ bool32 sub_8054A9C(u8 *a1) case 3: sub_8054814(); sub_8054C54(); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); (*a1)++; break; case 4: @@ -1669,7 +1669,7 @@ void sub_8054BA8(void) REG_DISPCNT = 0; - remove_some_task(); + ScanlineEffect_Stop(); DmaClear16(3, PLTT + 2, PLTT_SIZE - 2); @@ -1695,8 +1695,8 @@ void sub_8054C2C(void) { sub_8054814(); sub_8054C54(); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); mapdata_load_assets_to_gpu_and_full_redraw(); } @@ -1731,7 +1731,7 @@ void sub_8054D4C(u32 a1) ResetTasks(); ResetSpriteData(); ResetPaletteFade(); - dp12_8087EA4(); + ScanlineEffect_Clear(); ResetCameraUpdateInfo(); InstallCameraPanAheadCallback(); sub_805C7C4(0); diff --git a/src/field/party_menu.c b/src/field/party_menu.c index 790aede60..7d243f569 100644 --- a/src/field/party_menu.c +++ b/src/field/party_menu.c @@ -32,7 +32,7 @@ #include "string_util.h" #include "strings.h" #include "task.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "util.h" #include "script_pokemon_80F9.h" #include "ewram.h" @@ -648,7 +648,7 @@ bool8 InitPartyMenu(void) gMain.state++; break; case 1: - remove_some_task(); + ScanlineEffect_Stop(); gMain.state++; break; case 2: @@ -679,11 +679,11 @@ bool8 InitPartyMenu(void) gMain.state++; break; case 7: - SetUpWindowConfig(&gWindowConfig_81E6C90); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C90); gMain.state++; break; case 8: - InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6C90); + Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6C90); MultistepInitWindowTileData(&gUnknown_03004210, 1); gMain.state++; break; @@ -716,7 +716,7 @@ bool8 InitPartyMenu(void) } break; case 13: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6CC8); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E6CC8); gMain.state++; break; case 14: @@ -2676,26 +2676,26 @@ void PrintPartyMenuPromptText(u8 textId, u8 b) switch (b) { case 0: - MenuDrawTextWindow(0, 16, 23, 19); + Menu_DrawStdWindowFrame(0, 16, 23, 19); break; case 1: - MenuDrawTextWindow(0, 16, 19, 19); + Menu_DrawStdWindowFrame(0, 16, 19, 19); break; case 2: - MenuDrawTextWindow(0, 16, 22, 19); + Menu_DrawStdWindowFrame(0, 16, 22, 19); break; case 3: - MenuDrawTextWindow(0, 16, 18, 19); + Menu_DrawStdWindowFrame(0, 16, 18, 19); break; } - MenuPrint(PartyMenuPromptTexts[textId], 1, 17); + Menu_PrintText(PartyMenuPromptTexts[textId], 1, 17); } } void sub_806D5A4(void) { - MenuZeroFillWindowRect(0, 16, 29, 19); + Menu_EraseWindowRect(0, 16, 29, 19); } void sub_806D5B8(u8 monIndex) @@ -2706,7 +2706,7 @@ void sub_806D5B8(u8 monIndex) u8 right = gUnknown_08376948[IsDoubleBattle()][monIndex].right; u8 bottom = gUnknown_08376948[IsDoubleBattle()][monIndex].bottom; - ZeroFillWindowRect(&gUnknown_03004210, left, top, right, bottom); + Text_EraseWindowRect(&gUnknown_03004210, left, top, right, bottom); var1 = 0; CpuFastSet(&var1, OBJ_VRAM1 + monIndex * 0x400, 0x1000100); @@ -2720,7 +2720,7 @@ void sub_806D668(u8 monIndex) u8 right = gUnknown_08376978[IsDoubleBattle()][monIndex].right; u8 bottom = gUnknown_08376978[IsDoubleBattle()][monIndex].bottom; - ZeroFillWindowRect(&gUnknown_03004210, left, top, right, bottom); + Text_EraseWindowRect(&gUnknown_03004210, left, top, right, bottom); var1 = 0; CpuFastSet(&var1, OBJ_VRAM1 + 0x300 + monIndex * 0x400, 0x1000040); @@ -3313,7 +3313,7 @@ void PartyMenuDoPrintMonNickname(u8 monIndex, int b, const u8 *nameBuffer) { u32 var1 = 0; CpuFastSet(&var1, gTileBuffer, 0x1000100); - sub_8004E3C((struct WindowConfig *)&gWindowConfig_81E6CAC, gTileBuffer, nameBuffer); + Text_InitWindow8004E3C((struct WindowTemplate *)&gWindowTemplate_81E6CAC, gTileBuffer, nameBuffer); CpuFastSet(gTileBuffer, OBJ_VRAM1 + (monIndex * 0x400), 128); } @@ -3423,7 +3423,7 @@ void PartyMenuDoPrintLevel(u8 monIndex, u8 menuLayout, u8 level) var1 = 0; CpuFastSet(&var1, gUnknown_02039460, 0x1000020); - sub_8004E3C((struct WindowConfig *)&gWindowConfig_81E6CAC, gUnknown_02039460 - 0x100 /*gTileBuffer*/, gStringVar1); + Text_InitWindow8004E3C((struct WindowTemplate *)&gWindowTemplate_81E6CAC, gUnknown_02039460 - 0x100 /*gTileBuffer*/, gStringVar1); CpuFastSet(gUnknown_02039460, OBJ_VRAM1 + 0x200 + (monIndex * 0x400), 32); } @@ -3517,7 +3517,7 @@ void PartyMenuDoPrintHP(u8 monIndex, u8 b, u16 currentHP, u16 maxHP) var = 0; CpuFastSet(&var, gUnknown_02039460, 0x1000040); - sub_8004E3C((struct WindowConfig *)&gWindowConfig_81E6CAC, gUnknown_02039460 - 0x100 /*gTileBuffer*/, gStringVar1); + Text_InitWindow8004E3C((struct WindowTemplate *)&gWindowTemplate_81E6CAC, gUnknown_02039460 - 0x100 /*gTileBuffer*/, gStringVar1); CpuFastSet(gUnknown_02039460, OBJ_VRAM1 + 0x300 + (monIndex * 0x400), 64); } @@ -3667,8 +3667,8 @@ void ClosePartyPopupMenu(u8 index, const struct PartyPopupMenu *menu) SetPartyPopupMenuOffsets(index, &left, &top, menu); - MenuZeroFillWindowRect(left, top, left + menu[index].width, menu[index].numChoices * 2 + top + 1); - HandleDestroyMenuCursors(); + Menu_EraseWindowRect(left, top, left + menu[index].width, menu[index].numChoices * 2 + top + 1); + Menu_DestroyCursor(); } TaskFunc PartyMenuGetPopupMenuFunc(u8 menuIndex, const struct PartyPopupMenu *menus, const struct MenuAction2 *menuActions, u8 itemIndex) @@ -3683,7 +3683,7 @@ u8 sub_806E834(const u8 *message, u8 arg1) gUnknown_0202E8F6 = 1; - MenuDrawTextWindow(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + Menu_DrawStdWindowFrame(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); MenuPrintMessage(message, WINDOW_LEFT + 1, 15); taskId = CreateTask(sub_806E884, 1); @@ -3694,11 +3694,11 @@ u8 sub_806E834(const u8 *message, u8 arg1) static void sub_806E884(u8 taskId) { - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { gUnknown_0202E8F6 = 0; if (gTasks[taskId].data[0] == 0) - MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + Menu_EraseWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); DestroyTask(taskId); } } @@ -3788,13 +3788,13 @@ void party_menu_link_mon_held_item_object(u8 taskId) void PartyMenuTryGiveMonHeldItem_806EACC(u8 taskId) { - s8 selection = ProcessMenuInputNoWrap_(); + s8 selection = Menu_ProcessInputNoWrap_(); if (selection == 0) { u16 currentItem; - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); currentItem = GetMonData(ewram1C000.pokemon, MON_DATA_HELD_ITEM); RemoveBagItem(ewram1C000.unk6, 1); if (AddBagItem(currentItem, 1) == TRUE) @@ -3823,7 +3823,7 @@ void PartyMenuTryGiveMonHeldItem_806EACC(u8 taskId) return; if (selection == -1) PlaySE(SE_SELECT); - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); } gTasks[taskId].func = party_menu_link_mon_held_item_object; } @@ -3925,7 +3925,7 @@ void DoTakeMail(u8 taskId, TaskFunc func) void Task_LoseMailMessage(u8 taskId) { - s8 selection = ProcessMenuInputNoWrap_(); + s8 selection = Menu_ProcessInputNoWrap_(); if (selection == 0) { @@ -3938,7 +3938,7 @@ void Task_LoseMailMessage(u8 taskId) { sub_806E834(gOtherText_BagFullCannotRemoveItem, 0); } - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); gTasks[taskId].func = party_menu_link_mon_held_item_object; } else @@ -3947,8 +3947,8 @@ void Task_LoseMailMessage(u8 taskId) return; if (selection == -1) PlaySE(SE_SELECT); - MenuZeroFillWindowRect(23, 8, 29, 13); - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(0, 14, 29, 19); gTasks[taskId].func = party_menu_link_mon_held_item_object; } } @@ -3964,11 +3964,11 @@ void Task_ConfirmLoseMailMessage(u8 taskId) void Task_TakeHeldMail(u8 taskId) { - s8 selection = ProcessMenuInputNoWrap_(); + s8 selection = Menu_ProcessInputNoWrap_(); if (selection == 0) { - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); if (TakeMailFromMon2(ewram1C000.pokemon) != 0xFF) sub_806E834(gOtherText_MailWasSent, 0); else @@ -3981,7 +3981,7 @@ void Task_TakeHeldMail(u8 taskId) return; if (selection == -1) PlaySE(SE_SELECT); - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); sub_806E834(gOtherText_MailRemovedMessageLost, 1); gTasks[taskId].func = Task_ConfirmLoseMailMessage; } @@ -4126,11 +4126,11 @@ void sub_806F358(u8 taskId) void sub_806F390(u8 taskId) { - s8 selection = ProcessMenuInputNoWrap_(); + s8 selection = Menu_ProcessInputNoWrap_(); if (selection == 0) { - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); sub_806E834(gOtherText_WhichMoveToForget2, 1); gTasks[taskId].func = sub_806F44C; } @@ -4206,7 +4206,7 @@ void StopTryingToTeachMove_806F588(u8 taskId) void StopTryingToTeachMove_806F614(u8 taskId) { - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); StringExpandPlaceholders(gStringVar4, gOtherText_StopTryingTo); sub_806E834(gStringVar4, 1); @@ -4224,11 +4224,11 @@ void StopTryingToTeachMove_806F67C(u8 taskId) void StopTryingToTeachMove_806F6B4(u8 taskId) { - s8 selection = ProcessMenuInputNoWrap_(); + s8 selection = Menu_ProcessInputNoWrap_(); if (selection == 0) { - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); GetMonNickname(ewram1C000.pokemon, gStringVar1); StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); StringExpandPlaceholders(gStringVar4, gOtherText_DidNotLearnMove2); @@ -4241,7 +4241,7 @@ void StopTryingToTeachMove_806F6B4(u8 taskId) return; if (selection == -1) PlaySE(SE_SELECT); - MenuZeroFillWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(23, 8, 29, 13); GetMonNickname(ewram1C000.pokemon, gStringVar1); StringCopy(gStringVar2, gMoveNames[ewram1C000.unk8]); StringExpandPlaceholders(gStringVar4, gOtherText_WantsToLearn); @@ -4592,7 +4592,7 @@ void sub_8070088(u8 taskId) else { gUnknown_0202E8F4 = 1; - MenuZeroFillWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); + Menu_EraseWindowRect(WINDOW_LEFT, 14, WINDOW_RIGHT, 19); PlaySE(SE_KAIFUKU); PartyMenuUpdateLevelOrStatus(ewram1C000.pokemon, ewram1C000.unk5); task_pc_turn_off(&gUnknown_083769A8[IsDoubleBattle() * 12 + ewram1C000.unk5 * 2], 9); @@ -4649,12 +4649,12 @@ void CreateItemUseMoveMenu(u8 partyMonIndex) u8 i; r6 = 0; - MenuDrawTextWindow(19, 10, 29, 19); + Menu_DrawStdWindowFrame(19, 10, 29, 19); for (i = 0; i < 4; i++) { u16 move = GetMonData(&gPlayerParty[partyMonIndex], MON_DATA_MOVE1 + i); - MenuPrint(gMoveNames[move], 20, i * 2 + 11); + Menu_PrintText(gMoveNames[move], 20, i * 2 + 11); if (move != 0) r6++; } @@ -4666,12 +4666,12 @@ void Task_HandleItemUseMoveMenuInput(u8 taskId) if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } else if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); } else if (gMain.newKeys & A_BUTTON) { @@ -4713,17 +4713,17 @@ void DoPPRecoveryItemEffect(u8 taskId, u16 item, TaskFunc c) void ItemUseMoveMenu_HandleMoveSelection(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(19, 10, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(19, 10, 29, 19); sub_806D5A4(); - gTasks[taskId].data[11] = GetMenuCursorPos(); + gTasks[taskId].data[11] = Menu_GetCursorPos(); DoRecoverPP(taskId); } void ItemUseMoveMenu_HandleCancel(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(19, 10, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(19, 10, 29, 19); if (gMain.inBattle) gTasks[ewram1C000.unk4].func = HandleBattlePartyMenu; else @@ -4852,7 +4852,7 @@ void PrintStatGrowthsInLevelUpWindow(u8 taskId) { u8 i; - MenuDrawTextWindow(11, 0, 29, 7); + Menu_DrawStdWindowFrame(11, 0, 29, 7); for (i = 0; i < NUM_STATS; i++) { @@ -4868,12 +4868,12 @@ void PrintStatGrowthsInLevelUpWindow(u8 taskId) x = (i / 3) * 9 + 11; y = ((i % 3) << 1) + 1; - MenuPrint_PixelCoords(StatNames[i], (x + 1) * 8, y * 8, 1); + Menu_PrintTextPixelCoords(StatNames[i], (x + 1) * 8, y * 8, 1); if (i == 2) - MenuPrint_PixelCoords(gOtherText_TallPlusAndRightArrow, (x + 6) * 8 + 6, y * 8, 0); + Menu_PrintTextPixelCoords(gOtherText_TallPlusAndRightArrow, (x + 6) * 8 + 6, y * 8, 0); else - MenuPrint_PixelCoords(gOtherText_TallPlusAndRightArrow, (x + 6) * 8 + 6, y * 8, 1); + Menu_PrintTextPixelCoords(gOtherText_TallPlusAndRightArrow, (x + 6) * 8 + 6, y * 8, 1); gStringVar1[0] = EXT_CTRL_CODE_BEGIN; gStringVar1[1] = 0x14; @@ -4881,7 +4881,7 @@ void PrintStatGrowthsInLevelUpWindow(u8 taskId) ConvertIntToDecimalStringN(gStringVar1 + 3, ewram1B000.statGrowths[i], 1, 2); - MenuPrint_PixelCoords(gStringVar1, (x + 6) * 8 + 12, y * 8, 0); + Menu_PrintTextPixelCoords(gStringVar1, (x + 6) * 8 + 12, y * 8, 0); } } #elif GERMAN @@ -4897,7 +4897,7 @@ void PrintStatGrowthsInLevelUpWindow(u8 taskId) { movs r1, 0\n\ movs r2, 0x1D\n\ movs r3, 0x7\n\ - bl MenuDrawTextWindow\n\ + bl Menu_DrawStdWindowFrame\n\ movs r7, 0\n\ ldr r0, _0807092C @ =gStringVar1\n\ mov r10, r0\n\ @@ -4981,7 +4981,7 @@ _0807086C:\n\ mov r0, r10\n\ adds r1, r4, 0\n\ adds r2, r5, 0\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ adds r0, r7, 0x1\n\ lsls r0, 24\n\ lsrs r7, r0, 24\n\ @@ -5028,7 +5028,7 @@ void PrintNewStatsInLevelUpWindow(u8 taskId) gStringVar1[2] = 0x06; ConvertIntToDecimalStringN(gStringVar1 + 3, ewram1B000.statGrowths[newStatIndex], 1, 3); - MenuPrint_PixelCoords(gStringVar1, (x + 6) * 8 + 6, y * 8, 0); + Menu_PrintTextPixelCoords(gStringVar1, (x + 6) * 8 + 6, y * 8, 0); } } @@ -5070,7 +5070,7 @@ void Task_RareCandy3(u8 taskId) u16 learnedMove; u16 evolutionSpecies; - MenuZeroFillWindowRect(11, 0, 29, 7); + Menu_EraseWindowRect(11, 0, 29, 7); learnedMove = MonTryLearningNewMove(ewram1C000.pokemon, TRUE); ewram1B000.unk282 = 1; diff --git a/src/field/player_pc.c b/src/field/player_pc.c index 928cb9689..0d5c5234b 100644 --- a/src/field/player_pc.c +++ b/src/field/player_pc.c @@ -217,8 +217,8 @@ void PlayerPC(void) static void InitPlayerPCMenu(u8 taskId) { - MenuDrawTextWindow(0, 0, 10, gPcItemMenuOptionsNum * 2 + 1); - PrintMenuItemsReordered(1, 1, gPcItemMenuOptionsNum, sPlayerPCMenuActions, gPcItemMenuOptionOrder); + Menu_DrawStdWindowFrame(0, 0, 10, gPcItemMenuOptionsNum * 2 + 1); + Menu_PrintItemsReordered(1, 1, gPcItemMenuOptionsNum, sPlayerPCMenuActions, gPcItemMenuOptionOrder); InitMenu(0, 1, 1, gPcItemMenuOptionsNum, 0, 9); TASK.FUNC = PlayerPCProcessMenuInput; } @@ -228,22 +228,22 @@ static void PlayerPCProcessMenuInput(u8 taskId) if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); } else if (gMain.newKeys & A_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); - sPlayerPCMenuActions[gPcItemMenuOptionOrder[GetMenuCursorPos()]].func(taskId); + sPlayerPCMenuActions[gPcItemMenuOptionOrder[Menu_GetCursorPos()]].func(taskId); } else if (gMain.newKeys & B_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); sPlayerPCMenuActions[gPcItemMenuOptionsNum[gPcItemMenuOptionOrder - 1]].func(taskId); // run EXIT. } @@ -262,7 +262,7 @@ static void PlayerPC_ItemStorage(u8 taskId) static void PlayerPC_Mailbox(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 10, 9); + Menu_EraseWindowRect(0, 0, 10, 9); eMailboxInfo.count = GetMailboxMailCount(); if (eMailboxInfo.count == 0) @@ -280,7 +280,7 @@ static void PlayerPC_Mailbox(u8 taskId) static void PlayerPC_Decoration(u8 var) { - MenuZeroFillWindowRect(0, 0, 10, 9); + Menu_EraseWindowRect(0, 0, 10, 9); DoPlayerPCDecoration(var); } @@ -288,7 +288,7 @@ static void PlayerPC_TurnOff(u8 taskId) { if (gPcItemMenuOptionsNum == 4) // if the option count is 4, we are at the bedroom PC and not player PC, so do gender specific handling. { - MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); + Menu_EraseWindowRect(0, 0, 0x1D, 0x13); if (gSaveBlock2.playerGender == MALE) ScriptContext1_SetupScript(gBrendanHouse_TurnPCOff); @@ -297,7 +297,7 @@ static void PlayerPC_TurnOff(u8 taskId) } else { - MenuZeroFillWindowRect(0, 0, 10, 9); + Menu_EraseWindowRect(0, 0, 10, 9); EnableBothScriptContexts(); } DestroyTask(taskId); @@ -305,17 +305,17 @@ static void PlayerPC_TurnOff(u8 taskId) static void InitItemStorageMenu(u8 var) { - MenuZeroFillWindowRect(0, 0, 10, 9); - MenuDrawTextWindow(0, 0, 11, 9); - PrintMenuItems(1, 1, 4, (struct MenuAction *)gPCText_ItemPCOptionsText); + Menu_EraseWindowRect(0, 0, 10, 9); + Menu_DrawStdWindowFrame(0, 0, 11, 9); + Menu_PrintItems(1, 1, 4, (struct MenuAction *)gPCText_ItemPCOptionsText); InitMenu(0, 1, 1, 4, var, 10); ItemStorageMenuPrint(gPCText_OptionDescList[var]); } static void ItemStorageMenuPrint(const u8 *textPtr) { - MenuFillWindowRectWithBlankTile(2, 15, 27, 18); - MenuPrint(textPtr, 2, 15); + Menu_BlankWindowRect(2, 15, 27, 18); + Menu_PrintText(textPtr, 2, 15); } static void ItemStorageMenuProcessInput(u8 var) @@ -323,23 +323,23 @@ static void ItemStorageMenuProcessInput(u8 var) if (gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); - ItemStorageMenuPrint(gPCText_OptionDescList[GetMenuCursorPos()]); + Menu_MoveCursor(-1); + ItemStorageMenuPrint(gPCText_OptionDescList[Menu_GetCursorPos()]); } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor(1); - ItemStorageMenuPrint(gPCText_OptionDescList[GetMenuCursorPos()]); + Menu_MoveCursor(1); + ItemStorageMenuPrint(gPCText_OptionDescList[Menu_GetCursorPos()]); } else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - gPCText_ItemPCOptionsText[GetMenuCursorPos()].func(var); + gPCText_ItemPCOptionsText[Menu_GetCursorPos()].func(var); } else if (gMain.newKeys & B_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); gPCText_ItemPCOptionsText[ITEMPC_MENU_EXIT].func(var); } @@ -368,7 +368,7 @@ static void ItemStorage_HandleReturnToProcessInput(u8 taskId) void ItemStorage_ReturnToMenuAfterDeposit(void) { - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); InitItemStorageMenu(ITEMPC_MENU_DEPOSIT); CreateTask(ItemStorage_HandleReturnToProcessInput, 0); pal_fill_black(); @@ -378,13 +378,13 @@ static void ItemStorage_Withdraw(u8 taskId) { s16 *data = TASK.data; - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 11, 9); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 11, 9); NUM_ITEMS = CountUsedPCItemSlots(); if (NUM_ITEMS != 0) { - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); CURRENT_ITEM_STORAGE_MENU = ITEMPC_MENU_WITHDRAW; PAGE_INDEX = 0; ITEMS_ABOVE_TOP = 0; @@ -400,13 +400,13 @@ static void ItemStorage_Toss(u8 taskId) { s16 *data = TASK.data; - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 11, 9); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 11, 9); NUM_ITEMS = CountUsedPCItemSlots(); if (NUM_ITEMS) { - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); CURRENT_ITEM_STORAGE_MENU = ITEMPC_MENU_TOSS; PAGE_INDEX = 0; ITEMS_ABOVE_TOP = 0; @@ -420,8 +420,8 @@ static void ItemStorage_Toss(u8 taskId) static void ItemStorage_Exit(u8 var) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 11, 9); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 11, 9); ReshowPlayerPC(var); } @@ -450,7 +450,7 @@ static void ItemStorage_ProcessInput(u8 taskId) if(PAGE_INDEX != 0) // did the cursor move physically upwards? { PlaySE(SE_SELECT); - PAGE_INDEX = MoveMenuCursor(-1); + PAGE_INDEX = Menu_MoveCursor(-1); trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; if (SWITCH_MODE_ACTIVE == FALSE) // are we not currently switching items? { @@ -474,7 +474,7 @@ static void ItemStorage_ProcessInput(u8 taskId) ItemStorage_DrawBothListAndDescription(taskId); if (SWITCH_MODE_ACTIVE != FALSE) - MoveMenuCursor(0); // don't move the cursor. it's at the top of the page index, but not the true index. + Menu_MoveCursor(0); // don't move the cursor. it's at the top of the page index, but not the true index. } } else if(gMain.newAndRepeatedKeys & DPAD_DOWN) // _0813A306 @@ -482,7 +482,7 @@ static void ItemStorage_ProcessInput(u8 taskId) if(PAGE_INDEX != NUM_PAGE_ITEMS - 1) { PlaySE(SE_SELECT); - PAGE_INDEX = MoveMenuCursor(1); + PAGE_INDEX = Menu_MoveCursor(1); trueIndex = ITEMS_ABOVE_TOP + PAGE_INDEX; if(SWITCH_MODE_ACTIVE != FALSE) @@ -500,7 +500,7 @@ static void ItemStorage_ProcessInput(u8 taskId) ItemStorage_DrawBothListAndDescription(taskId); if (SWITCH_MODE_ACTIVE != FALSE) - MoveMenuCursor(0); + Menu_MoveCursor(0); } } else if(gMain.newKeys & SELECT_BUTTON) // _0813A3A0 @@ -549,7 +549,7 @@ static void ItemStorage_ProcessInput(u8 taskId) PlaySE(SE_SELECT); if(SWITCH_MODE_ACTIVE == FALSE) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); ItemStorage_GoBackToPlayerPCMenu(taskId); } else @@ -565,8 +565,8 @@ static void ItemStorage_GoBackToPlayerPCMenu(u8 taskId) BuyMenuFreeMemory(); DestroyVerticalScrollIndicator(0); DestroyVerticalScrollIndicator(1); - MenuZeroFillWindowRect(0, 0, 29, 19); - MenuDisplayMessageBox(); + Menu_EraseWindowRect(0, 0, 29, 19); + Menu_DisplayDialogueFrame(); InitItemStorageMenu(TASK.CURRENT_ITEM_STORAGE_MENU); TASK.FUNC = ItemStorageMenuProcessInput; } @@ -603,7 +603,7 @@ static void ItemStorage_DoItemAction(u8 taskId) ItemStorage_PrintItemPcResponse(ITEMPC_HOW_MANY_TO_TOSS); } NUM_QUANTITY_ROLLER = 1; - MenuDrawTextWindow(6, 8, 13, 11); + Menu_DrawStdWindowFrame(6, 8, 13, 11); sub_80A418C(NUM_QUANTITY_ROLLER, STR_CONV_MODE_RIGHT_ALIGN, 8, 9, 3); TASK.FUNC = ItemStorage_HandleQuantityRolling; } @@ -652,7 +652,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) else if(gMain.newKeys & A_BUTTON) // confirm quantity. { PlaySE(SE_SELECT); - MenuZeroFillWindowRect(6, 6, 0xD, 0xB); + Menu_EraseWindowRect(6, 6, 0xD, 0xB); if(CURRENT_ITEM_STORAGE_MENU == ITEMPC_MENU_WITHDRAW) ItemStorage_DoItemWithdraw(taskId); @@ -662,7 +662,7 @@ static void ItemStorage_HandleQuantityRolling(u8 taskId) else if(gMain.newKeys & B_BUTTON) // cancel quantity. { PlaySE(SE_SELECT); - MenuZeroFillWindowRect(6, 6, 0xD, 0xB); + Menu_EraseWindowRect(6, 6, 0xD, 0xB); StartVerticalScrollIndicators(0); StartVerticalScrollIndicators(1); ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[ITEMS_ABOVE_TOP + PAGE_INDEX].itemId); // why not use trueIndex? @@ -713,7 +713,7 @@ static void ItemStorage_DoItemToss(u8 taskId) static void ItemStorage_ResumeInputFromYesToss(u8 taskId) { - MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); + Menu_EraseWindowRect(0x6, 0x6, 0xD, 0xB); ItemStorage_PrintItemPcResponse(ITEMPC_THREW_AWAY_ITEM); TASK.FUNC = ItemStorage_HandleRemoveItem; } @@ -722,7 +722,7 @@ static void ItemStorage_ResumeInputFromNoToss(u8 taskId) { s16 *data = TASK.data; - MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); + Menu_EraseWindowRect(0x6, 0x6, 0xD, 0xB); InitMenu(0, 16, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); StartVerticalScrollIndicators(0); StartVerticalScrollIndicators(1); @@ -765,7 +765,7 @@ static void ItemStorage_WaitPressHandleResumeProcessInput(u8 taskId) static void ItemStorage_HandleResumeProcessInput(u8 taskId) { - MenuZeroFillWindowRect(0x6, 0x6, 0xD, 0xB); + Menu_EraseWindowRect(0x6, 0x6, 0xD, 0xB); StartVerticalScrollIndicators(0); StartVerticalScrollIndicators(1); ItemStorage_DrawBothListAndDescription(taskId); @@ -817,14 +817,14 @@ static void ItemStorage_DrawItemQuantity(u16 arg1, enum StringConvertMode arg2, sub_80A4164(gStringVar1, arg1, arg2, arg4); if(isSwapSelected != FALSE) - MenuPrint(gSelectedItemQuantityFormatText, 0x1A, arg3); + Menu_PrintText(gSelectedItemQuantityFormatText, 0x1A, arg3); else - MenuPrint(gNonSelectedItemQuantityFormatText, 0x1A, arg3); + Menu_PrintText(gNonSelectedItemQuantityFormatText, 0x1A, arg3); } static void ItemStorage_DrawItemVoidQuantity(u8 var) { - MenuPrint(gUnknown_08406330, 0x19, var); + Menu_PrintText(gUnknown_08406330, 0x19, var); } static void ItemStorage_DrawItemName(struct ItemSlot *itemSlot, u8 var, int isSwapSelected) @@ -832,9 +832,9 @@ static void ItemStorage_DrawItemName(struct ItemSlot *itemSlot, u8 var, int isSw CopyItemName(itemSlot->itemId, gStringVar1); if(isSwapSelected != FALSE) - MenuPrint(gSelectedItemFormattedText, 16, var); + Menu_PrintText(gSelectedItemFormattedText, 16, var); else - MenuPrint(gNonSelectedItemFormattedText, 16, var); + Menu_PrintText(gNonSelectedItemFormattedText, 16, var); } static void ItemStorage_DrawNormalItemEntry(struct ItemSlot *itemSlot, u8 var, int var2) @@ -900,7 +900,7 @@ static void ItemStorage_DrawItemList(u8 taskId) } if (i - ITEMS_ABOVE_TOP < 8) - MenuFillWindowRectWithBlankTile(16, yCoord + 4, 0x1C, 0x12); + Menu_BlankWindowRect(16, yCoord + 4, 0x1C, 0x12); if (ITEMS_ABOVE_TOP != 0) CreateVerticalScrollIndicators(0, 0xB8, 8); @@ -977,11 +977,11 @@ static void ItemStorage_GoBackToItemPCMenu(u8 taskId, u8 var) sub_80F944C(); LoadScrollIndicatorPalette(); ItemStorage_LoadPalette(); - MenuDrawTextWindow(0xF, 0, 0x1D, 0x13); - MenuDrawTextWindow(0, 0xC, 0xE, 0x13); - MenuDrawTextWindow(0, 0, 0xB, 3); + Menu_DrawStdWindowFrame(0xF, 0, 0x1D, 0x13); + Menu_DrawStdWindowFrame(0, 0xC, 0xE, 0x13); + Menu_DrawStdWindowFrame(0, 0, 0xB, 3); ItemStorage_PrintItemPcResponse(gSaveBlock1.pcItems[0].itemId); - MenuPrint(gPCText_ItemPCOptionsText[var].text, 1, 1); + Menu_PrintText(gPCText_ItemPCOptionsText[var].text, 1, 1); ItemStorage_DrawItemList(taskId); InitMenu(0, 0x10, 2, NUM_PAGE_ITEMS, PAGE_INDEX, 0xD); } @@ -1037,22 +1037,22 @@ static void Mailbox_DrawMailList(u8 taskId) // taskId is unused for (i = eMailboxInfo.itemsAbove; i < eMailboxInfo.itemsAbove + eMailboxInfo.pageItems; i++) { yCoord = (i - eMailboxInfo.itemsAbove) * 2; - MenuFillWindowRectWithBlankTile(0x15, yCoord + 2, 0x1C, yCoord + 3); + Menu_BlankWindowRect(0x15, yCoord + 2, 0x1C, yCoord + 3); if (i == eMailboxInfo.count) { - MenuPrint(gOtherText_CancelNoTerminator, 0x15, yCoord + 2); + Menu_PrintText(gOtherText_CancelNoTerminator, 0x15, yCoord + 2); break; } else { StringCopy(gStringVar1, gSaveBlock1.mail[i + 6].playerName); SanitizeNameString(gStringVar1); - MenuPrint(gStringVar1, 0x15, yCoord + 2); + Menu_PrintText(gStringVar1, 0x15, yCoord + 2); } } if (i - eMailboxInfo.itemsAbove != 8) - MenuFillWindowRectWithBlankTile(0x15, yCoord + 4, 0x1C, 0x12); + Menu_BlankWindowRect(0x15, yCoord + 4, 0x1C, 0x12); if (eMailboxInfo.itemsAbove != 0) CreateVerticalScrollIndicators(0, 0xC8, 8); @@ -1069,10 +1069,10 @@ static void Mailbox_DrawMailboxMenu(u8 taskId) { sub_80F944C(); LoadScrollIndicatorPalette(); - MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); - MenuDrawTextWindow(0, 0, 0x8, 0x3); - MenuPrint(gPCText_Mailbox, 1, 1); - MenuDrawTextWindow(0x14, 0, 0x1D, 0x13); + Menu_EraseWindowRect(0, 0, 0x1D, 0x13); + Menu_DrawStdWindowFrame(0, 0, 0x8, 0x3); + Menu_PrintText(gPCText_Mailbox, 1, 1); + Menu_DrawStdWindowFrame(0x14, 0, 0x1D, 0x13); Mailbox_DrawMailList(taskId); InitMenu(0, 0x15, 2, eMailboxInfo.pageItems, eMailboxInfo.cursorPos, 8); } @@ -1087,7 +1087,7 @@ static void Mailbox_ProcessInput(u8 taskId) if(eMailboxInfo.cursorPos != 0) { PlaySE(SE_SELECT); - eMailboxInfo.cursorPos = MoveMenuCursor(-1); + eMailboxInfo.cursorPos = Menu_MoveCursor(-1); } else if(eMailboxInfo.itemsAbove != 0) { @@ -1101,7 +1101,7 @@ static void Mailbox_ProcessInput(u8 taskId) if(eMailboxInfo.cursorPos != eMailboxInfo.pageItems - 1) { PlaySE(SE_SELECT); - eMailboxInfo.cursorPos = MoveMenuCursor(1); + eMailboxInfo.cursorPos = Menu_MoveCursor(1); } else if(eMailboxInfo.itemsAbove + eMailboxInfo.cursorPos != eMailboxInfo.count) { @@ -1112,7 +1112,7 @@ static void Mailbox_ProcessInput(u8 taskId) } else if(gMain.newKeys & A_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); if(eMailboxInfo.itemsAbove + eMailboxInfo.cursorPos == eMailboxInfo.count) @@ -1127,7 +1127,7 @@ static void Mailbox_ProcessInput(u8 taskId) } else if(gMain.newKeys & B_BUTTON) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); Mailbox_TurnOff(taskId); } @@ -1143,7 +1143,7 @@ static void Mailbox_CloseScrollIndicators(void) static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); + Menu_EraseWindowRect(0, 0, 0x1D, 0x13); StringCopy(gStringVar1, gSaveBlock1.mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos].playerName); SanitizeNameString(gStringVar1); StringExpandPlaceholders(gStringVar4, gOtherText_WhatWillYouDoMail); @@ -1152,7 +1152,7 @@ static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) static void Mailbox_ReturnToPlayerPC(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 0x1D, 0x13); + Menu_EraseWindowRect(0, 0, 0x1D, 0x13); ReshowPlayerPC(taskId); } @@ -1164,8 +1164,8 @@ static void Mailbox_TurnOff(u8 taskId) static void Mailbox_PrintMailOptions(u8 taskId) // Mailbox_PrintMailOptions { - MenuDrawTextWindow(0, 0, 0xC, 0x9); - PrintMenuItems(1, 1, 4, (struct MenuAction *)gMailboxMailOptions); + Menu_DrawStdWindowFrame(0, 0, 0xC, 0x9); + Menu_PrintItems(1, 1, 4, (struct MenuAction *)gMailboxMailOptions); InitMenu(0, 1, 1, 4, 0, 0xB); TASK.FUNC = Mailbox_MailOptionsProcessInput; } @@ -1175,17 +1175,17 @@ static void Mailbox_MailOptionsProcessInput(u8 taskId) if(gMain.newAndRepeatedKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } else if(gMain.newAndRepeatedKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); } else if(gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - gMailboxMailOptions[GetMenuCursorPos()].func(taskId); + gMailboxMailOptions[Menu_GetCursorPos()].func(taskId); } else if(gMain.newKeys & B_BUTTON) { @@ -1231,9 +1231,9 @@ static const u8 gHighlightedMoveToBagFormatText[] = _("{COLOR RED}{STR_VAR_1}"); static void Mailbox_MoveToBag(u8 taskId) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); StringCopy(gStringVar1, gOtherText_MoveToBag); - MenuPrint(gHighlightedMoveToBagFormatText, 1, 3); // gHighlightedMoveToBagFormatText + Menu_PrintText(gHighlightedMoveToBagFormatText, 1, 3); // gHighlightedMoveToBagFormatText DisplayItemMessageOnField(taskId, gOtherText_MessageWillBeLost, Mailbox_DrawYesNoBeforeMove, 0); } @@ -1247,7 +1247,7 @@ static void Mailbox_DoMailMoveToBag(u8 taskId) { struct MailStruct *mail = &gSaveBlock1.mail[eMailboxInfo.itemsAbove + 6 + eMailboxInfo.cursorPos]; - MenuZeroFillWindowRect(0x14, 8, 0x1A, 0xD); + Menu_EraseWindowRect(0x14, 8, 0x1A, 0xD); if(AddBagItem(mail->itemId, 1) == FALSE) { @@ -1270,7 +1270,7 @@ static void Mailbox_DoMailMoveToBag(u8 taskId) static void Mailbox_ReturnToInputAfterNo(u8 taskId) // Mailbox_ReturnToInputAfterNo { - MenuZeroFillWindowRect(0x14, 0x8, 0x1A, 0xD); + Menu_EraseWindowRect(0x14, 0x8, 0x1A, 0xD); Mailbox_DrawMailMenuAndDoProcessInput(taskId); } @@ -1325,8 +1325,8 @@ static void Mailbox_NoPokemonForMail(u8 taskId) static void Mailbox_Cancel(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 0xC, 0x9); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 0xC, 0x9); Mailbox_DrawMailMenuAndDoProcessInput(taskId); } diff --git a/src/field/pokeblock.c b/src/field/pokeblock.c index 640d4731f..7e8bdc2ce 100644 --- a/src/field/pokeblock.c +++ b/src/field/pokeblock.c @@ -8,7 +8,7 @@ #include "script.h" #include "strings.h" #include "task.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "text.h" #include "main.h" #include "menu.h" @@ -255,7 +255,7 @@ static bool8 sub_810B6C0(void) gMain.state++; break; case 1: - remove_some_task(); + ScanlineEffect_Stop(); gMain.state++; break; case 2: @@ -275,15 +275,15 @@ static bool8 sub_810B6C0(void) gMain.state++; break; case 5: - SetUpWindowConfig(&gWindowConfig_81E6E34); + Text_LoadWindowTemplate(&gWindowTemplate_81E6E34); gMain.state++; break; case 6: - SetUpWindowConfig(&gWindowConfig_81E6E50); + Text_LoadWindowTemplate(&gWindowTemplate_81E6E50); gMain.state++; break; case 7: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6E34); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E6E34); gMain.state++; break; case 8: @@ -293,7 +293,7 @@ static bool8 sub_810B6C0(void) } break; case 9: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6E50); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E6E50); gMain.state++; break; case 10: @@ -445,18 +445,18 @@ void debug_sub_8120F98(void) static void sub_810BB0C(void) { - BasicInitMenuWindow(&gWindowConfig_81E6E34); + BasicInitMenuWindow(&gWindowTemplate_81E6E34); sub_8072BD8(ItemId_GetItem(ITEM_POKEBLOCK_CASE)->name, 2, 1, 0x48); } static void sub_810BB30(void) { - BasicInitMenuWindow(&gWindowConfig_81E6E34); - MenuPrint(gContestStatsText_Spicy, 2, 13); - MenuPrint(gContestStatsText_Dry, 2, 15); - MenuPrint(gContestStatsText_Sweet, 2, 17); - MenuPrint(gContestStatsText_Bitter, 8, 13); - MenuPrint(gContestStatsText_Sour, 8, 15); + BasicInitMenuWindow(&gWindowTemplate_81E6E34); + Menu_PrintText(gContestStatsText_Spicy, 2, 13); + Menu_PrintText(gContestStatsText_Dry, 2, 15); + Menu_PrintText(gContestStatsText_Sweet, 2, 17); + Menu_PrintText(gContestStatsText_Bitter, 8, 13); + Menu_PrintText(gContestStatsText_Sour, 8, 15); } static void sub_810BB88(u8 a0) @@ -464,17 +464,17 @@ static void sub_810BB88(u8 a0) u8 i; u8 y; u8 *buf; - BasicInitMenuWindow(&gWindowConfig_81E6E34); + BasicInitMenuWindow(&gWindowTemplate_81E6E34); for (i=a0; i<=a0+8; i++) { y = (i - a0) << 1; if (i == gUnknown_02039248.unk2) { buf = sub_8072C74(gStringVar1, gContestStatsText_StowCase, 0x78, 0); - MenuPrint(gStringVar1, 15, y + 1); + Menu_PrintText(gStringVar1, 15, y + 1); if (i != a0 + 8) { - MenuZeroFillWindowRect(15, y + 3, 29, 18); + Menu_EraseWindowRect(15, y + 3, 29, 18); } break; } @@ -484,7 +484,7 @@ static void sub_810BB88(u8 a0) buf[2] = 0x06; buf += 3; ConvertIntToDecimalStringN(buf, sub_810C9B0(&gSaveBlock1.pokeblocks[i]), STR_CONV_MODE_RIGHT_ALIGN, 3); - MenuPrint(gStringVar1, 15, y + 1); + Menu_PrintText(gStringVar1, 15, y + 1); } } @@ -596,15 +596,15 @@ static void sub_810BDAC(bool8 flag) gBGTilemapBuffers[2][v0 + 32] = 15; } } - BasicInitMenuWindow(&gWindowConfig_81E6E34); + BasicInitMenuWindow(&gWindowTemplate_81E6E34); if (gUnknown_02039248.unk0 + gUnknown_02039248.unk1 != gUnknown_02039248.unk2) { sub_8072C14(gStringVar1, sub_810C9E8(&gSaveBlock1.pokeblocks[gUnknown_02039248.unk0 + gUnknown_02039248.unk1]), 16, 1); - MenuPrint(gStringVar1, 11, 17); + Menu_PrintText(gStringVar1, 11, 17); } else { - MenuZeroFillWindowRect(11, 17, 12, 18); + Menu_EraseWindowRect(11, 17, 12, 18); } } @@ -812,9 +812,9 @@ static void sub_810C368(u8 taskId) v0 = 2; sub_80F98A4(0); sub_80F98A4(1); - BasicInitMenuWindow(&gWindowConfig_81E6E50); - MenuDrawTextWindow(7, v0 + 4, 13, 11); - PrintMenuItemsReordered(8, v0 + 5, gUnknown_0203924C, gUnknown_083F7EF4, gUnknown_03000758); + BasicInitMenuWindow(&gWindowTemplate_81E6E50); + Menu_DrawStdWindowFrame(7, v0 + 4, 13, 11); + Menu_PrintItemsReordered(8, v0 + 5, gUnknown_0203924C, gUnknown_083F7EF4, gUnknown_03000758); InitMenu(0, 8, v0 + 5, gUnknown_0203924C, 0, 5); gSpecialVar_ItemId = gUnknown_02039248.unk0 + gUnknown_02039248.unk1; gTasks[taskId].func = sub_810C40C; @@ -824,24 +824,24 @@ static void sub_810C40C(u8 taskId) { if (gMain.newAndRepeatedKeys & DPAD_UP) { - if (GetMenuCursorPos()) + if (Menu_GetCursorPos()) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - if (GetMenuCursorPos() != gUnknown_0203924C - 1) + if (Menu_GetCursorPos() != gUnknown_0203924C - 1) { PlaySE(SE_SELECT); - MoveMenuCursor(+1); + Menu_MoveCursor(+1); } } else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - gUnknown_083F7EF4[gUnknown_03000758[GetMenuCursorPos()]].func(taskId); + gUnknown_083F7EF4[gUnknown_03000758[Menu_GetCursorPos()]].func(taskId); } else if (gMain.newKeys & B_BUTTON) { @@ -868,9 +868,9 @@ static void sub_810C508(u8 taskId) static void sub_810C540(u8 taskId) { - BasicInitMenuWindow(&gWindowConfig_81E6E50); - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(7, 4, 13, 11); + BasicInitMenuWindow(&gWindowTemplate_81E6E50); + Menu_DestroyCursor(); + Menu_EraseWindowRect(7, 4, 13, 11); StringCopy(gStringVar1, gPokeblockNames[gSaveBlock1.pokeblocks[gUnknown_02039248.unk0 + gUnknown_02039248.unk1].color]); StringExpandPlaceholders(gStringVar4, gContestStatsText_ThrowAwayPrompt); DisplayItemMessageOnField(taskId, gStringVar4, sub_810C5EC, 0); @@ -890,7 +890,7 @@ static void sub_810C5EC(u8 taskId) static void sub_810C610(u8 taskId) { - MenuZeroFillWindowRect(7, 6, 13, 11); + Menu_EraseWindowRect(7, 6, 13, 11); PokeblockClearIfExists((gUnknown_02039248.unk0 + gUnknown_02039248.unk1)); StringExpandPlaceholders(gStringVar4, gContestStatsText_WasThrownAway); DisplayItemMessageOnField(taskId, gStringVar4, sub_810C704, 0); @@ -906,9 +906,9 @@ static void sub_810C668(u8 taskId) { sub_80F979C(1, 0); } - BasicInitMenuWindow(&gWindowConfig_81E6E50); - MenuZeroFillWindowRect(7, 6, 13, 11); - MenuZeroFillWindowRect(0, 14, 29, 19); + BasicInitMenuWindow(&gWindowTemplate_81E6E50); + Menu_EraseWindowRect(7, 6, 13, 11); + Menu_EraseWindowRect(0, 14, 29, 19); gTasks[taskId].func = sub_810BF7C; } @@ -922,7 +922,7 @@ static void sub_810C6DC(u8 taskId) static void sub_810C704(u8 taskId) { - BasicInitMenuWindow(&gWindowConfig_81E6E34); + BasicInitMenuWindow(&gWindowTemplate_81E6E34); sub_810BC84(gUnknown_02039248.unk1); sub_80F979C(1, 1); gTasks[taskId].func = sub_810C6DC; @@ -932,8 +932,8 @@ static void sub_810C748(u8 taskId) { StartVerticalScrollIndicators(0); StartVerticalScrollIndicators(1); - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(7, 4, 13, 11); + Menu_DestroyCursor(); + Menu_EraseWindowRect(7, 4, 13, 11); gTasks[taskId].func = sub_810BF7C; } diff --git a/src/field/region_map.c b/src/field/region_map.c index 07e77e389..a098eb73d 100644 --- a/src/field/region_map.c +++ b/src/field/region_map.c @@ -1540,11 +1540,11 @@ void CB2_InitFlyRegionMap(void) FreeAllSpritePalettes(); break; case 1: - SetUpWindowConfig(&gWindowConfig_81E7224); + Text_LoadWindowTemplate(&gWindowTemplate_81E7224); break; case 2: - InitMenuWindow(&gWindowConfig_81E7224); - MenuZeroFillScreen(); + InitMenuWindow(&gWindowTemplate_81E7224); + Menu_EraseScreen(); break; case 3: InitRegionMap(&ewram0_3.regionMap, 0); @@ -1562,7 +1562,7 @@ void CB2_InitFlyRegionMap(void) break; case 6: LoadPalette(sFlyRegionMapFrame_Pal, 16, 32); - MenuPrint_PixelCoords(gOtherText_FlyToWhere, 1, 0x90, 1); + Menu_PrintTextPixelCoords(gOtherText_FlyToWhere, 1, 0x90, 1); break; case 7: CreateFlyTargetGraphics(); @@ -1619,8 +1619,8 @@ static void PrintFlyTargetName(void) { if (FlagGet(r4->flag)) { - MenuDrawTextWindow(16, 14, 29, 19); - MenuPrint(ewram0_3.regionMap.mapSectionName, 17, 15); + Menu_DrawStdWindowFrame(16, 14, 29, 19); + Menu_PrintText(ewram0_3.regionMap.mapSectionName, 17, 15); MenuPrint_RightAligned(r4->unk0[ewram0_3.regionMap.everGrandeCityArea], 29, 17); return; } @@ -1631,16 +1631,16 @@ static void PrintFlyTargetName(void) asm("mov %0, #0\n":"=r"(zero)); // zero = 0 if (zero == 0) { - MenuDrawTextWindow(16, 16, 29, 19); - MenuPrint(ewram0_3.regionMap.mapSectionName, 17, 17); - MenuZeroFillWindowRect(16, 14, 29, 15); + Menu_DrawStdWindowFrame(16, 16, 29, 19); + Menu_PrintText(ewram0_3.regionMap.mapSectionName, 17, 17); + Menu_EraseWindowRect(16, 14, 29, 15); } } else { - MenuDrawTextWindow(16, 16, 29, 19); - MenuPrint(ewramBlankMapName, 17, 17); - MenuZeroFillWindowRect(16, 14, 29, 15); + Menu_DrawStdWindowFrame(16, 16, 29, 19); + Menu_PrintText(ewramBlankMapName, 17, 17); + Menu_EraseWindowRect(16, 14, 29, 15); } } diff --git a/src/field/scrcmd.c b/src/field/scrcmd.c index 05a909e81..e795fd8ed 100644 --- a/src/field/scrcmd.c +++ b/src/field/scrcmd.c @@ -1333,7 +1333,7 @@ bool8 ScrCmd_drawbox(struct ScriptContext *ctx) u8 right = ScriptReadByte(ctx); u8 bottom = ScriptReadByte(ctx); - MenuDrawTextWindow(left, top, right, bottom); + Menu_DrawStdWindowFrame(left, top, right, bottom); return FALSE; } @@ -1363,7 +1363,7 @@ bool8 ScrCmd_erasebox(struct ScriptContext *ctx) u8 right = ScriptReadByte(ctx); u8 bottom = ScriptReadByte(ctx); - MenuZeroFillWindowRect(left, top, right, bottom); + Menu_EraseWindowRect(left, top, right, bottom); return FALSE; } @@ -1428,8 +1428,8 @@ bool8 ScrCmd_braillemessage(struct ScriptContext *ctx) u8 v6 = ptr[4]; u8 v7 = ptr[5]; StringBraille(gStringVar4, ptr + 6); - MenuDrawTextWindow(v2, v3, v4, v5); - MenuPrint(gStringVar4, v6, v7); + Menu_DrawStdWindowFrame(v2, v3, v4, v5); + Menu_PrintText(gStringVar4, v6, v7); return FALSE; } diff --git a/src/field/script_menu.c b/src/field/script_menu.c index 9f3ab75cc..9d901a03c 100644 --- a/src/field/script_menu.c +++ b/src/field/script_menu.c @@ -622,7 +622,7 @@ bool8 ScriptMenu_MultichoiceWithDefault(u8 left, u8 top, u8 multichoiceId, u8 ig static u16 GetStringWidthInTilesForScriptMenu(const u8 *str) { // each tile on screen is 8x8, so it needs the number of tiles and not pixels, hence the division by 8. - return (GetStringWidthGivenWindowConfig((struct WindowConfig *)&gWindowConfig_81E6CE4, str) + 7) / 8; + return (Text_GetStringWidthFromWindowTemplate((struct WindowTemplate *)&gWindowTemplate_81E6CE4, str) + 7) / 8; } static void DrawMultichoiceMenu(u8 left, u8 top, u8 count, const struct MenuAction *list, u8 ignoreBPress, u8 cursorPos) @@ -651,8 +651,8 @@ static void DrawMultichoiceMenu(u8 left, u8 top, u8 count, const struct MenuActi bottom = top + (2 * count + 1); - MenuDrawTextWindow(left, top, right, bottom); - PrintMenuItems(left + 1, top + 1, count, list); + Menu_DrawStdWindowFrame(left, top, right, bottom); + Menu_PrintItems(left + 1, top + 1, count, list); InitMenu(0, left + 1, top + 1, count, cursorPos, right - left - 1); StartScriptMenuTask(left, top, right, bottom, ignoreBPress, count); } @@ -687,9 +687,9 @@ static void Task_HandleMultichoiceInput(u8 taskId) if (!gPaletteFade.active) { if (!gTasks[taskId].tDoWrap) - selection = ProcessMenuInputNoWrap(); + selection = Menu_ProcessInputNoWrap(); else - selection = ProcessMenuInput(); + selection = Menu_ProcessInput(); if (selection != -2) { @@ -704,8 +704,8 @@ static void Task_HandleMultichoiceInput(u8 taskId) { gSpecialVar_Result = selection; } - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(gTasks[taskId].tLeft, gTasks[taskId].tTop, gTasks[taskId].tRight, gTasks[taskId].tBottom); + Menu_DestroyCursor(); + Menu_EraseWindowRect(gTasks[taskId].tLeft, gTasks[taskId].tTop, gTasks[taskId].tRight, gTasks[taskId].tBottom); DestroyTask(taskId); EnableBothScriptContexts(); } @@ -745,7 +745,7 @@ static void sub_80B53B4(u8 left, u8 top, u8 count, const struct MenuAction *list right = (right + left) + 2; bottom = top + (2 * count + 1); - PrintMenuItems(left, top, count, list); + Menu_PrintItems(left, top, count, list); InitMenu(0, left, top, count, 0, right - left - 1); StartScriptMenuTask(left, top, right, bottom, ignoreBPress, count); } @@ -788,7 +788,7 @@ static void Task_HandleYesNoInput(u8 taskId) return; } - switch (ProcessMenuInputNoWrap()) + switch (Menu_ProcessInputNoWrap()) { case -2: return; @@ -805,7 +805,7 @@ static void Task_HandleYesNoInput(u8 taskId) left = gTasks[taskId].tLeft; top = gTasks[taskId].tTop; - MenuZeroFillWindowRect(left, top, left + 6, top + 5); + Menu_EraseWindowRect(left, top, left + 6, top + 5); DestroyTask(taskId); EnableBothScriptContexts(); } @@ -839,7 +839,7 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPr bottom = (2 * (gMultichoiceLists[multichoiceId].count / columnCount)) + 3 + top; } - width = sub_807288C(columnCount); + width = Menu_GetColumnXCoord(columnCount); gTasks[taskId].tLeft = left; gTasks[taskId].tTop = top; gTasks[taskId].tRight = width + left + 2; @@ -851,7 +851,7 @@ bool8 ScriptMenu_MultichoiceGrid(u8 left, u8 top, u8 multichoiceId, u8 ignoreBPr static void Task_HandleMultichoiceGridInput(u8 taskId) { - s8 selection = sub_80727CC(); + s8 selection = Menu_ProcessInputGridLayout(); if (selection != -2) { @@ -866,8 +866,8 @@ static void Task_HandleMultichoiceGridInput(u8 taskId) { gSpecialVar_Result = selection; } - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(gTasks[taskId].tLeft, gTasks[taskId].tTop, gTasks[taskId].tRight, gTasks[taskId].tBottom); + Menu_DestroyCursor(); + Menu_EraseWindowRect(gTasks[taskId].tLeft, gTasks[taskId].tTop, gTasks[taskId].tRight, gTasks[taskId].tBottom); DestroyTask(taskId); EnableBothScriptContexts(); } @@ -909,23 +909,23 @@ void ScriptMenu_CreatePCMenu(void) if (FlagGet(FLAG_SYS_GAME_CLEAR)) // player has cleared game? { numChoices = 4; - MenuDrawTextWindow(0, 0, width + 2, 9); - MenuPrint(gPCText_HallOfFame, 1, 5); - MenuPrint(gPCText_LogOff, 1, 7); + Menu_DrawStdWindowFrame(0, 0, width + 2, 9); + Menu_PrintText(gPCText_HallOfFame, 1, 5); + Menu_PrintText(gPCText_LogOff, 1, 7); } else { numChoices = 3; - MenuDrawTextWindow(0, 0, width + 2, 7); - MenuPrint(gPCText_LogOff, 1, 5); + Menu_DrawStdWindowFrame(0, 0, width + 2, 7); + Menu_PrintText(gPCText_LogOff, 1, 5); } if (FlagGet(FLAG_SYS_PC_LANETTE)) // player met lanette? - MenuPrint(gPCText_LanettesPC, 1, 1); + Menu_PrintText(gPCText_LanettesPC, 1, 1); else - MenuPrint(gPCText_SomeonesPC, 1, 1); + Menu_PrintText(gPCText_SomeonesPC, 1, 1); - MenuPrint(gPCText_PlayersPC, 1, 3); + Menu_PrintText(gPCText_PlayersPC, 1, 3); InitMenu(0, 1, 1, numChoices, 0, width + 1); StartScriptMenuTask(0, 0, width + 2, 2 * numChoices + 1, 0, numChoices); } @@ -1008,15 +1008,15 @@ _080B57B4:\n\ movs r0, 0\n\ movs r1, 0\n\ movs r3, 0x9\n\ - bl MenuDrawTextWindow\n\ + bl Menu_DrawStdWindowFrame\n\ ldr r0, _080B57F8 @ =gPCText_HallOfFame\n\ movs r1, 0x1\n\ movs r2, 0x5\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ ldr r0, _080B57F0 @ =gPCText_LogOff\n\ movs r1, 0x1\n\ movs r2, 0x7\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ b _080B5818\n\ .align 2, 0\n\ _080B57E8: .4byte gPCText_SomeonesPC\n\ @@ -1032,11 +1032,11 @@ _080B57FC:\n\ movs r0, 0\n\ movs r1, 0\n\ movs r3, 0x7\n\ - bl MenuDrawTextWindow\n\ + bl Menu_DrawStdWindowFrame\n\ ldr r0, _080B5834 @ =gPCText_LogOff\n\ movs r1, 0x1\n\ movs r2, 0x5\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ _080B5818:\n\ adds r6, r4, 0\n\ ldr r0, _080B5838 @ =0x0000084b\n\ @@ -1047,7 +1047,7 @@ _080B5818:\n\ ldr r0, _080B583C @ =gPCText_LanettesPC\n\ movs r1, 0x1\n\ movs r2, 0x1\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ b _080B584A\n\ .align 2, 0\n\ _080B5834: .4byte gPCText_LogOff\n\ @@ -1057,12 +1057,12 @@ _080B5840:\n\ ldr r0, _080B5888 @ =gPCText_SomeonesPC\n\ movs r1, 0x1\n\ movs r2, 0x1\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ _080B584A:\n\ ldr r0, _080B588C @ =gPCText_PlayersPC\n\ movs r1, 0x1\n\ movs r2, 0x3\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ movs r4, 0\n\ str r4, [sp]\n\ adds r0, r5, 0x1\n\ @@ -1096,8 +1096,8 @@ _080B588C: .4byte gPCText_PlayersPC\n\ void ScriptMenu_DisplayPCStartupPrompt(void) { - MenuDisplayMessageBox(); - MenuPrint(gPCText_WhichPCShouldBeAccessed, 2, 15); + Menu_DisplayDialogueFrame(); + Menu_PrintText(gPCText_WhichPCShouldBeAccessed, 2, 15); } #define tState data[0] @@ -1122,7 +1122,7 @@ static void Task_PokemonPicWindow(u8 taskId) task->tState++; break; case 3: - MenuZeroFillWindowRect(task->tWindowX, task->tWindowY, task->tWindowX + 9, task->tWindowY + 10); + Menu_EraseWindowRect(task->tWindowX, task->tWindowY, task->tWindowX + 9, task->tWindowY + 10); DestroyTask(taskId); break; } @@ -1139,7 +1139,7 @@ bool8 ScriptMenu_ShowPokemonPic(u16 species, u8 x, u8 y) } else { - MenuDrawTextWindow(x, y, x + 9, y + 10); + Menu_DrawStdWindowFrame(x, y, x + 9, y + 10); taskId = CreateTask(Task_PokemonPicWindow, 0x50); gTasks[taskId].tState = 0; gTasks[taskId].tMonSpecies = species; diff --git a/src/field/secret_base.c b/src/field/secret_base.c index 2e4138a3b..203b57867 100644 --- a/src/field/secret_base.c +++ b/src/field/secret_base.c @@ -913,7 +913,7 @@ void Task_SecretBasePC_Registry(u8 taskId) taskData[1] = 0; taskData[2] = 0; - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); sub_80BC7D8(taskId); gTasks[taskId].func = sub_80BC824; @@ -948,8 +948,8 @@ void sub_80BC6B0(u8 taskId) if (sub_80BC268(i) == TRUE) { sub_80BC190(gStringVar1, i); - MenuFillWindowRectWithBlankTile(18, 2 * n + 2, 28, 2 * n + 3); - MenuPrint(gStringVar1, 18, 2 * n + 2); + Menu_BlankWindowRect(18, 2 * n + 2, 28, 2 * n + 3); + Menu_PrintText(gStringVar1, 18, 2 * n + 2); if (++n == 8) break; } @@ -957,11 +957,11 @@ void sub_80BC6B0(u8 taskId) if (n < 8) { - MenuFillWindowRectWithBlankTile(18, 2 * n + 2, 28, 2 * n + 3); - MenuPrint(gUnknownText_Exit, 18, 2 * n + 2); + Menu_BlankWindowRect(18, 2 * n + 2, 28, 2 * n + 3); + Menu_PrintText(gUnknownText_Exit, 18, 2 * n + 2); DestroyVerticalScrollIndicator(1); if (n != 7) - MenuFillWindowRectWithBlankTile(18, ((n << 25) + (1 << 26)) >> 24, 28, 18); // the shifts are needed to match + Menu_BlankWindowRect(18, ((n << 25) + (1 << 26)) >> 24, 28, 18); // the shifts are needed to match } else CreateVerticalScrollIndicators(1, 0xbc, 0x98); @@ -975,7 +975,7 @@ void sub_80BC6B0(u8 taskId) void sub_80BC7D8(u8 taskId) { u16 *taskData = gTasks[taskId].data; - MenuDrawTextWindow(17, 0, 29, 19); + Menu_DrawStdWindowFrame(17, 0, 29, 19); InitMenu(0, 18, 2, taskData[3] + 1, taskData[1], 11); sub_80BC6B0(taskId); @@ -990,7 +990,7 @@ void sub_80BC824(u8 taskId) if (taskData[1]) { PlaySE(5); - taskData[1] = MoveMenuCursor(-1); + taskData[1] = Menu_MoveCursor(-1); } else if (taskData[2]) { @@ -1013,7 +1013,7 @@ void sub_80BC824(u8 taskId) else { PlaySE(5); - taskData[1] = MoveMenuCursor(1); + taskData[1] = Menu_MoveCursor(1); } } else if (gMain.newKeys & A_BUTTON) @@ -1021,13 +1021,13 @@ void sub_80BC824(u8 taskId) PlaySE(5); if (taskData[1] + taskData[2] == taskData[0]) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 29, 19); sub_80BCC54(taskId); } else { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); taskData[4] = sub_80BC948(taskData[1] + taskData[2]); sub_80BC980(taskId); } @@ -1035,8 +1035,8 @@ void sub_80BC824(u8 taskId) else if (gMain.newKeys & B_BUTTON) { PlaySE(5); - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 29, 19); sub_80BCC54(taskId); } } @@ -1066,8 +1066,8 @@ void sub_80BC980(u8 taskId) { PauseVerticalScrollIndicator(0); PauseVerticalScrollIndicator(1); - MenuDrawTextWindow(1, 0, 12, 5); - PrintMenuItems(2, 1, 2, (const struct MenuAction *)gUnknown_083D13D4); + Menu_DrawStdWindowFrame(1, 0, 12, 5); + Menu_PrintItems(2, 1, 2, (const struct MenuAction *)gUnknown_083D13D4); InitMenu(0, 2, 1, 2, 0, 10); gTasks[taskId].func = sub_80BC9E4; } @@ -1076,24 +1076,24 @@ void sub_80BC9E4(u8 taskId) { if (gMain.newAndRepeatedKeys & DPAD_UP) { - if (GetMenuCursorPos()) + if (Menu_GetCursorPos()) { PlaySE(5); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) { - if (GetMenuCursorPos() != 1) + if (Menu_GetCursorPos() != 1) { PlaySE(5); - MoveMenuCursor(1); + Menu_MoveCursor(1); } } else if (gMain.newKeys & A_BUTTON) { PlaySE(5); - gUnknown_083D13D4[GetMenuCursorPos()].func(taskId); + gUnknown_083D13D4[Menu_GetCursorPos()].func(taskId); } else if (gMain.newKeys & B_BUTTON) { @@ -1108,8 +1108,8 @@ void sub_80BCA84(u8 taskId) DestroyVerticalScrollIndicator(0); DestroyVerticalScrollIndicator(1); - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 29, 19); sub_80BC190(gStringVar1, taskData[4]); StringExpandPlaceholders(gStringVar4, gOtherText_OkayToDeleteFromRegistry); @@ -1126,7 +1126,7 @@ void sub_80BCB10(u8 taskId) { s16 *taskData = gTasks[taskId].data; - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); gSaveBlock1.secretBases[taskData[4]].sbr_field_1_6 = 0; taskData[0]--; @@ -1147,13 +1147,13 @@ void sub_80BCB10(u8 taskId) void sub_80BCB90(u8 taskId) { - MenuZeroFillWindowRect(20, 8, 26, 13); + Menu_EraseWindowRect(20, 8, 26, 13); DisplayItemMessageOnField(taskId, gOtherText_RegisteredDataDeleted, sub_80BCB10, 0); } void sub_80BCBC0(u8 taskId) { - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); sub_80BC7D8(taskId); gTasks[taskId].func = sub_80BC824; @@ -1164,7 +1164,7 @@ void sub_80BCBF8(u8 taskId) s16 *taskData = gTasks[taskId].data; InitMenu(0, 18, 2, taskData[3] + 1, taskData[1], 11); - MenuZeroFillWindowRect(1, 0, 12, 5); + Menu_EraseWindowRect(1, 0, 12, 5); StartVerticalScrollIndicators(0); StartVerticalScrollIndicators(1); diff --git a/src/field/shop.c b/src/field/shop.c index 23d668fc7..1dc6ba0cd 100644 --- a/src/field/shop.c +++ b/src/field/shop.c @@ -15,7 +15,7 @@ #include "strings.h" #include "task.h" #include "tv.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "field_map_obj.h" #include "field_player_avatar.h" #include "fieldmap.h" @@ -84,14 +84,14 @@ u8 CreateShopMenu(u8 martType) if (martType == MART_TYPE_0) { gMartInfo.numChoices = 2; - MenuDrawTextWindow(0, 0, 10, 7); - PrintMenuItemsReordered(1, 1, 3, sBuySellQuitMenuActions, gUnknown_083CC6E8); + Menu_DrawStdWindowFrame(0, 0, 10, 7); + Menu_PrintItemsReordered(1, 1, 3, sBuySellQuitMenuActions, gUnknown_083CC6E8); } else { gMartInfo.numChoices = 1; - MenuDrawTextWindow(0, 0, 10, 5); - PrintMenuItemsReordered(1, 1, 2, sBuySellQuitMenuActions, gUnknown_083CC6EB); + Menu_DrawStdWindowFrame(0, 0, 10, 5); + Menu_PrintItemsReordered(1, 1, 2, sBuySellQuitMenuActions, gUnknown_083CC6EB); } InitMenu(0, 1, 1, gMartInfo.numChoices + 1, 0, 9); // add 1 for cancel @@ -126,7 +126,7 @@ void sub_80B2E38(u8 var) if (gMartInfo.cursor) // can move cursor up? { PlaySE(SE_SELECT); - gMartInfo.cursor = MoveMenuCursor(-1); + gMartInfo.cursor = Menu_MoveCursor(-1); } } else if (gMain.newAndRepeatedKeys & DPAD_DOWN) @@ -134,7 +134,7 @@ void sub_80B2E38(u8 var) if (gMartInfo.cursor != gMartInfo.numChoices) // can move cursor down? { PlaySE(SE_SELECT); - gMartInfo.cursor = MoveMenuCursor(1); + gMartInfo.cursor = Menu_MoveCursor(1); } } else if (gMain.newKeys & A_BUTTON) @@ -174,8 +174,8 @@ void sub_80B2F30(u8 taskId) void HandleShopMenuQuit(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 11, 8); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 11, 8); sub_80BE3BC(); ScriptContext2_Disable(); DestroyTask(taskId); @@ -266,7 +266,7 @@ void BuyMenuDrawGraphics(void) register u16 zero2 asm("r5"); sub_80F9438(); - remove_some_task(); + ScanlineEffect_Stop(); REG_BG1HOFS = (zero2 = 0); REG_BG1VOFS = zero2; REG_BG2HOFS = zero2; @@ -285,12 +285,12 @@ void BuyMenuDrawGraphics(void) ResetPaletteFade(); ResetSpriteData(); ResetTasks(); - SetUpWindowConfig(&gWindowConfig_81E6DFC); - InitMenuWindow(&gWindowConfig_81E6DFC); + Text_LoadWindowTemplate(&gWindowTemplate_81E6DFC); + InitMenuWindow(&gWindowTemplate_81E6DFC); BuyMenuDrawMapGraphics(); gMartInfo.cursor = zero; gMartInfo.choicesAbove = zero2; - MenuZeroFillWindowRect(0, 0, 0x20, 0x20); + Menu_EraseWindowRect(0, 0, 0x20, 0x20); OpenMoneyWindow(gSaveBlock1.money, 0, 0); sub_80B3764(0, 7); sub_80B37EC(); @@ -532,7 +532,7 @@ void sub_80B37F8(u8 taskId) gStringVar1[1] = 0x14; gStringVar1[2] = 0x6; ConvertIntToDecimalStringN(&gStringVar1[3], gTasks[taskId].data[1], 1, 2); - MenuPrint(gOtherText_xString1, 1, 11); + Menu_PrintText(gOtherText_xString1, 1, 11); sub_80A3FA0(gBGTilemapBuffers[1], 1, 11, 12, 2, 0xC3E1); } @@ -557,7 +557,7 @@ void sub_80B389C(u16 itemId, u8 var2, bool32 hasControlCode) stringPtr = &gStringVar1[3]; GetMoneyAmountText(stringPtr, (ItemId_GetPrice(itemId) >> GetPriceReduction(1)), 0x4); - MenuPrint_PixelCoords(&gStringVar1[0], 0xCA, var2 << 3, 1); + Menu_PrintTextPixelCoords(&gStringVar1[0], 0xCA, var2 << 3, 1); } void sub_80B3930(u16 itemId, u8 var2, bool32 hasControlCode) @@ -586,7 +586,7 @@ void sub_80B3930(u16 itemId, u8 var2, bool32 hasControlCode) else { GetMoneyAmountText(stringPtr, gDecorations[itemId].price, 0x4); - MenuPrint_PixelCoords(&gStringVar1[0], 0xCA, var2 << 3, 0x1); + Menu_PrintTextPixelCoords(&gStringVar1[0], 0xCA, var2 << 3, 0x1); } } @@ -604,8 +604,8 @@ void sub_80B39D0(int var1, int var2, bool32 hasControlCode) if (i != 8 && gMartInfo.choicesAbove + i == gMartInfo.itemCount) { - MenuFillWindowRectWithBlankTile(0xE, (i << 1) + 2, 0x1C, (i << 1) + 3); - MenuPrint(gOtherText_CancelNoTerminator, 0xE, (i << 1) + 2); + Menu_BlankWindowRect(0xE, (i << 1) + 2, 0x1C, (i << 1) + 3); + Menu_PrintText(gOtherText_CancelNoTerminator, 0xE, (i << 1) + 2); } } @@ -659,7 +659,7 @@ void sub_80B3BD0(u8 taskId) void sub_80B3BF4(u8 taskId) { - MenuZeroFillWindowRect(0x7, 0x8, 0xD, 0xD); + Menu_EraseWindowRect(0x7, 0x8, 0xD, 0xD); sub_80A3FA0(gBGTilemapBuffers[1], 8, 9, 4, 4, 0); sub_80B379C(); sub_80B3420(); @@ -706,7 +706,7 @@ void sub_80B3D38(u8 taskId) void sub_80B3D7C(u8 taskId) { sub_80B39D0(gMartInfo.cursor, gMartInfo.cursor, 0); - MenuZeroFillWindowRect(0x7, 0x8, 0xD, 0xD); + Menu_EraseWindowRect(0x7, 0x8, 0xD, 0xD); sub_80A3FA0(gBGTilemapBuffers[1], 0x8, 0x9, 0x4, 0x4, 0); sub_80B4378(taskId); } @@ -719,7 +719,7 @@ void sub_80B3DC8(u8 taskId) if (gMain.newKeys & A_BUTTON) { gMartTotalCost = (ItemId_GetPrice(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]) >> GetPriceReduction(1)) * gTasks[taskId].data[1]; // set total cost of your purchase. - MenuZeroFillWindowRect(0, 0xA, 0xD, 0xD); + Menu_EraseWindowRect(0, 0xA, 0xD, 0xD); sub_80A3FA0(gBGTilemapBuffers[1], 0x1, 0xB, 0xC, 0x2, 0); sub_80B379C(); sub_80B3420(); @@ -741,7 +741,7 @@ void sub_80B3EFC(u8 taskId) u16 var; gTasks[taskId].data[1] = 1; - MenuDrawTextWindow(0, 0xA, 0xD, 0xD); + Menu_DrawStdWindowFrame(0, 0xA, 0xD, 0xD); sub_80B37F8(taskId); var = gSaveBlock1.money / (ItemId_GetPrice(gMartInfo.itemList[gMartInfo.choicesAbove + gMartInfo.cursor]) >> GetPriceReduction(1)); @@ -1049,7 +1049,7 @@ void sub_80B40E8(u8 taskId) // Mart_DoCursorAction else // if the cursor is not 0, choicesAbove cannot be updated yet since the cursor is at the top of the menu, so update cursor. { PlaySE(SE_SELECT); - gMartInfo.cursor = MoveMenuCursor(-1); // move cursor up + gMartInfo.cursor = Menu_MoveCursor(-1); // move cursor up sub_80B3A70(); } } @@ -1070,7 +1070,7 @@ void sub_80B40E8(u8 taskId) // Mart_DoCursorAction else if (gMartInfo.cursor != gMartInfo.itemCount) { PlaySE(SE_SELECT); - gMartInfo.cursor = MoveMenuCursor(1); + gMartInfo.cursor = Menu_MoveCursor(1); sub_80B3A70(); } } @@ -1084,8 +1084,8 @@ void sub_80B40E8(u8 taskId) // Mart_DoCursorAction PauseVerticalScrollIndicator(1); sub_80F979C(1, 1); sub_80B39D0(gMartInfo.cursor, gMartInfo.cursor, 1); - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0xC, 0xD, 0x13); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0xC, 0xD, 0x13); if (gMartInfo.martType == MART_TYPE_0) { @@ -1139,8 +1139,8 @@ void sub_80B40E8(u8 taskId) // Mart_DoCursorAction void sub_80B4378(u8 taskId) { - MenuZeroFillWindowRect(0, 0xE, 0x1D, 0x13); - MenuZeroFillWindowRect(0, 0xA, 0xD, 0xD); + Menu_EraseWindowRect(0, 0xE, 0x1D, 0x13); + Menu_EraseWindowRect(0, 0xA, 0xD, 0xD); sub_80A3FA0(gBGTilemapBuffers[1], 0x1, 0xB, 0xC, 0x2, 0); sub_80B3420(); sub_80B3764(6, 7); diff --git a/src/field/slot_machine.c b/src/field/slot_machine.c index a524790b4..9ff3a037c 100644 --- a/src/field/slot_machine.c +++ b/src/field/slot_machine.c @@ -400,8 +400,8 @@ static void SlotMachineSetup_0_1(void) static void SlotMachineSetup_3_0(void) { - SetUpWindowConfig(&gWindowConfig_81E7128); - InitMenuWindow(&gWindowConfig_81E7128); + Text_LoadWindowTemplate(&gWindowTemplate_81E7128); + InitMenuWindow(&gWindowTemplate_81E7128); } static void SlotMachineSetup_4_0(void) @@ -584,8 +584,8 @@ static bool8 sub_8101E3C(struct Task *task) static void sub_8101F2C(const u8 *str) { - MenuDisplayMessageBox(); - MenuPrint(str, 2, 15); + Menu_DisplayDialogueFrame(); + Menu_PrintText(str, 2, 15); } static bool8 sub_8101F44(struct Task *task) @@ -599,7 +599,7 @@ static bool8 sub_8101F60(struct Task *task) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { - MenuZeroFillScreen(); + Menu_EraseScreen(); eSlotMachine->state = 5; } return FALSE; @@ -850,10 +850,10 @@ static bool8 sub_8102318(struct Task *task) static bool8 sub_8102344(struct Task *task) { - s8 input = ProcessMenuInputNoWrap_(); + s8 input = Menu_ProcessInputNoWrap_(); if (input == 0) { - MenuZeroFillScreen(); + Menu_EraseScreen(); sub_8103D8C(0); sub_8103D8C(1); sub_8103D8C(2); @@ -862,7 +862,7 @@ static bool8 sub_8102344(struct Task *task) } else if (input == 1 || input == -1) { - MenuZeroFillScreen(); + Menu_EraseScreen(); eSlotMachine->state = 5; } return FALSE; @@ -879,7 +879,7 @@ static bool8 sub_81023B8(struct Task *task) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { - MenuZeroFillScreen(); + Menu_EraseScreen(); eSlotMachine->state = 5; } return FALSE; @@ -896,7 +896,7 @@ static bool8 sub_81023FC(struct Task *task) { if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { - MenuZeroFillScreen(); + Menu_EraseScreen(); eSlotMachine->state = 27; } return FALSE; @@ -2807,8 +2807,8 @@ static void sub_8104B80(struct Task *task) { sub_8104DA4(); sub_81065DC(); - BasicInitMenuWindow(&gWindowConfig_81E7144); - MenuPrint_PixelCoords(gOtherText_ReelTime, 10, 32, 1); + BasicInitMenuWindow(&gWindowTemplate_81E7144); + Menu_PrintTextPixelCoords(gOtherText_ReelTime, 10, 32, 1); BeginNormalPaletteFade(-1, 0, 16, 0, 0); task->data[0]++; } @@ -2824,8 +2824,8 @@ static void sub_8104BC8(struct Task *task) static void sub_8104BFC(struct Task *task) { - MenuZeroFillScreen(); - BasicInitMenuWindow(&gWindowConfig_81E7128); + Menu_EraseScreen(); + BasicInitMenuWindow(&gWindowTemplate_81E7128); sub_81064B8(); sub_8104CAC(task->data[1]); sub_810423C(eSlotMachine->pikaPower); diff --git a/src/field/start_menu.c b/src/field/start_menu.c index dccf1714e..d6881cb01 100644 --- a/src/field/start_menu.c +++ b/src/field/start_menu.c @@ -28,7 +28,7 @@ #include "strings2.h" #include "task.h" #include "trainer_card.h" -#include "unknown_task.h" +#include "scanline_effect.h" //Menu actions enum { @@ -193,8 +193,8 @@ static void BuildStartMenuActions_Link(void) static void DisplaySafariBallsWindow(void) { sub_8072C44(gStringVar1, gNumSafariBalls, 12, 1); - MenuDrawTextWindow(0, 0, 10, 5); - MenuPrint(gOtherText_SafariStock, 1, 1); + Menu_DrawStdWindowFrame(0, 0, 10, 5); + Menu_PrintText(gOtherText_SafariStock, 1, 1); } //Prints n menu items starting at *index @@ -204,7 +204,7 @@ static bool32 PrintStartMenuItemsMultistep(s16 *index, u32 n) do { - MenuPrint(sStartMenuItems[sCurrentStartMenuActions[_index]].text, 23, 2 + _index * 2); + Menu_PrintText(sStartMenuItems[sCurrentStartMenuActions[_index]].text, 23, 2 + _index * 2); _index++; if (_index >= sNumStartMenuActions) { @@ -226,7 +226,7 @@ static bool32 InitStartMenuMultistep(s16 *step, s16 *index) (*step)++; break; case 2: - MenuDrawTextWindow(22, 0, 29, sNumStartMenuActions * 2 + 3); + Menu_DrawStdWindowFrame(22, 0, 29, sNumStartMenuActions * 2 + 3); *index = 0; (*step)++; break; @@ -271,7 +271,7 @@ void CreateStartMenuTask(void (*func)(u8)) { u8 taskId; - InitMenuWindow(&gWindowConfig_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); taskId = CreateTask(Task_StartMenu, 0x50); SetTaskFuncWithFollowupFunc(taskId, Task_StartMenu, func); } @@ -310,12 +310,12 @@ static u8 StartMenu_InputProcessCallback(void) if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); - sStartMenuCursorPos = MoveMenuCursor(-1); + sStartMenuCursorPos = Menu_MoveCursor(-1); } if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - sStartMenuCursorPos = MoveMenuCursor(1); + sStartMenuCursorPos = Menu_MoveCursor(1); } if (gMain.newKeys & A_BUTTON) { @@ -404,7 +404,7 @@ static u8 StartMenu_PlayerCallback(void) //When player selects SAVE static u8 StartMenu_SaveCallback(void) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); gCallback_03004AE8 = SaveCallback1; return 0; } @@ -473,13 +473,13 @@ static u8 SaveCallback2(void) return FALSE; case SAVE_CANCELED: //Go back to start menu - MenuZeroFillScreen(); + Menu_EraseScreen(); InitStartMenu(); gCallback_03004AE8 = StartMenu_InputProcessCallback; return FALSE; case SAVE_SUCCESS: case SAVE_ERROR: - MenuZeroFillScreen(); + Menu_EraseScreen(); sub_8064E2C(); ScriptContext2_Disable(); return TRUE; @@ -498,7 +498,7 @@ static u8 RunSaveDialogCallback(void) { if (savingComplete) { - if (!MenuUpdateWindowText()) + if (!Menu_UpdateWindowText()) return 0; } savingComplete = FALSE; @@ -514,7 +514,7 @@ void ScrSpecial_DoSaveDialog(void) static void DisplaySaveMessageWithCallback(const u8 *ptr, u8 (*func)(void)) { StringExpandPlaceholders(gStringVar4, ptr); - MenuDisplayMessageBox(); + Menu_DisplayDialogueFrame(); MenuPrintMessageDefaultCoords(gStringVar4); savingComplete = TRUE; saveDialogCallback = func; @@ -547,7 +547,7 @@ static void sub_8071700(void) static void HideSaveDialog(void) { - MenuZeroFillWindowRect(20, 8, 26, 13); + Menu_EraseWindowRect(20, 8, 26, 13); } static void SaveDialogStartTimeout(void) @@ -579,7 +579,7 @@ static bool8 SaveDialogCheckForTimeoutAndKeypress(void) static u8 SaveDialogCB_DisplayConfirmMessage(void) { - MenuZeroFillScreen(); + Menu_EraseScreen(); HandleDrawSaveWindowInfo(0, 0); DisplaySaveMessageWithCallback(gSaveText_WouldYouLikeToSave, SaveDialogCB_DisplayConfirmYesNoMenu); return SAVE_IN_PROGRESS; @@ -594,7 +594,7 @@ static u8 SaveDialogCB_DisplayConfirmYesNoMenu(void) static u8 SaveDialogCB_ProcessConfirmYesNoMenu(void) { - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: //YES HideSaveDialog(); @@ -640,7 +640,7 @@ static u8 SaveDialogCB_DisplayOverwriteYesNoMenu(void) static u8 SaveDialogCB_ProcessOverwriteYesNoMenu(void) { - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: //YES HideSaveDialog(); @@ -694,7 +694,7 @@ static u8 SaveDialogCB_DoSave(void) static u8 SaveDialogCB_SaveSuccess(void) { - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { PlaySE(SE_SAVE); saveDialogCallback = SaveDialogCB_ReturnSuccess; @@ -715,7 +715,7 @@ static u8 SaveDialogCB_ReturnSuccess(void) static u8 SaveDialogCB_SaveError(void) { - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { PlaySE(SE_BOO); saveDialogCallback = SaveDialogCB_ReturnError; @@ -750,7 +750,7 @@ static bool32 sub_80719FC(u8 *step) REG_DISPCNT = 0; SetVBlankCallback(NULL); - remove_some_task(); + ScanlineEffect_Stop(); DmaClear16(3, PLTT, PLTT_SIZE); addr = (void *)VRAM; size = 0x18000; @@ -771,11 +771,11 @@ static bool32 sub_80719FC(u8 *step) ResetSpriteData(); ResetTasks(); ResetPaletteFade(); - dp12_8087EA4(); + ScanlineEffect_Clear(); break; case 2: - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); REG_DISPCNT = DISPCNT_MODE_0 | DISPCNT_BG0_ON; break; case 3: @@ -821,8 +821,8 @@ static void Task_8071B64(u8 taskId) switch (*step) { case 0: - MenuDisplayMessageBox(); - MenuPrint(gSystemText_Saving, 2, 15); + Menu_DisplayDialogueFrame(); + Menu_PrintText(gSystemText_Saving, 2, 15); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); (*step)++; break; diff --git a/src/field/starter_choose.c b/src/field/starter_choose.c index 701d4087a..418488774 100644 --- a/src/field/starter_choose.c +++ b/src/field/starter_choose.c @@ -14,7 +14,7 @@ #include "strings.h" #include "task.h" #include "trig.h" -#include "unknown_task.h" +#include "scanline_effect.h" extern u16 gSpecialVar_Result; extern struct SpriteTemplate gUnknown_02024E8C; @@ -285,7 +285,7 @@ void CB2_ChooseStarter(void) LZ77UnCompVram(&gBirchHelpGfx, (void *)VRAM); LZ77UnCompVram(&gBirchBagTilemap, (void *)(VRAM + 0x3000)); LZ77UnCompVram(&gBirchGrassTilemap, (void *)(VRAM + 0x3800)); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); ResetPaletteFade(); @@ -294,8 +294,8 @@ void CB2_ChooseStarter(void) LoadCompressedObjectPic(&gUnknown_083F7794[0]); LoadCompressedObjectPic(&gUnknown_083F77A4[0]); LoadSpritePalettes(gUnknown_083F77B4); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); BeginNormalPaletteFade(-1, 0, 0x10, 0, 0); savedIme = REG_IME; @@ -355,8 +355,8 @@ static void MainCallback2(void) static void Task_StarterChoose1(u8 taskId) { CreateStarterPokemonLabel(0xFF, gTasks[taskId].tStarterSelection); - MenuDrawTextWindow(2, 14, 27, 19); - MenuPrint(gOtherText_BirchInTrouble, 3, 15); + Menu_DrawStdWindowFrame(2, 14, 27, 19); + Menu_PrintText(gOtherText_BirchInTrouble, 3, 15); gTasks[taskId].func = Task_StarterChoose2; } @@ -368,7 +368,7 @@ static void Task_StarterChoose2(u8 taskId) { u8 spriteId; - MenuZeroFillWindowRect( + Menu_EraseWindowRect( gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1], gStarterChoose_LabelCoords[selection][0] + 13, @@ -424,9 +424,9 @@ static void Task_StarterChoose3(u8 taskId) static void Task_StarterChoose4(u8 taskId) { PlayCry1(GetStarterPokemon(gTasks[taskId].tStarterSelection), 0); - MenuDrawTextWindow(2, 14, 27, 19); + Menu_DrawStdWindowFrame(2, 14, 27, 19); //"Do you choose this POKEMON?" - MenuPrint(gOtherText_DoYouChoosePoke, 3, 15); + Menu_PrintText(gOtherText_DoYouChoosePoke, 3, 15); DisplayYesNoMenu(21, 7, 1); gTasks[taskId].func = Task_StarterChoose5; } @@ -435,7 +435,7 @@ static void Task_StarterChoose5(u8 taskId) { u8 spriteId; - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: // YES //Return the starter choice and exit. @@ -445,7 +445,7 @@ static void Task_StarterChoose5(u8 taskId) case 1: // NO case -1: // B button PlaySE(SE_SELECT); - MenuZeroFillWindowRect(21, 7, 27, 12); + Menu_EraseWindowRect(21, 7, 27, 12); spriteId = gTasks[taskId].tPkmnSpriteId; FreeSpritePaletteByTag(GetSpritePaletteTagByPaletteNum(gSprites[spriteId].oam.paletteNum)); @@ -498,7 +498,7 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) if (prevSelection != 0xFF) { //Remove the old Pokemon label - MenuZeroFillWindowRect( + Menu_EraseWindowRect( gStarterChoose_LabelCoords[prevSelection][0], gStarterChoose_LabelCoords[prevSelection][1], gStarterChoose_LabelCoords[prevSelection][0] + 13, @@ -527,7 +527,7 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) //Copy POKEMON string to label StringCopy(labelText + dstIndex, gOtherText_Poke); - MenuPrint( + Menu_PrintText( labelText, gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1]); @@ -535,7 +535,7 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) //Copy Pokemon name to label sub_8072C74(labelText + 5, gSpeciesNames[species], 0x6B, 1); - MenuPrint( + Menu_PrintText( labelText, gStarterChoose_LabelCoords[selection][0], gStarterChoose_LabelCoords[selection][1] + 2); @@ -574,7 +574,7 @@ static void CreateStarterPokemonLabel(u8 prevSelection, u8 selection) adds r3, r1, 0x3\n\ lsls r3, 24\n\ lsrs r3, 24\n\ - bl MenuZeroFillWindowRect\n\ + bl Menu_EraseWindowRect\n\ ldr r0, _0810A964 @ =0x04000040\n\ movs r1, 0\n\ strh r1, [r0]\n\ @@ -649,7 +649,7 @@ _0810A8CA:\n\ mov r0, sp\n\ adds r1, r4, 0\n\ adds r2, r5, 0\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ mov r0, sp\n\ movs r1, 0\n\ movs r2, 0xF\n\ @@ -669,7 +669,7 @@ _0810A8CA:\n\ lsrs r2, 24\n\ mov r0, sp\n\ adds r1, r4, 0\n\ - bl MenuPrint\n\ + bl Menu_PrintText\n\ lsls r0, r4, 3\n\ adds r0, 0x4\n\ lsls r0, 24\n\ diff --git a/src/field/trader.c b/src/field/trader.c index 61cb0b4a2..b4732ab15 100644 --- a/src/field/trader.c +++ b/src/field/trader.c @@ -100,7 +100,7 @@ void CreateAvailableDecorationsMenu(u8 taskId) } } - MenuDrawTextWindow(0, 1, 12, numChoices * 2 + 2); + Menu_DrawStdWindowFrame(0, 1, 12, numChoices * 2 + 2); for (i = 0; i < 4; i++) { @@ -108,18 +108,18 @@ void CreateAvailableDecorationsMenu(u8 taskId) { if (trader->unk1[i] > DECOR_REGISTEEL_DOLL) { - MenuPrint(gOtherText_FiveQuestionsAndSlash, 1, numDecorations * 2 + 2); + Menu_PrintText(gOtherText_FiveQuestionsAndSlash, 1, numDecorations * 2 + 2); } else { - MenuPrint(gDecorations[trader->unk1[i]].name, 1, numDecorations * 2 + 2); + Menu_PrintText(gDecorations[trader->unk1[i]].name, 1, numDecorations * 2 + 2); } numDecorations++; } } - MenuPrint(gOtherText_CancelNoTerminator, 1, numDecorations * 2 + 2); + Menu_PrintText(gOtherText_CancelNoTerminator, 1, numDecorations * 2 + 2); InitMenu(0, 1, 2, numChoices, 0, 11); gTasks[taskId].data[1] = numDecorations; } @@ -135,8 +135,8 @@ void sub_8109B34(u8 taskId, u8 decorationId) gSpecialVar_0x8004 = decorationId; } - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 1, 12, 12); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 1, 12, 12); DestroyTask(taskId); EnableBothScriptContexts(); } @@ -148,17 +148,17 @@ void Task_HandleGetDecorationMenuInput(u8 taskId) if (gMain.newKeys & DPAD_UP) { PlaySE(SE_SELECT); - MoveMenuCursor(-1); + Menu_MoveCursor(-1); } else if (gMain.newKeys & DPAD_DOWN) { PlaySE(SE_SELECT); - MoveMenuCursor(1); + Menu_MoveCursor(1); } else if (gMain.newKeys & A_BUTTON) { PlaySE(SE_SELECT); - gSpecialVar_0x8005 = GetMenuCursorPos(); + gSpecialVar_0x8005 = Menu_GetCursorPos(); if (gTasks[taskId].data[1] == gSpecialVar_0x8005) { sub_8109B34(taskId, 0); @@ -215,8 +215,8 @@ void ScrSpecial_TraderMenuGiveDecoration(void) void sub_8109D04(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 29, 19); DestroyVerticalScrollIndicator(0); DestroyVerticalScrollIndicator(1); sub_80F9520(gUnknown_020388F7, 8); @@ -237,8 +237,8 @@ void sub_8109D04(u8 taskId) void sub_8109DAC(u8 taskId) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 29, 19); gSpecialVar_0x8006 = 0; DestroyTask(taskId); EnableBothScriptContexts(); diff --git a/src/field/tv.c b/src/field/tv.c index e88e3c72b..e1eade130 100644 --- a/src/field/tv.c +++ b/src/field/tv.c @@ -864,7 +864,7 @@ void PutPokemonTodayCaughtOnAir(void) sub_80BE138((TVShow *)pokemonToday); pokemonToday->language = GAME_LANGUAGE; pokemonToday->language2 = sub_80BDEAC(pokemonToday->nickname); - StripExtCtrlCodes(pokemonToday->nickname); + Text_StripExtCtrlCodes(pokemonToday->nickname); } } } @@ -966,7 +966,7 @@ void InterviewAfter_BravoTrainerPokemonProfile(void) sub_80BE160((TVShow *)bravoTrainerNew); bravoTrainerNew->language = GAME_LANGUAGE; bravoTrainerNew->var1f = sub_80BDEAC(bravoTrainerNew->pokemonNickname); - StripExtCtrlCodes(bravoTrainerNew->pokemonNickname); + Text_StripExtCtrlCodes(bravoTrainerNew->pokemonNickname); } } @@ -1075,7 +1075,7 @@ void sub_80BE478(void) sub_80BE160((TVShow *)nameRaterShow); nameRaterShow->language = GAME_LANGUAGE; nameRaterShow->pokemonNameLanguage = sub_80BDEAC(nameRaterShow->pokemonName); - StripExtCtrlCodes(nameRaterShow->pokemonName); + Text_StripExtCtrlCodes(nameRaterShow->pokemonName); } } @@ -1138,7 +1138,7 @@ void InterviewAfter_PkmnFanClubOpinions(void) sub_80BE160((TVShow *)fanclubOpinions); fanclubOpinions->language = GAME_LANGUAGE; fanclubOpinions->var0E = sub_80BDEAC(fanclubOpinions->var10); - StripExtCtrlCodes(fanclubOpinions->var10); + Text_StripExtCtrlCodes(fanclubOpinions->var10); } void InterviewAfter_DummyShow4(void) diff --git a/src/field/use_pokeblock.c b/src/field/use_pokeblock.c index 354193c14..8ea93aab8 100644 --- a/src/field/use_pokeblock.c +++ b/src/field/use_pokeblock.c @@ -116,7 +116,7 @@ static void sub_81365A0(void); static void sub_81365C8(void); static void sub_8136638(void); static void sub_81368A4(void); -void sub_8089668(void); +void ScanlineEffect_InitHBlankDmaTransfer(void); static void sub_8136B44(void); static u8 sub_81370E4(u8); static void sub_8136BB8(void); @@ -193,7 +193,7 @@ static void sub_8136264(void) ProcessSpriteCopyRequests(); TransferPlttBuffer(); sub_80F5CDC(6); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); } static void launch_c3_walk_stairs_and_run_once(void (*const func)(void)) @@ -227,11 +227,11 @@ static void sub_8136294(void) gUnknown_02039304->unk50++; break; case 3: - SetUpWindowConfig(&gWindowConfig_81E7080); + Text_LoadWindowTemplate(&gWindowTemplate_81E7080); gUnknown_02039304->unk50++; break; case 4: - MultistepInitMenuWindowBegin(&gWindowConfig_81E7080); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E7080); gUnknown_02039304->unk50++; break; case 5: @@ -609,28 +609,28 @@ static void sub_8136BB8(void) GetMonData(&gPlayerParty[sub_81370A4(gUnknown_083DFEC4->unk87DC)], MON_DATA_NICKNAME, gUnknown_02039304->stringBuffer); StringGetEnd10(gUnknown_02039304->stringBuffer); StringAppend(gUnknown_02039304->stringBuffer, gOtherText_GetsAPokeBlock); - BasicInitMenuWindow(&gWindowConfig_81E709C); - MenuDrawTextWindow(0, 16, 29, 19); - MenuPrint(gUnknown_02039304->stringBuffer, 1, 17); + BasicInitMenuWindow(&gWindowTemplate_81E709C); + Menu_DrawStdWindowFrame(0, 16, 29, 19); + Menu_PrintText(gUnknown_02039304->stringBuffer, 1, 17); DisplayYesNoMenu(23, 10, 1); - MoveMenuCursor(0); + Menu_MoveCursor(0); } static s8 sub_8136C40(void) { - s8 retval = ProcessMenuInputNoWrap(); + s8 retval = Menu_ProcessInputNoWrap(); if ((u8)(retval + 1) < 3) { - MenuZeroFillScreen(); - BasicInitMenuWindow(&gWindowConfig_81E7080); + Menu_EraseScreen(); + BasicInitMenuWindow(&gWindowTemplate_81E7080); } return retval; } static void sub_8136C6C(void) { - BasicInitMenuWindow(&gWindowConfig_81E709C); - MenuDrawTextWindow(0, 16, 29, 19); + BasicInitMenuWindow(&gWindowTemplate_81E709C); + Menu_DrawStdWindowFrame(0, 16, 29, 19); for (gUnknown_02039304->unk53 = 0; gUnknown_02039304->unk53 < 5 && gUnknown_02039304->unk61[gUnknown_02039304->unk53] == 0; gUnknown_02039304->unk53++); if (gUnknown_02039304->unk53 < 5) { @@ -666,21 +666,21 @@ static bool8 sub_8136D00(void) static void sub_8136D60(void) { - BasicInitMenuWindow(&gWindowConfig_81E709C); - MenuDrawTextWindow(0, 16, 29, 19); - MenuPrint(gOtherText_WontEat, 1, 17); + BasicInitMenuWindow(&gWindowTemplate_81E709C); + Menu_DrawStdWindowFrame(0, 16, 29, 19); + Menu_PrintText(gOtherText_WontEat, 1, 17); } static void sub_8136D8C(void) { - MenuZeroFillScreen(); - BasicInitMenuWindow(&gWindowConfig_81E7080); + Menu_EraseScreen(); + BasicInitMenuWindow(&gWindowTemplate_81E7080); } static void Pokeblock_MenuWindowTextPrint(const u8 *message) { - MenuDrawTextWindow(0, 16, 29, 19); - MenuPrint(message, 1, 17); + Menu_DrawStdWindowFrame(0, 16, 29, 19); + Menu_PrintText(message, 1, 17); } #ifdef NONMATCHING diff --git a/src/field/wallclock.c b/src/field/wallclock.c index 2892d09f9..aaa7f9ae8 100644 --- a/src/field/wallclock.c +++ b/src/field/wallclock.c @@ -10,7 +10,7 @@ #include "strings2.h" #include "task.h" #include "trig.h" -#include "unknown_task.h" +#include "scanline_effect.h" extern u16 gSpecialVar_0x8004; extern u8 gMiscClock_Gfx[]; @@ -229,15 +229,15 @@ static void LoadWallClockGraphics(void) LoadPalette(gMiscClockMale_Pal, 0, 32); else LoadPalette(gMiscClockFemale_Pal, 0, 32); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); ResetPaletteFade(); FreeAllSpritePalettes(); LoadCompressedObjectPic(&gUnknown_083F7A90[0]); LoadSpritePalettes(gUnknown_083F7AA0); - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); } static void WallClockInit(void) @@ -414,10 +414,10 @@ static void Task_SetClock2(u8 taskId) //Ask player "Is this the correct time?" static void Task_SetClock3(u8 taskId) { - MenuDrawTextWindow(2, 16, 27, 19); - MenuPrint(gOtherText_CorrectTimePrompt, 3, 17); - MenuDrawTextWindow(23, 8, 29, 13); - PrintMenuItems(24, 9, 2, gMenuYesNoItems); + Menu_DrawStdWindowFrame(2, 16, 27, 19); + Menu_PrintText(gOtherText_CorrectTimePrompt, 3, 17); + Menu_DrawStdWindowFrame(23, 8, 29, 13); + Menu_PrintItems(24, 9, 2, gMenuYesNoItems); InitMenu(0, 24, 9, 2, 1, 5); gTasks[taskId].func = Task_SetClock4; } @@ -425,7 +425,7 @@ static void Task_SetClock3(u8 taskId) //Get menu selection static void Task_SetClock4(u8 taskId) { - switch (ProcessMenuInputNoWrap_()) + switch (Menu_ProcessInputNoWrap_()) { case 0: //YES PlaySE(SE_SELECT); @@ -433,10 +433,10 @@ static void Task_SetClock4(u8 taskId) return; case -1: //B button case 1: //NO - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); - MenuZeroFillWindowRect(23, 8, 29, 13); - MenuZeroFillWindowRect(2, 16, 27, 19); + Menu_EraseWindowRect(23, 8, 29, 13); + Menu_EraseWindowRect(2, 16, 27, 19); gTasks[taskId].func = Task_SetClock2; //Go back and let player adjust clock } } diff --git a/src/libs/libagbsyscall.s b/src/libs/libagbsyscall.s new file mode 100644 index 000000000..cdf6ca905 --- /dev/null +++ b/src/libs/libagbsyscall.s @@ -0,0 +1,91 @@ + .include "include/macros.inc" + .syntax unified + + .text + + thumb_func_start ArcTan2 +ArcTan2: @ 81E07E0 + swi 0xA + bx lr + thumb_func_end ArcTan2 + + thumb_func_start BgAffineSet +BgAffineSet: @ 81E07E4 + swi 0xE + bx lr + thumb_func_end BgAffineSet + + thumb_func_start CpuFastSet +CpuFastSet: @ 81E07E8 + swi 0xC + bx lr + thumb_func_end CpuFastSet + + thumb_func_start CpuSet +CpuSet: @ 81E07EC + swi 0xB + bx lr + thumb_func_end CpuSet + + thumb_func_start LZ77UnCompVram +LZ77UnCompVram: @ 81E07F4 + swi 0x12 + bx lr + thumb_func_end LZ77UnCompVram + + thumb_func_start LZ77UnCompWram +LZ77UnCompWram: @ 81E07F8 + swi 0x11 + bx lr + thumb_func_end LZ77UnCompWram + + thumb_func_start ObjAffineSet +ObjAffineSet: @ 81E0804 + swi 0xF + bx lr + thumb_func_end ObjAffineSet + + thumb_func_start RLUnCompVram +RLUnCompVram: @ 81E0808 + swi 0x15 + bx lr + thumb_func_end RLUnCompVram + + thumb_func_start RLUnCompWram +RLUnCompWram: @ 81E080C + swi 0x14 + bx lr + thumb_func_end RLUnCompWram + + thumb_func_start RegisterRamReset +RegisterRamReset: @ 81E0810 + swi 0x1 + bx lr + thumb_func_end RegisterRamReset + + thumb_func_start SoftReset +SoftReset: @ 81E0814 + ldr r3, =0x04000208 + movs r2, 0 + strb r2, [r3] + ldr r1, =0x03007f00 @ User Stack + mov sp, r1 + swi 0x1 + swi 0 + .pool + thumb_func_end SoftReset + + thumb_func_start Sqrt +Sqrt: @ 81E082C + swi 0x8 + bx lr + thumb_func_end Sqrt + + thumb_func_start VBlankIntrWait +VBlankIntrWait: @ 81E0830 + movs r2, 0 + swi 0x5 + bx lr + thumb_func_end VBlankIntrWait + + .align 2, 0 @ Don't pad with nop. diff --git a/src/libs/libgcnmultiboot.s b/src/libs/libgcnmultiboot.s new file mode 100644 index 000000000..8c8b94998 --- /dev/null +++ b/src/libs/libgcnmultiboot.s @@ -0,0 +1,641 @@ +@ This library can be used to download and execute a multi-boot image from +@ a GameCube using the JOY Bus protocol over the link cable. + + .include "include/macros.inc" + .include "constants/constants.inc" + + .equiv GCMB_STRUCT_COUNTER1, 0x00 + .equiv GCMB_STRUCT_COUNTER2, 0x01 + .equiv GCMB_STRUCT_MBPROGRESS, 0x02 + .equiv GCMB_STRUCT_SAVEDVCOUNT, 0x03 + .equiv GCMB_STRUCT_KEYA, 0x04 + .equiv GCMB_STRUCT_KEYB, 0x08 + .equiv GCMB_STRUCT_KEYC, 0x0C + .equiv GCMB_STRUCT_BOOT_KEY, 0x10 + .equiv GCMB_STRUCT_IMAGE_SIZE, 0x12 + .equiv GCMB_STRUCT_SESSION_KEY, 0x14 + .equiv GCMB_STRUCT_HASH_VAL, 0x18 + .equiv GCMB_STRUCT_KEYC_DERIVATION, 0x1C + .equiv GCMB_STRUCT_BASE_DEST_PTR, 0x20 + .equiv GCMB_STRUCT_CUR_DEST_PTR, 0x24 + .equiv GCMB_STRUCT_SERIAL_INTR_HANDLER, 0x28 + + .equiv ROM_HEADER_NINTENDO_LOGO_OFFSET, 0x04 + .equiv ROM_HEADER_NINTENDO_LOGO_LENGTH, 0x98 + .equiv ROM_HEADER_NINTENDO_LOGO_END, 0xA0 + + .equiv MBPROGRESS_NONE, 0x00 + .equiv MBPROGRESS_LOGO_CORRECT, 0x01 + .equiv MBPROGRESS_READY_TO_BOOT, 0x02 + + .equiv GCMB_MAGIC_BOOTKEY_HASHVAL, 0xBB + .equiv GCMB_MAGIC_BOOTKEY, 0xBB + .equiv GCMB_MAGIC_COUNTER2, 0xCC + .equiv GCMB_MAGIC_KEYA, 0xDD + .equiv GCMB_MAGIC_KEYB, 0xEE + .equiv GCMB_MAGIC_KEYCDERIVATION, 0xFF + + .syntax unified + + .text + + thumb_func_start GameCubeMultiBoot_Hash +GameCubeMultiBoot_Hash: @ 81DCB38 + push {r4,lr} + ldr r4, pool_HashVal + eors r3, r1 + movs r2, 0x20 + +GameCubeMultiBoot_Hash_Loop: + lsrs r3, 1 + bcc GameCubeMultiBoot_Hash_SkipEor + + eors r3, r4 + +GameCubeMultiBoot_Hash_SkipEor: + subs r2, 0x1 + bne GameCubeMultiBoot_Hash_Loop + + pop {r4,pc} + thumb_func_end GameCubeMultiBoot_Hash + + thumb_func_start GameCubeMultiBoot_Main +@ void GameCubeMultiBoot_Main(struct GameCubeMultiBoot *mb)@ +GameCubeMultiBoot_Main: @ 81DCB4C + @ If there is no interrupt handler, skip counter manipulation + ldr r1, [r0, GCMB_STRUCT_SERIAL_INTR_HANDLER] + cmp r1, 0 + beq GameCubeMultiBoot_Main_SkipCounters + @ Increment the second counter + ldrb r1, [r0, GCMB_STRUCT_COUNTER2] + adds r1, 0x1 + strb r1, [r0, GCMB_STRUCT_COUNTER2] + @ If there is nothing more to do, bail out + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] + cmp r1, MBPROGRESS_READY_TO_BOOT + beq GameCubeMultiBoot_Main_Return + @ Save current interrupt master register value + ldr r3, pool_InterruptRegs + ldrh r2, [r3, OFFSET_REG_IME - 0x200] + @ Disable all interrupts + movs r1, 0 + strh r1, [r3, OFFSET_REG_IME - 0x200] + @ Increment the first counter, if it's less than or equal to 10. + ldrb r1, [r0, GCMB_STRUCT_COUNTER1] + cmp r1, 0xA + bgt GameCubeMultiBoot_Main_SkipCounter1Inc + adds r1, 0x1 + strb r1, [r0, GCMB_STRUCT_COUNTER1] +GameCubeMultiBoot_Main_SkipCounter1Inc: + @ Load the saved interrupt master register value (re-enables interrupts if they were enabled before) + strh r2, [r3, OFFSET_REG_IME - 0x200] +GameCubeMultiBoot_Main_SkipCounters: + @ Initialise multiboot structures if required + bcs GameCubeMultiBoot_Init + @ Skip this section (check Nintendo logo) if the check has already passed + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] + cmp r1, MBPROGRESS_NONE + bne GameCubeMultiBoot_Main_SkipLogoCheck + @ Bail out if no multiboot image data has been transferred yet + ldr r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + ldr r2, [r0, GCMB_STRUCT_BASE_DEST_PTR] + subs r1, r2 + beq GameCubeMultiBoot_Main_Return2 + @ Also bail out if not enough data has been transferred + cmp r1, ROM_HEADER_NINTENDO_LOGO_END + bcc GameCubeMultiBoot_Main_Return2 + @ Compare the Nintendo logo of the transferred multiboot image header, with the one in the ROM image of the inserted cart + push {r4-r6} + movs r1, ROM_HEADER_NINTENDO_LOGO_LENGTH + adds r2, ROM_HEADER_NINTENDO_LOGO_OFFSET + ldr r4, pool_NintendoLogo +GameCubeMultiBoot_Main_LogoCmpLoop: + ldm r2!, {r5} + ldm r4!, {r6} + cmp r5, r6 + bne GameCubeMultiBoot_Main_LogoCmpEnd + subs r1, 0x4 + bne GameCubeMultiBoot_Main_LogoCmpLoop + ldm r2!, {r5} + ldm r4!, {r6} + eors r5, r6 + lsrs r5, 8 + str r2, [r0, GCMB_STRUCT_BASE_DEST_PTR] +GameCubeMultiBoot_Main_LogoCmpEnd: + pop {r4-r6} + @ Throw everything away if the logo data didn't match + bne GameCubeMultiBoot_Init + @ Logo matched, set the relevent multiboot progress bit + movs r1, MBPROGRESS_LOGO_CORRECT + strb r1, [r0, GCMB_STRUCT_MBPROGRESS] + @ XOR together KeyA and KeyB to get the initial multiboot image checksum value + ldr r1, [r0, GCMB_STRUCT_KEYA] + ldr r2, [r0, GCMB_STRUCT_KEYB] + eors r1, r2 + str r1, [r0, GCMB_STRUCT_HASH_VAL] + @ ...also use it as the initial value for the image encryption session key. Algorithm is the same as the GBA BIOS multiboot: sessionkey = (initialvalue * 0x6177614b) + 1 + ldr r2, pool_Kawa + muls r1, r2 + adds r1, 0x1 + str r1, [r0, GCMB_STRUCT_SESSION_KEY] +GameCubeMultiBoot_Main_Return: + bx lr +GameCubeMultiBoot_Main_SkipLogoCheck: + @ If this code is executed, then the logo check has passed, and the data being transferred in is encrypted. + @ Set up registers. + ldr r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + mov r12, r1 + ldr r3, [r0, GCMB_STRUCT_HASH_VAL] + push {r4-r7} + ldr r4, [r0, GCMB_STRUCT_BASE_DEST_PTR] + ldr r5, pool_Kawa + ldr r6, [r0, GCMB_STRUCT_SESSION_KEY] + ldr r7, pool_HashVal +GameCubeMultiBoot_Main_ImageDecryptHashLoop: + @ If there's no more data, break out of the loop + cmp r4, r12 + bcs GameCubeMultiBoot_Main_ImageDecryptHashEnd + @ Get the next uint32 + ldr r1, [r4] + @ Decrypt the ciphertext: plaintext = (ciphertext ^ sessionkey) + hashval + eors r1, r6 + adds r1, r3 + @ Save the current uint32 of plaintext and advance the pointer + stm r4!, {r1} + @ Advance the hashval with this uint32 of plaintext -- this is the same code as GameCubeMultiBoot_Hash. + eors r3, r1 + movs r2, 0x20 +GameCubeMultiBoot_Main_HashLoop: + lsrs r3, 1 + bcc GameCubeMultiBoot_Main_HashSkipEor + eors r3, r7 +GameCubeMultiBoot_Main_HashSkipEor: + subs r2, 0x1 + bne GameCubeMultiBoot_Main_HashLoop + @ Advance the sessionkey with the usual algorithm: sessionkey = (sessionkey * 0x6177614b) + 1 + muls r6, r5 + adds r6, 0x1 + b GameCubeMultiBoot_Main_ImageDecryptHashLoop +GameCubeMultiBoot_Main_ImageDecryptHashEnd: + @ Save the new pointer, sessionkey, hashval + str r4, [r0, GCMB_STRUCT_BASE_DEST_PTR] + str r6, [r0, GCMB_STRUCT_SESSION_KEY] + pop {r4-r7} + str r3, [r0, GCMB_STRUCT_HASH_VAL] + @ Bail out if the image size is unknown + ldrh r1, [r0, GCMB_STRUCT_IMAGE_SIZE] + cmp r1, 0 + bne GameCubeMultiBoot_Main_Return2 + @ Bail out if no image data has been transferred + ldr r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + ldr r2, [r0, GCMB_STRUCT_BASE_DEST_PTR] + cmp r1, r2 + bne GameCubeMultiBoot_Main_Return2 + @ If KeyC hasn't been generated yet, go generate it + ldr r1, [r0, GCMB_STRUCT_KEYC] + cmp r1, 0 + beq GameCubeMultiBoot_Main_GenerateKeyC + @ If the other side hasn't sent its boot key yet, bail out + ldrh r1, [r0, GCMB_STRUCT_BOOT_KEY] + cmp r1, 0 + beq GameCubeMultiBoot_Main_Return + @ Save off LR so it doesn't get clobbered by the upcoming function call + mov r12, lr + @ Generate the real boot key, which is the checksum of a hardcoded value and KeyC + movs r1, GCMB_MAGIC_BOOTKEY_HASHVAL + ldr r3, [r0, GCMB_STRUCT_KEYC] + bl GameCubeMultiBoot_Hash + ldrh r1, [r0, GCMB_STRUCT_BOOT_KEY] + @ Restore the saved LR value + mov lr, r12 + @ Compare the two boot keys (real and passed in), if they don't match then throw everything away + subs r1, r3 + bne GameCubeMultiBoot_Init + @ The two boot keys matched, tell the caller that the image is ready to boot + movs r1, MBPROGRESS_READY_TO_BOOT + strb r1, [r0, GCMB_STRUCT_MBPROGRESS] + @ Nothing more to do, return. + bx lr +GameCubeMultiBoot_Main_GenerateKeyC: + @ Save off LR so it doesn't get clobbered by the upcoming function call + mov r12, lr + @ KeyC = (SavedVCount << 24) - 1 + ldrb r1, [r0, GCMB_STRUCT_SAVEDVCOUNT] + lsls r1, 24 + subs r1, 0x1 + str r1, [r0, GCMB_STRUCT_KEYC] + @ Hash the KeyC with the multiboot image checksum to generate the KeyC derivation material to be sent to the other side of the link + bl GameCubeMultiBoot_Hash + @ Make sure the sent KeyC derivation material contains a magic value so that the other side can detect it + lsls r3, 8 + adds r3, GCMB_MAGIC_KEYCDERIVATION + @ Save off the KeyC derivation material and return to caller + str r3, [r0, GCMB_STRUCT_KEYC_DERIVATION] + bx r12 +GameCubeMultiBoot_Main_Return2: + bx lr + thumb_func_end GameCubeMultiBoot_Main + + .align 2, 0 + +pool_HashVal: .4byte 0xa1c1 + +pool_Kawa: .ascii "Kawa" @ name of BIOS developer + +pool_NintendoLogo: .4byte RomHeaderNintendoLogo + + thumb_func_start GameCubeMultiBoot_ExecuteProgram +@ void GameCubeMultiBoot_ExecuteProgram(struct GameCubeMultiBoot *mb)@ +GameCubeMultiBoot_ExecuteProgram: @ 81DCC4C + @ If there's no multiboot image ready, just return to caller + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] + cmp r1, MBPROGRESS_READY_TO_BOOT + bne GameCubeMultiBoot_ExecuteProgram_Fail + @ Disable interrupts + ldr r3, pool_InterruptRegs + movs r1, 0 + strh r1, [r3, OFFSET_REG_IME - 0x200] + @ Jump to the real entry point of the multiboot image (past the image header), in ARM mode + ldr r1, pool_MultiBootLoadAddr + adds r1, 0xC0 + bx r1 +GameCubeMultiBoot_ExecuteProgram_Fail: + bx lr + thumb_func_end GameCubeMultiBoot_ExecuteProgram + + thumb_func_start GameCubeMultiBoot_Init +@ void GameCubeMultiBoot_Init(struct GameCubeMultiBoot *mb)@ +GameCubeMultiBoot_Init: @ 81DCC60 + ldr r3, pool_InterruptRegs + +@ Save IME register. + ldrh r2, [r3, OFFSET_REG_IME - 0x200] + +@ Disable interrupts. + movs r1, 0 + strh r1, [r3, OFFSET_REG_IME - 0x200] + +@ Set the handler to the "Stop" routine. +@ Unless the first command that is received is a device reset command, the +@ "Stop" routine will be executed and no further commands will be processed. + adr r3, GcMbIntrHandler_Stop + str r3, [r0, GCMB_STRUCT_SERIAL_INTR_HANDLER] + + ldrb r3, [r0, 0x3] + push {r3} + ldrb r3, [r0, 0x1] + push {r0,r3} + + adds r3, r0, 0 + adds r3, GCMB_STRUCT_BASE_DEST_PTR + +@ clear all but the last 3 fields of the struct +GameCubeMultiBoot_Init_ClearStructLoop: + stm r0!, {r1} + cmp r0, r3 + blo GameCubeMultiBoot_Init_ClearStructLoop + + pop {r0,r3} + lsrs r3, 1 + strb r3, [r0, 0x3] + pop {r3} + strb r3, [r0, 0x1] + + ldr r3, pool_SerialRegs + +@ Turn off JOY Bus mode. + lsls r0, r3, 10 + strh r0, [r3, OFFSET_REG_RCNT - 0x120] + +@ Turn on JOY Bus mode. + movs r0, 0xC0 + lsls r0, 8 + strh r0, [r3, OFFSET_REG_RCNT - 0x120] + +@ Init JOY Bus registers. + movs r0, 0x47 + strh r0, [r3, OFFSET_REG_JOYCNT - 0x120] + strh r1, [r3, OFFSET_REG_JOYSTAT - 0x120] + + ldr r3, pool_InterruptRegs + +@ Acknowledge serial interrupt. + movs r0, INTR_FLAG_SERIAL + strh r0, [r3, OFFSET_REG_IF - 0x200] + +@ Enable serial interrupt. + ldrh r1, [r3, OFFSET_REG_IE - 0x200] + orrs r1, r0 + strh r1, [r3, OFFSET_REG_IE - 0x200] + +@ Restore IME register. + strh r2, [r3, OFFSET_REG_IME - 0x200] + + bx lr + thumb_func_end GameCubeMultiBoot_Init + + non_word_aligned_thumb_func_start GameCubeMultiBoot_HandleSerialInterrupt +@ void GameCubeMultiBoot_HandleSerialInterrupt(struct GameCubeMultiBoot *mb)@ +GameCubeMultiBoot_HandleSerialInterrupt: @ 81DCCAA + ldr r3, pool_SerialRegs + +@ Acknowledge reset/receive/send flags. + ldrh r1, [r3, OFFSET_REG_JOYCNT - 0x120] + strh r1, [r3, OFFSET_REG_JOYCNT - 0x120] + + movs r2, 0 + strb r2, [r0] + + ldr r2, [r0, GCMB_STRUCT_SERIAL_INTR_HANDLER] + cmp r2, 0 + beq GameCubeMultiBoot_HandleSerialInterruptDone + + lsrs r1, 1 @ was a device reset command received? + bcs GameCubeMultiBoot_BeginHandshake @ branch if so + + mov pc, r2 + + .align 2, 0 + +@ Zero the status and the interrupt handler pointer. +@ Commands from the GameCube will not be processed after this is executed +@ unless GameCubeMultiBoot_Init() is called again. +GcMbIntrHandler_Stop: + movs r2, 0 + strh r2, [r3, OFFSET_REG_JOYSTAT - 0x120] + +GameCubeMultiBoot_SetInterruptHandler: + str r2, [r0, GCMB_STRUCT_SERIAL_INTR_HANDLER] + +GameCubeMultiBoot_ReadVCount: + ldr r3, pool_RegDispstat + ldrh r1, [r3, OFFSET_REG_VCOUNT - OFFSET_REG_DISPSTAT] + strb r1, [r0, 0x3] + +GameCubeMultiBoot_HandleSerialInterruptDone: + bx lr + +GameCubeMultiBoot_BeginHandshake: + @ Throw away anything that got sent + ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + @ Send the game code, the other side of the link must send back the same game code + ldr r1, pool_RubyUSAGameCode + str r1, [r3, OFFSET_REG_JOY_TRANS - 0x120] + movs r1, 0x10 + strh r1, [r3, OFFSET_REG_JOYSTAT - 0x120] + @ Use the saved VCount value to provide 8 bits of entropy for KeyB + ldrb r1, [r0, GCMB_STRUCT_SAVEDVCOUNT] + strb r1, [r0, GCMB_STRUCT_KEYB + 1] + @ If a multiboot image has been transferred at least enough such that the Nintendo logo check has passed, stop everything. + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] + cmp r1, 0 + bne GcMbIntrHandler_Stop + @ Set the image destination pointers. + ldr r1, pool_MultiBootLoadAddr + str r1, [r0, GCMB_STRUCT_BASE_DEST_PTR] + str r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + @ Set the new interrupt handler. + adr r2, GcMbIntrHandler_CheckGameCodeSent + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_CheckGameCodeSent: @ 81DCCEC + lsls r1, 31 + bcc GcMbIntrHandler_Stop @ stop if send failed + bmi GameCubeMultiBoot_CheckHandshakeResponse @ branch if receive is complete + +@ If the response hasn't been fully received yet, +@ check again upon the next interrupt. + adr r2, GcMbIntrHandler_CheckHandshakeResponse + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_CheckHandshakeResponse: @ 81DCCF8 + lsrs r1, 1 @ is receive complete? + bcc GcMbIntrHandler_Stop @ stop if not + +GameCubeMultiBoot_CheckHandshakeResponse: + ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + ldr r2, pool_RubyUSAGameCode + cmp r1, r2 + bne GcMbIntrHandler_Stop @ stop if the GameCube didn't reply with the same game code + @ Use the saved VCount value to provide another 8 bits of entropy for KeyB. + ldrb r1, [r0, GCMB_STRUCT_SAVEDVCOUNT] + strb r1, [r0, GCMB_STRUCT_KEYB + 3] + adr r2, GcMbIntrHandler_ReceiveKeyA + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_ReceiveKeyA: @ 81DCD0C + lsrs r1, 1 @ is receive complete? + bcc GcMbIntrHandler_Stop @ branch if not + ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + @ make sure top 8 bits of the received value is the KeyA magic number, stop if KeyA is invalid + lsrs r2, r1, 24 + cmp r2, GCMB_MAGIC_KEYA + bne GcMbIntrHandler_Stop + @ save received KeyA + str r1, [r0, GCMB_STRUCT_KEYA] + @ use the second GameCubeMultiBoot_Main() counter as another 8 bits of entropy for KeyB + ldrb r1, [r0, GCMB_STRUCT_COUNTER2] + strb r1, [r0, GCMB_STRUCT_KEYB + 2] + movs r2, 0 + movs r3, 0 + ldr r1, [r0, GCMB_STRUCT_KEYB] + lsrs r1, 8 + @ make sure KeyB is valid (other side of the link is supposed to check KeyB too), if it's not then change the byte that was just set so it is +GameCubeMultiBoot_KeyBCheckLoop: + lsrs r1, 1 + adcs r2, r3 + cmp r1, 0 + bne GameCubeMultiBoot_KeyBCheckLoop + cmp r2, 0xE + bgt GameCubeMultiBoot_KeyBSaveNewByte + cmp r2, 0x7 + bge GameCubeMultiBoot_KeyBCheckEnd + movs r1, 0xFF +GameCubeMultiBoot_KeyBSaveNewByte: + strb r1, [r0, GCMB_STRUCT_KEYB + 2] +GameCubeMultiBoot_KeyBCheckEnd: + @ add in the KeyB magic number and send off KeyB + ldr r1, [r0, GCMB_STRUCT_KEYB] + adds r1, GCMB_MAGIC_KEYB + ldr r3, pool_SerialRegs + str r1, [r3, OFFSET_REG_JOY_TRANS - 0x120] + movs r1, 0x30 + strh r1, [r3, OFFSET_REG_JOYSTAT - 0x120] + @ set new interrupt handler + adr r2, GcMbIntrHandler_CheckKeyBSent + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_CheckKeyBSent: @ 81DCD4C + lsls r1, 31 + bcc GcMbIntrHandler_Stop @ stop if send failed + bmi GameCubeMultiBoot_CheckImageSizeResponse @ branch if receive is complete + adr r2, GcMbIntrHandler_CheckImageSizeResponse + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_CheckImageSizeResponse: @ 81DCD58 + lsrs r1, 1 @ is receive complete? + bcc GcMbIntrHandler_Stop @ branch if not +GameCubeMultiBoot_CheckImageSizeResponse: + ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + ldr r2, GameCubeMultiBoot_MaximumImageSizeUInt32s + cmp r1, r2 + bhs GcMbIntrHandler_Stop + adds r1, 0x1 + adds r1, r1 + strh r1, [r0, GCMB_STRUCT_IMAGE_SIZE] + ldrb r1, [r0, GCMB_STRUCT_MBPROGRESS] + cmp r1, 0 +GcMbIntrHandler_StopIfNotEqual: + bne GcMbIntrHandler_Stop + ldr r1, pool_MultiBootLoadAddr + str r1, [r0, GCMB_STRUCT_BASE_DEST_PTR] + str r1, [r0, GCMB_STRUCT_CUR_DEST_PTR] + adr r2, GcMbIntrHandler_CheckImageResponse + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_CheckImageResponse: @ 81DCD7C + lsrs r1, 1 @ is receive complete? + bcc GcMbIntrHandler_Stop @ branch if not + ldr r2, [r0, GCMB_STRUCT_CUR_DEST_PTR] + movs r1, 0x4 + ands r1, r2 + adds r1, 0x8 + lsls r1, 2 + strh r1, [r3, OFFSET_REG_JOYSTAT - 0x120] + @ get the recieved uint32 + ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + @ put it in the current destination pointer and advance that pointer + stm r2!, {r1} + @ save off the advanced pointer + str r2, [r0, GCMB_STRUCT_CUR_DEST_PTR] + @ decrease the image size (in uint32s) + ldrh r1, [r0, GCMB_STRUCT_IMAGE_SIZE] + subs r1, 0x1 + strh r1, [r0, GCMB_STRUCT_IMAGE_SIZE] + @ branch away if the transfer is not yet complete + bne GameCubeMultiBoot_ReadVCount + +GcMbIntrHandler_SendCounter2: + @ send counter2 with magic number + ldrb r1, [r0, GCMB_STRUCT_COUNTER2] + lsls r1, 8 + adds r1, GCMB_MAGIC_COUNTER2 + str r1, [r3, OFFSET_REG_JOY_TRANS - 0x120] + adr r2, GcMbIntrHandler_CheckCounter2Sent + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_CheckCounter2Sent: + lsls r1, 31 + +GcMbIntrHandler_StopIfSendFailed: + bcc GcMbIntrHandler_Stop @ stop if send failed + @ if KeyC derivation value has not yet been generated, send Counter2 again, otherwise, send KeyC derivation + ldr r1, [r0, GCMB_STRUCT_KEYC_DERIVATION] + cmp r1, 0 + beq GcMbIntrHandler_SendCounter2 + str r1, [r3, OFFSET_REG_JOY_TRANS - 0x120] + adr r2, GcMbIntrHandler_CheckKeyCDerivationSent + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_CheckKeyCDerivationSent: @ 81DCDB8 + lsls r1, 31 + bcc GcMbIntrHandler_StopIfSendFailed @ branch if send failed + bmi GameCubeMultiBoot_CheckBootKeyResponse @ branch if receive is complete + adr r2, GcMbIntrHandler_CheckBootKeyResponse + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_CheckBootKeyResponse: @ 81DCDC4 + lsrs r1, 1 @ is receive complete? + bcc GcMbIntrHandler_StopIfSendFailed @ branch if not + +GameCubeMultiBoot_CheckBootKeyResponse: + ldr r1, [r3, OFFSET_REG_JOY_RECV - 0x120] + @ make sure received boot key contains expected magic number, stop if not + lsrs r2, r1, 24 + cmp r2, GCMB_MAGIC_BOOTKEY + bne GcMbIntrHandler_StopIfNotEqual + @ save received bootkey to be checked in GameCubeMultiBoot_Main() + strh r1, [r0, GCMB_STRUCT_BOOT_KEY] + @ stop if anything more gets sent + adr r2, GcMbIntrHandler_StopUnconditionally + b GameCubeMultiBoot_SetInterruptHandler + + .align 2, 0 + +GcMbIntrHandler_StopUnconditionally: @ 81DCDD8 + b GcMbIntrHandler_Stop + + thumb_func_end GameCubeMultiBoot_HandleSerialInterrupt + + non_word_aligned_thumb_func_start GameCubeMultiBoot_Quit +@ void GameCubeMultiBoot_Quit()@ +GameCubeMultiBoot_Quit: @ 81DCDDA + ldr r3, pool_InterruptRegs + +@ Save IME register. + ldrh r2, [r3, OFFSET_REG_IME - 0x200] + +@ Disable interrupts. + movs r1, 0 + strh r1, [r3, OFFSET_REG_IME - 0x200] + + ldr r3, pool_SerialRegs + +@ Acknowledge all JOYCNT flags. + movs r0, 0x7 + strh r0, [r3, OFFSET_REG_JOYCNT - 0x120] + +@ Turn off JOY Bus mode. + lsls r0, r3, 10 + strh r0, [r3, OFFSET_REG_RCNT - 0x120] @ store 0x8000 + + ldr r3, pool_InterruptRegs + +@ Acknowledge serial interrupt. + movs r0, INTR_FLAG_SERIAL + strh r0, [r3, OFFSET_REG_IF - 0x200] + +@ Disable serial interrupt. + ldrh r1, [r3, OFFSET_REG_IE - 0x200] + bics r1, r0 + strh r1, [r3, OFFSET_REG_IE - 0x200] + +@ Restore IME register. + strh r2, [r3, OFFSET_REG_IME - 0x200] + + bx lr + thumb_func_end GameCubeMultiBoot_Quit + + .align 2, 0 + +GameCubeMultiBoot_MaximumImageSizeUInt32s: .4byte 0x00004000 + +pool_InterruptRegs: .4byte REG_BASE + 0x200 + +pool_SerialRegs: .4byte REG_BASE + 0x120 + +pool_RegDispstat: .4byte REG_DISPSTAT + +pool_RubyUSAGameCode: .ascii "AXVE" + +pool_MultiBootLoadAddr: .4byte EWRAM_START + + .align 2, 0 @ Don't pad with nop. diff --git a/src/libs/libisagbprn.c b/src/libs/libisagbprn.c new file mode 100755 index 000000000..e0e979e95 --- /dev/null +++ b/src/libs/libisagbprn.c @@ -0,0 +1,177 @@ +#include <stdarg.h> +#include <stdio.h> +#include "gba/gba.h" +#include "config.h" + +#define AGB_PRINT_FLUSH_ADDR 0x9FE209D +#define AGB_PRINT_STRUCT_ADDR 0x9FE20F8 +#define AGB_PRINT_PROTECT_ADDR 0x9FE2FFE +#define WSCNT_DATA (WAITCNT_PHI_OUT_16MHZ | WAITCNT_WS0_S_2 | WAITCNT_WS0_N_4) + +// originally for auto no$gba support, the string "no$gba" should be at this address, +// the user needs to read this string out as the memory viewer won't show it. +#define NOCASHGBAIDADDR 0x4FFFA00 +#define NOCASHGBAPRINTADDR1 0x4FFFA10 // automatically adds a newline after the string has finished +#define NOCASHGBAPRINTADDR2 0x4FFFA14 // does not automatically add the newline. by default, NOCASHGBAPRINTADDR2 is used. this is used to keep strings consistent between no$gba and VBA-RR, but a user can choose to forgo this. + +struct AGBPrintStruct +{ + u16 m_nRequest; + u16 m_nBank; + u16 m_nGet; + u16 m_nPut; +}; + +typedef void (*LPFN_PRINT_FLUSH)(void); + +#ifndef NDEBUG + +void AGBPrintFlush1Block(void); + +void AGBPrintInit(void) +{ + volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 *pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; + u16 nOldWSCNT = *pWSCNT; + *pWSCNT = WSCNT_DATA; + *pProtect = 0x20; + pPrint->m_nRequest = pPrint->m_nGet = pPrint->m_nPut = 0; + pPrint->m_nBank = 0xFD; + *pProtect = 0; + *pWSCNT = nOldWSCNT; +} + +static void AGBPutcInternal(const char cChr) +{ + volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + u16 *pPrintBuf = (u16 *)(0x8000000 + (pPrint->m_nBank << 16)); + u16 *pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; + u16 nData = pPrintBuf[pPrint->m_nPut / 2]; + *pProtect = 0x20; + nData = (pPrint->m_nPut & 1) ? (nData & 0xFF) | (cChr << 8) : (nData & 0xFF00) | cChr; + pPrintBuf[pPrint->m_nPut / 2] = nData; + pPrint->m_nPut++; + *pProtect = 0; +} + +void AGBPutc(const char cChr) +{ + u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 nOldWSCNT = *pWSCNT; + volatile struct AGBPrintStruct *pPrint; + *pWSCNT = WSCNT_DATA; + AGBPutcInternal(cChr); + *pWSCNT = nOldWSCNT; + pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + if (pPrint->m_nPut == ((pPrint->m_nGet - 1) & 0xFFFF)) + AGBPrintFlush1Block(); +} + +void AGBPrint(const char *pBuf) +{ + volatile struct AGBPrintStruct *pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + u16 *pWSCNT = (u16 *)REG_ADDR_WAITCNT; + u16 nOldWSCNT = *pWSCNT; + *pWSCNT = WSCNT_DATA; + while (*pBuf) + { + AGBPutc(*pBuf); + pBuf++; + } + *pWSCNT = nOldWSCNT; +} + +void AGBPrintf(const char *pBuf, ...) +{ + char bufPrint[0x100]; + va_list vArgv; + va_start(vArgv, pBuf); + vsprintf(bufPrint, pBuf, vArgv); + va_end(vArgv); + AGBPrint(bufPrint); +} + +static void AGBPrintTransferDataInternal(u32 bAllData) +{ + LPFN_PRINT_FLUSH lpfnFuncFlush; + u16 *pIME; + u16 nIME; + u16 *pWSCNT; + u16 nOldWSCNT; + u16 *pProtect; + volatile struct AGBPrintStruct *pPrint; + + pProtect = (u16 *)AGB_PRINT_PROTECT_ADDR; + pPrint = (struct AGBPrintStruct *)AGB_PRINT_STRUCT_ADDR; + lpfnFuncFlush = (LPFN_PRINT_FLUSH)AGB_PRINT_FLUSH_ADDR; + pIME = (u16 *)REG_ADDR_IME; + nIME = *pIME; + pWSCNT = (u16 *)REG_ADDR_WAITCNT; + nOldWSCNT = *pWSCNT; + *pIME = nIME & ~1; + *pWSCNT = WSCNT_DATA; + + if (bAllData) + { + while (pPrint->m_nPut != pPrint->m_nGet) + { + *pProtect = 0x20; + lpfnFuncFlush(); + *pProtect = 0; + } + } + else if (pPrint->m_nPut != pPrint->m_nGet) + { + *pProtect = 0x20; + lpfnFuncFlush(); + *pProtect = 0; + } + + *pWSCNT = nOldWSCNT; + *pIME = nIME; +} + +void AGBPrintFlush1Block(void) +{ + AGBPrintTransferDataInternal(FALSE); +} + +void AGBPrintFlush(void) +{ + AGBPrintTransferDataInternal(TRUE); +} + +void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram) +{ + if (nStopProgram) + { + AGBPrintf("ASSERTION FAILED FILE=[%s] LINE=[%d] EXP=[%s] \n", pFile, nLine, pExpression); + AGBPrintFlush(); + asm(".hword 0xEFFF"); + } + else + { + AGBPrintf("WARING FILE=[%s] LINE=[%d] EXP=[%s] \n", pFile, nLine, pExpression); + } +} + +// no$gba print functions, uncomment to use +/* +void NoCashGBAPrint(const char *pBuf) +{ + *(volatile u32*)NOCASHGBAPRINTADDR2 = (u32)pBuf; +} + +void NoCashGBAPrintf(const char *pBuf, ...) +{ + char bufPrint[0x100]; + va_list vArgv; + va_start(vArgv, pBuf); + vsprintf(bufPrint, pBuf, vArgv); + va_end(vArgv); + NoCashGBAPrint(bufPrint); +} +*/ + +#endif diff --git a/src/libs/m4a_1.s b/src/libs/m4a_1.s new file mode 100644 index 000000000..be8b44488 --- /dev/null +++ b/src/libs/m4a_1.s @@ -0,0 +1,1911 @@ + .include "include/macros.inc" + .include "constants/gba_constants.inc" + .include "constants/m4a_constants.inc" + + .syntax unified + + .lcomm gUnknown_030007B8, 0x770 + + .text + + thumb_func_start umul3232H32 +umul3232H32: + adr r2, __umul3232H32 + bx r2 + .arm +__umul3232H32: + umull r2, r3, r0, r1 + add r0, r3, 0 + bx lr + thumb_func_end umul3232H32 + + thumb_func_start SoundMain +SoundMain: + ldr r0, lt_SOUND_INFO_PTR + ldr r0, [r0] + ldr r2, lt_ID_NUMBER + ldr r3, [r0, o_SoundInfo_ident] + cmp r2, r3 + beq SoundMain_1 + bx lr @ Exit the function if ident doesn't match ID_NUMBER. +SoundMain_1: + adds r3, 1 + str r3, [r0, o_SoundInfo_ident] + push {r4-r7,lr} + mov r1, r8 + mov r2, r9 + mov r3, r10 + mov r4, r11 + push {r0-r4} + sub sp, 0x18 + ldrb r1, [r0, o_SoundInfo_maxLines] + cmp r1, 0 @ if maxLines is 0, there is no maximum + beq SoundMain_3 + ldr r2, lt_REG_VCOUNT + ldrb r2, [r2] + cmp r2, VCOUNT_VBLANK + bhs SoundMain_2 + adds r2, TOTAL_SCANLINES +SoundMain_2: + adds r1, r2 +SoundMain_3: + str r1, [sp, 0x14] + ldr r3, [r0, o_SoundInfo_func] + cmp r3, 0 + beq SoundMain_4 + ldr r0, [r0, o_SoundInfo_intp] + bl _081DD25E + ldr r0, [sp, 0x18] +SoundMain_4: + ldr r3, [r0, o_SoundInfo_CgbSound] + bl _081DD25E + ldr r0, [sp, 0x18] + ldr r3, [r0, o_SoundInfo_pcmSamplesPerVBlank] + mov r8, r3 + ldr r5, lt_o_SoundInfo_pcmBuffer + adds r5, r0 + ldrb r4, [r0, o_SoundInfo_pcmDmaCounter] + subs r7, r4, 1 + bls SoundMain_5 + ldrb r1, [r0, o_SoundInfo_pcmDmaPeriod] + subs r1, r7 + mov r2, r8 + muls r2, r1 + adds r5, r2 +SoundMain_5: + str r5, [sp, 0x8] + ldr r6, lt_PCM_DMA_BUF_SIZE + ldr r3, lt_SoundMainRAM_Buffer + bx r3 + + .align 2, 0 +lt_SOUND_INFO_PTR: .word SOUND_INFO_PTR +lt_ID_NUMBER: .word ID_NUMBER +lt_SoundMainRAM_Buffer: .word SoundMainRAM_Buffer + 1 +lt_REG_VCOUNT: .word REG_VCOUNT +lt_o_SoundInfo_pcmBuffer: .word o_SoundInfo_pcmBuffer +lt_PCM_DMA_BUF_SIZE: .word PCM_DMA_BUF_SIZE + thumb_func_end SoundMain + + thumb_func_start SoundMainRAM +SoundMainRAM: + ldrb r3, [r0, o_SoundInfo_reverb] + cmp r3, 0 + beq SoundMainRAM_NoReverb + adr r1, SoundMainRAM_Reverb + bx r1 + .arm +SoundMainRAM_Reverb: + cmp r4, 0x2 + addeq r7, r0, o_SoundInfo_pcmBuffer + addne r7, r5, r8 + mov r4, r8 +_081DCEC4: + ldrsb r0, [r5, r6] + ldrsb r1, [r5] + add r0, r0, r1 + ldrsb r1, [r7, r6] + add r0, r0, r1 + ldrsb r1, [r7], 0x1 + add r0, r0, r1 + mul r1, r0, r3 + mov r0, r1, asr 9 + tst r0, 0x80 + addne r0, r0, 0x1 + strb r0, [r5, r6] + strb r0, [r5], 0x1 + subs r4, r4, 0x1 + bgt _081DCEC4 + adr r0, _081DCF36 + 1 @ plus 1 because THUMB + bx r0 + .thumb +SoundMainRAM_NoReverb: + movs r0, 0 + mov r1, r8 + adds r6, r5 + lsrs r1, 3 + bcc SoundMainRAM_NoReverb_Ok + stm r5!, {r0} + stm r6!, {r0} +SoundMainRAM_NoReverb_Ok: + lsrs r1, 1 + bcc SoundMainRAM_NoReverb_Loop + stm r5!, {r0} + stm r6!, {r0} + stm r5!, {r0} + stm r6!, {r0} +SoundMainRAM_NoReverb_Loop: + stm r5!, {r0} + stm r6!, {r0} + stm r5!, {r0} + stm r6!, {r0} + stm r5!, {r0} + stm r6!, {r0} + stm r5!, {r0} + stm r6!, {r0} + subs r1, 1 + bgt SoundMainRAM_NoReverb_Loop +_081DCF36: + ldr r4, [sp, 0x18] + ldr r0, [r4, o_SoundInfo_divFreq] + mov r12, r0 + ldrb r0, [r4, o_SoundInfo_maxChans] + adds r4, o_SoundInfo_chans + +SoundMainRAM_ChanLoop: + str r0, [sp, 0x4] + ldr r3, [r4, o_SoundChannel_wav] + ldr r0, [sp, 0x14] + cmp r0, 0 + beq _081DCF60 + ldr r1, =REG_VCOUNT + ldrb r1, [r1] + cmp r1, VCOUNT_VBLANK + bhs _081DCF54 + adds r1, TOTAL_SCANLINES +_081DCF54: + cmp r1, r0 + blo _081DCF60 + b _081DD24A + + .pool + +_081DCF60: + ldrb r6, [r4, o_SoundChannel_status] + movs r0, 0xC7 + tst r0, r6 + bne _081DCF6A + b _081DD240 +_081DCF6A: + movs r0, 0x80 + tst r0, r6 + beq _081DCFA0 + movs r0, 0x40 + tst r0, r6 + bne _081DCFB0 + movs r6, 0x3 + strb r6, [r4, o_SoundChannel_status] + adds r0, r3, 0 + adds r0, 0x10 + ldr r1, [r4, o_SoundChannel_ct] + adds r0, r1 + str r0, [r4, o_SoundChannel_cp] + ldr r0, [r3, 0xC] + subs r0, r1 + str r0, [r4, o_SoundChannel_ct] + movs r5, 0 + strb r5, [r4, o_SoundChannel_ev] + str r5, [r4, o_SoundChannel_fw] + ldrb r2, [r3, 0x3] + movs r0, 0xC0 + tst r0, r2 + beq _081DCFF8 + movs r0, 0x10 + orrs r6, r0 + strb r6, [r4, o_SoundChannel_status] + b _081DCFF8 +_081DCFA0: + ldrb r5, [r4, o_SoundChannel_ev] + movs r0, 0x4 + tst r0, r6 + beq _081DCFB6 + ldrb r0, [r4, o_SoundChannel_iel] + subs r0, 1 + strb r0, [r4, o_SoundChannel_iel] + bhi _081DD006 +_081DCFB0: + movs r0, 0 + strb r0, [r4, o_SoundChannel_status] + b _081DD240 +_081DCFB6: + movs r0, 0x40 + tst r0, r6 + beq _081DCFD6 + ldrb r0, [r4, o_SoundChannel_release] + muls r5, r0 + lsrs r5, 8 + ldrb r0, [r4, o_SoundChannel_iev] + cmp r5, r0 + bhi _081DD006 +_081DCFC8: + ldrb r5, [r4, o_SoundChannel_iev] + cmp r5, 0 + beq _081DCFB0 + movs r0, 0x4 + orrs r6, r0 + strb r6, [r4, o_SoundChannel_status] + b _081DD006 +_081DCFD6: + movs r2, 0x3 + ands r2, r6 + cmp r2, 0x2 + bne _081DCFF4 + ldrb r0, [r4, o_SoundChannel_decay] + muls r5, r0 + lsrs r5, 8 + ldrb r0, [r4, o_SoundChannel_sustain] + cmp r5, r0 + bhi _081DD006 + adds r5, r0, 0 + beq _081DCFC8 + subs r6, 0x1 + strb r6, [r4, o_SoundChannel_status] + b _081DD006 +_081DCFF4: + cmp r2, 0x3 + bne _081DD006 +_081DCFF8: + ldrb r0, [r4, o_SoundChannel_attack] + adds r5, r0 + cmp r5, 0xFF + bcc _081DD006 + movs r5, 0xFF + subs r6, 0x1 + strb r6, [r4, o_SoundChannel_status] +_081DD006: + strb r5, [r4, o_SoundChannel_ev] + ldr r0, [sp, 0x18] + ldrb r0, [r0, o_SoundChannel_release] + adds r0, 0x1 + muls r0, r5 + lsrs r5, r0, 4 + ldrb r0, [r4, o_SoundChannel_rightVolume] + muls r0, r5 + lsrs r0, 8 + strb r0, [r4, o_SoundChannel_er] + ldrb r0, [r4, o_SoundChannel_leftVolume] + muls r0, r5 + lsrs r0, 8 + strb r0, [r4, o_SoundChannel_el] + movs r0, 0x10 + ands r0, r6 + str r0, [sp, 0x10] + beq _081DD03A + adds r0, r3, 0 + adds r0, 0x10 + ldr r1, [r3, 0x8] + adds r0, r1 + str r0, [sp, 0xC] + ldr r0, [r3, 0xC] + subs r0, r1 + str r0, [sp, 0x10] +_081DD03A: + ldr r5, [sp, 0x8] + ldr r2, [r4, o_SoundChannel_ct] + ldr r3, [r4, o_SoundChannel_cp] + adr r0, _081DD044 + bx r0 + .arm +_081DD044: + str r8, [sp] + ldr r9, [r4, o_SoundChannel_fw] + ldrb r10, [r4, o_SoundChannel_er] + ldrb r11, [r4, o_SoundChannel_el] + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x30 + beq _081DD068 + bl sub_81DD264 + b _081DD228 +_081DD068: + mov r10, r10, lsl 16 + mov r11, r11, lsl 16 + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x8 + beq _081DD19C +_081DD07C: + cmp r2, 0x4 + ble _081DD0EC + subs r2, r2, r8 + movgt r9, 0 + bgt _081DD0A8 + mov r9, r8 + add r2, r2, r8 + sub r8, r2, 0x4 + sub r9, r9, r8 + ands r2, r2, 0x3 + moveq r2, 0x4 +_081DD0A8: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD0B0: + ldrsb r0, [r3], 0x1 + mul r1, r10, r0 + bic r1, r1, 0xFF0000 + add r6, r1, r6, ror 8 + mul r1, r11, r0 + bic r1, r1, 0xFF0000 + add r7, r1, r7, ror 8 + adds r5, r5, 0x40000000 + bcc _081DD0B0 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + subs r8, r8, 0x4 + bgt _081DD0A8 + adds r8, r8, r9 + beq _081DD22C +_081DD0EC: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD0F4: + ldrsb r0, [r3], 0x1 + mul r1, r10, r0 + bic r1, r1, 0xFF0000 + add r6, r1, r6, ror 8 + mul r1, r11, r0 + bic r1, r1, 0xFF0000 + add r7, r1, r7, ror 8 + subs r2, r2, 0x1 + beq _081DD164 +_081DD118: + adds r5, r5, 0x40000000 + bcc _081DD0F4 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + subs r8, r8, 0x4 + bgt _081DD07C + b _081DD22C +_081DD134: + ldr r0, [sp, 0x18] + cmp r0, 0 + beq _081DD158 + ldr r3, [sp, 0x14] + rsb lr, r2, 0 +_081DD148: + adds r2, r0, r2 + bgt _081DD1FC + sub lr, lr, r0 + b _081DD148 +_081DD158: + pop {r4,r12} + mov r2, 0 + b _081DD174 +_081DD164: + ldr r2, [sp, 0x10] + cmp r2, 0 + ldrne r3, [sp, 0xC] + bne _081DD118 +_081DD174: + strb r2, [r4, o_SoundChannel_status] + mov r0, r5, lsr 30 + bic r5, r5, 0xC0000000 + rsb r0, r0, 0x3 + mov r0, r0, lsl 3 + mov r6, r6, ror r0 + mov r7, r7, ror r0 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + b _081DD234 +_081DD19C: + push {r4,r12} + ldr r1, [r4, o_SoundChannel_freq] + mul r4, r12, r1 + ldrsb r0, [r3] + ldrsb r1, [r3, 0x1]! + sub r1, r1, r0 +_081DD1B4: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD1BC: + mul lr, r9, r1 + add lr, r0, lr, asr 23 + mul r12, r10, lr + bic r12, r12, 0xFF0000 + add r6, r12, r6, ror 8 + mul r12, r11, lr + bic r12, r12, 0xFF0000 + add r7, r12, r7, ror 8 + add r9, r9, r4 + movs lr, r9, lsr 23 + beq _081DD208 + bic r9, r9, 0x3F800000 + subs r2, r2, lr + ble _081DD134 + subs lr, lr, 0x1 + addeq r0, r0, r1 +_081DD1FC: + ldrsbne r0, [r3, lr]! + ldrsb r1, [r3, 0x1]! + sub r1, r1, r0 +_081DD208: + adds r5, r5, 0x40000000 + bcc _081DD1BC + str r7, [r5, 0x630] + str r6, [r5], 0x4 + subs r8, r8, 0x4 + bgt _081DD1B4 + sub r3, r3, 0x1 + pop {r4,r12} +_081DD228: + str r9, [r4, o_SoundChannel_fw] +_081DD22C: + str r2, [r4, o_SoundChannel_ct] + str r3, [r4, o_SoundChannel_cp] +_081DD234: + ldr r8, [sp] + add r0, pc, 0x1 + bx r0 + .thumb +_081DD240: + ldr r0, [sp, 0x4] + subs r0, 1 + ble _081DD24A + adds r4, SoundChannel_size + b SoundMainRAM_ChanLoop +_081DD24A: + ldr r0, [sp, 0x18] + ldr r3, =ID_NUMBER + str r3, [r0] + add sp, 0x1C + pop {r0-r7} + mov r8, r0 + mov r9, r1 + mov r10, r2 + mov r11, r3 + pop {r3} +_081DD25E: + bx r3 + .pool + thumb_func_end SoundMainRAM + + arm_func_start sub_81DD264 +sub_81DD264: + ldr r6, [r4, o_SoundChannel_wav] + ldrb r0, [r4, o_SoundChannel_status] + tst r0, 0x20 + bne _081DD2B4 + orr r0, r0, 0x20 + strb r0, [r4, o_SoundChannel_status] + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x10 + beq _081DD29C + ldr r1, [r6, 0xC] + add r1, r1, r6, lsl 1 + add r1, r1, 0x20 + sub r3, r1, r3 + str r3, [r4, o_SoundChannel_cp] +_081DD29C: + ldrh r0, [r6] + cmp r0, 0 + beq _081DD2B4 + sub r3, r3, r6 + sub r3, r3, 0x10 + str r3, [r4, o_SoundChannel_cp] +_081DD2B4: + push {r8,r12,lr} + mov r10, r10, lsl 16 + mov r11, r11, lsl 16 + ldr r1, [r4, o_SoundChannel_freq] + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x8 + movne r8, 0x800000 + muleq r8, r12, r1 + ldrh r0, [r6] + cmp r0, 0 + beq _081DD468 + mov r0, 0xFF000000 + str r0, [r4, o_SoundChannel_xpi] + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x10 + bne _081DD3C0 + bl sub_81DD520 + mov r0, r1 + add r3, r3, 0x1 + bl sub_81DD520 + sub r1, r1, r0 +_081DD308: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD310: + mul lr, r9, r1 + add lr, r0, lr, asr 23 + mul r12, r10, lr + bic r12, r12, 0xFF0000 + add r6, r12, r6, ror 8 + mul r12, r11, lr + bic r12, r12, 0xFF0000 + add r7, r12, r7, ror 8 + add r9, r9, r8 + movs lr, r9, lsr 23 + beq _081DD370 + bic r9, r9, 0x3F800000 + subs r2, r2, lr + ble _081DD398 + subs lr, lr, 0x1 + bne _081DD358 + add r0, r0, r1 + b _081DD364 +_081DD358: + add r3, r3, lr + bl sub_81DD520 + mov r0, r1 +_081DD364: + add r3, r3, 0x1 + bl sub_81DD520 + sub r1, r1, r0 +_081DD370: + adds r5, r5, 0x40000000 + bcc _081DD310 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + ldr r6, [sp] + subs r6, r6, 0x4 + str r6, [sp] + bgt _081DD308 + sub r3, r3, 0x1 + b _081DD4F0 +_081DD398: + ldr r0, [sp, 0x1C] + cmp r0, 0 + beq _081DD4F4 + ldr r3, [r4, o_SoundChannel_wav] + ldr r3, [r3, 0x8] + rsb lr, r2, 0 +_081DD3B0: + adds r2, r2, r0 + bgt _081DD358 + sub lr, lr, r0 + b _081DD3B0 +_081DD3C0: + sub r3, r3, 0x1 + bl sub_81DD520 + mov r0, r1 + sub r3, r3, 0x1 + bl sub_81DD520 + sub r1, r1, r0 +_081DD3D8: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD3E0: + mul lr, r9, r1 + add lr, r0, lr, asr 23 + mul r12, r10, lr + bic r12, r12, 0xFF0000 + add r6, r12, r6, ror 8 + mul r12, r11, lr + bic r12, r12, 0xFF0000 + add r7, r12, r7, ror 8 + add r9, r9, r8 + movs lr, r9, lsr 23 + beq _081DD440 + bic r9, r9, 0x3F800000 + subs r2, r2, lr + ble _081DD4F4 + subs lr, lr, 0x1 + bne _081DD428 + add r0, r0, r1 + b _081DD434 +_081DD428: + sub r3, r3, lr + bl sub_81DD520 + mov r0, r1 +_081DD434: + sub r3, r3, 0x1 + bl sub_81DD520 + sub r1, r1, r0 +_081DD440: + adds r5, r5, 0x40000000 + bcc _081DD3E0 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + ldr r6, [sp] + subs r6, r6, 0x4 + str r6, [sp] + bgt _081DD3D8 + add r3, r3, 0x2 + b _081DD4F0 +_081DD468: + ldrb r0, [r4, o_SoundChannel_type] + tst r0, 0x10 + beq _081DD4F0 + ldrsb r0, [r3, -0x1]! + ldrsb r1, [r3, -0x1] + sub r1, r1, r0 +_081DD480: + ldr r6, [r5] + ldr r7, [r5, 0x630] +_081DD488: + mul lr, r9, r1 + add lr, r0, lr, asr 23 + mul r12, r10, lr + bic r12, r12, 0xFF0000 + add r6, r12, r6, ror 8 + mul r12, r11, lr + bic r12, r12, 0xFF0000 + add r7, r12, r7, ror 8 + add r9, r9, r8 + movs lr, r9, lsr 23 + beq _081DD4CC + bic r9, r9, 0x3F800000 + subs r2, r2, lr + ble _081DD4F4 + ldrsb r0, [r3, -lr]! + ldrsb r1, [r3, -0x1] + sub r1, r1, r0 +_081DD4CC: + adds r5, r5, 0x40000000 + bcc _081DD488 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + ldr r6, [sp] + subs r6, r6, 0x4 + str r6, [sp] + bgt _081DD480 + add r3, r3, 0x1 +_081DD4F0: + pop {r8,r12,pc} +_081DD4F4: + mov r2, 0 + strb r2, [r4, o_SoundChannel_status] + mov r0, r5, lsr 30 + bic r5, r5, 0xC0000000 + rsb r0, r0, 0x3 + mov r0, r0, lsl 3 + mov r6, r6, ror r0 + mov r7, r7, ror r0 + str r7, [r5, 0x630] + str r6, [r5], 0x4 + pop {r8,r12,pc} + arm_func_end sub_81DD264 + + arm_func_start sub_81DD520 +sub_81DD520: + push {r0,r2,r5-r7,lr} + mov r0, r3, lsr 6 + ldr r1, [r4, o_SoundChannel_xpi] + cmp r0, r1 + beq _081DD594 + str r0, [r4, o_SoundChannel_xpi] + mov r1, 0x21 + mul r2, r1, r0 + ldr r1, [r4, o_SoundChannel_wav] + add r2, r2, r1 + add r2, r2, 0x10 + ldr r5, =gUnknown_030007B8 + ldr r6, =gDeltaEncodingTable + mov r7, 0x40 + ldrb lr, [r2], 1 + strb lr, [r5], 1 + ldrb r1, [r2], 1 + b _081DD57C +_081DD568: + ldrb r1, [r2], 1 + mov r0, r1, lsr 4 + ldrsb r0, [r6, r0] + add lr, lr, r0 + strb lr, [r5], 1 +_081DD57C: + and r0, r1, 0xF + ldrsb r0, [r6, r0] + add lr, lr, r0 + strb lr, [r5], 1 + subs r7, r7, 2 + bgt _081DD568 +_081DD594: + ldr r5, =gUnknown_030007B8 + and r0, r3, 0x3F + ldrsb r1, [r5, r0] + pop {r0,r2,r5-r7,pc} + .pool + arm_func_end sub_81DD520 + + thumb_func_start SoundMainBTM +SoundMainBTM: + mov r12, r4 + movs r1, 0 + movs r2, 0 + movs r3, 0 + movs r4, 0 + stm r0!, {r1-r4} + stm r0!, {r1-r4} + stm r0!, {r1-r4} + stm r0!, {r1-r4} + mov r4, r12 + bx lr + thumb_func_end SoundMainBTM + + thumb_func_start RealClearChain +RealClearChain: + ldr r3, [r0, 0x2C] + cmp r3, 0 + beq _081DD5E2 + ldr r1, [r0, 0x34] + ldr r2, [r0, 0x30] + cmp r2, 0 + beq _081DD5D6 + str r1, [r2, 0x34] + b _081DD5D8 +_081DD5D6: + str r1, [r3, 0x20] +_081DD5D8: + cmp r1, 0 + beq _081DD5DE + str r2, [r1, 0x30] +_081DD5DE: + movs r1, 0 + str r1, [r0, 0x2C] +_081DD5E2: + bx lr + thumb_func_end RealClearChain + + thumb_func_start ply_fine +ply_fine: + push {r4,r5,lr} + adds r5, r1, 0 + ldr r4, [r5, o_MusicPlayerTrack_chan] + cmp r4, 0 + beq ply_fine_done +ply_fine_loop: + ldrb r1, [r4] + movs r0, 0xC7 + tst r0, r1 + beq ply_fine_ok + movs r0, 0x40 + orrs r1, r0 + strb r1, [r4] +ply_fine_ok: + adds r0, r4, 0 + bl RealClearChain + ldr r4, [r4, 0x34] + cmp r4, 0 + bne ply_fine_loop +ply_fine_done: + movs r0, 0 + strb r0, [r5] + pop {r4,r5} + pop {r0} + bx r0 + thumb_func_end ply_fine + + thumb_func_start MPlayJumpTableCopy +MPlayJumpTableCopy: + mov r12, lr + movs r1, 0x24 + ldr r2, lt_MPlayJumpTableTemplate +MPlayJumpTableCopy_Loop: + ldr r3, [r2] + bl chk_adr_r2 + stm r0!, {r3} + adds r2, 0x4 + subs r1, 0x1 + bgt MPlayJumpTableCopy_Loop + bx r12 + thumb_func_end MPlayJumpTableCopy + + .align 2, 0 + .thumb_func +ldrb_r3_r2: + ldrb r3, [r2] + +@ This attempts to protect against reading anything from the BIOS ROM +@ besides the jump table template. +@ It assumes that the jump table template is located at the end of the ROM. + .thumb_func +chk_adr_r2: + push {r0} + lsrs r0, r2, 25 + bne chk_adr_r2_done @ if adr >= 0x2000000 (i.e. not in BIOS ROM), accept it + ldr r0, lt_MPlayJumpTableTemplate + cmp r2, r0 + blo chk_adr_r2_reject @ if adr < gMPlayJumpTableTemplate, reject it + lsrs r0, r2, 14 + beq chk_adr_r2_done @ if adr < 0x40000 (i.e. in BIOS ROM), accept it +chk_adr_r2_reject: + movs r3, 0 +chk_adr_r2_done: + pop {r0} + bx lr + + .align 2, 0 +lt_MPlayJumpTableTemplate: .word gMPlayJumpTableTemplate + + thumb_func_start ld_r3_tp_adr_i +ld_r3_tp_adr_i: + ldr r2, [r1, 0x40] +_081DD64A: + adds r3, r2, 0x1 + str r3, [r1, 0x40] + ldrb r3, [r2] + b chk_adr_r2 + thumb_func_end ld_r3_tp_adr_i + + thumb_func_start ply_goto +ply_goto: + push {lr} +ply_goto_1: + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r0, [r2, 0x3] + lsls r0, 8 + ldrb r3, [r2, 0x2] + orrs r0, r3 + lsls r0, 8 + ldrb r3, [r2, 0x1] + orrs r0, r3 + lsls r0, 8 + bl ldrb_r3_r2 + orrs r0, r3 + str r0, [r1, o_MusicPlayerTrack_cmdPtr] + pop {r0} + bx r0 + thumb_func_end ply_goto + + thumb_func_start ply_patt +ply_patt: + ldrb r2, [r1, o_MusicPlayerTrack_patternLevel] + cmp r2, 3 + bhs ply_patt_done + lsls r2, 2 + adds r3, r1, r2 + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + adds r2, 0x4 + str r2, [r3, o_MusicPlayerTrack_patternStack] + ldrb r2, [r1, o_MusicPlayerTrack_patternLevel] + adds r2, 1 + strb r2, [r1, o_MusicPlayerTrack_patternLevel] + b ply_goto +ply_patt_done: + b ply_fine + thumb_func_end ply_patt + + thumb_func_start ply_pend +ply_pend: + ldrb r2, [r1, o_MusicPlayerTrack_patternLevel] + cmp r2, 0 + beq ply_pend_done + subs r2, 1 + strb r2, [r1, o_MusicPlayerTrack_patternLevel] + lsls r2, 2 + adds r3, r1, r2 + ldr r2, [r3, o_MusicPlayerTrack_patternStack] + str r2, [r1, o_MusicPlayerTrack_cmdPtr] +ply_pend_done: + bx lr + thumb_func_end ply_pend + + thumb_func_start ply_rept +ply_rept: + push {lr} + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + cmp r3, 0 + bne ply_rept_1 + adds r2, 1 + str r2, [r1, o_MusicPlayerTrack_cmdPtr] + b ply_goto_1 +ply_rept_1: + ldrb r3, [r1, o_MusicPlayerTrack_repN] + adds r3, 1 + strb r3, [r1, o_MusicPlayerTrack_repN] + mov r12, r3 + bl ld_r3_tp_adr_i + cmp r12, r3 + bhs ply_rept_2 + b ply_goto_1 +ply_rept_2: + movs r3, 0 + strb r3, [r1, o_MusicPlayerTrack_repN] + adds r2, 5 + str r2, [r1, o_MusicPlayerTrack_cmdPtr] + pop {r0} + bx r0 + thumb_func_end ply_rept + + thumb_func_start ply_prio +ply_prio: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_priority] + bx r12 + thumb_func_end ply_prio + + thumb_func_start ply_tempo +ply_tempo: + mov r12, lr + bl ld_r3_tp_adr_i + lsls r3, 1 + strh r3, [r0, o_MusicPlayerInfo_tempoD] + ldrh r2, [r0, o_MusicPlayerInfo_tempoU] + muls r3, r2 + lsrs r3, 8 + strh r3, [r0, o_MusicPlayerInfo_tempoI] + bx r12 + thumb_func_end ply_tempo + + thumb_func_start ply_keysh +ply_keysh: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_keyShift] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xC + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_keysh + + thumb_func_start ply_voice +ply_voice: + mov r12, lr + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + adds r2, 1 + str r2, [r1, o_MusicPlayerTrack_cmdPtr] + lsls r2, r3, 1 + adds r2, r3 + lsls r2, 2 + ldr r3, [r0, o_MusicPlayerInfo_tone] + adds r2, r3 + ldr r3, [r2] + bl chk_adr_r2 + str r3, [r1, o_MusicPlayerTrack_ToneData_type] + ldr r3, [r2, 0x4] + bl chk_adr_r2 + str r3, [r1, o_MusicPlayerTrack_ToneData_wav] + ldr r3, [r2, 0x8] + bl chk_adr_r2 + str r3, [r1, o_MusicPlayerTrack_ToneData_attack] + bx r12 + thumb_func_end ply_voice + + thumb_func_start ply_vol +ply_vol: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_vol] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0x3 + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_vol + + thumb_func_start ply_pan +ply_pan: + mov r12, lr + bl ld_r3_tp_adr_i + subs r3, 0x40 + strb r3, [r1, o_MusicPlayerTrack_pan] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0x3 + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_pan + + thumb_func_start ply_bend +ply_bend: + mov r12, lr + bl ld_r3_tp_adr_i + subs r3, 0x40 + strb r3, [r1, o_MusicPlayerTrack_bend] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xC + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_bend + + thumb_func_start ply_bendr +ply_bendr: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_bendRange] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xC + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_bendr + + thumb_func_start ply_lfodl +ply_lfodl: + mov r12, lr + bl ld_r3_tp_adr_i + strb r3, [r1, o_MusicPlayerTrack_lfoDelay] + bx r12 + thumb_func_end ply_lfodl + + thumb_func_start ply_modt +ply_modt: + mov r12, lr + bl ld_r3_tp_adr_i + ldrb r0, [r1, o_MusicPlayerTrack_modT] + cmp r0, r3 + beq _081DD7AA + strb r3, [r1, o_MusicPlayerTrack_modT] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xF + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] +_081DD7AA: + bx r12 + thumb_func_end ply_modt + + thumb_func_start ply_tune +ply_tune: + mov r12, lr + bl ld_r3_tp_adr_i + subs r3, 0x40 + strb r3, [r1, o_MusicPlayerTrack_tune] + ldrb r3, [r1, o_MusicPlayerTrack_flags] + movs r2, 0xC + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx r12 + thumb_func_end ply_tune + + thumb_func_start ply_port +ply_port: + mov r12, lr + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + adds r2, 1 + ldr r0, =REG_SOUND1CNT_L @ sound register base address + adds r0, r3 + bl _081DD64A + strb r3, [r0] + bx r12 + .pool + thumb_func_end ply_port + + thumb_func_start m4aSoundVSync +m4aSoundVSync: + ldr r0, lt2_SOUND_INFO_PTR + ldr r0, [r0] + + @ Exit the function if ident is not ID_NUMBER or ID_NUMBER+1. + ldr r2, lt2_ID_NUMBER + ldr r3, [r0, o_SoundInfo_ident] + subs r3, r2 + cmp r3, 1 + bhi m4aSoundVSync_Done + + @ Decrement the PCM DMA counter. If it reaches 0, we need to do a DMA. + ldrb r1, [r0, o_SoundInfo_pcmDmaCounter] + subs r1, 1 + strb r1, [r0, o_SoundInfo_pcmDmaCounter] + bgt m4aSoundVSync_Done + + @ Reload the PCM DMA counter. + ldrb r1, [r0, o_SoundInfo_pcmDmaPeriod] + strb r1, [r0, o_SoundInfo_pcmDmaCounter] + + ldr r2, =REG_DMA1 + + ldr r1, [r2, 0x8] @ DMA1CNT + lsls r1, 7 + bcc m4aSoundVSync_SkipDMA1 @ branch if repeat bit isn't set + + ldr r1, =((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4 + str r1, [r2, 0x8] @ DMA1CNT + +m4aSoundVSync_SkipDMA1: + ldr r1, [r2, 0xC + 0x8] @ DMA2CNT + lsls r1, 7 + bcc m4aSoundVSync_SkipDMA2 @ branch if repeat bit isn't set + + ldr r1, =((DMA_ENABLE | DMA_START_NOW | DMA_32BIT | DMA_SRC_INC | DMA_DEST_FIXED) << 16) | 4 + str r1, [r2, 0xC + 0x8] @ DMA2CNT + +m4aSoundVSync_SkipDMA2: + + @ turn off DMA1/DMA2 + movs r1, DMA_32BIT >> 8 + lsls r1, 8 + strh r1, [r2, 0xA] @ DMA1CNT_H + strh r1, [r2, 0xC + 0xA] @ DMA2CNT_H + + @ turn on DMA1/DMA2 direct-sound FIFO mode + movs r1, (DMA_ENABLE | DMA_START_SPECIAL | DMA_32BIT | DMA_REPEAT) >> 8 + lsls r1, 8 @ LSB is 0, so DMA_SRC_INC is used (destination is always fixed in FIFO mode) + strh r1, [r2, 0xA] @ DMA1CNT_H + strh r1, [r2, 0xC + 0xA] @ DMA2CNT_H + +m4aSoundVSync_Done: + bx lr + + .pool + thumb_func_end m4aSoundVSync + + thumb_func_start MPlayMain +MPlayMain: + ldr r2, lt2_ID_NUMBER + ldr r3, [r0, o_MusicPlayerInfo_ident] + cmp r2, r3 + beq _081DD82E + bx lr +_081DD82E: + adds r3, 0x1 + str r3, [r0, o_MusicPlayerInfo_ident] + push {r0,lr} + ldr r3, [r0, o_MusicPlayerInfo_func] + cmp r3, 0 + beq _081DD840 + ldr r0, [r0, o_MusicPlayerInfo_intp] + bl call_r3 +_081DD840: + pop {r0} + push {r4-r7} + mov r4, r8 + mov r5, r9 + mov r6, r10 + mov r7, r11 + push {r4-r7} + adds r7, r0, 0 + ldr r0, [r7, o_MusicPlayerInfo_status] + cmp r0, 0 + bge _081DD858 + b _081DDA6C +_081DD858: + ldr r0, lt2_SOUND_INFO_PTR + ldr r0, [r0] + mov r8, r0 + adds r0, r7, 0 + bl FadeOutBody + ldr r0, [r7, o_MusicPlayerInfo_status] + cmp r0, 0 + bge _081DD86C + b _081DDA6C +_081DD86C: + ldrh r0, [r7, o_MusicPlayerInfo_tempoC] + ldrh r1, [r7, o_MusicPlayerInfo_tempoI] + adds r0, r1 + b _081DD9BC +_081DD874: + ldrb r6, [r7, o_MusicPlayerInfo_trackCount] + ldr r5, [r7, o_MusicPlayerInfo_tracks] + movs r3, 0x1 + movs r4, 0 +_081DD87C: + ldrb r0, [r5] + movs r1, 0x80 + tst r1, r0 + bne _081DD886 + b _081DD998 +_081DD886: + mov r10, r3 + orrs r4, r3 + mov r11, r4 + ldr r4, [r5, o_MusicPlayerTrack_chan] + cmp r4, 0 + beq _081DD8BA +_081DD892: + ldrb r1, [r4] + movs r0, 0xC7 + tst r0, r1 + beq _081DD8AE + ldrb r0, [r4, 0x10] + cmp r0, 0 + beq _081DD8B4 + subs r0, 0x1 + strb r0, [r4, 0x10] + bne _081DD8B4 + movs r0, 0x40 + orrs r1, r0 + strb r1, [r4] + b _081DD8B4 +_081DD8AE: + adds r0, r4, 0 + bl ClearChain +_081DD8B4: + ldr r4, [r4, 0x34] + cmp r4, 0 + bne _081DD892 +_081DD8BA: + ldrb r3, [r5, o_MusicPlayerTrack_flags] + movs r0, 0x40 + tst r0, r3 + beq _081DD938 + adds r0, r5, 0 + bl Clear64byte + movs r0, 0x80 + strb r0, [r5] + movs r0, 0x2 + strb r0, [r5, o_MusicPlayerTrack_bendRange] + movs r0, 0x40 + strb r0, [r5, o_MusicPlayerTrack_volX] + movs r0, 0x16 + strb r0, [r5, o_MusicPlayerTrack_lfoSpeed] + movs r0, 0x1 + adds r1, r5, 0x6 + strb r0, [r1, o_MusicPlayerTrack_ToneData_type - 0x6] + b _081DD938 +_081DD8E0: + ldr r2, [r5, o_MusicPlayerTrack_cmdPtr] + ldrb r1, [r2] + cmp r1, 0x80 + bhs _081DD8EC + ldrb r1, [r5, o_MusicPlayerTrack_runningStatus] + b _081DD8F6 +_081DD8EC: + adds r2, 0x1 + str r2, [r5, o_MusicPlayerTrack_cmdPtr] + cmp r1, 0xBD + bcc _081DD8F6 + strb r1, [r5, o_MusicPlayerTrack_runningStatus] +_081DD8F6: + cmp r1, 0xCF + bcc _081DD90C + mov r0, r8 + ldr r3, [r0, o_SoundInfo_plynote] + adds r0, r1, 0 + subs r0, 0xCF + adds r1, r7, 0 + adds r2, r5, 0 + bl call_r3 + b _081DD938 +_081DD90C: + cmp r1, 0xB0 + bls _081DD92E + adds r0, r1, 0 + subs r0, 0xB1 + strb r0, [r7, o_MusicPlayerInfo_cmd] + mov r3, r8 + ldr r3, [r3, o_SoundInfo_MPlayJumpTable] + lsls r0, 2 + ldr r3, [r3, r0] + adds r0, r7, 0 + adds r1, r5, 0 + bl call_r3 + ldrb r0, [r5, o_MusicPlayerTrack_flags] + cmp r0, 0 + beq _081DD994 + b _081DD938 +_081DD92E: + ldr r0, lt_gClockTable + subs r1, 0x80 + adds r1, r0 + ldrb r0, [r1] + strb r0, [r5, o_MusicPlayerTrack_wait] +_081DD938: + ldrb r0, [r5, o_MusicPlayerTrack_wait] + cmp r0, 0 + beq _081DD8E0 + subs r0, 0x1 + strb r0, [r5, o_MusicPlayerTrack_wait] + ldrb r1, [r5, o_MusicPlayerTrack_lfoSpeed] + cmp r1, 0 + beq _081DD994 + ldrb r0, [r5, o_MusicPlayerTrack_mod] + cmp r0, 0 + beq _081DD994 + ldrb r0, [r5, o_MusicPlayerTrack_lfoDelayC] + cmp r0, 0 + beq _081DD95A + subs r0, 0x1 + strb r0, [r5, o_MusicPlayerTrack_lfoDelayC] + b _081DD994 +_081DD95A: + ldrb r0, [r5, o_MusicPlayerTrack_lfoSpeedC] + adds r0, r1 + strb r0, [r5, o_MusicPlayerTrack_lfoSpeedC] + adds r1, r0, 0 + subs r0, 0x40 + lsls r0, 24 + bpl _081DD96E + lsls r2, r1, 24 + asrs r2, 24 + b _081DD972 +_081DD96E: + movs r0, 0x80 + subs r2, r0, r1 +_081DD972: + ldrb r0, [r5, o_MusicPlayerTrack_mod] + muls r0, r2 + asrs r2, r0, 6 + ldrb r0, [r5, o_MusicPlayerTrack_modM] + eors r0, r2 + lsls r0, 24 + beq _081DD994 + strb r2, [r5, o_MusicPlayerTrack_modM] + ldrb r0, [r5] + ldrb r1, [r5, o_MusicPlayerTrack_modT] + cmp r1, 0 + bne _081DD98E + movs r1, 0xC + b _081DD990 +_081DD98E: + movs r1, 0x3 +_081DD990: + orrs r0, r1 + strb r0, [r5, o_MusicPlayerTrack_flags] +_081DD994: + mov r3, r10 + mov r4, r11 +_081DD998: + subs r6, 0x1 + ble _081DD9A4 + movs r0, 0x50 + adds r5, r0 + lsls r3, 1 + b _081DD87C +_081DD9A4: + ldr r0, [r7, o_MusicPlayerInfo_clock] + adds r0, 0x1 + str r0, [r7, o_MusicPlayerInfo_clock] + cmp r4, 0 + bne _081DD9B6 + movs r0, 0x80 + lsls r0, 24 + str r0, [r7, o_MusicPlayerInfo_status] + b _081DDA6C +_081DD9B6: + str r4, [r7, o_MusicPlayerInfo_status] + ldrh r0, [r7, o_MusicPlayerInfo_tempoC] + subs r0, 0x96 +_081DD9BC: + strh r0, [r7, o_MusicPlayerInfo_tempoC] + cmp r0, 0x96 + bcc _081DD9C4 + b _081DD874 +_081DD9C4: + ldrb r2, [r7, o_MusicPlayerInfo_trackCount] + ldr r5, [r7, o_MusicPlayerInfo_tracks] +_081DD9C8: + ldrb r0, [r5, o_MusicPlayerTrack_flags] + movs r1, 0x80 + tst r1, r0 + beq _081DDA62 + movs r1, 0xF + tst r1, r0 + beq _081DDA62 + mov r9, r2 + adds r0, r7, 0 + adds r1, r5, 0 + bl TrkVolPitSet + ldr r4, [r5, o_MusicPlayerTrack_chan] + cmp r4, 0 + beq _081DDA58 +_081DD9E6: + ldrb r1, [r4, o_SoundChannel_status] + movs r0, 0xC7 + tst r0, r1 + bne _081DD9F6 + adds r0, r4, 0 + bl ClearChain + b _081DDA52 +_081DD9F6: + ldrb r0, [r4, o_SoundChannel_type] + movs r6, 0x7 + ands r6, r0 + ldrb r3, [r5, o_MusicPlayerTrack_flags] + movs r0, 0x3 + tst r0, r3 + beq _081DDA14 + bl ChnVolSetAsm + cmp r6, 0 + beq _081DDA14 + ldrb r0, [r4, o_CgbChannel_mo] + movs r1, 0x1 + orrs r0, r1 + strb r0, [r4, o_CgbChannel_mo] +_081DDA14: + ldrb r3, [r5, o_MusicPlayerTrack_flags] + movs r0, 0xC + tst r0, r3 + beq _081DDA52 + ldrb r1, [r4, o_SoundChannel_ky] + movs r0, 0x8 + ldrsb r0, [r5, r0] + adds r2, r1, r0 + bpl _081DDA28 + movs r2, 0 +_081DDA28: + cmp r6, 0 + beq _081DDA46 + mov r0, r8 + ldr r3, [r0, o_SoundInfo_MidiKeyToCgbFreq] + adds r1, r2, 0 + ldrb r2, [r5, o_MusicPlayerTrack_pitM] + adds r0, r6, 0 + bl call_r3 + str r0, [r4, o_CgbChannel_fr] + ldrb r0, [r4, o_CgbChannel_mo] + movs r1, 0x2 + orrs r0, r1 + strb r0, [r4, o_CgbChannel_mo] + b _081DDA52 +_081DDA46: + adds r1, r2, 0 + ldrb r2, [r5, o_MusicPlayerTrack_pitM] + ldr r0, [r4, o_SoundChannel_wav] + bl MidiKeyToFreq + str r0, [r4, o_SoundChannel_freq] +_081DDA52: + ldr r4, [r4, o_SoundChannel_np] + cmp r4, 0 + bne _081DD9E6 +_081DDA58: + ldrb r0, [r5, o_MusicPlayerTrack_flags] + movs r1, 0xF0 + ands r0, r1 + strb r0, [r5, o_MusicPlayerTrack_flags] + mov r2, r9 +_081DDA62: + subs r2, 0x1 + ble _081DDA6C + movs r0, 0x50 + adds r5, r0 + bgt _081DD9C8 +_081DDA6C: + ldr r0, lt2_ID_NUMBER + str r0, [r7, o_MusicPlayerInfo_ident] + pop {r0-r7} + mov r8, r0 + mov r9, r1 + mov r10, r2 + mov r11, r3 + pop {r3} + +call_r3: + bx r3 + + .align 2, 0 +lt_gClockTable: .word gClockTable +lt2_SOUND_INFO_PTR: .word SOUND_INFO_PTR +lt2_ID_NUMBER: .word ID_NUMBER + thumb_func_end MPlayMain + + thumb_func_start TrackStop +TrackStop: + push {r4-r6,lr} + adds r5, r1, 0 + ldrb r1, [r5, o_MusicPlayerTrack_flags] + movs r0, 0x80 + tst r0, r1 + beq TrackStop_Done + ldr r4, [r5, o_MusicPlayerTrack_chan] + cmp r4, 0 + beq TrackStop_3 + movs r6, 0 +TrackStop_Loop: + ldrb r0, [r4, o_SoundChannel_status] + cmp r0, 0 + beq TrackStop_2 + ldrb r0, [r4, o_SoundChannel_type] + movs r3, 0x7 + ands r0, r3 + beq TrackStop_1 + ldr r3, =SOUND_INFO_PTR + ldr r3, [r3] + ldr r3, [r3, o_SoundInfo_CgbOscOff] + bl call_r3 +TrackStop_1: + strb r6, [r4, o_SoundChannel_status] +TrackStop_2: + str r6, [r4, o_SoundChannel_track] + ldr r4, [r4, o_SoundChannel_np] + cmp r4, 0 + bne TrackStop_Loop +TrackStop_3: + str r4, [r5, o_MusicPlayerTrack_chan] +TrackStop_Done: + pop {r4-r6} + pop {r0} + bx r0 + .pool + thumb_func_end TrackStop + + thumb_func_start ChnVolSetAsm +ChnVolSetAsm: + ldrb r1, [r4, 0x12] + movs r0, 0x14 + ldrsb r2, [r4, r0] + movs r3, 0x80 + adds r3, r2 + muls r3, r1 + ldrb r0, [r5, 0x10] + muls r0, r3 + asrs r0, 14 + cmp r0, 0xFF + bls _081DDAE8 + movs r0, 0xFF +_081DDAE8: + strb r0, [r4, 0x2] + movs r3, 0x7F + subs r3, r2 + muls r3, r1 + ldrb r0, [r5, 0x11] + muls r0, r3 + asrs r0, 14 + cmp r0, 0xFF + bls _081DDAFC + movs r0, 0xFF +_081DDAFC: + strb r0, [r4, 0x3] + bx lr + thumb_func_end ChnVolSetAsm + + thumb_func_start ply_note +ply_note: + push {r4-r7,lr} + mov r4, r8 + mov r5, r9 + mov r6, r10 + mov r7, r11 + push {r4-r7} + sub sp, 0x18 + str r1, [sp] + adds r5, r2, 0 + ldr r1, =SOUND_INFO_PTR + ldr r1, [r1] + str r1, [sp, 0x4] + ldr r1, =gClockTable + adds r0, r1 + ldrb r0, [r0] + strb r0, [r5, o_MusicPlayerTrack_gateTime] + ldr r3, [r5, o_MusicPlayerTrack_cmdPtr] + ldrb r0, [r3] + cmp r0, 0x80 + bhs _081DDB46 + strb r0, [r5, o_MusicPlayerTrack_key] + adds r3, 0x1 + ldrb r0, [r3] + cmp r0, 0x80 + bhs _081DDB44 + strb r0, [r5, o_MusicPlayerTrack_velocity] + adds r3, 0x1 + ldrb r0, [r3] + cmp r0, 0x80 + bhs _081DDB44 + ldrb r1, [r5, o_MusicPlayerTrack_gateTime] + adds r1, r0 + strb r1, [r5, o_MusicPlayerTrack_gateTime] + adds r3, 0x1 +_081DDB44: + str r3, [r5, o_MusicPlayerTrack_cmdPtr] +_081DDB46: + movs r0, 0 + str r0, [sp, 0x14] + adds r4, r5, 0 + adds r4, o_MusicPlayerTrack_ToneData_type + ldrb r2, [r4] + movs r0, TONEDATA_TYPE_RHY | TONEDATA_TYPE_SPL + tst r0, r2 + beq _081DDB98 + ldrb r3, [r5, o_MusicPlayerTrack_key] + movs r0, TONEDATA_TYPE_SPL + tst r0, r2 + beq _081DDB66 + ldr r1, [r5, o_MusicPlayerTrack_ToneData_keySplitTable] + adds r1, r3 + ldrb r0, [r1] + b _081DDB68 +_081DDB66: + adds r0, r3, 0 +_081DDB68: + lsls r1, r0, 1 + adds r1, r0 + lsls r1, 2 + ldr r0, [r5, o_MusicPlayerTrack_ToneData_wav] + adds r1, r0 + mov r9, r1 + mov r6, r9 + ldrb r1, [r6] + movs r0, 0xC0 + tst r0, r1 + beq _081DDB80 + b _081DDCEA +_081DDB80: + movs r0, 0x80 + tst r0, r2 + beq _081DDB9C + ldrb r1, [r6, 0x3] + movs r0, 0x80 + tst r0, r1 + beq _081DDB94 + subs r1, 0xC0 + lsls r1, 1 + str r1, [sp, 0x14] +_081DDB94: + ldrb r3, [r6, 0x1] + b _081DDB9C +_081DDB98: + mov r9, r4 + ldrb r3, [r5, 0x5] +_081DDB9C: + str r3, [sp, 0x8] + ldr r6, [sp] + ldrb r1, [r6, 0x9] + ldrb r0, [r5, 0x1D] + adds r0, r1 + cmp r0, 0xFF + bls _081DDBAC + movs r0, 0xFF +_081DDBAC: + str r0, [sp, 0x10] + mov r6, r9 + ldrb r0, [r6] + movs r6, 0x7 + ands r6, r0 + str r6, [sp, 0xC] + beq _081DDBEC + ldr r0, [sp, 0x4] + ldr r4, [r0, 0x1C] + cmp r4, 0 + bne _081DDBC4 + b _081DDCEA +_081DDBC4: + subs r6, 0x1 + lsls r0, r6, 6 + adds r4, r0 + ldrb r1, [r4] + movs r0, 0xC7 + tst r0, r1 + beq _081DDC40 + movs r0, 0x40 + tst r0, r1 + bne _081DDC40 + ldrb r1, [r4, 0x13] + ldr r0, [sp, 0x10] + cmp r1, r0 + bcc _081DDC40 + beq _081DDBE4 + b _081DDCEA +_081DDBE4: + ldr r0, [r4, 0x2C] + cmp r0, r5 + bcs _081DDC40 + b _081DDCEA +_081DDBEC: + ldr r6, [sp, 0x10] + adds r7, r5, 0 + movs r2, 0 + mov r8, r2 + ldr r4, [sp, 0x4] + ldrb r3, [r4, 0x6] + adds r4, 0x50 +_081DDBFA: + ldrb r1, [r4] + movs r0, 0xC7 + tst r0, r1 + beq _081DDC40 + movs r0, 0x40 + tst r0, r1 + beq _081DDC14 + cmp r2, 0 + bne _081DDC18 + adds r2, 0x1 + ldrb r6, [r4, 0x13] + ldr r7, [r4, 0x2C] + b _081DDC32 +_081DDC14: + cmp r2, 0 + bne _081DDC34 +_081DDC18: + ldrb r0, [r4, 0x13] + cmp r0, r6 + bcs _081DDC24 + adds r6, r0, 0 + ldr r7, [r4, 0x2C] + b _081DDC32 +_081DDC24: + bhi _081DDC34 + ldr r0, [r4, 0x2C] + cmp r0, r7 + bls _081DDC30 + adds r7, r0, 0 + b _081DDC32 +_081DDC30: + bcc _081DDC34 +_081DDC32: + mov r8, r4 +_081DDC34: + adds r4, 0x40 + subs r3, 0x1 + bgt _081DDBFA + mov r4, r8 + cmp r4, 0 + beq _081DDCEA +_081DDC40: + adds r0, r4, 0 + bl ClearChain + movs r1, 0 + str r1, [r4, 0x30] + ldr r3, [r5, 0x20] + str r3, [r4, 0x34] + cmp r3, 0 + beq _081DDC54 + str r4, [r3, 0x30] +_081DDC54: + str r4, [r5, 0x20] + str r5, [r4, 0x2C] + ldrb r0, [r5, 0x1B] + strb r0, [r5, 0x1C] + cmp r0, r1 + beq _081DDC66 + adds r1, r5, 0 + bl clear_modM +_081DDC66: + ldr r0, [sp] + adds r1, r5, 0 + bl TrkVolPitSet + ldr r0, [r5, 0x4] + str r0, [r4, 0x10] + ldr r0, [sp, 0x10] + strb r0, [r4, 0x13] + ldr r0, [sp, 0x8] + strb r0, [r4, 0x8] + ldr r0, [sp, 0x14] + strb r0, [r4, 0x14] + mov r6, r9 + ldrb r0, [r6] + strb r0, [r4, 0x1] + ldr r7, [r6, 0x4] + str r7, [r4, 0x24] + ldr r0, [r6, 0x8] + str r0, [r4, 0x4] + ldrh r0, [r5, 0x1E] + strh r0, [r4, 0xC] + bl ChnVolSetAsm + ldrb r1, [r4, 0x8] + movs r0, 0x8 + ldrsb r0, [r5, r0] + adds r3, r1, r0 + bpl _081DDCA0 + movs r3, 0 +_081DDCA0: + ldr r6, [sp, 0xC] + cmp r6, 0 + beq _081DDCCE + mov r6, r9 + ldrb r0, [r6, 0x2] + strb r0, [r4, 0x1E] + ldrb r1, [r6, 0x3] + movs r0, 0x80 + tst r0, r1 + bne _081DDCBA + movs r0, 0x70 + tst r0, r1 + bne _081DDCBC +_081DDCBA: + movs r1, 0x8 +_081DDCBC: + strb r1, [r4, 0x1F] + ldrb r2, [r5, 0x9] + adds r1, r3, 0 + ldr r0, [sp, 0xC] + ldr r3, [sp, 0x4] + ldr r3, [r3, 0x30] + bl call_r3 + b _081DDCDC +_081DDCCE: + ldr r0, [r5, o_MusicPlayerTrack_unk_3C] + str r0, [r4, 0x18] + ldrb r2, [r5, 0x9] + adds r1, r3, 0 + adds r0, r7, 0 + bl MidiKeyToFreq +_081DDCDC: + str r0, [r4, 0x20] + movs r0, 0x80 + strb r0, [r4] + ldrb r1, [r5] + movs r0, 0xF0 + ands r0, r1 + strb r0, [r5] +_081DDCEA: + add sp, 0x18 + pop {r0-r7} + mov r8, r0 + mov r9, r1 + mov r10, r2 + mov r11, r3 + pop {r0} + bx r0 + .pool + thumb_func_end ply_note + + thumb_func_start ply_endtie +ply_endtie: + push {r4,r5} + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + cmp r3, 0x80 + bhs _081DDD16 + strb r3, [r1, o_MusicPlayerTrack_key] + adds r2, 0x1 + str r2, [r1, o_MusicPlayerTrack_cmdPtr] + b _081DDD18 +_081DDD16: + ldrb r3, [r1, o_MusicPlayerTrack_key] +_081DDD18: + ldr r1, [r1, o_MusicPlayerTrack_chan] + cmp r1, 0 + beq _081DDD40 + movs r4, 0x83 + movs r5, 0x40 +_081DDD22: + ldrb r2, [r1, o_SoundChannel_status] + tst r2, r4 + beq _081DDD3A + tst r2, r5 + bne _081DDD3A + ldrb r0, [r1, o_SoundChannel_mk] + cmp r0, r3 + bne _081DDD3A + movs r0, 0x40 + orrs r2, r0 + strb r2, [r1, o_SoundChannel_status] + b _081DDD40 +_081DDD3A: + ldr r1, [r1, o_SoundChannel_np] + cmp r1, 0 + bne _081DDD22 +_081DDD40: + pop {r4,r5} + bx lr + thumb_func_end ply_endtie + + thumb_func_start clear_modM +clear_modM: + movs r2, 0 + strb r2, [r1, o_MusicPlayerTrack_modM] + strb r2, [r1, o_MusicPlayerTrack_lfoSpeedC] + ldrb r2, [r1, o_MusicPlayerTrack_modT] + cmp r2, 0 + bne _081DDD54 + movs r2, 0xC + b _081DDD56 +_081DDD54: + movs r2, 0x3 +_081DDD56: + ldrb r3, [r1, o_MusicPlayerTrack_flags] + orrs r3, r2 + strb r3, [r1, o_MusicPlayerTrack_flags] + bx lr + thumb_func_end clear_modM + + thumb_func_start ld_r3_tp_adr_i +ld_r3_tp_adr_i_unchecked: + ldr r2, [r1, o_MusicPlayerTrack_cmdPtr] + adds r3, r2, 1 + str r3, [r1, o_MusicPlayerTrack_cmdPtr] + ldrb r3, [r2] + bx lr + thumb_func_end ld_r3_tp_adr_i + + thumb_func_start ply_lfos +ply_lfos: + mov r12, lr + bl ld_r3_tp_adr_i_unchecked + strb r3, [r1, o_MusicPlayerTrack_lfoSpeed] + cmp r3, 0 + bne _081DDD7C + bl clear_modM +_081DDD7C: + bx r12 + thumb_func_end ply_lfos + + thumb_func_start ply_mod +ply_mod: + mov r12, lr + bl ld_r3_tp_adr_i_unchecked + strb r3, [r1, o_MusicPlayerTrack_mod] + cmp r3, 0 + bne _081DDD90 + bl clear_modM +_081DDD90: + bx r12 + thumb_func_end ply_mod + + .align 2, 0 @ Don't pad with nop. diff --git a/src/pokemon/learn_move.c b/src/pokemon/learn_move.c index ef1d66349..356a31b00 100644 --- a/src/pokemon/learn_move.c +++ b/src/pokemon/learn_move.c @@ -25,8 +25,8 @@ extern u16 gSpecialVar_0x8004; extern u16 gSpecialVar_0x8005; extern u8 gTileBuffer[]; -extern const struct WindowConfig gWindowConfig_81E6CE4; -extern const struct WindowConfig gWindowConfig_81E7240; +extern const struct WindowTemplate gWindowTemplate_81E6CE4; +extern const struct WindowTemplate gWindowTemplate_81E7240; extern const u8 *const gContestEffectStrings[]; extern const u8 *const gMoveDescriptions[]; extern const u8 gTypeNames[][7]; @@ -268,13 +268,13 @@ void CB2_InitLearnMove(void) sub_8133558(); SetVBlankCallback(VBlankCB_LearnMove); - SetUpWindowConfig(&gWindowConfig_81E7240); - InitMenuWindow(&gWindowConfig_81E7240); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E7240); + InitMenuWindow(&gWindowTemplate_81E7240); + Menu_EraseScreen(); - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); + Menu_EraseScreen(); REG_BG0VOFS = 0; REG_BG0VOFS = 0; // huh? @@ -302,13 +302,13 @@ void sub_81327A4(void) sLearnMoveStruct->unk2C6 = gSpecialVar_0x8005; SetVBlankCallback(VBlankCB_LearnMove); - SetUpWindowConfig(&gWindowConfig_81E7240); - InitMenuWindow(&gWindowConfig_81E7240); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E7240); + InitMenuWindow(&gWindowTemplate_81E7240); + Menu_EraseScreen(); - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); - MenuZeroFillScreen(); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); + Menu_EraseScreen(); REG_DISPCNT = 0x1340; REG_BG0VOFS = 0; @@ -333,7 +333,7 @@ void CB2_LearnMove(void) if (sLearnMoveStruct->unk1D) { sLearnMoveStruct->unk1D = FALSE; - sub_814AD7C(0x58, (sLearnMoveStruct->unk18 * 2 + 1) * 8); + MenuCursor_SetPos814AD7C(0x58, (sLearnMoveStruct->unk18 * 2 + 1) * 8); } if (sLearnMoveStruct->unk1E != 0) { @@ -401,7 +401,7 @@ void LearnMoveMain(void) sub_813362C(); break; case 8: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { DisplayYesNoMenu(21, 7, 1); sLearnMoveStruct->state++; @@ -409,7 +409,7 @@ void LearnMoveMain(void) break; case 9: { - s8 selection = ProcessMenuInputNoWrap_(); + s8 selection = Menu_ProcessInputNoWrap_(); if (selection == 0) { @@ -436,7 +436,7 @@ void LearnMoveMain(void) } break; case 12: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { DisplayYesNoMenu(21, 7, 1); sLearnMoveStruct->state++; @@ -444,7 +444,7 @@ void LearnMoveMain(void) break; case 13: { - s8 selection = ProcessMenuInputNoWrap_(); + s8 selection = Menu_ProcessInputNoWrap_(); if (selection == 0) { @@ -467,7 +467,7 @@ void LearnMoveMain(void) sLearnMoveStruct->state++; break; case 17: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { DisplayYesNoMenu(21, 7, 1); sLearnMoveStruct->state = 18; @@ -475,7 +475,7 @@ void LearnMoveMain(void) break; case 18: { - s8 var = ProcessMenuInputNoWrap_(); + s8 var = Menu_ProcessInputNoWrap_(); if (var == 0) { @@ -495,7 +495,7 @@ void LearnMoveMain(void) sLearnMoveStruct->state++; break; case 25: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { sLearnMoveStruct->state = 26; DisplayYesNoMenu(21, 7, 1); @@ -503,7 +503,7 @@ void LearnMoveMain(void) break; case 26: { - s8 var = ProcessMenuInputNoWrap_(); + s8 var = Menu_ProcessInputNoWrap_(); if (var == 0) { @@ -524,7 +524,7 @@ void LearnMoveMain(void) } break; case 27: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { if (sLearnMoveStruct->showContestInfo == FALSE) sLearnMoveStruct->state = 3; @@ -533,7 +533,7 @@ void LearnMoveMain(void) } break; case 19: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { sLearnMoveStruct->state = 20; BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, 0); @@ -547,7 +547,7 @@ void LearnMoveMain(void) } break; case 21: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) sLearnMoveStruct->state = 14; break; case 22: @@ -597,7 +597,7 @@ void LearnMoveMain(void) } break; case 30: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { #ifdef ENGLISH sub_81328E8(gOtherText_ForgotOrDidNotLearnMove); @@ -609,7 +609,7 @@ void LearnMoveMain(void) } break; case 31: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { PlayFanfare(BGM_FANFA1); sLearnMoveStruct->state = 32; @@ -633,16 +633,16 @@ void DrawLearnMoveMenuWindow(void) { u32 i; - BasicInitMenuWindow(&gWindowConfig_81E7240); + BasicInitMenuWindow(&gWindowTemplate_81E7240); for (i = 0; i < 4; i++) { - MenuDrawTextWindow( + Menu_DrawStdWindowFrame( gUnknown_08402CF8[i][0], gUnknown_08402CF8[i][1], gUnknown_08402CF8[i][2], gUnknown_08402CF8[i][3]); } - BasicInitMenuWindow(&gWindowConfig_81E6CE4); + BasicInitMenuWindow(&gWindowTemplate_81E6CE4); } void sub_8133030(bool8 a) @@ -658,7 +658,7 @@ void sub_8133030(bool8 a) for (i = 0; gUnknown_08402D08[0][i].unk0 != NULL; i++) { sub_8072C74(gTileBuffer, gUnknown_08402D08[0][i].unk0, 64, 2); - MenuPrint(gTileBuffer, gUnknown_08402D08[0][i].unk4, gUnknown_08402D08[0][i].unk5); + Menu_PrintText(gTileBuffer, gUnknown_08402D08[0][i].unk4, gUnknown_08402D08[0][i].unk5); } if (!a) @@ -696,10 +696,10 @@ void sub_8133140(bool8 a) for (i = 0; gUnknown_08402D08[0][i].unk0 != NULL; i++) { sub_8072C74(gTileBuffer, gUnknown_08402D08[1][i].unk0, 64, 2); - MenuPrint(gTileBuffer, gUnknown_08402D08[1][i].unk4, gUnknown_08402D08[1][i].unk5); + Menu_PrintText(gTileBuffer, gUnknown_08402D08[1][i].unk4, gUnknown_08402D08[1][i].unk5); if (i != 0) { - MenuZeroFillWindowRect( + Menu_EraseWindowRect( gUnknown_08402D08[1][i].unk4, gUnknown_08402D08[1][i].unk5 + 2, gUnknown_08402D08[1][i].unk4 + 7, @@ -938,7 +938,7 @@ void sub_8133800(void) r6++; } *str = EOS; - MenuPrint(gTileBuffer, 11, 1); + Menu_PrintText(gTileBuffer, 11, 1); sub_813360C(0); } @@ -972,17 +972,17 @@ void PrintMoveInfo(u16 moveId, const u8 *b) sub_8072C74(str, gOtherText_ThreeDashes2, 32, 2); else sub_8072C14(str, gBattleMoves[moveId].power, 32, 2); - MenuPrint(str, b[0], b[1]); + Menu_PrintText(str, b[0], b[1]); break; case 4: if (gBattleMoves[moveId].accuracy == 0) sub_8072C74(str, gOtherText_ThreeDashes2, 32, 2); else sub_8072C14(str, gBattleMoves[moveId].accuracy, 32, 2); - MenuPrint(str, b[0], b[1]); + Menu_PrintText(str, b[0], b[1]); break; case 6: - MenuZeroFillWindowRect(b[0], b[1], b[0], b[1] + 1); + Menu_EraseWindowRect(b[0], b[1], b[0], b[1] + 1); numHearts = gContestEffects[gContestMoves[moveId].effect].appeal / 10; if (numHearts == 255) numHearts = 0; @@ -995,7 +995,7 @@ void PrintMoveInfo(u16 moveId, const u8 *b) } break; case 7: - MenuZeroFillWindowRect(b[0], b[1], b[0], b[1] + 1); + Menu_EraseWindowRect(b[0], b[1], b[0], b[1] + 1); numHearts = gContestEffects[gContestMoves[moveId].effect].jam / 10; if (numHearts == 255) numHearts = 0; @@ -1037,7 +1037,7 @@ void sub_8133AEC(bool8 contestInfo, int unused) { u8 r1 = var * 2 + 9; - MenuFillWindowRectWithBlankTile(11, r1, 28, 12); + Menu_BlankWindowRect(11, r1, 28, 12); } } } @@ -1045,22 +1045,22 @@ void sub_8133AEC(bool8 contestInfo, int unused) { if (contestInfo) { - MenuZeroFillWindowRect(gUnknown_08402E24[5][0], gUnknown_08402E24[5][1], gUnknown_08402E24[5][0], gUnknown_08402E24[5][1] + 1); - MenuZeroFillWindowRect(gUnknown_08402E24[6][0], gUnknown_08402E24[6][1], gUnknown_08402E24[6][0], gUnknown_08402E24[6][1] + 1); + Menu_EraseWindowRect(gUnknown_08402E24[5][0], gUnknown_08402E24[5][1], gUnknown_08402E24[5][0], gUnknown_08402E24[5][1] + 1); + Menu_EraseWindowRect(gUnknown_08402E24[6][0], gUnknown_08402E24[6][1], gUnknown_08402E24[6][0], gUnknown_08402E24[6][1] + 1); for (i = 0; i < 16; i++) gSprites[sLearnMoveStruct->spriteIDs[i + 4]].invisible = TRUE; } else { - MenuZeroFillWindowRect(gUnknown_08402E24[1][0], gUnknown_08402E24[1][1], gUnknown_08402E24[1][0] + 3, gUnknown_08402E24[1][1] + 1); - MenuZeroFillWindowRect(gUnknown_08402E24[3][0], gUnknown_08402E24[3][1], gUnknown_08402E24[3][0] + 3, gUnknown_08402E24[3][1] + 1); + Menu_EraseWindowRect(gUnknown_08402E24[1][0], gUnknown_08402E24[1][1], gUnknown_08402E24[1][0] + 3, gUnknown_08402E24[1][1] + 1); + Menu_EraseWindowRect(gUnknown_08402E24[3][0], gUnknown_08402E24[3][1], gUnknown_08402E24[3][0] + 3, gUnknown_08402E24[3][1] + 1); } - MenuZeroFillWindowRect(11, 9, 28, 12); + Menu_EraseWindowRect(11, 9, 28, 12); } } void sub_8133CA4(void) { - MenuZeroFillWindowRect(21, 7, 27, 12); + Menu_EraseWindowRect(21, 7, 27, 12); sub_8133AEC(sLearnMoveStruct->showContestInfo, 0); } diff --git a/src/pokemon/mail.c b/src/pokemon/mail.c index 2ab05ca2b..921a3ad93 100644 --- a/src/pokemon/mail.c +++ b/src/pokemon/mail.c @@ -15,7 +15,7 @@ #include "strings2.h" #include "task.h" #include "text.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "ewram.h" struct UnkMailStruct @@ -320,7 +320,7 @@ static u8 sub_80F8A28(void) { case 0: SetVBlankCallback(NULL); - remove_some_task(); + ScanlineEffect_Stop(); REG_DISPCNT = 0; RETURN_UP_STATE; @@ -354,11 +354,11 @@ static u8 sub_80F8A28(void) RETURN_UP_STATE; case 6: - SetUpWindowConfig(&gWindowConfig_81E6DFC); + Text_LoadWindowTemplate(&gWindowTemplate_81E6DFC); RETURN_UP_STATE; case 7: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6DFC); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E6DFC); RETURN_UP_STATE; case 8: @@ -369,7 +369,7 @@ static u8 sub_80F8A28(void) RETURN_UP_STATE; case 9: - MenuZeroFillScreen(); + Menu_EraseScreen(); RETURN_UP_STATE; case 10: CpuFill16(1, (void *)(VRAM + 0x4800), 0x800); @@ -528,11 +528,11 @@ static void sub_80F8E80(void) x = ewram0_4.var10C->var4[pos].unk_0_4; y += ewram0_4.var10C->var4[pos].unk_0_0; - MenuPrint(ewram0_4.words[pos], ewram0_4.var10C->var3_4 + x, ewram0_4.var10C->var3_0 + y); + Menu_PrintText(ewram0_4.words[pos], ewram0_4.var10C->var3_4 + x, ewram0_4.var10C->var3_0 + y); y += 2; } - MenuPrint(ewram0_4.varD8, ewram0_4.varF9, ewram0_4.var10C->var1); + Menu_PrintText(ewram0_4.varD8, ewram0_4.varF9, ewram0_4.var10C->var1); } static void sub_80F8F18(void) diff --git a/src/pokemon/mon_markings.c b/src/pokemon/mon_markings.c index d27719c4a..149dda45f 100644 --- a/src/pokemon/mon_markings.c +++ b/src/pokemon/mon_markings.c @@ -294,7 +294,7 @@ void sub_80F727C(struct PokemonMarkMenu *ptr) void sub_80F728C(void) { - const struct FrameGraphics *frame = GetTextWindowFrameGraphics(gSaveBlock2.optionsWindowFrameType); + const struct FrameGraphics *frame = TextWindow_GetFrameGraphics(gSaveBlock2.optionsWindowFrameType); sMenu->frameTiles = frame->tiles; sMenu->framePalette = frame->palette; sMenu->tileLoadState = 0; @@ -548,8 +548,8 @@ void sub_80F761C(s16 x, s16 y, u16 baseTileTag, u16 basePaletteTag) } sMenu->cursorBaseY = y + 8; - sub_814A5C0(0, basePaletteTag + 1, 15, 0, 0x30); - sub_814A880(x + 8, sMenu->cursorBaseY); + MenuCursor_Create814A5C0(0, basePaletteTag + 1, 15, 0, 0x30); + MenuCursor_SetPos814A880(x + 8, sMenu->cursorBaseY); sub_814AABC(sub_80F7908); } diff --git a/src/pokemon/pokeblock_feed.c b/src/pokemon/pokeblock_feed.c index 8e3adda12..194636e4d 100644 --- a/src/pokemon/pokeblock_feed.c +++ b/src/pokemon/pokeblock_feed.c @@ -530,11 +530,11 @@ static bool8 TransitionToPokeblockFeedScene(void) gMain.state++; break; case 4: - SetUpWindowConfig(&gWindowConfig_81E6E50); + Text_LoadWindowTemplate(&gWindowTemplate_81E6E50); gMain.state++; break; case 5: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6E50); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E6E50); gMain.state++; break; case 6: @@ -559,7 +559,7 @@ static bool8 TransitionToPokeblockFeedScene(void) gMain.state++; break; case 10: - MenuDrawTextWindow(0, 14, 29, 19); + Menu_DrawStdWindowFrame(0, 14, 29, 19); gMain.state++; break; case 11: @@ -715,7 +715,7 @@ static void LaunchPokeblockFeedTask(u8 a0) static void Task_WaitForAtePokeblockText(u8 taskID) { - if (MenuUpdateWindowText() == 1) + if (Menu_UpdateWindowText() == 1) gTasks[taskID].func = Task_PaletteFadeToReturn; } diff --git a/src/pokemon/pokedex.c b/src/pokemon/pokedex.c index 1c1c71454..4fb6a4920 100644 --- a/src/pokemon/pokedex.c +++ b/src/pokemon/pokedex.c @@ -23,7 +23,7 @@ #include "strings.h" #include "task.h" #include "trig.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "ewram.h" #define NATIONAL_DEX_COUNT 386 @@ -1419,14 +1419,14 @@ void CB2_InitPokedex(void) } break; case 1: - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); ResetPaletteFade(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 8; - SetUpWindowConfig(&gWindowConfig_81E7048); - InitMenuWindow(&gWindowConfig_81E7048); + Text_LoadWindowTemplate(&gWindowTemplate_81E7048); + InitMenuWindow(&gWindowTemplate_81E7048); gMain.state++; break; case 2: @@ -1494,7 +1494,7 @@ u8 unref_sub_808C540(void (*func)(u8)) SetVBlankCallback(NULL); sub_8091060(0x200); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetPaletteFade(); savedIme = REG_IME; @@ -1937,8 +1937,8 @@ static bool8 sub_808D344(u8 a) gMain.state++; break; case 2: - SetUpWindowConfig(&gWindowConfig_81E7048); - InitMenuWindow(&gWindowConfig_81E7048); + Text_LoadWindowTemplate(&gWindowTemplate_81E7048); + InitMenuWindow(&gWindowTemplate_81E7048); LZ77UnCompVram(gUnknown_0839FA7C, (void *)(VRAM + 0xFF80)); gMain.state++; break; @@ -2241,7 +2241,7 @@ static void sub_808DEB0(u16 a, u8 b, u8 c, u16 d) text[3] = EOS; *(u16 *)(VRAM + d * 0x800 + c * 0x40 + b * 2) = unk[0]; *(u16 *)(VRAM + d * 0x800 + (c + 1) * 0x40 + b * 2) = unk[1]; - MenuPrint(text, b - 15, c); + Menu_PrintText(text, b - 15, c); } static void sub_808DF88(u16 a, u8 b, u8 c, u16 d) @@ -2283,7 +2283,7 @@ static u8 sub_808DFE4(u16 num, u8 b, u8 c) text[i] = CHAR_HYPHEN; break; } - MenuPrint_PixelCoords(text, (b - 0x11) * 8 + 0xFC, c * 8, 0); + Menu_PrintTextPixelCoords(text, (b - 0x11) * 8 + 0xFC, c * 8, 0); return i; } @@ -2951,8 +2951,8 @@ static void Task_InitPageScreenMultistep(u8 taskId) gMain.state++; break; case 3: - SetUpWindowConfig(&gWindowConfig_81E7064); - InitMenuWindow(&gWindowConfig_81E7064); + Text_LoadWindowTemplate(&gWindowTemplate_81E7064); + InitMenuWindow(&gWindowTemplate_81E7064); gMain.state++; break; case 4: @@ -2961,20 +2961,20 @@ static void Task_InitPageScreenMultistep(u8 taskId) else sub_8091154(gUnknown_0202FFBC->dexNum, 0xD, 3); sub_80911C8(gUnknown_0202FFBC->dexNum, 0x10, 3); - MenuPrint(gDexText_UnknownPoke, CATEGORY_LEFT, 5); - MenuPrint(gDexText_UnknownHeight, 16, 7); - MenuPrint(gDexText_UnknownWeight, 16, 9); + Menu_PrintText(gDexText_UnknownPoke, CATEGORY_LEFT, 5); + Menu_PrintText(gDexText_UnknownHeight, 16, 7); + Menu_PrintText(gDexText_UnknownWeight, 16, 9); if (gUnknown_0202FFBC->owned) { sub_8091304(gPokedexEntries[gUnknown_0202FFBC->dexNum].categoryName, CATEGORY_LEFT, 5); sub_8091458(gPokedexEntries[gUnknown_0202FFBC->dexNum].height, 16, 7); sub_8091564(gPokedexEntries[gUnknown_0202FFBC->dexNum].weight, 16, 9); - MenuPrint(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage1, 2, 13); + Menu_PrintText(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage1, 2, 13); sub_80917CC(14, 0x3FC); } else { - MenuPrint(gUnknown_083A05F8, 2, 13); + Menu_PrintText(gUnknown_083A05F8, 2, 13); LoadPalette(gPlttBufferUnfaded + 1, 0x31, 0x1E); } gMain.state++; @@ -3205,13 +3205,13 @@ static void Task_InitCryScreenMultistep(u8 taskId) gMain.state++; break; case 3: - SetUpWindowConfig(&gWindowConfig_81E702C); - InitMenuWindow(&gWindowConfig_81E702C); + Text_LoadWindowTemplate(&gWindowTemplate_81E702C); + InitMenuWindow(&gWindowTemplate_81E702C); ResetPaletteFade(); gMain.state++; break; case 4: - MenuPrint(gDexText_CryOf, 10, 4); + Menu_PrintText(gDexText_CryOf, 10, 4); sub_8091260(gUnknown_0202FFBC->dexNum, 10, 6, 2); gMain.state++; break; @@ -3394,8 +3394,8 @@ static void Task_InitSizeScreenMultistep(u8 taskId) { u8 string[40]; //I hope this is the correct size - SetUpWindowConfig(&gWindowConfig_81E702C); - InitMenuWindow(&gWindowConfig_81E702C); + Text_LoadWindowTemplate(&gWindowTemplate_81E702C); + InitMenuWindow(&gWindowTemplate_81E702C); string[0] = EOS; StringAppend(string, gDexText_SizeComparedTo); StringAppend(string, gSaveBlock2.playerName); @@ -3841,8 +3841,8 @@ static void sub_8090750(u8 taskId) gTasks[taskId].data[0]++; break; case 2: - SetUpWindowConfig(&gWindowConfig_81E7064); - InitMenuWindow(&gWindowConfig_81E7064); + Text_LoadWindowTemplate(&gWindowTemplate_81E7064); + InitMenuWindow(&gWindowTemplate_81E7064); DmaClear16(3, (void *)(VRAM + 0xC000), 0x200); gTasks[taskId].data[0]++; break; @@ -3853,13 +3853,13 @@ static void sub_8090750(u8 taskId) else sub_8091154(dexNum, 13, 3); sub_80911C8(dexNum, 16, 3); - MenuPrint(gDexText_UnknownPoke, CATEGORY_LEFT, 5); - MenuPrint(gDexText_UnknownHeight, 16, 7); - MenuPrint(gDexText_UnknownWeight, 16, 9); + Menu_PrintText(gDexText_UnknownPoke, CATEGORY_LEFT, 5); + Menu_PrintText(gDexText_UnknownHeight, 16, 7); + Menu_PrintText(gDexText_UnknownWeight, 16, 9); sub_8091304(gPokedexEntries[dexNum].categoryName, CATEGORY_LEFT, 5); sub_8091458(gPokedexEntries[dexNum].height, 16, 7); sub_8091564(gPokedexEntries[dexNum].weight, 16, 9); - MenuPrint(gPokedexEntries[dexNum].descriptionPage1, 2, 13); + Menu_PrintText(gPokedexEntries[dexNum].descriptionPage1, 2, 13); sub_80917CC(14, 0x3FC); gTasks[taskId].data[0]++; break; @@ -3906,8 +3906,8 @@ static void sub_8090A3C(u8 taskId) { u16 r4 = gTasks[taskId].data[1]; - MenuZeroFillWindowRect(2, 13, 27, 19); - MenuPrint(gPokedexEntries[r4].descriptionPage2, 2, 13); + Menu_EraseWindowRect(2, 13, 27, 19); + Menu_PrintText(gPokedexEntries[r4].descriptionPage2, 2, 13); (*(u16 *)(VRAM + 0x7ACA))++; (*(u16 *)(VRAM + 0x7B0A))++; gTasks[taskId].data[4] = 1; @@ -3970,8 +3970,8 @@ static void sub_8090C68(void) { if (gPokedexView->descriptionPageNum == 0) { - MenuZeroFillWindowRect(2, 13, 27, 19); - MenuPrint(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage2, 2, 13); + Menu_EraseWindowRect(2, 13, 27, 19); + Menu_PrintText(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage2, 2, 13); gPokedexView->descriptionPageNum = 1; (*(u16 *)(VRAM + 0x7ACA))++; (*(u16 *)(VRAM + 0x7B0A))++; @@ -3979,8 +3979,8 @@ static void sub_8090C68(void) } else { - MenuZeroFillWindowRect(2, 13, 27, 19); - MenuPrint(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage1, 2, 13); + Menu_EraseWindowRect(2, 13, 27, 19); + Menu_PrintText(gPokedexEntries[gUnknown_0202FFBC->dexNum].descriptionPage1, 2, 13); gPokedexView->descriptionPageNum = 0; (*(u16 *)(VRAM + 0x7ACA))--; (*(u16 *)(VRAM + 0x7B0A))--; @@ -4190,7 +4190,7 @@ static void sub_8091154(u16 order, u8 b, u8 c) str[1] = CHAR_0 + (order % 100) / 10; str[2] = CHAR_0 + (order % 100) % 10; str[3] = EOS; - MenuPrint(str, b, c); + Menu_PrintText(str, b, c); } static u8 sub_80911C8(u16 num, u8 b, u8 c) @@ -4212,7 +4212,7 @@ static u8 sub_80911C8(u16 num, u8 b, u8 c) str[i] = 0xAE; break; } - MenuPrint(str, b, c); + Menu_PrintText(str, b, c); return i; } @@ -4237,7 +4237,7 @@ static u8 sub_8091260(u16 num, u8 b, u8 c, u8 d) break; } end[i] = EOS; - MenuPrint(str, b, c); + Menu_PrintText(str, b, c); return i; } @@ -4297,7 +4297,7 @@ void unref_sub_80913A4(u16 a, u8 left, u8 top) str[3] = CHAR_PERIOD; str[4] = CHAR_0 + ((a % 1000) % 100) % 10; str[5] = EOS; - MenuPrint(str, left, top); + Menu_PrintText(str, left, top); } #elif GERMAN void unref_sub_80913A4(u16 arg0, u8 left, u8 top) { @@ -4341,7 +4341,7 @@ void unref_sub_80913A4(u16 arg0, u8 left, u8 top) { buffer[r6++] = EOS; buffer[2] = offset; - MenuPrint(buffer, left, top); + Menu_PrintText(buffer, left, top); } #endif @@ -4378,7 +4378,7 @@ static void sub_8091458(u16 height, u8 left, u8 top) buffer[i++] = (inches % 10) + CHAR_0; buffer[i++] = CHAR_DOUBLE_PRIME; buffer[i++] = EOS; - MenuPrint(buffer, left, top); + Menu_PrintText(buffer, left, top); } #else static void sub_8091458(u16 height, u8 left, u8 top) @@ -4448,7 +4448,7 @@ static void sub_8091564(u16 weight, u8 left, u8 top) buffer[i++] = CHAR_s; buffer[i++] = CHAR_PERIOD; buffer[i++] = EOS; - MenuPrint(buffer, left, top); + Menu_PrintText(buffer, left, top); } #else static void sub_8091564(u16 arg0, u8 left, u8 top) @@ -4770,8 +4770,8 @@ static void sub_8091E54(u8 taskId) } break; case 1: - SetUpWindowConfig(&gWindowConfig_81E7064); - InitMenuWindow(&gWindowConfig_81E7064); + Text_LoadWindowTemplate(&gWindowTemplate_81E7064); + InitMenuWindow(&gWindowTemplate_81E7064); LoadCompressedObjectPic(&gUnknown_083A05CC[0]); LoadSpritePalettes(gUnknown_083A05DC); sub_809308C(taskId); @@ -4997,7 +4997,7 @@ static void sub_8092508(u8 taskId) static void sub_80925B4(u16 a, int unused) { - sub_814AD7C(0x90, (a * 2 + 1) * 8); + MenuCursor_SetPos814AD7C(0x90, (a * 2 + 1) * 8); } static void sub_80925CC(u8 taskId) @@ -5036,7 +5036,7 @@ static void sub_8092644(u8 taskId) { sub_814ADC8(); PlaySE(SE_PIN); - MenuZeroFillWindowRect(18, 1, 28, 12); + Menu_EraseWindowRect(18, 1, 28, 12); sub_8092C8C(1); gTasks[taskId].func = sub_809217C; return; @@ -5045,7 +5045,7 @@ static void sub_8092644(u8 taskId) { sub_814ADC8(); PlaySE(SE_BOWA); - MenuZeroFillWindowRect(18, 1, 28, 12); + Menu_EraseWindowRect(18, 1, 28, 12); sub_8092C8C(1); *p1 = gTasks[taskId].data[14]; *p2 = gTasks[taskId].data[15]; @@ -5305,29 +5305,29 @@ static void sub_8092B68(u8 taskId) var = gTasks[taskId].data[6] + gTasks[taskId].data[7]; StringCopy(gStringVar1, gUnknown_083B5910[var].text2); - MenuPrint_PixelCoords(gUnknown_083B5AB2, 45, 16, 1); + Menu_PrintTextPixelCoords(gUnknown_083B5AB2, 45, 16, 1); var = gTasks[taskId].data[8] + gTasks[taskId].data[9]; StringCopy(gStringVar1, gUnknown_083B5968[var].text2); - MenuPrint_PixelCoords(gUnknown_083B5AB2, 45, 32, 1); + Menu_PrintTextPixelCoords(gUnknown_083B5AB2, 45, 32, 1); var = gTasks[taskId].data[10] + gTasks[taskId].data[11]; StringCopy(gStringVar1, gUnknown_083B59C8[var].text2); - MenuPrint_PixelCoords(gUnknown_083B5AAC, 45, 48, 1); + Menu_PrintTextPixelCoords(gUnknown_083B5AAC, 45, 48, 1); var = gTasks[taskId].data[12] + gTasks[taskId].data[13]; StringCopy(gStringVar1, gUnknown_083B59C8[var].text2); - MenuPrint_PixelCoords(gUnknown_083B5AAC, 93, 48, 1); + Menu_PrintTextPixelCoords(gUnknown_083B5AAC, 93, 48, 1); var = gTasks[taskId].data[4] + gTasks[taskId].data[5]; StringCopy(gStringVar1, gUnknown_083B58D8[var].text2); - MenuPrint_PixelCoords(gUnknown_083B5AB2, 45, 64, 1); + Menu_PrintTextPixelCoords(gUnknown_083B5AB2, 45, 64, 1); if (IsNationalPokedexEnabled()) { var = gTasks[taskId].data[2] + gTasks[taskId].data[3]; StringCopy(gStringVar1, gUnknown_083B58C0[var].text2); - MenuPrint_PixelCoords(gUnknown_083B5AB2, 45, 80, 1); + Menu_PrintTextPixelCoords(gUnknown_083B5AB2, 45, 80, 1); } } @@ -5374,13 +5374,13 @@ static void sub_8092D78(u8 taskId) u16 i; u16 j; - MenuZeroFillWindowRect(18, 1, 28, 12); + Menu_EraseWindowRect(18, 1, 28, 12); for (i = 0, j = *r7; i < 6 && r6[j].text2 != NULL; i++, j++) { #ifndef NONMATCHING j += 0; // Useless statement needed to match #endif - MenuPrint(r6[j].text2, 18, i * 2 + 1); + Menu_PrintText(r6[j].text2, 18, i * 2 + 1); } sub_8091E20(r6[*r8 + *r7].text1); } diff --git a/src/pokemon/pokemon_1.c b/src/pokemon/pokemon_1.c index f4d227f7f..bfd0bc972 100644 --- a/src/pokemon/pokemon_1.c +++ b/src/pokemon/pokemon_1.c @@ -308,7 +308,7 @@ void sub_803ADE8(struct Pokemon *mon, struct UnknownPokemonStruct *src) language = GAME_LANGUAGE; SetMonData(mon, MON_DATA_LANGUAGE, &language); - StripExtCtrlCodes(nickname); + Text_StripExtCtrlCodes(nickname); SetMonData(mon, MON_DATA_NICKNAME, nickname); SetMonData(mon, MON_DATA_FRIENDSHIP, &src->friendship); SetMonData(mon, MON_DATA_HP_EV, &src->hpEV); diff --git a/src/pokemon/pokemon_menu.c b/src/pokemon/pokemon_menu.c index 6c3c6c2b8..70234ac48 100644 --- a/src/pokemon/pokemon_menu.c +++ b/src/pokemon/pokemon_menu.c @@ -229,8 +229,8 @@ static void sub_8089A8C(void) static void sub_8089BDC(u8 arg0, u8 arg1, u8 arg2, u8 noOfOptions, const struct MenuAction2 *menuActions, const u8 *order, u8 arg6) { PrintPartyMenuPromptText(5, arg6); - MenuDrawTextWindow(arg0, arg1, arg0 + arg2, (noOfOptions * 2) + arg1 + 1); - PrintMenuItemsReordered(arg0 + 1, arg1 + 1, noOfOptions, menuActions, order); + Menu_DrawStdWindowFrame(arg0, arg1, arg0 + arg2, (noOfOptions * 2) + arg1 + 1); + Menu_PrintItemsReordered(arg0 + 1, arg1 + 1, noOfOptions, menuActions, order); } void sub_8089C50(u8 arg0, u8 arg1, u8 arg2, u8 noOfOptions, const struct MenuAction2 *menuActions, const u8 *order) @@ -279,13 +279,13 @@ static void sub_8089D94(u8 taskID) if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_UP) { PlaySE(SE_SELECT); - sPokeMenuCursorPos = MoveMenuCursor(-1); + sPokeMenuCursorPos = Menu_MoveCursor(-1); sub_808B5B4(taskID); } else if ((gMain.newAndRepeatedKeys & DPAD_ANY) == DPAD_DOWN) { PlaySE(SE_SELECT); - sPokeMenuCursorPos = MoveMenuCursor(1); + sPokeMenuCursorPos = Menu_MoveCursor(1); sub_808B5B4(taskID); } else if (gMain.newKeys & A_BUTTON) @@ -363,12 +363,12 @@ static void PokemonMenu_Summary(u8 taskID) void DoPokemonMenu_Switch(u8 taskID) { SetTaskFuncWithFollowupFunc(taskID, SetupDefaultPartyMenuSwitchPokemon, HandleDefaultPartyMenu); - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_EraseWindowRect(19, 0, 29, 19); } static void PokemonMenu_Switch(u8 taskID) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); ewram01000.unkC = sub_806CD5C; ewram01000.array[53553] = 1; DoPokemonMenu_Switch(taskID); @@ -378,12 +378,12 @@ static void sub_808A060(u8 taskID) { if (gMain.newKeys == DPAD_UP && sPokeMenuCursorPos != 0) { - sPokeMenuCursorPos = MoveMenuCursor(-1); + sPokeMenuCursorPos = Menu_MoveCursor(-1); PlaySE(SE_SELECT); } if (gMain.newKeys == DPAD_DOWN && sPokeMenuCursorPos != 2) { - sPokeMenuCursorPos = MoveMenuCursor(1); + sPokeMenuCursorPos = Menu_MoveCursor(1); PlaySE(SE_SELECT); } if (gMain.newKeys & A_BUTTON) @@ -407,9 +407,9 @@ static void sub_808A100(u8 taskID) static void PokemonMenu_Item(u8 taskID) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); sPokeMenuCursorPos = 0; - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_EraseWindowRect(19, 0, 29, 19); gTasks[taskID].func = sub_808A100; } @@ -442,7 +442,7 @@ static void sub_808A228(u8 taskID) } else { - MenuZeroFillWindowRect(0, 0, 29, 19); + Menu_EraseWindowRect(0, 0, 29, 19); PrintPartyMenuPromptText(0, 0); gTasks[taskID].func = HandleDefaultPartyMenu; } @@ -600,25 +600,25 @@ static void sub_808A678(u8 taskID) static void PokemonMenu_TakeItem(u8 taskID) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(19, 0, 29, 19); sub_806D5A4(); PartyMenuTryGiveMonHeldItem_806ECE8(taskID, sub_808A678); } static void PokemonMenu_TakeMail(u8 taskID) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_DestroyCursor(); + Menu_EraseWindowRect(19, 0, 29, 19); sub_806D5A4(); DoTakeMail(taskID, sub_808A678); } static void PokemonMenu_Mail(u8 taskID) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); sPokeMenuCursorPos = 0; - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_EraseWindowRect(19, 0, 29, 19); ShowPartyPopupMenu(0, &sUnknown_0839F584, (void*) sPokemonMenuActions, 0); gTasks[taskID].func = sub_808A73C; } @@ -629,17 +629,17 @@ static void sub_808A73C(u8 taskID) { PlaySE(SE_SELECT); if (sPokeMenuCursorPos == 0) - sPokeMenuCursorPos = MoveMenuCursor(sUnknown_0839F584.numChoices - 1); + sPokeMenuCursorPos = Menu_MoveCursor(sUnknown_0839F584.numChoices - 1); else - sPokeMenuCursorPos = MoveMenuCursor(-1); + sPokeMenuCursorPos = Menu_MoveCursor(-1); } if (gMain.newAndRepeatedKeys == DPAD_DOWN) { PlaySE(SE_SELECT); if (sPokeMenuCursorPos == sUnknown_0839F584.numChoices - 1) - sPokeMenuCursorPos = MoveMenuCursor(1 - sUnknown_0839F584.numChoices); + sPokeMenuCursorPos = Menu_MoveCursor(1 - sUnknown_0839F584.numChoices); else - sPokeMenuCursorPos = MoveMenuCursor(1); + sPokeMenuCursorPos = Menu_MoveCursor(1); } if (gMain.newKeys & A_BUTTON) { @@ -679,23 +679,23 @@ static void sub_808A8A8(void) static void sub_808A8D4(u8 taskID) { sPokeMenuCursorPos = 0; - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_EraseWindowRect(19, 0, 29, 19); PrintPartyMenuPromptText(0, 0); gTasks[taskID].func = HandleDefaultPartyMenu; } static void PokemonMenu_Cancel(u8 taskID) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); sub_808A8D4(taskID); } static void PokemonMenu_CancelSubmenu(u8 taskID) { - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); PlaySE(SE_SELECT); - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_EraseWindowRect(19, 0, 29, 19); sub_806D5A4(); sub_8089C7C(sPokeMenuCursorPos); gTasks[taskID].func = sub_8089D94; @@ -711,11 +711,11 @@ static void PokemonMenu_FieldMove(u8 taskID) { s16* data = gTasks[taskID].data; - HandleDestroyMenuCursors(); + Menu_DestroyCursor(); tFieldMoveId = sPokeMenuOptionsOrder[sPokeMenuCursorPos] - POKEMENU_FIRST_FIELD_MOVE_ID; if (sub_80F9344() == TRUE) { - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_EraseWindowRect(19, 0, 29, 19); if (IS_SOFTBOILED_MILKDRINK(tFieldMoveId)) PrintPartyMenuPromptText(9, 0); else @@ -725,7 +725,7 @@ static void PokemonMenu_FieldMove(u8 taskID) else if (tFieldMoveId <= 7 && FlagGet(FLAG_BADGE01_GET + tFieldMoveId) != TRUE) { // can't use a field HM move without a proper badge - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_EraseWindowRect(19, 0, 29, 19); sub_806D5A4(); sub_806E834(gOtherText_CantBeUsedBadge, 1); gTasks[taskID].func = sub_808AAF0; @@ -745,7 +745,7 @@ static void PokemonMenu_FieldMove(u8 taskID) } else { - MenuZeroFillWindowRect(19, 0, 29, 19); + Menu_EraseWindowRect(19, 0, 29, 19); if (IS_SURF(tFieldMoveId) && TestPlayerAvatarFlags(8)) PrintPartyMenuPromptText(8, 0); else @@ -759,7 +759,7 @@ static void sub_808AAF0(u8 taskID) { if (gUnknown_0202E8F6 != 1 && (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON)) { - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); PokemonMenu_Cancel(taskID); } } @@ -798,7 +798,7 @@ static void sub_808ABF4(u8 taskID) { if (gMain.newKeys & A_BUTTON || gMain.newKeys & B_BUTTON) { - MenuZeroFillWindowRect(1, 17, 28, 18); + Menu_EraseWindowRect(1, 17, 28, 18); PokemonMenu_Cancel(taskID); } } diff --git a/src/pokemon/pokemon_storage_system.c b/src/pokemon/pokemon_storage_system.c index aebd13498..80081c963 100644 --- a/src/pokemon/pokemon_storage_system.c +++ b/src/pokemon/pokemon_storage_system.c @@ -346,7 +346,7 @@ s16 StorageSystemGetNextMonIndex(struct BoxPokemon *box, s8 startIdx, u8 stopIdx void StorageSystemClearMessageWindow(void) { - MenuFillWindowRectWithBlankTile(2, 15, 27, 18); + Menu_BlankWindowRect(2, 15, 27, 18); } void Task_PokemonStorageSystem(u8 taskId) @@ -356,8 +356,8 @@ void Task_PokemonStorageSystem(u8 taskId) { case 0: StorageSystemCreatePrimaryMenu(task->data[1]); - MenuDisplayMessageBox(); - MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); + Menu_DisplayDialogueFrame(); + Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0]++; break; case 1: @@ -367,7 +367,7 @@ void Task_PokemonStorageSystem(u8 taskId) } break; case 2: - task->data[2] = ProcessMenuInput(); + task->data[2] = Menu_ProcessInput(); switch(task->data[2]) { case -2: @@ -381,13 +381,13 @@ void Task_PokemonStorageSystem(u8 taskId) { task->data[1] = task->data[3]; StorageSystemClearMessageWindow(); - MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); + Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15); } break; case -1: case 3: - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(0, 0, 13, 9); + Menu_DestroyCursor(); + Menu_EraseWindowRect(0, 0, 13, 9); ScriptContext2_Disable(); EnableBothScriptContexts(); DestroyTask(taskId); @@ -396,13 +396,13 @@ void Task_PokemonStorageSystem(u8 taskId) if (task->data[2] == 0 && StorageSystemGetPartySize() == PARTY_SIZE) { StorageSystemClearMessageWindow(); - MenuPrint(gPCText_PartyFull2, 2, 15); + Menu_PrintText(gPCText_PartyFull2, 2, 15); task->data[0] = 3; } else if (task->data[2] == 1 && StorageSystemGetPartySize() == 1) { StorageSystemClearMessageWindow(); - MenuPrint(gPCText_OnlyOne, 2, 15); + Menu_PrintText(gPCText_OnlyOne, 2, 15); task->data[0] = 3; } else @@ -417,27 +417,27 @@ void Task_PokemonStorageSystem(u8 taskId) if (gMain.newKeys & (A_BUTTON | B_BUTTON)) { StorageSystemClearMessageWindow(); - MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); + Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0] = 2; } else if (gMain.newKeys & DPAD_UP) { if (--task->data[1] < 0) task->data[1] = 3; - MoveMenuCursor(-1); - task->data[1] = GetMenuCursorPos(); + Menu_MoveCursor(-1); + task->data[1] = Menu_GetCursorPos(); StorageSystemClearMessageWindow(); - MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); + Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0] = 2; } else if (gMain.newKeys & DPAD_DOWN) { if (++task->data[1] > 3) task->data[1] = 0; - MoveMenuCursor(1); - task->data[1] = GetMenuCursorPos(); + Menu_MoveCursor(1); + task->data[1] = Menu_GetCursorPos(); StorageSystemClearMessageWindow(); - MenuPrint(gUnknown_083B600C[task->data[1]].desc, 2, 15); + Menu_PrintText(gUnknown_083B600C[task->data[1]].desc, 2, 15); task->data[0] = 2; } break; @@ -469,8 +469,8 @@ void FieldCB_ReturnToOverworld(void) void StorageSystemCreatePrimaryMenu(u8 whichMenu) { - MenuDrawTextWindow(0, 0, 13, 9); - PrintMenuItems(1, 1, 4, (const struct MenuAction *)gUnknown_083B600C); + Menu_DrawStdWindowFrame(0, 0, 13, 9); + Menu_PrintItems(1, 1, 4, (const struct MenuAction *)gUnknown_083B600C); InitMenu(0, 1, 1, 4, whichMenu, 12); } @@ -692,7 +692,7 @@ void sub_80966F4(const u8 *sourceString, u16 x, u16 y) u16 *vdest = (u16 *)(BG_CHAR_ADDR(4) + (GetSpriteTileStartByTag(gUnknown_02038478->unk_0240) * 32) + y * 256 + x * 32); u8 *tileBuff = gUnknown_083B6DB8; DmaFill16(3, 0x1111, tileBuff, 0x400); - sub_8004E3C(&gWindowConfig_81E6D38, tileBuff, sourceString); + Text_InitWindow8004E3C(&gWindowTemplate_81E6D38, tileBuff, sourceString); DmaCopy16(3, tileBuff, vdest, 0x400); } diff --git a/src/pokemon/pokemon_storage_system_2.c b/src/pokemon/pokemon_storage_system_2.c index f5eaa2166..290fa120a 100644 --- a/src/pokemon/pokemon_storage_system_2.c +++ b/src/pokemon/pokemon_storage_system_2.c @@ -203,12 +203,12 @@ void sub_8096884(void) gMain.state++; break; case 1: - SetUpWindowConfig(&gWindowConfig_81E6D00); + Text_LoadWindowTemplate(&gWindowTemplate_81E6D00); gMain.state++; break; case 2: - InitMenuWindow(&gWindowConfig_81E6D00); - MenuZeroFillScreen(); + InitMenuWindow(&gWindowTemplate_81E6D00); + Menu_EraseScreen(); gMain.state++; break; case 3: @@ -267,12 +267,12 @@ void sub_80969A0(void) gMain.state++; break; case 1: - SetUpWindowConfig(&gWindowConfig_81E6D00); + Text_LoadWindowTemplate(&gWindowTemplate_81E6D00); gMain.state++; break; case 2: - InitMenuWindow(&gWindowConfig_81E6D00); - MenuZeroFillScreen(); + InitMenuWindow(&gWindowTemplate_81E6D00); + Menu_EraseScreen(); gMain.state++; break; case 3: @@ -900,7 +900,7 @@ void sub_8097594(void) gPokemonStorageSystemPtr->unk_0004++; // fallthrough case 1: - switch (ProcessMenuInputNoWrap()) + switch (Menu_ProcessInputNoWrap()) { case -1: case 1: @@ -1268,7 +1268,7 @@ void sub_8097BA0(void) } break; case 2: - switch (ProcessMenuInputNoWrap()) + switch (Menu_ProcessInputNoWrap()) { case 1: case -1: @@ -1322,7 +1322,7 @@ void sub_8097CC0(void) { } break; case 2: - switch (ProcessMenuInputNoWrap()) { + switch (Menu_ProcessInputNoWrap()) { case 0: sub_8098A5C(); SetPSSCallback(sub_8096C84); @@ -1666,11 +1666,11 @@ void sub_80982B4(void) { gPokemonStorageSystemPtr->unk_12ac->invisible = TRUE; } - MenuZeroFillWindowRect(0, 11, 9, 17); - MenuPrint(gPokemonStorageSystemPtr->unk_127a, 1, 16); - MenuPrint(gPokemonStorageSystemPtr->unk_120f, 1, 11); - MenuPrint(gPokemonStorageSystemPtr->unk_1234, 0, 13); - MenuPrint(gPokemonStorageSystemPtr->unk_1259, 1, 15); + Menu_EraseWindowRect(0, 11, 9, 17); + Menu_PrintText(gPokemonStorageSystemPtr->unk_127a, 1, 16); + Menu_PrintText(gPokemonStorageSystemPtr->unk_120f, 1, 11); + Menu_PrintText(gPokemonStorageSystemPtr->unk_1234, 0, 13); + Menu_PrintText(gPokemonStorageSystemPtr->unk_1259, 1, 15); } void sub_8098350(void) @@ -1881,7 +1881,7 @@ const struct StorageAction gPCStorageActionTexts[] = { void PrintStorageActionText(u8 index) { u8 *ptr; - MenuDrawTextWindow(10, 16, 29, 19); + Menu_DrawStdWindowFrame(10, 16, 29, 19); switch (gPCStorageActionTexts[index].format) { @@ -1954,7 +1954,7 @@ void PrintStorageActionText(u8 index) { } ptr[0] = EOS; - MenuPrint(gPokemonStorageSystemPtr->unk_2694, 11, 17); + Menu_PrintText(gPokemonStorageSystemPtr->unk_2694, 11, 17); } const struct OamData gOamData_83B6EAC = { @@ -2009,14 +2009,14 @@ const struct SpriteTemplate gSpriteTemplate_83B6EFC = { void sub_8098A38(s8 a0) { DisplayYesNoMenu(23, 10, 0); - MoveMenuCursor(a0); + Menu_MoveCursor(a0); } void sub_8098A5C(void) { - HandleDestroyMenuCursors(); - MenuZeroFillWindowRect(10, 16, 29, 19); - MenuZeroFillWindowRect(23, 10, 29, 15); + Menu_DestroyCursor(); + Menu_EraseWindowRect(10, 16, 29, 19); + Menu_EraseWindowRect(23, 10, 29, 15); } void sub_8098A80(void) diff --git a/src/pokemon/pokemon_summary_screen.c b/src/pokemon/pokemon_summary_screen.c index fb8363569..ce83ad070 100644 --- a/src/pokemon/pokemon_summary_screen.c +++ b/src/pokemon/pokemon_summary_screen.c @@ -29,7 +29,7 @@ #include "strings2.h" #include "task.h" #include "tv.h" -#include "unknown_task.h" +#include "scanline_effect.h" static void sub_809FC0C(void); static void sub_809FEB8(void); @@ -123,12 +123,12 @@ extern u8 StorageSystemGetNextMonIndex(struct BoxPokemon *, u8, u8, u8); extern struct MusicPlayerInfo gMPlay_BGM; extern u8 gUnknown_020384F0; extern u8 gUnknown_08208238[]; -extern u16 gUnknown_030041B8; +extern u16 gBattle_BG3_Y; extern u16 gBattle_BG2_Y; extern u16 gBattle_BG1_Y; extern u16 gBattle_BG1_X; extern u16 gBattle_BG2_X; -extern u16 gUnknown_030041B0; +extern u16 gBattle_BG3_X; extern TaskFunc gUnknown_03005CF0; extern struct Sprite *gUnknown_020384F4; extern struct SpriteTemplate gUnknown_02024E8C; @@ -585,8 +585,8 @@ void sub_809D85C(void) REG_BG1VOFS = gBattle_BG1_Y; REG_BG2HOFS = gBattle_BG2_X; REG_BG2VOFS = gBattle_BG2_Y; - REG_BG3HOFS = gUnknown_030041B0; - REG_BG3VOFS = gUnknown_030041B8; + REG_BG3HOFS = gBattle_BG3_X; + REG_BG3VOFS = gBattle_BG3_Y; LoadOam(); ProcessSpriteCopyRequests(); @@ -700,7 +700,7 @@ bool8 sub_809DA84(void) gMain.state++; break; case 1: - remove_some_task(); + ScanlineEffect_Stop(); gMain.state++; break; case 2: @@ -717,11 +717,11 @@ bool8 sub_809DA84(void) gMain.state++; break; case 5: - SetUpWindowConfig(&gWindowConfig_81E6E6C); + Text_LoadWindowTemplate(&gWindowTemplate_81E6E6C); gMain.state++; break; case 6: - MultistepInitMenuWindowBegin(&gWindowConfig_81E6E6C); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E6E6C); gMain.state++; break; case 7: @@ -812,11 +812,11 @@ bool8 sub_809DA84(void) case 20: if (GetMonData(&pssData.loadedMon, MON_DATA_IS_EGG)) { - gUnknown_030041B0 = 256; + gBattle_BG3_X = 256; } else { - gUnknown_030041B0 = 0; + gBattle_BG3_X = 0; } gMain.state++; @@ -871,8 +871,8 @@ static void sub_809DE64(void) gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 0; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 0; + gBattle_BG3_Y = 0; REG_BG0HOFS = 0; REG_BG0VOFS = 0; @@ -1036,7 +1036,7 @@ static void sub_809E260(u8 taskId) { if (pssData.page == PSS_PAGE_CONTEST_MOVES && (pssData.selectedMoveIndex != 4 || pssData.moveToLearn != 0)) { - MenuZeroFillWindowRect(0, 14, 9, 18); + Menu_EraseWindowRect(0, 14, 9, 18); } SummaryScreenHandleLeftRightInput(taskId, -1); @@ -1047,7 +1047,7 @@ static void sub_809E260(u8 taskId) { if (pssData.page == PSS_PAGE_BATTLE_MOVES && (pssData.selectedMoveIndex != 4 || pssData.moveToLearn != 0)) { - MenuZeroFillWindowRect(0, 14, 9, 18); + Menu_EraseWindowRect(0, 14, 9, 18); } SummaryScreenHandleLeftRightInput(taskId, 1); @@ -1481,8 +1481,8 @@ static void sub_809EAC8(u8 taskId) sub_80A1B1C(9); sub_80A16CC(1); - MenuZeroFillWindowRect(15, 12, 28, 13); - MenuZeroFillWindowRect(11, 15, 28, 18); + Menu_EraseWindowRect(15, 12, 28, 13); + Menu_EraseWindowRect(11, 15, 28, 18); pssData.headerActionTextId = 6; PrintSummaryWindowHeaderText(); @@ -2175,11 +2175,11 @@ void sub_809F43C(u8 taskId) pssData.loadGfxState = 0; if (GetMonData(&pssData.loadedMon, MON_DATA_IS_EGG)) { - gUnknown_030041B0 = 256; + gBattle_BG3_X = 256; } else { - gUnknown_030041B0 = 0; + gBattle_BG3_X = 0; } gMain.state++; @@ -2370,7 +2370,7 @@ void sub_809F814(u8 taskId) { if (pssData.page == PSS_PAGE_CONTEST_MOVES && (pssData.selectedMoveIndex != 4 || pssData.moveToLearn != 0)) { - MenuZeroFillWindowRect(0, 14, 9, 18); + Menu_EraseWindowRect(0, 14, 9, 18); } gTasks[taskId].func = sub_809E260; @@ -2386,7 +2386,7 @@ void sub_809F814(u8 taskId) { if (pssData.page == PSS_PAGE_BATTLE_MOVES && (pssData.selectedMoveIndex != 4 || pssData.moveToLearn != 0)) { - MenuZeroFillWindowRect(0, 14, 9, 18); + Menu_EraseWindowRect(0, 14, 9, 18); } gTasks[taskId].func = sub_809E260; @@ -2413,8 +2413,8 @@ static void sub_809F9D0(u8 taskId, u8 b) sub_80A1488(-2, 4); sub_80A1654(-2, 4); - MenuZeroFillWindowRect(11, 15, 28, 18); - MenuPrint(gOtherText_CantForgetHMs, 11, 15); + Menu_EraseWindowRect(11, 15, 28, 18); + Menu_PrintText(gOtherText_CantForgetHMs, 11, 15); gTasks[taskId].func = sub_809F814; } @@ -2493,9 +2493,9 @@ static void sub_809FAC8(struct Pokemon *mon) if (GetMonData(mon, MON_DATA_IS_EGG)) { - MenuZeroFillWindowRect(1, 2, 4, 3); - MenuZeroFillWindowRect(3, 16, 9, 17); - MenuZeroFillWindowRect(0, 12, 11, 15); + Menu_EraseWindowRect(1, 2, 4, 3); + Menu_EraseWindowRect(3, 16, 9, 17); + Menu_EraseWindowRect(0, 12, 11, 15); GetMonNickname(mon, gStringVar1); sub_80A1FF8(gStringVar1, 13, 3, 16); LoadPalette(sUnknown_083C157C, 4, 2); @@ -2519,7 +2519,7 @@ static void sub_809FAC8(struct Pokemon *mon) } else { - MenuZeroFillWindowRect(1, 2, 4, 3); + Menu_EraseWindowRect(1, 2, 4, 3); } buffer = gStringVar1; @@ -2529,7 +2529,7 @@ static void sub_809FAC8(struct Pokemon *mon) buffer[1] = 0x13; buffer[2] = 0x3C; buffer[3] = EOS; - MenuPrint(gStringVar1, 1, 12); + Menu_PrintText(gStringVar1, 1, 12); sub_80A0958(mon); } @@ -2544,12 +2544,12 @@ static void sub_809FBE4(void) sub_80A1918(i, 1); } - MenuZeroFillWindowRect(11, 4, 29, 18); + Menu_EraseWindowRect(11, 4, 29, 18); } static void sub_809FC0C(void) { - MenuPrint(gOtherText_Type2, 11, 6); + Menu_PrintText(gOtherText_Type2, 11, 6); GetStringCenterAlignXOffset(0, 22, 4); GetStringCenterAlignXOffset(2, 23, 4); } @@ -2568,7 +2568,7 @@ static void sub_809FC34(struct Pokemon *mon) sub_80A1918(i, 1); } - MenuZeroFillWindowRect(11, 9, 28, 12); + Menu_EraseWindowRect(11, 9, 28, 12); if (GetMonData(mon, MON_DATA_IS_EGG)) { buffer = gStringVar1; @@ -2579,7 +2579,7 @@ static void sub_809FC34(struct Pokemon *mon) buffer[1] = 0x13; buffer[2] = 0x4E; buffer[3] = EOS; - MenuPrint(gStringVar1, 11, 4); + Menu_PrintText(gStringVar1, 11, 4); sub_80A1EF8(gOtherText_FiveQuestionsAndSlash, 13, 193, 32, 1); sub_80A198C(9, 120, 48, 0); @@ -2587,19 +2587,19 @@ static void sub_809FC34(struct Pokemon *mon) friendship = GetMonData(mon, MON_DATA_FRIENDSHIP); if (friendship < 6) { - MenuPrint(gOtherText_EggAbout, 11, 9); + Menu_PrintText(gOtherText_EggAbout, 11, 9); } else if (friendship < 11) { - MenuPrint(gOtherText_EggSoon, 11, 9); + Menu_PrintText(gOtherText_EggSoon, 11, 9); } else if (friendship < 41) { - MenuPrint(gOtherText_EggSomeTime, 11, 9); + Menu_PrintText(gOtherText_EggSomeTime, 11, 9); } else { - MenuPrint(gOtherText_EggLongTime, 11, 9); + Menu_PrintText(gOtherText_EggLongTime, 11, 9); } PokemonSummaryScreen_PrintEggTrainerMemo(mon, 11, 14); @@ -2628,7 +2628,7 @@ static void sub_809FC34(struct Pokemon *mon) buffer[1] = 0x13; buffer[2] = 0x4E; buffer[3] = EOS; - MenuPrint(gStringVar1, 11, 4); + Menu_PrintText(gStringVar1, 11, 4); sub_80A1F98(GetMonData(mon, MON_DATA_OT_ID) & 0xFFFF, 13, 5, 2, 193, 32, 1); @@ -2641,7 +2641,7 @@ static void sub_809FC34(struct Pokemon *mon) ability = GetAbilityBySpecies(GetMonData(mon, MON_DATA_SPECIES), GetMonData(mon, MON_DATA_ALT_ABILITY)); sub_80A1FF8(gAbilityNames[ability], 13, 11, 9); - MenuPrint(gAbilityDescriptions[ability], 11, 11); + Menu_PrintText(gAbilityDescriptions[ability], 11, 11); PokemonSummaryScreen_PrintTrainerMemo(mon, 11, 14); } @@ -2655,17 +2655,17 @@ static void sub_809FE6C(struct Pokemon *mon) static void sub_809FE80(void) { - MenuZeroFillWindowRect(14, 4, 18, 5); - MenuZeroFillWindowRect(25, 4, 30, 5); - MenuZeroFillWindowRect(11, 9, 28, 12); - MenuZeroFillWindowRect(11, 14, 28, 17); + Menu_EraseWindowRect(14, 4, 18, 5); + Menu_EraseWindowRect(25, 4, 30, 5); + Menu_EraseWindowRect(11, 9, 28, 12); + Menu_EraseWindowRect(11, 14, 28, 17); } static void sub_809FEB8(void) { sub_80A1FF8(gOtherText_ExpPoints, 13, 11, 14); sub_80A1FF8(gOtherText_NextLv, 13, 11, 16); - MenuPrint(gOtherText_Terminator18, 21, 16); + Menu_PrintText(gOtherText_Terminator18, 21, 16); sub_80A1F48(gOtherText_HP, 13, 11, 7, 42); sub_80A1F48(gOtherText_Attack, 13, 11, 9, 42); @@ -2715,7 +2715,7 @@ static void sub_809FF64(struct Pokemon *mon) *buffer++ = CHAR_SLASH; buffer = sub_8072C14(buffer, GetMonData(mon, MON_DATA_MAX_HP), 48, 1); - MenuPrint_PixelCoords(gStringVar1, 126, 56, 1); + Menu_PrintTextPixelCoords(gStringVar1, 126, 56, 1); } static void sub_80A0090(struct Pokemon *mon) @@ -2726,12 +2726,12 @@ static void sub_80A0090(struct Pokemon *mon) static void sub_80A00A4(void) { - MenuZeroFillWindowRect(11, 4, 19, 5); - MenuZeroFillWindowRect(16, 7, 21, 8); - MenuZeroFillWindowRect(17, 9, 21, 12); - MenuZeroFillWindowRect(27, 7, 29, 12); - MenuZeroFillWindowRect(22, 14, 28, 15); - MenuZeroFillWindowRect(23, 16, 28, 17); + Menu_EraseWindowRect(11, 4, 19, 5); + Menu_EraseWindowRect(16, 7, 21, 8); + Menu_EraseWindowRect(17, 9, 21, 12); + Menu_EraseWindowRect(27, 7, 29, 12); + Menu_EraseWindowRect(22, 14, 28, 15); + Menu_EraseWindowRect(23, 16, 28, 17); } static void sub_80A00F4(u8 a) @@ -2769,7 +2769,7 @@ static void sub_80A015C(struct Pokemon *mon) { sub_80A1918(i, 1); sub_80A1FF8(gOtherText_OneDash, 13, 15, (2 * i) + 4); - MenuPrint(gOtherText_TwoDashes, 26, (2 * i) + 4); + Menu_PrintText(gOtherText_TwoDashes, 26, (2 * i) + 4); } else { @@ -2792,7 +2792,7 @@ static void sub_80A015C(struct Pokemon *mon) buffer = sub_8072C14(buffer, curPP, 14, 1); *buffer++ = CHAR_SLASH; sub_8072C14(buffer, maxPP, 32, 1); - MenuPrint(gStringVar1, 25, (2 * i) + 4); + Menu_PrintText(gStringVar1, 25, (2 * i) + 4); } } } @@ -2828,7 +2828,7 @@ static void sub_80A029C(struct Pokemon *mon) buffer = sub_8072C14(buffer, pp, 14, 1); *buffer++ = CHAR_SLASH; buffer = sub_8072C14(buffer, pp, 32, 1); - MenuPrint(gStringVar1, 25, 12); + Menu_PrintText(gStringVar1, 25, 12); } static void sub_80A0390(void) @@ -2837,7 +2837,7 @@ static void sub_80A0390(void) for (i = 0; i < MAX_MON_MOVES; i++) { - MenuZeroFillWindowRect(15, (i * 2) + 4, 28, (i * 2) + 5); + Menu_EraseWindowRect(15, (i * 2) + 4, 28, (i * 2) + 5); } } @@ -2882,7 +2882,7 @@ void sub_80A03F0(struct Pokemon *mon, u8 *selectedMoveIndex) static void sub_80A0428(struct Pokemon *mon, u8 *selectedMoveIndex) { u16 move = sub_80A03BC(mon, *selectedMoveIndex); - MenuZeroFillWindowRect(11, 15, 28, 18); + Menu_EraseWindowRect(11, 15, 28, 18); if (pssData.page == PSS_PAGE_BATTLE_MOVES) { @@ -2900,14 +2900,14 @@ static void sub_80A046C(u16 move) { if (move == 0xFFFF) return; - MenuPrint(gMoveDescriptions[move - 1], 11, 15); + Menu_PrintText(gMoveDescriptions[move - 1], 11, 15); } static void sub_80A0498(u16 move) { if (move == 0xFFFF) return; - MenuPrint(gContestEffectStrings[gContestMoves[move].effect], 11, 15); + Menu_PrintText(gContestEffectStrings[gContestMoves[move].effect], 11, 15); } static void sub_80A04CC(u16 move) @@ -2920,26 +2920,26 @@ static void sub_80A04CC(u16 move) { buffer = gStringVar1; buffer = sub_8072C74(buffer, gOtherText_ThreeDashes2, 21, 1); - MenuPrint(gStringVar1, 7, 15); + Menu_PrintText(gStringVar1, 7, 15); } else { buffer = gStringVar1; buffer = sub_8072C14(buffer, gBattleMoves[move].power, 21, 1); - MenuPrint(gStringVar1, 7, 15); + Menu_PrintText(gStringVar1, 7, 15); } if (gBattleMoves[move].accuracy == 0) { buffer = gStringVar1; buffer = sub_8072C74(buffer, gOtherText_ThreeDashes2, 21, 1); - MenuPrint(gStringVar1, 7, 17); + Menu_PrintText(gStringVar1, 7, 17); } else { buffer = gStringVar1; buffer = sub_8072C14(buffer, gBattleMoves[move].accuracy, 21, 1); - MenuPrint(gStringVar1, 7, 17); + Menu_PrintText(gStringVar1, 7, 17); } } @@ -3126,7 +3126,7 @@ bool8 PokemonSummaryScreen_CheckOT(struct Pokemon *mon) u8 enemyId = GetMultiplayerId() ^ 1; trainerId = gLinkPlayers[enemyId].trainerId & 0xFFFF; StringCopy(gStringVar1, gLinkPlayers[enemyId].name); - StripExtCtrlCodes(gStringVar1); + Text_StripExtCtrlCodes(gStringVar1); } else { @@ -3152,7 +3152,7 @@ static void PokemonSummaryScreen_PrintEggTrainerMemo(struct Pokemon *mon, u8 lef if (!(gameMet == VERSION_RUBY || gameMet == VERSION_SAPPHIRE || gameMet == VERSION_EMERALD)) { - MenuPrint(gOtherText_EggObtainedInTrade, left, top); + Menu_PrintText(gOtherText_EggObtainedInTrade, left, top); return; } @@ -3161,13 +3161,13 @@ static void PokemonSummaryScreen_PrintEggTrainerMemo(struct Pokemon *mon, u8 lef if (locationMet == 255) { // Eggs received from Pokemon Box. - MenuPrint(gOtherText_EggNicePlace, left, top); + Menu_PrintText(gOtherText_EggNicePlace, left, top); return; } if (!PokemonSummaryScreen_CheckOT(mon)) { - MenuPrint(gOtherText_EggObtainedInTrade, left, top); + Menu_PrintText(gOtherText_EggObtainedInTrade, left, top); return; } @@ -3175,11 +3175,11 @@ static void PokemonSummaryScreen_PrintEggTrainerMemo(struct Pokemon *mon, u8 lef if (locationMet == 253) { - MenuPrint(gOtherText_EggHotSprings, left, top); + Menu_PrintText(gOtherText_EggHotSprings, left, top); return; } - MenuPrint(gOtherText_EggDayCare, left, top); + Menu_PrintText(gOtherText_EggDayCare, left, top); } static void PokemonSummaryScreen_PrintTrainerMemo(struct Pokemon *mon, u8 left, u8 top) @@ -3284,7 +3284,7 @@ static void PokemonSummaryScreen_PrintTrainerMemo(struct Pokemon *mon, u8 left, } } - MenuPrint(gStringVar4, left++, top++); + Menu_PrintText(gStringVar4, left++, top++); } static void sub_80A0958(struct Pokemon *mon) @@ -3309,8 +3309,8 @@ static void sub_80A0958(struct Pokemon *mon) buffer[2] = 0x50; buffer[3] = EOS; - MenuPrint(gStringVar1, 0, 14); - MenuZeroFillWindowRect(3, 16, 9, 17); + Menu_PrintText(gStringVar1, 0, 14); + Menu_EraseWindowRect(3, 16, 9, 17); level = GetMonData(mon, MON_DATA_LEVEL); @@ -3324,7 +3324,7 @@ static void sub_80A0958(struct Pokemon *mon) buffer[2] = 0x20; buffer[3] = EOS; - MenuPrint(gStringVar1, 3, 16); + Menu_PrintText(gStringVar1, 3, 16); sub_80A0A2C(mon, 7, 16); } @@ -3342,7 +3342,7 @@ static void sub_80A0A2C(struct Pokemon *mon, u8 left, u8 top) { default: bottom = top + 1; - MenuZeroFillWindowRect(left, top, left, bottom); + Menu_EraseWindowRect(left, top, left, bottom); return; case MON_MALE: genderSymbol = gOtherText_MaleSymbol2; @@ -3405,7 +3405,7 @@ static void PrintNumRibbons(struct Pokemon *mon) ConvertIntToDecimalStringN(&text[3], numRibbons, 1, 2); } - MenuPrint(sUnknown_083C15AE, 21, 4); + Menu_PrintText(sUnknown_083C15AE, 21, 4); } static void PrintHeldItemName(u16 itemId, u8 left, u8 top) @@ -3426,7 +3426,7 @@ static void PrintHeldItemName(u16 itemId, u8 left, u8 top) CopyItemName(itemId, gStringVar1); } - MenuPrint(sUnknown_083C15B4, left, top); + Menu_PrintText(sUnknown_083C15B4, left, top); } static void DrawExperienceProgressBar(struct Pokemon *mon, u8 left, u8 top) @@ -3517,7 +3517,7 @@ static void PrintSummaryWindowHeaderText(void) buffer[2] = 0x58; buffer[3] = EOS; - MenuPrint(gStringVar1, 0, 0); + Menu_PrintText(gStringVar1, 0, 0); if (pssData.headerActionTextId != 0) { @@ -3526,7 +3526,7 @@ static void PrintSummaryWindowHeaderText(void) } else { - MenuZeroFillWindowRect(23, 0, 24, 1); + Menu_EraseWindowRect(23, 0, 24, 1); } buffer = gStringVar1; @@ -3538,7 +3538,7 @@ static void PrintSummaryWindowHeaderText(void) buffer[2] = 0x28; buffer[3] = EOS; - MenuPrint(gStringVar1, 25, 0); + Menu_PrintText(gStringVar1, 25, 0); } // If the given pokemon previously had the pokerus virus, a small @@ -4137,7 +4137,7 @@ static void sub_80A12D0(s8 a) { u8 newTaskId; - MenuZeroFillWindowRect(1, 18, 5, 19); + Menu_EraseWindowRect(1, 18, 5, 19); sub_80A18E4(29); newTaskId = CreateTask(sub_80A1048, 0); @@ -4193,14 +4193,14 @@ static void sub_80A12D0(s8 a) // } // else // { -// MenuZeroFillWindowRect(0, 19, 9, 19); +// Menu_EraseWindowRect(0, 19, 9, 19); // } // if (gTasks[taskId].data[0] == 0 || gTasks[taskId].data[1] < 0) // { // if (pssData.page == PSS_PAGE_BATTLE_MOVES) // { -// MenuZeroFillWindowRect(0, 14, 9, 18); +// Menu_EraseWindowRect(0, 14, 9, 18); // sub_80A0958(pssData.loadedMon); // if (GetMonStatusAndPokerus(pssData.loadedMon)) @@ -4326,7 +4326,7 @@ _080A13F4:\n\ movs r1, 0x13\n\ movs r2, 0x9\n\ movs r3, 0x13\n\ - bl MenuZeroFillWindowRect\n\ + bl Menu_EraseWindowRect\n\ _080A1400:\n\ movs r1, 0\n\ ldrsh r0, [r7, r1]\n\ @@ -4345,7 +4345,7 @@ _080A1410:\n\ movs r1, 0xE\n\ movs r2, 0x9\n\ movs r3, 0x12\n\ - bl MenuZeroFillWindowRect\n\ + bl Menu_EraseWindowRect\n\ adds r4, 0x10\n\ adds r0, r4, 0\n\ bl sub_80A0958\n\ @@ -4403,7 +4403,7 @@ static void sub_80A1488(s8 a, u8 b) if (pssData.page == PSS_PAGE_BATTLE_MOVES) { - MenuZeroFillWindowRect(0, 14, 9, 19); + Menu_EraseWindowRect(0, 14, 9, 19); } taskId = FindTaskIdByFunc(sub_80A1334); @@ -4530,7 +4530,7 @@ _080A15C0:\n\ movs r1, 0x13\n\ movs r2, 0x9\n\ movs r3, 0x13\n\ - bl MenuZeroFillWindowRect\n\ + bl Menu_EraseWindowRect\n\ _080A15CC:\n\ movs r1, 0\n\ ldrsh r0, [r7, r1]\n\ @@ -4549,7 +4549,7 @@ _080A15DC:\n\ movs r1, 0xE\n\ movs r2, 0x9\n\ movs r3, 0x12\n\ - bl MenuZeroFillWindowRect\n\ + bl Menu_EraseWindowRect\n\ adds r4, 0x10\n\ adds r0, r4, 0\n\ bl sub_80A0958\n\ @@ -4605,7 +4605,7 @@ static void sub_80A1654(s8 a, u8 b) if (pssData.page == PSS_PAGE_CONTEST_MOVES) { - MenuZeroFillWindowRect(0, 14, 9, 19); + Menu_EraseWindowRect(0, 14, 9, 19); } taskId = FindTaskIdByFunc(sub_80A1500); @@ -5271,7 +5271,7 @@ u8 *sub_80A1E9C(u8 *dest, const u8 *src, u8 id) { u8 arr[3]; - sub_8072CD4(&arr[0], &arr[1], &arr[2]); + Menu_GetTextColors(&arr[0], &arr[1], &arr[2]); dest = sub_80A1E58(dest, id); dest = StringCopy(dest, src); @@ -5294,7 +5294,7 @@ u8 *sub_80A1E9C(u8 *dest, const u8 *src, u8 id) static void sub_80A1EF8(const u8 *text, u8 id, u8 left, u16 top, s32 e) { sub_80A1E9C(gStringVar4, text, id); - MenuPrint_PixelCoords(gStringVar4, left, top, (bool8)e); + Menu_PrintTextPixelCoords(gStringVar4, left, top, (bool8)e); } static void sub_80A1F48(const u8 *text, u8 id, u8 c, u8 d, u16 e) @@ -5312,7 +5312,7 @@ static void sub_80A1F98(s32 value, u8 id, u8 n, u8 mode, u8 left, u16 top, s32 e static void sub_80A1FF8(const u8 *text, u8 id, u8 left, u8 top) { sub_80A1E9C(gStringVar4, text, id); - MenuPrint(gStringVar4, left, top); + Menu_PrintText(gStringVar4, left, top); } u8 *PokemonSummaryScreen_CopyPokemonLevel(u8 *dest, u8 level) diff --git a/src/pokenav_before.c b/src/pokenav_before.c index ee5bdb1cb..600c5aba8 100644 --- a/src/pokenav_before.c +++ b/src/pokenav_before.c @@ -18,7 +18,7 @@ #include "sound.h" #include "task.h" #include "text.h" -#include "unknown_task.h" +#include "scanline_effect.h" extern u8 ewram[]; @@ -328,7 +328,7 @@ void sub_80EBA5C() ResetTasks(); break; case 6: - remove_some_task(); + ScanlineEffect_Stop(); break; case 7: sub_80F1A90(); @@ -435,7 +435,7 @@ void sub_80EBD4C() ProcessSpriteCopyRequests(); TransferPlttBuffer(); sub_80F5BF0(); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); } void sub_80EBD68() @@ -3267,10 +3267,10 @@ bool8 sub_80EF284(u8 a) sub_80EEDE8(); break; case 1: - SetUpWindowConfig(&gWindowConfig_81E7224); + Text_LoadWindowTemplate(&gWindowTemplate_81E7224); break; case 2: - MultistepInitMenuWindowBegin(&gWindowConfig_81E7224); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E7224); break; case 3: if (!MultistepInitMenuWindowContinue()) @@ -3336,7 +3336,7 @@ void sub_80EF428(u8 a, u8 b) tileBuffer = gUnknown_083DFEC8; sub_8072C74(&tileBuffer[0x800], pcText, 0xC0, 2); - MenuPrint(&tileBuffer[0x800], 3, 17); + Menu_PrintText(&tileBuffer[0x800], 3, 17); } void sub_80EF490(u8 a) @@ -3659,17 +3659,17 @@ bool8 sub_80EF874(void) sub_80EEDE8(); break; case 1: - SetUpWindowConfig(&gWindowConfig_81E7224); + Text_LoadWindowTemplate(&gWindowTemplate_81E7224); break; case 2: - MultistepInitMenuWindowBegin(&gWindowConfig_81E7224); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E7224); break; case 3: if (!MultistepInitMenuWindowContinue()) return TRUE; break; case 4: - MenuZeroFillScreen(); + Menu_EraseScreen(); break; case 5: sub_80FA904(&gUnknown_083DFEC4->regionMap, gSaveBlock2.regionMapZoom ? TRUE : FALSE); @@ -3690,7 +3690,7 @@ bool8 sub_80EF874(void) return TRUE; break; case 10: - MenuDrawTextWindow(13, 3, 29, 17); + Menu_DrawStdWindowFrame(13, 3, 29, 17); sub_80EF9F8(); break; case 11: @@ -3764,8 +3764,8 @@ void sub_80EF9F8(void) b = gUnknown_083DFEC4->regionMap.everGrandeCityArea; if (gUnknown_083DFEC4->unkCDCC[mapSectionId][b] != NULL) { - MenuFillWindowRectWithBlankTile(14, top, 15, 15); - MenuFillWindowRectWithBlankTile(26, top, 28, 15); + Menu_BlankWindowRect(14, top, 15, 15); + Menu_BlankWindowRect(26, top, 28, 15); sub_8095C8C((void *)(VRAM + 0xF800), 16, 6, gUnknown_083DFEC4->unkCDCC[mapSectionId][b], 0, 0, 10, 10, 10); top += 11; } @@ -3778,7 +3778,7 @@ void sub_80EF9F8(void) // Epic fail by the compiler at optimizing this. if (!someBool && top < 16) - MenuFillWindowRectWithBlankTile(14, top, 28, 15); + Menu_BlankWindowRect(14, top, 28, 15); if (gUnknown_083DFEC4->regionMap.unk16 == 2) sub_80EFD74(); @@ -3971,17 +3971,17 @@ bool8 sub_80EFF68(void) gUnknown_083DFEC4->unkD162[0] = 11; break; case 1: - SetUpWindowConfig(&gWindowConfig_81E7080); + Text_LoadWindowTemplate(&gWindowTemplate_81E7080); break; case 2: - MultistepInitMenuWindowBegin(&gWindowConfig_81E7080); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E7080); break; case 3: if (!MultistepInitMenuWindowContinue()) return TRUE; break; case 4: - MenuZeroFillScreen(); + Menu_EraseScreen(); break; case 5: sub_80F1614(); @@ -4049,13 +4049,13 @@ void sub_80F01A4(void) void sub_80F01E0(u16 a) { - MenuPrint(gUnknown_083DFEC4->unk8829[a], 13, 1); + Menu_PrintText(gUnknown_083DFEC4->unk8829[a], 13, 1); if (gUnknown_083DFEC4->unk76AA == 1) { - MenuPrint(gUnknown_083DFEC4->unk88E9[a], 13, 3); + Menu_PrintText(gUnknown_083DFEC4->unk88E9[a], 13, 3); sub_80F443C(gUnknown_083DFEC4->unk8788, gUnknown_083DFEC4->unk893c[gUnknown_083DFEC4->unk87DC].unk2); - MenuPrint(gUnknown_083DFEC4->unk8788, 1, 6); + Menu_PrintText(gUnknown_083DFEC4->unk8788, 1, 6); } } @@ -4085,10 +4085,10 @@ bool8 sub_80F02A0(void) gUnknown_083DFEC4->unkD162[0] = 11; break; case 1: - SetUpWindowConfig(&gWindowConfig_81E70D4); + Text_LoadWindowTemplate(&gWindowTemplate_81E70D4); break; case 2: - MultistepInitMenuWindowBegin(&gWindowConfig_81E70D4); + MultistepInitMenuWindowBegin(&gWindowTemplate_81E70D4); break; case 3: if (!MultistepInitMenuWindowContinue()) @@ -4097,7 +4097,7 @@ bool8 sub_80F02A0(void) } break; case 4: - MenuZeroFillScreen(); + Menu_EraseScreen(); break; case 5: LZ77UnCompVram(gUnknown_08E9FC64, (void *)VRAM + 0xE800); @@ -4267,17 +4267,17 @@ _080F0338: .4byte 0x000087ca\n\ _080F033C: .4byte 0x000087c8\n\ _080F0340: .4byte 0x0000d162\n\ _080F0344:\n\ - ldr r0, _080F034C @ =gWindowConfig_81E70D4\n\ - bl SetUpWindowConfig\n\ + ldr r0, _080F034C @ =gWindowTemplate_81E70D4\n\ + bl Text_LoadWindowTemplate\n\ b _080F0618\n\ .align 2, 0\n\ -_080F034C: .4byte gWindowConfig_81E70D4\n\ +_080F034C: .4byte gWindowTemplate_81E70D4\n\ _080F0350:\n\ - ldr r0, _080F0358 @ =gWindowConfig_81E70D4\n\ + ldr r0, _080F0358 @ =gWindowTemplate_81E70D4\n\ bl MultistepInitMenuWindowBegin\n\ b _080F0618\n\ .align 2, 0\n\ -_080F0358: .4byte gWindowConfig_81E70D4\n\ +_080F0358: .4byte gWindowTemplate_81E70D4\n\ _080F035C:\n\ bl MultistepInitMenuWindowContinue\n\ cmp r0, 0\n\ @@ -4286,7 +4286,7 @@ _080F035C:\n\ _080F0366:\n\ b _080F0626\n\ _080F0368:\n\ - bl MenuZeroFillScreen\n\ + bl Menu_EraseScreen\n\ b _080F0618\n\ _080F036E:\n\ ldr r0, _080F0378 @ =gUnknown_08E9FC64\n\ diff --git a/src/rom_800D42C.c b/src/rom_800D42C.c index bf6d03fb7..9449ca0d1 100644 --- a/src/rom_800D42C.c +++ b/src/rom_800D42C.c @@ -28,8 +28,8 @@ extern u8 BattleText_Tie[]; #define PRINT_MESSAGE(text, tileDataStartOffset, x) \ { \ - InitWindow(&gUnknown_03004210, text, tileDataStartOffset, x, MESSAGE_Y); \ - sub_8002F44(&gUnknown_03004210); \ + Text_InitWindow(&gUnknown_03004210, text, tileDataStartOffset, x, MESSAGE_Y); \ + Text_PrintWindow8002F44(&gUnknown_03004210); \ } #define PRINT_MESSAGE_LEFT(text, tileDataStartOffset) PRINT_MESSAGE(text, tileDataStartOffset, LEFT_MESSAGE_X) diff --git a/src/rom_8077ABC.c b/src/rom_8077ABC.c index 2691da859..2b5a3c036 100644 --- a/src/rom_8077ABC.c +++ b/src/rom_8077ABC.c @@ -786,7 +786,7 @@ void oamt_add_pos2_onto_pos1(struct Sprite *sprite) sprite->pos2.y = 0; } -void sub_8078764(struct Sprite *sprite, u8 a2) +void sub_8078764(struct Sprite *sprite, bool8 a2) { if (!a2) { @@ -2105,7 +2105,7 @@ int sub_807A100(u8 slot, u8 a2) } } -void sub_807A3FC(u8 slot, u8 a2, s16 *a3, s16 *a4) +void sub_807A3FC(u8 slot, bool8 a2, s16 *a3, s16 *a4) { u8 v1, v2; s16 v3, v4; diff --git a/src/roulette.c b/src/roulette.c index 1d612d071..6d79f9d38 100644 --- a/src/roulette.c +++ b/src/roulette.c @@ -23,7 +23,7 @@ #include "task.h" #include "text.h" #include "trig.h" -#include "unknown_task.h" +#include "scanline_effect.h" asm(".include \"constants/gba_constants.inc\""); @@ -578,7 +578,7 @@ void sub_8115384(void) { case 0x0: SetVBlankCallback(NULL); - remove_some_task(); + ScanlineEffect_Stop(); sub_80F9438(); sub_80F9368(); REG_BG2CNT = 0x4686; @@ -596,8 +596,8 @@ void sub_8115384(void) gMain.state++; break; case 0x2: - SetUpWindowConfig(&gWindowConfig_81E6C3C); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C3C); + InitMenuWindow(&gWindowTemplate_81E6CE4); LoadPalette(&gUnknown_083F86BC, 0x0, 0x1C0); gMain.state++; break; @@ -625,8 +625,8 @@ void sub_8115384(void) sub_81182F8(0x6); sub_811829C(0x0); sub_8117158(0x0); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C4157[0], 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C4157[0], 0x1, 0xF); gSpriteCoordOffsetX = -0x3C; gSpriteCoordOffsetY = 0x0; gMain.state++; @@ -693,14 +693,14 @@ void sub_8115734(u8 taskid) { DisplayYesNoMenu(0x14, 0x8, 0x1); sub_814AAF8(0x2D9E); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C41E3, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C41E3, 0x1, 0xF); DoYesNoFuncWithChoice(taskid, &gUnknown_083F8EBC); } void sub_811577C(u8 taskid) { - MenuZeroFillWindowRect(0x14, 0x8, 0x1A, 0xD); + Menu_EraseWindowRect(0x14, 0x8, 0x1A, 0xD); gTasks[taskid].func = &sub_81159BC; } @@ -1446,21 +1446,21 @@ void sub_8116638(u8 taskid) if (gTasks[taskid].data[0x2] == 0xC) { PlayFanfare(BGM_ME_B_BIG); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C41A5, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C41A5, 0x1, 0xF); } else { PlayFanfare(BGM_ME_B_SMALL); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C4199, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C4199, 0x1, 0xF); } break; case 0: default: m4aSongNumStart(SE_HAZURE); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C41AE, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C41AE, 0x1, 0xF); } gTasks[taskid].data[0x1] = 0x0; gTasks[taskid].func = &sub_811659C; @@ -1500,8 +1500,8 @@ void sub_811677C(u8 taskid) { ConvertIntToDecimalStringN((u8 *)&gStringVar1, (eRoulette->var19 * gTasks[taskid].data[0x2]), STR_CONV_MODE_LEFT_ALIGN, 0x2); StringExpandPlaceholders((u8 *)&gStringVar4, &gUnknown_081C41BD); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint((u8 *)&gStringVar4, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText((u8 *)&gStringVar4, 0x1, 0xF); gTasks[taskid].data[0x1] = (eRoulette->var19 * gTasks[taskid].data[0x2]); gTasks[taskid].data[0x7] = 0x0; gTasks[taskid].func = &sub_81166E8; @@ -1534,14 +1534,14 @@ void sub_8116880(u8 taskid) { if (gTasks[taskid].data[0x6] == 0x6) { - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C41F1, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C41F1, 0x1, 0xF); sub_8116C34(taskid, &dp01t_12_3_battle_menu, 0xFFFF, 0x3); } else if (gTasks[taskid].data[0xD] == 0x270F) { - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C4231, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C4231, 0x1, 0xF); sub_8116C34(taskid, &sub_8115734, 0xFFFF, 0x3); } else @@ -1551,8 +1551,8 @@ void sub_8116880(u8 taskid) } else { - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C41D2, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C41D2, 0x1, 0xF); sub_8116C34(taskid, &sub_81157AC, 0x3C, 0x3); } } @@ -1570,8 +1570,8 @@ void dp01t_12_3_battle_menu(u8 taskid) gSprites[eRoulette->var3C[i + 0x7]].invisible = FALSE; if (gTasks[taskid].data[0xD] == 0x270F) { - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C4231, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C4231, 0x1, 0xF); sub_8116C34(taskid, &sub_8115734, 0xFFFF, 0x3); } else @@ -2619,8 +2619,8 @@ void sub_8117528(u8 taskid) void sub_811755C(u8 taskid) { - MenuZeroFillWindowRect(0x14, 0x8, 0x1A, 0xD); - MenuZeroFillScreen(); + Menu_EraseWindowRect(0x14, 0x8, 0x1A, 0xD); + Menu_EraseScreen(); BeginNormalPaletteFade(-0x1, 0x0, 0x0, 0x10, 0x0); gPaletteFade.delayCounter = gPaletteFade.multipurpose2; UpdatePaletteFade(); @@ -2629,7 +2629,7 @@ void sub_811755C(u8 taskid) void sub_81175C0(u8 taskid) { - MenuZeroFillScreen(); + Menu_EraseScreen(); ScriptContext2_Disable(); DestroyTask(taskid); } @@ -2640,7 +2640,7 @@ void sub_81175DC(u8 taskid) if (!(gMain.newKeys & (A_BUTTON | B_BUTTON)) && gTasks[taskid].data[0] < 0x3D) return; gSpecialVar_0x8004 = 0x1; - MenuZeroFillScreen(); + Menu_EraseScreen(); ScriptContext2_Disable(); DestroyTask(taskid); } @@ -2650,8 +2650,8 @@ void sub_8117630(u8 taskid) u32 temp = gUnknown_083F8DF0[(gSpecialVar_0x8004 & 0x1) + (gSpecialVar_0x8004 >> 0x7 << 0x1)]; ConvertIntToDecimalStringN(gStringVar1, temp, 0x2, 0x1); StringExpandPlaceholders(gStringVar4, &gUnknown_081C40DF); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(gStringVar4, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(gStringVar4, 0x1, 0xF); gTasks[taskid].func = &sub_81174F8; } @@ -2660,7 +2660,7 @@ void Task_Roulette_0(u8 taskid) s32 temp; ConvertIntToDecimalStringN(gStringVar1, gTasks[taskid].data[0xD], 0x1, 0x4); StringExpandPlaceholders(gStringVar4, gOtherText_Coins); - MenuDrawTextWindow(0x0, 0x0, 0x9, 0x3); + Menu_DrawStdWindowFrame(0x0, 0x0, 0x9, 0x3); MenuPrint_RightAligned(gStringVar4, 0x9, 0x1); temp = gUnknown_083F8DF0[(gSpecialVar_0x8004 & 0x1) + (gSpecialVar_0x8004 >> 0x7 << 0x1)]; ConvertIntToDecimalStringN(gStringVar1, temp, 0x2, 0x1); @@ -2668,23 +2668,23 @@ void Task_Roulette_0(u8 taskid) { if ((gSpecialVar_0x8004 & 0x80) && (gSpecialVar_0x8004 & 0x1)) { - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(&gUnknown_081C4139, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(&gUnknown_081C4139, 0x1, 0xF); sub_8116C34(taskid , &sub_8117630, 0xFFFF, 0x3); } else { StringExpandPlaceholders(gStringVar4, &gUnknown_081C40DF); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(gStringVar4, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(gStringVar4, 0x1, 0xF); gTasks[taskid].func = &sub_81174F8; } } else { StringExpandPlaceholders(gStringVar4, &gUnknown_081C411C); - MenuDrawTextWindow(0x0, 0xE, 0x1D, 0x13); - MenuPrint(gStringVar4, 0x1, 0xF); + Menu_DrawStdWindowFrame(0x0, 0xE, 0x1D, 0x13); + Menu_PrintText(gStringVar4, 0x1, 0xF); gTasks[taskid].func = &sub_81175DC; gTasks[taskid].data[0xD] = 0x0; gTasks[taskid].data[0x0] = 0x0; diff --git a/src/scanline_effect.c b/src/scanline_effect.c new file mode 100644 index 000000000..b4de0689f --- /dev/null +++ b/src/scanline_effect.c @@ -0,0 +1,261 @@ +#include "global.h" +#include "data2.h" +#include "task.h" +#include "trig.h" +#include "scanline_effect.h" + +static void CopyValue16Bit(void); +static void CopyValue32Bit(void); + +extern u16 gBattle_BG0_Y; +extern u16 gBattle_BG0_X; +extern u16 gBattle_BG1_X; +extern u16 gBattle_BG1_Y; +extern u16 gBattle_BG2_X; +extern u16 gBattle_BG2_Y; +extern u16 gBattle_BG3_X; +extern u16 gBattle_BG3_Y; + +EWRAM_DATA static u8 sShouldStopWaveTask = FALSE; + +struct ScanlineEffect gScanlineEffect; + +// Per-scanline register values. +// This is double buffered so that it can be safely written to at any time +// without overwriting the buffer that the DMA is currently reading +u16 gScanlineEffectRegBuffers[2][0x3C0]; + +void ScanlineEffect_Stop(void) +{ + gScanlineEffect.state = 0; + DmaStop(0); + if (gScanlineEffect.waveTaskId != 0xFF) + { + DestroyTask(gScanlineEffect.waveTaskId); + gScanlineEffect.waveTaskId = 0xFF; + } +} + +void ScanlineEffect_Clear(void) +{ + CpuFill16(0, gScanlineEffectRegBuffers, sizeof(gScanlineEffectRegBuffers)); + gScanlineEffect.dmaSrcBuffers[0] = NULL; + gScanlineEffect.dmaSrcBuffers[1] = NULL; + gScanlineEffect.dmaDest = NULL; + gScanlineEffect.dmaControl = 0; + gScanlineEffect.srcBuffer = 0; + gScanlineEffect.state = 0; + gScanlineEffect.unused16 = 0; + gScanlineEffect.unused17 = 0; + gScanlineEffect.waveTaskId = 0xFF; +} + +void ScanlineEffect_SetParams(struct ScanlineEffectParams params) +{ + if (params.dmaControl == SCANLINE_EFFECT_DMACNT_16BIT) // 16-bit + { + // Set the DMA src to the value for the second scanline because the + // first DMA transfer occurs in HBlank *after* the first scanline is drawn + gScanlineEffect.dmaSrcBuffers[0] = (u16 *)gScanlineEffectRegBuffers[0] + 1; + gScanlineEffect.dmaSrcBuffers[1] = (u16 *)gScanlineEffectRegBuffers[1] + 1; + gScanlineEffect.setFirstScanlineReg = CopyValue16Bit; + } + else // assume 32-bit + { + // Set the DMA src to the value for the second scanline because the + // first DMA transfer occurs in HBlank *after* the first scanline is drawn + gScanlineEffect.dmaSrcBuffers[0] = (u32 *)gScanlineEffectRegBuffers[0] + 1; + gScanlineEffect.dmaSrcBuffers[1] = (u32 *)gScanlineEffectRegBuffers[1] + 1; + gScanlineEffect.setFirstScanlineReg = CopyValue32Bit; + } + + gScanlineEffect.dmaControl = params.dmaControl; + gScanlineEffect.dmaDest = params.dmaDest; + gScanlineEffect.state = params.initState; + gScanlineEffect.unused16 = params.unused9; + gScanlineEffect.unused17 = params.unused9; +} + +void ScanlineEffect_InitHBlankDmaTransfer(void) +{ + if (gScanlineEffect.state == 0) + { + return; + } + else if (gScanlineEffect.state == 3) + { + gScanlineEffect.state = 0; + DmaStop(0); + sShouldStopWaveTask = TRUE; + } + else + { + DmaStop(0); + // Set DMA to copy to dest register on each HBlank for the next frame. + // The HBlank DMA transfers do not occurr during VBlank, so the transfer + // will begin on the HBlank after the first scanline + DmaSet(0, gScanlineEffect.dmaSrcBuffers[gScanlineEffect.srcBuffer], gScanlineEffect.dmaDest, gScanlineEffect.dmaControl); + // Manually set the reg for the first scanline + gScanlineEffect.setFirstScanlineReg(); + // Swap current buffer + gScanlineEffect.srcBuffer ^= 1; + } +} + +// These two functions are used to copy the register for the first scanline, +// depending whether it is a 16-bit register or a 32-bit register. + +static void CopyValue16Bit(void) +{ + u16 *dest = (u16 *)gScanlineEffect.dmaDest; + u16 *src = (u16 *)&gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer]; + + *dest = *src; +} + +static void CopyValue32Bit(void) +{ + u32 *dest = (u32 *)gScanlineEffect.dmaDest; + u32 *src = (u32 *)&gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer]; + + *dest = *src; +} + +#define tStartLine data[0] +#define tEndLine data[1] +#define tWaveLength data[2] +#define tSrcBufferOffset data[3] +#define tFramesUntilMove data[4] +#define tDelayInterval data[5] +#define tRegOffset data[6] +#define tApplyBattleBgOffsets data[7] + +static void TaskFunc_UpdateWavePerFrame(u8 taskId) +{ + int value = 0; + int i; + int offset; + + if (sShouldStopWaveTask) + { + DestroyTask(taskId); + gScanlineEffect.waveTaskId = 0xFF; + } + else + { + if (gTasks[taskId].tApplyBattleBgOffsets) + { + switch (gTasks[taskId].tRegOffset) + { + case SCANLINE_EFFECT_REG_BG0HOFS: + value = gBattle_BG0_X; + break; + case SCANLINE_EFFECT_REG_BG0VOFS: + value = gBattle_BG0_Y; + break; + case SCANLINE_EFFECT_REG_BG1HOFS: + value = gBattle_BG1_X; + break; + case SCANLINE_EFFECT_REG_BG1VOFS: + value = gBattle_BG1_Y; + break; + case SCANLINE_EFFECT_REG_BG2HOFS: + value = gBattle_BG2_X; + break; + case SCANLINE_EFFECT_REG_BG2VOFS: + value = gBattle_BG2_Y; + break; + case SCANLINE_EFFECT_REG_BG3HOFS: + value = gBattle_BG3_X; + break; + case SCANLINE_EFFECT_REG_BG3VOFS: + value = gBattle_BG3_Y; + break; + } + } + if (gTasks[taskId].tFramesUntilMove != 0) + { + gTasks[taskId].tFramesUntilMove--; + offset = gTasks[taskId].tSrcBufferOffset + 320; + for (i = gTasks[taskId].tStartLine; i < gTasks[taskId].tEndLine; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gScanlineEffectRegBuffers[0][offset] + value; + offset++; + } + } + else + { + gTasks[taskId].tFramesUntilMove = gTasks[taskId].tDelayInterval; + offset = gTasks[taskId].tSrcBufferOffset + 320; + for (i = gTasks[taskId].tStartLine; i < gTasks[taskId].tEndLine; i++) + { + gScanlineEffectRegBuffers[gScanlineEffect.srcBuffer][i] = gScanlineEffectRegBuffers[0][offset] + value; + offset++; + } + + // increment src buffer offset + gTasks[taskId].tSrcBufferOffset++; + if (gTasks[taskId].tSrcBufferOffset == gTasks[taskId].tWaveLength) + gTasks[taskId].tSrcBufferOffset = 0; + } + } +} + +static void GenerateWave(u16 *buffer, u8 frequency, u8 amplitude, u8 unused) +{ + u16 i = 0; + u8 theta = 0; + + while (i < 256) + { + buffer[i] = (gSineTable[theta] * amplitude) / 256; + theta += frequency; + i++; + } +} + +// Initializes a background "wave" effect that affects scanlines startLine (inclusive) to endLine (exclusive). +// 'frequency' and 'amplitude' control the frequency and amplitude of the wave. +// 'delayInterval' controls how fast the wave travels up the screen. The wave will shift upwards one scanline every 'delayInterval'+1 frames. +// 'regOffset' is the offset of the video register to modify. +u8 ScanlineEffect_InitWave(u8 startLine, u8 endLine, u8 frequency, u8 amplitude, u8 delayInterval, u8 regOffset, bool8 applyBattleBgOffsets) +{ + int i; + int offset; + struct ScanlineEffectParams params; + u8 taskId; + + ScanlineEffect_Clear(); + + params.dmaDest = (void *)(REG_ADDR_BG0HOFS + regOffset); + params.dmaControl = SCANLINE_EFFECT_DMACNT_16BIT; + params.initState = 1; + params.unused9 = 0; + ScanlineEffect_SetParams(params); + + taskId = CreateTask(TaskFunc_UpdateWavePerFrame, 0); + + gTasks[taskId].tStartLine = startLine; + gTasks[taskId].tEndLine = endLine; + gTasks[taskId].tWaveLength = 256 / frequency; + gTasks[taskId].tSrcBufferOffset = 0; + gTasks[taskId].tFramesUntilMove = delayInterval; + gTasks[taskId].tDelayInterval = delayInterval; + gTasks[taskId].tRegOffset = regOffset; + gTasks[taskId].tApplyBattleBgOffsets = applyBattleBgOffsets; + + gScanlineEffect.waveTaskId = taskId; + sShouldStopWaveTask = FALSE; + + GenerateWave(&gScanlineEffectRegBuffers[0][320], frequency, amplitude, endLine - startLine); + + offset = 320; + for (i = startLine; i < endLine; i++) + { + gScanlineEffectRegBuffers[0][i] = gScanlineEffectRegBuffers[0][offset]; + gScanlineEffectRegBuffers[1][i] = gScanlineEffectRegBuffers[0][offset]; + offset++; + } + + return taskId; +} diff --git a/src/scene/berry_blender.c b/src/scene/berry_blender.c index 53308e856..b59d02939 100644 --- a/src/scene/berry_blender.c +++ b/src/scene/berry_blender.c @@ -198,8 +198,8 @@ void m4aMPlayTempoControl(struct MusicPlayerInfo *mplayInfo, u16 tempo); void m4aMPlayStop(struct MusicPlayerInfo *mplayInfo); void sub_80A6978(void); u8 sub_80A7DEC(u8 berryId, u8 x, u8 y, bool8 animate); -void sub_814A880(u8 a1, u8 a2); -u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5); +void MenuCursor_SetPos814A880(u8 a1, u8 a2); +u8 MenuCursor_Create814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5); s8 GetFirstFreePokeblockSlot(void); bool8 sub_810CA34(struct Pokeblock *pokeblock); #ifdef GERMAN @@ -215,7 +215,7 @@ extern u8 byte_3002A68; extern const u8 gUnknown_08E6C100[]; extern const u8 gUnknown_08E6C920[]; extern const u8 gUnknown_08E6D354[]; -extern const struct WindowConfig gWindowConfig_81E6F68; +extern const struct WindowTemplate gWindowTemplate_81E6F68; extern const u8 *const gPokeblockNames[]; extern const struct Berry gBerries[]; @@ -957,8 +957,8 @@ static void sub_804E56C(void) ResetSpriteData(); FreeAllSpritePalettes(); SetVBlankCallback(NULL); - SetUpWindowConfig(&gWindowConfig_81E6F68); - InitMenuWindow(&gWindowConfig_81E6F68); + Text_LoadWindowTemplate(&gWindowTemplate_81E6F68); + InitMenuWindow(&gWindowTemplate_81E6F68); gBerryBlenderData->field_0++; gBerryBlenderData->field_140 = 0; gBerryBlenderData->field_13E = 0; @@ -993,12 +993,12 @@ static void sub_804E56C(void) } break; case 4: - MenuDrawTextWindow(0, 14, 29, 19); + Menu_DrawStdWindowFrame(0, 14, 29, 19); MenuPrintMessage(gOtherText_BlenderChooseBerry, 1, 15); gBerryBlenderData->field_0++; break; case 5: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { gBerryBlenderData->field_0++; BeginNormalPaletteFade(-1, 0, 0, 0x10, 0); @@ -1135,8 +1135,8 @@ static void sub_804E9F8(void) FreeAllSpritePalettes(); ResetTasks(); SetVBlankCallback(VBlankCB0_BerryBlender); - SetUpWindowConfig(&gWindowConfig_81E6F68); - InitMenuWindow(&gWindowConfig_81E6F68); + Text_LoadWindowTemplate(&gWindowTemplate_81E6F68); + InitMenuWindow(&gWindowTemplate_81E6F68); gLinkType = 0x4422; gBerryBlenderData->field_0++; gBerryBlenderData->field_4E = 0; @@ -1184,8 +1184,8 @@ static void sub_804E9F8(void) } break; case 5: - MenuDrawTextWindow(0, 13, 29, 19); - MenuPrint(gOtherText_LinkStandby3, 1, 14); + Menu_DrawStdWindowFrame(0, 13, 29, 19); + Menu_PrintText(gOtherText_LinkStandby3, 1, 14); gBerryBlenderData->field_0 = 8; gBerryBlenderData->framesToWait = 0; break; @@ -1209,7 +1209,7 @@ static void sub_804E9F8(void) case 10: if (++gBerryBlenderData->framesToWait > 20) { - MenuZeroFillScreen(); + Menu_EraseScreen(); if (GetBlockReceivedStatus() == sub_8008198()) { for (i = 0; i < GetLinkPlayerCount(); i++) @@ -1309,12 +1309,12 @@ static void sub_804E9F8(void) PlayBGM(BGM_CYCLING); break; case 100: - MenuDrawTextWindow(0, 13, 29, 19); + Menu_DrawStdWindowFrame(0, 13, 29, 19); MenuPrintMessage(gOtherText_LinkNotFound, 1, 15); gBerryBlenderData->field_0++; break; case 101: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) gBerryBlenderData->field_0++; break; case 102: @@ -1338,8 +1338,8 @@ static void sub_804F0F4(void) SetVBlankCallback(VBlankCB0_BerryBlender); - SetUpWindowConfig(&gWindowConfig_81E6F68); - InitMenuWindow(&gWindowConfig_81E6F68); + Text_LoadWindowTemplate(&gWindowTemplate_81E6F68); + InitMenuWindow(&gWindowTemplate_81E6F68); gLinkType = 0x4422; @@ -1426,7 +1426,7 @@ static void sub_804F2A8(void) if (GetMultiplayerId() == gBerryBlenderData->field_9A[i]) stringPtr = StringCopy(stringPtr, sRedColorString); StringCopy(stringPtr, gLinkPlayers[gBerryBlenderData->field_9A[i]].name); - MenuPrint_PixelCoords(gStringVar1, gUnknown_082162D4[i][0] * 8 + 1, gUnknown_082162D4[i][1] * 8, 1); + Menu_PrintTextPixelCoords(gStringVar1, gUnknown_082162D4[i][0] * 8 + 1, gUnknown_082162D4[i][1] * 8, 1); } } } @@ -2494,15 +2494,15 @@ static void sub_8050760(void) static void sub_80508D4(u8 value) { gBerryBlenderData->field_AA = value; - sub_814A880(192, (gBerryBlenderData->field_AA * 16) + 72); + MenuCursor_SetPos814A880(192, (gBerryBlenderData->field_AA * 16) + 72); } static void sub_80508FC(void) { gBerryBlenderData->field_AA = 0; - MenuDrawTextWindow(23, 8, 28, 13); - sub_814A5C0(0, -1, 12, 0x2D9F, 32); - MenuPrint(gOtherText_YesNoTerminating, 24, 9); + Menu_DrawStdWindowFrame(23, 8, 28, 13); + MenuCursor_Create814A5C0(0, -1, 12, 0x2D9F, 32); + Menu_PrintText(gOtherText_YesNoTerminating, 24, 9); sub_80508D4(gBerryBlenderData->field_AA); } @@ -2575,11 +2575,11 @@ static void sub_8050954(void) break; case 7: gBerryBlenderData->field_6F++; - MenuDrawTextWindow(0, 14, 29, 19); + Menu_DrawStdWindowFrame(0, 14, 29, 19); MenuPrintMessage(gOtherText_BlendAnotherBerryPrompt, 1, 15); break; case 8: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) gBerryBlenderData->field_6F++; break; case 9: @@ -2654,7 +2654,7 @@ static void sub_8050954(void) } break; case 13: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { SetMainCallback2(sub_8050E30); gBerryBlenderData->field_6F = 0; @@ -2746,7 +2746,7 @@ static void sub_8050E30(void) case 1: gBerryBlenderData->field_6F = 3; DestroyMenuCursor(); - MenuZeroFillWindowRect(23, 8, 28, 13); + Menu_EraseWindowRect(23, 8, 28, 13); #ifdef ENGLISH StringCopy(gStringVar4, gLinkPlayers[gBerryBlenderData->field_7A].name); StringAppend(gStringVar4, gOtherText_OtherCaseIsFull); @@ -2759,7 +2759,7 @@ static void sub_8050E30(void) case 2: gBerryBlenderData->field_6F++; DestroyMenuCursor(); - MenuZeroFillWindowRect(23, 8, 28, 13); + Menu_EraseWindowRect(23, 8, 28, 13); #ifdef ENGLISH StringCopy(gStringVar4, gLinkPlayers[gBerryBlenderData->field_7A].name); StringAppend(gStringVar4, gOtherText_NoBerriesForBlend); @@ -2770,7 +2770,7 @@ static void sub_8050E30(void) MenuPrintMessage(gStringVar4, 1, 15); break; case 3: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { gBerryBlenderData->framesToWait = 0; gBerryBlenderData->field_6F++; @@ -2781,8 +2781,8 @@ static void sub_8050E30(void) gBerryBlenderData->field_6F = 5; break; case 5: - MenuDrawTextWindow(0, 14, 29, 19); - MenuPrint(gMultiText_Saving, 2, 15); + Menu_DrawStdWindowFrame(0, 14, 29, 19); + Menu_PrintText(gMultiText_Saving, 2, 15); sub_80084A4(); gBerryBlenderData->field_6F++; break; @@ -2859,17 +2859,17 @@ static void sub_80510E8(void) case 1: gBerryBlenderData->field_6F = 3; DestroyMenuCursor(); - MenuZeroFillWindowRect(23, 8, 28, 13); + Menu_EraseWindowRect(23, 8, 28, 13); MenuPrintMessage(gOtherText_CaseIsFull, 1, 15); break; case 2: gBerryBlenderData->field_6F++; DestroyMenuCursor(); - MenuZeroFillWindowRect(23, 8, 28, 13); + Menu_EraseWindowRect(23, 8, 28, 13); MenuPrintMessage(gOtherText_OutOfBerries, 1, 15); break; case 3: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) gBerryBlenderData->field_6F = 9; break; case 9: @@ -3080,14 +3080,14 @@ void unref_sub_80516F8(u8 taskID) task->data[0] = 0; if (task->data[0] == 100) { - ZeroFillWindowRect(&gBerryBlenderData->field_4, 0, 0, 16, 20); - MenuDrawTextWindow(4, 4, 10, 12); + Text_EraseWindowRect(&gBerryBlenderData->field_4, 0, 0, 16, 20); + Menu_DrawStdWindowFrame(4, 4, 10, 12); for (i = 0; i < 3; i++) { if (gLinkPlayers[i + 1].trainerId != 0) - MenuPrint(gUnknown_08216284[i], 5, (2 * i) + 5); - MenuDrawTextWindow(0, 13, 29, 19); - MenuPrint(gOtherText_PressAToStart, 1, 15); + Menu_PrintText(gUnknown_08216284[i], 5, (2 * i) + 5); + Menu_DrawStdWindowFrame(0, 13, 29, 19); + Menu_PrintText(gOtherText_PressAToStart, 1, 15); } } if (gMain.newKeys & A_BUTTON) @@ -3099,7 +3099,7 @@ void unref_sub_80516F8(u8 taskID) else { if (task->data[0] == 10) - MenuPrint(gOtherText_PleaseWait, 3, 10); + Menu_PrintText(gOtherText_PleaseWait, 3, 10); if (++task->data[0] > 120) task->data[0] = 0; if (byte_3002A68 > 4 && gReceivedRemoteLinkPlayers == 1) @@ -3348,7 +3348,7 @@ static bool8 Blender_PrintBlendingResults(void) u8* textPtr; u16 secondsPassed, minutes, seconds; - MenuDrawTextWindow(4, 2, 25, 17); + Menu_DrawStdWindowFrame(4, 2, 25, 17); sub_8072BD8(gOtherText_ResultsOfBlending, 5, 3, 160); for (i = 0; i < gBerryBlenderData->playersNo; i++) { @@ -3370,7 +3370,7 @@ static bool8 Blender_PrintBlendingResults(void) textPtr += 3; textPtr = sub_8072C74(textPtr, gLinkPlayers[place].name, 88, 0); sub_8072C74(textPtr, text[0], 157, 0); - MenuPrint(gBerryBlenderData->stringVar, 5, gUnknown_082165E9[gBerryBlenderData->playersNo] + (i * gUnknown_082165EE[gBerryBlenderData->playersNo])); + Menu_PrintText(gBerryBlenderData->stringVar, 5, gUnknown_082165E9[gBerryBlenderData->playersNo] + (i * gUnknown_082165EE[gBerryBlenderData->playersNo])); } ConvertIntToDecimalStringN(text[0], gBerryBlenderData->max_RPM % 100, 2, 2); textPtr = gBerryBlenderData->stringVar; @@ -3388,7 +3388,7 @@ static bool8 Blender_PrintBlendingResults(void) textPtr = sub_8072C74(textPtr, text[0], 136, 1); #endif StringCopy(textPtr, gOtherText_RPM); - MenuPrint(gBerryBlenderData->stringVar, 5, 13); + Menu_PrintText(gBerryBlenderData->stringVar, 5, 13); secondsPassed = gBerryBlenderData->gameFrameTime / 60; seconds = secondsPassed % 60; @@ -3408,7 +3408,7 @@ static bool8 Blender_PrintBlendingResults(void) textPtr = sub_8072C74(textPtr, text[1], 136, 1); StringCopy(textPtr, gOtherText_Sec); - MenuPrint(gBerryBlenderData->stringVar, 5, 15); + Menu_PrintText(gBerryBlenderData->stringVar, 5, 15); gBerryBlenderData->framesToWait = 0; gBerryBlenderData->field_0++; @@ -3419,8 +3419,8 @@ static bool8 Blender_PrintBlendingResults(void) gBerryBlenderData->field_0++; break; case 5: - MenuZeroFillScreen(); - MenuDrawTextWindow(0, 14, 29, 19); + Menu_EraseScreen(); + Menu_DrawStdWindowFrame(0, 14, 29, 19); for (i = 0; i < BLENDER_MAX_PLAYERS; i++) { if (gBerryBlenderData->chosenItemID[i] != 0) @@ -3436,7 +3436,7 @@ static bool8 Blender_PrintBlendingResults(void) gBerryBlenderData->field_0++; break; case 6: - if (MenuUpdateWindowText()) + if (Menu_UpdateWindowText()) { Blender_TrySettingRecord(); return TRUE; @@ -3536,7 +3536,7 @@ static bool8 Blender_PrintBlendingRanking(void) } break; case 3: - MenuDrawTextWindow(4, 2, 25, 17); + Menu_DrawStdWindowFrame(4, 2, 25, 17); sub_8072BD8(gOtherText_Ranking, 5, 3, 160); gBerryBlenderData->scoreIconIDs[BLENDER_SCORE_BEST] = CreateSprite(&sSpriteTemplate_821645C, 140, 52, 0); @@ -3575,7 +3575,7 @@ static bool8 Blender_PrintBlendingRanking(void) txtPtr = sub_8072C14(txtPtr, gBerryBlenderData->scores[place][BLENDER_SCORE_GOOD], 132, 1); txtPtr = sub_8072C14(txtPtr, gBerryBlenderData->scores[place][BLENDER_SCORE_MISS], 156, 1); - MenuPrint(gBerryBlenderData->stringVar, 5, i * gUnknown_082165F3[gBerryBlenderData->playersNo] + 8); + Menu_PrintText(gBerryBlenderData->stringVar, 5, i * gUnknown_082165F3[gBerryBlenderData->playersNo] + 8); } gBerryBlenderData->framesToWait = 0; gBerryBlenderData->field_0++; @@ -3606,8 +3606,8 @@ void unref_sub_80524BC(void) FreeAllSpritePalettes(); ResetTasks(); SetVBlankCallback(VBlankCB1_BerryBlender); - SetUpWindowConfig(&gWindowConfig_81E6CE4); - InitMenuWindow(&gWindowConfig_81E6CE4); + Text_LoadWindowTemplate(&gWindowTemplate_81E6CE4); + InitMenuWindow(&gWindowTemplate_81E6CE4); SeedRng(gMain.vblankCounter1); REG_DISPCNT = 0x1540; RunTasks(); @@ -3625,10 +3625,10 @@ static void BlenderDebug_PrintBerryData(void) u8 i; StringCopy(text, sText_BPM); - MenuPrint(text, 2, 0); + Menu_PrintText(text, 2, 0); ConvertIntToDecimalStringN(text, sBlenderDebug.BPM / 100, 2, 3); - MenuPrint(text, 6, 0); + Menu_PrintText(text, 6, 0); for (i = 0; i < 4; i++) { @@ -3646,7 +3646,7 @@ static void BlenderDebug_PrintBerryData(void) text[7] = EOS; } var = (i * 3) + 3; - MenuPrint(text, 2, var); + Menu_PrintText(text, 2, var); ConvertIntToDecimalStringN(&text[0], gBerries[sBlenderDebug.berries[i]].spicy, 2, 2); StringAppend(text, sText_Space); @@ -3666,12 +3666,12 @@ static void BlenderDebug_PrintBerryData(void) ConvertIntToDecimalStringN(&text[15], gBerries[sBlenderDebug.berries[i]].smoothness, 2, 2); text[17] = EOS; - MenuPrint(text, 7, var); + Menu_PrintText(text, 7, var); } if (sBlenderDebug.pokeblock.color != 0) { StringCopy(text, gPokeblockNames[sBlenderDebug.pokeblock.color]); - MenuPrint(text, 2, 15); + Menu_PrintText(text, 2, 15); ConvertIntToHexStringN(&text[0], sBlenderDebug.spicy, 2, 2); StringAppend(text, sText_Space); @@ -3691,7 +3691,7 @@ static void BlenderDebug_PrintBerryData(void) ConvertIntToHexStringN(&text[15], sBlenderDebug.feel, 2, 2); text[17] = EOS; - MenuPrint(text, 7, 17); + Menu_PrintText(text, 7, 17); } } @@ -3743,7 +3743,7 @@ static void sub_80527BC(void) gUnknown_020297DC = 0; } - MenuPrint(text, 2, 15); + Menu_PrintText(text, 2, 15); } static void sub_8052918(void) @@ -3845,9 +3845,9 @@ void ShowBerryBlenderRecordWindow(void) u8 text[30]; s32 i; - MenuDrawTextWindow(6, 3, 23, 16); - MenuPrint(gMultiText_BerryBlenderMaxSpeedRecord, 8, 4); - MenuPrint(gMultiText_2P3P4P, 8, 9); + Menu_DrawStdWindowFrame(6, 3, 23, 16); + Menu_PrintText(gMultiText_BerryBlenderMaxSpeedRecord, 8, 4); + Menu_PrintText(gMultiText_2P3P4P, 8, 9); for (i = 0; i < 3; i++) { @@ -3865,7 +3865,7 @@ void ShowBerryBlenderRecordWindow(void) txtPtr = ConvertIntToDecimalStringN(txtPtr, record % 100, 2, 2); StringAppend(txtPtr, gOtherText_RPM); - MenuPrint(text, 15, i * 2 + 9); + Menu_PrintText(text, 15, i * 2 + 9); } } diff --git a/src/scene/cable_car.c b/src/scene/cable_car.c index 52a0aeebf..d8e099130 100644 --- a/src/scene/cable_car.c +++ b/src/scene/cable_car.c @@ -14,7 +14,7 @@ #include "decompress.h" #include "field_weather.h" #include "field_map_obj.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "event_data.h" #include "cable_car_util.h" #include "constants/map_objects.h" @@ -208,7 +208,7 @@ static void CableCarMainCallback_Setup(void) case 0: default: SetVBlankCallback(NULL); - remove_some_task(); + ScanlineEffect_Stop(); DmaFill16Large(3, 0, VRAM, VRAM_SIZE, 0x1000); DmaFill32Defvars(3, 0, OAM, OAM_SIZE); DmaFill16Defvars(3, 0, PLTT, PLTT_SIZE); diff --git a/src/scene/contest_painting.c b/src/scene/contest_painting.c index 442d8ec26..3aa898b03 100644 --- a/src/scene/contest_painting.c +++ b/src/scene/contest_painting.c @@ -11,7 +11,7 @@ #include "string_util.h" #include "strings.h" #include "text.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "ewram.h" static u8 gUnknown_03000750; @@ -147,7 +147,7 @@ static void ShowContestPainting(void) switch (gMain.state) { case 0: - remove_some_task(); + ScanlineEffect_Stop(); SetVBlankCallback(NULL); gUnknown_03005E8C = &ewram15DE0; ContestPaintingInitVars(TRUE); @@ -243,8 +243,8 @@ static void HoldContestPainting(void) static void ContestPaintingInitWindow(u8 arg0) { - InitMenuWindow(&gWindowConfig_81E7160); - SetUpWindowConfig(&gWindowConfig_81E7160); + InitMenuWindow(&gWindowTemplate_81E7160); + Text_LoadWindowTemplate(&gWindowTemplate_81E7160); } static void ContestPaintingPrintCaption(u8 contestType, u8 arg1) @@ -291,7 +291,7 @@ static void ContestPaintingPrintCaption(u8 contestType, u8 arg1) xPos = 3; yPos = 14; } - MenuPrint_PixelCoords(gUnknown_03005E40, xPos * 8 + 1, yPos * 8, 1); + Menu_PrintTextPixelCoords(gUnknown_03005E40, xPos * 8 + 1, yPos * 8, 1); } static void ContestPaintingInitBG(void) diff --git a/src/scene/credits.c b/src/scene/credits.c index 17c1bf263..e31e2c797 100644 --- a/src/scene/credits.c +++ b/src/scene/credits.c @@ -474,8 +474,8 @@ void sub_81439D0(void) taskIdC = gTasks[taskIdA].data[TDA_TASK_C_ID]; gTasks[taskIdC].data[TDC_0] = 40; - SetUpWindowConfig(&gWindowConfig_81E7208); - InitMenuWindow(&gWindowConfig_81E7208); + Text_LoadWindowTemplate(&gWindowTemplate_81E7208); + InitMenuWindow(&gWindowTemplate_81E7208); LoadPalette(&gUnknown_0840B7BC, 0x80, sizeof(gUnknown_0840B7BC)); CpuCopy16(&gUnknown_0840B7FC, (void *)(VRAM + 0xBEE0), sizeof(gUnknown_0840B7FC)); @@ -857,7 +857,7 @@ static void task_b_81441B8(u8 taskIdB) case 5: if (!gPaletteFade.active) { - MenuZeroFillWindowRect(0, 9, 29, 19); + Menu_EraseWindowRect(0, 9, 29, 19); gTasks[taskIdB].data[TDB_0] = 2; } return; diff --git a/src/scene/egg_hatch.c b/src/scene/egg_hatch.c index c0111de7d..e0b798aea 100644 --- a/src/scene/egg_hatch.c +++ b/src/scene/egg_hatch.c @@ -471,10 +471,10 @@ static void CB2_EggHatch_0(void) gSpecialVar_0x8005 = GetCurrentMapMusic(); break; case 1: - SetUpWindowConfig(&gWindowConfig_81E6F84); - InitWindowFromConfig(&gEggHatchData->window, &gWindowConfig_81E6F84); - gEggHatchData->tileDataStartOffset = SetTextWindowBaseTileNum(20); - LoadTextWindowGraphics(&gEggHatchData->window); + Text_LoadWindowTemplate(&gWindowTemplate_81E6F84); + Text_InitWindowWithTemplate(&gEggHatchData->window, &gWindowTemplate_81E6F84); + gEggHatchData->tileDataStartOffset = TextWindow_SetBaseTileNum(20); + TextWindow_LoadStdFrameGraphics(&gEggHatchData->window); gMain.state++; break; case 2: @@ -625,7 +625,7 @@ static void CB2_EggHatch_1(void) case 8: if (EggHatchUpdateWindowText()) { - MenuDrawTextWindow(22, 8, 27, 13); + Menu_DrawStdWindowFrame(22, 8, 27, 13); InitYesNoMenu(22, 8, 4); gEggHatchData->CB2_state++; } @@ -633,7 +633,7 @@ static void CB2_EggHatch_1(void) case 9: { s8 menuInput; - if ((menuInput = ProcessMenuInputNoWrap_()) != -2) + if ((menuInput = Menu_ProcessInputNoWrap_()) != -2) { if (menuInput != -1 && menuInput != 1) { @@ -848,15 +848,15 @@ static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 static void EggHatchPrintMessage1(u8* src) { - sub_8002EB0(&gEggHatchData->window, src, gEggHatchData->tileDataStartOffset, 3, 15); + Text_InitWindow8002EB0(&gEggHatchData->window, src, gEggHatchData->tileDataStartOffset, 3, 15); } static void EggHatchPrintMessage2(u8* src) { - sub_8003460(&gEggHatchData->window, src, gEggHatchData->tileDataStartOffset, 3, 15); + Text_InitWindowAndPrintText(&gEggHatchData->window, src, gEggHatchData->tileDataStartOffset, 3, 15); } static bool8 EggHatchUpdateWindowText(void) { - return sub_80035AC(&gEggHatchData->window); + return Text_UpdateWindow(&gEggHatchData->window); } diff --git a/src/scene/evolution_scene.c b/src/scene/evolution_scene.c index 4ee601360..53eb2f1e8 100644 --- a/src/scene/evolution_scene.c +++ b/src/scene/evolution_scene.c @@ -9,7 +9,7 @@ #include "pokemon.h" #include "string_util.h" #include "battle.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "data2.h" #include "decompress.h" #include "m4a.h" @@ -71,8 +71,8 @@ extern u16 gBattle_BG1_X; extern u16 gBattle_BG1_Y; extern u16 gBattle_BG2_X; extern u16 gBattle_BG2_Y; -extern u16 gUnknown_030041B0; -extern u16 gUnknown_030041B8; +extern u16 gBattle_BG3_X; +extern u16 gBattle_BG3_Y; extern u8 gBattleTerrain; extern u8 gReservedSpritePaletteCount; extern u16 gMoveToLearn; @@ -197,7 +197,7 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo, REG_WININ = 0; REG_WINOUT = 0; - SetUpWindowConfig(&gWindowConfig_81E6C58); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C58); ResetPaletteFade(); gBattle_BG0_X = 0; @@ -206,16 +206,16 @@ void EvolutionScene(struct Pokemon* mon, u16 speciesToEvolve, bool8 canStopEvo, gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 256; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 256; + gBattle_BG3_Y = 0; - InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6C58); + Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6C58); gBattleTerrain = BATTLE_TERRAIN_PLAIN; sub_800D6D4(); sub_800DAB8(); ResetSpriteData(); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); FreeAllSpritePalettes(); @@ -306,7 +306,7 @@ static void CB2_EvolutionSceneLoadGraphics(void) REG_WIN1V = 0; REG_WININ = 0; REG_WINOUT = 0; - SetUpWindowConfig(&gWindowConfig_81E6C58); + Text_LoadWindowTemplate(&gWindowTemplate_81E6C58); ResetPaletteFade(); gBattle_BG0_X = 0; gBattle_BG0_Y = 0; @@ -314,10 +314,10 @@ static void CB2_EvolutionSceneLoadGraphics(void) gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 256; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 256; + gBattle_BG3_Y = 0; - InitWindowFromConfig(&gUnknown_03004210, &gWindowConfig_81E6C58); + Text_InitWindowWithTemplate(&gUnknown_03004210, &gWindowTemplate_81E6C58); gBattleTerrain = BATTLE_TERRAIN_PLAIN; sub_800D6D4(); @@ -368,20 +368,20 @@ static void CB2_TradeEvolutionSceneLoadGraphics(void) gBattle_BG1_Y = 0; gBattle_BG2_X = 0; gBattle_BG2_Y = 0; - gUnknown_030041B0 = 256; - gUnknown_030041B8 = 0; + gBattle_BG3_X = 256; + gBattle_BG3_Y = 0; gMain.state++; break; case 1: - SetUpWindowConfig(&gWindowConfig_81E6F84); - InitWindowFromConfig(&gUnknown_03004828->window, &gWindowConfig_81E6F84); + Text_LoadWindowTemplate(&gWindowTemplate_81E6F84); + Text_InitWindowWithTemplate(&gUnknown_03004828->window, &gWindowTemplate_81E6F84); gMain.state++; break; case 2: - LoadTextWindowGraphics(&gUnknown_03004828->window); - gUnknown_03004828->textWindowBaseTileNum = SetTextWindowBaseTileNum(2); - LoadTextWindowGraphics(&gUnknown_03004828->window); - MenuZeroFillScreen(); + TextWindow_LoadStdFrameGraphics(&gUnknown_03004828->window); + gUnknown_03004828->textWindowBaseTileNum = TextWindow_SetBaseTileNum(2); + TextWindow_LoadStdFrameGraphics(&gUnknown_03004828->window); + Menu_EraseScreen(); ResetPaletteFade(); gMain.state++; SetHBlankCallback(EvoDummyFunc); @@ -481,7 +481,7 @@ static void CB2_EvolutionSceneUpdate(void) { AnimateSprites(); BuildOamBuffer(); - sub_800374C(&gUnknown_03004210); + Text_UpdateWindowInBattle(&gUnknown_03004210); UpdatePaletteFade(); RunTasks(); } @@ -490,7 +490,7 @@ static void CB2_TradeEvolutionSceneUpdate(void) { AnimateSprites(); BuildOamBuffer(); - sub_80035AC(&gUnknown_03004828->window); + Text_UpdateWindow(&gUnknown_03004828->window); UpdatePaletteFade(); RunTasks(); } @@ -558,7 +558,7 @@ static void Task_EvolutionScene(u8 taskID) if (!gPaletteFade.active) { StringExpandPlaceholders(gStringVar4, BattleText_StartEvo); - sub_8002EB0(&gUnknown_03004210, gStringVar4, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gStringVar4, 144, 2, 15); gTasks[taskID].tState++; } break; @@ -646,7 +646,7 @@ static void Task_EvolutionScene(u8 taskID) if (IsCryFinished() && !gPaletteFade.active) { StringExpandPlaceholders(gStringVar4, BattleText_FinishEvo); - sub_8002EB0(&gUnknown_03004210, gStringVar4, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gStringVar4, 144, 2, 15); PlayBGM(BGM_FANFA5); gTasks[taskID].tState++; SetMonData(mon, MON_DATA_SPECIES, (void*)(&gTasks[taskID].tPostEvoSpecies)); @@ -715,7 +715,7 @@ static void Task_EvolutionScene(u8 taskID) if (IsCryFinished()) { StringExpandPlaceholders(gStringVar4, BattleText_StopEvo); - sub_8002EB0(&gUnknown_03004210, gStringVar4, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gStringVar4, 144, 2, 15); gTasks[taskID].tEvoWasStopped = TRUE; gTasks[taskID].tState = 14; } @@ -726,7 +726,7 @@ static void Task_EvolutionScene(u8 taskID) sub_8024CEC(); PlayFanfare(BGM_FANFA1); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[3]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tLearnsFirstMove = 0x40; // re-used as a counter gTasks[taskID].tState++; } @@ -743,7 +743,7 @@ static void Task_EvolutionScene(u8 taskID) { sub_8024CEC(); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[4]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tLearnMoveState++; } break; @@ -751,7 +751,7 @@ static void Task_EvolutionScene(u8 taskID) if (gUnknown_03004210.state == 0 && !IsSEPlaying()) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[5]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tLearnMoveState++; } break; @@ -761,7 +761,7 @@ static void Task_EvolutionScene(u8 taskID) if (!IsSEPlaying()) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[6]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tData9 = 5; gTasks[taskID].tdata10 = 9; gTasks[taskID].tLearnMoveState++; @@ -794,7 +794,7 @@ static void Task_EvolutionScene(u8 taskID) { sub_8023AD8(); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[292]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); PlaySE(SE_SELECT); if (sEvoCursorPos != 0) gTasks[taskID].tLearnMoveState = gTasks[taskID].tdata10; @@ -809,7 +809,7 @@ static void Task_EvolutionScene(u8 taskID) { sub_8023AD8(); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[292]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); PlaySE(SE_SELECT); gTasks[taskID].tLearnMoveState = gTasks[taskID].tdata10; } @@ -835,7 +835,7 @@ static void Task_EvolutionScene(u8 taskID) if (IsHMMove2(move)) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[307]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tLearnMoveState = 11; } else @@ -848,7 +848,7 @@ static void Task_EvolutionScene(u8 taskID) RemoveMonPPBonus(mon, var); SetMonMoveSlot(mon, gMoveToLearn, var); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[207]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tLearnMoveState++; } } @@ -858,7 +858,7 @@ static void Task_EvolutionScene(u8 taskID) if (gUnknown_03004210.state == 0 && !IsSEPlaying()) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[7]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tLearnMoveState++; } break; @@ -866,20 +866,20 @@ static void Task_EvolutionScene(u8 taskID) if (gUnknown_03004210.state == 0 && !IsSEPlaying()) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[208]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tState = 19; } break; case 9: StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[8]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tData9 = 10; gTasks[taskID].tdata10 = 0; gTasks[taskID].tLearnMoveState = 3; break; case 10: StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[9]); - sub_8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004210, gDisplayedStringBattle, 144, 2, 15); gTasks[taskID].tState = 14; break; case 11: @@ -900,7 +900,7 @@ static void Task_TradeEvolutionScene(u8 taskID) { case 0: StringExpandPlaceholders(gStringVar4, BattleText_StartEvo); - sub_8002EB0(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tState++; break; case 1: @@ -988,7 +988,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (IsCryFinished() && !gPaletteFade.active) { StringExpandPlaceholders(gStringVar4, BattleText_FinishEvo); - sub_8002EB0(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gStringVar4, gUnknown_03004828->textWindowBaseTileNum, 2, 15); PlayFanfare(BGM_FANFA5); gTasks[taskID].tState++; SetMonData(mon, MON_DATA_SPECIES, (void*)(&gTasks[taskID].tPostEvoSpecies)); @@ -1022,7 +1022,7 @@ static void Task_TradeEvolutionScene(u8 taskID) else { PlayBGM(BGM_SHINKA); - sub_8002EB0(&gUnknown_03004828->window, gOtherText_LinkStandby2, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gOtherText_LinkStandby2, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tState++; } } @@ -1040,7 +1040,7 @@ static void Task_TradeEvolutionScene(u8 taskID) sub_8024CEC(); PlayFanfare(BGM_FANFA1); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[3]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tLearnsFirstMove = 0x40; // re-used as a counter gTasks[taskID].tState++; } @@ -1057,7 +1057,7 @@ static void Task_TradeEvolutionScene(u8 taskID) { sub_8024CEC(); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[4]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tLearnMoveState++; } break; @@ -1065,7 +1065,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (gUnknown_03004828->window.state == 0 && !IsSEPlaying()) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[5]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tLearnMoveState++; } break; @@ -1075,7 +1075,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (!IsSEPlaying()) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[6]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tData9 = 5; gTasks[taskID].tdata10 = 9; gTasks[taskID].tLearnMoveState++; @@ -1083,11 +1083,11 @@ static void Task_TradeEvolutionScene(u8 taskID) case 3: if (gUnknown_03004828->window.state == 0 && !IsSEPlaying()) { - DrawTextWindow(&gUnknown_03004828->window, 24, 8, 29, 13); + TextWindow_DrawStdFrame(&gUnknown_03004828->window, 24, 8, 29, 13); sEvoCursorPos = 0; - InitWindow(&gUnknown_03004828->window, gOtherText_YesNoAndPlayer, gUnknown_03004828->textWindowBaseTileNum + 128, 25, 9); - sub_8002F44(&gUnknown_03004828->window); - sub_814A5C0(0, 0xFFFF, 0xC, 0x2D9F, 0x20); + Text_InitWindow(&gUnknown_03004828->window, gOtherText_YesNoAndPlayer, gUnknown_03004828->textWindowBaseTileNum + 128, 25, 9); + Text_PrintWindow8002F44(&gUnknown_03004828->window); + MenuCursor_Create814A5C0(0, 0xFFFF, 0xC, 0x2D9F, 0x20); sub_81150D8(); gTasks[taskID].tLearnMoveState++; sEvoCursorPos = 0; @@ -1110,10 +1110,10 @@ static void Task_TradeEvolutionScene(u8 taskID) } if (gMain.newKeys & A_BUTTON) { - ZeroFillWindowRect(&gUnknown_03004828->window, 0x18, 8, 0x1D, 0xD); + Text_EraseWindowRect(&gUnknown_03004828->window, 0x18, 8, 0x1D, 0xD); DestroyMenuCursor(); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[292]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); PlaySE(SE_SELECT); if (sEvoCursorPos != 0) gTasks[taskID].tLearnMoveState = gTasks[taskID].tdata10; @@ -1126,10 +1126,10 @@ static void Task_TradeEvolutionScene(u8 taskID) } if (gMain.newKeys & B_BUTTON) { - ZeroFillWindowRect(&gUnknown_03004828->window, 0x18, 8, 0x1D, 0xD); + Text_EraseWindowRect(&gUnknown_03004828->window, 0x18, 8, 0x1D, 0xD); DestroyMenuCursor(); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[292]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); PlaySE(SE_SELECT); gTasks[taskID].tLearnMoveState = gTasks[taskID].tdata10; } @@ -1155,7 +1155,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (IsHMMove2(move)) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[307]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tLearnMoveState = 11; } else @@ -1168,7 +1168,7 @@ static void Task_TradeEvolutionScene(u8 taskID) RemoveMonPPBonus(mon, var); SetMonMoveSlot(mon, gMoveToLearn, var); StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[207]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tLearnMoveState++; } } @@ -1178,7 +1178,7 @@ static void Task_TradeEvolutionScene(u8 taskID) if (gUnknown_03004828->window.state == 0 && !IsSEPlaying()) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[7]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tLearnMoveState++; } break; @@ -1186,20 +1186,20 @@ static void Task_TradeEvolutionScene(u8 taskID) if (gUnknown_03004828->window.state == 0 && !IsSEPlaying()) { StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[208]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tState = 15; } break; case 9: StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[8]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tData9 = 10; gTasks[taskID].tdata10 = 0; gTasks[taskID].tLearnMoveState = 3; break; case 10: StrCpyDecodeToDisplayedStringBattle(gBattleStringsTable[9]); - sub_8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); + Text_InitWindow8002EB0(&gUnknown_03004828->window, gDisplayedStringBattle, gUnknown_03004828->textWindowBaseTileNum, 2, 15); gTasks[taskID].tState = 13; break; case 11: @@ -3929,12 +3929,12 @@ static void VBlankCB_EvolutionScene(void) REG_BG1VOFS = gBattle_BG1_Y; REG_BG2HOFS = gBattle_BG2_X; REG_BG2VOFS = gBattle_BG2_Y; - REG_BG3HOFS = gUnknown_030041B0; - REG_BG3VOFS = gUnknown_030041B8; + REG_BG3HOFS = gBattle_BG3_X; + REG_BG3VOFS = gBattle_BG3_Y; LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); } static void VBlankCB_TradeEvolutionScene(void) @@ -3945,17 +3945,17 @@ static void VBlankCB_TradeEvolutionScene(void) REG_BG1VOFS = gBattle_BG1_Y; REG_BG2HOFS = gBattle_BG2_X; REG_BG2VOFS = gBattle_BG2_Y; - REG_BG3HOFS = gUnknown_030041B0; - REG_BG3VOFS = gUnknown_030041B8; + REG_BG3HOFS = gBattle_BG3_X; + REG_BG3VOFS = gBattle_BG3_Y; LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); } static void sub_81150D8(void) { - sub_814A880(200, 72 + (sEvoCursorPos * 16)); + MenuCursor_SetPos814A880(200, 72 + (sEvoCursorPos * 16)); } static void EvoDummyFunc2(void) diff --git a/src/scene/hall_of_fame.c b/src/scene/hall_of_fame.c index 4740c086d..bfa0d1705 100644 --- a/src/scene/hall_of_fame.c +++ b/src/scene/hall_of_fame.c @@ -16,7 +16,10 @@ #include "data2.h" #include "decompress.h" #include "random.h" +#include "scanline_effect.h" #include "trig.h" +#include "hof_pc.h" +#include "credits.h" #include "pc_screen_effect.h" #include "ewram.h" @@ -88,11 +91,6 @@ static u32 HallOfFame_LoadPokemonPic(u16 species, s16 posX, s16 posY, u16 pokeID static u32 HallOfFame_LoadTrainerPic(u16 trainerPicID, s16 posX, s16 posY, u16 a3); static bool8 sub_81438C4(void); -// functions from different files -void sub_81439D0(void); -void ReturnFromHallOfFamePC(void); -void remove_some_task(void); - // data and gfx static const struct CompressedSpriteSheet sHallOfFame_ConfettiSpriteSheet = @@ -554,8 +552,8 @@ static void sub_814217C(u8 taskID) lastSavedTeam--; } *lastSavedTeam = *fameMons; - MenuDrawTextWindow(2, 14, 27, 19); - MenuPrint(gMenuText_HOFSaving, 3, 15); + Menu_DrawStdWindowFrame(2, 14, 27, 19); + Menu_PrintText(gMenuText_HOFSaving, 3, 15); gTasks[taskID].func = sub_8142274; } @@ -578,8 +576,8 @@ static void sub_81422B8(u8 taskID) static void sub_81422E8(u8 taskID) { - SetUpWindowConfig(&gWindowConfig_81E7198); - InitMenuWindow(&gWindowConfig_81E7198); + Text_LoadWindowTemplate(&gWindowTemplate_81E7198); + InitMenuWindow(&gWindowTemplate_81E7198); gTasks[taskID].func = sub_8142320; } @@ -613,7 +611,7 @@ static void sub_8142320(u8 taskID) gSprites[spriteID].data[0] = 0; gSprites[spriteID].callback = sub_81435DC; gTasks[taskID].tMonSpriteID(currPokeID) = spriteID; - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); gTasks[taskID].func = sub_8142404; } @@ -666,7 +664,7 @@ static void sub_8142570(u8 taskID) if (gTasks[taskID].tMonSpriteID(i) != 0xFF) gSprites[gTasks[taskID].tMonSpriteID(i)].oam.priority = 0; } - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); sub_8143068(0, 15); PlaySE(SE_DENDOU); gTasks[taskID].tFrameCount = 400; @@ -690,7 +688,7 @@ static void sub_8142618(u8 taskID) gSprites[gTasks[taskID].tMonSpriteID(i)].oam.priority = 1; } BeginNormalPaletteFade(sUnknown_0203931C, 0, 12, 12, 0x735F); - MenuZeroFillWindowRect(0, 14, 29, 19); + Menu_EraseWindowRect(0, 14, 29, 19); gTasks[taskID].tFrameCount = 7; gTasks[taskID].func = sub_81426F8; } @@ -710,8 +708,8 @@ static void sub_81426F8(u8 taskID) static void sub_8142738(u8 taskID) { REG_DISPCNT = 0x1940; - SetUpWindowConfig(&gWindowConfig_81E71B4); - InitMenuWindow(&gWindowConfig_81E71B4); + Text_LoadWindowTemplate(&gWindowTemplate_81E71B4); + InitMenuWindow(&gWindowTemplate_81E71B4); gTasks[taskID].tPlayerSpriteID = HallOfFame_LoadTrainerPic(gSaveBlock2.playerGender, 120, 72, 6); gTasks[taskID].tFrameCount = 120; @@ -728,10 +726,10 @@ static void sub_8142794(u8 taskID) gSprites[gTasks[taskID].tPlayerSpriteID].pos1.x++; else { - MenuDrawTextWindow(1, 2, 15, 9); + Menu_DrawStdWindowFrame(1, 2, 15, 9); HallOfFame_PrintPlayerInfo(1, 2); - MenuDrawTextWindow(2, 14, 27, 19); - MenuPrint(gMenuText_HOFCongratulations, 4, 15); + Menu_DrawStdWindowFrame(2, 14, 27, 19); + Menu_PrintText(gMenuText_HOFCongratulations, 4, 15); gTasks[taskID].func = sub_8142818; } } @@ -855,8 +853,8 @@ static void sub_8142A28(u8 taskID) *(vram1 + i) = i + 3; *(vram2 + i) = i + 20; } - SetUpWindowConfig(&gWindowConfig_81E7198); - InitMenuWindow(&gWindowConfig_81E7198); + Text_LoadWindowTemplate(&gWindowTemplate_81E7198); + InitMenuWindow(&gWindowTemplate_81E7198); gTasks[taskID].func = sub_8142B04; } } @@ -921,7 +919,7 @@ static void sub_8142B04(u8 taskID) stringPtr[1] = 0x13; stringPtr[2] = 0xF0; stringPtr[3] = EOS; - MenuPrint(gStringVar1, 0, 0); + Menu_PrintText(gStringVar1, 0, 0); gTasks[taskID].func = sub_8142CC8; } @@ -1030,14 +1028,14 @@ static void sub_8142FCC(u8 taskID) static void sub_8142FEC(u8 taskID) { - MenuDrawTextWindow(2, 14, 27, 19); + Menu_DrawStdWindowFrame(2, 14, 27, 19); MenuPrintMessage(gMenuText_HOFCorrupt, 3, 15); gTasks[taskID].func = sub_814302C; } static void sub_814302C(u8 taskID) { - if (MenuUpdateWindowText() && gMain.newKeys & A_BUTTON) + if (Menu_UpdateWindowText() && gMain.newKeys & A_BUTTON) gTasks[taskID].func = sub_8142F78; } @@ -1074,7 +1072,7 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 a1, u8 a2) } } - MenuPrint(gStringVar1, a1 + 4, a2 + 1); + Menu_PrintText(gStringVar1, a1 + 4, a2 + 1); stringPtr = gStringVar1; for (i = 0; i < 10 && currMon->nick[i] != EOS; stringPtr[i] = currMon->nick[i], i++) {} @@ -1087,8 +1085,8 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 a1, u8 a2) stringPtr[1] = 0x13; stringPtr[2] = 0xA0; stringPtr[3] = EOS; - MenuPrint(gStringVar1, a1 + 9, a2 + 1); - MenuZeroFillWindowRect(0, a2 + 3, 29, a2 + 4); + Menu_PrintText(gStringVar1, a1 + 9, a2 + 1); + Menu_EraseWindowRect(0, a2 + 3, 29, a2 + 4); } else { @@ -1127,7 +1125,7 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 a1, u8 a2) stringPtr[2] = 0xA0; stringPtr[3] = EOS; - MenuPrint(gStringVar1, a1 + 9, a2 + 1); + Menu_PrintText(gStringVar1, a1 + 9, a2 + 1); monData = currMon->lvl; @@ -1145,14 +1143,14 @@ static void HallOfFame_PrintMonInfo(struct HallofFameMon* currMon, u8 a1, u8 a2) stringPtr[2] = 0x30; stringPtr[3] = EOS; - MenuPrint(gStringVar1, a1 + 7, a2 + 3); + Menu_PrintText(gStringVar1, a1 + 7, a2 + 3); monData = currMon->tid; stringPtr = StringCopy(gStringVar1, gOtherText_IDNumber); ConvertIntToDecimalStringN(stringPtr, monData, 2, 5); - MenuPrint(gStringVar1, a1 + 13, a2 + 3); + Menu_PrintText(gStringVar1, a1 + 13, a2 + 3); } } @@ -1163,15 +1161,15 @@ static void HallOfFame_PrintPlayerInfo(u8 a0, u8 a1) u8* stringPtr; u16 visibleTid; - MenuPrint(gOtherText_Name, a0 + 1, a1 + 1); + Menu_PrintText(gOtherText_Name, a0 + 1, a1 + 1); MenuPrint_RightAligned(gSaveBlock2.playerName, a0 + 14, a1 + 1); - MenuPrint(gOtherText_IDNumber2, a0 + 1, a1 + 3); + Menu_PrintText(gOtherText_IDNumber2, a0 + 1, a1 + 3); visibleTid = ByteRead16(gSaveBlock2.playerTrainerId); ConvertIntToDecimalStringN(gStringVar1, visibleTid, 2, 5); MenuPrint_RightAligned(gStringVar1, a0 + 14, a1 + 3); - MenuPrint(gMainMenuString_Time, a0 + 1, a1 + 5); + Menu_PrintText(gMainMenuString_Time, a0 + 1, a1 + 5); stringPtr = ConvertIntToDecimalString(gStringVar1, gSaveBlock2.playTimeHours); stringPtr[0] = CHAR_SPACE; @@ -1266,15 +1264,15 @@ static void sub_81433E0(void) static void sub_8143570(void) { - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); gReservedSpritePaletteCount = 8; LoadCompressedObjectPic(&sHallOfFame_ConfettiSpriteSheet); LoadCompressedObjectPalette(&sHallOfFame_ConfettiSpritePalette); - SetUpWindowConfig(&gWindowConfig_81E71B4); - InitMenuWindow(&gWindowConfig_81E71B4); + Text_LoadWindowTemplate(&gWindowTemplate_81E71B4); + InitMenuWindow(&gWindowTemplate_81E71B4); } static void sub_81435B8(void) diff --git a/src/scene/intro.c b/src/scene/intro.c index 4dc6cc91c..d7d772a40 100644 --- a/src/scene/intro.c +++ b/src/scene/intro.c @@ -19,7 +19,7 @@ #include "task.h" #include "title_screen.h" #include "trig.h" -#include "unknown_task.h" +#include "scanline_effect.h" #include "ewram.h" extern struct SpriteTemplate gUnknown_02024E8C; @@ -873,7 +873,7 @@ static u8 SetUpCopyrightScreen(void) DmaFill16(3, 0, (void *)(PLTT + 2), PLTT_SIZE - 2); ResetPaletteFade(); LoadCopyrightGraphics(0, 0x3800, 0); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); diff --git a/src/scene/intro_credits_graphics.c b/src/scene/intro_credits_graphics.c index 6cee74cce..f0f1264a0 100755 --- a/src/scene/intro_credits_graphics.c +++ b/src/scene/intro_credits_graphics.c @@ -19,7 +19,7 @@ #include "task.h" #include "title_screen.h" #include "trig.h" -#include "unknown_task.h" +#include "scanline_effect.h" // define register constants for the inline asm asm(".include \"constants/gba_constants.inc\"\n"); diff --git a/src/scene/title_screen.c b/src/scene/title_screen.c index 26fe088d5..202b752a6 100644 --- a/src/scene/title_screen.c +++ b/src/scene/title_screen.c @@ -13,7 +13,7 @@ #include "sound.h" #include "sprite.h" #include "task.h" -#include "unknown_task.h" +#include "scanline_effect.h" #if ENGLISH #define VERSION_BANNER_SHAPE 1 @@ -598,7 +598,7 @@ static void StartPokemonLogoShine(bool8 flashBackground) static void VBlankCB(void) { - sub_8089668(); + ScanlineEffect_InitHBlankDmaTransfer(); LoadOam(); ProcessSpriteCopyRequests(); TransferPlttBuffer(); @@ -644,7 +644,7 @@ void CB2_InitTitleScreen(void) LZ77UnCompVram(sLegendaryMonTilemap, (void *)(VRAM + 0xC000)); LZ77UnCompVram(sBackdropTilemap, (void *)(VRAM + 0xC800)); LoadPalette(sLegendaryMonPalettes, 0xE0, sizeof(sLegendaryMonPalettes)); - remove_some_task(); + ScanlineEffect_Stop(); ResetTasks(); ResetSpriteData(); FreeAllSpritePalettes(); @@ -711,7 +711,7 @@ void CB2_InitTitleScreen(void) if (!UpdatePaletteFade()) { StartPokemonLogoShine(FALSE); - sub_8089944(0, 0xA0, 4, 4, 0, 4, 1); + ScanlineEffect_InitWave(0, DISPLAY_HEIGHT, 4, 4, 0, SCANLINE_EFFECT_REG_BG1HOFS, TRUE); SetMainCallback2(MainCB2); } break; diff --git a/src/script_pokemon_util_80C4BF0.c b/src/script_pokemon_util_80C4BF0.c index f397e5ebb..b13006c13 100644 --- a/src/script_pokemon_util_80C4BF0.c +++ b/src/script_pokemon_util_80C4BF0.c @@ -292,7 +292,7 @@ void ShowContestEntryMonPic(void) u8 left = CONTEST_ENTRY_PIC_LEFT; u8 top = CONTEST_ENTRY_PIC_TOP; - MenuDrawTextWindow(left, top, 19, 13); + Menu_DrawStdWindowFrame(left, top, 19, 13); species = gContestMons[gSpecialVar_0x8006].species; var1 = gContestMons[gSpecialVar_0x8006].personality; var2 = gContestMons[gSpecialVar_0x8006].otId; @@ -349,7 +349,7 @@ void sub_80C5190(u8 taskId) task->data[0]++; break; case 3: - MenuZeroFillWindowRect(task->data[3], task->data[4], task->data[3] + 9, task->data[4] + 10); + Menu_EraseWindowRect(task->data[3], task->data[4], task->data[3] + 9, task->data[4] + 10); DestroyTask(taskId); break; case 1: diff --git a/src/unknown_task.c b/src/unknown_task.c deleted file mode 100644 index 2c71bfb08..000000000 --- a/src/unknown_task.c +++ /dev/null @@ -1,235 +0,0 @@ -#include "global.h" -#include "data2.h" -#include "task.h" -#include "trig.h" -#include "unknown_task.h" - -static void sub_80896F4(void); -static void sub_8089714(void); - -extern u16 gUnknown_030041B0; -extern u16 gBattle_BG1_Y; -extern u16 gUnknown_030041B8; -extern u16 gBattle_BG2_Y; -extern u16 gBattle_BG2_X; -extern u16 gBattle_BG0_Y; -extern u16 gBattle_BG0_X; -extern u16 gBattle_BG1_X; - -extern u8 gUnknown_0202FFA4; - -extern struct UnknownTaskStruct2 gUnknown_03004DC0; - -// Is this a struct? -extern u16 gUnknown_03004DE0[][0x3C0]; - -void remove_some_task(void) -{ - gUnknown_03004DC0.unk15 = 0; - DmaStop(0); - if (gUnknown_03004DC0.taskId != 0xFF) - { - DestroyTask(gUnknown_03004DC0.taskId); - gUnknown_03004DC0.taskId = 0xFF; - } -} - -void dp12_8087EA4(void) -{ - CpuFill16(0, gUnknown_03004DE0, 0x780 * 2); - gUnknown_03004DC0.src[0] = 0; - gUnknown_03004DC0.src[1] = 0; - gUnknown_03004DC0.dest = 0; - gUnknown_03004DC0.unkC = 0; - gUnknown_03004DC0.srcBank = 0; - gUnknown_03004DC0.unk15 = 0; - gUnknown_03004DC0.unk16 = 0; - gUnknown_03004DC0.unk17 = 0; - gUnknown_03004DC0.taskId = 0xFF; -} - -void sub_80895F8(struct UnknownTaskStruct unk) -{ - if (unk.control == (((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1)) - { - gUnknown_03004DC0.src[0] = &gUnknown_03004DE0[0][1]; - gUnknown_03004DC0.src[1] = &gUnknown_03004DE0[1][1]; - gUnknown_03004DC0.unk10 = sub_80896F4; - } - else - { - gUnknown_03004DC0.src[0] = &gUnknown_03004DE0[0][2]; - gUnknown_03004DC0.src[1] = &gUnknown_03004DE0[1][2]; - gUnknown_03004DC0.unk10 = sub_8089714; - } - - gUnknown_03004DC0.unkC = unk.control; - gUnknown_03004DC0.dest = unk.dest; - gUnknown_03004DC0.unk15 = unk.unk8; - gUnknown_03004DC0.unk16 = unk.unk9; - gUnknown_03004DC0.unk17 = unk.unk9; -} - -void sub_8089668(void) -{ - if (gUnknown_03004DC0.unk15) - { - if (gUnknown_03004DC0.unk15 == 3) - { - gUnknown_03004DC0.unk15 = 0; - DmaStop(0); - gUnknown_0202FFA4 = 1; - } - else - { - DmaStop(0); - DmaSet(0, gUnknown_03004DC0.src[gUnknown_03004DC0.srcBank], gUnknown_03004DC0.dest, gUnknown_03004DC0.unkC); - gUnknown_03004DC0.unk10(); - gUnknown_03004DC0.srcBank ^= 1; - } - } -} - -static void sub_80896F4(void) -{ - u16 *dest = (u16 *)gUnknown_03004DC0.dest; - u16 *src = (u16 *)&gUnknown_03004DE0[gUnknown_03004DC0.srcBank]; - *dest = *src; -} - -static void sub_8089714(void) -{ - u32 *dest = (u32 *)gUnknown_03004DC0.dest; - u32 *src = (u32 *)&gUnknown_03004DE0[gUnknown_03004DC0.srcBank]; - *dest = *src; -} - -static void task00_for_dp12(u8 taskId) -{ - int value = 0; - - if (gUnknown_0202FFA4) - { - DestroyTask(taskId); - gUnknown_03004DC0.taskId = 0xFF; - } - else - { - if (gTasks[taskId].data[7]) - { - switch (gTasks[taskId].data[6]) - { - case 0x0: - value = gBattle_BG0_X; - break; - case 0x2: - value = gBattle_BG0_Y; - break; - case 0x4: - value = gBattle_BG1_X; - break; - case 0x6: - value = gBattle_BG1_Y; - break; - case 0x8: - value = gBattle_BG2_X; - break; - case 0xA: - value = gBattle_BG2_Y; - break; - case 0xC: - value = gUnknown_030041B0; - break; - case 0xE: - value = gUnknown_030041B8; - break; - } - } - if (gTasks[taskId].data[4]) - { - int i; - int offset; - gTasks[taskId].data[4]--; - offset = gTasks[taskId].data[3] + 320; - for (i = gTasks[taskId].data[0]; i < gTasks[taskId].data[1]; i++) - { - gUnknown_03004DE0[gUnknown_03004DC0.srcBank][i] = gUnknown_03004DE0[0][offset] + value; - offset++; - } - } - else - { - int i; - int offset; - gTasks[taskId].data[4] = gTasks[taskId].data[5]; - offset = gTasks[taskId].data[3] + 320; - for (i = gTasks[taskId].data[0]; i < gTasks[taskId].data[1]; i++) - { - gUnknown_03004DE0[gUnknown_03004DC0.srcBank][i] = gUnknown_03004DE0[0][offset] + value; - offset++; - } - gTasks[taskId].data[3]++; - if (gTasks[taskId].data[3] == gTasks[taskId].data[2]) - { - gTasks[taskId].data[3] = 0; - } - } - } -} - -static void sub_80898FC(u16 *a1, u8 a2, u8 a3, u8 a4) -{ - u16 i = 0; - u8 offset = 0; - - while (i < 0x100) - { - a1[i] = (gSineTable[offset] * a3) / 256; - offset += a2; - i++; - } -} - -u8 sub_8089944(u8 a1, u8 a2, u8 a3, u8 a4, u8 a5, u8 a6, u8 a7) -{ - int i; - int offset; - struct UnknownTaskStruct unk; - u8 taskId; - - dp12_8087EA4(); - - unk.dest = (void *)(REG_ADDR_BG0HOFS + a6); - unk.control = ((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_DEST_RELOAD) << 16) | 1; - unk.unk8 = 1; - unk.unk9 = 0; - - sub_80895F8(unk); - - taskId = CreateTask(task00_for_dp12, 0); - - gTasks[taskId].data[0] = a1; - gTasks[taskId].data[1] = a2; - gTasks[taskId].data[2] = 256 / a3; - gTasks[taskId].data[3] = 0; - gTasks[taskId].data[4] = a5; - gTasks[taskId].data[5] = a5; - gTasks[taskId].data[6] = a6; - gTasks[taskId].data[7] = a7; - - gUnknown_03004DC0.taskId = taskId; - gUnknown_0202FFA4 = 0; - - sub_80898FC(&gUnknown_03004DE0[0][320], a3, a4, a2 - a1); - - offset = 320; - - for (i = a1; i < a2; i++) - { - gUnknown_03004DE0[0][i] = gUnknown_03004DE0[0][offset]; - gUnknown_03004DE0[1][i] = gUnknown_03004DE0[0][offset]; - offset++; - } - - return taskId; -} diff --git a/src/unused_81258BC.c b/src/unused_81258BC.c index c509ea4c9..c25884053 100644 --- a/src/unused_81258BC.c +++ b/src/unused_81258BC.c @@ -31,6 +31,6 @@ bool8 unref_sub_812AECC(u8 *script) void sub_812AF10(void) { - MenuDrawTextWindow(2, 14, 27, 19); - MenuPrint(gStringVar4, 3, 15); + Menu_DrawStdWindowFrame(2, 14, 27, 19); + Menu_PrintText(gStringVar4, 3, 15); }
\ No newline at end of file |