#if 0 --{{{ --{{{ static int *linterp ( int *coeffptr, static int *linterp ( int *coeffptr, int result, int op1, int op2, int alpha, int oplen, int alphalen ) { int i; IGC_SETENABS ( coeffptr ); IGC_CLEAR ( coeffptr, result, oplen+alphalen ); for (i = 0; i < alphalen; i++) { IGC_MEMintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result, op2, oplen+1, oplen); IGC_MEMBARintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result, op1, oplen+1, oplen); result++; alpha++; } return coeffptr; } --}}} --{{{ int result, int op1, int op2, int alpha, int oplen, int alphalen ) --}}} --{{{ static int *linterp866 ( int *coeffptr, static int *linterp866 ( int *coeffptr, int result, int op1, int op2, int alpha ) { /* linterp866 - takes 2 operands and alpha, each 6 bits, produces an 8-bit result this is a very tight fit linterp for end-of frame work - we can afford just 2 6-bit adds, the rest are short */ int i; IGC_SETENABS ( coeffptr ); IGC_CLEAR ( coeffptr, result, 8 ); for (i=0; i<4; i++ ) { IGC_MEMintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result, op2+(4-i), 3+i, 2+i ); IGC_MEMBARintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result, op1+(4-i), 3+i, 2+i ); alpha++; } for (i=0; i<2; i++ ) { IGC_MEMintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result+i, op2, 7, 6 ); IGC_MEMBARintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result+i, op1, 7, 6 ); alpha++; } return coeffptr; } --}}} --{{{ static int *linterp865 ( int *coeffptr, static int *linterp865 ( int *coeffptr, int result, int op1, int op2, int alpha ) { /* linterp865 - takes 2 operands of 6 bits, and alpha of 5 bits, produces an 8-bit result NOTE that this is linterp866 with initial value of i set to 1, not 0 - note that alpha ranges 1..63 */ int i=0; IGC_SETENABS ( coeffptr ); IGC_CLEAR ( coeffptr, result, 8 ); IGC_MEMpluseqMEM ( coeffptr, result, op2+(4-i), 3+i, 2+i ); for (i=1; i<4; i++ ) { IGC_MEMintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result, op2+(4-i), 3+i, 2+i ); IGC_MEMBARintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result, op1+(4-i), 3+i, 2+i ); alpha++; } for (i=0; i<2; i++ ) { IGC_MEMintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result+i, op2, 7, 6 ); IGC_MEMBARintoENAB ( coeffptr, alpha ); IGC_MEMpluseqMEM ( coeffptr, result+i, op1, 7, 6 ); alpha++; } return coeffptr; } --}}} --}}} #endif #if 0 --{{{ --{{{ fake spheres { #define material_ks(ks) \ (((ks) >> 4) << (dvpx_ks - dvpx_scalar)) #define material_rgb(r,g,b) \ ((((r) >> 5) | (((g) >> 5) << 3) | (((b) >> 5) << 6)) << (dvpx_intrinsic - dvpx_scalar)) #define material_specularity(ks) \ (((ks) >> 1) << (dvpx_specularity - dvpx_scalar)) int material; int r, g, b; int ks; int specularity; float lx, ly, lz; lx= 5.0f; ly= -5.0; lz= 1.2f; material =material_rgb ( 0, 0, 255 ); material|=material_ks ( 255 ); material|=material_specularity ( 1 ); coeffptr = sphere ( coeffptr, 450.0f, 160.0f, 60.0f, lx, ly, lz, material ); material =material_rgb ( 0, 255, 0 ); material|=material_ks ( 255 ); material|=material_specularity ( 1 ); coeffptr = sphere ( coeffptr, 410.0f, 100.0f, 40.0f, lx, ly, lz, material ); material =material_rgb ( 255, 0, 0 ); material|=material_ks ( 255 ); material|=material_specularity ( 1 ); coeffptr = sphere ( coeffptr, 310.0f, 120.0f, 30.0f, lx, ly, lz, material ); material =material_rgb ( 128, 128, 0 ); material|=material_ks ( 255 ); material|=material_specularity ( 1 ); coeffptr = sphere ( coeffptr, 110.0f, 320.0f, 70.0f, lx, ly, lz, material ); } --}}} --}}} --{{{ int *dither ( int *coeffptr ) int *dither ( int *coeffptr ) { /* dithering works like this - i transmit 'are you a 1 pixel', then all enabled pixels check that they bits 0..1 & 3 > 1, then add on 1 so we dither on a 2x2 grid in 9 x (check i, ge i, clmpplus) */ int checkVal, ditherVal=34, enablr =36, enablg =37, enablb =38, tmp1 =39, tmp2 =40, pixelPlus=41; /* set up pixel identifiers - we scan-convert 0 1 2 3 0 1 2 3 0 1 2 3 3 2 1 0 3 2 1 0 3 2 1 0 into the dither bits */ #define dither_bits 1 IGC_SETENABS ( coeffptr ); IGC_CLEAR ( coeffptr, enablr, 3 ); IGC_SCAintoMEM_S1 ( coeffptr, pixelPlus, 9, 2< worsterr) { worsterr=err; wi=gi; wj=gj; wk=gk; } } --}}} --{{{ static void set_vertex ( VERTEX *vert, static void set_vertex ( VERTEX *vert, float x, float y, float z, float diff, float spec, float u, float v ) { vert->position[0]=x; vert->position[1]=y; vert->position[2]=z; vert->texcoords[0]=u; vert->texcoords[1]=v; vert->normcol[0]=diff; vert->normcol[1]=spec; } --}}} --{{{ static void rms_test ( int (checkdiv_fn)(int, int, int), char *mess, int iter ) static void rms_test ( int (checkdiv_fn)(int, int, int), char *mess, int iter ) { int res, first, numer, denom; float error, maxerror, maxnumerr; float fnum, fden, fres, answer; int numnum, numden, numres, badnum, badden, badres; printf ( "RMS test : %s\n", mess ); maxerror=0.0; numer=127; while (numer < 65535) { denom=numer+1; maxnumerr=0.0; first=1; while (denom < 65535) { res=checkdiv_fn ( numer, denom, iter ); fnum=((float) numer) / 65536.0f; fden=((float) denom) / 65536.0f; fres=((float) res ) / 65536.0f; answer=fnum/fden; error = sqrt((fres-answer)*(fres-answer)); /* what is the error as a percentage? this error is in parts per 64k - turn into parts per 256 */ error /= 256.0f; if (error>maxnumerr) { numnum=numer; numden=denom; numres=res; maxnumerr=error; } denom*=11; denom/=10; if (first) printf ("checked %d / %d = %d (%f / %f -> %f) answer = %f\n", numer, denom, res, fnum, fden, fres, answer ); first=0; } if (maxnumerr>maxerror) { badnum=numnum; badden=numden; badres=numres; maxerror=maxnumerr; } printf ("num=%d (%f) maxerror=%f abs max error %f\n", numer, fnum, maxnumerr, maxerror ); printf ("worst combination numer=%d (0x%x) denom=%d (0x%x) res=%d\n", numnum, numnum, numden, numden, numres ); numer*=11; numer/=10; } } --}}} --{{{ static void time_triangles() static void time_triangles() { VERTEX *vert0, *vert1, *vert2, *vert3, *vert4, *vert5; int j, benny=0; float then, now; float materials[5]; int opcode0; binit=(void *) &safe_binitize_fn; opcode0 = Ix_MEMintoENAB ( 0 ); vert0=(VERTEX *) malloc( sizeof(VERTEX)); vert1=(VERTEX *) malloc( sizeof(VERTEX)); vert2=(VERTEX *) malloc( sizeof(VERTEX)); vert3=(VERTEX *) malloc( sizeof(VERTEX)); vert4=(VERTEX *) malloc( sizeof(VERTEX)); vert5=(VERTEX *) malloc( sizeof(VERTEX)); if (vert0 == NULL) { printf ("Failed to malloc vertex\n" ); exit (666); } if (vert1 == NULL) { printf ("Failed to malloc vertex\n" ); exit (666); } if (vert2 == NULL) { printf ("Failed to malloc vertex\n" ); exit (666); } if (vert3 == NULL) { printf ("Failed to malloc vertex\n" ); exit (666); } if (vert4 == NULL) { printf ("Failed to malloc vertex\n" ); exit (666); } if (vert5 == NULL) { printf ("Failed to malloc vertex\n" ); exit (666); } materials[0] = 0.0f; materials[1] = 1.0f; materials[2] = 2.0f; materials[3] = 3.0f; materials[4] = 4.0f; set_vertex ( vert0, 32.0f, 32.0f, 122.0f, 1.4f, 1.31f, 0.0f, 1.0f ); set_vertex ( vert1, 42.0f, 22.0f, 38.0f, 2.1f, -2.04f, 1.0f, 1.0f ); set_vertex ( vert2, 12.0f, 62.0f, 822.0f, 3.43f, 1.53f, 0.0f, 0.0f ); set_vertex ( vert3, 132.0f, 132.0f, 622.0f, 1.4f, 3.31f, 0.0f, 0.0f ); set_vertex ( vert4, 142.0f, 150.0f, 138.0f, 2.1f, 1.04f, 0.0f, 1.0f ); set_vertex ( vert5, 152.0f, 162.0f, 222.0f, 3.43f, -1.53f, 1.0f, 1.0f ); then=second_(); for (benny=0, j=20; j; j-- ) { float *coeffs=coeffstore0; int i; for (i=0; i<250; i++ ) { coeffs=tri_zb_f_t ( coeffs, materials[0], opcode0, (float *)vert3,(float *)vert4,(float *)vert5, binit ); coeffs=tri_zb_f_t ( coeffs, materials[1], opcode0, (float *)vert0,(float *)vert1,(float *)vert2, binit ); coeffs=tri_zb_f_t ( coeffs, materials[2], opcode0, (float *)vert3,(float *)vert4,(float *)vert5, binit ); coeffs=tri_zb_f_t ( coeffs, materials[3], opcode0, (float *)vert0,(float *)vert1,(float *)vert2, binit ); benny+=4; coeffs=tri_zb_d_s ( coeffs, materials[0], opcode0, (float *)vert3,(float *)vert4,(float *)vert5, binit ); coeffs=tri_zb_d_s ( coeffs, materials[1], opcode0, (float *)vert0,(float *)vert1,(float *)vert2, binit ); coeffs=tri_zb_d_s ( coeffs, materials[2], opcode0, (float *)vert3,(float *)vert4,(float *)vert5, binit ); coeffs=tri_zb_d_s ( coeffs, materials[3], opcode0, (float *)vert0,(float *)vert1,(float *)vert2, binit ); benny+=4; coeffs=tri_zb_d_s_t ( coeffs, materials[0], opcode0, (float *)vert3,(float *)vert4,(float *)vert5, binit ); coeffs=tri_zb_d_s_t ( coeffs, materials[1], opcode0, (float *)vert0,(float *)vert1,(float *)vert2, binit ); coeffs=tri_zb_d_s_t ( coeffs, materials[2], opcode0, (float *)vert3,(float *)vert4,(float *)vert5, binit ); coeffs=tri_zb_d_s_t ( coeffs, materials[3], opcode0, (float *)vert0,(float *)vert1,(float *)vert2, binit ); benny+=4; coeffs=tri_zb_f ( coeffs, materials[0], opcode0, (float *)vert3,(float *)vert4,(float *)vert5, binit ); coeffs=tri_zb_f ( coeffs, materials[1], opcode0, (float *)vert0,(float *)vert1,(float *)vert2, binit ); coeffs=tri_zb_f ( coeffs, materials[2], opcode0, (float *)vert3,(float *)vert4,(float *)vert5, binit ); coeffs=tri_zb_f ( coeffs, materials[3], opcode0, (float *)vert0,(float *)vert1,(float *)vert2, binit ); benny+=4; } } now =second_(); printf ("Gosh golly gee - %d triangles pxpl5ized in %f ticks (%f per sec)\n", benny, now - then, (float) benny / (now - then)); } --}}} --{{{ static void trace_triangle_fns () static void trace_triangle_fns() { printf (" tri_zb_d_s is at 0x%x\n", (int) tri_zb_d_s ); printf (" tri_zb_rgb is at 0x%x\n", (int) tri_zb_rgb ); printf (" tri_zb_f is at 0x%x\n", (int) tri_zb_f ); printf (" tri_zb_f_t is at 0x%x\n", (int) tri_zb_f_t ); printf (" tri_zb_rgb_t is at 0x%x\n", (int) tri_zb_rgb_t ); printf (" tri_zb_d_s_t is at 0x%x\n", (int) tri_zb_d_s_t ); } --}}} --{{{ static void time_matrices () static void time_matrices () { /* uurgh ? */ int total=0, i=0, j=0, k=0; float then, now; MATRIX m, minv; then=second_(); for (i=0; i<360; i+=13 ) { gi=i; /* printf ("i = %d, current worst=%f at %d,%d,%d \r", i, worsterr, wi,wj,wk ); fflush(stdout); */ for (j=0; j<360; j+=13 ) { gj=j; for (k=0; k<360; k+=13 ) { gk=k; _idmatrix ( m ); _rotX ( m, i, 1 ); _rotY ( m, j, 1 ); _rotZ ( m, k, 1 ); _scale ( m, 32.0, 0.3, 512.6, 1 ); m[3][0] = 2048.0*i; m[3][1] = -4096.0*j; m[3][2] = 16384.0*k; _invert ( minv, m ); checkInverse ( m, minv ); total++; } } } now=second_(); printf ("Done, %f seconds for %d matrices, worsterr = %f at %d,%d,%d \n", now-then, total, worsterr, wi, wj, wk ); } --}}} #endif