aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2006-07-27 18:29:14 +0000
committerJohannes Schickel2006-07-27 18:29:14 +0000
commit8a0ec2a3e5f042e38964f20a82429f2e74936eca (patch)
tree7ffb106f59c37cd8105c18981f397702709067b7
parentd9e5134919141fe50ab97399f6951b8d3fc8950c (diff)
downloadscummvm-rg350-8a0ec2a3e5f042e38964f20a82429f2e74936eca.tar.gz
scummvm-rg350-8a0ec2a3e5f042e38964f20a82429f2e74936eca.tar.bz2
scummvm-rg350-8a0ec2a3e5f042e38964f20a82429f2e74936eca.zip
- moving KyraEngine_v3 declaration to newly added kyra3.h
- implements a little bit init stuff - implements some music handling svn-id: r23610
-rw-r--r--engines/kyra/kyra.h43
-rw-r--r--engines/kyra/kyra3.cpp126
-rw-r--r--engines/kyra/kyra3.h95
-rw-r--r--engines/kyra/plugin.cpp1
-rw-r--r--engines/kyra/script.h4
-rw-r--r--engines/kyra/staticres.cpp48
-rw-r--r--engines/kyra/wsamovie.cpp1
7 files changed, 268 insertions, 50 deletions
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index bbb5812bdc..d015c5e708 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -705,7 +705,7 @@ protected:
bool _abortWalkFlag2;
bool _mousePressFlag;
int8 _mouseWheel;
- uint8 _flagsTable[53];
+ uint8 _flagsTable[69];
uint8 *_shapes[377];
uint16 _gameSpeed;
uint16 _tickLength;
@@ -1023,47 +1023,6 @@ public:
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
diff --git a/engines/kyra/kyra3.cpp b/engines/kyra/kyra3.cpp
index 0952c01d62..539c67d1a0 100644
--- a/engines/kyra/kyra3.cpp
+++ b/engines/kyra/kyra3.cpp
@@ -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 @@ KyraEngine_v3::KyraEngine_v3(OSystem *system) : KyraEngine(system) {
_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 @@ int KyraEngine_v3::go() {
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 @@ void KyraEngine_v3::playVQA(const char *name) {
}
}
+#pragma mark -
+
void KyraEngine_v3::playMenuAudioFile() {
debugC(9, kDebugLevelMain, "KyraEngine::playMenuAudioFile()");
if (_soundDigital->isPlaying(_musicSoundChannel))
@@ -202,9 +215,84 @@ void KyraEngine_v3::playMenuAudioFile() {
_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 @@ void KyraEngine_v3::gui_printString(const char *format, int x, int y, int col1,
_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
diff --git a/engines/kyra/kyra3.h b/engines/kyra/kyra3.h
new file mode 100644
index 0000000000..3538d25a12
--- /dev/null
+++ b/engines/kyra/kyra3.h
@@ -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
diff --git a/engines/kyra/plugin.cpp b/engines/kyra/plugin.cpp
index de8864623b..dc98125f74 100644
--- a/engines/kyra/plugin.cpp
+++ b/engines/kyra/plugin.cpp
@@ -20,6 +20,7 @@
*/
#include "kyra/kyra.h"
+#include "kyra/kyra3.h"
#include "common/config-manager.h"
#include "common/file.h"
diff --git a/engines/kyra/script.h b/engines/kyra/script.h
index 28f5170422..72bcb0f4ed 100644
--- a/engines/kyra/script.h
+++ b/engines/kyra/script.h
@@ -46,10 +46,6 @@ struct ScriptState {
int16 stack[61];
};
-enum {
- SCRIPT_INIT = 0
-};
-
class ScriptHelper {
public:
ScriptHelper(KyraEngine *vm);
diff --git a/engines/kyra/staticres.cpp b/engines/kyra/staticres.cpp
index 5a26d2f1f5..03fe9020cc 100644
--- a/engines/kyra/staticres.cpp
+++ b/engines/kyra/staticres.cpp
@@ -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 @@ const char *KyraEngine_v3::_mainMenuStrings[] = {
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
diff --git a/engines/kyra/wsamovie.cpp b/engines/kyra/wsamovie.cpp
index 6e2a2888c9..d2fe5bad2a 100644
--- a/engines/kyra/wsamovie.cpp
+++ b/engines/kyra/wsamovie.cpp
@@ -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"