Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > resetting the SID
2011-07-02 23:32
ThunderBlade

Registered: Jan 2002
Posts: 78
resetting the SID

Hi, not sure if this is an awkward question, but... what's the proper way to reset the SID?

When starting various musics, I sometimes, very rarely, notice they sound different like all the other times. It seems to depend which music I played previously!

Inbetween playing musics, currently I just fill $D400 - $D418 with a counting down loop (starting with $D418) with zeroes. Is there a recommended better way?
 
... 44 posts hidden. Click here to view all posts....
 
2021-06-01 15:48
Bacchus

Registered: Jan 2002
Posts: 156
Picking up this thread, can we agree this piece of code is the utter and complete SID init? It's basically the above but also optimised to minimise memory footprint.


sidinit:
lda #$00
ldx #$18 //00
!: sta $d400,x
dex
bpl !-

lda #$08
jsr sidset

ldx #$03
!: bit $d011
bpl *-3
bit $d011
bmi *-3
dex
bpl !-

lda #$00
sidset: sta $d404
sta $d40b
sta $d412
rts

/Bacchus
2021-06-01 16:01
chatGPZ

Registered: Dec 2001
Posts: 11523
For broken music players you want $1f in $d418. Also to really reset the noise lfsr, you gotta wait kindof long with testbit set (but thats probably not required for most things)
2021-06-01 19:30
Frantic

Registered: Mar 2003
Posts: 1661
@gpz: What constitutes a "broken music player" in this context, and why enable the lo pass filter? Looks strange to me, but I guess I am missing something obvious here.
2021-06-01 20:25
TheRyk

Registered: Mar 2009
Posts: 2480
I also tend to leave $D418 alone, normally, because older .SID files (done with ancient trackers, that's what gpz means I guess) can't deal with $d418 muted and (re-)setting $d418 ain't essential anyway, when $D400-$d417 are restted, unless you wanna do some good old $d418 samples on 6581 :)

For sure, it all depends on what you're aiming at. Most possible "universality" or 2020 modern approach that makes most sense.
2021-06-01 21:01
chatGPZ

Registered: Dec 2001
Posts: 11523
Frantic: see ians comment above (#8). It seems to work best :) There are a bunch of old players that dont init "enough", and with those $1f in $d418 is often what seems right.
2021-06-01 23:18
Frantic

Registered: Mar 2003
Posts: 1661
Ah.. haha.. thanks gpz. Amusing to see that I was involved in the discussion you refer to in those old posts too, and even kind of asked the same question. Memory is short I suppose. At least mine. :)
2021-06-02 07:28
Fred

Registered: Feb 2003
Posts: 299
Quote: Picking up this thread, can we agree this piece of code is the utter and complete SID init? It's basically the above but also optimised to minimise memory footprint.


sidinit:
lda #$00
ldx #$18 //00
!: sta $d400,x
dex
bpl !-

lda #$08
jsr sidset

ldx #$03
!: bit $d011
bpl *-3
bit $d011
bmi *-3
dex
bpl !-

lda #$00
sidset: sta $d404
sta $d40b
sta $d412
rts

/Bacchus


For tunes like:

/MUSICIANS/T/Tel_Jeroen/Cybernoid.sid
/MUSICIANS/B/Bjerregaard_Johannes/Stormlord_V2.sid

the mentioned SID reset is not enough. If you restart those tunes and perform the reset it will not always play the same. To fix it you have to write #$ff first to every SID register, then #$08 and then #$00 and have some time between writing those values.

For the Sidplayer in the Ultimate devices I wrote this:
                lda #$ff
resetSidLoop    ldx #$17
-               sta $d400,x
                dex
                bpl -
                tax
                bpl +
                lda #$08
                bpl resetSidLoop
+
-               bit $d011
                bpl -
-               bit $d011
                bmi -
                eor #$08
                beq resetSidLoop

                lda #$0f
                sta $d418

Note that it doesn't write #$1f to $d418. I don't think there are SIDs in HVSC anymore that require this.
2021-06-02 13:15
chatGPZ

Registered: Dec 2001
Posts: 11523
Quote:
To fix it you have to write #$ff first to every SID register, then #$08 and then #$00 and have some time between writing those values.

Effectively you are doing what i said - reset the noise lfsr :) (you dont actually need to write $ff or $08 to _all_ registers)
2021-06-02 22:00
Fred

Registered: Feb 2003
Posts: 299
Quote: Quote:
To fix it you have to write #$ff first to every SID register, then #$08 and then #$00 and have some time between writing those values.

Effectively you are doing what i said - reset the noise lfsr :) (you dont actually need to write $ff or $08 to _all_ registers)


True, not needed for all registers but it's doesn't matter if you do so for the noise lfsr. This way I could optimize the code in size.
2021-06-02 22:24
chatGPZ

Registered: Dec 2001
Posts: 11523
Of course, doing it "properly" would probably take twice as much code... at least :)
Previous - 1 | 2 | 3 | 4 | 5 | 6 - Next
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
goerp/F4CG/HF
Krill/Plush
Alakran_64
TheEnemy/TREX🦖/THD
Freeze/Blazon
Chesser/Blazon
Icon/TRIAD
Mike
Guests online: 313
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Codeboys & Endians  (9.7)
4 Mojo  (9.6)
5 Coma Light 13  (9.6)
6 Edge of Disgrace  (9.6)
7 Signal Carnival  (9.6)
8 Wonderland XIV  (9.5)
9 Uncensored  (9.5)
10 Comaland 100%  (9.5)
Top onefile Demos
1 Nine  (9.7)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.5)
6 Scan and Spin  (9.5)
7 Onscreen 5k  (9.5)
8 Grey  (9.5)
9 Dawnfall V1.1  (9.5)
10 Rainbow Connection  (9.5)
Top Groups
1 Artline Designs  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Performers  (9.3)
5 Censor Design  (9.3)
Top Crackers
1 Mr. Z  (9.9)
2 OTD  (9.8)
3 Antitrack  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2025
Page generated in: 0.067 sec.