TRECISION: Move CheckSystem to main class, turn SoundSystemActive and SpeechTrackEnabled into bool, simplify related code
This commit is contained in:
parent
5d5783f5e9
commit
fca384fac7
8 changed files with 63 additions and 72 deletions
|
@ -135,8 +135,8 @@ extern uint32 CurBufferSize;
|
|||
extern uint8 *MemoryArea;
|
||||
extern uint8 *SoundStartBuffer;
|
||||
// SOUND
|
||||
extern uint8 SoundSystemActive;
|
||||
extern uint8 SpeechTrackEnabled;
|
||||
extern bool SoundSystemActive;
|
||||
extern bool SpeechTrackEnabled;
|
||||
// MOUSE
|
||||
extern SDText curString;
|
||||
extern SDText oldString;
|
||||
|
|
|
@ -455,8 +455,8 @@ insave:
|
|||
|
||||
bool skipSave = false;
|
||||
ch = 0;
|
||||
for (; ;) {
|
||||
CheckSystem();
|
||||
for (;;) {
|
||||
g_vm->CheckSystem();
|
||||
Mouse(MCMD_UPDT);
|
||||
|
||||
GetKey();
|
||||
|
@ -517,7 +517,7 @@ insave:
|
|||
|
||||
for (; ;) {
|
||||
g_vm->_keybInput = true;
|
||||
CheckSystem();
|
||||
g_vm->CheckSystem();
|
||||
ch = GetKey();
|
||||
FreeKey();
|
||||
|
||||
|
@ -772,7 +772,7 @@ bool DataLoad() {
|
|||
bool skipLoad = false;
|
||||
|
||||
for (;;) {
|
||||
CheckSystem();
|
||||
g_vm->CheckSystem();
|
||||
Mouse(MCMD_UPDT);
|
||||
|
||||
GetKey();
|
||||
|
@ -941,7 +941,7 @@ bool DataLoad() {
|
|||
|
||||
actorStop();
|
||||
nextStep();
|
||||
CheckSystem();
|
||||
g_vm->CheckSystem();
|
||||
|
||||
for (int a = FIRSTLINE; a < MAXY; a++)
|
||||
wordset(g_vm->_video2 + CurRoomMaxX * a + CurScrollPageDx, 0, SCREENLEN);
|
||||
|
|
|
@ -46,9 +46,6 @@ int VertexNum, FaceNum, MatNum, LightNum;
|
|||
#define MAXLIGHT 40
|
||||
#define MAXMAT 20
|
||||
|
||||
#define SOUND_OFF 0
|
||||
#define SOUND_ON 1
|
||||
|
||||
int MaxMemory = 0;
|
||||
// GAME POINTER
|
||||
uint16 *ImagePointer;
|
||||
|
@ -91,8 +88,8 @@ STexture FTexture[MAXMAT];
|
|||
uint8 *MemoryArea;
|
||||
uint32 CurBufferSize;
|
||||
// SOUND
|
||||
uint8 SoundSystemActive;
|
||||
uint8 SpeechTrackEnabled = 0;
|
||||
bool SoundSystemActive;
|
||||
bool SpeechTrackEnabled = false;
|
||||
uint8 *SoundStartBuffer;
|
||||
// Temporary variables
|
||||
Common::SeekableReadStream *ff;
|
||||
|
@ -126,7 +123,7 @@ void openSys() {
|
|||
}
|
||||
}
|
||||
|
||||
SoundSystemActive = SOUND_OFF;
|
||||
SoundSystemActive = false;
|
||||
|
||||
StartSoundSystem();
|
||||
|
||||
|
|
|
@ -205,7 +205,6 @@ void PaintString();
|
|||
void DoClearText();
|
||||
void DoSys(uint16 curObj);
|
||||
void SetRoom(uint16 r, bool b);
|
||||
void CheckSystem();
|
||||
char GetKey();
|
||||
char waitKey();
|
||||
void FreeKey();
|
||||
|
|
|
@ -49,17 +49,6 @@ void VMouseOFF();
|
|||
char waitKey();
|
||||
void wordset(void *dest, uint16 value, uint32 len);
|
||||
|
||||
/* -----------------25/10/97 15.12-------------------
|
||||
CheckSystem
|
||||
--------------------------------------------------*/
|
||||
void CheckSystem() {
|
||||
//for ( int a=0; a<5; a++ )
|
||||
{
|
||||
g_vm->_animMgr->refreshAllAnimations();
|
||||
g_vm->eventLoop();
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------16/01/97 20.53-------------------
|
||||
GetKey
|
||||
--------------------------------------------------*/
|
||||
|
@ -97,7 +86,7 @@ char GetKey() {
|
|||
--------------------------------------------------*/
|
||||
char waitKey() {
|
||||
while (g_vm->_curKey == Common::KEYCODE_INVALID)
|
||||
CheckSystem();
|
||||
g_vm->CheckSystem();
|
||||
|
||||
Common::KeyCode t = g_vm->_curKey;
|
||||
g_vm->_curKey = Common::KEYCODE_INVALID;
|
||||
|
@ -126,7 +115,7 @@ void NlDelay(uint32 val) {
|
|||
uint32 sv = ReadTime();
|
||||
|
||||
while ((sv + val) > ReadTime())
|
||||
CheckSystem();
|
||||
g_vm->CheckSystem();
|
||||
}
|
||||
|
||||
/* -----------------24/06/98 15.00-------------------
|
||||
|
@ -138,7 +127,7 @@ void NlDissolve(int val) {
|
|||
|
||||
int lastv = 9000;
|
||||
while ((sv + val) > (cv = ReadTime())) {
|
||||
CheckSystem();
|
||||
g_vm->CheckSystem();
|
||||
if (lastv < (sv + val - cv))
|
||||
continue;
|
||||
|
||||
|
@ -205,7 +194,7 @@ void NlDissolve(int val) {
|
|||
Mouse
|
||||
--------------------------------------------------*/
|
||||
void Mouse(MouseCmd opt) {
|
||||
CheckSystem();
|
||||
g_vm->CheckSystem();
|
||||
|
||||
switch (opt) {
|
||||
// Update mouse
|
||||
|
|
|
@ -72,13 +72,12 @@ int16 SoundFadInVal;
|
|||
int16 SoundFadOutVal;
|
||||
|
||||
extern uint8 *SpeechBuf[2];
|
||||
extern uint8 SpeechTrackEnabled;
|
||||
extern bool SpeechTrackEnabled;
|
||||
void CloseSys(const char *str);
|
||||
void CheckSystem();
|
||||
void ReadExtraObj41D();
|
||||
void StopTalk();
|
||||
|
||||
extern uint8 SoundSystemActive;
|
||||
extern bool SoundSystemActive;
|
||||
extern const char *_sysSentence[];
|
||||
int SpeechFileLen(const char *name);
|
||||
int SpeechFileRead(const char *name, unsigned char *buf);
|
||||
|
@ -148,7 +147,7 @@ void soundtimefunct() {
|
|||
--------------------------------------------------*/
|
||||
void StartSoundSystem() {
|
||||
if (g_system->getMixer()->isReady())
|
||||
SoundSystemActive = SOUND_ON;
|
||||
SoundSystemActive = true;
|
||||
}
|
||||
|
||||
/* -----------------05/08/97 16.35-------------------
|
||||
|
@ -157,9 +156,8 @@ void StartSoundSystem() {
|
|||
void StopSoundSystem() {
|
||||
if (!SoundSystemActive)
|
||||
return;
|
||||
else if (SoundSystemActive == SOUND_ON) {
|
||||
g_system->getMixer()->stopAll();
|
||||
}
|
||||
|
||||
g_system->getMixer()->stopAll();
|
||||
}
|
||||
|
||||
/* -----------------14/08/97 12.06-------------------
|
||||
|
@ -188,41 +186,37 @@ short LoadAudioWav(int num, uint8 *wav, int len) {
|
|||
NLPlaySound
|
||||
--------------------------------------------------*/
|
||||
void NLPlaySound(int num) {
|
||||
int channel;
|
||||
|
||||
if (!SoundSystemActive)
|
||||
return;
|
||||
else if (SoundSystemActive == SOUND_ON) {
|
||||
channel = 2;
|
||||
if (g_system->getMixer()->isSoundHandleActive(smp[channel])) {
|
||||
g_system->getMixer()->stopHandle(smp[channel]);
|
||||
playing[channel] = 0;
|
||||
}
|
||||
|
||||
int volume = VOLUME(GSample[num]._volume);
|
||||
|
||||
if (GSample[num]._flag & SOUNDFLAG_SON) {
|
||||
volume = 0;
|
||||
smpvol[channel] = 0;
|
||||
}
|
||||
|
||||
Audio::AudioStream *stream = NLSample[num].stream;
|
||||
if (stream != nullptr && GSample[num]._flag & SOUNDFLAG_SLOOP)
|
||||
stream = Audio::makeLoopingAudioStream(NLSample[num].stream, 0);
|
||||
|
||||
g_system->getMixer()->playStream(NLSample[num].type, &smp[channel], stream, -1, volume, 0, DisposeAfterUse::NO);
|
||||
|
||||
playing[channel] = num;
|
||||
|
||||
return;
|
||||
int channel = 2;
|
||||
if (g_system->getMixer()->isSoundHandleActive(smp[channel])) {
|
||||
g_system->getMixer()->stopHandle(smp[channel]);
|
||||
playing[channel] = 0;
|
||||
}
|
||||
|
||||
int volume = VOLUME(GSample[num]._volume);
|
||||
|
||||
if (GSample[num]._flag & SOUNDFLAG_SON) {
|
||||
volume = 0;
|
||||
smpvol[channel] = 0;
|
||||
}
|
||||
|
||||
Audio::AudioStream *stream = NLSample[num].stream;
|
||||
if (stream != nullptr && GSample[num]._flag & SOUNDFLAG_SLOOP)
|
||||
stream = Audio::makeLoopingAudioStream(NLSample[num].stream, 0);
|
||||
|
||||
g_system->getMixer()->playStream(NLSample[num].type, &smp[channel], stream, -1, volume, 0, DisposeAfterUse::NO);
|
||||
|
||||
playing[channel] = num;
|
||||
}
|
||||
|
||||
/* -----------------14/08/97 16.30-------------------
|
||||
NLStopSound
|
||||
--------------------------------------------------*/
|
||||
void NLStopSound(int num) {
|
||||
if (!SoundSystemActive || SoundSystemActive != SOUND_ON)
|
||||
if (!SoundSystemActive)
|
||||
return;
|
||||
|
||||
for (int a = 2; a < SpeechChannel; a++) {
|
||||
|
@ -237,7 +231,7 @@ void NLStopSound(int num) {
|
|||
SoundFadOut
|
||||
--------------------------------------------------*/
|
||||
void SoundFadOut() {
|
||||
if (!SoundSystemActive || SoundSystemActive != SOUND_ON)
|
||||
if (!SoundSystemActive)
|
||||
return;
|
||||
|
||||
for (int a = 0; a < SAMPLEVOICES; a++) { // spegne tutti i canali eccetto il background
|
||||
|
@ -255,7 +249,7 @@ void SoundFadOut() {
|
|||
SoundFadIn
|
||||
--------------------------------------------------*/
|
||||
void SoundFadIn(int num) {
|
||||
if (!SoundSystemActive || SoundSystemActive != SOUND_ON)
|
||||
if (!SoundSystemActive)
|
||||
return;
|
||||
|
||||
Audio::AudioStream *stream = NLSample[num].stream;
|
||||
|
@ -281,7 +275,7 @@ void WaitSoundFadEnd() {
|
|||
}
|
||||
|
||||
while ((SoundFadInVal != (GSample[playing[StepChannel]]._volume * FADMULT)) && (playing[StepChannel] != 0) && (SoundFadOutVal != 0))
|
||||
CheckSystem();
|
||||
g_vm->CheckSystem();
|
||||
SoundFadStatus = 0;
|
||||
|
||||
g_system->getMixer()->stopHandle(smp[BackChannel]);
|
||||
|
@ -395,21 +389,21 @@ int32 Talk(const char *name) {
|
|||
StopTalk();
|
||||
|
||||
int Len = SpeechFileLen(name);
|
||||
if ((Len > SPEECHSIZE) || (SoundSystemActive == SOUND_OFF)) {
|
||||
SpeechTrackEnabled = 0;
|
||||
return ((Len * 60L) / (11025));
|
||||
if (Len > SPEECHSIZE || !SoundSystemActive) {
|
||||
SpeechTrackEnabled = false;
|
||||
return (Len * 60L) / 11025;
|
||||
}
|
||||
if (SpeechFileRead(name, SpeechBuf[0]) == 0) {
|
||||
SpeechTrackEnabled = 0;
|
||||
return ((Len * 60L) / (11025));
|
||||
SpeechTrackEnabled = false;
|
||||
return (Len * 60L) / 11025;
|
||||
}
|
||||
|
||||
SpeechTrackEnabled = 1;
|
||||
SpeechTrackEnabled = true;
|
||||
if (LoadAudioWav(0xFFFF, SpeechBuf[0], Len))
|
||||
Len *= 2;
|
||||
|
||||
if ((SoundSystemActive == SOUND_OFF))
|
||||
SpeechTrackEnabled = 0;
|
||||
if (!SoundSystemActive)
|
||||
SpeechTrackEnabled = false;
|
||||
else {
|
||||
extern uint32 CharacterSpeakTime;
|
||||
g_system->getMixer()->playStream(SpeechSample.type, &smp[SpeechChannel], SpeechSample.stream);
|
||||
|
@ -423,7 +417,7 @@ void StopTalk() {
|
|||
if (SoundSystemActive)
|
||||
g_system->getMixer()->stopHandle(smp[SpeechChannel]);
|
||||
|
||||
SpeechTrackEnabled = 0;
|
||||
SpeechTrackEnabled = false;
|
||||
}
|
||||
|
||||
} // End of namespace Trecision
|
||||
|
|
|
@ -465,4 +465,13 @@ void TrecisionEngine::LoadAll() {
|
|||
|
||||
dataNl.close();
|
||||
}
|
||||
|
||||
/*-------------------------------------------------
|
||||
CheckSystem
|
||||
--------------------------------------------------*/
|
||||
void TrecisionEngine::CheckSystem() {
|
||||
_animMgr->refreshAllAnimations();
|
||||
eventLoop();
|
||||
}
|
||||
|
||||
} // End of namespace Trecision
|
||||
|
|
|
@ -55,6 +55,9 @@ public:
|
|||
void setInventoryStart(uint8 StartIcon, uint8 StartLine);
|
||||
void doInventory();
|
||||
|
||||
void CheckSystem();
|
||||
|
||||
|
||||
uint16 _curRoom;
|
||||
uint16 _oldRoom;
|
||||
SRoom _room[MAXROOMS];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue