@@ -35,35 +35,37 @@ typedef struct __attribute__((packed, aligned(8))) uPSM3DDispCmd_t {
35
35
/** @brief Vertex for PSM3D */
36
36
typedef struct __attribute__((packed , aligned (8 ))) uPSM3DVtx_t {
37
37
/** @brief X-Coordinate Integral (s15.16 fixed point) */
38
- u16 xi ;
38
+ s16 xi ;
39
39
/** @brief Y-Coordinate Integral (s15.16 fixed point) */
40
- u16 yi ;
40
+ s16 yi ;
41
41
/** @brief Z-Coordinate Integral (s15.16 fixed point) */
42
- u16 zi ;
42
+ s16 zi ;
43
43
/** @brief Padding */
44
- u8 pad ;
45
- /** @brief X-Normal (s.7 fixed point) */
46
- u8 xn ;
44
+ u16 pad ;
47
45
/** @brief X-Coordinate Fractional (s15.16 fixed point) */
48
- u16 xf ;
46
+ s16 xf ;
49
47
/** @brief Y-Coordinate Fractional (s15.16 fixed point) */
50
- u16 yf ;
48
+ s16 yf ;
51
49
/** @brief Z-Coordinate Fractional (s15.16 fixed point) */
52
- u16 zf ;
53
- /** @brief Y-Normal (s.7 fixed point) */
54
- u8 yn ;
55
- /** @brief Z-Normal (s.7 fixed point) */
56
- u8 zn ;
50
+ s16 zf ;
51
+ /** @brief Padding */
52
+ u16 pad2 ;
57
53
/** @brief S coordinate (s10.5) */
58
- u16 s ;
54
+ s16 s ;
59
55
/** @brief T coordinate (s10.5) */
60
- u16 t ;
61
- /** @brief Padding */
62
- u32 pad2 ;
56
+ s16 t ;
63
57
/** @brief Padding */
64
58
u32 pad3 ;
59
+ /** @brief X-Normal (s.7 fixed point) / R Shading */
60
+ s8 xn ;
61
+ /** @brief Y-Normal (s.7 fixed point) / G Shading */
62
+ s8 yn ;
63
+ /** @brief Z-Normal (s.7 fixed point) / B Shading */
64
+ s8 zn ;
65
+ /** @brief Padding (this padding must be zero) */
66
+ u8 pad4 ;
65
67
/** @brief Padding */
66
- u32 pad4 ;
68
+ u32 pad5 ;
67
69
} uPSM3DVtx ;
68
70
69
71
/** @brief Matrix for PSM3D */
@@ -81,11 +83,48 @@ typedef struct __attribute__((packed, aligned(8))) uPSM3DVp_t {
81
83
/** @brief Half the viewport height */
82
84
u16 hheight ;
83
85
/** @brief Viewport X offset */
84
- u16 xoff ;
86
+ s16 xoff ;
85
87
/** @brief Viewport Y offset */
86
- u16 yoff ;
88
+ s16 yoff ;
87
89
} uPSM3DVp ;
88
90
91
+ /** @brief Ambient light structure for PSM3D */
92
+ typedef struct __attribute((aligned (8 ))) uPSM3DAmbientLight_t {
93
+ /** @brief Red value of ambient light color */
94
+ u8 r ;
95
+ /** @brief Green value of ambient light color */
96
+ u8 g ;
97
+ /** @brief Blue value of ambient light color */
98
+ u8 b ;
99
+ } uPSM3DAmbientLight ;
100
+
101
+ /** @brief Point light structure for PSM3D */
102
+ typedef struct __attribute((aligned (8 ))) uPSM3DPointLight_t {
103
+ /** @brief Red value of point light color */
104
+ u8 r ;
105
+ /** @brief Green value of point light color */
106
+ u8 g ;
107
+ /** @brief Blue value of point light color */
108
+ u8 b ;
109
+ /** @brief Attenuation factor */
110
+ u8 att ;
111
+ /** @brief X value of point light in current coordinate system (MODELVIEW) */
112
+ s8 x ;
113
+ /** @brief Y value of point light in current coordinate system (MODELVIEW) */
114
+ s8 y ;
115
+ /** @brief Z value of point light in current coordinate system (MODELVIEW) */
116
+ s8 z ;
117
+ /** @brief Padding */
118
+ u8 pad ;
119
+ } uPSM3DPointLight ;
120
+
121
+ /** @brief Light structure for PSM3D */
122
+ typedef struct __attribute__((packed , aligned (8 ))) uPSM3DLights_t {
123
+ /** @brief Ambient light */
124
+ uPSM3DAmbientLight ambient ;
125
+ /** @brief Point lights */
126
+ uPSM3DPointLight point_lights [];
127
+ } uPSM3DLights ;
89
128
90
129
#endif
91
130
@@ -107,6 +146,7 @@ typedef struct __attribute__((packed, aligned(8))) uPSM3DVp_t {
107
146
#define UCODE_PSM3D_OP_TRI 0x07
108
147
#define UCODE_PSM3D_OP_SET_VP 0x08
109
148
#define UCODE_PSM3D_OP_POP_MTX 0x09
149
+ #define UCODE_PSM3D_OP_LOAD_LIGHTS 0x0A
110
150
111
151
/*
112
152
* Operation macros
@@ -138,6 +178,14 @@ typedef struct __attribute__((packed, aligned(8))) uPSM3DVp_t {
138
178
#define UCODE_PSM3D_RSPMODE_ZBUF_OFF 0
139
179
#define UCODE_PSM3D_RSPMODE_ZBUF_ON 0x400
140
180
181
+ #define UCODE_PSM3D_RSPMODE_LIGHT 0x800
182
+ #define UCODE_PSM3D_RSPMODE_LIGHT_OFF 0
183
+ #define UCODE_PSM3D_RSPMODE_LIGHT_ON 0x800
184
+
185
+ #define UCODE_PSM3D_RSPMODE_SHADE 0x1000
186
+ #define UCODE_PSM3D_RSPMODE_SHADE_OFF 0
187
+ #define UCODE_PSM3D_RSPMODE_SHADE_ON 0x1000
188
+
141
189
#define usPSM3DSetRSPMode (mask , data ) \
142
190
{\
143
191
_FMT(UCODE_PSM3D_OP_SET_RSP_MODE, 24, 8) | _FMT(mask, 0, 24)\
@@ -293,6 +341,22 @@ typedef struct __attribute__((packed, aligned(8))) uPSM3DVp_t {
293
341
_FMT(vp, 0, 24)\
294
342
}
295
343
344
+ #define usPSM3DLoadLights (lights , count ) \
345
+ {\
346
+ _FMT(UCODE_PSM3D_OP_LOAD_LIGHTS, 24, 8) |\
347
+ _FMT(count, 0, 8),\
348
+ \
349
+ _FMT(lights, 0, 24)\
350
+ }
351
+ #define uPSM3DLoadLights (dl , lights , count ) \
352
+ *((dl) ++) = (uPSM3DDispCmd) {\
353
+ _FMT(UCODE_PSM3D_OP_LOAD_LIGHTS, 24, 8) |\
354
+ _FMT(count, 0, 8),\
355
+ \
356
+ _FMT(lights, 0, 24)\
357
+ }
358
+
359
+
296
360
#define usPSM3DPopMtx () { (UCODE_PSM3D_OP_POP_MTX << 24), 0 }
297
361
#define uPSM3DPopMtx (dl ) *((dl) ++) = (uPSM3DDispCmd) { _FMT(UCODE_PSM3D_OP_POP_MTX, 24, 8), 0 }
298
362
0 commit comments