Added VGA grayscale and choose screen type

VGA render can transform to grayscale and applying color.
Green, amber and white.
This commit is contained in:
basic2004
2017-07-17 23:04:50 +09:00
committed by GitHub
parent f8229f6cbd
commit ccea4a189a
6 changed files with 93 additions and 8 deletions

View File

@@ -17,6 +17,7 @@
*/
#include <stdio.h>
#include <math.h>
#include "../ibm.h"
#include "../mem.h"
#include "video.h"
@@ -25,21 +26,69 @@
int invert_display = 0;
int video_grayscale = 0;
uint32_t svga_color_transform(uint32_t color)
{
uint32_t temp = 0;
temp = color;
if (video_grayscale != 0)
{
temp = ((77 * (color & 0xff0000)) >> 24) + ((150 * (color & 0xff00)) >> 16) + ((29 * (color & 0xff)) >> 8);
if (temp > 0xff)
temp = 0xff;
float temp_r = 0;
float temp_g = 0;
float temp_b = 0;
temp_r = temp_g = temp_b = ((float)temp) / 256;
switch (video_grayscale)
{
case 2:
temp_r = pow(temp_r, 0.6);
temp_g = 0.9 * pow(temp_g, 2);
temp_b = 0.2 * pow(temp_b, 6);
break;
case 3:
temp_r = 0.225 * pow(temp_r, 4);
temp_g = pow(temp_g, 0.75);
temp_b = 0.375 * pow(temp_b, 2);
break;
case 4:
temp_r = pow(temp_r, 1.05);
temp_g = 0.99 * temp_g;
temp_b = 0.925 * pow(temp_b, 0.9);
break;
}
if (temp_r >= 1)
temp = 0xff0000;
else if (temp_r <= 0)
temp = 0x000000;
else
temp = (int)(temp_r * 256) << 16;
if (temp_g >= 1)
temp |= 0x00ff00;
else if (temp_g <= 0)
temp &= 0xff00ff;
else
temp = temp + ((int)(temp_g * 256) << 8);
if (temp_b >= 1)
temp |= 0x0000ff;
else if (temp_b <= 0)
temp &= 0xffff00;
else
temp = temp + (int)(temp_b * 256);
color = temp;
}
if (invert_display)
{
temp |= (0xff - (color & 0xff));
temp = (0xff - (color & 0xff));
temp |= (0xff00 - (color & 0xff00));
temp |= (0xff0000 - (color & 0xff0000));
}
else
{
temp = color;
}
return temp;
}

View File

@@ -46,7 +46,7 @@ BEGIN
BEGIN
MENUITEM "&Hard Reset", IDM_ACTION_HRESET
MENUITEM "&Ctrl+Alt+Del\tCtrl+F12", IDM_ACTION_RESET_CAD
MENUITEM "&Ctrl+Alt+Esc", IDM_ACTION_CTRL_ALT_ESC
MENUITEM "Ctrl+Alt+&Esc", IDM_ACTION_CTRL_ALT_ESC
MENUITEM SEPARATOR
MENUITEM "E&xit", IDM_ACTION_EXIT
END
@@ -81,6 +81,14 @@ BEGIN
BEGIN
MENUITEM "&Inverted VGA monitor", IDM_VID_INVERT
MENUITEM "E&GA/(S)VGA overscan", IDM_VID_OVERSCAN
POPUP "VGA Screen &type"
BEGIN
MENUITEM "RGB &Color", IDM_VID_GRAY_RGB
MENUITEM "&RGB Grayscale", IDM_VID_GRAY_MONO
MENUITEM "&Amber monitor", IDM_VID_GRAY_AMBER
MENUITEM "&Green monitor", IDM_VID_GRAY_GREEN
MENUITEM "&White monitor", IDM_VID_GRAY_WHITE
END
END
MENUITEM SEPARATOR
MENUITEM "F&orce 4:3 display ratio", IDM_VID_FORCE43

View File

@@ -410,6 +410,11 @@
#define IDM_VID_OVERSCAN 40076
#define IDM_VID_INVERT 40079
#define IDM_VID_CGACON 40080
#define IDM_VID_GRAY_RGB 40090
#define IDM_VID_GRAY_MONO 40091
#define IDM_VID_GRAY_AMBER 40092
#define IDM_VID_GRAY_GREEN 40093
#define IDM_VID_GRAY_WHITE 40094
#define IDM_LOG_BREAKPOINT 51201
#define IDM_DUMP_VRAM 51202 // should be an Action

View File

@@ -1532,6 +1532,7 @@ int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpsz
CheckMenuItem(menu, IDM_VID_SCALE_1X + scale, MF_CHECKED);
CheckMenuItem(menu, IDM_VID_CGACON, vid_cga_contrast ? MF_CHECKED : MF_UNCHECKED);
CheckMenuItem(menu, IDM_VID_GRAY_RGB + video_grayscale, MF_CHECKED);
d=romset;
for (c=0;c<ROM_MAX;c++)
@@ -1970,6 +1971,18 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
saveconfig();
break;
case IDM_VID_GRAY_RGB:
case IDM_VID_GRAY_MONO:
case IDM_VID_GRAY_AMBER:
case IDM_VID_GRAY_GREEN:
case IDM_VID_GRAY_WHITE:
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB + video_grayscale, MF_UNCHECKED);
video_grayscale = LOWORD(wParam) - IDM_VID_GRAY_RGB;
CheckMenuItem(hmenu, IDM_VID_GRAY_RGB + video_grayscale, MF_CHECKED);
saveconfig();
device_force_redraw();
break;
#ifdef ENABLE_LOG_TOGGLES
#ifdef ENABLE_BUSLOGIC_LOG
case IDM_LOG_BUSLOGIC:

View File

@@ -804,7 +804,7 @@ static void loadconfig_general(void)
}
enable_overscan = !!config_get_int(cat, "enable_overscan", 0);
vid_cga_contrast = !!config_get_int(cat, "vid_cga_contrast", 0);
video_grayscale = config_get_int(cat, "video_grayscale", 0);
window_remember = config_get_int(cat, "window_remember", 0);
@@ -1801,6 +1801,15 @@ static void saveconfig_general(void)
config_set_int(cat, "vid_cga_contrast", vid_cga_contrast);
}
if (video_grayscale == 0)
{
config_delete_var(cat, "video_grayscale");
}
else
{
config_set_int(cat, "video_grayscale", video_grayscale);
}
if (window_remember)
{

View File

@@ -737,6 +737,7 @@ extern int serial_enabled[2];
extern int lpt_enabled, bugger_enabled;
extern int invert_display;
extern int video_grayscale;
uint32_t svga_color_transform(uint32_t color);