vn/code/vn_types.h

199 lines
2.7 KiB
C
Raw Normal View History

2023-06-17 17:00:55 +00:00
/* date = April 26th 2023 4:55 pm */
#ifndef VN_TYPES_H
#define VN_TYPES_H
#include <stdint.h>
#include <intrin.h>
#include <stdarg.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef float r32;
typedef double r64;
typedef u8 b8;
typedef u16 b16;
typedef u32 b32;
typedef uintptr_t umm;
typedef intptr_t smm;
#define U8_Min 0x00
#define U8_Max 0xFF
#define U16_Min 0x0000
#define U16_Max 0xFFFF
#define U32_Min 0x00000000
#define U32_Max 0xFFFFFFFF
#define U64_Min 0x0000000000000000
#define U64_Max 0xFFFFFFFFFFFFFFFF
#define S8_Min 0x80
#define S8_Max 0x7F
#define S16_Min 0x8000
#define S16_Max 0x7FFF
#define S32_Min 0x80000000
#define S32_Max 0x7FFFFFFF
#define S64_Min 0x8000000000000000
#define S64_Max 0x7FFFFFFFFFFFFFFF
struct string
{
s64 Count;
u8 *Data;
};
struct string16
{
s64 Count;
s16 *Data;
};
typedef string buffer;
typedef string16 buffer16;
#define StrLit(String) MakeString(String, ArrayCount(String) - 1)
#define Str16Lit(String) MakeString16(String, ArrayCount(String) - 1)
inline string MakeString(char *Data, s64 Count)
{
string Result = {Count, (u8 *)Data};
return(Result);
}
inline string MakeString16(wchar_t *Data, s64 Count)
{
string Result = {Count, (u8 *)Data};
return(Result);
}
struct v2s
{
s32 x, y;
};
inline v2s V2S(s32 x, s32 y)
{
v2s Result = {x, y};
return(Result);
}
struct v2u
{
u32 x, y;
};
inline v2u V2U(u32 x, u32 y)
{
v2u Result = {x, y};
return(Result);
}
struct v2
{
union
{
struct
{
r32 x, y;
};
r32 E[2];
};
};
inline v2 V2(r32 x, r32 y)
{
v2 Result = {x, y};
return(Result);
}
inline v2 V2(v2s V)
{
v2 Result = {(r32)V.x, (r32)V.y};
return(Result);
}
struct v3
{
union
{
struct
{
r32 x, y, z;
};
struct
{
r32 r, g, b;
};
};
};
inline v3 V3(r32 x, r32 y, r32 z)
{
v3 Result = {x, y, z};
return(Result);
}
struct v4
{
union
{
struct
{
r32 x, y, z, w;
};
struct
{
r32 r, g, b, a;
};
};
};
inline v4 V4(r32 x, r32 y, r32 z, r32 w)
{
v4 Result = {x, y, z, w};
return(Result);
}
enum axis2
{
Axis2_X,
Axis2_Y,
Axis2_Count,
};
inline axis2 Opposite(axis2 Axis)
{
axis2 Result = (axis2)(!(u32)Axis);
return(Result);
}
struct range_s64
{
s64 Min;
s64 Max;
};
struct range_r32
{
r32 Min;
r32 Max;
};
struct range2_r32
{
v2 Min;
v2 Max;
};
struct ticket_mutex
{
u64 volatile Ticket;
u64 volatile Serving;
};
#endif //VN_TYPES_H