1 /*
2  * COPYRIGHT:            See COPYING in the top level directory
3  * PROJECT:              ReactOS DirectX
4  * FILE:                 dll/directx/ddraw/Ddraw/callbacks_dd_hel.c
5  * PURPOSE:              HEL Callbacks for Direct Draw
6  * PROGRAMMER:           Magnus Olsen
7  *
8  */
9 
10 #include "rosdraw.h"
11 
12 
13 extern  DDPIXELFORMAT pixelformats[];
14 extern DWORD pixelformatsCount;
15 
16 /*
17  * Direct Draw Callbacks
18  */
19 
HelDdDestroyDriver(LPDDHAL_DESTROYDRIVERDATA lpDestroyDriver)20 DWORD CALLBACK  HelDdDestroyDriver(LPDDHAL_DESTROYDRIVERDATA lpDestroyDriver)
21 {
22     DX_STUB;
23 }
24 
HelDdCreateSurface(LPDDHAL_CREATESURFACEDATA lpCreateSurface)25 DWORD CALLBACK  HelDdCreateSurface(LPDDHAL_CREATESURFACEDATA lpCreateSurface)
26 {
27     DX_STUB;
28 }
29 
30 
HelDdSetColorKey(LPDDHAL_DRVSETCOLORKEYDATA lpDrvSetColorKey)31 DWORD CALLBACK  HelDdSetColorKey(LPDDHAL_DRVSETCOLORKEYDATA lpDrvSetColorKey)
32 {
33     DX_STUB;
34 }
35 
36 
HelDdSetMode(LPDDHAL_SETMODEDATA SetMode)37 DWORD CALLBACK  HelDdSetMode(LPDDHAL_SETMODEDATA SetMode)
38 {
39     DEVMODE DevMode;
40 
41     DX_STUB_str("in hel");
42 
43     DevMode.dmSize = (WORD)sizeof(DEVMODE);
44     DevMode.dmDriverExtra = 0;
45 
46     SetMode->ddRVal = DDERR_UNSUPPORTEDMODE;
47 
48     if (EnumDisplaySettingsEx(NULL, SetMode->dwModeIndex, &DevMode, 0 ) != 0)
49     {
50 
51 
52         if (ChangeDisplaySettings(&DevMode, CDS_FULLSCREEN) != DISP_CHANGE_SUCCESSFUL)
53         {
54             DX_STUB_str("FAIL");
55             SetMode->ddRVal = DDERR_UNSUPPORTEDMODE;
56         }
57         else
58         {
59             DX_STUB_str("OK");
60             SetMode->ddRVal = DD_OK;
61         }
62     }
63 
64     return DDHAL_DRIVER_HANDLED;
65 }
66 
HelDdWaitForVerticalBlank(LPDDHAL_WAITFORVERTICALBLANKDATA lpWaitForVerticalBlank)67 DWORD CALLBACK  HelDdWaitForVerticalBlank(LPDDHAL_WAITFORVERTICALBLANKDATA lpWaitForVerticalBlank)
68 {
69     DX_STUB;
70 }
71 
HelDdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA lpCanCreateSurface)72 DWORD CALLBACK  HelDdCanCreateSurface(LPDDHAL_CANCREATESURFACEDATA lpCanCreateSurface)
73 {
74     DX_STUB;
75 }
76 
HelDdCreatePalette(LPDDHAL_CREATEPALETTEDATA lpCreatePalette)77 DWORD CALLBACK HelDdCreatePalette(LPDDHAL_CREATEPALETTEDATA lpCreatePalette)
78 {
79     DDRAWI_DDRAWPALETTE_GBL* ddPalGbl = lpCreatePalette->lpDDPalette;
80     LOGPALETTE* logPal ;
81     WORD size=1;
82 
83     if(ddPalGbl->dwFlags & DDRAWIPAL_2)
84         size = 2;
85     else if(ddPalGbl->dwFlags & DDRAWIPAL_4)
86         size = 4;
87     else if(ddPalGbl->dwFlags & DDRAWIPAL_16)
88         size = 16;
89     else if(ddPalGbl->dwFlags & DDRAWIPAL_256)
90         size = 256;
91 
92     DxHeapMemAlloc(logPal, sizeof(LOGPALETTE) + size*sizeof(PALETTEENTRY));
93     if(logPal == NULL)
94     {
95         lpCreatePalette->ddRVal = DDERR_OUTOFMEMORY;
96         return DDHAL_DRIVER_HANDLED;
97     }
98 
99     logPal->palVersion = 0x300;
100     logPal->palNumEntries = size;
101     CopyMemory(&logPal->palPalEntry[0], lpCreatePalette->lpColorTable, size*sizeof(PALETTEENTRY));
102 
103     ddPalGbl->hHELGDIPalette = CreatePalette(logPal);
104 
105     if (ddPalGbl->hHELGDIPalette == NULL)
106     {
107         DxHeapMemFree(logPal);
108         lpCreatePalette->ddRVal = DDERR_INVALIDOBJECT;
109         return DDHAL_DRIVER_HANDLED;
110     }
111 
112     DxHeapMemFree(logPal);
113     ddPalGbl->lpColorTable = lpCreatePalette->lpColorTable;
114     ddPalGbl->dwFlags |= DDRAWIPAL_INHEL | DDRAWIPAL_GDI ;
115     lpCreatePalette->ddRVal = DD_OK;
116     return DDHAL_DRIVER_HANDLED;
117 }
118 
HelDdGetScanLine(LPDDHAL_GETSCANLINEDATA lpGetScanLine)119 DWORD CALLBACK  HelDdGetScanLine(LPDDHAL_GETSCANLINEDATA lpGetScanLine)
120 {
121     DX_STUB;
122 }
123 
HelDdSetExclusiveMode(LPDDHAL_SETEXCLUSIVEMODEDATA lpSetExclusiveMode)124 DWORD CALLBACK  HelDdSetExclusiveMode(LPDDHAL_SETEXCLUSIVEMODEDATA lpSetExclusiveMode)
125 {
126     DX_WINDBG_trace();
127     DX_STUB_str("Not implement yet, return DD_OK for not bsod\n");
128     lpSetExclusiveMode->ddRVal = DD_OK;
129 
130     return DDHAL_DRIVER_HANDLED;
131 }
132 
HelDdFlipToGDISurface(LPDDHAL_FLIPTOGDISURFACEDATA lpFlipToGDISurface)133 DWORD CALLBACK  HelDdFlipToGDISurface(LPDDHAL_FLIPTOGDISURFACEDATA lpFlipToGDISurface)
134 {
135     DX_STUB;
136 }
137 
138