Skip to content

Commit 4186c99

Browse files
authored
RGB LED support
1 parent d95a41a commit 4186c99

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

Source/reSIDWrapper.cc

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ uint8_t POT_OUTLIER_REJECTION = 0;
6868
uint32_t SID2_ADDR_PREV = 255;
6969
uint8_t config[ 64 ];
7070

71+
#ifdef USE_RGB_LED
72+
int32_t voiceOutAcc[ 3 ], nSamplesAcc;
73+
#endif
74+
7175
SID16 *sid16;
7276
SID16 *sid16b;
7377

@@ -212,6 +216,13 @@ extern "C"
212216
sid16b->set_sampling_parameters( C64_CLOCK, SAMPLE_INTERPOLATE, 44100 );
213217

214218
updateConfiguration();
219+
220+
#ifdef USE_RGB_LED
221+
voiceOutAcc[ 0 ] =
222+
voiceOutAcc[ 1 ] =
223+
voiceOutAcc[ 2 ] = 0;
224+
nSamplesAcc = 0;
225+
#endif
215226
}
216227

217228
void emulateCyclesReSID( int cyclesToEmulate )
@@ -238,13 +249,28 @@ extern "C"
238249
void outputReSID( int16_t * left, int16_t * right )
239250
{
240251
int32_t sid1 = sid16->output(),
241-
sid2 = sid16b->output();
252+
sid2 = sid16b->output();
242253

243254
int32_t L = sid1 * actVolSID1_Left + sid2 * actVolSID2_Left;
244255
int32_t R = sid1 * actVolSID1_Right + sid2 * actVolSID2_Right;
245256

246257
*left = L >> 16;
247258
*right = R >> 16;
259+
260+
#ifdef USE_RGB_LED
261+
// SID #1 voices map to red, green, blue
262+
voiceOutAcc[ 0 ] = sid16->voiceOut[ 0 ];
263+
voiceOutAcc[ 1 ] = sid16->voiceOut[ 1 ];
264+
voiceOutAcc[ 2 ] = sid16->voiceOut[ 2 ];
265+
// SID #2 voices map to orange, cyan, purple
266+
voiceOutAcc[ 0 ] += ( 3 * sid16b->voiceOut[ 0 ] ) >> 2;
267+
voiceOutAcc[ 1 ] += sid16b->voiceOut[ 0 ] >> 2;
268+
voiceOutAcc[ 1 ] += sid16b->voiceOut[ 1 ] >> 1;
269+
voiceOutAcc[ 2 ] += sid16b->voiceOut[ 1 ] >> 1;
270+
voiceOutAcc[ 2 ] += sid16b->voiceOut[ 2 ] >> 1;
271+
voiceOutAcc[ 0 ] += sid16b->voiceOut[ 2 ] >> 1;
272+
nSamplesAcc ++;
273+
#endif
248274
}
249275

250276
void resetReSID()

0 commit comments

Comments
 (0)