mirror of
https://github.com/isledecomp/isle.git
synced 2026-01-20 23:01:16 +00:00
move _countof, impove up to 96.90%
This commit is contained in:
parent
41604832cf
commit
475270451c
@ -4,6 +4,10 @@
|
|||||||
#define DECOMP_STATIC_ASSERT(V) namespace { typedef int foo[(V)?1:-1]; }
|
#define DECOMP_STATIC_ASSERT(V) namespace { typedef int foo[(V)?1:-1]; }
|
||||||
#define DECOMP_SIZE_ASSERT(T, S) DECOMP_STATIC_ASSERT(sizeof(T) == S)
|
#define DECOMP_SIZE_ASSERT(T, S) DECOMP_STATIC_ASSERT(sizeof(T) == S)
|
||||||
|
|
||||||
|
#ifndef _countof
|
||||||
|
#define _countof(arr) sizeof(arr) / sizeof(arr[0])
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef unsigned char undefined;
|
typedef unsigned char undefined;
|
||||||
typedef unsigned short undefined2;
|
typedef unsigned short undefined2;
|
||||||
typedef unsigned int undefined4;
|
typedef unsigned int undefined4;
|
||||||
|
|||||||
@ -1,10 +1,7 @@
|
|||||||
|
|
||||||
#include "mxdirectdraw.h"
|
#include "mxdirectdraw.h"
|
||||||
|
#include "decomp.h"
|
||||||
|
|
||||||
//TODO: make commonn place for defines like that
|
|
||||||
#ifndef _countof
|
|
||||||
#define _countof(arr) sizeof(arr) / sizeof(arr[0])
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DDSCAPS_3DDEVICE
|
#ifndef DDSCAPS_3DDEVICE
|
||||||
#define DDSCAPS_3DDEVICE 0x00002000l
|
#define DDSCAPS_3DDEVICE 0x00002000l
|
||||||
@ -32,6 +29,20 @@ void EnableResizing(HWND hwnd, BOOL flag)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// OFFSET: LEGO1 0x1009EFD0
|
||||||
|
MxDirectDraw::DeviceModesInfo::~DeviceModesInfo()
|
||||||
|
{
|
||||||
|
if (p_guid != NULL)
|
||||||
|
{
|
||||||
|
free(p_guid);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_mode_ARRAY != NULL)
|
||||||
|
{
|
||||||
|
free(m_mode_ARRAY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// OFFSET: LEGO1 0x1009D490
|
// OFFSET: LEGO1 0x1009D490
|
||||||
MxDirectDraw::MxDirectDraw()
|
MxDirectDraw::MxDirectDraw()
|
||||||
{
|
{
|
||||||
@ -1038,49 +1049,54 @@ BOOL MxDirectDraw::SetPaletteEntries(
|
|||||||
int paletteEntryCount,
|
int paletteEntryCount,
|
||||||
BOOL fullscreen)
|
BOOL fullscreen)
|
||||||
{
|
{
|
||||||
HRESULT result;
|
int reservedLowEntryCount = 10;
|
||||||
|
int reservedHighEntryCount = 10;
|
||||||
|
int arraySize = _countof(m_paletteEntries);
|
||||||
HDC hdc;
|
HDC hdc;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (g_is_PALETTEINDEXED8)
|
if (g_is_PALETTEINDEXED8)
|
||||||
{
|
{
|
||||||
hdc = GetDC(NULL);
|
hdc = GetDC(NULL);
|
||||||
GetSystemPaletteEntries(hdc, 0, _countof(m_paletteEntries), m_paletteEntries);
|
GetSystemPaletteEntries(hdc, 0, arraySize, m_paletteEntries);
|
||||||
ReleaseDC(NULL, hdc);
|
ReleaseDC(NULL, hdc);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < 10; i++)
|
for (i = 0; i < reservedLowEntryCount; i++)
|
||||||
{
|
{
|
||||||
m_paletteEntries[i].peFlags = 0x80;
|
m_paletteEntries[i].peFlags = 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 10; i < 142; i++)
|
for (i = reservedLowEntryCount; i < 142; i++)
|
||||||
{
|
{
|
||||||
m_paletteEntries[i].peFlags = 0x44;
|
m_paletteEntries[i].peFlags = 0x44;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 142; i < 246; i++)
|
for (i = 142; i < arraySize - reservedHighEntryCount; i++)
|
||||||
{
|
{
|
||||||
m_paletteEntries[i].peFlags = 0x84;
|
m_paletteEntries[i].peFlags = 0x84;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 246; i < 256; i++)
|
for (i = arraySize - reservedHighEntryCount; i < arraySize; i++)
|
||||||
{
|
{
|
||||||
m_paletteEntries[i].peFlags = 0x80;
|
m_paletteEntries[i].peFlags = 0x80;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (paletteEntryCount != 0)
|
if (paletteEntryCount != 0)
|
||||||
{
|
{
|
||||||
for (i = 10; (i < paletteEntryCount) && (i < 246); i++)
|
for (i = reservedLowEntryCount;
|
||||||
|
(i < paletteEntryCount) && (i < arraySize - reservedHighEntryCount);
|
||||||
|
i++)
|
||||||
{
|
{
|
||||||
m_paletteEntries[i].peRed = pPaletteEntries[i].peRed;
|
m_paletteEntries[i].peRed = pPaletteEntries[i].peRed;
|
||||||
m_paletteEntries[i].peGreen = pPaletteEntries[i].peGreen;
|
m_paletteEntries[i].peGreen = pPaletteEntries[i].peGreen;
|
||||||
m_paletteEntries[i].peBlue = pPaletteEntries[i].peBlue;
|
m_paletteEntries[i].peBlue = pPaletteEntries[i].peBlue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_pPalette != NULL)
|
if (m_pPalette != NULL)
|
||||||
{
|
{
|
||||||
|
HRESULT result;
|
||||||
result = m_pPalette->SetEntries(0, 0, _countof(m_paletteEntries), m_paletteEntries);
|
result = m_pPalette->SetEntries(0, 0, _countof(m_paletteEntries), m_paletteEntries);
|
||||||
if (result != DD_OK)
|
if (result != DD_OK)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -37,18 +37,7 @@ class MxDirectDraw
|
|||||||
DDCAPS m_ddcaps;
|
DDCAPS m_ddcaps;
|
||||||
void* a_178;
|
void* a_178;
|
||||||
|
|
||||||
~DeviceModesInfo()
|
~DeviceModesInfo();
|
||||||
{
|
|
||||||
if (p_guid != NULL)
|
|
||||||
{
|
|
||||||
free(p_guid);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_mode_ARRAY != NULL)
|
|
||||||
{
|
|
||||||
free(m_mode_ARRAY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user