GTK: Add new splash background options.

This commit is contained in:
Brandon Wright 2019-03-21 16:37:00 -05:00
parent 2988cbb8ac
commit dfe66f57b3
5 changed files with 872 additions and 14369 deletions

View File

@ -87,6 +87,7 @@ int Snes9xConfig::load_defaults ()
save_sram_after_secs = 0;
rom_loaded = false;
multithreading = false;
splash_image = SPLASH_IMAGE_PATTERN;
hw_accel = 0;
allow_opengl = false;
allow_xv = false;
@ -247,6 +248,7 @@ int Snes9xConfig::save_config_file ()
cf.SetInt (z"NumberOfThreads", num_threads);
cf.SetInt (z"HardwareAcceleration", hw_accel, "0: None, 1: OpenGL, 2: XVideo");
outbool (cf, z"BilinearFilter", Settings.BilinearFilter, "Smoothes scaled image");
cf.SetInt (z"SplashBackground", splash_image, "0: Black, 1: Color bars, 2: Pattern, 3: Blue");
#undef z
#define z "NTSC::"
@ -477,6 +479,7 @@ int Snes9xConfig::load_config_file ()
inint (z"NumberOfThreads", num_threads);
inint (z"HardwareAcceleration", hw_accel);
inbool (z"BilinearFilter", Settings.BilinearFilter);
inint (z"SplashBackground", splash_image);
#undef z
#define z "NTSC::"

View File

@ -39,6 +39,13 @@ enum {
THROTTLE_NONE = 3
};
enum {
SPLASH_IMAGE_BLACK = 0,
SPLASH_IMAGE_SMTPE = 1,
SPLASH_IMAGE_PATTERN = 2,
SPLASH_IMAGE_BLUE = 3
};
class Snes9xConfig
{
public:
@ -68,6 +75,7 @@ class Snes9xConfig
bool multithreading;
int hires_effect;
bool force_inverted_byte_order;
int splash_image;
snes_ntsc_setup_t ntsc_setup;
int ntsc_format;

View File

@ -685,40 +685,92 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
resize (config->window_width, config->window_height);
}
extern const gtk_splash_t gtk_splash;
extern int gtk_splash_smtpe_size;
extern unsigned char gtk_splash_smtpe[];
extern int gtk_splash_pattern_size;
extern unsigned char gtk_splash_pattern[];
void Snes9xWindow::setup_splash()
{
uint16 *screen_ptr = GFX.Screen;
/* Load splash image (RGB24) into Snes9x buffer (RGB15) */
last_width = 256;
last_height = 224;
if (config->splash_image == SPLASH_IMAGE_PATTERN ||
config->splash_image == SPLASH_IMAGE_SMTPE) {
unsigned char *pattern = NULL;
int pattern_size = 0;
if (config->splash_image == SPLASH_IMAGE_PATTERN) {
pattern = gtk_splash_pattern;
pattern_size = gtk_splash_pattern_size;
} else {
pattern = gtk_splash_smtpe;
pattern_size = gtk_splash_smtpe_size;
}
auto pixbuf_loader = gdk_pixbuf_loader_new_with_type("png", NULL);
gdk_pixbuf_loader_write(pixbuf_loader, pattern, pattern_size, NULL);
gdk_pixbuf_loader_close(pixbuf_loader, NULL);
auto pixbuf = gdk_pixbuf_loader_get_pixbuf(pixbuf_loader);
const unsigned char *splash_ptr = gdk_pixbuf_get_pixels(pixbuf);
const int channels = gdk_pixbuf_get_n_channels(pixbuf);
for (int y = 0; y < 224; y++, screen_ptr += (GFX.Pitch / 2)) {
for (int x = 0; x < 256; x++) {
unsigned int red = splash_ptr[0];
unsigned int green = splash_ptr[1];
unsigned int blue = splash_ptr[2];
screen_ptr[x] = ((red & 0xF8) << 8) +
((green & 0xF8) << 3) +
((green & 0x80) >> 2) +
((blue & 0xF8) >> 3);
splash_ptr += channels;
}
}
g_object_unref(pixbuf_loader);
return;
}
if (config->splash_image == SPLASH_IMAGE_BLUE) {
for (int y = 0; y < 224; y++, screen_ptr += (GFX.Pitch / 2)) {
uint16 colora = (uint16)y / 7;
uint16 colorb = ((uint16)y - 3) / 7;
if (colorb > 32)
colorb = 0;
for (int x = 0; x < 256; x++) {
screen_ptr[x] = ((x ^ y) & 1) ? colorb : colora;
}
}
return;
}
for (int y = 0; y < 224; y++, screen_ptr += (GFX.Pitch / 2)) {
memset(screen_ptr, 0, 256 * sizeof(uint16));
}
}
void
Snes9xWindow::expose ()
{
if (!(config->fullscreen) && !(maximized_state))
{
config->window_width = get_width();
config->window_height = get_height();
}
if (last_width < 0)
{
if (!(config->fullscreen) && !(maximized_state))
{
config->window_width = get_width ();
config->window_height = get_height ();
}
/* Load splash image (RGB24) into Snes9x buffer (RGB15) */
last_width = 256;
last_height = 224;
uint16 *screen_ptr = GFX.Screen;
const unsigned char *splash_ptr = gtk_splash.pixel_data;
for (int y = 0; y < 224; y++, screen_ptr += (GFX.Pitch / 2))
{
for (int x = 0; x < 256; x++)
{
unsigned int red = *splash_ptr++;
unsigned int green = *splash_ptr++;
unsigned int blue = *splash_ptr++;
screen_ptr[x] = ((red & 0xF8) << 8) +
((green & 0xF8) << 3) +
((blue & 0xF8) >> 3);
}
}
}
setup_splash();
}
S9xDisplayRefresh (last_width, last_height);

View File

@ -66,6 +66,7 @@ class Snes9xWindow : public GtkBuilderWindow
void resize_to_multiple (int factor);
void resize_viewport (int width, int height);
void expose ();
void setup_splash();
double get_refresh_rate ();
int get_auto_input_rate ();

File diff suppressed because it is too large Load Diff