private void drawLine_color_alpha_spatial(int x0, int y0, int dt,
                                            int length, boolean vertical)  {
    int offset = 0;
    float iz = m_z0;

    int ir = (int) m_r0;
    int ig = (int) m_g0;
    int ib = (int) m_b0;
    int ia = (int) m_a0;

    if (vertical) {
      length += y0;
      for (int j = 0x8000 + (x0<<16); y0 <= length; ++y0) {
        offset = y0 * SCREEN_WIDTH + (j>>16);

        if (iz <= m_zbuffer[offset]) {
          int pr = ir & 0xFF0000;
          int pg = (ig >> 8) & 0xFF00;
          int pb = (ib >> 16);

          int r0 = m_pixels[offset];
          int g0 = r0 & 0xFF00;
          int b0 = r0 & 0xFF;
          r0&=0xFF0000;

          int alpha = ia >> 16;

          r0 = r0 + (((pr - r0) * alpha) >> 8);
          g0 = g0 + (((pg - g0) * alpha) >> 8);
          b0 = b0 + (((pb - b0) * alpha) >> 8);

          m_pixels[offset] = 0xFF000000 |
            (r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
          m_zbuffer[offset] = iz;
        }
        iz+=dz;
        ir+= dr;
        ig+= dg;
        ib+= db;
        ia+= da;
        j+=dt;
      }

    } else {  // horizontal
      length += x0;
      for (int j = 0x8000 + (y0<<16); x0 <= length; ++x0) {
        offset = (j>>16) * SCREEN_WIDTH + x0;

        if (iz <= m_zbuffer[offset]) {
          int pr = ir & 0xFF0000;
          int pg = (ig >> 8) & 0xFF00;
          int pb = (ib >> 16);

          int r0 = m_pixels[offset];
          int g0 = r0 & 0xFF00;
          int b0 = r0 & 0xFF;
          r0 &= 0xFF0000;

          int alpha = ia >> 16;

          r0 = r0 + (((pr - r0) * alpha) >> 8);
          g0 = g0 + (((pg - g0) * alpha) >> 8);
          b0 = b0 + (((pb - b0) * alpha) >> 8);

          m_pixels[offset] = 0xFF000000 |
            (r0 & 0xFF0000) | (g0 & 0xFF00) | (b0 & 0xFF);
          m_zbuffer[offset] = iz;
        }
        iz += dz;
        ir += dr;
        ig += dg;
        ib += db;
        ia += da;
        j += dt;
      }
    }
  }