02 January 2023, 20:09 | #1 |
Not a Rebel anymore
Join Date: Apr 2005
Location: UK
Age: 51
Posts: 497
|
TOD Clock Sync issue (was: Winuae 4.10 clock drift)
Since I've upgraded to winuae 4.10 my setup seems to suffer quite significant clock drift. I haven't had time to do much investigation so far but my setup was always fine with previous versions. I'm emulating a 4000 and the tod clock source is set to 50hz clock not vsync. I leave my system running winuae 24/7 as I'm running a bbs so clock sync is quite important.
I've switched back to the previous version for now but I will attempt to do further testing to see if I can figure out anything. Last edited by Phantasm; 31 March 2023 at 10:15. |
02 January 2023, 20:52 | #2 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,506
|
It was supposedly fixed in last few 4.10 betas. Attach your config, please.
|
03 January 2023, 10:44 | #3 |
Not a Rebel anymore
Join Date: Apr 2005
Location: UK
Age: 51
Posts: 497
|
config file attached as requested
|
03 January 2023, 17:23 | #4 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,506
|
Can't see anything obviously wrong. Does the clock run too slow or too fast and how much is the drift for example after 10 minutes?
EDIT: and is the drift same if you select 60Hz PSU tick compared to 50Hz PSU tick? Last edited by Toni Wilen; 03 January 2023 at 17:38. |
04 January 2023, 14:54 | #5 |
Not a Rebel anymore
Join Date: Apr 2005
Location: UK
Age: 51
Posts: 497
|
i may have jumped the gun as i am now not able to recreate it.
I will continue trying and let you know. |
04 January 2023, 18:31 | #6 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,506
|
Clock drift can still happen if emulator gets slowed down too much for any reason.
|
05 January 2023, 12:00 | #7 | |
Not a Rebel anymore
Join Date: Apr 2005
Location: UK
Age: 51
Posts: 497
|
Quote:
There is definitely something a bit weird going on. I left it running overnight and this morning I checked and it had lost around 8 hours (still showing around 17:00 from yesterday). When I clicked on the window to activate the clock started updating quickly as if it was trying to catch up but when it hit 00:00 it briefly updated to the next day and then reset back to the day before and its just cycling round and round now. It seems to run fine when i'm sitting watching it (no drift happens after 1 hour or more) then when its been left it seems to act strangely. Video clip.. https://tempclip.com/en/3tljcpbOUOkomWa/watch Last edited by Phantasm; 05 January 2023 at 12:10. |
|
31 March 2023, 11:12 | #8 |
Not a Rebel anymore
Join Date: Apr 2005
Location: UK
Age: 51
Posts: 497
|
I grabbed the WinUAE source code from github and after quite a bit of trial and error over the last few days I've managed to figure out whats going on here.
Its not a clock drift issue as such - its related to the TOD clock sync code. In the versions from this commit onwards https://github.com/tonioni/WinUAE/co...53a2ac9703735e where the CIA TOD code was refactored the tod clock sync goes wrong after around running for roughly 12 hours or so. so in the do_tod_hack code one line was changed to facilitate the refactoring Code:
static void do_tod_hack(int dotod) { ... if (docount) { cia[0].tod++; cia[0].tod &= 0x00ffffff; tod_hack_tod_last = cia[0].tod; - ciaa_checkalarm(false); //this line changed from this + cia_checkalarm(false, false, 0); // to this } Code:
static void ciaa_checkalarm(bool inc) { struct CIA *c = &cia[0]; if (checkalarm(c->tod, c->alarm, inc, 0)) { #if CIAA_DEBUG_IRQ write_log(_T("CIAA tod %08x %08x\n"), c->tod, c->alarm); #endif CIA_sync_interrupt(0, ICR_ALARM); } } Code:
static bool cia_checkalarm(bool inc, bool irq, int num) { struct CIA *c = &cia[num]; // hack: do not trigger alarm interrupt if KS code and both // tod and alarm == 0. This incorrectly triggers on non-cycle exact // modes. Real hardware value written to ciabtod by KS is always // at least 1 or larger due to bus cycle delays when reading // old value. #if 1 if (num) { if (!currprefs.cpu_compatible && (munge24(m68k_getpc()) & 0xFFF80000) != 0xF80000) { if (c->tod == 0 && c->alarm == 0) return false; } } #endif if (checkalarm(c->tod, c->alarm, inc)) { #if CIAB_DEBUG_IRQ write_log(_T("CIAB tod %08x %08x\n"), c->tod, c->alarm); #endif if (irq) { CIA_sync_interrupt(num, ICR_ALARM); } return true; } return false; } changing the new code to read cia_checkalarm(false, true, 0); resolves the problem and allows the time to work correctly and restores the code to working the same way it was working previous to the commit. In order more easily see this issue in effect I was able to run the do_tod_hack at a higher rate by focing this code to execute every time (by setting docount=1 just prior to the code block) if (docount) { cia[0].tod++; cia[0].tod &= 0x00ffffff; tod_hack_tod_last = cia[0].tod; cia_checkalarm(false, false, 0); } here is a video clip of the clock looping around using the above hack to speed up the process.. https://tempclip.com/52x9NkfQG6nmfgw/watch Hope this all makes sense. |
01 April 2023, 15:29 | #9 |
WinUAE developer
Join Date: Aug 2001
Location: Hämeenlinna/Finland
Age: 49
Posts: 26,506
|
Fix looks correct, thanks.
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
WinUAE clock not updated after Windows resume from sleep | hexaae | support.WinUAE | 17 | 23 February 2022 20:31 |
WormsDC Mouse drift | ScottC2010 | support.Games | 3 | 25 May 2017 13:12 |
Power Drift | antonvaltaz | HOL data problems | 2 | 17 July 2009 16:48 |
Clock not works on Winuae on Workbench/kick 1.3 | laser | support.WinUAE | 3 | 18 October 2007 15:28 |
Anyone played Rorke's Drift ? | Wally | support.Games | 1 | 26 October 2003 12:17 |
|
|