Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ add_executable(legoracers WIN32
common/src/golfsutil.cpp
LEGORacers/src/save/memorycardfilebase.cpp
LEGORacers/src/save/savedirectory.cpp
LEGORacers/src/race/powerups/powerupaction.cpp
LEGORacers/src/race/powerups/racepowerupbrickdebris.cpp
LEGORacers/src/race/powerups/cannonballaction.cpp
LEGORacers/src/race/powerups/curseaction.cpp
Expand Down
5 changes: 3 additions & 2 deletions GolDP/include/core/goldpexport.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
// SIZE 0xc8ac8
class GolDPExport : public GolExport {
public:
~GolDPExport() override; // vtable+0x00

// SYNTHETIC: GOLDP 0x10007040
// GolDPExport::`scalar deleting destructor'

// FUNCTION: GOLDP 0x10007060
// GolDPExport::~GolDPExport

GolCommonDrawState* GetDrawState() override; // vtable+0x04
GolWorldDatabase* CreateWorldDatabase() override; // vtable+0x08
GolTextureList* CreateTextureList() override; // vtable+0x0c
Expand Down
8 changes: 5 additions & 3 deletions GolDP/include/world/golworlddatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,11 @@ class GolWorldDatabase {
}
GolCollidableEntity* FindCollidableEntity(const LegoChar* p_name) const
{
return m_collidableEntityNames.GetNameEntries()
? static_cast<GolCollidableEntity*>(m_collidableEntityNames.GetName(p_name))
: NULL;
if (m_collidableEntityNames.GetNameEntries() == NULL) {
return NULL;
}

return static_cast<GolCollidableEntity*>(m_collidableEntityNames.GetName(p_name));
}
GolBoundedEntity* FindBoundedEntity(const LegoChar* p_name) const
{
Expand Down
3 changes: 1 addition & 2 deletions GolDP/include/world/wdbbillboardsprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ struct WdbBillboardSprite {
LegoFloat m_width; // 0x20
LegoFloat m_height; // 0x24
LegoFloat m_maxDistance; // 0x28
LegoU8 m_flags; // 0x2c
undefined m_unk0x2d[0x2e - 0x2d]; // 0x2d
LegoU16 m_flags; // 0x2c
undefined2 m_materialAnimationIndex; // 0x2e
undefined2 m_materialTrackIndex; // 0x30
undefined2 m_hasMaterialAnimation; // 0x32
Expand Down
19 changes: 14 additions & 5 deletions GolDP/src/camera/golcamera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,15 @@ void GolCamera::UpdateViewMatrix()
viewMatrix.m_m[2][1] = up.m_z;
viewMatrix.m_m[2][2] = direction.m_z;
viewMatrix.m_m[2][3] = 0.0f;
viewMatrix.m_m[3][0] = -(position.m_x * right.m_x + position.m_y * right.m_y + position.m_z * right.m_z);
viewMatrix.m_m[3][1] = -(position.m_x * up.m_x + position.m_y * up.m_y + position.m_z * up.m_z);
viewMatrix.m_m[3][3] = 1.0f;
LegoFloat rightDot = position.m_z * right.m_z + position.m_y * right.m_y;
rightDot += position.m_x * right.m_x;
viewMatrix.m_m[3][0] = -rightDot;

LegoFloat upDot = position.m_z * up.m_z + position.m_y * up.m_y;
upDot += position.m_x * up.m_x;
viewMatrix.m_m[3][1] = -upDot;

viewMatrix.m_m[3][3] = 1.0f;
m_flags &= ~c_flagViewDirty;
viewMatrix.m_m[3][2] =
-(position.m_x * direction.m_x + position.m_y * direction.m_y + position.m_z * direction.m_z);
Expand Down Expand Up @@ -151,12 +156,16 @@ void GolCamera::BuildProjection(
p_matrix->m_m[1][2] = 0.0f;
p_matrix->m_m[1][3] = 0.0f;
p_matrix->m_m[2][0] = p_offsetX - ((m_viewBounds.m_x + m_viewBounds.m_z) * xScale);
p_matrix->m_m[2][1] = p_offsetY - ((m_viewBounds.m_y + m_viewBounds.m_u) * yScale);
LegoFloat yBounds = m_viewBounds.m_y;
yBounds += m_viewBounds.m_u;
p_matrix->m_m[2][1] = p_offsetY - (yBounds * yScale);
p_matrix->m_m[2][2] = zScale;
p_matrix->m_m[2][3] = 1.0f;
p_matrix->m_m[3][0] = 0.0f;
p_matrix->m_m[3][1] = 0.0f;
p_matrix->m_m[3][2] = -(m_nearClip * zScale);
LegoFloat nearProduct = m_nearClip;
nearProduct *= zScale;
p_matrix->m_m[3][2] = -nearProduct;
p_matrix->m_m[3][3] = 0.0f;
}

Expand Down
18 changes: 13 additions & 5 deletions GolDP/src/camera/golscenetransformnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,19 @@ void GolSceneTransformNode::UpdateWorldMatrices(const GolMatrix4& p_m)

for (; obj < end; obj++) {
GolTransform* parent = static_cast<GolTransform*>(obj->m_parent);
const GolMatrix4& parentMatrix = parent != NULL ? parent->m_worldMatrix : p_m;
GolMath::MultiplyMatrix4Affine(obj->m_matrix, parentMatrix, &obj->m_worldMatrix);
if (parent == NULL) {
GolMath::MultiplyMatrix4Affine(obj->m_matrix, p_m, &obj->m_worldMatrix);
}
else {
GolMath::MultiplyMatrix4Affine(obj->m_matrix, parent->m_worldMatrix, &obj->m_worldMatrix);
}
}
return;
}

for (; i < m_capacity; i++) {
GolTransform* parent = static_cast<GolTransform*>(m_transforms[i].m_parent);
GolTransform* obj = &m_transforms[i];
GolTransform* parent = static_cast<GolTransform*>(obj->m_parent);

if (m_composer->HasOverride(i)) {
GolQuat rotation;
Expand All @@ -153,8 +157,12 @@ void GolSceneTransformNode::UpdateWorldMatrices(const GolMatrix4& p_m)
m_composer->Compose(i, rotation, position, parentMatrix, &obj->m_worldMatrix);
}
else {
const GolMatrix4& parentMatrix = parent != NULL ? parent->m_worldMatrix : p_m;
GolMath::MultiplyMatrix4Affine(obj->m_matrix, parentMatrix, &obj->m_worldMatrix);
if (parent == NULL) {
GolMath::MultiplyMatrix4Affine(obj->m_matrix, p_m, &obj->m_worldMatrix);
}
else {
GolMath::MultiplyMatrix4Affine(obj->m_matrix, parent->m_worldMatrix, &obj->m_worldMatrix);
}
}
}
}
Expand Down
66 changes: 29 additions & 37 deletions GolDP/src/camera/goltransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,18 @@ void GolTransform::SetDirectionUp(GolVec3* p_direction, GolVec3* p_up)
right.m_z *= up.m_x;
right.m_z -= up.m_y * direction.m_x;

m_matrix.m_m[0][0] = right.m_x;
m_matrix.m_m[0][1] = right.m_y;
m_matrix.m_m[0][2] = right.m_z;
m_matrix.m_m[1][0] = up.m_x;
m_matrix.m_m[1][1] = up.m_y;
m_matrix.m_m[1][2] = up.m_z;
m_matrix.m_m[2][0] = direction.m_x;
m_matrix.m_m[2][1] = direction.m_y;
m_matrix.m_m[2][2] = direction.m_z;
LegoFloat* row0 = &m_matrix.m_m[0][0];
LegoFloat* row1 = &m_matrix.m_m[1][0];
LegoFloat* row2 = &m_matrix.m_m[2][0];
row0[0] = right.m_x;
row0[1] = right.m_y;
row0[2] = right.m_z;
row1[0] = up.m_x;
row1[1] = up.m_y;
row1[2] = up.m_z;
row2[0] = direction.m_x;
row2[1] = direction.m_y;
row2[2] = direction.m_z;
}

// FUNCTION: GOLDP 0x10002b20
Expand Down Expand Up @@ -164,15 +167,18 @@ void GolTransform::SetRightDirection(GolVec3* p_right, GolVec3* p_direction)
up.m_z *= direction.m_x;
up.m_z -= direction.m_y * right.m_x;

m_matrix.m_m[0][0] = right.m_x;
m_matrix.m_m[0][1] = right.m_y;
m_matrix.m_m[0][2] = right.m_z;
m_matrix.m_m[1][0] = up.m_x;
m_matrix.m_m[1][1] = up.m_y;
m_matrix.m_m[1][2] = up.m_z;
m_matrix.m_m[2][0] = direction.m_x;
m_matrix.m_m[2][1] = direction.m_y;
m_matrix.m_m[2][2] = direction.m_z;
LegoFloat* row0 = &m_matrix.m_m[0][0];
LegoFloat* row1 = &m_matrix.m_m[1][0];
LegoFloat* row2 = &m_matrix.m_m[2][0];
row0[0] = right.m_x;
row0[1] = right.m_y;
row1[0] = up.m_x;
row0[2] = right.m_z;
row1[1] = up.m_y;
row1[2] = up.m_z;
row2[0] = direction.m_x;
row2[1] = direction.m_y;
row2[2] = direction.m_z;
}

// FUNCTION: GOLDP 0x10002c10
Expand Down Expand Up @@ -238,30 +244,16 @@ void GolTransform::InverseTransformPoint(const GolVec3* p_src, GolVec3* p_dest)
product *= p_src->m_z;
p_dest->m_z = product + p_dest->m_z;

LegoFloat offset = m_matrix.m_m[3][0] * m_matrix.m_m[0][0];
product = m_matrix.m_m[0][1];
product *= m_matrix.m_m[3][1];
offset += product;
LegoFloat offset = (m_matrix.m_m[3][0] * m_matrix.m_m[0][0]) + (m_matrix.m_m[0][1] * m_matrix.m_m[3][1]);
offset += m_matrix.m_m[3][2] * m_matrix.m_m[0][2];
p_dest->m_x -= offset;

offset = m_matrix.m_m[3][2] * m_matrix.m_m[1][2];
product = m_matrix.m_m[1][1];
product *= m_matrix.m_m[3][1];
offset += product;
product = m_matrix.m_m[3][0];
product *= m_matrix.m_m[1][0];
offset += product;
offset = (m_matrix.m_m[3][2] * m_matrix.m_m[1][2]) + (m_matrix.m_m[1][1] * m_matrix.m_m[3][1]);
offset += m_matrix.m_m[3][0] * m_matrix.m_m[1][0];
p_dest->m_y -= offset;

offset = m_matrix.m_m[2][2];
offset *= m_matrix.m_m[3][2];
product = m_matrix.m_m[2][1];
product *= m_matrix.m_m[3][1];
offset += product;
product = m_matrix.m_m[3][0];
product *= m_matrix.m_m[2][0];
offset += product;
offset = (m_matrix.m_m[2][2] * m_matrix.m_m[3][2]) + (m_matrix.m_m[2][1] * m_matrix.m_m[3][1]);
offset += m_matrix.m_m[3][0] * m_matrix.m_m[2][0];
p_dest->m_z -= offset;
}

Expand Down
5 changes: 0 additions & 5 deletions GolDP/src/core/goldpexport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@
DECOMP_SIZE_ASSERT(GolExport, 0x4)
DECOMP_SIZE_ASSERT(GolDPExport, 0xc8ac8)

// FUNCTION: GOLDP 0x10007060
GolDPExport::~GolDPExport()
{
}

// FUNCTION: GOLDP 0x10015090
GolCommonDrawState* GolDPExport::GetDrawState()
{
Expand Down
14 changes: 6 additions & 8 deletions GolDP/src/device/goldirectdrawpalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,12 @@ void GolDirectDrawPalette::CreateDirectDrawPalette(GolD3DRenderDevice* p_rendere
else {
LegoU32 paletteEntryCount = entryCount - 1;
LegoU32 lastEntry = 0;
if (paletteEntryCount > 0) {
lastEntry = paletteEntryCount;
for (LegoU32 paletteEntry = 0; paletteEntry < paletteEntryCount; paletteEntry++) {
g_paletteEntries[paletteEntry].peRed = 0;
g_paletteEntries[paletteEntry].peGreen = 0;
g_paletteEntries[paletteEntry].peBlue = 0;
g_paletteEntries[paletteEntry].peFlags = PC_NOCOLLAPSE;
}

for (; lastEntry < paletteEntryCount; lastEntry++) {
g_paletteEntries[lastEntry].peRed = 0;
g_paletteEntries[lastEntry].peGreen = 0;
g_paletteEntries[lastEntry].peBlue = 0;
g_paletteEntries[lastEntry].peFlags = PC_NOCOLLAPSE;
}

g_paletteEntries[lastEntry].peRed = c_colorChannelMax;
Expand Down
25 changes: 17 additions & 8 deletions GolDP/src/material/golsoftwarematerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,25 @@ void GolSoftwareMaterial::UpdateD3DMaterial(GolD3DRenderDevice* p_renderer)
{
D3DMATERIAL material;
LegoChar errorMessage[64];
LegoFloat color;

material.dwSize = sizeof(D3DMATERIAL);
material.ambient.r = static_cast<LegoFloat>(static_cast<double>(m_ambient.m_red & 0xff) / 255.0);
material.ambient.g = static_cast<LegoFloat>(static_cast<double>(m_ambient.m_grn & 0xff) / 255.0);
material.ambient.b = static_cast<LegoFloat>(static_cast<double>(m_ambient.m_blu & 0xff) / 255.0);
material.ambient.a = static_cast<LegoFloat>(static_cast<double>(m_ambient.m_alp & 0xff) / 255.0);
material.diffuse.r = static_cast<LegoFloat>(static_cast<double>(m_diffuse.m_red & 0xff) / 255.0);
material.diffuse.g = static_cast<LegoFloat>(static_cast<double>(m_diffuse.m_grn & 0xff) / 255.0);
material.diffuse.b = static_cast<LegoFloat>(static_cast<double>(m_diffuse.m_blu & 0xff) / 255.0);
material.diffuse.a = static_cast<LegoFloat>(static_cast<double>(m_diffuse.m_alp & 0xff) / 255.0);
color = static_cast<LegoFloat>(static_cast<double>(m_ambient.m_red & 0xff) / 255.0);
material.ambient.r = color;
color = static_cast<LegoFloat>(static_cast<double>(m_ambient.m_grn & 0xff) / 255.0);
material.ambient.g = color;
color = static_cast<LegoFloat>(static_cast<double>(m_ambient.m_blu & 0xff) / 255.0);
material.ambient.b = color;
color = static_cast<LegoFloat>(static_cast<double>(m_ambient.m_alp & 0xff) / 255.0);
material.ambient.a = color;
color = static_cast<LegoFloat>(static_cast<double>(m_diffuse.m_red & 0xff) / 255.0);
material.diffuse.r = color;
color = static_cast<LegoFloat>(static_cast<double>(m_diffuse.m_grn & 0xff) / 255.0);
material.diffuse.g = color;
color = static_cast<LegoFloat>(static_cast<double>(m_diffuse.m_blu & 0xff) / 255.0);
material.diffuse.b = color;
color = static_cast<LegoFloat>(static_cast<double>(m_diffuse.m_alp & 0xff) / 255.0);
material.diffuse.a = color;
material.specular.r = 0.0f;
material.specular.g = 0.0f;
material.specular.b = 0.0f;
Expand Down
18 changes: 8 additions & 10 deletions GolDP/src/material/goltexturelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,6 @@ void GolTextureList::Load(GolD3DRenderDevice* p_renderer, const LegoChar* p_file

for (LegoU32 i = 0; i < m_itemCount; i++) {
GolName textureName;
ColorRGBA colorKey;
LegoU16 mipmapCount;
LegoU16 flags;

parser->AssertNextTokenIs(static_cast<GolFileParser::ParserTokenType>(TdbTxtParser::e_texture));
GolD3DTexture* texture = GetItem(i);
Expand All @@ -105,8 +102,9 @@ void GolTextureList::Load(GolD3DRenderDevice* p_renderer, const LegoChar* p_file
}

parser->ReadLeftCurly();
mipmapCount = 0;
flags = 0;
ColorRGBA colorKey;
LegoU16 flags = 0;
LegoU16 mipmapCount = 0;
colorKey.m_red = 0;
colorKey.m_grn = 0;
colorKey.m_blu = 0;
Expand Down Expand Up @@ -187,12 +185,12 @@ void GolTextureList::LoadTextures()
}

texture->SetTextureFlags(flags);
texture->SetSourceTextureDefinition(sourceItem.m_mipmapCount, flags, sourceItem.m_colorKey);
texture->SetTextureDefinition(sourceItem.m_mipmapCount, flags, sourceItem.m_colorKey);

m_renderer->SelectTextureFormat(
sourceItem.m_textureFormat,
&textureFormat,
flags & GolTexture::c_textureFlagColorKeyed
texture->GetTextureFlags() & GolTexture::c_textureFlagColorKeyed
);
AllocateTexture(i, textureFormat, sourceItem.m_width, sourceItem.m_height);
m_textureSource->OnTextureLoaded(i, 0, texture);
Expand All @@ -210,15 +208,15 @@ void GolTextureList::LoadTextures()
continue;
}

const GolName& sourceName = texture->GetName();
GolName sourceName;
::memcpy(sourceName, texture->GetName(), sizeof(GolName));
if (sourceName[0] == '\0') {
continue;
}

::memcpy(textureName, sourceName, sizeof(GolName));
textureName[sizeof(GolName)] = '\0';

LegoU8 textureFlags = static_cast<LegoU8>(texture->GetTextureFlags());
LegoU8 textureFlags = static_cast<LegoU8>(texture->m_textureFlags);
GolImgFile* imageFile = &g_textureBmpFile;
if (!(textureFlags & GolTexture::c_textureFlagBmpSource)) {
imageFile = &g_textureTgaFile;
Expand Down
10 changes: 3 additions & 7 deletions GolDP/src/mesh/gdbcoloredvertexarraybase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,16 @@ void GdbColoredVertexArrayBase::Destroy()
// FUNCTION: GOLDP 0x10017050
void GdbColoredVertexArrayBase::ApplyColorTransform(const ColorTransform& p_details)
{
LegoU32* ptrIn;
LegoU32* ptrOut;
LegoU32* ptrInEnd;

if (m_transformedColors == NULL) {
m_transformedColors = new LegoU32[m_count];
if (m_transformedColors == NULL) {
GOL_FATALERROR(c_golErrorOutOfMemory);
}
}

ptrOut = m_transformedColors;
ptrIn = m_colors;
ptrInEnd = ptrIn + m_count;
LegoU32* ptrIn = m_colors;
LegoU32* ptrInEnd = ptrIn + m_count;
LegoU32* ptrOut = m_transformedColors;

for (; ptrIn < ptrInEnd; ptrIn++, ptrOut++) {
LegoU32 original = *ptrIn;
Expand Down
Loading
Loading