From a09ac7b1140b3b1db32b5f6cb553643744544400 Mon Sep 17 00:00:00 2001 From: Nipun Garg Date: Thu, 25 Jul 2019 06:51:06 +0530 Subject: HDB: Add voice related data --- engines/hdb/sound.cpp | 19 ++++++++----------- engines/hdb/sound.h | 48 ++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 46 insertions(+), 21 deletions(-) (limited to 'engines/hdb') diff --git a/engines/hdb/sound.cpp b/engines/hdb/sound.cpp index 5eda13341c..88bede7d9a 100644 --- a/engines/hdb/sound.cpp +++ b/engines/hdb/sound.cpp @@ -21,10 +21,6 @@ */ #include "common/debug.h" -#include "audio/audiostream.h" -#include "audio/mixer.h" -#include "audio/decoders/wave.h" -#include "audio/decoders/mp3.h" #include "hdb/hdb.h" #include "hdb/file-manager.h" @@ -1430,21 +1426,22 @@ bool Sound::init() { _numSounds = index; // voices are on by default - warning("STUB: Initialize voices"); + _voicesOn = 1; + memset(&_voicePlayed[0], 0, sizeof(_voicePlayed)); return true; } void Sound::save(Common::OutSaveFile *out) { - warning("STUB: Sound::save()"); + for (int i = 0; i < NUM_VOICES; i++) { + out->writeByte(_voicePlayed[i]); + } } void Sound::loadSaveFile(Common::InSaveFile *in) { - warning("STUB: Sound::loadSaveFile()"); -} - -void Sound::clearPersistent() { - warning("STUB: Sound::clearPersistent()"); + for (int i = 0; i < NUM_VOICES; i++) { + _voicePlayed[i] = in->readByte(); + } } bool Sound::playSound(int index) { diff --git a/engines/hdb/sound.h b/engines/hdb/sound.h index 67b8d10da5..68501a14ec 100644 --- a/engines/hdb/sound.h +++ b/engines/hdb/sound.h @@ -47,6 +47,11 @@ #define FIRST_VOICE V00_AIRLOCK_01 #define NUM_VOICES ( LAST_SOUND - FIRST_VOICE ) +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/wave.h" +#include "audio/decoders/mp3.h" + namespace HDB { enum { @@ -1408,6 +1413,18 @@ struct SoundLookUp { const char *luaName; // name for Lua code to use }; +struct Voice { + bool active; + int32 length; + int index; + Audio::SoundHandle *handle; + + Voice() : active(false), length(0), index(0), handle(new Audio::SoundHandle) {} + ~Voice() { + delete handle; + } +}; + struct SoundCache { int loaded; // -1 = freeable; in memory, 0 = not cached, 1 = cached int32 size; // size of sound @@ -1417,9 +1434,7 @@ struct SoundCache { //void *data; // actual file data //FSOUND_SAMPLE *sample; // used to play sound in FMOD - SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0) { - - } + SoundCache() : loaded(0), size(0), name(nullptr), luaName(nullptr), ext(0) {} }; class Sound { @@ -1432,7 +1447,6 @@ public: bool init(); void save(Common::OutSaveFile *out); void loadSaveFile(Common::InSaveFile *in); - void clearPersistent(); void setMusicVolume(int value) { //debug(9, "STUB: Add Music System Variables"); } @@ -1441,18 +1455,19 @@ public: return 1; } void setSFXVolume(int value) { - //debug(9, "STUB: Add Music System Variables"); + _sfxVolume = value; } int getSFXVolume() { - //debug(9, "STUB: Add Music System Variables"); - return 1; + return _sfxVolume; } void setVoiceStatus(int value) { - //debug(9, "STUB: Add Music System Variables"); + _voicesOn = value; } int getVoiceStatus() { - //debug(9, "STUB: Add Music System Variables"); - return 1; + return _voicesOn; + } + void clearPersistent() { + memset(&_voicePlayed[0], 0, sizeof(_voicePlayed)); } bool playSound(int index); @@ -1476,6 +1491,19 @@ public: void markSoundCacheFreeable(); + // Voice System Variables + + enum { + GUY, + OTHER, + MAX_VOICES + }; + + Voice _voices[MAX_VOICES]; + + int _voicesOn; + byte _voicePlayed[NUM_VOICES]; + // Sound Caching System Variables SoundCache _soundCache[kMaxSounds]; -- cgit v1.2.3