X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=platform%2Fwin32%2FGenaDrive%2FDirect.cpp;h=da86b16f77a06c9c9adccf1e50e24b6a87000da4;hb=bcc9eda077d079ea5005d60ac58f9fe0d5105abe;hp=a726acba19220fef1a7f925195fec625b664ab3c;hpb=1b0ac8adc97d65c686a48c4375c07907de86be24;p=picodrive.git diff --git a/platform/win32/GenaDrive/Direct.cpp b/platform/win32/GenaDrive/Direct.cpp index a726acb..da86b16 100644 --- a/platform/win32/GenaDrive/Direct.cpp +++ b/platform/win32/GenaDrive/Direct.cpp @@ -58,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; @@ -95,7 +95,7 @@ static int DirectScreenDDraw() ret = m_pddsBackBuffer->Lock(NULL, &sd, DDLOCK_SURFACEMEMORYPTR|DDLOCK_WAIT|DDLOCK_WRITEONLY, NULL); if (ret) { LOGFAIL(); return 1; } - //dprintf2("w: %i h: %i pi: %i pf: %i\n", sd.dwWidth, sd.dwHeight, sd.lPitch, sd.ddpfPixelFormat.dwRGBBitCount); + //lprintf("w: %i h: %i pi: %i pf: %i\n", sd.dwWidth, sd.dwHeight, sd.lPitch, sd.ddpfPixelFormat.dwRGBBitCount); if (sd.ddpfPixelFormat.dwRGBBitCount == 32) { @@ -110,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; @@ -146,7 +160,9 @@ static int DirectClearDDraw(unsigned int colour) static int DirectPresentDDraw() { - int ret = m_pddsFrontBuffer->Blt(&FrameRectMy, m_pddsBackBuffer, &EmuScreenRect, DDBLT_WAIT, NULL); + int ret = 0; + if (FrameRectMy.right - FrameRectMy.left > 0 && FrameRectMy.bottom - FrameRectMy.top > 0) + ret = m_pddsFrontBuffer->Blt(&FrameRectMy, m_pddsBackBuffer, &EmuScreenRect, DDBLT_WAIT, NULL); if (ret) { LOGFAIL(); return 1; } return 0; } @@ -289,6 +305,8 @@ int DirectPresent() } #ifdef USE_D3D +#define PI 3.14159265f + static int MakeVertexList() { struct CustomVertex *vert=NULL,*pv=NULL; @@ -374,7 +392,7 @@ int DirectScreen() TexScreenSwizzle(); #else ret=TexScreenLinear(); - if (ret) dprintf2("TexScreenLinear failed\n"); + if (ret) lprintf("TexScreenLinear failed\n"); #endif SetupMatrices(); @@ -383,7 +401,7 @@ int DirectScreen() // Copy vertices in: VertexBuffer->Lock(0,sizeof(VertexList),&lock,0); - if (lock==NULL) { dprintf2("VertexBuffer->Lock failed\n"); return 1; } + if (lock==NULL) { lprintf("VertexBuffer->Lock failed\n"); return 1; } memcpy(lock,VertexList,sizeof(VertexList)); VertexBuffer->Unlock();