2017-09-25 14:53:25 +02:00
|
|
|
|
|
|
|
// Includes
|
|
|
|
#include "global.h"
|
|
|
|
#include "songs.h"
|
|
|
|
#include "sound.h"
|
2017-10-29 02:03:24 +02:00
|
|
|
#include "overworld.h"
|
2017-09-25 14:53:25 +02:00
|
|
|
#include "task.h"
|
|
|
|
#include "main.h"
|
2017-09-25 23:30:49 +02:00
|
|
|
#include "window.h"
|
2017-09-25 14:53:25 +02:00
|
|
|
#include "palette.h"
|
2017-09-26 01:57:44 +02:00
|
|
|
#include "event_data.h"
|
2017-09-25 14:53:25 +02:00
|
|
|
#include "easy_chat.h"
|
|
|
|
|
|
|
|
// Static type declarations
|
|
|
|
|
2017-09-25 23:30:49 +02:00
|
|
|
#define EZCHAT_TASK_STATE 0
|
|
|
|
#define EZCHAT_TASK_UNK01 1
|
|
|
|
#define EZCHAT_TASK_UNK02 2
|
|
|
|
#define EZCHAT_TASK_MAINCALLBACK 4
|
|
|
|
#define EZCHAT_TASK_UNK06 6
|
|
|
|
#define EZCHAT_TASK_UNK07 7
|
|
|
|
|
2017-09-25 14:53:25 +02:00
|
|
|
// Static RAM declarations
|
|
|
|
static void sub_811A2C0(u8);
|
|
|
|
static void sub_811A278(void);
|
2017-09-25 23:22:51 +02:00
|
|
|
static bool8 sub_811A428(u8);
|
2017-09-25 14:53:25 +02:00
|
|
|
static void sub_811A2FC(u8);
|
|
|
|
/*static*/ u16 sub_811AAAC(void);
|
|
|
|
/*static*/ bool32 sub_811A88C(u16);
|
|
|
|
/*static*/ void sub_811C158(u16);
|
|
|
|
/*static*/ bool8 sub_811C170(void);
|
|
|
|
/*static*/ void sub_811A8A4(u16);
|
2017-09-25 23:30:49 +02:00
|
|
|
/*static*/ void sub_811A4D0(MainCallback);
|
2017-09-25 23:22:51 +02:00
|
|
|
bool8 sub_811F28C(void);
|
|
|
|
bool8 sub_811A95C(u8, u32, u8);
|
|
|
|
bool8 sub_811BF8C(void);
|
|
|
|
bool8 sub_811BFA4(void);
|
2017-09-25 23:30:49 +02:00
|
|
|
void sub_811C13C(void);
|
|
|
|
void sub_811AA90(void);
|
|
|
|
void sub_811F2B8(void);
|
2017-09-25 14:53:25 +02:00
|
|
|
|
|
|
|
// Static ROM declarations
|
|
|
|
|
|
|
|
// .rodata
|
|
|
|
|
|
|
|
// .text
|
|
|
|
|
2017-09-25 23:30:49 +02:00
|
|
|
void sub_811A20C(u8 a0, u32 a1, MainCallback callback, u8 a3)
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
|
|
|
u8 taskId;
|
|
|
|
|
|
|
|
ResetTasks();
|
|
|
|
taskId = CreateTask(sub_811A2C0, 0);
|
2017-09-25 23:30:49 +02:00
|
|
|
gTasks[taskId].data[EZCHAT_TASK_UNK01] = a0;
|
|
|
|
gTasks[taskId].data[EZCHAT_TASK_UNK07] = a3;
|
|
|
|
SetWordTaskArg(taskId, EZCHAT_TASK_UNK02, a1);
|
|
|
|
SetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK, (u32)callback);
|
2017-09-25 14:53:25 +02:00
|
|
|
SetMainCallback2(sub_811A278);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_811A278(void)
|
|
|
|
{
|
|
|
|
RunTasks();
|
|
|
|
AnimateSprites();
|
|
|
|
BuildOamBuffer();
|
|
|
|
UpdatePaletteFade();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_811A290(void)
|
|
|
|
{
|
|
|
|
TransferPlttBuffer();
|
|
|
|
LoadOam();
|
|
|
|
ProcessSpriteCopyRequests();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_811A2A4(u8 taskId, TaskFunc taskFunc)
|
|
|
|
{
|
|
|
|
gTasks[taskId].func = taskFunc;
|
2017-09-25 23:30:49 +02:00
|
|
|
gTasks[taskId].data[EZCHAT_TASK_STATE] = 0;
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_811A2C0(u8 taskId)
|
|
|
|
{
|
|
|
|
if (!is_c1_link_related_active())
|
|
|
|
{
|
|
|
|
while (sub_811A428(taskId));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (sub_811A428(taskId) == TRUE)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sub_811A2A4(taskId, sub_811A2FC);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sub_811A2FC(u8 taskId)
|
|
|
|
{
|
|
|
|
u16 v0;
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2017-09-25 23:30:49 +02:00
|
|
|
switch (data[EZCHAT_TASK_STATE])
|
2017-09-25 14:53:25 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetVBlankCallback(sub_811A290);
|
|
|
|
BlendPalettes(-1, 16, 0);
|
|
|
|
BeginNormalPaletteFade(-1, -1, 16, 0, 0);
|
2017-09-25 23:30:49 +02:00
|
|
|
data[EZCHAT_TASK_STATE] = 5;
|
2017-09-25 14:53:25 +02:00
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
v0 = sub_811AAAC();
|
|
|
|
if (sub_811A88C(v0))
|
|
|
|
{
|
|
|
|
BeginNormalPaletteFade(-1, -2, 0, 16, 0);
|
2017-09-25 23:30:49 +02:00
|
|
|
data[EZCHAT_TASK_STATE] = 3;
|
|
|
|
data[EZCHAT_TASK_UNK06] = v0;
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
else if (v0 == 0x18)
|
|
|
|
{
|
|
|
|
BeginNormalPaletteFade(-1, -1, 0, 16, 0);
|
2017-09-25 23:30:49 +02:00
|
|
|
data[EZCHAT_TASK_STATE] = 4;
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
else if (v0 != 0)
|
|
|
|
{
|
|
|
|
PlaySE(SE_SELECT);
|
|
|
|
sub_811C158(v0);
|
2017-09-25 23:30:49 +02:00
|
|
|
data[EZCHAT_TASK_STATE] ++;
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (!sub_811C170())
|
|
|
|
{
|
2017-09-25 23:30:49 +02:00
|
|
|
data[EZCHAT_TASK_STATE] = 1;
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2017-09-25 23:30:49 +02:00
|
|
|
sub_811A8A4(data[EZCHAT_TASK_UNK06]);
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2017-09-25 23:30:49 +02:00
|
|
|
sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK));
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5:
|
|
|
|
if (!gPaletteFade.active)
|
|
|
|
{
|
2017-09-25 23:30:49 +02:00
|
|
|
data[EZCHAT_TASK_STATE] = 1;
|
2017-09-25 14:53:25 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2017-09-25 23:22:51 +02:00
|
|
|
|
|
|
|
static bool8 sub_811A428(u8 taskId)
|
|
|
|
{
|
|
|
|
s16 *data;
|
|
|
|
|
|
|
|
data = gTasks[taskId].data;
|
2017-09-25 23:30:49 +02:00
|
|
|
switch (data[EZCHAT_TASK_STATE])
|
2017-09-25 23:22:51 +02:00
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
SetVBlankCallback(NULL);
|
|
|
|
ResetSpriteData();
|
|
|
|
FreeAllSpritePalettes();
|
|
|
|
ResetPaletteFade();
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (!sub_811F28C())
|
|
|
|
{
|
2017-09-25 23:30:49 +02:00
|
|
|
sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK));
|
2017-09-25 23:22:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
2017-09-25 23:30:49 +02:00
|
|
|
if (!sub_811A95C(data[EZCHAT_TASK_UNK01], GetWordTaskArg(taskId, EZCHAT_TASK_UNK02), data[EZCHAT_TASK_UNK07]))
|
2017-09-25 23:22:51 +02:00
|
|
|
{
|
2017-09-25 23:30:49 +02:00
|
|
|
sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK));
|
2017-09-25 23:22:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
if (!sub_811BF8C())
|
|
|
|
{
|
2017-09-25 23:30:49 +02:00
|
|
|
sub_811A4D0((MainCallback)GetWordTaskArg(taskId, EZCHAT_TASK_MAINCALLBACK));
|
2017-09-25 23:22:51 +02:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4:
|
|
|
|
if (sub_811BFA4())
|
|
|
|
{
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return FALSE;
|
|
|
|
}
|
2017-09-25 23:30:49 +02:00
|
|
|
data[EZCHAT_TASK_STATE] ++;
|
2017-09-25 23:22:51 +02:00
|
|
|
return TRUE;
|
|
|
|
}
|
2017-09-25 23:30:49 +02:00
|
|
|
|
|
|
|
void sub_811A4D0(MainCallback callback)
|
|
|
|
{
|
|
|
|
sub_811C13C();
|
|
|
|
sub_811AA90();
|
|
|
|
sub_811F2B8();
|
|
|
|
FreeAllWindowBuffers();
|
|
|
|
SetMainCallback2(callback);
|
|
|
|
}
|
2017-09-26 01:57:44 +02:00
|
|
|
//
|
|
|
|
//void easy_chat_input_maybe(void)
|
|
|
|
//{
|
|
|
|
// u16 i;
|
|
|
|
// u16 *words;
|
|
|
|
// OldMan *oldMan;
|
|
|
|
// u8 sizeParam = 3;
|
|
|
|
// switch (gSpecialVar_0x8004)
|
|
|
|
// {
|
|
|
|
// case 0:
|
|
|
|
// words = gSaveBlock1Ptr->unk2BB0;
|
|
|
|
// break;
|
|
|
|
// case 1:
|
|
|
|
// words = gSaveBlock1Ptr->unk2BBC;
|
|
|
|
// break;
|
|
|
|
// case 2:
|
|
|
|
// words = gSaveBlock1Ptr->unk2BC8;
|
|
|
|
// break;
|
|
|
|
// case 3:
|
|
|
|
// words = gSaveBlock1Ptr->unk2BD4;
|
|
|
|
// break;
|
|
|
|
// case 4:
|
|
|
|
// words = gSaveBlock1Ptr->mail[gSpecialVar_0x8005].words;
|
|
|
|
// break;
|
|
|
|
// case 6:
|
|
|
|
// oldMan = &gSaveBlock1Ptr->oldMan;
|
|
|
|
// for (i=0; i<6; i++)
|
|
|
|
// {
|
|
|
|
// oldMan->oldMan1.mauvilleOldMan_ecArray2[i] = oldMan->oldMan1.mauvilleOldMan_ecArray[i];
|
|
|
|
// }
|
|
|
|
// words = oldMan->oldMan1.mauvilleOldMan_ecArray2;
|
|
|
|
// break;
|
|
|
|
// case 5:
|
|
|
|
// words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.var04;
|
|
|
|
// sizeParam = gSpecialVar_0x8006;
|
|
|
|
// break;
|
|
|
|
// case 7:
|
|
|
|
// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.var1C[gSpecialVar_0x8006];
|
|
|
|
// sizeParam = 1;
|
|
|
|
// break;
|
|
|
|
// case 8:
|
|
|
|
// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].recentHappenings.var02;
|
|
|
|
// sizeParam = 0;
|
|
|
|
// break;
|
|
|
|
// case 9:
|
|
|
|
// words = NULL;
|
|
|
|
// break;
|
|
|
|
// case 10:
|
|
|
|
// words = &gSaveBlock1Ptr->gabbyAndTyData.quote;
|
|
|
|
// *words = -1;
|
|
|
|
// sizeParam = 1;
|
|
|
|
// break;
|
|
|
|
// case 11:
|
|
|
|
// words = &gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].bravoTrainer.var04[gSpecialVar_0x8006];
|
|
|
|
// sizeParam = 0;
|
|
|
|
// break;
|
|
|
|
// case 12:
|
|
|
|
// words = gSaveBlock1Ptr->tvShows[gSpecialVar_0x8005].fanclubOpinions.var18;
|
|
|
|
// sizeParam = 1;
|
|
|
|
// break;
|
|
|
|
// case 13:
|
|
|
|
// words = (u16 *)gStringVar3;
|
|
|
|
// sub_811F88C(words, 2);
|
|
|
|
// break;
|
|
|
|
// case 14:
|
|
|
|
// words =
|
|
|
|
// default:
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// overworld_free_bg_tilemaps();
|
|
|
|
// sub_811A20C(gSpecialVar_0x8004, words, sub_80861B0, sizeParam);
|
|
|
|
//}
|
|
|
|
|