backported build fixes and warnings cleanup from dos
[dosdemo] / src / 3dgfx.c
index fb24c43..e58ac89 100644 (file)
@@ -62,8 +62,8 @@ struct g3d_state {
 };
 
 static void imm_flush(void);
-static void xform4_vec3(const float *mat, float *vec);
-static void xform3_vec3(const float *mat, float *vec);
+static __inline void xform4_vec3(const float *mat, float *vec);
+static __inline void xform3_vec3(const float *mat, float *vec);
 static void shade(struct g3d_vertex *v);
 
 static struct g3d_state *st;
@@ -586,21 +586,22 @@ void g3d_normal(float x, float y, float z)
 }
 
 #define CLAMP(x, a, b) ((x) < (a) ? (a) : ((x) > (b) ? (b) : (x)))
+#define MIN(a, b)              ((a) < (b) ? (a) : (b))
 
 void g3d_color3b(unsigned char r, unsigned char g, unsigned char b)
 {
-       st->imm_curv.r = CLAMP(r, 0, 255);
-       st->imm_curv.g = CLAMP(g, 0, 255);
-       st->imm_curv.b = CLAMP(b, 0, 255);
+       st->imm_curv.r = MIN(r, 255);
+       st->imm_curv.g = MIN(g, 255);
+       st->imm_curv.b = MIN(b, 255);
        st->imm_curv.a = 255;
 }
 
 void g3d_color4b(unsigned char r, unsigned char g, unsigned char b, unsigned char a)
 {
-       st->imm_curv.r = CLAMP(r, 0, 255);
-       st->imm_curv.g = CLAMP(g, 0, 255);
-       st->imm_curv.b = CLAMP(b, 0, 255);
-       st->imm_curv.a = CLAMP(a, 0, 255);
+       st->imm_curv.r = MIN(r, 255);
+       st->imm_curv.g = MIN(g, 255);
+       st->imm_curv.b = MIN(b, 255);
+       st->imm_curv.a = MIN(a, 255);
 }
 
 void g3d_color3f(float r, float g, float b)
@@ -632,28 +633,24 @@ void g3d_texcoord(float u, float v)
        st->imm_curv.v = v;
 }
 
-static void xform4_vec3(const float *mat, float *vec)
+static __inline void xform4_vec3(const float *mat, float *vec)
 {
        float x = mat[0] * vec[0] + mat[4] * vec[1] + mat[8] * vec[2] + mat[12];
        float y = mat[1] * vec[0] + mat[5] * vec[1] + mat[9] * vec[2] + mat[13];
        float z = mat[2] * vec[0] + mat[6] * vec[1] + mat[10] * vec[2] + mat[14];
-       float w = mat[3] * vec[0] + mat[7] * vec[1] + mat[11] * vec[2] + mat[15];
-
-       vec[0] = x;
-       vec[1] = y;
+       vec[3] = mat[3] * vec[0] + mat[7] * vec[1] + mat[11] * vec[2] + mat[15];
        vec[2] = z;
-       vec[3] = w;
+       vec[1] = y;
+       vec[0] = x;
 }
 
-static void xform3_vec3(const float *mat, float *vec)
+static __inline void xform3_vec3(const float *mat, float *vec)
 {
        float x = mat[0] * vec[0] + mat[4] * vec[1] + mat[8] * vec[2];
        float y = mat[1] * vec[0] + mat[5] * vec[1] + mat[9] * vec[2];
-       float z = mat[2] * vec[0] + mat[6] * vec[1] + mat[10] * vec[2];
-
-       vec[0] = x;
+       vec[2] = mat[2] * vec[0] + mat[6] * vec[1] + mat[10] * vec[2];
        vec[1] = y;
-       vec[2] = z;
+       vec[0] = x;
 }
 
 #define NORMALIZE(v) \