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