mirror of https://github.com/snes9xgit/snes9x.git
GTK: Add new splash background options.
This commit is contained in:
parent
2988cbb8ac
commit
dfe66f57b3
|
@ -87,6 +87,7 @@ int Snes9xConfig::load_defaults ()
|
||||||
save_sram_after_secs = 0;
|
save_sram_after_secs = 0;
|
||||||
rom_loaded = false;
|
rom_loaded = false;
|
||||||
multithreading = false;
|
multithreading = false;
|
||||||
|
splash_image = SPLASH_IMAGE_PATTERN;
|
||||||
hw_accel = 0;
|
hw_accel = 0;
|
||||||
allow_opengl = false;
|
allow_opengl = false;
|
||||||
allow_xv = false;
|
allow_xv = false;
|
||||||
|
@ -247,6 +248,7 @@ int Snes9xConfig::save_config_file ()
|
||||||
cf.SetInt (z"NumberOfThreads", num_threads);
|
cf.SetInt (z"NumberOfThreads", num_threads);
|
||||||
cf.SetInt (z"HardwareAcceleration", hw_accel, "0: None, 1: OpenGL, 2: XVideo");
|
cf.SetInt (z"HardwareAcceleration", hw_accel, "0: None, 1: OpenGL, 2: XVideo");
|
||||||
outbool (cf, z"BilinearFilter", Settings.BilinearFilter, "Smoothes scaled image");
|
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
|
#undef z
|
||||||
#define z "NTSC::"
|
#define z "NTSC::"
|
||||||
|
@ -477,6 +479,7 @@ int Snes9xConfig::load_config_file ()
|
||||||
inint (z"NumberOfThreads", num_threads);
|
inint (z"NumberOfThreads", num_threads);
|
||||||
inint (z"HardwareAcceleration", hw_accel);
|
inint (z"HardwareAcceleration", hw_accel);
|
||||||
inbool (z"BilinearFilter", Settings.BilinearFilter);
|
inbool (z"BilinearFilter", Settings.BilinearFilter);
|
||||||
|
inint (z"SplashBackground", splash_image);
|
||||||
|
|
||||||
#undef z
|
#undef z
|
||||||
#define z "NTSC::"
|
#define z "NTSC::"
|
||||||
|
|
|
@ -39,6 +39,13 @@ enum {
|
||||||
THROTTLE_NONE = 3
|
THROTTLE_NONE = 3
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
SPLASH_IMAGE_BLACK = 0,
|
||||||
|
SPLASH_IMAGE_SMTPE = 1,
|
||||||
|
SPLASH_IMAGE_PATTERN = 2,
|
||||||
|
SPLASH_IMAGE_BLUE = 3
|
||||||
|
};
|
||||||
|
|
||||||
class Snes9xConfig
|
class Snes9xConfig
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -68,6 +75,7 @@ class Snes9xConfig
|
||||||
bool multithreading;
|
bool multithreading;
|
||||||
int hires_effect;
|
int hires_effect;
|
||||||
bool force_inverted_byte_order;
|
bool force_inverted_byte_order;
|
||||||
|
int splash_image;
|
||||||
|
|
||||||
snes_ntsc_setup_t ntsc_setup;
|
snes_ntsc_setup_t ntsc_setup;
|
||||||
int ntsc_format;
|
int ntsc_format;
|
||||||
|
|
|
@ -685,12 +685,81 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
|
||||||
resize (config->window_width, config->window_height);
|
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
|
void
|
||||||
Snes9xWindow::expose ()
|
Snes9xWindow::expose ()
|
||||||
{
|
|
||||||
if (last_width < 0)
|
|
||||||
{
|
{
|
||||||
if (!(config->fullscreen) && !(maximized_state))
|
if (!(config->fullscreen) && !(maximized_state))
|
||||||
{
|
{
|
||||||
|
@ -698,26 +767,9 @@ Snes9xWindow::expose ()
|
||||||
config->window_height = get_height();
|
config->window_height = get_height();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load splash image (RGB24) into Snes9x buffer (RGB15) */
|
if (last_width < 0)
|
||||||
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++)
|
setup_splash();
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
S9xDisplayRefresh (last_width, last_height);
|
S9xDisplayRefresh (last_width, last_height);
|
||||||
|
|
|
@ -66,6 +66,7 @@ class Snes9xWindow : public GtkBuilderWindow
|
||||||
void resize_to_multiple (int factor);
|
void resize_to_multiple (int factor);
|
||||||
void resize_viewport (int width, int height);
|
void resize_viewport (int width, int height);
|
||||||
void expose ();
|
void expose ();
|
||||||
|
void setup_splash();
|
||||||
double get_refresh_rate ();
|
double get_refresh_rate ();
|
||||||
int get_auto_input_rate ();
|
int get_auto_input_rate ();
|
||||||
|
|
||||||
|
|
15119
gtk/src/gtk_splash.cpp
15119
gtk/src/gtk_splash.cpp
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue