[Scummvm-cvs-logs] SF.net SVN: scummvm:[41139] scummvm/trunk/engines/sci

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Jun 3 16:09:25 CEST 2009


Revision: 41139
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41139&view=rev
Author:   thebluegr
Date:     2009-06-03 14:09:25 +0000 (Wed, 03 Jun 2009)

Log Message:
-----------
- Moved the engine state and the console to be private members of SciEngine
- Implemented pauseEngineIntern()
- Music now stops and resumes when entering/leaving the debugger

Modified Paths:
--------------
    scummvm/trunk/engines/sci/console.cpp
    scummvm/trunk/engines/sci/console.h
    scummvm/trunk/engines/sci/engine/grammar.cpp
    scummvm/trunk/engines/sci/engine/kevent.cpp
    scummvm/trunk/engines/sci/gfx/operations.cpp
    scummvm/trunk/engines/sci/sci.cpp
    scummvm/trunk/engines/sci/sci.h
    scummvm/trunk/engines/sci/tools.cpp
    scummvm/trunk/engines/sci/vocabulary.cpp

Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/console.cpp	2009-06-03 14:09:25 UTC (rev 41139)
@@ -169,6 +169,16 @@
 Console::~Console() {
 }
 
+void Console::preEnter() {
+	g_EngineState->_sound.sfx_suspend(true);
+	_vm->_mixer->pauseAll(true);
+}
+
+void Console::postEnter() {
+	g_EngineState->_sound.sfx_suspend(false);
+	_vm->_mixer->pauseAll(false);
+}
+
 bool Console::cmdHelp(int argc, const char **argv) {
 	DebugPrintf("\n");
 	DebugPrintf("Variables\n");
@@ -1408,10 +1418,9 @@
 	return true;
 }
 
-// TODO/FIXME: This should be using DebugPrintf
 void _print_address(void * _, reg_t addr) {
 	if (addr.segment)
-		sciprintf("  %04x:%04x\n", PRINT_REG(addr));
+		((SciEngine *)g_engine)->getDebugger()->DebugPrintf("  %04x:%04x\n", PRINT_REG(addr));
 }
 
 bool Console::cmdGCShowReachable(int argc, const char **argv) {

Modified: scummvm/trunk/engines/sci/console.h
===================================================================
--- scummvm/trunk/engines/sci/console.h	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/console.h	2009-06-03 14:09:25 UTC (rev 41139)
@@ -42,6 +42,8 @@
 public:
 	Console(SciEngine *vm);
 	virtual ~Console();
+	void preEnter();
+	void postEnter();
 
 private:
 	// General

Modified: scummvm/trunk/engines/sci/engine/grammar.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/grammar.cpp	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/engine/grammar.cpp	2009-06-03 14:09:25 UTC (rev 41139)
@@ -351,7 +351,7 @@
 	int ntrules_nr;
 	parse_rule_list_t *ntlist = NULL;
 	parse_rule_list_t *tlist, *new_tlist;
-	Sci::Console *con = ((SciEngine *)g_engine)->_console;
+	GUI::Debugger *con = ((SciEngine *)g_engine)->getDebugger();
 
 	for (uint i = 1; i < _parserBranches.size(); i++) { // branch rule 0 is treated specially
 		parse_rule_t *rule = _vbuild_rule(&_parserBranches[i]);
@@ -477,7 +477,7 @@
 }
 
 int Vocabulary::parseGNF(parse_tree_node_t *nodes, const ResultWordList &words, bool verbose) {
-	Sci::Console *con = ((SciEngine *)g_engine)->_console;
+	GUI::Debugger *con = ((SciEngine *)g_engine)->getDebugger();
 	// Get the start rules:
 	parse_rule_list_t *work = _vocab_clone_rule_list_by_id(_parserRules, _parserBranches[0].data[1]);
 	parse_rule_list_t *results = NULL;

Modified: scummvm/trunk/engines/sci/engine/kevent.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kevent.cpp	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/engine/kevent.cpp	2009-06-03 14:09:25 UTC (rev 41139)
@@ -111,7 +111,7 @@
 
 		// track left buttton clicks, if requested
 		if (e.type == SCI_EVT_MOUSE_PRESS && e.data == 1 && debug_track_mouse_clicks) {
-			((SciEngine *)g_engine)->_console->DebugPrintf("Mouse clicked at %d, %d\n", 
+			((SciEngine *)g_engine)->getDebugger()->DebugPrintf("Mouse clicked at %d, %d\n", 
 						s->gfx_state->pointer_pos.x, s->gfx_state->pointer_pos.y);
 		}
 

Modified: scummvm/trunk/engines/sci/gfx/operations.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/operations.cpp	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/gfx/operations.cpp	2009-06-03 14:09:25 UTC (rev 41139)
@@ -1457,8 +1457,8 @@
 			// Debug console
 			if (ev.kbd.flags == Common::KBD_CTRL && ev.kbd.keycode == Common::KEYCODE_d) {	
 				// Open debug console
-				((Sci::SciEngine*)g_engine)->_console->attach();
-				((Sci::SciEngine*)g_engine)->_console->onFrame();
+				((Sci::SciEngine*)g_engine)->getDebugger()->attach();
+				((Sci::SciEngine*)g_engine)->getDebugger()->onFrame();
 
 				// Clear keyboard event
 				input.type = SCI_EVT_NONE;

Modified: scummvm/trunk/engines/sci/sci.cpp
===================================================================
--- scummvm/trunk/engines/sci/sci.cpp	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/sci.cpp	2009-06-03 14:09:25 UTC (rev 41139)
@@ -144,37 +144,37 @@
 	map_MIDI_instruments(_resmgr);
 #endif
 
-	EngineState *gamestate = new EngineState();
-	gamestate->resmgr = _resmgr;
-	gamestate->gfx_state = NULL;
-	gamestate->flags = getFlags();
+	_gamestate = new EngineState();
+	_gamestate->resmgr = _resmgr;
+	_gamestate->gfx_state = NULL;
+	_gamestate->flags = getFlags();
 
 	// Verify that we haven't got an invalid game detection entry
 	if (version < SCI_VERSION_1_EARLY) {
 		// SCI0/SCI01
-		if (gamestate->flags & GF_SCI1_EGA ||
-			gamestate->flags & GF_SCI1_LOFSABSOLUTE ||
-			gamestate->flags & GF_SCI1_NEWDOSOUND) {
+		if (_gamestate->flags & GF_SCI1_EGA ||
+			_gamestate->flags & GF_SCI1_LOFSABSOLUTE ||
+			_gamestate->flags & GF_SCI1_NEWDOSOUND) {
 			error("This game entry is erroneous. It's marked as SCI0/SCI01, but it has SCI1 flags set");
 		}
 	} else if (version >= SCI_VERSION_1_EARLY && version <= SCI_VERSION_1_LATE) {
 		// SCI1
 
-		if (gamestate->flags & GF_SCI0_OLD ||
-			gamestate->flags & GF_SCI0_OLDGFXFUNCS ||
-			gamestate->flags & GF_SCI0_OLDGETTIME) {
+		if (_gamestate->flags & GF_SCI0_OLD ||
+			_gamestate->flags & GF_SCI0_OLDGFXFUNCS ||
+			_gamestate->flags & GF_SCI0_OLDGETTIME) {
 			error("This game entry is erroneous. It's marked as SCI1, but it has SCI0 flags set");
 		}
 	} else if (version == SCI_VERSION_1_1 || version == SCI_VERSION_32) {
-		if (gamestate->flags & GF_SCI1_EGA ||
-			gamestate->flags & GF_SCI1_LOFSABSOLUTE ||
-			gamestate->flags & GF_SCI1_NEWDOSOUND) {
+		if (_gamestate->flags & GF_SCI1_EGA ||
+			_gamestate->flags & GF_SCI1_LOFSABSOLUTE ||
+			_gamestate->flags & GF_SCI1_NEWDOSOUND) {
 			error("This game entry is erroneous. It's marked as SCI1.1/SCI32, but it has SCI1 flags set");
 		}
 
-		if (gamestate->flags & GF_SCI0_OLD ||
-			gamestate->flags & GF_SCI0_OLDGFXFUNCS ||
-			gamestate->flags & GF_SCI0_OLDGETTIME) {
+		if (_gamestate->flags & GF_SCI0_OLD ||
+			_gamestate->flags & GF_SCI0_OLDGFXFUNCS ||
+			_gamestate->flags & GF_SCI0_OLDGETTIME) {
 			error("This game entry is erroneous. It's marked as SCI1.1/SCI32, but it has SCI0 flags set");
 		}
 
@@ -183,11 +183,11 @@
 		error ("Unknown SCI version in game entry");
 	}
 
-	if (script_init_engine(gamestate, version))
+	if (script_init_engine(_gamestate, version))
 		return Common::kUnknownError;
 
 
-	if (game_init(gamestate)) { /* Initialize */
+	if (game_init(_gamestate)) { /* Initialize */
 		warning("Game initialization failed: Aborting...");
 		// TODO: Add an "init failed" error?
 		return Common::kUnknownError;
@@ -195,13 +195,13 @@
 
 	// Set the savegame dir (actually, we set it to a fake value,
 	// since we cannot let the game control where saves are stored)
-	script_set_gamestate_save_dir(gamestate, "/");
+	script_set_gamestate_save_dir(_gamestate, "/");
 
 	GfxState gfx_state;
 	gfx_state.driver = &gfx_driver_scummvm;
 
-	gamestate->animation_granularity = 4;
-	gamestate->gfx_state = &gfx_state;
+	_gamestate->animation_granularity = 4;
+	_gamestate->gfx_state = &gfx_state;
 
 	// Default config:
 	gfx_options_t gfx_options;
@@ -232,25 +232,25 @@
 		return Common::kUnknownError;
 	}
 
-	if (game_init_graphics(gamestate)) { // Init interpreter graphics
+	if (game_init_graphics(_gamestate)) { // Init interpreter graphics
 		warning("Game initialization failed: Error in GFX subsystem. Aborting...");
 		return Common::kUnknownError;
 	}
 
-	if (game_init_sound(gamestate, 0)) {
+	if (game_init_sound(_gamestate, 0)) {
 		warning("Game initialization failed: Error in sound subsystem. Aborting...");
 		return Common::kUnknownError;
 	}
 
 	printf("Emulating SCI version %s\n", versionNames[version]);
 
-	game_run(&gamestate); // Run the game
+	game_run(&_gamestate); // Run the game
 
-	game_exit(gamestate);
-	script_free_engine(gamestate); // Uninitialize game state
-	script_free_breakpoints(gamestate);
+	game_exit(_gamestate);
+	script_free_engine(_gamestate); // Uninitialize game state
+	script_free_breakpoints(_gamestate);
 
-	delete gamestate;
+	delete _gamestate;
 
 	delete _resmgr;
 
@@ -309,8 +309,7 @@
 }
 
 void SciEngine::pauseEngineIntern(bool pause) {
-	// TODO: pause music and game script execution here
-
+	_gamestate->_sound.sfx_suspend(pause);
 	_mixer->pauseAll(pause);
 }
 

Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/sci.h	2009-06-03 14:09:25 UTC (rev 41139)
@@ -159,11 +159,11 @@
 	/** Remove the 'TARGET-' prefix of the given filename, if present. */
 	Common::String unwrapFilename(const Common::String &name) const;
 
-	Console *_console;
-
 private:
 	const SciGameDescription *_gameDescription;
 	ResourceManager *_resmgr;
+	EngineState *_gamestate;
+	Console *_console;
 };
 
 } // End of namespace Sci

Modified: scummvm/trunk/engines/sci/tools.cpp
===================================================================
--- scummvm/trunk/engines/sci/tools.cpp	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/tools.cpp	2009-06-03 14:09:25 UTC (rev 41139)
@@ -70,7 +70,7 @@
 
 	// Display the result suitably
 	if (g_redirect_sciprintf_to_gui)
-		((SciEngine *)g_engine)->_console->DebugPrintf("%s", buf);
+		((SciEngine *)g_engine)->getDebugger()->DebugPrintf("%s", buf);
 	printf("%s", buf);
 
 	free(buf);

Modified: scummvm/trunk/engines/sci/vocabulary.cpp
===================================================================
--- scummvm/trunk/engines/sci/vocabulary.cpp	2009-06-03 14:03:05 UTC (rev 41138)
+++ scummvm/trunk/engines/sci/vocabulary.cpp	2009-06-03 14:09:25 UTC (rev 41139)
@@ -438,7 +438,7 @@
 
 void Vocabulary::printSuffixes() const {
 	char word_buf[256], alt_buf[256];
-	Sci::Console *con = ((SciEngine *)g_engine)->_console;
+	GUI::Debugger *con = ((SciEngine *)g_engine)->getDebugger();
 
 	int i = 0;
 	for (SuffixList::const_iterator suf = _parserSuffixes.begin(); suf != _parserSuffixes.end(); ++suf) {
@@ -453,7 +453,7 @@
 }
 
 void Vocabulary::printParserWords() const {
-	Sci::Console *con = ((SciEngine *)g_engine)->_console;
+	GUI::Debugger *con = ((SciEngine *)g_engine)->getDebugger();
 
 	int j = 0;
 	for (WordMap::iterator i = _parserWords.begin(); i != _parserWords.end(); ++i) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list