Skip to content

Commit b6da20b

Browse files
authored
fix no-paddle-value, stereo DAC mode
1 parent deefccc commit b6da20b

File tree

3 files changed

+48
-18
lines changed

3 files changed

+48
-18
lines changed

Source/SIDKick/AudioStreamSID.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ uint8_t samActive = 0;
8686
#ifdef SID_DAC_MODE_SUPPORT
8787
extern uint8_t sidDACMode;
8888
int16_t sidCurDACValue = 0;
89+
int16_t sidCurDACValueR = 0;
8990
#endif
9091

9192
uint32_t samCurPos, samEndPos1, samStartPos2, samEndPos2;
@@ -125,12 +126,15 @@ void AudioStreamSID::init()
125126

126127
#ifdef SID_DAC_MODE_SUPPORT
127128
sidCurDACValue = 0;
129+
sidCurDACValueR = 0;
128130
#endif
129131

130132
sid16_1->set_chip_model( MOS6581 );
131133
sid16_2->set_chip_model( MOS6581 );
132134
sid16_1->reset();
133135
sid16_2->reset();
136+
sid16_1->input( 0 );
137+
sid16_2->input( 0 );
134138
sid16_1->set_sampling_parameters( CLOCKFREQ, SAMPLE_INTERPOLATE, AUDIO_SAMPLE_RATE_EXACT );
135139
sid16_2->set_sampling_parameters( CLOCKFREQ, SAMPLE_INTERPOLATE, AUDIO_SAMPLE_RATE_EXACT );
136140

@@ -261,10 +265,12 @@ void AudioStreamSID::updateConfiguration( uint8_t *cfg, uint8_t *globalCfg )
261265
{
262266
sid_1->set_voice_mask( 0x07 );
263267
sid_1->input( 0 );
268+
sid16_1->input( 0 );
264269
} else
265270
{
266271
sid_1->set_voice_mask( 0x0f );
267272
sid_1->input( -(1<<cfg[1]) );
273+
sid16_1->input( -(1<<cfg[1]) );
268274
}
269275
#endif
270276
}
@@ -289,10 +295,12 @@ void AudioStreamSID::updateConfiguration( uint8_t *cfg, uint8_t *globalCfg )
289295
{
290296
sid_2->set_voice_mask( 0x07 );
291297
sid_2->input( 0 );
298+
sid16_2->input( 0 );
292299
} else
293300
{
294301
sid_2->set_voice_mask( 0x0f );
295302
sid_2->input( -(1<<cfg[9]) );
303+
sid16_2->input( -(1<<cfg[9]) );
296304
}
297305
#endif
298306
} else
@@ -690,6 +698,13 @@ FASTRUN void AudioStreamSID::update()
690698
} else
691699
{
692700
#ifdef SID_DAC_MODE_SUPPORT
701+
if ( sidDACMode == SID_DAC_STEREO8 )
702+
{
703+
if ( ( A & 31 ) == 0x18 )
704+
sidCurDACValue = ((int16_t)D - 128) << 8;
705+
if ( ( A & 31 ) == 0x19 )
706+
sidCurDACValueR = ((int16_t)D - 128) << 8;
707+
}
693708
if ( sidDACMode == SID_DAC_MONO8 && ( A & 31 ) == 0x18 )
694709
{
695710
sidCurDACValue = ((int16_t)D - 128) << 8;
@@ -1024,9 +1039,16 @@ FASTRUN void AudioStreamSID::update()
10241039
} else
10251040
{
10261041
#ifdef SID_DAC_MODE_SUPPORT
1027-
if ( sidDACMode )
1042+
if ( sidDACMode == SID_DAC_MONO8 )
10281043
{
1029-
sid1 = sid2 = sidCurDACValue;
1044+
left = right = sidCurDACValue;
1045+
goto skipMixer;
1046+
} else
1047+
if ( sidDACMode == SID_DAC_STEREO8 )
1048+
{
1049+
left = sidCurDACValue;
1050+
right = sidCurDACValueR;
1051+
goto skipMixer;
10301052
} else
10311053
#endif
10321054
{
@@ -1058,7 +1080,7 @@ FASTRUN void AudioStreamSID::update()
10581080
asm volatile ( "SMLABB %0, %1, %2, %3" : "=r" (right) : "r" (valOPL), "r" (actVolOPL_Right), "r" (right) );
10591081
right >>= 8;
10601082

1061-
1083+
skipMixer:
10621084
if ( samSpeaking )
10631085
{
10641086
int32_t sam = ( (int32_t)(*(int8_t*)&samvoice_raw[ samCurPos >> 1 ]) * samActive ) << 2;

Source/SIDKick/SIDKick.ino

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,25 @@ const uint8_t *prgCode = NULL;
6767

6868
#ifdef FIRMWARE_C128
6969
#if audioDevice == 1
70-
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', 0x44, 0x41, 0x43, '1', '2', '8' };
70+
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', 0x44, 0x41, 0x43, '1', '2', '8', 0, 0, 0, 0 };
7171
#else
72-
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', 0x4d, 0x51, 0x53, '1', '2', '8' };
72+
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', 0x4d, 0x51, 0x53, '1', '2', '8', 0, 0, 0, 0 };
7373
#endif
7474
#else
7575
#if audioDevice == 1
76-
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', '/', 0x44, 0x41, 0x43, '6', '4' };
76+
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', '/', 0x44, 0x41, 0x43, '6', '4', 0, 0, 0, 0 };
7777
#else
78-
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', '/', 0x4d, 0x51, 0x53, '6', '4' };
78+
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', '/', 0x4d, 0x51, 0x53, '6', '4', 0, 0, 0, 0 };
7979
#endif
8080
#endif
8181

82-
// signature + version 0.21
82+
// signature + version 0.22
8383
#define VERSION_STR_EXT_SIZE 16
8484
static const unsigned char VERSION_STR_ext[VERSION_STR_EXT_SIZE] = {
8585
0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, 0x00, // signature + extension version 0
86-
0, 21, // firmware version with stepping
86+
0, 22, // firmware version with stepping
8787
#ifdef SID_DAC_MODE_SUPPORT // support DAC modes? which?
88-
1,
88+
SID_DAC_MONO8 | SID_DAC_STEREO8,
8989
#else
9090
0,
9191
#endif
@@ -140,6 +140,7 @@ uint8_t sidOnlyMode = SID_ONLY_OFF;
140140
uint8_t sidDACMode = SID_DAC_OFF;
141141
#endif
142142

143+
143144
uint8_t addrLine = 0;
144145
uint32_t fmFakeOutput = 0;
145146
uint32_t fmAutoDetectStep = 0;
@@ -1526,7 +1527,14 @@ FASTRUN void isrSID()
15261527
#ifdef SID_DAC_MODE_SUPPORT
15271528
else if ( D == 0xfc )
15281529
{
1529-
sidDACMode = 1;
1530+
sidDACMode = SID_DAC_MONO8;
1531+
stateInConfigMode =
1532+
stateInTransferMode =
1533+
stateInVisualizationMode = 0;
1534+
}
1535+
else if ( D == 0xfb )
1536+
{
1537+
sidDACMode = SID_DAC_STEREO8;
15301538
stateInConfigMode =
15311539
stateInTransferMode =
15321540
stateInVisualizationMode = 0;
@@ -1615,7 +1623,7 @@ FASTRUN void isrSID()
16151623
busValueTTL = 0xa2000; else // 8580
16161624
busValueTTL = 0x1d00; // 6581
16171625

1618-
if ( A <= 24 )
1626+
if ( A <= 25 )
16191627
{
16201628
// pseudo stereo?
16211629
if ( SID2_ADDR == (uint32_t)(1 << 31) )
@@ -1826,12 +1834,12 @@ noSID_FM_MIDI_Commands:
18261834
newPotCounterX = newPotCounterY = 1;
18271835
} else if ( potCycleCounter >= 256 )
18281836
{
1829-
if ( newPotCounterX && (data_9 & CORE_PIN4_BITMASK) )
1837+
if ( newPotCounterX && ( (data_9 & CORE_PIN4_BITMASK) || potCycleCounter == 511 ) )
18301838
{
18311839
outRegisters[ 25 ] = potCycleCounter - 256;
18321840
newPotCounterX = 0;
18331841
}
1834-
if ( newPotCounterY && (data_9 & CORE_PIN5_BITMASK) )
1842+
if ( newPotCounterY && ( (data_9 & CORE_PIN5_BITMASK) || potCycleCounter == 511 ) )
18351843
{
18361844
outRegisters[ 26 ] = potCycleCounter - 256;
18371845
newPotCounterY = 0;

Source/SIDKick/globals.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// Teensy clock speed (keep 816 unless you deactivate MIDI and LED)
3838
#define TEENSY_CLOCK 816
3939

40-
#define FIRMWARE_C128
40+
//#define FIRMWARE_C128
4141

4242
// C128 does not support $D500 for SID #2
4343
// except for the C64-mode if:
@@ -50,7 +50,7 @@
5050
//#define SUPPORT_MIDI
5151

5252
// define if WS2818b-LED support to be included in the firmware
53-
#define FANCY_LED
53+
//#define FANCY_LED
5454

5555
// define this to use the sample generation routine which adapts to the actual C64/C128 clock
5656
#define DYNAMIC_ADJUSTMENT_MIXER
@@ -63,7 +63,7 @@
6363
#define SID_DAC_OFF 0
6464
#define SID_DAC_MONO8 1
6565
#define SID_DAC_STEREO8 2
66-
#define SID_DAC_MONO16 3
67-
#define SID_DAC_STEREO16 4
66+
#define SID_DAC_MONO16 4
67+
#define SID_DAC_STEREO16 8
6868

6969
//#define DEBUG_OUTPUT

0 commit comments

Comments
 (0)