Game Development Community

NfoCipher's FC4 Tutorial

by Charles Doty · in Torque Game Engine · 12/24/2005 (9:03 am) · 1 replies

Currently, I am trying to comiler and run the Torque SDK 1.3 on Suse 10.0 running 32 bit on a AMD Athlon 64. I was reading the "Unable to compile Torque 1.3.0 on Fedora Core 4" thread, and that fixed most of my problems. Later in the thread, the person having the problem says they fixed a Seg Fault from NfoCipher's T2D FC4 Tutorial. The link doesn't work anymore for the tutorial. My exact problem is I got everything to compile and link, but everytime I run either the release or debug it Seg Faults before even opening up a window. Has anyone had this particular problem or does anybody have a copy of NfoCipher's tutorial? Thanks in advance.

#1
12/24/2005 (9:43 am)
Here's the fix for the segfaults:
--- x86UNIXCPUInfo.old.cc	2004-11-15 22:11:32.000000000 -0500
+++ x86UNIXCPUInfo.cc	2004-11-15 22:13:07.000000000 -0500
@@ -29,6 +29,8 @@
 static char vendor[13] = {0,};
 static U32 properties = 0;
 static U32 processor  = 0;
+static U32 timeLo;
+static U32 timeHi;
 
 void Processor::init()
 {
@@ -55,6 +57,9 @@
        Platform::SystemInfo.processor.properties & CPU_PROP_FPU)
    {
       const U32 MS_INTERVAL = 750;
+#if defined(TORQUE_COMPILER_GCC) && ((__GNUC__ >= 3) && (__GNUC_MINOR__ >= 4))
+       asm ("rdtsc" : "=a" (timeLo), "=d" (timeHi));
+#else
       __asm__(
          "pushl  %eax\n"
          "pushl  %edx\n"
@@ -64,10 +69,23 @@
          "popl   %edx\n"
          "popl   %eax\n"
          );
+#endif
       U32 ms = Platform::getRealMilliseconds();
       while ( Platform::getRealMilliseconds() < ms+MS_INTERVAL )
       { /* empty */ }
       ms = Platform::getRealMilliseconds()-ms;
+#if defined(TORQUE_COMPILER_GCC) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ == 4))
+      asm(
+         "pushl  %eax\n"
+         "pushl  %edx\n"
+         "rdtsc\n"
+         "sub    (timeHi), %edx\n"
+         "sbb    (timeLo), %eax\n"
+         "mov    %eax, (clockticks)\n"
+         "popl   %edx\n"
+         "popl   %eax\n"
+         );
+#else
       asm(
          "pushl  %eax\n"
          "pushl  %edx\n"
@@ -78,6 +96,7 @@
          "popl   %edx\n"
          "popl   %eax\n"
          );
+#endif
       U32 mhz = static_cast<U32>(F32(clockticks) / F32(ms) / 1000.0f);
       
       // catch-22 the timing method used above to calc Mhz is generally