| |
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. :) |
|
| |
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. |
| |
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. |
| |
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. |
| |
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. |
| |
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. |
| |
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. |
| |
chatGPZ
Registered: Dec 2001 Posts: 11390 |
Cant you make it use shadow-registers? That should make it trivial |
| |
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.. |
| |
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) |
| |
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. |