Add high-resolution blending option to GTK+ port.

This commit is contained in:
Brandon Wright 2011-01-23 16:25:46 -06:00
parent d5aae6da63
commit 288a629311
7 changed files with 239 additions and 166 deletions

View File

@ -135,7 +135,7 @@ Snes9xConfig::load_defaults (void)
allow_xv = 0;
allow_xrandr = 0;
force_inverted_byte_order = FALSE;
force_hires = 0;
hires_effect = HIRES_MERGE;
pause_emulation_on_switch = 0;
num_threads = 2;
mute_sound = FALSE;
@ -283,7 +283,7 @@ Snes9xConfig::save_config_file (void)
xml_out_int (xml, "aspect_ratio", aspect_ratio);
xml_out_int (xml, "scale_method", scale_method);
xml_out_int (xml, "overscan", overscan);
xml_out_int (xml, "force_hires", force_hires);
xml_out_int (xml, "hires_effect", hires_effect);
xml_out_int (xml, "force_inverted_byte_order", force_inverted_byte_order);
xml_out_int (xml, "multithreading", multithreading);
xml_out_string (xml, "last_directory", last_directory);
@ -467,7 +467,12 @@ Snes9xConfig::set_option (const char *name, const char *value)
}
else if (!strcasecmp (name, "force_hires"))
{
force_hires = atoi (value);
/* Deprecated */
}
else if (!strcasecmp (name, "hires_effect"))
{
hires_effect = atoi (value);
hires_effect = CLAMP (hires_effect, 0, 2);
}
else if (!strcasecmp (name, "scale_method"))
{

View File

@ -15,6 +15,10 @@
#define HWA_OPENGL 1
#define HWA_XV 2
#define HIRES_MERGE 0
#define HIRES_NORMAL 1
#define HIRES_SCALE 2
#define ESC_TOGGLE_MENUBAR 0
#define ESC_EXIT_FULLSCREEN 1
#define ESC_EXIT_SNES9X 2
@ -63,7 +67,7 @@ class Snes9xConfig
unsigned int scale_method;
unsigned char overscan;
unsigned char multithreading;
unsigned char force_hires;
int hires_effect;
unsigned char force_inverted_byte_order;
snes_ntsc_setup_t ntsc_setup;

View File

@ -688,6 +688,39 @@ S9xForceHires (void *buffer,
return;
}
#undef AVERAGE_1555
#define AVERAGE_1555(el0, el1) (((el0) & (el1)) + ((((el0) ^ (el1)) & 0x7BDE) >> 1))
static void
S9xMergeHires (void *buffer,
int pitch,
int &width,
int &height)
{
if (width <= 256)
return;
for (register int y = 0; y < height; y++)
{
register uint16 *input = (uint16 *) ((uint8 *) buffer + y * pitch);
register uint16 *output = input;
register uint16 l, r;
l = 0;
for (register int x = 0; x < (width >> 1); x++)
{
r = *input++;
*output++ = AVERAGE_1555 (l, r);
l = r;
r = *input++;
*output++ = AVERAGE_1555 (l, r);
l = r;
}
}
return;
}
void
filter_2x (void *src,
int src_pitch,
@ -1603,11 +1636,19 @@ S9xDeinitUpdate (int width, int height)
else
height = 224;
if (gui_config->force_hires)
if (gui_config->hires_effect == HIRES_SCALE)
{
S9xForceHires (GFX.Screen,
S9xDisplayDriver::image_width *
S9xDisplayDriver::image_bpp,
S9xDisplayDriver::image_bpp,
width,
height);
}
else if (gui_config->hires_effect == HIRES_MERGE)
{
S9xMergeHires (GFX.Screen,
S9xDisplayDriver::image_width *
S9xDisplayDriver::image_bpp,
width,
height);
}

View File

@ -17,7 +17,7 @@ class S9xDisplayDriver
virtual void reconfigure (int width, int height) = 0;
/* Namespaced sizing constants */
static const int image_width = 512;
static const int image_width = 1024;
static const int image_height = 478;
static const int image_bpp = 2;
static const int scaled_max_width = 1024;

View File

@ -545,13 +545,6 @@ Snes9xPreferences::Snes9xPreferences (Snes9xConfig *config) :
last_toggled = NULL;
this->config = config;
size_group[0] = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group[0], get_widget ("resolution_combo"));
gtk_size_group_add_widget (size_group[0], get_widget ("scale_method_combo"));
size_group[1] = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
gtk_size_group_add_widget (size_group[1], get_widget ("change_display_resolution"));
gtk_size_group_add_widget (size_group[1], get_widget ("scale_method_label"));
fix_style ();
gtk_widget_realize (window);
@ -563,9 +556,6 @@ Snes9xPreferences::Snes9xPreferences (Snes9xConfig *config) :
Snes9xPreferences::~Snes9xPreferences (void)
{
g_object_unref (size_group[0]);
g_object_unref (size_group[1]);
return;
}
@ -630,7 +620,7 @@ Snes9xPreferences::move_settings_to_dialog (void)
set_check ("scale_to_fit", config->scale_to_fit);
set_check ("overscan", config->overscan);
set_check ("multithreading", config->multithreading);
set_check ("force_hires", config->force_hires);
set_combo ("hires_effect", config->hires_effect);
set_check ("maintain_aspect_ratio", config->maintain_aspect_ratio);
set_combo ("aspect_ratio", config->aspect_ratio);
if (config->sram_directory[0] == '\0')
@ -808,7 +798,7 @@ Snes9xPreferences::get_settings_from_dialog (void)
config->maintain_aspect_ratio = get_check ("maintain_aspect_ratio");
config->aspect_ratio = get_combo ("aspect_ratio");
config->scale_method = get_combo ("scale_method_combo");
config->force_hires = get_check ("force_hires");
config->hires_effect = get_combo ("hires_effect");
config->force_inverted_byte_order = get_check ("force_inverted_byte_order");
Settings.AutoSaveDelay = get_entry_value ("save_sram_after_sec");
config->multithreading = get_check ("multithreading");

View File

@ -41,8 +41,6 @@ class Snes9xPreferences : public GtkBuilderWindow
private:
void get_settings_from_dialog (void);
void move_settings_to_dialog (void);
GtkSizeGroup *size_group[2];
};
#endif /* __GTK_PREFERENCES_H */

File diff suppressed because it is too large Load Diff