diff --git a/asm/mail.s b/asm/mail.s deleted file mode 100644 index 72e5673d81..0000000000 --- a/asm/mail.s +++ /dev/null @@ -1,160 +0,0 @@ - .include "asm/macros.inc" - .include "constants/constants.inc" - - .syntax unified - - .text - - thumb_func_start sub_8121C50 -sub_8121C50: @ 8121C50 - push {lr} - bl LoadOam - bl ProcessSpriteCopyRequests - bl TransferPlttBuffer - pop {r0} - bx r0 - thumb_func_end sub_8121C50 - - thumb_func_start sub_8121C64 -sub_8121C64: @ 8121C64 - push {r4,lr} - ldr r4, =gUnknown_0203A134 - ldr r0, [r4] - ldr r1, =0x0000021b - adds r0, r1 - ldrb r0, [r0] - cmp r0, 0 - beq _08121C7C - bl AnimateSprites - bl BuildOamBuffer -_08121C7C: - ldr r0, [r4] - movs r1, 0x84 - lsls r1, 2 - adds r0, r1 - ldr r0, [r0] - bl _call_via_r0 - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8121C64 - - thumb_func_start sub_8121C98 -sub_8121C98: @ 8121C98 - push {lr} - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _08121CB2 - ldr r0, =gUnknown_0203A134 - ldr r0, [r0] - movs r1, 0x84 - lsls r1, 2 - adds r0, r1 - ldr r1, =sub_8121CC0 - str r1, [r0] -_08121CB2: - pop {r0} - bx r0 - .pool - thumb_func_end sub_8121C98 - - thumb_func_start sub_8121CC0 -sub_8121CC0: @ 8121CC0 - push {lr} - sub sp, 0x4 - ldr r0, =gMain - ldrh r1, [r0, 0x2E] - movs r0, 0x3 - ands r0, r1 - cmp r0, 0 - beq _08121CEE - movs r0, 0x1 - negs r0, r0 - movs r1, 0 - str r1, [sp] - movs r2, 0 - movs r3, 0x10 - bl BeginNormalPaletteFade - ldr r0, =gUnknown_0203A134 - ldr r0, [r0] - movs r1, 0x84 - lsls r1, 2 - adds r0, r1 - ldr r1, =sub_8121D00 - str r1, [r0] -_08121CEE: - add sp, 0x4 - pop {r0} - bx r0 - .pool - thumb_func_end sub_8121CC0 - - thumb_func_start sub_8121D00 -sub_8121D00: @ 8121D00 - push {r4,lr} - bl UpdatePaletteFade - lsls r0, 24 - cmp r0, 0 - bne _08121D88 - ldr r4, =gUnknown_0203A134 - ldr r0, [r4] - movs r1, 0x83 - lsls r1, 2 - adds r0, r1 - ldr r0, [r0] - bl SetMainCallback2 - ldr r1, [r4] - ldr r2, =0x0000021b - adds r0, r1, r2 - ldrb r0, [r0] - cmp r0, 0x2 - bgt _08121D58 - cmp r0, 0x1 - blt _08121D58 - subs r2, 0x7 - adds r0, r1, r2 - ldr r0, [r0] - ldrh r0, [r0, 0x1E] - bl sub_80D2E84 - lsls r0, 16 - lsrs r0, 16 - bl sub_80D2FF0 - ldr r0, [r4] - movs r1, 0x87 - lsls r1, 2 - adds r0, r1 - ldrb r1, [r0] - lsls r0, r1, 4 - adds r0, r1 - lsls r0, 2 - ldr r1, =gSprites - adds r0, r1 - bl sub_80D2EF8 -_08121D58: - ldr r4, =gUnknown_0203A134 - ldr r0, [r4] - ldr r2, =0x0000222c - movs r1, 0 - bl memset - bl ResetPaletteFade - movs r0, 0 - bl UnsetBgTilemapBuffer - movs r0, 0x1 - bl UnsetBgTilemapBuffer - movs r0, 0 - bl ResetBgsAndClearDma3BusyFlags - bl FreeAllWindowBuffers - ldr r0, [r4] - bl Free - movs r0, 0 - str r0, [r4] -_08121D88: - pop {r4} - pop {r0} - bx r0 - .pool - thumb_func_end sub_8121D00 - - .align 2, 0 @ Don't pad with nop. diff --git a/include/pokemon_icon.h b/include/pokemon_icon.h index 1863f9f7a1..b6d21823e0 100644 --- a/include/pokemon_icon.h +++ b/include/pokemon_icon.h @@ -6,5 +6,7 @@ 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 diff --git a/ld_script.txt b/ld_script.txt index 8349338bc0..b120074015 100644 --- a/ld_script.txt +++ b/ld_script.txt @@ -165,7 +165,6 @@ SECTIONS { asm/mon_markings.o(.text); asm/mauville_old_man.o(.text); src/mail.o(.text); - asm/mail.o(.text); asm/menu_helpers.o(.text); asm/dewford_trend.o(.text); asm/heal_location.o(.text); diff --git a/src/mail.c b/src/mail.c index 48dc7eba02..bcb08b49da 100644 --- a/src/mail.c +++ b/src/mail.c @@ -51,8 +51,8 @@ struct Unk203A134 /*0x0218*/ bool8 flag; /*0x0219*/ u8 signatureWidth; /*0x021a*/ u8 mailType; - /*0x021b*/ u8 unk_021b; - /*0x021c*/ u8 unk_021c; + /*0x021b*/ u8 animsActive; + /*0x021c*/ u8 monIconSprite; /*0x021d*/ u8 language; /*0x021e*/ bool8 playerIsSender; /*0x0220*/ void (*parserSingle)(u8 *dest, u16 word); @@ -85,6 +85,8 @@ 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 @@ -299,19 +301,19 @@ void sub_8121478(struct MailStruct *mail, MainCallback callback, bool8 flag) { switch (gUnknown_0203A134->mailType) { default: - gUnknown_0203A134->unk_021b = 0; + gUnknown_0203A134->animsActive = 0; break; case ITEM_BEAD_MAIL - ITEM_ORANGE_MAIL: - gUnknown_0203A134->unk_021b = 1; + gUnknown_0203A134->animsActive = 1; break; case ITEM_DREAM_MAIL - ITEM_ORANGE_MAIL: - gUnknown_0203A134->unk_021b = 2; + gUnknown_0203A134->animsActive = 2; break; } } else { - gUnknown_0203A134->unk_021b = 0; + gUnknown_0203A134->animsActive = 0; } gUnknown_0203A134->mail = mail; gUnknown_0203A134->callback = callback; @@ -422,15 +424,15 @@ bool8 sub_81215EC(void) break; case 17: icon = sub_80D2E84(gUnknown_0203A134->mail->species); - switch (gUnknown_0203A134->unk_021b) + switch (gUnknown_0203A134->animsActive) { case 1: sub_80D2F68(icon); - gUnknown_0203A134->unk_021c = sub_80D2D78(icon, SpriteCallbackDummy, 0x60, 0x80, 0, 0); + gUnknown_0203A134->monIconSprite = sub_80D2D78(icon, SpriteCallbackDummy, 0x60, 0x80, 0, 0); break; case 2: sub_80D2F68(icon); - gUnknown_0203A134->unk_021c = sub_80D2D78(icon, SpriteCallbackDummy, 0x28, 0x80, 0, 0); + gUnknown_0203A134->monIconSprite = sub_80D2D78(icon, SpriteCallbackDummy, 0x28, 0x80, 0, 0); break; } break; @@ -518,3 +520,60 @@ void sub_8121B1C(void) 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; + } +}