version 1.1 | | version 1.2 |
---|
| | |
extern CD3DFramework* g_pFramework; | | extern CD3DFramework* g_pFramework; |
extern BOOL g_bWindowed; | | extern BOOL g_bWindowed; |
| | |
| | extern "C" { |
| | #include "d3dhelp.h" |
| | } |
| | |
//----------------------------------------------------------------------------- | | //----------------------------------------------------------------------------- |
// Declare the application globals for use in WinMain.cpp | | // Declare the application globals for use in WinMain.cpp |
//----------------------------------------------------------------------------- | | //----------------------------------------------------------------------------- |
| | void Win32_SetupColor(void); |
| | BOOL g_TrueColor; |
| | int g_RShift, g_GShift, g_BShift; |
| | int g_RBits6, g_GBits6, g_BBits6; |
| | |
TCHAR* g_strAppTitle = TEXT( "Direct3D Descent" ); | | TCHAR* g_strAppTitle = TEXT( "Direct3D Descent" ); |
BOOL g_bAppUseZBuffer = FALSE; | | BOOL g_bAppUseZBuffer = FALSE; |
BOOL g_bAppUseBackBuffer = TRUE; | | BOOL g_bAppUseBackBuffer = TRUE; |
| | |
g_bTransparentLast = FALSE; | | g_bTransparentLast = FALSE; |
g_pd3dtLast = NULL; | | g_pd3dtLast = NULL; |
| | |
| | Win32_SetupColor(); |
| | |
return S_OK; | | return S_OK; |
} | | } |
| | |
| | |
D3DTextr_InvalidateAllTextures(); | | D3DTextr_InvalidateAllTextures(); |
| | |
g_setTextures.Uninitialize (); | | g_setTextures.Uninitialize (); |
| | |
| | Win32_InvalidatePages(); |
| | |
| | Win32_SetupColor(); |
} | | } |
| | |
| | |
| | |
#include "..\main\object.h" | | #include "..\main\object.h" |
#include "..\3d\globvars.h" | | #include "..\3d\globvars.h" |
#include "3d.h" | | #include "3d.h" |
| | #include "palette.h" |
} | | } |
| | |
#undef __BOGUS1 | | #undef __BOGUS1 |
| | |
return hResult; | | return hResult; |
} | | } |
| | |
| | extern "C" RGBQUAD w32lastrgb[256]; |
| | |
extern "C" void Win32_DoSetPalette (PALETTEENTRY *rgpe) | | extern "C" void Win32_DoSetPalette (PALETTEENTRY *rgpe) |
{ | | { |
g_setTextures.SetPaletteEntries (rgpe); | | g_setTextures.SetPaletteEntries (rgpe); |
| | for (int i = 0; i < 256; i++) { |
| | w32lastrgb[i].rgbBlue = rgpe[i].peBlue; |
| | w32lastrgb[i].rgbGreen = rgpe[i].peGreen; |
| | w32lastrgb[i].rgbRed = rgpe[i].peRed; |
| | } |
} | | } |
| | |
extern "C" void Win32_DoGetPalette (PALETTEENTRY *rgpe) | | extern "C" void Win32_DoGetPalette (PALETTEENTRY *rgpe) |
| | |
return S_OK; | | return S_OK; |
} | | } |
| | |
| | extern "C" void BlitToPrimary(HDC hSrcDC) |
| | { |
| | RECT rectDest; |
| | rectDest.left = 0; |
| | rectDest.top = 0; |
| | rectDest.right = g_pFramework->m_dwRenderWidth; |
| | rectDest.bottom = g_pFramework->m_dwRenderHeight; |
| | |
| | if (g_bWindowed) |
| | { |
| | rectDest.left += g_pFramework->m_rcScreenRect.left; |
| | rectDest.right += g_pFramework->m_rcScreenRect.left; |
| | rectDest.top += g_pFramework->m_rcScreenRect.top; |
| | rectDest.bottom += g_pFramework->m_rcScreenRect.top; |
| | } |
| | |
| | HDC hDstDC; |
| | if (g_pFramework->GetFrontBuffer()->GetDC(&hDstDC) == DD_OK) |
| | { |
| | StretchBlt(hDstDC, rectDest.left, rectDest.top, |
| | rectDest.right - rectDest.left, rectDest.bottom - rectDest.top, |
| | hSrcDC, 0, 0, 320, 200, SRCCOPY); |
| | g_pFramework->GetFrontBuffer()->ReleaseDC(hDstDC); |
| | } |
| | return; |
| | } |
| | |
| | extern "C" void BlitToPrimaryRect(HDC hSrcDC, int x, int y, int w, int h, |
| | unsigned char *dst) |
| | { |
| | RECT rectDest; |
| | int destWidth = g_pFramework->m_dwRenderWidth; |
| | int destHeight = g_pFramework->m_dwRenderHeight; |
| | |
| | rectDest.left = (x * destWidth) / 320; |
| | rectDest.top = (y * destHeight) / 200; |
| | rectDest.right = ((x + w) * destWidth) / 320; |
| | rectDest.bottom = ((y + h) * destHeight) / 200; |
| | |
| | if (g_bWindowed && (int)dst == BM_D3D_DISPLAY) |
| | { |
| | rectDest.left += g_pFramework->m_rcScreenRect.left; |
| | rectDest.right += g_pFramework->m_rcScreenRect.left; |
| | rectDest.top += g_pFramework->m_rcScreenRect.top; |
| | rectDest.bottom += g_pFramework->m_rcScreenRect.top; |
| | } |
| | |
| | HDC hDstDC; |
| | IDirectDrawSurface4 *pddsDest = ((int)dst == BM_D3D_DISPLAY) ? |
| | g_pFramework->GetFrontBuffer() : |
| | g_pFramework->GetRenderSurface(); |
| | if (pddsDest->GetDC(&hDstDC) == DD_OK) |
| | { |
| | StretchBlt(hDstDC, rectDest.left, rectDest.top, |
| | rectDest.right - rectDest.left, rectDest.bottom - rectDest.top, |
| | hSrcDC, x, y, w, h, SRCCOPY); |
| | pddsDest->ReleaseDC(hDstDC); |
| | } |
| | return; |
| | } |
| | |
HRESULT Blit ( | | HRESULT Blit ( |
RECT &rectDest, | | RECT &rectDest, |
LPDIRECTDRAWSURFACE4 pddsSrc, | | LPDIRECTDRAWSURFACE4 pddsSrc, |
| | |
pddbltfx); | | pddbltfx); |
} | | } |
| | |
| | static void findmask6(int in_mask, int *shift, int *bits6) |
| | { |
| | int i; |
| | |
| | if (!in_mask) { |
| | *shift = 0; |
| | *bits6 = 6; |
| | return; |
| | } |
| | i = 0; |
| | while (!(in_mask & 1)) |
| | { |
| | in_mask >>= 1; |
| | i++; |
| | } |
| | *shift = i; |
| | i = 0; |
| | while (in_mask & 1) |
| | { |
| | in_mask >>= 1; |
| | i++; |
| | } |
| | *bits6 = 6 - i; |
| | } |
| | |
| | void Win32_SetupColor(void) |
| | { |
| | DDPIXELFORMAT pf; |
| | pf.dwSize = sizeof(pf); |
| | g_pFramework->GetFrontBuffer ()->GetPixelFormat(&pf); |
| | g_TrueColor = pf.dwRGBBitCount == 24 || pf.dwRGBBitCount == 32; |
| | if (!g_TrueColor) |
| | { |
| | findmask6(pf.dwRBitMask, &g_RShift, &g_RBits6); |
| | findmask6(pf.dwGBitMask, &g_GShift, &g_GBits6); |
| | findmask6(pf.dwBBitMask, &g_BShift, &g_BBits6); |
| | } |
| | } |
| | |
extern "C" void Win32_Rect ( | | extern "C" void Win32_Rect ( |
int left, int top, int right, int bot, | | int left, int top, int right, int bot, |
int iSurf, | | int iSurf, |
| | |
DDBLTFX ddbltfx; | | DDBLTFX ddbltfx; |
ddbltfx.dwSize = sizeof (ddbltfx); | | ddbltfx.dwSize = sizeof (ddbltfx); |
| | |
| | #if 0 |
if (g_setTextures.HasPalette ()) | | if (g_setTextures.HasPalette ()) |
{ | | { |
ddbltfx.dwFillColor = iCol; | | ddbltfx.dwFillColor = iCol; |
| | |
PALETTEENTRY pe = g_setTextures.ReadPalette (iCol); | | PALETTEENTRY pe = g_setTextures.ReadPalette (iCol); |
ddbltfx.dwFillColor = *(DWORD*) &pe; | | ddbltfx.dwFillColor = *(DWORD*) &pe; |
} | | } |
| | #else |
| | unsigned char *p = gr_current_pal + iCol * 3; |
| | if (g_TrueColor) |
| | ddbltfx.dwFillColor = (255 << 24) | (p[0] << 18) | |
| | (p[1] << 10) | (p[2] << 2); |
| | else |
| | ddbltfx.dwFillColor = (p[0] >> g_RBits6) << g_RShift | |
| | (p[1] >> g_GBits6) << g_GShift | |
| | (p[2] >> g_BBits6) << g_BShift; |
| | #endif |
| | |
HRESULT hr = Blit ( | | HRESULT hr = Blit ( |
rectDest, | | rectDest, |