Subject: render full 'c' source?

From: [email-masked] (Tng Tai Hou)
Date: Tue, 4 Feb 92 23:04:05 SST

Hi folks, the subject I think says it all. When will the
full 'c' source be released? It is indeed very fast. And I would
like to port it to the Mac. In particular, I refer to
the polyblit functions - compute_slope and tpoly. They
are written in assembly. Can someone please post the
pseudo-code, or better still, their 'c' equivalent, so they
can be easily ported to other platforms (Mac for me), and
then turn into assembly later when everything works.

Please, I sent this before. But so far no positive replies
beyond 'I'll look into it'. I know I have no right to
expect a reply. But this is such a good package it would
be ashame to restrict it to just one platform.

If I had the time, maybe I'll learn 386 assembly and then
learn the code myself. But I don't have the time.

Thanks for reading.

Tai Hou
Singapore

---

From: Dave Stampe-Psy+Eng <dstamp@watserv1>
Date: Tue, 4 Feb 92 18:07:24 -0500

Well, the polyblit stuff is pretty simple, and optimized for the VGA
archetecture to boot.  But you asked for it.

Compute_slope basically figures the slope of a line: (x2-x1)/(y2-y1)
times 65536 so a fractional part is kept.  This is rounded up if 
positive.  x2-x1 is returned if y2-y1 is zero.

Tpoly does a trapeziod fill, given top, bottom+1, left, and right side
starting positions.  It converts the side positions to 16-bit integer and
16-bit fractional parts, comncatenated in one 32-bit word.  1/2 times 65536
is added to the left side so it will round up.

Then it computes the address of the topmost line and the number of lines.
It does a very fast horizontal line fill (this is VERY processor dependent,
so I won't cover it in detail).  Then it bumps the line address up so
the next line can be drawn, and adds the slopes to the left and right
sides.  Shifting these values right by 16 bits gives the left and right
sides for the next line.

I haven't discussed clipping, etc. because REND386 does its own clipping.
You should get the new versions of the blitter from sunee.uwaterloo.edu
and look at the fastri() routine for a better way to do it (50% faster
for small polygons).  It relies on a CCW ordered vertex list.

First, it rotates the list till the topmost (leftmost if more than one
vertex on top line) is at the start.  Then it compares the points to
find which of 3 configurations the triangle is: flat top, flat bottom,
third point on left, third point on right, or degenerate (all on one
line).  It then processes each case as one or two trapezoidal slices.

One thing to note is that one side may carry through between two 
trapezoids.  In this case, the slope and the full precision edge
location (32 bit) is used in the next trapezoid draw.

This gives you an idea what's done.  I make no claims that it's 
optimal.  I'm sure Mac programming gurus have done good polys
on that machine.  If you need more info, please make it specific
and I'll explain further.  But I suggest you get the new code too.

- Dave Stampe