[Scummvm-cvs-logs] CVS: scummvm Makefile,1.40,1.41 Makefile.common,1.3,1.4 gameDetector.cpp,1.40,1.41 gameDetector.h,1.10,1.11 main.cpp,1.9,1.10 readme.txt,1.37,1.38 scumm.h,1.146,1.147 sys.cpp,1.11,1.12

James Brown ender at users.sourceforge.net
Sun Apr 28 13:09:21 CEST 2002


Update of /cvsroot/scummvm/scummvm
In directory usw-pr-cvs1:/tmp/cvs-serv17548

Modified Files:
	Makefile Makefile.common gameDetector.cpp gameDetector.h 
	main.cpp readme.txt scumm.h sys.cpp 
Log Message:
Add config file support. Thanks |Pixel| :)



Index: Makefile
===================================================================
RCS file: /cvsroot/scummvm/scummvm/Makefile,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** Makefile	27 Apr 2002 11:06:27 -0000	1.40
--- Makefile	27 Apr 2002 16:58:28 -0000	1.41
***************
*** 1,5 ****
  # $Header$
  
! CC      = gcc
  CFLAGS  = -g -O -Wall -Wstrict-prototypes -Wuninitialized -Wno-long-long -Wno-multichar 
  DEFINES = -DUNIX
--- 1,5 ----
  # $Header$
  
! CC      = g++
  CFLAGS  = -g -O -Wall -Wstrict-prototypes -Wuninitialized -Wno-long-long -Wno-multichar 
  DEFINES = -DUNIX

Index: Makefile.common
===================================================================
RCS file: /cvsroot/scummvm/scummvm/Makefile.common,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Makefile.common	27 Apr 2002 11:06:27 -0000	1.3
--- Makefile.common	27 Apr 2002 16:58:28 -0000	1.4
***************
*** 13,17 ****
  	akos.o vars.o insane.o gameDetector.o init.o \
  	v3/resource_v3.o v4/resource_v4.o 2xsai.o main.o \
! 	simon/midi.o simon/simon.o simon/simonsys.o sound/mididrv.o
  
  DISTFILES=$(OBJS:.o=.cpp) Makefile scumm.h scummsys.h stdafx.h stdafx.cpp \
--- 13,17 ----
  	akos.o vars.o insane.o gameDetector.o init.o \
  	v3/resource_v3.o v4/resource_v4.o 2xsai.o main.o \
! 	simon/midi.o simon/simon.o simon/simonsys.o sound/mididrv.o config-file.o
  
  DISTFILES=$(OBJS:.o=.cpp) Makefile scumm.h scummsys.h stdafx.h stdafx.cpp \

Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gameDetector.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -C2 -d -r1.40 -r1.41
*** gameDetector.cpp	27 Apr 2002 04:31:24 -0000	1.40
--- gameDetector.cpp	27 Apr 2002 16:58:29 -0000	1.41
***************
*** 38,57 ****
  	"\tscummvm [-v] [-d[<num>]] [-n] [-b<num>] [-t<num>] [-s<num>] [-p<path>] [-m<num>] [-f] game\n"
  	"Flags:\n"
! 	"\t-v       - show version info and exit\n"
! 	"\t-c<num>  - use cdrom <num> for cd audio\n"
! 	"\t-d[<num>]- enable debug output (level <num>)\n"
! 	"\t-n       - no subtitles for speech\n"
! 	"\t-b<num>  - start in room <num>\n"
! 	"\t-t<num>  - set music tempo. Suggested: 1F0000\n"
! 	"\t-p<path> - look for game in <path>\n"
! 	"\t-m<num>  - set music volume to <num> (0-100)\n"
! 	"\t-s<num>  - set sfx volume to <num> (0-255)\n"
! 	"\t-e<mode> - set music engine. see readme.txt for details\n"
! 	"\t-r       - emulate roland mt32 instruments\n"
! 	"\t-f       - fullscreen mode\n"
! 	"\t-g<mode> - graphics mode. normal,2x,3x,2xsai,super2xsai,supereagle.advmame2x\n"
! 	"\t-a       - specify game is amiga version\n"
  ;
  
  void GameDetector::parseCommandLine(int argc, char **argv)
  {
--- 38,109 ----
  	"\tscummvm [-v] [-d[<num>]] [-n] [-b<num>] [-t<num>] [-s<num>] [-p<path>] [-m<num>] [-f] game\n"
  	"Flags:\n"
! 	"\t-v        - show version info and exit\n"
! 	"\t-c<num>   - use cdrom <num> for cd audio\n"
! 	"\t-d[<num>] - enable debug output (level <num>)\n"
! 	"\t-n        - no subtitles for speech\n"
! 	"\t-b<num>   - start in room <num>\n"
! 	"\t-t<num>   - set music tempo. Suggested: 1F0000\n"
! 	"\t-p<path>  - look for game in <path>\n"
! 	"\t-m<num>   - set music volume to <num> (0-100)\n"
! 	"\t-s<num>   - set sfx volume to <num> (0-255)\n"
! 	"\t-e<mode>  - set music engine. see readme.txt for details\n"
! 	"\t-r        - emulate roland mt32 instruments\n"
! 	"\t-f        - fullscreen mode\n"
! 	"\t-g<mode>  - graphics mode. normal,2x,3x,2xsai,super2xsai,supereagle.advmame2x\n"
! 	"\t-a        - specify game is amiga version\n"
! 	"\t-w[<file>]- write the config file\n"
! 	"\t-l<file>  - load a different config file\n"
  ;
  
+ void GameDetector::updateconfig()
+ {
+         const char * val;
+ 
+         if ((val = scummcfg->get("amiga")))
+                 if (!scumm_stricmp(val, "true"))
+                         _amiga = true;
+                 else
+                         _amiga = false;
+ 
+         if ((val = scummcfg->get("fullscreen", "scummvm")))
+                 if (!scumm_stricmp(val, "true"))
+                         _fullScreen = true;
+                 else
+                         _fullScreen = false;
+ 
+         if ((val = scummcfg->get("path")))
+                 _gameDataPath = Scumm::Strdup(val);
+ 
+         if ((val = scummcfg->get("tempo")))
+                 _gameTempo = strtol(val, 0, 0);
+ 
+         if ((val = scummcfg->get("music_volume")))
+                 _music_volume = atoi(val);
+ 
+         if ((val = scummcfg->get("sfx_volume")))
+                 _sfx_volume = atoi(val);
+ 
+         if ((val = scummcfg->get("mt32emulate")))
+                 if (!scumm_stricmp(val, "true"))
+                         _mt32emulate = true;
+                 else
+                         _mt32emulate = false;
+ 
+         if ((val = scummcfg->get("music_driver")))
+                 if (!parseMusicDriver(val)) {
+                         printf(USAGE_STRING);
+                         exit(-1);
+                 }
+ 
+         if ((val = scummcfg->get("gfx_mode")))
+                 if ((_gfx_mode = parseGraphicsMode(val)) == -1) {
+                     printf(USAGE_STRING);
+                     exit(-1);
+                 }
+ 
+         if ((val = scummcfg->get("cdrom")))
+                 _cdrom = atoi(val);
+ }
+ 
  void GameDetector::parseCommandLine(int argc, char **argv)
  {
***************
*** 66,69 ****
--- 118,122 ----
  	}
  
+ 	scummcfg->set_domain("game-specific");
  	/* Parse the arguments */
  	for (i = 1; i < argc; i++) {
***************
*** 76,79 ****
--- 129,133 ----
  				case 'a':
  					_amiga = true;
+ 					scummcfg->set("amiga", "true");
  					break;
  				case 'b':
***************
*** 88,91 ****
--- 142,146 ----
  						goto ShowHelpAndExit;
  					_cdrom = atoi(s);
+ 					scummcfg->set("cdrom", _cdrom);
  					goto NextArg;
  				case 'd':
***************
*** 100,124 ****
  					if (!parseMusicDriver(s))
  						goto ShowHelpAndExit;
  					goto NextArg;
  				case 'f':
  					_fullScreen = true;
  					break;
! 				case 'g': {
! 						s = GET_VALUE();
! 						int gfx_mode = parseGraphicsMode(s);
! 						if (gfx_mode == -1)
! 							goto ShowHelpAndExit;
! 						_gfx_mode = gfx_mode;
! 					}
  					goto NextArg;
- 				case 'm':{
- 						s = GET_VALUE();
- 						if (*s == '\0')
- 							goto ShowHelpAndExit;
- 						_music_volume = atoi(s);
- 						goto NextArg;
- 					}
  				case 'n':
  					_noSubtitles = true;
  					break;
  				case 'p':
--- 155,191 ----
  					if (!parseMusicDriver(s))
  						goto ShowHelpAndExit;
+ 					scummcfg->set("music_driver", s);
  					goto NextArg;
  				case 'f':
  					_fullScreen = true;
+ 					scummcfg->set("fullscreen", "true", "scummvm");
  					break;
! 				case 'g':
! 					s = GET_VALUE();
! 					_gfx_mode = parseGraphicsMode(s);
! 					if (_gfx_mode == -1)
! 						goto ShowHelpAndExit;
! 					scummcfg->set("gfx_mode", _gfx_mode, "scummvm");
! 					goto NextArg;
! 				case 'l':
! 				    s = GET_VALUE();
! 				    if (*s != '\0') {
! 					    Config * newconfig = new Config(s, "scummvm");
! 					    scummcfg->merge_config(newconfig);
! 					    delete newconfig;
! 					    updateconfig();
! 					    goto NextArg;
! 				    } else
! 					    goto ShowHelpAndExit;
! 				case 'm':
! 					s = GET_VALUE();
! 					if (*s == '\0')
! 						goto ShowHelpAndExit;
! 					_music_volume = atoi(s);
! 					scummcfg->set("music_volume", _music_volume, "scummvm");
  					goto NextArg;
  				case 'n':
  					_noSubtitles = true;
+ 					scummcfg->set("nosubtitles", "true");
  					break;
  				case 'p':
***************
*** 127,147 ****
  						goto ShowHelpAndExit;
  					_gameDataPath = s;
   					goto NextArg;
! 				case 'r':{
! 						_mt32emulate = true;
! 						break;
! 					}
! 				case 's':{
! 						s = GET_VALUE();
! 						if (*s == '\0')
! 							goto ShowHelpAndExit;
! 						_sfx_volume = atoi(s);
! 						goto NextArg;
! 					}
  				case 't':
  					s = GET_VALUE();
  					if (*s == '\0')
  						goto ShowHelpAndExit;
! 					_gameTempo = atoi(s);
  					goto NextArg;
  				case 'v':
--- 194,216 ----
  						goto ShowHelpAndExit;
  					_gameDataPath = s;
+ 					scummcfg->set("path", _gameDataPath);
   					goto NextArg;
! 				case 'r':
! 					_mt32emulate = true;
! 					scummcfg->set("mt32emulate", "true");
! 					break;
! 				case 's':
! 					s = GET_VALUE();
! 					if (*s == '\0')
! 						goto ShowHelpAndExit;
! 					_sfx_volume = atoi(s);
! 					scummcfg->set("sfx_volume", _sfx_volume, "scummvm");
! 					goto NextArg;
  				case 't':
  					s = GET_VALUE();
  					if (*s == '\0')
  						goto ShowHelpAndExit;
! 					_gameTempo = strtol(s + 1, 0, 0);
! 					scummcfg->set("tempo", s + 1);
  					goto NextArg;
  				case 'v':
***************
*** 153,156 ****
--- 222,231 ----
  					exit(1);
  
+ 				case 'w':
+ 					_saveconfig = true;
+ 					s = GET_VALUE();
+ 					if (*s != '\0')
+ 						scummcfg->change_filename(s);
+ 					goto NextArg;
  				default:
  				ShowHelpAndExit:;
***************
*** 164,170 ****
  				goto ShowHelpAndExit;
  			_exe_name = s;
  		}
  	}
! 
  #else
  	_midi_driver = 4; /* FIXME: don't use numerics */
--- 239,250 ----
  				goto ShowHelpAndExit;
  			_exe_name = s;
+ 			scummcfg->rename_domain(s);
+ 			scummcfg->set_domain(s);
+ 			updateconfig();
  		}
  	}
! 	
! 	if (_saveconfig)
! 		scummcfg->flush();
  #else
  	_midi_driver = 4; /* FIXME: don't use numerics */
***************
*** 347,353 ****
  		char buf[256];
  		sprintf(buf, "Unknown game: \"%s\"", _exe_name);
! 		return strdup(buf);
  	}
! 	return strdup(_gameText);
  }
  
--- 427,433 ----
  		char buf[256];
  		sprintf(buf, "Unknown game: \"%s\"", _exe_name);
! 		return Scumm::Strdup(buf);
  	}
! 	return Scumm::Strdup(_gameText);
  }
  
***************
*** 388,391 ****
--- 468,473 ----
  	dc_setup(*this);
  #else
+ 	_saveconfig = false;
+ 	updateconfig();
  	parseCommandLine(argc, argv);
  #endif
***************
*** 414,418 ****
  	if (!_gameDataPath) {
  		warning("No path was provided. Assuming the data files are in the current directory");
! 		_gameDataPath = strdup("");
  	}
  
--- 496,500 ----
  	if (!_gameDataPath) {
  		warning("No path was provided. Assuming the data files are in the current directory");
! 		_gameDataPath = Scumm::Strdup("");
  	}
  

Index: gameDetector.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gameDetector.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** gameDetector.h	17 Apr 2002 03:11:37 -0000	1.10
--- gameDetector.h	27 Apr 2002 16:58:29 -0000	1.11
***************
*** 57,64 ****
--- 57,68 ----
  	int _scummVersion;
  	int _cdrom;
+ 	
+ 	bool _saveconfig;
  
  	int parseGraphicsMode(const char *s);
  
  	bool parseMusicDriver(const char *s);
+ 	
+ 	void updateconfig();
  
  public:

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/main.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** main.cpp	26 Apr 2002 13:16:35 -0000	1.9
--- main.cpp	27 Apr 2002 16:58:29 -0000	1.10
***************
*** 27,30 ****
--- 27,31 ----
  #include "gui.h"
  #include "simon/simon.h"
+ #include "config-file.h"
  
  GameDetector detector;
***************
*** 33,36 ****
--- 34,39 ----
  Scumm *g_scumm;
  
+ Config * scummcfg;
+ 
  
  #if defined(__APPLE__)
***************
*** 40,43 ****
--- 43,48 ----
  #endif
  
+ #define DEFAULT_CONFIG_FILE "scummvm.ini"
+ 
  int main(int argc, char *argv[])
  {
***************
*** 75,79 ****
  
  #endif
! 
  	if (detector.detectMain(argc, argv))
  		return (-1);
--- 80,85 ----
  
  #endif
! 	scummcfg = new Config(DEFAULT_CONFIG_FILE, "scummvm");
! 	scummcfg->set("versioninfo", SCUMMVM_VERSION);
  	if (detector.detectMain(argc, argv))
  		return (-1);
***************
*** 84,88 ****
  		char *s = detector.getGameName();
  		system->property(OSystem::PROP_SET_WINDOW_CAPTION, (long)s);
! 		free(s);
  	}
  
--- 90,94 ----
  		char *s = detector.getGameName();
  		system->property(OSystem::PROP_SET_WINDOW_CAPTION, (long)s);
! 		Scumm::free(s);
  	}
  
***************
*** 108,111 ****
--- 114,119 ----
  		scumm->go();
  	}
+ 	
+ 	delete scummcfg;
  	
  	return 0;

Index: readme.txt
===================================================================
RCS file: /cvsroot/scummvm/scummvm/readme.txt,v
retrieving revision 1.37
retrieving revision 1.38
diff -C2 -d -r1.37 -r1.38
*** readme.txt	27 Apr 2002 10:21:04 -0000	1.37
--- readme.txt	27 Apr 2002 16:58:29 -0000	1.38
***************
*** 177,180 ****
--- 177,184 ----
    C:\Games\LucasArts\scummvm.exe -f -n -pD:\resource\ ft
  
+ Note that if you run the game once this way, and specify the -w commandline
+ parameter (or edit scummvm.ini manually), ScummVM will remember the path,
+ and other settings for this game.
+ 
  The short game name you see at the end of the command line is very
  important. A short list is contained at the top of this file. You can also
***************
*** 192,211 ****
          scummvm [OPTIONS] [GAME]
  
!         [GAME]    - Short name of game to load. E.g. monkey for Monkey Island.
          
!         -p<path>  - Path to where the game is installed. Default is Cwd.
!         -b<num>   - Start in room <num>.
!         -c<num>   - Drive to play cd audio from.  E.g., 0 is first drive.
!         -s<num>   - Set the sfx volume, 0-255.    Default is '100'
!         -m<num>   - Set the music volume, 0-100.  Default is '60'
!         -t<num>   - Set music tempo.              Default is '2031616'
!         -e<mode>  - Select sound engine. See below.
!         -g<mode>  - Select graphics scaler. See below.
!         -f        - Full-screen mode.
!         -n        - Disable subtitles. Use with games that have voice.
!         -r        - Enable Roland conversion. Try if music sounds incorrect.
!         -a        - Enable amiga pal conversion, for playing Amiga versions
!         -d[<num>] - Set debug verbosity to <num>
! 
  
  In game Hot Keys:
--- 196,216 ----
          scummvm [OPTIONS] [GAME]
  
!         [GAME]     - Short name of game to load. E.g. monkey for Monkey Island.
          
!         -p<path>   - Path to where the game is installed. Default is Cwd.
!         -b<num>    - Start in room <num>.
!         -c<num>    - Drive to play cd audio from.  E.g., 0 is first drive.
!         -s<num>    - Set the sfx volume, 0-255.    Default is '100'
!         -m<num>    - Set the music volume, 0-100.  Default is '60'
!         -t<num>    - Set music tempo.              Default is '2031616'
!         -e<mode>   - Select sound engine. See below.
!         -g<mode>   - Select graphics scaler. See below.
!         -f         - Full-screen mode.
!         -n         - Disable subtitles. Use with games that have voice.
!         -r         - Enable Roland conversion. Try if music sounds incorrect.
!         -a         - Enable amiga pal conversion, for playing Amiga versions
!         -d[<num>]  - Set debug verbosity to <num>
!         -w[<file>] - Write configuration file
!         -l<file>   - Load alternate configration file (default: scummvm.ini)
  
  In game Hot Keys:
***************
*** 377,381 ****
          Tim 'realmz'      - Initial MI1 CD music support
          Jonathan 'khalek' - Expert weaver in the Loom
!  
          And to all the contributors, users, and beta testers we've missed.
          Thanks!
--- 382,387 ----
          Tim 'realmz'      - Initial MI1 CD music support
          Jonathan 'khalek' - Expert weaver in the Loom
!         Nicolas Noble     - Config file support
! 
          And to all the contributors, users, and beta testers we've missed.
          Thanks!

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm.h,v
retrieving revision 1.146
retrieving revision 1.147
diff -C2 -d -r1.146 -r1.147
*** scumm.h	27 Apr 2002 07:42:13 -0000	1.146
--- scumm.h	27 Apr 2002 16:58:29 -0000	1.147
***************
*** 23,26 ****
--- 23,27 ----
  #include "system.h"
  #include "sound/mixer.h"
+ #include "config-file.h"
  
  #define SCUMMVM_VERSION "0.2.0 devel"
***************
*** 1338,1342 ****
--- 1339,1345 ----
  
  	static byte *alloc(int size);
+ 	static byte *realloc(void *mem, int size);
  	static void free(void *mem);
+ 	static char *Strdup(const char *);
  
  	/* Version 5 script opcodes */
***************
*** 1848,1851 ****
--- 1851,1856 ----
  extern const byte revBitMask[8];
  //void blitToScreen(Scumm *s, byte *src, int x, int y, int w, int h);
+ 
+ extern Config * scummcfg;
  
  #if defined(__GNUC__)

Index: sys.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sys.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** sys.cpp	11 Apr 2002 17:19:15 -0000	1.11
--- sys.cpp	27 Apr 2002 16:58:29 -0000	1.12
***************
*** 185,188 ****
--- 185,215 ----
  }
  
+ byte *Scumm::realloc(void *mem, int size)
+ {
+ 	byte * me = (byte *) mem;
+ 	if (mem) {
+ 		if (size) {
+ 			me = (byte *) ::realloc((me - 4), size + 4);
+ 			return me + 4;
+ 		} else {
+ 			free(me);
+ 			return NULL;
+ 		}
+ 	} else {
+ 		return alloc(size);
+ 	}
+ }
+ 
+ char *Scumm::Strdup(const char *s)
+ {
+ 	if (s) {
+ 		int l = strlen(s) + 1;
+ 		char * r = (char *) alloc(l);
+ 		memcpy(r, s, l);
+ 		return r;
+ 	}
+ 	return NULL;
+ }
+ 
  bool Scumm::checkFixedDisk()
  {





More information about the Scummvm-git-logs mailing list