I'm about to dig into Polymost to see if I can understand the rendering algorithm
I would suggest taking a look at
POLYMOST.BAS It will be well worth your effort. Polymost works exactly like the classic Build renderer with respect to wall sorting and portal following. The main difference is: Polymost performs clipping at the tops of bottoms of walls BEFORE rasterization - essentially performing intersections of vertical trapezoids. Build Classic does clipping AFTER rasterization by comparing heights for every vertical line (I.E. a span buffer for vertical lines).
...red lines of sectors as a kind of portals, but still that can potentially give you LOTS of lines to consider...
Build considers each wall for drawing at most once per frame. The clipping routine must then consider every vertical trapezoid (or vertical line for classic) that may intersect the new wall.
How do you clip sprites? I know that you have span buffers but still I can't figure out this one... Z-buffer?
Polymost uses a Z-buffer, write-only (because there's no overdraw) during the wall/ceiling/floor render stage. It uses a standard read/write Z-buffer for the rendering of masked walls and sprites.