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....
 
2011-07-04 06:45
j0x

Registered: Mar 2004
Posts: 215
Quote:

Probably enabling the filter for some voice(s) but not selecting any filter type results in silence then.. I guess.

Sounds like Frantic is probably on the right track. If this is true, is it only true for SID emulation?

Sorry for side-tracking the thread slightly, btw... :(
2011-07-04 07:36
Frantic

Registered: Mar 2003
Posts: 1661
Sidwave: Sorry if I am rude now, but I have to say that that was quite a crappy answer to his question. To begin with, $d41d is not a valid SID register at all, and there is no need to write anything to the registers $d419-$d41c which are purely output registers. ...and the whole thread began on the assumption that something more than just writing zeroes to the SID would be relevant.

j0x: I think it may very well be true on the real hardware too, but I don't have it right here where I am at the moment, so I can't tell for sure.
2011-07-05 20:53
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
ok Frantic,

i didnt make a sidplayer yet, but what i think will work is:

clear d418, and do a hard restart with no sound, then set filter type.

now the sid will have a filter type when the first note is played, and the ADSR will be reset.

i have a sound like that in SDI:

waveform:

09 00
.01 00
ff .

it resets the sid (as of what i know),
and my filters begin at the correct spot.

this any help ?
2011-07-05 20:59
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
this positively works 100% (on 6581 R4 AR anyway), its from a tune i made, i used it many times:

ADSR: 0002
HARD RESTART
FILTER type: 1F (lowpass, max resonance)

WAVEFORM:
01 .
FF .


just a 1.


work every time.
2011-07-05 21:04
Soren
Account closed

Registered: Dec 2001
Posts: 547
SIDwave: what if you don't want to start the tune with hard restart? ;-)
2011-07-05 21:07
SIDWAVE
Account closed

Registered: Apr 2002
Posts: 2238
/MUSICIANS/H/Harries_Jan/Equations.sid

Jeff, its just a sid reset that works, that what he asked.
2011-07-05 21:40
Devia

Registered: Oct 2004
Posts: 403
Quoting Frantic
Filter regs, frequency regs, and pulse width regs should simply be set to 00.

I would first set ADSR regs to 00, then set the control registers to $08 to set gate off and turn oscillators off (what Jeff suggested, sort of). Then you should preferably wait for a while (2-3 frames should be completely safe) to make sure that the internal ADSR counters are reset properly.

...and finally, if everything is silent when you try to play your tune, just set global sid volume to $0f before initializing the tune. (The tune init routine really should take care of this itself though, so I guess you won't ever need that.)


Quoting iAN CooG
or even $1f as probably is best for most tunes, happened also that some tunes lacked a proper init (yes there are) and setting $0f would make the tune play with one voice muted =)


sooo.. to recap, the issues may be ADSR related and related to "incomplete" music init routines, right?
And based on at least 10489 tunes having hardcoded low-pass filter somewhere in the code, the assumption is that an incomplete music init routine is best supported by a preconfigured low-pass filter, right?
Since KERNAL sets $d418 to $00, I'm curious as to what has initialized $d418 to something other than that in the original code? ..or maybe they are just bad (incomplete) rips?

That aside,

Quoting Frantic
Probably enabling the filter for some voice(s) but not selecting any filter type results in silence then.. I guess.

You guessed right.


So to sum up: A SID reset routine would have to look something like this:

SIDRST:
	ldx	#$18
	lda	#$00
:	sta	$d400,x
	dex
	bpl	:-

	lda	#$08
	sta	$d404
	sta	$d40b
	sta	$d412

	ldx	#$03
	lda	#$ff
:	cmp	$d012
	bne	:-
	dex
	bpl	:-

	lda	#$00
	sta	$d404
	sta	$d40b
	sta	$d412

	lda	#WhateverValueUThinkIsMosLikelyToMakeSenseIfWhateverYouJumpToNextDoesntSetI tItself
	sta	$d418
	rts

2011-07-06 07:59
j0x

Registered: Mar 2004
Posts: 215
Devia:
Quote:

You guessed right


Did you check on real hardware?

And, fwiw, your delay loop probably doesn't do what it's intended to. It may make a number of "dex"'s while $d012 equals $ff.
2011-07-06 08:10
ThunderBlade

Registered: Jan 2002
Posts: 78
This is a great discussion. Very helpful indeed, thank you all!
2011-07-06 08:11
JackAsser

Registered: Jun 2002
Posts: 2038
Quote: Devia:
Quote:

You guessed right


Did you check on real hardware?

And, fwiw, your delay loop probably doesn't do what it's intended to. It may make a number of "dex"'s while $d012 equals $ff.


Indeed that wait will fail. Patch to:

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

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
MWR/Visdom
Mason/Unicess
Sokratekk
Steffan/BOOM!
Meikel aka ZUX/Sparks
katon/Lepsi De
Guests online: 231
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 Swappers
1 Derbyshire Ram  (10)
2 Jerry  (9.8)
3 Acidchild  (9.7)
4 Cash  (9.6)
5 Violator  (9.6)

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