Skip to content

Commit fc3519c

Browse files
authored
PSP NO3 EntityTransparentWater Decomp/Codeshare (Xeeynamo#2567)
Nothing special here, no code changes needed, just some light file shuffling.
1 parent 1b9424a commit fc3519c

11 files changed

+333
-323
lines changed

config/splat.pspeu.stno3.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ segments:
4949
- [0x13C8, c, no3/e_heartroom]
5050
- [0x19A0, c, no3/entrance_weights]
5151
- [0x22C0, c, no3/e_cavern_door]
52-
- [0x2C60, c, no3_psp/2C60]
52+
- [0x2C60, c, no3/e_transparent_water]
53+
- [0x3050, c, no3/e_background_bushes_trees]
54+
- [0x3958, c, no3_psp/working_on]
5355
- [0x1AA80, c, no3_psp/e_particles]
5456
- [0x1F830, c, no3_psp/e_misc]
5557
- [0x21CC8, c, no3_psp/collision]
@@ -61,11 +63,15 @@ segments:
6163
- [0x347E0, data]
6264
- [0x5E430, .data, no3/e_castle_door]
6365
- [0x5E530, .data, no3/e_cavern_door]
64-
- [0x5E540, data]
66+
- [0x5E540, .data, no3/e_transparent_water]
67+
- [0x5E580, .data, no3/e_background_bushes_trees]
68+
- [0x5E630, data]
6569
- [0x61600, .rodata, no3/e_castle_door]
66-
- [0x61618, .rodata, no3_psp/2C60] # EntityPushAlucard
70+
- [0x61618, .rodata, no3_psp/working_on] # EntityPushAlucard
6771
- [0x61810, .rodata, no3_psp/e_particles]
6872
- [0x61880, .rodata, no3_psp/e_misc]
6973
- [0x618A8, .rodata, no3_psp/collision]
70-
- {type: bss, vram: 0x9298F80}
71-
- [0x61900]
74+
- [0x61900, bss, 61900]
75+
- [0x61BB0, .bss, no3/e_background_bushes_trees]
76+
- [0x61BC0, bss, 61BC0]
77+
- [0x62280]

config/splat.us.stno3.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ segments:
5050
- [0xE90, data]
5151
- [0xEA0, .data, entrance_stage_entities]
5252
- [0x1044, .data, e_castle_door]
53-
- [0x1140, .data, entrance_stage_entities_2]
53+
- [0x1140, .data, e_background_bushes_trees]
5454
- [0x123C, .data, entrance_stage_entities_3]
5555
- [0x13A8, data]
5656
- [0x1ACC, .data, cutscene]
@@ -164,7 +164,8 @@ segments:
164164
- [0x37A64, c, e_breakable]
165165
- [0x37B98, c, entrance_stage_entities]
166166
- [0x38564, c, e_castle_door]
167-
- [0x38A74, c, entrance_stage_entities_2]
167+
- [0x38A74, c, e_background_bushes_trees]
168+
- [0x39198, c, e_transparent_water]
168169
- [0x394F0, c, e_cavern_door]
169170
- [0x39C44, c, entrance_weights]
170171
- [0x3A348, c, entrance_stage_entities_3]

config/splat.us.stnp3.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ segments:
4545
- [0xE18, .data, e_breakable]
4646
- [0xE78, .data, entrance_stage_entities]
4747
- [0xF0C, .data, e_castle_door]
48-
- [0x1008, .data, entrance_stage_entities_2]
48+
- [0x1008, .data, e_background_bushes_trees]
4949
- [0x1104, .data, entrance_stage_entities_3]
5050
- [0x122C, data]
5151
- [0x1300, data]
@@ -165,7 +165,8 @@ segments:
165165
- [0x326FC, c, e_breakable]
166166
- [0x32830, c, entrance_stage_entities]
167167
- [0x32F30, c, e_castle_door]
168-
- [0x332A8, c, entrance_stage_entities_2]
168+
- [0x332A8, c, e_background_bushes_trees]
169+
- [0x339CC, c, e_transparent_water]
169170
- [0x33D24, c, e_cavern_door]
170171
- [0x344B4, c, entrance_weights]
171172
- [0x34BE8, c, entrance_stage_entities_3]

src/st/entrance_stage_entities_2.h renamed to src/st/e_background_bushes_trees.h

Lines changed: 9 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,16 @@ static u8 bush_uvwh[] = {
88
// Seems to be used when continuing a bush from one of the above starts?
99
static u8 bush_uvwh_cont[] = {
1010
UVWH(0x80, 0x80, 0x38, 0x42), UVWH(0x80, 0x80, 0x2C, 0x34)};
11-
// clang-format off
12-
static s16 bush_unk_data[] = {0, 20, 0, 32, 1, 32, 0, 8, 2, 20, 1, 16, 0xFFFF, 0,
13-
3, 63, 0xFFFF, 0,
14-
4, 64, 4, 96, 0xFFFF, 0,
15-
5, 80, 5, 96, 5, 32, 0xFFFF, 0};
16-
// clang-format on
11+
static s16 bush_unk_1[] = {0, 20, 0, 32, 1, 32, 0, 8, 2, 20, 1, 16, 0xFFFF, 0};
12+
static s16 bush_unk_2[] = {3, 63, 0xFFFF, 0};
13+
static s16 bush_unk_3[] = {4, 64, 4, 96, 0xFFFF, 0};
14+
static s16 bush_unk_4[] = {5, 80, 5, 96, 5, 32, 0xFFFF, 0};
1715
// VZ, Priority, Clut, and an X value. 4 such sets.
1816
static s16 bush_render_data[] = {
1917
0x00C0, 0x005E, 0x0017, 0x0080, 0x0200, 0x005B, 0x0014, 0x003F,
2018
0x0140, 0x005D, 0x003C, 0x00A0, 0x01C0, 0x005C, 0x003C, 0x00D0};
21-
static s16* bush_unk_starts[] = {&bush_unk_data[0], &bush_unk_data[14],
22-
&bush_unk_data[18], &bush_unk_data[24]};
19+
static s16* bush_unk_starts[] = {
20+
bush_unk_1, bush_unk_2, bush_unk_3, bush_unk_4};
2321
static s16 backgroundTreePositions[][2] = {
2422
{0x200, 0}, {0x280, 12}, {0x300, 4}, {0x380, 16}};
2523
static u16 backgroundTreeCluts[] = {0x15, 0x46, 0x47, 0x48};
@@ -40,9 +38,9 @@ void EntityBackgroundBushes(Entity* self) {
4038
s32 yOffset;
4139
s16 xPos;
4240
s16 yPos;
43-
s32 rotTransXYResult;
44-
s32 unused1; // return args for rottranspers
45-
s32 unused2; // we don't use them.
41+
long rotTransXYResult;
42+
long unused1; // return args for rottranspers
43+
long unused2; // we don't use them.
4644
VECTOR trans;
4745
MATRIX m;
4846

@@ -217,105 +215,3 @@ void EntityBackgroundTrees(Entity* self) {
217215
prim = prim->next;
218216
}
219217
}
220-
221-
static u8 transWaterCluts[] = {
222-
0x24, 0x1A, 0x21, 0x1A, 0x2B, 0x1B, 0x22, 0x1B, 0x2C, 0x1C, 0x23,
223-
0x1C, 0x2D, 0x1D, 0x24, 0x1D, 0x2E, 0x1E, 0x25, 0x1E, 0x2F, 0x1F,
224-
0x26, 0x1F, 0x56, 0x20, 0x21, 0x20, 0xFF, 0x00, 0x00, 0x00};
225-
static u8 transWaterUV[] = {
226-
UVWH(0xA1, 0x01, 0x26, 0x3E), UVWH(0xC9, 0x01, 0x26, 0x3E),
227-
UVWH(0xA1, 0x41, 0x26, 0x3E)};
228-
static u8 transWaterAnim[] = {10, 0, 10, 1, 10, 2, 10, 1, 0, 0, 0, 0};
229-
// Transparent water plane that can be seen in the merman room
230-
void EntityTransparentWater(Entity* self) {
231-
Primitive* prim;
232-
s32 primIndex;
233-
u32 selfY;
234-
s32 uCoord;
235-
s32 vCoord;
236-
u8* uvPtr;
237-
u8* clutIdx;
238-
s32 prim_xPos;
239-
240-
switch (self->step) {
241-
case 0:
242-
InitializeEntity(g_EInitInteractable);
243-
self->ext.transparentWater.unk80 = 4;
244-
primIndex = g_api.AllocPrimitives(PRIM_GT4, 16);
245-
if (primIndex == -1) {
246-
DestroyEntity(self);
247-
return;
248-
}
249-
self->flags |= FLAG_HAS_PRIMS;
250-
self->primIndex = primIndex;
251-
prim = &g_PrimBuf[primIndex];
252-
self->ext.transparentWater.prim = prim;
253-
while (prim != NULL) {
254-
prim->tpage = 0xF;
255-
prim->clut = 0x18;
256-
prim->priority = 0xB0;
257-
prim->drawMode = DRAW_HIDE;
258-
prim = prim->next;
259-
}
260-
break;
261-
262-
case 1:
263-
clutIdx = &transWaterCluts[0];
264-
while (*clutIdx != 0xFF) {
265-
g_ClutIds[clutIdx[0]] = g_ClutIds[clutIdx[2] + 0x200];
266-
clutIdx += 4;
267-
}
268-
269-
if (!--self->ext.transparentWater.unk80) {
270-
self->ext.transparentWater.unk80 = 4;
271-
self->step++;
272-
}
273-
break;
274-
275-
case 2:
276-
clutIdx = &transWaterCluts[0];
277-
while (*clutIdx != 0xFF) {
278-
g_ClutIds[clutIdx[0]] = g_ClutIds[clutIdx[3] + 0x200];
279-
clutIdx += 4;
280-
}
281-
282-
if (!--self->ext.transparentWater.unk80) {
283-
self->ext.transparentWater.unk80 = 4;
284-
self->step--;
285-
}
286-
break;
287-
}
288-
289-
AnimateEntity(transWaterAnim, self);
290-
291-
prim_xPos = -1 * g_Tilemap.scrollX.i.hi % 38;
292-
prim_xPos += 304;
293-
if (self->params) {
294-
prim_xPos = 96;
295-
}
296-
297-
uvPtr = transWaterUV;
298-
uvPtr += 4 * self->animCurFrame;
299-
uCoord = uvPtr[0];
300-
vCoord = uvPtr[1];
301-
selfY = self->posY.i.hi;
302-
prim = self->ext.transparentWater.prim;
303-
while (prim_xPos > 0) {
304-
prim->u0 = prim->u2 = uCoord;
305-
prim->u1 = prim->u3 = uCoord + 0x26;
306-
prim->v0 = prim->v1 = vCoord;
307-
prim->v2 = prim->v3 = vCoord + 0x3E;
308-
prim->x1 = prim->x3 = prim_xPos;
309-
prim_xPos -= 0x26;
310-
prim->x0 = prim->x2 = prim_xPos;
311-
prim->y0 = prim->y1 = selfY;
312-
prim->y2 = prim->y3 = selfY + 0x3E;
313-
prim->drawMode = DRAW_TPAGE2 | DRAW_TPAGE | DRAW_UNK02 | DRAW_TRANSP;
314-
prim = prim->next;
315-
}
316-
317-
while (prim != NULL) {
318-
prim->drawMode = DRAW_HIDE;
319-
prim = prim->next;
320-
}
321-
}

src/st/e_transparent_water.h

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// SPDX-License-Identifier: AGPL-3.0-or-later
2+
#define UVWH(u, v, w, h) u, v, w, h
3+
4+
static u8 transWaterCluts[] = {
5+
0x24, 0x1A, 0x21, 0x1A, 0x2B, 0x1B, 0x22, 0x1B, 0x2C, 0x1C, 0x23,
6+
0x1C, 0x2D, 0x1D, 0x24, 0x1D, 0x2E, 0x1E, 0x25, 0x1E, 0x2F, 0x1F,
7+
0x26, 0x1F, 0x56, 0x20, 0x21, 0x20, 0xFF, 0x00, 0x00, 0x00};
8+
static u8 transWaterUV[] = {
9+
UVWH(0xA1, 0x01, 0x26, 0x3E), UVWH(0xC9, 0x01, 0x26, 0x3E),
10+
UVWH(0xA1, 0x41, 0x26, 0x3E)};
11+
static u8 transWaterAnim[] = {10, 0, 10, 1, 10, 2, 10, 1, 0, 0, 0, 0};
12+
// Transparent water plane that can be seen in the merman room
13+
void EntityTransparentWater(Entity* self) {
14+
Primitive* prim;
15+
s32 primIndex;
16+
u32 selfY;
17+
s32 uCoord;
18+
s32 vCoord;
19+
u8* uvPtr;
20+
u8* clutIdx;
21+
s32 prim_xPos;
22+
23+
switch (self->step) {
24+
case 0:
25+
InitializeEntity(g_EInitInteractable);
26+
self->ext.transparentWater.unk80 = 4;
27+
primIndex = g_api.AllocPrimitives(PRIM_GT4, 16);
28+
if (primIndex == -1) {
29+
DestroyEntity(self);
30+
return;
31+
}
32+
self->flags |= FLAG_HAS_PRIMS;
33+
self->primIndex = primIndex;
34+
prim = &g_PrimBuf[primIndex];
35+
self->ext.transparentWater.prim = prim;
36+
while (prim != NULL) {
37+
prim->tpage = 0xF;
38+
prim->clut = 0x18;
39+
prim->priority = 0xB0;
40+
prim->drawMode = DRAW_HIDE;
41+
prim = prim->next;
42+
}
43+
break;
44+
45+
case 1:
46+
clutIdx = &transWaterCluts[0];
47+
while (*clutIdx != 0xFF) {
48+
g_ClutIds[clutIdx[0]] = g_ClutIds[clutIdx[2] + 0x200];
49+
clutIdx += 4;
50+
}
51+
52+
if (!--self->ext.transparentWater.unk80) {
53+
self->ext.transparentWater.unk80 = 4;
54+
self->step++;
55+
}
56+
break;
57+
58+
case 2:
59+
clutIdx = &transWaterCluts[0];
60+
while (*clutIdx != 0xFF) {
61+
g_ClutIds[clutIdx[0]] = g_ClutIds[clutIdx[3] + 0x200];
62+
clutIdx += 4;
63+
}
64+
65+
if (!--self->ext.transparentWater.unk80) {
66+
self->ext.transparentWater.unk80 = 4;
67+
self->step--;
68+
}
69+
break;
70+
}
71+
72+
AnimateEntity(transWaterAnim, self);
73+
74+
prim_xPos = -1 * g_Tilemap.scrollX.i.hi % 38;
75+
prim_xPos += 304;
76+
if (self->params) {
77+
prim_xPos = 96;
78+
}
79+
80+
uvPtr = transWaterUV;
81+
uvPtr += 4 * self->animCurFrame;
82+
uCoord = uvPtr[0];
83+
vCoord = uvPtr[1];
84+
selfY = self->posY.i.hi;
85+
prim = self->ext.transparentWater.prim;
86+
while (prim_xPos > 0) {
87+
prim->u0 = prim->u2 = uCoord;
88+
prim->u1 = prim->u3 = uCoord + 0x26;
89+
prim->v0 = prim->v1 = vCoord;
90+
prim->v2 = prim->v3 = vCoord + 0x3E;
91+
prim->x1 = prim->x3 = prim_xPos;
92+
prim_xPos -= 0x26;
93+
prim->x0 = prim->x2 = prim_xPos;
94+
prim->y0 = prim->y1 = selfY;
95+
prim->y2 = prim->y3 = selfY + 0x3E;
96+
prim->drawMode = DRAW_TPAGE2 | DRAW_TPAGE | DRAW_UNK02 | DRAW_TRANSP;
97+
prim = prim->next;
98+
}
99+
100+
while (prim != NULL) {
101+
prim->drawMode = DRAW_HIDE;
102+
prim = prim->next;
103+
}
104+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// SPDX-License-Identifier: AGPL-3.0-or-later
22
#include "no3.h"
33

4-
#include "../entrance_stage_entities_2.h"
4+
#include "../e_background_bushes_trees.h"

src/st/no3/e_transparent_water.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// SPDX-License-Identifier: AGPL-3.0-or-later
2+
#include "no3.h"
3+
4+
#include "../e_transparent_water.h"

0 commit comments

Comments
 (0)