shithub: choc

Download patch

ref: f81c93613de934a49ba60637d5ad3eca142a69a4
parent: 7e528998a2c4dac76c004dc869d0a398188926fd
parent: 8edbbe8acfc2ac01a9e2d202692cf37eeee5c325
author: Mike Swanson <mikeonthecomputer@gmail.com>
date: Mon Feb 20 07:00:41 EST 2017

Merge remote-tracking branch 'jmtd/gh-832-vga-porch-emu' into sdl2-branch

--- a/src/i_video.c
+++ b/src/i_video.c
@@ -130,6 +130,10 @@
 
 int integer_scaling = false;
 
+// VGA Porch palette change emulation
+
+int vga_porch_flash = false;
+
 // Force software rendering, for systems which lack effective hardware
 // acceleration
 
@@ -745,6 +749,14 @@
     {
         SDL_SetPaletteColors(screenbuffer->format->palette, palette, 0, 256);
         palette_to_set = false;
+
+        if (vga_porch_flash)
+        {
+            // "flash" the pillars/letterboxes with palette changes, emulating
+            // VGA "porch" behaviour (GitHub issue #832)
+            SDL_SetRenderDrawColor(renderer, palette[0].r, palette[0].g,
+                palette[0].b, SDL_ALPHA_OPAQUE);
+        }
     }
 
     // Blit from the paletted 8-bit screen buffer to the intermediate
@@ -1400,6 +1412,7 @@
     M_BindIntVariable("video_display",             &video_display);
     M_BindIntVariable("aspect_ratio_correct",      &aspect_ratio_correct);
     M_BindIntVariable("integer_scaling",           &integer_scaling);
+    M_BindIntVariable("vga_porch_flash",           &vga_porch_flash);
     M_BindIntVariable("startup_delay",             &startup_delay);
     M_BindIntVariable("fullscreen_width",          &fullscreen_width);
     M_BindIntVariable("fullscreen_height",         &fullscreen_height);
--- a/src/i_video.h
+++ b/src/i_video.h
@@ -91,6 +91,7 @@
 extern int fullscreen;
 extern int aspect_ratio_correct;
 extern int integer_scaling;
+extern int vga_porch_flash;
 extern int force_software_renderer;
 
 #endif
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -733,6 +733,12 @@
 
     CONFIG_VARIABLE_INT(integer_scaling),
 
+    // If non-zero, any pillar/letter boxes drawn around the game area
+    // will "flash" when the game palette changes, simulating the VGA
+    // "porch"
+
+    CONFIG_VARIABLE_INT(vga_porch_flash),
+
     //!
     // Window width when running in windowed mode.
     //
--- a/src/setup/display.c
+++ b/src/setup/display.c
@@ -67,6 +67,7 @@
 static char *window_position = "";
 static int aspect_ratio_correct = 1;
 static int integer_scaling = 0;
+static int vga_porch_flash = 0;
 static int force_software_renderer = 0;
 static int fullscreen = 1;
 static int fullscreen_width = 0, fullscreen_height = 0;
@@ -209,6 +210,8 @@
         TXT_NewCheckBox("Save screenshots in PNG format",
                         &png_screenshots),
 #endif
+        TXT_NewCheckBox("Flash borders (VGA porch emulation)",
+                        &vga_porch_flash),
         NULL);
 
     TXT_SignalConnect(ar_checkbox, "changed", GenerateSizesTable, sizes_table);
@@ -265,6 +268,7 @@
     M_BindStringVariable("window_position",        &window_position);
     M_BindIntVariable("usegamma",                  &usegamma);
     M_BindIntVariable("png_screenshots",           &png_screenshots);
+    M_BindIntVariable("vga_porch_flash",           &vga_porch_flash);
     M_BindIntVariable("force_software_renderer",   &force_software_renderer);
     M_BindIntVariable("max_scaling_buffer_pixels", &max_scaling_buffer_pixels);