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
2019-05-29 18:06:33 +02:00
# pragma warning(disable: 4305) // double to float
2019-05-15 16:52:37 +02:00
# 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>
2019-06-02 23:42:51 +02:00
//#include <assert.h>
2019-05-15 16:52:37 +02:00
# include <new>
2019-05-30 13:35:13 +02:00
# ifdef WITHD3D
2019-06-30 12:53:39 +02:00
# include <windows.h>
2019-05-30 13:35:13 +02:00
# include <d3d8types.h>
# endif
2019-05-15 16:52:37 +02:00
# include <rwcore.h>
# include <rpworld.h>
# define rwVENDORID_ROCKSTAR 0x0253F2
2019-05-30 00:47:33 +02:00
// Get rid of bullshit windows definitions, we're not running on an 8086
# ifdef far
# undef far
# endif
# ifdef near
# undef near
# endif
2019-06-17 00:16:38 +02:00
typedef uint8_t uint8 ;
typedef int8_t int8 ;
typedef uint16_t uint16 ;
typedef int16_t int16 ;
typedef uint32_t uint32 ;
typedef int32_t int32 ;
2019-05-15 16:52:37 +02:00
typedef uintptr_t uintptr ;
2019-06-17 00:16:38 +02:00
typedef uint64_t uint64 ;
typedef int64_t int64 ;
2019-06-01 23:17:39 +02:00
// hardcode ucs-2
2019-06-17 00:16:38 +02:00
typedef uint16_t wchar ;
2019-05-29 02:52:30 +02:00
2019-06-30 12:53:39 +02:00
# define nil nullptr
2019-05-15 16:52:37 +02:00
# include "config.h"
# define ALIGNPTR(p) (void*)((((uintptr)(void*)p) + sizeof(void*)-1) & ~(sizeof(void*)-1))
// little hack
extern void * * rwengine ;
# define RwEngineInstance (*rwengine)
2019-06-30 12:53:39 +02:00
# include "skeleton.h"
2019-06-16 00:20:55 +02:00
# include "Draw.h"
2019-06-20 02:31:03 +02:00
/*
{ SCREEN_STRETCH } Done originally by the game for most of the printed stuff .
Stretches everything to screen avoiding it ' s aspect ratio .
Looks good only in 4 : 3.
{ SCREEN_SCALE } Alternative to the one above , it ' s used in this project to scale
original content to a * DEFINED aspect ratio with the possibility to
set a multiplier and scale content differently .
In theory should look good on any screen .
*/
2019-06-16 00:20:55 +02:00
# define SCREEN_ASPECT_RATIO (CDraw::GetAspectRatio())
2019-05-15 16:52:37 +02:00
# 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)
2019-06-17 00:16:38 +02:00
# 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)))
2019-06-20 02:31:03 +02:00
# define SCREEN_STRETCH_FROM_RIGHT(a) float(SCREEN_WIDTH - SCREEN_STRETCH_X(a))
# define SCREEN_STRETCH_FROM_BOTTOM(a) float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a))
# define SCREEN_MULTIPLIER (CDraw::GetScreenMult())
# define SCREEN_SCALE(a) float((a) * (4.0f / 3.0f) / SCREEN_ASPECT_RATIO)
# define SCREEN_SCALE_X(a) SCREEN_SCALE(SCREEN_STRETCH_X(a) * SCREEN_MULTIPLIER)
# define SCREEN_SCALE_Y(a) (SCREEN_STRETCH_Y(a) * SCREEN_MULTIPLIER)
# define SCREEN_SCALE_FROM_RIGHT(a) (SCREEN_WIDTH - SCREEN_SCALE_X(a))
# define SCREEN_SCALE_FROM_BOTTOM(a) (SCREEN_HEIGHT - SCREEN_SCALE_Y(a))
2019-06-16 19:06:01 +02:00
2019-05-15 16:52:37 +02:00
# 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
2019-05-30 00:47:33 +02:00
operator RwRGBA & ( void ) {
2019-05-29 02:52:30 +02:00
return rwRGBA ;
}
2019-05-30 00:47:33 +02:00
operator RwRGBA * ( void ) {
2019-05-29 02:52:30 +02:00
return & rwRGBA ;
}
2019-05-30 00:47:33 +02:00
operator RwRGBA ( void ) const {
2019-05-29 02:52:30 +02:00
return rwRGBA ;
}
# endif
2019-05-15 16:52:37 +02:00
} ;
2019-05-30 00:47:33 +02:00
# define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v))
2019-05-29 02:52:30 +02:00
2019-05-30 00:47:33 +02:00
inline float sq ( float x ) { return x * x ; }
# define SQR(x) ((x) * (x))
2019-05-29 02:52:30 +02:00
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
2019-06-03 00:25:46 +02:00
# ifdef USE_PS2_RAND
2019-05-30 23:49:06 +02:00
# define MYRAND_MAX 65535
# else
# define MYRAND_MAX 32767
# endif
2019-05-15 16:52:37 +02:00
int myrand ( void ) ;
void mysrand ( unsigned int seed ) ;
2019-06-02 23:42:51 +02:00
void re3_debug ( char * format , . . . ) ;
void re3_trace ( const char * filename , unsigned int lineno , const char * func , char * format , . . . ) ;
void re3_assert ( const char * expr , const char * filename , unsigned int lineno , const char * func ) ;
2019-06-11 11:30:53 +02:00
# define DEBUGBREAK() __debugbreak();
2019-06-02 23:42:51 +02:00
# define debug(f, ...) re3_debug("[DBG]: " f, __VA_ARGS__)
# define DEV(f, ...) re3_debug("[DEV]: " f, __VA_ARGS__)
# define TRACE(f, ...) re3_trace(__FILE__, __LINE__, __FUNCTION__, f, __VA_ARGS__)
2019-06-19 15:22:42 +02:00
# define Error(f, ...) re3_debug("[ERROR]: " f, __VA_ARGS__)
2019-06-02 23:42:51 +02:00
# define assert(_Expression) (void)( (!!(_Expression)) || (re3_assert(#_Expression, __FILE__, __LINE__, __FUNCTION__), 0) )
2019-05-29 02:52:30 +02:00
# define ASSERT assert
2019-05-15 16:52:37 +02:00
2019-06-19 15:22:42 +02:00
# define _TODO(x)
2019-05-29 20:02:58 +02:00
# define _TODOCONST(x) (x)
2019-05-15 16:52:37 +02:00
2019-05-29 20:02:58 +02:00
# 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 "...")
2019-06-17 00:16:38 +02:00
# define PERCENT(x, p) ((float(x) * (float(p) / 100.0f)))
2019-05-29 02:52:30 +02:00
# define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
2019-05-30 00:47:33 +02:00
# define BIT(num) (1<<(num))
2019-06-30 12:53:39 +02:00
# define max(a, b) (((a) > (b)) ? (a) : (b))
# define min(a, b) (((a) < (b)) ? (a) : (b))