Skip to content

Commit 89331ae

Browse files
committed
fix bugs in ICS2115 and MSM5232 cores
- ICS2115: fix chip reset also resetting channel muting - MSM5232: fix reset leaving some notes on, simplify TA7630 volume
1 parent 35fc3b7 commit 89331ae

File tree

2 files changed

+34
-34
lines changed

2 files changed

+34
-34
lines changed

emu/cores/ics2115.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static void ics2115_alloc_rom(void* info, UINT32 memsize);
5454
static void ics2115_write_rom(void *info, UINT32 offset, UINT32 length, const UINT8* data);
5555

5656
static void ics2115_set_mute_mask(void *info, UINT32 MuteMask);
57+
static UINT32 ics2115_get_mute_mask(void *info);
5758
static void ics2115_set_srchg_cb(void *info, DEVCB_SRATE_CHG CallbackFunc, void* DataPtr);
5859

5960
static DEVDEF_RWFUNC devFunc[] =
@@ -330,9 +331,11 @@ static void device_stop_ics2115(void *info)
330331

331332
static void device_reset_ics2115(void *info)
332333
{
333-
int i;
334-
335334
ics2115_state *chip = (ics2115_state *)info;
335+
int i;
336+
UINT32 muteMask;
337+
338+
muteMask = ics2115_get_mute_mask(chip);
336339
chip->irq_enabled = 0;
337340
chip->irq_pending = 0;
338341
//possible re-suss
@@ -371,6 +374,7 @@ static void device_reset_ics2115(void *info)
371374
v->state.on = false;
372375
v->state.ramp = 0;
373376
}
377+
ics2115_set_mute_mask(chip, muteMask);
374378
chip->output_rate = ics2115_get_output_rate(chip);
375379
if (chip->SmpRateFunc != NULL)
376380
chip->SmpRateFunc(chip->SmpRateData, chip->output_rate);
@@ -1309,6 +1313,19 @@ static void ics2115_set_mute_mask(void *info, UINT32 MuteMask)
13091313
return;
13101314
}
13111315

1316+
static UINT32 ics2115_get_mute_mask(void *info)
1317+
{
1318+
ics2115_state *chip = (ics2115_state *)info;
1319+
UINT32 muteMask;
1320+
UINT8 CurChn;
1321+
1322+
muteMask = 0x00000000;
1323+
for (CurChn = 0; CurChn < 32; CurChn ++)
1324+
muteMask |= (chip->voice[CurChn].Muted << CurChn);
1325+
1326+
return muteMask;
1327+
}
1328+
13121329
static void ics2115_set_srchg_cb(void *info, DEVCB_SRATE_CHG CallbackFunc, void* DataPtr)
13131330
{
13141331
ics2115_state *chip = (ics2115_state *)info;

emu/cores/msm5232.c

Lines changed: 15 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ typedef struct {
9292

9393
// --- TA7630 external volume (0..15, as used by Taito hardware) ---
9494
uint8_t ext_vol[MSM5232_EXTVOL_GROUPS]; // [0]=group1 0..3, [1]=group2 4..7
95-
double ext_vol_gain[MSM5232_EXTVOL_GROUPS]; // multiplier for output
9695

9796
UINT8 per_out_vol[MSM5232_NUM_OUTPUTS]; // per-output volume
9897
UINT8 Muted[MSM5232_NUM_OUTPUTS];
@@ -273,33 +272,8 @@ static UINT8 device_start_msm5232(const MSM5232_CFG* cfg, DEV_INFO* retDevInf)
273272
}
274273

275274
init_tables(chip);
276-
for (i = 0; i < MSM5232_NUM_CHANNELS; i++)
277-
{
278-
init_voice(chip, i);
279-
}
280275
msm5232_set_mute_mask(chip, 0);
281276

282-
chip->noise_rng = 1;
283-
chip->noise_out = 0;
284-
chip->noise_cnt = 0;
285-
chip->noise_clocks = 0;
286-
chip->control1 = chip->control2 = 0;
287-
chip->EN_out16[0] = chip->EN_out8[0] = chip->EN_out4[0] = chip->EN_out2[0] = 0;
288-
chip->EN_out16[1] = chip->EN_out8[1] = chip->EN_out4[1] = chip->EN_out2[1] = 0;
289-
290-
// --- TA7630 external volume defaults: max (0x0F) ---
291-
chip->ext_vol[0] = 0x0F;
292-
chip->ext_vol[1] = 0x0F;
293-
chip->ext_vol_gain[0] = chip->vol_ctrl[chip->ext_vol[0]];
294-
chip->ext_vol_gain[1] = chip->vol_ctrl[chip->ext_vol[1]];
295-
296-
// initialize per-output volume (0x80 = 100%)
297-
for (i = 0; i < MSM5232_NUM_OUTPUTS; i++)
298-
{
299-
// enable 0..7 by default, mute 8..10 (not connected in Taito machines)
300-
chip->per_out_vol[i] = (i >= 8) ? 0 : 0x80;
301-
}
302-
303277
chip->_devData.chipInf = chip;
304278
INIT_DEVINF(retDevInf, &chip->_devData, chip->sample_rate, &devDef);
305279
return 0x00;
@@ -323,14 +297,25 @@ static void device_reset_msm5232(void* info)
323297
msm5232_write(chip, i, 0x80);
324298
msm5232_write(chip, i, 0x00);
325299
}
326-
chip->noise_cnt = 0;
327300
chip->noise_rng = 1;
328-
chip->noise_out = 0;
301+
chip->noise_out = 0;
302+
chip->noise_cnt = 0;
329303
chip->noise_clocks = 0;
330304
chip->control1 = chip->control2 = 0;
331305
chip->EN_out16[0] = chip->EN_out8[0] = chip->EN_out4[0] = chip->EN_out2[0] = 0;
332306
chip->EN_out16[1] = chip->EN_out8[1] = chip->EN_out4[1] = chip->EN_out2[1] = 0;
333307

308+
// --- TA7630 external volume defaults: max (0x0F) ---
309+
chip->ext_vol[0] = 0x0F;
310+
chip->ext_vol[1] = 0x0F;
311+
312+
// initialize per-output volume (0x80 = 100%)
313+
for (i = 0; i < MSM5232_NUM_OUTPUTS; i++)
314+
{
315+
// enable 0..7 by default, mute 8..10 (not connected in Taito machines)
316+
chip->per_out_vol[i] = (i >= 8) ? 0 : 0x80;
317+
}
318+
334319
if (chip->SmpRateFunc)
335320
chip->SmpRateFunc(chip->SmpRateData, chip->sample_rate);
336321
}
@@ -564,8 +549,8 @@ static void device_update_msm5232(void* info, UINT32 samples, DEV_SMPL** outputs
564549
so16 = (group2.solo16 * chip->per_out_vol[9]) >> 7;
565550
nout = chip->noise_out * chip->per_out_vol[10]; // is 0 or "maximum volume"
566551
mix =
567-
(DEV_SMPL)((double)(g1o2 + g1o4 + g1o8 + g1o16) * chip->ext_vol_gain[0]) +
568-
(DEV_SMPL)((double)(g2o2 + g2o4 + g2o8 + g2o16) * chip->ext_vol_gain[1]) +
552+
(DEV_SMPL)((double)(g1o2 + g1o4 + g1o8 + g1o16) * chip->vol_ctrl[chip->ext_vol[0]]) +
553+
(DEV_SMPL)((double)(g2o2 + g2o4 + g2o8 + g2o16) * chip->vol_ctrl[chip->ext_vol[1]]) +
569554
(DEV_SMPL)(so8 + so16 + nout);
570555

571556
outL[i] = mix;
@@ -681,11 +666,9 @@ static void msm5232_write(void* info, UINT8 reg, UINT8 value)
681666
// --- TA7630 external volume for MSM5232 ---
682667
case 0x1E: // external volume for group 1 (ch 0..3)
683668
chip->ext_vol[0] = value & 0x0F;
684-
chip->ext_vol_gain[0] = chip->vol_ctrl[value & 0x0F];
685669
break;
686670
case 0x1F: // external volume for group 2 (ch 4..7)
687671
chip->ext_vol[1] = value & 0x0F;
688-
chip->ext_vol_gain[1] = chip->vol_ctrl[value & 0x0F];
689672
break;
690673
case 0x20: // chip clock, 000000xx
691674
case 0x21: // chip clock, 0000xx00

0 commit comments

Comments
 (0)