Wed, 17 Jul 2013 19:44:46 +0300
Added a prompt for demo information
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
1 | #ifndef MISC_H |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
2 | #define MISC_H |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
3 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
4 | #include "types.h" |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
5 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
6 | uint32 makeByteID( uint8 a, uint8 b, uint8 c, uint8 d ); |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
7 | str binaryConfigName( str ver ); |
8
e8f645d9f28f
Added a prompt for demo information
Teemu Piippo <crimsondusk64@gmail.com>
parents:
6
diff
changeset
|
8 | str basename( str path ); |
6
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
9 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
10 | // ----------------------------------------------------------------------------- |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
11 | // Templated clamp |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
12 | template<class T> static inline T clamp (T a, T min, T max) { |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
13 | return (a > max) ? max : (a < min) ? min : a; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
14 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
15 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
16 | // Templated minimum |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
17 | template<class T> static inline T min (T a, T b) { |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
18 | return (a < b) ? a : b; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
19 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
20 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
21 | // Templated maximum |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
22 | template<class T> static inline T max (T a, T b) { |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
23 | return (a > b) ? a : b; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
24 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
25 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
26 | // Templated absolute value |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
27 | template<class T> static inline T abs (T a) { |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
28 | return (a >= 0) ? a : -a; |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
29 | } |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
30 | |
67b6ef6917ba
Now capable of actually launching demos
Teemu Piippo <crimsondusk64@gmail.com>
parents:
diff
changeset
|
31 | #endif // MISC_H |