ReactOS  0.4.14-dev-293-g2b39b42
cards.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <wingdi.h>
#include <winuser.h>
#include "cards.h"
Include dependency graph for cards.c:

Go to the source code of this file.

Functions

BOOL WINAPI WEP (DWORD Unknown)
 
BOOL WINAPI cdtInit (INT *Width, INT *Height)
 
VOID WINAPI cdtTerm (VOID)
 
BOOL WINAPI cdtDraw (HDC hdc, INT x, INT y, INT card, INT type, COLORREF color)
 
static __inline VOID BltCard (HDC hdc, INT x, INT y, INT dx, INT dy, HDC hdcCard, DWORD dwRasterOp, BOOL bStretch)
 
BOOL WINAPI cdtDrawExt (HDC hdc, INT x, INT y, INT dx, INT dy, INT card, INT type, COLORREF color)
 
BOOL WINAPI cdtAnimate (HDC hdc, int cardback, int x, int y, int frame)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 

Variables

HBITMAP g_CardBitmaps [MAX_CARD_BITMAPS]
 
HINSTANCE g_hModule = 0
 

Function Documentation

◆ BltCard()

static __inline VOID BltCard ( HDC  hdc,
INT  x,
INT  y,
INT  dx,
INT  dy,
HDC  hdcCard,
DWORD  dwRasterOp,
BOOL  bStretch 
)
static

Definition at line 82 of file cards.c.

83 {
84  if (bStretch)
85  {
86  StretchBlt(hdc, x, y, dx, dy, hdcCard, 0, 0, CARD_WIDTH, CARD_HEIGHT, dwRasterOp);
87  }
88  else
89  {
90  BitBlt(hdc, x, y, dx, dy, hdcCard, 0, 0, dwRasterOp);
91 /*
92  * This is need when using Microsoft images, because they use two-color red/white images for
93  * red cards and thus needs fix-up of the edge to black color.
94  */
95 #if 0
96  if (ISREDCARD(card))
97  {
98  PatBlt(hdc, x, y + 2, 1, dy - 4, BLACKNESS);
99  PatBlt(hdc, x + dx - 1, y + 2, 1, dy - 4, BLACKNESS);
100  PatBlt(hdc, x + 2, y, dx - 4, 1, BLACKNESS);
101  PatBlt(hdc, x + 2, y + dy - 1, dx - 4, 1, BLACKNESS);
102  SetPixel(hdc, x + 1, y + 1, 0);
103  SetPixel(hdc, x + dx - 2, y + 1, 0);
104  SetPixel(hdc, x + 1, y + dy - 2, 0);
105  SetPixel(hdc, x + dx - 2, y + dy - 2, 0);
106  }
107 #endif
108  }
109 }
GLint dy
Definition: linetemp.h:97
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:410
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:93
HDC hdc
Definition: main.c:9
#define BLACKNESS
Definition: wingdi.h:322
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint dx
Definition: linetemp.h:97
#define ISREDCARD(x)
Definition: cards.h:53

Referenced by cdtDrawExt().

◆ cdtAnimate()

BOOL WINAPI cdtAnimate ( HDC  hdc,
int  cardback,
int  x,
int  y,
int  frame 
)

Definition at line 238 of file cards.c.

239 {
240  UNREFERENCED_PARAMETER(frame);
243  UNREFERENCED_PARAMETER(cardback);
245  return TRUE;
246 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC hdc
Definition: main.c:9
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ cdtDraw()

BOOL WINAPI cdtDraw ( HDC  hdc,
INT  x,
INT  y,
INT  card,
INT  type,
COLORREF  color 
)

Definition at line 74 of file cards.c.

75 {
76  return cdtDrawExt(hdc, x, y, CARD_WIDTH, CARD_HEIGHT, card, type, color);
77 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint color
Definition: glext.h:6243
HDC hdc
Definition: main.c:9
BOOL WINAPI cdtDrawExt(HDC hdc, INT x, INT y, INT dx, INT dy, INT card, INT type, COLORREF color)
Definition: cards.c:124
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548

◆ cdtDrawExt()

BOOL WINAPI cdtDrawExt ( HDC  hdc,
INT  x,
INT  y,
INT  dx,
INT  dy,
INT  card,
INT  type,
COLORREF  color 
)

Definition at line 124 of file cards.c.

125 {
126  DWORD dwRasterOp = SRCCOPY;
127  BOOL bSaveEdges = TRUE;
128  BOOL bStretch = FALSE;
129 
130  if (type & ectSAVEEDGESMASK)
131  {
133  bSaveEdges = FALSE;
134  }
135 
136  if (dx != CARD_WIDTH || dy != CARD_HEIGHT)
137  {
138  bStretch = TRUE;
139  bSaveEdges = FALSE;
140  }
141 
142  switch (type)
143  {
144  case ectINVERTED:
145  dwRasterOp = NOTSRCCOPY;
146  case ectFACES:
147  card = (card % 4) * 13 + (card / 4);
148  break;
149  case ectBACKS:
150  --card;
151  break;
152  case ectEMPTYNOBG:
153  dwRasterOp = SRCAND;
154  case ectEMPTY:
155  card = 52;
156  break;
157  case ectERASE:
158  break;
159  case ectREDX:
160  card = 66;
161  break;
162  case ectGREENO:
163  card = 67;
164  break;
165  default:
166  return FALSE;
167  }
168 
169  if (type == ectEMPTY || type == ectERASE)
170  {
171  POINT pPoint;
172  HBRUSH hBrush, hOldBrush;
173 
174  hBrush = CreateSolidBrush(color);
175  GetDCOrgEx(hdc, &pPoint);
176  SetBrushOrgEx(hdc, pPoint.x, pPoint.y, 0);
177  hOldBrush = SelectObject(hdc, hBrush);
178  PatBlt(hdc, x, y, dx, dy, PATCOPY);
179  SelectObject(hdc, hOldBrush);
180  DeleteObject(hBrush);
181  }
182  if (type != ectERASE)
183  {
184  HDC hdcCard;
185  COLORREF OldBkColor;
186 
187  hdcCard = CreateCompatibleDC(hdc);
188  SelectObject(hdcCard, g_CardBitmaps[card]);
189  OldBkColor = SetBkColor(hdc, (type == ectFACES) ? 0xFFFFFF : color);
190  if (bSaveEdges)
191  {
192  COLORREF SavedPixels[12];
193  SavedPixels[0] = GetPixel(hdc, x, y);
194  SavedPixels[1] = GetPixel(hdc, x + 1, y);
195  SavedPixels[2] = GetPixel(hdc, x, y + 1);
196  SavedPixels[3] = GetPixel(hdc, x + dx - 1, y);
197  SavedPixels[4] = GetPixel(hdc, x + dx - 2, y);
198  SavedPixels[5] = GetPixel(hdc, x + dx - 1, y + 1);
199  SavedPixels[6] = GetPixel(hdc, x, y + dy - 1);
200  SavedPixels[7] = GetPixel(hdc, x + 1, y + dy - 1);
201  SavedPixels[8] = GetPixel(hdc, x, y + dy - 2);
202  SavedPixels[9] = GetPixel(hdc, x + dx - 1, y + dy - 1);
203  SavedPixels[10] = GetPixel(hdc, x + dx - 2, y + dy - 1);
204  SavedPixels[11] = GetPixel(hdc, x + dx - 1, y + dy - 2);
205 
206  BltCard(hdc, x, y, dx, dy, hdcCard, dwRasterOp, bStretch);
207 
208  SetPixel(hdc, x, y, SavedPixels[0]);
209  SetPixel(hdc, x + 1, y, SavedPixels[1]);
210  SetPixel(hdc, x, y + 1, SavedPixels[2]);
211  SetPixel(hdc, x + dx - 1, y, SavedPixels[3]);
212  SetPixel(hdc, x + dx - 2, y, SavedPixels[4]);
213  SetPixel(hdc, x + dx - 1, y + 1, SavedPixels[5]);
214  SetPixel(hdc, x, y + dy - 1, SavedPixels[6]);
215  SetPixel(hdc, x + 1, y + dy - 1, SavedPixels[7]);
216  SetPixel(hdc, x, y + dy - 2, SavedPixels[8]);
217  SetPixel(hdc, x + dx - 1, y + dy - 1, SavedPixels[9]);
218  SetPixel(hdc, x + dx - 2, y + dy - 1, SavedPixels[10]);
219  SetPixel(hdc, x + dx - 1, y + dy - 2, SavedPixels[11]);
220  }
221  else
222  {
223  BltCard(hdc, x, y, dx, dy, hdcCard, dwRasterOp, bStretch);
224  }
225  SetBkColor(hdc, OldBkColor);
226  DeleteDC(hdcCard);
227  }
228 
229  return TRUE;
230 }
#define TRUE
Definition: types.h:120
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
static __inline VOID BltCard(HDC hdc, INT x, INT y, INT dx, INT dy, HDC hdcCard, DWORD dwRasterOp, BOOL bStretch)
Definition: cards.c:82
GLint dy
Definition: linetemp.h:97
static HDC
Definition: imagelist.c:92
#define ectBACKS
Definition: cards.h:34
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
#define ectEMPTY
Definition: cards.h:36
DWORD GetPixel(LPDIRECTDRAWSURFACE7 Surface, UINT x, UINT y)
Definition: blt.cpp:2
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define ectREDX
Definition: cards.h:39
unsigned int BOOL
Definition: ntddk_ex.h:94
GLuint color
Definition: glext.h:6243
#define ectSAVEEDGESMASK
Definition: cards.h:41
#define NOTSRCCOPY
Definition: wingdi.h:324
BOOL WINAPI SetBrushOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:93
#define ectINVERTED
Definition: cards.h:35
DWORD COLORREF
Definition: windef.h:285
#define ectERASE
Definition: cards.h:37
unsigned long DWORD
Definition: ntddk_ex.h:95
HBITMAP g_CardBitmaps[MAX_CARD_BITMAPS]
Definition: cards.c:28
HDC hdc
Definition: main.c:9
#define ectGREENO
Definition: cards.h:40
#define ectEMPTYNOBG
Definition: cards.h:38
#define PATCOPY
Definition: wingdi.h:334
BOOL WINAPI DeleteDC(_In_ HDC)
#define SRCAND
Definition: wingdi.h:329
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint dx
Definition: linetemp.h:97
#define ectFACES
Definition: cards.h:33
#define SRCCOPY
Definition: wingdi.h:332
BOOL WINAPI GetDCOrgEx(_In_ HDC, _Out_ LPPOINT)
Definition: coord.c:816

Referenced by cdtDraw().

◆ cdtInit()

BOOL WINAPI cdtInit ( INT Width,
INT Height 
)

Definition at line 43 of file cards.c.

44 {
45  DWORD dwIndex;
46 
47  /* Report card width and height to user */
48  *Width = CARD_WIDTH;
49  *Height = CARD_HEIGHT;
50 
51  /* Load images */
52  for (dwIndex = 0; dwIndex < MAX_CARD_BITMAPS; ++dwIndex)
53  g_CardBitmaps[dwIndex] =
55 
56  return TRUE;
57 }
#define TRUE
Definition: types.h:120
HBITMAP WINAPI LoadBitmapA(_In_opt_ HINSTANCE, _In_ LPCSTR)
Definition: cursoricon.c:2117
#define MAKEINTRESOURCEA(i)
Definition: winuser.h:581
unsigned long DWORD
Definition: ntddk_ex.h:95
HBITMAP g_CardBitmaps[MAX_CARD_BITMAPS]
Definition: cards.c:28
#define MAX_CARD_BITMAPS
Definition: cards.h:31
static HBITMAP
Definition: button.c:44
HINSTANCE g_hModule
Definition: cards.c:29

◆ cdtTerm()

VOID WINAPI cdtTerm ( VOID  )

Definition at line 62 of file cards.c.

63 {
64  DWORD dwIndex;
65 
66  /* Unload images */
67  for (dwIndex = 0; dwIndex < MAX_CARD_BITMAPS; dwIndex++)
68  DeleteObject(g_CardBitmaps[dwIndex]);
69 }
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
unsigned long DWORD
Definition: ntddk_ex.h:95
HBITMAP g_CardBitmaps[MAX_CARD_BITMAPS]
Definition: cards.c:28
#define MAX_CARD_BITMAPS
Definition: cards.h:31

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 248 of file cards.c.

249 {
251 
252  if (fdwReason == DLL_PROCESS_ATTACH)
253  g_hModule = hinstDLL;
254 
255  return TRUE;
256 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
static IN DWORD IN LPVOID lpvReserved
HINSTANCE g_hModule
Definition: cards.c:29

◆ WEP()

BOOL WINAPI WEP ( DWORD  Unknown)

Definition at line 34 of file cards.c.

35 {
37  return TRUE;
38 }
#define TRUE
Definition: types.h:120
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323

Variable Documentation

◆ g_CardBitmaps

HBITMAP g_CardBitmaps[MAX_CARD_BITMAPS]

Definition at line 28 of file cards.c.

Referenced by cdtDrawExt(), cdtInit(), and cdtTerm().

◆ g_hModule

HINSTANCE g_hModule = 0

Definition at line 29 of file cards.c.

Referenced by cdtInit(), and DllMain().