Document mail

This commit is contained in:
GriffinR 2021-02-20 15:15:38 -05:00
parent b04f0aaa2b
commit 1cac608dbe
17 changed files with 521 additions and 275 deletions

View File

@ -495,7 +495,9 @@
#define NUM_ROUTE_114_MAN_BERRIES (LAST_ROUTE_114_MAN_BERRY - FIRST_ROUTE_114_MAN_BERRY + 1) #define NUM_ROUTE_114_MAN_BERRIES (LAST_ROUTE_114_MAN_BERRY - FIRST_ROUTE_114_MAN_BERRY + 1)
#define NUM_ROUTE_114_MAN_BERRIES_SKIPPED (FIRST_ROUTE_114_MAN_BERRY - FIRST_BERRY_INDEX) #define NUM_ROUTE_114_MAN_BERRIES_SKIPPED (FIRST_ROUTE_114_MAN_BERRY - FIRST_BERRY_INDEX)
#define ITEM_TO_BERRY(itemId)(((itemId - FIRST_BERRY_INDEX) + 1)) #define ITEM_TO_BERRY(itemId)(((itemId) - FIRST_BERRY_INDEX) + 1)
#define ITEM_TO_MAIL(itemId)((itemId) - FIRST_MAIL_INDEX)
#define MAIL_NONE 0xFF
#define NUM_TECHNICAL_MACHINES 50 #define NUM_TECHNICAL_MACHINES 50
#define NUM_HIDDEN_MACHINES 8 #define NUM_HIDDEN_MACHINES 8

View File

@ -288,8 +288,6 @@
#define MAX_TOTAL_EVS 510 #define MAX_TOTAL_EVS 510
#define EV_ITEM_RAISE_LIMIT 100 #define EV_ITEM_RAISE_LIMIT 100
#define UNOWN_FORM_COUNT 28
// Battle move flags // Battle move flags
#define FLAG_MAKES_CONTACT (1 << 0) #define FLAG_MAKES_CONTACT (1 << 0)
#define FLAG_PROTECT_AFFECTED (1 << 1) #define FLAG_PROTECT_AFFECTED (1 << 1)

View File

@ -5025,4 +5025,42 @@ extern const u16 gObjectEventPal_May[];
extern const u16 gObjectEventPal_RubySapphireBrendan[]; extern const u16 gObjectEventPal_RubySapphireBrendan[];
extern const u16 gObjectEventPal_RubySapphireMay[]; extern const u16 gObjectEventPal_RubySapphireMay[];
// Mail
extern const u16 gMailPalette_Orange[];
extern const u16 gMailPalette_Harbor[];
extern const u16 gMailPalette_Glitter[];
extern const u16 gMailPalette_Mech[];
extern const u16 gMailPalette_Wood[];
extern const u16 gMailPalette_Wave[];
extern const u16 gMailPalette_Bead[];
extern const u16 gMailPalette_Shadow[];
extern const u16 gMailPalette_Tropic[];
extern const u16 gMailPalette_Dream[];
extern const u16 gMailPalette_Fab[];
extern const u16 gMailPalette_Retro[];
extern const u8 gMailTiles_Orange[];
extern const u8 gMailTilemap_Orange[];
extern const u8 gMailTiles_Harbor[];
extern const u8 gMailTilemap_Harbor[];
extern const u8 gMailTiles_Glitter[];
extern const u8 gMailTilemap_Glitter[];
extern const u8 gMailTiles_Mech[];
extern const u8 gMailTilemap_Mech[];
extern const u8 gMailTiles_Wood[];
extern const u8 gMailTilemap_Wood[];
extern const u8 gMailTiles_Wave[];
extern const u8 gMailTilemap_Wave[];
extern const u8 gMailTiles_Bead[];
extern const u8 gMailTilemap_Bead[];
extern const u8 gMailTiles_Shadow[];
extern const u8 gMailTilemap_Shadow[];
extern const u8 gMailTiles_Tropic[];
extern const u8 gMailTilemap_Tropic[];
extern const u8 gMailTiles_Dream[];
extern const u8 gMailTilemap_Dream[];
extern const u8 gMailTiles_Fab[];
extern const u8 gMailTilemap_Fab[];
extern const u8 gMailTiles_Retro[];
extern const u8 gMailTilemap_Retro[];
#endif //GUARD_GRAPHICS_H #endif //GUARD_GRAPHICS_H

View File

@ -4,7 +4,7 @@
#include "menu.h" #include "menu.h"
#include "list_menu.h" #include "list_menu.h"
void sub_81DB52C(u8 *src); void ConvertInternationalPlayerName(u8 *src);
void TVShowConvertInternationalString(u8 *dest, const u8 *src, int language); void TVShowConvertInternationalString(u8 *dest, const u8 *src, int language);
int GetStringCenterAlignXOffset(int fontId, const u8 *str, int totalWidth); int GetStringCenterAlignXOffset(int fontId, const u8 *str, int totalWidth);
int GetStringRightAlignXOffset(int fontId, const u8 *str, int totalWidth); int GetStringRightAlignXOffset(int fontId, const u8 *str, int totalWidth);
@ -16,7 +16,7 @@ int Intl_GetListMenuWidth(const struct ListMenuTemplate *listMenu);
void CopyMonCategoryText(int dexNum, u8 *dest); void CopyMonCategoryText(int dexNum, u8 *dest);
u8 *sub_81DB494(u8 *str, int fontId, const u8 *str2, int totalStringWidth); u8 *sub_81DB494(u8 *str, int fontId, const u8 *str2, int totalStringWidth);
void PadNameString(u8 *dest, u8 padChar); void PadNameString(u8 *dest, u8 padChar);
void sub_81DB554(u8 *, u8); void ConvertInternationalPlayerNameStripChar(u8 *, u8);
void sub_81DB5AC(u8 *); void sub_81DB5AC(u8 *);
int sub_81DB604(u8 *); int sub_81DB604(u8 *);
void sub_81DB620(int windowId, int columnStart, int rowStart, int numFillTiles, int numRows); void sub_81DB620(int windowId, int columnStart, int rowStart, int numFillTiles, int numRows);

View File

@ -10,14 +10,14 @@ const u8 *GetMonIconPtr(u16 speciesId, u32 personality, u32 frameNo);
const u16 *GetValidMonIconPalettePtr(u16 speciesId); const u16 *GetValidMonIconPalettePtr(u16 speciesId);
u16 GetIconSpecies(u16 species, u32 personality); u16 GetIconSpecies(u16 species, u32 personality);
u16 GetUnownLetterByPersonality(u32 personality); u16 GetUnownLetterByPersonality(u32 personality);
u16 sub_80D2E84(u16 speciesId); u16 GetIconSpeciesNoPersonality(u16 speciesId);
void LoadMonIconPalettes(void); void LoadMonIconPalettes(void);
void LoadMonIconPalette(u16 species); void LoadMonIconPalette(u16 species);
void FreeMonIconPalettes(void); void FreeMonIconPalettes(void);
u8 sub_80D2D78(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, bool32 extra); u8 CreateMonIconNoPersonality(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, bool32 handleDeoxys);
void FreeMonIconPalette(u16 species); void FreeMonIconPalette(u16 species);
void FreeAndDestroyMonIconSprite(struct Sprite *sprite); void FreeAndDestroyMonIconSprite(struct Sprite *sprite);
u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool32 extra); u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, u32 personality, bool32 handleDeoxys);
u8 UpdateMonIconFrame(struct Sprite *sprite); u8 UpdateMonIconFrame(struct Sprite *sprite);
void LoadMonIconPalette(u16 species); void LoadMonIconPalette(u16 species);
void sub_80D328C(struct Sprite *sprite); void sub_80D328C(struct Sprite *sprite);

View File

@ -1479,7 +1479,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_ORANGE_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_ORANGE_MAIL),
}, },
[ITEM_HARBOR_MAIL] = [ITEM_HARBOR_MAIL] =
@ -1491,7 +1491,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_HARBOR_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_HARBOR_MAIL),
}, },
[ITEM_GLITTER_MAIL] = [ITEM_GLITTER_MAIL] =
@ -1503,7 +1503,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_GLITTER_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_GLITTER_MAIL),
}, },
[ITEM_MECH_MAIL] = [ITEM_MECH_MAIL] =
@ -1515,7 +1515,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_MECH_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_MECH_MAIL),
}, },
[ITEM_WOOD_MAIL] = [ITEM_WOOD_MAIL] =
@ -1527,7 +1527,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_WOOD_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_WOOD_MAIL),
}, },
[ITEM_WAVE_MAIL] = [ITEM_WAVE_MAIL] =
@ -1539,7 +1539,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_WAVE_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_WAVE_MAIL),
}, },
[ITEM_BEAD_MAIL] = [ITEM_BEAD_MAIL] =
@ -1551,7 +1551,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_BEAD_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_BEAD_MAIL),
}, },
[ITEM_SHADOW_MAIL] = [ITEM_SHADOW_MAIL] =
@ -1563,7 +1563,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_SHADOW_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_SHADOW_MAIL),
}, },
[ITEM_TROPIC_MAIL] = [ITEM_TROPIC_MAIL] =
@ -1575,7 +1575,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_TROPIC_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_TROPIC_MAIL),
}, },
[ITEM_DREAM_MAIL] = [ITEM_DREAM_MAIL] =
@ -1587,7 +1587,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_DREAM_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_DREAM_MAIL),
}, },
[ITEM_FAB_MAIL] = [ITEM_FAB_MAIL] =
@ -1599,7 +1599,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_FAB_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_FAB_MAIL),
}, },
[ITEM_RETRO_MAIL] = [ITEM_RETRO_MAIL] =
@ -1611,7 +1611,7 @@ const struct Item gItems[] =
.pocket = POCKET_ITEMS, .pocket = POCKET_ITEMS,
.type = ITEM_USE_MAIL, .type = ITEM_USE_MAIL,
.fieldUseFunc = ItemUseOutOfBattle_Mail, .fieldUseFunc = ItemUseOutOfBattle_Mail,
.secondaryId = ITEM_RETRO_MAIL - FIRST_MAIL_INDEX, .secondaryId = ITEM_TO_MAIL(ITEM_RETRO_MAIL),
}, },
// Berries // Berries

View File

@ -32,6 +32,7 @@
#include "constants/battle_string_ids.h" #include "constants/battle_string_ids.h"
#include "constants/songs.h" #include "constants/songs.h"
#include "constants/rgb.h" #include "constants/rgb.h"
#include "constants/items.h"
struct EvoInfo struct EvoInfo
{ {
@ -565,7 +566,7 @@ static void CreateShedinja(u16 preEvoSpecies, struct Pokemon* mon)
SetMonData(&gPlayerParty[gPlayerPartyCount], i, &data); SetMonData(&gPlayerParty[gPlayerPartyCount], i, &data);
SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_STATUS, &data); SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_STATUS, &data);
data = 0xFF; data = MAIL_NONE;
SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_MAIL, &data); SetMonData(&gPlayerParty[gPlayerPartyCount], MON_DATA_MAIL, &data);
CalculateMonStats(&gPlayerParty[gPlayerPartyCount]); CalculateMonStats(&gPlayerParty[gPlayerPartyCount]);

View File

@ -152,7 +152,7 @@ void PadNameString(u8 *dest, u8 padChar)
dest[length] = EOS; dest[length] = EOS;
} }
void sub_81DB52C(u8 *str) void ConvertInternationalPlayerName(u8 *str)
{ {
if (StringLength(str) < PLAYER_NAME_LENGTH - 1) if (StringLength(str) < PLAYER_NAME_LENGTH - 1)
ConvertInternationalString(str, LANGUAGE_JAPANESE); ConvertInternationalString(str, LANGUAGE_JAPANESE);
@ -160,14 +160,14 @@ void sub_81DB52C(u8 *str)
StripExtCtrlCodes(str); StripExtCtrlCodes(str);
} }
void sub_81DB554(u8 *str, u8 arg1) void ConvertInternationalPlayerNameStripChar(u8 *str, u8 removeChar)
{ {
u8 *buffer; u8 *buffer;
if (StringLength(str) < PLAYER_NAME_LENGTH - 1) if (StringLength(str) < PLAYER_NAME_LENGTH - 1)
{ {
ConvertInternationalString(str, LANGUAGE_JAPANESE); ConvertInternationalString(str, LANGUAGE_JAPANESE);
} }
else if (arg1 == EXT_CTRL_CODE_BEGIN) else if (removeChar == EXT_CTRL_CODE_BEGIN)
{ {
StripExtCtrlCodes(str); StripExtCtrlCodes(str);
} }
@ -177,7 +177,7 @@ void sub_81DB554(u8 *str, u8 arg1)
while (buffer[1] != EOS) while (buffer[1] != EOS)
buffer++; buffer++;
while (buffer >= str && buffer[0] == arg1) while (buffer >= str && buffer[0] == removeChar)
{ {
buffer[0] = EOS; buffer[0] = EOS;
buffer--; buffer--;

View File

@ -18,62 +18,31 @@
#include "pokemon_icon.h" #include "pokemon_icon.h"
#include "malloc.h" #include "malloc.h"
#include "easy_chat.h" #include "easy_chat.h"
#include "graphics.h"
#include "constants/rgb.h" #include "constants/rgb.h"
extern const u16 gMailPalette_Orange[]; // Bead and Dream mail feature an icon of the Pokémon holding it.
extern const u16 gMailPalette_Harbor[]; enum {
extern const u16 gMailPalette_Glitter[]; ICON_TYPE_NONE,
extern const u16 gMailPalette_Mech[]; ICON_TYPE_BEAD,
extern const u16 gMailPalette_Wood[]; ICON_TYPE_DREAM,
extern const u16 gMailPalette_Wave[]; };
extern const u16 gMailPalette_Bead[];
extern const u16 gMailPalette_Shadow[];
extern const u16 gMailPalette_Tropic[];
extern const u16 gMailPalette_Dream[];
extern const u16 gMailPalette_Fab[];
extern const u16 gMailPalette_Retro[];
extern const u8 gMailTiles_Orange[];
extern const u8 gMailTilemap_Orange[];
extern const u8 gMailTiles_Harbor[];
extern const u8 gMailTilemap_Harbor[];
extern const u8 gMailTiles_Glitter[];
extern const u8 gMailTilemap_Glitter[];
extern const u8 gMailTiles_Mech[];
extern const u8 gMailTilemap_Mech[];
extern const u8 gMailTiles_Wood[];
extern const u8 gMailTilemap_Wood[];
extern const u8 gMailTiles_Wave[];
extern const u8 gMailTilemap_Wave[];
extern const u8 gMailTiles_Bead[];
extern const u8 gMailTilemap_Bead[];
extern const u8 gMailTiles_Shadow[];
extern const u8 gMailTilemap_Shadow[];
extern const u8 gMailTiles_Tropic[];
extern const u8 gMailTilemap_Tropic[];
extern const u8 gMailTiles_Dream[];
extern const u8 gMailTilemap_Dream[];
extern const u8 gMailTiles_Fab[];
extern const u8 gMailTilemap_Fab[];
extern const u8 gMailTiles_Retro[];
extern const u8 gMailTilemap_Retro[];
// Static type declarations struct MailLineLayout
struct UnkMailStruct
{ {
u32 numEasyChatWords:2; u8 numEasyChatWords:2;
u32 xOffset:6; u8 xOffset:6;
u32 lineHeight:8; u8 height;
}; };
struct MailLayout struct MailLayout
{ {
u8 numSubStructs; u8 numLines;
u8 signatureYPos; u8 signatureYPos;
u8 signatureWidth; u8 signatureWidth;
u8 wordsXPos;
u8 wordsYPos; u8 wordsYPos;
const struct UnkMailStruct *var8; u8 wordsXPos;
const struct MailLineLayout *lines;
}; };
struct MailGraphics struct MailGraphics
@ -81,26 +50,25 @@ struct MailGraphics
const u16 *palette; const u16 *palette;
const u8 *tiles; const u8 *tiles;
const u8 *tileMap; const u8 *tileMap;
u16 var0C; u32 unused;
u16 var0E; u16 textColor;
u16 color10; u16 textShadow;
u16 color12;
}; };
struct MailRead struct MailRead
{ {
/*0x0000*/ u8 strbuf[8][64]; /*0x0000*/ u8 message[8][64];
/*0x0200*/ u8 playerName[12]; /*0x0200*/ u8 playerName[12];
/*0x020C*/ MainCallback callback; /*0x020C*/ MainCallback exitCallback;
/*0x0210*/ MainCallback callback2; /*0x0210*/ MainCallback callback;
/*0x0214*/ struct MailStruct *mail; /*0x0214*/ struct MailStruct *mail;
/*0x0218*/ bool8 flag; /*0x0218*/ bool8 hasText;
/*0x0219*/ u8 signatureWidth; /*0x0219*/ u8 signatureWidth;
/*0x021a*/ u8 mailType; /*0x021a*/ u8 mailType;
/*0x021b*/ u8 animsActive; /*0x021b*/ u8 iconType;
/*0x021c*/ u8 monIconSprite; /*0x021c*/ u8 monIconSpriteId;
/*0x021d*/ u8 language; /*0x021d*/ u8 language;
/*0x021e*/ bool8 playerIsSender; /*0x021e*/ bool8 international;
/*0x0220*/ u8 * (*parserSingle)(u8 *dest, u16 word); /*0x0220*/ u8 * (*parserSingle)(u8 *dest, u16 word);
/*0x0224*/ u8 * (*parserMultiple)(u8 *dest, const u16 *src, u16 length1, u16 length2); /*0x0224*/ u8 * (*parserMultiple)(u8 *dest, const u16 *src, u16 length1, u16 length2);
/*0x0228*/ const struct MailLayout *layout; /*0x0228*/ const struct MailLayout *layout;
@ -108,23 +76,17 @@ struct MailRead
/*0x122c*/ u8 bg2TilemapBuffer[0x1000]; /*0x122c*/ u8 bg2TilemapBuffer[0x1000];
}; };
// Static RAM declarations
static EWRAM_DATA struct MailRead *sMailRead = NULL; static EWRAM_DATA struct MailRead *sMailRead = NULL;
// Static ROM declarations
static void CB2_InitMailRead(void); static void CB2_InitMailRead(void);
static void sub_8121A1C(void); static void BufferMailText(void);
static void sub_8121B1C(void); static void PrintMailText(void);
static void VBlankCB_MailRead(void); static void VBlankCB_MailRead(void);
static void CB2_MailRead(void); static void CB2_MailRead(void);
static void CB2_WaitForPaletteExitOnKeyPress(void); static void CB2_WaitForPaletteExitOnKeyPress(void);
static void CB2_ExitOnKeyPress(void); static void CB2_ExitOnKeyPress(void);
static void CB2_ExitMailReadFreeVars(void); static void CB2_ExitMailReadFreeVars(void);
// .rodata
static const struct BgTemplate sBgTemplates[] = { static const struct BgTemplate sBgTemplates[] = {
{ {
.bg = 0, .bg = 0,
@ -144,7 +106,7 @@ static const struct BgTemplate sBgTemplates[] = {
} }
}; };
static const struct WindowTemplate sUnknown_0859F29C[] = { static const struct WindowTemplate sWindowTemplates[] = {
{ {
.bg = 0, .bg = 0,
.tilemapLeft = 2, .tilemapLeft = 2,
@ -163,137 +125,377 @@ static const u8 sTextColors[] = {
TEXT_DYNAMIC_COLOR_2 TEXT_DYNAMIC_COLOR_2
}; };
static const u16 sUnknown_0859F2B0[][2] = { // Background is alternating bars of a dark/light color.
{ 0x6ACD, 0x51A5 }, // Either blue or red depending on player's gender
{ 0x45FC, 0x38D4 } static const u16 sBgColors[GENDER_COUNT][2] = {
[MALE] = { RGB(13, 22, 26), RGB(5, 13, 20) },
[FEMALE] = { RGB(28, 15, 17), RGB(20, 6, 14) }
}; };
static const struct MailGraphics sUnknown_0859F2B8[] = { static const struct MailGraphics sMailGraphics[] = {
{ [ITEM_TO_MAIL(ITEM_ORANGE_MAIL)] = {
gMailPalette_Orange, gMailTiles_Orange, gMailTilemap_Orange, 0x02c0, 0, 0x294a, 0x6739 .palette = gMailPalette_Orange,
}, { .tiles = gMailTiles_Orange,
gMailPalette_Harbor, gMailTiles_Harbor, gMailTilemap_Harbor, 0x02e0, 0, 0x7fff, 0x4631 .tileMap = gMailTilemap_Orange,
}, { .unused = 0x2C0,
gMailPalette_Glitter, gMailTiles_Glitter, gMailTilemap_Glitter, 0x0400, 0, 0x294a, 0x6739 .textColor = RGB(10, 10, 10),
}, { .textShadow = RGB(25, 25, 25),
gMailPalette_Mech, gMailTiles_Mech, gMailTilemap_Mech, 0x01e0, 0, 0x7fff, 0x4631 },
}, { [ITEM_TO_MAIL(ITEM_HARBOR_MAIL)] = {
gMailPalette_Wood, gMailTiles_Wood, gMailTilemap_Wood, 0x02e0, 0, 0x7fff, 0x4631 .palette = gMailPalette_Harbor,
}, { .tiles = gMailTiles_Harbor,
gMailPalette_Wave, gMailTiles_Wave, gMailTilemap_Wave, 0x0300, 0, 0x294a, 0x6739 .tileMap = gMailTilemap_Harbor,
}, { .unused = 0x2E0,
gMailPalette_Bead, gMailTiles_Bead, gMailTilemap_Bead, 0x0140, 0, 0x7fff, 0x4631 .textColor = RGB_WHITE,
}, { .textShadow = RGB(17, 17, 17),
gMailPalette_Shadow, gMailTiles_Shadow, gMailTilemap_Shadow, 0x0300, 0, 0x7fff, 0x4631 },
}, { [ITEM_TO_MAIL(ITEM_GLITTER_MAIL)] = {
gMailPalette_Tropic, gMailTiles_Tropic, gMailTilemap_Tropic, 0x0220, 0, 0x294a, 0x6739 .palette = gMailPalette_Glitter,
}, { .tiles = gMailTiles_Glitter,
gMailPalette_Dream, gMailTiles_Dream, gMailTilemap_Dream, 0x0340, 0, 0x294a, 0x6739 .tileMap = gMailTilemap_Glitter,
}, { .unused = 0x400,
gMailPalette_Fab, gMailTiles_Fab, gMailTilemap_Fab, 0x02a0, 0, 0x294a, 0x6739 .textColor = RGB(10, 10, 10),
}, { .textShadow = RGB(25, 25, 25),
gMailPalette_Retro, gMailTiles_Retro, gMailTilemap_Retro, 0x0520, 0, 0x294a, 0x6739 },
[ITEM_TO_MAIL(ITEM_MECH_MAIL)] = {
.palette = gMailPalette_Mech,
.tiles = gMailTiles_Mech,
.tileMap = gMailTilemap_Mech,
.unused = 0x1E0,
.textColor = RGB_WHITE,
.textShadow = RGB(17, 17, 17),
},
[ITEM_TO_MAIL(ITEM_WOOD_MAIL)] = {
.palette = gMailPalette_Wood,
.tiles = gMailTiles_Wood,
.tileMap = gMailTilemap_Wood,
.unused = 0x2E0,
.textColor = RGB_WHITE,
.textShadow = RGB(17, 17, 17),
},
[ITEM_TO_MAIL(ITEM_WAVE_MAIL)] = {
.palette = gMailPalette_Wave,
.tiles = gMailTiles_Wave,
.tileMap = gMailTilemap_Wave,
.unused = 0x300,
.textColor = RGB(10, 10, 10),
.textShadow = RGB(25, 25, 25),
},
[ITEM_TO_MAIL(ITEM_BEAD_MAIL)] = {
.palette = gMailPalette_Bead,
.tiles = gMailTiles_Bead,
.tileMap = gMailTilemap_Bead,
.unused = 0x140,
.textColor = RGB_WHITE,
.textShadow = RGB(17, 17, 17),
},
[ITEM_TO_MAIL(ITEM_SHADOW_MAIL)] = {
.palette = gMailPalette_Shadow,
.tiles = gMailTiles_Shadow,
.tileMap = gMailTilemap_Shadow,
.unused = 0x300,
.textColor = RGB_WHITE,
.textShadow = RGB(17, 17, 17),
},
[ITEM_TO_MAIL(ITEM_TROPIC_MAIL)] = {
.palette = gMailPalette_Tropic,
.tiles = gMailTiles_Tropic,
.tileMap = gMailTilemap_Tropic,
.unused = 0x220,
.textColor = RGB(10, 10, 10),
.textShadow = RGB(25, 25, 25),
},
[ITEM_TO_MAIL(ITEM_DREAM_MAIL)] = {
.palette = gMailPalette_Dream,
.tiles = gMailTiles_Dream,
.tileMap = gMailTilemap_Dream,
.unused = 0x340,
.textColor = RGB(10, 10, 10),
.textShadow = RGB(25, 25, 25),
},
[ITEM_TO_MAIL(ITEM_FAB_MAIL)] = {
.palette = gMailPalette_Fab,
.tiles = gMailTiles_Fab,
.tileMap = gMailTilemap_Fab,
.unused = 0x2a0,
.textColor = RGB(10, 10, 10),
.textShadow = RGB(25, 25, 25),
},
[ITEM_TO_MAIL(ITEM_RETRO_MAIL)] = {
.palette = gMailPalette_Retro,
.tiles = gMailTiles_Retro,
.tileMap = gMailTilemap_Retro,
.unused = 0x520,
.textColor = RGB(10, 10, 10),
.textShadow = RGB(25, 25, 25),
} }
}; };
static const struct UnkMailStruct Unknown_0859F3A8[] = { static const struct MailLineLayout sLineLayouts_Wide[] = {
{ .numEasyChatWords = 3, .lineHeight = 16 }, { .numEasyChatWords = 3, .xOffset = 0, .height = 16 },
{ .numEasyChatWords = 3, .lineHeight = 16 }, { .numEasyChatWords = 3, .xOffset = 0, .height = 16 },
{ .numEasyChatWords = 3, .lineHeight = 16 } { .numEasyChatWords = 3, .xOffset = 0, .height = 16 }
}; };
static const struct MailLayout sUnknown_0859F3B4[] = { static const struct MailLayout sMailLayouts_Wide[] = {
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, [ITEM_TO_MAIL(ITEM_ORANGE_MAIL)] = {
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, .numLines = ARRAY_COUNT(sLineLayouts_Wide),
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, .signatureYPos = 0,
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, .signatureWidth = 0,
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, .wordsYPos = 2,
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, .wordsXPos = 4,
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, .lines = sLineLayouts_Wide,
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, [ITEM_TO_MAIL(ITEM_HARBOR_MAIL)] = {
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, .numLines = ARRAY_COUNT(sLineLayouts_Wide),
{ 0x03, 0x08, 0x00, 0x02, 0x04, Unknown_0859F3A8 }, .signatureYPos = 0,
{ 0x03, 0x00, 0x00, 0x02, 0x00, Unknown_0859F3A8 } .signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_GLITTER_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_MECH_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_WOOD_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_WAVE_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_BEAD_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_SHADOW_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_TROPIC_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_DREAM_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_FAB_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 8,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 4,
.lines = sLineLayouts_Wide,
},
[ITEM_TO_MAIL(ITEM_RETRO_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Wide),
.signatureYPos = 0,
.signatureWidth = 0,
.wordsYPos = 2,
.wordsXPos = 0,
.lines = sLineLayouts_Wide,
},
}; };
static const struct UnkMailStruct Unknown_0859F444[] = { static const struct MailLineLayout sLineLayouts_Tall[] = {
{ .numEasyChatWords = 2, .lineHeight = 16 }, { .numEasyChatWords = 2, .xOffset = 0, .height = 16 },
{ .numEasyChatWords = 2, .lineHeight = 16 }, { .numEasyChatWords = 2, .xOffset = 0, .height = 16 },
{ .numEasyChatWords = 2, .lineHeight = 16 }, { .numEasyChatWords = 2, .xOffset = 0, .height = 16 },
{ .numEasyChatWords = 2, .lineHeight = 16 }, { .numEasyChatWords = 2, .xOffset = 0, .height = 16 },
{ .numEasyChatWords = 1, .lineHeight = 16 } { .numEasyChatWords = 1, .xOffset = 0, .height = 16 }
}; };
static const struct MailLayout sUnknown_0859F458[] = { static const struct MailLayout sMailLayouts_Tall[] = {
{ 0x05, 0x07, 0x58, 0x0b, 0x1e, Unknown_0859F444 }, [ITEM_TO_MAIL(ITEM_ORANGE_MAIL)] = {
{ 0x05, 0x0a, 0x60, 0x09, 0x1e, Unknown_0859F444 }, .numLines = ARRAY_COUNT(sLineLayouts_Tall),
{ 0x05, 0x0c, 0x68, 0x05, 0x1e, Unknown_0859F444 }, .signatureYPos = 7,
{ 0x05, 0x05, 0x60, 0x08, 0x1e, Unknown_0859F444 }, .signatureWidth = 88,
{ 0x05, 0x0a, 0x60, 0x09, 0x1e, Unknown_0859F444 }, .wordsYPos = 11,
{ 0x05, 0x09, 0x70, 0x05, 0x1e, Unknown_0859F444 }, .wordsXPos = 30,
{ 0x05, 0x0c, 0x68, 0x09, 0x1e, Unknown_0859F444 }, .lines = sLineLayouts_Tall,
{ 0x05, 0x0d, 0x68, 0x0d, 0x1e, Unknown_0859F444 }, },
{ 0x05, 0x09, 0x60, 0x09, 0x1e, Unknown_0859F444 }, [ITEM_TO_MAIL(ITEM_HARBOR_MAIL)] = {
{ 0x05, 0x09, 0x60, 0x09, 0x1e, Unknown_0859F444 }, .numLines = ARRAY_COUNT(sLineLayouts_Tall),
{ 0x05, 0x11, 0x68, 0x0f, 0x1e, Unknown_0859F444 }, .signatureYPos = 10,
{ 0x05, 0x09, 0x60, 0x05, 0x1e, Unknown_0859F444 } .signatureWidth = 96,
.wordsYPos = 9,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_GLITTER_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 12,
.signatureWidth = 104,
.wordsYPos = 5,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_MECH_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 5,
.signatureWidth = 96,
.wordsYPos = 8,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_WOOD_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 10,
.signatureWidth = 96,
.wordsYPos = 9,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_WAVE_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 9,
.signatureWidth = 112,
.wordsYPos = 5,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_BEAD_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 12,
.signatureWidth = 104,
.wordsYPos = 9,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_SHADOW_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 13,
.signatureWidth = 104,
.wordsYPos = 13,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_TROPIC_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 9,
.signatureWidth = 96,
.wordsYPos = 9,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_DREAM_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 9,
.signatureWidth = 96,
.wordsYPos = 9,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_FAB_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 17,
.signatureWidth = 104,
.wordsYPos = 15,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
[ITEM_TO_MAIL(ITEM_RETRO_MAIL)] = {
.numLines = ARRAY_COUNT(sLineLayouts_Tall),
.signatureYPos = 9,
.signatureWidth = 96,
.wordsYPos = 5,
.wordsXPos = 30,
.lines = sLineLayouts_Tall,
},
}; };
// .text void ReadMail(struct MailStruct *mail, void (*exitCallback)(void), bool8 hasText)
void ReadMail(struct MailStruct *mail, void (*callback)(void), bool8 flag)
{ {
u16 buffer[2]; u16 buffer[2];
u16 species; u16 species;
sMailRead = calloc(1, sizeof(*sMailRead)); sMailRead = calloc(1, sizeof(*sMailRead));
sMailRead->language = GAME_LANGUAGE; sMailRead->language = GAME_LANGUAGE;
sMailRead->playerIsSender = TRUE; sMailRead->international = TRUE;
sMailRead->parserSingle = CopyEasyChatWord; sMailRead->parserSingle = CopyEasyChatWord;
sMailRead->parserMultiple = ConvertEasyChatWordsToString; sMailRead->parserMultiple = ConvertEasyChatWordsToString;
if (IS_ITEM_MAIL(mail->itemId)) if (IS_ITEM_MAIL(mail->itemId))
{ {
sMailRead->mailType = mail->itemId - FIRST_MAIL_INDEX; sMailRead->mailType = ITEM_TO_MAIL(mail->itemId);
} }
else else
{ {
sMailRead->mailType = 0; sMailRead->mailType = ITEM_TO_MAIL(FIRST_MAIL_INDEX);
flag = FALSE; hasText = FALSE;
} }
switch (sMailRead->playerIsSender) switch (sMailRead->international)
{ {
case FALSE: case FALSE:
default: default:
sMailRead->layout = &sUnknown_0859F3B4[sMailRead->mailType]; // Never reached. JP only?
break; sMailRead->layout = &sMailLayouts_Wide[sMailRead->mailType];
case TRUE: break;
sMailRead->layout = &sUnknown_0859F458[sMailRead->mailType]; case TRUE:
break; sMailRead->layout = &sMailLayouts_Tall[sMailRead->mailType];
break;
} }
species = MailSpeciesToSpecies(mail->species, buffer); species = MailSpeciesToSpecies(mail->species, buffer);
if (species >= SPECIES_BULBASAUR && species < NUM_SPECIES) if (species > SPECIES_NONE && species < NUM_SPECIES)
{ {
switch (sMailRead->mailType) switch (sMailRead->mailType)
{ {
default: default:
sMailRead->animsActive = 0; sMailRead->iconType = ICON_TYPE_NONE;
break; break;
case ITEM_BEAD_MAIL - FIRST_MAIL_INDEX: case ITEM_TO_MAIL(ITEM_BEAD_MAIL):
sMailRead->animsActive = 1; sMailRead->iconType = ICON_TYPE_BEAD;
break; break;
case ITEM_DREAM_MAIL - FIRST_MAIL_INDEX: case ITEM_TO_MAIL(ITEM_DREAM_MAIL):
sMailRead->animsActive = 2; sMailRead->iconType = ICON_TYPE_DREAM;
break; break;
} }
} }
else else
{ {
sMailRead->animsActive = 0; sMailRead->iconType = ICON_TYPE_NONE;
} }
sMailRead->mail = mail; sMailRead->mail = mail;
sMailRead->callback = callback; sMailRead->exitCallback = exitCallback;
sMailRead->flag = flag; sMailRead->hasText = hasText;
SetMainCallback2(CB2_InitMailRead); SetMainCallback2(CB2_InitMailRead);
} }
@ -341,11 +543,11 @@ static bool8 MailReadBuildGraphics(void)
SetBgTilemapBuffer(2, sMailRead->bg2TilemapBuffer); SetBgTilemapBuffer(2, sMailRead->bg2TilemapBuffer);
break; break;
case 7: case 7:
InitWindows(sUnknown_0859F29C); InitWindows(sWindowTemplates);
DeactivateAllTextPrinters(); DeactivateAllTextPrinters();
break; break;
case 8: case 8:
DecompressAndCopyTileDataToVram(1, sUnknown_0859F2B8[sMailRead->mailType].tiles, 0, 0, 0); DecompressAndCopyTileDataToVram(1, sMailGraphics[sMailRead->mailType].tiles, 0, 0, 0);
break; break;
case 9: case 9:
if (FreeTempTileDataBuffersIfPossible()) if (FreeTempTileDataBuffersIfPossible())
@ -356,7 +558,7 @@ static bool8 MailReadBuildGraphics(void)
case 10: case 10:
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20);
FillBgTilemapBufferRect_Palette0(2, 1, 0, 0, 30, 20); FillBgTilemapBufferRect_Palette0(2, 1, 0, 0, 30, 20);
CopyToBgTilemapBuffer(1, sUnknown_0859F2B8[sMailRead->mailType].tileMap, 0, 0); CopyToBgTilemapBuffer(1, sMailGraphics[sMailRead->mailType].tileMap, 0, 0);
break; break;
case 11: case 11:
CopyBgTilemapBufferToVram(0); CopyBgTilemapBufferToVram(0);
@ -365,26 +567,28 @@ static bool8 MailReadBuildGraphics(void)
break; break;
case 12: case 12:
LoadPalette(GetOverworldTextboxPalettePtr(), 240, 32); LoadPalette(GetOverworldTextboxPalettePtr(), 240, 32);
gPlttBufferUnfaded[250] = sUnknown_0859F2B8[sMailRead->mailType].color10;
gPlttBufferFaded[250] = sUnknown_0859F2B8[sMailRead->mailType].color10; gPlttBufferUnfaded[250] = sMailGraphics[sMailRead->mailType].textColor;
gPlttBufferUnfaded[251] = sUnknown_0859F2B8[sMailRead->mailType].color12; gPlttBufferFaded[250] = sMailGraphics[sMailRead->mailType].textColor;
gPlttBufferFaded[251] = sUnknown_0859F2B8[sMailRead->mailType].color12; gPlttBufferUnfaded[251] = sMailGraphics[sMailRead->mailType].textShadow;
LoadPalette(sUnknown_0859F2B8[sMailRead->mailType].palette, 0, 32); gPlttBufferFaded[251] = sMailGraphics[sMailRead->mailType].textShadow;
gPlttBufferUnfaded[10] = sUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][0]; LoadPalette(sMailGraphics[sMailRead->mailType].palette, 0, 32);
gPlttBufferFaded[10] = sUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][0];
gPlttBufferUnfaded[11] = sUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][1]; gPlttBufferUnfaded[10] = sBgColors[gSaveBlock2Ptr->playerGender][0];
gPlttBufferFaded[11] = sUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][1]; gPlttBufferFaded[10] = sBgColors[gSaveBlock2Ptr->playerGender][0];
gPlttBufferUnfaded[11] = sBgColors[gSaveBlock2Ptr->playerGender][1];
gPlttBufferFaded[11] = sBgColors[gSaveBlock2Ptr->playerGender][1];
break; break;
case 13: case 13:
if (sMailRead->flag) if (sMailRead->hasText)
{ {
sub_8121A1C(); BufferMailText();
} }
break; break;
case 14: case 14:
if (sMailRead->flag) if (sMailRead->hasText)
{ {
sub_8121B1C(); PrintMailText();
RunTextPrinters(); RunTextPrinters();
} }
break; break;
@ -399,17 +603,17 @@ static bool8 MailReadBuildGraphics(void)
gPaletteFade.bufferTransferDisabled = TRUE; gPaletteFade.bufferTransferDisabled = TRUE;
break; break;
case 17: case 17:
icon = sub_80D2E84(sMailRead->mail->species); icon = GetIconSpeciesNoPersonality(sMailRead->mail->species);
switch (sMailRead->animsActive) switch (sMailRead->iconType)
{ {
case 1: case ICON_TYPE_BEAD:
LoadMonIconPalette(icon); LoadMonIconPalette(icon);
sMailRead->monIconSprite = sub_80D2D78(icon, SpriteCallbackDummy, 0x60, 0x80, 0, 0); sMailRead->monIconSpriteId = CreateMonIconNoPersonality(icon, SpriteCallbackDummy, 96, 128, 0, FALSE);
break; break;
case 2: case ICON_TYPE_DREAM:
LoadMonIconPalette(icon); LoadMonIconPalette(icon);
sMailRead->monIconSprite = sub_80D2D78(icon, SpriteCallbackDummy, 0x28, 0x80, 0, 0); sMailRead->monIconSpriteId = CreateMonIconNoPersonality(icon, SpriteCallbackDummy, 40, 128, 0, FALSE);
break; break;
} }
break; break;
case 18: case 18:
@ -419,7 +623,7 @@ static bool8 MailReadBuildGraphics(void)
ShowBg(2); ShowBg(2);
BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK); BeginNormalPaletteFade(0xFFFFFFFF, 0, 16, 0, RGB_BLACK);
gPaletteFade.bufferTransferDisabled = FALSE; gPaletteFade.bufferTransferDisabled = FALSE;
sMailRead->callback2 = CB2_WaitForPaletteExitOnKeyPress; sMailRead->callback = CB2_WaitForPaletteExitOnKeyPress;
return TRUE; return TRUE;
default: default:
return FALSE; return FALSE;
@ -440,35 +644,39 @@ static void CB2_InitMailRead(void)
} while (MenuHelpers_LinkSomething() != TRUE); } while (MenuHelpers_LinkSomething() != TRUE);
} }
static void sub_8121A1C(void) static void BufferMailText(void)
{ {
u16 i; u16 i;
u8 total; u8 numWords;
u8 *ptr; u8 *ptr;
total = 0; // Convert the easy chat words to strings line by line and buffer them to message
for (i = 0; i < sMailRead->layout->numSubStructs; i ++) numWords = 0;
for (i = 0; i < sMailRead->layout->numLines; i ++)
{ {
ConvertEasyChatWordsToString(sMailRead->strbuf[i], &sMailRead->mail->words[total], sMailRead->layout->var8[i].numEasyChatWords, 1); ConvertEasyChatWordsToString(sMailRead->message[i], &sMailRead->mail->words[numWords], sMailRead->layout->lines[i].numEasyChatWords, 1);
total += sMailRead->layout->var8[i].numEasyChatWords; numWords += sMailRead->layout->lines[i].numEasyChatWords;
} }
// Buffer the signature
ptr = StringCopy(sMailRead->playerName, sMailRead->mail->playerName); ptr = StringCopy(sMailRead->playerName, sMailRead->mail->playerName);
if (!sMailRead->playerIsSender) if (!sMailRead->international)
{ {
StringCopy(ptr, gText_FromSpace); // Never reached
sMailRead->signatureWidth = sMailRead->layout->signatureWidth - (StringLength(sMailRead->playerName) * 8 - 0x60); StringCopy(ptr, gText_FromSpace); // Odd, "From" text is already printed in PrintMailText
sMailRead->signatureWidth = sMailRead->layout->signatureWidth - (StringLength(sMailRead->playerName) * 8 - 96);
} }
else else
{ {
sub_81DB52C(sMailRead->playerName); ConvertInternationalPlayerName(sMailRead->playerName);
sMailRead->signatureWidth = sMailRead->layout->signatureWidth; sMailRead->signatureWidth = sMailRead->layout->signatureWidth;
} }
} }
static void sub_8121B1C(void) static void PrintMailText(void)
{ {
u16 i; u16 i;
u8 strbuf[0x20]; u8 signature[32];
u8 y; u8 y;
u8 *bufptr; u8 *bufptr;
s32 box_x; s32 box_x;
@ -479,20 +687,19 @@ static void sub_8121B1C(void)
PutWindowTilemap(1); PutWindowTilemap(1);
FillWindowPixelBuffer(0, PIXEL_FILL(0)); FillWindowPixelBuffer(0, PIXEL_FILL(0));
FillWindowPixelBuffer(1, PIXEL_FILL(0)); FillWindowPixelBuffer(1, PIXEL_FILL(0));
for (i = 0; i < sMailRead->layout->numSubStructs; i ++) for (i = 0; i < sMailRead->layout->numLines; i ++)
{ {
if (sMailRead->strbuf[i][0] == EOS || sMailRead->strbuf[i][0] == CHAR_SPACE) if (sMailRead->message[i][0] == EOS || sMailRead->message[i][0] == CHAR_SPACE)
{
continue; continue;
}
AddTextPrinterParameterized3(0, 1, sMailRead->layout->var8[i].xOffset + sMailRead->layout->wordsYPos, y + sMailRead->layout->wordsXPos, sTextColors, 0, sMailRead->strbuf[i]); AddTextPrinterParameterized3(0, 1, sMailRead->layout->lines[i].xOffset + sMailRead->layout->wordsXPos, y + sMailRead->layout->wordsYPos, sTextColors, 0, sMailRead->message[i]);
y += sMailRead->layout->var8[i].lineHeight; y += sMailRead->layout->lines[i].height;
} }
bufptr = StringCopy(strbuf, gText_FromSpace); bufptr = StringCopy(signature, gText_FromSpace);
StringCopy(bufptr, sMailRead->playerName); StringCopy(bufptr, sMailRead->playerName);
box_x = GetStringCenterAlignXOffset(1, strbuf, sMailRead->signatureWidth) + 0x68; box_x = GetStringCenterAlignXOffset(1, signature, sMailRead->signatureWidth) + 104;
box_y = sMailRead->layout->signatureYPos + 0x58; box_y = sMailRead->layout->signatureYPos + 88;
AddTextPrinterParameterized3(0, 1, box_x, box_y, sTextColors, 0, strbuf); AddTextPrinterParameterized3(0, 1, box_x, box_y, sTextColors, 0, signature);
CopyWindowToVram(0, 3); CopyWindowToVram(0, 3);
CopyWindowToVram(1, 3); CopyWindowToVram(1, 3);
} }
@ -506,19 +713,19 @@ static void VBlankCB_MailRead(void)
static void CB2_MailRead(void) static void CB2_MailRead(void)
{ {
if (sMailRead->animsActive != 0) if (sMailRead->iconType != ICON_TYPE_NONE)
{ {
AnimateSprites(); AnimateSprites();
BuildOamBuffer(); BuildOamBuffer();
} }
sMailRead->callback2(); sMailRead->callback();
} }
static void CB2_WaitForPaletteExitOnKeyPress(void) static void CB2_WaitForPaletteExitOnKeyPress(void)
{ {
if (!UpdatePaletteFade()) if (!UpdatePaletteFade())
{ {
sMailRead->callback2 = CB2_ExitOnKeyPress; sMailRead->callback = CB2_ExitOnKeyPress;
} }
} }
@ -527,7 +734,7 @@ static void CB2_ExitOnKeyPress(void)
if (JOY_NEW(A_BUTTON | B_BUTTON)) if (JOY_NEW(A_BUTTON | B_BUTTON))
{ {
BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK); BeginNormalPaletteFade(0xFFFFFFFF, 0, 0, 16, RGB_BLACK);
sMailRead->callback2 = CB2_ExitMailReadFreeVars; sMailRead->callback = CB2_ExitMailReadFreeVars;
} }
} }
@ -535,13 +742,13 @@ static void CB2_ExitMailReadFreeVars(void)
{ {
if (!UpdatePaletteFade()) if (!UpdatePaletteFade())
{ {
SetMainCallback2(sMailRead->callback); SetMainCallback2(sMailRead->exitCallback);
switch (sMailRead->animsActive) switch (sMailRead->iconType)
{ {
case 1: case ICON_TYPE_BEAD:
case 2: case ICON_TYPE_DREAM:
FreeMonIconPalette(sub_80D2E84(sMailRead->mail->species)); FreeMonIconPalette(GetIconSpeciesNoPersonality(sMailRead->mail->species));
FreeAndDestroyMonIconSprite(&gSprites[sMailRead->monIconSprite]); FreeAndDestroyMonIconSprite(&gSprites[sMailRead->monIconSpriteId]);
} }
memset(sMailRead, 0, sizeof(*sMailRead)); memset(sMailRead, 0, sizeof(*sMailRead));
ResetPaletteFade(); ResetPaletteFade();

View File

@ -24,7 +24,7 @@ void ClearMailStruct(struct MailStruct *mail)
for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++) for (i = 0; i < PLAYER_NAME_LENGTH + 1; i++)
mail->playerName[i] = EOS; mail->playerName[i] = EOS;
for (i = 0; i < 4; i++) for (i = 0; i < TRAINER_ID_LENGTH; i++)
mail->trainerId[i] = 0; mail->trainerId[i] = 0;
mail->species = SPECIES_BULBASAUR; mail->species = SPECIES_BULBASAUR;
@ -34,7 +34,7 @@ void ClearMailStruct(struct MailStruct *mail)
bool8 MonHasMail(struct Pokemon *mon) bool8 MonHasMail(struct Pokemon *mon)
{ {
u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM); u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM);
if (ItemIsMail(heldItem) && GetMonData(mon, MON_DATA_MAIL) != 0xFF) if (ItemIsMail(heldItem) && GetMonData(mon, MON_DATA_MAIL) != MAIL_NONE)
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
@ -52,12 +52,12 @@ u8 GiveMailToMon(struct Pokemon *mon, u16 itemId)
for (id = 0; id < PARTY_SIZE; id++) for (id = 0; id < PARTY_SIZE; id++)
{ {
if (gSaveBlock1Ptr->mail[id].itemId == 0) if (gSaveBlock1Ptr->mail[id].itemId == ITEM_NONE)
{ {
for (i = 0; i < MAIL_WORDS_COUNT; i++) for (i = 0; i < MAIL_WORDS_COUNT; i++)
gSaveBlock1Ptr->mail[id].words[i] = 0xFFFF; gSaveBlock1Ptr->mail[id].words[i] = 0xFFFF;
for (i = 0; i < PLAYER_NAME_LENGTH + 1 - 1; i++) for (i = 0; i < PLAYER_NAME_LENGTH; i++)
gSaveBlock1Ptr->mail[id].playerName[i] = gSaveBlock2Ptr->playerName[i]; gSaveBlock1Ptr->mail[id].playerName[i] = gSaveBlock2Ptr->playerName[i];
gSaveBlock1Ptr->mail[id].playerName[i] = EOS; gSaveBlock1Ptr->mail[id].playerName[i] = EOS;
PadNameString(gSaveBlock1Ptr->mail[id].playerName, CHAR_SPACE); PadNameString(gSaveBlock1Ptr->mail[id].playerName, CHAR_SPACE);
@ -75,7 +75,7 @@ u8 GiveMailToMon(struct Pokemon *mon, u16 itemId)
} }
} }
return 0xFF; return MAIL_NONE;
} }
u16 SpeciesToMailSpecies(u16 species, u32 personality) u16 SpeciesToMailSpecies(u16 species, u32 personality)
@ -93,7 +93,7 @@ u16 MailSpeciesToSpecies(u16 mailSpecies, u16 *buffer)
{ {
u16 result; u16 result;
if (mailSpecies >= 30000 && mailSpecies < (30000 + UNOWN_FORM_COUNT)) if (mailSpecies >= 30000 && mailSpecies < (30000 + NUM_UNOWN_FORMS))
{ {
result = SPECIES_UNOWN; result = SPECIES_UNOWN;
*buffer = mailSpecies - 30000; *buffer = mailSpecies - 30000;
@ -112,8 +112,8 @@ u8 GiveMailToMon2(struct Pokemon *mon, struct MailStruct *mail)
u16 itemId = mail->itemId; u16 itemId = mail->itemId;
u8 mailId = GiveMailToMon(mon, itemId); u8 mailId = GiveMailToMon(mon, itemId);
if (mailId == 0xFF) if (mailId == MAIL_NONE)
return 0xFF; return MAIL_NONE;
gSaveBlock1Ptr->mail[mailId] = *mail; gSaveBlock1Ptr->mail[mailId] = *mail;
@ -141,7 +141,7 @@ void TakeMailFromMon(struct Pokemon *mon)
{ {
mailId = GetMonData(mon, MON_DATA_MAIL); mailId = GetMonData(mon, MON_DATA_MAIL);
gSaveBlock1Ptr->mail[mailId].itemId = ITEM_NONE; gSaveBlock1Ptr->mail[mailId].itemId = ITEM_NONE;
mailId = 0xFF; mailId = MAIL_NONE;
heldItem[0] = ITEM_NONE; heldItem[0] = ITEM_NONE;
heldItem[1] = ITEM_NONE << 8; heldItem[1] = ITEM_NONE << 8;
SetMonData(mon, MON_DATA_MAIL, &mailId); SetMonData(mon, MON_DATA_MAIL, &mailId);
@ -162,7 +162,7 @@ u8 TakeMailFromMon2(struct Pokemon *mon)
newHeldItem[0] = ITEM_NONE; newHeldItem[0] = ITEM_NONE;
newHeldItem[1] = ITEM_NONE << 8; newHeldItem[1] = ITEM_NONE << 8;
newMailId = 0xFF; newMailId = MAIL_NONE;
for (i = PARTY_SIZE; i < MAIL_COUNT; i++) for (i = PARTY_SIZE; i < MAIL_COUNT; i++)
{ {
@ -176,7 +176,7 @@ u8 TakeMailFromMon2(struct Pokemon *mon)
} }
} }
return 0xFF; return MAIL_NONE;
} }
bool8 ItemIsMail(u16 itemId) bool8 ItemIsMail(u16 itemId)

View File

@ -261,10 +261,10 @@ static void sub_81D1D44(u8 windowId, s32 itemId, u8 y)
if (itemId == LIST_CANCEL) if (itemId == LIST_CANCEL)
return; return;
StringCopy(buffer, gSaveBlock1Ptr->mail[6 + itemId].playerName); StringCopy(buffer, gSaveBlock1Ptr->mail[PARTY_SIZE + itemId].playerName);
sub_81DB52C(buffer); ConvertInternationalPlayerName(buffer);
length = StringLength(buffer); length = StringLength(buffer);
if (length <= 5) if (length < PLAYER_NAME_LENGTH - 1)
ConvertInternationalString(buffer, LANGUAGE_JAPANESE); ConvertInternationalString(buffer, LANGUAGE_JAPANESE);
AddTextPrinterParameterized4(windowId, 1, 8, y, 0, 0, sPlayerNameTextColors, -1, buffer); AddTextPrinterParameterized4(windowId, 1, 8, y, 0, 0, sPlayerNameTextColors, -1, buffer);
} }

View File

@ -420,7 +420,7 @@ void sub_801C4C0(void)
sWonderCardData->unk_017C = 0xFF; sWonderCardData->unk_017C = 0xFF;
if (sWonderCardData->unk_014C.unk_06 != SPECIES_NONE) if (sWonderCardData->unk_014C.unk_06 != SPECIES_NONE)
{ {
sWonderCardData->unk_017C = sub_80D2D78(sub_80D2E84(sWonderCardData->unk_014C.unk_06), SpriteCallbackDummy, 0xDC, 0x14, 0, FALSE); sWonderCardData->unk_017C = CreateMonIconNoPersonality(GetIconSpeciesNoPersonality(sWonderCardData->unk_014C.unk_06), SpriteCallbackDummy, 0xDC, 0x14, 0, FALSE);
gSprites[sWonderCardData->unk_017C].oam.priority = 2; gSprites[sWonderCardData->unk_017C].oam.priority = 2;
} }
if (sWonderCardData->unk_0000.unk_09 != 0 && sWonderCardData->unk_0000.unk_08_0 == 1) if (sWonderCardData->unk_0000.unk_09 != 0 && sWonderCardData->unk_0000.unk_08_0 == 1)
@ -434,7 +434,7 @@ void sub_801C4C0(void)
sWonderCardData->unk_017D[r7][0] = CreateSprite(&gUnknown_082F1D48, 0xd8 - 32 * r7, 0x90, 8); sWonderCardData->unk_017D[r7][0] = CreateSprite(&gUnknown_082F1D48, 0xd8 - 32 * r7, 0x90, 8);
if (sWonderCardData->unk_014C.unk_08[0][r7] != 0) if (sWonderCardData->unk_014C.unk_08[0][r7] != 0)
{ {
sWonderCardData->unk_017D[r7][1] = sub_80D2D78(sub_80D2E84(sWonderCardData->unk_014C.unk_08[0][r7]), SpriteCallbackDummy, 0xd8 - 32 * r7, 0x88, 0, 0); sWonderCardData->unk_017D[r7][1] = CreateMonIconNoPersonality(GetIconSpeciesNoPersonality(sWonderCardData->unk_014C.unk_08[0][r7]), SpriteCallbackDummy, 0xd8 - 32 * r7, 0x88, 0, 0);
} }
} }
} }

View File

@ -325,7 +325,7 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx)
} }
else else
{ {
memcpy(&gPlayerParty[5], pokemonPtr, sizeof(struct Pokemon)); memcpy(&gPlayerParty[PARTY_SIZE - 1], pokemonPtr, sizeof(struct Pokemon));
memcpy(&mail, mailPtr, sizeof(struct MailStruct)); memcpy(&mail, mailPtr, sizeof(struct MailStruct));
if (species != SPECIES_EGG) if (species != SPECIES_EGG)
@ -335,9 +335,9 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx)
GetSetPokedexFlag(pokedexNum, FLAG_SET_CAUGHT); GetSetPokedexFlag(pokedexNum, FLAG_SET_CAUGHT);
} }
heldItem = GetMonData(&gPlayerParty[5], MON_DATA_HELD_ITEM); heldItem = GetMonData(&gPlayerParty[PARTY_SIZE - 1], MON_DATA_HELD_ITEM);
if (ItemIsMail(heldItem)) if (ItemIsMail(heldItem))
GiveMailToMon2(&gPlayerParty[5], &mail); GiveMailToMon2(&gPlayerParty[PARTY_SIZE - 1], &mail);
CompactPartySlots(); CompactPartySlots();
CalculatePlayerPartyCount(); CalculatePlayerPartyCount();
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftSentOver); StringExpandPlaceholders(gStringVar4, gText_MysteryGiftSentOver);
@ -350,7 +350,7 @@ bool8 MEScrCmd_givepokemon(struct ScriptContext *ctx)
bool8 MEScrCmd_addtrainer(struct ScriptContext *ctx) bool8 MEScrCmd_addtrainer(struct ScriptContext *ctx)
{ {
u32 data = ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0]; u32 data = ScriptReadWord(ctx) - ctx->data[1] + ctx->data[0];
memcpy((void*)(gSaveBlock2Ptr) + 0xBEC, (void *)data, 0xBC); memcpy(&gSaveBlock2Ptr->frontier.ereaderTrainer, (void *)data, sizeof(gSaveBlock2Ptr->frontier.ereaderTrainer));
ValidateEReaderTrainer(); ValidateEReaderTrainer();
StringExpandPlaceholders(gStringVar4, gText_MysteryGiftNewTrainer); StringExpandPlaceholders(gStringVar4, gText_MysteryGiftNewTrainer);
ctx->data[2] = 2; ctx->data[2] = 2;

View File

@ -955,7 +955,7 @@ static void DisplayPartyPokemonDataForMultiBattle(u8 slot)
menuBox->infoRects->blitFunc(menuBox->windowId, 0, 0, 0, 0, FALSE); menuBox->infoRects->blitFunc(menuBox->windowId, 0, 0, 0, 0, FALSE);
StringCopy(gStringVar1, gMultiPartnerParty[actualSlot].nickname); StringCopy(gStringVar1, gMultiPartnerParty[actualSlot].nickname);
StringGetEnd10(gStringVar1); StringGetEnd10(gStringVar1);
sub_81DB52C(gStringVar1); ConvertInternationalPlayerName(gStringVar1);
DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, menuBox->infoRects->dimensions); DisplayPartyPokemonBarDetail(menuBox->windowId, gStringVar1, 0, menuBox->infoRects->dimensions);
DisplayPartyPokemonLevel(gMultiPartnerParty[actualSlot].level, menuBox); DisplayPartyPokemonLevel(gMultiPartnerParty[actualSlot].level, menuBox);
DisplayPartyPokemonGender(gMultiPartnerParty[actualSlot].gender, gMultiPartnerParty[actualSlot].species, gMultiPartnerParty[actualSlot].nickname, menuBox); DisplayPartyPokemonGender(gMultiPartnerParty[actualSlot].gender, gMultiPartnerParty[actualSlot].species, gMultiPartnerParty[actualSlot].nickname, menuBox);

View File

@ -593,8 +593,8 @@ static u8 GetMailboxMailCount(void)
{ {
u8 i, j; u8 i, j;
for(i = 0, j = 6; j < 16; j++) for(i = 0, j = PARTY_SIZE; j < MAIL_COUNT; j++)
if (gSaveBlock1Ptr->mail[j].itemId != 0) if (gSaveBlock1Ptr->mail[j].itemId != ITEM_NONE)
i++; i++;
return i; return i;
@ -605,9 +605,9 @@ static void Mailbox_UpdateMailList(void)
struct MailStruct mailBuffer; struct MailStruct mailBuffer;
u8 i, j; u8 i, j;
for (i=6; i<15; i++) for (i = PARTY_SIZE; i < MAIL_COUNT - 1; i++)
{ {
for (j=i+1; j<16; j++) for (j = i + 1; j < MAIL_COUNT; j++)
{ {
if (gSaveBlock1Ptr->mail[i].itemId == 0) if (gSaveBlock1Ptr->mail[i].itemId == 0)
{ {
@ -665,8 +665,8 @@ static void Mailbox_ProcessInput(u8 taskId)
static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId) static void Mailbox_PrintWhatToDoWithPlayerMailText(u8 taskId)
{ {
StringCopy(gStringVar1, gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos].playerName); StringCopy(gStringVar1, gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + PARTY_SIZE + playerPCItemPageInfo.cursorPos].playerName);
sub_81DB554(gStringVar1, 0); ConvertInternationalPlayerNameStripChar(gStringVar1, CHAR_SPACE);
StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithVar1sMail); StringExpandPlaceholders(gStringVar4, gText_WhatToDoWithVar1sMail);
DisplayItemMessageOnField(taskId, gStringVar4, Mailbox_PrintMailOptions); DisplayItemMessageOnField(taskId, gStringVar4, Mailbox_PrintMailOptions);
} }
@ -724,7 +724,7 @@ static void Mailbox_FadeAndReadMail(u8 taskId)
{ {
sub_81D1EC0(); sub_81D1EC0();
CleanupOverworldWindowsAndTilemaps(); CleanupOverworldWindowsAndTilemaps();
ReadMail(&(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]), Mailbox_ReturnToFieldFromReadMail, TRUE); ReadMail(&(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + PARTY_SIZE + playerPCItemPageInfo.cursorPos]), Mailbox_ReturnToFieldFromReadMail, TRUE);
DestroyTask(taskId); DestroyTask(taskId);
} }
} }
@ -785,7 +785,7 @@ static void Mailbox_MoveToBagYesNoPrompt(u8 taskId)
static void Mailbox_DoMailMoveToBag(u8 taskId) static void Mailbox_DoMailMoveToBag(u8 taskId)
{ {
struct MailStruct *mailStruct = &(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + 6 + playerPCItemPageInfo.cursorPos]); struct MailStruct *mailStruct = &(gSaveBlock1Ptr->mail[playerPCItemPageInfo.itemsAbove + PARTY_SIZE + playerPCItemPageInfo.cursorPos]);
if (!AddBagItem(mailStruct->itemId, 1)) if (!AddBagItem(mailStruct->itemId, 1))
{ {
DisplayItemMessageOnField(taskId, gText_BagIsFull, Mailbox_Cancel); DisplayItemMessageOnField(taskId, gText_BagIsFull, Mailbox_Cancel);

View File

@ -1051,7 +1051,7 @@ u8 CreateMonIcon(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u
return spriteId; return spriteId;
} }
u8 sub_80D2D78(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, bool32 extra) u8 CreateMonIconNoPersonality(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8 subpriority, bool32 handleDeoxys)
{ {
u8 spriteId; u8 spriteId;
struct MonIconSpriteTemplate iconTemplate = struct MonIconSpriteTemplate iconTemplate =
@ -1064,7 +1064,7 @@ u8 sub_80D2D78(u16 species, void (*callback)(struct Sprite *), s16 x, s16 y, u8
.paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndices[species], .paletteTag = POKE_ICON_BASE_PAL_TAG + gMonIconPaletteIndices[species],
}; };
iconTemplate.image = GetMonIconTiles(species, extra); iconTemplate.image = GetMonIconTiles(species, handleDeoxys);
spriteId = CreateMonIconSprite(&iconTemplate, x, y, subpriority); spriteId = CreateMonIconSprite(&iconTemplate, x, y, subpriority);
UpdateMonIconFrame(&gSprites[spriteId]); UpdateMonIconFrame(&gSprites[spriteId]);
@ -1104,7 +1104,7 @@ u16 GetUnownLetterByPersonality(u32 personality)
return GET_UNOWN_LETTER(personality); return GET_UNOWN_LETTER(personality);
} }
u16 sub_80D2E84(u16 species) u16 GetIconSpeciesNoPersonality(u16 species)
{ {
u16 value; u16 value;

View File

@ -3024,7 +3024,7 @@ static void TradeMons(u8 playerPartyIdx, u8 partnerPartyIdx)
struct Pokemon *partnerMon = &gEnemyParty[partnerPartyIdx]; struct Pokemon *partnerMon = &gEnemyParty[partnerPartyIdx];
u16 partnerMail = GetMonData(partnerMon, MON_DATA_MAIL); u16 partnerMail = GetMonData(partnerMon, MON_DATA_MAIL);
if (playerMail != 0xFF) if (playerMail != MAIL_NONE)
ClearMailStruct(&gSaveBlock1Ptr->mail[playerMail]); ClearMailStruct(&gSaveBlock1Ptr->mail[playerMail]);
sTradeData->mon = *playerMon; sTradeData->mon = *playerMon;
@ -3035,7 +3035,7 @@ static void TradeMons(u8 playerPartyIdx, u8 partnerPartyIdx)
if (!GetMonData(playerMon, MON_DATA_IS_EGG)) if (!GetMonData(playerMon, MON_DATA_IS_EGG))
SetMonData(playerMon, MON_DATA_FRIENDSHIP, &friendship); SetMonData(playerMon, MON_DATA_FRIENDSHIP, &friendship);
if (partnerMail != 0xFF) if (partnerMail != MAIL_NONE)
GiveMailToMon2(playerMon, &gTradeMail[partnerMail]); GiveMailToMon2(playerMon, &gTradeMail[partnerMail]);
UpdatePokedexForReceivedMon(playerPartyIdx); UpdatePokedexForReceivedMon(playerPartyIdx);