@@ -34,16 +34,15 @@ void sgu1_init(sgu1_t* sgu, const sgu1_desc_t* desc) {
3434 sgu->sample_counter = sgu->sample_period ;
3535 sgu->sample_mag = desc->magnitude ;
3636 // sgu->sample_accum_count[0] = sgu->sample_accum_count[1] = 1.0f;
37- sgu->su = new SoundUnit ();
3837 sgu->tick_period = (desc->tick_hz * SGU1_FIXEDPOINT_SCALE) / (CHIP_CLOCK / CHIP_DIVIDER);
3938 sgu->tick_counter = sgu->tick_period ;
40- SoundUnit_Init (sgu->su , 65536 , false );
39+ SoundUnit_Init (& sgu->su , 65536 , false );
4140 sgu->resampler = speex_resampler_init (SGU1_AUDIO_CHANNELS, CHIP_CLOCK / CHIP_DIVIDER, sgu->sound_hz , 10 , nullptr );
4241}
4342
4443void sgu1_reset (sgu1_t * sgu) {
4544 CHIPS_ASSERT (sgu);
46- SoundUnit_Reset (sgu->su );
45+ SoundUnit_Reset (& sgu->su );
4746 memset (sgu->reg , 0 , sizeof (sgu->reg ));
4847 sgu->tick_counter = sgu->tick_period ;
4948 sgu->sample_counter = sgu->sample_period ;
@@ -59,14 +58,14 @@ static uint64_t _sgu1_tick(sgu1_t* sgu, uint64_t pins) {
5958 if (sgu->tick_counter <= 0 ) {
6059 sgu->tick_counter += sgu->tick_period ;
6160 short l, r;
62- SoundUnit_NextSample (sgu->su , &l, &r);
61+ SoundUnit_NextSample (& sgu->su , &l, &r);
6362 float in[2 ] = { ((float )l / 32767 .0f ), ((float )r / 32767 .0f ) };
6463 spx_uint32_t in_len = 1 ; // 1 stereo frame
6564 spx_uint32_t out_len = 1 ; // room for 1 stereo frame
6665 speex_resampler_process_interleaved_float (sgu->resampler , in, &in_len, sgu->sample , &out_len);
6766
6867 for (int i = 0 ; i < SGU1_NUM_CHANNELS; i++) {
69- sgu->voice [i].sample_buffer [sgu->voice [i].sample_pos ++] = (float )SoundUnit_GetSample (sgu->su , i);
68+ sgu->voice [i].sample_buffer [sgu->voice [i].sample_pos ++] = (float )SoundUnit_GetSample (& sgu->su , i);
7069 if (sgu->voice [i].sample_pos >= SGU1_AUDIO_SAMPLES) {
7170 sgu->voice [i].sample_pos = 0 ;
7271 }
@@ -98,7 +97,7 @@ uint8_t sgu1_reg_read(sgu1_t* sgu, uint8_t reg) {
9897 }
9998 else {
10099 uint8_t chan = _sgu1_selected_channel (sgu);
101- data = ((unsigned char *)sgu->su -> chan )[chan << 5 | (reg & (SGU1_NUM_CHANNEL_REGS - 1 ))];
100+ data = ((unsigned char *)sgu->su . chan )[chan << 5 | (reg & (SGU1_NUM_CHANNEL_REGS - 1 ))];
102101 }
103102 return data;
104103}
@@ -111,7 +110,7 @@ void sgu1_reg_write(sgu1_t* sgu, uint8_t reg, uint8_t data) {
111110 }
112111 else {
113112 uint8_t chan = _sgu1_selected_channel (sgu);
114- ((unsigned char *)sgu->su -> chan )[chan << 5 | (reg & (SGU1_NUM_CHANNEL_REGS - 1 ))] = data;
113+ ((unsigned char *)sgu->su . chan )[chan << 5 | (reg & (SGU1_NUM_CHANNEL_REGS - 1 ))] = data;
115114 }
116115}
117116
0 commit comments