diff --git a/include/ctrff/bcstm.hpp b/include/ctrff/bcstm.hpp index d2107b4..91dbf73 100644 --- a/include/ctrff/bcstm.hpp +++ b/include/ctrff/bcstm.hpp @@ -138,6 +138,7 @@ class CTRFF_API BCSTM { DSP_ADPCM_Param() {} PD::u16 Coefficients[0x10]; }; + struct DSP_ADPCM_Context { DSP_ADPCM_Context() : PredictorScale(0), diff --git a/source/bcstm.cpp b/source/bcstm.cpp index 4252243..2465030 100644 --- a/source/bcstm.cpp +++ b/source/bcstm.cpp @@ -147,15 +147,10 @@ CTRFF_API void BCSTM::ReadGotoBeginning(bool use_loop_beg) { size_t off = pDataBlockRef.Ref.Offset + 0x20; /** Shift to loop start if enabled */ if (use_loop_beg) { - off += GetNumBlocks() * GetNumChannels() * GetLoopStart(); - // off += GetNumChannels() * pInfoBlock.StreamInfo.LoopStartFrame; - } - // block_size * channel_count * loop_start - try { - pFile.seekg(off, std::ios::beg); - } catch (const std::exception& e) { - throw std::runtime_error(e.what()); + off += GetLoopStart() * GetBlockSize() * GetNumChannels(); } + pFile.seekg(off, std::ios::beg); + if (pFile.tellg() > pHeader.FileSize) { throw std::runtime_error("BCSTM: Seeked Out of range!"); }