Sync mystery_gift_show_news
This commit is contained in:
+15
-7
@@ -9,6 +9,14 @@
|
||||
#define CARD_STAT_NUM_STAMPS 3
|
||||
#define CARD_STAT_MAX_STAMPS 4
|
||||
|
||||
enum {
|
||||
NEWS_INPUT_A,
|
||||
NEWS_INPUT_B,
|
||||
NEWS_INPUT_SCROLL_UP,
|
||||
NEWS_INPUT_SCROLL_DOWN,
|
||||
NEWS_INPUT_NONE = 0xFF
|
||||
};
|
||||
|
||||
struct MEventClientHeaderStruct
|
||||
{
|
||||
u32 unk_00;
|
||||
@@ -74,21 +82,21 @@ u32 MEvent_CanPlayerReceiveDistributionMon(const u16 * a0, const struct MEventCl
|
||||
bool32 sub_8144474(const struct MEventClientHeaderStruct * a0, const u16 * a1);
|
||||
u16 sub_81444B0(const struct MEventClientHeaderStruct * a0, u32 command);
|
||||
bool32 WonderCard_Init(struct WonderCard * card, struct WonderCardMetadata * metadata);
|
||||
bool32 InitWonderNewsResources(const struct WonderNews * a0);
|
||||
bool32 WonderNews_Init(const struct WonderNews * a0);
|
||||
s32 WonderCard_Enter(void);
|
||||
s32 FadeToWonderNewsMenu(void);
|
||||
s32 WonderNews_Enter(void);
|
||||
void DestroyWonderCard(void);
|
||||
void DestroyWonderNews(void);
|
||||
void WonderCard_Destroy(void);
|
||||
void DestroyWonderNewsResources(void);
|
||||
void WonderNews_Destroy(void);
|
||||
s32 WonderCard_Exit(bool32 flag);
|
||||
s32 FadeOutFromWonderNews(bool32 flag);
|
||||
s32 WonderNews_Exit(bool32 flag);
|
||||
bool32 CheckReceivedGiftFromWonderCard(void);
|
||||
void MENews_AddScrollIndicatorArrowPair(void);
|
||||
void MENews_RemoveScrollIndicatorArrowPair(void);
|
||||
void WonderNews_AddScrollIndicatorArrowPair(void);
|
||||
void WonderNews_RemoveScrollIndicatorArrowPair(void);
|
||||
bool32 WonderNews_Test_Unk_02(void);
|
||||
bool32 WonderCard_Test_Unk_08_6(void);
|
||||
u32 MENews_GetInput(u16 input);
|
||||
u32 WonderNews_GetInput(u16 input);
|
||||
void InitMEventData(void);
|
||||
u16 MEvent_GetBattleCardCount(u32 command);
|
||||
void MysteryGift_TryIncrementStat(u32 eventId, u32 trainerId);
|
||||
|
||||
@@ -806,7 +806,7 @@ bool32 HandleLoadWonderCardOrNews(u8 * state, bool32 cardOrNews)
|
||||
}
|
||||
else
|
||||
{
|
||||
InitWonderNewsResources(GetSavedWonderNews());
|
||||
WonderNews_Init(GetSavedWonderNews());
|
||||
}
|
||||
(*state)++;
|
||||
break;
|
||||
@@ -823,7 +823,7 @@ bool32 HandleLoadWonderCardOrNews(u8 * state, bool32 cardOrNews)
|
||||
}
|
||||
else
|
||||
{
|
||||
v0 = FadeToWonderNewsMenu();
|
||||
v0 = WonderNews_Enter();
|
||||
goto check;
|
||||
}
|
||||
done:
|
||||
@@ -863,9 +863,9 @@ bool32 TearDownCardOrNews_ReturnToTopMenu(bool32 cardOrNews, bool32 arg1)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FadeOutFromWonderNews(arg1) != 0)
|
||||
if (WonderNews_Exit(arg1) != 0)
|
||||
{
|
||||
DestroyWonderNewsResources();
|
||||
WonderNews_Destroy();
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
@@ -1456,10 +1456,10 @@ void task00_mystery_gift(u8 taskId)
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (MENews_GetInput(gMain.newKeys))
|
||||
switch (WonderNews_GetInput(gMain.newKeys))
|
||||
{
|
||||
case 0:
|
||||
MENews_RemoveScrollIndicatorArrowPair();
|
||||
WonderNews_RemoveScrollIndicatorArrowPair();
|
||||
data->state = 21;
|
||||
break;
|
||||
case 1:
|
||||
@@ -1507,7 +1507,7 @@ void task00_mystery_gift(u8 taskId)
|
||||
case -2u:
|
||||
if (data->IsCardOrNews == 1)
|
||||
{
|
||||
MENews_AddScrollIndicatorArrowPair();
|
||||
WonderNews_AddScrollIndicatorArrowPair();
|
||||
}
|
||||
data->state = 20;
|
||||
break;
|
||||
|
||||
+193
-146
@@ -6,45 +6,80 @@
|
||||
#include "mystery_gift_menu.h"
|
||||
#include "menu.h"
|
||||
#include "link_rfu.h"
|
||||
#include "list_menu.h"
|
||||
#include "constants/mystery_gift.h"
|
||||
|
||||
struct UnkStruct_203F3CC
|
||||
{
|
||||
/*0000*/ struct WonderNews wonderNews;
|
||||
/*01bc*/ const struct UnkStruct_8467FB8 * bgSpec;
|
||||
/*01c0*/ u8 verticalScrollDisabled:1;
|
||||
u8 state:7;
|
||||
/*01c1*/ u8 menuIndicatorsId;
|
||||
/*01c2*/ u8 unk_01C2_0:1;
|
||||
u8 unk_01C2_1:7;
|
||||
/*01c3*/ u8 scrollDirection:1;
|
||||
u8 unk_01C3_1:7;
|
||||
/*01c4*/ u16 numMails;
|
||||
/*01c6*/ u16 scrollOffset;
|
||||
/*01c8*/ u16 windowIds[2];
|
||||
/*01cc*/ u8 filler_01CC[2];
|
||||
/*01ce*/ u8 title[41];
|
||||
/*01f7*/ u8 messages[10][41];
|
||||
/*0394*/ struct ScrollArrowsTemplate scrollArrowsTemplate;
|
||||
/*03a4*/ u8 buffer_03A4[0x1000];
|
||||
enum {
|
||||
WIN_TITLE,
|
||||
WIN_BODY,
|
||||
WIN_COUNT
|
||||
};
|
||||
|
||||
static EWRAM_DATA struct UnkStruct_203F3CC * sWork = NULL;
|
||||
#define TAG_ARROWS 0x1000
|
||||
|
||||
static void sub_8146980(void);
|
||||
static void sub_8146A30(void);
|
||||
static void sub_8146B58(void);
|
||||
struct WonderNewsData
|
||||
{
|
||||
struct WonderNews news;
|
||||
const struct UnkStruct_8467FB8 * gfx;
|
||||
bool8 verticalScrollDisabled:1;
|
||||
u8 enterExitState:7;
|
||||
u8 arrowTaskId;
|
||||
bool8 scrolling:1;
|
||||
u8 scrollIncrement:7;
|
||||
bool8 scrollingDown:1;
|
||||
u8 scrollTotal:7;
|
||||
u16 scrollEnd;
|
||||
u16 scrollOffset;
|
||||
u16 windowIds[WIN_COUNT];
|
||||
u8 unused[2];
|
||||
u8 titleText[WONDER_NEWS_TEXT_LENGTH + 1];
|
||||
u8 bodyText[WONDER_NEWS_BODY_TEXT_LINES][WONDER_NEWS_TEXT_LENGTH + 1];
|
||||
struct ScrollArrowsTemplate arrowsTemplate;
|
||||
u8 bgTilemapBuffer[0x1000];
|
||||
};
|
||||
|
||||
static const u8 sTextPals[][3] = {
|
||||
static EWRAM_DATA struct WonderNewsData * sWonderNewsData = NULL;
|
||||
|
||||
static void BufferNewsText(void);
|
||||
static void DrawNewsWindows(void);
|
||||
static void UpdateNewsScroll(void);
|
||||
|
||||
static const u8 sTextColorTable[][3] = {
|
||||
{0, 2, 3},
|
||||
{0, 1, 2}
|
||||
};
|
||||
static const struct WindowTemplate gUnknown_8468040[] = {
|
||||
{0, 1, 0, 28, 3, 15, 0x000},
|
||||
{2, 1, 3, 28, 20, 15, 0x000}
|
||||
static const struct WindowTemplate sWindowTemplates[] = {
|
||||
[WIN_TITLE] = {
|
||||
.bg = 0,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 0,
|
||||
.width = 28,
|
||||
.height = 3,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x000
|
||||
},
|
||||
[WIN_BODY] = {
|
||||
.bg = 2,
|
||||
.tilemapLeft = 1,
|
||||
.tilemapTop = 3,
|
||||
.width = 28,
|
||||
.height = 20,
|
||||
.paletteNum = 15,
|
||||
.baseBlock = 0x000
|
||||
}
|
||||
};
|
||||
static const struct ScrollArrowsTemplate sScrollArrowsTemplate = {
|
||||
0x02, 0xe8, 0x18, 0x03, 0xe8, 0x98,
|
||||
0x0000, 0x0002, 0x1000, 0x1000, 0x0,
|
||||
static const struct ScrollArrowsTemplate sArrowsTemplate = {
|
||||
.firstArrowType = SCROLL_ARROW_UP,
|
||||
.firstX = 232,
|
||||
.firstY = 24,
|
||||
.secondArrowType = SCROLL_ARROW_DOWN,
|
||||
.secondX = 232,
|
||||
.secondY = 152,
|
||||
.fullyUpThreshold = 0,
|
||||
.fullyDownThreshold = 2,
|
||||
.tileTag = TAG_ARROWS,
|
||||
.palTag = TAG_ARROWS,
|
||||
.palNum = 0
|
||||
};
|
||||
|
||||
static const u16 sNews1Pal[] = INCBIN_U16("graphics/mevent/pal_468060.gbapal");
|
||||
@@ -61,7 +96,7 @@ static const u8 sNews6Map[] = INCBIN_U8("graphics/mevent/tilemap_4684D8.bin.lz")
|
||||
static const u8 sNews7Gfx[] = INCBIN_U8("graphics/mevent/gfx_4685B4.4bpp.lz");
|
||||
static const u8 sNews7Map[] = INCBIN_U8("graphics/mevent/tilemap_468644.bin.lz");
|
||||
|
||||
static const struct UnkStruct_8467FB8 sBgSpecs[] = {
|
||||
static const struct UnkStruct_8467FB8 sNewsGraphics[NUM_WONDER_BGS] = {
|
||||
{1, 0, 0, 0, sNews0Gfx, sNews0Map, sNews1Pal},
|
||||
{1, 0, 0, 0, sNews1Gfx, sNews1Map, gCard1Pal},
|
||||
{1, 0, 0, 0, sNews2Gfx, sNews2Map, gCard2Pal},
|
||||
@@ -72,37 +107,36 @@ static const struct UnkStruct_8467FB8 sBgSpecs[] = {
|
||||
{1, 0, 0, 0, sNews7Gfx, sNews7Map, sNews7Pal}
|
||||
};
|
||||
|
||||
bool32 InitWonderNewsResources(const struct WonderNews * news)
|
||||
bool32 WonderNews_Init(const struct WonderNews * news)
|
||||
{
|
||||
if (news == NULL)
|
||||
return FALSE;
|
||||
sWork = AllocZeroed(sizeof(struct UnkStruct_203F3CC));
|
||||
if (sWork == NULL)
|
||||
sWonderNewsData = AllocZeroed(sizeof(*sWonderNewsData));
|
||||
if (sWonderNewsData == NULL)
|
||||
return FALSE;
|
||||
sWork->wonderNews = *news;
|
||||
if (sWork->wonderNews.bgType >= NELEMS(sBgSpecs))
|
||||
sWork->wonderNews.bgType = 0;
|
||||
sWork->bgSpec = &sBgSpecs[sWork->wonderNews.bgType];
|
||||
sWork->menuIndicatorsId = 0xFF;
|
||||
sWonderNewsData->news = *news;
|
||||
if (sWonderNewsData->news.bgType >= NUM_WONDER_BGS)
|
||||
sWonderNewsData->news.bgType = 0;
|
||||
sWonderNewsData->gfx = &sNewsGraphics[sWonderNewsData->news.bgType];
|
||||
sWonderNewsData->arrowTaskId = TASK_NONE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void DestroyWonderNewsResources(void)
|
||||
void WonderNews_Destroy(void)
|
||||
{
|
||||
if (sWork != NULL)
|
||||
if (sWonderNewsData != NULL)
|
||||
{
|
||||
*sWork = (struct UnkStruct_203F3CC){};
|
||||
Free(sWork);
|
||||
sWork = NULL;
|
||||
*sWonderNewsData = (struct WonderNewsData){};
|
||||
FREE_AND_SET_NULL(sWonderNewsData);
|
||||
}
|
||||
}
|
||||
|
||||
s32 FadeToWonderNewsMenu(void)
|
||||
s32 WonderNews_Enter(void)
|
||||
{
|
||||
if (sWork == NULL)
|
||||
if (sWonderNewsData == NULL)
|
||||
return -1;
|
||||
|
||||
switch (sWork->state)
|
||||
switch (sWonderNewsData->enterExitState)
|
||||
{
|
||||
case 0:
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
@@ -110,11 +144,11 @@ s32 FadeToWonderNewsMenu(void)
|
||||
case 1:
|
||||
if (UpdatePaletteFade())
|
||||
return 0;
|
||||
ChangeBgY(0, 0, 0);
|
||||
ChangeBgY(1, 0, 0);
|
||||
ChangeBgY(2, 0, 0);
|
||||
ChangeBgY(3, 0, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, 240));
|
||||
ChangeBgY(0, 0, BG_COORD_SET);
|
||||
ChangeBgY(1, 0, BG_COORD_SET);
|
||||
ChangeBgY(2, 0, BG_COORD_SET);
|
||||
ChangeBgY(3, 0, BG_COORD_SET);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, WIN_RANGE(0, DISPLAY_WIDTH));
|
||||
SetGpuReg(REG_OFFSET_WIN0V, WIN_RANGE(26, 152));
|
||||
SetGpuReg(REG_OFFSET_WININ, WININ_WIN0_BG_ALL | WININ_WIN0_OBJ);
|
||||
SetGpuReg(REG_OFFSET_WINOUT, WINOUT_WIN01_BG0 | WINOUT_WIN01_BG1 | WINOUT_WIN01_BG3 | WINOUT_WIN01_OBJ);
|
||||
@@ -129,26 +163,26 @@ s32 FadeToWonderNewsMenu(void)
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
CopyBgTilemapBufferToVram(2);
|
||||
CopyBgTilemapBufferToVram(3);
|
||||
DecompressAndCopyTileDataToVram(3, sWork->bgSpec->tiles, 0, 8, 0);
|
||||
sWork->windowIds[0] = AddWindow(&gUnknown_8468040[0]);
|
||||
sWork->windowIds[1] = AddWindow(&gUnknown_8468040[1]);
|
||||
DecompressAndCopyTileDataToVram(3, sWonderNewsData->gfx->tiles, 0, 8, 0);
|
||||
sWonderNewsData->windowIds[WIN_TITLE] = AddWindow(&sWindowTemplates[WIN_TITLE]);
|
||||
sWonderNewsData->windowIds[WIN_BODY] = AddWindow(&sWindowTemplates[WIN_BODY]);
|
||||
break;
|
||||
case 3:
|
||||
if (FreeTempTileDataBuffersIfPossible())
|
||||
return 0;
|
||||
gPaletteFade.bufferTransferDisabled = TRUE;
|
||||
LoadPalette(sWork->bgSpec->pal, 0x10, 0x20);
|
||||
LZ77UnCompWram(sWork->bgSpec->map, sWork->buffer_03A4);
|
||||
CopyRectToBgTilemapBufferRect(1, sWork->buffer_03A4, 0, 0, 30, 3, 0, 0, 30, 3, 1, 8, 0);
|
||||
CopyRectToBgTilemapBufferRect(3, sWork->buffer_03A4, 0, 3, 30, 23, 0, 3, 30, 23, 1, 8, 0);
|
||||
LoadPalette(sWonderNewsData->gfx->pal, 0x10, 0x20);
|
||||
LZ77UnCompWram(sWonderNewsData->gfx->map, sWonderNewsData->bgTilemapBuffer);
|
||||
CopyRectToBgTilemapBufferRect(1, sWonderNewsData->bgTilemapBuffer, 0, 0, 30, 3, 0, 0, 30, 3, 1, 8, 0);
|
||||
CopyRectToBgTilemapBufferRect(3, sWonderNewsData->bgTilemapBuffer, 0, 3, 30, 23, 0, 3, 30, 23, 1, 8, 0);
|
||||
CopyBgTilemapBufferToVram(1);
|
||||
CopyBgTilemapBufferToVram(3);
|
||||
break;
|
||||
case 4:
|
||||
sub_8146980();
|
||||
BufferNewsText();
|
||||
break;
|
||||
case 5:
|
||||
sub_8146A30();
|
||||
DrawNewsWindows();
|
||||
CopyBgTilemapBufferToVram(0);
|
||||
CopyBgTilemapBufferToVram(2);
|
||||
break;
|
||||
@@ -157,26 +191,26 @@ s32 FadeToWonderNewsMenu(void)
|
||||
ShowBg(2);
|
||||
ShowBg(3);
|
||||
gPaletteFade.bufferTransferDisabled = FALSE;
|
||||
sWork->menuIndicatorsId = AddScrollIndicatorArrowPair(&sWork->scrollArrowsTemplate, &sWork->scrollOffset);
|
||||
sWonderNewsData->arrowTaskId = AddScrollIndicatorArrowPair(&sWonderNewsData->arrowsTemplate, &sWonderNewsData->scrollOffset);
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
|
||||
UpdatePaletteFade();
|
||||
break;
|
||||
default:
|
||||
if (UpdatePaletteFade())
|
||||
return 0;
|
||||
sWork->state = 0;
|
||||
sWonderNewsData->enterExitState = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
++sWork->state;
|
||||
sWonderNewsData->enterExitState++;
|
||||
return 0;
|
||||
}
|
||||
|
||||
s32 FadeOutFromWonderNews(bool32 flag)
|
||||
s32 WonderNews_Exit(bool32 useCancel)
|
||||
{
|
||||
if (sWork == NULL)
|
||||
if (sWonderNewsData == NULL)
|
||||
return -1;
|
||||
switch (sWork->state)
|
||||
switch (sWonderNewsData->enterExitState)
|
||||
{
|
||||
case 0:
|
||||
BeginNormalPaletteFade(PALETTES_ALL, 0, 0, 16, RGB_BLACK);
|
||||
@@ -184,7 +218,7 @@ s32 FadeOutFromWonderNews(bool32 flag)
|
||||
case 1:
|
||||
if (UpdatePaletteFade())
|
||||
return 0;
|
||||
ChangeBgY(2, 0, 0);
|
||||
ChangeBgY(2, 0, BG_COORD_SET);
|
||||
SetGpuReg(REG_OFFSET_WIN0H, 0);
|
||||
SetGpuReg(REG_OFFSET_WIN0V, 0);
|
||||
SetGpuReg(REG_OFFSET_WININ, 0);
|
||||
@@ -204,20 +238,20 @@ s32 FadeOutFromWonderNews(bool32 flag)
|
||||
case 3:
|
||||
HideBg(1);
|
||||
HideBg(2);
|
||||
RemoveWindow(sWork->windowIds[1]);
|
||||
RemoveWindow(sWork->windowIds[0]);
|
||||
RemoveWindow(sWonderNewsData->windowIds[WIN_BODY]);
|
||||
RemoveWindow(sWonderNewsData->windowIds[WIN_TITLE]);
|
||||
break;
|
||||
case 4:
|
||||
ChangeBgY(2, 0, 0);
|
||||
ChangeBgY(3, 0, 0);
|
||||
if (sWork->menuIndicatorsId != 0xFF)
|
||||
ChangeBgY(2, 0, BG_COORD_SET);
|
||||
ChangeBgY(3, 0, BG_COORD_SET);
|
||||
if (sWonderNewsData->arrowTaskId != TASK_NONE)
|
||||
{
|
||||
RemoveScrollIndicatorArrowPair(sWork->menuIndicatorsId);
|
||||
sWork->menuIndicatorsId = 0xFF;
|
||||
RemoveScrollIndicatorArrowPair(sWonderNewsData->arrowTaskId);
|
||||
sWonderNewsData->arrowTaskId = TASK_NONE;
|
||||
}
|
||||
break;
|
||||
case 5:
|
||||
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, flag);
|
||||
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, useCancel);
|
||||
break;
|
||||
case 6:
|
||||
MG_DrawCheckerboardPattern();
|
||||
@@ -228,130 +262,143 @@ s32 FadeOutFromWonderNews(bool32 flag)
|
||||
default:
|
||||
if (UpdatePaletteFade())
|
||||
return 0;
|
||||
sWork->state = 0;
|
||||
sWonderNewsData->enterExitState = 0;
|
||||
return 1;
|
||||
}
|
||||
++sWork->state;
|
||||
++sWonderNewsData->enterExitState;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MENews_RemoveScrollIndicatorArrowPair(void)
|
||||
void WonderNews_RemoveScrollIndicatorArrowPair(void)
|
||||
{
|
||||
if (!sWork->verticalScrollDisabled && sWork->menuIndicatorsId != 0xFF)
|
||||
if (!sWonderNewsData->verticalScrollDisabled && sWonderNewsData->arrowTaskId != TASK_NONE)
|
||||
{
|
||||
RemoveScrollIndicatorArrowPair(sWork->menuIndicatorsId);
|
||||
sWork->menuIndicatorsId = 0xFF;
|
||||
sWork->verticalScrollDisabled = TRUE;
|
||||
RemoveScrollIndicatorArrowPair(sWonderNewsData->arrowTaskId);
|
||||
sWonderNewsData->arrowTaskId = TASK_NONE;
|
||||
sWonderNewsData->verticalScrollDisabled = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MENews_AddScrollIndicatorArrowPair(void)
|
||||
void WonderNews_AddScrollIndicatorArrowPair(void)
|
||||
{
|
||||
if (sWork->verticalScrollDisabled)
|
||||
if (sWonderNewsData->verticalScrollDisabled)
|
||||
{
|
||||
sWork->menuIndicatorsId = AddScrollIndicatorArrowPair(&sWork->scrollArrowsTemplate, &sWork->scrollOffset);
|
||||
sWork->verticalScrollDisabled = FALSE;
|
||||
sWonderNewsData->arrowTaskId = AddScrollIndicatorArrowPair(&sWonderNewsData->arrowsTemplate, &sWonderNewsData->scrollOffset);
|
||||
sWonderNewsData->verticalScrollDisabled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
u32 MENews_GetInput(u16 input)
|
||||
u32 WonderNews_GetInput(u16 input)
|
||||
{
|
||||
if (sWork->unk_01C2_0)
|
||||
if (sWonderNewsData->scrolling)
|
||||
{
|
||||
sub_8146B58();
|
||||
return 0xFF;
|
||||
UpdateNewsScroll();
|
||||
return NEWS_INPUT_NONE;
|
||||
}
|
||||
switch (input)
|
||||
{
|
||||
case A_BUTTON:
|
||||
return 0;
|
||||
return NEWS_INPUT_A;
|
||||
case B_BUTTON:
|
||||
return 1;
|
||||
return NEWS_INPUT_B;
|
||||
case DPAD_UP:
|
||||
if (sWork->scrollOffset == 0)
|
||||
return 0xFF;
|
||||
if (sWork->verticalScrollDisabled)
|
||||
return 0xFF;
|
||||
sWork->scrollDirection = FALSE;
|
||||
if (sWonderNewsData->scrollOffset == 0)
|
||||
return NEWS_INPUT_NONE;
|
||||
if (sWonderNewsData->verticalScrollDisabled)
|
||||
return NEWS_INPUT_NONE;
|
||||
sWonderNewsData->scrollingDown = FALSE;
|
||||
break;
|
||||
case DPAD_DOWN:
|
||||
if (sWork->scrollOffset == sWork->numMails)
|
||||
return 0xFF;
|
||||
if (sWork->verticalScrollDisabled)
|
||||
return 0xFF;
|
||||
sWork->scrollDirection = TRUE;
|
||||
if (sWonderNewsData->scrollOffset == sWonderNewsData->scrollEnd)
|
||||
return NEWS_INPUT_NONE;
|
||||
if (sWonderNewsData->verticalScrollDisabled)
|
||||
return NEWS_INPUT_NONE;
|
||||
sWonderNewsData->scrollingDown = TRUE;
|
||||
break;
|
||||
default:
|
||||
return 0xFF;
|
||||
return NEWS_INPUT_NONE;
|
||||
}
|
||||
sWork->unk_01C2_0 = TRUE;
|
||||
sWork->unk_01C2_1 = 2;
|
||||
sWork->unk_01C3_1 = 0;
|
||||
if (sWork->scrollDirection == FALSE)
|
||||
return 2;
|
||||
|
||||
// Init scroll
|
||||
sWonderNewsData->scrolling = TRUE;
|
||||
sWonderNewsData->scrollIncrement = 2;
|
||||
sWonderNewsData->scrollTotal = 0;
|
||||
if (!sWonderNewsData->scrollingDown)
|
||||
return NEWS_INPUT_SCROLL_UP;
|
||||
else
|
||||
return 3;
|
||||
return NEWS_INPUT_SCROLL_DOWN;
|
||||
}
|
||||
|
||||
static void sub_8146980(void)
|
||||
static void BufferNewsText(void)
|
||||
{
|
||||
u8 i = 0;
|
||||
memcpy(sWork->title, sWork->wonderNews.titleText, 40);
|
||||
sWork->title[40] = EOS;
|
||||
for (; i < 10; ++i)
|
||||
|
||||
// Copy title text
|
||||
memcpy(sWonderNewsData->titleText, sWonderNewsData->news.titleText, WONDER_NEWS_TEXT_LENGTH);
|
||||
sWonderNewsData->titleText[WONDER_NEWS_TEXT_LENGTH] = EOS;
|
||||
|
||||
// Copy body text
|
||||
for (; i < WONDER_NEWS_BODY_TEXT_LINES; i++)
|
||||
{
|
||||
memcpy(sWork->messages[i], sWork->wonderNews.bodyText[i], 40);
|
||||
sWork->messages[i][40] = EOS;
|
||||
if (i > 7 && sWork->messages[i][0] != EOS)
|
||||
++sWork->numMails;
|
||||
memcpy(sWonderNewsData->bodyText[i], sWonderNewsData->news.bodyText[i], WONDER_NEWS_TEXT_LENGTH);
|
||||
sWonderNewsData->bodyText[i][WONDER_NEWS_TEXT_LENGTH] = EOS;
|
||||
if (i > 7 && sWonderNewsData->bodyText[i][0] != EOS)
|
||||
sWonderNewsData->scrollEnd++;
|
||||
}
|
||||
sWork->scrollArrowsTemplate = sScrollArrowsTemplate;
|
||||
sWork->scrollArrowsTemplate.fullyDownThreshold = sWork->numMails;
|
||||
sWonderNewsData->arrowsTemplate = sArrowsTemplate;
|
||||
sWonderNewsData->arrowsTemplate.fullyDownThreshold = sWonderNewsData->scrollEnd;
|
||||
}
|
||||
|
||||
static void sub_8146A30(void)
|
||||
static void DrawNewsWindows(void)
|
||||
{
|
||||
u8 i = 0;
|
||||
s32 x;
|
||||
PutWindowTilemap(sWork->windowIds[0]);
|
||||
PutWindowTilemap(sWork->windowIds[1]);
|
||||
FillWindowPixelBuffer(sWork->windowIds[0], 0);
|
||||
FillWindowPixelBuffer(sWork->windowIds[1], 0);
|
||||
x = (0xe0 - GetStringWidth(FONT_3, sWork->title, GetFontAttribute(FONT_3, FONTATTR_LETTER_SPACING))) / 2;
|
||||
PutWindowTilemap(sWonderNewsData->windowIds[WIN_TITLE]);
|
||||
PutWindowTilemap(sWonderNewsData->windowIds[WIN_BODY]);
|
||||
FillWindowPixelBuffer(sWonderNewsData->windowIds[WIN_TITLE], 0);
|
||||
FillWindowPixelBuffer(sWonderNewsData->windowIds[WIN_BODY], 0);
|
||||
|
||||
// Print title text
|
||||
x = (224 - GetStringWidth(FONT_3, sWonderNewsData->titleText, GetFontAttribute(FONT_3, FONTATTR_LETTER_SPACING))) / 2;
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
AddTextPrinterParameterized3(sWork->windowIds[0], FONT_3, x, 6, sTextPals[sWork->bgSpec->textPal1], 0, sWork->title);
|
||||
for (; i < 10; ++i)
|
||||
AddTextPrinterParameterized3(sWonderNewsData->windowIds[WIN_TITLE], FONT_3, x, 6, sTextColorTable[sWonderNewsData->gfx->textPal1], 0, sWonderNewsData->titleText);
|
||||
|
||||
// Print body text
|
||||
for (; i < WONDER_NEWS_BODY_TEXT_LINES; ++i)
|
||||
{
|
||||
AddTextPrinterParameterized3(sWork->windowIds[1], FONT_3, 0, 16 * i + 2, sTextPals[sWork->bgSpec->textPal2], 0, sWork->messages[i]);
|
||||
AddTextPrinterParameterized3(sWonderNewsData->windowIds[WIN_BODY], FONT_3, 0,
|
||||
16 * i + 2,
|
||||
sTextColorTable[sWonderNewsData->gfx->textPal2],
|
||||
0, sWonderNewsData->bodyText[i]);
|
||||
}
|
||||
CopyWindowToVram(sWork->windowIds[0], COPYWIN_FULL);
|
||||
CopyWindowToVram(sWork->windowIds[1], COPYWIN_FULL);
|
||||
CopyWindowToVram(sWonderNewsData->windowIds[WIN_TITLE], COPYWIN_FULL);
|
||||
CopyWindowToVram(sWonderNewsData->windowIds[WIN_BODY], COPYWIN_FULL);
|
||||
}
|
||||
|
||||
static void sub_8146B58(void)
|
||||
static void UpdateNewsScroll(void)
|
||||
{
|
||||
u16 r4 = sWork->unk_01C2_1;
|
||||
r4 <<= 8;
|
||||
if (sWork->scrollDirection)
|
||||
u16 bgMove = sWonderNewsData->scrollIncrement;
|
||||
bgMove *= 256;
|
||||
if (sWonderNewsData->scrollingDown)
|
||||
{
|
||||
ChangeBgY(2, r4, 1);
|
||||
ChangeBgY(3, r4, 1);
|
||||
ChangeBgY(2, bgMove, BG_COORD_ADD);
|
||||
ChangeBgY(3, bgMove, BG_COORD_ADD);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChangeBgY(2, r4, 2);
|
||||
ChangeBgY(3, r4, 2);
|
||||
ChangeBgY(2, bgMove, BG_COORD_SUB);
|
||||
ChangeBgY(3, bgMove, BG_COORD_SUB);
|
||||
}
|
||||
sWork->unk_01C3_1 += sWork->unk_01C2_1;
|
||||
if (sWork->unk_01C3_1 > 15)
|
||||
sWonderNewsData->scrollTotal += sWonderNewsData->scrollIncrement;
|
||||
if (sWonderNewsData->scrollTotal > 15)
|
||||
{
|
||||
if (sWork->scrollDirection)
|
||||
++sWork->scrollOffset;
|
||||
if (sWonderNewsData->scrollingDown)
|
||||
sWonderNewsData->scrollOffset++;
|
||||
else
|
||||
--sWork->scrollOffset;
|
||||
sWork->unk_01C2_0 = FALSE;
|
||||
sWork->unk_01C3_1 = 0;
|
||||
sWonderNewsData->scrollOffset--;
|
||||
sWonderNewsData->scrolling = FALSE;
|
||||
sWonderNewsData->scrollTotal = 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user