decompile some of mail_data.s

This commit is contained in:
YamaArashi 2017-05-08 18:12:23 -07:00
parent 6608d61fdb
commit fdab157386
6 changed files with 104 additions and 317 deletions

View File

@ -6,314 +6,6 @@
.text
thumb_func_start sub_80A2B18
sub_80A2B18: @ 80A2B18
push {r4,r5,lr}
movs r4, 0
ldr r5, _080A2B3C @ =gSaveBlock1 + 0x2B4C
_080A2B1E:
lsls r0, r4, 3
adds r0, r4
lsls r0, 2
adds r0, r5
bl sub_80A2B40
adds r0, r4, 0x1
lsls r0, 24
lsrs r4, r0, 24
cmp r4, 0xF
bls _080A2B1E
pop {r4,r5}
pop {r0}
bx r0
.align 2, 0
_080A2B3C: .4byte gSaveBlock1 + 0x2B4C
thumb_func_end sub_80A2B18
thumb_func_start sub_80A2B40
sub_80A2B40: @ 80A2B40
push {r4-r6,lr}
adds r3, r0, 0
ldr r0, _080A2B90 @ =0x0000ffff
adds r4, r0, 0
adds r1, r3, 0
movs r2, 0x8
_080A2B4C:
ldrh r0, [r1]
orrs r0, r4
strh r0, [r1]
adds r1, 0x2
subs r2, 0x1
cmp r2, 0
bge _080A2B4C
movs r2, 0
adds r6, r3, 0
adds r6, 0x1A
adds r4, r3, 0
adds r4, 0x12
movs r5, 0xFF
_080A2B66:
adds r1, r4, r2
ldrb r0, [r1]
orrs r0, r5
strb r0, [r1]
adds r2, 0x1
cmp r2, 0x7
ble _080A2B66
adds r1, r6, 0
movs r2, 0
adds r0, r1, 0x3
_080A2B7A:
strb r2, [r0]
subs r0, 0x1
cmp r0, r1
bge _080A2B7A
movs r1, 0
movs r0, 0x1
strh r0, [r3, 0x1E]
strh r1, [r3, 0x20]
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_080A2B90: .4byte 0x0000ffff
thumb_func_end sub_80A2B40
thumb_func_start sub_80A2B94
sub_80A2B94: @ 80A2B94
push {r4,lr}
adds r4, r0, 0
movs r1, 0xC
bl GetMonData
lsls r0, 16
lsrs r0, 16
bl itemid_is_mail
lsls r0, 24
cmp r0, 0
beq _080A2BBC
adds r0, r4, 0
movs r1, 0x40
bl GetMonData
cmp r0, 0xFF
beq _080A2BBC
movs r0, 0x1
b _080A2BBE
_080A2BBC:
movs r0, 0
_080A2BBE:
pop {r4}
pop {r1}
bx r1
thumb_func_end sub_80A2B94
thumb_func_start sub_80A2BC4
sub_80A2BC4: @ 80A2BC4
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0xC
adds r7, r0, 0
lsls r1, 16
lsrs r0, r1, 16
str r0, [sp, 0x8]
mov r0, sp
movs r2, 0
ldrb r3, [r0, 0x8]
strb r3, [r0]
lsrs r1, 24
strb r1, [r0, 0x1]
add r3, sp, 0x4
strb r2, [r3]
mov r10, r3
ldr r4, _080A2D00 @ =gSaveBlock1
mov r9, r4
mov r8, r3
adds r2, r3, 0
_080A2BF2:
ldrb r1, [r2]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
add r0, r9
ldr r5, _080A2D04 @ =0x00002b6c
adds r0, r5
ldrh r0, [r0]
cmp r0, 0
beq _080A2C08
b _080A2D24
_080A2C08:
movs r3, 0
ldr r0, _080A2D08 @ =gSaveBlock2
mov r12, r0
mov r4, r10
ldr r6, _080A2D0C @ =gSaveBlock1 + 0x2B4C
ldr r1, _080A2D10 @ =0x0000ffff
adds r5, r1, 0
_080A2C16:
lsls r2, r3, 1
ldrb r1, [r4]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r2, r0
adds r2, r6
ldrh r0, [r2]
orrs r0, r5
strh r0, [r2]
adds r0, r3, 0x1
lsls r0, 24
lsrs r3, r0, 24
cmp r3, 0x8
bls _080A2C16
movs r3, 0
mov r2, r10
ldr r4, _080A2D14 @ =gSaveBlock1 + 0x2B5E
_080A2C3A:
ldrb r1, [r2]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r0, r3, r0
adds r0, r4
mov r5, r12
adds r1, r3, r5
ldrb r1, [r1]
strb r1, [r0]
adds r0, r3, 0x1
lsls r0, 24
lsrs r3, r0, 24
cmp r3, 0x6
bls _080A2C3A
mov r0, r8
ldrb r1, [r0]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r0, r3, r0
ldr r1, _080A2D14 @ =gSaveBlock1 + 0x2B5E
adds r0, r1
movs r1, 0xFF
strb r1, [r0]
mov r2, r8
ldrb r1, [r2]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
ldr r3, _080A2D14 @ =gSaveBlock1 + 0x2B5E
adds r0, r3
movs r1, 0
bl PadNameString
movs r3, 0
mov r2, r10
ldr r5, _080A2D18 @ =gSaveBlock1 + 0x2B66
ldr r4, _080A2D1C @ =gSaveBlock2 + 0xA
_080A2C88:
ldrb r1, [r2]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
adds r0, r3, r0
adds r0, r5
adds r1, r3, r4
ldrb r1, [r1]
strb r1, [r0]
adds r0, r3, 0x1
lsls r0, 24
lsrs r3, r0, 24
cmp r3, 0x3
bls _080A2C88
adds r0, r7, 0
movs r1, 0xB
bl GetBoxMonData
adds r4, r0, 0
lsls r4, 16
lsrs r4, 16
adds r0, r7, 0
movs r1, 0
bl GetBoxMonData
adds r1, r0, 0
adds r0, r4, 0
bl sub_80A2D44
mov r4, r8
ldrb r2, [r4]
lsls r1, r2, 3
adds r1, r2
lsls r1, 2
add r1, r9
ldr r5, _080A2D20 @ =0x00002b6a
adds r1, r5
strh r0, [r1]
ldrb r1, [r4]
lsls r0, r1, 3
adds r0, r1
lsls r0, 2
add r0, r9
ldr r1, _080A2D04 @ =0x00002b6c
adds r0, r1
mov r2, sp
ldrh r2, [r2, 0x8]
strh r2, [r0]
adds r0, r7, 0
movs r1, 0x40
mov r2, r8
bl SetMonData
adds r0, r7, 0
movs r1, 0xC
mov r2, sp
bl SetMonData
ldrb r0, [r4]
b _080A2D32
.align 2, 0
_080A2D00: .4byte gSaveBlock1
_080A2D04: .4byte 0x00002b6c
_080A2D08: .4byte gSaveBlock2
_080A2D0C: .4byte gSaveBlock1 + 0x2B4C
_080A2D10: .4byte 0x0000ffff
_080A2D14: .4byte gSaveBlock1 + 0x2B5E
_080A2D18: .4byte gSaveBlock1 + 0x2B66
_080A2D1C: .4byte gSaveBlock2 + 0xA
_080A2D20: .4byte 0x00002b6a
_080A2D24:
adds r0, r1, 0x1
strb r0, [r3]
ldrb r0, [r2]
cmp r0, 0x5
bhi _080A2D30
b _080A2BF2
_080A2D30:
movs r0, 0xFF
_080A2D32:
add sp, 0xC
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_80A2BC4
thumb_func_start sub_80A2D44
sub_80A2D44: @ 80A2D44
push {lr}
lsls r0, 16
lsrs r0, 16
cmp r0, 0xC9
bne _080A2D5C
adds r0, r1, 0
bl sub_809D474
lsls r0, 16
ldr r1, _080A2D60 @ =0x75300000
adds r0, r1
lsrs r0, 16
_080A2D5C:
pop {r1}
bx r1
.align 2, 0
_080A2D60: .4byte 0x75300000
thumb_func_end sub_80A2D44
thumb_func_start sub_80A2D64
sub_80A2D64: @ 80A2D64
push {lr}

View File

@ -65,7 +65,7 @@
#define MON_DATA_SPD 61
#define MON_DATA_SPATK 62
#define MON_DATA_SPDEF 63
#define MON_DATA_64 64
#define MON_DATA_MAIL 64
#define MON_DATA_SPECIES2 65
#define MON_DATA_IVS 66
#define MON_DATA_CHAMPION_RIBBON 67
@ -252,7 +252,7 @@ struct Pokemon
struct BoxPokemon box;
u32 status;
u8 level;
u8 pokerus;
u8 mail;
u16 hp;
u16 maxHP;
u16 attack;

View File

@ -152,6 +152,7 @@ SECTIONS {
asm/pokemon_summary_screen.o(.text_80A0958);
src/script_movement.o(.text);
src/fldeff_cut.o(.text);
src/mail_data.o(.text);
asm/mail_data.o(.text);
src/map_name_popup.o(.text);
asm/item_menu.o(.text);

94
src/mail_data.c Normal file
View File

@ -0,0 +1,94 @@
#include "global.h"
#include "name_string_util.h"
#include "pokemon.h"
#include "species.h"
#include "text.h"
void sub_80A2B40(struct MailStruct *);
u16 sub_80A2D44(u16, u32);
bool8 itemid_is_mail(u16);
u16 sub_809D474(u32);
void sub_80A2B18(void)
{
u8 i;
for (i = 0; i < 16; i++)
sub_80A2B40(&gSaveBlock1.mail[i]);
}
void sub_80A2B40(struct MailStruct *mail)
{
int i;
for (i = 0; i < 9; i++)
mail->words[i] = -1;
for (i = 0; i < 8; i++)
mail->playerName[i] = -1;
for (i = 0; i < 4; i++)
mail->trainerId[i] = 0;
mail->species = 1;
mail->itemId = 0;
}
bool8 sub_80A2B94(struct Pokemon *mon)
{
u16 heldItem = GetMonData(mon, MON_DATA_HELD_ITEM);
if (itemid_is_mail(heldItem) && GetMonData(mon, MON_DATA_MAIL) != 0xFF)
return TRUE;
else
return FALSE;
}
u8 sub_80A2BC4(struct Pokemon *mon, u16 itemId)
{
u16 _itemId;
u8 heldItem[2];
u8 id;
u8 i;
u16 species;
u32 personality;
_itemId = itemId;
heldItem[0] = _itemId;
heldItem[1] = _itemId >> 8;
id = 0;
while (id < 6)
{
if (gSaveBlock1.mail[id].itemId == 0)
{
for (i = 0; i < 9; i++)
gSaveBlock1.mail[id].words[i] = -1;
for (i = 0; i < 7; i++)
gSaveBlock1.mail[id].playerName[i] = gSaveBlock2.playerName[i];
gSaveBlock1.mail[id].playerName[i] = EOS;
PadNameString(gSaveBlock1.mail[id].playerName, 0);
for (i = 0; i < 4; i++)
gSaveBlock1.mail[id].trainerId[i] = gSaveBlock2.playerTrainerId[i];
species = GetBoxMonData(mon, MON_DATA_SPECIES);
personality = GetBoxMonData(mon, MON_DATA_PERSONALITY);
gSaveBlock1.mail[id].species = sub_80A2D44(species, personality);
gSaveBlock1.mail[id].itemId = _itemId;
SetMonData(mon, MON_DATA_MAIL, &id);
SetMonData(mon, MON_DATA_HELD_ITEM, heldItem);
return id;
}
id++;
}
return -1;
}
u16 sub_80A2D44(u16 species, u32 personality)
{
if (species != SPECIES_UNOWN)
return species;
return ((sub_809D474(personality) << 16) + (30000 << 16)) >> 16;
}

View File

@ -51,7 +51,7 @@ void ZeroMonData(struct Pokemon *mon)
SetMonData(mon, MON_DATA_SPATK, (u8 *)&arg);
SetMonData(mon, MON_DATA_SPDEF, (u8 *)&arg);
arg = 255;
SetMonData(mon, MON_DATA_64, (u8 *)&arg);
SetMonData(mon, MON_DATA_MAIL, (u8 *)&arg);
}
void ZeroPlayerPartyMons(void)
@ -75,7 +75,7 @@ void CreateMon(struct Pokemon *mon, u16 species, u8 level, u8 fixedIV, u8 hasFix
CreateBoxMon(&mon->box, species, level, fixedIV, hasFixedPersonality, fixedPersonality, otIdType, fixedOtId);
SetMonData(mon, MON_DATA_LEVEL, &level);
arg = 255;
SetMonData(mon, MON_DATA_64, (u8 *)&arg);
SetMonData(mon, MON_DATA_MAIL, (u8 *)&arg);
CalculateMonStats(mon);
}
@ -478,7 +478,7 @@ void sub_803B4B4(struct Pokemon *src, struct Pokemon *dest)
SetMonData(dest, MON_DATA_HP, (u8 *)&value);
SetMonData(dest, MON_DATA_MAX_HP, (u8 *)&value);
value = 255;
SetMonData(dest, MON_DATA_64, (u8 *)&value);
SetMonData(dest, MON_DATA_MAIL, (u8 *)&value);
CalculateMonStats(dest);
}

View File

@ -383,8 +383,8 @@ u32 GetMonData(struct Pokemon *mon, s32 field, u8 *data)
return mon->spAttack;
case MON_DATA_SPDEF:
return mon->spDefense;
case MON_DATA_64:
return mon->pokerus;
case MON_DATA_MAIL:
return mon->mail;
default:
return GetBoxMonData(&mon->box, field, data);
}
@ -761,8 +761,8 @@ void SetMonData(struct Pokemon *mon, s32 field, const u8 *data)
case MON_DATA_SPDEF:
SET16(mon->spDefense);
break;
case MON_DATA_64:
SET8(mon->pokerus);
case MON_DATA_MAIL:
SET8(mon->mail);
break;
case MON_DATA_SPECIES2:
break;