| |
Credits :
Download :
Look for downloads on external sites:
Pokefinder.org
Production Info Submitted by Rastah Bar on 28 January 2014
A couple of remarks about the code:
Rotations are around one axis at a time. I used the following tricks to make them fast:
Rotations are over a fixed small angle. The angle is chosen such that sin(phi)=1/8 or -1/8, then cos(phi) is very close to 1-1/128-1/32768. Rotations are calculated with 24 bits accuracy. Further, suppose you rotate first around the x-axis and then around the z-axis, then you can write:
x(i+2)=z(i)+(x(i+1)-z(i+1))*cos(phi)
y(i+2)=y(i)+(x(i+1)-z(i+1))*sin(phi)
where e.g. y(i) is the y-coord after the i-th rotation.
Now you need to calculate only 2 cos/sin terms, while with the rotation matrix there are 4 of such terms.
Similar equations can be derived for 2 consecutive rotations around any 2 axes.
All lines are composed of short segments where either the x or y coordinate doesn't change. I stored for each full line (in one octant) the lengths of the short segments. Then when drawing a line, I read the segment lengths from the table and decreased a counter (the x- or y-register usually), and when it is zero, I have to increase/decrease the x- or y- coordinate. I tried to make the code as efficient as possible. For example, for longer horizontal segments you can plot 1 whole byte at a time instead of 1 bit at a time. And I actually subtracted 1 from all segment lengths in the table, because I can then branch off with an 'beq' to plot just the one point when the segment has length 1. I considered several variations, but found that often you win some for flat lines and then you lose some for steeper lines, or there is some compromise between shorter and longer lines. It will probably help to write separate routines for different line slopes, but I did not want to go that far.
I keep track of the maximum x and y coordinates in a plot, so that I only have to clear the used part of the screen when starting to draw a new plot.
To calculate the projections (in "perspective" mode) I used the so-called log-exp method, with carefully designed tables. |
|
|
|
| Search CSDb |
| Navigate | |
|
| Detailed Info | |
|
| Fun Stuff | |
· Goofs · Hidden Parts · Trivia
|
|
| Forum | |
|
| Support CSDb | |
|
| |
|