ShowDungeonNameBanner

This commit is contained in:
DizzyEggg 2024-09-21 19:58:53 +02:00
parent b20adedb18
commit 1c9a67668a
3 changed files with 176 additions and 524 deletions

View File

@ -5,527 +5,8 @@
.text
thumb_func_start sub_803D808
sub_803D808:
push {r4-r7,lr}
mov r7, r8
push {r7}
sub sp, 0x4
adds r7, r1, 0
movs r6, 0
ldr r2, _0803D820
lsls r1, r7, 3
adds r1, r0
mov r8, r1
b _0803D840
.align 2, 0
_0803D820: .4byte 0x0001cd98
_0803D824:
ldr r0, [r5]
ldr r1, _0803D868
adds r0, r1
adds r0, r4
ldr r1, [r0, 0x4]
ldr r0, [r0]
mov r3, r8
adds r3, 0x8
mov r8, r3
subs r3, 0x8
stm r3!, {r0,r1}
adds r7, 0x1
adds r2, 0x8
adds r6, 0x1
_0803D840:
cmp r6, 0x1F
bgt _0803D85A
ldr r5, _0803D86C
lsls r4, r6, 3
ldr r0, [r5]
adds r0, r2
str r2, [sp]
bl ExtractSpeciesIndex
lsls r0, 16
ldr r2, [sp]
cmp r0, 0
bne _0803D824
_0803D85A:
adds r0, r7, 0
add sp, 0x4
pop {r3}
mov r8, r3
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0803D868: .4byte 0x0001cd98
_0803D86C: .4byte gDungeon
thumb_func_end sub_803D808
thumb_func_start sub_803D870
sub_803D870:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
adds r6, r1, 0
movs r5, 0
lsls r1, r6, 3
adds r1, r0
mov r9, r1
b _0803D8B8
_0803D884:
bl GetBodySize
lsls r0, 24
lsrs r0, 24
cmp r0, 0x1
bhi _0803D8B6
ldr r1, [r7]
adds r0, r1, r4
ldr r2, _0803D8E4
adds r0, r2
movs r2, 0
ldrsh r0, [r0, r2]
cmp r0, 0
beq _0803D8B6
mov r2, r8
adds r0, r1, r2
adds r0, r4
ldr r1, [r0, 0x4]
ldr r0, [r0]
mov r2, r9
adds r2, 0x8
mov r9, r2
subs r2, 0x8
stm r2!, {r0,r1}
adds r6, 0x1
_0803D8B6:
adds r5, 0x1
_0803D8B8:
cmp r5, 0x1F
bgt _0803D8D6
ldr r7, _0803D8E8
lsls r4, r5, 3
ldr r0, _0803D8EC
mov r8, r0
adds r1, r4, r0
ldr r0, [r7]
adds r0, r1
bl ExtractSpeciesIndex
lsls r0, 16
asrs r0, 16
cmp r0, 0
bne _0803D884
_0803D8D6:
adds r0, r6, 0
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0803D8E4: .4byte 0x0001cd9a
_0803D8E8: .4byte gDungeon
_0803D8EC: .4byte 0x0001cd98
thumb_func_end sub_803D870
thumb_func_start sub_803D8F0
sub_803D8F0:
push {r4,lr}
ldr r4, _0803D920
ldr r0, [r4]
ldr r2, _0803D924
adds r1, r0, r2
ldrb r0, [r1]
cmp r0, 0
bne _0803D918
movs r0, 0x1
strb r0, [r1]
ldr r0, [r4]
ldr r1, _0803D928
adds r0, r1
movs r1, 0
bl sub_803D808
ldr r1, [r4]
ldr r2, _0803D92C
adds r1, r2
str r0, [r1]
_0803D918:
pop {r4}
pop {r0}
bx r0
.align 2, 0
_0803D920: .4byte gDungeon
_0803D924: .4byte 0x000037ec
_0803D928: .4byte 0x0000343c
_0803D92C: .4byte 0x000037e4
thumb_func_end sub_803D8F0
thumb_func_start sub_803D930
sub_803D930:
push {r4-r7,lr}
lsls r0, 16
asrs r6, r0, 16
movs r5, 0
ldr r7, _0803D940
ldr r4, _0803D944
b _0803D954
.align 2, 0
_0803D940: .4byte gDungeon
_0803D944: .4byte 0x0001cd98
_0803D948:
cmp r0, r6
bne _0803D950
movs r0, 0x1
b _0803D96A
_0803D950:
adds r4, 0x8
adds r5, 0x1
_0803D954:
cmp r5, 0x1F
bgt _0803D968
ldr r0, [r7]
adds r0, r4
bl ExtractSpeciesIndex
lsls r0, 16
asrs r0, 16
cmp r0, 0
bne _0803D948
_0803D968:
movs r0, 0
_0803D96A:
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sub_803D930
thumb_func_start sub_803D970
sub_803D970:
push {r4-r7,lr}
adds r5, r0, 0
ldr r0, _0803D9EC
bl DungeonRandInt
adds r6, r0, 0
movs r3, 0
ldr r1, _0803D9F0
ldr r0, [r1]
ldr r2, _0803D9F4
adds r0, r2
ldr r0, [r0]
cmp r3, r0
bge _0803D9BA
ldr r4, _0803D9F8
_0803D98E:
ldr r2, [r1]
lsls r1, r5, 1
lsls r0, r3, 3
adds r1, r0
ldr r7, _0803D9FC
adds r0, r2, r7
adds r1, r0, r1
movs r7, 0
ldrsh r0, [r1, r7]
cmp r0, 0
beq _0803D9A8
cmp r0, r6
bge _0803D9E0
_0803D9A8:
adds r4, 0x8
adds r3, 0x1
ldr r1, _0803D9F0
ldr r0, [r1]
ldr r2, _0803D9F4
adds r0, r2
ldr r0, [r0]
cmp r3, r0
blt _0803D98E
_0803D9BA:
movs r3, 0
ldr r0, _0803D9F0
ldr r1, [r0]
ldr r7, _0803D9F4
adds r1, r7
ldr r1, [r1]
adds r6, r0, 0
cmp r3, r1
bge _0803DA10
ldr r4, _0803D9F8
lsls r1, r5, 1
_0803D9D0:
ldr r2, [r6]
ldr r5, _0803D9FC
adds r0, r2, r5
adds r0, r1
movs r7, 0
ldrsh r0, [r0, r7]
cmp r0, 0
beq _0803DA00
_0803D9E0:
adds r0, r2, r4
bl ExtractSpeciesIndex
lsls r0, 16
asrs r0, 16
b _0803DA14
.align 2, 0
_0803D9EC: .4byte 0x00002710
_0803D9F0: .4byte gDungeon
_0803D9F4: .4byte 0x000037e4
_0803D9F8: .4byte 0x0000343c
_0803D9FC: .4byte 0x0000343e
_0803DA00:
adds r4, 0x8
adds r1, 0x8
adds r3, 0x1
ldr r5, _0803DA1C
adds r0, r2, r5
ldr r0, [r0]
cmp r3, r0
blt _0803D9D0
_0803DA10:
movs r0, 0xBE
lsls r0, 1
_0803DA14:
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0803DA1C: .4byte 0x000037e4
thumb_func_end sub_803D970
thumb_func_start sub_803DA20
sub_803DA20:
push {r4-r7,lr}
lsls r0, 16
asrs r7, r0, 16
movs r5, 0
ldr r1, _0803DA54
ldr r0, [r1]
ldr r2, _0803DA58
adds r0, r2
ldr r0, [r0]
cmp r5, r0
bge _0803DA70
adds r6, r1, 0
ldr r4, _0803DA5C
_0803DA3A:
ldr r0, [r6]
adds r0, r4
bl ExtractSpeciesIndex
lsls r0, 16
asrs r0, 16
cmp r0, r7
bne _0803DA60
ldr r0, [r6]
adds r0, r4
bl ExtractLevel
b _0803DA72
.align 2, 0
_0803DA54: .4byte gDungeon
_0803DA58: .4byte 0x000037e4
_0803DA5C: .4byte 0x0000343c
_0803DA60:
adds r4, 0x8
adds r5, 0x1
ldr r0, [r6]
ldr r1, _0803DA78
adds r0, r1
ldr r0, [r0]
cmp r5, r0
blt _0803DA3A
_0803DA70:
movs r0, 0x1
_0803DA72:
pop {r4-r7}
pop {r1}
bx r1
.align 2, 0
_0803DA78: .4byte 0x000037e4
thumb_func_end sub_803DA20
thumb_func_start ShowDungeonNameBanner
ShowDungeonNameBanner:
push {r4-r7,lr}
mov r7, r9
mov r6, r8
push {r6,r7}
sub sp, 0x68
ldr r0, _0803DB84
ldr r4, _0803DB88
adds r1, r4, 0
bl OpenFileAndGetFileDataPtr
ldr r5, _0803DB8C
str r0, [r5]
ldr r0, _0803DB90
adds r1, r4, 0
bl OpenFileAndGetFileDataPtr
ldr r1, _0803DB94
str r0, [r1]
ldr r1, _0803DB98
ldr r0, [r0, 0x4]
ldr r0, [r0, 0x4]
str r0, [r1]
movs r4, 0
_0803DAAA:
adds r0, r4, 0
adds r0, 0xE0
ldr r1, [r5]
lsls r2, r4, 2
ldr r1, [r1, 0x4]
adds r1, r2
bl SetBGPaletteBufferColorArray
adds r4, 0x1
cmp r4, 0xF
ble _0803DAAA
ldr r0, _0803DB9C
movs r1, 0xE0
lsls r1, 5
bl CpuClear
bl sub_80848EC
lsls r0, 24
cmp r0, 0
bne _0803DAD6
b _0803DBEA
_0803DAD6:
ldr r0, _0803DBA0
ldr r0, [r0]
ldr r1, _0803DBA4
adds r2, r0, r1
movs r3, 0x14
ldrsh r1, [r0, r3]
ldrb r2, [r2]
adds r2, r1
mov r8, r2
ldr r1, _0803DBA8
adds r0, r1
ldrb r0, [r0]
bl GetDungeonName2
mov r9, r0
movs r5, 0xA
movs r0, 0
_0803DAF8:
movs r4, 0
adds r6, r0, 0x4
adds r7, r0, 0x1
_0803DAFE:
adds r4, 0x1
ldr r3, _0803DBAC
adds r0, r3, 0
adds r2, r5, 0
orrs r2, r0
lsls r2, 16
lsrs r2, 16
adds r0, r4, 0
adds r1, r6, 0
movs r3, 0
bl sub_8008DC8
adds r5, 0x1
cmp r4, 0x1B
ble _0803DAFE
adds r0, r7, 0
cmp r0, 0x7
ble _0803DAF8
mov r0, r9
bl CalcStringWidth
movs r1, 0xE0
subs r1, r0
lsrs r0, r1, 31
adds r1, r0
asrs r1, 1
mov r0, r9
movs r2, 0
bl sub_803DC14
adds r7, r0, 0
ldr r0, _0803DBA0
ldr r0, [r0]
ldr r1, _0803DBA8
adds r0, r1
ldrb r0, [r0]
bl IsStairDirectionUp
lsls r0, 24
ldr r6, _0803DBB0
cmp r0, 0
beq _0803DB54
ldr r6, _0803DBB4
_0803DB54:
mov r3, r8
cmp r3, 0x9
ble _0803DBBC
ldr r5, _0803DBB8
mov r0, r8
movs r1, 0xA
bl __divsi3
adds r4, r0, 0
adds r4, 0x30
mov r0, r8
movs r1, 0xA
bl __modsi3
adds r0, 0x30
str r0, [sp]
add r0, sp, 0x4
adds r1, r5, 0
adds r2, r6, 0
adds r3, r4, 0
bl sprintfStatic
b _0803DBCA
.align 2, 0
_0803DB84: .4byte gUnknown_80F60F8
_0803DB88: .4byte gDungeonFileArchive
_0803DB8C: .4byte gDungeonNameBannerPalette
_0803DB90: .4byte gUnknown_80F6100
_0803DB94: .4byte gDungeonNameBannerFontFile
_0803DB98: .4byte gDungeonNameBannerFont
_0803DB9C: .4byte 0x06000140
_0803DBA0: .4byte gDungeon
_0803DBA4: .4byte 0x00000645
_0803DBA8: .4byte 0x00000644
_0803DBAC: .4byte 0xffffe000
_0803DBB0: .4byte gUnknown_80F610C
_0803DBB4: .4byte gUnknown_80F6108
_0803DBB8: .4byte gUnknown_80F6110
_0803DBBC:
ldr r1, _0803DC08
mov r3, r8
adds r3, 0x30
add r0, sp, 0x4
adds r2, r6, 0
bl sprintfStatic
_0803DBCA:
add r0, sp, 0x4
bl CalcStringWidth
movs r1, 0xE0
subs r1, r0
lsrs r0, r1, 31
adds r1, r0
asrs r1, 1
adds r2, r7, 0
adds r2, 0x20
add r0, sp, 0x4
bl sub_803DC14
ldr r1, _0803DC0C
movs r0, 0x1
strb r0, [r1]
_0803DBEA:
ldr r0, _0803DC10
ldr r0, [r0]
bl CloseFile
movs r0, 0x2
bl sub_803E46C
add sp, 0x68
pop {r3,r4}
mov r8, r3
mov r9, r4
pop {r4-r7}
pop {r0}
bx r0
.align 2, 0
_0803DC08: .4byte gUnknown_80F6118
_0803DC0C: .4byte gUnknown_20274A5
_0803DC10: .4byte gDungeonNameBannerFontFile
thumb_func_end ShowDungeonNameBanner
thumb_func_start sub_803DC14
sub_803DC14:
push {r4-r6,lr}

View File

@ -157,8 +157,8 @@ typedef struct UnkDungeonGlobal_unk1C590
typedef struct UnkDungeonGlobal_unk1CD98
{
struct PokemonStruct1 *unk0;
void *unk4;
s16 unk0; // species
s16 unk2[2];
} UnkDungeonGlobal_unk1CD98;
// size: 0x1CEDC
@ -242,9 +242,14 @@ typedef struct Dungeon
u8 fill69A[0x69C - 0x69A];
EntityInfo unk69C[4];
EntityInfo unkEBC[1]; // Unsure about the size... See sub_8082A08()
u8 fill10C4[0x363C - 0x10C4];
u8 fill10C4[0x343C - 0x10C4];
/* 0x343C */ UnkDungeonGlobal_unk1CD98 unk343C[32];
u8 fill353C[0x363c-0x353c];
/* 0x363C */ u8 expYieldRankings[NUM_MONSTERS];
u8 fill37D9[0x37F0 - 0x37D9];
u8 fill37D9[0x37E4 - 0x37D9];
/* 0x37E4 */ s32 unk37E4;
u8 fill37E8[4];
/* 0x37EC */ u8 unk37EC;
/* 0x37F0 */ u32 unk37F0;
/* 0x37F4 */ s32 unk37F4;
/* 0x37F8 */ bool8 plusIsActive[2]; // Index 0: Enemy , Index 1: Team

View File

@ -2,15 +2,27 @@
#include "dungeon.h"
#include "pokemon.h"
#include "file_system.h"
#include "code_803E46C.h"
#include "cpu.h"
#include "dungeon_random.h"
#include "bg_palette_buffer.h"
#include "code_800D090.h"
extern void sub_80901D8(DungeonLocation *param_1,DungeonLocation *param_2);
extern s32 sub_80902C8(u8 dungeon);
extern u16 ExtractSpeciesIndex(UnkDungeonGlobal_unk1CD98 *r0);
extern s16 ExtractSpeciesIndex(UnkDungeonGlobal_unk1CD98 *r0);
extern u32 ExtractLevel(UnkDungeonGlobal_unk1CD98 *r0);
extern void sub_808E9C4(UnkDungeonGlobal_unk1CD98 *r0, s16 r1);
extern u8 GetBodySize(s16 index);
extern bool8 sub_80848EC(void);
extern const char gUnknown_80F4D8C[]; // "mapparam"
extern const char gUnknown_80F60F8[]; // "banrpal"
extern const char gUnknown_80F6100[]; // "banfont"
extern struct FileArchive gDungeonFileArchive;
extern OpenedFile *gDungeonNameBannerPalette;
extern OpenedFile *gDungeonNameBannerFontFile;
extern void *gDungeonNameBannerFont;
struct UnkDungeonFileData
{
@ -408,3 +420,157 @@ u8 sub_803D73C(s32 a0)
return 105;
}
s32 sub_803D808(UnkDungeonGlobal_unk1CD98 *strPtr, s32 id)
{
s32 i;
for (i = 0; i < 32; i++) {
if (ExtractSpeciesIndex(&gDungeon->unk1CD98[i]) == 0)
break;
strPtr[id] = gDungeon->unk1CD98[i];
id++;
}
return id;
}
s32 sub_803D870(UnkDungeonGlobal_unk1CD98 *strPtr, s32 id)
{
s32 i;
for (i = 0; i < 32; i++) {
s16 species = ExtractSpeciesIndex(&gDungeon->unk1CD98[i]);
if (species == 0)
break;
if (GetBodySize(species) < 2 && gDungeon->unk1CD98[i].unk2[0] != 0) {
strPtr[id] = gDungeon->unk1CD98[i];
id++;
}
}
return id;
}
void sub_803D8F0(void)
{
if (gDungeon->unk37EC == 0) {
gDungeon->unk37EC = 1;
gDungeon->unk37E4 = sub_803D808(gDungeon->unk343C, 0);
}
}
// Hmm...
static inline s16 SpeciesId(s32 id)
{
return id;
}
bool8 sub_803D930(s16 speciesToFind)
{
s32 i;
s32 id = SpeciesId(speciesToFind);
for (i = 0; i < 32; i++) {
s16 species = ExtractSpeciesIndex(&gDungeon->unk1CD98[i]);
if (species == 0)
break;
if (species == id)
return TRUE;
}
return FALSE;
}
s16 sub_803D970(s32 arrId)
{
s32 i;
s32 rand = DungeonRandInt(10000);
for (i = 0; i < gDungeon->unk37E4; i++) {
if (gDungeon->unk343C[i].unk2[arrId] != 0 && gDungeon->unk343C[i].unk2[arrId] >= rand) {
return ExtractSpeciesIndex(&gDungeon->unk343C[i]);
}
}
for (i = 0; i < gDungeon->unk37E4; i++) {
if (gDungeon->unk343C[i].unk2[arrId] != 0) {
return ExtractSpeciesIndex(&gDungeon->unk343C[i]);
}
}
return MONSTER_KECLEON;
}
s32 sub_803DA20(s32 species)
{
s32 i;
s32 speciesId = SpeciesId(species);
for (i = 0; i < gDungeon->unk37E4; i++) {
if (ExtractSpeciesIndex(&gDungeon->unk343C[i]) == speciesId)
return ExtractLevel(&gDungeon->unk343C[i]);
}
return 1;
}
extern const u8 *GetDungeonName2(u8 dungeon);
extern void sub_8008DC8(s32 r0, s32 r1, u16 r2, u16 r3);
extern const char gUnknown_80F6108[];
extern const char gUnknown_80F610C[];
extern const char gUnknown_80F6110[];
extern const char gUnknown_80F6118[];
extern u8 gUnknown_20274A5;
s32 sub_803DC14(const u8 *dungName, s32 strWidth, s32 a2);
s32 CalcStringWidth(const u8 *dungName);
void ShowDungeonNameBanner(void)
{
u8 text[100];
s32 var;
s32 i, r7;
const u8 *r6;
gDungeonNameBannerPalette = OpenFileAndGetFileDataPtr(gUnknown_80F60F8, &gDungeonFileArchive);
gDungeonNameBannerFontFile = OpenFileAndGetFileDataPtr(gUnknown_80F6100, &gDungeonFileArchive);
gDungeonNameBannerFont = ((u8**) gDungeonNameBannerFontFile->data)[1];
for (i = 0; i < 16; i++) {
SetBGPaletteBufferColorArray(i + 224, (void*) &((u8**) gDungeonNameBannerPalette->data)[i]); // Todo: Fix when there is a better idea what to do with structs from opened files
}
CpuClear((void *)(VRAM + 0x140), 0x1C00);
if (sub_80848EC()) {
s32 r8 = gDungeon->dungeonLocation.floor + gDungeon->unk14;
const u8 *dungName = GetDungeonName2(gDungeon->dungeonLocation.id);
s32 r5 = 10;
for (r7 = 0; r7 < 8; r7++) {
for (i = 0; i < 28; r5++) {
u16 a2;
i++;
a2 = r5 | 0xE000;
sub_8008DC8(i, r7 + 4, r5 | a2, 0);
}
}
var = sub_803DC14(dungName, (224 - CalcStringWidth(dungName)) / 2, 0);
if (IsStairDirectionUp(gDungeon->dungeonLocation.id))
r6 = gUnknown_80F6108;
else
r6 = gUnknown_80F610C;
if (r8 > 9) {
sprintfStatic(text, gUnknown_80F6110, r6, 48 + (r8 / 10), 48 + (r8 % 10));
}
else {
sprintfStatic(text, gUnknown_80F6118, r6, 48 + r8);
}
sub_803DC14(text, (224 - CalcStringWidth(text)) / 2, var + 32);
gUnknown_20274A5 = 1;
}
CloseFile(gDungeonNameBannerFontFile);
sub_803E46C(2);
}