| |
SIDWAVE Account closed
Registered: Apr 2002 Posts: 2238 |
C64 Clock/Time routine
Houston we have a problem!
About all clocks i have seen on C64, run too slow.
More specificly i am annoyed with SDI music tracker, and PSID64 clocks.
They run too slow!
If they play music for 4 minutes, they will claim they only played like 3:41 or so.
So my question is:
Are the coders on the wrong path, or is the C64 ? |
|
... 23 posts hidden. Click here to view all posts.... |
| |
Stainless Steel
Registered: Mar 2003 Posts: 966 |
Quoting GRGThis will be fixed for the next release.
Did i hear "next release" ? <3<3<3
|
| |
Devia
Registered: Oct 2004 Posts: 401 |
oh noes.. I just remembered that the SX-64 has 60Hz TOD ONLY!
This means that even if you detect a PAL SX-64 correctly as PAL, you still end up gaining roughtly 10 seconds every minute if you set $DC0E bit 7 to 1 (50Hz)
So how does one properly detect an SX-64 if its KERNAL got replaced?
Seems to me like you have to "measure" the time of the TOD to be sure if its 50 or 60Hz clocked :(
|
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: oh noes.. I just remembered that the SX-64 has 60Hz TOD ONLY!
This means that even if you detect a PAL SX-64 correctly as PAL, you still end up gaining roughtly 10 seconds every minute if you set $DC0E bit 7 to 1 (50Hz)
So how does one properly detect an SX-64 if its KERNAL got replaced?
Seems to me like you have to "measure" the time of the TOD to be sure if its 50 or 60Hz clocked :(
To detect PAL or NTSC couldn't one simply just poll $d011&$d012. PAL machines will be able to reach higher values than NTSC.
From the top of my head completely untested:
sei
bit $d011
bmi *-3
bit $d011
bpl *-3
; we're now on line 256.
; Check if we ever reach line 311 before VBL
ldx #0
lda #<311
:
cmp $d012
bne :+
inx
jmp :++
:
bit $d011
bmi :--
:
cli
txa
beq :+
; PAL
jmp :++
:
; NTSC
:
|
| |
JackAsser
Registered: Jun 2002 Posts: 2014 |
Quote: oh noes.. I just remembered that the SX-64 has 60Hz TOD ONLY!
This means that even if you detect a PAL SX-64 correctly as PAL, you still end up gaining roughtly 10 seconds every minute if you set $DC0E bit 7 to 1 (50Hz)
So how does one properly detect an SX-64 if its KERNAL got replaced?
Seems to me like you have to "measure" the time of the TOD to be sure if its 50 or 60Hz clocked :(
Not that my detection routine solves that issue... :) |
| |
Devia
Registered: Oct 2004 Posts: 401 |
heh.. appreciate your efforts, but no, that doesn't really solve the problem ;-)
|
| |
yago
Registered: May 2002 Posts: 333 |
Quote: TOD is more than good enough to measure 4 minutes accuratly
Unfortunately, no.
While playing around with TOD, i sent my testprg around the world, and in some places,where power-frequency ought to be 50Hz, it was 60Hz.
(On many places, the difference was smaller, but on many the clock will go wrong after 4 minutes)
With other Words: Its 2009, Power Companies deliver worse Quality then ever.
|
| |
Devia
Registered: Oct 2004 Posts: 401 |
Hmm.. yeah.. so unless you have a xtal generating the TOD clk, like in the SX-64, you're at the mercy of your local power company in regards to TOD precision.
So the conlusion must be that TOD is reliable only under controlled circumstances and is definately not to be relied on in all cases.
That sux.
|
| |
yago
Registered: May 2002 Posts: 333 |
Dont be so negative!
TOD can be used to measure quality of power!
;-) |
| |
chatGPZ
Registered: Dec 2001 Posts: 11386 |
Quote:and in some places,where power-frequency ought to be 50Hz, it was 60Hz.
seriously, if that is the case you have a much bigger problem than a clock that doesnt work right :)
you can be pretty sure that there is no problem all over europe, and all over the usa (both unified power nets, which makes it kinda impossible that frequencies are not what you expect).
also i kinda doubt it, a broken pal/ntsc detection is much more likely :) what country would that be that has "wrong" power frequency? (and after reading devias post: were sx-64s involved?).
seriously, the power frequency beeing wrong is... something you might experience in a handful 3rd world countries that dont have unified power nets. anywhere else.... no. |
| |
Devia
Registered: Oct 2004 Posts: 401 |
ha HA!
I found a solution..
To properly initialize the TOD on any platform(*) do this:
1. Detect PAL/NTSC
2. If PAL, set 60Hz, else set 50Hz TOD
3. Wait for more than 5 and less than 6 frames
4. If $DC08 == 1, set 60Hz, else set 50Hz TOD
This method should work on PAL and NTSC with both 50Hz and 60Hz clocked TODs.
(*) - Well.. any platform but Vice apparently. Vice seems to ignore bit 7 of $DC0E, so it will always be correct ;)
I don't have any NTSC machines, so if there's someone out there with an NTSC c64 who wants to test this, please PM me. |
Previous - 1 | 2 | 3 | 4 - Next |