mirror of
https://github.com/isledecomp/isle-portable.git
synced 2024-12-18 20:02:30 -05:00
659a54b221
Some checks are pending
Build / Current ${{ matrix.toolchain.name }} (map[clang-tidy:true d3drm-from-wine:true dx5-libs:false msys-env:mingw-w64-i686 msystem:mingw32 name:msys2 mingw32 shell:msys2 {0} werror:true]) (push) Waiting to run
Build / Current ${{ matrix.toolchain.name }} (map[clang-tidy:true d3drm-from-wine:true dx5-libs:false msys-env:mingw-w64-x86_64 msystem:mingw64 name:msys2 mingw64 shell:msys2 {0} werror:true]) (push) Waiting to run
Build / Current ${{ matrix.toolchain.name }} (map[d3drm-from-wine:false dx5-libs:true name:MSVC (32-bit) setup-cmake:true setup-msvc:true setup-ninja:true shell:sh vc-arch:amd64_x86]) (push) Waiting to run
Build / Current ${{ matrix.toolchain.name }} (map[d3drm-from-wine:true dx5-libs:false name:MSVC (64-bit) setup-cmake:true setup-msvc:true setup-ninja:true shell:sh vc-arch:amd64]) (push) Waiting to run
Format / C++ (push) Waiting to run
Naming / C++ (push) Waiting to run
* d3drm: store LPVOID data instead of DWORD * m_extraCharacterId is an integer, not a pointer * cmake: look for iniparser using config file first, then try our custom module file Our custom module file is still useful. My linux distro does not package the cmake files. * x86's stdcall becomes MS's x64 calling canvention * Fix 64-bit mxdsbuffer pointer arithmetic * Casting from void* to a smaller-sized integer needs an intermediate equally-sized integer * Don't cast address to scalar (this is fishy) * Add mingw64 build to the ci matrix * Ignore -Wdiscarded-qualifiers warning with const vtables * Ignore different 'const' qualifiers with MSVC * Create d3dxof import library for MSVC * DESCRIPTION in .def file(s) is deprecated * Assume mmx is supported on x64, require a test for x86 and disabled on other archs * 32- and 64-bit LEGO1.dll export different symbol names * Introduce d3drm_guid containing the guids of d3drm * Disable __wine_dbg_cdecl * Include d3drm directory with EXCLUDE_FROM_ALL * lego1 leaks d3drm headers * Add dxfile.h * Add 64-bit MSVC to the build matrix * cmake: using ISLE_USE_DX5 means going all-in * Load d3dxof.dll dynamically * cmake: don't emit a warning about bitness anymore
138 lines
4 KiB
C++
138 lines
4 KiB
C++
#include "legocontainer.h"
|
|
|
|
#include "lego/legoomni/include/legovideomanager.h"
|
|
#include "lego/legoomni/include/misc.h"
|
|
#include "mxdirectx/mxdirect3d.h"
|
|
#include "tgl/d3drm/impl.h"
|
|
|
|
DECOMP_SIZE_ASSERT(LegoContainerInfo<LegoTexture>, 0x10);
|
|
// DECOMP_SIZE_ASSERT(LegoContainer<LegoTexture>, 0x18);
|
|
DECOMP_SIZE_ASSERT(LegoTextureContainer, 0x24);
|
|
|
|
// FUNCTION: LEGO1 0x10099870
|
|
LegoTextureContainer::~LegoTextureContainer()
|
|
{
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x100998e0
|
|
LegoTextureInfo* LegoTextureContainer::GetCached(LegoTextureInfo* p_textureInfo)
|
|
{
|
|
DDSURFACEDESC desc, newDesc;
|
|
DWORD width, height;
|
|
memset(&desc, 0, sizeof(desc));
|
|
desc.dwSize = sizeof(desc);
|
|
|
|
if (p_textureInfo->m_surface->Lock(NULL, &desc, DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK) {
|
|
width = desc.dwWidth;
|
|
height = desc.dwHeight;
|
|
p_textureInfo->m_surface->Unlock(desc.lpSurface);
|
|
}
|
|
|
|
for (LegoCachedTextureList::iterator it = m_cached.begin(); it != m_cached.end(); it++) {
|
|
if ((*it).second == FALSE && (*it).first->m_texture->AddRef() != 0 && (*it).first->m_texture->Release() == 1) {
|
|
if (!strcmp((*it).first->m_name, p_textureInfo->m_name)) {
|
|
LPDIRECTDRAWSURFACE surface = (*it).first->m_surface;
|
|
memset(&newDesc, 0, sizeof(newDesc));
|
|
newDesc.dwSize = sizeof(newDesc);
|
|
|
|
if (surface->Lock(NULL, &newDesc, DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK) {
|
|
BOOL und = FALSE;
|
|
if (newDesc.dwWidth == width && newDesc.dwHeight == height) {
|
|
und = TRUE;
|
|
}
|
|
|
|
surface->Unlock(newDesc.lpSurface);
|
|
|
|
if (und) {
|
|
(*it).second = TRUE;
|
|
(*it).first->m_texture->AddRef();
|
|
return (*it).first;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
LegoTextureInfo* textureInfo = new LegoTextureInfo();
|
|
|
|
textureInfo->m_palette = p_textureInfo->m_palette;
|
|
textureInfo->m_palette->AddRef();
|
|
|
|
memset(&newDesc, 0, sizeof(newDesc));
|
|
newDesc.dwWidth = desc.dwWidth;
|
|
newDesc.dwHeight = desc.dwHeight;
|
|
newDesc.dwSize = sizeof(newDesc);
|
|
newDesc.dwFlags = DDSD_PIXELFORMAT | DDSD_WIDTH | DDSD_HEIGHT | DDSD_CAPS;
|
|
newDesc.ddsCaps.dwCaps = DDCAPS_OVERLAYCANTCLIP | DDCAPS_OVERLAY;
|
|
newDesc.ddpfPixelFormat.dwSize = sizeof(desc.ddpfPixelFormat);
|
|
newDesc.ddpfPixelFormat.dwFlags = DDPF_RGB | DDPF_PALETTEINDEXED8;
|
|
newDesc.ddpfPixelFormat.dwRGBBitCount = 8;
|
|
|
|
if (VideoManager()->GetDirect3D()->DirectDraw()->CreateSurface(&newDesc, &textureInfo->m_surface, NULL) == DD_OK) {
|
|
RECT rect;
|
|
rect.left = 0;
|
|
rect.right = newDesc.dwWidth - 1;
|
|
rect.top = 0;
|
|
rect.bottom = newDesc.dwHeight - 1;
|
|
|
|
textureInfo->m_surface->SetPalette(textureInfo->m_palette);
|
|
|
|
if (textureInfo->m_surface->BltFast(0, 0, p_textureInfo->m_surface, &rect, DDBLTFAST_WAIT) != DD_OK) {
|
|
textureInfo->m_surface->Release();
|
|
textureInfo->m_palette->Release();
|
|
delete textureInfo;
|
|
return NULL;
|
|
}
|
|
else {
|
|
if (((TglImpl::RendererImpl*) VideoManager()->GetRenderer())
|
|
->CreateTextureFromSurface(textureInfo->m_surface, &textureInfo->m_texture) != D3DRM_OK) {
|
|
textureInfo->m_surface->Release();
|
|
textureInfo->m_palette->Release();
|
|
delete textureInfo;
|
|
return NULL;
|
|
}
|
|
else {
|
|
textureInfo->m_texture->SetAppData((LPD3DRM_APPDATA) textureInfo);
|
|
m_cached.push_back(LegoCachedTexture(textureInfo, TRUE));
|
|
|
|
textureInfo->m_texture->AddRef();
|
|
|
|
if (textureInfo->m_name != NULL) {
|
|
delete[] textureInfo->m_name;
|
|
}
|
|
|
|
textureInfo->m_name = new char[strlen(p_textureInfo->m_name) + 1];
|
|
strcpy(textureInfo->m_name, p_textureInfo->m_name);
|
|
return textureInfo;
|
|
}
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
// FUNCTION: LEGO1 0x10099cc0
|
|
void LegoTextureContainer::EraseCached(LegoTextureInfo* p_textureInfo)
|
|
{
|
|
if (p_textureInfo == NULL) {
|
|
return;
|
|
}
|
|
|
|
#ifdef COMPAT_MODE
|
|
LegoCachedTextureList::iterator it;
|
|
for (it = m_cached.begin(); it != m_cached.end(); it++) {
|
|
#else
|
|
for (LegoCachedTextureList::iterator it = m_cached.begin(); it != m_cached.end(); it++) {
|
|
#endif
|
|
if ((*it).first == p_textureInfo) {
|
|
(*it).second = FALSE;
|
|
|
|
if (p_textureInfo->m_texture->Release() == TRUE) {
|
|
delete p_textureInfo;
|
|
m_cached.erase(it);
|
|
}
|
|
|
|
return;
|
|
}
|
|
}
|
|
}
|