Merge branch 'master' into pc98x1

This commit is contained in:
TC1995
2024-07-20 01:07:01 +02:00
2 changed files with 40 additions and 15 deletions

View File

@@ -186,7 +186,8 @@ device_add_common(const device_t *dev, void *p, void *params, int inst)
devices[c] = NULL;
device_priv[c] = NULL;
free(init_dev);
if ((init_dev != NULL) && (init_dev != (device_t *) dev))
free(init_dev);
return (NULL);
}

View File

@@ -553,8 +553,12 @@ sb_resume_dma(const sb_dsp_t *dsp, const int is_8)
} else if (is_8)
dma_set_drq(dsp->sb_8_dmanum, 1);
else {
if (dsp->sb_16_dmanum != 0xff)
dma_set_drq(dsp->sb_16_dmanum, 1);
if (dsp->sb_16_dmanum != 0xff) {
if (dsp->sb_16_dmanum == 4)
dma_set_drq(dsp->sb_8_dmanum, 1);
else
dma_set_drq(dsp->sb_16_dmanum, 1);
}
if (dsp->sb_16_8_dmanum != 0xff)
dma_set_drq(dsp->sb_16_8_dmanum, 1);
@@ -566,8 +570,12 @@ sb_stop_dma(const sb_dsp_t *dsp)
{
dma_set_drq(dsp->sb_8_dmanum, 0);
if (dsp->sb_16_dmanum != 0xff)
dma_set_drq(dsp->sb_16_dmanum, 0);
if (dsp->sb_16_dmanum != 0xff) {
if (dsp->sb_16_dmanum == 4)
dma_set_drq(dsp->sb_8_dmanum, 0);
else
dma_set_drq(dsp->sb_16_dmanum, 0);
}
if (dsp->sb_16_8_dmanum != 0xff)
dma_set_drq(dsp->sb_16_8_dmanum, 0);
@@ -609,9 +617,12 @@ sb_start_dma(sb_dsp_t *dsp, int dma8, int autoinit, uint8_t format, int len)
if (!timer_is_enabled(&dsp->output_timer))
timer_set_delay_u64(&dsp->output_timer, (uint64_t) dsp->sblatcho);
if (dsp->sb_16_dma_supported)
dma_set_drq(dsp->sb_16_dmanum, 1);
else
if (dsp->sb_16_dma_supported) {
if (dsp->sb_16_dmanum == 4)
dma_set_drq(dsp->sb_8_dmanum, 1);
else
dma_set_drq(dsp->sb_16_dmanum, 1);
} else
dma_set_drq(dsp->sb_16_8_dmanum, 1);
}
@@ -649,9 +660,12 @@ sb_start_dma_i(sb_dsp_t *dsp, int dma8, int autoinit, uint8_t format, int len)
if (!timer_is_enabled(&dsp->input_timer))
timer_set_delay_u64(&dsp->input_timer, (uint64_t) dsp->sblatchi);
if (dsp->sb_16_dma_supported)
dma_set_drq(dsp->sb_16_dmanum, 1);
else
if (dsp->sb_16_dma_supported) {
if (dsp->sb_16_dmanum == 4)
dma_set_drq(dsp->sb_8_dmanum, 1);
else
dma_set_drq(dsp->sb_16_dmanum, 1);
} else
dma_set_drq(dsp->sb_16_8_dmanum, 1);
}
@@ -761,13 +775,16 @@ sb_16_read_dma(void *priv)
int ret;
int dma_ch = dsp->sb_16_dmanum;
if (dsp->sb_16_dma_enabled && dsp->sb_16_dma_supported && !dsp->sb_16_dma_translate)
if (dsp->sb_16_dma_enabled && dsp->sb_16_dma_supported && !dsp->sb_16_dma_translate && (dma_ch != 4))
ret = dma_channel_read(dma_ch);
else {
if (dsp->sb_16_dma_enabled) {
/* High DMA channel enabled, either translation is enabled or
16-bit transfers are not supported. */
dma_ch = dsp->sb_16_8_dmanum;
if (dsp->sb_16_dma_supported && !dsp->sb_16_dma_translate && (dma_ch == 4))
dma_ch = dsp->sb_8_dmanum;
else
dma_ch = dsp->sb_16_8_dmanum;
} else
/* High DMA channel disabled, always use the first 8-bit channel. */
dma_ch = dsp->sb_8_dmanum;
@@ -795,13 +812,16 @@ sb_16_write_dma(void *priv, uint16_t val)
int dma_ch = dsp->sb_16_dmanum;
int ret;
if (dsp->sb_16_dma_enabled && dsp->sb_16_dma_supported && !dsp->sb_16_dma_translate)
if (dsp->sb_16_dma_enabled && dsp->sb_16_dma_supported && !dsp->sb_16_dma_translate && (dma_ch != 4))
ret = dma_channel_write(dma_ch, val) == DMA_NODATA;
else {
if (dsp->sb_16_dma_enabled) {
/* High DMA channel enabled, either translation is enabled or
16-bit transfers are not supported. */
dma_ch = dsp->sb_16_8_dmanum;
if (dsp->sb_16_dma_supported && !dsp->sb_16_dma_translate && (dma_ch == 4))
dma_ch = dsp->sb_8_dmanum;
else
dma_ch = dsp->sb_16_8_dmanum;
} else
/* High DMA channel disabled, always use the first 8-bit channel. */
dma_ch = dsp->sb_8_dmanum;
@@ -1886,6 +1906,10 @@ sb_read(uint16_t a, void *priv)
dsp->state = DSP_S_NORMAL;
break;
case 0xC: /* Write data ready */
/* Advance the state just in case something reads from here
without reading the status first. */
if (dsp->state == DSP_S_RESET_WAIT)
dsp->state = DSP_S_NORMAL;
if ((dsp->state == DSP_S_NORMAL) || IS_ESS(dsp)) {
if (dsp->sb_8_enable || dsp->sb_type >= SB16)
dsp->busy_count = (dsp->busy_count + 1) & 3;