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
0 commit comments