From 3c6552ba4dbf5c8777f38e81e6b9af14b4b07e08 Mon Sep 17 00:00:00 2001 From: driver1998 Date: Mon, 7 Sep 2020 10:07:07 +0800 Subject: [PATCH 1/6] msg_hash_chs: Don't translate MSG_PROGRAM, prevent a crash on startup --- intl/msg_hash_chs.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 9bd2da76c3..bb59d2aede 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -9750,10 +9750,6 @@ MSG_HASH( MSG_PAUSED, "暂停。" ) -MSG_HASH( - MSG_PROGRAM, - "全能模拟器" - ) MSG_HASH( MSG_READING_FIRST_DATA_TRACK, "读取第一条数据轨..." From a4dec6e226d3e37df54afd63bda7f8a4a019a4ef Mon Sep 17 00:00:00 2001 From: driver1998 Date: Mon, 7 Sep 2020 10:08:07 +0800 Subject: [PATCH 2/6] d3d9: "Fix" the HLSL render chain It won't get you very far, but at least it won't crash. Needs HAVE_HLSL and HAVE_D3DX defines and DirectX SDK --- gfx/drivers/d3d_shaders/opaque.hlsl.d3d9.h | 4 ++-- gfx/drivers_renderchain/d3d9_hlsl_renderchain.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/drivers/d3d_shaders/opaque.hlsl.d3d9.h b/gfx/drivers/d3d_shaders/opaque.hlsl.d3d9.h index 388751e10c..b3be6f4391 100644 --- a/gfx/drivers/d3d_shaders/opaque.hlsl.d3d9.h +++ b/gfx/drivers/d3d_shaders/opaque.hlsl.d3d9.h @@ -34,11 +34,11 @@ static const char *stock_hlsl_program = CG( float frame_rotation; }; - output main_fragment(float2 texCoord : TEXCOORD0, + output main_fragment(float4 color : COLOR, float2 texCoord : TEXCOORD0, uniform sampler2D decal : TEXUNIT0, uniform input IN) { output OUT; - OUT.color = tex2D(decal, texCoord); + OUT.color = color * tex2D(decal, texCoord); return OUT; } ); diff --git a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c index 68097e5f55..6240a67929 100644 --- a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c +++ b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c @@ -246,7 +246,7 @@ static bool hlsl_d3d9_renderchain_create_first_pass( unsigned _fmt) { unsigned i; - struct shader_pass pass; + struct shader_pass pass = { 0 }; unsigned fmt = (_fmt == RETRO_PIXEL_FORMAT_RGB565) ? d3d9_get_rgb565_format() : d3d9_get_xrgb8888_format(); From 693162f0803be63fcce4a95a8c42f20f50866e75 Mon Sep 17 00:00:00 2001 From: driver1998 Date: Mon, 7 Sep 2020 10:54:51 +0800 Subject: [PATCH 3/6] VS2019 solution: Use v142 toolchain for all targets --- pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj b/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj index 6a637ca55d..323f533d03 100644 --- a/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj +++ b/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj @@ -141,27 +141,27 @@ Application true NotSet - v141 + v142 Application true NotSet - v141 + v142 true Application true NotSet - v141 + v142 true Application true NotSet - v141 + v142 Application @@ -173,43 +173,43 @@ Application true NotSet - v141 + v142 Application true NotSet - v141 + v142 Application true NotSet - v141 + v142 Application true NotSet - v141 + v142 Application true NotSet - v141 + v142 Application true NotSet - v141 + v142 Application true NotSet - v141 + v142 Application @@ -227,27 +227,27 @@ Application true NotSet - v141 + v142 Application true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 true @@ -255,7 +255,7 @@ false true NotSet - v141 + v142 true @@ -263,63 +263,63 @@ false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application @@ -333,21 +333,21 @@ false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 Application false true NotSet - v141 + v142 @@ -1002,8 +1002,8 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_PATCH;HAVE_DSP_FILTER;HAVE_VIDEO_FILTER;HAVE_REWIND;HAVE_SCREENSHOTS;HAVE_CHEATS;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_RWAV;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_PATCH;HAVE_DSP_FILTER;HAVE_VIDEO_FILTER;HAVE_REWIND;HAVE_SCREENSHOTS;HAVE_CHEATS;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_RWAV;HAVE_STB_FONT;HAVE_HLSL;HAVE_D3DX + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;D:\minidx9\Include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp Fast @@ -2564,4 +2564,4 @@ - + \ No newline at end of file From fb00bf86021aba0264dbb7aa01e5accf0b6187a9 Mon Sep 17 00:00:00 2001 From: driver1998 Date: Mon, 7 Sep 2020 10:55:25 +0800 Subject: [PATCH 4/6] gdi: Fix crashing --- gfx/drivers/gdi_gfx.c | 46 +++++++++++++++++++++++-------------------- gfx/gfx_animation.c | 4 ++-- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index b2ecd17faf..f6b514ebde 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -301,7 +301,7 @@ static bool gdi_gfx_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - BITMAPINFO info; + BITMAPINFO* info = NULL; unsigned mode_width = 0; unsigned mode_height = 0; const void *frame_to_copy = frame; @@ -410,22 +410,25 @@ static bool gdi_gfx_frame(void *data, const void *frame, gdi->screen_width = mode_width; gdi->screen_height = mode_height; - info.bmiColors[0].rgbBlue = 0; - info.bmiColors[0].rgbGreen = 0; - info.bmiColors[0].rgbRed = 0; - info.bmiColors[0].rgbReserved = 0; + info = malloc(sizeof(BITMAPINFO) + 3 * sizeof(DWORD)); + if (!info) return false; - info.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - info.bmiHeader.biWidth = pitch / (bits / 8); - info.bmiHeader.biHeight = -height; - info.bmiHeader.biPlanes = 1; - info.bmiHeader.biBitCount = bits; - info.bmiHeader.biCompression = 0; - info.bmiHeader.biSizeImage = 0; - info.bmiHeader.biXPelsPerMeter= 0; - info.bmiHeader.biYPelsPerMeter= 0; - info.bmiHeader.biClrUsed = 0; - info.bmiHeader.biClrImportant = 0; + info->bmiColors[0].rgbBlue = 0; + info->bmiColors[0].rgbGreen = 0; + info->bmiColors[0].rgbRed = 0; + info->bmiColors[0].rgbReserved = 0; + + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biWidth = pitch / (bits / 8); + info->bmiHeader.biHeight = -height; + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = bits; + info->bmiHeader.biCompression = 0; + info->bmiHeader.biSizeImage = 0; + info->bmiHeader.biXPelsPerMeter= 0; + info->bmiHeader.biYPelsPerMeter= 0; + info->bmiHeader.biClrUsed = 0; + info->bmiHeader.biClrImportant = 0; if (bits == 16) { @@ -445,13 +448,13 @@ static bool gdi_gfx_frame(void *data, const void *frame, } frame_to_copy = gdi->temp_buf; - info.bmiHeader.biCompression = BI_RGB; + info->bmiHeader.biCompression = BI_RGB; } else { - unsigned *masks = (unsigned*)info.bmiColors; + DWORD* masks = (DWORD*)info->bmiColors; - info.bmiHeader.biCompression = BI_BITFIELDS; + info->bmiHeader.biCompression = BI_BITFIELDS; /* default 16-bit format on Windows is XRGB1555 */ if (frame_to_copy == gdi->menu_frame) @@ -471,12 +474,13 @@ static bool gdi_gfx_frame(void *data, const void *frame, } } else - info.bmiHeader.biCompression = BI_RGB; + info->bmiHeader.biCompression = BI_RGB; if (draw) StretchDIBits(gdi->memDC, 0, 0, width, height, 0, 0, width, height, - frame_to_copy, &info, DIB_RGB_COLORS, SRCCOPY); + frame_to_copy, info, DIB_RGB_COLORS, SRCCOPY); + free(info); SelectObject(gdi->memDC, gdi->bmp_old); if (msg) diff --git a/gfx/gfx_animation.c b/gfx/gfx_animation.c index 72836ba60b..64f026793a 100644 --- a/gfx/gfx_animation.c +++ b/gfx/gfx_animation.c @@ -2004,14 +2004,14 @@ bool gfx_animation_line_ticker_smooth(gfx_animation_ctx_line_ticker_smooth_t *li glyph_width = font_driver_get_message_width( line_ticker->font, "a", 1, line_ticker->font_scale); - if (glyph_width < 0) + if (glyph_width <= 0) goto end; /* > Height */ glyph_height = font_driver_get_line_height( line_ticker->font, line_ticker->font_scale); - if (glyph_height < 0) + if (glyph_height <= 0) goto end; /* Determine line wrap parameters */ From 8d82c7b08f9ccae958f7a9599bb1f3d294f99ed7 Mon Sep 17 00:00:00 2001 From: driver1998 Date: Mon, 7 Sep 2020 11:03:24 +0800 Subject: [PATCH 5/6] VS2019 solution: revert test changes --- pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj b/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj index 323f533d03..fd0a5b56cc 100644 --- a/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj +++ b/pkg/msvc/msvc-2019/RetroArch-msvc2019.vcxproj @@ -1002,8 +1002,8 @@ Level3 Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_PATCH;HAVE_DSP_FILTER;HAVE_VIDEO_FILTER;HAVE_REWIND;HAVE_SCREENSHOTS;HAVE_CHEATS;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_RWAV;HAVE_STB_FONT;HAVE_HLSL;HAVE_D3DX - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;D:\minidx9\Include;%(AdditionalIncludeDirectories) + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;WANT_GLSLANG;HAVE_SLANG;HAVE_GLSLANG;HAVE_BUILTINGLSLANG;HAVE_SPIRV_CROSS;HAVE_ONLINE_UPDATER;HAVE_UPDATE_ASSETS;HAVE_UPDATE_CORES;HAVE_D3D;HAVE_D3D9;HAVE_D3D10;HAVE_D3D11;HAVE_D3D12;HAVE_VULKAN;ENABLE_HLSL;RC_DISABLE_LUA;HAVE_WASAPI;HAVE_GLSL;HAVE_CHEEVOS;HAVE_RUNAHEAD;HAVE_TRANSLATE;HAVE_CDROM;HAVE_GRIFFIN;HAVE_GDI;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_OZONE;HAVE_SHADERPIPELINE;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_OPENGL_CORE;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_NETPLAYDISCOVERY;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_GFX_WIDGETS;HAVE_CONFIGFILE;HAVE_PATCH;HAVE_DSP_FILTER;HAVE_VIDEO_FILTER;HAVE_REWIND;HAVE_SCREENSHOTS;HAVE_CHEATS;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_AUDIOMIXER;HAVE_RWAV;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\rcheevos\include;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include\compat\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) MultiThreadedDebug CompileAsCpp Fast From 9cf71619d351123e5665ce43395123c5ca039601 Mon Sep 17 00:00:00 2001 From: driver1998 Date: Mon, 7 Sep 2020 12:36:43 +0800 Subject: [PATCH 6/6] GDI: use custom BITMAPINFO struct to avoid malloc --- gfx/drivers/gdi_gfx.c | 67 ++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 32 deletions(-) diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index f6b514ebde..6a1bfe6a1a 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -43,6 +43,15 @@ static HDC win32_gdi_hdc; static void *dinput_gdi; +struct bitmap_info { + BITMAPINFOHEADER header; + union { + RGBQUAD colors; + DWORD masks[3]; + } u; +}; + + static void gfx_ctx_gdi_update_title(void) { char title[128]; @@ -301,7 +310,7 @@ static bool gdi_gfx_frame(void *data, const void *frame, unsigned frame_width, unsigned frame_height, uint64_t frame_count, unsigned pitch, const char *msg, video_frame_info_t *video_info) { - BITMAPINFO* info = NULL; + struct bitmap_info info; unsigned mode_width = 0; unsigned mode_height = 0; const void *frame_to_copy = frame; @@ -410,25 +419,22 @@ static bool gdi_gfx_frame(void *data, const void *frame, gdi->screen_width = mode_width; gdi->screen_height = mode_height; - info = malloc(sizeof(BITMAPINFO) + 3 * sizeof(DWORD)); - if (!info) return false; + info.u.colors.rgbBlue = 0; + info.u.colors.rgbGreen = 0; + info.u.colors.rgbRed = 0; + info.u.colors.rgbReserved = 0; - info->bmiColors[0].rgbBlue = 0; - info->bmiColors[0].rgbGreen = 0; - info->bmiColors[0].rgbRed = 0; - info->bmiColors[0].rgbReserved = 0; - - info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - info->bmiHeader.biWidth = pitch / (bits / 8); - info->bmiHeader.biHeight = -height; - info->bmiHeader.biPlanes = 1; - info->bmiHeader.biBitCount = bits; - info->bmiHeader.biCompression = 0; - info->bmiHeader.biSizeImage = 0; - info->bmiHeader.biXPelsPerMeter= 0; - info->bmiHeader.biYPelsPerMeter= 0; - info->bmiHeader.biClrUsed = 0; - info->bmiHeader.biClrImportant = 0; + info.header.biSize = sizeof(BITMAPINFOHEADER); + info.header.biWidth = pitch / (bits / 8); + info.header.biHeight = -height; + info.header.biPlanes = 1; + info.header.biBitCount = bits; + info.header.biCompression = 0; + info.header.biSizeImage = 0; + info.header.biXPelsPerMeter= 0; + info.header.biYPelsPerMeter= 0; + info.header.biClrUsed = 0; + info.header.biClrImportant = 0; if (bits == 16) { @@ -448,39 +454,36 @@ static bool gdi_gfx_frame(void *data, const void *frame, } frame_to_copy = gdi->temp_buf; - info->bmiHeader.biCompression = BI_RGB; + info.header.biCompression = BI_RGB; } else { - DWORD* masks = (DWORD*)info->bmiColors; - - info->bmiHeader.biCompression = BI_BITFIELDS; + info.header.biCompression = BI_BITFIELDS; /* default 16-bit format on Windows is XRGB1555 */ if (frame_to_copy == gdi->menu_frame) { /* map RGB444 color bits for RGUI */ - masks[0] = 0xF000; - masks[1] = 0x0F00; - masks[2] = 0x00F0; + info.u.masks[0] = 0xF000; + info.u.masks[1] = 0x0F00; + info.u.masks[2] = 0x00F0; } else { /* map RGB565 color bits for core */ - masks[0] = 0xF800; - masks[1] = 0x07E0; - masks[2] = 0x001F; + info.u.masks[0] = 0xF800; + info.u.masks[1] = 0x07E0; + info.u.masks[2] = 0x001F; } } } else - info->bmiHeader.biCompression = BI_RGB; + info.header.biCompression = BI_RGB; if (draw) StretchDIBits(gdi->memDC, 0, 0, width, height, 0, 0, width, height, - frame_to_copy, info, DIB_RGB_COLORS, SRCCOPY); + frame_to_copy, (BITMAPINFO*)&info, DIB_RGB_COLORS, SRCCOPY); - free(info); SelectObject(gdi->memDC, gdi->bmp_old); if (msg)