DisplayDungeonDialogue

This commit is contained in:
DizzyEggg 2024-10-20 12:31:25 +02:00
parent 2442708b15
commit c6b04f6213
4 changed files with 165 additions and 329 deletions

View File

@ -5,322 +5,6 @@
.text .text
thumb_func_start sub_80528F4
sub_80528F4:
push {r4,r5,lr}
adds r5, r0, 0
adds r4, r1, 0
movs r0, 0
movs r2, 0x1
bl PrintFieldMessage
adds r0, r5, 0
adds r1, r4, 0
bl sub_80522E8
pop {r4,r5}
pop {r0}
bx r0
thumb_func_end sub_80528F4
thumb_func_start DisplayDungeonDialogue
DisplayDungeonDialogue:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x14
adds r6, r0, 0
bl xxx_call_GetLeader
adds r4, r0, 0
bl GetPartnerEntity
adds r5, r0, 0
movs r0, 0
mov r9, r0
cmp r4, 0
beq _0805295C
ldr r4, [r4, 0x70]
ldr r2, _08052950
ldrb r1, [r4, 0xA]
movs r0, 0x64
muls r0, r1
ldr r1, _08052954
adds r0, r1
ldr r1, [r2]
adds r1, r0
ldr r0, _08052958
bl sub_808DA0C
movs r2, 0x4
ldrsh r7, [r4, r2]
b _08052966
.align 2, 0
_08052950: .4byte gRecruitedPokemonRef
_08052954: .4byte 0x00008df8
_08052958: .4byte gAvailablePokemonNames
_0805295C:
movs r7, 0
ldr r0, _08052988
ldr r1, _0805298C
bl strcpy
_08052966:
cmp r5, 0
beq _0805299C
ldr r4, [r5, 0x70]
ldr r2, _08052990
ldrb r1, [r4, 0xA]
movs r0, 0x64
muls r0, r1
ldr r1, _08052994
adds r0, r1
ldr r1, [r2]
adds r1, r0
ldr r0, _08052998
bl sub_808DA0C
movs r2, 0x4
ldrsh r4, [r4, r2]
b _080529A6
.align 2, 0
_08052988: .4byte gAvailablePokemonNames
_0805298C: .4byte gUnknown_80F7AF8
_08052990: .4byte gRecruitedPokemonRef
_08052994: .4byte 0x00008df8
_08052998: .4byte gUnknown_202DFE8
_0805299C:
movs r4, 0
ldr r0, _080529C0
ldr r1, _080529C4
bl strcpy
_080529A6:
movs r0, 0x4
ldrsh r1, [r6, r0]
movs r0, 0xD5
lsls r0, 1
cmp r1, r0
beq _080529F0
cmp r1, r0
bgt _080529C8
subs r0, 0x1
cmp r1, r0
beq _080529D4
b _08052A1C
.align 2, 0
_080529C0: .4byte gUnknown_202DFE8
_080529C4: .4byte gUnknown_80F7AF8
_080529C8:
ldr r0, _080529D0
cmp r1, r0
beq _08052A08
b _08052A1C
.align 2, 0
_080529D0: .4byte 0x000001ab
_080529D4:
adds r4, r7, 0
ldr r0, _080529E4
ldr r1, _080529E8
ldr r2, _080529EC
bl sprintfStatic
b _08052A28
.align 2, 0
_080529E4: .4byte gUnknown_202E5D8
_080529E8: .4byte gUnknown_80F7AFC
_080529EC: .4byte gAvailablePokemonNames
_080529F0:
ldr r0, _080529FC
ldr r1, _08052A00
ldr r2, _08052A04
bl sprintfStatic
b _08052A28
.align 2, 0
_080529FC: .4byte gUnknown_202E5D8
_08052A00: .4byte gUnknown_80F7AFC
_08052A04: .4byte gUnknown_202DFE8
_08052A08:
movs r4, 0
ldr r0, _08052A14
ldr r1, _08052A18
bl strcpy
b _08052A28
.align 2, 0
_08052A14: .4byte gUnknown_202E5D8
_08052A18: .4byte gUnknown_80F7B04
_08052A1C:
movs r1, 0x4
ldrsh r4, [r6, r1]
ldr r0, _08052A48
adds r1, r4, 0
bl CopyYellowMonsterNametoBuffer
_08052A28:
ldrh r0, [r6]
subs r0, 0x2
lsls r0, 16
lsrs r0, 16
cmp r0, 0x1
bhi _08052A3C
ldr r0, _08052A48
ldr r1, _08052A4C
bl strcpy
_08052A3C:
movs r2, 0x6
ldrsh r0, [r6, r2]
ldr r2, _08052A50
add r7, sp, 0x10
b _08052A8E
.align 2, 0
_08052A48: .4byte gUnknown_202E5D8
_08052A4C: .4byte gUnknown_80F7B04
_08052A50: .4byte gDungeon
_08052A54:
movs r0, 0x6
ldrsh r1, [r6, r0]
cmp r1, 0x1
bne _08052A78
cmp r4, 0x1
beq _08052A9E
cmp r4, 0x9B
beq _08052A9E
ldr r0, _08052B08
cmp r4, r0
beq _08052A9E
cmp r4, 0x19
beq _08052A9E
cmp r4, 0x4
beq _08052A9E
subs r0, 0x6
cmp r4, r0
beq _08052A9E
_08052A78:
movs r0, 0x8C
lsls r0, 1
cmp r1, r0
bne _08052A88
cmp r4, r1
beq _08052A9E
cmp r4, 0x98
beq _08052A9E
_08052A88:
adds r6, 0xC
movs r1, 0x6
ldrsh r0, [r6, r1]
_08052A8E:
cmp r0, 0
beq _08052A9E
cmp r0, 0x7
bne _08052A54
cmp r4, 0x7
beq _08052A9E
cmp r4, 0x9E
bne _08052A54
_08052A9E:
ldr r1, [r2]
ldr r2, _08052B0C
adds r0, r1, r2
ldrb r0, [r0]
cmp r0, 0
bne _08052B14
adds r2, 0x6
adds r0, r1, r2
ldrb r0, [r0]
mov r8, r0
cmp r0, 0
bne _08052B14
ldrh r0, [r6]
cmp r0, 0x4
beq _08052B14
ldrb r0, [r6, 0x2]
cmp r0, 0x80
beq _08052B14
cmp r4, 0
beq _08052B14
ldrb r0, [r6, 0x3]
bl sub_808CDB0
adds r5, r0, 0
mov r9, sp
adds r0, r4, 0
bl GetDialogueSpriteDataPtr
str r0, [sp]
cmp r0, 0
beq _08052B10
ldr r0, [r0, 0x4]
str r0, [sp, 0x4]
mov r1, r8
mov r0, r9
strb r1, [r0, 0xE]
ldrb r0, [r6, 0x2]
mov r2, r9
strb r0, [r2, 0xC]
ldrb r0, [r5, 0x4]
strb r0, [r2, 0xD]
ldrh r0, [r5]
strh r0, [r2, 0x8]
ldrh r0, [r5, 0x2]
strh r0, [r2, 0xA]
lsls r0, 16
asrs r0, 16
cmp r0, 0x1
bgt _08052B14
movs r0, 0x2
strh r0, [r2, 0xA]
b _08052B14
.align 2, 0
_08052B08: .4byte 0x0000011b
_08052B0C: .4byte 0x0001820a
_08052B10:
movs r0, 0
mov r9, r0
_08052B14:
movs r0, 0xA
bl sub_8052740
movs r0, 0x2
movs r1, 0
bl sub_803EAF0
movs r0, 0
bl sub_8052210
ldr r0, [r6, 0x8]
ldr r2, _08052B88
ldrh r1, [r6]
lsls r1, 1
adds r1, r2
ldrh r3, [r1]
movs r1, 0
mov r2, r9
bl xxx_info_box_80141B4
_08052B3C:
bl xxx_draw_string_80144C4
movs r0, 0x9
bl sub_803E46C
adds r0, r7, 0
bl sub_80144A4
cmp r0, 0
bne _08052B3C
mov r1, r9
cmp r1, 0
beq _08052B5C
ldr r0, [r1]
bl CloseFile
_08052B5C:
ldrh r0, [r6]
cmp r0, 0x1
beq _08052B72
cmp r0, 0x3
beq _08052B72
bl sub_8040238
movs r0, 0
movs r1, 0
bl sub_803EAF0
_08052B72:
movs r0, 0x8
movs r1, 0x9
bl sub_803E708
add sp, 0x14
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_08052B88: .4byte gUnknown_80F7AEA
thumb_func_end DisplayDungeonDialogue
thumb_func_start sub_8052B8C thumb_func_start sub_8052B8C
sub_8052B8C: sub_8052B8C:
push {r4-r7,lr} push {r4-r7,lr}

View File

@ -78,7 +78,7 @@ s16 GetPokemonEvolveConditons(s16 index, unkEvolve *);
u8 GetPokemonOverworldPalette(s16 index, u32 r1); u8 GetPokemonOverworldPalette(s16 index, u32 r1);
bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 spriteId); bool8 IsPokemonDialogueSpriteAvail(s16 index, s32 spriteId);
OpenedFile *OpenPokemonDialogueSpriteFile(s16 index); OpenedFile *OpenPokemonDialogueSpriteFile(s16 index);
OpenedFile *GetDialogueSpriteDataPtr(s16 index); OpenedFile *GetDialogueSpriteDataPtr(s32 index);
s32 GetUnownIndex(s16 index); s32 GetUnownIndex(s16 index);
void GenerateHiddenPower(HiddenPower *); void GenerateHiddenPower(HiddenPower *);
s32 GetEvolutionSequence(PokemonStruct1 *pokemon, EvolveStage *); s32 GetEvolutionSequence(PokemonStruct1 *pokemon, EvolveStage *);

View File

@ -10,6 +10,8 @@
#include "text2.h" #include "text2.h"
#include "pokemon.h" #include "pokemon.h"
#include "file_system.h" #include "file_system.h"
#include "dungeon_util_1.h"
#include "code_800D090.h"
void sub_80526D0(s32 r0); void sub_80526D0(s32 r0);
extern bool8 sub_8045888(Entity *r0); extern bool8 sub_8045888(Entity *r0);
@ -22,23 +24,23 @@ void sub_805229C(void)
return sub_80526D0(0x50); return sub_80526D0(0x50);
} }
void SendMessage(Entity *pokemon, const char message[]) void SendMessage(Entity *pokemon, const char *str)
{ {
if (sub_8045888(pokemon)){ if (sub_8045888(pokemon)){
sub_80523A8(pokemon, message, 1); sub_80523A8(pokemon, str, TRUE);
} }
} }
void sub_80522C8(Entity *r0, const char *str) void sub_80522C8(Entity *r0, const char *str)
{ {
if (sub_8045888(r0)){ if (sub_8045888(r0)){
sub_80523A8(r0, str, 0); sub_80523A8(r0, str, FALSE);
} }
} }
void sub_80522E8(Entity *r0, const char *str) void sub_80522E8(Entity *r0, const char *str)
{ {
sub_80523A8(r0, str, 0); sub_80523A8(r0, str, FALSE);
} }
void sub_80522F4(Entity *r0, Entity *r1, const char *str) void sub_80522F4(Entity *r0, Entity *r1, const char *str)
@ -51,7 +53,7 @@ void sub_80522F4(Entity *r0, Entity *r1, const char *str)
} }
if(flag) if(flag)
{ {
sub_80523A8(r0, str, 1); sub_80523A8(r0, str, TRUE);
} }
} }
@ -65,7 +67,7 @@ void sub_805232C(Entity *r0, Entity *r1, const char *str)
} }
if(flag) if(flag)
{ {
sub_80523A8(r0, str, 0); sub_80523A8(r0, str, FALSE);
} }
} }
@ -79,13 +81,13 @@ void sub_8052364(Entity *r0, Position *pos, const char *str)
} }
if(flag) if(flag)
{ {
sub_80523A8(r0, str, 1); sub_80523A8(r0, str, TRUE);
} }
} }
void sub_805239C(Entity *r0, const char *str) void sub_805239C(Entity *r0, const char *str)
{ {
sub_80523A8(r0, str, 1); sub_80523A8(r0, str, TRUE);
} }
void sub_8053210(u8 *txt, u32 a1, u32 a2); void sub_8053210(u8 *txt, u32 a1, u32 a2);
@ -328,3 +330,151 @@ void PrintFieldMessage(struct MonDialogueSpriteInfo *monSpriteInfo, const u8 *st
sub_803E708(8, 9); sub_803E708(8, 9);
} }
void sub_80528F4(Entity *a0, const u8 *str)
{
PrintFieldMessage(NULL, str, TRUE);
sub_80522E8(a0, str);
}
extern const u8 gUnknown_80F7AF8[];
extern const u8 gUnknown_80F7AFC[];
extern const u8 gUnknown_80F7B04[];
struct DungeonDialogueStruct
{
u16 unk0;
u8 unk2;
u8 unk3;
s16 unk4;
s16 unk6;
const u8 *str;
};
struct Struct_sub_808CDB0
{
Position pos;
bool8 flip;
};
extern const struct Struct_sub_808CDB0 *sub_808CDB0(s32 a0);
extern const u16 gUnknown_80F7AEA[];
extern u8 gAvailablePokemonNames[];
extern u8 gUnknown_202E5D8[];
extern u8 gUnknown_202DFE8[];
void DisplayDungeonDialogue(const struct DungeonDialogueStruct *dialogueInfo)
{
s32 unkPrintRet;
struct MonPortraitMsg monPortrait;
s32 unkSpVar;
s32 leaderId, partnerId, dialogueMonId;
Entity *leader = xxx_call_GetLeader();
Entity *partner = GetPartnerEntity();
struct MonPortraitMsg *monPortraitPtr = NULL;
if (leader != NULL) {
EntityInfo *leaderInfo = GetEntInfo(leader);
PokemonStruct2 *monStruct2 = &gRecruitedPokemonRef->pokemon2[leaderInfo->teamIndex];
sub_808DA0C(gAvailablePokemonNames, monStruct2);
leaderId = leaderInfo->apparentID;
}
else {
leaderId = MONSTER_NONE;
strcpy(gAvailablePokemonNames, gUnknown_80F7AF8); // ??
}
if (partner != NULL) {
EntityInfo *partnerInfo = GetEntInfo(partner);
PokemonStruct2 *monStruct2 = &gRecruitedPokemonRef->pokemon2[partnerInfo->teamIndex];
sub_808DA0C(gUnknown_202DFE8, monStruct2);
partnerId = partnerInfo->apparentID;
}
else {
partnerId = MONSTER_NONE;
strcpy(gUnknown_202DFE8, gUnknown_80F7AF8); // ??
}
switch (dialogueInfo->unk4) {
case 425:
dialogueMonId = leaderId;
sprintfStatic(gUnknown_202E5D8, gUnknown_80F7AFC, gAvailablePokemonNames);
break;
case 426:
dialogueMonId = partnerId;
sprintfStatic(gUnknown_202E5D8, gUnknown_80F7AFC, gUnknown_202DFE8);
break;
case 427:
dialogueMonId = MONSTER_NONE;
strcpy(gUnknown_202E5D8, gUnknown_80F7B04);
break;
default:
dialogueMonId = dialogueInfo->unk4;
CopyYellowMonsterNametoBuffer(gUnknown_202E5D8, dialogueMonId);
break;
}
if (dialogueInfo->unk0 == 2 || dialogueInfo->unk0 == 3) {
strcpy(gUnknown_202E5D8, gUnknown_80F7B04);
}
while (1) {
if (dialogueInfo->unk6 == 0)
break;
if (dialogueInfo->unk6 == 7 && (dialogueMonId == MONSTER_SQUIRTLE || dialogueMonId == MONSTER_TOTODILE))
break;
if (dialogueInfo->unk6 == 1 && (dialogueMonId == MONSTER_BULBASAUR || dialogueMonId == MONSTER_CYNDAQUIL || dialogueMonId == MONSTER_MUDKIP || dialogueMonId == MONSTER_PIKACHU || dialogueMonId == MONSTER_CHARMANDER || dialogueMonId == MONSTER_TREECKO))
break;
if (dialogueInfo->unk6 == 280 && (dialogueMonId == MONSTER_TORCHIC || dialogueMonId == MONSTER_CHIKORITA))
break;
dialogueInfo++;
}
if (!gDungeon->unk181e8.blinded
&& !gDungeon->unk181e8.hallucinating
&& dialogueInfo->unk0 != 4
&& dialogueInfo->unk2 != 0x80
&& dialogueMonId != MONSTER_NONE)
{
const struct Struct_sub_808CDB0 *strPtr = sub_808CDB0(dialogueInfo->unk3);
monPortraitPtr = &monPortrait;
monPortraitPtr->faceFile = GetDialogueSpriteDataPtr(dialogueMonId);
if (monPortraitPtr->faceFile != NULL) {
monPortraitPtr->faceData = monPortraitPtr->faceFile->data;
monPortraitPtr->unkE = 0;
monPortraitPtr->spriteId = dialogueInfo->unk2;
monPortraitPtr->flip = strPtr->flip;
monPortraitPtr->pos.x = strPtr->pos.x;
monPortraitPtr->pos.y = strPtr->pos.y;
if (monPortraitPtr->pos.y < 2) {
monPortraitPtr->pos.y = 2;
}
}
else {
monPortraitPtr = NULL;
}
}
sub_8052740(10);
sub_803EAF0(2, 0);
sub_8052210(0);
xxx_info_box_80141B4(dialogueInfo->str, 0, monPortraitPtr, gUnknown_80F7AEA[dialogueInfo->unk0]);
do {
xxx_draw_string_80144C4();
sub_803E46C(9);
unkPrintRet = sub_80144A4(&unkSpVar);
} while (unkPrintRet != 0);
if (monPortraitPtr != NULL) {
CloseFile(monPortraitPtr->faceFile);
}
if (dialogueInfo->unk0 != 1 && dialogueInfo->unk0 != 3) {
sub_8040238();
sub_803EAF0(0, 0);
}
sub_803E708(8, 9);
}

View File

@ -534,16 +534,18 @@ OpenedFile *OpenPokemonDialogueSpriteFile(s16 index)
return OpenFile(buffer, &gMonsterFileArchive); return OpenFile(buffer, &gMonsterFileArchive);
} }
OpenedFile *GetDialogueSpriteDataPtr(s16 index) OpenedFile *GetDialogueSpriteDataPtr(s32 index)
{ {
// Looks like this loads the dialogue sprite for the pokemon // Looks like this loads the dialogue sprite for the pokemon
char buffer[0xC]; char buffer[0xC];
if(gMonsterParameters[index].dialogueSprites == 0) // TODO: Use the static inline function for indexing
s16 index_ = index;
if(gMonsterParameters[index_].dialogueSprites == 0)
{ {
return NULL; return NULL;
} }
sprintf(buffer, gUnknown_8107684, index); // "kao%03d" sprintf(buffer, gUnknown_8107684, index_); // "kao%03d"
return OpenFileAndGetFileDataPtr(buffer, &gMonsterFileArchive); return OpenFileAndGetFileDataPtr(buffer, &gMonsterFileArchive);
} }