2021-06-23 19:25:12 +02:00
|
|
|
// MACROS
|
|
|
|
// swap(x, y, buffer)
|
|
|
|
#define SWAP(a,b,c) {(c)=(a); (a)=(b); (b)=(c);}
|
|
|
|
|
|
|
|
// dotproduct of two vectors
|
|
|
|
#define dotProduct(v0, v1) \
|
|
|
|
(v0).vx * (v1).vx + \
|
|
|
|
(v0).vy * (v1).vy + \
|
|
|
|
(v0).vz * (v1).vz
|
|
|
|
|
2021-07-01 15:09:18 +02:00
|
|
|
// return min value
|
2021-06-23 19:25:12 +02:00
|
|
|
#define min(a,b) \
|
|
|
|
(a)-(b)>0?(b):(a)
|
2021-07-01 15:09:18 +02:00
|
|
|
// return max value
|
2021-06-23 19:25:12 +02:00
|
|
|
#define max(a,b) \
|
|
|
|
(a)-(b)>0?(a):(b)
|
2021-07-01 15:09:18 +02:00
|
|
|
// add 2 vector and store in a third vector
|
2021-10-13 12:41:28 +02:00
|
|
|
#define addVector2(v0, v1, v2) \
|
|
|
|
(v2)->vx = (v0)->vx + (v1)->vx, \
|
|
|
|
(v2)->vy = (v0)->vy + (v1)->vy, \
|
|
|
|
(v2)->vz = (v0)->vz + (v1)->vz, \
|
|
|
|
(v2)->pad = (v0)->pad + (v1)->pad \
|
2021-07-01 15:09:18 +02:00
|
|
|
|
2021-06-23 19:25:12 +02:00
|
|
|
// substract vector
|
|
|
|
#define subVector(v0, v1) \
|
|
|
|
(v0).vx - (v1).vx, \
|
|
|
|
(v0).vy - (v1).vy, \
|
|
|
|
(v0).vz - (v1).vz
|
|
|
|
|
|
|
|
#define normalizeVector(v) \
|
|
|
|
((v)->vx << 12) >> 8, \
|
|
|
|
((v)->vy << 12) >> 8, \
|
|
|
|
((v)->vz << 12) >> 8
|
2021-07-05 17:47:30 +02:00
|
|
|
|
|
|
|
// GTE Macros
|
|
|
|
|
|
|
|
#define gte_RotAverageNclip4(r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12) \
|
2021-07-10 12:08:52 +02:00
|
|
|
{ gte_ldv3(r1,r2,r3); \
|
|
|
|
gte_rtpt(); \
|
|
|
|
gte_stflg(r11); \
|
|
|
|
gte_nclip(); \
|
|
|
|
gte_ldv0(r4); \
|
|
|
|
gte_stopz(r12); \
|
|
|
|
gte_stsxy3(r5,r6,r7); \
|
|
|
|
gte_rtps(); \
|
|
|
|
gte_stsxy(r8); \
|
|
|
|
gte_stdp(r9); \
|
|
|
|
gte_avsz4(); \
|
|
|
|
gte_stotz(r10); }
|
2021-08-15 19:12:03 +02:00
|
|
|
|
|
|
|
// convert Little endian to Big endian
|
|
|
|
#define SWAP_ENDIAN32(x) (((x)>>24) | (((x)>>8) & 0xFF00) | (((x)<<8) & 0x00FF0000) | ((x)<<24))
|