- YM2612UpdateOne_(buffer, length, stereo);
-
- /* mix data */
- if (stereo) {
- int *mb = mix_buffer;
- for (i = length; i > 0; i--) {
- int l, r;
- l = r = *buffer;
- l += *mb++, r += *mb++;
- Limit( l, MAXOUT, MINOUT );
- Limit( r, MAXOUT, MINOUT );
- *buffer++ = l; *buffer++ = r;
+static FILE *loaded_mp3 = 0;
+
+int YM2612UpdateOne_940(int *buffer, int length, int stereo, int is_buf_empty)
+{
+#if 0
+ int cdda_on, *ym_buffer = mix_buffer;
+ static int mp3_samples_ready = 0, mp3_buffer_offs = 0;
+ static int mp3_play_bufsel = 1;
+
+
+ YM2612UpdateOne_(buffer, length, stereo); // really writes to mix_buffer
+
+ // emulatind MCD, not data track, CDC is reading, playback was started, track not ended
+ cdda_on = (PicoMCD & 1) && !(Pico_mcd->s68k_regs[0x36] & 1) && (Pico_mcd->scd.Status_CDC & 1)
+ && loaded_mp3 && shared_ctl->mp3_offs < shared_ctl->mp3_len;
+
+ /* mix data from previous go */
+ if (cdda_on && mp3_samples_ready >= length)
+ {
+ if (1152 - mp3_buffer_offs >= length) {
+ mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, length, stereo);
+
+ mp3_buffer_offs += length;
+ } else {
+ // collect from both buffers..
+ int left = 1152 - mp3_buffer_offs;
+ mix_samples(buffer, ym_buffer, shared_data->mp3_buffer[mp3_play_bufsel] + mp3_buffer_offs*2, left, stereo);
+ mp3_play_bufsel ^= 1;
+ mp3_buffer_offs = length - left;
+ mix_samples(buffer + left * 2, ym_buffer + left * 2,
+ shared_data->mp3_buffer[mp3_play_bufsel], mp3_buffer_offs, stereo);