Triangles seem to be a really scary thing for most of the coders. Only 5 contributions in this compo, but it seems that
the "best case" in length is still reached. The routines had to draw 4 triangles of different sizes and different positions.
Three routines drew the triangles with only 40(!) bytes. But Bluberrys routine was the cleanest and with only 300 rasterlines the fastest
routine among all contributions to this compo. So it is the clear winner.
Piru pointed out later, that it is even possible to get this routine to 38 bytes with a dirty trick - by using (a0).b as loop counter.
Place |
Contributor |
Length |
Speed |
Used Algorithm |
Accuracy |
1. |
Blueberry |
40 |
300 |
limited dual Interpolation |
good |
2. |
Zuikki * |
40 |
~15000 |
Subdivision |
bad |
|
Psycho * |
40 |
~187000 (!) |
Subdivision |
bad |
4. |
Piru |
42 |
1956 |
Recursive subdivision |
bad |
5. |
Nao |
48 |
540 |
Dual interpolation |
average |
* Zuikkis and Psychos routines were moved down due to their bad accuracy and
their extremly low speed.
The winning routine by Blueberry: (40 bytes)
movem.l (a1),d1/d3/d4
sub.l d1,d3 ; x2-x1 | y2-y1
sub.l d1,d4 ; x3-x1 | y3-y1
lsl.l #8,d1 ; 8.8 precision
st.b d7 ; Loop 256 times.
.loop1: move.l d1,d2
move.b d7,d6 ; Loop n times, this makes a triangle.
.loop2: move.l d2,d5
lsr.w #8,d5
swap.w d5
lsr.l #8,d5 ; x,y
move.b d0,(a0,d5.l)
add.l d4,d2 ; Inner position
subq.b #1,d6
bcc.b .loop2
add.l d3,d1 ; Outer position
subq.b #1,d7
bcc.b .loop1
|