X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fwin32%2FGenaDrive%2FDirect.cpp;h=b8112d3be414b76865f02bd7b68438120b6bc2c5;hb=a5f80ce405bdb5377ed58a2525819ca1a8e11685;hp=07e874764cf228bfe0e41746b4f93c1d1e4bd4c4;hpb=03a265e5ebabff7adbb4f97387f81e9b0428dbee;p=picodrive.git diff --git a/platform/win32/GenaDrive/Direct.cpp b/platform/win32/GenaDrive/Direct.cpp index 07e8747..b8112d3 100644 --- a/platform/win32/GenaDrive/Direct.cpp +++ b/platform/win32/GenaDrive/Direct.cpp @@ -1,5 +1,6 @@ #include "app.h" +#ifdef USE_D3D // d3d static IDirect3D8 *Direct3D=NULL; IDirect3DDevice8 *Device=NULL; @@ -16,6 +17,7 @@ struct CustomVertex #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1) static CustomVertex VertexList[4]; +#endif // ddraw #include @@ -56,7 +58,7 @@ static int DirectDrawInit() // Create the backbuffer surface ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_3DDEVICE; + ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; ddsd.dwWidth = EmuWidth; ddsd.dwHeight = EmuHeight; @@ -108,6 +110,20 @@ static int DirectScreenDDraw() dst = (int *)((char *)dst + sd.lPitch); } } + else if (sd.ddpfPixelFormat.dwRGBBitCount == 24) /* wine uses this for me */ + { + void *dst = sd.lpSurface; + for (y = 0; y < EmuHeight; y++) + { + unsigned char *dst1 = (unsigned char *) dst; + for (x = 0; x < EmuWidth; x++, dst1 += 3) + { + int s = *ps++; + dst1[2] = (s&0xf800)>>8; dst1[1] = (s&0x07e0)>>3; dst1[0] = s<<3; // BGR + } + dst = (void *)((char *)dst + sd.lPitch); + } + } else if (sd.ddpfPixelFormat.dwRGBBitCount == 16) { unsigned short *dst = (unsigned short *)sd.lpSurface; @@ -144,7 +160,7 @@ static int DirectClearDDraw(unsigned int colour) static int DirectPresentDDraw() { - int ret = m_pddsFrontBuffer->Blt(&FrameRectMy, m_pddsBackBuffer, NULL, DDBLT_WAIT, NULL); + int ret = m_pddsFrontBuffer->Blt(&FrameRectMy, m_pddsBackBuffer, &EmuScreenRect, DDBLT_WAIT, NULL); if (ret) { LOGFAIL(); return 1; } return 0; } @@ -154,6 +170,7 @@ static int DirectPresentDDraw() int DirectInit() { +#if USE_D3D D3DPRESENT_PARAMETERS d3dpp; D3DDISPLAYMODE mode; int i,u,ret=0; @@ -242,14 +259,14 @@ fail0: RELEASE(Direct3D) // error("Failed to use Direct3D, trying DirectDraw.."); - +#endif // try DirectDraw return DirectDrawInit(); } void DirectExit() { - //FontExit(); +#ifdef USE_D3D TexScreenExit(); // d3d @@ -257,11 +274,35 @@ void DirectExit() RELEASE(DirectBack) RELEASE(Device) RELEASE(Direct3D) - +#endif DirectExitDDraw(); } +int DirectClear(unsigned int colour) +{ +#ifdef USE_D3D + if (Device != NULL) { + Device->Clear(0,NULL,D3DCLEAR_TARGET,colour,1.0f,0); + return 0; + } +#endif + + return DirectClearDDraw(colour); +} + +int DirectPresent() +{ +#ifdef USE_D3D + if (Device != NULL) { + Device->Present(NULL,NULL,NULL,NULL); + return 0; + } +#endif + + return DirectPresentDDraw(); +} +#ifdef USE_D3D static int MakeVertexList() { struct CustomVertex *vert=NULL,*pv=NULL; @@ -303,24 +344,6 @@ static int MakeVertexList() return 0; } -int DirectClear(unsigned int colour) -{ - if (Device == NULL) - return DirectClearDDraw(colour); - - Device->Clear(0,NULL,D3DCLEAR_TARGET,colour,1.0f,0); - return 0; -} - -int DirectPresent() -{ - if (Device == NULL) - return DirectPresentDDraw(); - - Device->Present(NULL,NULL,NULL,NULL); - return 0; -} - static int SetupMatrices() { D3DXVECTOR3 eye ( 0.0f, 0.0f, 0.0f ); @@ -387,3 +410,10 @@ int DirectScreen() return 0; } +#else +int DirectScreen() +{ + return DirectScreenDDraw(); +} +#endif +