Merge pull request #82 from PikalaxALT/mail

Decompile functions for reading mail
This commit is contained in:
Diegoisawesome 2017-10-20 13:22:56 -05:00 committed by GitHub
commit d2cf86bff9
13 changed files with 736 additions and 1072 deletions

1035
asm/mail.s

File diff suppressed because it is too large Load Diff

View File

@ -910,8 +910,116 @@ gCableCarCord_Gfx:: @ 8DBC2C0
gUnknown_08DBC2E8:: @ 8DBC2E8
.incbin "baserom.gba", 0xdbc2e8, 0x72c
gUnknown_08DBCA14:: @ 8DBCA14
.incbin "baserom.gba", 0xdbca14, 0x3d00
gUnknown_08DBCA14:: @ 0x08DBCA14
.incbin "baserom.gba", 0xdbca14, 0x1e04
gUnknown_08DBE818:: @ 0x08DBE818
.incbin "baserom.gba", 0xdbe818, 0x20
gUnknown_08DBE838:: @ 0x08DBE838
.incbin "baserom.gba", 0xdbe838, 0x20
gUnknown_08DBE858:: @ 0x08DBE858
.incbin "baserom.gba", 0xdbe858, 0x20
gUnknown_08DBE878:: @ 0x08DBE878
.incbin "baserom.gba", 0xdbe878, 0x20
gUnknown_08DBE898:: @ 0x08DBE898
.incbin "baserom.gba", 0xdbe898, 0x20
gUnknown_08DBE8B8:: @ 0x08DBE8B8
.incbin "baserom.gba", 0xdbe8b8, 0x20
gUnknown_08DBE8D8:: @ 0x08DBE8D8
.incbin "baserom.gba", 0xdbe8d8, 0x20
gUnknown_08DBE8F8:: @ 0x08DBE8F8
.incbin "baserom.gba", 0xdbe8f8, 0x20
gUnknown_08DBE918:: @ 0x08DBE918
.incbin "baserom.gba", 0xdbe918, 0x20
gUnknown_08DBE938:: @ 0x08DBE938
.incbin "baserom.gba", 0xdbe938, 0x20
gUnknown_08DBE958:: @ 0x08DBE958
.incbin "baserom.gba", 0xdbe958, 0x20
gUnknown_08DBE978:: @ 0x08DBE978
.incbin "baserom.gba", 0xdbe978, 0x20
gUnknown_08DBE998:: @ 0x08DBE998
.incbin "baserom.gba", 0xdbe998, 0x1a0
gUnknown_08DBEB38:: @ 0x08DBEB38
.incbin "baserom.gba", 0xdbeb38, 0x13c
gUnknown_08DBEC74:: @ 0x08DBEC74
.incbin "baserom.gba", 0xdbec74, 0x210
gUnknown_08DBEE84:: @ 0x08DBEE84
.incbin "baserom.gba", 0xdbee84, 0xd8
gUnknown_08DBEF5C:: @ 0x08DBEF5C
.incbin "baserom.gba", 0xdbef5c, 0x1f8
gUnknown_08DBF154:: @ 0x08DBF154
.incbin "baserom.gba", 0xdbf154, 0x180
gUnknown_08DBF2D4:: @ 0x08DBF2D4
.incbin "baserom.gba", 0xdbf2d4, 0xa8
gUnknown_08DBF37C:: @ 0x08DBF37C
.incbin "baserom.gba", 0xdbf37c, 0x190
gUnknown_08DBF50C:: @ 0x08DBF50C
.incbin "baserom.gba", 0xdbf50c, 0x140
gUnknown_08DBF64C:: @ 0x08DBF64C
.incbin "baserom.gba", 0xdbf64c, 0x168
gUnknown_08DBF7B4:: @ 0x08DBF7B4
.incbin "baserom.gba", 0xdbf7b4, 0x150
gUnknown_08DBF904:: @ 0x08DBF904
.incbin "baserom.gba", 0xdbf904, 0x2a0
gUnknown_08DBFBA4:: @ 0x08DBFBA4
.incbin "baserom.gba", 0xdbfba4, 0xd8
gUnknown_08DBFC7C:: @ 0x08DBFC7C
.incbin "baserom.gba", 0xdbfc7c, 0xe0
gUnknown_08DBFD5C:: @ 0x08DBFD5C
.incbin "baserom.gba", 0xdbfd5c, 0x10c
gUnknown_08DBFE68:: @ 0x08DBFE68
.incbin "baserom.gba", 0xdbfe68, 0xdc
gUnknown_08DBFF44:: @ 0x08DBFF44
.incbin "baserom.gba", 0xdbff44, 0xf0
gUnknown_08DC0034:: @ 0x08DC0034
.incbin "baserom.gba", 0xdc0034, 0xe0
gUnknown_08DC0114:: @ 0x08DC0114
.incbin "baserom.gba", 0xdc0114, 0xe0
gUnknown_08DC01F4:: @ 0x08DC01F4
.incbin "baserom.gba", 0xdc01f4, 0x10c
gUnknown_08DC0300:: @ 0x08DC0300
.incbin "baserom.gba", 0xdc0300, 0xf0
gUnknown_08DC03F0:: @ 0x08DC03F0
.incbin "baserom.gba", 0xdc03f0, 0xf8
gUnknown_08DC04E8:: @ 0x08DC04E8
.incbin "baserom.gba", 0xdc04e8, 0x118
gUnknown_08DC0600:: @ 0x08DC0600
.incbin "baserom.gba", 0xdc0600, 0x114
gUnknown_08DC0714:: @ 8DC0714
.incbin "baserom.gba", 0xdc0714, 0x40

View File

@ -1,26 +0,0 @@
.include "asm/macros.inc"
.include "constants/constants.inc"
.section .rodata
.align 2, 0
gUnknown_0859F290:: @ 859F290
.incbin "baserom.gba", 0x59f290, 0xc
gUnknown_0859F29C:: @ 859F29C
.incbin "baserom.gba", 0x59f29c, 0x10
gUnknown_0859F2AC:: @ 859F2AC
.incbin "baserom.gba", 0x59f2ac, 0x4
gUnknown_0859F2B0:: @ 859F2B0
.incbin "baserom.gba", 0x59f2b0, 0x8
gUnknown_0859F2B8:: @ 859F2B8
.incbin "baserom.gba", 0x59f2b8, 0xfc
gUnknown_0859F3B4:: @ 859F3B4
.incbin "baserom.gba", 0x59f3b4, 0xa4
gUnknown_0859F458:: @ 859F458
.incbin "baserom.gba", 0x59f458, 0xbc

View File

@ -1,6 +1,9 @@
#ifndef GUARD_INTERNATIONAL_STRING_UTIL_H
#define GUARD_INTERNATIONAL_STRING_UTIL_H
void sub_81DB52C(const u8 *src);
void TVShowConvertInternationalString(u8 *dest, const u8 *src, u8 language);
u32 sub_81DB604(const u8 *);
s32 GetStringCenterAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth);
s32 GetStringRightAlignXOffset(s32 fontId, const u8 *str, s32 totalWidth);
s32 GetStringCenterAlignXOffsetWithLetterSpacing(s32 fontId, const u8 *str, s32 totalWidth, s32 letterSpacing);
@ -14,7 +17,6 @@ s32 sub_81DB3D8(const u8 **str, u8* arg1, s32 arg2);
// sub_81DB52C
// sub_81DB554
// sub_81DB5AC
void TVShowConvertInternationalString(u8 *dest, const u8 *src, u8 language);
u32 sub_81DB604(const u8 *);
// sub_81DB620

12
include/mail_data.h Normal file
View File

@ -0,0 +1,12 @@
#ifndef GUARD_MAIL_DATA_H
#define GUARD_MAIL_DATA_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
u16 sub_80D45E8(u16, u16 *);
#endif //GUARD_MAIL_DATA_H

View File

@ -19,6 +19,9 @@ void box_print(u8, u8, u8, u8, const void *, s8, const u8 *);
void sub_8198070(u8 windowId, bool8 copyToVram);
void SetWindowTemplateFields(struct WindowTemplate* template, u8 priority, u8 tilemapLeft, u8 tilemapTop, u8 width, u8 height, u8 palNum, u16 baseBlock);
void SetWindowBorderStyle(u8 windowId, bool8 copyToVram, u16 tileStart, u8 palette);
void sub_8198A50(struct WindowTemplate*, u8, u8, u8, u8, u8, u8, u16); // returns something but it isn't used, fix when menu.s is decomp'd
void reset_temp_tile_data_buffers(void);
int decompress_and_copy_tile_data_to_vram(u8 bg_id, const void *src, int size, u16 offset, u8 mode);
bool8 free_temp_tile_data_buffers_if_possible(void);
u64 sub_8198A50(struct WindowTemplate*, u8, u8, u8, u8, u8, u8, u16); // returns something but it isn't used, fix when menu.s is decomp'd
#endif // GUARD_MENU_H

11
include/menu_helpers.h Normal file
View File

@ -0,0 +1,11 @@
#ifndef GUARD_MENU_HELPERS_H
#define GUARD_MENU_HELPERS_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
bool8 sub_81221AC(void);
#endif //GUARD_MENU_HELPERS_H

View File

@ -53,6 +53,7 @@ const struct MapHeader *get_mapheader_by_bank_and_number(u8, u8);
void FieldObjectMoveDestCoords(struct MapObject *, u32, s16 *, s16 *);
void sub_8086230(void);
void c2_exit_to_overworld_2_switch(void);
bool32 sub_8087598(void);
void c2_exit_to_overworld_1_continue_scripts_restart_music(void);
#endif //GUARD_ROM4_H

View File

@ -3,5 +3,10 @@
const u8 *GetMonIconPtr(u16 speciesId, u32 personality, u32 frameNo);
const u16 *GetValidMonIconPalettePtr(u16 speciesId);
u16 sub_80D2E84(u16 speciesId);
void sub_80D2F68(u16 iconId);
u8 sub_80D2D78(u16 iconId, void callback(struct Sprite *), u16 x, u16 y, u16 a4, u8 a5);
void sub_80D2FF0(u16 iconId);
void sub_80D2EF8(struct Sprite *sprite);
#endif // GUARD_POKEMON_ICON_H

View File

@ -1,6 +1,13 @@
#ifndef GUARD_strings_H
#define GUARD_strings_H
#ifndef GUARD_STRINGS_H
#define GUARD_STRINGS_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
extern const u8 gText_FromSpace[];
extern const u8 gText_Lv50[];
extern const u8 gText_OpenLevel[];
extern const u8 gText_Mom[];
@ -30,4 +37,4 @@ extern const u8 gText_First[];
extern const u8 gText_Second[];
extern const u8 gText_Third[];
#endif //GUARD_strings_H
#endif //GUARD_STRINGS_H

View File

@ -164,7 +164,7 @@ SECTIONS {
asm/easy_chat.o(.text);
asm/mon_markings.o(.text);
asm/mauville_old_man.o(.text);
asm/mail.o(.text);
src/mail.o(.text);
asm/menu_helpers.o(.text);
asm/dewford_trend.o(.text);
asm/heal_location.o(.text);
@ -403,7 +403,7 @@ SECTIONS {
data/easy_chat.o(.rodata);
data/mon_markings.o(.rodata);
data/mauville_old_man.o(.rodata);
data/mail.o(.rodata);
src/mail.o(.rodata);
data/menu_helpers.o(.rodata);
data/heal_location.o(.rodata);
data/region_map.o(.rodata);

577
src/mail.c Normal file
View File

@ -0,0 +1,577 @@
// Includes
#include "global.h"
#include "main.h"
#include "overworld.h"
#include "task.h"
#include "unknown_task.h"
#include "palette.h"
#include "menu.h"
#include "menu_helpers.h"
#include "text.h"
#include "text_window.h"
#include "string_util.h"
#include "international_string_util.h"
#include "strings.h"
#include "gpu_regs.h"
#include "bg.h"
#include "pokemon_icon.h"
#include "species.h"
#include "malloc.h"
#include "easy_chat.h"
#include "mail_data.h"
#include "mail.h"
// Static type declarations
struct UnkMailStruct
{
u32 numEasyChatWords:2;
u32 xOffset:6;
u32 lineHeight:8;
};
struct MailLayout
{
u8 numSubStructs;
u8 signatureYPos;
u8 signatureWidth;
u8 wordsXPos;
u8 wordsYPos;
const struct UnkMailStruct *var8;
};
struct MailGraphics
{
const u16 *palette;
const u8 *tiles;
const u8 *tileMap;
u16 var0C;
u16 var0E;
u16 color10;
u16 color12;
};
// Static RAM declarations
static EWRAM_DATA struct
{
/*0x0000*/ u8 strbuf[8][64];
/*0x0200*/ u8 playerName[12];
/*0x020C*/ MainCallback callback;
/*0x0210*/ MainCallback callback2;
/*0x0214*/ struct MailStruct *mail;
/*0x0218*/ bool8 flag;
/*0x0219*/ u8 signatureWidth;
/*0x021a*/ u8 mailType;
/*0x021b*/ u8 animsActive;
/*0x021c*/ u8 monIconSprite;
/*0x021d*/ u8 language;
/*0x021e*/ bool8 playerIsSender;
/*0x0220*/ void (*parserSingle)(u8 *dest, u16 word);
/*0x0224*/ void (*parserMultiple)(u8 *dest, const u16 *src, u16 length1, u16 length2);
/*0x0228*/ const struct MailLayout *layout;
/*0x022c*/ u8 bg1TilemapBuffer[0x1000];
/*0x122c*/ u8 bg2TilemapBuffer[0x1000];
} *gUnknown_0203A134 = NULL;
// Static ROM declarations
void sub_81219F0(void);
void sub_8121A1C(void);
void sub_8121B1C(void);
void sub_8121C50(void);
void sub_8121C64(void);
void sub_8121C98(void);
void sub_8121CC0(void);
void sub_8121D00(void);
// .rodata
const struct BgTemplate gUnknown_0859F290[] = {
{
.bg = 0,
.charBaseIndex = 2,
.mapBaseIndex = 31,
.priority = 0
}, {
.bg = 1,
.charBaseIndex = 0,
.mapBaseIndex = 30,
.priority = 1
}, {
.bg = 2,
.charBaseIndex = 0,
.mapBaseIndex = 29,
.priority = 2
}
};
const struct WindowTemplate gUnknown_0859F29C[] = {
{
.priority = 0,
.tilemapLeft = 2,
.tilemapTop = 3,
.width = 26,
.height = 15,
.paletteNum = 15,
.baseBlock = 1
},
DUMMY_WIN_TEMPLATE
};
const u8 gUnknown_0859F2AC[] = {
0,
10,
11
};
const u16 gUnknown_0859F2B0[][2] = {
{ 0x6ACD, 0x51A5 },
{ 0x45FC, 0x38D4 }
};
extern const u16 gUnknown_08DBE818[];
extern const u16 gUnknown_08DBE838[];
extern const u16 gUnknown_08DBE858[];
extern const u16 gUnknown_08DBE878[];
extern const u16 gUnknown_08DBE898[];
extern const u16 gUnknown_08DBE8B8[];
extern const u16 gUnknown_08DBE8D8[];
extern const u16 gUnknown_08DBE8F8[];
extern const u16 gUnknown_08DBE918[];
extern const u16 gUnknown_08DBE938[];
extern const u16 gUnknown_08DBE958[];
extern const u16 gUnknown_08DBE978[];
extern const u8 gUnknown_08DBE998[];
extern const u8 gUnknown_08DBFBA4[];
extern const u8 gUnknown_08DBEB38[];
extern const u8 gUnknown_08DBFC7C[];
extern const u8 gUnknown_08DBEC74[];
extern const u8 gUnknown_08DBFD5C[];
extern const u8 gUnknown_08DBEE84[];
extern const u8 gUnknown_08DBFE68[];
extern const u8 gUnknown_08DBEF5C[];
extern const u8 gUnknown_08DBFF44[];
extern const u8 gUnknown_08DBF154[];
extern const u8 gUnknown_08DC0034[];
extern const u8 gUnknown_08DBF2D4[];
extern const u8 gUnknown_08DC0114[];
extern const u8 gUnknown_08DBF37C[];
extern const u8 gUnknown_08DC01F4[];
extern const u8 gUnknown_08DBF50C[];
extern const u8 gUnknown_08DC0300[];
extern const u8 gUnknown_08DBF64C[];
extern const u8 gUnknown_08DC03F0[];
extern const u8 gUnknown_08DBF7B4[];
extern const u8 gUnknown_08DC04E8[];
extern const u8 gUnknown_08DBF904[];
extern const u8 gUnknown_08DC0600[];
const struct MailGraphics gUnknown_0859F2B8[] = {
{
gUnknown_08DBE818, gUnknown_08DBE998, gUnknown_08DBFBA4, 0x02c0, 0x0000, 0x294a, 0x6739
}, {
gUnknown_08DBE838, gUnknown_08DBEB38, gUnknown_08DBFC7C, 0x02e0, 0x0000, 0x7fff, 0x4631
}, {
gUnknown_08DBE858, gUnknown_08DBEC74, gUnknown_08DBFD5C, 0x0400, 0x0000, 0x294a, 0x6739
}, {
gUnknown_08DBE878, gUnknown_08DBEE84, gUnknown_08DBFE68, 0x01e0, 0x0000, 0x7fff, 0x4631
}, {
gUnknown_08DBE898, gUnknown_08DBEF5C, gUnknown_08DBFF44, 0x02e0, 0x0000, 0x7fff, 0x4631
}, {
gUnknown_08DBE8B8, gUnknown_08DBF154, gUnknown_08DC0034, 0x0300, 0x0000, 0x294a, 0x6739
}, {
gUnknown_08DBE8D8, gUnknown_08DBF2D4, gUnknown_08DC0114, 0x0140, 0x0000, 0x7fff, 0x4631
}, {
gUnknown_08DBE8F8, gUnknown_08DBF37C, gUnknown_08DC01F4, 0x0300, 0x0000, 0x7fff, 0x4631
}, {
gUnknown_08DBE918, gUnknown_08DBF50C, gUnknown_08DC0300, 0x0220, 0x0000, 0x294a, 0x6739
}, {
gUnknown_08DBE938, gUnknown_08DBF64C, gUnknown_08DC03F0, 0x0340, 0x0000, 0x294a, 0x6739
}, {
gUnknown_08DBE958, gUnknown_08DBF7B4, gUnknown_08DC04E8, 0x02a0, 0x0000, 0x294a, 0x6739
}, {
gUnknown_08DBE978, gUnknown_08DBF904, gUnknown_08DC0600, 0x0520, 0x0000, 0x294a, 0x6739
}
};
const struct UnkMailStruct Unknown_0859F3A8[] = {
{ .numEasyChatWords = 3, .lineHeight = 16 },
{ .numEasyChatWords = 3, .lineHeight = 16 },
{ .numEasyChatWords = 3, .lineHeight = 16 }
};
const struct MailLayout gUnknown_0859F3B4[] = {
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x08, 0x00, 0x02, 0x04, Unknown_0859F3A8 },
{ 0x03, 0x00, 0x00, 0x02, 0x00, Unknown_0859F3A8 }
};
const struct UnkMailStruct Unknown_0859F444[] = {
{ .numEasyChatWords = 2, .lineHeight = 16 },
{ .numEasyChatWords = 2, .lineHeight = 16 },
{ .numEasyChatWords = 2, .lineHeight = 16 },
{ .numEasyChatWords = 2, .lineHeight = 16 },
{ .numEasyChatWords = 1, .lineHeight = 16 }
};
const struct MailLayout gUnknown_0859F458[] = {
{ 0x05, 0x07, 0x58, 0x0b, 0x1e, Unknown_0859F444 },
{ 0x05, 0x0a, 0x60, 0x09, 0x1e, Unknown_0859F444 },
{ 0x05, 0x0c, 0x68, 0x05, 0x1e, Unknown_0859F444 },
{ 0x05, 0x05, 0x60, 0x08, 0x1e, Unknown_0859F444 },
{ 0x05, 0x0a, 0x60, 0x09, 0x1e, Unknown_0859F444 },
{ 0x05, 0x09, 0x70, 0x05, 0x1e, Unknown_0859F444 },
{ 0x05, 0x0c, 0x68, 0x09, 0x1e, Unknown_0859F444 },
{ 0x05, 0x0d, 0x68, 0x0d, 0x1e, Unknown_0859F444 },
{ 0x05, 0x09, 0x60, 0x09, 0x1e, Unknown_0859F444 },
{ 0x05, 0x09, 0x60, 0x09, 0x1e, Unknown_0859F444 },
{ 0x05, 0x11, 0x68, 0x0f, 0x1e, Unknown_0859F444 },
{ 0x05, 0x09, 0x60, 0x05, 0x1e, Unknown_0859F444 }
};
// What the heck are these meant to be? Call them u16 for now.
const u16 Unknown_0859F4E8[] = {
0x00, 0x4000, 0x00, 0x00
};
const u16 Unknown_0859F4F0[] = {
0x00, 0x00, -1, 0x00
};
const u16 Unknown_0859F4F8[] = {
0x04, 0x00, -1, 0x00
};
const u16 Unknown_0859F500[] = {
0x00, 0x40, -1, 0x00
};
const u16 *const gUnknown_0859F508[] = {
Unknown_0859F4F0,
Unknown_0859F4F8,
Unknown_0859F500
};
// .text
void sub_8121478(struct MailStruct *mail, MainCallback callback, bool8 flag) {
u16 buffer[2];
u16 species;
gUnknown_0203A134 = calloc(1, sizeof(*gUnknown_0203A134));
gUnknown_0203A134->language = LANGUAGE_ENGLISH;
gUnknown_0203A134->playerIsSender = TRUE;
gUnknown_0203A134->parserSingle = CopyEasyChatWord;
gUnknown_0203A134->parserMultiple = ConvertEasyChatWordsToString;
if (mail->itemId >= ITEM_ORANGE_MAIL && mail->itemId <= ITEM_RETRO_MAIL) {
gUnknown_0203A134->mailType = mail->itemId - ITEM_ORANGE_MAIL;
}
else
{
gUnknown_0203A134->mailType = 0;
flag = FALSE;
}
switch (gUnknown_0203A134->playerIsSender)
{
case FALSE:
default:
gUnknown_0203A134->layout = &gUnknown_0859F3B4[gUnknown_0203A134->mailType];
break;
case TRUE:
gUnknown_0203A134->layout = &gUnknown_0859F458[gUnknown_0203A134->mailType];
break;
}
species = sub_80D45E8(mail->species, buffer);
if (species >= SPECIES_BULBASAUR && species < NUM_SPECIES)
{
switch (gUnknown_0203A134->mailType)
{
default:
gUnknown_0203A134->animsActive = 0;
break;
case ITEM_BEAD_MAIL - ITEM_ORANGE_MAIL:
gUnknown_0203A134->animsActive = 1;
break;
case ITEM_DREAM_MAIL - ITEM_ORANGE_MAIL:
gUnknown_0203A134->animsActive = 2;
break;
}
}
else
{
gUnknown_0203A134->animsActive = 0;
}
gUnknown_0203A134->mail = mail;
gUnknown_0203A134->callback = callback;
gUnknown_0203A134->flag = flag;
SetMainCallback2(sub_81219F0);
}
bool8 sub_81215EC(void)
{
u16 icon;
switch (gMain.state)
{
case 0:
SetVBlankCallback(NULL);
remove_some_task();
SetGpuReg(REG_OFFSET_DISPCNT, 0x0000);
break;
case 1:
CpuFill16(0, (void *)OAM, OAM_SIZE);
break;
case 2:
ResetPaletteFade();
break;
case 3:
ResetTasks();
break;
case 4:
ResetSpriteData();
break;
case 5:
FreeAllSpritePalettes();
reset_temp_tile_data_buffers();
SetGpuReg(REG_OFFSET_BG0HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG0VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG1HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG1VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG2VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG2HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG3HOFS, 0x0000);
SetGpuReg(REG_OFFSET_BG3VOFS, 0x0000);
SetGpuReg(REG_OFFSET_BLDCNT, 0x0000);
SetGpuReg(REG_OFFSET_BLDALPHA, 0x0000);
break;
case 6:
ResetBgsAndClearDma3BusyFlags(0);
InitBgsFromTemplates(0, gUnknown_0859F290, 3);
SetBgTilemapBuffer(1, gUnknown_0203A134->bg1TilemapBuffer);
SetBgTilemapBuffer(2, gUnknown_0203A134->bg2TilemapBuffer);
break;
case 7:
InitWindows(gUnknown_0859F29C);
DeactivateAllTextPrinters();
break;
case 8:
decompress_and_copy_tile_data_to_vram(1, gUnknown_0859F2B8[gUnknown_0203A134->mailType].tiles, 0, 0, 0);
break;
case 9:
if (free_temp_tile_data_buffers_if_possible())
{
return FALSE;
}
break;
case 10:
FillBgTilemapBufferRect_Palette0(0, 0, 0, 0, 30, 20);
FillBgTilemapBufferRect_Palette0(2, 1, 0, 0, 30, 20);
CopyToBgTilemapBuffer(1, gUnknown_0859F2B8[gUnknown_0203A134->mailType].tileMap, 0, 0);
break;
case 11:
CopyBgTilemapBufferToVram(0);
CopyBgTilemapBufferToVram(1);
CopyBgTilemapBufferToVram(2);
break;
case 12:
LoadPalette(sub_8098C64(), 240, 32);
gPlttBufferUnfaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10;
gPlttBufferFaded[250] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color10;
gPlttBufferUnfaded[251] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color12;
gPlttBufferFaded[251] = gUnknown_0859F2B8[gUnknown_0203A134->mailType].color12;
LoadPalette(gUnknown_0859F2B8[gUnknown_0203A134->mailType].palette, 0, 32);
gPlttBufferUnfaded[10] = gUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][0];
gPlttBufferFaded[10] = gUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][0];
gPlttBufferUnfaded[11] = gUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][1];
gPlttBufferFaded[11] = gUnknown_0859F2B0[gSaveBlock2Ptr->playerGender][1];
break;
case 13:
if (gUnknown_0203A134->flag)
{
sub_8121A1C();
}
break;
case 14:
if (gUnknown_0203A134->flag)
{
sub_8121B1C();
RunTextPrinters();
}
break;
case 15:
if (sub_8087598() == TRUE)
{
return FALSE;
}
break;
case 16:
SetVBlankCallback(sub_8121C50);
gPaletteFade.bufferTransferDisabled = TRUE;
break;
case 17:
icon = sub_80D2E84(gUnknown_0203A134->mail->species);
switch (gUnknown_0203A134->animsActive)
{
case 1:
sub_80D2F68(icon);
gUnknown_0203A134->monIconSprite = sub_80D2D78(icon, SpriteCallbackDummy, 0x60, 0x80, 0, 0);
break;
case 2:
sub_80D2F68(icon);
gUnknown_0203A134->monIconSprite = sub_80D2D78(icon, SpriteCallbackDummy, 0x28, 0x80, 0, 0);
break;
}
break;
case 18:
SetGpuReg(REG_OFFSET_DISPCNT, DISPCNT_OBJ_ON | DISPCNT_OBJ_1D_MAP);
ShowBg(0);
ShowBg(1);
ShowBg(2);
BeginNormalPaletteFade(-1, 0, 16, 0, 0);
gPaletteFade.bufferTransferDisabled = FALSE;
gUnknown_0203A134->callback2 = sub_8121C98;
return TRUE;
default:
return FALSE;
}
gMain.state ++;
return FALSE;
}
void sub_81219F0(void)
{
do
{
if (sub_81215EC() == TRUE)
{
SetMainCallback2(sub_8121C64);
break;
}
} while (sub_81221AC() != TRUE);
}
void sub_8121A1C(void)
{
u16 i;
u8 total;
u8 *ptr;
total = 0;
for (i = 0; i < gUnknown_0203A134->layout->numSubStructs; i ++)
{
ConvertEasyChatWordsToString(gUnknown_0203A134->strbuf[i], &gUnknown_0203A134->mail->words[total], gUnknown_0203A134->layout->var8[i].numEasyChatWords, 1);
total += gUnknown_0203A134->layout->var8[i].numEasyChatWords;
}
ptr = StringCopy(gUnknown_0203A134->playerName, gUnknown_0203A134->mail->playerName);
if (!gUnknown_0203A134->playerIsSender)
{
StringCopy(ptr, gText_FromSpace);
gUnknown_0203A134->signatureWidth = gUnknown_0203A134->layout->signatureWidth - (StringLength(gUnknown_0203A134->playerName) * 8 - 0x60);
}
else
{
sub_81DB52C(gUnknown_0203A134->playerName);
gUnknown_0203A134->signatureWidth = gUnknown_0203A134->layout->signatureWidth;
}
}
void sub_8121B1C(void)
{
u16 i;
u8 strbuf[0x20];
u8 y;
u8 *bufptr;
s32 box_x;
s32 box_y;
y = 0;
PutWindowTilemap(0);
PutWindowTilemap(1);
FillWindowPixelBuffer(0, 0);
FillWindowPixelBuffer(1, 0);
for (i = 0; i < gUnknown_0203A134->layout->numSubStructs; i ++)
{
if (gUnknown_0203A134->strbuf[i][0] == EOS || gUnknown_0203A134->strbuf[i][0] == CHAR_SPACE)
{
continue;
}
box_print(0, 1, gUnknown_0203A134->layout->var8[i].xOffset + gUnknown_0203A134->layout->wordsYPos, y + gUnknown_0203A134->layout->wordsXPos, gUnknown_0859F2AC, 0, gUnknown_0203A134->strbuf[i]);
y += gUnknown_0203A134->layout->var8[i].lineHeight;
}
bufptr = StringCopy(strbuf, gText_FromSpace);
StringCopy(bufptr, gUnknown_0203A134->playerName);
box_x = GetStringCenterAlignXOffset(1, strbuf, gUnknown_0203A134->signatureWidth) + 0x68;
box_y = gUnknown_0203A134->layout->signatureYPos + 0x58;
box_print(0, 1, box_x, box_y, gUnknown_0859F2AC, 0, strbuf);
CopyWindowToVram(0, 3);
CopyWindowToVram(1, 3);
}
void sub_8121C50(void)
{
LoadOam();
ProcessSpriteCopyRequests();
TransferPlttBuffer();
}
void sub_8121C64(void)
{
if (gUnknown_0203A134->animsActive != 0)
{
AnimateSprites();
BuildOamBuffer();
}
gUnknown_0203A134->callback2();
}
void sub_8121C98(void)
{
if (!UpdatePaletteFade())
{
gUnknown_0203A134->callback2 = sub_8121CC0;
}
}
void sub_8121CC0(void)
{
if (gMain.newKeys & (A_BUTTON | B_BUTTON))
{
BeginNormalPaletteFade(-1, 0, 0, 16, 0);
gUnknown_0203A134->callback2 = sub_8121D00;
}
}
void sub_8121D00(void)
{
if (!UpdatePaletteFade())
{
SetMainCallback2(gUnknown_0203A134->callback);
switch (gUnknown_0203A134->animsActive)
{
case 1:
case 2:
sub_80D2FF0(sub_80D2E84(gUnknown_0203A134->mail->species));
sub_80D2EF8(&gSprites[gUnknown_0203A134->monIconSprite]);
}
memset(gUnknown_0203A134, 0, sizeof(*gUnknown_0203A134));
ResetPaletteFade();
UnsetBgTilemapBuffer(0);
UnsetBgTilemapBuffer(1);
ResetBgsAndClearDma3BusyFlags(0);
FreeAllWindowBuffers();
free(gUnknown_0203A134);
gUnknown_0203A134 = NULL;
}
}

View File

@ -1105,8 +1105,7 @@ gUnknown_0203A12C: @ 203A12C
gUnknown_0203A130: @ 203A130
.space 0x4
gUnknown_0203A134: @ 203A134
.space 0x4
.include "src/mail.o"
gUnknown_0203A138: @ 203A138
.space 0x8