Skip to content

Commit 257c77d

Browse files
committed
xCM work
1 parent a67ff3c commit 257c77d

File tree

2 files changed

+190
-0
lines changed

2 files changed

+190
-0
lines changed

src/SB/Core/x/xCM.cpp

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,114 @@
11
#include "xCM.h"
2+
#include "xEvent.h"
23

34
#include <types.h>
5+
6+
volatile static F32 credits_time;
7+
static xCreditsData* credits_data;
8+
static U32 credits_parentID;
9+
F32 dtscale;
10+
11+
void xCMprep(xCreditsData* data)
12+
{
13+
/*
14+
data seems to point to this general structure:
15+
0x00 - xCMheader
16+
0x18 - xCMcredits
17+
0x50 - xCMpreset* presets_array[xCMcredits.num_presets]
18+
- xCMhunk* hunk_array[?]
19+
*/
20+
21+
char* dp; // In the DWARF. Don't know what this is used for.
22+
xCMheader* hdr = (xCMheader*)data;
23+
24+
if (hdr->magic != 0xBEEEEEEF)
25+
{
26+
return;
27+
}
28+
29+
xCMcredits* cp = (xCMcredits *)(&hdr[1]);
30+
while (((int)cp - (int)data) < hdr->total_size)
31+
{
32+
xCMpreset* pp = (xCMpreset*)(&cp[1]);
33+
xCMhunk* hp = (xCMhunk*)(&pp[cp->num_presets]);
34+
35+
for ( ; (U32)((int)hp - (int)cp) < cp->credits_size; hp = (xCMhunk*)((int)hp + hp->hunk_size))
36+
{
37+
switch (pp[hp->preset].align)
38+
{
39+
case 0:
40+
case 1:
41+
case 2:
42+
case 3:
43+
44+
if (hdr->state == 0)
45+
{
46+
if (hp->text1 != NULL)
47+
{
48+
hp->text1 -= (int)data;
49+
}
50+
if (hp->text2 != NULL)
51+
{
52+
hp->text2 -= (int)data;
53+
}
54+
}
55+
else
56+
{
57+
if (hp->text1 != NULL)
58+
{
59+
hp->text1 += (int)data;
60+
}
61+
if (hp->text2 != NULL)
62+
{
63+
hp->text2 += (int)data;
64+
}
65+
}
66+
break;
67+
}
68+
}
69+
cp = (xCMcredits*)hp;
70+
}
71+
72+
hdr->state = hdr->state == 0 ? 1 : 0;
73+
}
74+
75+
void xCMupdate(F32 time)
76+
{
77+
if (credits_data != 0)
78+
{
79+
credits_time += (time * dtscale);
80+
if (credits_time >= *(F32*)((int)&credits_data->dummy + 0x10))
81+
{
82+
xCMstop();
83+
}
84+
}
85+
}
86+
87+
void xCMrender()
88+
{
89+
xCMrender(credits_time, credits_data);
90+
}
91+
92+
void xCMstart(xCreditsData* data, F32 time, xBase* parent)
93+
{
94+
if ((credits_data = data) != NULL)
95+
{
96+
credits_time = 0.0f;
97+
98+
if (parent != NULL)
99+
{
100+
credits_parentID = parent->id;
101+
}
102+
}
103+
}
104+
105+
// Equivalent: scheduling
106+
void xCMstop()
107+
{
108+
credits_time = 10000.0f;
109+
credits_data = NULL;
110+
if (credits_parentID != 0)
111+
{
112+
zEntEvent(credits_parentID, 0x212);
113+
}
114+
}

src/SB/Core/x/xCM.h

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,87 @@ struct xCreditsData
99
U32 dummy;
1010
};
1111

12+
class xCMheader
13+
{
14+
// total size: 0x18
15+
public:
16+
unsigned int magic; // offset 0x0, size 0x4
17+
unsigned int version; // offset 0x4, size 0x4
18+
unsigned int crdID; // offset 0x8, size 0x4
19+
unsigned int state; // offset 0xC, size 0x4
20+
float total_time; // offset 0x10, size 0x4
21+
unsigned int total_size; // offset 0x14, size 0x4
22+
};
23+
24+
class sxy
25+
{
26+
// total size: 0x8
27+
public:
28+
float x; // offset 0x0, size 0x4
29+
float y; // offset 0x4, size 0x4
30+
};
31+
32+
class fade
33+
{
34+
// total size: 0x8
35+
public:
36+
float start; // offset 0x0, size 0x4
37+
float end; // offset 0x4, size 0x4
38+
};
39+
40+
class xCMtextbox
41+
{
42+
// total size: 0x20
43+
public:
44+
unsigned int font; // offset 0x0, size 0x4
45+
class iColor_tag color; // offset 0x4, size 0x4
46+
class sxy char_size; // offset 0x8, size 0x8
47+
class sxy char_spacing; // offset 0x10, size 0x8
48+
class sxy box; // offset 0x18, size 0x8
49+
};
50+
51+
class xCMpreset
52+
{
53+
// total size: 0x4C
54+
public:
55+
unsigned short num; // offset 0x0, size 0x2
56+
unsigned short align; // offset 0x2, size 0x2
57+
float delay; // offset 0x4, size 0x4
58+
float innerspace; // offset 0x8, size 0x4
59+
class xCMtextbox box[2]; // offset 0xC, size 0x40
60+
};
61+
62+
class xCMhunk
63+
{
64+
// total size: 0x18
65+
public:
66+
unsigned int hunk_size; // offset 0x0, size 0x4
67+
unsigned int preset; // offset 0x4, size 0x4
68+
float t0; // offset 0x8, size 0x4
69+
float t1; // offset 0xC, size 0x4
70+
char * text1; // offset 0x10, size 0x4
71+
char * text2; // offset 0x14, size 0x4
72+
};
73+
74+
class xCMcredits
75+
{
76+
// total size: 0x38
77+
public:
78+
unsigned int credits_size; // offset 0x0, size 0x4
79+
float len; // offset 0x4, size 0x4
80+
unsigned int flags; // offset 0x8, size 0x4
81+
sxy in; // offset 0xC, size 0x8
82+
sxy out; // offset 0x14, size 0x8
83+
float scroll_rate; // offset 0x1C, size 0x4
84+
float lifetime; // offset 0x20, size 0x4
85+
fade fin; // offset 0x24, size 0x8
86+
fade fout; // offset 0x2C, size 0x8
87+
unsigned int num_presets; // offset 0x34, size 0x4
88+
};
89+
1290
void xCMupdate(F32 dt);
1391
void xCMrender();
92+
void xCMrender(F32 time, xCreditsData* data);
1493
void xCMstart(xCreditsData* data, F32, xBase* parent);
1594
void xCMstop();
1695

0 commit comments

Comments
 (0)