-
Notifications
You must be signed in to change notification settings - Fork 1
/
gl-sh4.h
88 lines (75 loc) · 3.28 KB
/
gl-sh4.h
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
/* KallistiGL for KallistiOS ##version##
libgl/gl-sh4.h
Copyright (C) 2013-2014 Josh Pearson
Macros for utilizing the Dreamcast's SH4 CPU vector / matrix math functions.
*/
#ifndef GL_SH4_H
#define GL_SH4_H
#include <arch/args.h>
typedef float vector3f[3]; /* 3 float vector */
typedef float matrix4f[4][4]; /* 4x4 float matrix */
/* DEG2RAD - convert Degrees to Radians = PI / 180.0f */
#define DEG2RAD (0.01745329251994329576923690768489f)
/* Calculate Spot Light Angle Cosine = (PI / 180.0f) * (n / 2) */
#define LCOS(n) fcos(n*0.00872664625997164788461845384244f)
/* Internal GL API macro */
#define mat_trans_fv12() { \
__asm__ __volatile__( \
"fldi1 fr15\n" \
"ftrv xmtrx, fv12\n" \
"fldi1 fr14\n" \
"fdiv fr15, fr14\n" \
"fmul fr14, fr12\n" \
"fmul fr14, fr13\n" \
: "=f" (__x), "=f" (__y), "=f" (__z) \
: "0" (__x), "1" (__y), "2" (__z) \
: "fr15" ); \
}
/* Internal GL API macro */
#define mat_trans_fv12_nodiv() { \
__asm__ __volatile__( \
"fldi1 fr15\n" \
"ftrv xmtrx, fv12\n" \
: "=f" (__x), "=f" (__y), "=f" (__z) \
: "0" (__x), "1" (__y), "2" (__z) ); \
}
#define mat_trans_fv12_nodivw() { \
__asm__ __volatile__( \
"fldi1 fr15\n" \
"ftrv xmtrx, fv12\n" \
: "=f" (__x), "=f" (__y), "=f" (__z), "=f" (__w) \
: "0" (__x), "1" (__y), "2" (__z), "3" (__w) ); \
}
#define mat_trans_texture4(s, t, r, q) { \
register float __s __asm__(KOS_FPARG(0)) = (s); \
register float __t __asm__(KOS_FPARG(1)) = (t); \
register float __r __asm__(KOS_FPARG(2)) = (r); \
register float __q __asm__(KOS_FPARG(3)) = (q); \
__asm__ __volatile__( \
"ftrv xmtrx,fv4\n" \
"fldi1 fr6\n" \
"fdiv fr7,fr6\n" \
"fmul fr6,fr4\n" \
"fmul fr6,fr5\n" \
: "=f" (__s), "=f" (__t), "=f" (__r) \
: "0" (__s), "1" (__t), "2" (__r) \
: "fr7" ); \
s = __s; t = __t; r = __r; \
}
#define mat_trans_texture2_nomod(s, t, so, to) { \
register float __s __asm__(KOS_FPARG(0)) = (s); \
register float __t __asm__(KOS_FPARG(1)) = (t); \
__asm__ __volatile__( \
"fldi0 fr6\n" \
"fldi1 fr7\n" \
"ftrv xmtrx,fv4\n" \
"fldi1 fr6\n" \
"fdiv fr7,fr6\n" \
"fmul fr6,fr4\n" \
"fmul fr6,fr5\n" \
: "=f" (__s), "=f" (__t) \
: "0" (__s), "1" (__t) \
: "fr7" ); \
so = __s; to = __t; \
}
#endif