mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-25 05:34:27 +00:00
imuse is now compilable
This commit is contained in:
parent
31e4e261a5
commit
8d1ad43bde
@ -26,6 +26,13 @@ OBJS =\
|
|||||||
mixer/mixer.o \
|
mixer/mixer.o \
|
||||||
mixer/rate.o \
|
mixer/rate.o \
|
||||||
mixer/audiostream.o \
|
mixer/audiostream.o \
|
||||||
|
imuse/imuse.o \
|
||||||
|
imuse/imuse_mcmp_mgr.o \
|
||||||
|
imuse/imuse_music.o \
|
||||||
|
imuse/imuse_script.o \
|
||||||
|
imuse/imuse_sndmgr.o \
|
||||||
|
imuse/imuse_tables.o \
|
||||||
|
imuse/imuse_track.o \
|
||||||
actor.o \
|
actor.o \
|
||||||
bitmap.o \
|
bitmap.o \
|
||||||
blocky16.o \
|
blocky16.o \
|
||||||
@ -49,6 +56,7 @@ OBJS =\
|
|||||||
scene.o \
|
scene.o \
|
||||||
screen.o \
|
screen.o \
|
||||||
smush.o \
|
smush.o \
|
||||||
|
sound.o \
|
||||||
textobject.o \
|
textobject.o \
|
||||||
textsplit.o \
|
textsplit.o \
|
||||||
timer.o \
|
timer.o \
|
||||||
|
@ -450,122 +450,42 @@
|
|||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse.cpp"
|
RelativePath="..\..\imuse\imuse.cpp"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse.h"
|
RelativePath="..\..\imuse\imuse.h"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse_mcmp_mgr.cpp"
|
RelativePath="..\..\imuse\imuse_mcmp_mgr.cpp"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse_mcmp_mgr.h"
|
RelativePath="..\..\imuse\imuse_mcmp_mgr.h"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse_music.cpp"
|
RelativePath="..\..\imuse\imuse_music.cpp"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse_script.cpp"
|
RelativePath="..\..\imuse\imuse_script.cpp"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse_sndmgr.cpp"
|
RelativePath="..\..\imuse\imuse_sndmgr.cpp"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse_sndmgr.h"
|
RelativePath="..\..\imuse\imuse_sndmgr.h"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCustomBuildTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse_tables.cpp"
|
RelativePath="..\..\imuse\imuse_tables.cpp"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
<File
|
<File
|
||||||
RelativePath="..\..\imuse\imuse_track.cpp"
|
RelativePath="..\..\imuse\imuse_track.cpp"
|
||||||
>
|
>
|
||||||
<FileConfiguration
|
|
||||||
Name="Debug|Win32"
|
|
||||||
ExcludedFromBuild="TRUE"
|
|
||||||
>
|
|
||||||
<Tool
|
|
||||||
Name="VCCLCompilerTool"
|
|
||||||
/>
|
|
||||||
</FileConfiguration>
|
|
||||||
</File>
|
</File>
|
||||||
</Filter>
|
</Filter>
|
||||||
<File
|
<File
|
||||||
|
@ -23,19 +23,28 @@
|
|||||||
#include "../mixer/mixer.h"
|
#include "../mixer/mixer.h"
|
||||||
#include "../mixer/audiostream.h"
|
#include "../mixer/audiostream.h"
|
||||||
|
|
||||||
|
#include "imuse.h"
|
||||||
#include "imuse_sndmgr.h"
|
#include "imuse_sndmgr.h"
|
||||||
|
|
||||||
|
extern SoundMixer *g_mixer;
|
||||||
|
|
||||||
|
Imuse *g_imuse;
|
||||||
|
|
||||||
Imuse::Track::Track()
|
Imuse::Track::Track()
|
||||||
: soundName(NULL), used(false), stream(NULL) {
|
: used(false), stream(NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::timerHandler(void *refCon) {
|
void Imuse::timerHandler(void *refCon) {
|
||||||
IMuseDigital *imuse = (Imuse *)refCon;
|
Imuse *imuse = (Imuse *)refCon;
|
||||||
imuse->callback();
|
imuse->callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void vimaInit(uint16 *destTable);
|
extern void vimaInit(uint16 *destTable);
|
||||||
extern uint16 imuseDestTable[5786];
|
extern uint16 imuseDestTable[5786];
|
||||||
|
extern ImuseTable grimStateMusicTable[];
|
||||||
|
extern ImuseTable grimSeqMusicTable[];
|
||||||
|
extern ImuseTable grimDemoStateMusicTable[];
|
||||||
|
extern ImuseTable grimDemoSeqMusicTable[];
|
||||||
|
|
||||||
Imuse::Imuse(int fps) {
|
Imuse::Imuse(int fps) {
|
||||||
_mutex = createMutex();
|
_mutex = createMutex();
|
||||||
@ -70,7 +79,6 @@ Imuse::~Imuse() {
|
|||||||
void Imuse::resetState() {
|
void Imuse::resetState() {
|
||||||
_curMusicState = 0;
|
_curMusicState = 0;
|
||||||
_curMusicSeq = 0;
|
_curMusicSeq = 0;
|
||||||
_curMusicCue = 0;
|
|
||||||
memset(_attributes, 0, sizeof(_attributes));
|
memset(_attributes, 0, sizeof(_attributes));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +120,6 @@ void Imuse::callback() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debug(5, "Fade: sound(%s), Vol(%d)", track->soundName, track->vol / 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
|
int pan = (track->pan != 64) ? 2 * track->pan - 127 : 0;
|
||||||
@ -190,23 +197,20 @@ void Imuse::callback() {
|
|||||||
|
|
||||||
void Imuse::switchToNextRegion(Track *track) {
|
void Imuse::switchToNextRegion(Track *track) {
|
||||||
assert(track);
|
assert(track);
|
||||||
debug(5, "switchToNextRegion(track:%d)", track->trackId);
|
|
||||||
|
|
||||||
if (track->trackId >= MAX_IMUSE_TRACKS) {
|
if (track->trackId >= MAX_IMUSE_TRACKS) {
|
||||||
track->toBeRemoved = true;
|
track->toBeRemoved = true;
|
||||||
debug(5, "exit (fadetrack can't go next region) switchToNextRegion(trackId:%d)", track->trackId);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int num_regions = _sound->getNumRegions(track->soundHandle);
|
int numRegions = _sound->getNumRegions(track->soundHandle);
|
||||||
|
|
||||||
if (++track->curRegion == num_regions) {
|
if (++track->curRegion == numRegions) {
|
||||||
track->toBeRemoved = true;
|
track->toBeRemoved = true;
|
||||||
debug(5, "exit (end of regions) switchToNextRegion(track:%d)", track->trackId);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImuseDigiSndMgr::soundStruct *soundHandle = track->soundHandle;
|
ImuseSndMgr::SoundStruct *soundHandle = track->soundHandle;
|
||||||
int jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, track->curHookId);
|
int jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, track->curHookId);
|
||||||
if (jumpId == -1)
|
if (jumpId == -1)
|
||||||
jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, 0);
|
jumpId = _sound->getJumpIdByRegionAndHookId(soundHandle, track->curRegion, 0);
|
||||||
@ -222,11 +226,9 @@ void Imuse::switchToNextRegion(Track *track) {
|
|||||||
Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay);
|
Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay);
|
||||||
fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion);
|
fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion);
|
||||||
fadeTrack->regionOffset = 0;
|
fadeTrack->regionOffset = 0;
|
||||||
debug(5, "switchToNextRegion-sound(%s) select %d region, curHookId: %d", fadeTrack->soundName, fadeTrack->curRegion, fadeTrack->curHookId);
|
|
||||||
fadeTrack->curHookId = 0;
|
fadeTrack->curHookId = 0;
|
||||||
}
|
}
|
||||||
track->curRegion = region;
|
track->curRegion = region;
|
||||||
debug(5, "switchToNextRegion-sound(%s) jump to %d region, curHookId: %d", track->soundName, track->curRegion, track->curHookId);
|
|
||||||
track->curHookId = 0;
|
track->curHookId = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -234,14 +236,11 @@ void Imuse::switchToNextRegion(Track *track) {
|
|||||||
Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay);
|
Track *fadeTrack = cloneToFadeOutTrack(track, fadeDelay);
|
||||||
fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion);
|
fadeTrack->dataOffset = _sound->getRegionOffset(fadeTrack->soundHandle, fadeTrack->curRegion);
|
||||||
fadeTrack->regionOffset = 0;
|
fadeTrack->regionOffset = 0;
|
||||||
debug(5, "switchToNextRegion-sound(%s) select %d region, curHookId: %d", fadeTrack->soundName, fadeTrack->curRegion, fadeTrack->curHookId);
|
|
||||||
}
|
}
|
||||||
track->curRegion = region;
|
track->curRegion = region;
|
||||||
debug(5, "switchToNextRegion-sound(%s) jump to %d region, curHookId: %d", track->soundName, track->curRegion, track->curHookId);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
debug(5, "switchToNextRegion-sound(%s) select %d region, curHookId: %d", track->soundName, track->curRegion, track->curHookId);
|
|
||||||
track->dataOffset = _sound->getRegionOffset(soundHandle, track->curRegion);
|
track->dataOffset = _sound->getRegionOffset(soundHandle, track->curRegion);
|
||||||
track->regionOffset = 0;
|
track->regionOffset = 0;
|
||||||
}
|
}
|
||||||
|
@ -21,15 +21,27 @@
|
|||||||
#include "../stdafx.h"
|
#include "../stdafx.h"
|
||||||
#include "../bits.h"
|
#include "../bits.h"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
#include "imuse.h"
|
|
||||||
#include "imuse_sndmgr.h"
|
|
||||||
|
|
||||||
#include "../mixer/mixer.h"
|
#include "../mixer/mixer.h"
|
||||||
#include "../mixer/audiostream.h"
|
#include "../mixer/audiostream.h"
|
||||||
|
|
||||||
|
#include "imuse_sndmgr.h"
|
||||||
|
#include "imuse_mcmp_mgr.h"
|
||||||
|
|
||||||
#define MAX_IMUSE_TRACKS 8
|
#define MAX_IMUSE_TRACKS 8
|
||||||
#define MAX_IMUSE_FADETRACKS 8
|
#define MAX_IMUSE_FADETRACKS 8
|
||||||
|
|
||||||
|
struct ImuseTable {
|
||||||
|
byte opcode;
|
||||||
|
int16 soundId;
|
||||||
|
byte atribPos;
|
||||||
|
byte hookId;
|
||||||
|
int16 fadeOut60TicksDelay;
|
||||||
|
byte volume;
|
||||||
|
byte pan;
|
||||||
|
char filename[32];
|
||||||
|
};
|
||||||
|
|
||||||
class Imuse {
|
class Imuse {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -61,7 +73,7 @@ private:
|
|||||||
int32 mixerVol;
|
int32 mixerVol;
|
||||||
int32 mixerPan;
|
int32 mixerPan;
|
||||||
|
|
||||||
ImuseSndMgr::soundStruct *soundHandle;
|
ImuseSndMgr::SoundStruct *soundHandle;
|
||||||
PlayingSoundHandle handle;
|
PlayingSoundHandle handle;
|
||||||
AppendableAudioStream *stream;
|
AppendableAudioStream *stream;
|
||||||
|
|
||||||
@ -100,7 +112,7 @@ private:
|
|||||||
|
|
||||||
void setMusicState(int stateId);
|
void setMusicState(int stateId);
|
||||||
void setMusicSequence(int seqId);
|
void setMusicSequence(int seqId);
|
||||||
void playMusic(const char *songName, const ImuseTable *table, int atribPos, bool sequence);
|
void playMusic(const ImuseTable *table, int atribPos, bool sequence);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Imuse(int fps);
|
Imuse(int fps);
|
||||||
@ -130,19 +142,8 @@ public:
|
|||||||
// void parseScriptCmds(int cmd, int soundId, int sub_cmd, int d, int e, int f, int g, int h);
|
// void parseScriptCmds(int cmd, int soundId, int sub_cmd, int d, int e, int f, int g, int h);
|
||||||
void refreshScripts();
|
void refreshScripts();
|
||||||
void flushTracks();
|
void flushTracks();
|
||||||
int getSoundStatus(const char *soundName) const;
|
bool getSoundStatus(const char *soundName) const;
|
||||||
int32 getCurMusicPosInMs();
|
int32 getCurMusicPosInMs();
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ImuseTable {
|
|
||||||
byte opcode;
|
|
||||||
int16 soundId;
|
|
||||||
byte atribPos;
|
|
||||||
byte hookId;
|
|
||||||
int16 fadeOut60TicksDelay;
|
|
||||||
byte volume;
|
|
||||||
byte pan;
|
|
||||||
char filename[32];
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -18,16 +18,12 @@
|
|||||||
#include "../stdafx.h"
|
#include "../stdafx.h"
|
||||||
#include "../bits.h"
|
#include "../bits.h"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
#include "../timer.h"
|
|
||||||
#include "../resource.h"
|
#include "../resource.h"
|
||||||
|
|
||||||
#include "../mixer/mixer.h"
|
|
||||||
#include "../mixer/audiostream.h"
|
|
||||||
|
|
||||||
#include "imuse_mcmp_mgr.h"
|
#include "imuse_mcmp_mgr.h"
|
||||||
#include "imuse_sndmgr.h"
|
|
||||||
|
|
||||||
uint16 imuseDestTable[5786];
|
uint16 imuseDestTable[5786];
|
||||||
|
void decompressVima(const byte *src, int16 *dest, int destLen, uint16 *destTable);
|
||||||
|
|
||||||
McmpMgr::McmpMgr() {
|
McmpMgr::McmpMgr() {
|
||||||
_compTable = NULL;
|
_compTable = NULL;
|
||||||
@ -48,7 +44,7 @@ McmpMgr::~McmpMgr() {
|
|||||||
_compInput = NULL;
|
_compInput = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool McmpMgr::openSound(const char *filename, byte *resPtr, int &offsetData) {
|
bool McmpMgr::openSound(const char *filename, byte **resPtr, int &offsetData) {
|
||||||
_outputSize = 0;
|
_outputSize = 0;
|
||||||
_lastBlock = -1;
|
_lastBlock = -1;
|
||||||
|
|
||||||
@ -61,46 +57,48 @@ bool McmpMgr::openSound(const char *filename, byte *resPtr, int &offsetData) {
|
|||||||
|
|
||||||
uint32 tag;
|
uint32 tag;
|
||||||
fread(&tag, 1, 4, _file);
|
fread(&tag, 1, 4, _file);
|
||||||
tag = MKID_BE32(tag);
|
tag = MKID_BE(tag);
|
||||||
if (tag != MKID_BE('MCMP')) {
|
if (tag != MKID_BE('MCMP')) {
|
||||||
error("McmpMgr::loadCompTable() Expected MCMP tag");
|
error("McmpMgr::loadCompTable() Expected MCMP tag");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
fread(&_numCompItems, 1, 2, _file);
|
fread(&_numCompItems, 1, 2, _file);
|
||||||
_numCompItems = MKID_BE16(_numCompItems);
|
_numCompItems = MKID_BE(_numCompItems);
|
||||||
assert(_numCompItems > 0);
|
assert(_numCompItems > 0);
|
||||||
|
|
||||||
int offset = ftell(_file) + (_numCompItems * 9) + 8;
|
int offset = ftell(_file) + (_numCompItems * 9) + 8;
|
||||||
_numCompItems--;
|
_numCompItems--;
|
||||||
_compTable = (CompTable *)malloc(sizeof(CompTable) * _numCompItems);
|
_compTable = (CompTable *)malloc(sizeof(CompTable) * _numCompItems);
|
||||||
int32 header_size;
|
|
||||||
fseek(_file, 5, SEEK_CUR);
|
fseek(_file, 5, SEEK_CUR);
|
||||||
fread(_compTable[i].decompSize, 1, 4, _file);
|
fread(&_compTable[0].decompSize, 1, 4, _file);
|
||||||
|
|
||||||
int32 maxSize = 0;
|
int32 maxSize = 0;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < _numCompItems; i++) {
|
for (i = 0; i < _numCompItems; i++) {
|
||||||
fread(_compTable[i].codec, 1, 1, _file);
|
fread(&_compTable[i].codec, 1, 1, _file);
|
||||||
fread(_compTable[i].decompSize, 1, 4, _file);
|
fread(&_compTable[i].decompSize, 1, 4, _file);
|
||||||
_compTable[i].decompSize = MKID_BE32(_compTable[i].decompSize);
|
_compTable[i].decompSize = MKID_BE(_compTable[i].decompSize);
|
||||||
fread(_compTable[i].compSize, 1, 4, _file);
|
fread(&_compTable[i].compSize, 1, 4, _file);
|
||||||
_compTable[i].compSize = MKID_BE32(_compTable[i].compSize);
|
_compTable[i].compSize = MKID_BE(_compTable[i].compSize);
|
||||||
_compTable[i].offset = offset;
|
_compTable[i].offset = offset;
|
||||||
offset += _compTable[i].compSize;
|
offset += _compTable[i].compSize;
|
||||||
if (_compTable[i].size > maxSize)
|
if (_compTable[i].compSize > maxSize)
|
||||||
maxSize = _compTable[i].compSize;
|
maxSize = _compTable[i].compSize;
|
||||||
}
|
}
|
||||||
int16 sizeCodecs;
|
int16 sizeCodecs;
|
||||||
fread(&sizeCodecs, 1, 2, _file);
|
fread(&sizeCodecs, 1, 2, _file);
|
||||||
sizeCodecs = MKID_BE16(sizeCodecs);
|
sizeCodecs = MKID_BE(sizeCodecs);
|
||||||
for (i = 0; i < _numCompItems; i++) {
|
for (i = 0; i < _numCompItems; i++) {
|
||||||
_compTable[i].offset += sizeCodecs;
|
_compTable[i].offset += sizeCodecs;
|
||||||
}
|
}
|
||||||
fseek(_file, sizeCodecs, SEEK_CUR);
|
fseek(_file, sizeCodecs, SEEK_CUR);
|
||||||
_compInput = (byte *)malloc(maxSize);
|
_compInput = (byte *)malloc(maxSize);
|
||||||
fread(_compInput, 1, _compTable[0].decompSize);
|
fread(_compInput, 1, _compTable[0].decompSize, _file);
|
||||||
*resPtr = _compInput;
|
*resPtr = _compInput;
|
||||||
offsetData = _compTable[0].compSize;
|
offsetData = _compTable[0].compSize;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 McmpMgr::decompressSample(int32 offset, int32 size, byte **comp_final) {
|
int32 McmpMgr::decompressSample(int32 offset, int32 size, byte **comp_final) {
|
||||||
@ -118,6 +116,7 @@ int32 McmpMgr::decompressSample(int32 offset, int32 size, byte **comp_final) {
|
|||||||
|
|
||||||
first_block = offset / 0x2000;
|
first_block = offset / 0x2000;
|
||||||
last_block = (offset + size - 1) / 0x2000;
|
last_block = (offset + size - 1) / 0x2000;
|
||||||
|
skip = offset % 0x2000;
|
||||||
|
|
||||||
// Clip last_block by the total number of blocks (= "comp items")
|
// Clip last_block by the total number of blocks (= "comp items")
|
||||||
if ((last_block >= _numCompItems) && (_numCompItems > 0))
|
if ((last_block >= _numCompItems) && (_numCompItems > 0))
|
||||||
@ -127,12 +126,10 @@ int32 McmpMgr::decompressSample(int32 offset, int32 size, byte **comp_final) {
|
|||||||
*comp_final = (byte *)malloc(blocks_final_size);
|
*comp_final = (byte *)malloc(blocks_final_size);
|
||||||
final_size = 0;
|
final_size = 0;
|
||||||
|
|
||||||
skip = (offset + header_size) % 0x2000;
|
|
||||||
|
|
||||||
for (i = first_block; i <= last_block; i++) {
|
for (i = first_block; i <= last_block; i++) {
|
||||||
if (_lastBlock != i) {
|
if (_lastBlock != i) {
|
||||||
_file.seek(_compTable[i].offset, SEEK_SET);
|
fseek(_file, _compTable[i].offset, SEEK_SET);
|
||||||
_file.read(_compInput, _compTable[i].compSize);
|
fread(_compInput, 1, _compTable[i].compSize, _file);
|
||||||
decompressVima(_compInput, (int16 *)_compOutput, _compTable[i].decompSize, imuseDestTable);
|
decompressVima(_compInput, (int16 *)_compOutput, _compTable[i].decompSize, imuseDestTable);
|
||||||
_outputSize = _compTable[i].decompSize;
|
_outputSize = _compTable[i].decompSize;
|
||||||
if (_outputSize > 0x2000) {
|
if (_outputSize > 0x2000) {
|
||||||
|
@ -48,17 +48,13 @@ private:
|
|||||||
int _outputSize;
|
int _outputSize;
|
||||||
int _lastBlock;
|
int _lastBlock;
|
||||||
|
|
||||||
bool loadCompTable(int32 index);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
McmpMgr();
|
McmpMgr();
|
||||||
~McmpMgr();
|
~McmpMgr();
|
||||||
|
|
||||||
bool openFile(const char *filename);
|
bool openSound(const char *filename, byte **resPtr, int &offsetData);
|
||||||
int32 decompressSampleByName(const char *name, int32 offset, int32 size, byte **comp_final);
|
int32 decompressSample(int32 offset, int32 size, byte **comp_final);
|
||||||
int32 decompressSampleByIndex(int32 index, int32 offset, int32 size, byte **comp_final, int header_size);
|
|
||||||
int32 decompressSampleByCurIndex(int32 offset, int32 size, byte **comp_final, int header_size);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,15 +19,16 @@
|
|||||||
#include "../bits.h"
|
#include "../bits.h"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
|
|
||||||
|
#include "imuse.h"
|
||||||
|
|
||||||
void Imuse::setMusicState(int stateId) {
|
void Imuse::setMusicState(int stateId) {
|
||||||
int l, num = -1;
|
int l, num = -1;
|
||||||
|
|
||||||
if (stateId == 0)
|
if (stateId == 0)
|
||||||
stateId = 1000;
|
stateId = 1000;
|
||||||
|
|
||||||
for (l = 0; _stateMusicTable[l]->soundId != -1; l++) {
|
for (l = 0; _stateMusicTable[l].soundId != -1; l++) {
|
||||||
if (_stateMusicTable[l]->soundId == stateId) {
|
if (_stateMusicTable[l].soundId == stateId) {
|
||||||
debug(5, "Set music state: %s", _stateMusicTable[l]->filename);
|
|
||||||
num = l;
|
num = l;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -38,7 +39,7 @@ void Imuse::setMusicState(int stateId) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (_curMusicSeq == 0) {
|
if (_curMusicSeq == 0) {
|
||||||
playMusic(_stateMusicTable[num], num, false);
|
playMusic(&_stateMusicTable[num], num, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
_curMusicState = num;
|
_curMusicState = num;
|
||||||
@ -50,9 +51,8 @@ void Imuse::setMusicSequence(int seqId) {
|
|||||||
if (seqId == 0)
|
if (seqId == 0)
|
||||||
seqId = 2000;
|
seqId = 2000;
|
||||||
|
|
||||||
for (l = 0; _seqMusicTable[l]->soundId != -1; l++) {
|
for (l = 0; _seqMusicTable[l].soundId != -1; l++) {
|
||||||
if (_seqMusicTable[l]->soundId == seqId) {
|
if (_seqMusicTable[l].soundId == seqId) {
|
||||||
debug(5, "Set music sequence: %s", _seqMusicTable[l]->filename);
|
|
||||||
num = l;
|
num = l;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -63,16 +63,16 @@ void Imuse::setMusicSequence(int seqId) {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (num != 0) {
|
if (num != 0) {
|
||||||
playMusic(_seqMusicTable[num], 0, true);
|
playMusic(&_seqMusicTable[num], 0, true);
|
||||||
} else {
|
} else {
|
||||||
playMusic(_stateMusicTable[_curMusicState], _curMusicState, true);
|
playMusic(&_stateMusicTable[_curMusicState], _curMusicState, true);
|
||||||
num = 0;
|
num = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
_curMusicSeq = num;
|
_curMusicSeq = num;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::playMusic(const imuseTable *table, int atribPos, bool sequence) {
|
void Imuse::playMusic(const ImuseTable *table, int atribPos, bool sequence) {
|
||||||
int hookId = 0;
|
int hookId = 0;
|
||||||
|
|
||||||
if (atribPos != 0) {
|
if (atribPos != 0) {
|
||||||
@ -100,7 +100,7 @@ void Imuse::playMusic(const imuseTable *table, int atribPos, bool sequence) {
|
|||||||
} else {
|
} else {
|
||||||
fadeOutMusic(table->fadeOut60TicksDelay);
|
fadeOutMusic(table->fadeOut60TicksDelay);
|
||||||
if ((table->opcode == 3) && (!sequence) &&
|
if ((table->opcode == 3) && (!sequence) &&
|
||||||
(table->atribPos != 0) && (table->atribPos == _stateMusicTable[_curMusicState]->atribPos)) {
|
(table->atribPos != 0) && (table->atribPos == _stateMusicTable[_curMusicState].atribPos)) {
|
||||||
if (hookId == 100)
|
if (hookId == 100)
|
||||||
hookId = 0;
|
hookId = 0;
|
||||||
else
|
else
|
||||||
|
@ -23,7 +23,12 @@
|
|||||||
#include "../mixer/mixer.h"
|
#include "../mixer/mixer.h"
|
||||||
#include "../mixer/audiostream.h"
|
#include "../mixer/audiostream.h"
|
||||||
|
|
||||||
|
#include "imuse.h"
|
||||||
#include "imuse_sndmgr.h"
|
#include "imuse_sndmgr.h"
|
||||||
|
|
||||||
|
extern SoundMixer *g_mixer;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void Imuse::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, int g, int h) {
|
void Imuse::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, int g, int h) {
|
||||||
int soundId = b;
|
int soundId = b;
|
||||||
@ -100,11 +105,10 @@ void Imuse::parseScriptCmds(int cmd, int b, int c, int d, int e, int f, int g, i
|
|||||||
default:
|
default:
|
||||||
error("Imuse::doCommand DEFAULT command %d", cmd);
|
error("Imuse::doCommand DEFAULT command %d", cmd);
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
*/
|
|
||||||
void Imuse::flushTracks() {
|
void Imuse::flushTracks() {
|
||||||
debug(5, "flushTracks()");
|
for (int l = 0; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
|
||||||
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
|
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && track->readyToRemove) {
|
if (track->used && track->readyToRemove) {
|
||||||
if (track->stream) {
|
if (track->stream) {
|
||||||
@ -112,7 +116,7 @@ void Imuse::flushTracks() {
|
|||||||
track->stream->finish();
|
track->stream->finish();
|
||||||
}
|
}
|
||||||
if (track->stream->endOfStream()) {
|
if (track->stream->endOfStream()) {
|
||||||
_vm->_mixer->stopHandle(track->handle);
|
g_mixer->stopHandle(track->handle);
|
||||||
delete track->stream;
|
delete track->stream;
|
||||||
track->stream = NULL;
|
track->stream = NULL;
|
||||||
_sound->closeSound(track->soundHandle);
|
_sound->closeSound(track->soundHandle);
|
||||||
@ -125,9 +129,8 @@ void Imuse::flushTracks() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::refreshScripts() {
|
void Imuse::refreshScripts() {
|
||||||
debug(5, "refreshScripts()");
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
||||||
found = true;
|
found = true;
|
||||||
@ -135,28 +138,24 @@ void Imuse::refreshScripts() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!found && (_curMusicSeq != 0)) {
|
if (!found && (_curMusicSeq != 0)) {
|
||||||
debug(5, "refreshScripts() Start Sequence");
|
setMusicSequence(0x1001);
|
||||||
parseScriptCmds(0x1001, 0, 0, 0, 0, 0, 0, 0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::startVoice(const char *soundName) {
|
void Imuse::startVoice(const char *soundName) {
|
||||||
debug(5, "startVoice(%s)", soundName);
|
|
||||||
startSound(soundName, IMUSE_VOLGRP_VOICE, 0, 127, 0, 127);
|
startSound(soundName, IMUSE_VOLGRP_VOICE, 0, 127, 0, 127);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::startMusic(const char *soundName, int hookId, int volume, int pan) {
|
void Imuse::startMusic(const char *soundName, int hookId, int volume, int pan) {
|
||||||
debug(5, "startMusic(%s)", soundName);
|
|
||||||
startSound(soundName, IMUSE_VOLGRP_MUSIC, hookId, volume, pan, 126);
|
startSound(soundName, IMUSE_VOLGRP_MUSIC, hookId, volume, pan, 126);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::startSfx(const char *soundName, int priority) {
|
void Imuse::startSfx(const char *soundName, int priority) {
|
||||||
debug(5, "startSfx(%s)", soundName);
|
|
||||||
startSound(soundName, IMUSE_VOLGRP_SFX, 0, 127, 0, priority);
|
startSound(soundName, IMUSE_VOLGRP_SFX, 0, 127, 0, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 Imuse::getPosInMs(const char *soundName) {
|
int32 Imuse::getPosInMs(const char *soundName) {
|
||||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
||||||
int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->iteration / 200);
|
int32 pos = (5 * (track->dataOffset + track->regionOffset)) / (track->iteration / 200);
|
||||||
@ -168,8 +167,7 @@ int32 Imuse::getPosInMs(const char *soundName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool Imuse::getSoundStatus(const char *soundName) const {
|
bool Imuse::getSoundStatus(const char *soundName) const {
|
||||||
debug(5, "Imuse::getSoundStatus(%s)", soundName);
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (strcmp(track->soundName, soundName) == 0) {
|
if (strcmp(track->soundName, soundName) == 0) {
|
||||||
if (track->handle.isActive() || (track->stream && track->used && !track->readyToRemove)) {
|
if (track->handle.isActive() || (track->stream && track->used && !track->readyToRemove)) {
|
||||||
@ -182,8 +180,7 @@ bool Imuse::getSoundStatus(const char *soundName) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::stopSound(const char *soundName) {
|
void Imuse::stopSound(const char *soundName) {
|
||||||
debug(5, "Imuse::stopSound(%s)", soundName);
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
||||||
track->toBeRemoved = true;
|
track->toBeRemoved = true;
|
||||||
@ -194,7 +191,7 @@ void Imuse::stopSound(const char *soundName) {
|
|||||||
int32 Imuse::getCurMusicPosInMs() {
|
int32 Imuse::getCurMusicPosInMs() {
|
||||||
const char *soundName = NULL;
|
const char *soundName = NULL;
|
||||||
|
|
||||||
for (int l = 0; l < MAX_DIGITAL_TRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
||||||
soundName = track->soundName;
|
soundName = track->soundName;
|
||||||
@ -202,16 +199,13 @@ int32 Imuse::getCurMusicPosInMs() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32 msPos = getPosInMs(soundName);
|
int32 msPos = getPosInMs(soundName);
|
||||||
debug(5, "Imuse::getCurMusicPosInMs(%s) = %d", soundName, msPos);
|
|
||||||
return msPos;
|
return msPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::stopAllSounds() {
|
void Imuse::stopAllSounds() {
|
||||||
debug(5, "Imuse::stopAllSounds");
|
|
||||||
|
|
||||||
for(;;) {
|
for(;;) {
|
||||||
bool foundNotRemoved = false;
|
bool foundNotRemoved = false;
|
||||||
for (int l = 0; l < MAX_DIGITAL_TRACKS + MAX_DIGITAL_FADETRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used) {
|
if (track->used) {
|
||||||
track->toBeRemoved = true;
|
track->toBeRemoved = true;
|
||||||
|
@ -25,10 +25,11 @@
|
|||||||
#include "../mixer/audiostream.h"
|
#include "../mixer/audiostream.h"
|
||||||
|
|
||||||
#include "imuse_sndmgr.h"
|
#include "imuse_sndmgr.h"
|
||||||
|
#include "imuse_mcmp_mgr.h"
|
||||||
|
|
||||||
ImuseSndMgr::ImuseSndMgr(ScummEngine *scumm) {
|
ImuseSndMgr::ImuseSndMgr() {
|
||||||
for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) {
|
for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) {
|
||||||
memset(&_sounds[l], 0, sizeof(soundStruct));
|
memset(&_sounds[l], 0, sizeof(SoundStruct));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,10 +66,10 @@ void ImuseSndMgr::countElements(byte *ptr, int &numRegions, int &numJumps) {
|
|||||||
} while (tag != MKID_BE('DATA'));
|
} while (tag != MKID_BE('DATA'));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImuseSndMgr::parseSoundSound(byte *ptr, soundStruct *sound, int &headerSize) {
|
void ImuseSndMgr::parseSoundHeader(byte *ptr, SoundStruct *sound, int &headerSize) {
|
||||||
if (READ_UINT32(ptr) == MKID('RIFF')) {
|
if (READ_UINT32(ptr) == MKID('RIFF')) {
|
||||||
sound->region = (_region *)malloc(sizeof(_region));
|
sound->region = (Region *)malloc(sizeof(Region));
|
||||||
sound->jump = (_jump *)malloc(0);
|
sound->jump = (Jump *)malloc(0);
|
||||||
sound->numJumps = 0;
|
sound->numJumps = 0;
|
||||||
sound->numRegions = 1;
|
sound->numRegions = 1;
|
||||||
sound->region[0].offset = 0;
|
sound->region[0].offset = 0;
|
||||||
@ -88,9 +89,9 @@ void ImuseSndMgr::parseSoundSound(byte *ptr, soundStruct *sound, int &headerSize
|
|||||||
|
|
||||||
sound->numRegions = 0;
|
sound->numRegions = 0;
|
||||||
sound->numJumps = 0;
|
sound->numJumps = 0;
|
||||||
countElements(ptr, sound->numRegions, sound->numJumps, sound->numSyncs);
|
countElements(ptr, sound->numRegions, sound->numJumps);
|
||||||
sound->region = (_region *)malloc(sizeof(_region) * sound->numRegions);
|
sound->region = (Region *)malloc(sizeof(Region) * sound->numRegions);
|
||||||
sound->jump = (_jump *)malloc(sizeof(_jump) * sound->numJumps);
|
sound->jump = (Jump *)malloc(sizeof(Jump) * sound->numJumps);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
tag = READ_BE_UINT32(ptr); ptr += 4;
|
tag = READ_BE_UINT32(ptr); ptr += 4;
|
||||||
@ -139,7 +140,7 @@ void ImuseSndMgr::parseSoundSound(byte *ptr, soundStruct *sound, int &headerSize
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ImuseSndMgr::soundStruct *ImuseSndMgr::allocSlot() {
|
ImuseSndMgr::SoundStruct *ImuseSndMgr::allocSlot() {
|
||||||
for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) {
|
for (int l = 0; l < MAX_IMUSE_SOUNDS; l++) {
|
||||||
if (!_sounds[l].inUse) {
|
if (!_sounds[l].inUse) {
|
||||||
_sounds[l].inUse = true;
|
_sounds[l].inUse = true;
|
||||||
@ -150,13 +151,12 @@ ImuseSndMgr::soundStruct *ImuseSndMgr::allocSlot() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImuseSndMgr::soundStruct *ImuseSndMgr::openSound(const char *soundName, int volGroupId) {
|
ImuseSndMgr::SoundStruct *ImuseSndMgr::openSound(const char *soundName, int volGroupId) {
|
||||||
assert(oundType);
|
|
||||||
const char *extension = soundName + std::strlen(soundName) - 3;
|
const char *extension = soundName + std::strlen(soundName) - 3;
|
||||||
byte *ptr = NULL;
|
byte *ptr = NULL;
|
||||||
int headerSize = 0;
|
int headerSize = 0;
|
||||||
|
|
||||||
soundStruct *sound = allocSlot();
|
SoundStruct *sound = allocSlot();
|
||||||
if (!sound) {
|
if (!sound) {
|
||||||
error("ImuseSndMgr::openSound() Can't alloc free sound slot");
|
error("ImuseSndMgr::openSound() Can't alloc free sound slot");
|
||||||
}
|
}
|
||||||
@ -165,9 +165,9 @@ ImuseSndMgr::soundStruct *ImuseSndMgr::openSound(const char *soundName, int volG
|
|||||||
sound->volGroupId = volGroupId;
|
sound->volGroupId = volGroupId;
|
||||||
|
|
||||||
if (strcasecmp(extension, "imu") == 0) {
|
if (strcasecmp(extension, "imu") == 0) {
|
||||||
Block *b = getFileBlock(soundName);
|
Block *b = ResourceLoader::instance()->getFileBlock(soundName);
|
||||||
if (b != NULL) {
|
if (b != NULL) {
|
||||||
ptr = b->data();
|
ptr = (byte *)b->data();
|
||||||
delete b;
|
delete b;
|
||||||
parseSoundHeader(ptr, sound, headerSize);
|
parseSoundHeader(ptr, sound, headerSize);
|
||||||
sound->mcmpData = false;
|
sound->mcmpData = false;
|
||||||
@ -178,7 +178,7 @@ ImuseSndMgr::soundStruct *ImuseSndMgr::openSound(const char *soundName, int volG
|
|||||||
}
|
}
|
||||||
} else if (strcasecmp(extension, "wav") == 0 || strcasecmp(extension, "imc") == 0) {
|
} else if (strcasecmp(extension, "wav") == 0 || strcasecmp(extension, "imc") == 0) {
|
||||||
sound->mcmpMgr = new McmpMgr();
|
sound->mcmpMgr = new McmpMgr();
|
||||||
if (!sound->mcmpMgr->openSound(soundName, &ptr)) {
|
if (!sound->mcmpMgr->openSound(soundName, &ptr, headerSize)) {
|
||||||
closeSound(sound);
|
closeSound(sound);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ ImuseSndMgr::soundStruct *ImuseSndMgr::openSound(const char *soundName, int volG
|
|||||||
return sound;
|
return sound;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImuseSndMgr::closeSound(soundStruct *soundHandle) {
|
void ImuseSndMgr::closeSound(SoundStruct *soundHandle) {
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
|
|
||||||
if (soundHandle->mcmpMgr)
|
if (soundHandle->mcmpMgr)
|
||||||
@ -200,16 +200,16 @@ void ImuseSndMgr::closeSound(soundStruct *soundHandle) {
|
|||||||
free(soundHandle->region);
|
free(soundHandle->region);
|
||||||
free(soundHandle->jump);
|
free(soundHandle->jump);
|
||||||
|
|
||||||
memset(soundHandle, 0, sizeof(soundStruct));
|
memset(soundHandle, 0, sizeof(SoundStruct));
|
||||||
}
|
}
|
||||||
|
|
||||||
ImuseSndMgr::soundStruct *ImuseSndMgr::cloneSound(soundStruct *soundHandle) {
|
ImuseSndMgr::SoundStruct *ImuseSndMgr::cloneSound(SoundStruct *soundHandle) {
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
|
|
||||||
return openSound(soundHandle->name, soundHandle->volGroupId);
|
return openSound(soundHandle->name, soundHandle->volGroupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImuseSndMgr::checkForProperHandle(soundStruct *soundHandle) {
|
bool ImuseSndMgr::checkForProperHandle(SoundStruct *soundHandle) {
|
||||||
if (!soundHandle)
|
if (!soundHandle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -221,46 +221,44 @@ bool ImuseSndMgr::checkForProperHandle(soundStruct *soundHandle) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getFreq(soundStruct *soundHandle) {
|
int ImuseSndMgr::getFreq(SoundStruct *soundHandle) {
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
return soundHandle->freq;
|
return soundHandle->freq;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getBits(soundStruct *soundHandle) {
|
int ImuseSndMgr::getBits(SoundStruct *soundHandle) {
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
return soundHandle->bits;
|
return soundHandle->bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getChannels(soundStruct *soundHandle) {
|
int ImuseSndMgr::getChannels(SoundStruct *soundHandle) {
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
return soundHandle->channels;
|
return soundHandle->channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ImuseSndMgr::isEndOfRegion(soundStruct *soundHandle, int region) {
|
bool ImuseSndMgr::isEndOfRegion(SoundStruct *soundHandle, int region) {
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
assert(region >= 0 && region < soundHandle->numRegions);
|
assert(region >= 0 && region < soundHandle->numRegions);
|
||||||
return soundHandle->endFlag;
|
return soundHandle->endFlag;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getNumRegions(soundStruct *soundHandle) {
|
int ImuseSndMgr::getNumRegions(SoundStruct *soundHandle) {
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
return soundHandle->numRegions;
|
return soundHandle->numRegions;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getNumJumps(soundStruct *soundHandle) {
|
int ImuseSndMgr::getNumJumps(SoundStruct *soundHandle) {
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
return soundHandle->numJumps;
|
return soundHandle->numJumps;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getRegionOffset(soundStruct *soundHandle, int region) {
|
int ImuseSndMgr::getRegionOffset(SoundStruct *soundHandle, int region) {
|
||||||
debug(5, "getRegionOffset() region:%d", region);
|
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
assert(region >= 0 && region < soundHandle->numRegions);
|
assert(region >= 0 && region < soundHandle->numRegions);
|
||||||
return soundHandle->region[region].offset;
|
return soundHandle->region[region].offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId) {
|
int ImuseSndMgr::getJumpIdByRegionAndHookId(SoundStruct *soundHandle, int region, int hookId) {
|
||||||
debug(5, "getJumpIdByRegionAndHookId() region:%d, hookId:%d", region, hookId);
|
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
assert(region >= 0 && region < soundHandle->numRegions);
|
assert(region >= 0 && region < soundHandle->numRegions);
|
||||||
int32 offset = soundHandle->region[region].offset;
|
int32 offset = soundHandle->region[region].offset;
|
||||||
@ -274,8 +272,7 @@ int ImuseSndMgr::getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) {
|
int ImuseSndMgr::getRegionIdByJumpId(SoundStruct *soundHandle, int jumpId) {
|
||||||
debug(5, "getRegionIdByJumpId() jumpId:%d", jumpId);
|
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
assert(jumpId >= 0 && jumpId < soundHandle->numJumps);
|
assert(jumpId >= 0 && jumpId < soundHandle->numJumps);
|
||||||
int32 dest = soundHandle->jump[jumpId].dest;
|
int32 dest = soundHandle->jump[jumpId].dest;
|
||||||
@ -288,22 +285,19 @@ int ImuseSndMgr::getRegionIdByJumpId(soundStruct *soundHandle, int jumpId) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getJumpHookId(soundStruct *soundHandle, int number) {
|
int ImuseSndMgr::getJumpHookId(SoundStruct *soundHandle, int number) {
|
||||||
debug(5, "getJumpHookId() number:%d", number);
|
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
assert(number >= 0 && number < soundHandle->numJumps);
|
assert(number >= 0 && number < soundHandle->numJumps);
|
||||||
return soundHandle->jump[number].hookId;
|
return soundHandle->jump[number].hookId;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ImuseSndMgr::getJumpFade(soundStruct *soundHandle, int number) {
|
int ImuseSndMgr::getJumpFade(SoundStruct *soundHandle, int number) {
|
||||||
debug(5, "getJumpFade() number:%d", number);
|
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
assert(number >= 0 && number < soundHandle->numJumps);
|
assert(number >= 0 && number < soundHandle->numJumps);
|
||||||
return soundHandle->jump[number].fadeDelay;
|
return soundHandle->jump[number].fadeDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32 ImuseSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size) {
|
int32 ImuseSndMgr::getDataFromRegion(SoundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size) {
|
||||||
debug(5, "getDataFromRegion() region:%d, offset:%d, size:%d, numRegions:%d", region, offset, size, soundHandle->numRegions);
|
|
||||||
assert(checkForProperHandle(soundHandle));
|
assert(checkForProperHandle(soundHandle));
|
||||||
assert(buf && offset >= 0 && size >= 0);
|
assert(buf && offset >= 0 && size >= 0);
|
||||||
assert(region >= 0 && region < soundHandle->numRegions);
|
assert(region >= 0 && region < soundHandle->numRegions);
|
||||||
@ -318,11 +312,11 @@ int32 ImuseSndMgr::getDataFromRegion(soundStruct *soundHandle, int region, byte
|
|||||||
soundHandle->endFlag = false;
|
soundHandle->endFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sound->mcmpData) {
|
if (soundHandle->mcmpData) {
|
||||||
size = soundHandle->mcmpMgr->decompressSample(region_offset + offset, size, buf);
|
size = soundHandle->mcmpMgr->decompressSample(region_offset + offset, size, buf);
|
||||||
} else {
|
} else {
|
||||||
*buf = (byte *)malloc(size);
|
*buf = (byte *)malloc(size);
|
||||||
memcpy(*buf, soundHandle->resPtr + start + offset, size);
|
memcpy(*buf, soundHandle->resPtr + region_offset + offset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return size;
|
return size;
|
||||||
|
@ -26,6 +26,8 @@
|
|||||||
#include "../mixer/mixer.h"
|
#include "../mixer/mixer.h"
|
||||||
#include "../mixer/audiostream.h"
|
#include "../mixer/audiostream.h"
|
||||||
|
|
||||||
|
class McmpMgr;
|
||||||
|
|
||||||
class ImuseSndMgr {
|
class ImuseSndMgr {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -36,12 +38,12 @@ public:
|
|||||||
#define IMUSE_VOLGRP_MUSIC 3
|
#define IMUSE_VOLGRP_MUSIC 3
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct _region {
|
struct Region {
|
||||||
int32 offset; // offset of region
|
int32 offset; // offset of region
|
||||||
int32 length; // lenght of region
|
int32 length; // lenght of region
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _jump {
|
struct Jump {
|
||||||
int32 offset; // jump offset position
|
int32 offset; // jump offset position
|
||||||
int32 dest; // jump to dest position
|
int32 dest; // jump to dest position
|
||||||
byte hookId; // id of hook
|
byte hookId; // id of hook
|
||||||
@ -50,29 +52,30 @@ private:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct soundStruct {
|
struct SoundStruct {
|
||||||
uint16 freq; // frequency
|
uint16 freq; // frequency
|
||||||
byte channels; // stereo or mono
|
byte channels; // stereo or mono
|
||||||
byte bits; // 8, 12, 16
|
byte bits; // 8, 12, 16
|
||||||
int numJumps; // number of Jumps
|
int numJumps; // number of Jumps
|
||||||
int numRegions; // number of Regions
|
int numRegions; // number of Regions
|
||||||
_region *region;
|
Region *region;
|
||||||
_jump *jump;
|
Jump *jump;
|
||||||
bool endFlag;
|
bool endFlag;
|
||||||
bool inUse;
|
bool inUse;
|
||||||
char name[32];
|
char name[32];
|
||||||
McmpMgr *_mcmpMgr;
|
McmpMgr *mcmpMgr;
|
||||||
int volGroupId;
|
int volGroupId;
|
||||||
byte *resPtr;
|
byte *resPtr;
|
||||||
|
bool mcmpData;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
soundStruct _sounds[MAX_IMUSE_SOUNDS];
|
SoundStruct _sounds[MAX_IMUSE_SOUNDS];
|
||||||
|
|
||||||
bool checkForProperHandle(soundStruct *soundHandle);
|
bool checkForProperHandle(SoundStruct *soundHandle);
|
||||||
soundStruct *allocSlot();
|
SoundStruct *allocSlot();
|
||||||
void parseSoundHeader(byte *ptr, soundStruct *sound, int &headerSize);
|
void parseSoundHeader(byte *ptr, SoundStruct *sound, int &headerSize);
|
||||||
void countElements(byte *ptr, int &numRegions, int &numJumps);
|
void countElements(byte *ptr, int &numRegions, int &numJumps);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -80,23 +83,23 @@ public:
|
|||||||
ImuseSndMgr();
|
ImuseSndMgr();
|
||||||
~ImuseSndMgr();
|
~ImuseSndMgr();
|
||||||
|
|
||||||
soundStruct *openSound(const char *soundName, int volGroupId);
|
SoundStruct *openSound(const char *soundName, int volGroupId);
|
||||||
void closeSound(soundStruct *soundHandle);
|
void closeSound(SoundStruct *soundHandle);
|
||||||
soundStruct *cloneSound(soundStruct *soundHandle);
|
SoundStruct *cloneSound(SoundStruct *soundHandle);
|
||||||
|
|
||||||
int getFreq(soundStruct *soundHandle);
|
int getFreq(SoundStruct *soundHandle);
|
||||||
int getBits(soundStruct *soundHandle);
|
int getBits(SoundStruct *soundHandle);
|
||||||
int getChannels(soundStruct *soundHandle);
|
int getChannels(SoundStruct *soundHandle);
|
||||||
bool isEndOfRegion(soundStruct *soundHandle, int region);
|
bool isEndOfRegion(SoundStruct *soundHandle, int region);
|
||||||
int getNumRegions(soundStruct *soundHandle);
|
int getNumRegions(SoundStruct *soundHandle);
|
||||||
int getNumJumps(soundStruct *soundHandle);
|
int getNumJumps(SoundStruct *soundHandle);
|
||||||
int getRegionOffset(soundStruct *soundHandle, int region);
|
int getRegionOffset(SoundStruct *soundHandle, int region);
|
||||||
int getJumpIdByRegionAndHookId(soundStruct *soundHandle, int region, int hookId);
|
int getJumpIdByRegionAndHookId(SoundStruct *soundHandle, int region, int hookId);
|
||||||
int getRegionIdByJumpId(soundStruct *soundHandle, int jumpId);
|
int getRegionIdByJumpId(SoundStruct *soundHandle, int jumpId);
|
||||||
int getJumpHookId(soundStruct *soundHandle, int number);
|
int getJumpHookId(SoundStruct *soundHandle, int number);
|
||||||
int getJumpFade(soundStruct *soundHandle, int number);
|
int getJumpFade(SoundStruct *soundHandle, int number);
|
||||||
|
|
||||||
int32 getDataFromRegion(soundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size);
|
int32 getDataFromRegion(SoundStruct *soundHandle, int region, byte **buf, int32 offset, int32 size);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
#include "../bits.h"
|
#include "../bits.h"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
|
|
||||||
const ImuseTable grimStateMusicTable[] = {
|
#include "imuse.h"
|
||||||
|
|
||||||
|
ImuseTable grimStateMusicTable[] = {
|
||||||
{0, 1000, 0, 0, 60, 127, 0, ""},
|
{0, 1000, 0, 0, 60, 127, 0, ""},
|
||||||
{0, 1999, 0, 0, 60, 127, 0, ""},
|
{0, 1999, 0, 0, 60, 127, 0, ""},
|
||||||
{3, 1001, 0, 0, 60, 127, 0, "1001 - Manny's Office.IMC" },
|
{3, 1001, 0, 0, 60, 127, 0, "1001 - Manny's Office.IMC" },
|
||||||
@ -204,7 +206,7 @@ const ImuseTable grimStateMusicTable[] = {
|
|||||||
{0, -1, 0, 0, 0, 0, 0, ""}
|
{0, -1, 0, 0, 0, 0, 0, ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ImuseTable grimSeqMusicTable[] = {
|
ImuseTable grimSeqMusicTable[] = {
|
||||||
{0, 2000, 0, 0, 20, 127, 0, ""},
|
{0, 2000, 0, 0, 20, 127, 0, ""},
|
||||||
{2, 2001, 0, 0, 20, 127, 0, "2001 - Climb Rope.IMC"},
|
{2, 2001, 0, 0, 20, 127, 0, "2001 - Climb Rope.IMC"},
|
||||||
{2, 2010, 0, 0, 20, 127, 0, "2010 - Glottis OK.IMC"},
|
{2, 2010, 0, 0, 20, 127, 0, "2010 - Glottis OK.IMC"},
|
||||||
@ -249,7 +251,7 @@ const ImuseTable grimSeqMusicTable[] = {
|
|||||||
{0, -1, 0, 0, 0, 0, 0, ""}
|
{0, -1, 0, 0, 0, 0, 0, ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ImuseTable grimDemoStateMusicTable[] = {
|
ImuseTable grimDemoStateMusicTable[] = {
|
||||||
{0, 0, 0, 0, 60, 127, 0, ""},
|
{0, 0, 0, 0, 60, 127, 0, ""},
|
||||||
{0, 1000, 0, 0, 60, 127, 0, ""},
|
{0, 1000, 0, 0, 60, 127, 0, ""},
|
||||||
{3, 1001, 0, 0, 60, 127, 0, "MO - Manny's Office.IMC"},
|
{3, 1001, 0, 0, 60, 127, 0, "MO - Manny's Office.IMC"},
|
||||||
@ -275,7 +277,7 @@ const ImuseTable grimDemoStateMusicTable[] = {
|
|||||||
{0, -1, 0, 0, 0, 0, 0, ""}
|
{0, -1, 0, 0, 0, 0, 0, ""}
|
||||||
};
|
};
|
||||||
|
|
||||||
const ImuseTable grimDemoSeqMusicTable[] = {
|
ImuseTable grimDemoSeqMusicTable[] = {
|
||||||
{0, 2000, 0, 0, 60, 127, 0, ""},
|
{0, 2000, 0, 0, 60, 127, 0, ""},
|
||||||
{3, 2100, 0, 0, 60, 127, 0, "Rope Climb.IMC"},
|
{3, 2100, 0, 0, 60, 127, 0, "Rope Climb.IMC"},
|
||||||
{0, -1, 0, 0, 0, 0, 0, ""}
|
{0, -1, 0, 0, 0, 0, 0, ""}
|
||||||
|
@ -18,13 +18,16 @@
|
|||||||
#include "../stdafx.h"
|
#include "../stdafx.h"
|
||||||
#include "../bits.h"
|
#include "../bits.h"
|
||||||
#include "../debug.h"
|
#include "../debug.h"
|
||||||
#include "../timer.h"
|
|
||||||
|
|
||||||
#include "../mixer/mixer.h"
|
#include "../mixer/mixer.h"
|
||||||
#include "../mixer/audiostream.h"
|
#include "../mixer/audiostream.h"
|
||||||
|
|
||||||
|
#include "imuse.h"
|
||||||
#include "imuse_sndmgr.h"
|
#include "imuse_sndmgr.h"
|
||||||
|
|
||||||
|
extern SoundMixer *g_mixer;
|
||||||
|
|
||||||
|
|
||||||
int Imuse::allocSlot(int priority) {
|
int Imuse::allocSlot(int priority) {
|
||||||
int l, lowest_priority = 127;
|
int l, lowest_priority = 127;
|
||||||
int trackId = -1;
|
int trackId = -1;
|
||||||
@ -37,7 +40,7 @@ int Imuse::allocSlot(int priority) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (trackId == -1) {
|
if (trackId == -1) {
|
||||||
debug(5, "Imuse::startSound(): All slots are full");
|
warning("Imuse::startSound(): All slots are full");
|
||||||
for (l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
for (l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && !track->toBeRemoved && lowest_priority > track->priority) {
|
if (track->used && !track->toBeRemoved && lowest_priority > track->priority) {
|
||||||
@ -48,9 +51,9 @@ int Imuse::allocSlot(int priority) {
|
|||||||
if (lowest_priority <= priority) {
|
if (lowest_priority <= priority) {
|
||||||
assert(trackId != -1);
|
assert(trackId != -1);
|
||||||
_track[trackId]->toBeRemoved = true;
|
_track[trackId]->toBeRemoved = true;
|
||||||
debug(5, "Imuse::startSound(): Removed sound %s from track %d", _track[trackId]->soundName, trackId);
|
warning("Imuse::startSound(): Removed sound %s from track %d", _track[trackId]->soundName, trackId);
|
||||||
} else {
|
} else {
|
||||||
debug(5, "Imuse::startSound(): Priority sound too low");
|
warning("Imuse::startSound(): Priority sound too low");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -58,9 +61,7 @@ int Imuse::allocSlot(int priority) {
|
|||||||
return trackId;
|
return trackId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::startSound(const char *soundName, int volGroupId, int hookId, int volume, int pan = 64, int priority) {
|
void Imuse::startSound(const char *soundName, int volGroupId, int hookId, int volume, int pan, int priority) {
|
||||||
debug(5, "Imuse::startSound(%s)", soundName);
|
|
||||||
|
|
||||||
int l = allocSlot(priority);
|
int l = allocSlot(priority);
|
||||||
if (l == -1) {
|
if (l == -1) {
|
||||||
warning("Imuse::startSound() Can't start sound - no free slots");
|
warning("Imuse::startSound() Can't start sound - no free slots");
|
||||||
@ -98,7 +99,7 @@ void Imuse::startSound(const char *soundName, int volGroupId, int hookId, int vo
|
|||||||
int bits = 0, freq = 0, channels = 0;
|
int bits = 0, freq = 0, channels = 0;
|
||||||
|
|
||||||
strcpy(track->soundName, soundName);
|
strcpy(track->soundName, soundName);
|
||||||
track->soundHandle = _sound->openSound(soundName, volGroupId, -1);
|
track->soundHandle = _sound->openSound(soundName, volGroupId);
|
||||||
|
|
||||||
if (track->soundHandle == NULL)
|
if (track->soundHandle == NULL)
|
||||||
return;
|
return;
|
||||||
@ -141,13 +142,12 @@ void Imuse::startSound(const char *soundName, int volGroupId, int hookId, int vo
|
|||||||
// setup 1 second stream wrapped buffer
|
// setup 1 second stream wrapped buffer
|
||||||
int32 streamBufferSize = track->iteration;
|
int32 streamBufferSize = track->iteration;
|
||||||
track->stream = makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
|
track->stream = makeAppendableAudioStream(freq, track->mixerFlags, streamBufferSize);
|
||||||
_vm->_mixer->playInputStream(&track->handle, track->stream, false, -1, track->mixerVol, track->mixerPan, false);
|
g_mixer->playInputStream(&track->handle, track->stream, false, -1, track->mixerVol, track->mixerPan, false);
|
||||||
track->started = true;
|
track->started = true;
|
||||||
track->used = true;
|
track->used = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::setPriority(const char *soundName, int priority) {
|
void Imuse::setPriority(const char *soundName, int priority) {
|
||||||
debug(5, "Imuse::setPriority(%s, %d)", soundName, priority);
|
|
||||||
assert ((priority >= 0) && (priority <= 127));
|
assert ((priority >= 0) && (priority <= 127));
|
||||||
|
|
||||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
@ -158,9 +158,7 @@ void Imuse::setPriority(const char *soundName, int priority) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::setVolume(int soundName, int volume) {
|
void Imuse::setVolume(const char *soundName, int volume) {
|
||||||
debug(5, "IMuseDigital::setVolume(%s, %d)", soundName, volume);
|
|
||||||
|
|
||||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
||||||
@ -170,8 +168,6 @@ void Imuse::setVolume(int soundName, int volume) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::setPan(const char *soundName, int pan) {
|
void Imuse::setPan(const char *soundName, int pan) {
|
||||||
debug(5, "Imuse::setPan(%s, %d)", soundName, pan);
|
|
||||||
|
|
||||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
if (track->used && !track->toBeRemoved && (strcmp(track->soundName, soundName) == 0)) {
|
||||||
@ -181,7 +177,6 @@ void Imuse::setPan(const char *soundName, int pan) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::selectVolumeGroup(const char *soundName, int volGroupId) {
|
void Imuse::selectVolumeGroup(const char *soundName, int volGroupId) {
|
||||||
debug(5, "Imuse::setGroupVolume(%s, %d)", soundName, volGroupId);
|
|
||||||
assert((volGroupId >= 1) && (volGroupId <= 4));
|
assert((volGroupId >= 1) && (volGroupId <= 4));
|
||||||
|
|
||||||
if (volGroupId == 4)
|
if (volGroupId == 4)
|
||||||
@ -197,7 +192,6 @@ void Imuse::selectVolumeGroup(const char *soundName, int volGroupId) {
|
|||||||
|
|
||||||
void Imuse::setFade(const char *soundName, int destVolume, int delay60HzTicks) {
|
void Imuse::setFade(const char *soundName, int destVolume, int delay60HzTicks) {
|
||||||
StackLock lock(_mutex);
|
StackLock lock(_mutex);
|
||||||
debug(5, "Imuse::setFade(%s, %d, %d)", soundName, destVolume, delay60HzTicks);
|
|
||||||
|
|
||||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
@ -211,7 +205,6 @@ void Imuse::setFade(const char *soundName, int destVolume, int delay60HzTicks) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Imuse::fadeOutMusic(int fadeDelay) {
|
void Imuse::fadeOutMusic(int fadeDelay) {
|
||||||
debug(5, "Imuse::fadeOutMusic");
|
|
||||||
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
for (int l = 0; l < MAX_IMUSE_TRACKS; l++) {
|
||||||
Track *track = _track[l];
|
Track *track = _track[l];
|
||||||
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
if (track->used && !track->toBeRemoved && (track->volGroupId == IMUSE_VOLGRP_MUSIC)) {
|
||||||
@ -225,8 +218,6 @@ Imuse::Track *Imuse::cloneToFadeOutTrack(Track *track, int fadeDelay) {
|
|||||||
assert(track);
|
assert(track);
|
||||||
Track *fadeTrack = 0;
|
Track *fadeTrack = 0;
|
||||||
|
|
||||||
debug(5, "Imuse::cloneToFadeOutTrack(%d, %d)", track->trackId, fadeDelay);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
StackLock lock(_mutex);
|
StackLock lock(_mutex);
|
||||||
for (int l = MAX_IMUSE_TRACKS; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
|
for (int l = MAX_IMUSE_TRACKS; l < MAX_IMUSE_TRACKS + MAX_IMUSE_FADETRACKS; l++) {
|
||||||
@ -265,7 +256,7 @@ Imuse::Track *Imuse::cloneToFadeOutTrack(Track *track, int fadeDelay) {
|
|||||||
// setup 1 second stream wrapped buffer
|
// setup 1 second stream wrapped buffer
|
||||||
int32 streamBufferSize = fadeTrack->iteration;
|
int32 streamBufferSize = fadeTrack->iteration;
|
||||||
fadeTrack->stream = makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags, streamBufferSize);
|
fadeTrack->stream = makeAppendableAudioStream(_sound->getFreq(fadeTrack->soundHandle), fadeTrack->mixerFlags, streamBufferSize);
|
||||||
_vm->_mixer->playInputStream(&fadeTrack->handle, fadeTrack->stream, false, -1, fadeTrack->vol / 1000, fadeTrack->pan, false);
|
g_mixer->playInputStream(&fadeTrack->handle, fadeTrack->stream, false, -1, fadeTrack->vol / 1000, fadeTrack->pan, false);
|
||||||
fadeTrack->started = true;
|
fadeTrack->started = true;
|
||||||
fadeTrack->used = true;
|
fadeTrack->used = true;
|
||||||
|
|
||||||
|
10
main.cpp
10
main.cpp
@ -27,6 +27,7 @@
|
|||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "smush.h"
|
#include "smush.h"
|
||||||
#include "mixer/mixer.h"
|
#include "mixer/mixer.h"
|
||||||
|
#include "imuse/imuse.h"
|
||||||
|
|
||||||
#include "driver_gl.h"
|
#include "driver_gl.h"
|
||||||
|
|
||||||
@ -49,6 +50,7 @@ int PASCAL WinMain(HINSTANCE /*hInst*/, HINSTANCE /*hPrevInst*/, LPSTR /*lpCmdL
|
|||||||
|
|
||||||
extern SoundMixer *g_mixer;
|
extern SoundMixer *g_mixer;
|
||||||
extern Timer *g_timer;
|
extern Timer *g_timer;
|
||||||
|
extern Imuse *g_imuse;
|
||||||
|
|
||||||
static bool parseBoolStr(const char *val) {
|
static bool parseBoolStr(const char *val) {
|
||||||
if (val == NULL || val[0] == 0)
|
if (val == NULL || val[0] == 0)
|
||||||
@ -114,14 +116,11 @@ int main(int argc, char *argv[]) {
|
|||||||
atexit(saveRegistry);
|
atexit(saveRegistry);
|
||||||
|
|
||||||
g_mixer = new SoundMixer();
|
g_mixer = new SoundMixer();
|
||||||
|
g_mixer->setVolume(255);
|
||||||
g_timer = new Timer();
|
g_timer = new Timer();
|
||||||
g_smush = new Smush();
|
g_smush = new Smush();
|
||||||
|
|
||||||
g_driver = new Driver(640, 480, 24);
|
g_driver = new Driver(640, 480, 24);
|
||||||
|
g_imuse = new Imuse(10);
|
||||||
g_mixer->setVolume(255);
|
|
||||||
|
|
||||||
// Mixer::instance()->start();
|
|
||||||
|
|
||||||
Bitmap *splash_bm = ResourceLoader::instance()->loadBitmap("splash.bm");
|
Bitmap *splash_bm = ResourceLoader::instance()->loadBitmap("splash.bm");
|
||||||
|
|
||||||
@ -162,6 +161,7 @@ int main(int argc, char *argv[]) {
|
|||||||
lua_removelibslists();
|
lua_removelibslists();
|
||||||
lua_close();
|
lua_close();
|
||||||
|
|
||||||
|
delete g_imuse;
|
||||||
delete g_smush;
|
delete g_smush;
|
||||||
delete g_timer;
|
delete g_timer;
|
||||||
delete g_mixer;
|
delete g_mixer;
|
||||||
|
@ -34,7 +34,6 @@ static uint16 smushDestTable[5786];
|
|||||||
void vimaInit(uint16 *destTable);
|
void vimaInit(uint16 *destTable);
|
||||||
void decompressVima(const byte *src, int16 *dest, int destLen, uint16 *destTable);
|
void decompressVima(const byte *src, int16 *dest, int destLen, uint16 *destTable);
|
||||||
|
|
||||||
extern SoundMixer *g_mixer;
|
|
||||||
|
|
||||||
void Smush::timerCallback(void *refCon) {
|
void Smush::timerCallback(void *refCon) {
|
||||||
g_smush->handleFrame();
|
g_smush->handleFrame();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user