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 > Safe and robust method to detect 2nd or further SIDs?
2025-01-01 02:21
Dano

Registered: Jul 2004
Posts: 240
Safe and robust method to detect 2nd or further SIDs?

As Toggle just published his first 2 SID tune i wondered if there is some safe and trusted method to detect a second or further SIDs and where they are located?

Something that i can add to my player screens for occasional tunes with more that one SID.

Looked on codebase and here, but i could not find anything. Atleast not searching for $d420 and alike.

As i really know nearly nothing about SID and what is reliable, i hope to hear back from all you experienced coders. :)
2025-01-01 03:32
Devia

Registered: Oct 2004
Posts: 403
Well, it really depends on your Dual SID hardware implementation.
I believe the most common one out there today may be SIDFX, so a good place to start is to support that. Take a look at the SIDFX API Specification at https://www.sidfx.dk/download for how to detect a SIDFX and how to detect and utilize the additional SID.
2025-01-01 03:36
Devia

Registered: Oct 2004
Posts: 403
A more agnostic approach would probably involve writing/reading all the available SID address spaces to see if there is a SID there.. but your mileage may vary depending on if it's a real SID or a re-implementation like SwinSID etc.
2025-01-01 10:49
Mixer

Registered: Apr 2008
Posts: 454
I've not tested this example myself, but just from the top of my dome it goes something like this.

Write 08 to all possible voice3 sid ctrl registers SID + $12 and its mirrors there by stopping and resetting the oscillator of v3 of all possible SIDs from $d400 to $d800 at $20 intervals.

lda #$08
sta $d412
sta $d432
sta $d452
...
(yeah, loop it :)

Start the sid1 voice3 to run the oscillator at max frq using sawtooth and expect to read a changing value from SIDBASE+$1b.

lda #$00
sta $d418
lda #$ff
sta $d40e
sta $d40f
lda #$20
sta $d412

After the setup, the comparison then is
repeat
lda SIDBASE+$1b
cmp SIDBASE+$1b
beq different sid,
bne sid1 mirror, add $20 to SIDBASE and repeat

And then walk through all sid base addresses.

If you find a 2nd sid, then either stop, or look for more sids by starting the oscillator on the new found sid and continuing.

There are variations to the theme, but this may be the shortest.

Some sid software implementations may not have the osc3/env3 readback, so cannot help those.
2025-01-01 13:04
Repose

Registered: Oct 2010
Posts: 227
I was paid to do this for the diagnostic test of the SID Symphony cartridge. If anyone knows where to find this I'd be interested to take a look again.
But one thing I wanted to mention is that poking around can be dangerous if there are other devices. My routine worked with any combo of REU, Super Snapshot, or Swiftlink 232 without crashing anything or having bad effects.
You should also know where to look. The legacy ways were either $DE00 or $DF00, but now it can be in odd places like $DF80. One good thing about the SID is it has so many registers and most other things don't, so I'd use the registers later in address space.
Some general principles in hardware detection is looking for static values, testing writability, then testing for known effects. But doing this in a safe way for all common cartridges and all current or future weird address mappings is a bit more difficult. Even reading a location can have effects.
As to an actual routine, I'll have to think about how to do it properly. Before that, if you want to detect a sid and only a sid, checking the osc3 output seems the way to go.
2025-01-03 09:22
tlr

Registered: Sep 2003
Posts: 1791
I did an implementation of this here: sid-detect2 (source: testprogs/SID/mapping/)
(as discussed in this thread: Proposal for 2SID hardware-compatibility)

Didn't extensively test that against all combinations of carts and such so the order of scanning may need to be tweaked, but the general concept should be good.
2025-01-03 10:34
Dano

Registered: Jul 2004
Posts: 240
Thank you tlr!

Now i need to look what needs to be patched in a SidWizard tune to adjust to other Sid locations.
2025-01-03 22:46
chatGPZ

Registered: Dec 2001
Posts: 11390
Cant you make it use shadow-registers? That should make it trivial
2025-01-04 01:58
Dano

Registered: Jul 2004
Posts: 240
Could do that ofcourse.

Yet i am still unsure on how much a certain order on SID register writes does matter or not?!

It seems not to break Toggle's tunes when i use the analyser code. But i've seen player screens to seem to care for order of writes..
2025-01-04 02:01
chatGPZ

Registered: Dec 2001
Posts: 11390
well, the docs for the player should tell you the write order. Else you can just put a few watchpoints in VICE and figure it out. (Chances are copying backwards is fine)
2025-01-04 07:04
Raistlin

Registered: Mar 2007
Posts: 685
Quote: Could do that ofcourse.

Yet i am still unsure on how much a certain order on SID register writes does matter or not?!

It seems not to break Toggle's tunes when i use the analyser code. But i've seen player screens to seem to care for order of writes..


Yeah, the write order to SID registers matters… so you need to figure out the order from the player - and note that player settings can change everything (GoatTracker has multiple modes for example).

Just do:-

> w store d400 d418

In VICE mon and note the order that the writes happen.
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
Didi/Laxity
Black Hole
Twoflower/ΤRIΛD
Guests online: 113
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.6)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 Uncensored  (9.6)
7 The Demo Coder  (9.6)
8 Comaland 100%  (9.6)
9 Wonderland XIV  (9.6)
10 What Is The Matrix 2  (9.6)
Top onefile Demos
1 Layers  (9.7)
2 Cubic Dream  (9.6)
3 Party Elk 2  (9.6)
4 Copper Booze  (9.6)
5 Rainbow Connection  (9.5)
6 Morph  (9.5)
7 Dawnfall V1.1  (9.5)
8 Libertongo  (9.5)
9 Katzen-Video.mp4  (9.5)
10 Onscreen 5k  (9.5)
Top Groups
1 Booze Design  (9.3)
2 Oxyron  (9.3)
3 Performers  (9.3)
4 Fairlight  (9.3)
5 Triad  (9.3)
Top Graphicians
1 Hend  (9.8)
2 Mirage  (9.7)
3 Archmage  (9.7)
4 Pal  (9.6)
5 Carrion  (9.6)

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