Skip to content

Commit

Permalink
Fix warnings triggered by isle-portable (#1304)
Browse files Browse the repository at this point in the history
* Replace computed constant with more readable computed constants

* LegoAnim::GetActorUnknown0x04 returns a number, not a pointer

* Add macro for creating RGB555 colors

* Texture pixel data is passed through as const data

* Compare palette index against 0 instead of NULL pointer

* warning: deleting 'void*' is undefined [-Wdelete-incomplete] warning

Some DirectX sdk's declars D3DRMIMAGE::buffer1 and D3DRMIMAGE::buffer2
as a void pointer.

* Don't use floats

* Fix wrong op

---------

Co-authored-by: Christian Semmler <[email protected]>
  • Loading branch information
madebr and foxtacles authored Dec 29, 2024
1 parent 795d6e1 commit c77b586
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/include/legotextureinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class LegoTextureInfo {
static BOOL SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo);
static BOOL GetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo*& p_textureInfo);

LegoResult FUN_10066010(LegoU8* p_bits);
LegoResult FUN_10066010(const LegoU8* p_bits);

// private:
char* m_name; // 0x00
Expand Down
6 changes: 3 additions & 3 deletions LEGO1/lego/legoomni/src/common/legobackgroundcolor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ void LegoBackgroundColor::SetLightColor(float p_r, float p_g, float p_b)
{
if (!VideoManager()->GetVideoParam().Flags().GetF2bit0()) {
// TODO: Computed constants based on what?
p_r *= 4.3478260869565215;
p_g *= 1.5873015873015872;
p_b *= 1.1764705882352942;
p_r *= 1. / 0.23;
p_g *= 1. / 0.63;
p_b *= 1. / 0.85;

if (p_r > 1.0) {
p_r = 1.0;
Expand Down
6 changes: 3 additions & 3 deletions LEGO1/lego/legoomni/src/common/legotextureinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ LegoTextureInfo* LegoTextureInfo::Create(const char* p_name, LegoTexture* p_text
desc.ddpfPixelFormat.dwRGBBitCount = 8;

MxS32 i;
LegoU8* bits;
const LegoU8* bits;
MxU8* surface;

if (pDirectDraw->CreateSurface(&desc, &textureInfo->m_surface, NULL) != DD_OK) {
Expand Down Expand Up @@ -186,7 +186,7 @@ BOOL LegoTextureInfo::GetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo*& p_text
}

// FUNCTION: LEGO1 0x10066010
LegoResult LegoTextureInfo::FUN_10066010(LegoU8* p_bits)
LegoResult LegoTextureInfo::FUN_10066010(const LegoU8* p_bits)
{
if (m_surface != NULL && m_texture != NULL) {
DDSURFACEDESC desc;
Expand All @@ -195,7 +195,7 @@ LegoResult LegoTextureInfo::FUN_10066010(LegoU8* p_bits)

if (m_surface->Lock(NULL, &desc, 0, NULL) == DD_OK) {
MxU8* surface = (MxU8*) desc.lpSurface;
LegoU8* bits = p_bits;
const LegoU8* bits = p_bits;

if (desc.dwWidth == desc.lPitch) {
memcpy(desc.lpSurface, p_bits, desc.dwWidth * desc.dwHeight);
Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/legoomni/src/common/legoutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ void WriteDefaultTexture(LegoFile* p_file, const char* p_name)
}
else {
MxU8* surface = (MxU8*) desc.lpSurface;
LegoU8* bits = image->GetBits();
const LegoU8* bits = image->GetBits();

for (MxS32 i = 0; i < desc.dwHeight; i++) {
memcpy(surface, bits, desc.dwWidth);
Expand Down
2 changes: 1 addition & 1 deletion LEGO1/lego/sources/anim/legoanim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1163,7 +1163,7 @@ undefined4 LegoAnim::GetActorUnknown0x04(LegoU32 p_index)
return m_modelList[p_index].m_unk0x04;
}

return NULL;
return 0;
}

// FUNCTION: LEGO1 0x100a0f60
Expand Down
14 changes: 8 additions & 6 deletions LEGO1/omni/src/video/mxdisplaysurface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

DECOMP_SIZE_ASSERT(MxDisplaySurface, 0xac);

#define RGB555_CREATE(R, G, B) (((R) << 10) | (G) << 5 | (B) << 0)

// GLOBAL: LEGO1 0x1010215c
MxU32 g_unk0x1010215c = 0;

Expand Down Expand Up @@ -976,8 +978,8 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
if (p_transparent) {
for (MxS32 y = 0; y < heightAbs; y++) {
for (MxS32 x = 0; x < widthNormal; x++) {
if (*bitmapSrcPtr == NULL) {
*surfaceData = 31775;
if (*bitmapSrcPtr == 0) {
*surfaceData = RGB555_CREATE(0x1f, 0, 0x1f);
}
else {
*surfaceData = m_16bitPal[*bitmapSrcPtr];
Expand All @@ -992,7 +994,7 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
}

DDCOLORKEY key;
key.dwColorSpaceLowValue = key.dwColorSpaceHighValue = 31775;
key.dwColorSpaceLowValue = key.dwColorSpaceHighValue = RGB555_CREATE(0x1f, 0, 0x1f);
surface->SetColorKey(DDCKEY_SRCBLT, &key);
}
else {
Expand Down Expand Up @@ -1098,7 +1100,7 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface()
for (MxS32 y = 0; y < 16; y++) {
if ((y > 10 || x) && (x > 10 || y) && x + y != 10) {
if (x + y > 10) {
*surface2 = 31775;
*surface2 = RGB555_CREATE(0x1f, 0, 0x1f);
}
else {
*surface2 = -1;
Expand All @@ -1114,8 +1116,8 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface()

newSurface->Unlock(ddsd.lpSurface);
DDCOLORKEY colorkey;
colorkey.dwColorSpaceHighValue = 31775;
colorkey.dwColorSpaceLowValue = 31775;
colorkey.dwColorSpaceHighValue = RGB555_CREATE(0x1f, 0, 0x1f);
colorkey.dwColorSpaceLowValue = RGB555_CREATE(0x1f, 0, 0x1f);
newSurface->SetColorKey(DDCKEY_SRCBLT, &colorkey);

return newSurface;
Expand Down
4 changes: 2 additions & 2 deletions LEGO1/tgl/d3drm/texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ TglD3DRMIMAGE::TglD3DRMIMAGE(
void TglD3DRMIMAGE::Destroy()
{
if (m_texelsAllocatedByClient == 0) {
delete m_image.buffer1;
delete[] ((char*) m_image.buffer1);
}
delete m_image.palette;
}
Expand Down Expand Up @@ -111,7 +111,7 @@ Result TglD3DRMIMAGE::CreateBuffer(int width, int height, int depth, void* pBuff
m_image.bytes_per_line = width;

if (!m_texelsAllocatedByClient) {
delete[] m_image.buffer1;
delete[] ((char*) m_image.buffer1);
m_image.buffer1 = NULL;
}

Expand Down

0 comments on commit c77b586

Please sign in to comment.