The-Powder-Toy/includes/misc.h

97 lines
1.9 KiB
C
Raw Normal View History

2010-09-27 05:53:05 -05:00
#ifndef UTILS_H
#define UTILS_H
#include <stdio.h>
#include <stdlib.h>
2010-10-03 08:56:30 -05:00
#if defined(WIN32) && !defined(__GNUC__)
2010-09-27 05:53:05 -05:00
#define x86_cpuid(func,af,bf,cf,df) \
do {\
__asm mov eax, func\
__asm cpuid\
__asm mov af, eax\
__asm mov bf, ebx\
__asm mov cf, ecx\
__asm mov df, edx\
} while(0)
#else
#define x86_cpuid(func,af,bf,cf,df) \
__asm__ __volatile ("cpuid":\
"=a" (af), "=b" (bf), "=c" (cf), "=d" (df) : "a" (func));
#endif
static char hex[] = "0123456789ABCDEF";
2011-04-08 09:28:57 -05:00
2010-09-27 05:53:05 -05:00
//Signum function
2011-04-08 09:28:57 -05:00
int isign(float i);
2010-09-27 05:53:05 -05:00
2011-04-08 09:28:57 -05:00
unsigned clamp_flt(float f, float min, float max);
2010-09-27 05:53:05 -05:00
2011-04-08 09:28:57 -05:00
float restrict_flt(float f, float min, float max);
2010-09-27 05:53:05 -05:00
char *mystrdup(char *s);
struct strlist
{
2011-01-06 16:26:31 -06:00
char *str;
struct strlist *next;
2010-09-27 05:53:05 -05:00
};
void strlist_add(struct strlist **list, char *str);
int strlist_find(struct strlist **list, char *str);
void strlist_free(struct strlist **list);
void save_presets(int do_update);
void load_presets(void);
void save_string(FILE *f, char *str);
2011-01-31 10:54:13 -06:00
int sregexp(const char *str, char *pattern);
2010-09-27 05:53:05 -05:00
int load_string(FILE *f, char *str, int max);
void strcaturl(char *dst, char *src);
void strappend(char *dst, char *src);
void *file_load(char *fn, int *size);
void clipboard_push_text(char * text);
char * clipboard_pull_text();
int register_extension();
2010-09-27 05:53:05 -05:00
int cpu_check(void);
// a b
// c d
2011-04-08 05:09:42 -05:00
struct matrix2d {
float a,b,c,d;
};
typedef struct matrix2d matrix2d;
// column vector
2011-04-08 05:09:42 -05:00
struct vector2d {
float x,y;
};
typedef struct vector2d vector2d;
matrix2d m2d_multiply_m2d(matrix2d m1, matrix2d m2);
vector2d m2d_multiply_v2d(matrix2d m, vector2d v);
matrix2d m2d_multiply_float(matrix2d m, float s);
vector2d v2d_multiply_float(vector2d v, float s);
vector2d v2d_add(vector2d v1, vector2d v2);
vector2d v2d_sub(vector2d v1, vector2d v2);
matrix2d m2d_new(float me0, float me1, float me2, float me3);
vector2d v2d_new(float x, float y);
extern vector2d v2d_zero;
extern matrix2d m2d_identity;
2010-12-05 09:49:48 -06:00
#endif