Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Harvey ! (Registered 2024-11-25) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > How do I reliably detect 6581/8580 sid?
2006-08-22 14:18
tlr

Registered: Sep 2003
Posts: 1787
How do I reliably detect 6581/8580 sid?

There was an article in C=Hacking, but that does not work very well in VICE for example.
Maybe VICE's emulation is borked though.

I remember seeing a detailed analysis of the waveforms somewhere, but I can't seem to find it now.
2006-08-22 14:28
Jetboy

Registered: Jul 2006
Posts: 299
AFAIK you cannot test it _reliably_.
That's why many demos ask about it before they start.
2006-08-22 14:32
Zyron

Registered: Jan 2002
Posts: 2381
Mathematica has a SID tester that works in VICE too.
2006-08-22 14:54
tlr

Registered: Sep 2003
Posts: 1787
The principle that seems most workable is sampling the waveform of voice 3 (using $d41b) and interpreting it in some way. The test in C=Hacking checks the differences of the combined triangle + sawtooth waveforms. (http://www.ffd2.com/fridge/chacking/c=hacking20.txt)
It uses a very simplistic max-value approach which does not work in VICE.

Assuming there are differences in waveform, it should be possible to detect reliably because this is done in an all digital domain. The timing of triggering the voices/reading $d41b might be very tricky though.
2006-08-22 15:00
Frantic

Registered: Mar 2003
Posts: 1647
It's possible.

The solution in mathematica is the standard one I think (waveform 5 on onscillator 3.. and check osc3 output for values above $80. However.. I've done some testing and noticed that values over $80 can show up on 6581 machines too, but they do so very seldom, so if you just read some more values than ppl normally do and use a threshold value instead of expecting zero occurances you are totally safe. (You are 99.9% safe anyway, since I actually think you need to initialize SID with random values before setting this wav$05-stuff to get any values above $80 at all on a 6581 machine.)

One interesting side issue that I have discovered (by some help of Twoflower who did the actual slavework of running a testprogram on some of his machines ;) is that waveform $05 is not exactly identical on all 8580 machines when read from oscillator 3, which is a bit weird. It seems to depend on factors external to the SID itself, or something like that. In our tests it was actually 1:1 correlated to the serial numbers of the motherboards, eh... ...but that's probably a coincidence... or not..

Anyway.. I did this testing stuff without using a REU for reading osc3, which is of course how it should be done, so proper testing remains to be done to clarify the behaviour of waveform 5 on the different chips..
2006-08-22 15:01
chatGPZ

Registered: Dec 2001
Posts: 11357
you just play one of the combined waveforms that the 6581 can not produce and sample the output from osc3....that should be pretty reliable.

the timing test can be used for something else - detection of emulator :)
2006-08-22 15:20
tlr

Registered: Sep 2003
Posts: 1787
C=Hacking 20:
start    sei
         lda #11
         sta $d011
         lda #$20
         sta $d40e
         sta $d40f
         lda #%00110001
         sta $d412
         ldx #0
         stx high
loop     lda $d41b
         cmp high
         bcc ahead
         sta high
ahead    dex
         bne loop
         lda #%00110000
         sta $d412
         cli
         lda #27
         sta $d011
         lda high
         bmi SID8580
         bpl SID6581

Mathematica (interrupts disabled, but no blanked screen):
B11F   A2 18      LDX #$18
B121   A9 00      LDA #$00
B123   9D 18 D4   STA $D418,X
B126   CA         DEX
B127   10 FA      BPL $B123
B129   A9 02      LDA #$02
B12B   8D 0F D4   STA $D40F
B12E   A9 30      LDA #$30
B130   8D 12 D4   STA $D412
B133   A0 00      LDY #$00
B135   A2 00      LDX #$00
B137   AD 1B D4   LDA $D41B
B13A   30 08      BMI $B144
B13C   CA         DEX
B13D   D0 F8      BNE $B137
B13F   88         DEY
B140   D0 F5      BNE $B137
B142   F0 02      BEQ $B146
B144   A2 01      LDX #$01
B146   86 0B      STX $0B
B148   A9 00      LDA #$00
B14A   8D 0F D4   STA $D40F
B14D   8D 12 D4   STA $D412


The same basic principle.
The mathematica code never sets the Gate. The gate is unnecessary as $d41b reads the oscillator directly.
It also uses a lower frequency and a longer detection time.

Thanks for the suggestions! I'll try it out.
2006-08-22 15:39
Twoflower

Registered: Jan 2002
Posts: 434
Concerning my slave-testing of 8580's - it's clear that the waveform $05 differs from 8580 to 8580. It's also pretty clear that different SID's made at different production-runs at different factories produce slightly different results. The interesting part is that you probably can spot the factory and the time of making just by checking the combined waveform. One or two similar values, ok, that might be a coincidence. But here we have pretty much an 1:1 correlation?
2006-08-22 16:22
tlr

Registered: Sep 2003
Posts: 1787
Quote: Concerning my slave-testing of 8580's - it's clear that the waveform $05 differs from 8580 to 8580. It's also pretty clear that different SID's made at different production-runs at different factories produce slightly different results. The interesting part is that you probably can spot the factory and the time of making just by checking the combined waveform. One or two similar values, ok, that might be a coincidence. But here we have pretty much an 1:1 correlation?

@Twoflower: Do you mean $05 as in sync+ringmod+gate?
2006-08-22 19:14
McMeatLoaf

Registered: Jan 2005
Posts: 108
$05 as in ringmod+gate, I think.
2006-08-22 20:38
tlr

Registered: Sep 2003
Posts: 1787
Quote: $05 as in ringmod+gate, I think.

Doh! I knew that...

But what happens when you just set ringmod + gate with no selected waveform?
If you are unlucky you'll feed the ringmod xor-gate with High-Z which could result in process/temperature dependent behaviour (which is what seems to happen).
Also ringmod on voice 3 will surely depend on what voice 2 is setup to.

@Twoflower: could you please give some more details on your tests?
 
... 47 posts hidden. Click here to view all posts....
 
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
iceout/Avatar/HF
Mike
MWR/Visdom
Alakran_64
t0m3000/hf^boom!^ibx
csabanw
Frostbyte/Artline De..
subjik/F4CG
MightyAxle
Aomeba/Artline Desig..
Skate/Plush
rikib80
Guests online: 109
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 The Demo Coder  (9.6)
7 What Is The Matrix 2  (9.6)
8 Uncensored  (9.6)
9 Wonderland XIV  (9.6)
10 Comaland 100%  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Libertongo  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Morph  (9.5)
9 Dawnfall V1.1  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Nostalgia  (9.3)
5 Triad  (9.2)
Top Crackers
1 Mr. Z  (9.9)
2 Antitrack  (9.8)
3 OTD  (9.8)
4 Fungus  (9.8)
5 S!R  (9.8)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.277 sec.