summaryrefslogtreecommitdiff
path: root/3dc/win95/PENTIME.H
diff options
context:
space:
mode:
authorRebellion Developments <rebellion@nomail>2000-03-16 11:25:00 +0100
committerPatryk Obara <dreamer.tan@gmail.com>2019-08-19 05:45:17 +0200
commit218ca90543758a20ac326e444ca0643174ca7384 (patch)
tree16bfe3e5307f9f515489000f28728224291a0e3b /3dc/win95/PENTIME.H
Import Aliens vs Predator - Gold (Build 116)
Source code release, imported from: https://www.gamefront.com/games/aliens-vs-predator-3/file/avp-gold-complete-source-code All text files were converted to Unix format.
Diffstat (limited to '3dc/win95/PENTIME.H')
-rw-r--r--3dc/win95/PENTIME.H64
1 files changed, 64 insertions, 0 deletions
diff --git a/3dc/win95/PENTIME.H b/3dc/win95/PENTIME.H
new file mode 100644
index 0000000..8c66961
--- /dev/null
+++ b/3dc/win95/PENTIME.H
@@ -0,0 +1,64 @@
+/* pentime.h */
+extern unsigned long int rdtsc_lo(void);
+extern unsigned long int rdtsc_hi(void);
+extern unsigned long int rdtsc_mid(void);
+
+#define ProfileStart() \
+{ \
+ int time = rdtsc_lo();
+#define ProfileStop(x) \
+ textprint("%s %d\n",x,rdtsc_lo()-time); \
+}
+
+#pragma aux rdtsc_lo = \
+ "db 0fh, 31h" \
+ value [eax] \
+ modify [edx];
+
+#pragma aux rdtsc_hi = \
+ "db 0fh, 31h" \
+ value [edx] \
+ modify [eax];
+
+#pragma aux rdtsc_mid = \
+ "db 0fh, 31h" \
+ "shr eax, 10h" \
+ "shl edx, 10h" \
+ "add eax, edx" \
+ value [eax] \
+ modify [edx];
+
+/* Test to see if we have a Pentium or not. Note that this test is reliable
+ * enough for a tools project (where we can put in an overide switch) but not
+ * for a released product.
+ */
+extern unsigned char Pentium(void);
+#pragma aux Pentium = \
+ "pushfd" \
+ "pop eax" \
+ "or eax, 00200000h" \
+ "push eax" \
+ "popfd" \
+ "pushfd" \
+ "pop eax" \
+ "mov ecx, eax" \
+ "and eax, 00200000h" \
+ "cmp eax, 0" \
+ "je not_Pentium" \
+ "mov eax, ecx" \
+ "and eax, 0ffdfffffh" \
+ "push eax" \
+ "popfd" \
+ "pushfd" \
+ "pop eax" \
+ "and eax, 00200000h" \
+ "cmp eax, 0" \
+ "jne not_Pentium" \
+ "is_Pentium: mov al, 1" \
+ "jmp finish" \
+ "not_Pentium: mov al, 0" \
+ "finish: nop" \
+ value [al] \
+ modify [eax ecx]
+
+