CD-ROM and Iomega ZIP PIO request length is now reduced if it is bigger than the remaining amount of bytes to transfer;

Fixed CD-ROM sector reading from CUE/BIN images with 2048-byte sectors;
Fixed existing CD-ROM Mode 2 support and adding support for the remaining variants of Mode 2;
The Windows CD-ROM IOCTL code now correctly determines the track type, fixes CD Audio over IOCTL;
Applied all PCem sound-related commits;
Sound Blaster 16/AWE32 mixer effects now also apply to CD Audio when the Sound Blaster 16 or AWE32 is selected.
This commit is contained in:
OBattler
2018-02-15 23:14:44 +01:00
parent 07bc427839
commit 6cab207231
11 changed files with 514 additions and 169 deletions

View File

@@ -4,6 +4,7 @@
486-50 - 32kHz
Pentium - 45kHz*/
#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
@@ -15,6 +16,7 @@
#include "../dma.h"
#include "../timer.h"
#include "../device.h"
#include "filters.h"
#include "sound.h"
#include "midi.h"
#include "snd_mpu401.h"
@@ -115,6 +117,41 @@ uint16_t sb_dsp_versions[] = {0, 0, 0x105, 0x200, 0x201, 0x300, 0x302, 0x405, 0x
252, 0, 252, 0
};
float low_fir_sb16_coef[SB16_NCoef];
static inline double sinc(double x)
{
return sin(M_PI * x) / (M_PI * x);
}
static void recalc_sb16_filter(int playback_freq)
{
/*Cutoff frequency = playback / 2*/
float fC = ((float)playback_freq / 2.0) / 48000.0;
float gain;
int n;
for (n = 0; n < SB16_NCoef; n++)
{
/*Blackman window*/
double w = 0.42 - (0.5 * cos((2.0*n*M_PI)/(double)(SB16_NCoef-1))) + (0.08 * cos((4.0*n*M_PI)/(double)(SB16_NCoef-1)));
/*Sinc filter*/
double h = sinc(2.0 * fC * ((double)n - ((double)(SB16_NCoef-1) / 2.0)));
/*Create windowed-sinc filter*/
low_fir_sb16_coef[n] = w * h;
}
low_fir_sb16_coef[(SB16_NCoef - 1) / 2] = 1.0;
gain = 0.0;
for (n = 0; n < SB16_NCoef; n++)
gain += low_fir_sb16_coef[n];
/*Normalise filter, to produce unity gain*/
for (n = 0; n < SB16_NCoef; n++)
low_fir_sb16_coef[n] /= gain;
}
void sb_irq(sb_dsp_t *dsp, int irq8)
@@ -423,6 +460,8 @@ void sb_exec_command(sb_dsp_t *dsp)
temp = 256 - dsp->sb_data[0];
temp = 1000000 / temp;
// pclog("Sample rate - %ihz (%i)\n",temp, dsp->sblatcho);
if (dsp->sb_freq != temp && dsp->sb_type >= SB16)
recalc_sb16_filter(temp);
dsp->sb_freq = temp;
break;
case 0x41: /*Set output sampling rate*/
@@ -430,10 +469,13 @@ void sb_exec_command(sb_dsp_t *dsp)
if (dsp->sb_type < SB16) break;
dsp->sblatcho = (int)(TIMER_USEC * (1000000.0f / (float)(dsp->sb_data[1] + (dsp->sb_data[0] << 8))));
// pclog("Sample rate - %ihz (%i)\n",dsp->sb_data[1]+(dsp->sb_data[0]<<8), dsp->sblatcho);
temp = dsp->sb_freq;
dsp->sb_freq = dsp->sb_data[1] + (dsp->sb_data[0] << 8);
dsp->sb_timeo = 256LL + dsp->sb_freq;
dsp->sblatchi = dsp->sblatcho;
dsp->sb_timei = dsp->sb_timeo;
if (dsp->sb_freq != temp && dsp->sb_type >= SB16)
recalc_sb16_filter(dsp->sb_freq);
break;
case 0x48: /*Set DSP block transfer size*/
dsp->sb_8_autolen = dsp->sb_data[0] + (dsp->sb_data[1] << 8);
@@ -773,6 +815,10 @@ void sb_dsp_init(sb_dsp_t *dsp, int type)
timer_add(pollsb, &dsp->sbcount, &dsp->sbenable, dsp);
timer_add(sb_poll_i, &dsp->sb_count_i, &dsp->sb_enable_i, dsp);
timer_add(sb_wb_clear, &dsp->wb_time, &dsp->wb_time, dsp);
/*Initialise SB16 filter to same cutoff as 8-bit SBs (3.2 kHz). This will be recalculated when
a set frequency command is sent.*/
recalc_sb16_filter(3200*2);
}
void sb_dsp_setaddr(sb_dsp_t *dsp, uint16_t addr)