Fix warnings triggered by isle-portable (#1304)

* 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 <mail@csemmler.com>
This commit is contained in:
Anonymous Maarten
2024-12-29 22:45:00 +01:00
committed by GitHub
parent 795d6e144d
commit c77b5869f5
7 changed files with 19 additions and 17 deletions

View File

@@ -19,7 +19,7 @@ public:
static BOOL SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo); static BOOL SetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo* p_textureInfo);
static BOOL GetGroupTexture(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: // private:
char* m_name; // 0x00 char* m_name; // 0x00

View File

@@ -121,9 +121,9 @@ void LegoBackgroundColor::SetLightColor(float p_r, float p_g, float p_b)
{ {
if (!VideoManager()->GetVideoParam().Flags().GetF2bit0()) { if (!VideoManager()->GetVideoParam().Flags().GetF2bit0()) {
// TODO: Computed constants based on what? // TODO: Computed constants based on what?
p_r *= 4.3478260869565215; p_r *= 1. / 0.23;
p_g *= 1.5873015873015872; p_g *= 1. / 0.63;
p_b *= 1.1764705882352942; p_b *= 1. / 0.85;
if (p_r > 1.0) { if (p_r > 1.0) {
p_r = 1.0; p_r = 1.0;

View File

@@ -71,7 +71,7 @@ LegoTextureInfo* LegoTextureInfo::Create(const char* p_name, LegoTexture* p_text
desc.ddpfPixelFormat.dwRGBBitCount = 8; desc.ddpfPixelFormat.dwRGBBitCount = 8;
MxS32 i; MxS32 i;
LegoU8* bits; const LegoU8* bits;
MxU8* surface; MxU8* surface;
if (pDirectDraw->CreateSurface(&desc, &textureInfo->m_surface, NULL) != DD_OK) { if (pDirectDraw->CreateSurface(&desc, &textureInfo->m_surface, NULL) != DD_OK) {
@@ -186,7 +186,7 @@ BOOL LegoTextureInfo::GetGroupTexture(Tgl::Mesh* pMesh, LegoTextureInfo*& p_text
} }
// FUNCTION: LEGO1 0x10066010 // 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) { if (m_surface != NULL && m_texture != NULL) {
DDSURFACEDESC desc; DDSURFACEDESC desc;
@@ -195,7 +195,7 @@ LegoResult LegoTextureInfo::FUN_10066010(LegoU8* p_bits)
if (m_surface->Lock(NULL, &desc, 0, NULL) == DD_OK) { if (m_surface->Lock(NULL, &desc, 0, NULL) == DD_OK) {
MxU8* surface = (MxU8*) desc.lpSurface; MxU8* surface = (MxU8*) desc.lpSurface;
LegoU8* bits = p_bits; const LegoU8* bits = p_bits;
if (desc.dwWidth == desc.lPitch) { if (desc.dwWidth == desc.lPitch) {
memcpy(desc.lpSurface, p_bits, desc.dwWidth * desc.dwHeight); memcpy(desc.lpSurface, p_bits, desc.dwWidth * desc.dwHeight);

View File

@@ -709,7 +709,7 @@ void WriteDefaultTexture(LegoFile* p_file, const char* p_name)
} }
else { else {
MxU8* surface = (MxU8*) desc.lpSurface; MxU8* surface = (MxU8*) desc.lpSurface;
LegoU8* bits = image->GetBits(); const LegoU8* bits = image->GetBits();
for (MxS32 i = 0; i < desc.dwHeight; i++) { for (MxS32 i = 0; i < desc.dwHeight; i++) {
memcpy(surface, bits, desc.dwWidth); memcpy(surface, bits, desc.dwWidth);

View File

@@ -1163,7 +1163,7 @@ undefined4 LegoAnim::GetActorUnknown0x04(LegoU32 p_index)
return m_modelList[p_index].m_unk0x04; return m_modelList[p_index].m_unk0x04;
} }
return NULL; return 0;
} }
// FUNCTION: LEGO1 0x100a0f60 // FUNCTION: LEGO1 0x100a0f60

View File

@@ -13,6 +13,8 @@
DECOMP_SIZE_ASSERT(MxDisplaySurface, 0xac); DECOMP_SIZE_ASSERT(MxDisplaySurface, 0xac);
#define RGB555_CREATE(R, G, B) (((R) << 10) | (G) << 5 | (B) << 0)
// GLOBAL: LEGO1 0x1010215c // GLOBAL: LEGO1 0x1010215c
MxU32 g_unk0x1010215c = 0; MxU32 g_unk0x1010215c = 0;
@@ -976,8 +978,8 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
if (p_transparent) { if (p_transparent) {
for (MxS32 y = 0; y < heightAbs; y++) { for (MxS32 y = 0; y < heightAbs; y++) {
for (MxS32 x = 0; x < widthNormal; x++) { for (MxS32 x = 0; x < widthNormal; x++) {
if (*bitmapSrcPtr == NULL) { if (*bitmapSrcPtr == 0) {
*surfaceData = 31775; *surfaceData = RGB555_CREATE(0x1f, 0, 0x1f);
} }
else { else {
*surfaceData = m_16bitPal[*bitmapSrcPtr]; *surfaceData = m_16bitPal[*bitmapSrcPtr];
@@ -992,7 +994,7 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::VTable0x44(
} }
DDCOLORKEY key; DDCOLORKEY key;
key.dwColorSpaceLowValue = key.dwColorSpaceHighValue = 31775; key.dwColorSpaceLowValue = key.dwColorSpaceHighValue = RGB555_CREATE(0x1f, 0, 0x1f);
surface->SetColorKey(DDCKEY_SRCBLT, &key); surface->SetColorKey(DDCKEY_SRCBLT, &key);
} }
else { else {
@@ -1098,7 +1100,7 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface()
for (MxS32 y = 0; y < 16; y++) { for (MxS32 y = 0; y < 16; y++) {
if ((y > 10 || x) && (x > 10 || y) && x + y != 10) { if ((y > 10 || x) && (x > 10 || y) && x + y != 10) {
if (x + y > 10) { if (x + y > 10) {
*surface2 = 31775; *surface2 = RGB555_CREATE(0x1f, 0, 0x1f);
} }
else { else {
*surface2 = -1; *surface2 = -1;
@@ -1114,8 +1116,8 @@ LPDIRECTDRAWSURFACE MxDisplaySurface::CreateCursorSurface()
newSurface->Unlock(ddsd.lpSurface); newSurface->Unlock(ddsd.lpSurface);
DDCOLORKEY colorkey; DDCOLORKEY colorkey;
colorkey.dwColorSpaceHighValue = 31775; colorkey.dwColorSpaceHighValue = RGB555_CREATE(0x1f, 0, 0x1f);
colorkey.dwColorSpaceLowValue = 31775; colorkey.dwColorSpaceLowValue = RGB555_CREATE(0x1f, 0, 0x1f);
newSurface->SetColorKey(DDCKEY_SRCBLT, &colorkey); newSurface->SetColorKey(DDCKEY_SRCBLT, &colorkey);
return newSurface; return newSurface;

View File

@@ -81,7 +81,7 @@ TglD3DRMIMAGE::TglD3DRMIMAGE(
void TglD3DRMIMAGE::Destroy() void TglD3DRMIMAGE::Destroy()
{ {
if (m_texelsAllocatedByClient == 0) { if (m_texelsAllocatedByClient == 0) {
delete m_image.buffer1; delete[] ((char*) m_image.buffer1);
} }
delete m_image.palette; delete m_image.palette;
} }
@@ -111,7 +111,7 @@ Result TglD3DRMIMAGE::CreateBuffer(int width, int height, int depth, void* pBuff
m_image.bytes_per_line = width; m_image.bytes_per_line = width;
if (!m_texelsAllocatedByClient) { if (!m_texelsAllocatedByClient) {
delete[] m_image.buffer1; delete[] ((char*) m_image.buffer1);
m_image.buffer1 = NULL; m_image.buffer1 = NULL;
} }