forked from aqrit/ddwrapper
-
Notifications
You must be signed in to change notification settings - Fork 1
/
palette.cpp
85 lines (76 loc) · 2.71 KB
/
palette.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include "header.h"
namespace palette
{
struct XVTBL
{
HRESULT (__stdcall * QueryInterface)( WRAP* This, const IID& riid, void** ppvObject );
ULONG (__stdcall * AddRef)( WRAP* This );
ULONG (__stdcall * Release)( WRAP* This );
HRESULT (__stdcall * GetCaps)( WRAP* This, LPDWORD lpdwCaps );
HRESULT (__stdcall * GetEntries)( WRAP* This, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries );
HRESULT (__stdcall * Initialize)( WRAP* This, LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable );
HRESULT (__stdcall * SetEntries)( WRAP* This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries );
};
HRESULT __stdcall QueryInterface( WRAP* This, const IID& riid, void** ppvObject )
{
PROLOGUE;
HRESULT hResult = This->pal->lpVtbl->QueryInterface( This->pal, riid, ppvObject );
if( SUCCEEDED( hResult ) ) Wrap( This->dd_parent, iid_to_vtbl( riid ), ppvObject );
EPILOGUE( hResult );
}
ULONG __stdcall AddRef( WRAP* This )
{
PROLOGUE;
ULONG dwCount = This->pal->lpVtbl->AddRef( This->pal );
EPILOGUE( dwCount );
}
ULONG __stdcall Release( WRAP* This )
{
PROLOGUE;
ULONG dwCount = WrapRelease( This );
EPILOGUE( dwCount );
}
HRESULT __stdcall GetCaps( WRAP* This, LPDWORD lpdwCaps )
{
PROLOGUE;
HRESULT hResult = This->pal->lpVtbl->GetCaps( This->pal, lpdwCaps );
EPILOGUE( hResult );
}
HRESULT __stdcall GetEntries( WRAP* This, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries )
{
PROLOGUE;
HRESULT hResult = This->pal->lpVtbl->GetEntries( This->pal, dwFlags, dwBase, dwNumEntries, lpEntries );
EPILOGUE( hResult );
}
HRESULT __stdcall Initialize( WRAP* This, LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable )
{
PROLOGUE;
HRESULT hResult = This->pal->lpVtbl->Initialize( This->pal, GetInnerInterface( lpDD ), dwFlags, lpDDColorTable );
EPILOGUE( hResult );
}
HRESULT __stdcall SetEntries( WRAP* This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries )
{
PROLOGUE;
HRESULT hResult = This->pal->lpVtbl->SetEntries( This->pal, dwFlags, dwStartingEntry, dwCount, lpEntries );
INFO("SetEntries offset %d cnt %d\n", dwStartingEntry, dwCount);
if (SUCCEEDED(hResult) && (This->pal == dx::palette)) {
if (dx::enabled > 256) { // Palette is fully initialized.
dx::Flush(dx::fake[dx::flip], 1);
} else {
if (dx::enabled == 1) dx::Flush(dx::fake[dx::flip], 1); // Initial draw.
dx::enabled += dwCount;
}
}
EPILOGUE( hResult );
}
const XVTBL xVtbl =
{
QueryInterface, // 0x00
AddRef, // 0x04
Release, // 0x08
GetCaps, // 0x0C
GetEntries, // 0x10
Initialize, // 0x14
SetEntries, // 0x18
};
};