From 03ad29922fd7615aa072b4855394d6b20742ba4e Mon Sep 17 00:00:00 2001
From: jeblanchard <jeblanchard@users.sf.net>
Date: Mon, 26 May 2008 00:33:27 +0000
Subject: [PATCH] Minor Linux compilation fixes

---
 src/drivers/common/config.cpp    |  9 +++---
 src/drivers/sdl/input.cpp        |  4 +--
 src/drivers/sdl/sdl.cpp          | 54 ++++++++++++++++++++++++++++++--
 src/drivers/sdl/unix-netplay.cpp |  4 +--
 src/movie.cpp                    |  7 +++--
 src/utils/SConscript             |  2 +-
 6 files changed, 66 insertions(+), 14 deletions(-)

diff --git a/src/drivers/common/config.cpp b/src/drivers/common/config.cpp
index 4f3db4d4..5539b4b3 100644
--- a/src/drivers/common/config.cpp
+++ b/src/drivers/common/config.cpp
@@ -66,11 +66,12 @@ static void cfg_Parse(FILE *fp)
 	for(;;)
 	{
 		int c = fgetc(fp);
+		bool iswhitespace, iscommentchar, isnewline;
 		if(c == -1)
 			goto bail;
-		bool iswhitespace = (c==' '||c=='\t');
-		bool iscommentchar = (c=='#');
-		bool isnewline = (c==10||c==13);
+		iswhitespace = (c==' '||c=='\t');
+		iscommentchar = (c=='#');
+		isnewline = (c==10||c==13);
 		switch(state)
 		{
 		case NEWLINE:
@@ -370,4 +371,4 @@ void LoadFCEUConfig(const char *filename, CFGSTRUCT *cfgst)
 	cfg_NewToOld(cfgst);
 
 	fclose(fp);
-}
\ No newline at end of file
+}
diff --git a/src/drivers/sdl/input.cpp b/src/drivers/sdl/input.cpp
index 773a4b88..f975a53c 100644
--- a/src/drivers/sdl/input.cpp
+++ b/src/drivers/sdl/input.cpp
@@ -321,9 +321,9 @@ do {                                              \
         }                                         \
         FCEUI_DispMessage("Barcode: %s", bbuf);   \
     } else {                                      \
-        if(is_shift) {                            \
+      /*if(is_shift) {                            \
             FCEUI_SelectMovie(x,1);               \
-        } else {                                  \
+        } else */{                                \
             FCEUI_SelectState(x,1);               \
 	}                                         \
     }                                             \
diff --git a/src/drivers/sdl/sdl.cpp b/src/drivers/sdl/sdl.cpp
index 464ddd3a..29ef1317 100644
--- a/src/drivers/sdl/sdl.cpp
+++ b/src/drivers/sdl/sdl.cpp
@@ -49,6 +49,33 @@ static void DriverKill(void);
 static int DriverInitialize(FCEUGI *gi);
 int gametype = 0;
 
+char *DriverUsage=
+"--pal x	Use PAL timing.\n\
+--gamegenie x, -g x	Enable emulated Game Genie if x is nonzero.\n\
+--frameskip x	Set # of frames to skip per emulated frame.\n\
+--(x/y)res x, -(x/y) x	Set horizontal/vertical resolution to x for full screen mode.\n\
+--(x/y)scale x	Multiply width/height by x (Real numbers >0 with OpenGL, otherwise integers >0).\n\
+--(x/y)stretch x	Stretch to fill surface on x/y axis (fullscreen, only with OpenGL).\n\
+--bpp x, -b x	Bits per pixel for SDL surface(and video mode in fs). 8, 16, 32.\n\
+--opengl x	Enable OpenGL support if x is nonzero.\n\
+--doublebuf x	Enable SDL double-buffering if x is nonzero.\n\
+--fullscreen x, -f x	Select full screen mode if x is nonzero.\n\
+--color x	?\n\
+--hue x	?\n\
+--tint x	?\n\
+--palette p, -p p	?\n\
+--sound x, -s x	Enable sound if x is nonzero.\n\
+--volume x	Set volume to x%.\n\
+--lowpass x	Enable low-pass filter if x is nonzero.\n\
+--soundrecord s	Record sound to file s.\n\
+--inputcfg, -i	Configure input device(s) on startup.\n\
+--net s, -n s	Connect to server 's' for TCP/IP network play.\n\
+--port x, -p x	Use TCP/IP port x for network play.\
+--user s, -u s	Set the nickname to use in network play.\n\
+--pass s, -w s	Password to use for connecting to the server.\n\
+--netkey s, -k s	Use key 's' to create a unique session for the game loaded.\n\
+--players x, -l x	Set the number of local players.\n";
+
 
 // global configuration object
 Config *g_config;
@@ -342,8 +369,8 @@ static char *s_linuxCompilerString = "g++ " __VERSION__;
 /**
  * Returns the compiler string.
  */
-char *FCEUD_GetCompilerString() {
-    return (char *)s_linuxCompilerString;
+const char *FCEUD_GetCompilerString() {
+    return (const char *)s_linuxCompilerString;
 }
 
 /**
@@ -464,6 +491,29 @@ FCEUD_GetTimeFreq(void)
     return 1000;
 }
 
+/**
+* Prints a textual message without adding a newline at the end.
+*
+* @param text The text of the message.
+* 
+* TODO: This function should have a better name.
+**/
+void FCEUD_Message(const char *text)
+{
+	fputs(text, stdout);
+}
+
+/**
+* Shows an error message in a message box.
+* (For now: prints to stderr.)
+*
+* @param errormsg Text of the error message.
+**/
+void FCEUD_PrintError(const char *errormsg)
+{
+	fprintf(stderr, "%s\n", errormsg);
+}
+
 
 // dummy functions
 
diff --git a/src/drivers/sdl/unix-netplay.cpp b/src/drivers/sdl/unix-netplay.cpp
index d0688e49..4fc43b64 100644
--- a/src/drivers/sdl/unix-netplay.cpp
+++ b/src/drivers/sdl/unix-netplay.cpp
@@ -176,12 +176,12 @@ FCEUD_NetworkConnect(void)
         uint8 md5out[16];
 
         md5_starts(&md5);
-        md5_update(&md5, GameInfo->MD5, 16);
+        md5_update(&md5, (uint8*)&GameInfo->MD5.data, 16);
         md5_update(&md5, (uint8 *)key.c_str(), key.size());
         md5_finish(&md5, md5out);
         memcpy(sendbuf + 4, md5out, 16);
     } else {
-        memcpy(sendbuf + 4, GameInfo->MD5, 16);
+        memcpy(sendbuf + 4, (uint8*)&GameInfo->MD5.data, 16);
     }
 
     if(password.size()) {
diff --git a/src/movie.cpp b/src/movie.cpp
index 4b9c5cc7..41b62c2a 100644
--- a/src/movie.cpp
+++ b/src/movie.cpp
@@ -268,12 +268,13 @@ void LoadFM2(MovieData& movieData, FILE *fp)
 	bool bail = false;
 	for(;;)
 	{
+		bool iswhitespace, isrecchar, isnewline;
 		int c = fgetc(fp);
 		if(c == -1)
 			goto bail;
-		bool iswhitespace = (c==' '||c=='\t');
-		bool isrecchar = (c=='|');
-		bool isnewline = (c==10||c==13);
+		iswhitespace = (c==' '||c=='\t');
+		isrecchar = (c=='|');
+		isnewline = (c==10||c==13);
 		switch(state)
 		{
 		case NEWLINE:
diff --git a/src/utils/SConscript b/src/utils/SConscript
index a0fef7d0..369e2266 100644
--- a/src/utils/SConscript
+++ b/src/utils/SConscript
@@ -4,7 +4,7 @@ endian.cpp
 general.cpp
 md5.cpp
 memory.cpp
-unzip.c
+unzip.cpp
 xstring.cpp
 """)