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


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

Registered: Jan 2002
Posts: 62
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?
 
... 40 posts hidden. Click here to view all posts....
 
2021-06-02 07:28
Fred

Registered: Feb 2003
Posts: 255
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
Groepaz

Registered: Dec 2001
Posts: 9918
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: 255
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
Groepaz

Registered: Dec 2001
Posts: 9918
Of course, doing it "properly" would probably take twice as much code... at least :)
2021-06-03 07:06
Flavioweb

Registered: Nov 2011
Posts: 417
But... what does "proper" really mean?
Reset Sid as it is on machine power up, or what?
I guess after power up all internal regs are set to $FF except $D418 that kernal put at $00 during startup...
2021-06-03 12:38
Groepaz

Registered: Dec 2001
Posts: 9918
by "properly" i was referring to clean "by the book" code that only writes exactly the values needed only to the registers that require it.
2021-06-03 12:49
Flavioweb

Registered: Nov 2011
Posts: 417
Quote: by "properly" i was referring to clean "by the book" code that only writes exactly the values needed only to the registers that require it.

Ok.
But musicians out there start composing from an "after power up" state and not from a "by the book" Sid setup.
Some examples have been given, including "Cybernoid", so i guess the goal is "how to make play already made tunes same way, everywhere".
Maybe a "by the book" setup make "power up setup" tunes sound different.
Anyway, if is it, this mean that some tunes out there have no proper self Sid Setup code.
2021-06-03 13:56
Groepaz

Registered: Dec 2001
Posts: 9918
You lost it - both would reset the SID the same way, just the code to do it would be different.
2021-06-03 14:12
TheRyk

Registered: Mar 2009
Posts: 944
Quoting Flavioweb
some tunes out there have no proper self Sid Setup code.

varies a lot of course.

As you can already seen by nowadays
LDA #$SUBTUNE No.
JSR $INIT

being perfectly fine for Goattracker, whereas
TAX
TAY

before the JSR $INIT makes it more universal as older players expect X and/or Y regs set.

Slightly offtopic of course, so what has this to do with anything? Well, it's an example why not to rely on .SID-file immanent Init routine doing the I/O init job for you, especially if tunes are done with older or exotic trackers.
2021-06-03 18:47
iAN CooG

Registered: May 2002
Posts: 2887
TheRyk: that is the tune init, to init its internal counters, especially to restart playing it from pattern 0, and doesn't have anything to do with SID chip regs init. Also not all inits require A, X or Y, some just require some value stored in some address, it only depends on the tracker used.
Then, the tune init isn't even guaranteed to set all SID chip regs correctly and could rely on a SID chip just as it is at power up. There are TOO MANY sid files and each is made in its own special way =)
The typical problem is on cracks, or multipart demos made with different single parts linked together. After an intro played some music, then the next part sounds weird/wrong/not at all.
Reiniting manually the sid registers before starting the next tune is the only way.
Previous - 1 | 2 | 3 | 4 | 5 - 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
CreaMD/React
Didi/Laxity
iAN CooG/HVSC
Alakran_64
Holy Moses/Role
Lynx/ΤRIΛD
Mythus/Delysid
DeeKay/Crest
xAD/nIGHTFALL
Impetigo/Crescent
Mason/Unicess
Majikeyric/ONS+HF
Motion/ΛRTΣTΛTE·..
Moloch/TRIAD
Sentinel/Excess
Deev/Onslaught
Guests online: 317
Top Demos
1 Edge of Disgrace  (9.6)
2 Coma Light 13  (9.6)
3 Uncensored  (9.6)
4 Comaland 100%  (9.6)
5 Lunatico  (9.6)
6 Unboxed  (9.6)
7 Memento Mori  (9.5)
8 Christmas Megademo  (9.5)
9 Wonderland XII  (9.5)
10 The Shores of Reflec..  (9.5)
Top onefile Demos
1 Copper Booze  (9.8)
2 Daah, Those Acid Pil..  (9.5)
3 Lovecats  (9.5)
4 To Norah  (9.5)
5 Dawnfall V1.1  (9.5)
6 Elite Code Mechanics  (9.4)
7 Square Booze  (9.4)
8 Amber Cow - The Real..  (9.4)
9 Quadrants  (9.4)
10 Coma Job 2/3  (9.4)
Top Groups
1 Booze Design  (9.4)
2 Oxyron  (9.4)
3 Censor Design  (9.4)
4 PriorArt  (9.3)
5 Crest  (9.3)
Top Organizers
1 Burglar  (9.9)
2 Sixx  (9.8)
3 Irata  (9.8)
4 Taper  (9.8)
5 hedning  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2021
Page generated in: 0.058 sec.