diff --git a/asm/overlay_11_022ECD24.s b/asm/overlay_11_022ECD24.s index 4664678f..563d9c61 100644 --- a/asm/overlay_11_022ECD24.s +++ b/asm/overlay_11_022ECD24.s @@ -4,307 +4,7 @@ .text .public LoadMapType10 - - arm_func_start LoadMapType11 -LoadMapType11: ; 0x022ED244 - stmdb sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, lr} - sub sp, sp, #0x38 - mov r4, r1 - mvn r1, #0 - mov r7, r2 - cmp r4, r1 - ldrneb r1, [r7] - mov sl, r0 - mov r6, r3 - cmpne r1, #0xff - bne _022ED27C - mov r0, sl - bl ov11_022EC08C - b _022ED680 -_022ED27C: - bl ov11_022EBFC8 - mov r1, #2 - strh r1, [sl] - mov r2, #0 - add r0, sl, #0xea - strb r2, [sl, #0x1c0] - add r1, sl, #0x100 - strh r4, [r1, #0xbe] - strh r2, [r1, #0xea] - add r0, r0, #0x100 - strh r2, [r0, #2] - strh r2, [r1, #0xc8] - add r4, sl, #0x1c8 - strh r2, [r4, #0xa] - strb r2, [sl, #0x1e0] - add r5, sl, #0x1e0 - strb r2, [r5, #1] - strb r2, [r5, #2] - strb r2, [r5, #3] - strh r2, [r5, #4] - strh r2, [r5, #6] - strh r2, [r5, #8] - str r2, [sl, #0x1f0] - str r7, [sp] - ldr r0, [sl, #0x2d8] - add r2, sp, #0x28 - add r3, sp, #0x24 - mov r1, #0x40 - bl ov10_022C3E8C - ldr r0, [sp, #0x28] - mov r3, #0x40 - strb r0, [r5, #2] - ldr r1, [sp, #0x24] - add r0, sp, #0x2c - strb r1, [r5, #3] - ldr r2, [sp, #0x28] - add r1, sl, #0x194 - add r2, r2, r2, lsl #1 - strb r2, [sl, #0x1e0] - ldr r8, [sp, #0x24] - ldr r2, _022ED688 ; =0x06018000 - add r8, r8, r8, lsl #1 - strb r8, [r5, #1] - ldr r8, [sl, #0x2e4] - str r8, [sp] - str r7, [sp, #4] - str r6, [sp, #8] - str r3, [sp, #0xc] - ldrb r3, [r5, #3] - str r3, [sp, #0x10] - ldr r3, [sl, #0x2d8] - str r3, [sp, #0x14] - ldr r3, [sl, #0x2dc] - bl ov10_022C3938 - ldr r3, [sp, #0x2c] - ldr r0, [sp, #0x30] - mov r2, r5 - str r3, [sl, #0x17c] - str r0, [sl, #0x180] - ldr r3, [sp, #0x34] - add r0, sl, #0x200 - str r3, [sl, #0x1b8] - ldrsh r3, [r0, #0xce] - ldr r0, [sl, #0x2d8] - ldr r5, [sl, #0x2d4] - mov r1, #0 - blx r5 - mov r1, #0x200 - add r0, sl, #0x100 - strh r1, [r0, #0xc8] - mov r1, #0 - mov r7, r1 -_022ED39C: - add r0, r4, r1, lsl #1 - add r1, r1, #1 - strh r7, [r0, #2] - cmp r1, #4 - blt _022ED39C - mov r0, #0x190 - strh r0, [r4, #0xa] - add r0, sl, #0x100 - mov r1, #0xc - strh r1, [r0, #0xea] - strh r7, [r0, #0xec] - ldr r6, [sl, #0x1b8] - cmp r6, #0 - beq _022ED544 - ldr r0, _022ED68C ; =ov11_02324CBC - ldrb r1, [sl, #0x2bc] - ldr r5, [r0] - mov r0, #0x28 - smulbb r4, r1, r0 - ldr r3, _022ED690 ; =ov11_02320BEC - add r2, sp, #0x18 - mov r8, r7 - add r5, r5, #0x98 - mov r1, #4 -_022ED3FC: - ldrb r0, [r3], #1 - subs r1, r1, #1 - strb r0, [r2], #1 - bne _022ED3FC - b _022ED4C0 -_022ED410: - add r0, r7, #1 - mov r3, r0, lsl #0x10 - mov r1, r7 - ldr r2, _022ED694 ; =ov11_02320BF4 - add r0, r5, r4 - mov r7, r3, lsr #0x10 - bl sub_0200A590 - add r6, r6, #4 - mov sb, #1 - add fp, sp, #0x20 -_022ED438: - add r3, sp, #0x18 - add r2, sp, #0x1c - mov r1, #4 -_022ED444: - ldrb r0, [r3], #1 - subs r1, r1, #1 - strb r0, [r2], #1 - bne _022ED444 - ldrb r0, [r6] - add r3, sp, #0x1c - add r2, sp, #0x20 - strb r0, [sp, #0x1c] - ldrb r0, [r6, #1] - mov r1, #4 - strb r0, [sp, #0x1d] - ldrb r0, [r6, #2] - strb r0, [sp, #0x1e] - ldrb r0, [r6, #3] - strb r0, [sp, #0x1f] -_022ED480: - ldrb r0, [r3], #1 - subs r1, r1, #1 - strb r0, [r2], #1 - bne _022ED480 - add r0, r7, #1 - mov r1, r7 - mov r3, r0, lsl #0x10 - mov r2, fp - add r0, r5, r4 - mov r7, r3, lsr #0x10 - bl sub_0200A590 - add sb, sb, #1 - cmp sb, #0x10 - add r6, r6, #4 - blt _022ED438 - add r8, r8, #1 -_022ED4C0: - cmp r8, #0xc - bge _022ED4D8 - add r0, sl, #0x200 - ldrsh r0, [r0, #0xc4] - cmp r8, r0 - blt _022ED410 -_022ED4D8: - add r6, sl, #0x200 - ldr fp, _022ED694 ; =ov11_02320BF4 - b _022ED530 -_022ED4E4: - add r0, r7, #1 - mov r3, r0, lsl #0x10 - mov r1, r7 - mov r2, fp - add r0, r5, r4 - mov r7, r3, lsr #0x10 - bl sub_0200A590 - mov sb, #1 -_022ED504: - add r0, r7, #1 - mov r3, r0, lsl #0x10 - mov r1, r7 - ldr r2, _022ED698 ; =ov11_02320BE8 - add r0, r5, r4 - mov r7, r3, lsr #0x10 - bl sub_0200A590 - add sb, sb, #1 - cmp sb, #0x10 - blt _022ED504 - add r8, r8, #1 -_022ED530: - ldrsh r0, [r6, #0xc4] - cmp r8, r0 - blt _022ED4E4 - add r0, r5, r4 - bl sub_0200A504 -_022ED544: - mov r1, #0 - strb r1, [sl, #0x1ee] - ldr r0, _022ED68C ; =ov11_02324CBC - ldrb r2, [sl, #0x2bc] - ldr r3, [r0] - mov r0, #0x28 - strb r1, [sl, #0x1bc] - ldr r1, [sl, #0x19c] - add r4, sl, #4 - cmp r1, #0 - add r3, r3, #0x98 - smulbb r1, r2, r0 - beq _022ED5A0 - add r0, sl, #0x1a0 - add r1, r3, r1 - mov r2, #0x20 - bl sub_02063628 - ldr r1, [sl, #0x19c] - add r0, sl, #0x1a0 - mov r2, #0x20 - bl sub_02063734 - mov r0, #1 - strb r0, [sl, #0x1bc] -_022ED5A0: - mov r0, #0 - str r0, [sl, #0x1f4] - strb r0, [sl, #0x1f8] - strb r0, [sl, #0x1f9] - strb r0, [sl, #0x1fa] - strb r0, [sl, #0x1fb] - mov r5, r0 -_022ED5BC: - strh r5, [r4] - strh r5, [r4, #2] - add r0, r0, #1 - str r5, [r4, #8] - str r5, [r4, #4] - cmp r0, #0x10 - add r4, r4, #0xc - blt _022ED5BC - add r3, sl, #0xc4 - mov r1, #0 - mov r0, #0x2c -_022ED5E8: - mul r2, r5, r0 - strb r1, [r3, r2] - add r2, r3, r2 - strb r1, [r2, #1] - strh r1, [r2, #4] - strh r1, [r2, #2] - str r1, [r2, #0x10] - str r1, [r2, #0x18] - str r1, [r2, #0x14] - str r1, [r2, #0x20] - str r1, [r2, #0x1c] - add r5, r5, #1 - str r1, [r2, #0x24] - str r1, [r2, #0x28] - cmp r5, #4 - blt _022ED5E8 - add r2, sl, #0x200 - mov r1, #1 - mov r0, sl - strh r1, [r2, #0xb8] - bl ov11_022EE620 - ldr r1, [sl, #0x228] - add r0, sl, #0x210 - blx r1 - mov r1, #1 - add r0, sl, #0x184 - strb r1, [sl, #0x2ba] - bl PointsToZero - cmp r0, #0 - bne _022ED668 - add r0, sl, #0x184 - bl UnloadFile -_022ED668: - add r0, sl, #0x18c - bl PointsToZero - cmp r0, #0 - bne _022ED680 - add r0, sl, #0x18c - bl UnloadFile -_022ED680: - add sp, sp, #0x38 - ldmia sp!, {r3, r4, r5, r6, r7, r8, sb, sl, fp, pc} - .align 2, 0 -_022ED688: .word 0x06018000 -_022ED68C: .word ov11_02324CBC -_022ED690: .word ov11_02320BEC -_022ED694: .word ov11_02320BF4 -_022ED698: .word ov11_02320BE8 - arm_func_end LoadMapType11 +.public LoadMapType11 arm_func_start ov11_022ED69C ov11_022ED69C: ; 0x022ED69C diff --git a/include/overlay_11_022EBB40.h b/include/overlay_11_022EBB40.h index 73444c03..46228957 100644 --- a/include/overlay_11_022EBB40.h +++ b/include/overlay_11_022EBB40.h @@ -252,5 +252,6 @@ void ov11_022EC08C(GroundBg *groundBg); void ov11_022EC240(GroundBg *groundBg, s32 bgId); void ov11_022EC27C(GroundBg *groundBg, s32 bgId); void LoadMapType10(GroundBg *groundBg, s32 bgId, const DungeonLocation *dungLoc, s32 a3); +void LoadMapType11(GroundBg *groundBg, s32 bgId, const DungeonLocation *dungLoc, s32 a3); #endif //PMDSKY_OVERLAY_11_022EBB40_H diff --git a/src/overlay_11_022EBB40.c b/src/overlay_11_022EBB40.c index 72a4d449..c79744fe 100644 --- a/src/overlay_11_022EBB40.c +++ b/src/overlay_11_022EBB40.c @@ -1532,6 +1532,7 @@ struct Unk_022C3938 extern void sub_02063628(struct UnkGroundBg_1A0 * a0, struct UnkStruct_2324CBC_Sub98 *a1, s32 a2); extern void sub_02063734(struct UnkGroundBg_1A0 * a0, s32 a1, s32 a2); +extern void ov10_022C3E8C(u16 *a0, s32 a1, s32 *a2, s32 *a3, const DungeonLocation *a4); extern void ov10_022C3938(struct Unk_022C3938 *a0, struct UnkGroundBg_194 *a1, void *a2, @@ -1718,4 +1719,146 @@ void LoadMapType10(GroundBg *groundBg, s32 bgId, const DungeonLocation *dungLoc, TRY_CLOSE_FILE(groundBg->bmaFile); } +void LoadMapType11(GroundBg *groundBg, s32 bgId, const DungeonLocation *dungLoc, s32 a3) +{ + BplHeader *bplHeader; + LayerSpecs *layerSpecs; + BmaHeader *bmaHeader; + s32 i; + s32 sp24, sp28; + struct Unk_022C3938 sp2C; + SubStruct_0 *sub0Ptr; + + if (bgId == -1 || dungLoc->id == 0xff) { + ov11_022EC08C(groundBg); + return; + } + + ov11_022EBFC8(groundBg); + groundBg->newUnk0 = 2; + groundBg->unk1C0 = 0; + groundBg->unk1BE = bgId; + + layerSpecs = &groundBg->layerSpecs[0]; + bmaHeader = &groundBg->bmaHeader; + bplHeader = &groundBg->bplHeader; + + bplHeader->numPalettes = 0; + bplHeader->hasPalAnimations = 0; + + layerSpecs->numTiles = 0; + layerSpecs->numChunks = 0; + + bmaHeader->mapWidthTiles = 0; + bmaHeader->mapHeightTiles = 0; + /*bmaHeader->tilingWidth* = 0;*/ + /*bmaHeader->tilingHeight* = 0;*/ + bmaHeader->mapWidthChunks = 0; + bmaHeader->mapHeightChunks = 0; + bmaHeader->numLayers = 0; + bmaHeader->hasDataLayer = 0; + bmaHeader->hasCollision = 0; + + groundBg->unk1F0 = NULL; + ov10_022C3E8C(groundBg->unk2D8, 0x40, &sp24, &sp28, dungLoc); + bmaHeader->mapWidthChunks = sp24; + bmaHeader->mapHeightChunks = sp28; + bmaHeader->mapWidthTiles = sp24 * 3; + bmaHeader->mapHeightTiles = sp28 * 3; + ov10_022C3938(&sp2C, + &groundBg->unk194, + (void *)(VRAM + 0x18000), + groundBg->unk2DC[0], + groundBg->unk2E4[0], + dungLoc, + a3, + 0x40, + bmaHeader->mapHeightChunks, + groundBg->unk2D8); + groundBg->unk17C = sp2C.unk0; + groundBg->unk1B8 = sp2C.unk8; + groundBg->unk52C.unk18(groundBg->unk2D8, NULL, bmaHeader, groundBg->unk52C.unk12); + + layerSpecs->numTiles = 512; + for (i = 0; i < MAX_BPA_SLOTS; i++) { + layerSpecs->bpaSlotNumTiles[i] = 0; + } + + layerSpecs->numChunks = 0x190; + groundBg->bplHeader.numPalettes = 12; + groundBg->bplHeader.hasPalAnimations = FALSE; + if (groundBg->unk1B8 != NULL) { + const RGB_Array *strPtr = groundBg->unk1B8; + struct UnkStruct_2324CBC_Sub98 *unkSubPtr = &ov11_02324CBC->unk98[groundBg->unk52C.unk0]; + u16 palId = 0; + s32 i, j; + + for (i = 0; i < 12 && i < groundBg->unk52C.unk8; i++) { + sub_0200A590(unkSubPtr, palId++, &ov11_02320BF4); + strPtr++; + for (j = 1; j < 16; j++) { + RGB_Array sp20; + RGB_Array sp1C = ov11_02320BEC; + sp1C.c[0] = strPtr->c[0]; + sp1C.c[1] = strPtr->c[1]; + sp1C.c[2] = strPtr->c[2]; + sp1C.c[3] = strPtr->c[3]; + sp20 = sp1C; + sub_0200A590(unkSubPtr, palId++, &sp20); + strPtr++; + } + } + + for (; i < groundBg->unk52C.unk8; i++) { + sub_0200A590(unkSubPtr, palId++, &ov11_02320BF4); + for (j = 1; j < 16; j++) { + sub_0200A590(unkSubPtr, palId++, &ov11_02320BE8); + } + } + sub_0200A504(unkSubPtr); + } + + groundBg->unk1EE = 0; + sub0Ptr = groundBg->unk0; + struct UnkStruct_2324CBC_Sub98 *unkSubPtr = &ov11_02324CBC->unk98[groundBg->unk52C.unk0]; + groundBg->unk1BC = 0; + if (groundBg->unk194.unk8 != 0) { + sub_02063628(&groundBg->unk1A0, unkSubPtr, 0x20); + sub_02063734(&groundBg->unk1A0, groundBg->unk194.unk8, 0x20); + groundBg->unk1BC = 1; + } + groundBg->animationSpecifications = NULL; + groundBg->unk1F8 = 0; + groundBg->unk1F9 = 0; + groundBg->unk1FA = 0; + groundBg->unk1FB = 0; + + for (s32 unk0Id = 0; unk0Id < UNK_0_ARR_COUNT; unk0Id++, sub0Ptr++) { + sub0Ptr->unk0 = 0; + sub0Ptr->unk2 = 0; + sub0Ptr->unk4 = sub0Ptr->unk8 = 0; + } + + for (s32 unk3E0Id = 0; unk3E0Id < UNK_3E0_ARR_COUNT; unk3E0Id++) { + SubStruct_3E0 *sub3E0 = &groundBg->unk3E0[unk3E0Id]; + sub3E0->unk0 = 0; + sub3E0->unk1 = 0; + sub3E0->unk4 = 0; + sub3E0->unk2 = 0; + sub3E0->unk10 = 0; + sub3E0->unk18 = 0; + sub3E0->unk14 = 0; + sub3E0->unk20 = 0; + sub3E0->unk24 = sub3E0->unk1C = 0, + sub3E0->unk28 = 0; + } + + groundBg->unk2B8 = 1; + ov11_022EE620(groundBg, 1); + groundBg->mapRender[0].tilemapRenderFunc(&groundBg->mapRender[0]); + groundBg->unk2BA = 1; + TRY_CLOSE_FILE(groundBg->bpcFile); + TRY_CLOSE_FILE(groundBg->bmaFile); +} + //