Fully document move_tutor (formerly learn_move)

This commit is contained in:
Phlosioneer 2019-03-03 02:50:40 -05:00
parent 043071ae12
commit 4907ce6f7f
28 changed files with 1090 additions and 952 deletions

View File

@ -1579,12 +1579,12 @@ _081D2800:
.pool
thumb_func_end sub_81D2754
thumb_func_start sub_81D2824
sub_81D2824: @ 81D2824
thumb_func_start InitMoveTutorWindows
InitMoveTutorWindows: @ 81D2824
push {r4,r5,lr}
lsls r0, 24
lsrs r5, r0, 24
ldr r0, =gUnknown_08625510
ldr r0, =gMoveTutorWindowTemplates
bl InitWindows
bl DeactivateAllTextPrinters
movs r0, 0
@ -1645,21 +1645,21 @@ _081D288E:
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_81D2824
thumb_func_end InitMoveTutorWindows
thumb_func_start nullsub_79
nullsub_79: @ 81D28C4
bx lr
thumb_func_end nullsub_79
thumb_func_start sub_81D28C8
sub_81D28C8: @ 81D28C8
thumb_func_start LoadMoveTutorMovesList
LoadMoveTutorMovesList: @ 81D28C8
push {r4-r7,lr}
lsls r1, 16
lsrs r4, r1, 16
ldr r3, =gMultiuseListMenuTemplate
adds r2, r3, 0
ldr r1, =gUnknown_08625548
ldr r1, =gMoveTutorMovesListTemplate
ldm r1!, {r5-r7}
stm r2!, {r5-r7}
ldm r1!, {r5-r7}
@ -1679,10 +1679,10 @@ _081D28F4:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_81D28C8
thumb_func_end LoadMoveTutorMovesList
thumb_func_start sub_81D28FC
sub_81D28FC: @ 81D28FC
thumb_func_start MoveTutorLoadBattleMoveDescription
MoveTutorLoadBattleMoveDescription: @ 81D28FC
push {r4-r7,lr}
mov r7, r10
mov r6, r9
@ -1884,16 +1884,16 @@ _081D2AB6:
pop {r0}
bx r0
.pool
thumb_func_end sub_81D28FC
thumb_func_end MoveTutorLoadBattleMoveDescription
thumb_func_start sub_81D2ACC
sub_81D2ACC: @ 81D2ACC
thumb_func_start MoveTutorMenuLoadContestMoveDescription
MoveTutorMenuLoadContestMoveDescription: @ 81D2ACC
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0xC
adds r4, r0, 0
bl ShowHideHearts
bl MoveTutorShowHideHearts
movs r0, 0x1
movs r1, 0x11
bl FillWindowPixelBuffer
@ -1997,10 +1997,10 @@ _081D2BB8:
pop {r0}
bx r0
.pool
thumb_func_end sub_81D2ACC
thumb_func_end MoveTutorMenuLoadContestMoveDescription
thumb_func_start sub_81D2BD0
sub_81D2BD0: @ 81D2BD0
thumb_func_start MoveTutorCursorCallback
MoveTutorCursorCallback: @ 81D2BD0
push {r4,lr}
adds r4, r0, 0
lsls r1, 24
@ -2011,16 +2011,16 @@ sub_81D2BD0: @ 81D2BD0
bl PlaySE
_081D2BE2:
adds r0, r4, 0
bl sub_81D28FC
bl MoveTutorLoadBattleMoveDescription
adds r0, r4, 0
bl sub_81D2ACC
bl MoveTutorMenuLoadContestMoveDescription
pop {r4}
pop {r0}
bx r0
thumb_func_end sub_81D2BD0
thumb_func_end MoveTutorCursorCallback
thumb_func_start sub_81D2BF4
sub_81D2BF4: @ 81D2BF4
thumb_func_start MoveTutorPrintText
MoveTutorPrintText: @ 81D2BF4
push {r4,lr}
sub sp, 0x10
adds r4, r0, 0
@ -2052,10 +2052,10 @@ sub_81D2BF4: @ 81D2BF4
pop {r0}
bx r0
.pool
thumb_func_end sub_81D2BF4
thumb_func_end MoveTutorPrintText
thumb_func_start sub_81D2C3C
sub_81D2C3C: @ 81D2C3C
thumb_func_start MoveTutorRunTextPrinters
MoveTutorRunTextPrinters: @ 81D2C3C
push {lr}
bl RunTextPrinters
movs r0, 0x3
@ -2064,12 +2064,12 @@ sub_81D2C3C: @ 81D2C3C
lsrs r0, 16
pop {r1}
bx r1
thumb_func_end sub_81D2C3C
thumb_func_end MoveTutorRunTextPrinters
thumb_func_start sub_81D2C50
sub_81D2C50: @ 81D2C50
thumb_func_start MoveTutorCreateYesNoMenu
MoveTutorCreateYesNoMenu: @ 81D2C50
push {lr}
ldr r0, =gUnknown_08625540
ldr r0, =gMoveTutorYesNoMenuTemplate
movs r1, 0x1
movs r2, 0xE
movs r3, 0
@ -2077,7 +2077,7 @@ sub_81D2C50: @ 81D2C50
pop {r0}
bx r0
.pool
thumb_func_end sub_81D2C50
thumb_func_end MoveTutorCreateYesNoMenu
thumb_func_start sub_81D2C68
sub_81D2C68: @ 81D2C68

View File

@ -23,27 +23,22 @@ gUnknown_08625404:: @ 8625404
gUnknown_08625410:: @ 8625410
.byte 4, 5, 6, 7, 8, 9, 9, 0xA, 0xA, 0xB, 0xB, 0xC, 0xC, 0xD, 0xD, 0xD, 0xD, 0xE, 0xE, 0xE, 0xE, 0xF, 0xF, 0xF, 0xF, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x11, 0x11, 0x11, 0x11, 0x11, 0x11, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x13, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x17, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x19, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1A, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1C, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1D, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x22, 0x23
gUnknown_08625510:: @ 8625510
.4byte 0x10010101
.4byte 0xA0F0C
.4byte 0x10010101
.4byte 0xCA0F0C
.4byte 0xA011301
.4byte 0x18A0F0C
.4byte 0x160F0401
.4byte 0x2020F04
.4byte 0x5081600
.4byte 0x25A0F04
.4byte 0xFF
.4byte NULL
gMoveTutorWindowTemplates:: @ 8625510s
window_template 1, 1, 1, 16, 12, 0xF, 0x000A
window_template 1, 1, 1, 16, 12, 0xF, 0x00CA
window_template 1, 19, 1, 10, 12, 0xF, 0x018A
window_template 1, 4, 15, 22, 4, 0xF, 0x0202
window_template 0, 22, 8, 5, 4, 0xF, 0x025A
null_window_template
gUnknown_08625540:: @ 8625540
.4byte 0x5081600
.4byte 0x25A0F04
gMoveTutorYesNoMenuTemplate:: @ 8625540
window_template 0, 22, 8, 5, 4, 0xF, 0x025A
@.4byte 0x5081600
@.4byte 0x25A0F04
gUnknown_08625548:: @ 8625548
gMoveTutorMovesListTemplate:: @ 8625548 struct ListMenuTemplate
.4byte NULL
.4byte sub_81D2BD0
.4byte MoveTutorCursorCallback
.4byte NULL
.2byte 0
.2byte 0

View File

@ -5,7 +5,7 @@ void pal_fill_for_maplights(void);
void pal_fill_black(void);
void WarpFadeScreen(void);
void sub_80AF128(void);
void sub_80AF168(void);
void FieldCallback_ReturnToEventScript2(void);
void sub_80AF188(void);
void sub_80AF214(void);
void sub_80AF2B4(u8 taskId);

View File

@ -4,7 +4,7 @@
#include "window.h"
#define LIST_NOTHING_CHOSEN -1
#define LIST_B_PRESSED -2
#define LIST_CANCEL -2
#define LIST_HEADER -3
#define LIST_NO_MULTIPLE_SCROLL 0

View File

@ -2,6 +2,6 @@
#define GUARD_LEARN_MOVE_H
void TeachMoveTutorMove(void);
void ShowHideHearts(s32);
void MoveTutorShowHideHearts(s32);
#endif //GUARD_LEARN_MOVE_H

View File

@ -20,11 +20,11 @@ void sub_81D1EC0(void);
void sub_81D1D04(u8);
bool8 sub_81D1C44(u8);
bool8 sub_81D4A58(struct EventObject*);
void sub_81D2BF4(u8 *);
u16 sub_81D2C3C(void);
void sub_81D2C50(void);
u8 sub_81D28C8(const struct ListMenuItem *items, u16 numChoices);
void sub_81D2824(u16);
void MoveTutorPrintText(u8 *);
u16 MoveTutorRunTextPrinters(void);
void MoveTutorCreateYesNoMenu(void);
u8 LoadMoveTutorMovesList(const struct ListMenuItem *items, u16 numChoices);
void InitMoveTutorWindows(bool8 useContextWindow);
bool8 EventObjectIsFarawayIslandMew(struct EventObject *);
u32 sub_81D427C(void);
void sub_81D4998(void);

View File

@ -859,15 +859,15 @@ extern const u8 gText_Winona[];
extern const u8 gText_Phoebe[];
extern const u8 gText_Glacia[];
extern const u8 gText_PkmnLearnedMove4[];
extern const u8 gText_PkmnTryingToLearnMove[];
extern const u8 gText_WhichMoveToForget2[];
extern const u8 gText_StopTryingToTeachMove[];
extern const u8 gText_12AndPoof[];
extern const u8 gText_PkmnForgotMoveAndLearnedNew[];
extern const u8 gText_MoveTutorPkmnLearnedMove[];
extern const u8 gText_MoveTutorPkmnTryingToLearnMove[];
extern const u8 gText_MoveTutorWhichMoveToForget[];
extern const u8 gText_MoveTutorStopTryingToTeachMove[];
extern const u8 gText_MoveTutorAndPoof[];
extern const u8 gText_MoveTutorPkmnForgotMoveAndLearnedNew[];
extern const u8 gText_TeachWhichMoveToPkmn[];
extern const u8 gText_GiveUpTeachingNewMove[];
extern const u8 gText_TeachX[];
extern const u8 gText_MoveTutorGiveUp[];
extern const u8 gText_MoveTutorTeachMoveConfirm[];
extern const u8 gText_Kira[];
extern const u8 gText_Amy[];

View File

@ -226,7 +226,7 @@ SECTIONS {
src/battle_controller_safari.o(.text);
src/fldeff_sweetscent.o(.text);
src/battle_anim_effects_3.o(.text);
src/learn_move.o(.text);
src/move_tutor.o(.text);
src/fldeff_softboiled.o(.text);
src/decoration_inventory.o(.text);
src/roamer.o(.text);
@ -535,7 +535,7 @@ SECTIONS {
src/contest_ai.o(.rodata);
src/battle_controller_safari.o(.rodata);
src/battle_anim_effects_3.o(.rodata);
src/learn_move.o(.rodata);
src/move_tutor.o(.rodata);
src/roamer.o(.rodata);
src/battle_tower.o(.rodata);
src/use_pokeblock.o(.rodata);

View File

@ -576,7 +576,7 @@ static void SetBagItemsListTemplate(void)
}
StringCopy(gPyramidBagResources->itemStrings[i], gText_CloseBag);
gPyramidBagResources->bagListItems[i].name = gPyramidBagResources->itemStrings[i];
gPyramidBagResources->bagListItems[i].id = LIST_B_PRESSED;
gPyramidBagResources->bagListItems[i].id = LIST_CANCEL;
gMultiuseListMenuTemplate = gUnknown_0861F2C0;
gMultiuseListMenuTemplate.totalItems = gPyramidBagResources->listMenuCount;
gMultiuseListMenuTemplate.items = gPyramidBagResources->bagListItems;
@ -607,7 +607,7 @@ static void PyramidBagMoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMen
if (gPyramidBagResources->unk814 == 0xFF)
{
sub_81C6FF8(gPyramidBagResources->unk815 ^ 1);
if (itemIndex != LIST_B_PRESSED)
if (itemIndex != LIST_CANCEL)
ShowItemImage(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][itemIndex], gPyramidBagResources->unk815);
else
ShowItemImage(0xFFFF, gPyramidBagResources->unk815);
@ -619,7 +619,7 @@ static void PyramidBagMoveCursorFunc(s32 itemIndex, bool8 onInit, struct ListMen
static void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y)
{
s32 xAlign;
if (itemIndex == LIST_B_PRESSED)
if (itemIndex == LIST_CANCEL)
return;
if (gPyramidBagResources->unk814 != 0xFF)
@ -641,7 +641,7 @@ static void PrintItemQuantity(u8 windowId, s32 itemIndex, u8 y)
static void PrintItemDescription(s32 listMenuId)
{
const u8 *desc;
if (listMenuId != LIST_B_PRESSED)
if (listMenuId != LIST_CANCEL)
{
desc = ItemId_GetDescription(gSaveBlock2Ptr->frontier.pyramidBag.itemId[gSaveBlock2Ptr->frontier.lvlMode][listMenuId]);
}
@ -859,7 +859,7 @@ static void Task_HandlePyramidBagInput(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
gSpecialVar_ItemId = 0;
sub_81C5B14(taskId);
@ -1293,7 +1293,7 @@ static void Task_ItemSwapHandleInput(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
if (gMain.newKeys & A_BUTTON)
PerformItemSwap(taskId);

View File

@ -939,7 +939,7 @@ void sub_812764C(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
SecretBasePC_SelectedDecorActions[data[11]][1](taskId);
break;

View File

@ -469,7 +469,7 @@ static void Task_EggHatch(u8 taskID)
{
CleanupOverworldWindowsAndTilemaps();
SetMainCallback2(CB2_EggHatch_0);
gFieldCallback = sub_80AF168;
gFieldCallback = FieldCallback_ReturnToEventScript2;
DestroyTask(taskID);
}
}

View File

@ -58,7 +58,7 @@ static void task0A_fade_n_map_maybe(u8);
static void sub_808115C(u8);
static void palette_bg_faded_fill_white(void);
static void sub_80AF438(u8);
static bool32 sub_80AF71C(void);
static bool32 WaitForWeatherFadeIn(void);
static void task0A_mpl_807E31C(u8 taskId);
static void sub_80AFA0C(u8 taskId);
static void sub_80AFA88(u8 taskId);
@ -133,7 +133,7 @@ static void sub_80AF0F4(u8 arg)
static void task0A_nop_for_a_while(u8 taskId)
{
if (sub_80AF71C() == TRUE)
if (WaitForWeatherFadeIn() == TRUE)
DestroyTask(taskId);
}
@ -147,14 +147,14 @@ void sub_80AF128(void)
static void task0A_asap_script_env_2_enable_and_set_ctx_running(u8 taskID)
{
if (sub_80AF71C() == TRUE)
if (WaitForWeatherFadeIn() == TRUE)
{
DestroyTask(taskID);
EnableBothScriptContexts();
}
}
void sub_80AF168(void)
void FieldCallback_ReturnToEventScript2(void)
{
ScriptContext2_Enable();
Overworld_PlaySpecialMapMusic();
@ -187,7 +187,7 @@ static void task_mpl_807DD60(u8 taskId)
}
break;
case 2:
if (sub_80AF71C() == TRUE)
if (WaitForWeatherFadeIn() == TRUE)
{
ScriptContext2_Disable();
DestroyTask(taskId);
@ -227,7 +227,7 @@ static void sub_80AF234(u8 taskId)
}
break;
case 2:
if (sub_80AF71C() == TRUE)
if (WaitForWeatherFadeIn() == TRUE)
{
sub_8009F18();
ScriptContext2_Disable();
@ -347,7 +347,7 @@ static void sub_80AF438(u8 taskId)
task->data[0] = 1;
break;
case 1:
if (sub_80AF71C())
if (WaitForWeatherFadeIn())
{
u8 eventObjId;
sub_80AF0F4(1);
@ -395,7 +395,7 @@ static void task_map_chg_seq_0807E20C(u8 taskId)
task->data[0] = 1;
break;
case 1:
if (sub_80AF71C())
if (WaitForWeatherFadeIn())
{
u8 eventObjId;
sub_80AF0F4(1);
@ -428,7 +428,7 @@ static void task_map_chg_seq_0807E2CC(u8 taskId)
gTasks[taskId].data[0]++;
break;
case 1:
if (sub_80AF71C())
if (WaitForWeatherFadeIn())
{
UnfreezeEventObjects();
ScriptContext2_Disable();
@ -440,7 +440,7 @@ static void task_map_chg_seq_0807E2CC(u8 taskId)
static void sub_80AF660(u8 taskId)
{
if (sub_80AF71C() == TRUE)
if (WaitForWeatherFadeIn() == TRUE)
{
DestroyTask(taskId);
CreateTask(sub_809FA34, 80);
@ -462,7 +462,7 @@ bool8 sub_80AF6A4(void)
static void task_mpl_807E3C8(u8 taskId)
{
if (sub_80AF71C() == 1)
if (WaitForWeatherFadeIn() == 1)
{
ScriptContext2_Disable();
DestroyTask(taskId);
@ -490,7 +490,7 @@ static bool32 PaletteFadeActive(void)
return gPaletteFade.active;
}
static bool32 sub_80AF71C(void)
static bool32 WaitForWeatherFadeIn(void)
{
if (IsWeatherNotFadingIn() == TRUE)
return TRUE;
@ -1021,7 +1021,7 @@ static void task0A_mpl_807E31C(u8 taskId)
gTasks[taskId].data[0]++;
break;
case 1:
if (sub_80AF71C() && sub_808D1B4() != TRUE)
if (WaitForWeatherFadeIn() && sub_808D1B4() != TRUE)
{
UnfreezeEventObjects();
ScriptContext2_Disable();

View File

@ -2610,7 +2610,7 @@ static void sub_813A4EC(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
gSpecialVar_Result = 0x7F;
PlaySE(SE_SELECT);
sub_813A570(taskId);
@ -2690,10 +2690,10 @@ static void sub_813A664(u8 taskId)
static void sub_813A694(u8 taskId)
{
static const struct ScrollArrowsTemplate gUnknown_085B3030 = {
.firstArrowType = 2,
.firstArrowType = SCROLL_ARROW_UP,
.firstX = 0,
.firstY = 0,
.secondArrowType = 3,
.secondArrowType = SCROLL_ARROW_DOWN,
.secondX = 0,
.secondY = 0,
.fullyUpThreshold = 0,

View File

@ -1108,7 +1108,7 @@ void Task_BagMenu(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
if (gUnknown_0203CE58.location == 5)
{
PlaySE(SE_HAZURE);
@ -1324,7 +1324,7 @@ void sub_81AC3C0(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
if (gMain.newKeys & A_BUTTON)
sub_81AC498(taskId);

View File

@ -1,833 +0,0 @@
#include "global.h"
#include "main.h"
#include "battle.h"
#include "bg.h"
#include "contest_effect.h"
#include "data2.h"
#include "event_data.h"
#include "field_screen_effect.h"
#include "gpu_regs.h"
#include "learn_move.h"
#include "list_menu.h"
#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "overworld.h"
#include "palette.h"
#include "pokemon_summary_screen.h"
#include "pokenav.h"
#include "script.h"
#include "sound.h"
#include "sprite.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "constants/rgb.h"
#include "constants/songs.h"
static EWRAM_DATA struct
{
u8 state;
u8 spriteIds[16]; /*0x001*/
u16 movesToLearn[4]; /*0x012*/
u8 filler1A[0x44 - 0x1A]; /*0x01A*/
u8 partyMon; /*0x044*/
u8 moveSlot; /*0x045*/
struct ListMenuItem menuItems[20]; /*0x048*/
u8 fillerE8[0x110 - 0xE8]; /*0x0E8*/
u8 numMenuChoices; /*0x110*/
u8 numToShowAtOnce; /*0x111*/
u8 listMenuTask; /*0x112*/
u8 scrollArrowTaskId1; /*0x113*/
u8 scrollArrowTaskId2; /*0x114*/
u16 scrollOffset; /*0x116*/
} *sLearnMoveStruct = {0};
static EWRAM_DATA struct {
u16 listOffset;
u16 listRow;
u8 showContestInfo;
} sLearnMoveStruct2 = {0};
const u16 gUnknown_085CE9F8[] = INCBIN_U16("graphics/interface/ui_learn_move.gbapal");
const u8 gUnknown_085CEA18[] = INCBIN_U8("graphics/interface/ui_learn_move.4bpp");
const struct OamData gUnknown_085CEB98 =
{
.y = 0,
.affineMode = 0,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = ST_OAM_SQUARE,
.x = 0,
.matrixNum = 0,
.size = 0,
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
const struct OamData gUnknown_085CEBA0 =
{
.y = 0,
.affineMode = 0,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = ST_OAM_V_RECTANGLE,
.x = 0,
.matrixNum = 0,
.size = 0,
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
const struct OamData gUnknown_085CEBA8 =
{
.y = 0,
.affineMode = 0,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = ST_OAM_H_RECTANGLE,
.x = 0,
.matrixNum = 0,
.size = 0,
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
const struct SpriteSheet gUnknown_085CEBB0 =
{
.data = gUnknown_085CEA18,
.size = 0x180,
.tag = 5525
};
const struct SpritePalette gUnknown_085CEBB8 =
{
.data = gUnknown_085CE9F8,
.tag = 5526
};
const struct ScrollArrowsTemplate gUnknown_085CEBC0 =
{
.firstArrowType = 0,
.firstX = 27,
.firstY = 16,
.secondArrowType = 1,
.secondX = 117,
.secondY = 16,
.fullyUpThreshold = -1,
.fullyDownThreshold = -1,
.tileTag = 5325,
.palTag = 5325,
.palNum = 0,
};
const struct ScrollArrowsTemplate gUnknown_085CEBD0 =
{
.firstArrowType = 2,
.firstX = 192,
.firstY = 8,
.secondArrowType = 3,
.secondX = 192,
.secondY = 104,
.fullyUpThreshold = 0,
.fullyDownThreshold = 0,
.tileTag = 5425,
.palTag = 5425,
.palNum = 0,
};
const union AnimCmd gUnknown_085CEBE0[] =
{
ANIMCMD_FRAME(8, 5, FALSE, FALSE),
ANIMCMD_END
};
const union AnimCmd gUnknown_085CEBE8[] =
{
ANIMCMD_FRAME(9, 5, FALSE, FALSE),
ANIMCMD_END
};
const union AnimCmd gUnknown_085CEBF0[] =
{
ANIMCMD_FRAME(10, 5, FALSE, FALSE),
ANIMCMD_END
};
const union AnimCmd gUnknown_085CEBF8[] =
{
ANIMCMD_FRAME(11, 5, FALSE, FALSE),
ANIMCMD_END
};
const union AnimCmd *const gUnknown_085CEC00[] =
{
gUnknown_085CEBE0,
gUnknown_085CEBE8,
gUnknown_085CEBF0,
gUnknown_085CEBF8,
};
const struct SpriteTemplate gUnknown_085CEC10 =
{
.tileTag = 5525,
.paletteTag = 5526,
.oam = &gUnknown_085CEB98,
.anims = gUnknown_085CEC00,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
const struct BgTemplate gUnknown_085CEC28[] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0,
},
{
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0,
},
};
static void LearnMoveMain(void);
static void CreateMenuItemsList(void);
static void CreateHearts(void);
static void CB2_Main(void);
static void Task_WaitForFadeOut(u8 taskId);
static void CB2_InitLearnMove(void);
static void CB2_InitLearnMoveReturnFromSelectMove(void);
static void InitBGs(void);
static void AddScrollArrows(void);
static void HandleInput(u8);
static void ShowTeachMoveText(u8);
static s32 GetCurrentItemId(void);
static void FreeListMenuResources(void);
static void RemoveScrollArrows(void);
static void HideSpritesAndPrintTeachText(bool8);
static void VBlankCB_LearnMove(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void TeachMoveTutorMove(void)
{
ScriptContext2_Enable();
CreateTask(Task_WaitForFadeOut, 0xA);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, 0);
}
static void Task_WaitForFadeOut(u8 taskId)
{
if (!gPaletteFade.active)
{
SetMainCallback2(CB2_InitLearnMove);
gFieldCallback = sub_80AF168;
DestroyTask(taskId);
}
}
static void CB2_InitLearnMove(void)
{
ResetSpriteData();
FreeAllSpritePalettes();
ResetTasks();
clear_scheduled_bg_copies_to_vram();
sLearnMoveStruct = AllocZeroed(sizeof(*sLearnMoveStruct));
sLearnMoveStruct->partyMon = gSpecialVar_0x8004;
SetVBlankCallback(VBlankCB_LearnMove);
InitBGs();
sub_81D2824(0);
sLearnMoveStruct2.listOffset = 0;
sLearnMoveStruct2.listRow = 0;
sLearnMoveStruct2.showContestInfo = FALSE;
CreateMenuItemsList();
LoadSpriteSheet(&gUnknown_085CEBB0);
LoadSpritePalette(&gUnknown_085CEBB8);
CreateHearts();
sLearnMoveStruct->listMenuTask = ListMenuInit(&gMultiuseListMenuTemplate, sLearnMoveStruct2.listOffset, sLearnMoveStruct2.listRow);
FillPalette(RGB_BLACK, 0, 2);
SetMainCallback2(CB2_Main);
}
static void CB2_InitLearnMoveReturnFromSelectMove(void)
{
ResetSpriteData();
FreeAllSpritePalettes();
ResetTasks();
clear_scheduled_bg_copies_to_vram();
sLearnMoveStruct = AllocZeroed(sizeof(*sLearnMoveStruct));
sLearnMoveStruct->state = 28;
sLearnMoveStruct->partyMon = gSpecialVar_0x8004;
sLearnMoveStruct->moveSlot = gSpecialVar_0x8005;
SetVBlankCallback(VBlankCB_LearnMove);
InitBGs();
sub_81D2824(sLearnMoveStruct2.showContestInfo);
CreateMenuItemsList();
LoadSpriteSheet(&gUnknown_085CEBB0);
LoadSpritePalette(&gUnknown_085CEBB8);
CreateHearts();
sLearnMoveStruct->listMenuTask = ListMenuInit(&gMultiuseListMenuTemplate, sLearnMoveStruct2.listOffset, sLearnMoveStruct2.listRow);
FillPalette(RGB_BLACK, 0, 2);
SetMainCallback2(CB2_Main);
}
static void InitBGs(void)
{
ResetVramOamAndBgCntRegs();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_085CEC28, 2);
ResetAllBgsCoordinates();
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 |
DISPCNT_OBJ_1D_MAP |
DISPCNT_OBJ_ON);
ShowBg(0);
ShowBg(1);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
}
static void CB2_Main(void)
{
LearnMoveMain();
RunTasks();
AnimateSprites();
BuildOamBuffer();
do_scheduled_bg_tilemap_copies_to_vram();
UpdatePaletteFade();
}
static void sub_816084C(const u8 *src)
{
StringExpandPlaceholders(gStringVar4, src);
sub_81D2BF4(gStringVar4);
}
static void LearnMoveMain(void)
{
switch (sLearnMoveStruct->state)
{
case 0:
sLearnMoveStruct->state++;
HideSpritesAndPrintTeachText(FALSE);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
break;
case 1:
if (!gPaletteFade.active)
{
sLearnMoveStruct->state = 4;
}
break;
case 2:
sLearnMoveStruct->state++;
break;
case 3:
HideSpritesAndPrintTeachText(FALSE);
sLearnMoveStruct->state++;
AddScrollArrows();
break;
case 4:
HandleInput(FALSE);
return;
case 5:
ShowTeachMoveText(FALSE);
sLearnMoveStruct->state++;
AddScrollArrows();
break;
case 6:
HandleInput(TRUE);
break;
case 8:
if (!sub_81D2C3C())
{
sub_81D2C50();
sLearnMoveStruct->state++;
}
break;
case 9:
{
s8 selection = Menu_ProcessInputNoWrapClearOnChoose();
if (selection == 0)
{
if (GiveMoveToMon(&gPlayerParty[sLearnMoveStruct->partyMon], GetCurrentItemId()) != 0xFFFF)
{
sub_816084C(gText_PkmnLearnedMove4);
gSpecialVar_0x8004 = 1;
sLearnMoveStruct->state = 31;
}
else
{
sLearnMoveStruct->state = 16;
}
}
else if (selection == -1 || selection == 1)
{
if (sLearnMoveStruct2.showContestInfo == FALSE)
{
sLearnMoveStruct->state = 3;
}
else if (sLearnMoveStruct2.showContestInfo == TRUE)
{
sLearnMoveStruct->state = 5;
}
}
}
break;
case 12:
if (!sub_81D2C3C())
{
sub_81D2C50();
sLearnMoveStruct->state++;
}
break;
case 13:
{
s8 selection = Menu_ProcessInputNoWrapClearOnChoose();
if (selection == 0)
{
gSpecialVar_0x8004 = selection;
sLearnMoveStruct->state = 14;
}
else if (selection == -1 || selection == 1)
{
if (sLearnMoveStruct2.showContestInfo == FALSE)
{
sLearnMoveStruct->state = 3;
}
else if (sLearnMoveStruct2.showContestInfo == TRUE)
{
sLearnMoveStruct->state = 5;
}
}
}
break;
case 16:
sub_816084C(gText_PkmnTryingToLearnMove);
sLearnMoveStruct->state++;
break;
case 17:
if (!sub_81D2C3C())
{
sub_81D2C50();
sLearnMoveStruct->state = 18;
}
break;
case 18:
{
s8 var = Menu_ProcessInputNoWrapClearOnChoose();
if (var == 0)
{
sub_816084C(gText_WhichMoveToForget2);
sLearnMoveStruct->state = 19;
}
else if (var == -1 || var == 1)
{
sLearnMoveStruct->state = 24;
}
}
break;
case 24:
StringCopy(gStringVar2, gMoveNames[GetCurrentItemId()]);
sub_816084C(gText_StopTryingToTeachMove);
sLearnMoveStruct->state++;
break;
case 25:
if (!sub_81D2C3C())
{
sub_81D2C50();
sLearnMoveStruct->state++;
}
break;
case 26:
{
s8 var = Menu_ProcessInputNoWrapClearOnChoose();
if (var == 0)
{
sLearnMoveStruct->state = 27;
}
else if (var == -1 || var == 1)
{
// What's the point? It gets set to 16, anyway.
if (sLearnMoveStruct2.showContestInfo == FALSE)
{
sLearnMoveStruct->state = 3;
}
else if (sLearnMoveStruct2.showContestInfo == TRUE)
{
sLearnMoveStruct->state = 5;
}
sLearnMoveStruct->state = 16;
}
}
break;
case 27:
if (!sub_81D2C3C())
{
FillWindowPixelBuffer(3, 0x11);
if (sLearnMoveStruct2.showContestInfo == FALSE)
{
sLearnMoveStruct->state = 3;
}
else if (sLearnMoveStruct2.showContestInfo == TRUE)
{
sLearnMoveStruct->state = 5;
}
}
break;
case 19:
if (!sub_81D2C3C())
{
sLearnMoveStruct->state = 20;
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
}
break;
case 20:
if (!gPaletteFade.active)
{
ShowSelectMovePokemonSummaryScreen(gPlayerParty, sLearnMoveStruct->partyMon, gPlayerPartyCount - 1, CB2_InitLearnMoveReturnFromSelectMove, GetCurrentItemId());
FreeListMenuResources();
}
break;
case 21:
if (!sub_81D2C3C())
{
sLearnMoveStruct->state = 14;
}
break;
case 22:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
break;
case 14:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
sLearnMoveStruct->state++;
break;
case 15:
if (!gPaletteFade.active)
{
FreeListMenuResources();
SetMainCallback2(CB2_ReturnToField);
}
break;
case 28:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
sLearnMoveStruct->state++;
if (sLearnMoveStruct2.showContestInfo == FALSE)
{
HideSpritesAndPrintTeachText(TRUE);
}
else if (sLearnMoveStruct2.showContestInfo == TRUE)
{
ShowTeachMoveText(TRUE);
}
RemoveScrollArrows();
CopyWindowToVram(3, 2);
break;
case 29:
if (!gPaletteFade.active)
{
if (sLearnMoveStruct->moveSlot == MAX_MON_MOVES)
{
sLearnMoveStruct->state = 24;
}
else
{
u16 moveId = GetMonData(&gPlayerParty[sLearnMoveStruct->partyMon], MON_DATA_MOVE1 + sLearnMoveStruct->moveSlot);
StringCopy(gStringVar3, gMoveNames[moveId]);
RemoveMonPPBonus(&gPlayerParty[sLearnMoveStruct->partyMon], sLearnMoveStruct->moveSlot);
SetMonMoveSlot(&gPlayerParty[sLearnMoveStruct->partyMon], GetCurrentItemId(), sLearnMoveStruct->moveSlot);
StringCopy(gStringVar2, gMoveNames[GetCurrentItemId()]);
sub_816084C(gText_12AndPoof);
sLearnMoveStruct->state = 30;
gSpecialVar_0x8004 = 1;
}
}
break;
case 30:
if (!sub_81D2C3C())
{
sub_816084C(gText_PkmnForgotMoveAndLearnedNew);
sLearnMoveStruct->state = 31;
PlayFanfare(MUS_FANFA1);
}
break;
case 31:
if (!sub_81D2C3C())
{
PlayFanfare(MUS_FANFA1);
sLearnMoveStruct->state = 32;
}
break;
case 32:
if (IsFanfareTaskInactive())
{
sLearnMoveStruct->state = 33;
}
break;
case 33:
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
sLearnMoveStruct->state = 14;
}
break;
}
}
static void FreeListMenuResources(void)
{
RemoveScrollArrows();
DestroyListMenuTask(sLearnMoveStruct->listMenuTask, &sLearnMoveStruct2.listOffset, &sLearnMoveStruct2.listRow);
FreeAllWindowBuffers();
FREE_AND_SET_NULL(sLearnMoveStruct);
ResetSpriteData();
FreeAllSpritePalettes();
}
static void HideSpritesAndPrintTeachText(bool8 a)
{
s32 i;
for (i = 0; i < 16; i++)
{
gSprites[sLearnMoveStruct->spriteIds[i]].invisible = TRUE;
}
if (!a)
{
StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn);
FillWindowPixelBuffer(3, 0x11);
AddTextPrinterParameterized(3, 1, gStringVar4, 0, 1, 0, NULL);
}
}
static void HandleInput(bool8 showContest)
{
s32 itemId = ListMenu_ProcessInput(sLearnMoveStruct->listMenuTask);
ListMenuGetScrollAndRow(sLearnMoveStruct->listMenuTask, &sLearnMoveStruct2.listOffset, &sLearnMoveStruct2.listRow);
switch (itemId)
{
case LIST_NOTHING_CHOSEN:
if (!(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysState())
{
break;
}
PlaySE(SE_SELECT);
if (showContest == FALSE)
{
PutWindowTilemap(1);
sLearnMoveStruct->state = 5;
sLearnMoveStruct2.showContestInfo = TRUE;
}
else
{
PutWindowTilemap(0);
sLearnMoveStruct->state = 3;
sLearnMoveStruct2.showContestInfo = FALSE;
}
schedule_bg_copy_tilemap_to_vram(1);
ShowHideHearts(GetCurrentItemId());
break;
case LIST_B_PRESSED:
PlaySE(SE_SELECT);
RemoveScrollArrows();
sLearnMoveStruct->state = 12;
StringExpandPlaceholders(gStringVar4, gText_GiveUpTeachingNewMove);
sub_81D2BF4(gStringVar4);
break;
default:
PlaySE(SE_SELECT);
RemoveScrollArrows();
sLearnMoveStruct->state = 8;
StringCopy(gStringVar2, gMoveNames[itemId]);
StringExpandPlaceholders(gStringVar4, gText_TeachX);
sub_81D2BF4(gStringVar4);
break;
}
}
static s32 GetCurrentItemId(void)
{
return sLearnMoveStruct->menuItems[sLearnMoveStruct2.listRow + sLearnMoveStruct2.listOffset].id;
}
static void ShowTeachMoveText(bool8 showContest)
{
if (showContest == FALSE)
{
StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn);
FillWindowPixelBuffer(3, 0x11);
AddTextPrinterParameterized(3, 1, gStringVar4, 0, 1, 0, NULL);
}
}
static void CreateHearts(void)
{
int i;
sLearnMoveStruct->scrollArrowTaskId2 = -1;
sLearnMoveStruct->scrollArrowTaskId1 = -1;
AddScrollArrows();
for (i = 0; i < 8; i++)
{
sLearnMoveStruct->spriteIds[i] = CreateSprite(&gUnknown_085CEC10, (i - (i / 4) * 4) * 8 + 104, (i / 4) * 8 + 36, 0);
}
for (i = 0; i < 8; i++)
{
sLearnMoveStruct->spriteIds[i + 8] = CreateSprite(&gUnknown_085CEC10, (i - (i / 4) * 4) * 8 + 104, (i / 4) * 8 + 52, 0);
StartSpriteAnim(&gSprites[sLearnMoveStruct->spriteIds[i + 8]], 2);
}
for (i = 0; i < 16; i++)
{
gSprites[sLearnMoveStruct->spriteIds[i]].invisible = TRUE;
}
}
static void AddScrollArrows(void)
{
if (sLearnMoveStruct->scrollArrowTaskId2 == 0xFF)
{
sLearnMoveStruct->scrollArrowTaskId2 = AddScrollIndicatorArrowPair(&gUnknown_085CEBC0, &sLearnMoveStruct->scrollOffset);
}
if (sLearnMoveStruct->scrollArrowTaskId1 == 0xFF)
{
gTempScrollArrowTemplate = gUnknown_085CEBD0;
gTempScrollArrowTemplate.fullyDownThreshold = sLearnMoveStruct->numMenuChoices - sLearnMoveStruct->numToShowAtOnce;
sLearnMoveStruct->scrollArrowTaskId1 = AddScrollIndicatorArrowPair(&gTempScrollArrowTemplate, &sLearnMoveStruct2.listOffset);
}
}
static void RemoveScrollArrows(void)
{
if (sLearnMoveStruct->scrollArrowTaskId2 != 0xFF)
{
RemoveScrollIndicatorArrowPair(sLearnMoveStruct->scrollArrowTaskId2);
sLearnMoveStruct->scrollArrowTaskId2 = 0xFF;
}
if (sLearnMoveStruct->scrollArrowTaskId1 != 0xFF)
{
RemoveScrollIndicatorArrowPair(sLearnMoveStruct->scrollArrowTaskId1);
sLearnMoveStruct->scrollArrowTaskId1 = 0xFF;
}
}
static void CreateMenuItemsList(void)
{
s32 i;
u8 nickname[POKEMON_NAME_LENGTH + 1];
sLearnMoveStruct->numMenuChoices = GetMoveRelearnerMoves(&gPlayerParty[sLearnMoveStruct->partyMon], sLearnMoveStruct->movesToLearn);
for (i = 0; i < sLearnMoveStruct->numMenuChoices; i++)
{
sLearnMoveStruct->menuItems[i].name = gMoveNames[sLearnMoveStruct->movesToLearn[i]];
sLearnMoveStruct->menuItems[i].id = sLearnMoveStruct->movesToLearn[i];
}
GetMonData(&gPlayerParty[sLearnMoveStruct->partyMon], MON_DATA_NICKNAME, nickname);
StringCopy10(gStringVar1, nickname);
sLearnMoveStruct->menuItems[sLearnMoveStruct->numMenuChoices].name = gText_Cancel;
sLearnMoveStruct->menuItems[sLearnMoveStruct->numMenuChoices].id = LIST_B_PRESSED;
sLearnMoveStruct->numMenuChoices++;
sLearnMoveStruct->numToShowAtOnce = sub_81D28C8(sLearnMoveStruct->menuItems, sLearnMoveStruct->numMenuChoices);
}
void ShowHideHearts(s32 item)
{
u16 numHearts;
u16 i;
if (!sLearnMoveStruct2.showContestInfo || item == LIST_B_PRESSED)
{
for (i = 0; i < 16; i++)
{
gSprites[sLearnMoveStruct->spriteIds[i]].invisible = TRUE;
}
}
else
{
numHearts = (u8)(gContestEffects[gContestMoves[item].effect].appeal / 10);
if (numHearts == 0xFF)
{
numHearts = 0;
}
for (i = 0; i < 8; i++)
{
if (i < numHearts)
{
StartSpriteAnim(&gSprites[sLearnMoveStruct->spriteIds[i]], 1);
}
else
{
StartSpriteAnim(&gSprites[sLearnMoveStruct->spriteIds[i]], 0);
}
gSprites[sLearnMoveStruct->spriteIds[i]].invisible = FALSE;
}
numHearts = (u8)(gContestEffects[gContestMoves[item].effect].jam / 10);
if (numHearts == 0xFF)
{
numHearts = 0;
}
for (i = 0; i < 8; i++)
{
if (i < numHearts)
{
StartSpriteAnim(&gSprites[sLearnMoveStruct->spriteIds[i + 8]], 3);
}
else
{
StartSpriteAnim(&gSprites[sLearnMoveStruct->spriteIds[i + 8]], 2);
}
gSprites[sLearnMoveStruct->spriteIds[i + 8]].invisible = FALSE;
}
}
}

View File

@ -341,7 +341,7 @@ s32 DoMysteryGiftListMenu(struct WindowTemplate *windowTemplate, struct ListMenu
}
if (gMain.newKeys & B_BUTTON)
{
sMysteryGiftLinkMenu.currItemId = LIST_B_PRESSED;
sMysteryGiftLinkMenu.currItemId = LIST_CANCEL;
sMysteryGiftLinkMenu.state = 2;
}
if (sMysteryGiftLinkMenu.state == 2)
@ -416,7 +416,7 @@ s32 ListMenu_ProcessInput(u8 listTaskId)
}
else if (gMain.newKeys & B_BUTTON)
{
return LIST_B_PRESSED;
return LIST_CANCEL;
}
else if (gMain.newAndRepeatedKeys & DPAD_UP)
{

976
src/move_tutor.c Normal file
View File

@ -0,0 +1,976 @@
#include "global.h"
#include "main.h"
#include "battle.h"
#include "bg.h"
#include "contest_effect.h"
#include "data2.h"
#include "event_data.h"
#include "field_screen_effect.h"
#include "gpu_regs.h"
#include "move_tutor.h"
#include "list_menu.h"
#include "alloc.h"
#include "menu.h"
#include "menu_helpers.h"
#include "overworld.h"
#include "palette.h"
#include "pokemon_summary_screen.h"
#include "pokenav.h"
#include "script.h"
#include "sound.h"
#include "sprite.h"
#include "string_util.h"
#include "strings.h"
#include "task.h"
#include "constants/rgb.h"
#include "constants/songs.h"
/*
* Move tutor state machine
* ------------------------
*
* Entry point: TeachMoveTutorMove
*
* TeachMoveTutorMove
* Task_WaitForFadeOut
* CB2_InitLearnMove
* - Creates moveDisplayArrowTask to listen to right/left buttons.
* - Creates moveListScrollArrowTask to listen to up/down buttons.
* - Whenever the selected move changes (and once on init), the MoveTutorCursorCallback
* is called (see gMoveTutorMovesListTemplate). That callback will reload the contest
* display and battle display windows for the new move. Both are always loaded in
* memory, but only the currently active one is copied to VRAM. The exception to this
* is the appeal and jam hearts, which are sprites. MoveTutorShowHideHearts is called
* while reloading the contest display to control them.
* DoMoveTutorMain: MENU_STATE_FADE_TO_BLACK
* DoMoveTutorMain: MENU_STATE_WAIT_FOR_FADE
* - Go to MENU_STATE_IDLE_BATTLE_MODE
*
* DoMoveTutorMain: MENU_STATE_SETUP_BATTLE_MODE
* DoMoveTutorMain: MENU_STATE_IDLE_BATTLE_MODE
* - If the player selected a move (pressed A), go to MENU_STATE_PRINT_TEACH_MOVE_PROMPT.
* - If the player cancelled (pressed B), go to MENU_STATE_PRINT_GIVE_UP_PROMPT.
* - If the player pressed left or right, swap the move display window to contest mode,
* and go to MENU_STATE_SETUP_CONTEST_MODE.
*
* DoMoveTutorMain: MENU_STATE_SETUP_CONTEST_MODE
* DoMoveTutorMain: MENU_STATE_IDLE_CONTEST_MODE
* - If the player selected a move, go to MENU_STATE_PRINT_TEACH_MOVE_PROMPT.
* - If the player cancelled, go to MENU_STATE_PRINT_GIVE_UP_PROMPT
* - If the player pressed left or right, swap the move display window to battle mode,
* and go to MENU_STATE_SETUP_BATTLE_MODE.
*
* DoMoveTutorMain: MENU_STATE_PRINT_TEACH_MOVE_PROMPT
* DoMoveTutorMain: MENU_STATE_TEACH_MOVE_CONFIRM
* - Wait for the player to confirm.
* - If cancelled, go to either MENU_STATE_SETUP_BATTLE_MODE or MENU_STATE_SETUP_CONTEST_MODE.
* - If confirmed and the pokemon had an empty move slot, set VAR_0x8004 to TRUE and go to
* MENU_STATE_PRINT_TEXT_THEN_FANFARE.
* - If confirmed and the pokemon doesn't have an empty move slot, go to
* MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT.
*
* DoMoveTutorMain: MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT
* DoMoveTutorMain: MENU_STATE_WAIT_FOR_TRYING_TO_LEARN
* DoMoveTutorMain: MENU_STATE_CONFIRM_DELETE_OLD_MOVE
* - If the player confirms, go to MENU_STATE_PRINT_WHICH_MOVE_PROMPT.
* - If the player cancels, go to MENU_STATE_PRINT_STOP_TEACHING
*
* DoMoveTutorMain: MENU_STATE_PRINT_STOP_TEACHING
* DoMoveTutorMain: MENU_STATE_WAIT_FOR_STOP_TEACHING
* DoMoveTutorMain: MENU_STATE_CONFIRM_STOP_TEACHING
* - If the player confirms, go to MENU_STATE_CHOOSE_SETUP_STATE.
* - If the player cancels, go back to MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT.
*
* DoMoveTutorMain: MENU_STATE_PRINT_WHICH_MOVE_PROMPT
* DoMoveTutorMain: MENU_STATE_SHOW_MOVE_SUMMARY_SCREEN
* - Go to ShowSelectMovePokemonSummaryScreen. When done, control returns to
* CB2_InitLearnMoveReturnFromSelectMove.
*
* DoMoveTutorMain: MENU_STATE_DOUBLE_FANFARE_FORGOT_MOVE
* DoMoveTutorMain: MENU_STATE_PRINT_TEXT_THEN_FANFARE
* DoMoveTutorMain: MENU_STATE_WAIT_FOR_FANFARE
* DoMoveTutorMain: MENU_STATE_WAIT_FOR_A_BUTTON
* DoMoveTutorMain: MENU_STATE_FADE_AND_RETURN
* DoMoveTutorMain: MENU_STATE_RETURN_TO_FIELD
* - Clean up and go to CB2_ReturnToField.
*
* DoMoveTutorMain: MENU_STATE_PRINT_GIVE_UP_PROMPT
* DoMoveTutorMain: MENU_STATE_GIVE_UP_CONFIRM
* - If the player confirms, go to MENU_STATE_FADE_AND_RETURN, and set VAR_0x8004 to FALSE.
* - If the player cancels, go to either MENU_STATE_SETUP_BATTLE_MODE or
* MENU_STATE_SETUP_CONTEST_MODE.
*
* CB2_InitLearnMoveReturnFromSelectMove:
* - Do most of the same stuff as CB2_InitLearnMove.
* DoMoveTutorMain: MENU_STATE_FADE_FROM_SUMMARY_SCREEN
* DoMoveTutorMain: MENU_STATE_TRY_OVERWRITE_MOVE
* - If any of the pokemon's existing moves were chosen, overwrite the move and
* go to MENU_STATE_DOUBLE_FANFARE_FORGOT_MOVE and set VAR_0x8004 to TRUE.
* - If the chosen move is the one the player selected before the summary screen,
* go to MENU_STATE_PRINT_STOP_TEACHING.
*
*/
#define MENU_STATE_FADE_TO_BLACK 0
#define MENU_STATE_WAIT_FOR_FADE 1
#define MENU_STATE_UNREACHABLE 2
#define MENU_STATE_SETUP_BATTLE_MODE 3
#define MENU_STATE_IDLE_BATTLE_MODE 4
#define MENU_STATE_SETUP_CONTEST_MODE 5
#define MENU_STATE_IDLE_CONTEST_MODE 6
// State 7 is skipped.
#define MENU_STATE_PRINT_TEACH_MOVE_PROMPT 8
#define MENU_STATE_TEACH_MOVE_CONFIRM 9
// States 10 and 11 are skipped.
#define MENU_STATE_PRINT_GIVE_UP_PROMPT 12
#define MENU_STATE_GIVE_UP_CONFIRM 13
#define MENU_STATE_FADE_AND_RETURN 14
#define MENU_STATE_RETURN_TO_FIELD 15
#define MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT 16
#define MENU_STATE_WAIT_FOR_TRYING_TO_LEARN 17
#define MENU_STATE_CONFIRM_DELETE_OLD_MOVE 18
#define MENU_STATE_PRINT_WHICH_MOVE_PROMPT 19
#define MENU_STATE_SHOW_MOVE_SUMMARY_SCREEN 20
// States 21, 22, and 23 are skipped.
#define MENU_STATE_PRINT_STOP_TEACHING 24
#define MENU_STATE_WAIT_FOR_STOP_TEACHING 25
#define MENU_STATE_CONFIRM_STOP_TEACHING 26
#define MENU_STATE_CHOOSE_SETUP_STATE 27
#define MENU_STATE_FADE_FROM_SUMMARY_SCREEN 28
#define MENU_STATE_TRY_OVERWRITE_MOVE 29
#define MENU_STATE_DOUBLE_FANFARE_FORGOT_MOVE 30
#define MENU_STATE_PRINT_TEXT_THEN_FANFARE 31
#define MENU_STATE_WAIT_FOR_FANFARE 32
#define MENU_STATE_WAIT_FOR_A_BUTTON 33
// The different versions of hearts are selected using animation
// commands.
#define APPEAL_HEART_EMPTY 0
#define APPEAL_HEART_FULL 1
#define JAM_HEART_EMPTY 2
#define JAM_HEART_FULL 3
static EWRAM_DATA struct
{
u8 state;
u8 heartSpriteIds[16]; /*0x001*/
u16 movesToLearn[4]; /*0x012*/
u8 filler1A[0x44 - 0x1A]; /*0x01A*/
u8 partyMon; /*0x044*/
u8 moveSlot; /*0x045*/
struct ListMenuItem menuItems[20]; /*0x048*/
u8 fillerE8[0x110 - 0xE8]; /*0x0E8*/
u8 numMenuChoices; /*0x110*/
u8 numToShowAtOnce; /*0x111*/
u8 moveListMenuTask; /*0x112*/
u8 moveListScrollArrowTask; /*0x113*/
u8 moveDisplayArrowTask; /*0x114*/
u16 scrollOffset; /*0x116*/
} *sMoveTutorStruct = {0};
static EWRAM_DATA struct {
u16 listOffset;
u16 listRow;
bool8 showContestInfo;
} sMoveTutorMenuSate = {0};
static const u16 sMoveTutorPaletteData[] = INCBIN_U16("graphics/interface/ui_learn_move.gbapal");
// The arrow sprites in this spritesheet aren't used. The scroll-arrow system provides its own
// arrow sprites.
static const u8 sMoveTutorSpriteSheetData[] = INCBIN_U8("graphics/interface/ui_learn_move.4bpp");
static const struct OamData sHeartSpriteOamData =
{
.y = 0,
.affineMode = 0,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = ST_OAM_SQUARE,
.x = 0,
.matrixNum = 0,
.size = 0,
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sUnusedOam1 =
{
.y = 0,
.affineMode = 0,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = ST_OAM_V_RECTANGLE,
.x = 0,
.matrixNum = 0,
.size = 0,
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
static const struct OamData sUnusedOam2 =
{
.y = 0,
.affineMode = 0,
.objMode = ST_OAM_OBJ_NORMAL,
.mosaic = 0,
.bpp = ST_OAM_4BPP,
.shape = ST_OAM_H_RECTANGLE,
.x = 0,
.matrixNum = 0,
.size = 0,
.tileNum = 0,
.priority = 0,
.paletteNum = 0,
.affineParam = 0,
};
static const struct SpriteSheet sMoveTutorSpriteSheet =
{
.data = sMoveTutorSpriteSheetData,
.size = 0x180,
.tag = 5525
};
static const struct SpritePalette sMoveTutorPalette =
{
.data = sMoveTutorPaletteData,
.tag = 5526
};
static const struct ScrollArrowsTemplate sDisplayModeArrowsTemplate =
{
.firstArrowType = SCROLL_ARROW_LEFT,
.firstX = 27,
.firstY = 16,
.secondArrowType = SCROLL_ARROW_RIGHT,
.secondX = 117,
.secondY = 16,
.fullyUpThreshold = -1,
.fullyDownThreshold = -1,
.tileTag = 5325,
.palTag = 5325,
.palNum = 0,
};
static const struct ScrollArrowsTemplate sMoveListScrollArrowsTemplate =
{
.firstArrowType = SCROLL_ARROW_UP,
.firstX = 192,
.firstY = 8,
.secondArrowType = SCROLL_ARROW_DOWN,
.secondX = 192,
.secondY = 104,
.fullyUpThreshold = 0,
.fullyDownThreshold = 0,
.tileTag = 5425,
.palTag = 5425,
.palNum = 0,
};
static const union AnimCmd sHeartSprite_AppealEmptyFrame[] =
{
ANIMCMD_FRAME(8, 5, FALSE, FALSE),
ANIMCMD_END
};
static const union AnimCmd sHeartSprite_AppealFullFrame[] =
{
ANIMCMD_FRAME(9, 5, FALSE, FALSE),
ANIMCMD_END
};
static const union AnimCmd sHeartSprite_JamEmptyFrame[] =
{
ANIMCMD_FRAME(10, 5, FALSE, FALSE),
ANIMCMD_END
};
static const union AnimCmd sHeartSprite_JamFullFrame[] =
{
ANIMCMD_FRAME(11, 5, FALSE, FALSE),
ANIMCMD_END
};
static const union AnimCmd *const sHeartSpriteAnimationCommands[] =
{
[APPEAL_HEART_EMPTY] = sHeartSprite_AppealEmptyFrame,
[APPEAL_HEART_FULL] = sHeartSprite_AppealFullFrame,
[JAM_HEART_EMPTY] = sHeartSprite_JamEmptyFrame,
[JAM_HEART_FULL] = sHeartSprite_JamFullFrame,
};
static const struct SpriteTemplate sConstestMoveHeartSprite =
{
.tileTag = 5525,
.paletteTag = 5526,
.oam = &sHeartSpriteOamData,
.anims = sHeartSpriteAnimationCommands,
.images = NULL,
.affineAnims = gDummySpriteAffineAnimTable,
.callback = SpriteCallbackDummy
};
static const struct BgTemplate sMoveTutorMenuBackgroundTemplates[] =
{
{
.bg = 0,
.charBaseIndex = 0,
.mapBaseIndex = 31,
.screenSize = 0,
.paletteMode = 0,
.priority = 0,
.baseTile = 0,
},
{
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 30,
.screenSize = 0,
.paletteMode = 0,
.priority = 1,
.baseTile = 0,
},
};
static void DoMoveTutorMain(void);
static void CreateLearnableMovesList(void);
static void CreateUISprites(void);
static void CB2_MoveTutorMain(void);
static void Task_WaitForFadeOut(u8 taskId);
static void CB2_InitLearnMove(void);
static void CB2_InitLearnMoveReturnFromSelectMove(void);
static void InitMoveTutorBackgroundLayers(void);
static void AddScrollArrows(void);
static void HandleInput(u8);
static void ShowTeachMoveText(u8);
static s32 GetCurrentSelectedMove(void);
static void FreeMoveTutorResources(void);
static void RemoveScrollArrows(void);
static void HideHeartSpritesAndShowTeachMoveText(bool8);
static void VBlankCB_MoveTutor(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
// Script arguments: The pokemon to teach is in VAR_0x8004
void TeachMoveTutorMove(void)
{
ScriptContext2_Enable();
CreateTask(Task_WaitForFadeOut, 10);
// Fade to black
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 0x10, RGB_BLACK);
}
static void Task_WaitForFadeOut(u8 taskId)
{
if (!gPaletteFade.active)
{
SetMainCallback2(CB2_InitLearnMove);
gFieldCallback = FieldCallback_ReturnToEventScript2;
DestroyTask(taskId);
}
}
static void CB2_InitLearnMove(void)
{
ResetSpriteData();
FreeAllSpritePalettes();
ResetTasks();
clear_scheduled_bg_copies_to_vram();
sMoveTutorStruct = AllocZeroed(sizeof(*sMoveTutorStruct));
sMoveTutorStruct->partyMon = gSpecialVar_0x8004;
SetVBlankCallback(VBlankCB_MoveTutor);
InitMoveTutorBackgroundLayers();
InitMoveTutorWindows(FALSE);
sMoveTutorMenuSate.listOffset = 0;
sMoveTutorMenuSate.listRow = 0;
sMoveTutorMenuSate.showContestInfo = FALSE;
CreateLearnableMovesList();
LoadSpriteSheet(&sMoveTutorSpriteSheet);
LoadSpritePalette(&sMoveTutorPalette);
CreateUISprites();
sMoveTutorStruct->moveListMenuTask = ListMenuInit(&gMultiuseListMenuTemplate, sMoveTutorMenuSate.listOffset, sMoveTutorMenuSate.listRow);
FillPalette(RGB_BLACK, 0, 2);
SetMainCallback2(CB2_MoveTutorMain);
}
static void CB2_InitLearnMoveReturnFromSelectMove(void)
{
ResetSpriteData();
FreeAllSpritePalettes();
ResetTasks();
clear_scheduled_bg_copies_to_vram();
sMoveTutorStruct = AllocZeroed(sizeof(*sMoveTutorStruct));
sMoveTutorStruct->state = MENU_STATE_FADE_FROM_SUMMARY_SCREEN;
sMoveTutorStruct->partyMon = gSpecialVar_0x8004;
sMoveTutorStruct->moveSlot = gSpecialVar_0x8005;
SetVBlankCallback(VBlankCB_MoveTutor);
InitMoveTutorBackgroundLayers();
InitMoveTutorWindows(sMoveTutorMenuSate.showContestInfo);
CreateLearnableMovesList();
LoadSpriteSheet(&sMoveTutorSpriteSheet);
LoadSpritePalette(&sMoveTutorPalette);
CreateUISprites();
sMoveTutorStruct->moveListMenuTask = ListMenuInit(&gMultiuseListMenuTemplate, sMoveTutorMenuSate.listOffset, sMoveTutorMenuSate.listRow);
FillPalette(RGB_BLACK, 0, 2);
SetMainCallback2(CB2_MoveTutorMain);
}
static void InitMoveTutorBackgroundLayers(void)
{
ResetVramOamAndBgCntRegs();
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, sMoveTutorMenuBackgroundTemplates, ARRAY_COUNT(sMoveTutorMenuBackgroundTemplates));
ResetAllBgsCoordinates();
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_MODE_0 |
DISPCNT_OBJ_1D_MAP |
DISPCNT_OBJ_ON);
ShowBg(0);
ShowBg(1);
SetGpuReg(REG_OFFSET_BLDCNT, 0);
}
static void CB2_MoveTutorMain(void)
{
DoMoveTutorMain();
RunTasks();
AnimateSprites();
BuildOamBuffer();
do_scheduled_bg_tilemap_copies_to_vram();
UpdatePaletteFade();
}
static void FormatAndPrintText(const u8 *src)
{
StringExpandPlaceholders(gStringVar4, src);
MoveTutorPrintText(gStringVar4);
}
// See the state machine doc at the top of the file.
static void DoMoveTutorMain(void)
{
switch (sMoveTutorStruct->state)
{
case MENU_STATE_FADE_TO_BLACK:
sMoveTutorStruct->state++;
HideHeartSpritesAndShowTeachMoveText(FALSE);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
break;
case MENU_STATE_WAIT_FOR_FADE:
if (!gPaletteFade.active)
{
sMoveTutorStruct->state = MENU_STATE_IDLE_BATTLE_MODE;
}
break;
case MENU_STATE_UNREACHABLE:
sMoveTutorStruct->state++;
break;
case MENU_STATE_SETUP_BATTLE_MODE:
HideHeartSpritesAndShowTeachMoveText(FALSE);
sMoveTutorStruct->state++;
AddScrollArrows();
break;
case MENU_STATE_IDLE_BATTLE_MODE:
HandleInput(FALSE);
break;
case MENU_STATE_SETUP_CONTEST_MODE:
ShowTeachMoveText(FALSE);
sMoveTutorStruct->state++;
AddScrollArrows();
break;
case MENU_STATE_IDLE_CONTEST_MODE:
HandleInput(TRUE);
break;
case MENU_STATE_PRINT_TEACH_MOVE_PROMPT:
if (!MoveTutorRunTextPrinters())
{
MoveTutorCreateYesNoMenu();
sMoveTutorStruct->state++;
}
break;
case MENU_STATE_TEACH_MOVE_CONFIRM:
{
s8 selection = Menu_ProcessInputNoWrapClearOnChoose();
if (selection == 0)
{
if (GiveMoveToMon(&gPlayerParty[sMoveTutorStruct->partyMon], GetCurrentSelectedMove()) != 0xFFFF)
{
FormatAndPrintText(gText_MoveTutorPkmnLearnedMove);
gSpecialVar_0x8004 = TRUE;
sMoveTutorStruct->state = MENU_STATE_PRINT_TEXT_THEN_FANFARE;
}
else
{
sMoveTutorStruct->state = MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT;
}
}
else if (selection == MENU_B_PRESSED || selection == 1)
{
if (sMoveTutorMenuSate.showContestInfo == FALSE)
{
sMoveTutorStruct->state = MENU_STATE_SETUP_BATTLE_MODE;
}
else if (sMoveTutorMenuSate.showContestInfo == TRUE)
{
sMoveTutorStruct->state = MENU_STATE_SETUP_CONTEST_MODE;
}
}
}
break;
case MENU_STATE_PRINT_GIVE_UP_PROMPT:
if (!MoveTutorRunTextPrinters())
{
MoveTutorCreateYesNoMenu();
sMoveTutorStruct->state++;
}
break;
case MENU_STATE_GIVE_UP_CONFIRM:
{
s8 selection = Menu_ProcessInputNoWrapClearOnChoose();
if (selection == 0)
{
gSpecialVar_0x8004 = FALSE;
sMoveTutorStruct->state = MENU_STATE_FADE_AND_RETURN;
}
else if (selection == -1 || selection == 1)
{
if (sMoveTutorMenuSate.showContestInfo == FALSE)
{
sMoveTutorStruct->state = MENU_STATE_SETUP_BATTLE_MODE;
}
else if (sMoveTutorMenuSate.showContestInfo == TRUE)
{
sMoveTutorStruct->state = MENU_STATE_SETUP_CONTEST_MODE;
}
}
}
break;
case MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT:
FormatAndPrintText(gText_MoveTutorPkmnTryingToLearnMove);
sMoveTutorStruct->state++;
break;
case MENU_STATE_WAIT_FOR_TRYING_TO_LEARN:
if (!MoveTutorRunTextPrinters())
{
MoveTutorCreateYesNoMenu();
sMoveTutorStruct->state = MENU_STATE_CONFIRM_DELETE_OLD_MOVE;
}
break;
case MENU_STATE_CONFIRM_DELETE_OLD_MOVE:
{
s8 var = Menu_ProcessInputNoWrapClearOnChoose();
if (var == 0)
{
FormatAndPrintText(gText_MoveTutorWhichMoveToForget);
sMoveTutorStruct->state = MENU_STATE_PRINT_WHICH_MOVE_PROMPT;
}
else if (var == -1 || var == 1)
{
sMoveTutorStruct->state = MENU_STATE_PRINT_STOP_TEACHING;
}
}
break;
case MENU_STATE_PRINT_STOP_TEACHING:
StringCopy(gStringVar2, gMoveNames[GetCurrentSelectedMove()]);
FormatAndPrintText(gText_MoveTutorStopTryingToTeachMove);
sMoveTutorStruct->state++;
break;
case MENU_STATE_WAIT_FOR_STOP_TEACHING:
if (!MoveTutorRunTextPrinters())
{
MoveTutorCreateYesNoMenu();
sMoveTutorStruct->state++;
}
break;
case MENU_STATE_CONFIRM_STOP_TEACHING:
{
s8 var = Menu_ProcessInputNoWrapClearOnChoose();
if (var == 0)
{
sMoveTutorStruct->state = MENU_STATE_CHOOSE_SETUP_STATE;
}
else if (var == MENU_B_PRESSED || var == 1)
{
// What's the point? It gets set to MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT, anyway.
if (sMoveTutorMenuSate.showContestInfo == FALSE)
{
sMoveTutorStruct->state = MENU_STATE_SETUP_BATTLE_MODE;
}
else if (sMoveTutorMenuSate.showContestInfo == TRUE)
{
sMoveTutorStruct->state = MENU_STATE_SETUP_CONTEST_MODE;
}
sMoveTutorStruct->state = MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT;
}
}
break;
case MENU_STATE_CHOOSE_SETUP_STATE:
if (!MoveTutorRunTextPrinters())
{
FillWindowPixelBuffer(3, 0x11);
if (sMoveTutorMenuSate.showContestInfo == FALSE)
{
sMoveTutorStruct->state = MENU_STATE_SETUP_BATTLE_MODE;
}
else if (sMoveTutorMenuSate.showContestInfo == TRUE)
{
sMoveTutorStruct->state = MENU_STATE_SETUP_CONTEST_MODE;
}
}
break;
case MENU_STATE_PRINT_WHICH_MOVE_PROMPT:
if (!MoveTutorRunTextPrinters())
{
sMoveTutorStruct->state = MENU_STATE_SHOW_MOVE_SUMMARY_SCREEN;
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
}
break;
case MENU_STATE_SHOW_MOVE_SUMMARY_SCREEN:
if (!gPaletteFade.active)
{
ShowSelectMovePokemonSummaryScreen(gPlayerParty, sMoveTutorStruct->partyMon, gPlayerPartyCount - 1, CB2_InitLearnMoveReturnFromSelectMove, GetCurrentSelectedMove());
FreeMoveTutorResources();
}
break;
case 21:
if (!MoveTutorRunTextPrinters())
{
sMoveTutorStruct->state = MENU_STATE_FADE_AND_RETURN;
}
break;
case 22:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
break;
case MENU_STATE_FADE_AND_RETURN:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
sMoveTutorStruct->state++;
break;
case MENU_STATE_RETURN_TO_FIELD:
if (!gPaletteFade.active)
{
FreeMoveTutorResources();
SetMainCallback2(CB2_ReturnToField);
}
break;
case MENU_STATE_FADE_FROM_SUMMARY_SCREEN:
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
sMoveTutorStruct->state++;
if (sMoveTutorMenuSate.showContestInfo == FALSE)
{
HideHeartSpritesAndShowTeachMoveText(TRUE);
}
else if (sMoveTutorMenuSate.showContestInfo == TRUE)
{
ShowTeachMoveText(TRUE);
}
RemoveScrollArrows();
CopyWindowToVram(3, 2);
break;
case MENU_STATE_TRY_OVERWRITE_MOVE:
if (!gPaletteFade.active)
{
if (sMoveTutorStruct->moveSlot == MAX_MON_MOVES)
{
sMoveTutorStruct->state = MENU_STATE_PRINT_STOP_TEACHING;
}
else
{
u16 moveId = GetMonData(&gPlayerParty[sMoveTutorStruct->partyMon], MON_DATA_MOVE1 + sMoveTutorStruct->moveSlot);
StringCopy(gStringVar3, gMoveNames[moveId]);
RemoveMonPPBonus(&gPlayerParty[sMoveTutorStruct->partyMon], sMoveTutorStruct->moveSlot);
SetMonMoveSlot(&gPlayerParty[sMoveTutorStruct->partyMon], GetCurrentSelectedMove(), sMoveTutorStruct->moveSlot);
StringCopy(gStringVar2, gMoveNames[GetCurrentSelectedMove()]);
FormatAndPrintText(gText_MoveTutorAndPoof);
sMoveTutorStruct->state = MENU_STATE_DOUBLE_FANFARE_FORGOT_MOVE;
gSpecialVar_0x8004 = TRUE;
}
}
break;
case MENU_STATE_DOUBLE_FANFARE_FORGOT_MOVE:
if (!MoveTutorRunTextPrinters())
{
FormatAndPrintText(gText_MoveTutorPkmnForgotMoveAndLearnedNew);
sMoveTutorStruct->state = MENU_STATE_PRINT_TEXT_THEN_FANFARE;
PlayFanfare(MUS_FANFA1);
}
break;
case MENU_STATE_PRINT_TEXT_THEN_FANFARE:
if (!MoveTutorRunTextPrinters())
{
PlayFanfare(MUS_FANFA1);
sMoveTutorStruct->state = MENU_STATE_WAIT_FOR_FANFARE;
}
break;
case MENU_STATE_WAIT_FOR_FANFARE:
if (IsFanfareTaskInactive())
{
sMoveTutorStruct->state = MENU_STATE_WAIT_FOR_A_BUTTON;
}
break;
case MENU_STATE_WAIT_FOR_A_BUTTON:
if (gMain.newKeys & A_BUTTON)
{
PlaySE(SE_SELECT);
sMoveTutorStruct->state = MENU_STATE_FADE_AND_RETURN;
}
break;
}
}
static void FreeMoveTutorResources(void)
{
RemoveScrollArrows();
DestroyListMenuTask(sMoveTutorStruct->moveListMenuTask, &sMoveTutorMenuSate.listOffset, &sMoveTutorMenuSate.listRow);
FreeAllWindowBuffers();
FREE_AND_SET_NULL(sMoveTutorStruct);
ResetSpriteData();
FreeAllSpritePalettes();
}
// Note: The hearts are already made invisible by MoveTutorShowHideHearts,
// which is called whenever the cursor in either list changes.
static void HideHeartSpritesAndShowTeachMoveText(bool8 onlyHideSprites)
{
s32 i;
for (i = 0; i < 16; i++)
{
gSprites[sMoveTutorStruct->heartSpriteIds[i]].invisible = TRUE;
}
if (!onlyHideSprites)
{
StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn);
FillWindowPixelBuffer(3, 0x11);
AddTextPrinterParameterized(3, 1, gStringVar4, 0, 1, 0, NULL);
}
}
static void HandleInput(bool8 showContest)
{
s32 itemId = ListMenu_ProcessInput(sMoveTutorStruct->moveListMenuTask);
ListMenuGetScrollAndRow(sMoveTutorStruct->moveListMenuTask, &sMoveTutorMenuSate.listOffset, &sMoveTutorMenuSate.listRow);
switch (itemId)
{
case LIST_NOTHING_CHOSEN:
if (!(gMain.newKeys & (DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysState())
{
break;
}
PlaySE(SE_SELECT);
if (showContest == FALSE)
{
PutWindowTilemap(1);
sMoveTutorStruct->state = MENU_STATE_SETUP_CONTEST_MODE;
sMoveTutorMenuSate.showContestInfo = TRUE;
}
else
{
PutWindowTilemap(0);
sMoveTutorStruct->state = MENU_STATE_SETUP_BATTLE_MODE;
sMoveTutorMenuSate.showContestInfo = FALSE;
}
schedule_bg_copy_tilemap_to_vram(1);
MoveTutorShowHideHearts(GetCurrentSelectedMove());
break;
case LIST_CANCEL:
PlaySE(SE_SELECT);
RemoveScrollArrows();
sMoveTutorStruct->state = MENU_STATE_PRINT_GIVE_UP_PROMPT;
StringExpandPlaceholders(gStringVar4, gText_MoveTutorGiveUp);
MoveTutorPrintText(gStringVar4);
break;
default:
PlaySE(SE_SELECT);
RemoveScrollArrows();
sMoveTutorStruct->state = MENU_STATE_PRINT_TEACH_MOVE_PROMPT;
StringCopy(gStringVar2, gMoveNames[itemId]);
StringExpandPlaceholders(gStringVar4, gText_MoveTutorTeachMoveConfirm);
MoveTutorPrintText(gStringVar4);
break;
}
}
static s32 GetCurrentSelectedMove(void)
{
return sMoveTutorStruct->menuItems[sMoveTutorMenuSate.listRow + sMoveTutorMenuSate.listOffset].id;
}
// Theory: This used to make the heart sprites visible again (i.e.
// this was the inverse of HideHeartsAndShowTeachMoveText), but the
// code was commented out. The bool argument would have been named
// "justShowHearts." The code for showing/hiding the heards was moved
// to MoveTutorShowHideHearts, which is called whenever a new move is
// selected and whenever the display mode changes.
static void ShowTeachMoveText(bool8 shouldDoNothingInstead)
{
if (shouldDoNothingInstead == FALSE)
{
StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn);
FillWindowPixelBuffer(3, 0x11);
AddTextPrinterParameterized(3, 1, gStringVar4, 0, 1, 0, NULL);
}
}
static void CreateUISprites(void)
{
int i;
sMoveTutorStruct->moveDisplayArrowTask = 0xFF;
sMoveTutorStruct->moveListScrollArrowTask = 0xFF;
AddScrollArrows();
// These are the appeal hearts.
for (i = 0; i < 8; i++)
{
sMoveTutorStruct->heartSpriteIds[i] = CreateSprite(&sConstestMoveHeartSprite, (i - (i / 4) * 4) * 8 + 104, (i / 4) * 8 + 36, 0);
}
// These are the jam harts.
// The animation is used to toggle between full/empty heart sprites.
for (i = 0; i < 8; i++)
{
sMoveTutorStruct->heartSpriteIds[i + 8] = CreateSprite(&sConstestMoveHeartSprite, (i - (i / 4) * 4) * 8 + 104, (i / 4) * 8 + 52, 0);
StartSpriteAnim(&gSprites[sMoveTutorStruct->heartSpriteIds[i + 8]], 2);
}
for (i = 0; i < 16; i++)
{
gSprites[sMoveTutorStruct->heartSpriteIds[i]].invisible = TRUE;
}
}
static void AddScrollArrows(void)
{
if (sMoveTutorStruct->moveDisplayArrowTask == 0xFF)
{
sMoveTutorStruct->moveDisplayArrowTask = AddScrollIndicatorArrowPair(&sDisplayModeArrowsTemplate, &sMoveTutorStruct->scrollOffset);
}
if (sMoveTutorStruct->moveListScrollArrowTask == 0xFF)
{
gTempScrollArrowTemplate = sMoveListScrollArrowsTemplate;
gTempScrollArrowTemplate.fullyDownThreshold = sMoveTutorStruct->numMenuChoices - sMoveTutorStruct->numToShowAtOnce;
sMoveTutorStruct->moveListScrollArrowTask = AddScrollIndicatorArrowPair(&gTempScrollArrowTemplate, &sMoveTutorMenuSate.listOffset);
}
}
static void RemoveScrollArrows(void)
{
if (sMoveTutorStruct->moveDisplayArrowTask != 0xFF)
{
RemoveScrollIndicatorArrowPair(sMoveTutorStruct->moveDisplayArrowTask);
sMoveTutorStruct->moveDisplayArrowTask = 0xFF;
}
if (sMoveTutorStruct->moveListScrollArrowTask != 0xFF)
{
RemoveScrollIndicatorArrowPair(sMoveTutorStruct->moveListScrollArrowTask);
sMoveTutorStruct->moveListScrollArrowTask = 0xFF;
}
}
static void CreateLearnableMovesList(void)
{
s32 i;
u8 nickname[POKEMON_NAME_LENGTH + 1];
sMoveTutorStruct->numMenuChoices = GetMoveRelearnerMoves(&gPlayerParty[sMoveTutorStruct->partyMon], sMoveTutorStruct->movesToLearn);
for (i = 0; i < sMoveTutorStruct->numMenuChoices; i++)
{
sMoveTutorStruct->menuItems[i].name = gMoveNames[sMoveTutorStruct->movesToLearn[i]];
sMoveTutorStruct->menuItems[i].id = sMoveTutorStruct->movesToLearn[i];
}
GetMonData(&gPlayerParty[sMoveTutorStruct->partyMon], MON_DATA_NICKNAME, nickname);
StringCopy10(gStringVar1, nickname);
sMoveTutorStruct->menuItems[sMoveTutorStruct->numMenuChoices].name = gText_Cancel;
sMoveTutorStruct->menuItems[sMoveTutorStruct->numMenuChoices].id = LIST_CANCEL;
sMoveTutorStruct->numMenuChoices++;
sMoveTutorStruct->numToShowAtOnce = LoadMoveTutorMovesList(sMoveTutorStruct->menuItems, sMoveTutorStruct->numMenuChoices);
}
void MoveTutorShowHideHearts(s32 moveId)
{
u16 numHearts;
u16 i;
if (!sMoveTutorMenuSate.showContestInfo || moveId == LIST_CANCEL)
{
for (i = 0; i < 16; i++)
{
gSprites[sMoveTutorStruct->heartSpriteIds[i]].invisible = TRUE;
}
}
else
{
numHearts = (u8)(gContestEffects[gContestMoves[moveId].effect].appeal / 10);
if (numHearts == 0xFF)
{
numHearts = 0;
}
for (i = 0; i < 8; i++)
{
if (i < numHearts)
{
StartSpriteAnim(&gSprites[sMoveTutorStruct->heartSpriteIds[i]], 1);
}
else
{
StartSpriteAnim(&gSprites[sMoveTutorStruct->heartSpriteIds[i]], 0);
}
gSprites[sMoveTutorStruct->heartSpriteIds[i]].invisible = FALSE;
}
numHearts = (u8)(gContestEffects[gContestMoves[moveId].effect].jam / 10);
if (numHearts == 0xFF)
{
numHearts = 0;
}
for (i = 0; i < 8; i++)
{
if (i < numHearts)
{
StartSpriteAnim(&gSprites[sMoveTutorStruct->heartSpriteIds[i + 8]], 3);
}
else
{
StartSpriteAnim(&gSprites[sMoveTutorStruct->heartSpriteIds[i + 8]], 2);
}
gSprites[sMoveTutorStruct->heartSpriteIds[i + 8]].invisible = FALSE;
}
}
}

View File

@ -1688,7 +1688,7 @@ void CB2_ReturnToFieldContinueScript(void)
void CB2_ReturnToFieldContinueScriptPlayMapMusic(void)
{
FieldClearVBlankHBlankCallbacks();
gFieldCallback = sub_80AF168;
gFieldCallback = FieldCallback_ReturnToEventScript2;
CB2_ReturnToField();
}

View File

@ -7287,7 +7287,7 @@ static void sub_81B9640(u8 taskId)
void sub_81B968C(void)
{
ShowPokemonSummaryScreen(PSS_MODE_SELECT_MOVE, gPlayerParty, gSpecialVar_0x8004, gPlayerPartyCount - 1, CB2_ReturnToField);
gFieldCallback = sub_80AF168;
gFieldCallback = FieldCallback_ReturnToEventScript2;
}
void sub_81B96D0(void)

View File

@ -645,7 +645,7 @@ static void Mailbox_ProcessInput(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
RemoveScrollIndicatorArrowPair(playerPCItemPageInfo.scrollIndicatorId);
Mailbox_ReturnToPlayerPC(taskId);
@ -1151,7 +1151,7 @@ static void ItemStorage_ProcessInput(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
ItemStorage_GoBackToPlayerPCMenu(taskId);
break;
@ -1226,7 +1226,7 @@ static void sub_816C4FC(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
if (gMain.newKeys & A_BUTTON)
{
ItemStorage_DoItemSwap(taskId, FALSE);

View File

@ -709,7 +709,7 @@ static void HandlePokeblockListMenuItems(void)
StringCopy(sPokeblockMenu->menuItemsStrings[i], gText_StowCase);
sPokeblockMenu->items[i].name = sPokeblockMenu->menuItemsStrings[i];
sPokeblockMenu->items[i].id = LIST_B_PRESSED;
sPokeblockMenu->items[i].id = LIST_CANCEL;
gMultiuseListMenuTemplate = sPokeblockListMenuTemplate;
gMultiuseListMenuTemplate.fontId = 7;
@ -751,7 +751,7 @@ static void sub_8135FCC(s32 pkblId)
FillWindowPixelBuffer(7, 0);
if (pkblId != LIST_B_PRESSED)
if (pkblId != LIST_CANCEL)
{
pokeblock = &gSaveBlock1Ptr->pokeblocks[pkblId];
rectTilemapSrc[0] = 0x17;
@ -959,7 +959,7 @@ static void Task_FreeDataAndExitPokeblockCase(u8 taskId)
if (!gPaletteFade.active)
{
if (sPokeblockMenu->caseId == PBLOCK_CASE_FEEDER || sPokeblockMenu->caseId == PBLOCK_CASE_GIVE)
gFieldCallback = sub_80AF168;
gFieldCallback = FieldCallback_ReturnToEventScript2;
DestroyListMenuTask(data[0], &sSavedPokeblockData.lastItemPage, &sSavedPokeblockData.lastItemPos);
sub_8136418();
@ -1011,7 +1011,7 @@ static void Task_HandlePokeblockMenuInput(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
gSpecialVar_Result = 0xFFFF;
gSpecialVar_ItemId = 0;
@ -1066,7 +1066,7 @@ static void Task_HandlePokeblocksSwapInput(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED: // same id as STOW CASE field
case LIST_CANCEL: // same id as STOW CASE field
PlaySE(SE_SELECT);
if (gMain.newKeys & A_BUTTON)
HandlePokeblocksSwap(taskId, FALSE);

View File

@ -1984,7 +1984,7 @@ static void sub_8141E7C(u8 taskId) // end roulette ?
ResetPaletteFade();
ResetSpriteData();
sub_8140418();
gFieldCallback = sub_80AF168;
gFieldCallback = FieldCallback_ReturnToEventScript2;
SetMainCallback2(CB2_ReturnToField);
DestroyTask(taskId);
}

View File

@ -391,7 +391,7 @@ void sub_80E8FD0(u8 taskId)
}
sub_80E8F9C();
WarpIntoMap();
gFieldCallback = sub_80AF168;
gFieldCallback = FieldCallback_ReturnToEventScript2;
SetMainCallback2(CB2_LoadMap);
DestroyTask(taskId);
break;
@ -959,7 +959,7 @@ void sub_80E9E90(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
DestroyListMenuTask(data[5], NULL, NULL);
RemoveScrollIndicatorArrowPair(data[8]);

View File

@ -918,7 +918,7 @@ static void Task_BuyMenu(u8 taskId)
{
case LIST_NOTHING_CHOSEN:
break;
case LIST_B_PRESSED:
case LIST_CANCEL:
PlaySE(SE_SELECT);
ExitBuyMenu(taskId);
break;

View File

@ -1742,15 +1742,15 @@ const u8 gText_TrainerHill2F[] = _("2F");
const u8 gText_TrainerHill3F[] = _("3F");
const u8 gText_TrainerHill4F[] = _("4F");
const u8 gText_TeachWhichMoveToPkmn[] = _("Teach which move to {STR_VAR_1}?");
const u8 gText_TeachX[] = _("Teach {STR_VAR_2}?");
const u8 gText_PkmnLearnedMove4[] = _("{STR_VAR_1} learned\n{STR_VAR_2}!");
const u8 gText_PkmnTryingToLearnMove[] = _("{STR_VAR_1} is trying to learn\n{STR_VAR_2}.\pBut {STR_VAR_1} can't learn more\nthan four moves.\pDelete an older move to make\nroom for {STR_VAR_2}?");
const u8 gText_StopTryingToTeachMove[] = _("Stop trying to teach\n{STR_VAR_2}?");
const u8 gText_12AndPoof[] = _("{PAUSE 32}1, {PAUSE 15}2, and {PAUSE 15}… {PAUSE 15}… {PAUSE 15}… {PAUSE 15}{PLAY_SE 0x0038}Poof!\p");
const u8 gText_PkmnForgotMoveAndLearnedNew[] = _("{STR_VAR_1} forgot {STR_VAR_3}.\pAnd…\p{STR_VAR_1} learned {STR_VAR_2}.");
const u8 gText_MoveTutorTeachMoveConfirm[] = _("Teach {STR_VAR_2}?");
const u8 gText_MoveTutorPkmnLearnedMove[] = _("{STR_VAR_1} learned\n{STR_VAR_2}!");
const u8 gText_MoveTutorPkmnTryingToLearnMove[] = _("{STR_VAR_1} is trying to learn\n{STR_VAR_2}.\pBut {STR_VAR_1} can't learn more\nthan four moves.\pDelete an older move to make\nroom for {STR_VAR_2}?");
const u8 gText_MoveTutorStopTryingToTeachMove[] = _("Stop trying to teach\n{STR_VAR_2}?");
const u8 gText_MoveTutorAndPoof[] = _("{PAUSE 32}1, {PAUSE 15}2, and {PAUSE 15}… {PAUSE 15}… {PAUSE 15}… {PAUSE 15}{PLAY_SE 0x0038}Poof!\p");
const u8 gText_MoveTutorPkmnForgotMoveAndLearnedNew[] = _("{STR_VAR_1} forgot {STR_VAR_3}.\pAnd…\p{STR_VAR_1} learned {STR_VAR_2}.");
const u8 gUnknown_085EF9C8[] = _("{STR_VAR_1} did not learn the\nmove {STR_VAR_2}.");
const u8 gText_GiveUpTeachingNewMove[] = _("Give up trying to teach a new\nmove to {STR_VAR_1}?");
const u8 gText_WhichMoveToForget2[] = _("Which move should be\nforgotten?\p");
const u8 gText_MoveTutorGiveUp[] = _("Give up trying to teach a new\nmove to {STR_VAR_1}?");
const u8 gText_MoveTutorWhichMoveToForget[] = _("Which move should be\nforgotten?\p");
const u8 gText_BattleMoves2[] = _("BATTLE MOVES");
const u8 gText_ContestMoves2[] = _("CONTEST MOVES");
const u8 gUnknown_085EFA4C[] = _("TYPE/");

View File

@ -6061,7 +6061,7 @@ static void sub_807F110(u8 taskId)
if (!gPaletteFade.active)
{
SetMainCallback2(sub_807B270);
gFieldCallback = sub_80AF168;
gFieldCallback = FieldCallback_ReturnToEventScript2;
DestroyTask(taskId);
}
}

View File

@ -70,7 +70,7 @@ static void CB2_HandleGivenWaldaPhrase(void)
}
StringCopy(gStringVar1, GetWaldaPhrasePtr());
gFieldCallback = sub_80AF168;
gFieldCallback = FieldCallback_ReturnToEventScript2;
SetMainCallback2(CB2_ReturnToField);
}

View File

@ -192,7 +192,7 @@ gPlayerFacingPosition: @ 203AB40
.include "src/rom_81520A8.o"
.include "src/save.o"
.include "src/mystery_event_script.o"
.include "src/learn_move.o"
.include "src/move_tutor.o"
.include "src/decoration_inventory.o"
.include "src/roamer.o"
.include "src/battle_tower.o"