diff --git a/src/printer/prt_ps.c b/src/printer/prt_ps.c index 39d192d08..1391b7e0a 100644 --- a/src/printer/prt_ps.c +++ b/src/printer/prt_ps.c @@ -8,7 +8,7 @@ * * Implementation of a generic PostScript printer. * - * Version: @(#)prt_ps.c 1.0.0 2019/xx/xx + * Version: @(#)prt_ps.c 1.0.1 2019/12/06 * * Authors: David Hrdlička, * @@ -145,7 +145,7 @@ convert_to_pdf(ps_t *dev) code = ghostscript_set_arg_encoding(instance, GS_ARG_ENCODING_UTF16LE); if (code == 0) - code = ghostscript_init_with_args(instance, 9, gsargv); + code = ghostscript_init_with_args(instance, 9, (char **) gsargv); if (code == 0 || code == gs_error_Quit) code = ghostscript_exit(instance); diff --git a/src/video/vid_mda.c b/src/video/vid_mda.c index 382738b42..2651e30ea 100644 --- a/src/video/vid_mda.c +++ b/src/video/vid_mda.c @@ -8,13 +8,13 @@ * * MDA emulation. * - * Version: @(#)vid_mda.c 1.0.13 2019/09/03 + * Version: @(#)vid_mda.c 1.0.14 2019/11/24 * * Authors: Sarah Walker, * Miran Grca, * - * Copyright 2008-2018 Sarah Walker. - * Copyright 2016-2018 Miran Grca. + * Copyright 2008-2019 Sarah Walker. + * Copyright 2016-2019 Miran Grca. */ #include #include @@ -114,7 +114,7 @@ void mda_poll(void *p) int blink; if (!mda->linepos) { - timer_advance_u64(&mda->timer, mda->dispofftime); + timer_advance_u64(&mda->timer, mda->dispofftime); mda->stat |= 1; mda->linepos = 1; oldsc = mda->sc; @@ -125,6 +125,7 @@ void mda_poll(void *p) if (mda->displine < mda->firstline) { mda->firstline = mda->displine; + video_wait_for_buffer(); } mda->lastline = mda->displine; for (x = 0; x < mda->crtc[1]; x++) diff --git a/src/video/video.c b/src/video/video.c index 5f62afbe8..7d87c5382 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -40,7 +40,7 @@ * W = 3 bus clocks * L = 4 bus clocks * - * Version: @(#)video.c 1.0.34 2019/10/20 + * Version: @(#)video.c 1.0.35 2019/12/06 * * Authors: Sarah Walker, * Miran Grca, @@ -72,6 +72,7 @@ volatile int screenshots = 0; bitmap_t *buffer32 = NULL; +bitmap_t *render_buffer = NULL; uint8_t fontdat[2048][8]; /* IBM CGA font */ uint8_t fontdatm[2048][16]; /* IBM MDA font */ uint8_t fontdatw[512][32]; /* Wyse700 font */ @@ -381,10 +382,7 @@ video_take_screenshot(const wchar_t *fn, int startx, int starty, int w, int h) for (y = 0; y < h; ++y) { b_rgb[y] = (png_byte *) malloc(png_get_rowbytes(png_ptr, info_ptr)); for (x = 0; x < w; ++x) { - if (video_grayscale || invert_display) - video_transform_copy(&temp, &(buffer32->line[y + starty][x + startx]), 1); - else - temp = buffer32->line[y + starty][x + startx]; + temp = render_buffer->line[y + starty][x + startx]; b_rgb[y][(x) * 3 + 0] = (temp >> 16) & 0xff; b_rgb[y][(x) * 3 + 1] = (temp >> 8) & 0xff; @@ -433,11 +431,37 @@ video_screenshot(int x, int y, int w, int h) } +static void +video_transform_copy(uint32_t *dst, uint32_t *src, int len) +{ + int i; + + for (i = 0; i < len; i++) { + *dst = video_color_transform(*src); + dst++; + src++; + } +} + + void video_blit_memtoscreen(int x, int y, int y1, int y2, int w, int h) { + int yy; + + if ((w > 0) && (h > 0)) { + for (yy = 0; yy < h; yy++) { + if (((y + yy) >= 0) && ((y + yy) < buffer32->h)) { + if (video_grayscale || invert_display) + video_transform_copy(&(render_buffer->line[y + yy][x]), &(buffer32->line[y + yy][x]), w); + else + memcpy(&(render_buffer->line[y + yy][x]), &(buffer32->line[y + yy][x]), w << 2); + } + } + } + if (screenshots) { - if (buffer32 != NULL) + if (render_buffer != NULL) video_screenshot(x, y, w, h); screenshots--; video_log("screenshot taken, %i left\n", screenshots); @@ -520,17 +544,15 @@ video_blit_memtoscreen_8(int x, int y, int y1, int y2, int w, int h) { int yy, xx; - if (h <= 0) return; - - for (yy = 0; yy < h; yy++) - { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) - { - for (xx = 0; xx < w; xx++) { - if (buffer32->line[y + yy][x + xx] <= 0xff) - buffer32->line[y + yy][x + xx] = pal_lookup[buffer32->line[y + yy][x + xx]]; - else - buffer32->line[y + yy][x + xx] = 0x00000000; + if ((w > 0) && (h > 0)) { + for (yy = 0; yy < h; yy++) { + if ((y + yy) >= 0 && (y + yy) < buffer32->h) { + for (xx = 0; xx < w; xx++) { + if (buffer32->line[y + yy][x + xx] <= 0xff) + buffer32->line[y + yy][x + xx] = pal_lookup[buffer32->line[y + yy][x + xx]]; + else + buffer32->line[y + yy][x + xx] = 0x00000000; + } } } } @@ -555,7 +577,7 @@ cgapal_rebuild(void) if ((cga_palette > 1) && (cga_palette < 8)) { if (vid_cga_contrast != 0) { - for (c=0; c<16; c++) { + for (c = 0; c < 16; c++) { pal_lookup[c] = makecol(video_6to8[cgapal_mono[cga_palette - 2][c].r], video_6to8[cgapal_mono[cga_palette - 2][c].g], video_6to8[cgapal_mono[cga_palette - 2][c].b]); @@ -570,7 +592,7 @@ cgapal_rebuild(void) video_6to8[cgapal_mono[cga_palette - 2][c].b]); } } else { - for (c=0; c<16; c++) { + for (c = 0; c < 16; c++) { pal_lookup[c] = makecol(video_6to8[cgapal_mono[cga_palette - 1][c].r], video_6to8[cgapal_mono[cga_palette - 1][c].g], video_6to8[cgapal_mono[cga_palette - 1][c].b]); @@ -788,8 +810,8 @@ video_init(void) } /* Account for overscan. */ - // buffer32 = create_bitmap(2048 + 64, 2048 + 64); - buffer32 = create_bitmap(4096 + 64, 4096 + 64); + buffer32 = create_bitmap(2048 + 64, 2048 + 64); + render_buffer = create_bitmap(2048 + 64, 2048 + 64); for (c = 0; c < 64; c++) { cgapal[c + 64].r = (((c & 4) ? 2 : 0) | ((c & 0x10) ? 1 : 0)) * 21; @@ -855,6 +877,7 @@ video_close(void) free(video_8togs); free(video_6to8); + destroy_bitmap(render_buffer); destroy_bitmap(buffer32); if (fontdatksc5601) { @@ -1039,15 +1062,3 @@ video_color_transform(uint32_t color) color ^= 0x00ffffff; return color; } - -void -video_transform_copy(uint32_t *dst, uint32_t *src, int len) -{ - int i; - - for (i = 0; i < len; i++) { - *dst = video_color_transform(*src); - dst++; - src++; - } -} diff --git a/src/video/video.h b/src/video/video.h index e633c603b..427b0e5c9 100644 --- a/src/video/video.h +++ b/src/video/video.h @@ -8,15 +8,15 @@ * * Definitions for the video controller module. * - * Version: @(#)video.h 1.0.36 2018/10/28 + * Version: @(#)video.h 1.0.37 2019/12/06 * * Authors: Sarah Walker, * Miran Grca, * Fred N. van Kempen, * - * Copyright 2008-2018 Sarah Walker. - * Copyright 2016-2018 Miran Grca. - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2008-2019 Sarah Walker. + * Copyright 2016-2019 Miran Grca. + * Copyright 2017-2019 Fred N. van Kempen. */ #ifndef EMU_VIDEO_H # define EMU_VIDEO_H @@ -84,7 +84,7 @@ extern int egareads, extern int changeframecount; extern volatile int screenshots; -extern bitmap_t *buffer32; +extern bitmap_t *buffer32, *render_buffer; extern PALETTE cgapal, cgapal_mono[6]; extern uint32_t pal_lookup[256]; @@ -184,7 +184,6 @@ extern void svga_dump_vram(void); #endif extern uint32_t video_color_transform(uint32_t color); -extern void video_transform_copy(uint32_t *dst, uint32_t *src, int len); #ifdef __cplusplus } diff --git a/src/vnc.c b/src/vnc.c index 4f895cc60..7b6040c4b 100644 --- a/src/vnc.c +++ b/src/vnc.c @@ -8,12 +8,12 @@ * * Implement the VNC remote renderer with LibVNCServer. * - * Version: @(#)vnc.c 1.0.14 2018/10/17 + * Version: @(#)vnc.c 1.0.15 2019/12/06 * * Authors: Fred N. van Kempen, * Based on raw code by RichardG, * - * Copyright 2017,2018 Fred N. van Kempen. + * Copyright 2017-2019 Fred N. van Kempen. */ #include #include @@ -175,12 +175,8 @@ vnc_blit(int x, int y, int y1, int y2, int w, int h) for (yy=y1; yyframeBuffer)[yy*VNC_MAX_X]); - if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y) { - if (video_grayscale || invert_display) - video_transform_copy(p, &(buffer32->line[y+yy][x]), w); - else - memcpy(p, &(buffer32->line[y+yy][x]), w*4); - } + if ((y+yy) >= 0 && (y+yy) < VNC_MAX_Y) + memcpy(p, &(render_buffer->line[y+yy][x]), w*4); } video_blit_complete(); diff --git a/src/win/win_d2d.cpp b/src/win/win_d2d.cpp index 655cf0591..814cc0226 100644 --- a/src/win/win_d2d.cpp +++ b/src/win/win_d2d.cpp @@ -8,7 +8,7 @@ * * Rendering module for Microsoft Direct2D. * - * Version: @(#)win_d2d.cpp 1.0.4 2019/10/12 + * Version: @(#)win_d2d.cpp 1.0.5 2019/12/06 * * Authors: David Hrdlička, * @@ -221,29 +221,23 @@ d2d_blit(int x, int y, int y1, int y2, int w, int h) return; } - if (buffer32 == NULL) { + if (render_buffer == NULL) { video_blit_complete(); return; } - // TODO: Copy data directly from buffer32 to d2d_bitmap + // TODO: Copy data directly from render_buffer to d2d_bitmap srcdata = malloc(h * w * 4); for (yy = y1; yy < y2; yy++) { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) + if ((y + yy) >= 0 && (y + yy) < render_buffer->h) { - if (video_grayscale || invert_display) - video_transform_copy( - (uint32_t *) &(((uint8_t *)srcdata)[yy * w * 4]), - &(buffer32->line[y + yy][x]), - w); - else - memcpy( - (uint32_t *) &(((uint8_t *)srcdata)[yy * w * 4]), - &(buffer32->line[y + yy][x]), - w * 4); + memcpy( + (uint32_t *) &(((uint8_t *)srcdata)[yy * w * 4]), + &(render_buffer->line[y + yy][x]), + w * 4); } } diff --git a/src/win/win_d3d.cpp b/src/win/win_d3d.cpp deleted file mode 100644 index cb5942ab7..000000000 --- a/src/win/win_d3d.cpp +++ /dev/null @@ -1,573 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Rendering module for Microsoft Direct3D 9. - * - * Version: @(#)win_d3d.cpp 1.0.14 2019/11/01 - * - * Authors: Sarah Walker, - * Miran Grca, - * Fred N. van Kempen, - * - * Copyright 2008-2019 Sarah Walker. - * Copyright 2016-2019 Miran Grca. - * Copyright 2017-2019 Fred N. van Kempen. - */ -#include -#include -#include -#include "../86box.h" -#include "../device.h" -#include "../video/video.h" -#include "../plat.h" -#include "win.h" -#include "win_d3d.h" - - -struct CUSTOMVERTEX { - FLOAT x, y, z, rhw; // from the D3DFVF_XYZRHW flag - DWORD color; - FLOAT tu, tv; -}; - - -static LPDIRECT3D9 d3d = NULL; -static LPDIRECT3DDEVICE9 d3ddev = NULL; -static LPDIRECT3DVERTEXBUFFER9 v_buffer = NULL; -static LPDIRECT3DTEXTURE9 d3dTexture = NULL; -static D3DPRESENT_PARAMETERS d3dpp; -static HWND d3d_hwnd; -static HWND d3d_device_window; -static int d3d_w, d3d_h; -static int d3d_fs; -static volatile int d3d_enabled = 0; - -static CUSTOMVERTEX d3d_verts[] = { - { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, - {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, - { 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f}, - - { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, - {2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f}, - {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, - - { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, - {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f}, - { 0.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 1.0f}, - - { 0.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 0.0f, 0.0f}, - {2048.0f, 0.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 0.0f}, - {2048.0f, 2048.0f, 1.0f, 1.0f, 0xffffff, 1.0f, 1.0f} -}; - - -static void -d3d_size_default(RECT w_rect, double *l, double *t, double *r, double *b) -{ - *l = -0.5; - *t = -0.5; - *r = (w_rect.right - w_rect.left) - 0.5; - *b = (w_rect.bottom - w_rect.top) - 0.5; -} - - -static void -d3d_size(RECT w_rect, double *l, double *t, double *r, double *b, int w, int h) -{ - int ratio_w, ratio_h; - double hsr, gsr, d, sh, sw, wh, ww, mh, mw; - - sh = (double) (w_rect.bottom - w_rect.top); - sw = (double) (w_rect.right - w_rect.left); - wh = (double) h; - ww = (double) w; - - switch (video_fullscreen_scale) { - case FULLSCR_SCALE_FULL: - d3d_size_default(w_rect, l, t, r, b); - break; - - case FULLSCR_SCALE_43: - case FULLSCR_SCALE_KEEPRATIO: - if (video_fullscreen_scale == FULLSCR_SCALE_43) { - mw = 4.0; - mh = 3.0; - } else { - mw = ww; - mh = wh; - } - - hsr = sw / sh; - gsr = mw / mh; - - if (hsr > gsr) { - /* Host ratio is bigger than guest ratio. */ - d = (sw - (mw * (sh / mh))) / 2.0; - - *l = ((int) d) - 0.5; - *r = ((int) (sw - d)) - 0.5; - *t = -0.5; - *b = ((int) sh) - 0.5; - } else if (hsr < gsr) { - /* Host ratio is smaller or rqual than guest ratio. */ - d = (sh - (mh * (sw / mw))) / 2.0; - - *l = -0.5; - *r = ((int) sw) - 0.5; - *t = ((int) d) - 0.5; - *b = ((int) (sh - d)) - 0.5; - } else { - /* Host ratio is equal to guest ratio. */ - d3d_size_default(w_rect, l, t, r, b); - } - break; - - case FULLSCR_SCALE_INT: - ratio_w = (w_rect.right - w_rect.left) / w; - ratio_h = (w_rect.bottom - w_rect.top) / h; - if (ratio_h < ratio_w) - ratio_w = ratio_h; - *l = ((w_rect.right - w_rect.left) / 2) - ((w * ratio_w) / 2) - 0.5; - *r = ((w_rect.right - w_rect.left) / 2) + ((w * ratio_w) / 2) - 0.5; - *t = ((w_rect.bottom - w_rect.top) / 2) - ((h * ratio_w) / 2) - 0.5; - *b = ((w_rect.bottom - w_rect.top) / 2) + ((h * ratio_w) / 2) - 0.5; - break; - - } -} - - -static void -d3d_blit(int x, int y, int y1, int y2, int w, int h) -{ - HRESULT hr = D3D_OK; - HRESULT hbsr = D3D_OK; - VOID* pVoid; - D3DLOCKED_RECT dr; - RECT r; - int yy; - double l = 0, t = 0, rr = 0, b = 0; /* FS_ONLY */ - - if (!d3d_enabled) { - video_blit_complete(); - return; - } - - if ((y1 == y2) || (h <= 0)) { - video_blit_complete(); - return; /*Nothing to do*/ - } - - r.top = y1; - r.left = 0; - r.bottom = y2; - r.right = 2047; - - hr = d3dTexture->LockRect(0, &dr, &r, 0); - if (hr == D3D_OK) { - for (yy = y1; yy < y2; yy++) { - if (buffer32) { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) { - if (video_grayscale || invert_display) - video_transform_copy((uint32_t *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(buffer32->line[yy + y][x]), w); - else - memcpy((void *)((uintptr_t)dr.pBits + ((yy - y1) * dr.Pitch)), &(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; - d3d_verts[1].tu = d3d_verts[4].tu = d3d_verts[5].tu = (float)w / 2048.0; - d3d_verts[1].tv = d3d_verts[2].tv = d3d_verts[5].tv = (float)h / 2048.0; - d3d_verts[0].color = d3d_verts[1].color = d3d_verts[2].color = - d3d_verts[3].color = d3d_verts[4].color = d3d_verts[5].color = - d3d_verts[6].color = d3d_verts[7].color = d3d_verts[8].color = - d3d_verts[9].color = d3d_verts[10].color = d3d_verts[11].color = 0xffffff; - - if (d3d_fs) { - GetClientRect(d3d_device_window, &r); - d3d_size(r, &l, &t, &rr, &b, w, h); - d3d_verts[0].x = d3d_verts[2].x = d3d_verts[3].x = l; - d3d_verts[0].y = d3d_verts[3].y = d3d_verts[4].y = t; - d3d_verts[1].x = d3d_verts[4].x = d3d_verts[5].x = rr; - d3d_verts[1].y = d3d_verts[2].y = d3d_verts[5].y = b; - d3d_verts[6].x = d3d_verts[8].x = d3d_verts[9].x = rr - 40.5; - d3d_verts[6].y = d3d_verts[9].y = d3d_verts[10].y = t + 8.5; - d3d_verts[7].x = d3d_verts[10].x = d3d_verts[11].x = rr - 8.5; - d3d_verts[7].y = d3d_verts[8].y = d3d_verts[11].y = t + 14.5; - } else { - GetClientRect(d3d_hwnd, &r); - d3d_verts[0].x = d3d_verts[2].x = d3d_verts[3].x = -0.5; - d3d_verts[0].y = d3d_verts[3].y = d3d_verts[4].y = -0.5; - d3d_verts[1].x = d3d_verts[4].x = d3d_verts[5].x = (r.right-r.left)-0.5; - d3d_verts[1].y = d3d_verts[2].y = d3d_verts[5].y = (r.bottom-r.top)-0.5; - d3d_verts[6].x = d3d_verts[8].x = d3d_verts[9].x = (r.right-r.left)-40.5; - d3d_verts[6].y = d3d_verts[9].y = d3d_verts[10].y = 8.5; - d3d_verts[7].x = d3d_verts[10].x = d3d_verts[11].x = (r.right-r.left)-8.5; - d3d_verts[7].y = d3d_verts[8].y = d3d_verts[11].y = 14.5; - } - - if (hr == D3D_OK) - hr = v_buffer->Lock(0, 0, (void**)&pVoid, 0); // lock the vertex buffer - if (hr == D3D_OK) - memcpy(pVoid, d3d_verts, sizeof(d3d_verts)); // copy the vertices to the locked buffer - if (hr == D3D_OK) - hr = v_buffer->Unlock(); // unlock the vertex buffer - - if (hr == D3D_OK) - hbsr = hr = d3ddev->BeginScene(); - - if (hr == D3D_OK) { - if (hr == D3D_OK) - d3ddev->Clear(0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(0, 0, 0), 1.0, 0); - - if (hr == D3D_OK) - hr = d3ddev->SetTexture(0, d3dTexture); - - if (hr == D3D_OK) - hr = d3ddev->SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); - - if (hr == D3D_OK) - hr = d3ddev->SetStreamSource(0, v_buffer, 0, sizeof(CUSTOMVERTEX)); - - if (hr == D3D_OK) - hr = d3ddev->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2); - - if (hr == D3D_OK) - hr = d3ddev->SetTexture(0, NULL); - } - - if (hbsr == D3D_OK) - hr = d3ddev->EndScene(); - - if (hr == D3D_OK) - hr = d3ddev->Present(NULL, NULL, d3d_device_window, NULL); - - if (hr == D3DERR_DEVICELOST || hr == D3DERR_INVALIDCALL) - PostMessage(d3d_hwnd, WM_RESETD3D, 0, 0); -} - - -static void -d3d_init_objects(void) -{ - D3DLOCKED_RECT dr; - RECT r; - int y; - - if (FAILED(d3ddev->CreateVertexBuffer(12*sizeof(CUSTOMVERTEX), - 0, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, - D3DPOOL_MANAGED, - &v_buffer, - NULL))) - fatal("CreateVertexBuffer failed\n"); - - 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; - - if (FAILED(d3dTexture->LockRect(0, &dr, &r, 0))) - fatal("LockRect failed\n"); - - for (y = 0; y < 2048; y++) { - uint32_t *p = (uint32_t *)((uintptr_t)dr.pBits + (y * dr.Pitch)); - memset(p, 0, 2048 * 4); - } - - d3dTexture->UnlockRect(0); - - d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1); - d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE); - d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); -} - - -static int old_capture = 0; - - -int -d3d_init(HWND h) -{ - RECT rect; - - d3d_hwnd = h; - - d3d = Direct3DCreate9(D3D_SDK_VERSION); - - memset(&d3dpp, 0, sizeof(d3dpp)); - d3dpp.Flags = 0; - d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.hDeviceWindow = h; - d3dpp.BackBufferCount = 1; - d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp.MultiSampleQuality = 0; - d3dpp.EnableAutoDepthStencil = false; - d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN; - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - d3dpp.Windowed = true; - d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; - d3dpp.BackBufferWidth = 0; - d3dpp.BackBufferHeight = 0; - - if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, h, - D3DCREATE_SOFTWARE_VERTEXPROCESSING, - &d3dpp, &d3ddev))) - fatal("CreateDevice failed\n"); - - d3d_init_objects(); - - mouse_capture = old_capture; - - if (mouse_capture) { - GetWindowRect(hwndRender, &rect); - - ClipCursor(&rect); - } - - d3d_device_window = NULL; - - video_setblit(d3d_blit); - - d3d_fs = 0; - d3d_enabled = 1; - - return(1); -} - - -int -d3d_init_fs(HWND h) -{ - WCHAR title[200]; - RECT rect; - - d3d_w = GetSystemMetrics(SM_CXSCREEN); - d3d_h = GetSystemMetrics(SM_CYSCREEN); - - d3d_hwnd = h; - - /*FIXME: should be done once, in win.c */ - _swprintf(title, L"%s v%s", EMU_NAME_W, EMU_VERSION_W); - d3d_device_window = CreateWindowEx ( - 0, - SUB_CLASS_NAME, - title, - WS_POPUP, - CW_USEDEFAULT, - CW_USEDEFAULT, - 640, - 480, - HWND_DESKTOP, - NULL, - NULL, - NULL - ); - - d3d = Direct3DCreate9(D3D_SDK_VERSION); - - memset(&d3dpp, 0, sizeof(d3dpp)); - d3dpp.Flags = 0; - d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.hDeviceWindow = d3d_device_window; - d3dpp.BackBufferCount = 1; - d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp.MultiSampleQuality = 0; - d3dpp.EnableAutoDepthStencil = false; - d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN; - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - d3dpp.Windowed = false; - d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; - d3dpp.BackBufferWidth = d3d_w; - d3dpp.BackBufferHeight = d3d_h; - - if (FAILED(d3d->CreateDevice(D3DADAPTER_DEFAULT, - D3DDEVTYPE_HAL, h, - D3DCREATE_SOFTWARE_VERTEXPROCESSING, - &d3dpp, &d3ddev))) - fatal("CreateDevice failed\n"); - - d3d_init_objects(); - - /* Redirect RawInput to this new window. */ - plat_set_input(d3d_device_window); - - SetFocus(d3d_device_window); - - old_capture = mouse_capture; - - GetWindowRect(d3d_device_window, &rect); - - ClipCursor(&rect); - - mouse_capture = 1; - - video_setblit(d3d_blit); - - d3d_fs = 1; - d3d_enabled = 1; - - return(1); -} - - -static void -d3d_close_objects(void) -{ - if (d3dTexture) { - d3dTexture->Release(); - d3dTexture = NULL; - } - if (v_buffer) { - v_buffer->Release(); - v_buffer = NULL; - } -} - - -void -d3d_close(void) -{ - video_setblit(NULL); - - if (d3d_enabled) - d3d_enabled = 0; - - d3d_close_objects(); - - if (d3ddev) { - d3ddev->Release(); - d3ddev = NULL; - } - if (d3d) { - d3d->Release(); - d3d = NULL; - } - - if (d3d_device_window != NULL) { - plat_set_input(hwndMain); - - ShowWindow(hwndRender, TRUE); - - SetFocus(hwndMain); - - DestroyWindow(d3d_device_window); - d3d_device_window = NULL; - } -} - - -void -d3d_reset(void) -{ - HRESULT hr; - - if (! d3ddev) return; - - memset(&d3dpp, 0, sizeof(d3dpp)); - - d3dpp.Flags = 0; - d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.hDeviceWindow = d3d_hwnd; - d3dpp.BackBufferCount = 1; - d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp.MultiSampleQuality = 0; - d3dpp.EnableAutoDepthStencil = false; - d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN; - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - d3dpp.Windowed = true; - d3dpp.BackBufferFormat = D3DFMT_UNKNOWN; - d3dpp.BackBufferWidth = 0; - d3dpp.BackBufferHeight = 0; - - hr = d3ddev->Reset(&d3dpp); - - if (hr == D3DERR_DEVICELOST) return; - - d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1); - d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE); - d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); - - device_force_redraw(); -} - - -void -d3d_reset_fs(void) -{ - HRESULT hr; - - memset(&d3dpp, 0, sizeof(d3dpp)); - d3dpp.Flags = 0; - d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD; - d3dpp.hDeviceWindow = d3d_device_window; - d3dpp.BackBufferCount = 1; - d3dpp.MultiSampleType = D3DMULTISAMPLE_NONE; - d3dpp.MultiSampleQuality = 0; - d3dpp.EnableAutoDepthStencil = false; - d3dpp.AutoDepthStencilFormat = D3DFMT_UNKNOWN; - d3dpp.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; - d3dpp.Windowed = false; - d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8; - d3dpp.BackBufferWidth = d3d_w; - d3dpp.BackBufferHeight = d3d_h; - - hr = d3ddev->Reset(&d3dpp); - if (hr == D3DERR_DEVICELOST) return; - - d3ddev->SetTextureStageState(0,D3DTSS_COLOROP, D3DTOP_SELECTARG1); - d3ddev->SetTextureStageState(0,D3DTSS_COLORARG1, D3DTA_TEXTURE); - d3ddev->SetTextureStageState(0,D3DTSS_ALPHAOP, D3DTOP_DISABLE); - - d3ddev->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); - d3ddev->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR); - - device_force_redraw(); -} - - -void -d3d_resize(int x, int y) -{ - d3dpp.BackBufferWidth = x; - d3dpp.BackBufferHeight = y; - - d3d_reset(); -} - - -int -d3d_pause(void) -{ - return(0); -} - - -void -d3d_enable(int enable) -{ - d3d_enabled = enable; -} diff --git a/src/win/win_d3d.h b/src/win/win_d3d.h deleted file mode 100644 index d8f21dfc0..000000000 --- a/src/win/win_d3d.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Direct3D 9 rendererer and screenshots taking. - * - * Version: @(#)win_d3d.h 1.0.4 2019/10/12 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2019 Sarah Walker. - * Copyright 2016-2019 Miran Grca. - */ -#ifndef WIN_D3D_H -# define WIN_D3D_H -# define UNICODE -# define BITMAP WINDOWS_BITMAP -# include -# undef BITMAP - - -#ifdef __cplusplus -extern "C" { -#endif - -extern int d3d_init(HWND h); -extern int d3d_init_fs(HWND h); -extern void d3d_close(void); -extern void d3d_reset(void); -extern void d3d_reset_fs(void); -extern int d3d_pause(void); -extern void d3d_resize(int x, int y); -extern void d3d_enable(int enable); - -#ifdef __cplusplus -} -#endif - - -#endif /*WIN_D3D_H*/ diff --git a/src/win/win_ddraw.cpp b/src/win/win_ddraw.cpp deleted file mode 100644 index f7f97ff35..000000000 --- a/src/win/win_ddraw.cpp +++ /dev/null @@ -1,429 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Rendering module for Microsoft DirectDraw 9. - * - * NOTES: This code should be re-merged into a single init() with a - * 'fullscreen' argument, indicating FS mode is requested. - * - * Version: @(#)win_ddraw.cpp 1.0.16 2019/11/01 - * - * Authors: Sarah Walker, - * Miran Grca, - * Fred N. van Kempen, - * - * Copyright 2008-2019 Sarah Walker. - * Copyright 2016-2019 Miran Grca. - * Copyright 2017-2019 Fred N. van Kempen. - */ -#include -#include -#include -#define UNICODE -#define BITMAP WINDOWS_BITMAP -#include -#undef BITMAP - -#define HAVE_STDARG_H -#include "../86box.h" -#include "../device.h" -#include "../video/video.h" -#include "../plat.h" -#include "../ui.h" -#include "win_ddraw.h" -#include "win.h" - - -static LPDIRECTDRAW lpdd = NULL; -static LPDIRECTDRAW4 lpdd4 = NULL; -static LPDIRECTDRAWSURFACE4 lpdds_pri = NULL, - lpdds_back = NULL, - lpdds_back2 = NULL; -static LPDIRECTDRAWCLIPPER lpdd_clipper = NULL; -static DDSURFACEDESC2 ddsd; -static HWND ddraw_hwnd; -static int ddraw_w, ddraw_h; -static int ddraw_fs; -static volatile int ddraw_enabled = 0; - - -#ifdef ENABLE_DDRAW_LOG -int ddraw_do_log = ENABLE_DDRAW_LOG; - - -static void -ddraw_log(const char *fmt, ...) -{ - va_list ap; - - if (ddraw_do_log) { - va_start(ap, fmt); - pclog_ex(fmt, ap); - va_end(ap); - } -} -#else -#define ddraw_log(fmt, ...) -#endif - - -static void -ddraw_fs_size_default(RECT w_rect, RECT *r_dest) -{ - r_dest->left = 0; - r_dest->top = 0; - r_dest->right = (w_rect.right - w_rect.left) - 1; - r_dest->bottom = (w_rect.bottom - w_rect.top) - 1; -} - - -static void -ddraw_fs_size(RECT w_rect, RECT *r_dest, int w, int h) -{ - int ratio_w, ratio_h; - double hsr, gsr, d, sh, sw, wh, ww, mh, mw; - - ddraw_log("video_fullscreen_scale = %i\n", video_fullscreen_scale); - - sh = (double) (w_rect.bottom - w_rect.top); - sw = (double) (w_rect.right - w_rect.left); - wh = (double) h; - ww = (double) w; - - switch (video_fullscreen_scale) { - case FULLSCR_SCALE_FULL: - ddraw_fs_size_default(w_rect, r_dest); - break; - - case FULLSCR_SCALE_43: - case FULLSCR_SCALE_KEEPRATIO: - if (video_fullscreen_scale == FULLSCR_SCALE_43) { - mw = 4.0; - mh = 3.0; - } else { - mw = ww; - mh = wh; - } - - hsr = sw / sh; - gsr = mw / mh; - - if (hsr > gsr) { - /* Host ratio is bigger than guest ratio. */ - d = (sw - (mw * (sh / mh))) / 2.0; - - r_dest->left = (int) d; - r_dest->right = (int) (sw - d - 1.0); - r_dest->top = 0; - r_dest->bottom = (int) (sh - 1.0); - } else if (hsr < gsr) { - /* Host ratio is smaller or rqual than guest ratio. */ - d = (sh - (mh * (sw / mw))) / 2.0; - - r_dest->left = 0; - r_dest->right = (int) (sw - 1.0); - r_dest->top = (int) d; - r_dest->bottom = (int) (sh - d - 1.0); - } else { - /* Host ratio is equal to guest ratio. */ - ddraw_fs_size_default(w_rect, r_dest); - } - break; - - case FULLSCR_SCALE_INT: - ratio_w = (w_rect.right - w_rect.left) / w; - ratio_h = (w_rect.bottom - w_rect.top) / h; - if (ratio_h < ratio_w) - ratio_w = ratio_h; - r_dest->left = ((w_rect.right - w_rect.left) / 2) - ((w * ratio_w) / 2); - r_dest->right = ((w_rect.right - w_rect.left) / 2) + ((w * ratio_w) / 2) - 1; - r_dest->top = ((w_rect.bottom - w_rect.top) / 2) - ((h * ratio_w) / 2); - r_dest->bottom = ((w_rect.bottom - w_rect.top) / 2) + ((h * ratio_w) / 2) - 1; - break; - } -} - - -static void -ddraw_blit(int x, int y, int y1, int y2, int w, int h) -{ - RECT r_src; - RECT r_dest; - POINT po; - RECT w_rect; - int yy; - HRESULT hr; - DDBLTFX ddbltfx; - RECT *r_tgt = ddraw_fs ? &r_dest : &r_src; - - if (!ddraw_enabled) { - video_blit_complete(); - return; - } - - if (lpdds_back == NULL) { - video_blit_complete(); - return; /*Nothing to do*/ - } - - if ((y1 == y2) || (h <= 0)) { - video_blit_complete(); - return; - } - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - - hr = lpdds_back->Lock(NULL, &ddsd, - DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); - if (hr == DDERR_SURFACELOST) { - lpdds_back->Restore(); - lpdds_back->Lock(NULL, &ddsd, - DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL); - device_force_redraw(); - } - - if (! ddsd.lpSurface) { - video_blit_complete(); - return; - } - - for (yy = y1; yy < y2; yy++) { - if (buffer32) { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) { - if (video_grayscale || invert_display) - video_transform_copy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(buffer32->line[y + yy][x]), w); - else - memcpy((uint32_t *) &(((uint8_t *) ddsd.lpSurface)[yy * ddsd.lPitch]), &(buffer32->line[y + yy][x]), w * 4); - } - } - } - - video_blit_complete(); - lpdds_back->Unlock(NULL); - - if (ddraw_fs) { - w_rect.left = 0; - w_rect.top = 0; - w_rect.right = ddraw_w; - w_rect.bottom = ddraw_h; - ddraw_fs_size(w_rect, &r_dest, w, h); - } else { - po.x = po.y = 0; - - ClientToScreen(ddraw_hwnd, &po); - GetClientRect(ddraw_hwnd, &r_dest); - OffsetRect(&r_dest, po.x, po.y); - } - - r_src.left = 0; - r_src.top = 0; - r_src.right = w; - r_src.bottom = h; - - if (ddraw_fs) { - ddbltfx.dwSize = sizeof(ddbltfx); - ddbltfx.dwFillColor = 0; - - lpdds_back2->Blt(&w_rect, NULL, NULL, - DDBLT_WAIT | DDBLT_COLORFILL, &ddbltfx); - } - - hr = lpdds_back2->Blt(r_tgt, lpdds_back, &r_src, DDBLT_WAIT, NULL); - if (hr == DDERR_SURFACELOST) { - lpdds_back2->Restore(); - lpdds_back2->Blt(r_tgt, lpdds_back, &r_src, DDBLT_WAIT, NULL); - } - - if (ddraw_fs) - hr = lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC); - else { - lpdds_back2->Unlock(NULL); - - hr = lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL); - } - - if (hr == DDERR_SURFACELOST) { - lpdds_pri->Restore(); - if (ddraw_fs) - lpdds_pri->Flip(NULL, DDFLIP_NOVSYNC); - else - lpdds_pri->Blt(&r_dest, lpdds_back2, &r_src, DDBLT_WAIT, NULL); - } -} - - -int -ddraw_init(HWND h) -{ - if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL))) return(0); - - if (FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4))) - return(0); - - lpdd->Release(); - lpdd = NULL; - - atexit(ddraw_close); - - if (FAILED(lpdd4->SetCooperativeLevel(h, DDSCL_NORMAL))) return(0); - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - - ddsd.dwFlags = DDSD_CAPS; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_pri, NULL))) return(0); - - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - ddsd.dwWidth = 2048; - ddsd.dwHeight = 2048; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; - if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL))) { - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - ddsd.dwWidth = 2048; - ddsd.dwHeight = 2048; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; - if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL))) - fatal("CreateSurface back failed\n"); - } - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - ddsd.dwWidth = 2048; - ddsd.dwHeight = 2048; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; - if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back2, NULL))) { - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - ddsd.dwWidth = 2048; - ddsd.dwHeight = 2048; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; - if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back2, NULL))) - fatal("CreateSurface back failed\n"); - } - - if (FAILED(lpdd4->CreateClipper(0, &lpdd_clipper, NULL))) return(0); - - if (FAILED(lpdd_clipper->SetHWnd(0, h))) return(0); - - if (FAILED(lpdds_pri->SetClipper(lpdd_clipper))) return(0); - - ddraw_hwnd = h; - - video_setblit(ddraw_blit); - - ddraw_fs = 0; - ddraw_enabled = 1; - - return(1); -} - - -int -ddraw_init_fs(HWND h) -{ - ddraw_w = GetSystemMetrics(SM_CXSCREEN); - ddraw_h = GetSystemMetrics(SM_CYSCREEN); - - if (FAILED(DirectDrawCreate(NULL, &lpdd, NULL))) return 0; - - if (FAILED(lpdd->QueryInterface(IID_IDirectDraw4, (LPVOID *)&lpdd4))) return 0; - - lpdd->Release(); - lpdd = NULL; - - atexit(ddraw_close); - - if (FAILED(lpdd4->SetCooperativeLevel(h, - DDSCL_SETFOCUSWINDOW | \ - DDSCL_CREATEDEVICEWINDOW | \ - DDSCL_EXCLUSIVE | \ - DDSCL_FULLSCREEN | \ - DDSCL_ALLOWREBOOT))) return 0; - - if (FAILED(lpdd4->SetDisplayMode(ddraw_w, ddraw_h, 32, 0 ,0))) return 0; - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT; - ddsd.dwBackBufferCount = 1; - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE | DDSCAPS_COMPLEX | DDSCAPS_FLIP; - if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_pri, NULL))) return 0; - - ddsd.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER; - if (FAILED(lpdds_pri->GetAttachedSurface(&ddsd.ddsCaps, &lpdds_back2))) return 0; - - memset(&ddsd, 0, sizeof(ddsd)); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - ddsd.dwWidth = 2048; - ddsd.dwHeight = 2048; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_VIDEOMEMORY; - if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL))) { - ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT; - ddsd.dwWidth = 2048; - ddsd.dwHeight = 2048; - ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN | DDSCAPS_SYSTEMMEMORY; - if (FAILED(lpdd4->CreateSurface(&ddsd, &lpdds_back, NULL))) return 0; - } - - ddraw_hwnd = h; - - video_setblit(ddraw_blit); - - ddraw_fs = 1; - ddraw_enabled = 1; - - return(1); -} - - -void -ddraw_close(void) -{ - video_setblit(NULL); - - if (ddraw_enabled) - ddraw_enabled = 0; - - if (lpdds_back2) { - lpdds_back2->Release(); - lpdds_back2 = NULL; - } - if (lpdds_back) { - lpdds_back->Release(); - lpdds_back = NULL; - } - if (lpdds_pri) { - lpdds_pri->Release(); - lpdds_pri = NULL; - } - if (lpdd_clipper) { - lpdd_clipper->Release(); - lpdd_clipper = NULL; - } - if (lpdd4) { - lpdd4->Release(); - lpdd4 = NULL; - } -} - - -int -ddraw_pause(void) -{ - return(0); -} - - -void -ddraw_enable(int enable) -{ - ddraw_enabled = enable; -} diff --git a/src/win/win_ddraw.h b/src/win/win_ddraw.h deleted file mode 100644 index 5e8696d47..000000000 --- a/src/win/win_ddraw.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 86Box A hypervisor and IBM PC system emulator that specializes in - * running old operating systems and software designed for IBM - * PC systems and compatibles from 1981 through fairly recent - * system designs based on the PCI bus. - * - * This file is part of the 86Box distribution. - * - * Definitions for the DirectDraw 9 rendering module. - * - * Version: @(#)win_ddraw.h 1.0.2 2019/10/12 - * - * Authors: Sarah Walker, - * Miran Grca, - * - * Copyright 2008-2019 Sarah Walker. - * Copyright 2016-2019 Miran Grca. - */ -#ifndef WIN_DDRAW_H -# define WIN_DDRAW_H -# define UNICODE -# define BITMAP WINDOWS_BITMAP -# include -# undef BITMAP - - -#ifdef __cplusplus -extern "C" { -#endif - -extern int ddraw_init(HWND h); -extern int ddraw_init_fs(HWND h); -extern void ddraw_close(void); -extern int ddraw_pause(void); -extern void ddraw_enable(int enable); - -#ifdef __cplusplus -} -#endif - - -#endif /*WIN_DDRAW_H*/ diff --git a/src/win/win_sdl.c b/src/win/win_sdl.c index c8147cdc7..762f4c5db 100644 --- a/src/win/win_sdl.c +++ b/src/win/win_sdl.c @@ -12,7 +12,7 @@ * we will not use that, but, instead, use a new window which * coverrs the entire desktop. * - * Version: @(#)win_sdl.c 1.0.9 2019/12/05 + * Version: @(#)win_sdl.c 1.0.10 2019/12/06 * * Authors: Fred N. van Kempen, * Michael Dring, @@ -187,7 +187,7 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h) return; } - if (buffer32 == NULL) { + if (render_buffer == NULL) { video_blit_complete(); return; } @@ -202,12 +202,8 @@ sdl_blit(int x, int y, int y1, int y2, int w, int h) SDL_LockTexture(sdl_tex, 0, &pixeldata, &pitch); for (yy = y1; yy < y2; yy++) { - if ((y + yy) >= 0 && (y + yy) < buffer32->h) { - if (video_grayscale || invert_display) - video_transform_copy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(buffer32->line[y + yy][x]), w); - else - memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(buffer32->line[y + yy][x]), w * 4); - } + if ((y + yy) >= 0 && (y + yy) < render_buffer->h) + memcpy((uint32_t *) &(((uint8_t *)pixeldata)[yy * pitch]), &(render_buffer->line[y + yy][x]), w * 4); } video_blit_complete(); @@ -290,6 +286,23 @@ sdl_close(void) static int old_capture = 0; +static void +sdl_select_best_hw_driver(void) +{ + int i; + SDL_RendererInfo renderInfo; + + for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) + { + SDL_GetRenderDriverInfo(i, &renderInfo); + if (renderInfo.flags & SDL_RENDERER_ACCELERATED) { + SDL_SetHint(SDL_HINT_RENDER_DRIVER, renderInfo.name); + return; + } + } +} + + static int sdl_init_common(int flags) { @@ -311,8 +324,7 @@ sdl_init_common(int flags) } if (flags & RENDERER_HARDWARE) - SDL_SetHint(SDL_HINT_RENDER_DRIVER, "direct3d"); - /* TODO: why is this necessary to avoid black screen on Win7/8/10? */ + sdl_select_best_hw_driver(); if (flags & RENDERER_FULL_SCREEN) { /* Get the size of the (current) desktop. */ diff --git a/src/win/win_stbar.c b/src/win/win_stbar.c index 398ee5020..ede2cb271 100644 --- a/src/win/win_stbar.c +++ b/src/win/win_stbar.c @@ -8,7 +8,7 @@ * * Implement the application's Status Bar. * - * Version: @(#)win_stbar.c 1.0.26 2019/09/26 + * Version: @(#)win_stbar.c 1.0.27 2019/12/06 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -37,6 +37,7 @@ #include "../disk/hdd.h" #include "../disk/hdc.h" #include "../floppy/fdd.h" +#include "../floppy/fdd_86f.h" #include "../scsi/scsi.h" #include "../scsi/scsi_device.h" #include "../cdrom/cdrom.h"