train_cmd.c
changeset 3341 b8febc9509d7
parent 3334 b72ac8637a30
child 3355 a653b8e47f27
equal deleted inserted replaced
3340:eb5021cb6639 3341:b8febc9509d7
  2085 	{ 3, 2, 9, 9 }, // track left
  2085 	{ 3, 2, 9, 9 }, // track left
  2086 	{ 9, 9, 1, 0 }, // track right
  2086 	{ 9, 9, 1, 0 }, // track right
  2087 };
  2087 };
  2088 
  2088 
  2089 static const byte _pick_track_table[6] = {1, 3, 2, 2, 0, 0};
  2089 static const byte _pick_track_table[6] = {1, 3, 2, 2, 0, 0};
  2090 #ifdef PF_BENCHMARK
       
  2091 #if !defined(_MSC_VER)
       
  2092 unsigned int _rdtsc()
       
  2093 {
       
  2094 	unsigned int high, low;
       
  2095 
       
  2096 	__asm__ __volatile__ ("rdtsc" : "=a" (low), "=d" (high));
       
  2097 	return low;
       
  2098 }
       
  2099 #else
       
  2100 #ifndef _M_AMD64
       
  2101 static unsigned int _declspec(naked) _rdtsc(void)
       
  2102 {
       
  2103 	_asm {
       
  2104 		rdtsc
       
  2105 		ret
       
  2106 	}
       
  2107 }
       
  2108 #endif
       
  2109 #endif
       
  2110 #endif
       
  2111 
       
  2112 
       
  2113 
  2090 
  2114 /* choose a track */
  2091 /* choose a track */
  2115 static byte ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirbits)
  2092 static byte ChooseTrainTrack(Vehicle* v, TileIndex tile, DiagDirection enterdir, TrackdirBits trackdirbits)
  2116 {
  2093 {
  2117 	TrainTrackFollowerData fd;
  2094 	TrainTrackFollowerData fd;
  2118 	uint best_track;
  2095 	uint best_track;
  2119 #ifdef PF_BENCHMARK
  2096 #ifdef PF_BENCHMARK
  2120 	int time = _rdtsc();
  2097 	TIC()
  2121 	static float f;
       
  2122 #endif
  2098 #endif
  2123 
  2099 
  2124 	assert((trackdirbits & ~0x3F) == 0);
  2100 	assert((trackdirbits & ~0x3F) == 0);
  2125 
  2101 
  2126 	/* quick return in case only one possible track is available */
  2102 	/* quick return in case only one possible track is available */
  2169 			best_track = fd.best_track & 7;
  2145 			best_track = fd.best_track & 7;
  2170 		}
  2146 		}
  2171 	}
  2147 	}
  2172 
  2148 
  2173 #ifdef PF_BENCHMARK
  2149 #ifdef PF_BENCHMARK
  2174 	time = _rdtsc() - time;
  2150 	TOC("PF time = ", 1)
  2175 	f = f * 0.99 + 0.01 * time;
       
  2176 	printf("PF time = %d %f\n", time, f);
       
  2177 #endif
  2151 #endif
  2178 
  2152 
  2179 	return best_track;
  2153 	return best_track;
  2180 }
  2154 }
  2181 
  2155