[Scummvm-cvs-logs] SF.net SVN: scummvm:[46421] scummvm/trunk/engines/sci
thebluegr at users.sourceforge.net
thebluegr at users.sourceforge.net
Sat Dec 19 17:19:53 CET 2009
Revision: 46421
http://scummvm.svn.sourceforge.net/scummvm/?rev=46421&view=rev
Author: thebluegr
Date: 2009-12-19 16:19:53 +0000 (Sat, 19 Dec 2009)
Log Message:
-----------
- Started wrapping the current sound code around appropriate defines
- Introduced a new resource type, SoundResource, used in the new music code
Modified Paths:
--------------
scummvm/trunk/engines/sci/console.cpp
scummvm/trunk/engines/sci/engine/game.cpp
scummvm/trunk/engines/sci/engine/kgraphics.cpp
scummvm/trunk/engines/sci/engine/ksound.cpp
scummvm/trunk/engines/sci/engine/state.h
scummvm/trunk/engines/sci/engine/vm.cpp
scummvm/trunk/engines/sci/resource.cpp
scummvm/trunk/engines/sci/resource.h
scummvm/trunk/engines/sci/sci.h
Modified: scummvm/trunk/engines/sci/console.cpp
===================================================================
--- scummvm/trunk/engines/sci/console.cpp 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/console.cpp 2009-12-19 16:19:53 UTC (rev 46421)
@@ -40,8 +40,10 @@
#include "sci/gfx/gfx_state_internal.h"
#include "sci/gfx/gfx_widgets.h" // for getPort
#endif
+#ifdef USE_OLD_MUSIC_FUNCTIONS
#include "sci/sfx/songlib.h" // for SongLibrary
#include "sci/sfx/iterator.h" // for SCI_SONG_ITERATOR_TYPE_SCI0
+#endif
#include "sci/sfx/softseq/mididriver.h"
#include "sci/vocabulary.h"
#include "sci/gui/gui.h"
@@ -204,14 +206,18 @@
}
void Console::preEnter() {
+#ifdef USE_OLD_MUSIC_FUNCTIONS
if (_vm->_gamestate)
_vm->_gamestate->_sound.sfx_suspend(true);
+#endif
_vm->_mixer->pauseAll(true);
}
void Console::postEnter() {
+#ifdef USE_OLD_MUSIC_FUNCTIONS
if (_vm->_gamestate)
_vm->_gamestate->_sound.sfx_suspend(false);
+#endif
_vm->_mixer->pauseAll(false);
if (!_videoFile.empty()) {
@@ -1602,6 +1608,7 @@
bool Console::cmdSongLib(int argc, const char **argv) {
DebugPrintf("Song library:\n");
+#ifdef USE_OLD_MUSIC_FUNCTIONS
Song *seeker = _vm->_gamestate->_sound._songlib._lib;
do {
@@ -1614,6 +1621,7 @@
DebugPrintf("\n");
} while (seeker);
DebugPrintf("\n");
+#endif
return true;
}
@@ -2523,6 +2531,7 @@
return true;
}
+#ifdef USE_OLD_MUSIC_FUNCTIONS
Resource *song = _vm->getResourceManager()->findResource(ResourceId(kResourceTypeSound, atoi(argv[1])), 0);
SongIterator *songit;
Audio::AudioStream *data;
@@ -2550,6 +2559,7 @@
DebugPrintf("Valid song, but not a sample.\n");
delete songit;
+#endif
return true;
}
@@ -2757,6 +2767,7 @@
return true;
}
+#ifdef USE_OLD_MUSIC_FUNCTIONS
int handle = id.segment << 16 | id.offset; // frobnicate handle
if (id.segment) {
@@ -2767,6 +2778,7 @@
PUT_SEL32V(segMan, id, nodePtr, 0);
PUT_SEL32V(segMan, id, handle, 0);
}
+#endif
return true;
}
Modified: scummvm/trunk/engines/sci/engine/game.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/game.cpp 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/engine/game.cpp 2009-12-19 16:19:53 UTC (rev 46421)
@@ -292,11 +292,13 @@
#endif
int game_init_sound(EngineState *s, int sound_flags) {
+#ifdef USE_OLD_MUSIC_FUNCTIONS
if (getSciVersion() > SCI_VERSION_0_LATE)
sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
s->sfx_init_flags = sound_flags;
s->_sound.sfx_init(s->resMan, sound_flags);
+#endif
return 0;
}
@@ -417,8 +419,10 @@
s->_menubar = new Menubar(); // Create menu bar
#endif
+#ifdef USE_OLD_MUSIC_FUNCTIONS
if (s->sfx_init_flags & SFX_STATE_FLAG_NOSOUND)
game_init_sound(s, 0);
+#endif
// Load game language into printLang property of game object
s->getLanguage();
@@ -429,11 +433,13 @@
int game_exit(EngineState *s) {
s->_executionStack.clear();
+#ifdef USE_OLD_MUSIC_FUNCTIONS
if (!s->successor) {
s->_sound.sfx_exit();
// Reinit because some other code depends on having a valid state
game_init_sound(s, SFX_STATE_FLAG_NOSOUND);
}
+#endif
// Note: It's a bad idea to delete the segment manager here
// when loading a game.
Modified: scummvm/trunk/engines/sci/engine/kgraphics.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kgraphics.cpp 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/engine/kgraphics.cpp 2009-12-19 16:19:53 UTC (rev 46421)
@@ -956,7 +956,9 @@
bool cycle = (argc > 1) ? ((argv[1].toUint16()) ? true : false) : false;
// Take care of incoming events (kAnimate is called semi-regularly)
+#ifdef USE_OLD_MUSIC_FUNCTIONS
process_sound_events(s);
+#endif
s->_gui->animate(castListReference, cycle, argc, argv);
Modified: scummvm/trunk/engines/sci/engine/ksound.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/ksound.cpp 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/engine/ksound.cpp 2009-12-19 16:19:53 UTC (rev 46421)
@@ -25,7 +25,6 @@
#include "sci/sci.h"
#include "sci/engine/state.h"
-#include "sci/sfx/iterator.h"
#include "sci/sfx/soundcmd.h"
#include "sci/engine/kernel.h"
#include "sci/engine/vm.h" // for Object
Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/engine/state.h 2009-12-19 16:19:53 UTC (rev 46421)
@@ -43,7 +43,9 @@
#include "sci/engine/seg_manager.h"
#include "sci/gfx/gfx_system.h"
#include "sci/sfx/audio.h"
+#ifdef USE_OLD_MUSIC_FUNCTIONS
#include "sci/sfx/core.h"
+#endif
#include "sci/sfx/soundcmd.h"
namespace Sci {
@@ -149,7 +151,9 @@
GfxState *gfx_state; /**< Graphics state and driver */
AudioPlayer *_audio;
+#ifdef USE_OLD_MUSIC_FUNCTIONS
SfxState _sound; /**< sound subsystem */
+#endif
SoundCommandParser *_soundCmd;
int sfx_init_flags; /**< flags the sfx subsystem was initialised with */
Modified: scummvm/trunk/engines/sci/engine/vm.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/vm.cpp 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/engine/vm.cpp 2009-12-19 16:19:53 UTC (rev 46421)
@@ -1797,7 +1797,9 @@
game_exit(s);
script_init_engine(s);
game_init(s);
+#ifdef USE_OLD_MUSIC_FUNCTIONS
s->_sound.sfx_reset_player();
+#endif
_init_stack_base_with_selector(s, s->_kernel->_selectorCache.play);
send_selector(s, s->_gameObj, s->_gameObj, s->stack_base, 2, s->stack_base);
Modified: scummvm/trunk/engines/sci/resource.cpp
===================================================================
--- scummvm/trunk/engines/sci/resource.cpp 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/resource.cpp 2009-12-19 16:19:53 UTC (rev 46421)
@@ -1808,4 +1808,85 @@
return offset == res->size;
}
+#ifndef USE_OLD_MUSIC_FUNCTIONS
+
+SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan) : _resMan(resMan) {
+ Resource *res = resNumber ? _resMan->findResource(ResourceId(kResourceTypeSound, resNumber), true) : NULL;
+ if (!res)
+ return;
+
+ _innerResource = res;
+
+ byte *ptr = res->data, *p1;
+ tagChannel *pCh;
+ // count # of tracks
+ nTracks = 0;
+ while ((*ptr++) != 0xFF) {
+ nTracks++;
+ while (*ptr != 0xFF)
+ ptr += 6;
+ ptr++;
+ }
+ aTracks = new tagTrack[nTracks];
+ ptr = res->data;
+ for (int i = 0; i < nTracks; i++) {
+ aTracks[i].type = (kTrackType) * ptr++;
+ // counting # of channels used
+ p1 = ptr;
+ aTracks[i].nChannels = 0;
+ while (*p1 != 0xFF) {
+ p1 += 6;
+ aTracks[i].nChannels++;
+ }
+ aTracks[i].aChannels = new tagChannel[aTracks[i].nChannels];
+ if (aTracks[i].type != 0xF0) // digital track marker - not supported at time
+ {
+ aTracks[i].nDigital = 0xFF; // meanwhile - no ditigal channel associated
+ for (int j = 0; j < aTracks[i].nChannels; j++) {
+ pCh = &aTracks[i].aChannels[j];
+ pCh->unk = READ_LE_UINT16(ptr);
+ pCh->ptr = res->data + READ_LE_UINT16(ptr + 2) + 2;
+ pCh->size = READ_LE_UINT16(ptr + 4) - 2; // not counting channel header
+ pCh->number = *(pCh->ptr - 2);
+ pCh->poly = *(pCh->ptr - 1);
+ pCh->time = pCh->prev = 0;
+ if (pCh->number == 0xFE) // digital channel
+ aTracks[i].nDigital = j;
+ ptr += 6;
+ }
+ }
+ ptr++; // skipping 0xFF that closes channels list
+ }
+ /*
+ digital track ->ptr points to header:
+ [w] sample rate
+ [w] size
+ [w] ? 00 00 maybe compression flag
+ [w] ? size again - decompressed size maybe
+ */
+}
+//----------------------------------------------------
+SoundResource::~SoundResource() {
+ for (int i = 0; i < nTracks; i++)
+ delete[] aTracks[i].aChannels;
+ delete[] aTracks;
+
+ _resMan->unlockResource(_innerResource);
+}
+//----------------------------------------------------
+SoundResource::tagTrack* SoundResource::getTrackByNumber(uint16 number) {
+ if (/*number >= 0 &&*/number < nTracks)
+ return &aTracks[number];
+ return NULL;
+}
+
+SoundResource::tagTrack* SoundResource::getTrackByType(kTrackType type) {
+ for (int i = 0; i < nTracks; i++)
+ if (aTracks[i].type == type)
+ return &aTracks[i];
+ return NULL;
+}
+
+#endif
+
} // End of namespace Sci
Modified: scummvm/trunk/engines/sci/resource.h
===================================================================
--- scummvm/trunk/engines/sci/resource.h 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/resource.h 2009-12-19 16:19:53 UTC (rev 46421)
@@ -427,6 +427,49 @@
void detectSciVersion();
};
+#ifndef USE_OLD_MUSIC_FUNCTIONS
+
+class SoundResource {
+public:
+ enum kTrackType {
+ kTrackAdlib = 0,
+ kTrackGameBlaster = 9,
+ kTrackMT32 = 12,
+ kTrackSpeaker = 18,
+ kTrackTandy = 19
+ };
+
+ struct tagChannel {
+ byte number;
+ byte poly;
+ uint16 unk;
+ uint16 size;
+ byte *ptr;
+ long time;
+ byte prev;
+ };
+
+ struct tagTrack {
+ kTrackType type;
+ byte nDigital;
+ byte nChannels;
+ tagChannel *aChannels;
+ uint sz;
+ };
+public:
+ SoundResource(uint32 resNumber, ResourceManager *resMan);
+ ~SoundResource();
+ tagTrack *getTrackByNumber(uint16 number);
+ tagTrack *getTrackByType(kTrackType type);
+
+private:
+ byte nTracks;
+ tagTrack *aTracks;
+ Resource *_innerResource;
+ ResourceManager *_resMan;
+};
+#endif
+
} // End of namespace Sci
#endif // SCI_SCICORE_RESOURCE_H
Modified: scummvm/trunk/engines/sci/sci.h
===================================================================
--- scummvm/trunk/engines/sci/sci.h 2009-12-19 16:05:47 UTC (rev 46420)
+++ scummvm/trunk/engines/sci/sci.h 2009-12-19 16:19:53 UTC (rev 46421)
@@ -41,9 +41,10 @@
*/
namespace Sci {
-#define INCLUDE_OLDGFX
// Please uncomment this if you want to use oldgui
//#define USE_OLDGFX
+// Uncomment this to use old music functions
+#define USE_OLD_MUSIC_FUNCTIONS
class Console;
struct EngineState;
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