diff --git a/display.h b/display.h
index 4f261765..fd50d23d 100644
--- a/display.h
+++ b/display.h
@@ -179,6 +179,8 @@
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
+#include "snes9x.h"
+
enum s9x_getdirtype
{
DEFAULT_DIR = 0,
diff --git a/gtk/src/gtk_control.cpp b/gtk/src/gtk_control.cpp
index 13d935f1..906a2846 100644
--- a/gtk/src/gtk_control.cpp
+++ b/gtk/src/gtk_control.cpp
@@ -469,7 +469,7 @@ JoyDevice::~JoyDevice (void)
}
void
-JoyDevice::add_event (int parameter, int state)
+JoyDevice::add_event (unsigned int parameter, unsigned int state)
{
JoyEvent event = { parameter, state };
diff --git a/gtk/src/gtk_control.h b/gtk/src/gtk_control.h
index 916ad192..3afaa9e3 100644
--- a/gtk/src/gtk_control.h
+++ b/gtk/src/gtk_control.h
@@ -87,7 +87,7 @@ class JoyDevice
private:
void poll_events (void);
- void add_event (int parameter, int state);
+ void add_event (unsigned int parameter, unsigned int state);
};
#endif
diff --git a/gtk/src/gtk_display.cpp b/gtk/src/gtk_display.cpp
index c2897e1b..4cd792ad 100644
--- a/gtk/src/gtk_display.cpp
+++ b/gtk/src/gtk_display.cpp
@@ -63,10 +63,26 @@ S9xSetEndianess (int type)
double
S9xGetAspect (void)
{
- if (gui_config->aspect_ratio)
- return (4.0 / 3.0);
- else
- return (8.0 / 7.0);
+ double native_aspect = 256.0 / (gui_config->overscan ? 239.0 : 224.0);
+ double aspect;
+
+ switch (gui_config->aspect_ratio)
+ {
+ case 0: /* Square pixels */
+ aspect = native_aspect;
+ break;
+
+ case 1: /* 4:3 */
+ aspect = native_aspect * 7 / 6;
+ break;
+
+ case 2:
+ default: /* Correct */
+ aspect = native_aspect * 8 / 7;
+ break;
+ }
+
+ return aspect;
}
void
@@ -718,6 +734,7 @@ S9xMergeHires (void *buffer,
return;
}
+#if 0
static void
S9xBlendHires (void *buffer, int pitch, int &width, int &height)
{
@@ -751,6 +768,7 @@ S9xBlendHires (void *buffer, int pitch, int &width, int &height)
return;
}
+#endif
void
filter_2x (void *src,
diff --git a/gtk/src/gtk_display_driver.h b/gtk/src/gtk_display_driver.h
index 3aa11742..d36fd467 100644
--- a/gtk/src/gtk_display_driver.h
+++ b/gtk/src/gtk_display_driver.h
@@ -6,6 +6,7 @@
class S9xDisplayDriver
{
public:
+ virtual ~S9xDisplayDriver() {}
virtual void refresh (int width, int height) = 0;
virtual int init (void) = 0;
virtual void deinit (void) = 0;
diff --git a/gtk/src/gtk_display_driver_opengl.cpp b/gtk/src/gtk_display_driver_opengl.cpp
index 153bfc17..34ae173a 100644
--- a/gtk/src/gtk_display_driver_opengl.cpp
+++ b/gtk/src/gtk_display_driver_opengl.cpp
@@ -318,16 +318,22 @@ S9xOpenGLDisplayDriver::update (int width, int height)
if (using_shaders)
{
GLint location;
+ float inputSize[2];
+ float outputSize[2];
+ float textureSize[2];
- float inputSize[2] = { width, height };
+ inputSize[0] = width;
+ inputSize[1] = height;
location = glGetUniformLocation (program, "rubyInputSize");
glUniform2fv (location, 1, inputSize);
- float outputSize[2] = {w , h };
+ outputSize[0] = w;
+ outputSize[1] = h;
location = glGetUniformLocation (program, "rubyOutputSize");
glUniform2fv (location, 1, outputSize);
- float textureSize[2] = { texture_width, texture_height };
+ textureSize[0] = texture_width;
+ textureSize[1] = texture_height;
location = glGetUniformLocation (program, "rubyTextureSize");
glUniform2fv (location, 1, textureSize);
}
@@ -727,14 +733,10 @@ S9xOpenGLDisplayDriver::refresh (int width, int height)
void
S9xOpenGLDisplayDriver::resize_window (int width, int height)
{
- XWindowChanges changes;
-
- changes.width = width;
- changes.height = height;
- XConfigureWindow (display, xwindow, CWWidth | CWHeight, &changes);
- XSync (display, False);
-
- gdk_window_show (gdk_window);
+ g_object_unref (gdk_window);
+ XDestroyWindow (display, xwindow);
+ create_window (width, height);
+ glXMakeCurrent (display, xwindow, glx_context);
return;
}
diff --git a/gtk/src/gtk_display_driver_xv.cpp b/gtk/src/gtk_display_driver_xv.cpp
index 1333a705..c512dfc8 100644
--- a/gtk/src/gtk_display_driver_xv.cpp
+++ b/gtk/src/gtk_display_driver_xv.cpp
@@ -39,14 +39,9 @@ S9xXVDisplayDriver::S9xXVDisplayDriver (Snes9xWindow *window,
void
S9xXVDisplayDriver::resize_window (int width, int height)
{
- XWindowChanges changes;
-
- changes.width = width;
- changes.height = height;
- XConfigureWindow (display, xwindow, CWWidth | CWHeight, &changes);
- XSync (display, False);
-
- gdk_window_show (gdk_window);
+ g_object_unref (gdk_window);
+ XDestroyWindow (display, xwindow);
+ create_window (width, height);
return;
}
diff --git a/gtk/src/gtk_file.cpp b/gtk/src/gtk_file.cpp
index a0df75d8..9c0e0009 100644
--- a/gtk/src/gtk_file.cpp
+++ b/gtk/src/gtk_file.cpp
@@ -465,8 +465,11 @@ S9xOpenROMDialog (void)
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
directory =
gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (dialog));
- strncpy (gui_config->last_directory, directory, PATH_MAX);
- g_free (directory);
+ if (directory)
+ {
+ strncpy (gui_config->last_directory, directory, PATH_MAX);
+ g_free (directory);
+ }
}
else
diff --git a/gtk/src/gtk_s9xwindow.cpp b/gtk/src/gtk_s9xwindow.cpp
index 21e5ea34..7c275932 100644
--- a/gtk/src/gtk_s9xwindow.cpp
+++ b/gtk/src/gtk_s9xwindow.cpp
@@ -100,10 +100,7 @@ event_toggle_interface (GtkWidget *widget, gpointer data)
static gboolean
event_show_statusbar (GtkWidget *widget, gpointer data)
{
- Snes9xWindow *window = (Snes9xWindow *) data;
-
- window->config->statusbar_visible = !window->config->statusbar_visible;
- window->configure_widgets ();
+ ((Snes9xWindow *) data)->toggle_statusbar ();
return TRUE;
}
@@ -307,7 +304,7 @@ event_fullscreen (GtkWidget *widget, gpointer data)
static void
event_exact_pixels_1x (GtkWidget *widget, gpointer data)
{
- ((Snes9xWindow *) data)->resize_viewport (256, 224);
+ ((Snes9xWindow *) data)->resize_to_multiple (1);
return;
}
@@ -315,7 +312,7 @@ event_exact_pixels_1x (GtkWidget *widget, gpointer data)
static void
event_exact_pixels_2x (GtkWidget *widget, gpointer data)
{
- ((Snes9xWindow *) data)->resize_viewport (256 * 2, 224 * 2);
+ ((Snes9xWindow *) data)->resize_to_multiple (2);
return;
}
@@ -323,7 +320,7 @@ event_exact_pixels_2x (GtkWidget *widget, gpointer data)
static void
event_exact_pixels_3x (GtkWidget *widget, gpointer data)
{
- ((Snes9xWindow *) data)->resize_viewport (256 * 3, 224 * 3);
+ ((Snes9xWindow *) data)->resize_to_multiple (3);
return;
}
@@ -331,7 +328,7 @@ event_exact_pixels_3x (GtkWidget *widget, gpointer data)
static void
event_exact_pixels_4x (GtkWidget *widget, gpointer data)
{
- ((Snes9xWindow *) data)->resize_viewport (256 * 4, 224 * 4);
+ ((Snes9xWindow *) data)->resize_to_multiple (4);
return;
}
@@ -339,47 +336,7 @@ event_exact_pixels_4x (GtkWidget *widget, gpointer data)
static void
event_exact_pixels_5x (GtkWidget *widget, gpointer data)
{
- ((Snes9xWindow *) data)->resize_viewport (256 * 5, 224 * 5);
-
- return;
-}
-
-static void
-event_correct_aspect_1x (GtkWidget *widget, gpointer data)
-{
- ((Snes9xWindow *) data)->resize_viewport (224 * 4 / 3, 224);
-
- return;
-}
-
-static void
-event_correct_aspect_2x (GtkWidget *widget, gpointer data)
-{
- ((Snes9xWindow *) data)->resize_viewport (224 * 4 * 2 / 3, 224 * 2);
-
- return;
-}
-
-static void
-event_correct_aspect_3x (GtkWidget *widget, gpointer data)
-{
- ((Snes9xWindow *) data)->resize_viewport (224 * 4 * 3 / 3, 224 * 3);
-
- return;
-}
-
-static void
-event_correct_aspect_4x (GtkWidget *widget, gpointer data)
-{
- ((Snes9xWindow *) data)->resize_viewport (224 * 4 * 4 / 3, 224 * 4);
-
- return;
-}
-
-static void
-event_correct_aspect_5x (GtkWidget *widget, gpointer data)
-{
- ((Snes9xWindow *) data)->resize_viewport (224 * 4 * 5 / 3, 224 * 5);
+ ((Snes9xWindow *) data)->resize_to_multiple (5);
return;
}
@@ -626,11 +583,6 @@ Snes9xWindow::Snes9xWindow (Snes9xConfig *config) :
{ "exact_3x", G_CALLBACK (event_exact_pixels_3x) },
{ "exact_4x", G_CALLBACK (event_exact_pixels_4x) },
{ "exact_5x", G_CALLBACK (event_exact_pixels_5x) },
- { "correct_1x", G_CALLBACK (event_correct_aspect_1x) },
- { "correct_2x", G_CALLBACK (event_correct_aspect_2x) },
- { "correct_3x", G_CALLBACK (event_correct_aspect_3x) },
- { "correct_4x", G_CALLBACK (event_correct_aspect_4x) },
- { "correct_5x", G_CALLBACK (event_correct_aspect_5x) },
{ "open_multicart", G_CALLBACK (event_open_multicart) },
{ NULL, NULL }
@@ -1776,6 +1728,35 @@ Snes9xWindow::draw_background (int x, int y, int w, int h)
return;
}
+void
+Snes9xWindow::toggle_statusbar (void)
+{
+ GtkWidget *item;
+ GtkAllocation allocation;
+ int width = 0;
+ int height = 0;
+
+ item = get_widget ("menubar");
+ gtk_widget_get_allocation (item, &allocation);
+ height += gtk_widget_get_visible (item) ? allocation.height : 0;
+
+ item = get_widget ("drawingarea");
+ gtk_widget_get_allocation (item, &allocation);
+ height += allocation.height;
+ width = allocation.width;
+
+ config->statusbar_visible = !config->statusbar_visible;
+ configure_widgets ();
+
+ item = get_widget ("statusbar");
+ gtk_widget_get_allocation (item, &allocation);
+ height += gtk_widget_get_visible (item) ? allocation.height : 0;
+
+ resize (width, height);
+
+ return;
+}
+
void
Snes9xWindow::resize_viewport (int width, int height)
{
@@ -2044,3 +2025,14 @@ Snes9xWindow::update_accels (void)
return;
}
+
+void
+Snes9xWindow::resize_to_multiple (int factor)
+{
+ int h = (config->overscan ? 239 : 224) * factor;
+ int w = h * S9xGetAspect () + 0.5;
+
+ resize_viewport (w, h);
+
+ return;
+}
diff --git a/gtk/src/gtk_s9xwindow.h b/gtk/src/gtk_s9xwindow.h
index 8ae3bb4b..d5350480 100644
--- a/gtk/src/gtk_s9xwindow.h
+++ b/gtk/src/gtk_s9xwindow.h
@@ -53,6 +53,7 @@ class Snes9xWindow : public GtkBuilderWindow
void show (void);
void show_status_message (const char *message);
void update_statusbar (void);
+ void toggle_statusbar (void);
void draw_background (int x = -1, int y = -1, int w = -1, int h = -1);
void draw_background (cairo_t *cr);
void set_menu_item_selected (const char *name);
@@ -62,6 +63,7 @@ class Snes9xWindow : public GtkBuilderWindow
void reset_screensaver (void);
void update_accels (void);
void toggle_ui (void);
+ void resize_to_multiple (int factor);
void resize_viewport (int width, int height);
void expose (GdkEventExpose *event, cairo_t *cr);
diff --git a/gtk/src/gtk_sound_driver.h b/gtk/src/gtk_sound_driver.h
index 1c66ccd8..034c7012 100644
--- a/gtk/src/gtk_sound_driver.h
+++ b/gtk/src/gtk_sound_driver.h
@@ -6,6 +6,7 @@
class S9xSoundDriver
{
public:
+ virtual ~S9xSoundDriver () {}
virtual void init (void) = 0;
virtual void terminate (void) = 0;
virtual bool8 open_device (void) = 0;
diff --git a/gtk/src/snes9x.ui b/gtk/src/snes9x.ui
index bff0a613..051c2cd8 100644
--- a/gtk/src/snes9x.ui
+++ b/gtk/src/snes9x.ui
@@ -102,7 +102,6 @@
True
True
True
- False
True
@@ -264,7 +263,6 @@
True
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- False
True
@@ -385,7 +383,6 @@
True
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- False
True
@@ -402,7 +399,6 @@
True
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- False
True
@@ -459,7 +455,6 @@
True
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- False
True
@@ -477,7 +472,6 @@
True
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- False
True
@@ -795,6 +789,9 @@
4:3 SNES correct aspect
+
+ 8*8:7*7 NTSC
+
-
+
+
+ Maintain aspect-ratio
+ True
+ True
+ False
+ Scales the image as large as possible without distortion
+ True
+ True
+
+
+ False
+ False
+ 2
+
+
True
@@ -2932,7 +2783,6 @@
True
False
Allows scaling and filtering to use multiple processors
- False
True
True
@@ -2976,7 +2826,7 @@
False
True
- 2
+ 3
@@ -3018,7 +2868,7 @@
False
True
- 3
+ 4
@@ -3062,7 +2912,7 @@
False
False
- 4
+ 5
@@ -3133,7 +2983,6 @@
True
True
True
- False
@@ -3148,7 +2997,6 @@
True
True
True
- False
@@ -3163,7 +3011,6 @@
True
True
True
- False
@@ -3178,7 +3025,6 @@
True
True
True
- False
@@ -3571,7 +3417,6 @@
True
True
False
- False
True
@@ -3755,7 +3600,6 @@
True
True
False
- False
True
True
@@ -3778,7 +3622,6 @@
True
False
Sync the image to the vertical retrace to stop tearing
- False
True
True
@@ -3795,7 +3638,6 @@
True
False
Sync the program with the video output after every displayed frame to reduce input latency
- False
True
@@ -3811,7 +3653,6 @@
True
False
Prevents edge artifacts, but can slow performance
- False
True
@@ -3828,7 +3669,6 @@
False
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
Can be faster or slower depending on drivers
- False
True
@@ -3902,7 +3742,6 @@
True
True
False
- False
0
True
@@ -3935,7 +3774,6 @@
True
True
True
- False
@@ -3969,7 +3807,6 @@
True
False
Forces a swapped byte-ordering for cases where the system's endian is used instead of the video card
- False
True
@@ -4123,7 +3960,6 @@
True
False
Base emulation speed on the rate sound is output
- False
True
@@ -4139,7 +3975,6 @@
True
False
Disables output of sound
- False
True
True
@@ -4156,7 +3991,6 @@
True
False
Output two channels, left and right
- False
True
True
@@ -4479,7 +4313,6 @@
Block invalid VRAM access
True
False
- False
True
@@ -4495,7 +4328,6 @@
True
False
Let left and right or up and down be pressed at the same time
- False
True
@@ -4547,7 +4379,6 @@
True
True
False
- False
True
@@ -4640,7 +4471,6 @@
True
True
False
- False
True
@@ -4857,7 +4687,6 @@
True
True
True
- False
@@ -4873,7 +4702,6 @@
True
True
True
- False
@@ -4891,7 +4719,6 @@
True
True
True
- False
@@ -4909,7 +4736,6 @@
True
True
True
- False
@@ -4927,7 +4753,6 @@
True
True
True
- False
@@ -5213,7 +5038,6 @@
True
True
True
- False
True
@@ -5270,7 +5094,6 @@
True
True
True
- False
True
@@ -5294,7 +5117,6 @@
True
False
Allow using modifier keys as independent keys instead of modifiers
- False
True
True
@@ -6357,7 +6179,6 @@
True
True
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK
- False
True
diff --git a/libretro/libretro.cpp b/libretro/libretro.cpp
index 9ae42d9c..6100f298 100644
--- a/libretro/libretro.cpp
+++ b/libretro/libretro.cpp
@@ -370,9 +370,10 @@ void retro_init()
use_overscan = false;
}
- environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log);
- if (log.log)
+ if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
log_cb = log.log;
+ else
+ log_cb = NULL;
memset(&Settings, 0, sizeof(Settings));
Settings.MouseMaster = TRUE;
diff --git a/libretro/libretro.def b/libretro/libretro.def
index aa6381b4..77094e74 100644
--- a/libretro/libretro.def
+++ b/libretro/libretro.def
@@ -34,8 +34,6 @@ retro_load_game
retro_unload_game
retro_load_game_special
-retro_unload_cartridge
-
retro_get_region
retro_get_memory_data
retro_get_memory_size
\ No newline at end of file
diff --git a/libretro/libretro.h b/libretro/libretro.h
index 4ef9d93a..f3b31b00 100755
--- a/libretro/libretro.h
+++ b/libretro/libretro.h
@@ -23,7 +23,7 @@
#ifndef LIBRETRO_H__
#define LIBRETRO_H__
-#include
+#include "port.h"
#include
#include
diff --git a/memmap.cpp b/memmap.cpp
index 03ceaba6..fa1230f1 100644
--- a/memmap.cpp
+++ b/memmap.cpp
@@ -1519,10 +1519,8 @@ bool8 CMemory::LoadROMMem (const uint8 *source, uint32 sourceSize)
strcpy(ROMFilename,"MemoryROM");
- int counter=0;
do
{
- if (++counter>5) return FALSE;//if we keep failing, just give up after a while or we'll loop forever.
memset(ROM,0, MAX_ROM_SIZE);
memset(&Multi, 0,sizeof(Multi));
memcpy(ROM,source,sourceSize);
@@ -1539,10 +1537,8 @@ bool8 CMemory::LoadROM (const char *filename)
int32 totalFileSize;
- int counter=0;
do
{
- if (++counter>5) return FALSE;
memset(ROM,0, MAX_ROM_SIZE);
memset(&Multi, 0,sizeof(Multi));
totalFileSize = FileLoader(ROM, filename, MAX_ROM_SIZE);
diff --git a/snapshot.h b/snapshot.h
index 88798a23..a234b8d8 100644
--- a/snapshot.h
+++ b/snapshot.h
@@ -179,6 +179,8 @@
#ifndef _SNAPSHOT_H_
#define _SNAPSHOT_H_
+#include "snes9x.h"
+
#define SNAPSHOT_MAGIC "#!s9xsnp"
#define SNAPSHOT_VERSION_IRQ 7
#define SNAPSHOT_VERSION_BAPU 8
diff --git a/unzip/miniunz.c b/unzip/miniunz.c
index b5bc8b54..db1ddd4f 100644
--- a/unzip/miniunz.c
+++ b/unzip/miniunz.c
@@ -215,11 +215,13 @@ int do_list(uf)
else if ((iLevel==2) || (iLevel==3))
string_method="Defl:F"; /* 2:fast , 3 : extra fast*/
}
+#ifdef HAVE_BZIP2
else
if (file_info.compression_method==Z_BZIP2ED)
{
string_method="BZip2 ";
}
+#endif
else
string_method="Unkn. ";
diff --git a/unzip/unzip.c b/unzip/unzip.c
index 17d730d6..6ec52096 100644
--- a/unzip/unzip.c
+++ b/unzip/unzip.c
@@ -1013,9 +1013,9 @@ local int unzlocal_CheckCurrentFileCoherencyHeader (s,piSizeVar,
err=UNZ_BADZIPFILE;
if ((err==UNZ_OK) && (s->cur_file_info.compression_method!=0) &&
-/* #ifdef HAVE_BZIP2 */
+#ifdef HAVE_BZIP2
(s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-/* #endif */
+#endif
(s->cur_file_info.compression_method!=Z_DEFLATED))
err=UNZ_BADZIPFILE;
@@ -1130,9 +1130,9 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
}
if ((s->cur_file_info.compression_method!=0) &&
-/* #ifdef HAVE_BZIP2 */
+#ifdef HAVE_BZIP2
(s->cur_file_info.compression_method!=Z_BZIP2ED) &&
-/* #endif */
+#endif
(s->cur_file_info.compression_method!=Z_DEFLATED))
err=UNZ_BADZIPFILE;
@@ -1146,10 +1146,10 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
pfile_in_zip_read_info->stream.total_out = 0;
+#ifdef HAVE_BZIP2
if ((s->cur_file_info.compression_method==Z_BZIP2ED) &&
(!raw))
{
-#ifdef HAVE_BZIP2
pfile_in_zip_read_info->bstream.bzalloc = (void *(*) (void *, int, int))0;
pfile_in_zip_read_info->bstream.bzfree = (free_func)0;
pfile_in_zip_read_info->bstream.opaque = (voidpf)0;
@@ -1169,11 +1169,9 @@ extern int ZEXPORT unzOpenCurrentFile3 (file, method, level, raw, password)
TRYFREE(pfile_in_zip_read_info);
return err;
}
-#else
- pfile_in_zip_read_info->raw=1;
-#endif
}
else
+#endif
if ((s->cur_file_info.compression_method==Z_DEFLATED) &&
(!raw))
{
@@ -1385,10 +1383,10 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
pfile_in_zip_read_info->stream.total_out += uDoCopy;
iRead += uDoCopy;
}
+#ifdef HAVE_BZIP2
else
if (pfile_in_zip_read_info->compression_method==Z_BZIP2ED)
{
-#ifdef HAVE_BZIP2
uLong uTotalOutBefore,uTotalOutAfter;
const Bytef *bufBefore;
uLong uOutThis;
@@ -1430,8 +1428,8 @@ extern int ZEXPORT unzReadCurrentFile (file, buf, len)
return (iRead==0) ? UNZ_EOF : iRead;
if (err!=BZ_OK)
break;
-#endif
}
+#endif
else
{
uLong uTotalOutBefore,uTotalOutAfter;
diff --git a/win32/CD3DCG.cpp b/win32/CD3DCG.cpp
index 08348ac2..5129bd09 100644
--- a/win32/CD3DCG.cpp
+++ b/win32/CD3DCG.cpp
@@ -675,9 +675,9 @@ void CD3DCG::setShaderVars(int pass)
}\
if(cgpv) {\
cgD3D9SetTexture(cgpv,val);\
- cgD3D9SetSamplerState(cgpv, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);\
+ /*cgD3D9SetSamplerState(cgpv, D3DSAMP_ADDRESSU, D3DTADDRESS_BORDER);\
cgD3D9SetSamplerState(cgpv, D3DSAMP_ADDRESSV, D3DTADDRESS_BORDER);\
- /*cgD3D9SetSamplerState(cgpv, D3DSAMP_MINFILTER, linear?D3DTEXF_LINEAR:D3DTEXF_POINT);\
+ cgD3D9SetSamplerState(cgpv, D3DSAMP_MINFILTER, linear?D3DTEXF_LINEAR:D3DTEXF_POINT);\
cgD3D9SetSamplerState(cgpv, D3DSAMP_MAGFILTER, linear?D3DTEXF_LINEAR:D3DTEXF_POINT);*/\
}\
}\
diff --git a/win32/wconfig.cpp b/win32/wconfig.cpp
index 610111e4..1e8979ad 100644
--- a/win32/wconfig.cpp
+++ b/win32/wconfig.cpp
@@ -293,8 +293,6 @@ static bool try_save(const char *fname, ConfigFile &conf){
return false;
}
-static char rom_filename [MAX_PATH] = {0};
-
static bool S9xSaveConfigFile(ConfigFile &conf){
configMutex = CreateMutex(NULL, FALSE, TEXT("Snes9xConfigMutex"));
@@ -344,18 +342,30 @@ static inline char *SkipSpaces (char *p)
return (p);
}
-const char* WinParseCommandLineAndLoadConfigFile (char *line)
+const TCHAR* WinParseCommandLineAndLoadConfigFile (TCHAR *line)
{
// Break the command line up into an array of string pointers, each pointer
// points at a separate word or character sequence enclosed in quotes.
+ int count = 0;
+ static TCHAR return_filename[MAX_PATH];
+
+#ifdef UNICODE
+ // split params into argv
+ TCHAR **params = CommandLineToArgvW(line, &count);
+
+ // convert all parameters to utf8
+ char **parameters = new char*[count];
+ for(int i = 0; i < count; i++) {
+ int requiredChars = WideCharToMultiByte(CP_UTF8, 0, params[i], -1, NULL, 0, NULL, NULL);
+ parameters[i] = new char[requiredChars];
+ WideCharToMultiByte(CP_UTF8, 0, params[i], -1, parameters[i], requiredChars, NULL, NULL);
+ }
+ LocalFree(params);
+#else
#define MAX_PARAMETERS 100
char *p = line;
- static char *parameters [MAX_PARAMETERS];
- int count = 0;
-
- //parameters [count++] = "Snes9X";
-
+ char *parameters[MAX_PARAMETERS];
while (count < MAX_PARAMETERS && *p)
{
p = SkipSpaces (p);
@@ -387,6 +397,7 @@ const char* WinParseCommandLineAndLoadConfigFile (char *line)
}
}
+#endif
configMutex = CreateMutex(NULL, FALSE, TEXT("Snes9xConfigMutex"));
int times = 0;
DWORD waitVal = WAIT_TIMEOUT;
@@ -427,12 +438,19 @@ const char* WinParseCommandLineAndLoadConfigFile (char *line)
CloseHandle(configMutex);
const char* rf = S9xParseArgs (parameters, count);
- /*if(rf)
- strcpy(rom_filename, rf);
- else
- rom_filename[0] = '\0';*/
- return rf;
+ if(rf) // save rom_filename as TCHAR if available
+ lstrcpy(return_filename, _tFromChar(rf));
+
+#ifdef UNICODE
+ // free parameters
+ for(int i = 0; i < count; i++) {
+ delete [] parameters[i];
+ }
+ delete [] parameters;
+#endif
+
+ return rf ? return_filename : NULL;
}
#define S(x) GAMEDEVICE_VK_##x
@@ -955,7 +973,6 @@ void WinRegisterConfigItems()
AddBoolC("Cheat", Settings.ApplyCheats, true, "true to allow enabled cheats to be applied");
AddInvBoolC("Patch", Settings.NoPatch, true, "true to allow IPS/UPS patches to be applied (\"soft patching\")");
AddBoolC("BS", Settings.BS, false, "Broadcast Satellaview emulation");
- AddStringC("Filename", rom_filename, MAX_PATH, "", "filename of ROM to run when Snes9x opens");
#undef CATEGORY
#ifdef NETPLAY_SUPPORT
#define CATEGORY "Netplay"
diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp
index 3c3e7e6c..6ed8800d 100644
--- a/win32/wsnes9x.cpp
+++ b/win32/wsnes9x.cpp
@@ -635,7 +635,7 @@ bool8 S9xLoadROMImage (const TCHAR *string);
static void EnableServer (bool8 enable);
#endif
void WinDeleteRecentGamesList ();
-const char* WinParseCommandLineAndLoadConfigFile (char *line);
+const TCHAR* WinParseCommandLineAndLoadConfigFile (TCHAR *line);
void WinRegisterConfigItems ();
void WinSaveConfigFile ();
void WinSetDefaultValues ();
@@ -3330,7 +3330,6 @@ int WINAPI WinMain(
LPSTR lpCmdLine,
int nCmdShow)
{
- char cmdLine[MAX_PATH];
Settings.StopEmulation = TRUE;
SetCurrentDirectory(S9xGetDirectoryT(DEFAULT_DIR));
@@ -3352,8 +3351,7 @@ int WINAPI WinMain(
ChangeInputDevice();
- strcpy(cmdLine,_tToChar(GetCommandLine()));
- const char *rom_filename = WinParseCommandLineAndLoadConfigFile (cmdLine);
+ const TCHAR *rom_filename = WinParseCommandLineAndLoadConfigFile (GetCommandLine());
WinSaveConfigFile ();
WinLockConfigFile ();
@@ -3422,7 +3420,7 @@ int WINAPI WinMain(
}
if(rom_filename)
- LoadROM(_tFromChar(rom_filename));
+ LoadROM(rom_filename);
S9xUnmapAllControls();
S9xSetupDefaultKeymap();