diff --git a/Makefile.psp.mk b/Makefile.psp.mk index e0a101c59c..52d6cd43ad 100644 --- a/Makefile.psp.mk +++ b/Makefile.psp.mk @@ -44,7 +44,7 @@ $(BUILD_DIR)/dra.elf: $(BUILD_DIR)/dra.ld $(addprefix $(BUILD_DIR)/src/dra/,$(ad $(BUILD_DIR)/tt_%.elf: $(BUILD_DIR)/tt_%.ld $$(call list_o_files_psp,servant/tt_$$*) $(BUILD_DIR)/assets/servant/tt_%/mwo_header.bin.o $(call link_with_deadstrip,tt_$*,$@) -ST_LIB_MERGE = collision e_chair st_update create_entity e_red_door e_room_fg st_common prim_helpers e_bloody_zombie e_misc en_thornweed_corpseweed e_skeleton e_life_up e_flea_man e_mist_door e_flea_armor e_candle_table st_debug e_lock_camera +ST_LIB_MERGE = collision e_chair st_update create_entity e_red_door e_room_fg st_common prim_helpers e_bloody_zombie e_misc en_thornweed_corpseweed e_skeleton e_life_up e_flea_man e_mist_door e_flea_armor e_candle_table st_debug e_lock_camera unk_3B200 $(BUILD_DIR)/stlib.elf: $(BUILD_DIR)/stlib.ld $(addprefix $(BUILD_DIR)/src/st/lib/,$(addsuffix .c.o,$(ST_LIB_MERGE))) $$(call list_o_files_psp,st/lib_psp) $(BUILD_DIR)/assets/st/lib/mwo_header.bin.o $(call link_with_deadstrip,stlib,$@) ST_NO4_MERGE = diff --git a/config/splat.pspeu.stlib.yaml b/config/splat.pspeu.stlib.yaml index 04f97fd4dc..10355a4685 100644 --- a/config/splat.pspeu.stlib.yaml +++ b/config/splat.pspeu.stlib.yaml @@ -80,7 +80,7 @@ segments: - [0x290C8, c, lib_psp/e_shop] - [0x2BC10, c, lib_psp/2BC10] - [0x35798, c, lib/e_lock_camera] - - [0x35F60, c, lib_psp/35F60] + - [0x35F60, c, lib/unk_3B200] - [0x36428, c, lib/e_candle_table] - [0x367C0, data] - [0x36800, .data, lib/e_bloody_zombie] @@ -125,7 +125,7 @@ segments: - [0x6DAD8, .rodata, lib_psp/unk_25CD0] - [0x6DB78, .rodata, lib_psp/e_shop] - [0x6DBB8, .rodata, lib_psp/2BC10] - - [0x6DD20, .rodata, lib_psp/35F60] + - [0x6DD20, .rodata, lib/unk_3B200] - [0x6DD80, .bss, lib/create_entity] - [0x6DDA0, .bss, lib/e_life_up] - [0x6DDA8, .bss, lib_psp/e_collect] diff --git a/config/splat.us.stlib.yaml b/config/splat.us.stlib.yaml index a6b7ebd8e3..43efe0de2d 100644 --- a/config/splat.us.stlib.yaml +++ b/config/splat.us.stlib.yaml @@ -77,8 +77,9 @@ segments: - [0x2D278, .rodata, unk_36F30] - [0x2D760, .rodata, cutscene] - [0x2D804, .rodata, e_candle_table] - - [0x2D808, .rodata, unk_3BEB0] - - [0x2D868, .rodata, unk_3C57C] + - [0x2D810, .rodata, unk_3B200] + - [0x2D828, .rodata, unk_3B53C] + - [0x2D848, .rodata, e_lesser_demon] - [0x2D980, .rodata, e_chair] - [0x2D9C4, .rodata, e_red_door] - [0x2D9DC, .rodata, e_collect] @@ -107,8 +108,9 @@ segments: - [0x36324, c, unk_36F30] - [0x395EC, c, cutscene] - [0x3AF60, c, e_candle_table] - - [0x3B200, c, unk_3BEB0] - - [0x3C57C, c, unk_3C57C] + - [0x3B200, c, unk_3B200] + - [0x3B53C, c, unk_3B53C] + - [0x3B8DC, c, e_lesser_demon] - [0x3EDD8, c, e_chair] - [0x3EFEC, c, unk_3EFEC] - [0x3F130, c, st_update] diff --git a/config/symbols.pspeu.stlib.txt b/config/symbols.pspeu.stlib.txt index 07bd6b859b..7df8aa6056 100644 --- a/config/symbols.pspeu.stlib.txt +++ b/config/symbols.pspeu.stlib.txt @@ -1,3 +1,6 @@ +D_80097910 = 0x091CE5A0; +D_80097928 = 0x091CE5B0; +D_80076E98 = 0x091E5140; CreateEntityFromLayout = 0x09237700; CreateEntityWhenInVerticalRange = 0x09237820; CreateEntityWhenInHorizontalRange = 0x092379B8; @@ -102,6 +105,7 @@ PrimDecreaseBrightness = 0x09251098; EntityThornweed = 0x09251168; EntityCorpseweed = 0x092515F8; EntityCorpseweedProjectile = 0x09252858; +func_us_801BB53C = 0x09254288; EntityBreakable = 0x092546D0; EntityChair = 0x09254DC0; func_us_801BB8DC = 0x09255D78; @@ -119,6 +123,7 @@ LIB_EntityBackgroundBlock = 0x0925D350; EntityLibrarianChair = 0x0925E018; PlayerIsWithinHitbox = 0x0926CE18; EntityLockCamera = 0x0926CF18; +func_us_801BB200 = 0x0926D5E0; EntityCandleTable = 0x0926DAA8; explosionVariantSizes = 0x0926F738; g_UnkRecursPrim2Inds = 0x0926F798; @@ -147,6 +152,7 @@ g_EInitThornweed = 0x09276138; g_EInitCorpseweed = 0x09276148; g_EInitCorpseweedProjectile = 0x09276158; D_us_801808FC = 0x09276168; +D_us_8018095C = 0x092761D8; g_EInitSkeleton = 0x09276228; g_EInitSkeletonPieces = 0x09276238; g_EInitSkeletonBone = 0x09276248; @@ -166,6 +172,7 @@ D_us_801812C0 = 0x092A4600; D_us_801812C8 = 0x092A4608; D_us_801812D0 = 0x092A4610; D_us_801812D8 = 0x092A4618; +D_us_80181AA8 = 0x092A4DC8; D_us_80181A68 = 0x092A4DE8; D_us_80181A78 = 0x092A4DF8; g_LayoutObjPosVertical = 0x092A5400; @@ -178,6 +185,7 @@ D_psp_0924BC68 = 0x092A5470; D_psp_0924BC70 = 0x092A5478; D_psp_0924BC78 = 0x092A5480; LIB_cutscene_data = 0x092A54F8; +D_us_80181AC8 = 0x092A56F8; D_us_80181ACC = 0x092A5700; D_us_80181AD0 = 0x092A5708; g_IsCutsceneDone = 0x092A5728; diff --git a/include/entity.h b/include/entity.h index cda68198bc..105975d345 100644 --- a/include/entity.h +++ b/include/entity.h @@ -2854,6 +2854,12 @@ typedef struct { /* 0x84 */ s16 unk84; } ET_801B56E4; +typedef struct { + /* 0x7C */ s32 : 32; + /* 0x80 */ s32 : 32; + /* 0x84 */ u8 unk84; +} ET_801BB200; + typedef union { // offset=0x7C struct Primitive* prim; ET_Placeholder ILLEGAL; @@ -3101,6 +3107,7 @@ typedef union { // offset=0x7C ET_801AE8E8 et_801AE8E8; ET_FleaArmor fleaArmor; ET_801B56E4 et_801B56E4; + ET_801BB200 et_801BB200; } Ext; #define SYNC_FIELD(struct1, struct2, field) \ diff --git a/src/st/lib/unk_3C57C.c b/src/st/lib/e_lesser_demon.c similarity index 97% rename from src/st/lib/unk_3C57C.c rename to src/st/lib/e_lesser_demon.c index 26af2a423b..a32c6f8b82 100644 --- a/src/st/lib/unk_3C57C.c +++ b/src/st/lib/e_lesser_demon.c @@ -1,13 +1,23 @@ // SPDX-License-Identifier: AGPL-3.0-or-later #include "lib.h" -INCLUDE_ASM("st/lib/nonmatchings/unk_3C57C", func_us_801BC57C); +// Lesser demon start +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BB8DC); -INCLUDE_ASM("st/lib/nonmatchings/unk_3C57C", func_us_801BC814); +u8 func_us_801BBAB4(void); +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BBAB4); + +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BBEB0); + +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BC28C); + +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BC57C); + +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BC814); -INCLUDE_ASM("st/lib/nonmatchings/unk_3C57C", func_us_801BCC10); +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BCC10); -INCLUDE_ASM("st/lib/nonmatchings/unk_3C57C", func_us_801BCFD4); +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BCFD4); extern s32 D_psp_092A5510; extern s32 D_psp_092A5560; @@ -238,7 +248,7 @@ void func_us_801BD268(void) { } u8 func_us_801BDA34(void); -INCLUDE_ASM("st/lib/nonmatchings/unk_3C57C", func_us_801BDA34); +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BDA34); u8 func_us_801BBAB4(void); @@ -827,4 +837,4 @@ void func_us_801BDAE4(Entity* self) { } } -INCLUDE_ASM("st/lib/nonmatchings/unk_3C57C", func_us_801BED48); +INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BED48); diff --git a/src/st/lib/lib.h b/src/st/lib/lib.h index a8a50e2f78..03640107a5 100644 --- a/src/st/lib/lib.h +++ b/src/st/lib/lib.h @@ -24,12 +24,14 @@ typedef enum EntityIDs { // /* 0x0F */ E_DUMMY_0F, // /* 0x10 */ E_DUMMY_10, // /* 0x11 */ E_ID_11, + /* 0x12 */ E_ID_12 = 0x12, // /* 0x13 */ E_UNK_ID_13, /* 0x14 */ E_ID_14 = 0x14, /* 0x15 */ E_GREY_PUFF, /* 0x1C */ E_ID_1C = 0x1C, /* 0x1D */ E_BLOOD_DRIPS, /* 0x1E */ E_BLOOD_SPLATTER, + /* 0x1F */ E_ID_1F, /* 0x20 */ E_ID_20 = 0x20, /* 0x21 */ E_ID_21, /* 0x22 */ E_ID_22, @@ -51,6 +53,8 @@ typedef enum EntityIDs { /* 0x3C */ E_CORPSEWEED_PROJECTILE, /* 0x3D */ E_CANDLE_TABLE, /* 0x3E */ E_ID_3E = 0x3E, + /* 0x40 */ E_ID_40 = 0x40, + /* 0x42 */ E_ID_42 = 0x42, /* 0x43 */ E_SKELETON = 0x43, /* 0x44 */ E_SKELETON_THROWN_BONE, /* 0x45 */ E_SKELETON_PIECES, diff --git a/src/st/lib/unk_3B200.c b/src/st/lib/unk_3B200.c new file mode 100644 index 0000000000..392b12a46b --- /dev/null +++ b/src/st/lib/unk_3B200.c @@ -0,0 +1,116 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +#include "lib.h" + +#ifdef VERSION_PSP +extern s32 D_psp_092A5578; +#endif +extern u16 D_us_8018095C; +extern u16 D_us_80181AA8[][2]; +extern s32 D_us_80181AC8; + +// This seems to be related to the Lesser Demon boss fight somehow, but not the +// Lesser Demon itself. +void func_us_801BB200(Entity* self) { + s32 i; + s32 params; + s32 adjustedY; + s32 upperParams; + s32 tilePos; + Entity* newEntity; + + switch (self->step) { + case 0: + InitializeEntity(&D_us_8018095C); + params = self->params & 0xFF; + self->animCurFrame = params + 0xF; + self->zPriority = 0x69; + if (self->params & 0x100) { + self->facingLeft = 1; + } + self->ext.et_801BB200.unk84 = 0; + if (!self->params) { + newEntity = self + 1; + for (i = 1; i < 4; i++, newEntity++) { +#ifdef VERSION_PSP + CreateEntityFromCurrentEntity(D_psp_092A5578, newEntity); +#else + CreateEntityFromCurrentEntity(E_ID_40, newEntity); +#endif + newEntity->params = i; + } + for (i = 0; i < 4; i++, newEntity++) { +#ifdef VERSION_PSP + CreateEntityFromCurrentEntity(D_psp_092A5578, newEntity); +#else + CreateEntityFromCurrentEntity(E_ID_40, newEntity); +#endif + newEntity->params = i + 0x100; + } + } + self->posY.i.hi = 0x258 - g_Tilemap.scrollY.i.hi; + if (self->params & 0x100) { + self->posX.i.hi = 0x2E0 - g_Tilemap.scrollX.i.hi; + } else { + self->posX.i.hi = 0x120 - g_Tilemap.scrollX.i.hi; + } + break; + case 1: + if ((D_us_80181AC8) && (!(self->params & 0xFF))) { + self->step = 2; + } + if (self->ext.et_801BB200.unk84) { + self->step = 2; + } + break; + case 2: + self->velocityY = FIX(4.0); + self->step++; + /* fallthrough */ + case 3: + MoveEntity(); + self->velocityY += FIX(0.125); + params = self->params & 0xFF; + upperParams = self->params >> 8; + adjustedY = ((3 - params) * 16) + 0x268 - (g_Tilemap.scrollY.i.hi); + if (adjustedY < self->posY.i.hi) { + if (params != 4) { + newEntity = self + 1; + newEntity->ext.et_801BB200.unk84 = 1; + } + self->posY.i.hi = adjustedY; + tilePos = 0xBF2; + if (self->params & 0x100) { + g_api.PlaySfx(SFX_DOOR_CLOSE_B); + tilePos = 0xC0D; + } + tilePos += ((3 - params) * 0x50); + g_Tilemap.fg[tilePos] = D_us_80181AA8[7 - params][upperParams]; + self->velocityY = 0; + self->step++; + } + break; + case 4: + if (!D_us_80181AC8) { + self->step++; + } + break; + case 5: + tilePos = 0xBF2; + params = self->params & 0xFF; + upperParams = self->params >> 8; + if (self->params & 0x100) { + tilePos = 0xC0D; + } + tilePos += ((3 - params) * 0x50); + g_Tilemap.fg[tilePos] = D_us_80181AA8[3 - params][upperParams]; + newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]); + if (newEntity != NULL) { + CreateEntityFromEntity(2, self, newEntity); + newEntity->params = 3; + } + self->animCurFrame = 0; + self->step++; + case 6: + break; + } +} diff --git a/src/st/lib/unk_3B53C.c b/src/st/lib/unk_3B53C.c new file mode 100644 index 0000000000..5b4c829b1c --- /dev/null +++ b/src/st/lib/unk_3B53C.c @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +#include "lib.h" + +// Using an include to consolidate the code because it doesn't seem that PSP can +// be split in a way to allow merging at this time. +#include "unk_3B53C.h" diff --git a/src/st/lib/unk_3B53C.h b/src/st/lib/unk_3B53C.h new file mode 100644 index 0000000000..ae2c766109 --- /dev/null +++ b/src/st/lib/unk_3B53C.h @@ -0,0 +1,128 @@ +// SPDX-License-Identifier: AGPL-3.0-or-later +#ifdef VERSION_PSP +extern s32 D_psp_092A5680; +extern s32 D_psp_092A56E8; +extern s32 D_psp_092A5568; +extern Entity D_91E5084; +#endif +extern s32 D_80097910; +extern s32 D_80097928; +extern s32 D_us_80181AC8; +extern s32 D_us_80181ACC; +extern s32 D_us_80181AD0; +extern Entity D_80076E98; + +// PSX symbols unused in code, but referenced in ASM so may be needed for +// importing the data. +// D_80076E9A = tempEntity->posX.i.hi +// D_80076E9E = tempEntity->posY.i.hi +// D_80076E0C = tempEntity->params +// D_80076DDE = (tempEntity-1)->posX.i.hi +// D_80076DE2 = (tempEntity-1)->posY.i.hi + +// This also seems to be related to the Lesser Demon boss fight somehow, but not +// the Lesser Demon itself. Possibly the books that block escape from the +// fight. +void func_us_801BB53C(Entity* self) { + Entity* tempEntity; + s32 x, y; + s32 timeAttackRecord; + + switch (self->step) { + case 0: + InitializeEntity(g_EInitInteractable); + timeAttackRecord = g_api.TimeAttackController( + TIMEATTACK_EVENT_LESSER_DEMON_DEFEAT, TIMEATTACK_GET_RECORD); + if (timeAttackRecord) { + DestroyEntity(self); + return; + } + tempEntity = &D_80076E98; + +#ifdef VERSION_PSP + CreateEntityFromCurrentEntity(D_psp_092A5680, tempEntity); +#else + CreateEntityFromCurrentEntity(E_ID_1F, tempEntity); +#endif + + tempEntity->posX.i.hi = 0x200 - g_Tilemap.scrollX.i.hi; + tempEntity->posY.i.hi = 0x2A0 - g_Tilemap.scrollY.i.hi; + +#ifdef VERSION_PSP + tempEntity = &D_91E5084; + CreateEntityFromCurrentEntity(D_psp_092A56E8, tempEntity); +#else + CreateEntityFromCurrentEntity(E_ID_12, --tempEntity); +#endif + + tempEntity->params = 6; + tempEntity->posX.i.hi = 0x200 - g_Tilemap.scrollX.i.hi; + tempEntity->posY.i.hi = 0x270 - g_Tilemap.scrollY.i.hi; + case 1: + tempEntity = &g_Entities[0]; + x = tempEntity->posX.i.hi + g_Tilemap.scrollX.i.hi; + y = tempEntity->posY.i.hi + g_Tilemap.scrollY.i.hi; + if (x > 0x170 && x < 0x290 && y > 0x220 && y < 0x2c0) { + D_us_80181AC8 = 1; + D_us_80181ACC |= 1; + g_api.TimeAttackController( + TIMEATTACK_EVENT_LESSER_DEMON_DEFEAT, TIMEATTACK_SET_VISITED); + self->step++; + } + break; + case 2: + if (g_api.func_80131F68()) { + g_api.PlaySfx(SET_UNK_90); + } + D_80097928 = 1; + D_80097910 = MU_FESTIVAL_OF_SERVANTS; + self->step++; + break; + case 3: + if (!g_api.func_80131F68()) { + D_80097928 = 0; + g_api.PlaySfx(D_80097910); + self->step++; + } + /* fallthrough */ + case 4: + if (D_us_80181ACC & 0x2) { + g_api.TimeAttackController( + TIMEATTACK_EVENT_LESSER_DEMON_DEFEAT, TIMEATTACK_SET_RECORD); + if (g_api.func_80131F68() != 0) { + g_api.PlaySfx(SET_UNK_90); + } + D_80097910 = MU_WOOD_CARVING_PARTITA; + self->step = 5; + } + break; + case 5: + if (D_us_80181ACC & 0x4) { + tempEntity = AllocEntity(&g_Entities[160], &g_Entities[192]); + if (tempEntity != NULL) { +#ifdef VERSION_PSP + CreateEntityFromEntity(D_psp_092A5568, self, tempEntity); +#else + CreateEntityFromEntity(E_ID_42, self, tempEntity); +#endif + tempEntity->posX.i.hi = 0x80; + tempEntity->posY.i.hi = 0x80; + tempEntity->params = 7; + D_us_80181AC8 = 0; + D_80097928 = 1; + D_80097910 = MU_WOOD_CARVING_PARTITA; + D_us_80181AD0 = 1; + D_us_80181ACC &= ~1; + self->step++; + } + } + break; + case 6: + if (!g_api.func_80131F68()) { + D_80097928 = 0; + g_api.PlaySfx(D_80097910); + self->step++; + } + break; + } +} diff --git a/src/st/lib/unk_3BEB0.c b/src/st/lib/unk_3BEB0.c deleted file mode 100644 index 3b8b9196fc..0000000000 --- a/src/st/lib/unk_3BEB0.c +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-or-later -#include "lib.h" - -INCLUDE_ASM("st/lib/nonmatchings/unk_3BEB0", func_us_801BB200); - -INCLUDE_ASM("st/lib/nonmatchings/unk_3BEB0", func_us_801BB53C); - -INCLUDE_ASM("st/lib/nonmatchings/unk_3BEB0", func_us_801BB8DC); - -u8 func_us_801BBAB4(void); -INCLUDE_ASM("st/lib/nonmatchings/unk_3BEB0", func_us_801BBAB4); - -INCLUDE_ASM("st/lib/nonmatchings/unk_3BEB0", func_us_801BBEB0); - -INCLUDE_ASM("st/lib/nonmatchings/unk_3BEB0", func_us_801BC28C); diff --git a/src/st/lib_psp/1B7F0.c b/src/st/lib_psp/1B7F0.c index 0ff9884072..98247f6ac2 100644 --- a/src/st/lib_psp/1B7F0.c +++ b/src/st/lib_psp/1B7F0.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: AGPL-3.0-or-later -#include "common.h" +#include "../lib/lib.h" INCLUDE_ASM("st/lib_psp/psp/lib_psp/1B7F0", func_psp_09252E70); @@ -15,4 +15,7 @@ INCLUDE_ASM("st/lib_psp/psp/lib_psp/1B7F0", func_psp_09253E20); INCLUDE_ASM("st/lib_psp/psp/lib_psp/1B7F0", func_psp_09254120); -INCLUDE_ASM("st/lib_psp/psp/lib_psp/1B7F0", func_psp_09254288); +// Using an include to consolidate the code because I can't get +// the psp split in a way that allows merging at this time. +// func_us_801BB53C +#include "../lib/unk_3B53C.h" diff --git a/src/st/lib_psp/35F60.c b/src/st/lib_psp/35F60.c deleted file mode 100644 index da7a3de135..0000000000 --- a/src/st/lib_psp/35F60.c +++ /dev/null @@ -1,4 +0,0 @@ -// SPDX-License-Identifier: AGPL-3.0-or-later -#include "../lib/lib.h" - -INCLUDE_ASM("st/lib_psp/psp/lib_psp/35F60", func_psp_0926D5E0);