- SEPTiC DEMO'S COLLEGE -- 

                                 Lesson 12 
                                 ?????????? 
                         Written by Vicious / Septic 

                                  4 Feb 94 



                                  Introduction 
                                  ????????? 
I really hope you came with and understood everything in the last lesson, too 
if it was a little awkward. This time should we continue with 
vector objects, but to learn how to complete them! In other words, filled 
vectors will be a pushover after you read through this part of 
Demo School! 


                                    Theory 
                                    ????? 
Now we are going to finally take up blitterns fun fill-function, which can be used 
very nice effects. We will only fill our vector 
with it, and that's enough! 
   A filling really goes to to ensure that each rasterrad find out 
on startpixeln to fill and slutpixeln, and then it can be a stroke 
between the two pixels. This can then make all 256 (or whatever 
we now have the screen height) lines on the picture to a large vector 
to be filled. 
   We use instead blitterns filling so doing blittern completely 
agree this sad (and breaks consuming) work. However, we must do to 
the same way about, namely setting a start and an end point. Blittern works 
Indeed, in fill mode, it looks until a point, switch on 
the filling and filling until the next point. When one writes frequently 
lines so it will unfortunately end up more than one pixel per line on the line 
eg only three pixels in the Y-point, but 50 of the X-point. 
   Fortunately, there are even using a good feature when you draw lines, 
named Sing. Sets Singa-bitten when you draw the line there will be 
only to fall one pixel per line, and this is perfect for filling. 
   To fill to be absolutely, we must also ensure that we draw 
all the lines about the same vertical direction, that is always top-down or 
on the contrary. Moreover, we must make an EOR with lines only pixel to 
avoid sharp corners have only one pixel turn on the fill and 
produces ugly "threads" towards the edge of vectorfacets corner. 
   So, first and foremost, we must change a little in linjeritnings routine, but 
Then, just fill in! 
   When dealing with convex vector objects, namely those properties where a visible 
polygon NEVER overlap another visible polygon (like a cube), so can 
you use the handy method to draw out all polygons at once and 
Then fill the entire screen. Should I have inkonvexa object, like a torus 
(looks like a thick O), we must organize all the faces and then draw out 
those with early on along the back, fill each for themselves and also to copy 
them in the picture. You can use a combined convex / inkonvex routine 
who are capable of handling inkonvexa objects constructed of convex. I will 
However, do not go into inkonvexa vectors in this demo course, but only 
convex. 
   As I said, so, you can draw out all polygons at once, and then 
fill the object with blittern. This is very smooth, but they 
while a problem ... The polygons that are NOT visible must be removed 
in any way, otherwise the course blittern to fill them, and then 
the object will look very strange. 
   So, we must somehow feel of when a face is turned away 
away from us, and it can be done through the development of the polygons normal. 
Standard room is the vector pointing straight out from a face, and this is 
(typically) negative when the area is facing away from us. To produce the perpendicular 
for a surface is not very difficult. 
   First and foremost, you need the polygons first three coordinates. It is 
important that the coordinates are clockwise around the object, otherwise the perpendicular 
have the opposite meaning, so that it is negative when it is visible. How to 
But it is not the whole world, it is easy to reverse 
coordinates, so that tex coordinate sequence 0,1,2,3 becomes 3,2,1,0. This 
you will surely encounter when you do own property. 
   We make the calculation AFTER we converted the 3d to 2d. By 
Coordinate subtract 1 and then coordinate 2 with the coordinate 3 so get out 
how the polygon is facing. The following formula, we must then be presented under the lens 
value: 

    Vx1 = X1-X3 
    Vy1 = Y1-Y3 
    Vx2 = X2, X3 
    Vy2 = Y2-Y3 

    Normal = (Vx1 * Vx2) - (Vy1 * Vy2) 

If this standard is negative as polygon is invisible. Let us go 
furthermore ... 


                                  Register 
                                  ???????? 
The records used for filling is the same as for ordinary copier 
blittern. You could say that the filling is a common copying, because it 
copying it to be complete in itself, so to speak ... (It can be 
While also copy from one place to another while 
fill, but I have chosen to address only the simple filling way.) 
   As with the light, frequently copying, we need only Source A 
and Destination D in blittern. We must also bring a special mode called 
Descending the fashion that I not gone into as much yet. Descending fashion required 
to fill routine, but can also be used at the usual copying. What mode do 
is simply to turn the whole blitteroperationens execution, so that 
blittern begins to copy the end of the block and then REDUCES pekarna to 
the next word, so that it is copying the preceding word. Modular arithmetic 
SUBTRACT also values, instead of being added at a preserve the line-endings. 
Shift Money is the LEFT instead of right. And blitter mesh no 
also works WRONG WAY, so that FIRST WORD MASK worms LAST wordet on the line 
(but this is really the first because it is collected only when all 
is backwards :-) Pekarna assured in to point to last 
wordet in what you're copying. 
   Descending mode is good if you're going to copy eg a bob, which sits on the 
screen to a position further down the overlapping bobens current 
position. The problem with a regular blittning'd be bobens upper data 
will write over the bottom lines before having to copy them; 
boben and thus destroyed. Copying instead backwards, so eliminating the need for 
this problem. 
   We've looked at BLTCON1 ($ DFF042) before, but for safety's sake, take 
we have it again, to look more closely at the fill-bits ... 

BIT # BLTCON1 
---- ------- 
  15 BSH3 
  14 BSH2 
  13 BSH1 
  12 BSH0 
  11 x 
  10 x 
  09 x 
  08 x 
  07 x 
  06 x 
  05 x 
  04 EFE 
  03 IFE 
  02 FCI 
  01 desc 
  00 LINE 

As you can see is Descending fashion piece # 1, but then there are also some other 
funny bits left. 
   EFE is the Exclusive Fillmore Enable and with the means to fill blittern 
area between two pixels, and removes the left of them. A word with 
following: 

    % 0001000010000000 

Would be: 

    % 0000111110000000 

The area is filled pixel itself but the left hand removed. This is good 
to use when filled vectors, since all the faces lying next to 
another would overlap exactly at the edges and form 
annoying bugs. We will therefore turn on the EFE in our vector routine. 
   IFE is, as you might figured out, Inclusive Fill Enable, and the leaves 
the external borders intact: 

    % 0001000010000000 

With Inclusive Fill Mode: 

    % 0001111110000000 

One must choose either EFE or IFE to fill a surface. The last 
interesting piece, FCI, does Fill Carry In. This means that blittern 
turns off the surface instead. Our word: 

    % 0001000010000000 

Thus becomes then (with IFE): 

    % 1111000011111111 

And with EFE, it will be: 

    % 1111000001111111 

More difficult it is not to play. The rest is just a standard SRCA-> DEST 
copying that we learned in Lesson 7. 


                               Program example 
                               ??????????????? 
The program this time is a further development of the last lesson 
example. The cube is now instead FULL! 
   Since the program in principle is identical to the last so I can just 
through the changes I made. 
   In the first, I have done on the program so that it uses two 
bitplan instead of one. This means that we can use three different colors 
which is necessary to show a cube (three pages maximum display 
at the same time). 
   The first changes in routine DrawCube. A bit below labeln 
. nxtpoly do you see that I am jumping to a routine called Hidden Face. The 
routine counting up the perpendicular I described earlier. If it is positive 
we jump to. visible to draw the polygon. 
   To know which bitplan me to draw the lines makes me so that I 
shifter around the color code and see if it is negative, ie, when the highest bit 
the changes are set. Is it, it means that a line should be drawn. It may 
seems a little complicated to do, and I should perhaps be adapted for a routine 
any number of colors but then I had been a little more trouble with the records 
so I thought it was going anyway. 
   In Draw Line routine, I have to at labeln. X2gx1 some smart code 
makes a pointed corner of a polygon lack of alertness so that blitterns 
fill routine does not create ugly stripes at the edges. Try to eliminate 
the code until. notfix so you see what I mean. 
   I have also changed mintermen a bit during labeln. Signnl to 
use EOR fashion. This is necessary in vector procedures to fill 
faces connected correctly. Surfaces are just edge and will 
filled will then draw the line twice in which they overlap 
and thus invert the line (= remove it) so that the filling works 
perfect. 
   The table Octant_Table I have exchanged 1 to +3, which puts SING 
bitten in OCTANT. SING means single point per line and needed in filling 
to get more points on the line for the same line. 
   Routine Fill Page is also new. It thus resembles an ordinary copying, but 
As you can see I add (Screen Size * Nrofbpl) -2 to tap the vast 
in the last wordet I fill. In BLTCON1 I write in Exclusive Fillmore 
Enable and Descending fashion as we discussed earlier. The rest is normal 
for SRCA! DEST-copying. 
   I have added the two sides that were not needed in previous programs 
example at labeln Lines. The six lines describing all vektorobjektets 
polygon surfaces. The only thing new is that I introduced a color code before the coordinate 
numbers. By entering the same color value for the pages that sits opposite the 
each other so we avoid the ports so that people can see the border between 
surfaces. Try to bring all the colors to 1 so you can see that it is not 
so successful.