summaryrefslogtreecommitdiff
path: root/src/common.h
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-05-29 23:17:41 +0200
committerGitHub <noreply@github.com>2019-05-29 23:17:41 +0200
commitb705be0e873a3b93c561a7945748328604e48f21 (patch)
tree8f8b32c251a57707b676a037d6846e7d0162dd18 /src/common.h
parent820fd66a94c20c4e1dab21f6abda4138eaefbe79 (diff)
parent6f9c1f307f48d1eefc849b99123f9bc2c04e21b7 (diff)
Merge pull request #2 from Fire-Head/master
Particle, ParticleMgr done
Diffstat (limited to 'src/common.h')
-rw-r--r--src/common.h83
1 files changed, 79 insertions, 4 deletions
diff --git a/src/common.h b/src/common.h
index 083f4257..89c031fe 100644
--- a/src/common.h
+++ b/src/common.h
@@ -26,6 +26,24 @@ typedef uint32_t uint32;
typedef int32_t int32;
typedef uintptr_t uintptr;
+typedef char Int8;
+typedef unsigned char UInt8;
+typedef signed char SInt8;
+typedef short Int16;
+typedef unsigned short UInt16;
+typedef signed short SInt16;
+typedef int Int32;
+typedef unsigned int UInt32;
+typedef signed int SInt32;
+typedef float Float;
+typedef double Double;
+typedef Int8 Bool; //typedef bool Bool;
+typedef char Char;
+
+typedef __int64 Int64;
+typedef unsigned __int64 UInt64;
+typedef signed __int64 SInt64;
+
#define nil NULL
#include "config.h"
@@ -63,6 +81,15 @@ extern RsGlobalType &RsGlobal;
#define SCREENW (RsGlobal.maximumWidth)
#define SCREENH (RsGlobal.maximumHeight)
+#define DEFAULT_SCREEN_WIDTH (640)
+#define DEFAULT_SCREEN_HEIGHT (448)
+#define SCREEN_WIDTH Float(RsGlobal.width)
+#define SCREEN_HEIGHT Float(RsGlobal.height)
+#define SCREEN_STRETCH_X(a) Float( a * ( SCREEN_WIDTH / Float(DEFAULT_SCREEN_WIDTH) ) )
+#define SCREEN_STRETCH_Y(a) Float( a * ( SCREEN_HEIGHT / Float(DEFAULT_SCREEN_HEIGHT) ) )
+#define SCREEN_FROM_RIGHT(a) Float( SCREEN_WIDTH - SCREEN_STRETCH_X(a) )
+#define SCREEN_FROM_BOTTOM(a) Float( SCREEN_HEIGHT - SCREEN_STRETCH_Y(a) )
+
char *GetUserDirectory(void);
struct GlobalScene
@@ -80,22 +107,70 @@ extern GlobalScene &Scene;
class CRGBA
{
public:
- uint8 r, g, b, a;
+ union
+ {
+ uint32 color32;
+ struct { uint8 r, g, b, a; };
+ struct { uint8 red, green, blue, alpha; };
+#ifdef RWCORE_H
+ struct { RwRGBA rwRGBA; };
+#endif
+ };
+
CRGBA(void) { }
CRGBA(uint8 r, uint8 g, uint8 b, uint8 a) : r(r), g(g), b(b), a(a) { }
+#ifdef RWCORE_H
+ operator RwRGBA &(void)
+ {
+ return rwRGBA;
+ }
+
+ operator RwRGBA *(void)
+ {
+ return &rwRGBA;
+ }
+
+ operator RwRGBA (void) const
+ {
+ return rwRGBA;
+ }
+#endif
};
-inline float
-clamp(float v, float min, float max){ return v<min ? min : v>max ? max : v; }
+// inline float clamp(float v, float min, float max){ return v<min ? min : v>max ? max : v; }
+
inline float
sq(float x) { return x*x; }
+
+#define SQR(x) ( x * x )
+
#define PI M_PI
-#define DEGTORAD(d) (d/180.0f*PI)
+#define DEGTORAD(x) ((x) * PI / 180.0f)
+#define RADTODEG(x) ((x) * 180.0f / PI)
+
+
+#if USE_PS2_RAND == TRUE
+#define MY_RAND_MAX 65535
+#else
+#define MY_RAND_MAX 32767
+#endif
int myrand(void);
void mysrand(unsigned int seed);
#define debug printf
+#define ASSERT assert
+
+#define _TODO(x)
+#define _TODOCONST(x) (x)
+#define VALIDATE_SIZE(struc, size) static_assert(sizeof(struc) == size, "Invalid structure size of " #struc)
+#define VALIDATE_OFFSET(struc, member, offset) static_assert(offsetof(struc, member) == offset, "The offset of " #member " in " #struc " is not " #offset "...")
+
+#define clamp(v, a, b) (max(min(v, b), a))
//#define min(a, b) ((a) < (b) ? (a) : (b))
//#define max(a, b) ((a) > (b) ? (a) : (b))
+
+#define PERCENT(x, p) ( ( Float(x) * ( Float(p) / 100.0f ) ) )
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
+#define BIT(num) (1<<(num)) \ No newline at end of file