[mythtv] [patch] MythGame mame_handeler feedback.

J. Donavan Stanley jdonavan at gorpe.com
Thu Jan 1 10:53:42 EST 2004


This patch clears up some of the issues with getting xmame up and running:

1) Verbose messages added to the rom scanning, most under VB_ALL to 
provide status infromation and error information.  Basicly VB_ALL gives 
you a play by play, VB_GENERAL gives you important stuff.

2) Changed the function to load the catver to return a bool so it can 
report the fact that it failed to open/read the file.

3) Added message boxen for the cases of: Unsupported mame version, 
inability to get the number of supported roms, failure to open catver file.

4) Changed the out of memory handler to return instead of blithing going 
on and trying more.

5) Changed to help text in the setup dialog so that it correctly refers 
to highscores, history and cheat as files not directories.

6) Fixed the command line argument for fullscreen under X11.

This should clear up the issues where the mame handler fails to detect 
roms without any indication of why it failed.  I'll take a look at the 
other handlers once I get the additional emulators needed, and a rom or 
two to test with.


-------------- next part --------------
Index: gamesettings.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythgame/mythgame/gamesettings.cpp,v
retrieving revision 1.5
diff -u -r1.5 gamesettings.cpp
--- gamesettings.cpp	9 Nov 2003 04:34:25 -0000	1.5
+++ gamesettings.cpp	1 Jan 2004 12:39:01 -0000
@@ -77,7 +77,7 @@
         GlobalSetting("MameScoresLocation") {
         setLabel(QObject::tr("MAME hiscores path"));
         setValue("/var/lib/mythgame/highscores");
-        setHelpText(QObject::tr("Directory where MAME hiscores are kept."));
+        setHelpText(QObject::tr("The path to the MAME hiscore.dat file."));
     };
 };
 
@@ -107,8 +107,7 @@
         GlobalSetting("MameHistoryLocation") {
         setLabel(QObject::tr("MAME history path"));
         setValue("/var/lib/mythgame/history");
-        setHelpText(QObject::tr("Directory where MAME history files "
-                    "are kept."));
+        setHelpText(QObject::tr("The path to the MAME history.dat file."));
     };
 };
 
@@ -118,7 +117,7 @@
         GlobalSetting("MameCheatLocation") {
         setLabel(QObject::tr("MAME cheat files path"));
         setValue("");
-        setHelpText(QObject::tr("Directory where MAME cheat files are kept."));
+        setHelpText(QObject::tr("The path to the MAME cheat.dat file."));
     };
 };
 
Index: mamehandler.cpp
===================================================================
RCS file: /var/lib/mythcvs/mythgame/mythgame/mamehandler.cpp,v
retrieving revision 1.23
diff -u -r1.23 mamehandler.cpp
--- mamehandler.cpp	29 Dec 2003 04:29:01 -0000	1.23
+++ mamehandler.cpp	1 Jan 2004 12:39:05 -0000
@@ -79,7 +79,7 @@
         for (tmp_counter = 0; tmp_counter < 16; tmp_counter++) {
                 chip[tmp_counter] = "";
         }
-
+	VERBOSE( VB_ALL, "Checking xmame version" );
         check_xmame_exe();
         if (!xmame_version_ok) {
                 tmp_counter = 0;
@@ -88,10 +88,15 @@
                         tmp_counter++;
                 }
                 supported_games = 0;
+		VERBOSE( VB_GENERAL, "This version of xmame is not supported" );
+		MythPopupBox::showOkPopup(gContext->GetMainWindow(), QObject::tr("Wrong xmame version."),
+				      QObject::tr("This version of xmame is not supported.") );
+
                 return;
         }
 
         /* Get number of supported games */
+	VERBOSE( VB_ALL, "Getting the number of supported games" );
         makecmd_line("-list 2>/dev/null", &vrfycmd, NULL);
         xmame_info = popen(vrfycmd, "r");
 
@@ -108,26 +113,40 @@
         }
         pclose(xmame_info);
 
+	
         if (value)
             supported_games = atoi(value);
-        else
+        else {
+	    VERBOSE( VB_GENERAL, "Failed to get supported roms" );
+	    MythPopupBox::showOkPopup(gContext->GetMainWindow(), QObject::tr("Failed to get supported roms."),
+				      QObject::tr("MythTV was unable to retrieve the number of supported roms.\nIs your path to xame correct?") );
+	    
             return;
-
-        /* Generate the list */
+	}
+	
+	
+        
+	/* Generate the list */
+	VERBOSE( VB_ALL, QString("This version of xmame supports %1 roms... Getting a list of them.").arg(supported_games));
         makecmd_line("-listinfo 2>/dev/null", &infocmd, NULL);
         xmame_info = popen(infocmd, "r");
 
+	VERBOSE( VB_ALL, "Verifying the installed roms." );
         makecmd_line("-verifyroms 2>/dev/null", &vrfycmd, NULL);
         xmame_vrfy = popen(vrfycmd, "r");
 
+	VERBOSE( VB_ALL, "Getting the list of source files associated with the various roms." );
         makecmd_line("-listsourcefile 2>/dev/null", &drvcmd, NULL);
         xmame_drv = popen(drvcmd, "r");
 
         map<QString, QString> CatMap;
-        LoadCatfile(&CatMap);
- 
-        MythProgressDialog pdial(QObject::tr("Looking for Mame games..."), 
-			supported_games);
+        if( !LoadCatfile(&CatMap) ) {
+	    MythPopupBox::showOkPopup(gContext->GetMainWindow(), QObject::tr("Failed to read catver.ini"),
+				      QObject::tr( "MythTV was unable to read catver.ini.\nPlease enter the correct path and try again.") );
+
+	}
+	VERBOSE( VB_ALL, "Looking for roms..." );
+        MythProgressDialog pdial(QObject::tr("Looking for Mame games..."), supported_games);
 
         while (fgets(line, 500, xmame_info)) {
                 if (!strncmp(line, "game (", 6)) {
@@ -196,7 +215,7 @@
                         while (TRUE) {
                                 if (!fgets(line, 500, xmame_vrfy))
                                 {
-                                        cout << "breaking\n";
+				    VERBOSE( VB_ALL, "breaking" );
                                         break;
                                 }
                                 if (strstr(line, "romset")) {
@@ -255,10 +274,12 @@
                                         }
                                 }
                         }
+			VERBOSE( VB_ALL, QString("Found $1 ($2)").arg(romname).arg(gamename));
                         rom = new MameRomInfo();
                         if (!rom)
                         {
-                            cout << "Out of memory while generating gamelist";
+                            VERBOSE( VB_GENERAL, "Out of memory while generating gamelist" );
+			    return;
                         }
 
                         /* Setting som default values */
@@ -399,7 +420,8 @@
                 }
 
         }
-
+	VERBOSE( VB_ALL, "Finished rom scan. Cleaning up" );
+	VERBOSE( VB_ALL, "If the rom scan didn't detect any roms make sure your history,and high score point to FILES not directories." ); 
         pdial.Close();
 
         pclose(xmame_info);
@@ -711,7 +733,7 @@
 
         if (!strcmp(general_prefs.xmame_display_target, "x11")) {
                 fullscreen = (game_settings.fullscreen == 1) ? " -x11-mode 1" :
-                             " -fullscreen";
+                             " -x11-mode 3";
                 windowed = " -x11-mode 0";
                 winkeys = " -winkeys";
                 nowinkeys = " -nowinkeys";
@@ -991,12 +1013,13 @@
     return new MameRomInfo(*parent);
 }
 
-void MameHandler::LoadCatfile(map<QString, QString>* pCatMap)
+bool MameHandler::LoadCatfile(map<QString, QString>* pCatMap)
 {
     QString CatFile = gContext->GetSetting("XMameCatFile");
+    VERBOSE( VB_GENERAL, QString( "Loading xmame catfile from %1..." ).arg(CatFile));
     fstream fin(CatFile.ascii(), ios::in);
     if (!fin.is_open())
-        return;
+        return false;
 
     string strLine;
     QString strKey;
@@ -1018,6 +1041,7 @@
             }
         }
     }
+    return true;
 }   
 
 MameHandler* MameHandler::pInstance = 0;
Index: mamehandler.h
===================================================================
RCS file: /var/lib/mythcvs/mythgame/mythgame/mamehandler.h,v
retrieving revision 1.7
diff -u -r1.7 mamehandler.h
--- mamehandler.h	29 Jul 2003 02:02:40 -0000	1.7
+++ mamehandler.h	1 Jan 2004 12:39:06 -0000
@@ -37,7 +37,7 @@
     void SetGeneralPrefs();
     void SetGameSettings(GameSettings &game_settings, MameRomInfo *rominfo);
     void SetDefaultSettings();
-    void LoadCatfile(map<QString, QString>* pCatMap);
+    bool LoadCatfile(map<QString, QString>* pCatMap);
 
     GameSettings defaultSettings;
     bool xmame_version_ok;


More information about the mythtv-dev mailing list