summaryrefslogtreecommitdiff
path: root/include/common.h
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-03-12 23:17:12 +0100
committerTreeki <treeki@gmail.com>2011-03-12 23:17:12 +0100
commit7d4e4c0b34a613dd3c0220475ae4e448197522c1 (patch)
tree4f5cee367de3fdef4f9a7c84af59ffe76a2bb1c3 /include/common.h
downloadkamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.tar.gz
kamek-7d4e4c0b34a613dd3c0220475ae4e448197522c1.zip
initial commit. now I can start playing with stuff!
Diffstat (limited to '')
-rwxr-xr-xinclude/common.h107
1 files changed, 107 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
new file mode 100755
index 0000000..b8bce80
--- /dev/null
+++ b/include/common.h
@@ -0,0 +1,107 @@
+#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 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, *VecPtr, Point3d, *Point3dPtr;
+typedef struct { s16 x; s16 y; s16 z; }S16Vec, *S16VecPtr;
+typedef struct { f32 x, y, z, w; } Quaternion, *QuaternionPtr, Qtrn, *QtrnPtr;
+
+#include "rvl/mtx.h"
+
+
+inline void *operator new(unsigned long 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, int buff_size, const char *format, ...);
+char *strcat(const char *destination, const char *source);
+void *memset(void *ptr, int value, unsigned int num);
+
+void *AllocFromGameHeap1(u32 size);
+void FreeFromGameHeap1(void *block);
+
+/* 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