[Scummvm-cvs-logs] SF.net SVN: scummvm: [23610] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Thu Jul 27 20:29:29 CEST 2006


Revision: 23610
Author:   lordhoto
Date:     2006-07-27 11:29:14 -0700 (Thu, 27 Jul 2006)
ViewCVS:  http://svn.sourceforge.net/scummvm/?rev=23610&view=rev

Log Message:
-----------
- moving KyraEngine_v3 declaration to newly added kyra3.h
- implements a little bit init stuff
- implements some music handling

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/kyra.h
    scummvm/trunk/engines/kyra/kyra3.cpp
    scummvm/trunk/engines/kyra/plugin.cpp
    scummvm/trunk/engines/kyra/script.h
    scummvm/trunk/engines/kyra/staticres.cpp
    scummvm/trunk/engines/kyra/wsamovie.cpp

Added Paths:
-----------
    scummvm/trunk/engines/kyra/kyra3.h
Modified: scummvm/trunk/engines/kyra/kyra.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra.h	2006-07-27 00:10:20 UTC (rev 23609)
+++ scummvm/trunk/engines/kyra/kyra.h	2006-07-27 18:29:14 UTC (rev 23610)
@@ -705,7 +705,7 @@
 	bool _abortWalkFlag2;
 	bool _mousePressFlag;
 	int8 _mouseWheel;
-	uint8 _flagsTable[53];
+	uint8 _flagsTable[69];
 	uint8 *_shapes[377];
 	uint16 _gameSpeed;
 	uint16 _tickLength;
@@ -1023,47 +1023,6 @@
 	int go();
 };
 
-// maybe subclass KyraEngine_v2 later
-class WSAMovieV3;
-
-class KyraEngine_v3 : public KyraEngine {
-public:
-	KyraEngine_v3(OSystem *system);
-	~KyraEngine_v3();
-	
-	Movie *createWSAMovie();
-	
-	SoundDigital *soundDigital() { return _soundDigital; }
-
-	int setupGameFlags();
-	
-	int go();
-
-	void playVQA(const char *name);
-private:
-	int init();
-
-	SoundDigital *_soundDigital;
-	
-	int _lang;
-	
-	// sound specific
-private:
-	void playMenuAudioFile();
-	
-	int _musicSoundChannel;
-	const char *_menuAudioFile;
-
-	// gui/menu specific
-private:
-	static const char *_mainMenuStrings[];
-	int handleMainMenu(WSAMovieV3 *logo);
-	void drawMainMenu(const char * const *strings, int select);
-	void drawMainBox(int x, int y, int w, int h, int fill);
-	
-	void gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...);
-};
-
 } // End of namespace Kyra
 
 #endif

Modified: scummvm/trunk/engines/kyra/kyra3.cpp
===================================================================
--- scummvm/trunk/engines/kyra/kyra3.cpp	2006-07-27 00:10:20 UTC (rev 23609)
+++ scummvm/trunk/engines/kyra/kyra3.cpp	2006-07-27 18:29:14 UTC (rev 23610)
@@ -21,6 +21,7 @@
  */
 
 #include "kyra/kyra.h"
+#include "kyra/kyra3.h"
 #include "kyra/screen.h"
 #include "kyra/wsamovie.h"
 #include "kyra/sound.h"
@@ -38,10 +39,18 @@
 	_soundDigital = 0;
 	_musicSoundChannel = -1;
 	_menuAudioFile = "TITLE1.AUD";
+	_curMusicTrack = -1;
+	_unkPage1 = _unkPage2 = 0;
+	_interfaceCPS1 = _interfaceCPS2 = 0;
 }
 
 KyraEngine_v3::~KyraEngine_v3() {
 	delete _soundDigital;
+	
+	delete [] _unkPage1;
+	delete [] _unkPage2;
+	delete [] _interfaceCPS1;
+	delete [] _interfaceCPS2;
 }
 
 int KyraEngine_v3::setupGameFlags() {
@@ -132,10 +141,12 @@
 		
 		switch (handleMainMenu(logo)) {
 		case 0:
-			//delete logo;
-			//logo = 0;
-			//XXX run game
-			//running = false;
+			delete logo;
+			logo = 0;
+			preinit();
+			realInit();
+			// XXX
+			running = false;
 			break;
 		
 		case 1:
@@ -192,6 +203,8 @@
 	}
 }
 
+#pragma mark -
+
 void KyraEngine_v3::playMenuAudioFile() {
 	debugC(9, kDebugLevelMain, "KyraEngine::playMenuAudioFile()");
 	if (_soundDigital->isPlaying(_musicSoundChannel))
@@ -202,9 +215,84 @@
 	_res->fileHandle(_menuAudioFile, &temp, *handle);
 	if (handle->isOpen()) {
 		_musicSoundChannel = _soundDigital->playSound(handle, true);
+	} else {
+		delete handle;
 	}
 }
 
+void KyraEngine_v3::playMusicTrack(int track, int force) {
+	debugC(9, kDebugLevelMain, "KyraEngine::playMusicTrack(%d, %d)", track, force);
+	
+	// XXX byte_2C87C compare
+	
+	if (_musicSoundChannel != -1 && !_soundDigital->isPlaying(_musicSoundChannel)) {
+		force = 1;
+	} else if (_musicSoundChannel == -1) {
+		force = 1;
+	}
+	
+	if (track == _curMusicTrack && !force)
+		return;
+	
+	stopMusicTrack();
+	
+	if (_musicSoundChannel == -1) {
+		assert(track < _soundListSize && track >= 0);
+
+		Common::File *handle = new Common::File();
+		uint32 temp = 0;
+		_res->fileHandle(_soundList[track], &temp, *handle);
+		if (handle->isOpen()) {
+			_musicSoundChannel = _soundDigital->playSound(handle);
+		} else {
+			delete handle;
+		}
+	}
+	
+	_musicSoundChannel = track;
+}
+
+void KyraEngine_v3::stopMusicTrack() {
+	if (_musicSoundChannel != -1 && _soundDigital->isPlaying(_musicSoundChannel)) {
+		_soundDigital->stopSound(_musicSoundChannel);
+	}
+	
+	_curMusicTrack = -1;
+	_musicSoundChannel = -1;
+}
+
+int KyraEngine_v3::musicUpdate(int forceRestart) {
+	debugC(9, kDebugLevelMain, "KyraEngine::unkUpdate(%d)", forceRestart);
+	
+	static uint32 timer = 0;
+	static uint16 lock = 0;
+
+	if (ABS<int>(_system->getMillis() - timer) > (int)(0x0F * _tickLength)) {
+		timer = _system->getMillis();
+	}
+	
+	if (_system->getMillis() < timer && !forceRestart) {
+		return 1;
+	}
+
+	if (!lock) {
+		lock = 1;
+		if (_musicSoundChannel >= 0) {
+			// XXX sub_1C262 (sound specific. it seems to close some sound resource files in special cases)
+			if (!_soundDigital->isPlaying(_musicSoundChannel)) {
+				if (_curMusicTrack != -1)
+					playMusicTrack(_curMusicTrack, 1);
+			}
+		}
+		lock = 0;
+		timer = _system->getMillis() + 0x0F * _tickLength;
+	}
+	
+	return 1;
+}
+
+#pragma mark -
+
 int KyraEngine_v3::handleMainMenu(WSAMovieV3 *logo) {
 	debugC(9, kDebugLevelMain, "KyraEngine::handleMainMenu(%p)", (const void*)logo);
 	int command = -1;
@@ -400,4 +488,34 @@
 	_screen->printText(string, x, y, col1, col2);
 }
 
+#pragma mark -
+
+void KyraEngine_v3::preinit() {
+	debugC(9, kDebugLevelMain, "KyraEngine::preinit()");
+
+	musicUpdate(0);
+
+	// XXX snd_allocateSoundBuffer?
+	memset(_flagsTable, 0, sizeof(_flagsTable));
+
+	// XXX
+	setGameFlag(0x216);
+	
+	_unkPage1 = new uint8[64000];
+	assert(_unkPage1);
+	
+	musicUpdate(0);
+	musicUpdate(0);
+	
+	_interfaceCPS1 = new uint8[17920];
+	_interfaceCPS2 = new uint8[3840];
+	assert(_interfaceCPS1 && _interfaceCPS2);
+	
+	_screen->setFont(Screen::FID_6_FNT);
+}
+
+void KyraEngine_v3::realInit() {
+	debugC(9, kDebugLevelMain, "KyraEngine::realInit()");
+}
+
 } // end of namespace Kyra

Added: scummvm/trunk/engines/kyra/kyra3.h
===================================================================
--- scummvm/trunk/engines/kyra/kyra3.h	                        (rev 0)
+++ scummvm/trunk/engines/kyra/kyra3.h	2006-07-27 18:29:14 UTC (rev 23610)
@@ -0,0 +1,95 @@
+/* ScummVM - Scumm Interpreter
+ * Copyright (C) 2004-2006 The ScummVM project
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef KYRA_KYRA3_H
+#define KYRA_KYRA3_H
+
+#include "kyra/kyra.h"
+
+namespace Kyra {
+
+// maybe subclass KyraEngine_v2 later
+class WSAMovieV3;
+
+class KyraEngine_v3 : public KyraEngine {
+public:
+	KyraEngine_v3(OSystem *system);
+	~KyraEngine_v3();
+	
+	Movie *createWSAMovie();
+	
+	SoundDigital *soundDigital() { return _soundDigital; }
+
+	int setupGameFlags();
+	
+	int go();
+
+	void playVQA(const char *name);
+private:
+	int init();
+
+	void preinit();
+	void realInit();
+
+	SoundDigital *_soundDigital;
+	
+	int _lang;
+	
+	// sound specific
+private:
+	void playMenuAudioFile();
+	
+	int _musicSoundChannel;
+	const char *_menuAudioFile;
+	
+	static const char *_soundList[];
+	static const int _soundListSize;
+
+	int _curMusicTrack;
+
+	void playMusicTrack(int track, int force);
+	void stopMusicTrack();
+
+	int musicUpdate(int forceRestart);
+
+	// gui/menu specific
+private:
+	static const char *_mainMenuStrings[];
+	int handleMainMenu(WSAMovieV3 *logo);
+	void drawMainMenu(const char * const *strings, int select);
+	void drawMainBox(int x, int y, int w, int h, int fill);
+	
+	void gui_printString(const char *string, int x, int y, int col1, int col2, int flags, ...);
+
+	// unknown
+private:	
+	uint8 *_unkPage1;
+	uint8 *_unkPage2;
+	
+	// interface?
+	uint8 *_interfaceCPS1;
+	uint8 *_interfaceCPS2;
+};
+
+} // end of namespace Kyra
+
+#endif


Property changes on: scummvm/trunk/engines/kyra/kyra3.h
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + "Date Rev Author URL Id"
Name: svn:eol-style
   + native

Modified: scummvm/trunk/engines/kyra/plugin.cpp
===================================================================
--- scummvm/trunk/engines/kyra/plugin.cpp	2006-07-27 00:10:20 UTC (rev 23609)
+++ scummvm/trunk/engines/kyra/plugin.cpp	2006-07-27 18:29:14 UTC (rev 23610)
@@ -20,6 +20,7 @@
  */
 
 #include "kyra/kyra.h"
+#include "kyra/kyra3.h"
 
 #include "common/config-manager.h"
 #include "common/file.h"

Modified: scummvm/trunk/engines/kyra/script.h
===================================================================
--- scummvm/trunk/engines/kyra/script.h	2006-07-27 00:10:20 UTC (rev 23609)
+++ scummvm/trunk/engines/kyra/script.h	2006-07-27 18:29:14 UTC (rev 23610)
@@ -46,10 +46,6 @@
 	int16 stack[61];
 };
 
-enum {
-	SCRIPT_INIT = 0
-};
-
 class ScriptHelper {
 public:
 	ScriptHelper(KyraEngine *vm);

Modified: scummvm/trunk/engines/kyra/staticres.cpp
===================================================================
--- scummvm/trunk/engines/kyra/staticres.cpp	2006-07-27 00:10:20 UTC (rev 23609)
+++ scummvm/trunk/engines/kyra/staticres.cpp	2006-07-27 18:29:14 UTC (rev 23610)
@@ -23,6 +23,7 @@
 #include "common/stdafx.h"
 #include "common/endian.h"
 #include "kyra/kyra.h"
+#include "kyra/kyra3.h"
 #include "kyra/screen.h"
 #include "kyra/resource.h"
 
@@ -1241,4 +1242,51 @@
 	0
 };
 
+const char *KyraEngine_v3::_soundList[] = {
+	"ARREST1.AUD",
+	"BATH1.AUD",
+	"OCEAN1.AUD",
+	"CLOWN1.AUD",
+	"DARM2.AUD",
+	"FALL1M.AUD",
+	"FALL2.AUD",
+	"FISH1.AUD",
+	"FISHWNDR.AUD",
+	"HERMAN1.AUD",
+	"JAIL1.AUD",
+	"JUNGLE1.AUD",
+	"KATHY1.AUD",
+	"NICESINE.AUD",
+	"PEGASUS1.AUD",
+	"PIRATE1.AUD",
+	"PIRATE2.AUD",
+	"PIRATE3.AUD",
+	"POP3.AUD",
+	"PORT1.AUD",
+	"QUEEN1.AUD",
+	"RUINS1.AUD",
+	"SNAKES1.AUD",
+	"SPRING1.AUD",
+	"STATUE1.AUD",
+	"STATUE2.AUD",
+	"TITLE1.AUD",
+	"UNDER1.AUD",
+	"WALKCHP1.AUD",
+	"YANK1.AUD",
+	"ZAN2.AUD",
+	"GROOVE2.AUD",
+	"GROOVE3.AUD",
+	"KING1.AUD",
+	"KING2.AUD",
+	"GROOVE1.AUD",
+	"JAIL2.AUD",
+	"SPIRIT1.AUD",
+	"SPRING1A.AUD",
+	"POP1.AUD",
+	"POP2.AUD",
+	"SQUIRL1.AUD"
+};
+
+const int KyraEngine_v3::_soundListSize = ARRAYSIZE(KyraEngine_v3::_soundList);
+
 } // End of namespace Kyra

Modified: scummvm/trunk/engines/kyra/wsamovie.cpp
===================================================================
--- scummvm/trunk/engines/kyra/wsamovie.cpp	2006-07-27 00:10:20 UTC (rev 23609)
+++ scummvm/trunk/engines/kyra/wsamovie.cpp	2006-07-27 18:29:14 UTC (rev 23610)
@@ -23,6 +23,7 @@
 #include "common/stdafx.h"
 #include "common/endian.h"
 #include "kyra/kyra.h"
+#include "kyra/kyra3.h"
 #include "kyra/screen.h"
 #include "kyra/wsamovie.h"
 


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