summaryrefslogtreecommitdiff
path: root/include/common.h
blob: 5b85824b8b8e792991714947aee4373c74f4cac9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#ifndef __KAMEK_COMMON_H
#define __KAMEK_COMMON_H


#define GEKKO

/* Common Number Types */
typedef signed long long s64;
typedef signed int s32;
typedef signed short s16;
typedef signed char s8;

typedef unsigned long long u64;
typedef unsigned int u32;
typedef unsigned short u16;
typedef unsigned char u8;

typedef float f32;
typedef double f64;

typedef unsigned long ulong;
typedef unsigned int uint;
typedef unsigned short ushort;
typedef unsigned char uchar;

typedef unsigned long size_t;

typedef char* Ptr; // DUMB

typedef int BOOL;
#define TRUE 1
#define FALSE 0

#define NULL 0

/* Structures */
typedef f32 Mtx[3][4];
typedef f32 (*MtxPtr)[4];
typedef f32 Mtx44[4][4];
typedef f32 (*Mtx44Ptr)[4];
typedef f32 ROMtx[4][3];
typedef f32 (*ROMtxPtr)[3];

typedef struct { f32 x, y; } VEC2, Vec2, *Vec2Ptr, Point2d, *Point2dPtr;
typedef struct { f32 x, y, z; } VEC3, Vec, Vec3, *VecPtr, Point3d, *Point3dPtr;
typedef struct { s16 x; s16 y; s16 z; }S16Vec, *S16VecPtr;
typedef struct { f32 x, y, z, w; } Quaternion, *QuaternionPtr, Qtrn, *QtrnPtr;

typedef struct { f32 frame, value, slope; } HermiteKey;

extern "C" const char * strrchr ( const char * str, int character );
extern "C" int strcmp ( const char * str1, const char * str2 );

#include "rvl/mtx.h"


inline void *operator new(size_t size, void *ptr) { return ptr; }



struct tree_node {
	tree_node *parent, *child, *prev_sibling, *next_sibling;
	void *obj;
};

/* Virtual Function Helpers */
//#define VF_BEGIN(type, obj, id, vtable_offset) \
//	{ type __VFUNC = (((u32)(obj))+(vtable_offset));
#define VF_BEGIN(type, obj, id, vtable_offset) \
	{ type __VFUNC = ((type*)(*((void**)(((u32)(obj))+(vtable_offset)))))[(id)];

#define VF_CALL __VFUNC

#define VF_END }




/* Common Functions */

void OSReport(const char *format, ...);
int sprintf(char *buffer, const char *format, ...);
int snprintf(char *buffer, size_t buff_size, const char *format, ...);
char *strcat(char *destination, const char *source);
void *memset(void *ptr, int value, size_t num);
int memcmp(const void *ptr1, const void *ptr2, size_t num);

void *AllocFromGameHeap1(u32 size);
void FreeFromGameHeap1(void *block);

float GetHermiteCurveValue(float current_frame, HermiteKey* keys, unsigned int key_count);

/* Archive */
/*#ifdef REGION_PAL
	#define ARC_TABLE ((*((void**)0x8042A318))+4)
	#define RAW_ARC_TABLE (*((void**)0x8042A318))
#endif

#ifdef REGION_NTSC
	#define ARC_TABLE ((*((void**)0x8042A038))+4)
	#define RAW_ARC_TABLE (*((void**)0x8042A038))
#endif

char *RetrieveFileFromArc(void *table, char *name, char *path);
char *RetrieveFileFromArcAlt(void *table, char *name, char *path);*/

extern void *ArchiveHeap; // PAL 0x8042A72C, NTSC 0x8042A44C


#ifdef __MWERKS__
	#define InfiniteLoop for (;;) { asm { nop } }
#else
	#define InfiniteLoop for (;;) { asm("nop"); }
#endif


#endif