#ifndef TYPES_H #define TYPES_H typedef signed char s8; typedef signed short s16; typedef signed long s32; typedef signed long long s64; typedef unsigned char u8; typedef unsigned short u16; typedef unsigned long u32; typedef unsigned long size_t; typedef unsigned long long u64; typedef unsigned int uint; typedef volatile u8 vu8; typedef volatile u16 vu16; typedef volatile u32 vu32; typedef volatile u64 vu64; typedef volatile s8 vs8; typedef volatile s16 vs16; typedef volatile s32 vs32; typedef volatile s64 vs64; typedef float f32; typedef double f64; typedef volatile f32 vf32; typedef volatile f64 vf64; typedef int BOOL; typedef unsigned int uintptr_t; // Manually added // Pointer to unknown, to be determined at a later date. typedef void* unkptr; typedef u32 unknown; #define TRUE 1 #define FALSE 0 #define NULL ((void*)0) #define nullptr 0 #define AT_ADDRESS(x) : (x) #define ALIGN_PREV(u, align) (u & (~(align-1))) #define ALIGN_NEXT(u, align) ((u + (align-1)) & (~(align-1))) #ifndef ATTRIBUTE_ALIGN #if defined(__MWERKS__) || defined(__GNUC__) #define ATTRIBUTE_ALIGN(num) __attribute__((aligned(num))) #elif defined(_MSC_VER) #define ATTRIBUTE_ALIGN(num) #else #error unknown compiler #endif #endif #define MAX(a, b) (((a) > (b)) ? (a) : (b)) #define MIN(a, b) (((a) < (b)) ? (a) : (b)) /* ARGB8 color format (32 bits) to RGB5A3 color format (16 bits) */ #define ARGB8_to_RGB5A3(argb8) \ ((u16)(((argb8) & 0xFF000000) >= 0xE0000000 ? \ /* Fully opaque, 5 bits per color channel */ (0x8000 | ((((argb8) >> 16) & 0xF8) << 7) | ((((argb8) >> 8) & 0xF8) << 2) | (((argb8) & 0xFF) >> 3)) : \ /* 3 bits of transparency, 4 bits per color channel */ (((((argb8) >> 24) & 0xE0) << 7) | ((((argb8) >> 16) & 0xF0) << 4) | (((argb8) >> 8) & 0xF0) | (((argb8) & 0xF0) >> 4)))) #define GPACK_RGB5A3(r, g, b, a) ARGB8_to_RGB5A3((((a) & 0xFF) << 24) | (((r) & 0xFF) << 16) | (((g) & 0xFF) << 8) | ((b) & 0xFF)) #endif