Skip to content

Commit

Permalink
fix no-paddle-value, stereo DAC mode
Browse files Browse the repository at this point in the history
  • Loading branch information
frntc authored Dec 9, 2023
1 parent deefccc commit b6da20b
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
28 changes: 25 additions & 3 deletions Source/SIDKick/AudioStreamSID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ uint8_t samActive = 0;
#ifdef SID_DAC_MODE_SUPPORT
extern uint8_t sidDACMode;
int16_t sidCurDACValue = 0;
int16_t sidCurDACValueR = 0;
#endif

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

#ifdef SID_DAC_MODE_SUPPORT
sidCurDACValue = 0;
sidCurDACValueR = 0;
#endif

sid16_1->set_chip_model( MOS6581 );
sid16_2->set_chip_model( MOS6581 );
sid16_1->reset();
sid16_2->reset();
sid16_1->input( 0 );
sid16_2->input( 0 );
sid16_1->set_sampling_parameters( CLOCKFREQ, SAMPLE_INTERPOLATE, AUDIO_SAMPLE_RATE_EXACT );
sid16_2->set_sampling_parameters( CLOCKFREQ, SAMPLE_INTERPOLATE, AUDIO_SAMPLE_RATE_EXACT );

Expand Down Expand Up @@ -261,10 +265,12 @@ void AudioStreamSID::updateConfiguration( uint8_t *cfg, uint8_t *globalCfg )
{
sid_1->set_voice_mask( 0x07 );
sid_1->input( 0 );
sid16_1->input( 0 );
} else
{
sid_1->set_voice_mask( 0x0f );
sid_1->input( -(1<<cfg[1]) );
sid16_1->input( -(1<<cfg[1]) );
}
#endif
}
Expand All @@ -289,10 +295,12 @@ void AudioStreamSID::updateConfiguration( uint8_t *cfg, uint8_t *globalCfg )
{
sid_2->set_voice_mask( 0x07 );
sid_2->input( 0 );
sid16_2->input( 0 );
} else
{
sid_2->set_voice_mask( 0x0f );
sid_2->input( -(1<<cfg[9]) );
sid16_2->input( -(1<<cfg[9]) );
}
#endif
} else
Expand Down Expand Up @@ -690,6 +698,13 @@ FASTRUN void AudioStreamSID::update()
} else
{
#ifdef SID_DAC_MODE_SUPPORT
if ( sidDACMode == SID_DAC_STEREO8 )
{
if ( ( A & 31 ) == 0x18 )
sidCurDACValue = ((int16_t)D - 128) << 8;
if ( ( A & 31 ) == 0x19 )
sidCurDACValueR = ((int16_t)D - 128) << 8;
}
if ( sidDACMode == SID_DAC_MONO8 && ( A & 31 ) == 0x18 )
{
sidCurDACValue = ((int16_t)D - 128) << 8;
Expand Down Expand Up @@ -1024,9 +1039,16 @@ FASTRUN void AudioStreamSID::update()
} else
{
#ifdef SID_DAC_MODE_SUPPORT
if ( sidDACMode )
if ( sidDACMode == SID_DAC_MONO8 )
{
sid1 = sid2 = sidCurDACValue;
left = right = sidCurDACValue;
goto skipMixer;
} else
if ( sidDACMode == SID_DAC_STEREO8 )
{
left = sidCurDACValue;
right = sidCurDACValueR;
goto skipMixer;
} else
#endif
{
Expand Down Expand Up @@ -1058,7 +1080,7 @@ FASTRUN void AudioStreamSID::update()
asm volatile ( "SMLABB %0, %1, %2, %3" : "=r" (right) : "r" (valOPL), "r" (actVolOPL_Right), "r" (right) );
right >>= 8;


skipMixer:
if ( samSpeaking )
{
int32_t sam = ( (int32_t)(*(int8_t*)&samvoice_raw[ samCurPos >> 1 ]) * samActive ) << 2;
Expand Down
30 changes: 19 additions & 11 deletions Source/SIDKick/SIDKick.ino
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,25 @@ const uint8_t *prgCode = NULL;

#ifdef FIRMWARE_C128
#if audioDevice == 1
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', 0x44, 0x41, 0x43, '1', '2', '8' };
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 };
#else
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', 0x4d, 0x51, 0x53, '1', '2', '8' };
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 };
#endif
#else
#if audioDevice == 1
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', '/', 0x44, 0x41, 0x43, '6', '4' };
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 };
#else
static const char VERSION_STR_Flash[20] = {0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, '0', '.', '2', '/', 0x4d, 0x51, 0x53, '6', '4' };
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 };
#endif
#endif

// signature + version 0.21
// signature + version 0.22
#define VERSION_STR_EXT_SIZE 16
static const unsigned char VERSION_STR_ext[VERSION_STR_EXT_SIZE] = {
0x53, 0x49, 0x44, 0x4b, 0x09, 0x03, 0x0b, 0x00, // signature + extension version 0
0, 21, // firmware version with stepping
0, 22, // firmware version with stepping
#ifdef SID_DAC_MODE_SUPPORT // support DAC modes? which?
1,
SID_DAC_MONO8 | SID_DAC_STEREO8,
#else
0,
#endif
Expand Down Expand Up @@ -140,6 +140,7 @@ uint8_t sidOnlyMode = SID_ONLY_OFF;
uint8_t sidDACMode = SID_DAC_OFF;
#endif


uint8_t addrLine = 0;
uint32_t fmFakeOutput = 0;
uint32_t fmAutoDetectStep = 0;
Expand Down Expand Up @@ -1526,7 +1527,14 @@ FASTRUN void isrSID()
#ifdef SID_DAC_MODE_SUPPORT
else if ( D == 0xfc )
{
sidDACMode = 1;
sidDACMode = SID_DAC_MONO8;
stateInConfigMode =
stateInTransferMode =
stateInVisualizationMode = 0;
}
else if ( D == 0xfb )
{
sidDACMode = SID_DAC_STEREO8;
stateInConfigMode =
stateInTransferMode =
stateInVisualizationMode = 0;
Expand Down Expand Up @@ -1615,7 +1623,7 @@ FASTRUN void isrSID()
busValueTTL = 0xa2000; else // 8580
busValueTTL = 0x1d00; // 6581

if ( A <= 24 )
if ( A <= 25 )
{
// pseudo stereo?
if ( SID2_ADDR == (uint32_t)(1 << 31) )
Expand Down Expand Up @@ -1826,12 +1834,12 @@ noSID_FM_MIDI_Commands:
newPotCounterX = newPotCounterY = 1;
} else if ( potCycleCounter >= 256 )
{
if ( newPotCounterX && (data_9 & CORE_PIN4_BITMASK) )
if ( newPotCounterX && ( (data_9 & CORE_PIN4_BITMASK) || potCycleCounter == 511 ) )
{
outRegisters[ 25 ] = potCycleCounter - 256;
newPotCounterX = 0;
}
if ( newPotCounterY && (data_9 & CORE_PIN5_BITMASK) )
if ( newPotCounterY && ( (data_9 & CORE_PIN5_BITMASK) || potCycleCounter == 511 ) )
{
outRegisters[ 26 ] = potCycleCounter - 256;
newPotCounterY = 0;
Expand Down
8 changes: 4 additions & 4 deletions Source/SIDKick/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
// Teensy clock speed (keep 816 unless you deactivate MIDI and LED)
#define TEENSY_CLOCK 816

#define FIRMWARE_C128
//#define FIRMWARE_C128

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

// define if WS2818b-LED support to be included in the firmware
#define FANCY_LED
//#define FANCY_LED

// define this to use the sample generation routine which adapts to the actual C64/C128 clock
#define DYNAMIC_ADJUSTMENT_MIXER
Expand All @@ -63,7 +63,7 @@
#define SID_DAC_OFF 0
#define SID_DAC_MONO8 1
#define SID_DAC_STEREO8 2
#define SID_DAC_MONO16 3
#define SID_DAC_STEREO16 4
#define SID_DAC_MONO16 4
#define SID_DAC_STEREO16 8

//#define DEBUG_OUTPUT

0 comments on commit b6da20b

Please # to comment.