Files
oboe/osx/Scenario Editor/global.c
Catphive 9bc3b0c07b Adding osx files.
git-svn-id: http://openexile.googlecode.com/svn/trunk@2 4ebdad44-0ea0-11de-aab3-ff745001d230
2009-03-12 01:38:20 +00:00

58 lines
860 B
C

#include <Carbon/Carbon.h>
#include "global.h"
#include "math.h"
short get_ran (short times,short min,short max)
{
long int store;
short i, to_ret = 0;
for (i = 1; i < times + 1; i++) {
store = Random();
to_ret = to_ret + min + (((store + 32767) * (max - min + 1)) / 65536);
}
return to_ret;
}
short s_pow(short x,short y)
{
return (short) pow((double) x, (double) y);
}
short dist(location p1,location p2)
{
return (short) sqrt((double)((p1.x - p2.x) * (p1.x - p2.x) +
(p1.y - p2.y) * (p1.y - p2.y)));
}
short max(short a,short b)
{
if (a > b)
return a;
else return b;
}
short min(short a,short b)
{
if (a < b)
return a;
else return b;
}
short minmax(short min,short max,short k)
{
if (k < min)
return min;
if (k > max)
return max;
return k;
}
/*
short abs(short x)
{
if (x < 0)
return x * -1;
return x;
}
*/