Decomp more of personality_test (#27)

* decomp most of personality_test

* just gonna move the funcs to src in assembly for now so I can combine stuff

* label another func and some cleanup

* one func of personality test left in asm

* small cleanups and labeling of funcs
This commit is contained in:
Seth Barberee 2021-02-19 16:01:53 -08:00 committed by GitHub
parent 8dfd044ef3
commit c754c2a046
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 1915 additions and 1631 deletions

View File

@ -69,7 +69,7 @@ _08035472:
_080354C0: .4byte gUnknown_203B340 _080354C0: .4byte gUnknown_203B340
_080354C4: .4byte gUnknown_80E4A10 _080354C4: .4byte gUnknown_80E4A10
_080354C8: .4byte gUnknown_80E4A28 _080354C8: .4byte gUnknown_80E4A28
_080354CC: .4byte gUnknown_80E591C _080354CC: .4byte gCreditsTable
_080354D0: _080354D0:
ldr r2, [r1, 0x8] ldr r2, [r1, 0x8]
movs r3, 0x4 movs r3, 0x4
@ -157,7 +157,7 @@ _08035542:
pop {r1} pop {r1}
bx r1 bx r1
.align 2, 0 .align 2, 0
_08035570: .4byte gCreditsTable _08035570: .4byte gCreditsText
thumb_func_end sub_8035444 thumb_func_end sub_8035444
thumb_func_start sub_8035574 thumb_func_start sub_8035574
@ -201,7 +201,7 @@ _080355A8:
b _08035654 b _08035654
.align 2, 0 .align 2, 0
_080355C8: .4byte gUnknown_203B340 _080355C8: .4byte gUnknown_203B340
_080355CC: .4byte gCreditsTable _080355CC: .4byte gCreditsText
_080355D0: _080355D0:
bl sub_8099B94 bl sub_8099B94
lsls r0, 24 lsls r0, 24
@ -233,7 +233,7 @@ _08035600:
str r0, [r1, 0x64] str r0, [r1, 0x64]
b _08035654 b _08035654
.align 2, 0 .align 2, 0
_0803560C: .4byte gCreditsTable _0803560C: .4byte gCreditsText
_08035610: _08035610:
bl sub_8099B94 bl sub_8099B94
lsls r0, 24 lsls r0, 24
@ -262,7 +262,7 @@ _08035638:
movs r0, 0x3 movs r0, 0x3
b _08035656 b _08035656
.align 2, 0 .align 2, 0
_08035650: .4byte gCreditsTable _08035650: .4byte gCreditsText
_08035654: _08035654:
movs r0, 0 movs r0, 0
_08035656: _08035656:

View File

@ -286,8 +286,8 @@ _08035E0A:
bx r1 bx r1
thumb_func_end sub_8035DB4 thumb_func_end sub_8035DB4
thumb_func_start sub_8035E10 thumb_func_start DrawMainMenu
sub_8035E10: DrawMainMenu:
push {r4-r7,lr} push {r4-r7,lr}
mov r7, r8 mov r7, r8
push {r7} push {r7}
@ -335,7 +335,7 @@ _08035E42:
movs r1, 0x1 movs r1, 0x1
movs r2, 0x1 movs r2, 0x1
bl sub_800641C bl sub_800641C
bl sub_803628C bl SetMainMenuItems
ldr r0, [r4] ldr r0, [r4]
movs r7, 0xD2 movs r7, 0xD2
lsls r7, 1 lsls r7, 1
@ -343,7 +343,7 @@ _08035E42:
movs r1, 0x1 movs r1, 0x1
negs r1, r1 negs r1, r1
str r1, [r0] str r1, [r0]
bl SetMainMenuType bl SetMainMenuText
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08035E9A beq _08035E9A
@ -369,10 +369,10 @@ _08035E9A:
.align 2, 0 .align 2, 0
_08035EB8: .4byte gUnknown_203B34C _08035EB8: .4byte gUnknown_203B34C
_08035EBC: .4byte gUnknown_80E59C8 _08035EBC: .4byte gUnknown_80E59C8
thumb_func_end sub_8035E10 thumb_func_end DrawMainMenu
thumb_func_start sub_8035EC0 thumb_func_start CleanMainMenu
sub_8035EC0: CleanMainMenu:
push {r4,lr} push {r4,lr}
bl ResetUnusedInputStruct bl ResetUnusedInputStruct
movs r0, 0 movs r0, 0
@ -392,7 +392,7 @@ _08035EE0:
bx r0 bx r0
.align 2, 0 .align 2, 0
_08035EE8: .4byte gUnknown_203B34C _08035EE8: .4byte gUnknown_203B34C
thumb_func_end sub_8035EC0 thumb_func_end CleanMainMenu
thumb_func_start sub_8035EEC thumb_func_start sub_8035EEC
sub_8035EEC: sub_8035EEC:
@ -426,7 +426,7 @@ _08035F0A:
mov r1, sp mov r1, sp
bl sub_8013114 bl sub_8013114
_08035F28: _08035F28:
bl SetMainMenuType bl SetMainMenuText
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08035F4A beq _08035F4A
@ -553,8 +553,8 @@ _0803601A:
bx r1 bx r1
thumb_func_end sub_8035EEC thumb_func_end sub_8035EEC
thumb_func_start SetMainMenuType thumb_func_start SetMainMenuText
SetMainMenuType: SetMainMenuText:
push {r4-r6,lr} push {r4-r6,lr}
sub sp, 0x10 sub sp, 0x10
ldr r6, _08036048 ldr r6, _08036048
@ -789,7 +789,7 @@ _08036226:
_08036230: .4byte gUnknown_203B34C _08036230: .4byte gUnknown_203B34C
_08036234: .4byte gUnknown_80E5CB4 _08036234: .4byte gUnknown_80E5CB4
_08036238: .4byte gUnknown_80E5D48 _08036238: .4byte gUnknown_80E5D48
thumb_func_end SetMainMenuType thumb_func_end SetMainMenuText
thumb_func_start sub_803623C thumb_func_start sub_803623C
sub_803623C: sub_803623C:
@ -801,7 +801,7 @@ sub_803623C:
adds r0, r1 adds r0, r1
movs r1, 0x1 movs r1, 0x1
bl sub_8035CC0 bl sub_8035CC0
bl sub_803628C bl SetMainMenuItems
ldr r0, [r4] ldr r0, [r4]
movs r1, 0xD2 movs r1, 0xD2
lsls r1, 1 lsls r1, 1
@ -809,7 +809,7 @@ sub_803623C:
movs r1, 0x1 movs r1, 0x1
negs r1, r1 negs r1, r1
str r1, [r0] str r1, [r0]
bl SetMainMenuType bl SetMainMenuText
lsls r0, 24 lsls r0, 24
cmp r0, 0 cmp r0, 0
beq _08036276 beq _08036276
@ -831,8 +831,8 @@ _08036276:
_08036288: .4byte gUnknown_203B34C _08036288: .4byte gUnknown_203B34C
thumb_func_end sub_803623C thumb_func_end sub_803623C
thumb_func_start sub_803628C thumb_func_start SetMainMenuItems
sub_803628C: SetMainMenuItems:
push {r4,lr} push {r4,lr}
sub sp, 0x10 sub sp, 0x10
bl sub_8011C34 bl sub_8011C34
@ -984,7 +984,7 @@ _080363D0: .4byte gUnknown_203B34C
_080363D4: .4byte gUnknown_80E59E0 _080363D4: .4byte gUnknown_80E59E0
_080363D8: .4byte gUnknown_80E59F8 _080363D8: .4byte gUnknown_80E59F8
_080363DC: .4byte gUnknown_203B350 _080363DC: .4byte gUnknown_203B350
thumb_func_end sub_803628C thumb_func_end SetMainMenuItems
thumb_func_start sub_80363E0 thumb_func_start sub_80363E0
sub_80363E0: sub_80363E0:

File diff suppressed because it is too large Load Diff

106
asm/personality_test_2.s Normal file
View File

@ -0,0 +1,106 @@
.include "constants/gba_constants.inc"
.include "asm/macros.inc"
.syntax unified
.text
thumb_func_start RedrawPartnerSelectionMenu
RedrawPartnerSelectionMenu:
push {r4-r6,lr}
sub sp, 0x4
ldr r6, _0803CF60
ldr r0, [r6]
movs r1, 0x32
ldrsh r0, [r0, r1]
movs r1, 0xC
bl sub_80095E4
adds r0, 0x2
lsls r0, 16
ldr r2, [r6]
ldr r3, [r2, 0x4C]
lsls r1, r3, 1
adds r1, r3
lsls r1, 3
adds r1, r2, r1
adds r1, 0x62
movs r4, 0
asrs r3, r0, 16
lsrs r0, 16
strh r0, [r1]
ldr r1, [r2, 0x4C]
lsls r0, r1, 1
adds r0, r1
lsls r0, 3
adds r2, r0
adds r3, 0x2
adds r2, 0x64
strh r3, [r2]
bl ResetUnusedInputStruct
ldr r0, [r6]
adds r0, 0x54
movs r1, 0x1
movs r2, 0x1
bl sub_800641C
ldr r0, [r6]
ldr r0, [r0, 0x4C]
bl sub_8008C54
ldr r0, [r6]
ldr r0, [r0, 0x4C]
bl sub_80073B8
ldr r2, _0803CF64
ldr r0, [r6]
ldr r3, [r0, 0x4C]
str r4, [sp]
movs r0, 0xC
movs r1, 0
bl xxx_call_draw_string
movs r5, 0
b _0803CF98
.align 2, 0
_0803CF60: .4byte gUnknown_203B404
_0803CF64: .4byte gUnknown_80F42C0
_0803CF68:
ldr r0, [r6]
adds r0, 0x18
adds r1, r5, 0
bl sub_8013800
adds r4, r0, 0
ldr r0, [r6]
lsls r1, r5, 1
adds r0, 0x2
adds r0, r1
movs r1, 0
ldrsh r0, [r0, r1]
bl sub_808D994
adds r2, r0, 0
ldr r0, [r6]
ldr r3, [r0, 0x4C]
movs r0, 0
str r0, [sp]
movs r0, 0x8
adds r1, r4, 0
bl xxx_call_draw_string
adds r5, 0x1
_0803CF98:
ldr r0, [r6]
movs r1, 0x32
ldrsh r0, [r0, r1]
cmp r5, r0
blt _0803CF68
ldr r4, _0803CFBC
ldr r0, [r4]
ldr r0, [r0, 0x4C]
bl sub_80073E0
ldr r1, [r4]
movs r0, 0x1
strb r0, [r1, 0x16]
add sp, 0x4
pop {r4-r6}
pop {r0}
bx r0
.align 2, 0
_0803CFBC: .4byte gUnknown_203B404
thumb_func_end RedrawPartnerSelectionMenu
.align 2,0

View File

@ -4906,12 +4906,12 @@ gUnknown_80E4A28: @ 80E4A28
.byte 0x10, 0x00, 0x00, 0x00 .byte 0x10, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00 .byte 0x00, 0x00, 0x00, 0x00
.global gCreditsTable .global gCreditsText
gCreditsTable: @ 80E4A40 gCreditsText: @ 80E4A40
.incbin "baserom.gba", 0xE4A40, 0xEDC .incbin "baserom.gba", 0xE4A40, 0xEDC
.global gUnknown_80E591C .global gCreditsTable
gUnknown_80E591C: @ 80E591C gCreditsTable: @ 80E591C
.incbin "baserom.gba", 0xE591C, 0x74 .incbin "baserom.gba", 0xE591C, 0x74
.global gUnknown_80E5990 .global gUnknown_80E5990

View File

@ -164,12 +164,16 @@ gUnknown_80F4D44: @ 80F4D44
gUnknown_80F4D64: @ 80F4D64 gUnknown_80F4D64: @ 80F4D64
@ replacing .incbin "baserom.gba", 0x000f4d64, 0x28 @ replacing .incbin "baserom.gba", 0x000f4d64, 0x28
.byte 0x02, 0x06, 0x04, 0x00, 0x02, 0x00, 0x04, 0x06, 0x04, 0x00, 0x06, 0x02, 0x04, 0x02, 0x06, 0x00, 0x06, 0x02, 0x00, 0x04, 0x06, 0x04, 0x02, 0x00, 0x00, 0x04, 0x02, 0x06, 0x00, 0x06, 0x02, 0x04 .byte 0x02, 0x06, 0x04, 0x00, 0x02, 0x00, 0x04, 0x06, 0x04, 0x00, 0x06, 0x02, 0x04, 0x02, 0x06, 0x00, 0x06, 0x02, 0x00, 0x04, 0x06, 0x04, 0x02, 0x00, 0x00, 0x04, 0x02, 0x06, 0x00, 0x06, 0x02, 0x04
.byte 0x70, 0x6b, 0x73, 0x64, 0x69, 0x72, 0x30, 0x00 .string "pksdir0\0"
.align 2,0
.global gUnknown_80F4D8C .global gUnknown_80F4D8C
gUnknown_80F4D8C: @ 80F4D8C gUnknown_80F4D8C: @ 80F4D8C
@ replacing .incbin "baserom.gba", 0x000f4d8c, 0x14 @ replacing .incbin "baserom.gba", 0x000f4d8c, 0x14
.byte 0x6d, 0x61, 0x70, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x00, 0x70, 0x6b, 0x73, 0x64, 0x69, 0x72, 0x30, 0x00 .string "mapparam\0"
.align 2,0
.string "pksdir0\0"
.align 2,0
.global gUnknown_80F4DA0 .global gUnknown_80F4DA0
gUnknown_80F4DA0: @ 80F4DA0 gUnknown_80F4DA0: @ 80F4DA0
@ -1656,35 +1660,52 @@ gUnknown_80F6778: @ 80F6778
.global gUnknown_80F6788 .global gUnknown_80F6788
gUnknown_80F6788: @ 80F6788 gUnknown_80F6788: @ 80F6788
.incbin "baserom.gba", 0xF6788, 0xC .byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gUnknown_80F6794 .global gUnknown_80F6794
gUnknown_80F6794: @ 80F6794 gUnknown_80F6794: @ 80F6794
.incbin "baserom.gba", 0xF6794, 0x14 .byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x01, 0x00
.byte 0x00, 0x00, 0x02, 0x00
.byte 0x00, 0x00, 0x04, 0x00
.byte 0x00, 0x00, 0x08, 0x00
.global gUnknown_80F67A8 .global gUnknown_80F67A8
gUnknown_80F67A8: @ 80F67A8 gUnknown_80F67A8: @ 80F67A8
.incbin "baserom.gba", 0xF67A8, 0xC .byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gUnknown_80F67B4 .global gUnknown_80F67B4
gUnknown_80F67B4: @ 80F67B4 gUnknown_80F67B4: @ 80F67B4
.incbin "baserom.gba", 0xF67B4, 0x10 .byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.global gUnknown_80F67C4 .global gUnknown_80F67C4
gUnknown_80F67C4: @ 80F67C4 gUnknown_80F67C4: @ 80F67C4
.incbin "baserom.gba", 0xF67C4, 0x10 .byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x10, 0x00
.byte 0x00, 0x00, 0x20, 0x00
.byte 0x00, 0x00, 0x40, 0x00
.global gUnknown_80F67D4 .global gUnknown_80F67D4
gUnknown_80F67D4: @ 80F67D4 gUnknown_80F67D4: @ 80F67D4
.incbin "baserom.gba", 0xF67D4, 0x8 .byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x80, 0x00
.global gUnknown_80F67DC .global gUnknown_80F67DC
gUnknown_80F67DC: @ 80F67DC gUnknown_80F67DC: @ 80F67DC
.incbin "baserom.gba", 0xF67DC, 0x8 .byte 0xD8, 0x00, 0xD9, 0x00
.byte 0xD9, 0x00, 0x73, 0x01
.global gUnknown_80F67E4 .global gUnknown_80F67E4
gUnknown_80F67E4: @ 80F67E4 gUnknown_80F67E4: @ 80F67E4
.incbin "baserom.gba", 0xF67E4, 0x8 .byte 0xDA, 0x00, 0xDB, 0x00
.byte 0xDB, 0x00, 0x74, 0x01
.global gUnknown_80F67EC .global gUnknown_80F67EC
gUnknown_80F67EC: @ 80F67EC gUnknown_80F67EC: @ 80F67EC

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,22 @@
#ifndef GUARD_CONSTANTS_EMOTIONS_H
#define GUARD_CONSTANTS_EMOTIONS_H
#define EMOTION_NORMAL 0
#define EMOTION_HAPPY 2
#define EMOTION_PAINED 4
#define EMOTION_ANGRY 6
#define EMOTION_WORRIED 8
#define EMOTION_SAD 10
#define EMOTION_CRYING 12
#define EMOTION_SHOUTING 14
#define EMOTION_TEARY_EYE 16
#define EMOTION_DETERMINED 18
#define EMOTION_JOYOUS 20
#define EMOTION_INSPIRED 22
#define EMOTION_SUPRISED 24
#define EMOTION_DIZZY 26
#define EMOTION_SIGH 32
#define EMOTION_STUNNED 34
#define MAX_EMOTIONS 40
#endif // GUARD_CONSTANTS_EMOTIONS_H

View File

@ -1,3 +1,7 @@
#ifndef GUARD_CONSTANTS_FRIEND_AREA_H
#define GUARD_CONSTANTS_FRIEND_AREA_H
#define NUM_FRIEND_AREAS 58 #define NUM_FRIEND_AREAS 58
#define NONE 0 #define NONE 0
@ -58,3 +62,5 @@
#define SOUTHERN_ISLAND 55 #define SOUTHERN_ISLAND 55
#define ENCLOSED_ISLAND 56 #define ENCLOSED_ISLAND 56
#define FINAL_ISLAND 57 #define FINAL_ISLAND 57
#endif

View File

@ -0,0 +1,12 @@
#ifndef GUARD_CONSTANTS_PERSONALITY_TEST_H
#define GUARD_CONSTANTS_PERSONALITY_TEST_H
#define NUM_PARTNERS 10
#define NUM_PERSONALITIES 13
#define NUM_QUIZ_QUESTIONS 55
#define MAX_ASKED_QUESTIONS 8
#define MALE 0
#define FEMALE 1
#endif

View File

@ -0,0 +1,95 @@
#ifndef GUARD_PERSONALITY_TEST_H
#define GUARD_PERSONALITY_TEST_H
#include "constants/personality_test.h"
struct unkData
{
u8 unk0[24];
};
extern const struct unkData gUnknown_80F4244;
struct PersonalityStruct_203B400
{
s32 FrameCounter;
u32 unk4;
/* 0x8 */ s16 StarterID;
/* 0xA */ s16 PartnerID;
u8 padding[0x20 - 0xC];
s32 unk20;
u8 padding2[0x34 - 0x24];
/* 0x34 */ u32 TestState;
/* 0x38 */ s32 QuestionCounter;
/* 0x3C */ u32 currQuestionIndex;
/* 0x40 */ u8 playerNature;
u8 padding3[3];
/* 0x44 */ s32 NatureTotals[13];
/* 0x78 */ u8 QuestionTracker[NUM_QUIZ_QUESTIONS];
/* 0xB0 */ u32 playerGender; // 1 = Female, 0 = Male
u32 unkb4;
u32 unkb8;
u32 unkbc;
};
extern struct PersonalityStruct_203B400 *gUnknown_203B400;
struct PersonalitySubStruct
{
u8 unkb4;
u8 unkb5;
u8 unkb6;
u8 unkb7;
};
struct PersonalityStruct_203B404
{
// Size: 0xB8
/* 0x0 */ s16 StarterID;
/* 0x2 */ s16 PartnerArray[NUM_PARTNERS];
u8 unk16;
u8 unk17;
/* 0x18 */ struct UnkInputStruct *unk18; // something menu related (seems to be some struct)
u8 padding[0x30 - 0x1C];
/* 0x30 */ s16 currPartnerSelection;
s16 unk32;
u8 padding2[0x3A - 0x34];
/* 0x3A */ s16 numPartners;
u8 padding3[0x4C - 0x3C];
u32 unk4C;
/* 0x50 */ struct unkData *unk50;
/* 0x54 */ struct unkData unk54[4];
/* 0xB4 */ struct PersonalitySubStruct sub;
};
extern struct PersonalityStruct_203B404 *gUnknown_203B404;
void InitializeTestStats(void);
void GenerateNewQuestionOrGender(void);
void CallPromptNewQuestion(void);
void PrintPersonalityTypeDescription(void);
void SetPlayerGender(void);
void RevealPersonality(void);
void RevealStarter(void);
void sub_803CA8C(void);
void PromptPickPartner(void);
void sub_803CAD4(void);
void CallCreatePartnerSelectionMenu(void);
void PromptForPartnerNickname(void);
void sub_803CB5C(void);
void sub_803CB7C(void);
void PrintEndIntroText(void);
void sub_803CBE4(void);
s32 GetValidPartners(void);
void UpdateNatureTotals(void);
void PromptNewQuestion(void);
void PersonalityTest_DisplayPartnerSprite(void);
u16 HandlePartnerSelectionInput(void);
void PersonalityTest_DisplayStarterSprite(void);
void CreatePartnerSelectionMenu(s16);
void sub_803CECC(void);
void nullsub_135(void);
#endif

View File

@ -103,7 +103,7 @@ SECTIONS {
src/code_803C1B4.o(.text); src/code_803C1B4.o(.text);
asm/code_803C1D0.o(.text); asm/code_803C1D0.o(.text);
src/personality_test_pre.o(.text); src/personality_test_pre.o(.text);
asm/personality_test.o(.text); asm/personality_test_2.o(.text);
src/personality_test.o(.text); src/personality_test.o(.text);
asm/code_803D110.o(.text); asm/code_803D110.o(.text);
src/code_8040094.o(.text); src/code_8040094.o(.text);
@ -217,6 +217,7 @@ SECTIONS {
data/data_80B9BB8.o(.rodata); data/data_80B9BB8.o(.rodata);
data/pokemon_mail.o(.rodata); data/pokemon_mail.o(.rodata);
data/personality_test.o(.rodata); data/personality_test.o(.rodata);
src/personality_test_pre.o(.rodata);
src/personality_test.o(.rodata); src/personality_test.o(.rodata);
data/data_80F4278.o(.rodata); data/data_80F4278.o(.rodata);
data/friend_area_dialogue.o(.rodata); data/friend_area_dialogue.o(.rodata);

View File

@ -31,7 +31,7 @@ extern u8 sub_8071858(struct unkDungeon_8041D5C *r0, u8);
extern u32 sub_806F62C(u32); extern u32 sub_806F62C(u32);
extern void sub_8083E38(u32); extern void sub_8083E38(u32);
extern u8 sub_803F428(struct unkDungeon_8041D5C *r0); extern u8 sub_803F428(struct unkDungeon_8041D5C *r0);
extern void sub_8041550(struct unkDungeon_8041D5C *r0, u32, u32, u32); extern void sub_8041550(struct unkDungeon_8041D5C *r0, u32, u32, u32, u32, u32);
void sub_80421C0(struct unkDungeon_8041D5C *r0, u16 r1); void sub_80421C0(struct unkDungeon_8041D5C *r0, u16 r1);
@ -439,10 +439,7 @@ void sub_8041EF8(struct unkDungeon_8041D5C *r0)
void sub_8041F08(struct unkDungeon_8041D5C *r0) void sub_8041F08(struct unkDungeon_8041D5C *r0)
{ {
volatile struct unk_struct_8041F08 temp; sub_8041550(r0, 0x15, 1, 3, 2, 0);
temp.unk0 = 2;
temp.unk4 = 0;
sub_8041550(r0, 0x15, 1, 3);
} }
void nullsub_90(void) void nullsub_90(void)
@ -597,10 +594,7 @@ void sub_80420B8(struct unkDungeon_8041D5C *r0, u32 r1)
void sub_80420C8(struct unkDungeon_8041D5C *r0) void sub_80420C8(struct unkDungeon_8041D5C *r0)
{ {
volatile struct unk_struct_8041F08 temp; sub_8041550(r0, 0x15, 1, 3, 2, 0);
temp.unk0 = 2;
temp.unk4 = 0;
sub_8041550(r0, 0x15, 1, 3);
} }
void nullsub_92(void) void nullsub_92(void)
@ -611,7 +605,6 @@ void sub_80420E8(struct unkDungeon_8041D5C *r0, struct unkStruct_80420E8 *r1)
{ {
u32 temp; u32 temp;
u32 arg; u32 arg;
volatile struct unk_struct_8041F08 temp_1;
temp = r1->unk8; temp = r1->unk8;
if(gUnknown_203B418[0x16d] != 0) if(gUnknown_203B418[0x16d] != 0)
temp = sub_806F62C(r1->unk8); temp = sub_806F62C(r1->unk8);
@ -631,9 +624,7 @@ void sub_80420E8(struct unkDungeon_8041D5C *r0, struct unkStruct_80420E8 *r1)
arg = 11; arg = 11;
break; break;
} }
temp_1.unk0 = 0; sub_8041550(r0, arg, 1, 3, 0, 1);
temp_1.unk4 = 1;
sub_8041550(r0, arg, 1, 3);
} }
void sub_8042148(struct unkDungeon_8041D5C *r0) void sub_8042148(struct unkDungeon_8041D5C *r0)

View File

@ -18,7 +18,7 @@ extern s16 gUnknown_80F4FBE;
extern void sub_807D148(u32 r0, struct unkDungeon_8041D5C *r1, u32 r2, u32 r3); extern void sub_807D148(u32 r0, struct unkDungeon_8041D5C *r1, u32 r2, u32 r3);
extern void sub_8075FCC(u32 r0, struct unkDungeon_8041D5C *r1); extern void sub_8075FCC(u32 r0, struct unkDungeon_8041D5C *r1);
extern void sub_8077AE4(u32 r0, struct unkDungeon_8041D5C *r1, u32 r2); extern void sub_8077AE4(u32 r0, struct unkDungeon_8041D5C *r1, u32 r2);
extern void sub_8072008(u32 r0, struct unkDungeon_8041D5C *r1, u32 r2, u8 r3); extern void sub_8072008(u32 r0, struct unkDungeon_8041D5C *r1, u32 r2, u8 r3, u32);
extern void sub_8076D10(u32 r0, struct unkDungeon_8041D5C *r1); extern void sub_8076D10(u32 r0, struct unkDungeon_8041D5C *r1);
extern void sub_807232C(u32 r0, struct unkDungeon_8041D5C *r1, u32 r2); extern void sub_807232C(u32 r0, struct unkDungeon_8041D5C *r1, u32 r2);
@ -135,9 +135,7 @@ void sub_804849C(u32 r0, struct unkDungeon_8041D5C *r1)
void sub_80484A8(u32 r0, struct unkDungeon_8041D5C *r1) void sub_80484A8(u32 r0, struct unkDungeon_8041D5C *r1)
{ {
volatile u32 temp; sub_8072008(r0, r1, 1, 1, 1);
temp = 1;
sub_8072008(r0, r1, 1, 1);
} }
void sub_80484BC(u32 r0, struct unkDungeon_8041D5C *r1) void sub_80484BC(u32 r0, struct unkDungeon_8041D5C *r1)

View File

@ -7,7 +7,7 @@ extern void sub_800226C(u8 r0, u8 r1, u32* r2, u8 u3);
extern void sub_800160C(struct UnkEventStruct *r0, u32 r1, u32 r2); extern void sub_800160C(struct UnkEventStruct *r0, u32 r1, u32 r2);
extern u8 sub_8002658(s32); extern u8 sub_8002658(s32);
extern u8 gUnknown_2000A88; extern u8 gUnknown_2000A88[0x400];
bool8 sub_80026CC(s16 r0) bool8 sub_80026CC(s16 r0)
{ {
@ -21,7 +21,7 @@ void sub_80026E8(s16 r0)
bool8 sub_8002700(void *r0) bool8 sub_8002700(void *r0)
{ {
MemoryCopy8(r0, &gUnknown_2000A88, 0x80 << 3); MemoryCopy8(r0, gUnknown_2000A88, 0x400);
return 1; return 1;
} }
@ -29,7 +29,7 @@ bool8 sub_8002718(u8 *r0)
{ {
struct UnkEventStruct temp; struct UnkEventStruct temp;
sub_800160C(&temp, 0, 0); sub_800160C(&temp, 0, 0);
MemoryCopy8(&gUnknown_2000A88, r0, 0x80 << 3); MemoryCopy8(gUnknown_2000A88, r0, 0x400);
if (temp.unk0[5] != temp.unk4[0]) if (temp.unk0[5] != temp.unk4[0])
return 0; return 0;
return 1; return 1;

View File

@ -30,7 +30,7 @@ extern void MemoryFree(void *);
extern void sub_8094C14(void); extern void sub_8094C14(void);
extern void sub_8099690(u32); extern void sub_8099690(u32);
extern void sub_8035E10(void); extern void DrawMainMenu(void);
extern void CreateDebugMenu(void); extern void CreateDebugMenu(void);
extern void sub_8036400(void); extern void sub_8036400(void);
extern void sub_8036FDC(void); extern void sub_8036FDC(void);
@ -56,7 +56,7 @@ extern s32 sub_80383D4(void);
extern s32 sub_8038630(void); extern s32 sub_8038630(void);
extern s32 sub_803A2A4(void); extern s32 sub_803A2A4(void);
extern void sub_8035EC0(void); extern void CleanMainMenu(void);
extern void sub_80393F0(void); extern void sub_80393F0(void);
extern void sub_8036B04(void); extern void sub_8036B04(void);
extern void sub_80370D4(void); extern void sub_80370D4(void);
@ -103,7 +103,7 @@ void SetUpMenu(void)
case 1: case 1:
sub_8094C14(); sub_8094C14();
sub_8099690(0); sub_8099690(0);
sub_8035E10(); DrawMainMenu();
break; break;
case 6: case 6:
case 7: case 7:
@ -242,7 +242,7 @@ void CleanUpMenu(void)
if (gUnknown_203B348->unk8 != gUnknown_203B348->unk4) { if (gUnknown_203B348->unk8 != gUnknown_203B348->unk4) {
switch(gUnknown_203B348->unk8) { switch(gUnknown_203B348->unk8) {
case 1: case 1:
sub_8035EC0(); CleanMainMenu();
break; break;
case 6: case 6:
case 7: case 7:

View File

@ -1,21 +1,15 @@
#include "global.h" #include "global.h"
#include "constants/emotions.h"
#include "constants/species.h" #include "constants/species.h"
#include "personality_test.h"
#include "pokemon.h" #include "pokemon.h"
#define NUM_PARTNERS 10 extern void sub_80073E0(u32);
extern void sub_80073B8(u32);
extern void sub_8008C54(u32);
extern void sub_800836C(u32, u8 *r0, u32);
extern void SetBGPaletteBufferColorArray(s32 index, u8 *colorArray);
// TODO convert this... maybe a script?
const u8 gUnknown_80F4244[32] =
{
0, 0, 0, 0,
5, 0, 0, 0,
0xC, 0, 6, 0,
5, 0, 5, 0,
5, 0, 0, 0,
0, 0, 0, 0,
'p', 'k', 's', 'd', 'i', 'r', '0', 0
};
const s16 gPartners[NUM_PARTNERS] = const s16 gPartners[NUM_PARTNERS] =
{ {
@ -35,14 +29,34 @@ extern u8 gUnknown_80F42D0[];
extern u8 gUnknown_80F42F0[]; extern u8 gUnknown_80F42F0[];
extern u8 gUnknown_203B408; extern u8 gUnknown_203B408;
struct unkStruct_203B404 // Definitely wrong but need to figure out better structure later
struct FaceData
{ {
// Size: 0xB8 /* 0x0 */ u8 *unk0[5];
/* 0x0 */ s16 StarterID;
/* 0x2 */ s16 PartnerArray[NUM_PARTNERS];
}; };
extern struct unkStruct_203B404 *gUnknown_203B404; void PersonalityTest_DisplayPartnerSprite(void)
{
s32 partnerID;
struct OpenedFile *faceFile;
int palleteIndex;
u8 *r6;
u32 faceIndex;
partnerID = gUnknown_203B404->PartnerArray[gUnknown_203B404->currPartnerSelection];
sub_8008C54(1);
sub_80073B8(1);
faceFile = GetDialogueSpriteDataPtr(partnerID);
r6 = ((struct FaceData *)(faceFile->data))->unk0[1 + EMOTION_NORMAL];
faceIndex = EMOTION_NORMAL;
for(palleteIndex = 0; palleteIndex < 16; palleteIndex++){
SetBGPaletteBufferColorArray(palleteIndex + 224,&((struct FaceData *)(faceFile->data))->unk0[faceIndex][palleteIndex << 2]);
}
sub_800836C(1,r6,0xe);
CloseFile(faceFile);
sub_80073E0(1);
gUnknown_203B404->unk16 = 1;
}
s32 GetValidPartners(void) s32 GetValidPartners(void)
{ {
@ -88,5 +102,3 @@ u8 sub_803D100(u8 r0)
{ {
return gUnknown_80F42D0[r0]; return gUnknown_80F42D0[r0];
} }

View File

@ -1,54 +1,114 @@
#include "global.h" #include "global.h"
#include "personality_test.h"
#include "constants/emotions.h"
#include "random.h"
#include "file_system.h"
#include "pokemon.h"
#include "input.h"
#define NUM_PERSONALITIES 13
#define NUM_QUIZ_QUESTIONS 55
struct PersonalityStruct_203B400
{
u32 unk0;
u32 unk4;
u8 padding[0x34 - 8];
/* 0x34 */ u32 TestState;
/* 0x38 */ u32 QuestionCounter;
/* 0x3C */ u32 currQuestionIndex;
u8 unk40;
u8 padding2[3];
/* 0x44 */ u32 NatureTotals[13];
/* 0x78 */ u8 QuestionTracker[NUM_QUIZ_QUESTIONS];
u32 unkb0;
u32 unkb4;
u32 unkb8;
u32 unkbc;
};
extern struct PersonalityStruct_203B400 *gUnknown_203B400;
extern void* MemoryAlloc(u32, u32); extern void* MemoryAlloc(u32, u32);
extern void MemoryFree(void *); extern void MemoryFree(void *);
extern void sub_801317C(u32 *); extern void sub_801317C(u32 *);
extern void sub_8099690(u32); extern void sub_8099690(u32);
extern void sub_8001024(u32 *); extern void sub_8001024(u32 *);
extern s32 Random(void);
extern s32 sub_8094E4C(void); extern s32 sub_8094E4C(void);
extern void sub_8011C40(s32); extern void sub_8011C40(s32);
extern void sub_8094D28(s32); extern void sub_8094D28(s32);
extern void sub_8001044(u32 *); extern void sub_8001044(u32 *);
extern void sub_803C870(void);
extern void sub_803C908(void);
extern void sub_803C920(void); struct UnkSaveStruct1
extern void sub_803C98C(void); {
extern void sub_803C9D8(void); /* 0x0 */ u32 unk0;
extern void sub_803CA54(void); /* 0x4 */ u32 unk4;
extern void sub_803CA8C(void); /* 0x8 */ u16 unk8;
extern void sub_803CAAC(void); /* 0xA */ u8 unkA;
extern void sub_803CAD4(void); /* 0xB */ u8 playerGender;
extern void sub_803CAF4(void); };
extern void sub_803CB14(void); extern struct UnkSaveStruct1 *gUnknown_203B46C;
extern void sub_803CB5C(void);
extern void sub_803CB7C(void); // The frick... This is definitely wrong in terms of members
extern void sub_803CBB0(void); // There's 5 pointers in the data
extern void sub_803CBE4(void); struct FaceData
void InitializeTestStats(void); {
/* 0x0 */ u8 *unk0[5];
};
struct stack_PartnerSprite
{
// size: 0x60
u32 unk0;
u8 padding[0x18 - 4];
struct unkData data;
u32 padding2[12];
};
extern void sub_80141B4(const char *text, u32 r1, u32 r2, u16 r3);
extern void sub_8014248(const char *text, u32, u32, u32 *r0, u32, u32, u32, u32, u32);
extern u32 sub_80144A4(s32 *);
extern void sub_803CE6C(void);
extern u32 sub_808D994(u32);
extern void sub_80922F4(s32 *r0, u32);
extern void sub_801602C(u32, s32 *r0);
extern u32 sub_8016080(void);
extern void sub_80160D8(void);
extern void sub_8099690(u32);
extern void sub_808D8BC(u32 *r0, u32);
extern void sub_8006518(void *);
extern void sub_800641C(void *, u32, u32);
extern void sub_80073E0(u32);
extern void sub_80073B8(u32);
extern void sub_8008C54(u32);
extern void sub_800836C(u32, u8 *r0, u32);
extern void SetBGPaletteBufferColorArray(s32 index, u8 *colorArray);
extern void sub_803CEAC(void);
extern void RedrawPartnerSelectionMenu(void);
extern void sub_8013818(u32 *r0, s32, u32, u32);
extern u32 GetKeyPress(struct UnkInputStruct **r0);
extern u8 sub_80138B8(struct UnkInputStruct **r0, u32);
extern void sub_80119D4(u32);
extern void sub_8013984(struct UnkInputStruct **r0);
extern void AddMenuCursorSprite(struct UnkInputStruct **r0);
extern const char gStarterReveal;
extern const char gPartnerPrompt;
extern const char gPartnerNickPrompt;
extern const char gEndIntroText;
extern const char gGenderText;
extern u32 gGenderMenu;
extern u8 gNatureQuestionTable[NUM_QUIZ_QUESTIONS];
extern const char *gPersonalityTypeDescriptionTable[];
extern u32 gUnknown_202DF98;
struct unkData gUnknown_80F4244 =
{
0, 0, 0, 0,
5, 0, 0, 0,
0xC, 0, 6, 0,
5, 0, 5, 0,
5, 0, 0, 0,
0, 0, 0, 0,
};
const u8 filler[8] =
{
'p', 'k', 's', 'd', 'i', 'r', '0', 0
};
extern struct unkData gUnknown_80F4278;
u8 CreateTestTracker(void) u8 CreateTestTracker(void)
{ {
@ -64,7 +124,7 @@ void InitializeTestStats(void)
s32 counter; s32 counter;
sub_8001024(&gUnknown_203B400->unk4); sub_8001024(&gUnknown_203B400->unk4);
gUnknown_203B400->unk0 = 0; gUnknown_203B400->FrameCounter = 0;
gUnknown_203B400->TestState = 0; gUnknown_203B400->TestState = 0;
gUnknown_203B400->QuestionCounter = 0; gUnknown_203B400->QuestionCounter = 0;
for(counter = 0; counter < NUM_PERSONALITIES; counter++){ for(counter = 0; counter < NUM_PERSONALITIES; counter++){
@ -74,52 +134,51 @@ void InitializeTestStats(void)
for(counter = 0; counter < NUM_QUIZ_QUESTIONS; counter++){ for(counter = 0; counter < NUM_QUIZ_QUESTIONS; counter++){
gUnknown_203B400->QuestionTracker[counter] = 0; gUnknown_203B400->QuestionTracker[counter] = 0;
} }
gUnknown_203B400->unk40 = 0; gUnknown_203B400->playerNature = 0;
gUnknown_203B400->unkb0 = 0; gUnknown_203B400->playerGender = 0;
} }
#ifdef NONMATCHING
u8 HandleTestTrackerState(void) u8 HandleTestTrackerState(void)
{ {
s32 counter; s32 counter;
s32 iVar1; s32 iVar1;
gUnknown_203B400->unk0++; gUnknown_203B400->FrameCounter++;
switch(gUnknown_203B400->TestState) switch(gUnknown_203B400->TestState)
{ {
case 0: case 0:
sub_803C870(); GenerateNewQuestionOrGender();
break; break;
case 1: case 1:
sub_803C908(); CallPromptNewQuestion();
break; break;
case 2: case 2:
sub_803C920(); UpdateNatureTotals();
break; break;
case 3: case 3:
sub_803C98C(); SetPlayerGender();
break; break;
case 4: case 4:
sub_803C9D8(); RevealPersonality();
break; break;
case 5: case 5:
sub_803CA54(); RevealStarter();
break; break;
case 6: case 6:
sub_803CA8C(); sub_803CA8C();
break; break;
case 7: case 7:
sub_803CAAC(); PromptPickPartner();
break; break;
case 8: case 8:
sub_803CAD4(); sub_803CAD4();
break; break;
case 9: case 9:
sub_803CAF4(); CallCreatePartnerSelectionMenu();
break; break;
case 10: case 10:
sub_803CB14(); PromptForPartnerNickname();
break; break;
case 11: case 11:
sub_803CB5C(); sub_803CB5C();
@ -128,18 +187,17 @@ u8 HandleTestTrackerState(void)
sub_803CB7C(); sub_803CB7C();
break; break;
case 13: case 13:
sub_803CBB0(); PrintEndIntroText();
break; break;
case 14: case 14:
sub_803CBE4(); sub_803CBE4();
break; break;
case 15: case 15:
iVar1 = Random() * gUnknown_203B400->unk0; iVar1 = Random() * gUnknown_203B400->FrameCounter;
sub_8094D28(Random()); sub_8094D28(Random());
// TODO fix this math.. for(counter = 0; counter < NUM_PERSONALITIES; counter++){
for(counter = 0; counter < 13; counter++){ iVar1 *= (gUnknown_203B400->NatureTotals[counter] + counter + 3);
iVar1 *= (gUnknown_203B400->NatureTotals[counter] + 3);
} }
iVar1 += sub_8094E4C(); iVar1 += sub_8094E4C();
@ -154,146 +212,572 @@ u8 HandleTestTrackerState(void)
return 0; return 0;
} }
#else
NAKED
u8 HandleTestTrackerState(void)
{
asm_unified(
"\tpush {r4,r5,lr}\n"
"\tldr r0, _0803C750\n"
"\tldr r1, [r0]\n"
"\tldr r0, [r1]\n"
"\tadds r0, 0x1\n"
"\tstr r0, [r1]\n"
"\tldr r0, [r1, 0x34]\n"
"\tcmp r0, 0xF\n"
"\tbls _0803C744\n"
"\tb _0803C848\n"
"_0803C744:\n"
"\tlsls r0, 2\n"
"\tldr r1, _0803C754\n"
"\tadds r0, r1\n"
"\tldr r0, [r0]\n"
"\tmov pc, r0\n"
"\t.align 2, 0\n"
"_0803C750: .4byte gUnknown_203B400\n"
"_0803C754: .4byte _0803C758\n"
"\t.align 2, 0\n"
"_0803C758:\n"
"\t.4byte _0803C798\n"
"\t.4byte _0803C79E\n"
"\t.4byte _0803C7A4\n"
"\t.4byte _0803C7AA\n"
"\t.4byte _0803C7B0\n"
"\t.4byte _0803C7B6\n"
"\t.4byte _0803C7BC\n"
"\t.4byte _0803C7C2\n"
"\t.4byte _0803C7C8\n"
"\t.4byte _0803C7CE\n"
"\t.4byte _0803C7D4\n"
"\t.4byte _0803C7DA\n"
"\t.4byte _0803C7E0\n"
"\t.4byte _0803C7E6\n"
"\t.4byte _0803C7EC\n"
"\t.4byte _0803C7F2\n"
"_0803C798:\n"
"\tbl sub_803C870\n"
"\tb _0803C848\n"
"_0803C79E:\n"
"\tbl sub_803C908\n"
"\tb _0803C848\n"
"_0803C7A4:\n"
"\tbl sub_803C920\n"
"\tb _0803C848\n"
"_0803C7AA:\n"
"\tbl sub_803C98C\n"
"\tb _0803C848\n"
"_0803C7B0:\n"
"\tbl sub_803C9D8\n"
"\tb _0803C848\n"
"_0803C7B6:\n"
"\tbl sub_803CA54\n"
"\tb _0803C848\n"
"_0803C7BC:\n"
"\tbl sub_803CA8C\n"
"\tb _0803C848\n"
"_0803C7C2:\n"
"\tbl sub_803CAAC\n"
"\tb _0803C848\n"
"_0803C7C8:\n"
"\tbl sub_803CAD4\n"
"\tb _0803C848\n"
"_0803C7CE:\n"
"\tbl sub_803CAF4\n"
"\tb _0803C848\n"
"_0803C7D4:\n"
"\tbl sub_803CB14\n"
"\tb _0803C848\n"
"_0803C7DA:\n"
"\tbl sub_803CB5C\n"
"\tb _0803C848\n"
"_0803C7E0:\n"
"\tbl sub_803CB7C\n"
"\tb _0803C848\n"
"_0803C7E6:\n"
"\tbl sub_803CBB0\n"
"\tb _0803C848\n"
"_0803C7EC:\n"
"\tbl sub_803CBE4\n"
"\tb _0803C848\n"
"_0803C7F2:\n"
"\tbl Random\n"
"\tldr r4, _0803C844\n"
"\tldr r1, [r4]\n"
"\tldr r1, [r1]\n"
"\tadds r5, r0, 0\n"
"\tmuls r5, r1\n"
"\tbl Random\n"
"\tbl sub_8094D28\n"
"\tmovs r1, 0\n"
"\tldr r0, [r4]\n"
"\tadds r2, r0, 0\n"
"\tadds r2, 0x44\n"
"_0803C810:\n"
"\tldm r2!, {r0}\n"
"\tadds r0, r1\n"
"\tadds r0, 0x3\n"
"\tmuls r5, r0\n"
"\tadds r1, 0x1\n"
"\tcmp r1, 0xC\n"
"\tble _0803C810\n"
"\tbl sub_8094E4C\n"
"\tadds r5, r0\n"
"\tmovs r0, 0x1\n"
"\tnegs r0, r0\n"
"\tcmp r5, r0\n"
"\tbne _0803C838\n"
"\tadds r4, r5, 0\n"
"_0803C82E:\n"
"\tbl sub_8094E4C\n"
"\tadds r5, r0\n"
"\tcmp r5, r4\n"
"\tbeq _0803C82E\n"
"_0803C838:\n"
"\tadds r0, r5, 0\n"
"\tbl sub_8011C40\n"
"\tmovs r0, 0x3\n"
"\tb _0803C84A\n"
"\t.align 2, 0\n"
"_0803C844: .4byte gUnknown_203B400\n"
"_0803C848:\n"
"\tmovs r0, 0\n"
"_0803C84A:\n"
"\tpop {r4,r5}\n"
"\tpop {r1}\n"
"\tbx r1");
#endif
}
void DeleteTestTracker(void) void DeleteTestTracker(void)
{ {
sub_8001044(&gUnknown_203B400->unk4); sub_8001044(&gUnknown_203B400->unk4);
MemoryFree(gUnknown_203B400); MemoryFree(gUnknown_203B400);
gUnknown_203B400 = NULL; gUnknown_203B400 = NULL;
} }
void GenerateNewQuestionOrGender(void)
{
u8 category;
int counter;
int newQuestion;
gUnknown_203B400->QuestionCounter++;
if (gUnknown_203B400->QuestionCounter > MAX_ASKED_QUESTIONS) {
// We've asked enough questions
sub_8014248(&gGenderText, 0, 0, &gGenderMenu, 0, 3, 0, 0, 257);
gUnknown_203B400->TestState = 3;
}
else
{
do {
// Generate new question number and make sure we haven't done it
newQuestion = RandomCapped(NUM_QUIZ_QUESTIONS);
gUnknown_203B400->currQuestionIndex = newQuestion;
} while (gUnknown_203B400->QuestionTracker[newQuestion] == 1);
// Found one so let's get the category
category = gNatureQuestionTable[gUnknown_203B400->currQuestionIndex];
// Mark all of the questions in the category as used
for(counter = 0; counter < NUM_QUIZ_QUESTIONS; counter++){
if (gNatureQuestionTable[counter] == category)
gUnknown_203B400->QuestionTracker[counter] = 1;
}
gUnknown_203B400->TestState = 1;
}
}
void CallPromptNewQuestion(void)
{
PromptNewQuestion();
gUnknown_203B400->TestState = 2;
}
NAKED
void UpdateNatureTotals(void)
{
asm_unified(
"\tpush {r4-r6,lr}\n"
"\tsub sp, 0x4\n"
"\tmov r0, sp\n"
"\tbl sub_80144A4\n"
"\tcmp r0, 0\n"
"\tbne _0803C97C\n"
"\tldr r3, [sp]\n"
"\tcmp r3, 0x63\n"
"\tbne _0803C944\n"
"\tldr r0, _0803C940\n"
"\tldr r1, [r0]\n"
"\tmovs r0, 0x37\n"
"\tstr r0, [r1, 0x3C]\n"
"\tmovs r0, 0x1\n"
"\tb _0803C97A\n"
"\t.align 2, 0\n"
"_0803C940: .4byte gUnknown_203B400\n"
"_0803C944:\n"
"\tldr r1, _0803C984\n"
"\tldr r2, _0803C988\n"
"\tldr r0, [r2]\n"
"\tldr r0, [r0, 0x3C]\n"
"\tlsls r0, 2\n"
"\tadds r0, r1\n"
"\tldr r0, [r0]\n"
"\tldr r4, [r0, 0x8]\n"
"\tlsls r0, r3, 4\n"
"\tadds r4, r0\n"
"\tmovs r3, 0\n"
"\tadds r6, r2, 0\n"
"\tadds r5, r6, 0\n"
"_0803C95E:\n"
"\tldr r1, [r5]\n"
"\tlsls r0, r3, 2\n"
"\tadds r1, 0x44\n"
"\tadds r1, r0\n"
"\tadds r0, r4, r3\n"
"\tldrb r2, [r0]\n"
"\tldr r0, [r1]\n"
"\tadds r0, r2\n"
"\tstr r0, [r1]\n"
"\tadds r3, 0x1\n"
"\tcmp r3, 0xC\n"
"\tble _0803C95E\n"
"\tldr r1, [r6]\n"
"\tmovs r0, 0\n"
"_0803C97A:\n"
"\tstr r0, [r1, 0x34]\n"
"_0803C97C:\n"
"\tadd sp, 0x4\n"
"\tpop {r4-r6}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
"_0803C984: .4byte gPersonalityQuestionPointerTable\n"
"_0803C988: .4byte gUnknown_203B400"
);
}
void SetPlayerGender(void)
{
int gender;
if (sub_80144A4(&gender) == 0) {
if (gender == MALE) {
gUnknown_203B400->playerGender = MALE;
gUnknown_203B46C->playerGender = MALE;
}
else
{
gUnknown_203B400->playerGender = FEMALE;
gUnknown_203B46C->playerGender = FEMALE;
}
sub_8099690(0);
gUnknown_203B400->TestState = 4;
}
}
#ifdef NONMATCHING
void RevealPersonality(void)
{
s32 currentNature;
s32 counter;
gUnknown_203B400->playerNature = RandomCapped(NUM_PERSONALITIES);
currentNature = gUnknown_203B400->playerNature;
// 2 Statements flip-flop but is functionaly equivalent
// Struct saving into register and intialize of the counter
for(counter = NUM_PERSONALITIES - 2; counter >= 0; counter--){
currentNature = currentNature++;
// Wraparound check
if (currentNature > NUM_PERSONALITIES - 1) {
currentNature = 0;
}
if (gUnknown_203B400->NatureTotals[currentNature] > gUnknown_203B400->NatureTotals[gUnknown_203B400->playerNature]) {
gUnknown_203B400->playerNature = currentNature;
}
}
gUnknown_203B400->StarterID = gStarters[gUnknown_203B400->playerNature][gUnknown_203B400->playerGender];
PrintPersonalityTypeDescription();
gUnknown_203B400->TestState = 5;
}
#else
NAKED
void RevealPersonality(void)
{
asm_unified("\tpush {r4-r7,lr}\n"
"\tmovs r0, 0xD\n"
"\tbl RandomCapped\n"
"\tldr r2, _0803CA4C\n"
"\tldr r1, [r2]\n"
"\tadds r1, 0x40\n"
"\tstrb r0, [r1]\n"
"\tldr r0, [r2]\n"
"\tadds r0, 0x40\n"
"\tldrb r3, [r0]\n"
"\tadds r7, r2, 0\n"
"\tmovs r5, 0xB\n"
"_0803C9F2:\n"
"\tadds r3, 0x1\n"
"\tcmp r3, 0xC\n"
"\tble _0803C9FA\n"
"\tmovs r3, 0\n"
"_0803C9FA:\n"
"\tldr r0, [r7]\n"
"\tlsls r2, r3, 2\n"
"\tadds r1, r0, 0\n"
"\tadds r1, 0x44\n"
"\tadds r2, r1, r2\n"
"\tadds r4, r0, 0\n"
"\tadds r4, 0x40\n"
"\tldrb r0, [r4]\n"
"\tlsls r0, 2\n"
"\tadds r1, r0\n"
"\tldr r2, [r2]\n"
"\tldr r0, [r1]\n"
"\tldr r6, _0803CA4C\n"
"\tcmp r2, r0\n"
"\tble _0803CA1A\n"
"\tstrb r3, [r4]\n"
"_0803CA1A:\n"
"\tsubs r5, 0x1\n"
"\tcmp r5, 0\n"
"\tbge _0803C9F2\n"
"\tldr r3, [r6]\n"
"\tldr r2, _0803CA50\n"
"\tadds r0, r3, 0\n"
"\tadds r0, 0xB0\n"
"\tldr r1, [r0]\n"
"\tlsls r1, 1\n"
"\tsubs r0, 0x70\n"
"\tldrb r0, [r0]\n"
"\tlsls r0, 2\n"
"\tadds r1, r0\n"
"\tadds r1, r2\n"
"\tldrh r0, [r1]\n"
"\tstrh r0, [r3, 0x8]\n"
"\tbl PrintPersonalityTypeDescription\n"
"\tldr r1, [r6]\n"
"\tmovs r0, 0x5\n"
"\tstr r0, [r1, 0x34]\n"
"\tpop {r4-r7}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
"_0803CA4C: .4byte gUnknown_203B400\n"
"_0803CA50: .4byte gStarters");
}
#endif
void RevealStarter(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0) {
sub_80141B4(&gStarterReveal,0,0,0x101);
PersonalityTest_DisplayStarterSprite();
gUnknown_203B400->TestState = 6;
}
}
void sub_803CA8C(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0) {
gUnknown_203B400->TestState = 7;
}
}
void PromptPickPartner(void)
{
sub_80141B4(&gPartnerPrompt, 0, 0, 0x301);
gUnknown_203B400->TestState = 8;
}
void sub_803CAD4(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0) {
gUnknown_203B400->TestState = 9;
}
}
void CallCreatePartnerSelectionMenu(void)
{
CreatePartnerSelectionMenu(gUnknown_203B400->StarterID);
gUnknown_203B400->TestState = 10;
}
void PromptForPartnerNickname(void)
{
u16 selectedPartner;
selectedPartner = HandlePartnerSelectionInput();
if (selectedPartner != 0xffff)
{
if(selectedPartner != 0xfffe) {
sub_803CE6C();
gUnknown_203B400->PartnerID = selectedPartner;
sub_80141B4(&gPartnerNickPrompt, 0, 0, 0x301);
gUnknown_203B400->TestState = 11;
}
}
}
void sub_803CB5C(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0) {
gUnknown_203B400->TestState = 12;
}
}
void sub_803CB7C(void)
{
u32 uVar1;
s32 *iVar2;
iVar2 = &gUnknown_203B400->unk20;
uVar1 = sub_808D994(gUnknown_203B400->PartnerID);
sub_80922F4(iVar2,uVar1);
sub_801602C(3, &gUnknown_203B400->unk20);
gUnknown_203B400->TestState = 13;
}
void PrintEndIntroText(void)
{
if (sub_8016080() != 0) {
sub_80160D8();
sub_80141B4(&gEndIntroText, 0, 0, 0x301);
gUnknown_203B400->TestState = 14;
}
}
void sub_803CBE4(void)
{
s32 temp;
if (sub_80144A4(&temp) == 0) {
gUnknown_203B400->TestState = 15;
}
}
NAKED
void PromptNewQuestion(void)
{
asm_unified(
"\tpush {lr}\n"
"\tsub sp, 0x14\n"
"\tldr r1, _0803CC38\n"
"\tldr r0, _0803CC3C\n"
"\tldr r0, [r0]\n"
"\tldr r0, [r0, 0x3C]\n"
"\tlsls r0, 2\n"
"\tadds r0, r1\n"
"\tldr r1, [r0]\n"
"\tldr r0, [r1]\n"
"\tldr r3, [r1, 0x4]\n"
"\tmovs r2, 0\n"
"\tstr r2, [sp]\n"
"\tmovs r1, 0x3\n"
"\tstr r1, [sp, 0x4]\n"
"\tstr r2, [sp, 0x8]\n"
"\tstr r2, [sp, 0xC]\n"
"\tadds r1, 0xFE\n"
"\tstr r1, [sp, 0x10]\n"
"\tmovs r1, 0\n"
"\tbl sub_8014248\n"
"\tadd sp, 0x14\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
"_0803CC38: .4byte gPersonalityQuestionPointerTable\n"
"_0803CC3C: .4byte gUnknown_203B400"
);
}
void PrintPersonalityTypeDescription(void)
{
sub_808D8BC(&gUnknown_202DF98,gUnknown_203B400->StarterID);
sub_80141B4(gPersonalityTypeDescriptionTable[gUnknown_203B400->playerNature],0,
0,0x101);
}
void PersonalityTest_DisplayStarterSprite(void)
{
s32 starterID;
struct OpenedFile *faceFile;
int palleteIndex;
u8 *r6;
u32 faceIndex;
struct stack_PartnerSprite stackArray;
starterID = gUnknown_203B400->StarterID;
sub_8006518(&stackArray);
stackArray.data = gUnknown_80F4244;
ResetUnusedInputStruct();
sub_800641C(&stackArray, 1, 0);
sub_8008C54(1);
sub_80073B8(1);
faceFile = GetDialogueSpriteDataPtr(starterID);
r6 = ((struct FaceData *)(faceFile->data))->unk0[1 + EMOTION_HAPPY];
faceIndex = EMOTION_HAPPY;
for(palleteIndex = 0; palleteIndex < 16; palleteIndex++){
SetBGPaletteBufferColorArray(palleteIndex + 224, &((struct FaceData *)(faceFile->data))->unk0[faceIndex][palleteIndex << 2]);
}
sub_800836C(1, r6, 0xe);
CloseFile(faceFile);
sub_80073E0(1);
}
#ifdef NONMATCHING
void CreatePartnerSelectionMenu(s16 starterID)
{
s32 starterID_s32;
starterID_s32 = starterID; // force an asr shift.. does lsr without it
sub_803CEAC(); // creates 203B404
gUnknown_203B404->StarterID = starterID_s32;
gUnknown_203B404->unk4C = 0;
gUnknown_203B404->unk50 = &gUnknown_203B404->unk54;
gUnknown_203B404->unk54[0] = gUnknown_80F4290;
gUnknown_203B404->unk54[1] = gUnknown_80F42A8;
gUnknown_203B404->unk54[2] = gUnknown_80F4278;
gUnknown_203B404->unk54[3] = gUnknown_80F4278;
// TODO this is the problem area
//gUnknown_203B404->unk50[5] = (u32 *) &gUnknown_203B404->sub; // so weird but think they store the substruct
gUnknown_203B404->sub.unkb4 = 1;
gUnknown_203B404->sub.unkb5 = 0;
gUnknown_203B404->sub.unkb6 = 6;
gUnknown_203B404->sub.unkb7 = 0;
ResetUnusedInputStruct();
sub_800641C(gUnknown_203B404->unk54, 1, 1);
sub_8013818(&gUnknown_203B404->unk18, GetValidPartners(), 0xA, gUnknown_203B404->unk4C);
RedrawPartnerSelectionMenu();
PersonalityTest_DisplayPartnerSprite();
}
#else
NAKED
void CreatePartnerSelectionMenu(s16 starterID)
{
asm_unified("\tpush {r4-r7,lr}\n"
"\tadds r4, r0, 0\n"
"\tlsls r4, 16\n"
"\tasrs r4, 16\n"
"\tbl sub_803CEAC\n"
"\tldr r5, _0803CDB0\n"
"\tldr r0, [r5]\n"
"\tmovs r3, 0\n"
"\tmovs r1, 0\n"
"\tstrh r4, [r0]\n"
"\tstr r1, [r0, 0x4C]\n"
"\tadds r1, r0, 0\n"
"\tadds r1, 0x54\n"
"\tstr r1, [r0, 0x50]\n"
"\tldr r0, _0803CDB4\n"
"\tldm r0!, {r2,r4,r6}\n"
"\tstm r1!, {r2,r4,r6}\n"
"\tldm r0!, {r2,r4,r7}\n"
"\tstm r1!, {r2,r4,r7}\n"
"\tldr r1, [r5]\n"
"\tadds r1, 0x6C\n"
"\tldr r0, _0803CDB8\n"
"\tldm r0!, {r2,r6,r7}\n"
"\tstm r1!, {r2,r6,r7}\n"
"\tldm r0!, {r4,r6,r7}\n"
"\tstm r1!, {r4,r6,r7}\n"
"\tldr r1, [r5]\n"
"\tldr r2, _0803CDBC\n"
"\tadds r1, 0x84\n"
"\tadds r0, r2, 0\n"
"\tldm r0!, {r4,r6,r7}\n"
"\tstm r1!, {r4,r6,r7}\n"
"\tldm r0!, {r4,r6,r7}\n"
"\tstm r1!, {r4,r6,r7}\n"
"\tldr r0, [r5]\n"
"\tadds r0, 0x9C\n"
"\tldm r2!, {r1,r4,r6}\n"
"\tstm r0!, {r1,r4,r6}\n"
"\tldm r2!, {r1,r4,r7}\n"
"\tstm r0!, {r1,r4,r7}\n"
"\tldr r0, [r5]\n"
"\tldr r1, [r0, 0x50]\n"
"\tadds r0, 0xB4\n"
"\tstr r0, [r1, 0x14]\n"
"\tmovs r1, 0x1\n"
"\tstrb r1, [r0]\n"
"\tldr r0, [r5]\n"
"\tadds r0, 0xB5\n"
"\tstrb r3, [r0]\n"
"\tldr r0, [r5]\n"
"\tadds r0, 0xB6\n"
"\tmovs r1, 0x6\n"
"\tstrb r1, [r0]\n"
"\tldr r0, [r5]\n"
"\tadds r0, 0xB7\n"
"\tstrb r3, [r0]\n"
"\tbl ResetUnusedInputStruct\n"
"\tldr r0, [r5]\n"
"\tadds r0, 0x54\n"
"\tmovs r1, 0x1\n"
"\tmovs r2, 0x1\n"
"\tbl sub_800641C\n"
"\tldr r4, [r5]\n"
"\tadds r4, 0x18\n"
"\tbl GetValidPartners\n"
"\tadds r1, r0, 0\n"
"\tldr r0, [r5]\n"
"\tldr r3, [r0, 0x4C]\n"
"\tadds r0, r4, 0\n"
"\tmovs r2, 0xA\n"
"\tbl sub_8013818\n"
"\tbl RedrawPartnerSelectionMenu\n"
"\tbl PersonalityTest_DisplayPartnerSprite\n"
"\tpop {r4-r7}\n"
"\tpop {r0}\n"
"\tbx r0\n"
"\t.align 2, 0\n"
"_0803CDB0: .4byte gUnknown_203B404\n"
"_0803CDB4: .4byte gUnknown_80F4290\n"
"_0803CDB8: .4byte gUnknown_80F42A8\n"
"_0803CDBC: .4byte gUnknown_80F4278");
}
#endif
u16 HandlePartnerSelectionInput(void)
{
s32 sVar1;
sVar1 = gUnknown_203B404->currPartnerSelection;
gUnknown_203B404->unk16 = 0;
if (GetKeyPress(&gUnknown_203B404->unk18) == A_BUTTON) {
sub_80119D4(0);
return gUnknown_203B404->PartnerArray[gUnknown_203B404->currPartnerSelection];
}
else {
if (sub_80138B8(&gUnknown_203B404->unk18, 1) != '\0') {
RedrawPartnerSelectionMenu();
}
if (sVar1 != gUnknown_203B404->currPartnerSelection) {
PersonalityTest_DisplayPartnerSprite();
}
if (gUnknown_203B404->unk16 != '\0') {
return 0xfffe;
}
else {
return 0xffff;
}
}
}
void sub_803CE34(u8 param_1)
{
gUnknown_203B404->numPartners = GetValidPartners();
sub_8013984(&gUnknown_203B404->unk18);
RedrawPartnerSelectionMenu();
PersonalityTest_DisplayPartnerSprite();
if (param_1 != 0) {
AddMenuCursorSprite(&gUnknown_203B404->unk18);
}
}
void sub_803CE6C()
{
gUnknown_203B404->unk54[gUnknown_203B404->unk4C] = gUnknown_80F4278;
ResetUnusedInputStruct();
sub_800641C(gUnknown_203B404->unk54, 1, 1);
sub_803CECC(); // Free 203B404
}
void sub_803CEAC(void)
{
gUnknown_203B404 = MemoryAlloc(sizeof(struct PersonalityStruct_203B404), 8);
nullsub_135();
}
void nullsub_135(void)
{
}
void sub_803CECC(void)
{
if(gUnknown_203B404 != NULL){
nullsub_135();
MemoryFree(gUnknown_203B404);
gUnknown_203B404 = NULL;
}
}

View File

@ -8,7 +8,7 @@ extern struct FileArchive gSystemFileArchive;
extern const char gUnknown_81075F4; extern const char gUnknown_81075F4;
extern struct OpenedFile *gMonsterParametersFile; extern struct OpenedFile *gMonsterParametersFile;
extern u16 gLevelCurrentPokeId; extern u16 gLevelCurrentPokeId;
extern struct gPokemon gMonsterParameters; extern struct gPokemon *gMonsterParameters;
extern u64 gUnknown_8107544[]; extern u64 gUnknown_8107544[];
extern u32 gUnknown_810697C; extern u32 gUnknown_810697C;
@ -30,8 +30,7 @@ void LoadMonsterParameters(void)
{ {
gUnknown_203B45C = &gUnknown_202F400; gUnknown_203B45C = &gUnknown_202F400;
gMonsterParametersFile = OpenFileAndGetFileDataPtr(&gUnknown_81075F4, &gSystemFileArchive); gMonsterParametersFile = OpenFileAndGetFileDataPtr(&gUnknown_81075F4, &gSystemFileArchive);
// TODO verify this... other parts imply this is an array gMonsterParameters = (struct gPokemon *)gMonsterParametersFile->data;
gMonsterParameters.species = gMonsterParametersFile->data;
gLevelCurrentPokeId = 0; gLevelCurrentPokeId = 0;
} }