mirror of
https://github.com/Ninjdai1/pokeemerald.git
synced 2024-12-25 19:24:16 +01:00
sub_8121478
This commit is contained in:
parent
8914645231
commit
8d31a46c6f
158
asm/mail.s
158
asm/mail.s
@ -5,164 +5,6 @@
|
||||
|
||||
.text
|
||||
|
||||
thumb_func_start sub_8121478
|
||||
sub_8121478: @ 8121478
|
||||
push {r4-r7,lr}
|
||||
sub sp, 0x4
|
||||
adds r5, r0, 0
|
||||
adds r7, r1, 0
|
||||
lsls r2, 24
|
||||
lsrs r6, r2, 24
|
||||
ldr r4, =gUnknown_0203A134
|
||||
ldr r0, =0x0000222c
|
||||
bl AllocZeroed
|
||||
str r0, [r4]
|
||||
ldr r1, =0x0000021d
|
||||
adds r0, r1
|
||||
movs r1, 0x2
|
||||
strb r1, [r0]
|
||||
ldr r0, [r4]
|
||||
ldr r2, =0x0000021e
|
||||
adds r0, r2
|
||||
movs r1, 0x1
|
||||
strb r1, [r0]
|
||||
ldr r4, [r4]
|
||||
movs r3, 0x88
|
||||
lsls r3, 2
|
||||
adds r1, r4, r3
|
||||
ldr r0, =CopyEasyChatWord
|
||||
str r0, [r1]
|
||||
movs r0, 0x89
|
||||
lsls r0, 2
|
||||
adds r1, r4, r0
|
||||
ldr r0, =ConvertEasyChatWordsToString
|
||||
str r0, [r1]
|
||||
ldrh r1, [r5, 0x20]
|
||||
adds r0, r1, 0
|
||||
subs r0, 0x79
|
||||
lsls r0, 16
|
||||
lsrs r0, 16
|
||||
cmp r0, 0xB
|
||||
bhi _081214E8
|
||||
subs r1, 0x79
|
||||
subs r2, 0x4
|
||||
adds r0, r4, r2
|
||||
strb r1, [r0]
|
||||
b _081214F2
|
||||
.pool
|
||||
_081214E8:
|
||||
ldr r3, =0x0000021a
|
||||
adds r1, r4, r3
|
||||
movs r0, 0
|
||||
strb r0, [r1]
|
||||
movs r6, 0
|
||||
_081214F2:
|
||||
ldr r0, =gUnknown_0203A134
|
||||
ldr r1, [r0]
|
||||
ldr r2, =0x0000021e
|
||||
adds r0, r1, r2
|
||||
ldrb r0, [r0]
|
||||
cmp r0, 0
|
||||
beq _08121504
|
||||
cmp r0, 0x1
|
||||
beq _0812152C
|
||||
_08121504:
|
||||
movs r3, 0x8A
|
||||
lsls r3, 2
|
||||
adds r2, r1, r3
|
||||
subs r3, 0xE
|
||||
adds r0, r1, r3
|
||||
ldrb r1, [r0]
|
||||
lsls r0, r1, 1
|
||||
adds r0, r1
|
||||
lsls r0, 2
|
||||
ldr r1, =gUnknown_0859F3B4
|
||||
b _08121540
|
||||
.pool
|
||||
_0812152C:
|
||||
movs r0, 0x8A
|
||||
lsls r0, 2
|
||||
adds r2, r1, r0
|
||||
ldr r3, =0x0000021a
|
||||
adds r0, r1, r3
|
||||
ldrb r1, [r0]
|
||||
lsls r0, r1, 1
|
||||
adds r0, r1
|
||||
lsls r0, 2
|
||||
ldr r1, =gUnknown_0859F458
|
||||
_08121540:
|
||||
adds r0, r1
|
||||
str r0, [r2]
|
||||
ldrh r0, [r5, 0x1E]
|
||||
mov r1, sp
|
||||
bl sub_80D45E8
|
||||
lsls r0, 16
|
||||
ldr r1, =0xffff0000
|
||||
adds r0, r1
|
||||
movs r1, 0xCD
|
||||
lsls r1, 17
|
||||
cmp r0, r1
|
||||
bhi _081215AC
|
||||
ldr r1, =gUnknown_0203A134
|
||||
ldr r2, [r1]
|
||||
ldr r3, =0x0000021a
|
||||
adds r0, r2, r3
|
||||
ldrb r0, [r0]
|
||||
adds r3, r1, 0
|
||||
cmp r0, 0x6
|
||||
beq _0812158C
|
||||
cmp r0, 0x9
|
||||
beq _0812159C
|
||||
ldr r0, =0x0000021b
|
||||
adds r1, r2, r0
|
||||
movs r0, 0
|
||||
strb r0, [r1]
|
||||
b _081215BA
|
||||
.pool
|
||||
_0812158C:
|
||||
ldr r0, =0x0000021b
|
||||
adds r1, r2, r0
|
||||
movs r0, 0x1
|
||||
strb r0, [r1]
|
||||
b _081215BA
|
||||
.pool
|
||||
_0812159C:
|
||||
ldr r0, =0x0000021b
|
||||
adds r1, r2, r0
|
||||
movs r0, 0x2
|
||||
strb r0, [r1]
|
||||
b _081215BA
|
||||
.pool
|
||||
_081215AC:
|
||||
ldr r0, =gUnknown_0203A134
|
||||
ldr r1, [r0]
|
||||
ldr r2, =0x0000021b
|
||||
adds r1, r2
|
||||
movs r2, 0
|
||||
strb r2, [r1]
|
||||
adds r3, r0, 0
|
||||
_081215BA:
|
||||
ldr r1, [r3]
|
||||
movs r3, 0x85
|
||||
lsls r3, 2
|
||||
adds r0, r1, r3
|
||||
str r5, [r0]
|
||||
movs r2, 0x83
|
||||
lsls r2, 2
|
||||
adds r0, r1, r2
|
||||
str r7, [r0]
|
||||
adds r3, 0x4
|
||||
adds r0, r1, r3
|
||||
strb r6, [r0]
|
||||
ldr r0, =sub_81219F0
|
||||
bl SetMainCallback2
|
||||
add sp, 0x4
|
||||
pop {r4-r7}
|
||||
pop {r0}
|
||||
bx r0
|
||||
.pool
|
||||
thumb_func_end sub_8121478
|
||||
|
||||
thumb_func_start sub_81215EC
|
||||
sub_81215EC: @ 81215EC
|
||||
push {r4-r6,lr}
|
||||
|
@ -30,7 +30,8 @@ enum
|
||||
|
||||
void InitEasyChatPhrases(void);
|
||||
void easy_chat_input_maybe(void);
|
||||
void CopyEasyChatWord(u8 *, u16);
|
||||
void CopyEasyChatWord(u8 *dest, u16 word);
|
||||
void ConvertEasyChatWordsToString(u8 *dest, const u16 *src, u16 length1, u16 length2);
|
||||
bool32 sub_811F8D8(u16);
|
||||
|
||||
#endif // GUARD_EASYCHAT_H
|
||||
|
12
include/mail_data.h
Normal file
12
include/mail_data.h
Normal 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
|
@ -2,7 +2,7 @@
|
||||
#define GUARD_MALLOC_H
|
||||
|
||||
#define malloc Alloc
|
||||
#define calloc AllocZeroed
|
||||
#define calloc(ct, sz) AllocZeroed((ct) * (sz))
|
||||
#define free Free
|
||||
|
||||
extern u8 gHeap[];
|
||||
|
@ -164,6 +164,7 @@ SECTIONS {
|
||||
asm/easy_chat.o(.text);
|
||||
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);
|
||||
|
127
src/mail.c
Normal file
127
src/mail.c
Normal file
@ -0,0 +1,127 @@
|
||||
|
||||
// Includes
|
||||
#include "global.h"
|
||||
#include "main.h"
|
||||
#include "species.h"
|
||||
#include "malloc.h"
|
||||
#include "easy_chat.h"
|
||||
#include "mail_data.h"
|
||||
#include "mail.h"
|
||||
|
||||
// Static type declarations
|
||||
|
||||
struct UnkMailStruct
|
||||
{
|
||||
u8 unk_0_0:2;
|
||||
u8 unk_0_2:2;
|
||||
u8 unk_0_4:4;
|
||||
};
|
||||
|
||||
struct MailLayout
|
||||
{
|
||||
u8 var0;
|
||||
u8 var1;
|
||||
u8 var2;
|
||||
u8 var3_0:4;
|
||||
u8 var3_4:4;
|
||||
struct UnkMailStruct *var4;
|
||||
u32 var8;
|
||||
};
|
||||
|
||||
struct Unk203A134
|
||||
{
|
||||
/*0x0000*/ u8 filler_0000[0x20c];
|
||||
/*0x020C*/ MainCallback callback;
|
||||
/*0x0210*/ u8 filler_0210[4];
|
||||
/*0x0214*/ struct MailStruct *mail;
|
||||
/*0x0218*/ bool8 flag;
|
||||
/*0x0219*/ u8 filler_0219[1];
|
||||
/*0x021a*/ u8 mailType;
|
||||
/*0x021b*/ u8 unk_021b;
|
||||
/*0x021c*/ u8 unk_021c;
|
||||
/*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 filler_022C[0x2000];
|
||||
};
|
||||
|
||||
struct MailGraphics
|
||||
{
|
||||
u16 (*palette)[];
|
||||
u8 (*tiles)[];
|
||||
u8 (*tileMap)[];
|
||||
u16 var0C;
|
||||
u16 var0E;
|
||||
u16 color10;
|
||||
u16 color12;
|
||||
};
|
||||
|
||||
// Static RAM declarations
|
||||
|
||||
EWRAM_DATA struct Unk203A134 *gUnknown_0203A134;
|
||||
|
||||
// Static ROM declarations
|
||||
|
||||
void sub_81219F0(void);
|
||||
|
||||
// .rodata
|
||||
|
||||
extern const struct MailLayout gUnknown_0859F3B4[];
|
||||
extern const struct MailLayout gUnknown_0859F458[];
|
||||
|
||||
// .text
|
||||
|
||||
void sub_8121478(struct MailStruct *mail, MainCallback callback, bool8 flag) {
|
||||
u16 buffer[2];
|
||||
u16 species;
|
||||
|
||||
gUnknown_0203A134 = calloc(1, sizeof(struct Unk203A134));
|
||||
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->unk_021b = 0;
|
||||
break;
|
||||
case ITEM_BEAD_MAIL - ITEM_ORANGE_MAIL:
|
||||
gUnknown_0203A134->unk_021b = 1;
|
||||
break;
|
||||
case ITEM_DREAM_MAIL - ITEM_ORANGE_MAIL:
|
||||
gUnknown_0203A134->unk_021b = 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gUnknown_0203A134->unk_021b = 0;
|
||||
}
|
||||
gUnknown_0203A134->mail = mail;
|
||||
gUnknown_0203A134->callback = callback;
|
||||
gUnknown_0203A134->flag = flag;
|
||||
SetMainCallback2(sub_81219F0);
|
||||
}
|
Loading…
Reference in New Issue
Block a user