Skip to content

Commit 6e30e94

Browse files
authored
Some fixes (isledecomp#494)
1 parent bb80038 commit 6e30e94

25 files changed

Lines changed: 284 additions & 199 deletions

GolDP/include/scene/golbillboard.h

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class GolD3DRenderDevice;
1111
class GolRenderDevice;
1212
class DuskwindBananaRelic0x24;
1313

14+
typedef void(__cdecl* GolBillboardInitializerFunction)();
15+
extern GolBillboardInitializerFunction g_unk0x1005c010;
16+
1417
// VTABLE: GOLDP 0x10057500
1518
// SIZE 0x4c
1619
class GolBillboard : public GolWorldEntity {
@@ -36,6 +39,7 @@ class GolBillboard : public GolWorldEntity {
3639
};
3740

3841
GolBillboard();
42+
static void FUN_10014e20();
3943

4044
// FUNCTION: GOLDP 0x100156c0
4145
void VTable0x08(const GolVec3& p_v) override { GolWorldEntity::VTable0x08(p_v); } // vtable+0x08
@@ -55,33 +59,35 @@ class GolBillboard : public GolWorldEntity {
5559
void FUN_10014ff0(GolD3DRenderDevice* p_renderer);
5660
void FUN_10026fa0(LegoFloat p_arg1);
5761
VTable0x4cReturn FUN_10029e90(
58-
Field0x2c* p_container,
62+
MaterialTable0x0c* p_container,
5963
LegoS32 p_index,
6064
LegoFloat p_width,
6165
LegoFloat p_height,
6266
LegoFloat p_maxDistanceSquared
6367
);
6468
void FUN_10029fa0(const GolVec3& p_arg1, LegoBool32* p_result);
6569
DuskwindBananaRelic0x24* FUN_1002a020();
66-
Field0x2c* GetPositionContainer() const { return m_positionContainer; }
70+
MaterialTable0x0c* GetPositionContainer() const { return m_positionContainer; }
6771
LegoU16 GetFlags() const { return m_flags; }
6872
void SetWidth(LegoFloat p_width) { m_width = p_width; }
6973
void SetHeight(LegoFloat p_height) { m_height = p_height; }
74+
void EnableFlagBit1() { m_flags |= c_flagBit1; }
75+
void SetUnk0x30(const GolVec3& p_unk0x30) { m_unk0x30 = p_unk0x30; }
7076

7177
private:
7278
static GolVec3 g_billboardPositions[4];
7379
static GolVec2 g_billboardTexCoords[4];
7480
static LegoU32 g_billboardColors[4];
7581
static LegoU8 g_billboardTriangleIndices[8];
7682

77-
DuskwindBananaRelic0x24* m_position; // 0x28
78-
Field0x2c* m_positionContainer; // 0x2c
79-
GolVec3 m_unk0x30; // 0x30
80-
LegoFloat m_width; // 0x3c
81-
LegoFloat m_height; // 0x40
82-
LegoFloat m_maxDistanceSquared; // 0x44
83-
LegoU16 m_flags; // 0x48
84-
LegoU16 m_positionIndex; // 0x4a
83+
DuskwindBananaRelic0x24* m_position; // 0x28
84+
MaterialTable0x0c* m_positionContainer; // 0x2c
85+
GolVec3 m_unk0x30; // 0x30
86+
LegoFloat m_width; // 0x3c
87+
LegoFloat m_height; // 0x40
88+
LegoFloat m_maxDistanceSquared; // 0x44
89+
LegoU16 m_flags; // 0x48
90+
LegoU16 m_positionIndex; // 0x4a
8591
};
8692

8793
#endif // GOLBILLBOARD_H

GolDP/src/render/gold3drenderdevice.cpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ inline static LegoU32 BuildModelClipFlags(const GolD3DRenderDevice::VertexCacheE
6262
return lowFlags | (highFlags & ~(lowFlags << 1));
6363
}
6464

65-
inline static LegoFloat GetClipDistance(const GolD3DRenderDevice::VertexCacheEntry& p_vertex, LegoU32 p_plane)
65+
inline static LegoFloat GetClipDistance(
66+
const GolD3DRenderDevice::VertexCacheEntry& p_vertex,
67+
LegoU32 p_plane,
68+
LegoFloat p_farClip
69+
)
6670
{
6771
if (p_plane == 0x01) {
6872
return p_vertex.m_x;
@@ -80,7 +84,7 @@ inline static LegoFloat GetClipDistance(const GolD3DRenderDevice::VertexCacheEnt
8084
return p_vertex.m_z;
8185
}
8286

83-
return p_vertex.m_w - p_vertex.m_z;
87+
return p_vertex.m_z - p_farClip;
8488
}
8589

8690
inline static LegoU32 InterpolateColor(LegoU32 p_from, LegoU32 p_to, LegoFloat p_amount)
@@ -3675,7 +3679,6 @@ void GolD3DRenderDevice::FUN_1000d760(LegoU32 p_outputFirst, LegoU32 p_firstVert
36753679
vertex->sz = cache->m_z * vertex->rhw;
36763680
const LegoU8* sourceColor = reinterpret_cast<const LegoU8*>(&source->m_color);
36773681
vertex->color = (sourceColor[3] << 24) | (sourceColor[0] << 16) | (sourceColor[1] << 8) | sourceColor[2];
3678-
vertex->specular = m_unk0xc83fc;
36793682
vertex->tu = source->m_u + m_unk0xc83a0;
36803683
vertex->tv = source->m_v + m_unk0xc83a4;
36813684
}
@@ -3756,7 +3759,6 @@ void GolD3DRenderDevice::FUN_1000dbb0(LegoU32 p_outputFirst, LegoU32 p_firstVert
37563759
vertex->sz = cache->m_z * vertex->rhw;
37573760
const LegoU8* sourceColor = reinterpret_cast<const LegoU8*>(&source->m_color);
37583761
vertex->color = alpha | (sourceColor[0] << 16) | (sourceColor[1] << 8) | sourceColor[2];
3759-
vertex->specular = m_unk0xc83fc;
37603762
vertex->tu = source->m_u + m_unk0xc83a0;
37613763
vertex->tv = source->m_v + m_unk0xc83a4;
37623764
}
@@ -4219,12 +4221,12 @@ void GolD3DRenderDevice::FUN_1000edf0(undefined4 p_firstTriangle, undefined4 p_t
42194221
LegoU32 outputCount = 0;
42204222
LegoU32 previousIndex = vertexCount - 1;
42214223
LegoBool32 previousInside = (inputCache[previousIndex]->m_clipFlags & plane) == 0;
4222-
LegoFloat previousDistance = GetClipDistance(*inputCache[previousIndex], plane);
4224+
LegoFloat previousDistance = GetClipDistance(*inputCache[previousIndex], plane, farClip);
42234225
unionFlags = 0;
42244226

42254227
for (LegoU32 i = 0; i < vertexCount; i++) {
42264228
LegoBool32 currentInside = (inputCache[i]->m_clipFlags & plane) == 0;
4227-
LegoFloat currentDistance = GetClipDistance(*inputCache[i], plane);
4229+
LegoFloat currentDistance = GetClipDistance(*inputCache[i], plane, farClip);
42284230

42294231
if (previousInside != currentInside) {
42304232
LegoFloat delta = previousDistance - currentDistance;
@@ -4561,13 +4563,13 @@ void GolD3DRenderDevice::FUN_100106d0(undefined4 p_firstTriangle, undefined4 p_t
45614563
LegoU32 outputCount = 0;
45624564
LegoU32 previousIndex = inputIndices[vertexCount - 1];
45634565
LegoBool32 previousInside = (m_unk0xc38ec[previousIndex].m_clipFlags & plane) == 0;
4564-
LegoFloat previousDistance = GetClipDistance(m_unk0xc38ec[previousIndex], plane);
4566+
LegoFloat previousDistance = GetClipDistance(m_unk0xc38ec[previousIndex], plane, farClip);
45654567
unionFlags = 0;
45664568

45674569
for (LegoU32 i = 0; i < vertexCount; i++) {
45684570
LegoU32 currentIndex = inputIndices[i];
45694571
LegoBool32 currentInside = (m_unk0xc38ec[currentIndex].m_clipFlags & plane) == 0;
4570-
LegoFloat currentDistance = GetClipDistance(m_unk0xc38ec[currentIndex], plane);
4572+
LegoFloat currentDistance = GetClipDistance(m_unk0xc38ec[currentIndex], plane, farClip);
45714573

45724574
if (previousInside != currentInside) {
45734575
LegoFloat delta = previousDistance - currentDistance;

GolDP/src/render/golrasterizers1.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,13 @@ void FUN_100330d0(GolSoftwareRenderer* p_renderer, MipmapLevel* p_mipmap)
271271

272272
p_renderer->SetUnk0x34(p_mipmap);
273273

274+
if (!p_mipmap) {
275+
#pragma inline_depth(0)
276+
FUN_10032c80(p_renderer);
277+
#pragma inline_depth
278+
return;
279+
}
280+
274281
if (p_mipmap) {
275282
// LINE: GOLDP 0x100330f7
276283
if (p_mipmap->m_width == p_mipmap->m_height) {

GolDP/src/scene/golbillboard.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void GolBillboard::VTable0x4c(
4949

5050
// FUNCTION: GOLDP 0x10029e90
5151
void GolBillboard::FUN_10029e90(
52-
Field0x2c* p_container,
52+
MaterialTable0x0c* p_container,
5353
LegoS32 p_index,
5454
LegoFloat p_width,
5555
LegoFloat p_height,

GolDP/src/scene/golbillboardex.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ LegoU32 GolBillboard::g_billboardColors[4] = {0xffffffff, 0xffffffff, 0xffffffff
1515
// GLOBAL: GOLDP 0x1005ca5c
1616
LegoU8 GolBillboard::g_billboardTriangleIndices[8] = {1, 2, 0, 0, 3, 2, 1, 0};
1717

18+
// GLOBAL: GOLDP 0x1005675c
19+
extern const LegoFloat g_unk0x1005675c = 1.0f;
20+
21+
#pragma data_seg(".CRT$XCU")
22+
// GLOBAL: GOLDP 0x1005c010
23+
GolBillboardInitializerFunction g_unk0x1005c010 = &GolBillboard::FUN_10014e20;
24+
#pragma data_seg()
25+
26+
// STUB: GOLDP 0x10014e20
27+
void GolBillboard::FUN_10014e20()
28+
{
29+
g_billboardTexCoords[2].m_y = 0.0f;
30+
g_billboardTexCoords[1].m_y = g_unk0x1005675c;
31+
g_billboardTexCoords[2].m_x = g_unk0x1005675c;
32+
g_billboardTexCoords[3].m_x = g_unk0x1005675c;
33+
g_billboardTexCoords[3].m_y = g_unk0x1005675c;
34+
}
35+
1836
// STUB: GOLDP 0x10014e50
1937
LegoBool32 GolBillboard::FUN_10014e50(const GolVec3* p_arg1, const GolVec3* p_arg2, GolMatrix4* p_matrix)
2038
{

GolDP/src/world/golworlddatabaseex.cpp

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,6 @@ void GolWorldDatabaseEx::VTable0x08()
185185
// STUB: GOLDP 0x10017ac0
186186
undefined4* GolWorldDatabaseEx::VTable0x0c()
187187
{
188-
STUB(0x10017ac0);
189-
190188
LegoU32 i;
191189
GolD3DRenderDevice* textureRenderer = static_cast<GolD3DRenderDevice*>(m_unk0x04);
192190

@@ -238,6 +236,51 @@ undefined4* GolWorldDatabaseEx::VTable0x0c()
238236
VTable0x4c(i)->VTable0x04(m_unk0x04, fileName, m_binary);
239237
}
240238

239+
for (i = 0; i < m_unk0x6c; i++) {
240+
WdbBillboardSprite0x38* sprite = &m_unk0x70[i];
241+
GolBillboardEx* billboard = &m_unk0x100[i];
242+
LegoFloat maxDistanceSquared = sprite->m_unk0x28 * sprite->m_unk0x28;
243+
244+
if (sprite->m_flags & WdbBillboardSprite0x38::c_flagBit2) {
245+
LegoU32 materialTableIndex = sprite->m_unk0x34;
246+
if (materialTableIndex >= m_unk0x2c) {
247+
GOL_FATALERROR_MESSAGE("Illegal mat assign reference");
248+
}
249+
250+
billboard->FUN_10029e90(
251+
&m_unk0x104[materialTableIndex],
252+
sprite->m_unk0x36,
253+
sprite->m_unk0x20,
254+
sprite->m_unk0x24,
255+
maxDistanceSquared
256+
);
257+
}
258+
else {
259+
if (sprite->m_unk0x00[0] == '\0') {
260+
GOL_FATALERROR_MESSAGE("Sprite is missing material name");
261+
}
262+
263+
DuskwindBananaRelic0x24* material = m_unk0x04->FindMaterialByName(sprite->m_unk0x00);
264+
if (material == NULL) {
265+
LegoChar message[64];
266+
::memset(message, 0, sizeof(message));
267+
::strncpy(message, sprite->m_unk0x00, sizeof(GolName));
268+
::strcat(message, " sprite material not found");
269+
GOL_FATALERROR_MESSAGE(message);
270+
}
271+
272+
billboard->VTable0x4c(material, sprite->m_unk0x20, sprite->m_unk0x24, maxDistanceSquared);
273+
}
274+
275+
billboard->VTable0x08(sprite->m_unk0x08);
276+
if (sprite->m_flags & WdbBillboardSprite0x38::c_flagBit1) {
277+
billboard->EnableFlagBit1();
278+
billboard->SetUnk0x30(sprite->m_unk0x14);
279+
}
280+
281+
FUN_1002e250(billboard, sprite);
282+
}
283+
241284
return NULL;
242285
}
243286

LEGORacers/include/audio/audiohelpers.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ void DecodeMonoPcmToStereo(LegoU8* p_source, LegoS16* p_destination, LegoS32 p_c
1010
void DecodeStereoPcmToStereo(
1111
LegoU8* p_source,
1212
LegoS16* p_destination,
13-
LegoU32 p_count,
13+
LegoS32 p_count,
1414
LegoS32* p_leftState,
1515
LegoS32* p_rightState
1616
);

LEGORacers/include/race/cobalttrail0x140.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class CobaltTrail0x140 {
4141
LegoBool p_unk0x18
4242
);
4343
RaceState::Racer* FUN_004262c0(RaceState::Racer* p_unk0x04);
44-
void FUN_004262d0(LegoU32 p_time);
44+
void FUN_004262d0(LegoS32 p_time);
4545
void FUN_00426360();
4646
void FUN_00426370();
4747
void FUN_00426390(LegoU32 p_elapsedMs);
@@ -120,7 +120,7 @@ class CobaltTrail0x140 {
120120
LegoU32 m_unk0x074; // 0x074
121121
LegoFloat m_unk0x078; // 0x078
122122
LegoS32 m_unk0x07c; // 0x07c
123-
LegoU32 m_unk0x080; // 0x080
123+
LegoS32 m_unk0x080; // 0x080
124124
LegoU32 m_unk0x084; // 0x084
125125
LegoU32 m_unk0x088; // 0x088
126126
LegoS32 m_unk0x08c; // 0x08c

LEGORacers/include/race/racepowerupmanager.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ class RacePowerupManager {
330330
c_flags0x234Bit1 = 1 << 1,
331331
};
332332

333-
void FUN_00444540(const GolVec3* p_position, LegoU32 p_elapsedMs, LegoFloat p_amount);
333+
void FUN_00444540(const GolVec3* p_position, LegoFloat p_elapsedMs, LegoFloat p_amount);
334334
LegoS32 FUN_00444690(LegoU32 p_elapsedMs);
335335
LegoS32 FUN_00444820(LegoU32 p_elapsedMs);
336336

LEGORacers/include/race/racestate.h

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -571,17 +571,18 @@ class RaceState {
571571
// SIZE 0xf4
572572
class Snapshot {
573573
public:
574-
GolVec3 m_unk0x000[4]; // 0x00
575-
GolVec3 m_unk0x030; // 0x30
576-
undefined m_unk0x03c[0x040 - 0x03c]; // 0x3c
577-
GolVec3 m_unk0x040[4]; // 0x40
578-
GolVec3 m_unk0x070[4]; // 0x70
579-
GolVec3 m_unk0x0a0; // 0xa0
580-
LegoFloat m_unk0x0ac; // 0xac
581-
LegoFloat m_unk0x0b0; // 0xb0
582-
undefined m_unk0x0b4[0x0c4 - 0x0b4]; // 0xb4
583-
GolMatrix3 m_unk0x0c4; // 0xc4
584-
GolVec3 m_unk0x0e8; // 0xe8
574+
GolVec3 m_unk0x000[4]; // 0x00
575+
GolVec3 m_unk0x030; // 0x30
576+
undefined4 m_unk0x03c; // 0x3c
577+
GolVec3 m_unk0x040[4]; // 0x40
578+
GolVec3 m_unk0x070[4]; // 0x70
579+
GolVec3 m_unk0x0a0; // 0xa0
580+
LegoFloat m_unk0x0ac; // 0xac
581+
LegoFloat m_unk0x0b0; // 0xb0
582+
undefined4 m_unk0x0b4; // 0xb4
583+
GolVec3 m_unk0x0b8; // 0xb8
584+
GolMatrix3 m_unk0x0c4; // 0xc4
585+
GolVec3 m_unk0x0e8; // 0xe8
585586
};
586587

587588
void VTable0x04(LegoS32 p_elapsedMs) override; // vtable+0x04
@@ -710,7 +711,7 @@ class RaceState {
710711
void FUN_004452b0(LegoS32 p_elapsedMs);
711712
void FUN_00445500();
712713
void FUN_00445d10();
713-
void FUN_00445dc0(LegoU32 p_elapsedMs);
714+
void FUN_00445dc0(LegoS32 p_elapsedMs);
714715
LegoFloat FUN_00445cb0();
715716
void FUN_004464a0(LegoS32 p_elapsedMs);
716717
void FUN_004465c0(LegoU32 p_elapsedMs);

0 commit comments

Comments
 (0)