@@ -113,8 +113,8 @@ const DEV_DECL sndDev_ICS2115 =
113113
114114INLINE UINT8 count_leading_zeros_32 (UINT32 val )
115115{
116- if (!val ) return 32U ;
117116 UINT8 count ;
117+ if (!val ) return 32U ;
118118 for (count = 0 ; (INT32 )val >= 0 ; count ++ ) val <<= 1 ;
119119 return count ;
120120}
@@ -258,6 +258,8 @@ static UINT8 device_start_ics2115(const DEV_GEN_CFG* cfg, DEV_INFO* retDevInf)
258258{
259259 ics2115_state * chip ;
260260 int i ;
261+ UINT16 lut [8 ];
262+ UINT16 lut_initial ;
261263
262264 chip = (ics2115_state * )calloc (1 , sizeof (ics2115_state ));
263265 if (chip == NULL )
@@ -290,8 +292,7 @@ static UINT8 device_start_ics2115(const DEV_GEN_CFG* cfg, DEV_INFO* retDevInf)
290292 chip -> volume [i ] = ((0x100 | (i & 0xff )) << (VOLUME_BITS - 9 )) >> (15 - (i >>8 ));
291293
292294 //u-Law table as per MIL-STD-188-113
293- UINT16 lut [8 ];
294- UINT16 lut_initial = 33 << 2 ; //shift up 2-bits for 16-bit range.
295+ lut_initial = 33 << 2 ; //shift up 2-bits for 16-bit range.
295296 for (i = 0 ; i < 8 ; i ++ )
296297 lut [i ] = (lut_initial << i ) - lut_initial ;
297298
@@ -571,6 +572,9 @@ static INT32 get_sample(ics2115_state *chip, ics2115_voice *voice)
571572{
572573 UINT32 curaddr = voice -> osc .acc >> 12 ;
573574 UINT32 nextaddr ;
575+ INT16 sample1 , sample2 ;
576+ INT32 diff ;
577+ UINT16 fract ;
574578
575579 if (voice -> state .on && voice -> osc_conf .bitflags .loop && !voice -> osc_conf .bitflags .loop_bidir &&
576580 (voice -> osc .left < (voice -> osc .fc << 2 )))
@@ -581,7 +585,6 @@ static INT32 get_sample(ics2115_state *chip, ics2115_voice *voice)
581585 else
582586 nextaddr = curaddr + 2 ;
583587
584- INT16 sample1 , sample2 ;
585588 if (voice -> osc_conf .bitflags .ulaw )
586589 {
587590 sample1 = chip -> ulaw [read_sample (chip , voice , curaddr )];
@@ -601,16 +604,15 @@ static INT32 get_sample(ics2115_state *chip, ics2115_voice *voice)
601604
602605 //linear interpolation as in US patent 6,246,774 B1, column 2 row 59
603606 //LEN=1, BLEN=0, DIR=0, start+end interpolation
604- INT32 diff = sample2 - sample1 ;
605- UINT16 fract = (voice -> osc .acc >> 3 ) & 0x1ff ;
607+ diff = sample2 - sample1 ;
608+ fract = (voice -> osc .acc >> 3 ) & 0x1ff ;
606609
607610 //no need for interpolation since it's around 1 note a cycle?
608611 //if (!fract)
609612 // return sample1;
610613
611- INT32 sample = (((INT32 )sample1 << 9 ) + diff * fract ) >> 9 ;
612- //sample = sample1;
613- return sample ;
614+ //return sample1;
615+ return (((INT32 )sample1 << 9 ) + diff * fract ) >> 9 ;
614616}
615617
616618static bool playing (ics2115_voice * voice )
@@ -638,11 +640,12 @@ static void update_ramp(ics2115_voice *voice)
638640
639641static UINT8 fill_output (ics2115_state * chip , ics2115_voice * voice , UINT32 samples , INT32 * loutput , INT32 * routput )
640642{
643+ UINT32 i ;
641644 UINT8 irq_invalid = 0 ;
642645 UINT16 fine = 1 << (3 * (voice -> vol .incr >> 6 ));
643646 voice -> vol .add = (voice -> vol .incr & 0x3f ) << (10 - fine );
644647
645- for (int i = 0 ; i < samples ; i ++ )
648+ for (i = 0 ; i < samples ; i ++ )
646649 {
647650 UINT32 volacc = (voice -> vol .acc >> 14 ) & 0xfff ;
648651 INT16 vlefti = volacc - chip -> panlaw [255 - voice -> vol .pan ]; // left index from acc - pan law
@@ -681,14 +684,16 @@ static UINT8 fill_output(ics2115_state *chip, ics2115_voice *voice, UINT32 sampl
681684static void ics2115_update (void * param , UINT32 samples , DEV_SMPL * * outputs )
682685{
683686 ics2115_state * chip = (ics2115_state * )param ;
687+ UINT8 irq_invalid ;
688+ int osc ;
684689
685690 memset (outputs [0 ], 0 , samples * sizeof (DEV_SMPL ));
686691 memset (outputs [1 ], 0 , samples * sizeof (DEV_SMPL ));
687692 if (chip -> rom == NULL )
688693 return ;
689694
690- UINT8 irq_invalid = 0 ;
691- for (int osc = 0 ; osc <= chip -> active_osc ; osc ++ )
695+ irq_invalid = 0 ;
696+ for (osc = 0 ; osc <= chip -> active_osc ; osc ++ )
692697 {
693698 ics2115_voice * voice = & chip -> voice [osc ];
694699
@@ -1061,7 +1066,7 @@ static void reg_write(ics2115_state *chip, UINT16 data, UINT16 mem_mask)
10611066 if (ACCESSING_BITS_8_15 )
10621067 {
10631068 data >>= 8 ;
1064- voice -> osc .ctl = data ;
1069+ voice -> osc .ctl = ( UINT8 ) data ;
10651070 voice -> state .on = !voice -> osc .ctl ; // some early PGM games need this
10661071 if (!data )
10671072 keyon (chip );
@@ -1167,10 +1172,11 @@ static UINT8 ics2115_byte_r(void *info, UINT8 offset)
11671172 //TODO: check this suspect code
11681173 if (chip -> irq_on )
11691174 {
1175+ int i ;
11701176 ret |= 0x80 ;
11711177 if (chip -> irq_enabled && (chip -> irq_pending & 3 ))
11721178 ret |= 1 ;
1173- for (int i = 0 ; i <= chip -> active_osc ; i ++ )
1179+ for (i = 0 ; i <= chip -> active_osc ; i ++ )
11741180 {
11751181 if (//chip->voice[i].vol_ctrl.bitflags.irq_pending ||
11761182 chip -> voice [i ].osc_conf .bitflags .irq_pending )
0 commit comments