Skip to content

Commit 965a9d6

Browse files
Codeshared cen and chi e_breakable (#2933)
1 parent f35e83d commit 965a9d6

File tree

14 files changed

+278
-612
lines changed

14 files changed

+278
-612
lines changed

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,6 @@ set(SOURCE_FILES_STAGE_CEN
329329
src/st/cen/e_room_bg.c
330330
src/st/cen/e_lock_camera.c
331331
src/st/cen/e_breakable.c
332-
src/st/cen/DB18.c
333332
src/st/cen/d_prize_drops.c
334333
src/st/cen/cutscene.c
335334
src/st/cen/F890.c

config/splat.hd.stcen.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ segments:
7272
- [0xD5E8, c, e_room_bg]
7373
- [0xD6C8, c, e_lock_camera]
7474
- [0xD884, c, e_breakable]
75-
- [0xDB00, c, DB18]
7675
- [0xDEF4, c, cutscene]
7776
- [0xF818, c, F890]
7877
- [0x10DA0, c, st_update]

config/splat.pspeu.stchi.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ segments:
8080
- [0x19770, .data, chi/en_thornweed_corpseweed]
8181
- [0x19840, data]
8282
- [0x1D3F8, .data, chi/e_red_door_tiles]
83-
- [0x1D428, .data, chi_psp/dt_entity]
83+
- [0x1D428, .data, chi/dt_entity]
8484
- [0x1D630, data]
8585
- [0x1D6D0, .data, chi/en_breakable]
8686
- [0x1D758, .data, chi/en_stage_name]

config/splat.us.stcen.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ segments:
7777
- [0xD600, c, e_room_bg]
7878
- [0xD6E0, c, e_lock_camera]
7979
- [0xD89C, c, e_breakable]
80-
- [0xDB18, c]
8180
- [0xDF0C, c, cutscene]
8281
- [0xF890, c]
8382
- [0x10E4C, c, st_update]

include/entity.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,11 +2095,6 @@ typedef struct {
20952095
/* 0x80 */ s16 timer;
20962096
} ET_BloodSkeleton;
20972097

2098-
typedef struct {
2099-
/* 0x7C */ s32 : 32;
2100-
/* 0x80 */ s16 angle;
2101-
} ET_UnusedCENEnt;
2102-
21032098
typedef struct {
21042099
// not a physical angular direction, but the swaying left and right
21052100
// moves in a sinusoidal manner so uses an angle internally.
@@ -3720,7 +3715,6 @@ typedef union { // offset=0x7C
37203715
ET_CEN_Elevator cenElevator;
37213716
ET_TOP_Elevator topElevator;
37223717
ET_BloodSkeleton bloodSkeleton;
3723-
ET_UnusedCENEnt unusedCENEnt;
37243718
ET_SmallRisingHeart smallRisingHeart;
37253719
ET_EntranceUnk16 entrance16;
37263720

src/st/cen/DB18.c

Lines changed: 0 additions & 116 deletions
This file was deleted.

src/st/cen/cen.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@
99

1010
#define OVL_EXPORT(x) CEN_##x
1111

12+
enum OVL_EXPORT(Palette) {
13+
PAL_NONE = 0,
14+
PAL_BREAKABLE_DEBRIS = 0x159,
15+
};
16+
1217
typedef enum EntityIDs {
1318
/* 0x00 */ E_NONE,
1419
/* 0x01 */ E_ID_01,
@@ -39,7 +44,7 @@ typedef enum EntityIDs {
3944
/* 0x1A */ E_ELEVATOR_STATIONARY_UNUSED,
4045
/* 0x1B */ E_ELEVATOR_STATIONARY,
4146
/* 0x1C */ E_MOVING_ELEVATOR,
42-
/* 0x80 */ E_BREAKABLE_UNK0 = 0x80,
47+
/* 0x80 */ E_BREAKABLE_DEBRIS = 0x80,
4348
} EntityIDs;
4449

4550
void CreateEntityFromCurrentEntity(u16 entityId, Entity* entity);

src/st/cen/e_breakable.c

Lines changed: 4 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -4,98 +4,8 @@
44
#include "game.h"
55
#include "sfx.h"
66

7-
static u8 anim_1[] = {3, 14, 4, 15, 4, 16, 4, 17, 4, 18, 4, 19, 3, 20};
8-
static u8 anim_2[] = {3, 21, 4, 22, 4, 23, 4, 24, 4, 25, 4, 26, 3, 27};
7+
#define BREAKABLE_ZPRIORITY 176
8+
#define NO_HITBOX_STATE
99

10-
static u8* g_eBreakableAnimations[] = {
11-
anim_1, anim_2, NULL, NULL, NULL, NULL, NULL, NULL};
12-
static u8 g_eBreakableHitboxes[] = {12, 20, 0, 0, 0, 0, 0, 0};
13-
14-
static u8 g_eBreakableExplosionTypes[] = {3, 3, 0, 0, 0, 0, 0, 0};
15-
16-
static u16 g_eBreakableanimSets[] = {
17-
ANIMSET_OVL(1), ANIMSET_OVL(1), 0, 0, 0, 0, 0, 0,
18-
};
19-
20-
static u8 g_eBreakableDrawModes[] = {
21-
DRAW_TPAGE | DRAW_TPAGE2,
22-
DRAW_TPAGE | DRAW_TPAGE2,
23-
DRAW_DEFAULT,
24-
DRAW_DEFAULT,
25-
DRAW_DEFAULT,
26-
DRAW_DEFAULT,
27-
DRAW_DEFAULT,
28-
DRAW_DEFAULT,
29-
};
30-
31-
static s16 xyOffsets[] = {
32-
-4, -4, 3, -6, 2, 9, -4, 12, 0, 2, 0, 15, 0, 31,
33-
};
34-
35-
void EntityBreakable(Entity* self) {
36-
Entity* newEntity;
37-
u16* ptr;
38-
s32 j;
39-
s32 i;
40-
u16 breakableType = self->params >> 0xC;
41-
42-
if (self->step == 0) {
43-
InitializeEntity(OVL_EXPORT(EInitBreakable));
44-
self->zPriority = 0xB0;
45-
self->drawMode = g_eBreakableDrawModes[breakableType];
46-
newEntity = &self[1];
47-
self->hitboxHeight = g_eBreakableHitboxes[breakableType];
48-
self->animSet = g_eBreakableanimSets[breakableType];
49-
DestroyEntity(newEntity);
50-
CreateEntityFromEntity(E_BACKGROUND_BLOCK, self, newEntity);
51-
if (breakableType != 0) {
52-
self[1].posY.i.hi -= 32;
53-
} else {
54-
self[1].posY.i.hi -= 16;
55-
}
56-
newEntity->params = 1;
57-
}
58-
59-
AnimateEntity(g_eBreakableAnimations[breakableType], self);
60-
61-
if (self->hitParams) {
62-
g_api.PlaySfx(SFX_CANDLE_HIT);
63-
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
64-
if (newEntity != 0) {
65-
CreateEntityFromCurrentEntity(E_EXPLOSION, newEntity);
66-
newEntity->params =
67-
g_eBreakableExplosionTypes[breakableType] | 0x10;
68-
}
69-
70-
for (ptr = &xyOffsets, i = 0; i < 4; i++) {
71-
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
72-
if (newEntity != 0) {
73-
CreateEntityFromEntity(E_BREAKABLE_UNK0, self, newEntity);
74-
newEntity->posX.i.hi += *ptr;
75-
ptr++;
76-
newEntity->posY.i.hi = newEntity->posY.i.hi + *ptr;
77-
ptr++;
78-
if (breakableType != 0) {
79-
newEntity->posY.i.hi -= 20;
80-
}
81-
newEntity->params = i;
82-
}
83-
}
84-
85-
if (breakableType != 0) {
86-
for (j = 0; j < 3; j++) {
87-
newEntity = AllocEntity(&g_Entities[224], &g_Entities[256]);
88-
if (newEntity != 0) {
89-
CreateEntityFromEntity(E_BREAKABLE_UNK0, self, newEntity);
90-
newEntity->posX.i.hi += *ptr;
91-
ptr++;
92-
newEntity->posY.i.hi += *ptr;
93-
ptr++;
94-
newEntity->params = j + 4;
95-
}
96-
}
97-
}
98-
ReplaceBreakableWithItemDrop(self);
99-
DestroyEntity(&self[1]);
100-
}
101-
}
10+
// These functions are unused since there are no breakables in CEN
11+
#include "../e_breakable_with_lighting.h"

src/st/cen/e_init.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: AGPL-3.0-or-later
22
#include "cen.h"
33

4-
void EntityBreakable(Entity*);
4+
void OVL_EXPORT(EntityBreakable)(Entity*);
55
void EntityExplosion(Entity*);
66
void EntityPrizeDrop(Entity*);
77
void EntityDamageDisplay(Entity*);
@@ -30,7 +30,7 @@ void EntityUnkId1B(Entity*);
3030
void EntityMovingElevator(Entity*);
3131

3232
PfnEntityUpdate OVL_EXPORT(EntityUpdates)[] = {
33-
EntityBreakable,
33+
OVL_EXPORT(EntityBreakable),
3434
EntityExplosion,
3535
EntityPrizeDrop,
3636
EntityDamageDisplay,

src/st/chi/chi.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414

1515
#define OVL_EXPORT(x) CHI_##x
1616

17+
enum OVL_EXPORT(Palette) {
18+
PAL_NONE = 0,
19+
PAL_BREAKABLE_DEBRIS = 0x159,
20+
};
21+
1722
typedef enum {
1823
/* 0x00 */ E_NONE,
1924
/* 0x01 */ E_BREAKABLE,

0 commit comments

Comments
 (0)