Skip to content

Commit 3b7e0a9

Browse files
Decompiled func_us_801B4DA4 / func_pspeu_0925A248 (Xeeynamo#2762)
PSP: https://decomp.me/scratch/VSCcm PSX: https://decomp.me/scratch/D1atn This is a big one. There are difference between two versions this time. Somehow I cannot import that ``RECT`` struct correctly (endianness shenanigans). I'll try it another time.
1 parent 49380d2 commit 3b7e0a9

File tree

2 files changed

+298
-2
lines changed

2 files changed

+298
-2
lines changed

src/st/no2/34DA4.c

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

4-
INCLUDE_ASM("st/no2/nonmatchings/34DA4", func_us_801B4DA4);
4+
// already in e_init.c
5+
extern EInit D_us_80180844[];
6+
// st/no2/data/34DA4.rodata.s
7+
extern RECT D_us_801B2E20;
8+
9+
void func_us_801B4DA4(Entity* self) {
10+
DRAWENV draw;
11+
RECT rect;
12+
DR_ENV* dr_env;
13+
Primitive* prim;
14+
s32 i;
15+
s32 primIndex;
16+
u8 flag;
17+
18+
rect = D_us_801B2E20;
19+
switch (self->step) {
20+
case 0:
21+
InitializeEntity(D_us_80180844);
22+
primIndex = g_api.func_800EDB58(PRIM_GT4, 8);
23+
if (primIndex != -1) {
24+
self->flags |= FLAG_HAS_PRIMS;
25+
self->primIndex = primIndex;
26+
prim = &g_PrimBuf[primIndex];
27+
dr_env = g_api.func_800EDB08((POLY_GT4*)prim);
28+
if (dr_env == NULL) {
29+
DestroyEntity(self);
30+
return;
31+
}
32+
prim->type = PRIM_ENV;
33+
prim->priority = 0x13F;
34+
prim->drawMode = DRAW_HIDE;
35+
prim = prim->next;
36+
dr_env = g_api.func_800EDB08((POLY_GT4*)prim);
37+
if (dr_env == NULL) {
38+
DestroyEntity(self);
39+
return;
40+
}
41+
prim->type = PRIM_ENV;
42+
prim->priority = 0x141;
43+
prim->drawMode = DRAW_UNK_800;
44+
prim = prim->next;
45+
self->ext.prim = prim;
46+
while (prim != NULL) {
47+
prim->drawMode = DRAW_HIDE;
48+
prim = prim->next;
49+
}
50+
return;
51+
}
52+
DestroyEntity(self);
53+
return;
54+
case 1:
55+
prim = &g_PrimBuf[self->primIndex];
56+
draw = g_CurrentBuffer->draw;
57+
if (draw.ofs[0] == 0) {
58+
flag = 0;
59+
} else {
60+
flag = 1;
61+
}
62+
draw.isbg = 1;
63+
draw.r0 = 0;
64+
draw.g0 = 0;
65+
draw.b0 = 0;
66+
draw.dtd = 1;
67+
draw.clip = rect;
68+
draw.ofs[0] = 0;
69+
draw.ofs[1] = 0x100;
70+
dr_env = *(DR_ENV**)&prim->r1;
71+
SetDrawEnv(dr_env, &draw);
72+
prim->drawMode = DRAW_DEFAULT;
73+
prim = prim->next;
74+
prim = self->ext.prim;
75+
for (i = 2; i >= 0; i--) {
76+
prim->type = PRIM_GT4;
77+
prim->tpage = 0x110;
78+
prim->u0 = prim->u2 = 0;
79+
prim->u1 = prim->u3 = prim->u0 + 0x28;
80+
prim->v0 = prim->v1 = 0;
81+
prim->v2 = prim->v3 = prim->v0 + 0x28;
82+
prim->x0 = prim->x2 = i * 0xA;
83+
prim->x1 = prim->x3 = prim->x0 + (0x50 - (i * 0x14));
84+
prim->y0 = prim->y1 = (i * 0xA) + 0x40;
85+
prim->y2 = prim->y3 = prim->y0 + (0x50 - (i * 0x14));
86+
prim->r0 = prim->g0 = prim->b0 = 0xFF;
87+
LOW(prim->r1) = LOW(prim->r0);
88+
LOW(prim->r2) = LOW(prim->r0);
89+
LOW(prim->r3) = LOW(prim->r0);
90+
prim->priority = 0x140;
91+
prim->drawMode = DRAW_TPAGE2 | DRAW_TPAGE | DRAW_TRANSP;
92+
if (i == 0) {
93+
prim->drawMode = DRAW_DEFAULT;
94+
}
95+
prim->drawMode |= DRAW_COLORS;
96+
prim = prim->next;
97+
}
98+
prim->type = PRIM_GT4;
99+
prim->tpage = 0x1A;
100+
prim->clut = 0x15F;
101+
prim->u0 = prim->u2 = 0x10;
102+
prim->u1 = prim->u3 = 0x20;
103+
prim->v0 = prim->v1 = 0xD0;
104+
prim->v2 = prim->v3 = 0xE0;
105+
prim->x0 = prim->x2 = 0;
106+
prim->x1 = prim->x3 = 0x28;
107+
prim->y0 = prim->y1 = 0;
108+
prim->y2 = prim->y3 = 0x28;
109+
prim->r0 = 0x40;
110+
prim->g0 = 0x38;
111+
prim->b0 = 0x38;
112+
LOW(prim->r1) = LOW(prim->r0);
113+
LOW(prim->r2) = LOW(prim->r0);
114+
LOW(prim->r3) = LOW(prim->r0);
115+
prim->priority = 0x140;
116+
prim->drawMode = DRAW_UNK_40 | DRAW_TPAGE | DRAW_COLORS | DRAW_TRANSP;
117+
prim = prim->next;
118+
prim->type = PRIM_GT4;
119+
prim->tpage = (flag) ? 0x104 : 0x100;
120+
prim->u0 = prim->u2 = 0x8B;
121+
prim->u1 = prim->u3 = 0xB3;
122+
prim->v0 = prim->v1 = 0x37;
123+
prim->v2 = prim->v3 = 0x5F;
124+
prim->x0 = prim->x2 = 0;
125+
prim->x1 = prim->x3 = 0x28;
126+
prim->y0 = prim->y1 = 0;
127+
prim->y2 = prim->y3 = 0x28;
128+
prim->priority = 0x140;
129+
prim->drawMode = DRAW_DEFAULT;
130+
prim = prim->next;
131+
prim->type = PRIM_GT4;
132+
prim->tpage = 0x110;
133+
prim->u0 = prim->u2 = 4;
134+
prim->u1 = prim->u3 = 0x4C;
135+
prim->v0 = prim->v1 = 0x44;
136+
prim->v2 = prim->v3 = 0x8C;
137+
prim->x0 = prim->x2 = 0x7B;
138+
prim->x1 = prim->x3 = 0xC3;
139+
prim->y0 = prim->y1 = 0x27;
140+
prim->y2 = prim->y3 = 0x6F;
141+
prim->r0 = 0x10;
142+
prim->g0 = 0x8;
143+
prim->b0 = 0x10;
144+
LOW(prim->r1) = LOW(prim->r0);
145+
LOW(prim->r2) = LOW(prim->r0);
146+
LOW(prim->r3) = LOW(prim->r0);
147+
prim->priority = 0x142;
148+
prim->drawMode =
149+
DRAW_UNK_400 | DRAW_TPAGE2 | DRAW_TPAGE | DRAW_COLORS | DRAW_TRANSP;
150+
return;
151+
}
152+
}
5153

6154
INCLUDE_ASM("st/no2/nonmatchings/34DA4", func_us_801B52B4);
7155

src/st/no2_psp/22BC8.c

Lines changed: 149 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,152 @@
11
// SPDX-License-Identifier: AGPL-3.0-or-later
22
#include "../no2/no2.h"
33

4-
INCLUDE_ASM("st/no2_psp/nonmatchings/no2_psp/22BC8", func_pspeu_0925A248);
4+
// st/no2_psp/data/no2_psp/e_init.data.s
5+
extern EInit D_pspeu_09266648;
6+
// st/no2_psp/data/no2_psp/55990.data.s
7+
extern RECT D_pspeu_0928D028;
8+
9+
void func_pspeu_0925A248(Entity* self) {
10+
DRAWENV draw;
11+
RECT rect;
12+
DR_ENV* dr_env;
13+
Primitive* prim;
14+
s32 i;
15+
s32 primIndex;
16+
u8 flag;
17+
18+
rect = D_pspeu_0928D028;
19+
switch (self->step) {
20+
case 0:
21+
InitializeEntity(D_pspeu_09266648);
22+
primIndex = g_api.func_800EDB58(PRIM_GT4, 8);
23+
if (primIndex != -1) {
24+
self->flags |= FLAG_HAS_PRIMS;
25+
self->primIndex = primIndex;
26+
prim = &g_PrimBuf[primIndex];
27+
dr_env = g_api.func_800EDB08((POLY_GT4*)prim);
28+
if (dr_env == NULL) {
29+
DestroyEntity(self);
30+
return;
31+
}
32+
prim->type = PRIM_ENV;
33+
prim->priority = 0x13F;
34+
prim->drawMode = DRAW_HIDE;
35+
prim = prim->next;
36+
dr_env = g_api.func_800EDB08((POLY_GT4*)prim);
37+
if (dr_env == NULL) {
38+
DestroyEntity(self);
39+
return;
40+
}
41+
prim->type = PRIM_ENV;
42+
prim->priority = 0x141;
43+
prim->drawMode = DRAW_UNK_800;
44+
prim = prim->next;
45+
self->ext.prim = (Primitive*)prim;
46+
while (prim != NULL) {
47+
prim->drawMode = DRAW_HIDE;
48+
prim = prim->next;
49+
}
50+
return;
51+
}
52+
DestroyEntity(self);
53+
return;
54+
case 1:
55+
prim = &g_PrimBuf[self->primIndex];
56+
draw = g_CurrentBuffer->draw;
57+
if (draw.ofs[0] == 0) {
58+
flag = 0;
59+
} else {
60+
flag = 1;
61+
}
62+
draw.isbg = 1;
63+
draw.r0 = 0;
64+
draw.g0 = 0;
65+
draw.b0 = 0;
66+
draw.dtd = 1;
67+
draw.clip = rect;
68+
draw.ofs[0] = 0;
69+
draw.ofs[1] = 0x100;
70+
dr_env = *(DR_ENV**)&prim->r1;
71+
SetDrawEnv(dr_env, &draw);
72+
prim->drawMode = DRAW_DEFAULT;
73+
prim = prim->next;
74+
prim = self->ext.prim;
75+
for (i = 2; i >= 0; i--) {
76+
prim->type = PRIM_GT4;
77+
prim->tpage = 0x1110;
78+
prim->u0 = prim->u2 = 0;
79+
prim->u1 = prim->u3 = prim->u0 + 0x28;
80+
prim->v0 = prim->v1 = 0;
81+
prim->v2 = prim->v3 = prim->v0 + 0x28;
82+
prim->x0 = prim->x2 = i * 0xA;
83+
prim->x1 = prim->x3 = prim->x0 + (0x50 - (i * 0x14));
84+
prim->y0 = prim->y1 = (i * 0xA) + 0x40;
85+
prim->y2 = prim->y3 = prim->y0 + (0x50 - (i * 0x14));
86+
prim->r0 = prim->g0 = prim->b0 = 0xFF;
87+
LOW(prim->r1) = LOW(prim->r0);
88+
LOW(prim->r2) = LOW(prim->r0);
89+
LOW(prim->r3) = LOW(prim->r0);
90+
prim->priority = 0x140;
91+
prim->drawMode = DRAW_TPAGE2 | DRAW_TPAGE | DRAW_TRANSP;
92+
if (i == 0) {
93+
prim->drawMode = DRAW_DEFAULT;
94+
}
95+
prim->drawMode |= DRAW_COLORS;
96+
prim = prim->next;
97+
}
98+
prim->type = PRIM_GT4;
99+
prim->tpage = 0x101A;
100+
prim->clut = 0x15F;
101+
prim->u0 = prim->u2 = 0x10;
102+
prim->u1 = prim->u3 = 0x20;
103+
prim->v0 = prim->v1 = 0xD0;
104+
prim->v2 = prim->v3 = 0xE0;
105+
prim->x0 = prim->x2 = 0;
106+
prim->x1 = prim->x3 = 0x28;
107+
prim->y0 = prim->y1 = 0;
108+
prim->y2 = prim->y3 = 0x28;
109+
prim->r0 = 0x40;
110+
prim->g0 = 0x38;
111+
prim->b0 = 0x38;
112+
LOW(prim->r1) = LOW(prim->r0);
113+
LOW(prim->r2) = LOW(prim->r0);
114+
LOW(prim->r3) = LOW(prim->r0);
115+
prim->priority = 0x140;
116+
prim->drawMode = DRAW_UNK_40 | DRAW_TPAGE | DRAW_COLORS | DRAW_TRANSP;
117+
prim = prim->next;
118+
prim->type = PRIM_GT4;
119+
prim->tpage = 0x104;
120+
prim->u0 = prim->u2 = 0x8B;
121+
prim->u1 = prim->u3 = 0xB3;
122+
prim->v0 = prim->v1 = 0x37;
123+
prim->v2 = prim->v3 = 0x5F;
124+
prim->x0 = prim->x2 = 0;
125+
prim->x1 = prim->x3 = 0x28;
126+
prim->y0 = prim->y1 = 0;
127+
prim->y2 = prim->y3 = 0x28;
128+
prim->priority = 0x140;
129+
prim->drawMode = DRAW_DEFAULT;
130+
prim = prim->next;
131+
prim->type = PRIM_GT4;
132+
prim->tpage = 0x1110;
133+
prim->u0 = prim->u2 = 4;
134+
prim->u1 = prim->u3 = 0x4C;
135+
prim->v0 = prim->v1 = 0x44;
136+
prim->v2 = prim->v3 = 0x8C;
137+
prim->x0 = prim->x2 = 0x7B;
138+
prim->x1 = prim->x3 = 0xC3;
139+
prim->y0 = prim->y1 = 0x27;
140+
prim->y2 = prim->y3 = 0x6F;
141+
prim->r0 = 0x20;
142+
prim->g0 = 0x10;
143+
prim->b0 = 0x20;
144+
LOW(prim->r1) = LOW(prim->r0);
145+
LOW(prim->r2) = LOW(prim->r0);
146+
LOW(prim->r3) = LOW(prim->r0);
147+
prim->priority = 0x142;
148+
prim->drawMode =
149+
DRAW_UNK_400 | DRAW_TPAGE2 | DRAW_TPAGE | DRAW_COLORS | DRAW_TRANSP;
150+
return;
151+
}
152+
}

0 commit comments

Comments
 (0)