TITANIC: Implemented stopSound

This commit is contained in:
Paul Gilbert 2016-05-04 22:02:03 -04:00
parent b79ed60a8e
commit 6948a44ac4
11 changed files with 143 additions and 57 deletions

View File

@ -325,18 +325,6 @@ bool CGameObject::soundFn1(int val) {
return false;
}
void CGameObject::soundFn2(int val, int val2) {
if (val != 0 && val != -1) {
CGameManager *gameManager = getGameManager();
if (gameManager) {
if (val2)
gameManager->_sound.fn3(val, 0, val2);
else
gameManager->_sound.fn2(val);
}
}
}
void CGameObject::setVisible(bool val) {
if (val != _visible) {
_visible = val;
@ -456,7 +444,16 @@ void CGameObject::sound8(bool flag) const {
getGameManager()->_sound.managerProc8(flag ? 3 : 0);
}
bool CGameObject::playSound(const CString &name, int val2, int val3, int val4) {
void CGameObject::loadSound(const CString &name) {
CGameManager *gameManager = getGameManager();
if (gameManager) {
g_vm->_filesManager.preload(name);
if (!name.empty())
gameManager->_sound.loadSound(name);
}
}
int CGameObject::playSound(const CString &name, int val2, int val3, int val4) {
CProximity prox;
prox._field8 = val2;
prox._fieldC = val3;
@ -464,12 +461,24 @@ bool CGameObject::playSound(const CString &name, int val2, int val3, int val4) {
return playSound(name, prox);
}
bool CGameObject::playSound(const CString &name, CProximity &prox) {
int CGameObject::playSound(const CString &name, CProximity &prox) {
if (prox._field28 == 2) {
// TODO
}
return false;
return 0;
}
void CGameObject::stopSound(int handle, int val2) {
if (handle != 0 && handle != -1) {
CGameManager *gameManager = getGameManager();
if (gameManager) {
if (val2)
gameManager->_sound.fn3(handle, 0, val2);
else
gameManager->_sound.fn2(handle);
}
}
}
int CGameObject::addTimer(int endVal, uint firstDuration, uint duration) {
@ -749,13 +758,4 @@ void CGameObject::checkPlayMovie(const CString &name, int flags) {
}
}
void CGameObject::loadSound(const CString &name) {
CGameManager *gameManager = getGameManager();
if (gameManager) {
g_vm->_filesManager.preload(name);
if (!name.empty())
gameManager->_sound.loadSound(name);
}
}
} // End of namespace Titanic

View File

@ -123,20 +123,29 @@ protected:
CViewItem * parseView(const CString &viewString);
bool soundFn1(int val);
void soundFn2(int val, int val2);
void petFn2(int val);
void petFn3(CTreeItem *item);
void incState38();
/**
* Plays a sound
* Load a sound
*/
bool playSound(const CString &name, int val2, int val3, int val4);
void loadSound(const CString &name);
/**
* Plays a sound
*/
bool playSound(const CString &name, CProximity &prox);
int playSound(const CString &name, int val2, int val3, int val4);
/**
* Plays a sound
*/
int playSound(const CString &name, CProximity &prox);
/**
* Stop a sound
*/
void stopSound(int handle, int val2);
/**
* Adds a timer
@ -220,11 +229,6 @@ protected:
* Support function for drag moving
*/
void dragMove(const Point &pt);
/**
* Load a sound
*/
void loadSound(const CString &name);
public:
int _field60;
CursorId _cursorId;

View File

@ -51,7 +51,7 @@ int CTelevision::_v5;
int CTelevision::_v6;
CTelevision::CTelevision() : CBackground(), _fieldE0(1),
_fieldE4(7), _isOn(false), _fieldEC(0), _fieldF0(0) {
_fieldE4(7), _isOn(false), _fieldEC(0), _soundHandle(0) {
}
void CTelevision::init() {
@ -76,7 +76,7 @@ void CTelevision::save(SimpleFile *file, int indent) const {
file->writeNumberLine(_v3, indent);
file->writeNumberLine(_fieldEC, indent);
file->writeNumberLine(_v4, indent);
file->writeNumberLine(_fieldF0, indent);
file->writeNumberLine(_soundHandle, indent);
file->writeNumberLine(_v5, indent);
file->writeNumberLine(_v6, indent);
@ -93,7 +93,7 @@ void CTelevision::load(SimpleFile *file) {
_v3 = file->readNumber();
_fieldEC = file->readNumber();
_v4 = file->readNumber();
_fieldF0 = file->readNumber();
_soundHandle = file->readNumber();
_v5 = file->readNumber();
_v6 = file->readNumber();
@ -103,8 +103,8 @@ void CTelevision::load(SimpleFile *file) {
bool CTelevision::LeaveViewMsg(CLeaveViewMsg *msg) {
clearPet();
if (_isOn) {
if (soundFn1(_fieldF0))
soundFn2(_fieldF0, 0);
if (soundFn1(_soundHandle))
stopSound(_soundHandle, 0);
loadFrame(622);
stopMovie();
@ -153,8 +153,8 @@ static const int END_FRAMES[8] = { 0, 55, 111, 167, 223, 279, 335, 391 };
bool CTelevision::PETUpMsg(CPETUpMsg *msg) {
if (msg->_name == "Television" && _isOn) {
if (soundFn1(_fieldF0))
soundFn2(_fieldF0, 0);
if (soundFn1(_soundHandle))
stopSound(_soundHandle, 0);
_fieldE0 = _fieldE0 % _fieldE4 + 1;
stopMovie();
@ -166,8 +166,8 @@ bool CTelevision::PETUpMsg(CPETUpMsg *msg) {
bool CTelevision::PETDownMsg(CPETDownMsg *msg) {
if (msg->_name == "Television" && _isOn) {
if (soundFn1(_fieldF0))
soundFn2(_fieldF0, 0);
if (soundFn1(_soundHandle))
stopSound(_soundHandle, 0);
if (--_fieldE0 < 1)
_fieldE0 += _fieldE4;
@ -215,8 +215,8 @@ bool CTelevision::PETActivateMsg(CPETActivateMsg *msg) {
_fieldE0 = 1;
} else {
stopMovie();
if (soundFn1(_fieldF0))
soundFn2(_fieldF0, 0);
if (soundFn1(_soundHandle))
stopSound(_soundHandle, 0);
setVisible(false);
}
@ -236,7 +236,7 @@ bool CTelevision::MovieEndMsg(CMovieEndMsg *msg) {
if (_fieldE0 == 3 && compareRoomNameTo("SGTState") && !getPassengerClass()) {
playSound("z#47.wav", 100, 0, 0);
_fieldF0 = playSound("b#20.wav", 100, 0, 0);
_soundHandle = playSound("b#20.wav", 100, 0, 0);
CTreeItem *magazine = getRoot()->findByName("Magazine");
if (magazine) {

View File

@ -56,7 +56,7 @@ private:
int _fieldE4;
bool _isOn;
int _fieldEC;
int _fieldF0;
int _soundHandle;
public:
CLASSDEF
CTelevision();

View File

@ -412,6 +412,7 @@ MODULE_OBJS := \
sound/view_auto_sound_player.o \
sound/view_toggles_other_music.o \
sound/water_lapping_sounds.o \
sound/wave_file.o \
star_control/star_control.o \
star_control/star_control_sub1.o \
star_control/star_control_sub2.o \

View File

@ -56,11 +56,11 @@ bool CSound::fn1(int val) {
return false;
}
void CSound::fn2(int val) {
void CSound::fn2(int handle) {
warning("TODO: CSound::fn3");
}
void CSound::fn3(int val, int val2, int val3) {
void CSound::fn3(int handle, int val2, int val3) {
warning("TODO: CSound::fn3");
}

View File

@ -35,7 +35,7 @@ class CGameManager;
class CSoundItem : public ListItem {
public:
CString _name;
uint _soundHandle;
int _soundHandle;
int _field1C;
int _field20;
int _field24;
@ -113,8 +113,8 @@ public:
uint loadSound(const CString &name);
bool fn1(int val);
void fn2(int val);
void fn3(int val, int val2, int val3);
void fn2(int handle);
void fn3(int handle, int val2, int val3);
void managerProc8(int v) { _soundManager.proc8(v); }
};

View File

@ -34,7 +34,7 @@ QSoundManager::QSoundManager() : _field18(0), _field1C(0) {
Common::fill(&_field4A0[0], &_field4A0[16], 0);
}
uint QSoundManager::loadSound(const CString &name) {
int QSoundManager::loadSound(const CString &name) {
warning("TODO");
return 0;
}
@ -86,7 +86,7 @@ bool QSoundManager::proc14() {
return false;
}
bool QSoundManager::isActive(uint handle) const {
bool QSoundManager::isActive(int handle) const {
warning("TODO");
return false;
}

View File

@ -42,7 +42,7 @@ public:
* @param name Name of sound resource
* @returns Loaded sound handle
*/
virtual uint loadSound(const CString &name) { return 0; }
virtual int loadSound(const CString &name) { return 0; }
virtual int proc4() const { return 0; }
virtual int proc5() const { return 0; }
@ -55,7 +55,7 @@ public:
virtual void proc12() {}
virtual void proc13() {}
virtual bool proc14() = 0;
virtual bool isActive(uint handle) const { return false; }
virtual bool isActive(int handle) const { return false; }
virtual int proc16() const { return 0; }
virtual void WaveMixPump() {}
virtual int proc18() const { return 0; }
@ -111,7 +111,7 @@ public:
* @param name Name of sound resource
* @returns Loaded sound handle
*/
virtual uint loadSound(const CString &name);
virtual int loadSound(const CString &name);
virtual int proc4();
virtual int proc5();
@ -124,7 +124,7 @@ public:
virtual void proc12();
virtual void proc13();
virtual bool proc14();
virtual bool isActive(uint handle) const;
virtual bool isActive(int handle) const;
virtual int proc16();
virtual void WaveMixPump();
virtual int proc18() const;

View File

@ -0,0 +1,27 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "titanic/sound/wave_file.h"
namespace Titanic {
} // End of namespace Titanic z

View File

@ -0,0 +1,54 @@
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#ifndef TITANIC_WAVE_FILE_H
#define TITANIC_WAVE_FILE_H
#include "titanic/support/simple_file.h"
namespace Titanic {
class CSoundManager;
class WaveFile {
public:
int _field0;
int _field4;
int _field8;
uint _handle;
CSoundManager *_owner;
int _field14;
int _field18;
int _field1C;
int _field20;
int _field24;
int _field28;
int _field2C;
public:
WaveFile() : _field0(2), _field4(0), _field8(0), _handle(0),
_owner(nullptr), _field14(1), _field18(0), _field1C(0),
_field20(0), _field24(0), _field28(0), _field2C(-1) {}
};
} // End of namespace Titanic
#endif /* TITANIC_WAVE_FILE_H */