]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Added optional gettickcount() timing
authorToni Wilen <twilen@winuae.net>
Sun, 16 Nov 2025 11:39:01 +0000 (13:39 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 16 Nov 2025 11:39:01 +0000 (13:39 +0200)
include/uae/time.h
od-win32/win32.cpp
support/time.cpp

index dcbdd3a7f058c4269910ac5e35e5277da58be2bc..7627a1d72f695a2a1373b092c3a5f0a684f27856 100644 (file)
@@ -11,7 +11,7 @@ void uae_time_calibrate(void);
 uae_time_t uae_time(void);
 
 #ifdef _WIN32
-void uae_time_use_rdtsc(bool enable);
+void uae_time_use_mode(int mode);
 uae_s64 read_system_time(void);
 uae_s64 read_processor_time_rdtsc(void);
 #endif
index 45e3c03c092d18d30eb46d12e391ba51649fa75e..49fe75b3e20af24e5742fc4f74e779fe81dd66a9 100644 (file)
@@ -6886,7 +6886,11 @@ static int parseargs(const TCHAR *argx, const TCHAR *np, const TCHAR *np2)
                return 1;
        }
        if (!_tcscmp(arg, _T("forcerdtsc"))) {
-               uae_time_use_rdtsc(true);
+               uae_time_use_mode(1);
+               return 1;
+       }
+       if (!_tcscmp(arg, _T("forcetickcount"))) {
+               uae_time_use_mode(2);
                return 1;
        }
        if (!_tcscmp(arg, _T("ddsoftwarecolorkey"))) {
index b98b6454a52227189d34697d926f913a4c67255c..ec06b34dd60c65daa610dc80489c7a42cdca5d6d 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <process.h>
 
-static int userdtsc = 0;
+static int usedtimermode = 0;
 static int qpcdivisor = 0;
 static SYSTEM_INFO si;
 
@@ -27,6 +27,12 @@ static frame_time_t read_processor_time_qpf(void)
        return t;
 }
 
+static frame_time_t read_processor_time_tickcount(void)
+{
+       frame_time_t v = (frame_time_t)GetTickCount64();
+       return v;
+}
+
 uae_s64 read_processor_time_rdtsc(void)
 {
 #ifdef __arm__
@@ -48,10 +54,13 @@ uae_time_t uae_time(void)
                cnt = 0;
        }
 #endif
-       if (userdtsc)
+       if (usedtimermode == 1) {
                t = read_processor_time_rdtsc();
-       else
+       } else if (usedtimermode == 0) {
                t = read_processor_time_qpf();
+       } else {
+               t = read_processor_time_tickcount();
+       }
        return t;
 }
 
@@ -85,6 +94,12 @@ static uae_s64 win32_read_processor_time(void)
 #endif
 }
 
+static void figure_processor_speed_tickcount(void)
+{
+       syncbase = 1000;
+       write_log(_T("CLOCKFREQ: TC %.4fMHz\n"), syncbase / 10000000.0);
+}
+
 static void figure_processor_speed_rdtsc(void)
 {
        static int freqset;
@@ -106,7 +121,7 @@ static void figure_processor_speed_rdtsc(void)
        clockrate = (win32_read_processor_time() - clockrate) * 2;
        dummythread_die = 0;
        SetThreadPriority(th, oldpri);
-       write_log(_T("CLOCKFREQ: RDTSC %.2fMHz\n"), clockrate / 1000000.0);
+       write_log(_T("CLOCKFREQ: RDTSC %.4fMHz\n"), clockrate / 1000000.0);
        syncbase = clockrate >> 6;
 }
 
@@ -128,7 +143,7 @@ static void figure_processor_speed_qpf(void)
                qpfrate >>= 1;
                qpcdivisor++;
        }
-       write_log(_T("CLOCKFREQ: QPF %.2fMHz (%.2fMHz, DIV=%d)\n"),
+       write_log(_T("CLOCKFREQ: QPF %.4fMHz (%.2fMHz, DIV=%d)\n"),
                  freq.QuadPart / 1000000.0,
                  qpfrate / 1000000.0, 1 << qpcdivisor);
        syncbase = qpfrate;
@@ -136,17 +151,18 @@ static void figure_processor_speed_qpf(void)
 
 void uae_time_calibrate(void)
 {
-       if (userdtsc) {
+       if (usedtimermode == 1) {
                figure_processor_speed_rdtsc();
-       }
-       if (!userdtsc) {
+       } if (usedtimermode == 0) {
                figure_processor_speed_qpf();
+       } else {
+               figure_processor_speed_tickcount();
        }
 }
 
-void uae_time_use_rdtsc(bool enable)
+void uae_time_use_mode(int mode)
 {
-       userdtsc = enable;
+       usedtimermode = mode;
 }
 
 #elif defined(USE_GLIB)