decompile ov11_022EBC18

This commit is contained in:
DizzyEggg
2025-07-23 09:20:19 +02:00
parent fe4dacaa42
commit 8d6def627e
5 changed files with 328 additions and 189 deletions

View File

@@ -323,6 +323,7 @@
.public ov11_022EB2F4
.public ov11_022EB3C8
.public ov11_022EBAA0
.public ov11_022EBC18
.public ov11_02316AFC
.public ov11_02316B04
.public ov11_02316B14
@@ -2322,7 +2323,6 @@
.public sub_0200B33C
.public sub_0200B340
.public sub_0200B3C0
.public sub_0200B500
.public sub_0200CF6C
.public sub_0200D310
.public sub_0200D65C

View File

@@ -1,194 +1,8 @@
.include "asm/macros.inc"
.include "overlay_11_022EBC18.inc"
.include "overlay_11_022EBEAC.inc"
.text
arm_func_start ov11_022EBC18
ov11_022EBC18: ; 0x022EBC18
stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr}
sub sp, sp, #8
mov sl, r0
mov r5, r1
add r4, sl, #0x2bc
ldmia r5!, {r0, r1, r2, r3}
stmia r4!, {r0, r1, r2, r3}
ldmia r5, {r0, r1, r2}
stmia r4, {r0, r1, r2}
ldrb r0, [sl, #0x2bc]
add r4, sl, #0x200
mov r6, #0
cmp r0, #0
moveq sb, #6
movne sb, #0xf
ldrsh r7, [r4, #0xbe]
mov r5, r6
mov r8, #0x12
b _022EBC9C
_022EBC64:
add r0, sl, r6, lsl #1
add r0, r0, #0x200
ldrsh r1, [r0, #0xca]
cmp r1, #0
addle r0, sl, r6, lsl #2
strle r5, [r0, #0x2dc]
ble _022EBC94
mul r0, r1, r8
mov r1, sb
bl MemAlloc
add r1, sl, r6, lsl #2
str r0, [r1, #0x2dc]
_022EBC94:
add r6, r6, #1
add r7, r7, #1
_022EBC9C:
ldrsh r0, [r4, #0xc0]
cmp r6, r0
blt _022EBC64
mov r1, #0
b _022EBCC0
_022EBCB0:
add r0, sl, r6, lsl #2
str r1, [r0, #0x2dc]
add r6, r6, #1
add r7, r7, #1
_022EBCC0:
cmp r6, #2
blt _022EBCB0
add r4, sl, #0x200
mov r7, #0
ldrsh r8, [r4, #0xbe]
mov r6, r7
ldr r5, _022EBEA4 ; =ov11_02324CBC
mov fp, #0x1c
b _022EBD54
_022EBCE4:
ldrb r0, [sl, #0x2bc]
cmp r0, #0
ldr r0, [r5]
bne _022EBD00
mla r0, r8, fp, r0
bl sub_0200B500
b _022EBD10
_022EBD00:
add r1, r0, #0x38
mov r0, #0x1c
mla r0, r8, r0, r1
bl sub_0200B500
_022EBD10:
add r1, sl, r7, lsl #2
str r0, [r1, #0x2ec]
add r0, sl, r7, lsl #1
add r0, r0, #0x200
ldrsh r0, [r0, #0xca]
cmp r0, #0
addle r0, sl, r7, lsl #2
strle r6, [r0, #0x2e4]
ble _022EBD4C
ldrsh r0, [r4, #0xd0]
mov r1, sb
mov r0, r0, lsl #7
bl MemAlloc
add r1, sl, r7, lsl #2
str r0, [r1, #0x2e4]
_022EBD4C:
add r7, r7, #1
add r8, r8, #1
_022EBD54:
ldrsh r0, [r4, #0xc0]
cmp r7, r0
blt _022EBCE4
mov r1, #0
b _022EBD78
_022EBD68:
add r0, sl, r7, lsl #2
str r1, [r0, #0x2ec]
str r1, [r0, #0x2e4]
add r7, r7, #1
_022EBD78:
cmp r7, #2
blt _022EBD68
ldr r0, [sl, #0x2d4]
cmp r0, #0
moveq r0, #0
beq _022EBDA4
add r0, sl, #0x200
ldrsh r0, [r0, #0xce]
mov r1, sb
mov r0, r0, lsl #8
bl MemAlloc
_022EBDA4:
str r0, [sl, #0x2d8]
mov r0, sl
bl ov11_022EBF60
mov r2, #0
strh r2, [sl]
strb r2, [sl, #0x1c0]
strb r2, [sl, #0x2ba]
sub r1, r2, #1
add r0, sl, #0x100
strh r1, [r0, #0xbe]
str r2, [sl, #0x1f0]
strb r2, [sl, #0x1e0]
strb r2, [sl, #0x1e1]
strb r2, [sl, #0x1e2]
strb r2, [sl, #0x1e3]
strb r2, [sl, #0x1ee]
str r2, [sl, #0x1f4]
strb r2, [sl, #0x1f8]
strb r2, [sl, #0x1f9]
strb r2, [sl, #0x1fa]
strb r2, [sl, #0x1fb]
strb r2, [sl, #0x1bc]
add r0, sl, #4
mov r3, r2
_022EBE04:
strh r3, [r0]
strh r3, [r0, #2]
add r2, r2, #1
str r3, [r0, #8]
str r3, [r0, #4]
cmp r2, #0x10
add r0, r0, #0xc
blt _022EBE04
add r2, sl, #0xc4
mov r4, #0
mov r0, #0x2c
_022EBE30:
mul r1, r3, r0
strb r4, [r2, r1]
add r1, r2, r1
strb r4, [r1, #1]
strh r4, [r1, #2]
strh r4, [r1, #4]
str r4, [r1, #0x10]
str r4, [r1, #0x18]
str r4, [r1, #0x14]
str r4, [r1, #0x20]
str r4, [r1, #0x1c]
add r3, r3, #1
str r4, [r1, #0x24]
str r4, [r1, #0x28]
cmp r3, #4
blt _022EBE30
ldr r0, _022EBEA8 ; =ov11_02320BE4
ldr r2, [r0, #0x14]
ldr r1, [r0, #0x18]
str r2, [sp]
str r1, [sp, #4]
_022EBE84:
add r0, sl, r4, lsl #3
str r2, [r0, #0x200]
add r4, r4, #1
str r1, [r0, #0x204]
cmp r4, #2
blt _022EBE84
add sp, sp, #8
ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc}
.align 2, 0
_022EBEA4: .word ov11_02324CBC
_022EBEA8: .word ov11_02320BE4
arm_func_end ov11_022EBC18
arm_func_start ov11_022EBEAC
ov11_022EBEAC: ; 0x022EBEAC
stmdb sp!, {r4, r5, r6, r7, r8, lr}

View File

@@ -1,6 +1,12 @@
#ifndef PMDSKY_OVERLAY_11_022EBB40_H
#define PMDSKY_OVERLAY_11_022EBB40_H
struct iovec
{
void* iov_base;
u32 iov_len;
};
#define BG_NAME_LEN 8
struct bg_list_entry_sub_struct {
@@ -17,6 +23,213 @@ struct bg_list_entry {
struct bg_list_entry_sub_struct others_bpa[BPA_MAX_ENTRIES];
};
#define UNK_0_ARR_COUNT 16 // Was 14 in Red
#define UNK_E0_ARR_COUNT 32
#define UNK_3E0_ARR_COUNT 4 // Was 2 in Red
#define NUM_LAYERS 2
typedef struct PixelPos
{
/* 0x0 */ s32 x;
/* 0x4 */ s32 y;
} PixelPos;
typedef struct SubStruct_0
{
s16 unk0;
s16 unk2;
const void *unk4;
const void *unk8;
//u8 fillC; // Filler byte removed in Sky, present in Red
} SubStruct_0;
// Was 0x24 in Red...
typedef struct SubStruct_3E0
{
u8 unk0;
u8 unk1;
s16 unk2;
s16 unk4;
struct iovec bpaFile;
//const struct BpaHeader *unkC; hm...
const void *unk10;
const void *unk14;
const void *unk18;
const void *unk1C;
void *unk20;
u32 unk24;
u32 unk28;
} SubStruct_3E0;
// size: 0x18?
typedef struct SubStruct_52C
{
u8 unk0; // 0x52C
s16 unk2; // 0x52E
s16 unk4; // 0x530
s16 unk6; // 0x532
s16 unk8; // 0x534
s16 unkA; // 0x536
s16 unkC; // numLayers
s16 unkE[2]; // 0x53A
s16 unk12; // 0x53E
s16 unk14;
s16 unk16;
void *unk18; // Maybe void (*unk14)(void *, const void *, BmaHeader *, s32); // TODO: fix void * to proper ptr types 0x540
} SubStruct_52C;
#define CHUNK_DIMENSIONS_3x3 2
// size: 0x55C
typedef struct GroundBg
{
u16 newUnk0; // Not present in Red
SubStruct_0 unk0[UNK_0_ARR_COUNT];
SubStruct_3E0 unk3E0[UNK_3E0_ARR_COUNT]; // 0xc4
u8 unk174; // 0x174
u8 unk175;
u8 unk176;
u8 unk177;
u8 unk178;
u8 unk179;
u8 unk17A;
u8 unk17B;
u8 unk17C;
u8 unk17D;
u8 unk17E;
u8 unk17F;
u8 unk180;
u8 unk181;
u8 unk182;
u8 unk183;
u8 unk184;
u8 unk185;
u8 unk186;
u8 unk187;
u8 unk188;
u8 unk189;
u8 unk18A;
u8 unk18B;
u8 unk18C;
u8 unk18D;
u8 unk18E;
u8 unk18F;
u8 unk190;
u8 unk191;
u8 unk192;
u8 unk193;
u8 unk194;
u8 unk195;
u8 unk196;
u8 unk197;
u8 unk198;
u8 unk199;
u8 unk19A;
u8 unk19B;
u8 unk19C;
u8 unk19D;
u8 unk19E;
u8 unk19F;
u8 unk1A0;
u8 unk1A1;
u8 unk1A2;
u8 unk1A3;
u8 unk1A4;
u8 unk1A5;
u8 unk1A6;
u8 unk1A7;
u8 unk1A8;
u8 unk1A9;
u8 unk1AA;
u8 unk1AB;
u8 unk1AC;
u8 unk1AD;
u8 unk1AE;
u8 unk1AF;
u8 unk1B0;
u8 unk1B1;
u8 unk1B2;
u8 unk1B3;
u8 unk1B4;
u8 unk1B5;
u8 unk1B6;
u8 unk1B7;
u8 unk1B8;
u8 unk1B9;
u8 unk1BA;
u8 unk1BB;
u8 unk1BC;
u8 unk1BD;
s16 unk1BE;
u8 unk1C0;
u8 unk1C1;
u8 unk1C2;
u8 unk1C3;
u8 unk1C4;
u8 unk1C5;
u8 unk1C6;
u8 unk1C7;
u8 unk1C8;
u8 unk1C9;
u8 unk1CA;
u8 unk1CB;
u8 unk1CC;
u8 unk1CD;
u8 unk1CE;
u8 unk1CF;
u8 unk1D0;
u8 unk1D1;
u8 unk1D2;
u8 unk1D3;
u8 unk1D4;
u8 unk1D5;
u8 unk1D6;
u8 unk1D7;
u8 unk1D8;
u8 unk1D9;
u8 unk1DA;
u8 unk1DB;
u8 unk1DC;
u8 unk1DD;
u8 unk1DE;
u8 unk1DF;
u8 unk1E0;
u8 unk1E1;
u8 unk1E2;
u8 unk1E3;
u8 unk1E4;
u8 unk1E5;
u8 unk1E6;
u8 unk1E7;
u8 unk1E8;
u8 unk1E9;
u8 unk1EA;
u8 unk1EB;
u8 unk1EC;
u8 unk1ED;
u8 unk1EE;
u8 unk1EF;
s32 unk1F0;
s32 unk1F4;
u8 unk1F8;
u8 unk1F9;
u8 unk1FA;
u8 unk1FB;
u8 unk1FC;
u8 unk1FD;
u8 unk1FE;
u8 unk1FF;
PixelPos cameraPixelPosition[NUM_LAYERS]; // 0x200
u8 fillerForNow2[170];
u8 unk2BA;
SubStruct_52C unk52C; // 2bc
u16 *unk2D8;
u16 *unk2DC[2];
u16 *unk2E4[2];
u16 *unk2EC[2];
} GroundBg;
void LoadBackgroundAttributes(struct bg_list_entry* entry, int bgId);
void ov11_022EBC18(GroundBg *groundBg, const SubStruct_52C *a1);
#endif //PMDSKY_OVERLAY_11_022EBB40_H

View File

@@ -185,7 +185,7 @@ Overlay OVY_11
After OVY_10
Object asm/overlay_11.o
Object src/overlay_11_022EBB40.o
Object asm/overlay_11_022EBC18.o
Object asm/overlay_11_022EBEAC.o
}
Overlay OVY_12
{

View File

@@ -2,6 +2,7 @@
#include "file_rom.h"
extern void FileClose(struct file_stream* file);
extern void* MemAlloc(u32 len, u32 flags);
extern const char ov11_02320C44[];
@@ -32,3 +33,114 @@ void LoadBackgroundAttributes(struct bg_list_entry* entry, int bgId)
FileClose(&file);
FileRom_StopDataTransfer();
}
void ov11_022EBF60(GroundBg *groundBg);
void *sub_0200B500(void *unk);
struct UnkStruct_2324CBC
{
u8 fill0[0x1C];
};
extern struct UnkStruct_2324CBC *ov11_02324CBC;
struct ConstFileData
{
u8 otherData[20];
const PixelPos sPositionZero;
};
extern const struct ConstFileData ov11_02320BE4;
// GroundBg_Init?
void ov11_022EBC18(GroundBg *groundBg, const SubStruct_52C *a1)
{
SubStruct_0 *unk0Ptr;
s32 id, unk0Id, unk3E0Id;
s32 i;
s32 id2;
s32 memGroup;
groundBg->unk52C = *a1;
memGroup = (groundBg->unk52C.unk0 == 0) ? 6 : 15;
id2 = groundBg->unk52C.unk2;
for (id = 0; id < groundBg->unk52C.unk4; id++, id2++) {
if (groundBg->unk52C.unkE[id] > 0) {
groundBg->unk2DC[id] = MemAlloc(groundBg->unk52C.unkE[id] * 18u, memGroup);
}
else {
groundBg->unk2DC[id] = NULL;
}
}
for (; id < NUM_LAYERS; id++, id2++) {
groundBg->unk2DC[id] = NULL;
}
id = groundBg->unk52C.unk2;
for (id2 = 0; id2 < groundBg->unk52C.unk4; id2++, id++) {
if (groundBg->unk52C.unk0 == 0) {
groundBg->unk2EC[id2] = sub_0200B500(&ov11_02324CBC[id]);
}
else {
struct UnkStruct_2324CBC *ptr = ov11_02324CBC;
ptr += 2;
groundBg->unk2EC[id2] = sub_0200B500(&ptr[id]);
}
if (groundBg->unk52C.unkE[id2] > 0) {
groundBg->unk2E4[id2] = MemAlloc(groundBg->unk52C.unk14 * 128, memGroup);
}
else {
groundBg->unk2E4[id2] = NULL;
}
}
for (; id2 < 2; id2++) {
groundBg->unk2EC[id2] = NULL;
groundBg->unk2E4[id2] = NULL;
}
groundBg->unk2D8 = (groundBg->unk52C.unk18 == 0) ? NULL : MemAlloc(groundBg->unk52C.unk12 * 256, memGroup);
ov11_022EBF60(groundBg);
groundBg->newUnk0 = 0;
groundBg->unk1C0 = 0;
groundBg->unk2BA = 0;
groundBg->unk1BE = -1;
groundBg->unk1F0 = 0;
groundBg->unk1E0 = 0;
groundBg->unk1E1 = 0;
groundBg->unk1E2 = 0;
groundBg->unk1E3 = 0;
groundBg->unk1EE = 0;
groundBg->unk1F4 = 0;
groundBg->unk1F8 = 0;
groundBg->unk1F9 = 0;
groundBg->unk1FA = 0;
groundBg->unk1FB = 0;
groundBg->unk1BC = 0;
unk0Ptr = &groundBg->unk0[0];
for (unk0Id = 0; unk0Id < UNK_0_ARR_COUNT; unk0Id++, unk0Ptr++) {
unk0Ptr->unk0 = 0;
unk0Ptr->unk2 = 0;
unk0Ptr->unk4 = unk0Ptr->unk8 = 0;
}
for (unk3E0Id = 0; unk3E0Id < UNK_3E0_ARR_COUNT; unk3E0Id++) {
SubStruct_3E0 *unkPtr = &groundBg->unk3E0[unk3E0Id];
unkPtr->unk0 = 0;
unkPtr->unk1 = 0;
unkPtr->unk2 = 0;
unkPtr->unk4 = 0;
unkPtr->unk10 = 0;
unkPtr->unk18 = 0;
unkPtr->unk14 = 0;
unkPtr->unk20 = 0;
unkPtr->unk1C = 0;
unkPtr->unk28 = unkPtr->unk24 = 0;
}
for (i = 0; i < NUM_LAYERS; i++) {
groundBg->cameraPixelPosition[i] = ov11_02320BE4.sPositionZero;
}
}