@@ -214,37 +214,42 @@ namespace HyperSonicDrivers::hardware::opl::scummvm::dosbox
214
214
215
215
if (isStereo ())
216
216
{
217
- while (length_ > 0 )
217
+ if (m_emulator-> opl3Active ) // DUAL_OPL2 or OPL3 in OPL3 mode
218
218
{
219
- const unsigned int readSamples = std::min<unsigned int >(length_, bufferLength);
220
- const unsigned int readSamples2 = (readSamples << 1 );
221
- if (m_emulator->opl3Active )
219
+ while (length_ > 0 )
222
220
{
221
+ const unsigned int readSamples = std::min<unsigned int >(length_, bufferLength);
222
+ const unsigned int readSamples2 = (readSamples << 1 );
223
223
m_emulator->GenerateBlock3 (readSamples, tempBuffer.data ());
224
224
for (unsigned int i = 0 ; i < readSamples2; ++i)
225
225
buffer[i] = static_cast <int16_t >(tempBuffer[i]);
226
+
227
+ buffer += static_cast <int16_t >(readSamples2);
228
+ length_ -= readSamples;
226
229
}
227
- else
230
+ }
231
+ else // OPL3 in OPL2 compatibility mode
232
+ {
233
+ while (length_ > 0 )
228
234
{
235
+ const unsigned int readSamples = std::min<unsigned int >(length_, bufferLength);
236
+ const unsigned int readSamples2 = (readSamples << 1 );
229
237
m_emulator->GenerateBlock2 (readSamples, tempBuffer.data ());
230
- for (unsigned int i = 0 , j =0 ; i < readSamples; ++i, j+=2 )
231
- {
232
- buffer[j] = buffer[j+1 ] = static_cast <int16_t >(tempBuffer[i]);
233
- }
234
- }
238
+ for (unsigned int i = 0 , j = 0 ; i < readSamples; ++i, j += 2 )
239
+ buffer[j] = buffer[j + 1 ] = static_cast <int16_t >(tempBuffer[i]);
235
240
236
- buffer += static_cast <int16_t >(readSamples2);
237
- length_ -= readSamples;
241
+
242
+ buffer += static_cast <int16_t >(readSamples2);
243
+ length_ -= readSamples;
244
+ }
238
245
}
239
246
}
240
- else
247
+ else // OPL2
241
248
{
242
249
while (length_ > 0 )
243
250
{
244
251
const unsigned int readSamples = std::min<unsigned int >(length_, bufferLength << 1 );
245
-
246
252
m_emulator->GenerateBlock2 (readSamples, tempBuffer.data ());
247
-
248
253
for (unsigned int i = 0 ; i < readSamples; ++i)
249
254
buffer[i] = static_cast <int16_t >(tempBuffer[i]);
250
255
0 commit comments