2019-05-15 16:52:37 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#define _CRT_SECURE_NO_WARNINGS
|
|
|
|
#define _USE_MATH_DEFINES
|
|
|
|
#pragma warning(disable: 4244) // int to float
|
|
|
|
#pragma warning(disable: 4800) // int to bool
|
|
|
|
#pragma warning(disable: 4838) // narrowing conversion
|
2019-05-24 19:58:32 +02:00
|
|
|
#pragma warning(disable: 4996) // POSIX names
|
2019-05-15 16:52:37 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <math.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <new>
|
|
|
|
|
|
|
|
#include <rwcore.h>
|
|
|
|
#include <rpworld.h>
|
|
|
|
|
|
|
|
#define rwVENDORID_ROCKSTAR 0x0253F2
|
|
|
|
|
|
|
|
typedef uint8_t uint8;
|
|
|
|
typedef int8_t int8;
|
|
|
|
typedef uint16_t uint16;
|
|
|
|
typedef int16_t int16;
|
|
|
|
typedef uint32_t uint32;
|
|
|
|
typedef int32_t int32;
|
|
|
|
typedef uintptr_t uintptr;
|
|
|
|
|
2019-05-29 02:52:30 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
#define nil NULL
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#define ALIGNPTR(p) (void*)((((uintptr)(void*)p) + sizeof(void*)-1) & ~(sizeof(void*)-1))
|
|
|
|
|
|
|
|
// little hack
|
|
|
|
extern void **rwengine;
|
|
|
|
#define RwEngineInstance (*rwengine)
|
|
|
|
|
|
|
|
// TODO
|
|
|
|
struct RsInputDevice
|
|
|
|
{
|
|
|
|
int inputDeviceType;
|
|
|
|
int used;
|
|
|
|
void *inputEventHandler;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct RsGlobalType
|
|
|
|
{
|
|
|
|
const char *appName;
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int maximumWidth;
|
|
|
|
int maximumHeight;
|
|
|
|
int maxFPS;
|
|
|
|
int quit;
|
|
|
|
void *ps;
|
|
|
|
RsInputDevice keyboard;
|
|
|
|
RsInputDevice mouse;
|
|
|
|
RsInputDevice pad;
|
|
|
|
};
|
|
|
|
extern RsGlobalType &RsGlobal;
|
|
|
|
|
|
|
|
#define SCREENW (RsGlobal.maximumWidth)
|
|
|
|
#define SCREENH (RsGlobal.maximumHeight)
|
|
|
|
|
2019-05-29 02:52:30 +02:00
|
|
|
#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) )
|
|
|
|
|
2019-05-24 19:58:32 +02:00
|
|
|
char *GetUserDirectory(void);
|
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
struct GlobalScene
|
|
|
|
{
|
|
|
|
RpWorld *world;
|
|
|
|
RwCamera *camera;
|
|
|
|
};
|
|
|
|
extern GlobalScene &Scene;
|
|
|
|
|
|
|
|
#include "math/Vector.h"
|
|
|
|
#include "math/Vector2D.h"
|
|
|
|
#include "math/Matrix.h"
|
|
|
|
#include "math/Rect.h"
|
|
|
|
|
|
|
|
class CRGBA
|
|
|
|
{
|
|
|
|
public:
|
2019-05-29 02:52:30 +02:00
|
|
|
union
|
|
|
|
{
|
|
|
|
uint32 color32;
|
|
|
|
struct { uint8 r, g, b, a; };
|
|
|
|
struct { uint8 red, green, blue, alpha; };
|
|
|
|
#ifdef RWCORE_H
|
|
|
|
struct { RwRGBA rwRGBA; };
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
CRGBA(void) { }
|
|
|
|
CRGBA(uint8 r, uint8 g, uint8 b, uint8 a) : r(r), g(g), b(b), a(a) { }
|
2019-05-29 02:52:30 +02:00
|
|
|
#ifdef RWCORE_H
|
|
|
|
operator RwRGBA &(void)
|
|
|
|
{
|
|
|
|
return rwRGBA;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator RwRGBA *(void)
|
|
|
|
{
|
|
|
|
return &rwRGBA;
|
|
|
|
}
|
|
|
|
|
|
|
|
operator RwRGBA (void) const
|
|
|
|
{
|
|
|
|
return rwRGBA;
|
|
|
|
}
|
|
|
|
#endif
|
2019-05-15 16:52:37 +02:00
|
|
|
};
|
|
|
|
|
2019-05-29 02:52:30 +02:00
|
|
|
// inline float clamp(float v, float min, float max){ return v<min ? min : v>max ? max : v; }
|
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
inline float
|
|
|
|
sq(float x) { return x*x; }
|
2019-05-29 02:52:30 +02:00
|
|
|
|
|
|
|
#define SQR(x) ( x * x )
|
|
|
|
|
2019-05-15 16:52:37 +02:00
|
|
|
#define PI M_PI
|
2019-05-29 02:52:30 +02:00
|
|
|
#define DEGTORAD(x) ((x) * PI / 180.0f)
|
|
|
|
#define RADTODEG(x) ((x) * 180.0f / PI)
|
2019-05-15 16:52:37 +02:00
|
|
|
|
|
|
|
int myrand(void);
|
|
|
|
void mysrand(unsigned int seed);
|
|
|
|
|
|
|
|
#define debug printf
|
2019-05-29 02:52:30 +02:00
|
|
|
#define ASSERT assert
|
2019-05-15 16:52:37 +02:00
|
|
|
|
2019-05-29 02:52:30 +02:00
|
|
|
#define clamp(v, a, b) (max(min(v, b), a))
|
2019-05-15 16:52:37 +02:00
|
|
|
//#define min(a, b) ((a) < (b) ? (a) : (b))
|
|
|
|
//#define max(a, b) ((a) > (b) ? (a) : (b))
|
2019-05-29 02:52:30 +02:00
|
|
|
|
|
|
|
#define PERCENT(x, p) ( ( Float(x) * ( Float(p) / 100.0f ) ) )
|
|
|
|
#define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
|
|
|
|
#define BIT(num) (1<<(num))
|