gba-trycatch

diff src/x3d.c @ 9:b0ed38f13261

working on the rasterizer
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 22 Jun 2014 05:16:10 +0300
parents fb0a0d6a8b52
children ecc022a21279
line diff
     1.1 --- a/src/x3d.c	Thu Jun 19 05:53:46 2014 +0300
     1.2 +++ b/src/x3d.c	Sun Jun 22 05:16:10 2014 +0300
     1.3 @@ -1,3 +1,4 @@
     1.4 +#include "config.h"
     1.5  #include <string.h>
     1.6  #include "x3d.h"
     1.7  #include "fixed.h"
     1.8 @@ -33,6 +34,7 @@
     1.9  static unsigned short color_count;
    1.10  
    1.11  static int32_t im_color[3];
    1.12 +static uint8_t im_color_index;
    1.13  
    1.14  void x3d_projection(int32_t fov, int32_t aspect, int32_t nearz, int32_t farz)
    1.15  {
    1.16 @@ -155,7 +157,10 @@
    1.17  	int i, j, pverts = prim;
    1.18  	const int32_t *vptr = vertex_array;
    1.19  	const int32_t *cptr = color_array;
    1.20 +#ifndef PALMODE
    1.21  	short cr, cg, cb;
    1.22 +#endif
    1.23 +	uint16_t color;
    1.24  
    1.25  	if(!vertex_array) return -1;
    1.26  
    1.27 @@ -181,6 +186,9 @@
    1.28  			if(cptr) cptr += 3;
    1.29  		}
    1.30  
    1.31 +#ifdef PALMODE
    1.32 +		color = im_color_index;
    1.33 +#else
    1.34  		cr = col[0].x >> 8;
    1.35  		cg = col[0].y >> 8;
    1.36  		cb = col[0].z >> 8;
    1.37 @@ -189,9 +197,12 @@
    1.38  		if(cg > 255) cg = 255;
    1.39  		if(cb > 255) cb = 255;
    1.40  
    1.41 +		color = RGB(cr, cg, cb);
    1.42 +#endif
    1.43 +
    1.44  		switch(pverts) {
    1.45  		case X3D_POINTS:
    1.46 -			draw_point(vpos, RGB(cr, cg, cb));
    1.47 +			draw_point(vpos, color);
    1.48  			break;
    1.49  
    1.50  		case X3D_LINES:
    1.51 @@ -199,7 +210,7 @@
    1.52  
    1.53  		case X3D_TRIANGLES:
    1.54  		case X3D_QUADS:
    1.55 -			draw_poly(pverts, vpos, RGB(cr, cg, cb));
    1.56 +			draw_poly(pverts, vpos, color);
    1.57  			break;
    1.58  		}
    1.59  	}
    1.60 @@ -239,6 +250,11 @@
    1.61  	}
    1.62  }
    1.63  
    1.64 +void x3d_color_index(int cidx)
    1.65 +{
    1.66 +	im_color_index = cidx;
    1.67 +}
    1.68 +
    1.69  void x3d_color(int32_t r, int32_t g, int32_t b)
    1.70  {
    1.71  	im_color[0] = r;