| |
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.... |
| |
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 |
| |
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) |
| |
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. |
| |
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. |
| |
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. |
| |
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. :) |
| |
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. |
| |
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) |
| |
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. |
| |
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 |