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: 75
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: 284
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: 11113
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: 284
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: 11113
Of course, doing it "properly" would probably take twice as much code... at least :)
2021-06-03 07:06
Flavioweb

Registered: Nov 2011
Posts: 447
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
chatGPZ

Registered: Dec 2001
Posts: 11113
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: 447
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
chatGPZ

Registered: Dec 2001
Posts: 11113
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: 2069
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: 3132
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
Moloch/TRIAD
csabanw
Andy/AEG
Ghost/Quantum
Case/Padua
psych
Guests online: 169
Top Demos
1 Next Level  (9.8)
2 Mojo  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Comaland 100%  (9.6)
6 No Bounds  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Bromance  (9.6)
10 Memento Mori  (9.6)
Top onefile Demos
1 It's More Fun to Com..  (9.7)
2 Party Elk 2  (9.7)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.5)
5 Rainbow Connection  (9.5)
6 TRSAC, Gabber & Pebe..  (9.5)
7 Onscreen 5k  (9.5)
8 Wafer Demo  (9.5)
9 Dawnfall V1.1  (9.5)
10 Quadrants  (9.5)
Top Groups
1 Oxyron  (9.3)
2 Nostalgia  (9.3)
3 Booze Design  (9.3)
4 Censor Design  (9.3)
5 Crest  (9.3)
Top Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Violator  (9.8)
4 Acidchild  (9.7)
5 Starlight  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.05 sec.