This commit is contained in:
twinaphex 2014-04-06 21:19:45 +02:00
commit 7c9db9acf5
22 changed files with 178 additions and 329 deletions

View File

@ -179,6 +179,8 @@
#ifndef _DISPLAY_H_
#define _DISPLAY_H_
#include "snes9x.h"
enum s9x_getdirtype
{
DEFAULT_DIR = 0,

View File

@ -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 };

View File

@ -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

View File

@ -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,

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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;
}

View File

@ -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);

View File

@ -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;

File diff suppressed because it is too large Load Diff

View File

@ -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;

View File

@ -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

View File

@ -23,7 +23,7 @@
#ifndef LIBRETRO_H__
#define LIBRETRO_H__
#include <stdint.h>
#include "port.h"
#include <stddef.h>
#include <limits.h>

View File

@ -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);

View File

@ -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

View File

@ -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. ";

View File

@ -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;

View File

@ -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);*/\
}\
}\

View File

@ -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"

View File

@ -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();