
                          PAiN's coding compo++


Hello code addicts
We're summening you today for another showdown in coding skills. This time
everything is bigger, newer and of course matrox friendlier. And because you
all wined about to short a time for finishing your windows programm we will
extend the deadline from one month to two! This means that all of you must
compete. Enough small talk now.


The Goal
It's very simple, you just have to draw a filled triangle in mode 13h to a
given buffer as _fast_ as possible in 32bit protected mode. Very shocking yes,
now you're asking how am I gonna tell which one is fastest? Well we've also
done some work to write a server programm that, when linked with your
triangle routines, will measure how long it takes to draw a triangle in clock
cycles using the rdtsc opcode. I'm so sorry for all you xt till 486 owners,
but you won't be able to use the server programm, but fortunetly you can
still compete by sending me (zaphod@datacomm.ch) your code and I'll test it on
my machine and send the result back to you!.


How does it work?
Ok in this pain there are a few bonus files, one of them is called server.asm.
This module will have to be linked with your triangle.asm (or whatever
you call it) by DLINK. If you're not sure how to link files with TASM/DLINK
it is shown in the batch file comp.bat. But what exactly is DLINK? Why aren't
you using TLINK?! You may be asking, that's because you're going to have to
use DOS32, a superb 32bit dos extender, for this Coding compo. You can get DOS32
from the Lycaeum or some other BBS. I'm currently using DOS32 version 3.3.
The procedure that draws the triangle in triangle.asm is called drawtri.
If you look in server.asm drawtri is called up 10000 times to make sure the
speed measurement is exact enough. To make the whole thing a bit more
interesting, we're going to let you precalculate a bit too, but only once
at the beginning and only for a short time (10'000'000 clock cycles). The
procedure that does the precalculation is called precalc <duh>. Of course
the server programm must tell your triangle.asm the corner coordinates of
the triangle, the X-coordinates are saved in an array called vx which is
12 bytes long, and consists of 3 dword variables, vy saves the Y-coordinates
and works exactly the same as vx. The color of the to be drawn triangle
is saved in the byte flatcolor. Now the most important question is where
to draw the triangle in RAM, there are two ways: you can either use the
dword variable videoptr as an offset in memory operations like this

  mov eax,videoptr
  mov cl,flatcolor
  mov ds:[eax+ycoord*320+xcoord],cl

or you can use the ES selector which is a NULL selector (it points to 00000000h)

 mov cl,flatcolor
 mov es:[0a0000h+ycoord*320+xcoord],cl

For those who are not so used to coding assembler, I've put together a small
example triangle.asm , where you can just fill in the draw/precalc code.


Some very interessting facts

-The server.exe is so big, because 10000 triangle x/y coordinates are
 precalculated to make sure your program will always draw the same triangles
 and therefor making the compo fair
-The resolution is 320x200x256 (mode 13h) and will be initialized by server.asm
-You don't have to worry about clipping
-You can use the FPU but no MMX please
-Don't try to alter the precalculated triangle coordinates in your precalc
 routine ;)
-The winner gets nothing (well if really a lot compete, and buenzli6 is soon
 he'll maybe get beer or something)
-The losers get nothing
-You don't have to PUSH or POP the registers at the beginning or end of any
 routine. This is already done with server.asm
-All interrupts are disabled so you can fuck with ESP
-Pentium optimized code is the way to go
-The X/Y coordinates of the triangles coordinates are not saved in any
 particular order.
-Once in a while the server program gives a wrong speed result, don't pay
 any attention to it... sorry :(



The Compo Compu

All entries will be tested on my PC , a Pentium 66 with 24Megs RAM and a
ET4000 w32p/d graphics card. Because the speed result depends strongly on
the graphic card you won't be able to compare your results with your friends
(assuming you have any). But if you send me some beta version I'll post
the results on a WWW page, so please do send some pre-releases even if you have
a pentium to make the compo more interessting! The preresults site will be
somewhere on www.omedia.ch/pages/dake


cu&start right now!
zaphod and dake


ps.send questions or results to me (zaphod@datacomm.ch) or dake (dake@omedia.ch)


