Skip to content

Commit 378fed4

Browse files
authored
fixed sleep_ms bug, too-early-d418-heuristic
1 parent 1dcf58d commit 378fed4

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

Source/SKpico.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@ void runEmulation()
374374
{
375375
uint8_t reg = cmd >> 8;
376376

377+
// this is a work-around if very early writes to SID-registers are missed due to boot-up time (and d418 is only set once)
378+
static uint8_t d418_volume_set = 0;
379+
if ( !d418_volume_set )
380+
{
381+
if ( reg == 0x18 ) d418_volume_set = 1;
382+
if ( ringRead == 33 )
383+
writeReSID( 0x18, 15 );
384+
}
385+
377386
writeReSID( reg, cmd & 255 );
378387

379388
// pseudo stereo
@@ -384,7 +393,7 @@ void runEmulation()
384393

385394
//
386395
// Digi-Playing Detection to bypass reSID
387-
// (the heuristics below are based on the findings by Jürgen Wothke used in WebSid (https://bitbucket.org/wothke/websid/src/master/) )
396+
// (the heuristics below are based on the findings by J�rgen Wothke used in WebSid (https://bitbucket.org/wothke/websid/src/master/) )
388397
//
389398

390399
if ( SID_DIGI_DETECT )
@@ -393,7 +402,6 @@ void runEmulation()
393402
if ( reg > 6 && reg < 14 ) { voice = 1; reg -= 7; }
394403
if ( reg > 13 && reg < 21 ) { voice = 2; reg -= 14; }
395404

396-
397405
//
398406
// test-bit technique
399407

@@ -1261,7 +1269,8 @@ void readConfiguration()
12611269
void writeConfiguration()
12621270
{
12631271
SET_CLOCK_125MHZ
1264-
sleep_ms( 2 );
1272+
//sleep_ms( 2 );
1273+
DELAY_Nx3p2_CYCLES( 85000 );
12651274
flash_range_erase( FLASH_CONFIG_OFFSET, FLASH_SECTOR_SIZE );
12661275

12671276
uint16_t c = crc16( config, 62 );

0 commit comments

Comments
 (0)