Skip to content

Commit

Permalink
Decompiled lib func_psp_09253E20 and related adjustments. (#2245)
Browse files Browse the repository at this point in the history
PSP: https://decomp.me/scratch/ykdyz

I added a macro to coalesce PSX and PSP EntityIDs, added the missing
EnitityIDs to the enum, added the PSP entity ID symbols, and cleaned up
existing code to use the macro.
  • Loading branch information
ProjectOblivion authored Feb 22, 2025
1 parent 84fbda1 commit 7516577
Show file tree
Hide file tree
Showing 10 changed files with 293 additions and 163 deletions.
63 changes: 63 additions & 0 deletions config/symbols.pspeu.stlib.txt
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,69 @@ D_psp_0924BC68 = 0x092A5470;
D_psp_0924BC70 = 0x092A5478;
D_psp_0924BC78 = 0x092A5480;
LIB_cutscene_data = 0x092A54F8;
D_psp_E_ID_4F = 0x092A5500;
D_psp_E_ID_4E = 0x092A5508;
D_psp_E_ID_4D = 0x092A5510;
D_psp_E_ID_4C = 0x092A5518;
D_psp_E_ID_4B = 0x092A5520;
D_psp_E_ID_4A = 0x092A5528;
D_psp_E_ID_49 = 0x092A5530;
D_psp_E_ID_48 = 0x092A5538;
D_psp_E_ID_47 = 0x092A5540;
D_psp_E_ID_46 = 0x092A5548;
D_psp_E_SKELETON_PIECES = 0x092A5550;
D_psp_E_SKELETON_THROWN_BONE = 0x092A5558;
D_psp_E_SKELETON = 0x092A5560;
D_psp_E_ID_42 = 0x092A5568;
D_psp_E_ID_41 = 0x092A5570;
D_psp_E_ID_40 = 0x092A5578;
D_psp_E_ID_3F = 0x092A5580;
D_psp_E_ID_3E = 0x092A5588;
D_psp_E_CANDLE_TABLE = 0x092A5590;
D_psp_E_CORPSEWEED_PROJECTILE = 0x092A5598;
D_psp_E_CORPSEWEED = 0x092A55A0;
D_psp_E_THORNWEED = 0x092A55A8;
D_psp_E_ID_39 = 0x092A55B0;
D_psp_E_ID_38 = 0x092A55B8;
D_psp_E_ID_37 = 0x092A55C0;
D_psp_E_ID_36 = 0x092A55C8;
D_psp_E_ID_35 = 0x092A55D0;
D_psp_E_ID_34 = 0x092A55D8;
D_psp_E_ID_33 = 0x092A55E0;
D_psp_E_ID_32 = 0x092A55E8;
D_psp_E_ID_31 = 0x092A55F0;
D_psp_E_ID_30 = 0x092A55F8;
D_psp_E_ID_2F = 0x092A5600;
D_psp_E_ID_2E = 0x092A5608;
D_psp_E_ID_2D = 0x092A5610;
D_psp_E_ID_2C = 0x092A5618;
D_psp_E_ID_2B = 0x092A5620;
D_psp_E_ID_2A = 0x092A5628;
D_psp_E_ID_29 = 0x092A5630;
D_psp_E_ID_28 = 0x092A5638;
D_psp_E_ID_27 = 0x092A5640;
D_psp_E_ID_26 = 0x092A5648;
D_psp_E_ID_25 = 0x092A5650;
D_psp_E_ID_24 = 0x092A5658;
D_psp_E_ID_23 = 0x092A5660;
D_psp_E_ID_22 = 0x092A5668;
D_psp_E_ID_21 = 0x092A5670;
D_psp_E_ID_20 = 0x092A5678;
D_psp_E_ID_1F = 0x092A5680;
D_psp_E_BLOOD_SPLATTER = 0x092A5688;
D_psp_E_BLOOD_DRIPS = 0x092A5690;
D_psp_E_ID_1C = 0x092A5698;
D_psp_E_ID_1B = 0x092A56A0;
D_psp_E_ID_1A = 0x092A56A8;
D_psp_E_ID_19 = 0x092A56B0;
D_psp_E_ID_18 = 0x092A56B8;
D_psp_E_ID_17 = 0x092A56C0;
D_psp_E_ID_16 = 0x092A56C8;
D_psp_E_GREY_PUFF = 0x092A56D0;
D_psp_E_ID_14 = 0x092A56D8;
D_psp_E_ID_13 = 0x092A56E0;
D_psp_E_ID_12 = 0x092A56E8;
D_psp_E_ID_11 = 0x092A56F0;
D_us_80181AC8 = 0x092A56F8;
D_us_80181ACC = 0x092A5700;
D_us_80181AD0 = 0x092A5708;
Expand Down
6 changes: 6 additions & 0 deletions include/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ typedef enum {

#include "entity.h"

#ifdef VERSION_PSP
#define E_ID(name) D_psp_E_##name
#else
#define E_ID(name) E_##name
#endif

#define COLORS_PER_PAL (16)
#define COLOR_BPP (16)
#define COLOR_LEN ((COLOR_BPP) / 8)
Expand Down
13 changes: 4 additions & 9 deletions src/st/lib/e_candle_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ static u8 D_us_80181A68[] = {3, 1, 3, 2, 3, 3, 3, 4, 3, 5, 3, 6, 3, 7, 0, 0};
static u8 D_us_80181A78[] = {
3, 9, 3, 10, 3, 11, 3, 12, 3, 13, 3, 14, 3, 15, 3, 16, 0, 0};

extern s32 D_psp_092A5590;

#ifdef VERSION_PSP
static s32 D_us_80181A8C = 0;
// I expect this symbol will change depending on the function that is including
// pad2_anim_debug.h
extern s32 E_ID(CANDLE_TABLE);
// I expect this symbol will change depending on the function that is
// including pad2_anim_debug.h
extern s32 D_8B42050;
#define BUTTON_SYMBOL D_8B42050
#else
Expand Down Expand Up @@ -50,11 +49,7 @@ void EntityCandleTable(Entity* self) {
self->hitboxOffY = -10;
self->hitboxState = 2;
newEntity = self + 1;
#ifdef VERSION_PSP
CreateEntityFromEntity(D_psp_092A5590, self, newEntity);
#else
CreateEntityFromEntity(E_CANDLE_TABLE, self, newEntity);
#endif
CreateEntityFromEntity(E_ID(CANDLE_TABLE), self, newEntity);

newEntity->params = 0x100;
}
Expand Down
52 changes: 16 additions & 36 deletions src/st/lib/e_lesser_demon.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BCC10);

INCLUDE_ASM("st/lib/nonmatchings/e_lesser_demon", func_us_801BCFD4);

extern s32 D_psp_092A5510;
extern s32 D_psp_092A5560;
extern s32 D_psp_092A55C0;
#ifdef VERSION_PSP
extern s32 E_ID(ID_37);
extern s32 E_ID(E_SKELETON);
extern s32 E_ID(ID_4D);
#endif

// Lesser Demon minion spawn?
// Seems like the vertical tractor beam effect that spawns
Expand Down Expand Up @@ -144,27 +146,15 @@ void func_us_801BD268(void) {
switch (Random() & 3) {
case 0:
case 1:
#ifdef VERSION_PSP
entityId = D_psp_092A5510;
#else
entityId = E_ID_4D;
#endif
entityId = E_ID(ID_4D);
break;

case 2:
#ifdef VERSION_PSP
entityId = D_psp_092A55C0;
#else
entityId = E_ID_37;
#endif
entityId = E_ID(ID_37);
break;

case 3:
#ifdef VERSION_PSP
entityId = D_psp_092A5560;
#else
entityId = E_SKELETON;
#endif
entityId = E_ID(SKELETON);
break;
}
CreateEntityFromEntity(
Expand Down Expand Up @@ -267,9 +257,11 @@ extern u8 D_us_80181B9C[];
extern u8 D_us_80181BAC[];
extern u8 D_us_80181BBC[];
extern s16 D_us_80181C34[];
extern s32 D_psp_092A5668;
extern s32 D_psp_092A5670;
extern s32 D_psp_092A5678;
#ifdef VERSION_PSP
extern s32 E_ID(ID_22);
extern s32 E_ID(ID_21);
extern s32 E_ID(ID_20);
#endif

// Lesser Demon
void func_us_801BDAE4(Entity* self) {
Expand Down Expand Up @@ -499,11 +491,7 @@ void func_us_801BDAE4(Entity* self) {
}
tempEntity = AllocEntity(&g_Entities[160], &g_Entities[192]);
if (tempEntity != NULL) {
#ifdef VERSION_PSP
CreateEntityFromEntity(D_psp_092A5668, self, tempEntity);
#else
CreateEntityFromEntity(E_ID_22, self, tempEntity);
#endif
CreateEntityFromEntity(E_ID(ID_22), self, tempEntity);
self->ext.et_801BDAE4.unk88 = tempEntity;
} else {
self->ext.et_801BDAE4.unk88 = NULL;
Expand Down Expand Up @@ -594,11 +582,7 @@ void func_us_801BDAE4(Entity* self) {
if (func_us_801BBAB4()) {
tempEntity = AllocEntity(&g_Entities[160], &g_Entities[192]);
if (tempEntity != NULL) {
#ifdef VERSION_PSP
CreateEntityFromEntity(D_psp_092A5678, self, tempEntity);
#else
CreateEntityFromEntity(E_ID_20, self, tempEntity);
#endif
CreateEntityFromEntity(E_ID(ID_20), self, tempEntity);
tempEntity->facingLeft = self->facingLeft;
if (self->facingLeft) {
tempEntity->posX.i.hi += 12;
Expand Down Expand Up @@ -636,11 +620,7 @@ void func_us_801BDAE4(Entity* self) {
self->ext.et_801BDAE4.unk84 = 2;
tempEntity = AllocEntity(&g_Entities[160], &g_Entities[192]);
if (tempEntity != NULL) {
#ifdef VERSION_PSP
CreateEntityFromEntity(D_psp_092A5670, self, tempEntity);
#else
CreateEntityFromEntity(E_ID_21, self, tempEntity);
#endif
CreateEntityFromEntity(E_ID(ID_21), self, tempEntity);
tempEntity->facingLeft = self->facingLeft;
}
}
Expand Down
56 changes: 39 additions & 17 deletions src/st/lib/lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,47 +23,69 @@ typedef enum EntityIDs {
/* 0x0E */ E_MESSAGE_BOX = 0x0E,
// /* 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,
/* 0x11 */ E_ID_11 = 0x11,
/* 0x12 */ E_ID_12,
/* 0x13 */ E_ID_13,
/* 0x14 */ E_ID_14,
/* 0x15 */ E_GREY_PUFF,
/* 0x1C */ E_ID_1C = 0x1C,
/* 0x16 */ E_ID_16,
/* 0x17 */ E_ID_17,
/* 0x18 */ E_ID_18,
/* 0x19 */ E_ID_19,
/* 0x1A */ E_ID_1A,
/* 0x1B */ E_ID_1B,
/* 0x1C */ E_ID_1C,
/* 0x1D */ E_BLOOD_DRIPS,
/* 0x1E */ E_BLOOD_SPLATTER,
/* 0x1F */ E_ID_1F,
/* 0x20 */ E_ID_20 = 0x20,
/* 0x20 */ E_ID_20,
/* 0x21 */ E_ID_21,
/* 0x22 */ E_ID_22,
/* 0x27 */ E_ID_27 = 0x27,
/* 0x23 */ E_ID_23,
/* 0x24 */ E_ID_24,
/* 0x25 */ E_ID_25,
/* 0x26 */ E_ID_26,
/* 0x27 */ E_ID_27,
/* 0x28 */ E_ID_28,
/* 0x29 */ E_ID_29,
/* 0x2A */ E_ID_2A,
/* 0x2D */ E_ID_2D = 0x2D,
/* 0x2B */ E_ID_2B,
/* 0x2C */ E_ID_2C,
/* 0x2D */ E_ID_2D,
/* 0x2E */ E_ID_2E,
/* 0x2F */ E_ID_2F,
/* 0x31 */ E_ID_31 = 0x31,
/* 0x33 */ E_ID_33 = 0x33,
/* 0x30 */ E_ID_30,
/* 0x31 */ E_ID_31,
/* 0x32 */ E_ID_32,
/* 0x33 */ E_ID_33,
/* 0x34 */ E_ID_34,
/* 0x35 */ E_ID_35,
/* 0x36 */ E_ID_36,
/* 0x37 */ E_ID_37,
/* 0x3A */ E_THORNWEED = 0x3A,
/* 0x38 */ E_ID_38,
/* 0x39 */ E_ID_39,
/* 0x3A */ E_THORNWEED,
/* 0x3B */ E_CORPSEWEED,
/* 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,
/* 0x3E */ E_ID_3E,
/* 0x3F */ E_ID_3F,
/* 0x40 */ E_ID_40,
/* 0x41 */ E_ID_41,
/* 0x42 */ E_ID_42,
/* 0x43 */ E_SKELETON,
/* 0x44 */ E_SKELETON_THROWN_BONE,
/* 0x45 */ E_SKELETON_PIECES,
/* 0x48 */ E_ID_48 = 0x48,
/* 0x4A */ E_ID_4A = 0x4A,
/* 0x46 */ E_ID_46,
/* 0x47 */ E_ID_47,
/* 0x48 */ E_ID_48,
/* 0x49 */ E_ID_49,
/* 0x4A */ E_ID_4A,
/* 0x4B */ E_ID_4B,
/* 0x4C */ E_ID_4C,
/* 0x4D */ E_ID_4D,
/* 0x4E */ E_ID_4E,
/* 0x4F */ E_ID_4F,
} EntityIDs;

extern void EntityBloodDrips(Entity*);
Expand Down
Loading

0 comments on commit 7516577

Please sign in to comment.