From bf07930b8c3980c2e33bd6dd14c40eeff40c2617 Mon Sep 17 00:00:00 2001 From: nukeykt Date: Thu, 19 Sep 2019 22:38:28 +0900 Subject: [PATCH] wip --- source/audiolib/src/multivoc.cpp | 4 ++++ source/exhumed/src/exhumed.cpp | 5 ++--- source/exhumed/src/sequence.cpp | 7 ++++--- source/exhumed/src/sound.cpp | 21 ++++++++++++--------- source/exhumed/src/sound.h | 1 + 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/source/audiolib/src/multivoc.cpp b/source/audiolib/src/multivoc.cpp index e75379a7a..4755b448a 100644 --- a/source/audiolib/src/multivoc.cpp +++ b/source/audiolib/src/multivoc.cpp @@ -502,7 +502,11 @@ int32_t MV_GetFrequency(int32_t handle, int32_t *frequency) if (voice == NULL || !frequency) return MV_Error; + if (voice->SamplingRate == 0) + voice->GetSound(voice); + *frequency = voice->SamplingRate; + MV_EndService(); return MV_Ok; } diff --git a/source/exhumed/src/exhumed.cpp b/source/exhumed/src/exhumed.cpp index be99a04f3..6f2c022bb 100644 --- a/source/exhumed/src/exhumed.cpp +++ b/source/exhumed/src/exhumed.cpp @@ -1860,6 +1860,8 @@ int app_main(int argc, char const* const* argv) SetupInput(); InitView(); myloadconfig(); + InitFX(); + LoadFX(); setCDaudiovolume(gMusicVolume); seq_LoadSequences(); InitStatus(); @@ -1877,9 +1879,6 @@ int app_main(int argc, char const* const* argv) ResetEngine(); EraseScreen(overscanindex); - InitFX(); - LoadFX(); - ResetView(); GrabPalette(); diff --git a/source/exhumed/src/sequence.cpp b/source/exhumed/src/sequence.cpp index 098327d77..61e861b1f 100644 --- a/source/exhumed/src/sequence.cpp +++ b/source/exhumed/src/sequence.cpp @@ -191,6 +191,8 @@ int seq_ReadSequence(const char *seqName) SeqBase[sequences + i] += frames; } + short vdi = frames; + int16_t nFrames; kread(hFile, &nFrames, sizeof(nFrames)); @@ -269,10 +271,9 @@ int seq_ReadSequence(const char *seqName) kread(hFile, &var_28, sizeof(var_28)); kread(hFile, &var_2C, sizeof(var_2C)); - int hSound = 0; - // int hSound = LoadSound(); + int hSound = LoadSound(&buffer[(var_2C&0x1FF)*10]); - FrameSound[frames + var_28] = hSound | (var_2C & 0xFE00); + FrameSound[vdi + var_28] = hSound | (var_2C & 0xFE00); } } diff --git a/source/exhumed/src/sound.cpp b/source/exhumed/src/sound.cpp index 37461f209..e6a68e847 100644 --- a/source/exhumed/src/sound.cpp +++ b/source/exhumed/src/sound.cpp @@ -746,8 +746,8 @@ void UpdateSounds() } else { - dx = sprite[nSoundSprite].x-pASound->f_1e; - dy = sprite[nSoundSprite].y-pASound->f_22; + dx = x-sprite[nSoundSprite].x; + dy = y-sprite[nSoundSprite].y; } dx >>= 8; @@ -815,14 +815,17 @@ void UpdateSounds() if (nCreaturesLeft > 0 && !(SectFlag[nPlayerViewSect[nLocalPlayer]]&0x2000)) { int vsi = seq_GetFrameSound(SeqOffsets[kSeqCreepy], totalmoves%SeqSize[SeqOffsets[kSeqCreepy]]); - int vdx = (totalmoves+32)&31; - if (totalmoves & 1) - vdx = -vdx; - int vax = (totalmoves+32)&63; - if (totalmoves & 2) - vax = -vax; + if (vsi >= 0 && (vsi&0x1ff) < kMaxSounds) + { + int vdx = (totalmoves+32)&31; + if (totalmoves & 1) + vdx = -vdx; + int vax = (totalmoves+32)&63; + if (totalmoves & 2) + vax = -vax; - PlayFXAtXYZ(vsi, pSprite->x+vdx, pSprite->y+vax, pSprite->z, pSprite->sectnum); + PlayFXAtXYZ(vsi, pSprite->x+vdx, pSprite->y+vax, pSprite->z, pSprite->sectnum); + } } nCreepyTimer = 450; } diff --git a/source/exhumed/src/sound.h b/source/exhumed/src/sound.h index b25706554..72b39d4e2 100644 --- a/source/exhumed/src/sound.h +++ b/source/exhumed/src/sound.h @@ -103,6 +103,7 @@ int GetLocalSound(); void UpdateLocalSound(); void StopLocalSound(); void PlayLocalSound(short nSound, short val); +int LoadSound(const char* sound); void BendAmbientSound(); void CheckAmbience(short nSector);