Merge pull request #144 from basic2004/d3dfix

Some D3D fixes, and monochrome monitor...
This commit is contained in:
OBattler
2017-07-12 19:37:54 +02:00
committed by GitHub
3 changed files with 59 additions and 38 deletions

View File

@@ -1897,6 +1897,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
endblit();
saveconfig();
device_force_redraw();
cgapal_rebuild();
break;
case IDM_VID_FULLSCREEN:
@@ -1919,6 +1920,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
endblit();
saveconfig();
device_force_redraw();
cgapal_rebuild();
}
break;
@@ -2248,6 +2250,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
mouse_init();
endblit();
device_force_redraw();
cgapal_rebuild();
break;
case WM_KEYDOWN:

View File

@@ -95,7 +95,8 @@ int d3d_init(HWND h)
d3dpp.BackBufferWidth = 0;
d3dpp.BackBufferHeight = 0;
d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev)))
fatal("CreateDevice failed\n");
d3d_init_objects();
@@ -125,14 +126,16 @@ void d3d_init_objects()
int y;
RECT r;
d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
if (FAILED(d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
0,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_MANAGED,
&v_buffer,
NULL);
NULL)))
fatal("CreateVertexBuffer failed\n");
d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL);
if (FAILED(d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL)))
fatal("CreateTexture failed\n");
r.top = r.left = 0;
r.bottom = r.right = 2047;
@@ -244,19 +247,23 @@ void d3d_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
r.bottom = y2;
r.right = 2047;
hr = d3dTexture->LockRect(0, &dr, &r, 0);
if (hr == D3D_OK)
{
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
fatal("LockRect failed\n");
for (yy = y1; yy < y2; yy++)
{
if ((y + yy) >= 0 && (y + yy) < buffer32->h)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
}
video_blit_complete();
d3dTexture->UnlockRect(0);
}
else
{
video_blit_complete();
return;
}
d3d_verts[0].tu = d3d_verts[2].tu = d3d_verts[3].tu = 0;//0.5 / 2048.0;
d3d_verts[0].tv = d3d_verts[3].tv = d3d_verts[4].tv = 0;//0.5 / 2048.0;
@@ -334,11 +341,9 @@ void d3d_blit_memtoscreen_8(int x, int y, int w, int h)
r.bottom = h;
r.right = 2047;
hr = d3dTexture->LockRect(0, &dr, &r, 0);
if (hr == D3D_OK)
{
if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0)))
fatal("LockRect failed\n");
for (yy = 0; yy < h; yy++)
{
uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (yy * dr.Pitch));

View File

@@ -213,7 +213,8 @@ int d3d_fs_init(HWND h)
d3dpp.BackBufferWidth = d3d_fs_w;
d3dpp.BackBufferHeight = d3d_fs_h;
d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev);
if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, h, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3ddev)))
fatal("CreateDevice failed\n");
d3d_fs_init_objects();
@@ -243,14 +244,16 @@ static void d3d_fs_init_objects()
int y;
RECT r;
d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
if (FAILED(d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX),
0,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1,
D3DPOOL_MANAGED,
&v_buffer,
NULL);
NULL)))
fatal("CreateVertexBuffer failed\n");
d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL);
if (FAILED(d3ddev->CreateTexture(2048, 2048, 1, 0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED, &d3dTexture, NULL)))
fatal("CreateTexture failed\n");
r.top = r.left = 0;
r.bottom = r.right = 2047;
@@ -392,7 +395,7 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
D3DLOCKED_RECT dr;
RECT window_rect;
int yy;
double l, t, r, b;
double l = 0, t = 0, r = 0, b = 0;
if (y1 == y2)
{
@@ -409,15 +412,21 @@ static void d3d_fs_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h)
lock_rect.bottom = y2;
lock_rect.right = 2047;
if (FAILED(d3dTexture->LockRect(0, &dr, &lock_rect, 0)))
fatal("LockRect failed\n");
hr = d3dTexture->LockRect(0, &dr, &lock_rect, 0);
if (hr == D3D_OK)
{
for (yy = y1; yy < y2; yy++)
memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(((uint32_t *)buffer32->line[yy + y])[x]), w * 4);
video_blit_complete();
d3dTexture->UnlockRect(0);
}
else
{
video_blit_complete();
return;
}
}
else
video_blit_complete();
@@ -498,7 +507,7 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h)
D3DLOCKED_RECT dr;
RECT window_rect;
int xx, yy;
double l, t, r, b;
double l = 0, t = 0, r = 0, b = 0;
if (!h)
{
@@ -515,9 +524,9 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h)
lock_rect.bottom = 2047;
lock_rect.right = 2047;
if (FAILED(d3dTexture->LockRect(0, &dr, &lock_rect, 0)))
fatal("LockRect failed\n");
hr = d3dTexture->LockRect(0, &dr, &lock_rect, 0);
if (hr == D3D_OK)
{
for (yy = 0; yy < h; yy++)
{
uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (yy * dr.Pitch));
@@ -527,11 +536,15 @@ static void d3d_fs_blit_memtoscreen_8(int x, int y, int w, int h)
p[xx] = pal_lookup[buffer->line[y + yy][x + xx]];
}
}
video_blit_complete();
d3dTexture->UnlockRect(0);
}
else
{
video_blit_complete();
return;
}
}
else
video_blit_complete();