cz_step.c 1.81 KB

#include "graphic.h"

do_cz_step(mask)
  int mask;
{
  struct CZ *p, *d;
  struct Iter_color *ip;
  struct Color_depth *cd;
  int color;
  int r, g, b;

  p = &cz_step[0].pnt;
  d = &cz_step[0].del;
  cd = &col_dep[0];
  ip = &iter_color[0];

/*
if (debug) {
        printf("cz_step pr %.3f, pg %.3f, pb %.3f.\n",
        float_ewa( p->r), float_ewa( p->g), float_ewa( p->b));
        printf("cz_step dr %.3f, dg %.3f, db %.3f.\n",
        float_ewa( d->r), float_ewa( d->g), float_ewa( d->b));
	}
*/


  cd->d = /*int_ewa*/(p->z);
  ip->r = int_ewa(p->r);
  ip->g = int_ewa(p->g);
  ip->b = int_ewa(p->b);
  ip->a = int_ewa(p->a);

  if (en_antialias) {
    mask &= AA_SP_HALF;
  } else {
    mask &= AA_SP_CENTER;
  }

  if (mask & 0x00F0) {
    cd->d += dzdy >> 1;
    ip->r += drdy >> 1;
    ip->g += dgdy >> 1;
    ip->b += dbdy >> 1;
    mask <<= AA_SP_COUNT*2;
  } else
    if (mask & 0x0F00) {
      cd->d += dzdy >> 2;
      ip->r += drdy >> 2;
      ip->g += dgdy >> 2;
      ip->b += dbdy >> 2;
      mask <<= AA_SP_COUNT;
    } else
      if (mask & 0x000F) {
	cd->d += (dzdy >> 2) + (dzdy >> 1);
	ip->r += (drdy >> 2) + (drdy >> 1);
	ip->g += (dgdy >> 2) + (dgdy >> 1);
	ip->b += (dbdy >> 2) + (dbdy >> 1);
	mask <<= AA_SP_COUNT*3;
      }
  if (mask & 0x2000) {
    cd->d += dzdx >> 1;
    ip->r += drdx >> 1;
    ip->g += dgdx >> 1;
    ip->b += dbdx >> 1;
  } else
    if (mask & 0x4000) {
      cd->d += dzdx >> 2;
      ip->r += drdx >> 2;
      ip->g += dgdx >> 2;
      ip->b += dbdx >> 2;
    } else
      if (mask & 0x1000) {
	cd->d += (dzdx >> 2) + (dzdx >> 1);
	ip->r += (drdx >> 2) + (drdx >> 1);
	ip->g += (dgdx >> 2) + (dgdx >> 1);
	ip->b += (dbdx >> 2) + (dbdx >> 1);
      }

/*
if (debug)
	printf("cz_step r %d, g %d, b %d.\n", r, g, b);
*/

  p->r += d->r;
  p->g += d->g;
  p->b += d->b;
  p->a += d->a;
  p->z += d->z;
}