Skip to content

Commit a653e32

Browse files
authored
writing out values for RGB LED support
1 parent 7eb1995 commit a653e32

File tree

3 files changed

+80
-24
lines changed

3 files changed

+80
-24
lines changed

Source/reSID16/sid.cc

Lines changed: 70 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818
// ---------------------------------------------------------------------------
1919

20+
// please note that modifications have been made to this source code
21+
// for the use in the SIDKick pico firmware!
22+
2023
#include "sid.h"
2124
#include <math.h>
2225

@@ -38,6 +41,10 @@ __attribute__( ( optimize( "Os" ) ) ) SID16::SID16()
3841
bus_value = 0;
3942
bus_value_ttl = 0;
4043

44+
#ifdef USE_RGB_LED
45+
voiceOut[ 0 ] = voiceOut[ 1 ] = voiceOut[ 2 ] = 0;
46+
#endif
47+
4148
ext_in = 0;
4249
}
4350

@@ -654,19 +661,38 @@ void SID16::clock()
654661
int v1 = voice[1].output();
655662
int v2 = voice[2].output();
656663

657-
//v0 = v1 = v2 = 0;
664+
if ( forceOutput[ 0 ] & 2 ) { v0 = voice[ 0 ].output( forceOutput[ 0 ] & ~3 ) + voice[ 0 ].voice_DC; }
665+
if ( forceOutput[ 1 ] & 2 ) { v1 = voice[ 1 ].output( forceOutput[ 1 ] & ~3 ) + voice[ 1 ].voice_DC; }
666+
if ( forceOutput[ 2 ] & 2 ) { v2 = voice[ 2 ].output( forceOutput[ 2 ] & ~3 ) + voice[ 2 ].voice_DC; }
658667

659-
// if ( forceOutput[ 0 ] & 2 ) v0 = ( forceOutput[ 0 ] & ~3 ) << 4;
660-
// if ( forceOutput[ 1 ] & 2 ) v1 = ( forceOutput[ 1 ] & ~3 ) << 4;
661-
// if ( forceOutput[ 2 ] & 2 ) v2 = ( forceOutput[ 2 ] & ~3 ) << 4;
662-
if ( forceOutput[ 0 ] & 2 ) v0 = voice[ 0 ].output( forceOutput[ 0 ] & ~3 );
663-
if ( forceOutput[ 1 ] & 2 ) v1 = voice[ 1 ].output( forceOutput[ 1 ] & ~3 );
664-
if ( forceOutput[ 2 ] & 2 ) v2 = voice[ 2 ].output( forceOutput[ 2 ] & ~3 );
668+
#ifdef USE_RGB_LED
669+
voiceOut[ 0 ] = v0 - voice[ 0 ].voice_DC;
670+
voiceOut[ 1 ] = v1 - voice[ 1 ].voice_DC;
671+
voiceOut[ 2 ] = v2 - voice[ 2 ].voice_DC;
672+
#endif
665673

666674
v0p = 0;
667-
if ( forceOutput[ 0 ] & 1 ) { v0 = 0; v0p += forceOutput[ 0 ] & ~3; }
668-
if ( forceOutput[ 1 ] & 1 ) { v1 = 0; v0p += forceOutput[ 1 ] & ~3; }
669-
if ( forceOutput[ 2 ] & 1 ) { v2 = 0; v0p += forceOutput[ 2 ] & ~3; }
675+
if ( forceOutput[ 0 ] & 1 )
676+
{
677+
v0 = 0; v0p += forceOutput[ 0 ] & ~3;
678+
#ifdef USE_RGB_LED
679+
voiceOut[ 0 ] = ((forceOutput[ 0 ] & ~3)-512) << 8;
680+
#endif
681+
}
682+
if ( forceOutput[ 1 ] & 1 )
683+
{
684+
v1 = 0; v0p += forceOutput[ 1 ] & ~3;
685+
#ifdef USE_RGB_LED
686+
voiceOut[ 1 ] = ((forceOutput[ 1 ] & ~3)-512) << 8;
687+
#endif
688+
}
689+
if ( forceOutput[ 2 ] & 1 )
690+
{
691+
v2 = 0; v0p += forceOutput[ 2 ] & ~3;
692+
#ifdef USE_RGB_LED
693+
voiceOut[ 2 ] = ((forceOutput[ 2 ] & ~3)-512) << 8;
694+
#endif
695+
}
670696

671697
filter.clock( v0, v1, v2, ext_in );
672698

@@ -748,22 +774,42 @@ void SID16::clock(cycle_count delta_t)
748774
}
749775

750776
// Clock filter.
751-
int v0 = voice[0].output();
752-
int v1 = voice[1].output();
753-
int v2 = voice[2].output();
754-
755-
//v0 = v1 = v2 = 0;
756-
// if ( forceOutput[ 0 ] & 2 ) v0 = ( forceOutput[ 0 ] & ~3 ) << 4;
757-
// if ( forceOutput[ 1 ] & 2 ) v1 = ( forceOutput[ 1 ] & ~3 ) << 4;
758-
// if ( forceOutput[ 2 ] & 2 ) v2 = ( forceOutput[ 2 ] & ~3 ) << 4;
759-
if ( forceOutput[ 0 ] & 2 ) v0 = voice[ 0 ].output( forceOutput[ 0 ] & ~3 );
760-
if ( forceOutput[ 1 ] & 2 ) v1 = voice[ 1 ].output( forceOutput[ 1 ] & ~3 );
761-
if ( forceOutput[ 2 ] & 2 ) v2 = voice[ 2 ].output( forceOutput[ 2 ] & ~3 );
777+
int v0 = voice[ 0 ].output();
778+
int v1 = voice[ 1 ].output();
779+
int v2 = voice[ 2 ].output();
780+
781+
if ( forceOutput[ 0 ] & 2 ) { v0 = voice[ 0 ].output( forceOutput[ 0 ] & ~3 ) + voice[ 0 ].voice_DC; }
782+
if ( forceOutput[ 1 ] & 2 ) { v1 = voice[ 1 ].output( forceOutput[ 1 ] & ~3 ) + voice[ 1 ].voice_DC; }
783+
if ( forceOutput[ 2 ] & 2 ) { v2 = voice[ 2 ].output( forceOutput[ 2 ] & ~3 ) + voice[ 2 ].voice_DC; }
784+
785+
#ifdef USE_RGB_LED
786+
voiceOut[ 0 ] = v0 - voice[ 0 ].voice_DC;
787+
voiceOut[ 1 ] = v1 - voice[ 1 ].voice_DC;
788+
voiceOut[ 2 ] = v2 - voice[ 2 ].voice_DC;
789+
#endif
762790

763791
v0p = 0;
764-
if ( forceOutput[ 0 ] & 1 ) { v0 = 0; v0p += forceOutput[ 0 ] & ~3; }
765-
if ( forceOutput[ 1 ] & 1 ) { v1 = 0; v0p += forceOutput[ 1 ] & ~3; }
766-
if ( forceOutput[ 2 ] & 1 ) { v2 = 0; v0p += forceOutput[ 2 ] & ~3; }
792+
if ( forceOutput[ 0 ] & 1 )
793+
{
794+
v0 = 0; v0p += forceOutput[ 0 ] & ~3;
795+
#ifdef USE_RGB_LED
796+
voiceOut[ 0 ] = ( ( forceOutput[ 0 ] & ~3 ) - 512 ) << 8;
797+
#endif
798+
}
799+
if ( forceOutput[ 1 ] & 1 )
800+
{
801+
v1 = 0; v0p += forceOutput[ 1 ] & ~3;
802+
#ifdef USE_RGB_LED
803+
voiceOut[ 1 ] = ( ( forceOutput[ 1 ] & ~3 ) - 512 ) << 8;
804+
#endif
805+
}
806+
if ( forceOutput[ 2 ] & 1 )
807+
{
808+
v2 = 0; v0p += forceOutput[ 2 ] & ~3;
809+
#ifdef USE_RGB_LED
810+
voiceOut[ 2 ] = ( ( forceOutput[ 2 ] & ~3 ) - 512 ) << 8;
811+
#endif
812+
}
767813

768814
filter.clock(delta_t, v0, v1, v2, ext_in);
769815

Source/reSID16/sid.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818
// ---------------------------------------------------------------------------
1919

20+
// please note that modifications have been made to this source code
21+
// for the use in the SIDKick pico firmware!
22+
2023
#ifndef __SID16_H__
2124
#define __SID16_H__
2225

@@ -88,6 +91,10 @@ class SID16
8891

8992
void forceDigiOutput( int voice, int value );
9093

94+
#ifdef USE_RGB_LED
95+
int voiceOut[ 3 ];
96+
#endif
97+
9198
protected:
9299
static double I0(double x);
93100
RESID_INLINE int clock_fast(cycle_count& delta_t, short* buf, int n,

Source/reSID16/wave.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1818
// ---------------------------------------------------------------------------
1919

20+
// please note that modifications have been made to this source code
21+
// for the use in the SIDKick pico firmware!
22+
2023
#ifndef __WAVE_H__
2124
#define __WAVE_H__
2225

0 commit comments

Comments
 (0)