Stefan Dösinger schrieb:
Hi, I've brought my DirectDraw over WineD3D patch in a form where I want to show it to the public for review. I've uploaded it to http://stud4.tuwien.ac.at/~e0526822/, where it is described in detail(below the game list).
nice work :).
I just looked a bit into the palette issue( aka lost text color etc):
from IWineD3DDeviceImpl_CreatePalette: + memset(&palVersion, 0, sizeof(LOGPALETTE)); + object->hpal = CreatePalette(&palVersion); + memcpy(&object->palVersion, &palVersion, sizeof(LOGPALETTE)); + /* FIXME Using the palVersion member from IWineD3DPaletteImpl for CreatePalette + * directly causes a heap corruption. Why? In original ddraw this was a WORD, + * which failed too. Confused ... + */ + object->palNumEntries = IWineD3DPaletteImpl_Size(Flags);
That can't really work. This only creates a palette with zero entries. You need to set palNumEntries before calling CreatePalette. Attached patch( applies on top of yours ) should fix it( i.e. do it the same way it is done in the current implementation). But the text colors in AoE are still lacking :/. Needs some more investigation ...
Peter
b0a1e06bddc2bbc17bf7b5d991236a4cd76f0d1a diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index f224c2c..9b0e468 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1660,12 +1660,11 @@ HRESULT WINAPI IWineD3DDeviceImpl_Create HRESULT WINAPI IWineD3DDeviceImpl_CreatePalette(IWineD3DDevice *iface, DWORD Flags, PALETTEENTRY *PalEnt, IWineD3DPalette **Palette, IUnknown *Parent) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; IWineD3DPaletteImpl *object; - LOGPALETTE palVersion; HRESULT hr; FIXME("(%p)->(%lx, %p, %p, %p)\n", This, Flags, PalEnt, Palette, Parent);
/* Create the new object */ - object = HeapAlloc(GetProcessHeap(), 0, sizeof(IWineD3DPaletteImpl)); + object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DPaletteImpl)); if(!object) { ERR("Out of memory when allocating memory for a IWineD3DPalette implementation\n"); return DDERR_OUTOFVIDEOMEMORY; @@ -1676,15 +1675,14 @@ HRESULT WINAPI IWineD3DDeviceImpl_Create object->Flags = Flags; object->parent = Parent; object->wineD3DDevice = This; - - memset(&palVersion, 0, sizeof(LOGPALETTE)); - object->hpal = CreatePalette(&palVersion); - memcpy(&object->palVersion, &palVersion, sizeof(LOGPALETTE)); - /* FIXME Using the palVersion member from IWineD3DPaletteImpl for CreatePalette - * directly causes a heap corruption. Why? In original ddraw this was a WORD, - * which failed too. Confused ... - */ object->palNumEntries = IWineD3DPaletteImpl_Size(Flags); + + object->hpal = CreatePalette((const LOGPALETTE*)&(object->palVersion)); + + if(!object->hpal) { + HeapFree( GetProcessHeap(), 0, object); + return DDERR_OUTOFMEMORY; /* only reason why CreatePalette could have failed */ + }
hr = IWineD3DPalette_SetEntries((IWineD3DPalette *) object, 0, 0, IWineD3DPaletteImpl_Size(Flags), PalEnt); if(FAILED(hr)) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 86b10bb..626154a 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -1309,9 +1309,9 @@ struct IWineD3DPaletteImpl {
/* IWineD3DPalette */ HPALETTE hpal; - LOGPALETTE palVersion; - WORD palNumEntries; - PALETTEENTRY palents[256]; + WORD palVersion; /*| */ + WORD palNumEntries; /*| LOGPALETTE */ + PALETTEENTRY palents[256]; /*| */ /* This is to store the palette in 'screen format' */ int screen_palents[256]; DWORD Flags;