More sonarlint work

This commit is contained in:
Jasmine Iwanek
2023-06-09 23:46:54 -04:00
parent 0d1d069af4
commit ee695e71f9
218 changed files with 6282 additions and 3845 deletions

View File

@@ -41,6 +41,7 @@
#include <86box/sound.h>
#include <86box/timer.h>
#include <86box/snd_sb.h>
#include <86box/plat_unused.h>
/* 0 to 7 -> -14dB to 0dB i 2dB steps. 8 to 15 -> 0 to +14dB in 2dB steps.
Note that for positive dB values, this is not amplitude, it is amplitude - 1. */
@@ -177,9 +178,9 @@ sb_log(const char *fmt, ...)
/* SB 1, 1.5, MCV, and 2 do not have a mixer, so signal is hardwired. */
static void
sb_get_buffer_sb2(int32_t *buffer, int len, void *p)
sb_get_buffer_sb2(int32_t *buffer, int len, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
double out_mono = 0.0;
double out_l = 0.0;
@@ -245,9 +246,9 @@ sb_get_buffer_sb2(int32_t *buffer, int len, void *p)
}
static void
sb2_filter_cd_audio(int channel, double *buffer, void *p)
sb2_filter_cd_audio(UNUSED(int channel), double *buffer, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
double c;
@@ -255,15 +256,15 @@ sb2_filter_cd_audio(int channel, double *buffer, void *p)
c = ((sb_iir(1, 0, *buffer) / 1.3) * mixer->cd) / 3.0;
*buffer = c * mixer->master;
} else {
c = (((sb_iir(1, 0, ((double) *buffer)) / 1.3) * 65536) / 3.0) / 65536.0;
c = (((sb_iir(1, 0, (*buffer)) / 1.3) * 65536) / 3.0) / 65536.0;
*buffer = c;
}
}
void
sb_get_buffer_sbpro(int32_t *buffer, int len, void *p)
sb_get_buffer_sbpro(int32_t *buffer, int len, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
double out_l = 0.0;
double out_r = 0.0;
@@ -281,7 +282,8 @@ sb_get_buffer_sbpro(int32_t *buffer, int len, void *p)
sb_dsp_update(&sb->dsp);
for (int c = 0; c < len * 2; c += 2) {
out_l = 0.0, out_r = 0.0;
out_l = 0.0;
out_r = 0.0;
if (sb->opl_enabled) {
if (sb->dsp.sb_type == SBPRO) {
@@ -327,9 +329,9 @@ sb_get_buffer_sbpro(int32_t *buffer, int len, void *p)
}
void
sbpro_filter_cd_audio(int channel, double *buffer, void *p)
sbpro_filter_cd_audio(int channel, double *buffer, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
double c;
double cd = channel ? mixer->cd_r : mixer->cd_l;
@@ -343,9 +345,9 @@ sbpro_filter_cd_audio(int channel, double *buffer, void *p)
}
static void
sb_get_buffer_sb16_awe32(int32_t *buffer, int len, void *p)
sb_get_buffer_sb16_awe32(int32_t *buffer, int len, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
int dsp_rec_pos = sb->dsp.record_pos_write;
int c_emu8k = 0;
@@ -477,9 +479,9 @@ sb_get_buffer_sb16_awe32(int32_t *buffer, int len, void *p)
}
void
sb16_awe32_filter_cd_audio(int channel, double *buffer, void *p)
sb16_awe32_filter_cd_audio(int channel, double *buffer, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
double c;
double cd = channel ? mixer->cd_r : mixer->cd_l /* / 3.0 */;
@@ -519,9 +521,9 @@ sb16_awe32_filter_cd_audio(int channel, double *buffer, void *p)
}
void
sb_ct1335_mixer_write(uint16_t addr, uint8_t val, void *p)
sb_ct1335_mixer_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
if (!(addr & 1)) {
@@ -558,9 +560,9 @@ sb_ct1335_mixer_write(uint16_t addr, uint8_t val, void *p)
}
uint8_t
sb_ct1335_mixer_read(uint16_t addr, void *p)
sb_ct1335_mixer_read(uint16_t addr, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1335_mixer_t *mixer = &sb->mixer_sb2;
if (!(addr & 1))
@@ -589,9 +591,9 @@ sb_ct1335_mixer_reset(sb_t *sb)
}
void
sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p)
sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
if (!(addr & 1)) {
@@ -685,9 +687,9 @@ sb_ct1345_mixer_write(uint16_t addr, uint8_t val, void *p)
}
uint8_t
sb_ct1345_mixer_read(uint16_t addr, void *p)
sb_ct1345_mixer_read(uint16_t addr, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1345_mixer_t *mixer = &sb->mixer_sbpro;
if (!(addr & 1))
@@ -727,9 +729,9 @@ sb_ct1345_mixer_reset(sb_t *sb)
}
void
sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *p)
sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
if (!(addr & 1))
@@ -861,6 +863,9 @@ sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *p)
mpu401_change_addr(sb->mpu, 0);
}
break;
default:
break;
}
mixer->output_selector = mixer->regs[0x3c];
@@ -897,9 +902,9 @@ sb_ct1745_mixer_write(uint16_t addr, uint8_t val, void *p)
}
uint8_t
sb_ct1745_mixer_read(uint16_t addr, void *p)
sb_ct1745_mixer_read(uint16_t addr, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_ct1745_mixer_t *mixer = &sb->mixer_sb16;
uint8_t temp;
uint8_t ret = 0xff;
@@ -974,6 +979,9 @@ sb_ct1745_mixer_read(uint16_t addr, void *p)
case 10:
ret = 8;
break;
default:
break;
}
break;
@@ -996,6 +1004,9 @@ sb_ct1745_mixer_read(uint16_t addr, void *p)
case 3:
ret |= 8;
break;
default:
break;
}
switch (sb->dsp.sb_16_dmanum) {
case 5:
@@ -1007,6 +1018,9 @@ sb_ct1745_mixer_read(uint16_t addr, void *p)
case 7:
ret |= 0x80;
break;
default:
break;
}
break;
@@ -1078,9 +1092,9 @@ sb_ct1745_mixer_reset(sb_t *sb)
}
uint8_t
sb_mcv_read(int port, void *p)
sb_mcv_read(int port, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_log("sb_mcv_read: port=%04x\n", port);
@@ -1088,10 +1102,10 @@ sb_mcv_read(int port, void *p)
}
void
sb_mcv_write(int port, uint8_t val, void *p)
sb_mcv_write(int port, uint8_t val, void *priv)
{
uint16_t addr;
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
if (port < 0x102)
return;
@@ -1133,17 +1147,17 @@ sb_mcv_write(int port, uint8_t val, void *p)
}
uint8_t
sb_mcv_feedb(void *p)
sb_mcv_feedb(void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
return (sb->pos_regs[2] & 1);
}
static uint8_t
sb_pro_mcv_read(int port, void *p)
sb_pro_mcv_read(int port, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
uint8_t ret = sb->pos_regs[port & 7];
sb_log("sb_pro_mcv_read: port=%04x ret=%02x\n", port, ret);
@@ -1152,10 +1166,10 @@ sb_pro_mcv_read(int port, void *p)
}
static void
sb_pro_mcv_write(int port, uint8_t val, void *p)
sb_pro_mcv_write(int port, uint8_t val, void *priv)
{
uint16_t addr;
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
if (port < 0x102)
return;
@@ -1212,9 +1226,9 @@ sb_pro_mcv_write(int port, uint8_t val, void *p)
}
static uint8_t
sb_16_reply_mca_read(int port, void *p)
sb_16_reply_mca_read(int port, void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
uint8_t ret = sb->pos_regs[port & 7];
sb_log("sb_16_reply_mca_read: port=%04x ret=%02x\n", port, ret);
@@ -1223,13 +1237,13 @@ sb_16_reply_mca_read(int port, void *p)
}
static void
sb_16_reply_mca_write(int port, uint8_t val, void *p)
sb_16_reply_mca_write(int port, uint8_t val, void *priv)
{
uint16_t addr;
uint16_t mpu401_addr;
int low_dma;
int high_dma;
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
if (port < 0x102)
return;
@@ -1347,6 +1361,9 @@ sb_16_reply_mca_write(int port, uint8_t val, void *p)
case 0x60:
sb_dsp_setirq(&sb->dsp, 10);
break;
default:
break;
}
low_dma = sb->pos_regs[3] & 3;
@@ -1458,6 +1475,9 @@ sb_16_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *priv)
case 4: /* StereoEnhance (32) */
break;
default:
break;
}
}
@@ -1476,6 +1496,9 @@ sb_awe32_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, void *pr
case 3: /* WaveTable */
sb_16_pnp_config_changed(ld ^ 1, config, sb);
break;
default:
break;
}
}
@@ -1493,11 +1516,14 @@ sb_awe64_gold_pnp_config_changed(uint8_t ld, isapnp_device_config_t *config, voi
case 1: /* Game */
sb_16_pnp_config_changed(3, config, sb);
break;
default:
break;
}
}
void *
sb_1_init(const device_t *info)
sb_1_init(UNUSED(const device_t *info))
{
/* SB1/2 port mappings, 210h to 260h in 10h steps
2x0 to 2x3 -> CMS chip
@@ -1545,7 +1571,7 @@ sb_1_init(const device_t *info)
}
void *
sb_15_init(const device_t *info)
sb_15_init(UNUSED(const device_t *info))
{
/* SB1/2 port mappings, 210h to 260h in 10h steps
2x0 to 2x3 -> CMS chip
@@ -1595,7 +1621,7 @@ sb_15_init(const device_t *info)
}
void *
sb_mcv_init(const device_t *info)
sb_mcv_init(UNUSED(const device_t *info))
{
/* SB1/2 port mappings, 210h to 260h in 10h steps
2x6, 2xA, 2xC, 2xE -> DSP chip
@@ -1628,7 +1654,7 @@ sb_mcv_init(const device_t *info)
}
void *
sb_2_init(const device_t *info)
sb_2_init(UNUSED(const device_t *info))
{
/* SB2 port mappings, 220h or 240h.
2x0 to 2x3 -> CMS chip
@@ -1724,7 +1750,7 @@ sb_pro_v1_opl_write(uint16_t port, uint8_t val, void *priv)
}
static void *
sb_pro_v1_init(const device_t *info)
sb_pro_v1_init(UNUSED(const device_t *info))
{
/* SB Pro port mappings, 220h or 240h.
2x0 to 2x3 -> FM chip, Left and Right (9*2 voices)
@@ -1784,7 +1810,7 @@ sb_pro_v1_init(const device_t *info)
}
static void *
sb_pro_v2_init(const device_t *info)
sb_pro_v2_init(UNUSED(const device_t *info))
{
/* SB Pro 2 port mappings, 220h or 240h.
2x0 to 2x3 -> FM chip (18 voices)
@@ -1836,7 +1862,7 @@ sb_pro_v2_init(const device_t *info)
}
static void *
sb_pro_mcv_init(const device_t *info)
sb_pro_mcv_init(UNUSED(const device_t *info))
{
/* SB Pro MCV port mappings, 220h or 240h.
2x0 to 2x3 -> FM chip, Left and Right (18 voices)
@@ -1868,7 +1894,7 @@ sb_pro_mcv_init(const device_t *info)
}
static void *
sb_pro_compat_init(const device_t *info)
sb_pro_compat_init(UNUSED(const device_t *info))
{
sb_t *sb = malloc(sizeof(sb_t));
memset(sb, 0, sizeof(sb_t));
@@ -1890,7 +1916,7 @@ sb_pro_compat_init(const device_t *info)
}
static void *
sb_16_init(const device_t *info)
sb_16_init(UNUSED(const device_t *info))
{
sb_t *sb = malloc(sizeof(sb_t));
uint16_t addr = device_get_config_hex16("base");
@@ -1946,7 +1972,7 @@ sb_16_init(const device_t *info)
}
static void *
sb_16_reply_mca_init(const device_t *info)
sb_16_reply_mca_init(UNUSED(const device_t *info))
{
sb_t *sb = malloc(sizeof(sb_t));
memset(sb, 0x00, sizeof(sb_t));
@@ -1981,7 +2007,7 @@ sb_16_reply_mca_init(const device_t *info)
}
static void *
sb_16_pnp_init(const device_t *info)
sb_16_pnp_init(UNUSED(const device_t *info))
{
sb_t *sb = malloc(sizeof(sb_t));
memset(sb, 0x00, sizeof(sb_t));
@@ -2083,7 +2109,7 @@ sb_awe64_gold_available(void)
}
static void *
sb_awe32_init(const device_t *info)
sb_awe32_init(UNUSED(const device_t *info))
{
sb_t *sb = malloc(sizeof(sb_t));
uint16_t addr = device_get_config_hex16("base");
@@ -2194,6 +2220,9 @@ sb_awe32_pnp_init(const device_t *info)
case 4:
pnp_rom_file = "roms/sound/CT4540 PnP.BIN";
break;
default:
break;
}
uint8_t *pnp_rom = NULL;
@@ -2220,6 +2249,9 @@ sb_awe32_pnp_init(const device_t *info)
case 4:
isapnp_add_card(pnp_rom, sizeof(sb->pnp_rom), sb_awe64_gold_pnp_config_changed, NULL, NULL, NULL, sb);
break;
default:
break;
}
sb_dsp_setaddr(&sb->dsp, 0);
@@ -2238,18 +2270,18 @@ sb_awe32_pnp_init(const device_t *info)
}
void
sb_close(void *p)
sb_close(void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_dsp_close(&sb->dsp);
free(sb);
}
static void
sb_awe32_close(void *p)
sb_awe32_close(void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
emu8k_close(&sb->emu8k);
@@ -2257,9 +2289,9 @@ sb_awe32_close(void *p)
}
void
sb_speed_changed(void *p)
sb_speed_changed(void *priv)
{
sb_t *sb = (sb_t *) p;
sb_t *sb = (sb_t *) priv;
sb_dsp_speed_changed(&sb->dsp);
}