| |
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.... |
| |
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. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11123 |
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) |
| |
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. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11123 |
Of course, doing it "properly" would probably take twice as much code... at least :) |
| |
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... |
| |
chatGPZ
Registered: Dec 2001 Posts: 11123 |
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. |
| |
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. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11123 |
You lost it - both would reset the SID the same way, just the code to do it would be different. |
| |
TheRyk
Registered: Mar 2009 Posts: 2076 |
Quoting Flaviowebsome 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. |
| |
iAN CooG
Registered: May 2002 Posts: 3136 |
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 |