use namespace Common a bit more; don't zero the RNG in scumm (else the seed gets reset); remove obsolete 256 color blending code
svn-id: r10592
This commit is contained in:
parent
91da08e1f3
commit
d4734bd4f2
14 changed files with 65 additions and 137 deletions
|
@ -150,7 +150,7 @@ void OSystem_SDL_Common::copy_rect(const byte *src, int pitch, int x, int y, int
|
||||||
if (_screen == NULL)
|
if (_screen == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
|
|
||||||
if (((long)src & 3) == 0 && pitch == _screenWidth && x==0 && y==0 &&
|
if (((long)src & 3) == 0 && pitch == _screenWidth && x==0 && y==0 &&
|
||||||
w==_screenWidth && h==_screenHeight && _mode_flags&DF_WANT_RECT_OPTIM) {
|
w==_screenWidth && h==_screenHeight && _mode_flags&DF_WANT_RECT_OPTIM) {
|
||||||
|
@ -218,7 +218,7 @@ void OSystem_SDL_Common::move_screen(int dx, int dy, int height) {
|
||||||
if ((dx == 0 && dy == 0) || height <= 0)
|
if ((dx == 0 && dy == 0) || height <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
|
|
||||||
byte *src, *dst;
|
byte *src, *dst;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
@ -1295,7 +1295,7 @@ void OSystem_SDL_Common::clear_overlay() {
|
||||||
if (!_overlayVisible)
|
if (!_overlayVisible)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
|
|
||||||
// hide the mouse
|
// hide the mouse
|
||||||
undraw_mouse();
|
undraw_mouse();
|
||||||
|
|
|
@ -239,7 +239,7 @@ void OSystem_SDL::hotswap_gfx_mode() {
|
||||||
void OSystem_SDL::update_screen() {
|
void OSystem_SDL::update_screen() {
|
||||||
assert(_hwscreen != NULL);
|
assert(_hwscreen != NULL);
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
|
|
||||||
// If the shake position changed, fill the dirty area with blackness
|
// If the shake position changed, fill the dirty area with blackness
|
||||||
if (_currentShakePos != _newShakePos) {
|
if (_currentShakePos != _newShakePos) {
|
||||||
|
@ -369,7 +369,7 @@ void OSystem_SDL::update_screen() {
|
||||||
|
|
||||||
uint32 OSystem_SDL::property(int param, Property *value) {
|
uint32 OSystem_SDL::property(int param, Property *value) {
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
|
|
||||||
if (param == PROP_TOGGLE_FULLSCREEN) {
|
if (param == PROP_TOGGLE_FULLSCREEN) {
|
||||||
assert(_hwscreen != 0);
|
assert(_hwscreen != 0);
|
||||||
|
@ -408,7 +408,7 @@ uint32 OSystem_SDL::property(int param, Property *value) {
|
||||||
bool OSystem_SDL::save_screenshot(const char *filename) {
|
bool OSystem_SDL::save_screenshot(const char *filename) {
|
||||||
assert(_hwscreen != NULL);
|
assert(_hwscreen != NULL);
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
SDL_SaveBMP(_hwscreen, filename);
|
SDL_SaveBMP(_hwscreen, filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -359,7 +359,7 @@ void OSystem_SDL_OpenGL::hotswap_gfx_mode() {
|
||||||
|
|
||||||
void OSystem_SDL_OpenGL::update_screen() {
|
void OSystem_SDL_OpenGL::update_screen() {
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
|
|
||||||
// If the shake position changed, fill the dirty area with blackness
|
// If the shake position changed, fill the dirty area with blackness
|
||||||
if (_currentShakePos != _newShakePos) {
|
if (_currentShakePos != _newShakePos) {
|
||||||
|
@ -563,7 +563,7 @@ bool OSystem_SDL_OpenGL::poll_event(Event *event) {
|
||||||
|
|
||||||
uint32 OSystem_SDL_OpenGL::property(int param, Property *value) {
|
uint32 OSystem_SDL_OpenGL::property(int param, Property *value) {
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
|
|
||||||
if (param == PROP_TOGGLE_FULLSCREEN) {
|
if (param == PROP_TOGGLE_FULLSCREEN) {
|
||||||
if (!_usingOpenGL)
|
if (!_usingOpenGL)
|
||||||
|
@ -686,7 +686,7 @@ bool OSystem_SDL_OpenGL::save_screenshot(const char *filename) {
|
||||||
if (_usingOpenGL)
|
if (_usingOpenGL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
Common::StackLock lock(_graphicsMutex, this); // Lock the mutex until this function ends
|
||||||
|
|
||||||
assert(_hwscreen != NULL);
|
assert(_hwscreen != NULL);
|
||||||
SDL_SaveBMP(_hwscreen, filename);
|
SDL_SaveBMP(_hwscreen, filename);
|
||||||
|
|
|
@ -54,7 +54,7 @@ Timer::~Timer() {
|
||||||
_system->set_timer(0, 0);
|
_system->set_timer(0, 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
for (int i = 0; i < MAX_TIMERS; i++) {
|
for (int i = 0; i < MAX_TIMERS; i++) {
|
||||||
_timerSlots[i].procedure = NULL;
|
_timerSlots[i].procedure = NULL;
|
||||||
_timerSlots[i].interval = 0;
|
_timerSlots[i].interval = 0;
|
||||||
|
@ -81,7 +81,7 @@ int Timer::timer_handler(int t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int Timer::handler(int t) {
|
int Timer::handler(int t) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
uint32 interval, l;
|
uint32 interval, l;
|
||||||
|
|
||||||
_lastTime = _thisTime;
|
_lastTime = _thisTime;
|
||||||
|
@ -102,7 +102,7 @@ int Timer::handler(int t) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Timer::installProcedure(TimerProc procedure, int32 interval, void *refCon) {
|
bool Timer::installProcedure(TimerProc procedure, int32 interval, void *refCon) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
int32 l;
|
int32 l;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ bool Timer::installProcedure(TimerProc procedure, int32 interval, void *refCon)
|
||||||
}
|
}
|
||||||
|
|
||||||
void Timer::releaseProcedure(TimerProc procedure) {
|
void Timer::releaseProcedure(TimerProc procedure) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
int32 l;
|
int32 l;
|
||||||
|
|
||||||
for (l = 0; l < MAX_TIMERS; l++) {
|
for (l = 0; l < MAX_TIMERS; l++) {
|
||||||
|
|
|
@ -22,106 +22,34 @@
|
||||||
#include "base/engine.h"
|
#include "base/engine.h"
|
||||||
#include "common/util.h"
|
#include "common/util.h"
|
||||||
|
|
||||||
//
|
namespace Common {
|
||||||
// 8-bit alpha blending routines
|
|
||||||
//
|
|
||||||
#ifndef NEWGUI_256
|
|
||||||
static int BlendCache[256][256];
|
|
||||||
#endif
|
|
||||||
//
|
|
||||||
// Find the entry in the given palette which matches the color defined by
|
|
||||||
// the tripel (r,b,g) most closely.
|
|
||||||
//
|
|
||||||
int RGBMatch(byte *palette, int r, int g, int b) {
|
|
||||||
int i, bestidx = 0, besterr = 0xFFFFFF;
|
|
||||||
int error = 0;
|
|
||||||
|
|
||||||
for (i = 0;i < 256;i++) {
|
|
||||||
byte *pal = palette + (i * 3);
|
|
||||||
int r_diff = r - (int)*pal++;
|
|
||||||
int g_diff = g - (int)*pal++;
|
|
||||||
int b_diff = b - (int)*pal++;
|
|
||||||
r_diff *= r_diff; g_diff *= g_diff; b_diff *= b_diff;
|
|
||||||
|
|
||||||
error = r_diff + g_diff + b_diff;
|
|
||||||
if (error < besterr) {
|
|
||||||
besterr = error;
|
|
||||||
bestidx = i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return bestidx;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Blend two 8 bit colors into a third, all colors being defined by palette indices.
|
|
||||||
//
|
|
||||||
int Blend(int src, int dst, byte *palette) {
|
|
||||||
#ifndef NEWGUI_256
|
|
||||||
int r, g, b;
|
|
||||||
int alpha = 128; // Level of transparency [0-256]
|
|
||||||
byte *srcpal = palette + (dst * 3);
|
|
||||||
byte *dstpal = palette + (src * 3);
|
|
||||||
|
|
||||||
if (BlendCache[dst][src] > -1)
|
|
||||||
return BlendCache[dst][src];
|
|
||||||
|
|
||||||
r = (*srcpal++ * alpha);
|
|
||||||
r += (*dstpal++ * (256 - alpha));
|
|
||||||
r /= 256;
|
|
||||||
|
|
||||||
g = (*srcpal++ * alpha);
|
|
||||||
g += (*dstpal++ * (256 - alpha));
|
|
||||||
g /= 256;
|
|
||||||
|
|
||||||
b = (*srcpal++ * alpha);
|
|
||||||
b += (*dstpal++ * (256 - alpha));
|
|
||||||
b /= 256;
|
|
||||||
|
|
||||||
return (BlendCache[dst][src] = RGBMatch(palette, r , g , b ));
|
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Reset the blending cache
|
|
||||||
//
|
|
||||||
void ClearBlendCache() {
|
|
||||||
#ifndef NEWGUI_256
|
|
||||||
for (int i = 0; i < 256; i++)
|
|
||||||
for (int j = 0 ; j < 256 ; j++)
|
|
||||||
// BlendCache[i][j] = i; // No alphablending
|
|
||||||
// BlendCache[i][j] = j; // 100% translucent
|
|
||||||
BlendCache[i][j] = -1; // Enable alphablending
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Print hexdump of the data passed in
|
// Print hexdump of the data passed in
|
||||||
//
|
//
|
||||||
void hexdump(const byte * data, int len, int bytes_per_line) {
|
void hexdump(const byte * data, int len, int bytesPerLine) {
|
||||||
assert(1 <= bytes_per_line && bytes_per_line <= 32);
|
assert(1 <= bytesPerLine && bytesPerLine <= 32);
|
||||||
int i;
|
int i;
|
||||||
byte c;
|
byte c;
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
while (len >= bytes_per_line) {
|
while (len >= bytesPerLine) {
|
||||||
printf("%06x: ", offset);
|
printf("%06x: ", offset);
|
||||||
for (i = 0; i < bytes_per_line; i++) {
|
for (i = 0; i < bytesPerLine; i++) {
|
||||||
printf("%02x ", data[i]);
|
printf("%02x ", data[i]);
|
||||||
if (i % 4 == 3)
|
if (i % 4 == 3)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
printf(" |");
|
printf(" |");
|
||||||
for (i = 0; i < bytes_per_line; i++) {
|
for (i = 0; i < bytesPerLine; i++) {
|
||||||
c = data[i];
|
c = data[i];
|
||||||
if (c < 32 || c >= 127)
|
if (c < 32 || c >= 127)
|
||||||
c = '.';
|
c = '.';
|
||||||
printf("%c", c);
|
printf("%c", c);
|
||||||
}
|
}
|
||||||
printf("|\n");
|
printf("|\n");
|
||||||
data += bytes_per_line;
|
data += bytesPerLine;
|
||||||
len -= bytes_per_line;
|
len -= bytesPerLine;
|
||||||
offset += bytes_per_line;
|
offset += bytesPerLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
|
@ -133,7 +61,7 @@ void hexdump(const byte * data, int len, int bytes_per_line) {
|
||||||
if (i % 4 == 3)
|
if (i % 4 == 3)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
}
|
}
|
||||||
for (; i < bytes_per_line; i++)
|
for (; i < bytesPerLine; i++)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
printf(" |");
|
printf(" |");
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
|
@ -142,7 +70,7 @@ void hexdump(const byte * data, int len, int bytes_per_line) {
|
||||||
c = '.';
|
c = '.';
|
||||||
printf("%c", c);
|
printf("%c", c);
|
||||||
}
|
}
|
||||||
for (; i < bytes_per_line; i++)
|
for (; i < bytesPerLine; i++)
|
||||||
printf(" ");
|
printf(" ");
|
||||||
printf("|\n");
|
printf("|\n");
|
||||||
}
|
}
|
||||||
|
@ -187,3 +115,4 @@ void StackLock::unlock() {
|
||||||
_syst->unlock_mutex(_mutex);
|
_syst->unlock_mutex(_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // End of namespace Common
|
||||||
|
|
|
@ -35,22 +35,20 @@ template<typename T> inline void SWAP(T &a, T &b) { T tmp = a; a = b; b = tmp; }
|
||||||
|
|
||||||
#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
|
#define ARRAYSIZE(x) ((int)(sizeof(x) / sizeof(x[0])))
|
||||||
|
|
||||||
int RGBMatch(byte *palette, int r, int g, int b);
|
namespace Common {
|
||||||
int Blend(int src, int dst, byte *palette);
|
|
||||||
void ClearBlendCache();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print a hexdump of the data passed in. The number of bytes per line
|
* Print a hexdump of the data passed in. The number of bytes per line is
|
||||||
* is customizable.
|
* customizable.
|
||||||
* @param data the data to be dumped
|
* @param data the data to be dumped
|
||||||
* @param len the lenght of that data
|
* @param len the lenght of that data
|
||||||
* @param bytes_per_line number of bytes to print per line (default: 16)
|
* @param bytes_per_line number of bytes to print per line (default: 16)
|
||||||
*/
|
*/
|
||||||
void hexdump(const byte * data, int len, int bytes_per_line = 16);
|
void hexdump(const byte * data, int len, int bytesPerLine = 16);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple random number generator. Although it is definitely not suitable
|
* Simple random number generator. Although it is definitely not suitable for
|
||||||
* for cryptographic purposes, it serves our purposes just fine.
|
* cryptographic purposes, it serves our purposes just fine.
|
||||||
*/
|
*/
|
||||||
class RandomSource {
|
class RandomSource {
|
||||||
private:
|
private:
|
||||||
|
@ -88,6 +86,8 @@ public:
|
||||||
~StackLock();
|
~StackLock();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // End of namespace Common
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__)
|
||||||
|
|
|
@ -907,7 +907,7 @@ void ScummEngine_v5::saveVars() {
|
||||||
void ScummEngine_v5::loadVars() {
|
void ScummEngine_v5::loadVars() {
|
||||||
int a, b;
|
int a, b;
|
||||||
|
|
||||||
hexdump(_scriptPointer, 64);
|
// Common::hexdump(_scriptPointer, 64);
|
||||||
while ((_opcode = fetchScriptByte()) != 0) {
|
while ((_opcode = fetchScriptByte()) != 0) {
|
||||||
switch (_opcode & 0x1F) {
|
switch (_opcode & 0x1F) {
|
||||||
case 0x01: // read a range of variables
|
case 0x01: // read a range of variables
|
||||||
|
|
|
@ -362,7 +362,7 @@ protected:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/* Random number generation */
|
/* Random number generation */
|
||||||
RandomSource _rnd;
|
Common::RandomSource _rnd;
|
||||||
|
|
||||||
/* Core variable definitions */
|
/* Core variable definitions */
|
||||||
byte _gameId;
|
byte _gameId;
|
||||||
|
|
|
@ -296,7 +296,6 @@ ScummEngine::ScummEngine(GameDetector *detector, OSystem *syst)
|
||||||
_confirmExitDialog = NULL;
|
_confirmExitDialog = NULL;
|
||||||
_debuggerDialog = NULL;
|
_debuggerDialog = NULL;
|
||||||
_fastMode = 0;
|
_fastMode = 0;
|
||||||
memset(&_rnd, 0, sizeof(RandomSource));
|
|
||||||
_gameId = 0;
|
_gameId = 0;
|
||||||
memset(&gdi, 0, sizeof(Gdi));
|
memset(&gdi, 0, sizeof(Gdi));
|
||||||
_actors = NULL;
|
_actors = NULL;
|
||||||
|
|
|
@ -347,7 +347,7 @@ protected:
|
||||||
byte *_sdl_buf;
|
byte *_sdl_buf;
|
||||||
byte *_sdl_buf_attached;
|
byte *_sdl_buf_attached;
|
||||||
|
|
||||||
RandomSource _rnd;
|
Common::RandomSource _rnd;
|
||||||
|
|
||||||
byte *_vc_10_base_ptr_old;
|
byte *_vc_10_base_ptr_old;
|
||||||
byte _hebrew_char_widths[32];
|
byte _hebrew_char_widths[32];
|
||||||
|
|
|
@ -255,7 +255,7 @@ protected:
|
||||||
|
|
||||||
uint32 _currentSection;
|
uint32 _currentSection;
|
||||||
|
|
||||||
RandomSource _rnd;
|
Common::RandomSource _rnd;
|
||||||
|
|
||||||
SkyScreen *_skyScreen;
|
SkyScreen *_skyScreen;
|
||||||
SkyDisk *_skyDisk;
|
SkyDisk *_skyDisk;
|
||||||
|
|
|
@ -161,18 +161,18 @@ bool SoundMixer::bindToSystem(OSystem *syst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::setupPremix(PremixProc *proc, void *param) {
|
void SoundMixer::setupPremix(PremixProc *proc, void *param) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
_premixParam = param;
|
_premixParam = param;
|
||||||
_premixProc = proc;
|
_premixProc = proc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SoundMixer::newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan) {
|
int SoundMixer::newStream(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, uint32 buffer_size, byte volume, int8 pan) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
return insertChannel(handle, new ChannelStream(this, handle, sound, size, rate, flags, buffer_size, volume, pan));
|
return insertChannel(handle, new ChannelStream(this, handle, sound, size, rate, flags, buffer_size, volume, pan));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::appendStream(PlayingSoundHandle handle, void *sound, uint32 size) {
|
void SoundMixer::appendStream(PlayingSoundHandle handle, void *sound, uint32 size) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (handle == 0)
|
if (handle == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -198,7 +198,7 @@ void SoundMixer::appendStream(PlayingSoundHandle handle, void *sound, uint32 siz
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::endStream(PlayingSoundHandle handle) {
|
void SoundMixer::endStream(PlayingSoundHandle handle) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
// Simply ignore stop requests for handles of sounds that already terminated
|
// Simply ignore stop requests for handles of sounds that already terminated
|
||||||
if (handle == 0)
|
if (handle == 0)
|
||||||
|
@ -245,7 +245,7 @@ int SoundMixer::insertChannel(PlayingSoundHandle *handle, Channel *chan) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id, byte volume, int8 pan, uint32 loopStart, uint32 loopEnd) {
|
int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags, int id, byte volume, int8 pan, uint32 loopStart, uint32 loopEnd) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
// Prevent duplicate sounds
|
// Prevent duplicate sounds
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
|
@ -259,24 +259,24 @@ int SoundMixer::playRaw(PlayingSoundHandle *handle, void *sound, uint32 size, ui
|
||||||
|
|
||||||
#ifdef USE_MAD
|
#ifdef USE_MAD
|
||||||
int SoundMixer::playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan) {
|
int SoundMixer::playMP3(PlayingSoundHandle *handle, File *file, uint32 size, byte volume, int8 pan) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
return insertChannel(handle, new ChannelMP3(this, handle, file, size, volume, pan));
|
return insertChannel(handle, new ChannelMP3(this, handle, file, size, volume, pan));
|
||||||
}
|
}
|
||||||
int SoundMixer::playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume, int8 pan) {
|
int SoundMixer::playMP3CDTrack(PlayingSoundHandle *handle, File *file, mad_timer_t duration, byte volume, int8 pan) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
return insertChannel(handle, new ChannelMP3CDMusic(this, handle, file, duration, volume, pan));
|
return insertChannel(handle, new ChannelMP3CDMusic(this, handle, file, duration, volume, pan));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_VORBIS
|
#ifdef USE_VORBIS
|
||||||
int SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan) {
|
int SoundMixer::playVorbis(PlayingSoundHandle *handle, OggVorbis_File *ov_file, int duration, bool is_cd_track, byte volume, int8 pan) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
return insertChannel(handle, new ChannelVorbis(this, handle, ov_file, duration, is_cd_track, volume, pan));
|
return insertChannel(handle, new ChannelVorbis(this, handle, ov_file, duration, is_cd_track, volume, pan));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SoundMixer::mix(int16 *buf, uint len) {
|
void SoundMixer::mix(int16 *buf, uint len) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (_premixProc && !_paused) {
|
if (_premixProc && !_paused) {
|
||||||
_premixProc(_premixParam, buf, len);
|
_premixProc(_premixParam, buf, len);
|
||||||
|
@ -302,7 +302,7 @@ void SoundMixer::mixCallback(void *s, byte *samples, int len) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::stopAll() {
|
void SoundMixer::stopAll() {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
for (int i = 0; i != NUM_CHANNELS; i++)
|
for (int i = 0; i != NUM_CHANNELS; i++)
|
||||||
if (_channels[i])
|
if (_channels[i])
|
||||||
_channels[i]->destroy();
|
_channels[i]->destroy();
|
||||||
|
@ -314,13 +314,13 @@ void SoundMixer::stopChannel(int index) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
if (_channels[index])
|
if (_channels[index])
|
||||||
_channels[index]->destroy();
|
_channels[index]->destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::stopID(int id) {
|
void SoundMixer::stopID(int id) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
for (int i = 0; i != NUM_CHANNELS; i++) {
|
for (int i = 0; i != NUM_CHANNELS; i++) {
|
||||||
if (_channels[i] != NULL && _channels[i]->_id == id) {
|
if (_channels[i] != NULL && _channels[i]->_id == id) {
|
||||||
_channels[i]->destroy();
|
_channels[i]->destroy();
|
||||||
|
@ -330,7 +330,7 @@ void SoundMixer::stopID(int id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::stopHandle(PlayingSoundHandle handle) {
|
void SoundMixer::stopHandle(PlayingSoundHandle handle) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
// Simply ignore stop requests for handles of sounds that already terminated
|
// Simply ignore stop requests for handles of sounds that already terminated
|
||||||
if (handle == 0)
|
if (handle == 0)
|
||||||
|
@ -348,7 +348,7 @@ void SoundMixer::stopHandle(PlayingSoundHandle handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
|
void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (handle == 0)
|
if (handle == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -365,7 +365,7 @@ void SoundMixer::setChannelVolume(PlayingSoundHandle handle, byte volume) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::setChannelPan(PlayingSoundHandle handle, int8 pan) {
|
void SoundMixer::setChannelPan(PlayingSoundHandle handle, int8 pan) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (handle == 0)
|
if (handle == 0)
|
||||||
return;
|
return;
|
||||||
|
@ -391,13 +391,13 @@ void SoundMixer::pauseChannel(int index, bool paused) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
if (_channels[index])
|
if (_channels[index])
|
||||||
_channels[index]->pause(paused);
|
_channels[index]->pause(paused);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::pauseID(int id, bool paused) {
|
void SoundMixer::pauseID(int id, bool paused) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
for (int i = 0; i != NUM_CHANNELS; i++) {
|
for (int i = 0; i != NUM_CHANNELS; i++) {
|
||||||
if (_channels[i] != NULL && _channels[i]->_id == id) {
|
if (_channels[i] != NULL && _channels[i]->_id == id) {
|
||||||
_channels[i]->pause(paused);
|
_channels[i]->pause(paused);
|
||||||
|
@ -407,7 +407,7 @@ void SoundMixer::pauseID(int id, bool paused) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundMixer::pauseHandle(PlayingSoundHandle handle, bool paused) {
|
void SoundMixer::pauseHandle(PlayingSoundHandle handle, bool paused) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
// Simply ignore pause/unpause requests for handles of sound that alreayd terminated
|
// Simply ignore pause/unpause requests for handles of sound that alreayd terminated
|
||||||
if (handle == 0)
|
if (handle == 0)
|
||||||
|
@ -429,7 +429,7 @@ bool SoundMixer::hasActiveSFXChannel() {
|
||||||
// (and maybe also voice) here to work properly in iMuseDigital
|
// (and maybe also voice) here to work properly in iMuseDigital
|
||||||
// games. In the past that was achieve using the _beginSlots hack.
|
// games. In the past that was achieve using the _beginSlots hack.
|
||||||
// Since we don't have that anymore, it's not that simple anymore.
|
// Since we don't have that anymore, it's not that simple anymore.
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
for (int i = 0; i != NUM_CHANNELS; i++)
|
for (int i = 0; i != NUM_CHANNELS; i++)
|
||||||
if (_channels[i] && !_channels[i]->isMusicChannel())
|
if (_channels[i] && !_channels[i]->isMusicChannel())
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -126,7 +126,7 @@ MidiChannel *MidiDriver_MPU401::allocateChannel() {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MidiDriver_MPU401::setTimerCallback (void *timer_param, TimerProc timer_proc) {
|
void MidiDriver_MPU401::setTimerCallback(void *timer_param, TimerProc timer_proc) {
|
||||||
if (!_timer_proc || !timer_proc) {
|
if (!_timer_proc || !timer_proc) {
|
||||||
if (_timer_proc)
|
if (_timer_proc)
|
||||||
g_timer->releaseProcedure(_timer_proc);
|
g_timer->releaseProcedure(_timer_proc);
|
||||||
|
|
|
@ -180,7 +180,7 @@ void Sound::reverseStereo(void) {
|
||||||
// after the credits.
|
// after the credits.
|
||||||
|
|
||||||
void Sound::saveMusicState() {
|
void Sound::saveMusicState() {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
int saveStream;
|
int saveStream;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ void Sound::saveMusicState() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::restoreMusicState() {
|
void Sound::restoreMusicState() {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
int restoreStream;
|
int restoreStream;
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ int32 Sound::isFxOpen(int32 id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Sound::fxServer(int16 *data, uint len) {
|
void Sound::fxServer(int16 *data, uint len) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (!_soundOn)
|
if (!_soundOn)
|
||||||
return;
|
return;
|
||||||
|
@ -899,7 +899,7 @@ uint8 Sound::isFxMute(void) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int32 Sound::streamCompMusic(const char *filename, uint32 musicId, bool looping) {
|
int32 Sound::streamCompMusic(const char *filename, uint32 musicId, bool looping) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
uint32 len;
|
uint32 len;
|
||||||
int32 primaryStream = -1;
|
int32 primaryStream = -1;
|
||||||
|
@ -1062,7 +1062,7 @@ int32 Sound::dipMusic() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int32 Sound::musicTimeRemaining() {
|
int32 Sound::musicTimeRemaining() {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
for (int i = 0; i < MAXMUS; i++) {
|
for (int i = 0; i < MAXMUS; i++) {
|
||||||
if (_music[i]._streaming && !_music[i]._fading)
|
if (_music[i]._streaming && !_music[i]._fading)
|
||||||
|
@ -1077,7 +1077,7 @@ int32 Sound::musicTimeRemaining() {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Sound::stopMusic(void) {
|
void Sound::stopMusic(void) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
for (int i = 0; i < MAXMUS; i++) {
|
for (int i = 0; i < MAXMUS; i++) {
|
||||||
if (_music[i]._streaming)
|
if (_music[i]._streaming)
|
||||||
|
@ -1092,7 +1092,7 @@ void Sound::stopMusic(void) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Sound::pauseMusic(void) {
|
void Sound::pauseMusic(void) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (_soundOn) {
|
if (_soundOn) {
|
||||||
for (int i = 0; i < MAXMUS; i++) {
|
for (int i = 0; i < MAXMUS; i++) {
|
||||||
|
@ -1110,7 +1110,7 @@ void Sound::pauseMusic(void) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Sound::unpauseMusic(void) {
|
void Sound::unpauseMusic(void) {
|
||||||
StackLock lock(_mutex);
|
Common::StackLock lock(_mutex);
|
||||||
|
|
||||||
if (_soundOn) {
|
if (_soundOn) {
|
||||||
for (int i = 0; i < MAXMUS; i++)
|
for (int i = 0; i < MAXMUS; i++)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue