Merge remote-tracking branch 'pret/master' into RHH/sync/pret_20230214

# Conflicts:
#	data/battle_ai_scripts.s
#	src/menu_specialized.c
#	src/mystery_gift_menu.c
This commit is contained in:
Eduardo Quezada 2023-02-15 14:18:00 -03:00
commit 7ddebb6671
29 changed files with 738 additions and 633 deletions

View File

@ -15,6 +15,15 @@ enum {
MAILBOXWIN_COUNT
};
// Window IDs for the move relearner
enum {
RELEARNERWIN_DESC_BATTLE,
RELEARNERWIN_DESC_CONTEST,
RELEARNERWIN_MOVE_LIST,
RELEARNERWIN_MSG,
RELEARNERWIN_YESNO,
};
enum {
TAG_CONDITION_MON = 100,
TAG_CONDITION_BALL,
@ -117,11 +126,11 @@ void DestroyConditionSparkleSprites(struct Sprite **sprites);
void FreeConditionSparkles(struct Sprite **sprites);
// Move relearner
void MoveRelearnerPrintText(u8 *str);
void MoveRelearnerPrintMessage(u8 *str);
bool16 MoveRelearnerRunTextPrinters(void);
void MoveRelearnerCreateYesNoMenu(void);
u8 LoadMoveRelearnerMovesList(const struct ListMenuItem *items, u16 numChoices);
void InitMoveRelearnerWindows(bool8 useContextWindow);
void InitMoveRelearnerWindows(bool8 useContestWindow);
// Level up window
void DrawLevelUpWindowPg1(u16 windowId, u16 *statsBefore, u16 *statsAfter, u8 bgClr, u8 fgClr, u8 shadowClr);

View File

@ -5,11 +5,11 @@ extern bool8 gGiftIsFromEReader;
u16 GetMysteryGiftBaseBlock(void);
void CB2_MysteryGiftEReader(void);
void PrintMysteryGiftOrEReaderTopMenu(bool8 isJapanese, bool32 usePickOkCancel);
void PrintMysteryGiftOrEReaderHeader(bool8 isJapanese, bool32 usePickOkCancel);
void MG_DrawCheckerboardPattern(u32 bg);
void MainCB_FreeAllBuffersAndReturnToInitTitleScreen(void);
bool32 PrintMysteryGiftMenuMessage(u8 *textState, const u8 *str);
void AddTextPrinterToWindow1(const u8 *src);
void MG_AddMessageTextPrinter(const u8 *src);
void CB2_InitEReader(void);
void CB2_InitMysteryGift(void);
void MG_DrawTextBorder(u8 windowId);

View File

@ -21,7 +21,8 @@ enum {
MAPSECTYPE_ROUTE,
MAPSECTYPE_CITY_CANFLY,
MAPSECTYPE_CITY_CANTFLY,
MAPSECTYPE_BATTLE_FRONTIER
MAPSECTYPE_BATTLE_FRONTIER,
NUM_MAPSEC_TYPES
};
struct RegionMap {

View File

@ -73,9 +73,33 @@ struct TourneyTreeLineSection
#define tMode data[2]
#define tPrevTaskId data[3]
#define EFFECTIVENESS_MODE_GOOD 0
#define EFFECTIVENESS_MODE_BAD 1
#define EFFECTIVENESS_MODE_AI_VS_AI 2
enum {
EFFECTIVENESS_MODE_GOOD,
EFFECTIVENESS_MODE_BAD,
EFFECTIVENESS_MODE_AI_VS_AI,
};
// Window IDs for the tourney tree
enum {
TOURNEYWIN_NAMES_LEFT,
TOURNEYWIN_NAMES_RIGHT,
TOURNEYWIN_TITLE,
};
// Window IDs for the trainer (WIN_TRAINER_*) and match (WIN_MATCH_*) info cards.
// All 9 have a duplicate window at WIN + NUM_INFO_CARD_WINDOWS used by the alternate info card
enum {
WIN_TRAINER_NAME,
WIN_TRAINER_MON1_NAME,
WIN_TRAINER_MON2_NAME, // Used implicitly
WIN_TRAINER_MON3_NAME, // Used implicitly
WIN_TRAINER_FLAVOR_TEXT = WIN_TRAINER_MON1_NAME + FRONTIER_PARTY_SIZE, // Trainer's potential, battle style, and stat texts
WIN_MATCH_NUMBER,
WIN_MATCH_TRAINER_NAME_LEFT,
WIN_MATCH_TRAINER_NAME_RIGHT,
WIN_MATCH_WIN_TEXT,
NUM_INFO_CARD_WINDOWS
};
static u8 GetDomeTrainerMonIvs(u16);
static void SwapDomeTrainers(int, int, u16 *);
@ -670,7 +694,7 @@ static const struct BgTemplate sInfoCardBgTemplates[4] =
static const struct WindowTemplate sTourneyTreeWindowTemplates[] =
{
{
[TOURNEYWIN_NAMES_LEFT] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 3,
@ -679,7 +703,7 @@ static const struct WindowTemplate sTourneyTreeWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 16,
},
{
[TOURNEYWIN_NAMES_RIGHT] = {
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 3,
@ -688,7 +712,7 @@ static const struct WindowTemplate sTourneyTreeWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 144,
},
{
[TOURNEYWIN_TITLE] = {
.bg = 0,
.tilemapLeft = 8,
.tilemapTop = 1,
@ -702,7 +726,7 @@ static const struct WindowTemplate sTourneyTreeWindowTemplates[] =
static const struct WindowTemplate sInfoCardWindowTemplates[] =
{
{
[WIN_TRAINER_NAME] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 2,
@ -711,7 +735,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 1,
},
{
[WIN_TRAINER_MON1_NAME] = {
.bg = 0,
.tilemapLeft = 16,
.tilemapTop = 5,
@ -720,7 +744,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 53,
},
{
[WIN_TRAINER_MON2_NAME] = {
.bg = 0,
.tilemapLeft = 19,
.tilemapTop = 7,
@ -729,7 +753,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 69,
},
{
[WIN_TRAINER_MON3_NAME] = {
.bg = 0,
.tilemapLeft = 16,
.tilemapTop = 10,
@ -738,7 +762,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 96,
},
{
[WIN_TRAINER_FLAVOR_TEXT] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 12,
@ -747,7 +771,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 112,
},
{
[WIN_MATCH_NUMBER] = {
.bg = 0,
.tilemapLeft = 5,
.tilemapTop = 2,
@ -756,7 +780,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 294,
},
{
[WIN_MATCH_TRAINER_NAME_LEFT] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 5,
@ -765,7 +789,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 340,
},
{
[WIN_MATCH_TRAINER_NAME_RIGHT] = {
.bg = 0,
.tilemapLeft = 20,
.tilemapTop = 5,
@ -774,7 +798,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 356,
},
{
[WIN_MATCH_WIN_TEXT] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 16,
@ -783,7 +807,9 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 372,
},
{
// Duplicate windows used by the alternate info card
// Same as above but on bg 1 instead of bg 0
[WIN_TRAINER_NAME + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 2,
.tilemapTop = 2,
@ -792,7 +818,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 1,
},
{
[WIN_TRAINER_MON1_NAME + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 16,
.tilemapTop = 5,
@ -801,7 +827,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 53,
},
{
[WIN_TRAINER_MON2_NAME + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 19,
.tilemapTop = 7,
@ -810,7 +836,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 69,
},
{
[WIN_TRAINER_MON3_NAME + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 16,
.tilemapTop = 10,
@ -819,7 +845,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 96,
},
{
[WIN_TRAINER_FLAVOR_TEXT + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 2,
.tilemapTop = 12,
@ -828,7 +854,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 112,
},
{
[WIN_MATCH_NUMBER + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 5,
.tilemapTop = 2,
@ -837,7 +863,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 294,
},
{
[WIN_MATCH_TRAINER_NAME_LEFT + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 2,
.tilemapTop = 5,
@ -846,7 +872,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 340,
},
{
[WIN_MATCH_TRAINER_NAME_RIGHT + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 20,
.tilemapTop = 5,
@ -855,7 +881,7 @@ static const struct WindowTemplate sInfoCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 356,
},
{
[WIN_MATCH_WIN_TEXT + NUM_INFO_CARD_WINDOWS] = {
.bg = 1,
.tilemapLeft = 2,
.tilemapTop = 16,
@ -1397,26 +1423,27 @@ static const u8 sCompetitorRangeByMatch[DOME_TOURNAMENT_MATCHES_COUNT][3] =
{ NUM_POSSIBLE_MATCH_TRAINERS(DOME_FINAL) * 0, NUM_POSSIBLE_MATCH_TRAINERS(DOME_FINAL), DOME_FINAL},
};
// 1st value is the windowId (0 for left column, 1 for right column)
// 2nd value is the y coord
#define NAME_ROW_HEIGHT 16
// 1st value is the windowId, 2nd value is the y coord
static const u8 sTrainerNamePositions[DOME_TOURNAMENT_TRAINERS_COUNT][2] =
{
{ 0, 0},
{ 1, 112},
{ 1, 0},
{ 0, 112},
{ 0, 48},
{ 1, 64},
{ 1, 48},
{ 0, 64},
{ 0, 16},
{ 1, 96},
{ 1, 16},
{ 0, 96},
{ 0, 32},
{ 1, 80},
{ 1, 32},
{ 0, 80},
{ TOURNEYWIN_NAMES_LEFT, 0 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_RIGHT, 7 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_RIGHT, 0 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_LEFT, 7 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_LEFT, 3 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_RIGHT, 4 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_RIGHT, 3 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_LEFT, 4 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_LEFT, 1 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_RIGHT, 6 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_RIGHT, 1 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_LEFT, 6 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_LEFT, 2 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_RIGHT, 5 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_RIGHT, 2 * NAME_ROW_HEIGHT},
{ TOURNEYWIN_NAMES_LEFT, 5 * NAME_ROW_HEIGHT},
};
// Coords for the pokeballs on the tourney tree that act as buttons to view trainer/match info
@ -2427,7 +2454,7 @@ static void InitDomeTrainers(void)
break;
}
if (sTrainerNamePositions[i][0] != 0)
if (sTrainerNamePositions[i][0] != TOURNEYWIN_NAMES_LEFT)
{
j = 0;
DOME_TRAINERS[j].trainerId = TRAINER_FRONTIER_BRAIN;
@ -3420,11 +3447,11 @@ static void Task_HandleInfoCardInput(u8 taskId)
case MATCHCARD_INPUT_UP ... MATCHCARD_INPUT_RIGHT:
gTasks[taskId].data[5] = i;
if (gTasks[taskId].tUsingAlternateSlot)
windowId = 9;
windowId = NUM_INFO_CARD_WINDOWS;
else
windowId = 0;
for (i = windowId; i < windowId + 9; i++)
for (i = windowId; i < windowId + NUM_INFO_CARD_WINDOWS; i++)
{
CopyWindowToVram(i, COPYWIN_GFX);
FillWindowPixelBuffer(i, PIXEL_FILL(0));
@ -4246,14 +4273,14 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
int trainerId = 0;
u8 nature = 0;
int arrId = 0;
int windowId = 0;
int windowId = WIN_TRAINER_NAME;
int x = 0, y = 0;
u8 palSlot = 0;
s16 *allocatedArray = AllocZeroed(sizeof(s16) * ALLOC_ARRAY_SIZE);
trainerId = DOME_TRAINERS[trainerTourneyId].trainerId;
if (flags & CARD_ALTERNATE_SLOT)
arrId = 2 * (FRONTIER_PARTY_SIZE + 1), windowId = 9, palSlot = 2;
arrId = 2 * (FRONTIER_PARTY_SIZE + 1), windowId = WIN_TRAINER_NAME + NUM_INFO_CARD_WINDOWS, palSlot = 2;
if (flags & MOVE_CARD_RIGHT)
x = DISPLAY_WIDTH + 16;
if (flags & MOVE_CARD_DOWN)
@ -4371,19 +4398,19 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
else
textPrinter.currentChar = gSpeciesNames[gFacilityTrainerMons[DOME_MONS[trainerTourneyId][i]].species];
textPrinter.windowId = 1 + i + windowId;
textPrinter.windowId = WIN_TRAINER_MON1_NAME + i + windowId;
if (i == 1)
textPrinter.currentX = 7;
else
textPrinter.currentX = 0;
PutWindowTilemap(1 + i + windowId);
CopyWindowToVram(1 + i + windowId, COPYWIN_FULL);
PutWindowTilemap(WIN_TRAINER_MON1_NAME + i + windowId);
CopyWindowToVram(WIN_TRAINER_MON1_NAME + i + windowId, COPYWIN_FULL);
AddTextPrinter(&textPrinter, 0, NULL);
}
PutWindowTilemap(windowId + 4);
CopyWindowToVram(windowId + 4, COPYWIN_FULL);
PutWindowTilemap(windowId + WIN_TRAINER_FLAVOR_TEXT);
CopyWindowToVram(windowId + WIN_TRAINER_FLAVOR_TEXT, COPYWIN_FULL);
// Print text about trainers potential in the tourney
if (trainerId == TRAINER_FRONTIER_BRAIN)
@ -4392,7 +4419,7 @@ static void DisplayTrainerInfoOnCard(u8 flags, u8 trainerTourneyId)
textPrinter.currentChar = sBattleDomePotentialTexts[trainerTourneyId];
textPrinter.fontId = FONT_NORMAL;
textPrinter.windowId = windowId + 4;
textPrinter.windowId = windowId + WIN_TRAINER_FLAVOR_TEXT;
textPrinter.currentX = 0;
textPrinter.y = 4;
textPrinter.currentY = 4;
@ -4713,7 +4740,7 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo)
u8 palSlot = 0;
if (flags & CARD_ALTERNATE_SLOT)
arrId = 2 * (FRONTIER_PARTY_SIZE + 1), windowId = 9, palSlot = 2;
arrId = 2 * (FRONTIER_PARTY_SIZE + 1), windowId = NUM_INFO_CARD_WINDOWS, palSlot = 2;
if (flags & MOVE_CARD_RIGHT)
x = DISPLAY_WIDTH + 16;
if (flags & MOVE_CARD_DOWN)
@ -4855,10 +4882,10 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo)
textPrinter.shadowColor = TEXT_DYNAMIC_COLOR_4;
StringExpandPlaceholders(gStringVar4, sBattleDomeWinTexts[winStringId]);
textPrinter.currentChar = gStringVar4;
textPrinter.windowId = windowId + 8;
textPrinter.windowId = windowId + WIN_MATCH_WIN_TEXT;
textPrinter.fontId = FONT_NORMAL;
PutWindowTilemap(windowId + 8);
CopyWindowToVram(windowId + 8, COPYWIN_FULL);
PutWindowTilemap(windowId + WIN_MATCH_WIN_TEXT);
CopyWindowToVram(windowId + WIN_MATCH_WIN_TEXT, COPYWIN_FULL);
textPrinter.currentX = 0;
textPrinter.currentY = textPrinter.y = 0;
AddTextPrinter(&textPrinter, 0, NULL);
@ -4874,11 +4901,11 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo)
textPrinter.fontId = FONT_SHORT;
textPrinter.letterSpacing = 2;
textPrinter.currentChar = gStringVar1;
textPrinter.windowId = windowId + 6;
textPrinter.windowId = windowId + WIN_MATCH_TRAINER_NAME_LEFT;
textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0x40, textPrinter.letterSpacing);
textPrinter.currentY = textPrinter.y = 2;
PutWindowTilemap(windowId + 6);
CopyWindowToVram(windowId + 6, COPYWIN_FULL);
PutWindowTilemap(windowId + WIN_MATCH_TRAINER_NAME_LEFT);
CopyWindowToVram(windowId + WIN_MATCH_TRAINER_NAME_LEFT, COPYWIN_FULL);
AddTextPrinter(&textPrinter, 0, NULL);
// Print right trainer's name.
@ -4890,21 +4917,21 @@ static void DisplayMatchInfoOnCard(u8 flags, u8 matchNo)
CopyDomeTrainerName(gStringVar1, trainerIds[1]);
textPrinter.currentChar = gStringVar1;
textPrinter.windowId = windowId + 7;
textPrinter.windowId = windowId + WIN_MATCH_TRAINER_NAME_RIGHT;
textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0x40, textPrinter.letterSpacing);
textPrinter.currentY = textPrinter.y = 2;
PutWindowTilemap(windowId + 7);
CopyWindowToVram(windowId + 7, COPYWIN_FULL);
PutWindowTilemap(windowId + WIN_MATCH_TRAINER_NAME_RIGHT);
CopyWindowToVram(windowId + WIN_MATCH_TRAINER_NAME_RIGHT, COPYWIN_FULL);
AddTextPrinter(&textPrinter, 0, NULL);
// Print match number.
textPrinter.letterSpacing = 0;
textPrinter.currentChar = sBattleDomeMatchNumberTexts[matchNo];
textPrinter.windowId = windowId + 5;
textPrinter.windowId = windowId + WIN_MATCH_NUMBER;
textPrinter.currentX = GetStringCenterAlignXOffsetWithLetterSpacing(textPrinter.fontId, textPrinter.currentChar, 0xA0, textPrinter.letterSpacing);
textPrinter.currentY = textPrinter.y = 2;
PutWindowTilemap(windowId + 5);
CopyWindowToVram(windowId + 5, COPYWIN_FULL);
PutWindowTilemap(windowId + WIN_MATCH_NUMBER);
CopyWindowToVram(windowId + WIN_MATCH_NUMBER, COPYWIN_FULL);
AddTextPrinter(&textPrinter, 0, NULL);
}
@ -5338,7 +5365,7 @@ static void Task_ShowTourneyTree(u8 taskId)
case 4:
textPrinter.fontId = FONT_SHORT;
textPrinter.currentChar = gText_BattleTourney;
textPrinter.windowId = 2;
textPrinter.windowId = TOURNEYWIN_TITLE;
textPrinter.x = 0;
textPrinter.y = 0;
textPrinter.letterSpacing = 2;
@ -5424,7 +5451,7 @@ static void Task_ShowTourneyTree(u8 taskId)
}
}
if (sTrainerNamePositions[i][0] == 0)
if (sTrainerNamePositions[i][0] == TOURNEYWIN_NAMES_LEFT)
textPrinter.currentX = GetStringWidthDifference(textPrinter.fontId, gDisplayedStringBattle, 0x3D, textPrinter.letterSpacing);
else
textPrinter.currentX = 3;
@ -5436,12 +5463,12 @@ static void Task_ShowTourneyTree(u8 taskId)
gTasks[taskId].tState++;
break;
case 5:
PutWindowTilemap(0);
PutWindowTilemap(1);
PutWindowTilemap(2);
CopyWindowToVram(0, COPYWIN_FULL);
CopyWindowToVram(1, COPYWIN_FULL);
CopyWindowToVram(2, COPYWIN_FULL);
PutWindowTilemap(TOURNEYWIN_NAMES_LEFT);
PutWindowTilemap(TOURNEYWIN_NAMES_RIGHT);
PutWindowTilemap(TOURNEYWIN_TITLE);
CopyWindowToVram(TOURNEYWIN_NAMES_LEFT, COPYWIN_FULL);
CopyWindowToVram(TOURNEYWIN_NAMES_RIGHT, COPYWIN_FULL);
CopyWindowToVram(TOURNEYWIN_TITLE, COPYWIN_FULL);
SetHBlankCallback(HblankCb_TourneyTree);
SetVBlankCallback(VblankCb_TourneyTree);
if (r4 == 2)
@ -5538,7 +5565,7 @@ static void Task_HandleStaticTourneyTreeInput(u8 taskId)
if (DOME_TRAINERS[i].eliminatedAt == gSaveBlock2Ptr->frontier.curChallengeBattleNum - 1
&& DOME_TRAINERS[i].isEliminated)
{
if (sTrainerNamePositions[i][0] == 0)
if (sTrainerNamePositions[i][0] == TOURNEYWIN_NAMES_LEFT)
textPrinter.currentX = GetStringWidthDifference(textPrinter.fontId, gDisplayedStringBattle, 0x3D, textPrinter.letterSpacing);
else
textPrinter.currentX = 3;

View File

@ -106,6 +106,13 @@ enum {
// Last berry that an NPC can put in
#define NUM_NPC_BERRIES ITEM_TO_BERRY(ITEM_ASPEAR_BERRY)
enum {
// Windows 0-3 are used implicitly in several loops over BLENDER_MAX_PLAYERS
// i.e. window 0 is for player 1, window 1 for player 2, etc.
WIN_MSG = BLENDER_MAX_PLAYERS,
WIN_RESULTS,
};
struct BlenderBerry
{
u16 itemId;
@ -200,7 +207,7 @@ static void SpriteCB_ScoreSymbolBest(struct Sprite *);
static void InitLocalPlayers(u8);
static void CB2_LoadBerryBlender(void);
static void UpdateBlenderCenter(void);
static bool32 Blender_PrintText(s16 *, const u8 *, s32 );
static bool32 PrintMessage(s16 *, const u8 *, s32 );
static void StartBlender(void);
static void CB2_StartBlenderLink(void);
static void CB2_StartBlenderLocal(void);
@ -332,7 +339,7 @@ static const struct BgTemplate sBgTemplates[3] =
static const struct WindowTemplate sWindowTemplates[] =
{
{
{ // Player 1
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 6,
@ -341,7 +348,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 14,
.baseBlock = 0x28,
},
{
{ // Player 2
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 6,
@ -350,7 +357,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 14,
.baseBlock = 0x36,
},
{
{ // Player 3
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 12,
@ -359,7 +366,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 14,
.baseBlock = 0x44,
},
{
{ // Player 4
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 12,
@ -368,7 +375,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 14,
.baseBlock = 0x52,
},
{
[WIN_MSG] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 15,
@ -377,7 +384,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 14,
.baseBlock = 0x60,
},
{
[WIN_RESULTS] = {
.bg = 0,
.tilemapLeft = 5,
.tilemapTop = 3,
@ -1107,7 +1114,7 @@ static void CB2_LoadBerryBlender(void)
sBerryBlender->mainState++;
break;
case 4:
if (Blender_PrintText(&sBerryBlender->textState, sText_BerryBlenderStart, GetPlayerTextSpeedDelay()))
if (PrintMessage(&sBerryBlender->textState, sText_BerryBlenderStart, GetPlayerTextSpeedDelay()))
sBerryBlender->mainState++;
break;
case 5:
@ -1337,7 +1344,7 @@ static void CB2_StartBlenderLink(void)
}
break;
case 5:
Blender_PrintText(&sBerryBlender->textState, sText_CommunicationStandby, 0);
PrintMessage(&sBerryBlender->textState, sText_CommunicationStandby, 0);
sBerryBlender->mainState = 8;
sBerryBlender->framesToWait = 0;
break;
@ -1363,7 +1370,7 @@ static void CB2_StartBlenderLink(void)
if (++sBerryBlender->framesToWait > 20)
{
// Wait for partners' berries
ClearDialogWindowAndFrameToTransparent(4, TRUE);
ClearDialogWindowAndFrameToTransparent(WIN_MSG, TRUE);
if (GetBlockReceivedStatus() == GetLinkPlayerCountAsBitFlags())
{
for (i = 0; i < GetLinkPlayerCount(); i++)
@ -2276,9 +2283,9 @@ static u32 CalculatePokeblockColor(struct BlenderBerry* berries, s16 *_flavors,
j++;
}
// If all flavors are 0, or at least 3 were negative/0
// If all 5 flavors are 0, or if 4-5 flavors were negative,
// or if players used the same berry, color is black
if (j == 5 || negativeFlavors > 3)
if (j == FLAVOR_COUNT || negativeFlavors > 3)
return PBLOCK_CLR_BLACK;
for (i = 0; i < numPlayers; i++)
@ -2664,7 +2671,7 @@ static void CB2_EndBlenderGame(void)
}
break;
case 7:
if (Blender_PrintText(&sBerryBlender->textState, sText_WouldLikeToBlendAnotherBerry, GetPlayerTextSpeedDelay()))
if (PrintMessage(&sBerryBlender->textState, sText_WouldLikeToBlendAnotherBerry, GetPlayerTextSpeedDelay()))
sBerryBlender->gameEndState++;
break;
case 9:
@ -2748,7 +2755,7 @@ static void CB2_EndBlenderGame(void)
sBerryBlender->gameEndState++;
break;
case 13:
if (Blender_PrintText(&sBerryBlender->textState, sText_CommunicationStandby, GetPlayerTextSpeedDelay()))
if (PrintMessage(&sBerryBlender->textState, sText_CommunicationStandby, GetPlayerTextSpeedDelay()))
{
SetMainCallback2(CB2_CheckPlayAgainLink);
sBerryBlender->gameEndState = 0;
@ -2858,7 +2865,7 @@ static void CB2_CheckPlayAgainLink(void)
StringAppend(gStringVar4, sText_HasNoBerriesToPut);
break;
case 3:
if (Blender_PrintText(&sBerryBlender->textState, gStringVar4, GetPlayerTextSpeedDelay()))
if (PrintMessage(&sBerryBlender->textState, gStringVar4, GetPlayerTextSpeedDelay()))
{
sBerryBlender->framesToWait = 0;
sBerryBlender->gameEndState++;
@ -2869,7 +2876,7 @@ static void CB2_CheckPlayAgainLink(void)
sBerryBlender->gameEndState = 5;
break;
case 5:
Blender_PrintText(&sBerryBlender->textState, gText_SavingDontTurnOff2, 0);
PrintMessage(&sBerryBlender->textState, gText_SavingDontTurnOff2, 0);
SetLinkStandbyCallback();
sBerryBlender->gameEndState++;
break;
@ -2965,7 +2972,7 @@ static void CB2_CheckPlayAgainLocal(void)
StringCopy(gStringVar4, sText_RunOutOfBerriesForBlending);
break;
case 3:
if (Blender_PrintText(&sBerryBlender->textState, gStringVar4, GetPlayerTextSpeedDelay()))
if (PrintMessage(&sBerryBlender->textState, gStringVar4, GetPlayerTextSpeedDelay()))
sBerryBlender->gameEndState = 9;
break;
case 9:
@ -3495,7 +3502,7 @@ static bool8 PrintBlendingResults(void)
u8 *txtPtr;
xPos = GetStringCenterAlignXOffset(FONT_NORMAL, sText_BlendingResults, 0xA8);
Blender_AddTextPrinter(5, sText_BlendingResults, xPos, 1, TEXT_SKIP_DRAW, 0);
Blender_AddTextPrinter(WIN_RESULTS, sText_BlendingResults, xPos, 1, TEXT_SKIP_DRAW, 0);
if (sBerryBlender->numPlayers == BLENDER_MAX_PLAYERS)
yPos = 17;
@ -3510,15 +3517,15 @@ static bool8 PrintBlendingResults(void)
StringAppend(sBerryBlender->stringVar, sText_Dot);
StringAppend(sBerryBlender->stringVar, gText_Space);
StringAppend(sBerryBlender->stringVar, gLinkPlayers[place].name);
Blender_AddTextPrinter(5, sBerryBlender->stringVar, 8, yPos, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sBerryBlender->stringVar, 8, yPos, TEXT_SKIP_DRAW, 3);
StringCopy(sBerryBlender->stringVar, sBerryBlender->blendedBerries[place].name);
ConvertInternationalString(sBerryBlender->stringVar, gLinkPlayers[place].language);
StringAppend(sBerryBlender->stringVar, sText_SpaceBerry);
Blender_AddTextPrinter(5, sBerryBlender->stringVar, 0x54, yPos, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sBerryBlender->stringVar, 0x54, yPos, TEXT_SKIP_DRAW, 3);
}
Blender_AddTextPrinter(5, sText_MaximumSpeed, 0, 0x51, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sText_MaximumSpeed, 0, 0x51, TEXT_SKIP_DRAW, 3);
ConvertIntToDecimalStringN(sBerryBlender->stringVar, sBerryBlender->maxRPM / 100, STR_CONV_MODE_RIGHT_ALIGN, 3);
StringAppend(sBerryBlender->stringVar, sText_Dot);
@ -3527,8 +3534,8 @@ static bool8 PrintBlendingResults(void)
StringAppend(sBerryBlender->stringVar, sText_RPM);
xPos = GetStringRightAlignXOffset(FONT_NORMAL, sBerryBlender->stringVar, 0xA8);
Blender_AddTextPrinter(5, sBerryBlender->stringVar, xPos, 0x51, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(5, sText_Time, 0, 0x61, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sBerryBlender->stringVar, xPos, 0x51, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sText_Time, 0, 0x61, TEXT_SKIP_DRAW, 3);
seconds = (sBerryBlender->gameFrameTime / 60) % 60;
minutes = (sBerryBlender->gameFrameTime / (60 * 60));
@ -3540,12 +3547,12 @@ static bool8 PrintBlendingResults(void)
StringAppend(sBerryBlender->stringVar, sText_Sec);
xPos = GetStringRightAlignXOffset(FONT_NORMAL, sBerryBlender->stringVar, 0xA8);
Blender_AddTextPrinter(5, sBerryBlender->stringVar, xPos, 0x61, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sBerryBlender->stringVar, xPos, 0x61, TEXT_SKIP_DRAW, 3);
sBerryBlender->framesToWait = 0;
sBerryBlender->mainState++;
CopyWindowToVram(5, COPYWIN_GFX);
CopyWindowToVram(WIN_RESULTS, COPYWIN_GFX);
}
break;
case 4:
@ -3553,7 +3560,7 @@ static bool8 PrintBlendingResults(void)
sBerryBlender->mainState++;
break;
case 5:
ClearStdWindowAndFrameToTransparent(5, TRUE);
ClearStdWindowAndFrameToTransparent(WIN_RESULTS, TRUE);
for (i = 0; i < BLENDER_MAX_PLAYERS; i++)
{
@ -3581,7 +3588,7 @@ static bool8 PrintBlendingResults(void)
sBerryBlender->mainState++;
break;
case 6:
if (Blender_PrintText(&sBerryBlender->textState, sBerryBlender->stringVar, GetPlayerTextSpeedDelay()))
if (PrintMessage(&sBerryBlender->textState, sBerryBlender->stringVar, GetPlayerTextSpeedDelay()))
{
TryUpdateBerryBlenderRecord();
return TRUE;
@ -3692,9 +3699,9 @@ static bool8 PrintBlendingRanking(void)
}
break;
case 3:
DrawStdFrameWithCustomTileAndPalette(5, FALSE, 1, 0xD);
DrawStdFrameWithCustomTileAndPalette(WIN_RESULTS, FALSE, 1, 0xD);
xPos = GetStringCenterAlignXOffset(FONT_NORMAL, sText_Ranking, 168);
Blender_AddTextPrinter(5, sText_Ranking, xPos, 1, TEXT_SKIP_DRAW, 0);
Blender_AddTextPrinter(WIN_RESULTS, sText_Ranking, xPos, 1, TEXT_SKIP_DRAW, 0);
sBerryBlender->scoreIconIds[SCORE_BEST] = CreateSprite(&sSpriteTemplate_ScoreSymbols, 128, 52, 0);
StartSpriteAnim(&gSprites[sBerryBlender->scoreIconIds[SCORE_BEST]], SCOREANIM_BEST_STATIC);
@ -3718,20 +3725,20 @@ static bool8 PrintBlendingRanking(void)
StringAppend(sBerryBlender->stringVar, sText_Dot);
StringAppend(sBerryBlender->stringVar, gText_Space);
StringAppend(sBerryBlender->stringVar, gLinkPlayers[place].name);
Blender_AddTextPrinter(5, sBerryBlender->stringVar, 0, yPos, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sBerryBlender->stringVar, 0, yPos, TEXT_SKIP_DRAW, 3);
ConvertIntToDecimalStringN(sBerryBlender->stringVar, sBerryBlender->scores[place][SCORE_BEST], STR_CONV_MODE_RIGHT_ALIGN, 3);
Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78, yPos, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sBerryBlender->stringVar, 78, yPos, TEXT_SKIP_DRAW, 3);
ConvertIntToDecimalStringN(sBerryBlender->stringVar, sBerryBlender->scores[place][SCORE_GOOD], STR_CONV_MODE_RIGHT_ALIGN, 3);
Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78 + 32, yPos, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sBerryBlender->stringVar, 78 + 32, yPos, TEXT_SKIP_DRAW, 3);
ConvertIntToDecimalStringN(sBerryBlender->stringVar, sBerryBlender->scores[place][SCORE_MISS], STR_CONV_MODE_RIGHT_ALIGN, 3);
Blender_AddTextPrinter(5, sBerryBlender->stringVar, 78 + 64, yPos, TEXT_SKIP_DRAW, 3);
Blender_AddTextPrinter(WIN_RESULTS, sBerryBlender->stringVar, 78 + 64, yPos, TEXT_SKIP_DRAW, 3);
}
PutWindowTilemap(5);
CopyWindowToVram(5, COPYWIN_FULL);
PutWindowTilemap(WIN_RESULTS);
CopyWindowToVram(WIN_RESULTS, COPYWIN_FULL);
sBerryBlender->framesToWait = 0;
sBerryBlender->mainState++;
@ -3875,26 +3882,24 @@ static void Blender_AddTextPrinter(u8 windowId, const u8 *string, u8 x, u8 y, s3
}
if (caseId != 3)
{
FillWindowPixelBuffer(windowId, PIXEL_FILL(txtColor[0]));
}
AddTextPrinterParameterized4(windowId, FONT_NORMAL, x, y, letterSpacing, 1, txtColor, speed, string);
}
static bool32 Blender_PrintText(s16 *textState, const u8 *string, s32 textSpeed)
static bool32 PrintMessage(s16 *textState, const u8 *string, s32 textSpeed)
{
switch (*textState)
{
case 0:
DrawDialogFrameWithCustomTileAndPalette(4, FALSE, 0x14, 0xF);
Blender_AddTextPrinter(4, string, 0, 1, textSpeed, 0);
PutWindowTilemap(4);
CopyWindowToVram(4, COPYWIN_FULL);
DrawDialogFrameWithCustomTileAndPalette(WIN_MSG, FALSE, 0x14, 0xF);
Blender_AddTextPrinter(WIN_MSG, string, 0, 1, textSpeed, 0);
PutWindowTilemap(WIN_MSG);
CopyWindowToVram(WIN_MSG, COPYWIN_FULL);
(*textState)++;
break;
case 1:
if (!IsTextPrinterActive(4))
if (!IsTextPrinterActive(WIN_MSG))
{
*textState = 0;
return TRUE;

View File

@ -14,6 +14,13 @@
#include "m4a.h"
#include "constants/rgb.h"
enum {
WIN_TITLE, // "Berry Program Update" header on the first screen
WIN_MSG_BODY,
WIN_GAME_NAMES, // The labels under the GBA graphics on the link screen
WIN_TURN_OFF_TITLE, // "Ruby/Sapphire" at the top of the "turn off the power" screen
};
struct {
u8 state;
u8 curScene;
@ -71,7 +78,7 @@ static const struct BgTemplate sBerryFixBgTemplates[] = {
};
static const struct WindowTemplate sBerryFixWindowTemplates[] = {
{
[WIN_TITLE] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 4,
@ -80,7 +87,7 @@ static const struct WindowTemplate sBerryFixWindowTemplates[] = {
.paletteNum = 15,
.baseBlock = 1
},
{
[WIN_MSG_BODY] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 11,
@ -89,7 +96,7 @@ static const struct WindowTemplate sBerryFixWindowTemplates[] = {
.paletteNum = 15,
.baseBlock = 53
},
{
[WIN_GAME_NAMES] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 8,
@ -98,7 +105,7 @@ static const struct WindowTemplate sBerryFixWindowTemplates[] = {
.paletteNum = 15,
.baseBlock = 277
},
{
[WIN_TURN_OFF_TITLE] = {
.bg = 0,
.tilemapLeft = 8,
.tilemapTop = 0,
@ -217,11 +224,11 @@ static void BerryFix_Main(void)
sBerryFix->state = MAINSTATE_BEGIN;
break;
case MAINSTATE_BEGIN:
if (TryScene(SCENE_BEGIN) && (JOY_NEW(A_BUTTON)))
if (TryScene(SCENE_BEGIN) && JOY_NEW(A_BUTTON))
sBerryFix->state = MAINSTATE_CONNECT;
break;
case MAINSTATE_CONNECT:
if (TryScene(SCENE_ENSURE_CONNECT) && (JOY_NEW(A_BUTTON)))
if (TryScene(SCENE_ENSURE_CONNECT) && JOY_NEW(A_BUTTON))
sBerryFix->state = MAINSTATE_INIT_MULTIBOOT;
break;
case MAINSTATE_INIT_MULTIBOOT:
@ -299,29 +306,29 @@ static void BerryFix_GpuSet(void)
DmaCopy32(3, sBerryFixPalColors, BG_PLTT + 0x1E0, sizeof(sBerryFixPalColors));
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_1D_MAP);
FillWindowPixelBuffer(2, PIXEL_FILL(0));
FillWindowPixelBuffer(3, PIXEL_FILL(0));
FillWindowPixelBuffer(0, PIXEL_FILL(10));
FillWindowPixelBuffer(WIN_GAME_NAMES, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_TURN_OFF_TITLE, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_TITLE, PIXEL_FILL(10));
width = GetStringWidth(FONT_SMALL, sText_Emerald, 0);
left = (120 - width) / 2;
AddTextPrinterParameterized3(2, FONT_SMALL, left, 3, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_Emerald);
AddTextPrinterParameterized3(WIN_GAME_NAMES, FONT_SMALL, left, 3, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_Emerald);
width = GetStringWidth(FONT_SMALL, sText_RubySapphire, 0);
left = (120 - width) / 2 + 120;
AddTextPrinterParameterized3(2, FONT_SMALL, left, 3, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_RubySapphire);
AddTextPrinterParameterized3(WIN_GAME_NAMES, FONT_SMALL, left, 3, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_RubySapphire);
width = GetStringWidth(FONT_SMALL, sText_RubySapphire, 0);
left = (112 - width) / 2;
AddTextPrinterParameterized3(3, FONT_SMALL, left, 0, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_RubySapphire);
AddTextPrinterParameterized3(WIN_TURN_OFF_TITLE, FONT_SMALL, left, 0, sGameTitleTextColors, TEXT_SKIP_DRAW, sText_RubySapphire);
width = GetStringWidth(FONT_NORMAL, sText_BerryProgramUpdate, 0);
left = (208 - width) / 2;
AddTextPrinterParameterized3(0, FONT_NORMAL, left, 2, sBerryProgramTextColors, TEXT_SKIP_DRAW, sText_BerryProgramUpdate);
AddTextPrinterParameterized3(WIN_TITLE, FONT_NORMAL, left, 2, sBerryProgramTextColors, TEXT_SKIP_DRAW, sText_BerryProgramUpdate);
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(3, COPYWIN_GFX);
CopyWindowToVram(0, COPYWIN_GFX);
CopyWindowToVram(WIN_GAME_NAMES, COPYWIN_GFX);
CopyWindowToVram(WIN_TURN_OFF_TITLE, COPYWIN_GFX);
CopyWindowToVram(WIN_TITLE, COPYWIN_GFX);
}
static int BerryFix_TrySetScene(int scene)
@ -345,23 +352,23 @@ static int BerryFix_TrySetScene(int scene)
static void BerryFix_SetScene(int scene)
{
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 32, 32);
FillWindowPixelBuffer(1, PIXEL_FILL(10));
AddTextPrinterParameterized3(1, FONT_NORMAL, 0, 0, sBerryProgramTextColors, TEXT_SKIP_DRAW, sBerryProgramTexts[scene]);
PutWindowTilemap(1);
CopyWindowToVram(1, COPYWIN_GFX);
FillWindowPixelBuffer(WIN_MSG_BODY, PIXEL_FILL(10));
AddTextPrinterParameterized3(WIN_MSG_BODY, FONT_NORMAL, 0, 0, sBerryProgramTextColors, TEXT_SKIP_DRAW, sBerryProgramTexts[scene]);
PutWindowTilemap(WIN_MSG_BODY);
CopyWindowToVram(WIN_MSG_BODY, COPYWIN_GFX);
switch (scene)
{
case SCENE_ENSURE_CONNECT:
case SCENE_TRANSMITTING:
case SCENE_FOLLOW_INSTRUCT:
case SCENE_TRANSMIT_FAILED:
PutWindowTilemap(2);
PutWindowTilemap(WIN_GAME_NAMES);
break;
case SCENE_TURN_OFF_POWER:
PutWindowTilemap(3);
PutWindowTilemap(WIN_TURN_OFF_TITLE);
break;
case SCENE_BEGIN:
PutWindowTilemap(0);
PutWindowTilemap(WIN_TITLE);
break;
}
CopyBgTilemapBufferToVram(0);

View File

@ -102,7 +102,7 @@ static const u8 sTextColors[2][3] =
static const struct WindowTemplate sWindowTemplates[] =
{
{ // WIN_BERRY_NAME
[WIN_BERRY_NAME] = {
.bg = 1,
.tilemapLeft = 11,
.tilemapTop = 4,
@ -111,7 +111,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 69,
},
{ // WIN_SIZE_FIRM
[WIN_SIZE_FIRM] = {
.bg = 1,
.tilemapLeft = 11,
.tilemapTop = 7,
@ -120,7 +120,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 85,
},
{ // WIN_DESC
[WIN_DESC] = {
.bg = 1,
.tilemapLeft = 4,
.tilemapTop = 14,
@ -129,7 +129,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 157,
},
{ // WIN_BERRY_TAG
[WIN_BERRY_TAG] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 0,
@ -599,7 +599,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
switch (data[0])
{
case 0x30:
FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_BERRY_NAME, PIXEL_FILL(0));
break;
case 0x40:
PrintBerryNumberAndName();
@ -609,7 +609,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
CreateBerrySprite();
break;
case 0x60:
FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_SIZE_FIRM, PIXEL_FILL(0));
break;
case 0x70:
PrintBerrySize();
@ -621,7 +621,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
SetFlavorCirclesVisiblity();
break;
case 0xA0:
FillWindowPixelBuffer(2, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_DESC, PIXEL_FILL(0));
break;
case 0xB0:
PrintBerryDescription1();
@ -636,7 +636,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
switch (data[0])
{
case 0x30:
FillWindowPixelBuffer(2, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_DESC, PIXEL_FILL(0));
break;
case 0x40:
PrintBerryDescription2();
@ -648,7 +648,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
SetFlavorCirclesVisiblity();
break;
case 0x70:
FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_SIZE_FIRM, PIXEL_FILL(0));
break;
case 0x80:
PrintBerryFirmness();
@ -661,7 +661,7 @@ static void Task_DisplayAnotherBerry(u8 taskId)
CreateBerrySprite();
break;
case 0xB0:
FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_BERRY_NAME, PIXEL_FILL(0));
break;
case 0xC0:
PrintBerryNumberAndName();

View File

@ -5456,7 +5456,7 @@ static void Contest_StartTextPrinter(const u8 *currChar, bool32 b)
u8 speed;
printerTemplate.currentChar = currChar;
printerTemplate.windowId = 4;
printerTemplate.windowId = WIN_GENERAL_TEXT;
printerTemplate.fontId = FONT_NORMAL;
printerTemplate.x = 0;
printerTemplate.y = 1;
@ -5482,7 +5482,7 @@ static void Contest_StartTextPrinter(const u8 *currChar, bool32 b)
AddTextPrinter(&printerTemplate, speed, 0);
}
PutWindowTilemap(4);
PutWindowTilemap(WIN_GENERAL_TEXT);
Contest_SetBgCopyFlags(0);
}

View File

@ -319,9 +319,10 @@ static const struct BgTemplate sBgTemplates[] =
}
};
static const struct WindowTemplate sWindowTemplates[] =
// Window IDs are implicitly shared with contestant IDs in LoadContestMonName
static const struct WindowTemplate sWindowTemplates[CONTESTANT_COUNT + 1] =
{
{
{ // Contestant 1
.bg = 1,
.tilemapLeft = 7,
.tilemapTop = 4,
@ -330,7 +331,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 770
},
{
{ // Contestant 2
.bg = 1,
.tilemapLeft = 7,
.tilemapTop = 7,
@ -339,7 +340,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 794
},
{
{ // Contestant 3
.bg = 1,
.tilemapLeft = 7,
.tilemapTop = 10,
@ -348,7 +349,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 818
},
{
{ // Contestant 4
.bg = 1,
.tilemapLeft = 7,
.tilemapTop = 13,
@ -357,7 +358,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 842
},
DUMMY_WIN_TEMPLATE,
DUMMY_WIN_TEMPLATE
};
static const struct OamData sOamData_WirelessIndicatorWindow =

View File

@ -122,7 +122,7 @@ static const u8 sFontColorTable[][3] =
static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] =
{
{
{ // Party mon 1
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 3,
@ -131,7 +131,7 @@ static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] =
.paletteNum = 3,
.baseBlock = 0x63,
},
{
{ // Party mon 2
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 1,
@ -140,7 +140,7 @@ static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] =
.paletteNum = 4,
.baseBlock = 0xA9,
},
{
{ // Party mon 3
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 4,
@ -149,7 +149,7 @@ static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] =
.paletteNum = 5,
.baseBlock = 0xDF,
},
{
{ // Party mon 4
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 7,
@ -158,7 +158,7 @@ static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] =
.paletteNum = 6,
.baseBlock = 0x115,
},
{
{ // Party mon 5
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 10,
@ -167,7 +167,7 @@ static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] =
.paletteNum = 7,
.baseBlock = 0x14B,
},
{
{ // Party mon 6
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 13,
@ -176,7 +176,7 @@ static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] =
.paletteNum = 8,
.baseBlock = 0x181,
},
{
[WIN_MSG] = {
.bg = 2,
.tilemapLeft = 1,
.tilemapTop = 15,
@ -190,7 +190,7 @@ static const struct WindowTemplate sSinglePartyMenuWindowTemplate[] =
static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] =
{
{
{ // Party mon 1
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
@ -199,7 +199,7 @@ static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] =
.paletteNum = 3,
.baseBlock = 0x63,
},
{
{ // Party mon 2
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 8,
@ -208,7 +208,7 @@ static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] =
.paletteNum = 4,
.baseBlock = 0xA9,
},
{
{ // Party mon 3
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 1,
@ -217,7 +217,7 @@ static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] =
.paletteNum = 5,
.baseBlock = 0xEF,
},
{
{ // Party mon 4
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 5,
@ -226,7 +226,7 @@ static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] =
.paletteNum = 6,
.baseBlock = 0x125,
},
{
{ // Party mon 5
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 9,
@ -235,7 +235,7 @@ static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] =
.paletteNum = 7,
.baseBlock = 0x15B,
},
{
{ // Party mon 6
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 13,
@ -244,7 +244,7 @@ static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] =
.paletteNum = 8,
.baseBlock = 0x191,
},
{
[WIN_MSG] = {
.bg = 2,
.tilemapLeft = 1,
.tilemapTop = 15,
@ -258,7 +258,7 @@ static const struct WindowTemplate sDoublePartyMenuWindowTemplate[] =
static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] =
{
{
{ // Party mon 1
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
@ -267,7 +267,7 @@ static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] =
.paletteNum = 3,
.baseBlock = 0x63,
},
{
{ // Party mon 2
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 8,
@ -276,7 +276,7 @@ static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] =
.paletteNum = 4,
.baseBlock = 0xA9,
},
{
{ // Party mon 3
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 2,
@ -285,7 +285,7 @@ static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] =
.paletteNum = 5,
.baseBlock = 0xEF,
},
{
{ // Party mon 4
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 5,
@ -294,7 +294,7 @@ static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] =
.paletteNum = 6,
.baseBlock = 0x125,
},
{
{ // Party mon 5
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 9,
@ -303,7 +303,7 @@ static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] =
.paletteNum = 7,
.baseBlock = 0x15B,
},
{
{ // Party mon 6
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 12,
@ -312,7 +312,7 @@ static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] =
.paletteNum = 8,
.baseBlock = 0x191,
},
{
[WIN_MSG] = {
.bg = 2,
.tilemapLeft = 1,
.tilemapTop = 15,
@ -326,7 +326,7 @@ static const struct WindowTemplate sMultiPartyMenuWindowTemplate[] =
static const struct WindowTemplate sShowcaseMultiPartyMenuWindowTemplate[] =
{
{
{ // Party mon 1
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 2,
@ -335,7 +335,7 @@ static const struct WindowTemplate sShowcaseMultiPartyMenuWindowTemplate[] =
.paletteNum = 3,
.baseBlock = 0x63,
},
{
{ // Party mon 2
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 3,
@ -344,7 +344,7 @@ static const struct WindowTemplate sShowcaseMultiPartyMenuWindowTemplate[] =
.paletteNum = 5,
.baseBlock = 0xA9,
},
{
{ // Party mon 3
.bg = 0,
.tilemapLeft = 12,
.tilemapTop = 6,
@ -353,7 +353,7 @@ static const struct WindowTemplate sShowcaseMultiPartyMenuWindowTemplate[] =
.paletteNum = 6,
.baseBlock = 0xDF,
},
{
{ // Party mon 4
.bg = 2,
.tilemapLeft = 1,
.tilemapTop = 11,
@ -362,7 +362,7 @@ static const struct WindowTemplate sShowcaseMultiPartyMenuWindowTemplate[] =
.paletteNum = 4,
.baseBlock = 0x115,
},
{
{ // Party mon 5
.bg = 2,
.tilemapLeft = 12,
.tilemapTop = 12,
@ -371,7 +371,7 @@ static const struct WindowTemplate sShowcaseMultiPartyMenuWindowTemplate[] =
.paletteNum = 7,
.baseBlock = 0x16B,
},
{
{ // Party mon 6
.bg = 2,
.tilemapLeft = 12,
.tilemapTop = 15,

View File

@ -226,18 +226,23 @@ static void DoQuizQuestionEasyChatScreen(void);
static void DoQuizSetAnswerEasyChatScreen(void);
static void DoQuizSetQuestionEasyChatScreen(void);
#define PALTAG_TRIANGLE_CURSOR 0
#define PALTAG_RECTANGLE_CURSOR 1
#define PALTAG_MISC_UI 2
#define PALTAG_RS_INTERVIEW_FRAME 3
enum {
PALTAG_TRIANGLE_CURSOR,
PALTAG_RECTANGLE_CURSOR,
PALTAG_MISC_UI,
PALTAG_RS_INTERVIEW_FRAME,
};
enum {
GFXTAG_TRIANGLE_CURSOR,
GFXTAG_RECTANGLE_CURSOR,
GFXTAG_SCROLL_INDICATOR,
GFXTAG_START_SELECT_BUTTONS,
GFXTAG_MODE_WINDOW,
GFXTAG_RS_INTERVIEW_FRAME,
GFXTAG_BUTTON_WINDOW,
};
#define GFXTAG_TRIANGLE_CURSOR 0
#define GFXTAG_RECTANGLE_CURSOR 1
#define GFXTAG_SCROLL_INDICATOR 2
#define GFXTAG_START_SELECT_BUTTONS 3
#define GFXTAG_MODE_WINDOW 4
#define GFXTAG_RS_INTERVIEW_FRAME 5
#define GFXTAG_BUTTON_WINDOW 6
// State values for sEasyChatScreen->inputState
// Control which input handler to use in HandleEasyChatInput
@ -376,6 +381,13 @@ enum {
WINANIM_KEYBOARD_SWITCH_IN,
};
// Window IDs
enum {
WIN_TITLE,
WIN_MSG,
WIN_INPUT_SELECT, // Word groups, word list, and keyboard
};
// Values for text frame tilemap
#define FRAME_OFFSET_ORANGE 0x1000 // Orange frame, for phrase text
#define FRAME_OFFSET_GREEN 0x4000 // Green frame, for keyboard/word select
@ -814,7 +826,7 @@ static const struct BgTemplate sEasyChatBgTemplates[] = {
};
static const struct WindowTemplate sEasyChatWindowTemplates[] = {
{
[WIN_TITLE] = {
.bg = 1,
.tilemapLeft = 6,
.tilemapTop = 0,
@ -823,7 +835,7 @@ static const struct WindowTemplate sEasyChatWindowTemplates[] = {
.paletteNum = 10,
.baseBlock = 0x10,
},
{
[WIN_MSG] = {
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 15,
@ -832,7 +844,7 @@ static const struct WindowTemplate sEasyChatWindowTemplates[] = {
.paletteNum = 15,
.baseBlock = 0xA,
},
{
[WIN_INPUT_SELECT] = {
.bg = 2,
.tilemapLeft = 1,
.tilemapTop = 0,
@ -3934,10 +3946,10 @@ static void PrintTitle(void)
return;
xOffset = GetStringCenterAlignXOffset(FONT_NORMAL, titleText, 144);
FillWindowPixelBuffer(0, PIXEL_FILL(0));
PrintEasyChatTextWithColors(0, FONT_NORMAL, titleText, xOffset, 1, TEXT_SKIP_DRAW, TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY);
PutWindowTilemap(0);
CopyWindowToVram(0, COPYWIN_FULL);
FillWindowPixelBuffer(WIN_TITLE, PIXEL_FILL(0));
PrintEasyChatTextWithColors(WIN_TITLE, FONT_NORMAL, titleText, xOffset, 1, TEXT_SKIP_DRAW, TEXT_COLOR_TRANSPARENT, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY);
PutWindowTilemap(WIN_TITLE);
CopyWindowToVram(WIN_TITLE, COPYWIN_FULL);
}
static void PrintEasyChatText(u8 windowId, u8 fontId, const u8 *str, u8 x, u8 y, u8 speed, void (*callback)(struct TextPrinterTemplate *, u16))
@ -3957,10 +3969,10 @@ static void PrintEasyChatTextWithColors(u8 windowId, u8 fontId, const u8 *str, u
static void PrintInitialInstructions(void)
{
FillBgTilemapBufferRect(0, 0, 0, 0, 32, 20, 17);
LoadUserWindowBorderGfx(1, 1, BG_PLTT_ID(14));
DrawTextBorderOuter(1, 1, 14);
LoadUserWindowBorderGfx(WIN_MSG, 1, BG_PLTT_ID(14));
DrawTextBorderOuter(WIN_MSG, 1, 14);
PrintEasyChatStdMessage(MSG_INSTRUCTIONS);
PutWindowTilemap(1);
PutWindowTilemap(WIN_MSG);
CopyBgTilemapBufferToVram(0);
}
@ -4004,14 +4016,14 @@ static void PrintEasyChatStdMessage(u8 msgId)
break;
}
FillWindowPixelBuffer(1, PIXEL_FILL(1));
FillWindowPixelBuffer(WIN_MSG, PIXEL_FILL(1));
if (text1)
PrintEasyChatText(1, FONT_NORMAL, text1, 0, 1, TEXT_SKIP_DRAW, 0);
PrintEasyChatText(WIN_MSG, FONT_NORMAL, text1, 0, 1, TEXT_SKIP_DRAW, 0);
if (text2)
PrintEasyChatText(1, FONT_NORMAL, text2, 0, 17, TEXT_SKIP_DRAW, 0);
PrintEasyChatText(WIN_MSG, FONT_NORMAL, text2, 0, 17, TEXT_SKIP_DRAW, 0);
CopyWindowToVram(1, COPYWIN_FULL);
CopyWindowToVram(WIN_MSG, COPYWIN_FULL);
}
static void CreateEasyChatYesNoMenu(u8 initialCursorPos)
@ -4198,14 +4210,14 @@ static void AdjustBgTilemapForFooter(void)
static void DrawLowerWindow(void)
{
PutWindowTilemap(2);
CopyBgTilemapBufferToVram(2);
PutWindowTilemap(WIN_INPUT_SELECT);
CopyBgTilemapBufferToVram(WIN_INPUT_SELECT);
}
static void InitLowerWindowText(u32 whichText)
{
ResetLowerWindowScroll();
FillWindowPixelBuffer(2, PIXEL_FILL(1));
FillWindowPixelBuffer(WIN_INPUT_SELECT, PIXEL_FILL(1));
switch (whichText)
{
case TEXT_GROUPS:
@ -4219,7 +4231,7 @@ static void InitLowerWindowText(u32 whichText)
break;
}
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(WIN_INPUT_SELECT, COPYWIN_GFX);
}
static void PrintKeyboardText(void)
@ -4248,7 +4260,7 @@ static void PrintKeyboardGroupNames(void)
return;
}
PrintEasyChatText(2, FONT_NORMAL, GetEasyChatWordGroupName(groupId), x * 84 + 10, y, TEXT_SKIP_DRAW, NULL);
PrintEasyChatText(WIN_INPUT_SELECT, FONT_NORMAL, GetEasyChatWordGroupName(groupId), x * 84 + 10, y, TEXT_SKIP_DRAW, NULL);
}
y += 16;
@ -4260,7 +4272,7 @@ static void PrintKeyboardAlphabet(void)
u32 i;
for (i = 0; i < ARRAY_COUNT(sEasyChatKeyboardAlphabet); i++)
PrintEasyChatText(2, FONT_NORMAL, sEasyChatKeyboardAlphabet[i], 10, 97 + i * 16, TEXT_SKIP_DRAW, NULL);
PrintEasyChatText(WIN_INPUT_SELECT, FONT_NORMAL, sEasyChatKeyboardAlphabet[i], 10, 97 + i * 16, TEXT_SKIP_DRAW, NULL);
}
static void PrintInitialWordSelectText(void)
@ -4331,16 +4343,16 @@ static void PrintWordSelectText(u8 scrollOffset, u8 numRows)
{
CopyEasyChatWordPadded(sScreenControl->wordSelectPrintBuffer, easyChatWord, 0);
if (!DummyWordCheck(easyChatWord))
PrintEasyChatText(2, FONT_NORMAL, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SKIP_DRAW, NULL);
PrintEasyChatText(WIN_INPUT_SELECT, FONT_NORMAL, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SKIP_DRAW, NULL);
else // Never reached
PrintEasyChatTextWithColors(2, FONT_NORMAL, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SKIP_DRAW, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_RED, TEXT_COLOR_LIGHT_GRAY);
PrintEasyChatTextWithColors(WIN_INPUT_SELECT, FONT_NORMAL, sScreenControl->wordSelectPrintBuffer, (j * 13 + 3) * 8, y, TEXT_SKIP_DRAW, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_RED, TEXT_COLOR_LIGHT_GRAY);
}
}
y += 16;
}
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(WIN_INPUT_SELECT, COPYWIN_GFX);
}
static void EraseWordSelectRows(u8 scrollOffset, u8 numRows)
@ -4364,15 +4376,15 @@ static void EraseWordSelectRows(u8 scrollOffset, u8 numRows)
var1 = 0;
}
FillWindowPixelRect(2, PIXEL_FILL(1), 0, y, 224, var2);
FillWindowPixelRect(WIN_INPUT_SELECT, PIXEL_FILL(1), 0, y, 224, var2);
if (var1)
FillWindowPixelRect(2, PIXEL_FILL(1), 0, 0, 224, var1);
FillWindowPixelRect(WIN_INPUT_SELECT, PIXEL_FILL(1), 0, 0, 224, var1);
}
static void ClearWordSelectWindow(void)
{
FillWindowPixelBuffer(2, PIXEL_FILL(1));
CopyWindowToVram(2, COPYWIN_GFX);
FillWindowPixelBuffer(WIN_INPUT_SELECT, PIXEL_FILL(1));
CopyWindowToVram(WIN_INPUT_SELECT, COPYWIN_GFX);
}
static void InitLowerWindowAnim(int winAnimType)

View File

@ -343,7 +343,7 @@ static void Task_EReader(u8 taskId)
case ER_STATE_MSG_SELECT_CONNECT:
if (PrintMysteryGiftMenuMessage(&data->textState, gJPText_SelectConnectFromEReaderMenu))
{
AddTextPrinterToWindow1(gJPText_SelectConnectWithGBA);
MG_AddMessageTextPrinter(gJPText_SelectConnectWithGBA);
ResetTimer(&data->timer);
data->state = ER_STATE_MSG_SELECT_CONNECT_WAIT;
}
@ -397,7 +397,7 @@ static void Task_EReader(u8 taskId)
data->state = ER_STATE_MSG_SELECT_CONNECT;
break;
case ER_STATE_CONNECTING:
AddTextPrinterToWindow1(gJPText_Connecting);
MG_AddMessageTextPrinter(gJPText_Connecting);
// XXX: This (u32 *) cast is discarding the const qualifier from gMultiBootProgram_EReader_Start
EReader_Load(&gEReaderData, gMultiBootProgram_EReader_End - gMultiBootProgram_EReader_Start, (u32 *)gMultiBootProgram_EReader_Start);
data->state = ER_STATE_TRANSFER;
@ -416,7 +416,7 @@ static void Task_EReader(u8 taskId)
else if (data->status == TRANSFER_SUCCESS)
{
ResetTimer(&data->timer);
AddTextPrinterToWindow1(gJPText_PleaseWaitAMoment);
MG_AddMessageTextPrinter(gJPText_PleaseWaitAMoment);
data->state = ER_STATE_TRANSFER_SUCCESS;
}
else // TRANSFER_CANCELED
@ -430,7 +430,7 @@ static void Task_EReader(u8 taskId)
break;
case ER_STATE_LOAD_CARD_START:
OpenEReaderLink();
AddTextPrinterToWindow1(gJPText_AllowEReaderToLoadCard);
MG_AddMessageTextPrinter(gJPText_AllowEReaderToLoadCard);
data->state = ER_STATE_LOAD_CARD;
break;
case ER_STATE_LOAD_CARD:
@ -439,7 +439,7 @@ static void Task_EReader(u8 taskId)
case RECV_ACTIVE:
break;
case RECV_SUCCESS:
AddTextPrinterToWindow1(gJPText_Connecting);
MG_AddMessageTextPrinter(gJPText_Connecting);
data->state = ER_STATE_WAIT_RECV_CARD;
break;
case RECV_CANCELED:
@ -487,7 +487,7 @@ static void Task_EReader(u8 taskId)
case ER_STATE_SAVE:
if (TryWriteTrainerHill((struct EReaderTrainerHillSet *)&gDecompressionBuffer))
{
AddTextPrinterToWindow1(gJPText_ConnectionComplete);
MG_AddMessageTextPrinter(gJPText_ConnectionComplete);
ResetTimer(&data->timer);
data->state = ER_STATE_SUCCESS_MSG;
}
@ -499,7 +499,7 @@ static void Task_EReader(u8 taskId)
case ER_STATE_SUCCESS_MSG:
if (UpdateTimer(&data->timer, 120))
{
AddTextPrinterToWindow1(gJPText_NewTrainerHasComeToHoenn);
MG_AddMessageTextPrinter(gJPText_NewTrainerHasComeToHoenn);
PlayFanfare(MUS_OBTAIN_ITEM);
data->state = ER_STATE_SUCCESS_END;
}

View File

@ -23,9 +23,15 @@
* For the fly map, and utility functions all of the maps use, see region_map.c
*/
// Static type declarations
enum {
WIN_MAPSEC_NAME,
WIN_TITLE,
};
// Static RAM declarations
enum {
TAG_PLAYER_ICON,
TAG_CURSOR,
};
static EWRAM_DATA struct {
MainCallback callback;
@ -34,16 +40,12 @@ static EWRAM_DATA struct {
u16 state;
} *sFieldRegionMapHandler = NULL;
// Static ROM declarations
static void MCB2_InitRegionMapRegisters(void);
static void VBCB_FieldUpdateRegionMap(void);
static void MCB2_FieldUpdateRegionMap(void);
static void FieldUpdateRegionMap(void);
static void PrintRegionMapSecName(void);
// .rodata
static const struct BgTemplate sFieldRegionMapBgTemplates[] = {
{
.bg = 0,
@ -66,7 +68,7 @@ static const struct BgTemplate sFieldRegionMapBgTemplates[] = {
static const struct WindowTemplate sFieldRegionMapWindowTemplates[] =
{
{
[WIN_MAPSEC_NAME] = {
.bg = 0,
.tilemapLeft = 17,
.tilemapTop = 17,
@ -75,7 +77,7 @@ static const struct WindowTemplate sFieldRegionMapWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 1
},
{
[WIN_TITLE] = {
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 1,
@ -87,8 +89,6 @@ static const struct WindowTemplate sFieldRegionMapWindowTemplates[] =
DUMMY_WIN_TEMPLATE
};
// .text
void FieldInitRegionMap(MainCallback callback)
{
SetVBlankCallback(NULL);
@ -145,16 +145,16 @@ static void FieldUpdateRegionMap(void)
{
case 0:
InitRegionMap(&sFieldRegionMapHandler->regionMap, FALSE);
CreateRegionMapPlayerIcon(0, 0);
CreateRegionMapCursor(1, 1);
CreateRegionMapPlayerIcon(TAG_PLAYER_ICON, TAG_PLAYER_ICON);
CreateRegionMapCursor(TAG_CURSOR, TAG_CURSOR);
sFieldRegionMapHandler->state++;
break;
case 1:
DrawStdFrameWithCustomTileAndPalette(1, FALSE, 0x27, 0xd);
DrawStdFrameWithCustomTileAndPalette(WIN_TITLE, FALSE, 0x27, 0xd);
offset = GetStringCenterAlignXOffset(FONT_NORMAL, gText_Hoenn, 0x38);
AddTextPrinterParameterized(1, FONT_NORMAL, gText_Hoenn, offset, 1, 0, NULL);
AddTextPrinterParameterized(WIN_TITLE, FONT_NORMAL, gText_Hoenn, offset, 1, 0, NULL);
ScheduleBgCopyTilemapToVram(0);
DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x27, 0xd);
DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME, FALSE, 0x27, 0xd);
PrintRegionMapSecName();
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
sFieldRegionMapHandler->state++;
@ -203,13 +203,13 @@ static void PrintRegionMapSecName(void)
{
if (sFieldRegionMapHandler->regionMap.mapSecType != MAPSECTYPE_NONE)
{
FillWindowPixelBuffer(0, PIXEL_FILL(1));
AddTextPrinterParameterized(0, FONT_NORMAL, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL);
ScheduleBgCopyTilemapToVram(0);
FillWindowPixelBuffer(WIN_MAPSEC_NAME, PIXEL_FILL(1));
AddTextPrinterParameterized(WIN_MAPSEC_NAME, FONT_NORMAL, sFieldRegionMapHandler->regionMap.mapSecName, 0, 1, 0, NULL);
ScheduleBgCopyTilemapToVram(WIN_MAPSEC_NAME);
}
else
{
FillWindowPixelBuffer(0, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_FULL);
FillWindowPixelBuffer(WIN_MAPSEC_NAME, PIXEL_FILL(1));
CopyWindowToVram(WIN_MAPSEC_NAME, COPYWIN_FULL);
}
}

View File

@ -15,18 +15,14 @@
#include "constants/items.h"
#include "constants/hold_effects.h"
// this file's functions
static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count);
static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count);
// EWRAM variables
EWRAM_DATA struct BagPocket gBagPockets[POCKETS_COUNT] = {0};
// rodata
#include "data/text/item_descriptions.h"
#include "data/items.h"
// code
static u16 GetBagItemQuantity(u16 *quantity)
{
return gSaveBlock2Ptr->encryptionKey ^ *quantity;

View File

@ -28,6 +28,13 @@
#include "constants/rgb.h"
#include "constants/trade.h"
// Window IDs for the link error screens
enum {
WIN_LINK_ERROR_TOP,
WIN_LINK_ERROR_MID,
WIN_LINK_ERROR_BOTTOM,
};
struct BlockTransfer
{
u16 pos;
@ -193,8 +200,9 @@ static const struct BgTemplate sLinkErrorBgTemplates[] = {
.priority = 1
}
};
static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
{
[WIN_LINK_ERROR_TOP] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 0,
@ -202,7 +210,8 @@ static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
.height = 5,
.paletteNum = 15,
.baseBlock = 0x002
}, {
},
[WIN_LINK_ERROR_MID] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 6,
@ -210,7 +219,8 @@ static const struct WindowTemplate sLinkErrorWindowTemplates[] = {
.height = 7,
.paletteNum = 15,
.baseBlock = 0x098
}, {
},
[WIN_LINK_ERROR_BOTTOM] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 13,
@ -1641,26 +1651,26 @@ static void ErrorMsg_MoveCloserToPartner(void)
CopyToBgTilemapBuffer(1, sWirelessLinkDisplayTilemap, 0, 0);
CopyBgTilemapBufferToVram(1);
LoadPalette(sWirelessLinkDisplayPal, 0, 0x20);
FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized3(0, FONT_SHORT_COPY_1, 2, 6, sTextColors, 0, gText_CommErrorEllipsis);
AddTextPrinterParameterized3(2, FONT_SHORT_COPY_1, 2, 1, sTextColors, 0, gText_MoveCloserToLinkPartner);
PutWindowTilemap(0);
PutWindowTilemap(2);
CopyWindowToVram(0, COPYWIN_NONE); // Does nothing
CopyWindowToVram(2, COPYWIN_FULL);
FillWindowPixelBuffer(WIN_LINK_ERROR_TOP, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_LINK_ERROR_BOTTOM, PIXEL_FILL(0));
AddTextPrinterParameterized3(WIN_LINK_ERROR_TOP, FONT_SHORT_COPY_1, 2, 6, sTextColors, 0, gText_CommErrorEllipsis);
AddTextPrinterParameterized3(WIN_LINK_ERROR_BOTTOM, FONT_SHORT_COPY_1, 2, 1, sTextColors, 0, gText_MoveCloserToLinkPartner);
PutWindowTilemap(WIN_LINK_ERROR_TOP);
PutWindowTilemap(WIN_LINK_ERROR_BOTTOM);
CopyWindowToVram(WIN_LINK_ERROR_TOP, COPYWIN_NONE); // Does nothing
CopyWindowToVram(WIN_LINK_ERROR_BOTTOM, COPYWIN_FULL);
}
static void ErrorMsg_CheckConnections(void)
{
LoadBgTiles(0, sCommErrorBg_Gfx, 0x20, 0);
FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized3(1, FONT_SHORT_COPY_1, 2, 0, sTextColors, 0, gText_CommErrorCheckConnections);
PutWindowTilemap(1);
PutWindowTilemap(2);
CopyWindowToVram(1, COPYWIN_NONE); // Does nothing
CopyWindowToVram(2, COPYWIN_FULL);
FillWindowPixelBuffer(WIN_LINK_ERROR_MID, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_LINK_ERROR_BOTTOM, PIXEL_FILL(0));
AddTextPrinterParameterized3(WIN_LINK_ERROR_MID, FONT_SHORT_COPY_1, 2, 0, sTextColors, 0, gText_CommErrorCheckConnections);
PutWindowTilemap(WIN_LINK_ERROR_MID);
PutWindowTilemap(WIN_LINK_ERROR_BOTTOM);
CopyWindowToVram(WIN_LINK_ERROR_MID, COPYWIN_NONE); // Does nothing
CopyWindowToVram(WIN_LINK_ERROR_BOTTOM, COPYWIN_FULL);
}
static void CB2_PrintErrorMessage(void)
@ -1691,9 +1701,9 @@ static void CB2_PrintErrorMessage(void)
break;
case 130:
if (gWirelessCommType == 2)
AddTextPrinterParameterized3(0, FONT_SHORT_COPY_1, 2, 20, sTextColors, 0, gText_ABtnTitleScreen);
AddTextPrinterParameterized3(WIN_LINK_ERROR_TOP, FONT_SHORT_COPY_1, 2, 20, sTextColors, 0, gText_ABtnTitleScreen);
else if (gWirelessCommType == 1)
AddTextPrinterParameterized3(0, FONT_SHORT_COPY_1, 2, 20, sTextColors, 0, gText_ABtnRegistrationCounter);
AddTextPrinterParameterized3(WIN_LINK_ERROR_TOP, FONT_SHORT_COPY_1, 2, 20, sTextColors, 0, gText_ABtnRegistrationCounter);
break;
}
if (gMain.state == 160)

View File

@ -106,10 +106,9 @@ static const u8 sConditionToLineLength[MAX_CONDITION + 1] =
34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, 35
};
static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
{
{
[RELEARNERWIN_DESC_BATTLE] = {
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 1,
@ -118,7 +117,7 @@ static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0xA
},
{
[RELEARNERWIN_DESC_CONTEST] = {
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 1,
@ -127,7 +126,7 @@ static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0xCA
},
{
[RELEARNERWIN_MOVE_LIST] = {
.bg = 1,
.tilemapLeft = 19,
.tilemapTop = 1,
@ -136,7 +135,7 @@ static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x18A
},
{
[RELEARNERWIN_MSG] = {
.bg = 1,
.tilemapLeft = 4,
.tilemapTop = 15,
@ -145,7 +144,8 @@ static const struct WindowTemplate sMoveRelearnerWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x202
},
{
// Unused. Identical to sMoveRelearnerYesNoMenuTemplate
[RELEARNERWIN_YESNO] = {
.bg = 0,
.tilemapLeft = 22,
.tilemapTop = 8,
@ -176,7 +176,7 @@ static const struct ListMenuTemplate sMoveRelearnerMovesListTemplate =
.itemPrintFunc = NULL,
.totalItems = 0,
.maxShowed = 0,
.windowId = 2,
.windowId = RELEARNERWIN_MOVE_LIST,
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
@ -702,7 +702,7 @@ void ConditionGraph_CalcPositions(u8 *conditions, struct UCoords16 *positions)
// Move relearner
//----------------
void InitMoveRelearnerWindows(bool8 useContextWindow)
void InitMoveRelearnerWindows(bool8 useContestWindow)
{
u8 i;
@ -714,20 +714,20 @@ void InitMoveRelearnerWindows(bool8 useContextWindow)
for (i = 0; i < ARRAY_COUNT(sMoveRelearnerWindowTemplates) - 1; i++)
FillWindowPixelBuffer(i, PIXEL_FILL(1));
if (!useContextWindow)
if (!useContestWindow)
{
PutWindowTilemap(0);
DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x1, 0xE);
PutWindowTilemap(RELEARNERWIN_DESC_BATTLE);
DrawStdFrameWithCustomTileAndPalette(RELEARNERWIN_DESC_BATTLE, FALSE, 0x1, 0xE);
}
else
{
PutWindowTilemap(1);
DrawStdFrameWithCustomTileAndPalette(1, FALSE, 1, 0xE);
PutWindowTilemap(RELEARNERWIN_DESC_CONTEST);
DrawStdFrameWithCustomTileAndPalette(RELEARNERWIN_DESC_CONTEST, FALSE, 1, 0xE);
}
PutWindowTilemap(2);
PutWindowTilemap(3);
DrawStdFrameWithCustomTileAndPalette(2, FALSE, 1, 0xE);
DrawStdFrameWithCustomTileAndPalette(3, FALSE, 1, 0xE);
PutWindowTilemap(RELEARNERWIN_MOVE_LIST);
PutWindowTilemap(RELEARNERWIN_MSG);
DrawStdFrameWithCustomTileAndPalette(RELEARNERWIN_MOVE_LIST, FALSE, 1, 0xE);
DrawStdFrameWithCustomTileAndPalette(RELEARNERWIN_MSG, FALSE, 1, 0xE);
MoveRelearnerDummy();
ScheduleBgCopyTilemapToVram(1);
}
@ -758,33 +758,34 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
u8 buffer[32];
const u8 *str;
FillWindowPixelBuffer(0, PIXEL_FILL(1));
FillWindowPixelBuffer(RELEARNERWIN_DESC_BATTLE, PIXEL_FILL(1));
str = gText_MoveRelearnerBattleMoves;
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 0x80);
AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL);
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 128);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerPP;
AddTextPrinterParameterized(0, FONT_NORMAL, str, 4, 0x29, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, 4, 41, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerPower;
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x6A);
AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 0x19, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 106);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, x, 25, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerAccuracy;
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x6A);
AddTextPrinterParameterized(0, FONT_NORMAL, str, x, 0x29, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 106);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, x, 41, TEXT_SKIP_DRAW, NULL);
if (chosenMove == LIST_CANCEL)
{
CopyWindowToVram(0, COPYWIN_GFX);
// On "Cancel", skip printing move data
CopyWindowToVram(RELEARNERWIN_DESC_BATTLE, COPYWIN_GFX);
return;
}
move = &gBattleMoves[chosenMove];
str = gTypeNames[move->type];
AddTextPrinterParameterized(0, FONT_NORMAL, str, 4, 0x19, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, 4, 25, TEXT_SKIP_DRAW, NULL);
x = 4 + GetStringWidth(FONT_NORMAL, gText_MoveRelearnerPP, 0);
ConvertIntToDecimalStringN(buffer, move->pp, STR_CONV_MODE_LEFT_ALIGN, 2);
AddTextPrinterParameterized(0, FONT_NORMAL, buffer, x, 0x29, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, buffer, x, 41, TEXT_SKIP_DRAW, NULL);
if (move->power < 2)
{
@ -795,7 +796,7 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
ConvertIntToDecimalStringN(buffer, move->power, STR_CONV_MODE_LEFT_ALIGN, 3);
str = buffer;
}
AddTextPrinterParameterized(0, FONT_NORMAL, str, 0x6A, 0x19, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, 106, 25, TEXT_SKIP_DRAW, NULL);
if (move->accuracy == 0)
{
@ -806,14 +807,14 @@ static void MoveRelearnerLoadBattleMoveDescription(u32 chosenMove)
ConvertIntToDecimalStringN(buffer, move->accuracy, STR_CONV_MODE_LEFT_ALIGN, 3);
str = buffer;
}
AddTextPrinterParameterized(0, FONT_NORMAL, str, 0x6A, 0x29, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NORMAL, str, 106, 41, TEXT_SKIP_DRAW, NULL);
if (move->effect != EFFECT_PLACEHOLDER)
str = gMoveDescriptionPointers[chosenMove - 1];
else
str = gNotDoneYetDescription;
AddTextPrinterParameterized(0, FONT_NARROW, str, 0, 0x41, 0, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_BATTLE, FONT_NARROW, str, 0, 65, 0, NULL);
}
static void MoveRelearnerMenuLoadContestMoveDescription(u32 chosenMove)
@ -823,33 +824,33 @@ static void MoveRelearnerMenuLoadContestMoveDescription(u32 chosenMove)
const struct ContestMove *move;
MoveRelearnerShowHideHearts(chosenMove);
FillWindowPixelBuffer(1, PIXEL_FILL(1));
FillWindowPixelBuffer(RELEARNERWIN_DESC_CONTEST, PIXEL_FILL(1));
str = gText_MoveRelearnerContestMovesTitle;
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 0x80);
AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL);
x = GetStringCenterAlignXOffset(FONT_NORMAL, str, 128);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NORMAL, str, x, 1, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerAppeal;
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x5C);
AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 0x19, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 92);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NORMAL, str, x, 25, TEXT_SKIP_DRAW, NULL);
str = gText_MoveRelearnerJam;
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 0x5C);
AddTextPrinterParameterized(1, FONT_NORMAL, str, x, 0x29, TEXT_SKIP_DRAW, NULL);
x = GetStringRightAlignXOffset(FONT_NORMAL, str, 92);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NORMAL, str, x, 41, TEXT_SKIP_DRAW, NULL);
if (chosenMove == MENU_NOTHING_CHOSEN)
{
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(RELEARNERWIN_DESC_CONTEST, COPYWIN_GFX);
return;
}
move = &gContestMoves[chosenMove];
str = gContestMoveTypeTextPointers[move->contestCategory];
AddTextPrinterParameterized(1, FONT_NORMAL, str, 4, 0x19, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NORMAL, str, 4, 25, TEXT_SKIP_DRAW, NULL);
str = gContestEffectDescriptionPointers[move->effect];
AddTextPrinterParameterized(1, FONT_NARROW, str, 0, 0x41, TEXT_SKIP_DRAW, NULL);
AddTextPrinterParameterized(RELEARNERWIN_DESC_CONTEST, FONT_NARROW, str, 0, 65, TEXT_SKIP_DRAW, NULL);
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(RELEARNERWIN_DESC_CONTEST, COPYWIN_GFX);
}
static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct ListMenu *list)
@ -860,20 +861,20 @@ static void MoveRelearnerCursorCallback(s32 itemIndex, bool8 onInit, struct List
MoveRelearnerMenuLoadContestMoveDescription(itemIndex);
}
void MoveRelearnerPrintText(u8 *str)
void MoveRelearnerPrintMessage(u8 *str)
{
u8 speed;
FillWindowPixelBuffer(3, PIXEL_FILL(1));
FillWindowPixelBuffer(RELEARNERWIN_MSG, PIXEL_FILL(1));
gTextFlags.canABSpeedUpPrint = TRUE;
speed = GetPlayerTextSpeedDelay();
AddTextPrinterParameterized2(3, FONT_NORMAL, str, speed, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, 3);
AddTextPrinterParameterized2(RELEARNERWIN_MSG, FONT_NORMAL, str, speed, NULL, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, 3);
}
bool16 MoveRelearnerRunTextPrinters(void)
{
RunTextPrinters();
return IsTextPrinterActive(3);
return IsTextPrinterActive(RELEARNERWIN_MSG);
}
void MoveRelearnerCreateYesNoMenu(void)

View File

@ -465,10 +465,10 @@ static void CB2_MoveRelearnerMain(void)
UpdatePaletteFade();
}
static void FormatAndPrintText(const u8 *src)
static void PrintMessageWithPlaceholders(const u8 *src)
{
StringExpandPlaceholders(gStringVar4, src);
MoveRelearnerPrintText(gStringVar4);
MoveRelearnerPrintMessage(gStringVar4);
}
// See the state machine doc at the top of the file.
@ -522,7 +522,7 @@ static void DoMoveRelearnerMain(void)
{
if (GiveMoveToMon(&gPlayerParty[sMoveRelearnerStruct->partyMon], GetCurrentSelectedMove()) != MON_HAS_MAX_MOVES)
{
FormatAndPrintText(gText_MoveRelearnerPkmnLearnedMove);
PrintMessageWithPlaceholders(gText_MoveRelearnerPkmnLearnedMove);
gSpecialVar_0x8004 = TRUE;
sMoveRelearnerStruct->state = MENU_STATE_PRINT_TEXT_THEN_FANFARE;
}
@ -574,7 +574,7 @@ static void DoMoveRelearnerMain(void)
}
break;
case MENU_STATE_PRINT_TRYING_TO_LEARN_PROMPT:
FormatAndPrintText(gText_MoveRelearnerPkmnTryingToLearnMove);
PrintMessageWithPlaceholders(gText_MoveRelearnerPkmnTryingToLearnMove);
sMoveRelearnerStruct->state++;
break;
case MENU_STATE_WAIT_FOR_TRYING_TO_LEARN:
@ -590,7 +590,7 @@ static void DoMoveRelearnerMain(void)
if (selection == 0)
{
FormatAndPrintText(gText_MoveRelearnerWhichMoveToForget);
PrintMessageWithPlaceholders(gText_MoveRelearnerWhichMoveToForget);
sMoveRelearnerStruct->state = MENU_STATE_PRINT_WHICH_MOVE_PROMPT;
}
else if (selection == MENU_B_PRESSED || selection == 1)
@ -601,7 +601,7 @@ static void DoMoveRelearnerMain(void)
break;
case MENU_STATE_PRINT_STOP_TEACHING:
StringCopy(gStringVar2, gMoveNames[GetCurrentSelectedMove()]);
FormatAndPrintText(gText_MoveRelearnerStopTryingToTeachMove);
PrintMessageWithPlaceholders(gText_MoveRelearnerStopTryingToTeachMove);
sMoveRelearnerStruct->state++;
break;
case MENU_STATE_WAIT_FOR_STOP_TEACHING:
@ -637,7 +637,7 @@ static void DoMoveRelearnerMain(void)
case MENU_STATE_CHOOSE_SETUP_STATE:
if (!MoveRelearnerRunTextPrinters())
{
FillWindowPixelBuffer(3, 0x11);
FillWindowPixelBuffer(RELEARNERWIN_MSG, 0x11);
if (sMoveRelearnerMenuSate.showContestInfo == FALSE)
{
sMoveRelearnerStruct->state = MENU_STATE_SETUP_BATTLE_MODE;
@ -694,7 +694,7 @@ static void DoMoveRelearnerMain(void)
ShowTeachMoveText(TRUE);
}
RemoveScrollArrows();
CopyWindowToVram(3, COPYWIN_GFX);
CopyWindowToVram(RELEARNERWIN_MSG, COPYWIN_GFX);
break;
case MENU_STATE_TRY_OVERWRITE_MOVE:
if (!gPaletteFade.active)
@ -711,7 +711,7 @@ static void DoMoveRelearnerMain(void)
RemoveMonPPBonus(&gPlayerParty[sMoveRelearnerStruct->partyMon], sMoveRelearnerStruct->moveSlot);
SetMonMoveSlot(&gPlayerParty[sMoveRelearnerStruct->partyMon], GetCurrentSelectedMove(), sMoveRelearnerStruct->moveSlot);
StringCopy(gStringVar2, gMoveNames[GetCurrentSelectedMove()]);
FormatAndPrintText(gText_MoveRelearnerAndPoof);
PrintMessageWithPlaceholders(gText_MoveRelearnerAndPoof);
sMoveRelearnerStruct->state = MENU_STATE_DOUBLE_FANFARE_FORGOT_MOVE;
gSpecialVar_0x8004 = TRUE;
}
@ -720,7 +720,7 @@ static void DoMoveRelearnerMain(void)
case MENU_STATE_DOUBLE_FANFARE_FORGOT_MOVE:
if (!MoveRelearnerRunTextPrinters())
{
FormatAndPrintText(gText_MoveRelearnerPkmnForgotMoveAndLearnedNew);
PrintMessageWithPlaceholders(gText_MoveRelearnerPkmnForgotMoveAndLearnedNew);
sMoveRelearnerStruct->state = MENU_STATE_PRINT_TEXT_THEN_FANFARE;
PlayFanfare(MUS_LEVEL_UP);
}
@ -765,15 +765,13 @@ static void HideHeartSpritesAndShowTeachMoveText(bool8 onlyHideSprites)
s32 i;
for (i = 0; i < 16; i++)
{
gSprites[sMoveRelearnerStruct->heartSpriteIds[i]].invisible = TRUE;
}
if (!onlyHideSprites)
{
StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn);
FillWindowPixelBuffer(3, 0x11);
AddTextPrinterParameterized(3, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL);
FillWindowPixelBuffer(RELEARNERWIN_MSG, 0x11);
AddTextPrinterParameterized(RELEARNERWIN_MSG, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL);
}
}
@ -786,21 +784,19 @@ static void HandleInput(bool8 showContest)
{
case LIST_NOTHING_CHOSEN:
if (!(JOY_NEW(DPAD_LEFT | DPAD_RIGHT)) && !GetLRKeysPressed())
{
break;
}
PlaySE(SE_SELECT);
if (showContest == FALSE)
{
PutWindowTilemap(1);
PutWindowTilemap(RELEARNERWIN_DESC_CONTEST);
sMoveRelearnerStruct->state = MENU_STATE_SETUP_CONTEST_MODE;
sMoveRelearnerMenuSate.showContestInfo = TRUE;
}
else
{
PutWindowTilemap(0);
PutWindowTilemap(RELEARNERWIN_DESC_BATTLE);
sMoveRelearnerStruct->state = MENU_STATE_SETUP_BATTLE_MODE;
sMoveRelearnerMenuSate.showContestInfo = FALSE;
}
@ -813,7 +809,7 @@ static void HandleInput(bool8 showContest)
RemoveScrollArrows();
sMoveRelearnerStruct->state = MENU_STATE_PRINT_GIVE_UP_PROMPT;
StringExpandPlaceholders(gStringVar4, gText_MoveRelearnerGiveUp);
MoveRelearnerPrintText(gStringVar4);
MoveRelearnerPrintMessage(gStringVar4);
break;
default:
PlaySE(SE_SELECT);
@ -821,7 +817,7 @@ static void HandleInput(bool8 showContest)
sMoveRelearnerStruct->state = MENU_STATE_PRINT_TEACH_MOVE_PROMPT;
StringCopy(gStringVar2, gMoveNames[itemId]);
StringExpandPlaceholders(gStringVar4, gText_MoveRelearnerTeachMoveConfirm);
MoveRelearnerPrintText(gStringVar4);
MoveRelearnerPrintMessage(gStringVar4);
break;
}
}
@ -842,8 +838,8 @@ static void ShowTeachMoveText(bool8 shouldDoNothingInstead)
if (shouldDoNothingInstead == FALSE)
{
StringExpandPlaceholders(gStringVar4, gText_TeachWhichMoveToPkmn);
FillWindowPixelBuffer(3, 0x11);
AddTextPrinterParameterized(3, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL);
FillWindowPixelBuffer(RELEARNERWIN_MSG, 0x11);
AddTextPrinterParameterized(RELEARNERWIN_MSG, FONT_NORMAL, gStringVar4, 0, 1, 0, NULL);
}
}
@ -857,9 +853,7 @@ static void CreateUISprites(void)
// These are the appeal hearts.
for (i = 0; i < 8; i++)
{
sMoveRelearnerStruct->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.
@ -870,17 +864,13 @@ static void CreateUISprites(void)
}
for (i = 0; i < 16; i++)
{
gSprites[sMoveRelearnerStruct->heartSpriteIds[i]].invisible = TRUE;
}
}
static void AddScrollArrows(void)
{
if (sMoveRelearnerStruct->moveDisplayArrowTask == TASK_NONE)
{
sMoveRelearnerStruct->moveDisplayArrowTask = AddScrollIndicatorArrowPair(&sDisplayModeArrowsTemplate, &sMoveRelearnerStruct->scrollOffset);
}
if (sMoveRelearnerStruct->moveListScrollArrowTask == TASK_NONE)
{
@ -934,49 +924,35 @@ void MoveRelearnerShowHideHearts(s32 moveId)
if (!sMoveRelearnerMenuSate.showContestInfo || moveId == LIST_CANCEL)
{
for (i = 0; i < 16; i++)
{
gSprites[sMoveRelearnerStruct->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[sMoveRelearnerStruct->heartSpriteIds[i]], 1);
}
else
{
StartSpriteAnim(&gSprites[sMoveRelearnerStruct->heartSpriteIds[i]], 0);
}
gSprites[sMoveRelearnerStruct->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[sMoveRelearnerStruct->heartSpriteIds[i + 8]], 3);
}
else
{
StartSpriteAnim(&gSprites[sMoveRelearnerStruct->heartSpriteIds[i + 8]], 2);
}
gSprites[sMoveRelearnerStruct->heartSpriteIds[i + 8]].invisible = FALSE;
}
}

View File

@ -20,6 +20,11 @@
#include "decompress.h"
#include "constants/rgb.h"
enum {
WIN_MSG,
WIN_LOADING,
};
static void CB2_MysteryEventMenu(void);
static void PrintMysteryMenuText(u8 windowId, const u8 *text, u8 x, u8 y, s32 speed);
@ -40,7 +45,7 @@ static const struct BgTemplate sBgTemplates[] =
static const struct WindowTemplate sWindowTemplates[] =
{
{
[WIN_MSG] = {
.bg = 0,
.tilemapLeft = 4,
.tilemapTop = 15,
@ -49,7 +54,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 14,
.baseBlock = 20
},
{
[WIN_LOADING] = {
.bg = 0,
.tilemapLeft = 7,
.tilemapTop = 6,
@ -87,7 +92,7 @@ void CB2_InitMysteryEventMenu(void)
s32 i;
DeactivateAllTextPrinters();
for (i = 0; i < 2; i++)
for (i = 0; i < (int)ARRAY_COUNT(sWindowTemplates) - 1; i++)
FillWindowPixelBuffer(i, PIXEL_FILL(0));
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, DISPLAY_TILE_WIDTH, DISPLAY_TILE_HEIGHT);
@ -131,9 +136,9 @@ static void CB2_MysteryEventMenu(void)
switch (gMain.state)
{
case 0:
DrawStdFrameWithCustomTileAndPalette(0, TRUE, 1, 0xD);
PutWindowTilemap(0);
CopyWindowToVram(0, COPYWIN_FULL);
DrawStdFrameWithCustomTileAndPalette(WIN_MSG, TRUE, 1, 0xD);
PutWindowTilemap(WIN_MSG);
CopyWindowToVram(WIN_MSG, COPYWIN_FULL);
ShowBg(0);
BeginNormalPaletteFade(PALETTES_ALL, 0, 0x10, 0, RGB_BLACK);
gMain.state++;
@ -141,12 +146,12 @@ static void CB2_MysteryEventMenu(void)
case 1:
if (!gPaletteFade.active)
{
PrintMysteryMenuText(0, gText_LinkStandby2, 1, 2, 1);
PrintMysteryMenuText(WIN_MSG, gText_LinkStandby2, 1, 2, 1);
gMain.state++;
}
break;
case 2:
if (!IsTextPrinterActive(0))
if (!IsTextPrinterActive(WIN_MSG))
{
gMain.state++;
gLinkType = LINKTYPE_MYSTERY_EVENT;
@ -154,10 +159,10 @@ static void CB2_MysteryEventMenu(void)
}
break;
case 3:
if ((gLinkStatus & 0x20) && (gLinkStatus & 0x1C) > 4)
if ((gLinkStatus & LINK_STAT_MASTER) && (gLinkStatus & LINK_STAT_PLAYER_COUNT) > 4)
{
PlaySE(SE_PIN);
PrintMysteryMenuText(0, gText_PressAToLoadEvent, 1, 2, 1);
PrintMysteryMenuText(WIN_MSG, gText_PressAToLoadEvent, 1, 2, 1);
gMain.state++;
}
if (JOY_NEW(B_BUTTON))
@ -168,7 +173,7 @@ static void CB2_MysteryEventMenu(void)
}
break;
case 4:
if (!IsTextPrinterActive(0))
if (!IsTextPrinterActive(WIN_MSG))
gMain.state++;
break;
case 5:
@ -178,10 +183,10 @@ static void CB2_MysteryEventMenu(void)
{
PlaySE(SE_SELECT);
CheckShouldAdvanceLinkState();
DrawStdFrameWithCustomTileAndPalette(1, TRUE, 1, 0xD);
PrintMysteryMenuText(1, gText_LoadingEvent, 1, 2, 0);
PutWindowTilemap(1);
CopyWindowToVram(1, COPYWIN_FULL);
DrawStdFrameWithCustomTileAndPalette(WIN_LOADING, TRUE, 1, 0xD);
PrintMysteryMenuText(WIN_LOADING, gText_LoadingEvent, 1, 2, 0);
PutWindowTilemap(WIN_LOADING);
CopyWindowToVram(WIN_LOADING, COPYWIN_FULL);
gMain.state++;
}
else if (JOY_NEW(B_BUTTON))
@ -194,7 +199,7 @@ static void CB2_MysteryEventMenu(void)
else
{
GetEventLoadMessage(gStringVar4, MEVENT_STATUS_LOAD_ERROR);
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
PrintMysteryMenuText(WIN_MSG, gStringVar4, 1, 2, 1);
gMain.state = 13;
}
break;
@ -207,19 +212,19 @@ static void CB2_MysteryEventMenu(void)
{
SetCloseLinkCallback();
GetEventLoadMessage(gStringVar4, MEVENT_STATUS_LOAD_ERROR);
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
PrintMysteryMenuText(WIN_MSG, gStringVar4, 1, 2, 1);
gMain.state = 13;
}
else if (CheckLanguageMatch())
{
PrintMysteryMenuText(0, gText_DontRemoveCableTurnOff, 1, 2, 1);
PrintMysteryMenuText(WIN_MSG, gText_DontRemoveCableTurnOff, 1, 2, 1);
gMain.state++;
}
else
{
CloseLink();
GetEventLoadMessage(gStringVar4, MEVENT_STATUS_LOAD_ERROR);
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
PrintMysteryMenuText(WIN_MSG, gStringVar4, 1, 2, 1);
gMain.state = 13;
}
}
@ -232,7 +237,7 @@ static void CB2_MysteryEventMenu(void)
}
break;
case 7:
if (!IsTextPrinterActive(0))
if (!IsTextPrinterActive(WIN_MSG))
gMain.state++;
break;
case 8:
@ -260,11 +265,11 @@ static void CB2_MysteryEventMenu(void)
}
break;
case 12:
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
PrintMysteryMenuText(WIN_MSG, gStringVar4, 1, 2, 1);
gMain.state++;
break;
case 13:
if (!IsTextPrinterActive(0))
if (!IsTextPrinterActive(WIN_MSG))
{
gMain.state++;
sUnused = 0;
@ -287,11 +292,11 @@ static void CB2_MysteryEventMenu(void)
break;
}
if (gLinkStatus & 0x40 && !IsLinkMaster())
if (gLinkStatus & LINK_STAT_CONN_ESTABLISHED && !IsLinkMaster())
{
CloseLink();
GetEventLoadMessage(gStringVar4, MEVENT_STATUS_LOAD_ERROR);
PrintMysteryMenuText(0, gStringVar4, 1, 2, 1);
PrintMysteryMenuText(WIN_MSG, gStringVar4, 1, 2, 1);
gMain.state = 13;
}

View File

@ -32,6 +32,12 @@
#include "wonder_news.h"
#include "constants/cable_club.h"
enum {
WIN_HEADER,
WIN_MSG,
WIN_UNK, // Cleared, but nothing is ever apparently rendered on it
};
#define LIST_MENU_TILE_NUM 10
#define LIST_MENU_PAL_NUM BG_PLTT_ID(14)
@ -98,7 +104,7 @@ static const struct BgTemplate sBGTemplates[] = {
};
static const struct WindowTemplate sMainWindows[] = {
{
[WIN_HEADER] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 0,
@ -106,7 +112,8 @@ static const struct WindowTemplate sMainWindows[] = {
.height = 2,
.paletteNum = 12,
.baseBlock = 0x0013
}, {
},
[WIN_MSG] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 15,
@ -114,7 +121,8 @@ static const struct WindowTemplate sMainWindows[] = {
.height = 4,
.paletteNum = 12,
.baseBlock = 0x004f
}, {
},
[WIN_UNK] = {
.bg = 0,
.tilemapLeft = 0,
.tilemapTop = 15,
@ -224,7 +232,7 @@ static const struct ListMenuTemplate sListMenuTemplate_ThreeOptions = {
.itemPrintFunc = NULL,
.totalItems = 3,
.maxShowed = 3,
.windowId = 0,
.windowId = 0, // Overwritten by DoMysteryGiftListMenu
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
@ -269,7 +277,7 @@ static const struct ListMenuTemplate sListMenu_ReceiveSendToss = {
.itemPrintFunc = NULL,
.totalItems = 4,
.maxShowed = 4,
.windowId = 0,
.windowId = 0, // Overwritten by DoMysteryGiftListMenu
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
@ -290,7 +298,7 @@ static const struct ListMenuTemplate sListMenu_ReceiveToss = {
.itemPrintFunc = NULL,
.totalItems = 3,
.maxShowed = 3,
.windowId = 0,
.windowId = 0, // Overwritten by DoMysteryGiftListMenu
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
@ -311,7 +319,7 @@ static const struct ListMenuTemplate sListMenu_ReceiveSend = {
.itemPrintFunc = NULL,
.totalItems = 3,
.maxShowed = 3,
.windowId = 0,
.windowId = 0, // Overwritten by DoMysteryGiftListMenu
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
@ -332,7 +340,7 @@ static const struct ListMenuTemplate sListMenu_Receive = {
.itemPrintFunc = NULL,
.totalItems = 2,
.maxShowed = 2,
.windowId = 0,
.windowId = 0, // Overwritten by DoMysteryGiftListMenu
.header_X = 0,
.item_X = 8,
.cursor_X = 0,
@ -354,9 +362,9 @@ static const u8 *const sUnusedMenuTexts[] = {
gText_ReturnToTitle
};
ALIGNED(2) static const u8 sTextColors_TopMenu[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY };
ALIGNED(2) static const u8 sTextColors_TopMenu_Copy[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY };
ALIGNED(2) static const u8 sMG_Ereader_TextColor_2[] = { TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY };
ALIGNED(2) static const u8 sTextColors_Header[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY };
ALIGNED(2) static const u8 sTextColors_Header_Copy[] = { TEXT_COLOR_TRANSPARENT, TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY };
ALIGNED(2) static const u8 sMG_Ereader_TextColor_2[] = { TEXT_COLOR_WHITE, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_LIGHT_GRAY };
static void VBlankCB_MysteryGiftEReader(void)
{
@ -420,7 +428,7 @@ static bool32 HandleMysteryGiftOrEReaderSetup(s32 isEReader)
FillBgTilemapBufferRect(1, 0x000, 0, 0, 32, 32, 17);
FillBgTilemapBufferRect(2, 0x000, 0, 0, 32, 32, 17);
MG_DrawCheckerboardPattern(3);
PrintMysteryGiftOrEReaderTopMenu(isEReader, FALSE);
PrintMysteryGiftOrEReaderHeader(isEReader, FALSE);
gMain.state++;
break;
case 2:
@ -474,26 +482,27 @@ void MainCB_FreeAllBuffersAndReturnToInitTitleScreen(void)
SetMainCallback2(CB2_InitTitleScreen);
}
void PrintMysteryGiftOrEReaderTopMenu(bool8 isEReader, bool32 useCancel)
// Print the text window at the top of the screen with the title and control instructions
void PrintMysteryGiftOrEReaderHeader(bool8 isEReader, bool32 useCancel)
{
const u8 *header;
const u8 *title;
const u8 *options;
FillWindowPixelBuffer(0, 0);
FillWindowPixelBuffer(WIN_HEADER, 0);
if (!isEReader)
{
header = gText_MysteryGift;
title = gText_MysteryGift;
options = !useCancel ? gText_PickOKExit : gText_PickOKCancel;
}
else
{
header = gJPText_MysteryGift;
title = gJPText_MysteryGift;
options = gJPText_DecideStop;
}
AddTextPrinterParameterized4(0, FONT_NORMAL, 4, 1, 0, 0, sTextColors_TopMenu, TEXT_SKIP_DRAW, header);
AddTextPrinterParameterized4(0, FONT_SMALL, GetStringRightAlignXOffset(FONT_SMALL, options, 0xDE), 1, 0, 0, sTextColors_TopMenu, TEXT_SKIP_DRAW, options);
CopyWindowToVram(0, COPYWIN_GFX);
PutWindowTilemap(0);
AddTextPrinterParameterized4(WIN_HEADER, FONT_NORMAL, 4, 1, 0, 0, sTextColors_Header, TEXT_SKIP_DRAW, title);
AddTextPrinterParameterized4(WIN_HEADER, FONT_SMALL, GetStringRightAlignXOffset(FONT_SMALL, options, 0xDE), 1, 0, 0, sTextColors_Header, TEXT_SKIP_DRAW, options);
CopyWindowToVram(WIN_HEADER, COPYWIN_GFX);
PutWindowTilemap(WIN_HEADER);
}
void MG_DrawTextBorder(u8 windowId)
@ -533,21 +542,21 @@ static void ClearScreenInBg0(bool32 ignoreTopTwoRows)
CopyBgTilemapBufferToVram(0);
}
void AddTextPrinterToWindow1(const u8 *str)
void MG_AddMessageTextPrinter(const u8 *str)
{
StringExpandPlaceholders(gStringVar4, str);
FillWindowPixelBuffer(1, 0x11);
AddTextPrinterParameterized4(1, FONT_NORMAL, 0, 1, 0, 0, sMG_Ereader_TextColor_2, 0, gStringVar4);
DrawTextBorderOuter(1, 0x001, 0xF);
PutWindowTilemap(1);
CopyWindowToVram(1, COPYWIN_FULL);
FillWindowPixelBuffer(WIN_MSG, 0x11);
AddTextPrinterParameterized4(WIN_MSG, FONT_NORMAL, 0, 1, 0, 0, sMG_Ereader_TextColor_2, 0, gStringVar4);
DrawTextBorderOuter(WIN_MSG, 0x001, 0xF);
PutWindowTilemap(WIN_MSG);
CopyWindowToVram(WIN_MSG, COPYWIN_FULL);
}
static void ClearTextWindow(void)
static void ClearMessage(void)
{
rbox_fill_rectangle(1);
ClearWindowTilemap(1);
CopyWindowToVram(1, COPYWIN_MAP);
rbox_fill_rectangle(WIN_MSG);
ClearWindowTilemap(WIN_MSG);
CopyWindowToVram(WIN_MSG, COPYWIN_MAP);
}
#define DOWN_ARROW_X 208
@ -558,18 +567,18 @@ bool32 PrintMysteryGiftMenuMessage(u8 *textState, const u8 *str)
switch (*textState)
{
case 0:
AddTextPrinterToWindow1(str);
MG_AddMessageTextPrinter(str);
(*textState)++;
break;
case 1:
DrawDownArrow(1, DOWN_ARROW_X, DOWN_ARROW_Y, 1, FALSE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
if (({JOY_NEW(A_BUTTON | B_BUTTON);}))
DrawDownArrow(WIN_MSG, DOWN_ARROW_X, DOWN_ARROW_Y, 1, FALSE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
if (JOY_NEW(A_BUTTON | B_BUTTON))
(*textState)++;
break;
case 2:
DrawDownArrow(1, DOWN_ARROW_X, DOWN_ARROW_Y, 1, TRUE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
DrawDownArrow(WIN_MSG, DOWN_ARROW_X, DOWN_ARROW_Y, 1, TRUE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
*textState = 0;
ClearTextWindow();
ClearMessage();
return TRUE;
case 0xFF:
*textState = 2;
@ -580,12 +589,12 @@ bool32 PrintMysteryGiftMenuMessage(u8 *textState, const u8 *str)
static void HideDownArrow(void)
{
DrawDownArrow(1, DOWN_ARROW_X, DOWN_ARROW_Y, 1, FALSE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
DrawDownArrow(WIN_MSG, DOWN_ARROW_X, DOWN_ARROW_Y, 1, FALSE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
}
static void ShowDownArrow(void)
{
DrawDownArrow(1, DOWN_ARROW_X, DOWN_ARROW_Y, 1, TRUE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
DrawDownArrow(WIN_MSG, DOWN_ARROW_X, DOWN_ARROW_Y, 1, TRUE, &sDownArrowCounterAndYCoordIdx[0], &sDownArrowCounterAndYCoordIdx[1]);
}
// Unused
@ -609,12 +618,12 @@ static bool32 HideDownArrowAndWaitButton(u8 *textState)
static bool32 PrintStringAndWait2Seconds(u8 *counter, const u8 *str)
{
if (*counter == 0)
AddTextPrinterToWindow1(str);
MG_AddMessageTextPrinter(str);
if (++(*counter) > 120)
{
*counter = 0;
ClearTextWindow();
ClearMessage();
return TRUE;
}
else
@ -648,8 +657,8 @@ static u32 MysteryGift_HandleThreeOptionMenu(u8 *unused0, u16 * unused1, u8 whic
response = DoMysteryGiftListMenu(&windowTemplate, &listMenuTemplate, 1, LIST_MENU_TILE_NUM, LIST_MENU_PAL_NUM);
if (response != LIST_NOTHING_CHOSEN)
{
ClearWindowTilemap(2);
CopyWindowToVram(2, COPYWIN_MAP);
ClearWindowTilemap(WIN_UNK);
CopyWindowToVram(WIN_UNK, COPYWIN_MAP);
}
return response;
}
@ -865,7 +874,7 @@ static bool32 SaveOnMysteryGiftMenu(u8 *state)
switch (*state)
{
case 0:
AddTextPrinterToWindow1(gText_DataWillBeSaved);
MG_AddMessageTextPrinter(gText_DataWillBeSaved);
(*state)++;
break;
case 1:
@ -873,7 +882,7 @@ static bool32 SaveOnMysteryGiftMenu(u8 *state)
(*state)++;
break;
case 2:
AddTextPrinterToWindow1(gText_SaveCompletedPressA);
MG_AddMessageTextPrinter(gText_SaveCompletedPressA);
(*state)++;
break;
case 3:
@ -882,7 +891,7 @@ static bool32 SaveOnMysteryGiftMenu(u8 *state)
break;
case 4:
*state = 0;
ClearTextWindow();
ClearMessage();
return TRUE;
}
@ -967,7 +976,7 @@ static bool32 PrintSuccessMessage(u8 *state, const u8 *msg, u16 * timer)
{
case 0:
if (msg != NULL)
AddTextPrinterToWindow1(msg);
MG_AddMessageTextPrinter(msg);
PlayFanfare(MUS_OBTAIN_ITEM);
*timer = 0;
(*state)++;
@ -980,7 +989,7 @@ static bool32 PrintSuccessMessage(u8 *state, const u8 *msg, u16 * timer)
if (IsFanfareTaskInactive())
{
*state = 0;
ClearTextWindow();
ClearMessage();
return TRUE;
}
break;
@ -1161,7 +1170,7 @@ static void Task_MysteryGift(u8 taskId)
if (PrintMysteryGiftMenuMessage(&data->textState, gText_DontHaveCardNewOneInput))
{
data->state = MG_STATE_SOURCE_PROMPT;
PrintMysteryGiftOrEReaderTopMenu(FALSE, TRUE);
PrintMysteryGiftOrEReaderHeader(FALSE, TRUE);
}
}
else
@ -1169,16 +1178,16 @@ static void Task_MysteryGift(u8 taskId)
if (PrintMysteryGiftMenuMessage(&data->textState, gText_DontHaveNewsNewOneInput))
{
data->state = MG_STATE_SOURCE_PROMPT;
PrintMysteryGiftOrEReaderTopMenu(FALSE, TRUE);
PrintMysteryGiftOrEReaderHeader(FALSE, TRUE);
}
}
break;
}
case MG_STATE_SOURCE_PROMPT:
if (!data->isWonderNews)
AddTextPrinterToWindow1(gText_WhereShouldCardBeAccessed);
MG_AddMessageTextPrinter(gText_WhereShouldCardBeAccessed);
else
AddTextPrinterToWindow1(gText_WhereShouldNewsBeAccessed);
MG_AddMessageTextPrinter(gText_WhereShouldNewsBeAccessed);
data->state = MG_STATE_SOURCE_PROMPT_INPUT;
break;
case MG_STATE_SOURCE_PROMPT_INPUT:
@ -1186,17 +1195,17 @@ static void Task_MysteryGift(u8 taskId)
switch (MysteryGift_HandleThreeOptionMenu(&data->textState, &data->var, TRUE))
{
case 0: // "Wireless Communication"
ClearTextWindow();
ClearMessage();
data->state = MG_STATE_CLIENT_LINK_START;
data->sourceIsFriend = FALSE;
break;
case 1: // "Friend"
ClearTextWindow();
ClearMessage();
data->state = MG_STATE_CLIENT_LINK_START;
data->sourceIsFriend = TRUE;
break;
case LIST_CANCEL:
ClearTextWindow();
ClearMessage();
if (ValidateCardOrNews(data->isWonderNews))
{
data->state = MG_STATE_LOAD_GIFT;
@ -1204,7 +1213,7 @@ static void Task_MysteryGift(u8 taskId)
else
{
data->state = MG_STATE_TO_MAIN_MENU;
PrintMysteryGiftOrEReaderTopMenu(FALSE, FALSE);
PrintMysteryGiftOrEReaderHeader(FALSE, FALSE);
}
break;
}
@ -1246,7 +1255,7 @@ static void Task_MysteryGift(u8 taskId)
}
break;
case MG_STATE_CLIENT_COMMUNICATING:
AddTextPrinterToWindow1(gText_Communicating);
MG_AddMessageTextPrinter(gText_Communicating);
data->state = MG_STATE_CLIENT_LINK;
break;
case MG_STATE_CLIENT_LINK:
@ -1379,7 +1388,7 @@ static void Task_MysteryGift(u8 taskId)
{
// Did not receive card/news, return to main menu
data->state = MG_STATE_TO_MAIN_MENU;
PrintMysteryGiftOrEReaderTopMenu(FALSE, FALSE);
PrintMysteryGiftOrEReaderHeader(FALSE, FALSE);
}
else
{
@ -1500,7 +1509,7 @@ static void Task_MysteryGift(u8 taskId)
if (PrintThrownAway(&data->textState, data->isWonderNews))
{
data->state = MG_STATE_TO_MAIN_MENU;
PrintMysteryGiftOrEReaderTopMenu(FALSE, FALSE);
PrintMysteryGiftOrEReaderHeader(FALSE, FALSE);
}
break;
case MG_STATE_GIFT_INPUT_EXIT:
@ -1546,12 +1555,12 @@ static void Task_MysteryGift(u8 taskId)
if (!data->isWonderNews)
{
AddTextPrinterToWindow1(gText_SendingWonderCard);
MG_AddMessageTextPrinter(gText_SendingWonderCard);
MysterGiftServer_CreateForCard();
}
else
{
AddTextPrinterToWindow1(gText_SendingWonderNews);
MG_AddMessageTextPrinter(gText_SendingWonderNews);
MysterGiftServer_CreateForNews();
}
data->state = MG_STATE_SERVER_LINK;
@ -1586,7 +1595,7 @@ static void Task_MysteryGift(u8 taskId)
else
{
data->state = MG_STATE_TO_MAIN_MENU;
PrintMysteryGiftOrEReaderTopMenu(FALSE, FALSE);
PrintMysteryGiftOrEReaderHeader(FALSE, FALSE);
}
}
break;
@ -1595,7 +1604,7 @@ static void Task_MysteryGift(u8 taskId)
if (PrintMysteryGiftMenuMessage(&data->textState, gText_CommunicationError))
{
data->state = MG_STATE_TO_MAIN_MENU;
PrintMysteryGiftOrEReaderTopMenu(FALSE, FALSE);
PrintMysteryGiftOrEReaderHeader(FALSE, FALSE);
}
break;
case MG_STATE_EXIT:

View File

@ -310,7 +310,7 @@ s32 WonderCard_Exit(bool32 useCancel)
FreeMonIconPalettes();
break;
case 5:
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, useCancel);
PrintMysteryGiftOrEReaderHeader(gGiftIsFromEReader, useCancel);
CopyBgTilemapBufferToVram(0);
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, RGB_BLACK);
break;
@ -785,7 +785,7 @@ s32 WonderNews_Exit(bool32 useCancel)
}
break;
case 5:
PrintMysteryGiftOrEReaderTopMenu(gGiftIsFromEReader, useCancel);
PrintMysteryGiftOrEReaderHeader(gGiftIsFromEReader, useCancel);
MG_DrawCheckerboardPattern(3);
CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(3);

View File

@ -161,14 +161,18 @@ enum {
#define MENU_DIR_RIGHT 2
#define MENU_DIR_LEFT -2
enum
{
enum {
CAN_LEARN_MOVE,
CANNOT_LEARN_MOVE,
ALREADY_KNOWS_MOVE,
CANNOT_LEARN_MOVE_IS_EGG
};
enum {
// Window ids 0-5 are implicitly assigned to each party pokemon in InitPartyMenuBoxes
WIN_MSG = PARTY_SIZE,
};
struct PartyMenuBoxInfoRects
{
void (*blitFunc)(u8, u8, u8, u8, u8, bool8);
@ -321,7 +325,7 @@ static void UpdateCurrentPartySelection(s8 *, s8);
static void UpdatePartySelectionSingleLayout(s8 *, s8);
static void UpdatePartySelectionDoubleLayout(s8 *, s8);
static s8 GetNewSlotDoubleLayout(s8, s8);
static void PartyMenuPrintText(const u8 *);
static void PrintMessage(const u8 *);
static void Task_PrintAndWaitForText(u8);
static bool16 IsMonAllowedInPokemonJump(struct Pokemon *);
static bool16 IsMonAllowedInDodrioBerryPicking(struct Pokemon *);
@ -1702,7 +1706,7 @@ u8 DisplayPartyMenuMessage(const u8 *str, bool8 keepOpen)
{
u8 taskId;
PartyMenuPrintText(str);
PrintMessage(str);
taskId = CreateTask(Task_PrintAndWaitForText, 1);
gTasks[taskId].tKeepOpen = keepOpen;
return taskId;
@ -1710,12 +1714,12 @@ u8 DisplayPartyMenuMessage(const u8 *str, bool8 keepOpen)
static void Task_PrintAndWaitForText(u8 taskId)
{
if (RunTextPrintersRetIsActive(6) != TRUE)
if (RunTextPrintersRetIsActive(WIN_MSG) != TRUE)
{
if (gTasks[taskId].tKeepOpen == FALSE)
{
ClearStdWindowAndFrameToTransparent(6, FALSE);
ClearWindowTilemap(6);
ClearStdWindowAndFrameToTransparent(WIN_MSG, FALSE);
ClearWindowTilemap(WIN_MSG);
}
DestroyTask(taskId);
}
@ -1741,8 +1745,8 @@ static void Task_ReturnToChooseMonAfterText(u8 taskId)
{
if (IsPartyMenuTextPrinterActive() != TRUE)
{
ClearStdWindowAndFrameToTransparent(6, FALSE);
ClearWindowTilemap(6);
ClearStdWindowAndFrameToTransparent(WIN_MSG, FALSE);
ClearWindowTilemap(WIN_MSG);
if (MenuHelpers_IsLinkActive() == TRUE)
{
gTasks[taskId].func = Task_WaitForLinkAndReturnToChooseMon;
@ -2550,11 +2554,11 @@ static u8 DisplaySelectionWindow(u8 windowType)
return sPartyMenuInternal->windowId[0];
}
static void PartyMenuPrintText(const u8 *text)
static void PrintMessage(const u8 *text)
{
DrawStdFrameWithCustomTileAndPalette(6, FALSE, 0x4F, 13);
DrawStdFrameWithCustomTileAndPalette(WIN_MSG, FALSE, 0x4F, 13);
gTextFlags.canABSpeedUpPrint = TRUE;
AddTextPrinterParameterized2(6, FONT_NORMAL, text, GetPlayerTextSpeedDelay(), 0, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
AddTextPrinterParameterized2(WIN_MSG, FONT_NORMAL, text, GetPlayerTextSpeedDelay(), 0, TEXT_COLOR_DARK_GRAY, TEXT_COLOR_WHITE, TEXT_COLOR_LIGHT_GRAY);
}
static void PartyMenuDisplayYesNoMenu(void)

View File

@ -765,7 +765,7 @@ static void DrawPokeblockInfo(s32 pkblId)
struct Pokeblock *pokeblock;
u16 rectTilemapSrc[2];
FillWindowPixelBuffer(7, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_FEEL, PIXEL_FILL(0));
if (pkblId != LIST_CANCEL)
{
@ -802,7 +802,7 @@ static void DrawPokeblockInfo(s32 pkblId)
for (i = 0; i < FLAVOR_COUNT; i++)
CopyToBgTilemapBufferRect(2, rectTilemapSrc, (i / 3 * 6) + 1, (i % 3 * 2) + 13, 1, 2);
CopyWindowToVram(7, COPYWIN_GFX);
CopyWindowToVram(WIN_FEEL, COPYWIN_GFX);
}
ScheduleBgCopyTilemapToVram(0);

View File

@ -53,6 +53,13 @@ enum {
TAG_FLY_ICON,
};
// Window IDs for the fly map
enum {
WIN_MAPSEC_NAME,
WIN_MAPSEC_NAME_TALL, // For fly destinations with subtitles (just Ever Grande)
WIN_FLY_TO_WHERE,
};
struct MultiNameFlyDest
{
const u8 *const *name;
@ -378,7 +385,7 @@ static const struct BgTemplate sFlyMapBgTemplates[] =
static const struct WindowTemplate sFlyMapWindowTemplates[] =
{
{
[WIN_MAPSEC_NAME] = {
.bg = 0,
.tilemapLeft = 17,
.tilemapTop = 17,
@ -387,7 +394,7 @@ static const struct WindowTemplate sFlyMapWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x01
},
{
[WIN_MAPSEC_NAME_TALL] = {
.bg = 0,
.tilemapLeft = 17,
.tilemapTop = 15,
@ -396,7 +403,7 @@ static const struct WindowTemplate sFlyMapWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x19
},
{
[WIN_FLY_TO_WHERE] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 18,
@ -1394,7 +1401,7 @@ void CreateRegionMapCursor(u16 tileTag, u16 paletteTag)
}
LoadSpriteSheet(&sheet);
LoadSpritePalette(&palette);
spriteId = CreateSprite(&template, 0x38, 0x48, 0);
spriteId = CreateSprite(&template, 56, 72, 0);
if (spriteId != MAX_SPRITES)
{
sRegionMap->cursorSprite = &gSprites[spriteId];
@ -1703,9 +1710,9 @@ void CB2_OpenFlyMap(void)
break;
case 7:
LoadPalette(sRegionMapFramePal, BG_PLTT_ID(1), sizeof(sRegionMapFramePal));
PutWindowTilemap(2);
FillWindowPixelBuffer(2, PIXEL_FILL(0));
AddTextPrinterParameterized(2, FONT_NORMAL, gText_FlyToWhere, 0, 1, 0, NULL);
PutWindowTilemap(WIN_FLY_TO_WHERE);
FillWindowPixelBuffer(WIN_FLY_TO_WHERE, PIXEL_FILL(0));
AddTextPrinterParameterized(WIN_FLY_TO_WHERE, FONT_NORMAL, gText_FlyToWhere, 0, 1, 0, NULL);
ScheduleBgCopyTilemapToVram(0);
gMain.state++;
break;
@ -1758,7 +1765,7 @@ static void DrawFlyDestTextWindow(void)
bool32 namePrinted;
const u8 *name;
if (sFlyMap->regionMap.mapSecType > MAPSECTYPE_NONE && sFlyMap->regionMap.mapSecType <= MAPSECTYPE_BATTLE_FRONTIER)
if (sFlyMap->regionMap.mapSecType > MAPSECTYPE_NONE && sFlyMap->regionMap.mapSecType < NUM_MAPSEC_TYPES)
{
namePrinted = FALSE;
for (i = 0; i < ARRAY_COUNT(sMultiNameFlyDestinations); i++)
@ -1769,11 +1776,11 @@ static void DrawFlyDestTextWindow(void)
{
StringLength(sMultiNameFlyDestinations[i].name[sFlyMap->regionMap.posWithinMapSec]);
namePrinted = TRUE;
ClearStdWindowAndFrameToTransparent(0, FALSE);
DrawStdFrameWithCustomTileAndPalette(1, FALSE, 101, 13);
AddTextPrinterParameterized(1, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL);
ClearStdWindowAndFrameToTransparent(WIN_MAPSEC_NAME, FALSE);
DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME_TALL, FALSE, 101, 13);
AddTextPrinterParameterized(WIN_MAPSEC_NAME_TALL, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL);
name = sMultiNameFlyDestinations[i].name[sFlyMap->regionMap.posWithinMapSec];
AddTextPrinterParameterized(1, FONT_NORMAL, name, GetStringRightAlignXOffset(FONT_NORMAL, name, 96), 17, 0, NULL);
AddTextPrinterParameterized(WIN_MAPSEC_NAME_TALL, FONT_NORMAL, name, GetStringRightAlignXOffset(FONT_NORMAL, name, 96), 17, 0, NULL);
ScheduleBgCopyTilemapToVram(0);
sDrawFlyDestTextWindow = TRUE;
}
@ -1784,15 +1791,15 @@ static void DrawFlyDestTextWindow(void)
{
if (sDrawFlyDestTextWindow == TRUE)
{
ClearStdWindowAndFrameToTransparent(1, FALSE);
DrawStdFrameWithCustomTileAndPalette(0, FALSE, 101, 13);
ClearStdWindowAndFrameToTransparent(WIN_MAPSEC_NAME_TALL, FALSE);
DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME, FALSE, 101, 13);
}
else
{
// Window is already drawn, just empty it
FillWindowPixelBuffer(0, PIXEL_FILL(1));
FillWindowPixelBuffer(WIN_MAPSEC_NAME, PIXEL_FILL(1));
}
AddTextPrinterParameterized(0, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL);
AddTextPrinterParameterized(WIN_MAPSEC_NAME, FONT_NORMAL, sFlyMap->regionMap.mapSecName, 0, 1, 0, NULL);
ScheduleBgCopyTilemapToVram(0);
sDrawFlyDestTextWindow = FALSE;
}
@ -1802,11 +1809,11 @@ static void DrawFlyDestTextWindow(void)
// Selection is on MAPSECTYPE_NONE, draw empty fly destination text window
if (sDrawFlyDestTextWindow == TRUE)
{
ClearStdWindowAndFrameToTransparent(1, FALSE);
DrawStdFrameWithCustomTileAndPalette(0, FALSE, 101, 13);
ClearStdWindowAndFrameToTransparent(WIN_MAPSEC_NAME_TALL, FALSE);
DrawStdFrameWithCustomTileAndPalette(WIN_MAPSEC_NAME, FALSE, 101, 13);
}
FillWindowPixelBuffer(0, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_GFX);
FillWindowPixelBuffer(WIN_MAPSEC_NAME, PIXEL_FILL(1));
CopyWindowToVram(WIN_MAPSEC_NAME, COPYWIN_GFX);
ScheduleBgCopyTilemapToVram(0);
sDrawFlyDestTextWindow = FALSE;
}

View File

@ -49,6 +49,11 @@ enum {
SELECTION_NONE
};
enum {
WIN_TIME,
WIN_MSG,
};
struct ResetRtcInputMap
{
/*0x0*/ u8 dataIndex;
@ -79,7 +84,7 @@ static const struct BgTemplate sBgTemplates[] =
static const struct WindowTemplate sWindowTemplates[] =
{
{
[WIN_TIME] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 1,
@ -88,7 +93,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x155
},
{
[WIN_MSG] = {
.bg = 0,
.tilemapLeft = 2,
.tilemapTop = 15,
@ -562,8 +567,8 @@ static void VBlankCB(void)
static void ShowMessage(const u8 *str)
{
DrawDialogFrameWithCustomTileAndPalette(1, FALSE, 0x200, 0xF);
AddTextPrinterParameterized(1, FONT_NORMAL, str, 0, 1, 0, NULL);
DrawDialogFrameWithCustomTileAndPalette(WIN_MSG, FALSE, 0x200, 0xF);
AddTextPrinterParameterized(WIN_MSG, FONT_NORMAL, str, 0, 1, 0, NULL);
ScheduleBgCopyTilemapToVram(0);
}
@ -576,11 +581,11 @@ static void Task_ShowResetRtcPrompt(u8 taskId)
switch (tState)
{
case 0:
DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x214, 0xE);
DrawStdFrameWithCustomTileAndPalette(WIN_TIME, FALSE, 0x214, 0xE);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_PresentTime, 0, 1, TEXT_SKIP_DRAW, 0);
AddTextPrinterParameterized(WIN_TIME, FONT_NORMAL, gText_PresentTime, 0, 1, TEXT_SKIP_DRAW, 0);
PrintTime(
0,
WIN_TIME,
0,
17,
gLocalTime.days,
@ -588,9 +593,9 @@ static void Task_ShowResetRtcPrompt(u8 taskId)
gLocalTime.minutes,
gLocalTime.seconds);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_PreviousTime, 0, 33, TEXT_SKIP_DRAW, 0);
AddTextPrinterParameterized(WIN_TIME, FONT_NORMAL, gText_PreviousTime, 0, 33, TEXT_SKIP_DRAW, 0);
PrintTime(
0,
WIN_TIME,
0,
49,
gSaveBlock2Ptr->lastBerryTreeUpdate.days,
@ -599,7 +604,7 @@ static void Task_ShowResetRtcPrompt(u8 taskId)
gSaveBlock2Ptr->lastBerryTreeUpdate.seconds);
ShowMessage(gText_ResetRTCConfirmCancel);
CopyWindowToVram(0, COPYWIN_GFX);
CopyWindowToVram(WIN_TIME, COPYWIN_GFX);
ScheduleBgCopyTilemapToVram(0);
tState++;
case 1:
@ -666,7 +671,7 @@ static void Task_ResetRtcScreen(u8 taskId)
// Wait for A or B press on prompt first
if (gTasks[tSubTaskId].isActive != TRUE)
{
ClearStdWindowAndFrameToTransparent(0, FALSE);
ClearStdWindowAndFrameToTransparent(WIN_TIME, FALSE);
ShowMessage(gText_PleaseResetTime);
gLocalTime = gSaveBlock2Ptr->lastBerryTreeUpdate;
tSubTaskId = CreateTask(Task_ResetRtc_Init, 80);

View File

@ -33,6 +33,12 @@
#include "constants/trainers.h"
#include "constants/union_room.h"
enum {
WIN_MSG,
WIN_CARD_TEXT,
WIN_TRAINER_PIC,
};
struct TrainerCardData
{
u8 mainState;
@ -226,7 +232,7 @@ static const struct BgTemplate sTrainerCardBgTemplates[4] =
static const struct WindowTemplate sTrainerCardWindowTemplates[] =
{
{
[WIN_MSG] = {
.bg = 1,
.tilemapLeft = 2,
.tilemapTop = 15,
@ -235,7 +241,7 @@ static const struct WindowTemplate sTrainerCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x253,
},
{
[WIN_CARD_TEXT] = {
.bg = 1,
.tilemapLeft = 1,
.tilemapTop = 1,
@ -244,7 +250,7 @@ static const struct WindowTemplate sTrainerCardWindowTemplates[] =
.paletteNum = 15,
.baseBlock = 0x1,
},
{
[WIN_TRAINER_PIC] = {
.bg = 3,
.tilemapLeft = 19,
.tilemapTop = 5,
@ -376,7 +382,7 @@ static void Task_TrainerCard(u8 taskId)
case 0:
if (!IsDma3ManagerBusyWithBgCopy())
{
FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_CARD_TEXT, PIXEL_FILL(0));
sData->mainState++;
}
break;
@ -385,13 +391,13 @@ static void Task_TrainerCard(u8 taskId)
sData->mainState++;
break;
case 2:
DrawTrainerCardWindow(1);
DrawTrainerCardWindow(WIN_CARD_TEXT);
sData->mainState++;
break;
case 3:
FillWindowPixelBuffer(2, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_TRAINER_PIC, PIXEL_FILL(0));
CreateTrainerCardTrainerPic();
DrawTrainerCardWindow(2);
DrawTrainerCardWindow(WIN_TRAINER_PIC);
sData->mainState++;
break;
case 4:
@ -411,7 +417,7 @@ static void Task_TrainerCard(u8 taskId)
if (gWirelessCommType == 1 && gReceivedRemoteLinkPlayers == TRUE)
{
LoadWirelessStatusIndicatorSpriteGfx();
CreateWirelessStatusIndicatorSprite(230, 150);
CreateWirelessStatusIndicatorSprite(DISPLAY_WIDTH - 10, DISPLAY_HEIGHT - 10);
}
BlendPalettes(PALETTES_ALL, 16, sData->blendColor);
BeginNormalPaletteFade(PALETTES_ALL, 0, 16, 0, sData->blendColor);
@ -434,7 +440,7 @@ static void Task_TrainerCard(u8 taskId)
if (!gReceivedRemoteLinkPlayers && sData->timeColonNeedDraw)
{
PrintTimeOnCard();
DrawTrainerCardWindow(1);
DrawTrainerCardWindow(WIN_CARD_TEXT);
sData->timeColonNeedDraw = FALSE;
}
if (JOY_NEW(A_BUTTON))
@ -497,9 +503,9 @@ static void Task_TrainerCard(u8 taskId)
break;
case STATE_WAIT_LINK_PARTNER:
SetCloseLinkCallback();
DrawDialogueFrame(0, TRUE);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_WaitingTrainerFinishReading, 0, 1, 255, 0);
CopyWindowToVram(0, COPYWIN_FULL);
DrawDialogueFrame(WIN_MSG, TRUE);
AddTextPrinterParameterized(WIN_MSG, FONT_NORMAL, gText_WaitingTrainerFinishReading, 0, 1, 255, 0);
CopyWindowToVram(WIN_MSG, COPYWIN_FULL);
sData->mainState = STATE_CLOSE_CARD_LINK;
break;
case STATE_CLOSE_CARD_LINK:
@ -1002,9 +1008,9 @@ static void PrintNameOnCardFront(void)
StringCopy(txtPtr, sData->trainerCard.playerName);
ConvertInternationalString(txtPtr, sData->language);
if (sData->cardType == CARD_TYPE_FRLG)
AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 28, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 20, 28, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
else
AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 16, 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
}
static void PrintIdOnCard(void)
@ -1026,7 +1032,7 @@ static void PrintIdOnCard(void)
top = 9;
}
AddTextPrinterParameterized3(1, FONT_NORMAL, xPos, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, xPos, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, buffer);
}
static void PrintMoneyOnCard(void)
@ -1035,9 +1041,9 @@ static void PrintMoneyOnCard(void)
u8 top;
if (!sData->isHoenn)
AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 56, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 20, 56, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney);
else
AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 57, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 16, 57, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardMoney);
ConvertIntToDecimalStringN(gStringVar1, sData->trainerCard.money, STR_CONV_MODE_LEFT_ALIGN, 6);
StringExpandPlaceholders(gStringVar4, gText_PokedollarVar1);
@ -1051,7 +1057,7 @@ static void PrintMoneyOnCard(void)
xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 128);
top = 57;
}
AddTextPrinterParameterized3(1, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
}
static u16 GetCaughtMonsCount(void)
@ -1069,9 +1075,9 @@ static void PrintPokedexOnCard(void)
if (FlagGet(FLAG_SYS_POKEDEX_GET))
{
if (!sData->isHoenn)
AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 72, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 20, 72, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex);
else
AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 73, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 16, 73, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardPokedex);
StringCopy(ConvertIntToDecimalStringN(gStringVar4, sData->trainerCard.caughtMonsCount, STR_CONV_MODE_LEFT_ALIGN, 3), gText_EmptyString6);
if (!sData->isHoenn)
{
@ -1083,7 +1089,7 @@ static void PrintPokedexOnCard(void)
xOffset = GetStringRightAlignXOffset(FONT_NORMAL, gStringVar4, 128);
top = 73;
}
AddTextPrinterParameterized3(1, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, xOffset, top, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
}
}
@ -1097,9 +1103,9 @@ static void PrintTimeOnCard(void)
u32 x, y, totalWidth;
if (!sData->isHoenn)
AddTextPrinterParameterized3(1, FONT_NORMAL, 20, 88, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 20, 88, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime);
else
AddTextPrinterParameterized3(1, FONT_NORMAL, 16, 89, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 16, 89, sTrainerCardTextColors, TEXT_SKIP_DRAW, gText_TrainerCardTime);
if (sData->isLink)
{
@ -1131,14 +1137,14 @@ static void PrintTimeOnCard(void)
totalWidth = width + 30;
x -= totalWidth;
FillWindowPixelRect(1, PIXEL_FILL(0), x, y, totalWidth, 15);
FillWindowPixelRect(WIN_CARD_TEXT, PIXEL_FILL(0), x, y, totalWidth, 15);
ConvertIntToDecimalStringN(gStringVar4, hours, STR_CONV_MODE_RIGHT_ALIGN, 3);
AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
x += 18;
AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTimeColonTextColors[sData->timeColonInvisible], TEXT_SKIP_DRAW, gText_Colon2);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, x, y, sTimeColonTextColors[sData->timeColonInvisible], TEXT_SKIP_DRAW, gText_Colon2);
x += width;
ConvertIntToDecimalStringN(gStringVar4, minutes, STR_CONV_MODE_LEADING_ZEROS, 2);
AddTextPrinterParameterized3(1, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, x, y, sTrainerCardTextColors, TEXT_SKIP_DRAW, gStringVar4);
}
static void PrintProfilePhraseOnCard(void)
@ -1148,10 +1154,10 @@ static void PrintProfilePhraseOnCard(void)
if (sData->isLink)
{
AddTextPrinterParameterized3(1, FONT_NORMAL, 8, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[0]);
AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[0], 0) + 14, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[1]);
AddTextPrinterParameterized3(1, FONT_NORMAL, 8, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[2]);
AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[2], 0) + 14, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[3]);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 8, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[0]);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[0], 0) + 14, yOffsetsLine1[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[1]);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 8, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[2]);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, GetStringWidth(FONT_NORMAL, sData->easyChatProfile[2], 0) + 14, yOffsetsLine2[sData->isHoenn], sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->easyChatProfile[3]);
}
}
@ -1169,9 +1175,9 @@ static void BufferNameForCardBack(void)
static void PrintNameOnCardBack(void)
{
if (!sData->isHoenn)
AddTextPrinterParameterized3(1, FONT_NORMAL, 136, 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, 136, 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard);
else
AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, sData->textPlayersCard, 216), 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, sData->textPlayersCard, 216), 9, sTrainerCardTextColors, TEXT_SKIP_DRAW, sData->textPlayersCard);
}
static const u8 sText_HofTime[] = _("{STR_VAR_1}:{STR_VAR_2}:{STR_VAR_3}");
@ -1192,8 +1198,8 @@ static void PrintStatOnBackOfCard(u8 top, const u8 *statName, u8 *stat, const u8
static const u8 xOffsets[] = {8, 16};
static const u8 widths[] = {216, 216};
AddTextPrinterParameterized3(1, FONT_NORMAL, xOffsets[sData->isHoenn], top * 16 + 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, statName);
AddTextPrinterParameterized3(1, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, stat, widths[sData->isHoenn]), top * 16 + 33, color, TEXT_SKIP_DRAW, stat);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, xOffsets[sData->isHoenn], top * 16 + 33, sTrainerCardTextColors, TEXT_SKIP_DRAW, statName);
AddTextPrinterParameterized3(WIN_CARD_TEXT, FONT_NORMAL, GetStringRightAlignXOffset(FONT_NORMAL, stat, widths[sData->isHoenn]), top * 16 + 33, color, TEXT_SKIP_DRAW, stat);
}
static void PrintHofDebutTimeOnCard(void)
@ -1672,7 +1678,7 @@ static bool8 Task_DrawFlippedCardSide(struct Task *task)
switch (sData->flipDrawState)
{
case 0:
FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_CARD_TEXT, PIXEL_FILL(0));
FillBgTilemapBufferRect_Palette0(3, 0, 0, 0, 0x20, 0x20);
break;
case 1:
@ -1691,13 +1697,13 @@ static bool8 Task_DrawFlippedCardSide(struct Task *task)
if (!sData->onBack)
DrawCardFrontOrBack(sData->backTilemap);
else
DrawTrainerCardWindow(1);
DrawTrainerCardWindow(WIN_CARD_TEXT);
break;
case 3:
if (!sData->onBack)
DrawCardBackStats();
else
FillWindowPixelBuffer(2, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_TRAINER_PIC, PIXEL_FILL(0));
break;
case 4:
if (sData->onBack)
@ -1722,12 +1728,12 @@ static bool8 Task_SetCardFlipped(struct Task *task)
// If on back of card, draw front of card because its being flipped
if (sData->onBack)
{
DrawTrainerCardWindow(2);
DrawTrainerCardWindow(WIN_TRAINER_PIC);
DrawCardScreenBackground(sData->bgTilemap);
DrawCardFrontOrBack(sData->frontTilemap);
DrawStarsAndBadgesOnCard();
}
DrawTrainerCardWindow(1);
DrawTrainerCardWindow(WIN_CARD_TEXT);
sData->onBack ^= 1;
task->tFlipState++;
sData->allowDMACopy = TRUE;
@ -1882,7 +1888,7 @@ static void CreateTrainerCardTrainerPic(void)
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][0],
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][1],
8,
2);
WIN_TRAINER_PIC);
}
else
{
@ -1891,6 +1897,6 @@ static void CreateTrainerCardTrainerPic(void)
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][0],
sTrainerPicOffset[sData->isHoenn][sData->trainerCard.gender][1],
8,
2);
WIN_TRAINER_PIC);
}
}

View File

@ -1927,7 +1927,7 @@ static void Task_SendMysteryGift(u8 taskId)
data->state = 3;
break;
case 3:
AddTextPrinterToWindow1(gStringVar4);
MG_AddMessageTextPrinter(gStringVar4);
data->state = 4;
break;
case 4:
@ -2001,7 +2001,7 @@ static void Task_SendMysteryGift(u8 taskId)
}
break;
case 9:
AddTextPrinterToWindow1(gStringVar4);
MG_AddMessageTextPrinter(gStringVar4);
data->state = 10;
break;
case 10:
@ -2104,7 +2104,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId)
data->state = 1;
break;
case 1:
AddTextPrinterToWindow1(sText_ChooseTrainer);
MG_AddMessageTextPrinter(sText_ChooseTrainer);
data->state = 2;
break;
case 2:
@ -2176,7 +2176,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId)
}
break;
case 4:
AddTextPrinterToWindow1(sText_AwaitingPlayersResponse);
MG_AddMessageTextPrinter(sText_AwaitingPlayersResponse);
CopyAndTranslatePlayerName(gStringVar1, &data->playerList->players[data->leaderId]);
data->state = 5;
break;
@ -2195,7 +2195,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId)
data->state = 8;
break;
case RFU_STATUS_JOIN_GROUP_OK:
AddTextPrinterToWindow1(sText_PlayerSentBackOK);
MG_AddMessageTextPrinter(sText_PlayerSentBackOK);
RfuSetStatus(RFU_STATUS_OK, 0);
break;
}
@ -2223,7 +2223,7 @@ static void Task_CardOrNewsWithFriend(u8 taskId)
break;
case 7:
DestroyWirelessStatusIndicatorSprite();
AddTextPrinterToWindow1(sText_PleaseStartOver);
MG_AddMessageTextPrinter(sText_PleaseStartOver);
DestroyTask(taskId);
LinkRfu_Shutdown();
gSpecialVar_Result = LINKUP_FAILED;
@ -2272,7 +2272,7 @@ static void Task_CardOrNewsOverWireless(u8 taskId)
data->state = 1;
break;
case 1:
AddTextPrinterToWindow1(sText_SearchingForWirelessSystemWait);
MG_AddMessageTextPrinter(sText_SearchingForWirelessSystemWait);
data->state = 2;
break;
case 2:
@ -2341,7 +2341,7 @@ static void Task_CardOrNewsOverWireless(u8 taskId)
}
break;
case 4:
AddTextPrinterToWindow1(sText_AwaitingResponseFromWirelessSystem);
MG_AddMessageTextPrinter(sText_AwaitingResponseFromWirelessSystem);
CopyAndTranslatePlayerName(gStringVar1, &data->playerList->players[data->leaderId]);
data->state = 5;
break;
@ -2360,7 +2360,7 @@ static void Task_CardOrNewsOverWireless(u8 taskId)
data->state = 8;
break;
case RFU_STATUS_JOIN_GROUP_OK:
AddTextPrinterToWindow1(sText_WirelessLinkEstablished);
MG_AddMessageTextPrinter(sText_WirelessLinkEstablished);
RfuSetStatus(RFU_STATUS_OK, 0);
break;
}

View File

@ -116,6 +116,13 @@ enum {
// Shared by all above
#define PALTAG_INTERFACE 0
enum {
WIN_CHAT_HISTORY,
WIN_TEXT_ENTRY,
WIN_KEYBOARD,
WIN_SWAP_MENU,
};
struct UnionRoomChat
{
u32 filler1;
@ -560,7 +567,7 @@ static const struct BgTemplate sBgTemplates[] = {
};
static const struct WindowTemplate sWinTemplates[] = {
{
[WIN_CHAT_HISTORY] = {
.bg = 3,
.tilemapLeft = 8,
.tilemapTop = 1,
@ -568,7 +575,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 19,
.paletteNum = 15,
.baseBlock = 0x0001,
}, {
},
[WIN_TEXT_ENTRY] = {
.bg = 1,
.tilemapLeft = 9,
.tilemapTop = 18,
@ -576,7 +584,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 2,
.paletteNum = 12,
.baseBlock = 0x007a,
}, {
},
[WIN_KEYBOARD] = {
.bg = 1,
.tilemapLeft = 0,
.tilemapTop = 2,
@ -584,7 +593,8 @@ static const struct WindowTemplate sWinTemplates[] = {
.height = 15,
.paletteNum = 7,
.baseBlock = 0x0020,
}, {
},
[WIN_SWAP_MENU] = {
.bg = 0,
.tilemapLeft = 1,
.tilemapTop = 2,
@ -2280,7 +2290,7 @@ static bool32 Display_ShowKeyboardSwapMenu(u8 *state)
{
case 0:
ShowKeyboardSwapMenu();
CopyWindowToVram(3, COPYWIN_FULL);
CopyWindowToVram(WIN_SWAP_MENU, COPYWIN_FULL);
break;
case 1:
return IsDma3ManagerBusyWithBgCopy();
@ -2296,7 +2306,7 @@ static bool32 Display_HideKeyboardSwapMenu(u8 *state)
{
case 0:
HideKeyboardSwapMenu();
CopyWindowToVram(3, COPYWIN_FULL);
CopyWindowToVram(WIN_SWAP_MENU, COPYWIN_FULL);
break;
case 1:
return IsDma3ManagerBusyWithBgCopy();
@ -2316,7 +2326,7 @@ static bool32 Display_SwitchPages(u8 *state)
return TRUE;
PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(WIN_KEYBOARD, COPYWIN_GFX);
break;
case 1:
if (IsDma3ManagerBusyWithBgCopy())
@ -2393,7 +2403,7 @@ static bool32 Display_UpdateMessageBuffer(u8 *state)
FillTextEntryWindow(x, width, 0);
str = GetMessageEntryBuffer();
DrawTextEntryMessage(0, str, 3, 1, 2);
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
@ -2422,7 +2432,7 @@ static bool32 Display_AskRegisterText(u8 *state)
length = StringLength_Multibyte(str);
FillTextEntryWindow(x, length, PIXEL_FILL(6));
DrawTextEntryMessage(x, str, 0, 4, 5);
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
@ -2463,7 +2473,7 @@ static bool32 Display_CancelRegister(u8 *state)
length = StringLength_Multibyte(str);
FillTextEntryWindow(x, length, PIXEL_FILL(0));
DrawTextEntryMessage(x, str, 3, 1, 2);
CopyWindowToVram(1, COPYWIN_GFX);
CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_GFX);
break;
case 1:
if (!IsDma3ManagerBusyWithBgCopy())
@ -2501,7 +2511,7 @@ static bool32 Display_ReturnToKeyboard(u8 *state)
{
case 0:
PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_GFX);
CopyWindowToVram(WIN_KEYBOARD, COPYWIN_GFX);
(*state)++;
break;
case 1:
@ -2527,7 +2537,7 @@ static bool32 Display_ScrollChat(u8 *state)
str = GetLastReceivedMessage();
colorIdx = GetReceivedPlayerIndex();
PrintChatMessage(row, str, colorIdx);
CopyWindowToVram(0, COPYWIN_GFX);
CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_GFX);
break;
case 1:
if (IsDma3ManagerBusyWithBgCopy())
@ -2546,8 +2556,8 @@ static bool32 Display_ScrollChat(u8 *state)
}
// fall through
case 2:
ScrollWindow(0, 0, 5, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_GFX);
ScrollWindow(WIN_CHAT_HISTORY, 0, 5, PIXEL_FILL(1));
CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_GFX);
sDisplay->scrollCount++;
(*state)++;
// fall through
@ -2864,7 +2874,7 @@ static void DestroyStdMessageWindow(void)
static void FillTextEntryWindow(u16 x, u16 width, u8 fillValue)
{
FillWindowPixelRect(1, fillValue, x * 8, 1, width * 8, 14);
FillWindowPixelRect(WIN_TEXT_ENTRY, fillValue, x * 8, 1, width * 8, 14);
}
static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shadowColor)
@ -2881,7 +2891,7 @@ static void DrawTextEntryMessage(u16 x, u8 *str, u8 bgColor, u8 fgColor, u8 shad
strBuffer[1] = EXT_CTRL_CODE_MIN_LETTER_SPACING;
strBuffer[2] = 8;
StringCopy(&strBuffer[3], str);
AddTextPrinterParameterized3(1, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer);
AddTextPrinterParameterized3(WIN_TEXT_ENTRY, FONT_SHORT, x * 8, 1, color, TEXT_SKIP_DRAW, strBuffer);
}
static void PrintCurrentKeyboardPage(void)
@ -2894,7 +2904,7 @@ static void PrintCurrentKeyboardPage(void)
u8 str[45];
u8 *str2;
FillWindowPixelBuffer(2, PIXEL_FILL(15));
FillWindowPixelBuffer(WIN_KEYBOARD, PIXEL_FILL(15));
page = GetCurrentKeyboardPage();
color[0] = TEXT_COLOR_TRANSPARENT;
color[1] = TEXT_DYNAMIC_COLOR_5;
@ -2916,7 +2926,7 @@ static void PrintCurrentKeyboardPage(void)
return;
StringCopy(&str[3], sUnionRoomKeyboardText[page][i]);
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
}
}
else
@ -2927,7 +2937,7 @@ static void PrintCurrentKeyboardPage(void)
str2 = GetRegisteredTextByRow(i);
if (GetStringWidth(FONT_SMALL, str2, 0) <= 40)
{
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2);
AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str2);
}
else
{
@ -2938,8 +2948,8 @@ static void PrintCurrentKeyboardPage(void)
StringCopyN_Multibyte(str, str2, length);
} while (GetStringWidth(FONT_SMALL, str, 0) > 35);
AddTextPrinterParameterized3(2, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
AddTextPrinterParameterized3(2, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis);
AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left, top, color, TEXT_SKIP_DRAW, str);
AddTextPrinterParameterized3(WIN_KEYBOARD, FONT_SMALL, left + 35, top, color, TEXT_SKIP_DRAW, sText_Ellipsis);
}
}
}
@ -2989,17 +2999,17 @@ static bool32 SlideKeyboardPageIn(void)
static void ShowKeyboardSwapMenu(void)
{
FillWindowPixelBuffer(3, PIXEL_FILL(1));
DrawTextBorderOuter(3, 1, 13);
PrintMenuActionTextsAtPos(3, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts);
InitMenuNormal(3, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage());
PutWindowTilemap(3);
FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1));
DrawTextBorderOuter(WIN_SWAP_MENU, 1, 13);
PrintMenuActionTextsAtPos(WIN_SWAP_MENU, FONT_SHORT, 8, 1, 14, ARRAY_COUNT(sKeyboardPageTitleTexts), sKeyboardPageTitleTexts);
InitMenuNormal(WIN_SWAP_MENU, FONT_SHORT, 0, 1, 14, 5, GetCurrentKeyboardPage());
PutWindowTilemap(WIN_SWAP_MENU);
}
static void HideKeyboardSwapMenu(void)
{
ClearStdWindowAndFrameToTransparent(3, FALSE);
ClearWindowTilemap(3);
ClearStdWindowAndFrameToTransparent(WIN_SWAP_MENU, FALSE);
ClearWindowTilemap(WIN_SWAP_MENU);
}
static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
@ -3009,8 +3019,8 @@ static void PrintChatMessage(u16 row, u8 *str, u8 colorIdx)
color[0] = TEXT_COLOR_WHITE;
color[1] = colorIdx * 2 + 2;
color[2] = colorIdx * 2 + 3;
FillWindowPixelRect(0, PIXEL_FILL(1), 0, row * 15, 168, 15);
AddTextPrinterParameterized3(0, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str);
FillWindowPixelRect(WIN_CHAT_HISTORY, PIXEL_FILL(1), 0, row * 15, 168, 15);
AddTextPrinterParameterized3(WIN_CHAT_HISTORY, FONT_SHORT, 0, row * 15 + 1, color, TEXT_SKIP_DRAW, str);
}
static void ResetGpuBgState(void)
@ -3087,16 +3097,16 @@ static void LoadChatUnkPalette(void)
static void LoadChatMessagesWindow(void)
{
LoadPalette(sUnk_Palette2, BG_PLTT_ID(15), sizeof(sUnk_Palette2));
PutWindowTilemap(0);
FillWindowPixelBuffer(0, PIXEL_FILL(1));
CopyWindowToVram(0, COPYWIN_FULL);
PutWindowTilemap(WIN_CHAT_HISTORY);
FillWindowPixelBuffer(WIN_CHAT_HISTORY, PIXEL_FILL(1));
CopyWindowToVram(WIN_CHAT_HISTORY, COPYWIN_FULL);
}
static void LoadKeyboardWindow(void)
{
PutWindowTilemap(2);
PutWindowTilemap(WIN_KEYBOARD);
PrintCurrentKeyboardPage();
CopyWindowToVram(2, COPYWIN_FULL);
CopyWindowToVram(WIN_KEYBOARD, COPYWIN_FULL);
}
static void LoadTextEntryWindow(void)
@ -3107,18 +3117,18 @@ static void LoadTextEntryWindow(void)
unused[1] = 0xFF;
for (i = 0; i < MAX_MESSAGE_LENGTH; i++)
BlitBitmapToWindow(1, sDisplay->unk2128, i * 8, 0, 8, 16);
BlitBitmapToWindow(WIN_TEXT_ENTRY, sDisplay->unk2128, i * 8, 0, 8, 16);
FillWindowPixelBuffer(1, PIXEL_FILL(0));
PutWindowTilemap(1);
CopyWindowToVram(1, COPYWIN_FULL);
FillWindowPixelBuffer(WIN_TEXT_ENTRY, PIXEL_FILL(0));
PutWindowTilemap(WIN_TEXT_ENTRY);
CopyWindowToVram(WIN_TEXT_ENTRY, COPYWIN_FULL);
}
static void LoadKeyboardSwapWindow(void)
{
FillWindowPixelBuffer(3, PIXEL_FILL(1));
LoadUserWindowBorderGfx(3, 1, BG_PLTT_ID(13));
LoadUserWindowBorderGfx_(3, 0xA, BG_PLTT_ID(2));
FillWindowPixelBuffer(WIN_SWAP_MENU, PIXEL_FILL(1));
LoadUserWindowBorderGfx(WIN_SWAP_MENU, 1, BG_PLTT_ID(13));
LoadUserWindowBorderGfx_(WIN_SWAP_MENU, 0xA, BG_PLTT_ID(2));
LoadPalette(gStandardMenuPalette, BG_PLTT_ID(14), PLTT_SIZE_4BPP);
}

View File

@ -55,25 +55,28 @@ static void SpriteCB_AMIndicator(struct Sprite *sprite);
#define PALTAG_WALL_CLOCK_MALE 0x1000
#define PALTAG_WALL_CLOCK_FEMALE 0x1001
enum
{
enum {
PERIOD_AM,
PERIOD_PM,
};
enum
{
enum {
MOVE_NONE,
MOVE_BACKWARD,
MOVE_FORWARD,
};
enum {
WIN_MSG,
WIN_BUTTON_LABEL,
};
static const u32 sHand_Gfx[] = INCBIN_U32("graphics/wallclock/hand.4bpp.lz");
static const u16 sTextPrompt_Pal[] = INCBIN_U16("graphics/wallclock/text_prompt.gbapal"); // for "Cancel" or "Confirm"
static const struct WindowTemplate sWindowTemplates[] =
{
{
[WIN_MSG] = {
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 17,
@ -82,7 +85,7 @@ static const struct WindowTemplate sWindowTemplates[] =
.paletteNum = 14,
.baseBlock = 512
},
{
[WIN_BUTTON_LABEL] = {
.bg = 2,
.tilemapLeft = 24,
.tilemapTop = 16,
@ -717,8 +720,8 @@ void CB2_StartWallClock(void)
WallClockInit();
AddTextPrinterParameterized(1, FONT_NORMAL, gText_Confirm3, 0, 1, 0, NULL);
PutWindowTilemap(1);
AddTextPrinterParameterized(WIN_BUTTON_LABEL, FONT_NORMAL, gText_Confirm3, 0, 1, 0, NULL);
PutWindowTilemap(WIN_BUTTON_LABEL);
ScheduleBgCopyTilemapToVram(2);
}
@ -765,8 +768,8 @@ void CB2_ViewWallClock(void)
WallClockInit();
AddTextPrinterParameterized(1, FONT_NORMAL, gText_Cancel4, 0, 1, 0, NULL);
PutWindowTilemap(1);
AddTextPrinterParameterized(WIN_BUTTON_LABEL, FONT_NORMAL, gText_Cancel4, 0, 1, 0, NULL);
PutWindowTilemap(WIN_BUTTON_LABEL);
ScheduleBgCopyTilemapToVram(2);
}
@ -829,9 +832,9 @@ static void Task_SetClock_HandleInput(u8 taskId)
static void Task_SetClock_AskConfirm(u8 taskId)
{
DrawStdFrameWithCustomTileAndPalette(0, FALSE, 0x250, 0x0d);
AddTextPrinterParameterized(0, FONT_NORMAL, gText_IsThisTheCorrectTime, 0, 1, 0, NULL);
PutWindowTilemap(0);
DrawStdFrameWithCustomTileAndPalette(WIN_MSG, FALSE, 0x250, 0x0d);
AddTextPrinterParameterized(WIN_MSG, FONT_NORMAL, gText_IsThisTheCorrectTime, 0, 1, 0, NULL);
PutWindowTilemap(WIN_MSG);
ScheduleBgCopyTilemapToVram(0);
CreateYesNoMenu(&sWindowTemplate_ConfirmYesNo, 0x250, 0x0d, 1);
gTasks[taskId].func = Task_SetClock_HandleConfirmInput;
@ -848,8 +851,8 @@ static void Task_SetClock_HandleConfirmInput(u8 taskId)
case 1: // NO
case MENU_B_PRESSED:
PlaySE(SE_SELECT);
ClearStdWindowAndFrameToTransparent(0, FALSE);
ClearWindowTilemap(0);
ClearStdWindowAndFrameToTransparent(WIN_MSG, FALSE);
ClearWindowTilemap(WIN_MSG);
gTasks[taskId].func = Task_SetClock_HandleInput;
break;
}

View File

@ -28,12 +28,21 @@ enum {
COLORMODE_WHITE_DGRAY,
};
#define GROUPTYPE_TRADE 0
#define GROUPTYPE_BATTLE 1
#define GROUPTYPE_UNION 2
#define GROUPTYPE_TOTAL 3
#define GROUPTYPE_NONE 0xFF
#define NUM_GROUPTYPES 4
enum {
WIN_TITLE,
WIN_GROUP_NAMES,
WIN_GROUP_COUNTS,
};
enum {
GROUPTYPE_TRADE,
GROUPTYPE_BATTLE,
GROUPTYPE_UNION,
GROUPTYPE_TOTAL,
NUM_GROUPTYPES
};
#define GROUPTYPE_NONE 0xFF
struct WirelessCommunicationStatusScreen
{
@ -88,7 +97,7 @@ static const struct BgTemplate sBgTemplates[] = {
};
static const struct WindowTemplate sWindowTemplates[] = {
{
[WIN_TITLE] = {
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 0,
@ -96,7 +105,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
.height = 3,
.paletteNum = 15,
.baseBlock = 0x0001
}, {
},
[WIN_GROUP_NAMES] = {
.bg = 0,
.tilemapLeft = 3,
.tilemapTop = 4,
@ -104,7 +114,8 @@ static const struct WindowTemplate sWindowTemplates[] = {
.height = 15,
.paletteNum = 15,
.baseBlock = 0x0049
}, {
},
[WIN_GROUP_COUNTS] = {
.bg = 0,
.tilemapLeft = 24,
.tilemapTop = 4,
@ -253,24 +264,24 @@ static void CyclePalette(s16 * counter, s16 * palIdx)
static void PrintHeaderTexts(void)
{
s32 i;
FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(1, PIXEL_FILL(0));
FillWindowPixelBuffer(2, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_TITLE, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_GROUP_NAMES, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_GROUP_COUNTS, PIXEL_FILL(0));
// Print title
WCSS_AddTextPrinterParameterized(0, FONT_NORMAL, sHeaderTexts[0], GetStringCenterAlignXOffset(FONT_NORMAL, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN);
WCSS_AddTextPrinterParameterized(WIN_TITLE, FONT_NORMAL, sHeaderTexts[0], GetStringCenterAlignXOffset(FONT_NORMAL, sHeaderTexts[0], 0xC0), 6, COLORMODE_GREEN);
// Print label for each group (excluding total)
for (i = 0; i < NUM_GROUPTYPES - 1; i++)
WCSS_AddTextPrinterParameterized(1, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY);
WCSS_AddTextPrinterParameterized(WIN_GROUP_NAMES, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_WHITE_LGRAY);
// Print label for total
WCSS_AddTextPrinterParameterized(1, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_RED);
WCSS_AddTextPrinterParameterized(WIN_GROUP_NAMES, FONT_NORMAL, sHeaderTexts[i + 1], 0, 30 * i + 8, COLORMODE_RED);
PutWindowTilemap(0);
CopyWindowToVram(0, COPYWIN_GFX);
PutWindowTilemap(1);
CopyWindowToVram(1, COPYWIN_GFX);
PutWindowTilemap(WIN_TITLE);
CopyWindowToVram(WIN_TITLE, COPYWIN_GFX);
PutWindowTilemap(WIN_GROUP_NAMES);
CopyWindowToVram(WIN_GROUP_NAMES, COPYWIN_GFX);
}
#define tState data[0]
@ -298,17 +309,17 @@ static void Task_WirelessCommunicationScreen(u8 taskId)
case 3:
if (UpdateCommunicationCounts(sStatusScreen->groupCounts, sStatusScreen->prevGroupCounts, sStatusScreen->activities, sStatusScreen->rfuTaskId))
{
FillWindowPixelBuffer(2, PIXEL_FILL(0));
FillWindowPixelBuffer(WIN_GROUP_COUNTS, PIXEL_FILL(0));
for (i = 0; i < NUM_GROUPTYPES; i++)
{
ConvertIntToDecimalStringN(gStringVar4, sStatusScreen->groupCounts[i], STR_CONV_MODE_RIGHT_ALIGN, 2);
if (i != GROUPTYPE_TOTAL)
WCSS_AddTextPrinterParameterized(2, FONT_NORMAL, gStringVar4, 12, 30 * i + 8, COLORMODE_WHITE_LGRAY);
WCSS_AddTextPrinterParameterized(WIN_GROUP_COUNTS, FONT_NORMAL, gStringVar4, 12, 30 * i + 8, COLORMODE_WHITE_LGRAY);
else
WCSS_AddTextPrinterParameterized(2, FONT_NORMAL, gStringVar4, 12, 98, COLORMODE_RED);
WCSS_AddTextPrinterParameterized(WIN_GROUP_COUNTS, FONT_NORMAL, gStringVar4, 12, 98, COLORMODE_RED);
}
PutWindowTilemap(2);
CopyWindowToVram(2, COPYWIN_FULL);
PutWindowTilemap(WIN_GROUP_COUNTS);
CopyWindowToVram(WIN_GROUP_COUNTS, COPYWIN_FULL);
}
if (JOY_NEW(A_BUTTON) || JOY_NEW(B_BUTTON))
{