Attempt to decompile trainer memo printing

This commit is contained in:
Marijn van der Werf 2017-01-03 19:54:37 +01:00
parent 2b445e128c
commit c03e7be9af
6 changed files with 357 additions and 204 deletions

View File

@ -4750,7 +4750,7 @@ _0809FDF8:
adds r0, r6, 0 adds r0, r6, 0
movs r1, 0xB movs r1, 0xB
movs r2, 0xE movs r2, 0xE
bl sub_80A0798 bl PokemonSummaryScreen_PrintTrainerMemo
_0809FE4C: _0809FE4C:
add sp, 0xC add sp, 0xC
pop {r4-r6} pop {r4-r6}
@ -5890,203 +5890,7 @@ _080A0786:
_080A0794: .4byte gOtherText_EggDayCare _080A0794: .4byte gOtherText_EggDayCare
thumb_func_end sub_80A0708 thumb_func_end sub_80A0708
thumb_func_start sub_80A0798 .section .text_80A0958
sub_80A0798: @ 80A0798
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
adds r7, r0, 0
lsls r1, 24
lsrs r1, 24
mov r9, r1
lsls r2, 24
lsrs r2, 24
mov r8, r2
ldr r5, _080A0838 @ =gStringVar4
bl GetNature
lsls r0, 24
lsrs r4, r0, 24
ldr r1, _080A083C @ =gNatureNames
lsls r0, r4, 2
adds r0, r1
ldr r1, [r0]
adds r0, r5, 0
movs r2, 0xE
bl sub_80A1E9C
adds r5, r0, 0
cmp r4, 0x5
beq _080A07DA
cmp r4, 0x15
beq _080A07DA
ldr r1, _080A0840 @ =gOtherText_Terminator4
bl StringCopy
adds r5, r0, 0
_080A07DA:
ldr r1, _080A0844 @ =gOtherText_Nature
adds r0, r5, 0
bl StringCopy
adds r5, r0, 0
adds r0, r7, 0
bl sub_80A0664
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bne _080A0898
adds r0, r7, 0
movs r1, 0x23
bl GetMonData
lsls r0, 24
lsrs r6, r0, 24
adds r0, r7, 0
movs r1, 0x24
bl GetMonData
cmp r0, 0
bne _080A0850
adds r0, r5, 0
movs r1, 0x5
bl sub_80A203C
adds r5, r0, 0
movs r0, 0xFE
strb r0, [r5]
adds r5, 0x1
ldr r4, _080A0848 @ =gStringVar1
adds r0, r4, 0
adds r1, r6, 0
bl sub_80FC02C
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0xE
bl sub_80A1E9C
adds r5, r0, 0
ldr r1, _080A084C @ =gOtherText_Egg2
bl StringCopy
b _080A0934
.align 2, 0
_080A0838: .4byte gStringVar4
_080A083C: .4byte gNatureNames
_080A0840: .4byte gOtherText_Terminator4
_080A0844: .4byte gOtherText_Nature
_080A0848: .4byte gStringVar1
_080A084C: .4byte gOtherText_Egg2
_080A0850:
cmp r6, 0x57
bhi _080A08E8
adds r0, r7, 0
movs r1, 0x24
bl GetMonData
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r5, 0
bl sub_80A203C
adds r5, r0, 0
movs r0, 0xFE
strb r0, [r5]
adds r5, 0x1
ldr r4, _080A0890 @ =gStringVar1
adds r0, r4, 0
adds r1, r6, 0
bl sub_80FC02C
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0xE
bl sub_80A1E9C
adds r5, r0, 0
ldr r1, _080A0894 @ =gOtherText_Met
bl StringCopy
b _080A0934
.align 2, 0
_080A0890: .4byte gStringVar1
_080A0894: .4byte gOtherText_Met
_080A0898:
adds r0, r7, 0
movs r1, 0x25
bl GetMonData
lsls r0, 24
movs r1, 0xFF
lsls r1, 24
adds r0, r1
lsrs r0, 24
cmp r0, 0x2
bhi _080A08E8
adds r0, r7, 0
movs r1, 0x23
bl GetMonData
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0xFF
bne _080A08E4
adds r0, r7, 0
movs r1, 0x24
bl GetMonData
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r5, 0
bl sub_80A203C
adds r5, r0, 0
movs r0, 0xFE
strb r0, [r5]
adds r5, 0x1
ldr r1, _080A08E0 @ =gOtherText_FatefulEncounter
b _080A08F0
.align 2, 0
_080A08E0: .4byte gOtherText_FatefulEncounter
_080A08E4:
cmp r6, 0x57
bls _080A08FC
_080A08E8:
movs r0, 0xFE
strb r0, [r5]
adds r5, 0x1
ldr r1, _080A08F8 @ =gOtherText_ObtainedInTrade
_080A08F0:
adds r0, r5, 0
bl StringCopy
b _080A0934
.align 2, 0
_080A08F8: .4byte gOtherText_ObtainedInTrade
_080A08FC:
adds r0, r7, 0
movs r1, 0x24
bl GetMonData
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r5, 0
bl sub_80A203C
adds r5, r0, 0
movs r0, 0xFE
strb r0, [r5]
adds r5, 0x1
ldr r4, _080A094C @ =gStringVar1
adds r0, r4, 0
adds r1, r6, 0
bl sub_80FC02C
adds r0, r5, 0
adds r1, r4, 0
movs r2, 0xE
bl sub_80A1E9C
adds r5, r0, 0
ldr r1, _080A0950 @ =gOtherText_Met2
bl StringCopy
_080A0934:
ldr r0, _080A0954 @ =gStringVar4
mov r1, r9
mov r2, r8
bl MenuPrint
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_080A094C: .4byte gStringVar1
_080A0950: .4byte gOtherText_Met2
_080A0954: .4byte gStringVar4
thumb_func_end sub_80A0798
thumb_func_start sub_80A0958 thumb_func_start sub_80A0958
sub_80A0958: @ 80A0958 sub_80A0958: @ 80A0958
@ -9039,8 +8843,8 @@ sub_80A1FF8: @ 80A1FF8
_080A2038: .4byte gStringVar4 _080A2038: .4byte gStringVar4
thumb_func_end sub_80A1FF8 thumb_func_end sub_80A1FF8
thumb_func_start sub_80A203C thumb_func_start PokemonSummaryScreen_CopyPokemonLevel
sub_80A203C: @ 80A203C PokemonSummaryScreen_CopyPokemonLevel: @ 80A203C
push {r4,lr} push {r4,lr}
sub sp, 0xC sub sp, 0xC
adds r4, r0, 0 adds r4, r0, 0
@ -9069,7 +8873,7 @@ _080A2052:
bx r1 bx r1
.align 2, 0 .align 2, 0
_080A2074: .4byte gOtherText_Comma _080A2074: .4byte gOtherText_Comma
thumb_func_end sub_80A203C thumb_func_end PokemonSummaryScreen_CopyPokemonLevel
thumb_func_start sub_80A2078 thumb_func_start sub_80A2078
sub_80A2078: @ 80A2078 sub_80A2078: @ 80A2078

View File

@ -3034,8 +3034,8 @@ _080FC026:
bx r1 bx r1
thumb_func_end CopyMapName thumb_func_end CopyMapName
thumb_func_start sub_80FC02C thumb_func_start CopyLocationName
sub_80FC02C: @ 80FC02C CopyLocationName: @ 80FC02C
push {lr} push {lr}
lsls r1, 16 lsls r1, 16
lsrs r1, 16 lsrs r1, 16
@ -3051,7 +3051,7 @@ _080FC042:
bx r1 bx r1
.align 2, 0 .align 2, 0
_080FC048: .4byte gOtherText_Hideout _080FC048: .4byte gOtherText_Hideout
thumb_func_end sub_80FC02C thumb_func_end CopyLocationName
thumb_func_start sub_80FC04C thumb_func_start sub_80FC04C
sub_80FC04C: @ 80FC04C sub_80FC04C: @ 80FC04C

View File

@ -376,6 +376,7 @@ bool8 IsEasyChatPairEqual(u16 *, u16 *);
// asm/region_map.o // asm/region_map.o
void sub_80FBFB4(u8 *str, u8 region, u8); void sub_80FBFB4(u8 *str, u8 region, u8);
u8 *CopyLocationName(u8 *dest, u8 location);
void CopyMapName(); void CopyMapName();
// asm/slot_machine.o // asm/slot_machine.o

View File

@ -114,6 +114,34 @@
#define TYPE_DRAGON 0x10 #define TYPE_DRAGON 0x10
#define TYPE_DARK 0x11 #define TYPE_DARK 0x11
enum {
NATURE_HARDY,
NATURE_LONELY,
NATURE_BRAVE,
NATURE_ADAMANT,
NATURE_NAUGHTY,
NATURE_BOLD,
NATURE_DOCILE,
NATURE_RELAXED,
NATURE_IMPISH,
NATURE_LAX,
NATURE_TIMID,
NATURE_HASTY,
NATURE_SERIOUS,
NATURE_JOLLY,
NATURE_NAIVE,
NATURE_MODEST,
NATURE_MILD,
NATURE_QUIET,
NATURE_BASHFUL,
NATURE_RASH,
NATURE_CALM,
NATURE_GENTLE,
NATURE_SASSY,
NATURE_CAREFUL,
NATURE_QUIRKY,
};
struct PokemonSubstruct0 struct PokemonSubstruct0
{ {
u16 species; u16 species;

View File

@ -125,6 +125,8 @@ SECTIONS {
asm/pokemon_storage_system.o(.text); asm/pokemon_storage_system.o(.text);
asm/pokemon_icon.o(.text); asm/pokemon_icon.o(.text);
asm/pokemon_summary_screen.o(.text); asm/pokemon_summary_screen.o(.text);
src/pokemon_summary_screen.o(.text);
asm/pokemon_summary_screen.o(.text_80A0958);
asm/script_movement.o(.text); asm/script_movement.o(.text);
asm/fldeff_cut.o(.text); asm/fldeff_cut.o(.text);
asm/mail_data.o(.text); asm/mail_data.o(.text);

View File

@ -0,0 +1,318 @@
#include "global.h"
#include "asm.h"
#include "menu.h"
#include "pokemon.h"
#include "string_util.h"
extern u8 gStringVar1[];
extern u8 gStringVar4[];
extern u8 *(gNatureNames[]);
extern const u8 gOtherText_Terminator4[];
extern const u8 gOtherText_Nature[];
extern const u8 gOtherText_Met[];
extern const u8 gOtherText_Egg2[];
extern const u8 gOtherText_ObtainedInTrade[];
extern const u8 gOtherText_FatefulEncounter[];
extern const u8 gOtherText_Met2[];
u8 *sub_80A1E9C(u8 *dest, u8 *src, u8);
u8 sub_80A0664(struct Pokemon *pokemon);
u8 *PokemonSummaryScreen_CopyPokemonLevel(u8 *dest, u8 level);
#define CHAR_NEWLINE (0xFE)
#ifdef NONMATCHING
void PokemonSummaryScreen_PrintTrainerMemo(struct Pokemon *pokemon, u8 left, u8 top) {
u8 nature;
u8 *ptr = gStringVar4;
nature = GetNature(pokemon);
ptr = sub_80A1E9C(ptr, gNatureNames[nature], 14);
if (nature != NATURE_BOLD && nature != NATURE_GENTLE) {
ptr = StringCopy(ptr, gOtherText_Terminator4);
}
ptr = StringCopy(ptr, gOtherText_Nature);
if (sub_80A0664(pokemon) == TRUE) {
u8 locationMet;
locationMet = GetMonData(pokemon, MON_DATA_MET_LOCATION);
if (GetMonData(pokemon, MON_DATA_MET_LEVEL) == 0) {
ptr = PokemonSummaryScreen_CopyPokemonLevel(ptr, 5);
ptr[0] = CHAR_NEWLINE;
ptr++;
CopyLocationName(gStringVar1, locationMet);
ptr = sub_80A1E9C(ptr, gStringVar1, 14);
StringCopy(ptr, gOtherText_Egg2);
} else if (locationMet < 88) {
u8 levelMet;
levelMet = GetMonData(pokemon, MON_DATA_MET_LEVEL);
ptr = PokemonSummaryScreen_CopyPokemonLevel(ptr, levelMet);
ptr[0] = CHAR_NEWLINE;
ptr++;
CopyLocationName(gStringVar1, locationMet);
ptr = sub_80A1E9C(ptr, gStringVar1, 14);
StringCopy(ptr, gOtherText_Met);
} else {
ptr[0] = CHAR_NEWLINE;
ptr++;
StringCopy(ptr, gOtherText_ObtainedInTrade);
}
} else {
u8 gameMet;
gameMet = GetMonData(pokemon, MON_DATA_MET_GAME);
if (gameMet == VERSION_RUBY || gameMet == VERSION_SAPPHIRE || gameMet == 3) {
u8 locationMet;
locationMet = GetMonData(pokemon, MON_DATA_MET_LOCATION);
if (locationMet == 0xFF) {
u8 levelMet;
levelMet = GetMonData(pokemon, MON_DATA_MET_LEVEL);
ptr = PokemonSummaryScreen_CopyPokemonLevel(ptr, levelMet);
ptr[0] = CHAR_NEWLINE;
ptr++;
StringCopy(ptr, gOtherText_FatefulEncounter);
} else if (locationMet <= 88) {
u8 levelMet;
levelMet = GetMonData(pokemon, MON_DATA_MET_LEVEL);
ptr = PokemonSummaryScreen_CopyPokemonLevel(ptr, levelMet);
ptr[0] = CHAR_NEWLINE;
ptr++;
CopyLocationName(gStringVar1, locationMet);
ptr = sub_80A1E9C(ptr, gStringVar1, 14);
StringCopy(ptr, gOtherText_Met2);
} else {
ptr[0] = CHAR_NEWLINE;
ptr++;
StringCopy(ptr, gOtherText_ObtainedInTrade);
}
} else {
ptr[0] = CHAR_NEWLINE;
ptr++;
StringCopy(ptr, gOtherText_ObtainedInTrade);
}
}
MenuPrint(gStringVar4, left, top);
}
#else
__attribute__((naked))
void PokemonSummaryScreen_PrintTrainerMemo(void) {
asm(".syntax unified\n\
push {r4-r7,lr}\n\
mov r7, r9\n\
mov r6, r8\n\
push {r6,r7}\n\
adds r7, r0, 0\n\
lsls r1, 24\n\
lsrs r1, 24\n\
mov r9, r1\n\
lsls r2, 24\n\
lsrs r2, 24\n\
mov r8, r2\n\
ldr r5, _080A0838 @ =gStringVar4\n\
bl GetNature\n\
lsls r0, 24\n\
lsrs r4, r0, 24\n\
ldr r1, _080A083C @ =gNatureNames\n\
lsls r0, r4, 2\n\
adds r0, r1\n\
ldr r1, [r0]\n\
adds r0, r5, 0\n\
movs r2, 0xE\n\
bl sub_80A1E9C\n\
adds r5, r0, 0\n\
cmp r4, 0x5\n\
beq _080A07DA\n\
cmp r4, 0x15\n\
beq _080A07DA\n\
ldr r1, _080A0840 @ =gOtherText_Terminator4\n\
bl StringCopy\n\
adds r5, r0, 0\n\
_080A07DA:\n\
ldr r1, _080A0844 @ =gOtherText_Nature\n\
adds r0, r5, 0\n\
bl StringCopy\n\
adds r5, r0, 0\n\
adds r0, r7, 0\n\
bl sub_80A0664\n\
lsls r0, 24\n\
lsrs r0, 24\n\
cmp r0, 0x1\n\
bne _080A0898\n\
adds r0, r7, 0\n\
movs r1, 0x23\n\
bl GetMonData\n\
lsls r0, 24\n\
lsrs r6, r0, 24\n\
adds r0, r7, 0\n\
movs r1, 0x24\n\
bl GetMonData\n\
cmp r0, 0\n\
bne _080A0850\n\
adds r0, r5, 0\n\
movs r1, 0x5\n\
bl PokemonSummaryScreen_CopyPokemonLevel\n\
adds r5, r0, 0\n\
movs r0, 0xFE\n\
strb r0, [r5]\n\
adds r5, 0x1\n\
ldr r4, _080A0848 @ =gStringVar1\n\
adds r0, r4, 0\n\
adds r1, r6, 0\n\
bl CopyLocationName\n\
adds r0, r5, 0\n\
adds r1, r4, 0\n\
movs r2, 0xE\n\
bl sub_80A1E9C\n\
adds r5, r0, 0\n\
ldr r1, _080A084C @ =gOtherText_Egg2\n\
bl StringCopy\n\
b _080A0934\n\
.align 2, 0\n\
_080A0838: .4byte gStringVar4\n\
_080A083C: .4byte gNatureNames\n\
_080A0840: .4byte gOtherText_Terminator4\n\
_080A0844: .4byte gOtherText_Nature\n\
_080A0848: .4byte gStringVar1\n\
_080A084C: .4byte gOtherText_Egg2\n\
_080A0850:\n\
cmp r6, 0x57\n\
bhi _080A08E8\n\
adds r0, r7, 0\n\
movs r1, 0x24\n\
bl GetMonData\n\
adds r1, r0, 0\n\
lsls r1, 24\n\
lsrs r1, 24\n\
adds r0, r5, 0\n\
bl PokemonSummaryScreen_CopyPokemonLevel\n\
adds r5, r0, 0\n\
movs r0, 0xFE\n\
strb r0, [r5]\n\
adds r5, 0x1\n\
ldr r4, _080A0890 @ =gStringVar1\n\
adds r0, r4, 0\n\
adds r1, r6, 0\n\
bl CopyLocationName\n\
adds r0, r5, 0\n\
adds r1, r4, 0\n\
movs r2, 0xE\n\
bl sub_80A1E9C\n\
adds r5, r0, 0\n\
ldr r1, _080A0894 @ =gOtherText_Met\n\
bl StringCopy\n\
b _080A0934\n\
.align 2, 0\n\
_080A0890: .4byte gStringVar1\n\
_080A0894: .4byte gOtherText_Met\n\
_080A0898:\n\
adds r0, r7, 0\n\
movs r1, 0x25\n\
bl GetMonData\n\
lsls r0, 24\n\
movs r1, 0xFF\n\
lsls r1, 24\n\
adds r0, r1\n\
lsrs r0, 24\n\
cmp r0, 0x2\n\
bhi _080A08E8\n\
adds r0, r7, 0\n\
movs r1, 0x23\n\
bl GetMonData\n\
lsls r0, 24\n\
lsrs r6, r0, 24\n\
cmp r6, 0xFF\n\
bne _080A08E4\n\
adds r0, r7, 0\n\
movs r1, 0x24\n\
bl GetMonData\n\
adds r1, r0, 0\n\
lsls r1, 24\n\
lsrs r1, 24\n\
adds r0, r5, 0\n\
bl PokemonSummaryScreen_CopyPokemonLevel\n\
adds r5, r0, 0\n\
movs r0, 0xFE\n\
strb r0, [r5]\n\
adds r5, 0x1\n\
ldr r1, _080A08E0 @ =gOtherText_FatefulEncounter\n\
b _080A08F0\n\
.align 2, 0\n\
_080A08E0: .4byte gOtherText_FatefulEncounter\n\
_080A08E4:\n\
cmp r6, 0x57\n\
bls _080A08FC\n\
_080A08E8:\n\
movs r0, 0xFE\n\
strb r0, [r5]\n\
adds r5, 0x1\n\
ldr r1, _080A08F8 @ =gOtherText_ObtainedInTrade\n\
_080A08F0:\n\
adds r0, r5, 0\n\
bl StringCopy\n\
b _080A0934\n\
.align 2, 0\n\
_080A08F8: .4byte gOtherText_ObtainedInTrade\n\
_080A08FC:\n\
adds r0, r7, 0\n\
movs r1, 0x24\n\
bl GetMonData\n\
adds r1, r0, 0\n\
lsls r1, 24\n\
lsrs r1, 24\n\
adds r0, r5, 0\n\
bl PokemonSummaryScreen_CopyPokemonLevel\n\
adds r5, r0, 0\n\
movs r0, 0xFE\n\
strb r0, [r5]\n\
adds r5, 0x1\n\
ldr r4, _080A094C @ =gStringVar1\n\
adds r0, r4, 0\n\
adds r1, r6, 0\n\
bl CopyLocationName\n\
adds r0, r5, 0\n\
adds r1, r4, 0\n\
movs r2, 0xE\n\
bl sub_80A1E9C\n\
adds r5, r0, 0\n\
ldr r1, _080A0950 @ =gOtherText_Met2\n\
bl StringCopy\n\
_080A0934:\n\
ldr r0, _080A0954 @ =gStringVar4\n\
mov r1, r9\n\
mov r2, r8\n\
bl MenuPrint\n\
pop {r3,r4}\n\
mov r8, r3\n\
mov r9, r4\n\
pop {r4-r7}\n\
pop {r0}\n\
bx r0\n\
.align 2, 0\n\
_080A094C: .4byte gStringVar1\n\
_080A0950: .4byte gOtherText_Met2\n\
_080A0954: .4byte gStringVar4\n\
.syntax divided\n");
}
#endif