- SEPTiC DEMO'S COLLEGE -- 

                                  Lesson 8 
                                  ????????? 
                         Written by Vicious / Septic 

                                  10 Aug 93 



                                  Introduction 
                                  ????????? 
First of all, sorry that this part of the school was a few days 
delayed. I just did not have time to do it until now. And when we 
still talking about it, so I must now finally - unfortunately, you might think -- 
announce that I no longer want to do this for free. The programs, and 
classes are becoming long and complicated now, and it means that I must 
spend quite a lot of time on it. I do not think it is only right 
I will get some pay for the effort, as you can learn so cool things 
(we have some lessons to go, and they are not of the picks :-)) as 
Then you can use in your demos, plus the debates of the post area 
indeed by its absence, and it has made me quite unhappy. 
   So I ask you now nice to donate the sum spent a feeble 100 Swedish kronor 
to address at the end of the lesson (thus my address). Send the sum of 
eight p.m. Kronoren banknotes or 1 HUNDRED-KRONOR (no coins!), preferably in a invirade 
paper, so that not a greedy man stealing mail them, and please 
include your name, so I can let you in the Demo-Course area at 
base. There are many lessons remain, including vectors, spheres, 
trackloading, image stretching, so I really hope that YOU pay 
today (the money goes to the A1200 and it is well-charitable purposes; 
I suppose, for the Commodore needs to s money ...) 
   There you go, now we can go along in Amigans hardware and - after 
learned to scroll with blittern - watching Blitter Objects, so-called 
Bob's. 


                                    Theory 
                                    ????? 
As I said last time, so one can blittern copy data from a 
place to another. Through various manipulations can you get 
Bob's, which are objects similar spirit, but with almost unlimited range and 
height, plus they can have more colors and is not limited in number. 
   When one copy of blittern specifying the man who is well known, a square 
box to be moved. A bob usually not be exactly like that, 
square box, but perhaps around or multi-format, like a small 
hubby. It is, which is set to pick up the worm (which the fisherman said :-) and when 
dubbing mesh boben so that the background shines through in which the object is not 
has no graphics. In this way, a round object to float around the screen 
but a black square around it. 
   A worm is simply a 1-bitplansversion of boben where all bitplanen 
stored (?!?!) through logical OR. Hmmmm, maybe not so good 
Declaration ... If we say we have a 4-bitplansbob we want to make a 
mask and a range of 16 pixels boben looks like this: 

    % 0101110110101110; First bitplanet 
    % 1001000010000011; Other bitplanet 
    % 0000010110100101; Third shit plane 
    % 1001010111100000; Fourth bitplanet 

Then the worm to look like this: 

    % 1101110111101111; Mask 

As you see, (and in this way works are also OR) worm is 0 (zero) 
ONLY when ALL bitplanen is zero. And WHEN is all bitplanen ZERO? Yes! When 
0, make color appears in boben, and color zero always be transparent 
which means that when the mask is zero, so should the background visible through. 
   We can therefore without any major problems think of a minterm suits. 
Blittern will read from bobgrafiken when the worm is 1, and read from 
background (so that it can be seen through boben) when the mask is 0. If we use 
all three sources of blittern so we can let the first point to the worm, the 
others boben and the third on the background graphics. 
   Our minterm see something like this: 

    AB + aC (Or (A & B), (NA & C)) 

This, we read that A and B or not A and C, which means that blittern to 
read from the source B of A is 1, and from C to A source is 0. It later 
expression ((A & B), (NA & C)) can be deployed just as it is in the program, 
because I already have predefined aspect values mintermarna and that makes it 
whole lot easier to deal with. (Look at the end of the sample, so 
you will see a lot of strange numbers ... It is my predefined aspect mintermar, if 
you did not know it!) 
   So far, so good, so we can move forward on how the shift will not go to 
when you move Bob's. 
   The last lesson I went through why there was no shift, and for the 
who do not remember, I can tell you that it is used to move data to the 
pixels, which is located between WORD edges, therefore, was between 16: the pixel. I 
also used to shift to scroll text to the side. 
   Shift-up at bobhantering fixes is so that you can put on their bob 
jagged pixels by 11, 75 or 120 (that is not on the steady 16-pixel address 
ie) instead of just 16, 32, 48, 64 etc ... It is excellent good, 
or how? 
   So, how puttar out his little fine hubby on a special coordinate now 
then? - Yes, if we say we will bring boben on the X-coordinate 57, then we must 
First find out what we are going to have to shift value, therefore, how far into the 
wordet as boben sits. 
   This can be done by dividing the value by 16, and then look at 
Division rest of the high wordet. So many recommend that you do, but 
I only laugh about them, because I know better ways to travel :-) (hmmm, 
are given and become poetic here .... grrmhgfmhf ....) A division takes MANY 
cycles to execute, and we do not want to have slow procedures unnecessarily, so 
Instead, we simply pick out just the 4 lowest bits, as in speech 
57 (binary% 00111001) is% 1001. Decimal is% 1001 9, so 9 is therefore 
Shift-century! Magic or what? 
   Since shifter our 57 to the right, 4 steps, which is the same as 
divide by 16 (fast speed) and when we know which word boben found in. 
We then multiply by 2 to get replacement value, we should add to 
screen pointer and then we are finished! 
   Yes, the harder it is not, but you must remember the following: 

  * Shift Nobody is always right, if you are not in Descending 
fashion, and it makes you not yet, for it will when I take up the area filling! 

  * The graphics shifts AROUND! So bobgrafik which shifts 8 steps to the right will 
bobens into the right side again and it looks not at all attractive development! Therefore: Blitta 
always a word extra, with BLTAxWM ($ dff044), worms off the graphics there, 
so that the transparent data shifts in from the right place! 

A use also may have to blittern is to clean surfaces, such as a whole 
screen. This is very good for tex make an impact with the processor, for which 
blittern can clear a separate screen while drawing its power with 
processor, while on another screen. It saves quite a lot of time 
on. 
   In order to clear the blittern there is no need to copy the black background or 
something like, but simply ignore the sources. It thus use 
JUST destination, and boom! to clear blittern, because it has not 
something special, more than zeros, to write with! And mintermen be 
of course, also be zero ... 


                                  Register 
                                  ???????? 
Not much new in registervag this time. Besides, we must use 
BLTCON1 of us now, when we use more sources. (Look at last 
lesson if you do not remember its layout.) We are simply in the same 
shift value in BLTCON1 in BLTCON0, to bobgrafiken should also shifts, 
and not just the worm, which only leads to errors. 
   BLTAFWM ($ dff044) and BLTALWM ($ dff046) is blitterns mask registers 
going to use when you work with Bob's. BLTAFWM (BLiTter A source 
First Word Mask) and BLTALWM (BLiTter source A Last Word Mask), I 
describe as BLTAxWM instead, and address it as a whole long word, where 
high wordet is First Word worms and low wordet is Last Word worm. To 
stitches removed is made with logical operators AND, and for tex stitches removed last sixteen 
the pixels on boben (when we have blittat an MS Word too much, to 
shift without bugs, for example) sends only # $ ffff0000 to BLTAxWM, 
so does not deal with the 16 last bits on each line. 
   You can also use masking if you want to copy things that do not lie 
on the smooth words. Maybe a graphic block that begins at pixel 18 and 
ends at pixel 125 of the x-point. Then blittar simply from the pixel 16 (which 
after all is evenly) to the pixel 128 (also evenly:-D), and worms off the two 
pixels in the beginning and the end. Easy, right? 


                               Program example 
                               ??????????????? 
Something Unlimited Bob's "record will not this time, but only 20 
small pieces 16 * 16 pixels balls to go on screen. I say go, 
because they are not slipping up on a sine curve ... It is CHALLENGE! 
Yippi! Read more below! 
   The procedure is not particularly optimized, but it shows how to use 
Bob's (and they are in FOUR bitplan, which is pretty much to hold on and 
copy of this poor little blittern), and that's the main thing. 
   I have also (for the first time in this demo in school) used me out 
dubbelbuffring! With dubbelbuffring meant to have two instead of one 
screen, and while SHOWS one draw so at the other. When you 
drew finished in RITA-SCREEN, so changing them simply so that what you 
designed to arrive! With this method avoids stupid jitter-bugging on 
a nice way! You can also make arrangements that do not float up in 50 
frames per second, but they are a bit hackers then ... 
   Okay, lets look at what the program deals with? 
   As always, we make the ordinary in the beginning, initialise, our DMA and 
bitplanspekare ... But, after a routine called Create Mask! The 
do exactly what you can imagine, that creates a mesh of our ball-bob. 
As you can see in the routine, so I ladders in turn by all four 
bitplanen and ORar them on the mask. No problems at all ... 
   Then I jump into a routine InitCoords named. What it does is 
set coordinates for all the balls, and impose its direction of the X and 
Y, in a special table that we can read then when we puttar out Bob's 
(or units of the bobarna? Or bobsingarna?:-D) 
   Then we jump quickly to MAIN, where I first sync, as always, 
and I will jump to Swap Pages, which simply take care of 
dubbelbuffringen ... The freakin the wing we last wrote on and sounds 
who last appeared to be the new "drawing screen". 
   The next routine is ShowBobs. We jump down and look what it does ... 
   First, we reset the D0 and D1 that it does not happen strange 
bugs when we work with the words below. Then we get the address of 
"rite-screen", thus the Draw Page! We also point to ball - uh, Oops ... 
sorry ... - Thus, on the ball, which is the bob-ball and on the mask. Why we 
makes this so early is to avoid doing it twenty times inside the bob - 
putt production-loop and thus save some valuable breaks rows. 
   First, clear, we the old balls in a little routine that reads 
coordinates from our little table in turn, and then jumps to 
ClearBob routine. 
   In ClearBob routine happens following ... 
   First, I subtract 8 from D1, thus Y-coordinate, because I want 
clear the ball around and need a little extra edge. Then multiply I 
with the screen width in bytes (can be made faster, but you must figure out 
Indeed :-) I teach the foundation, then you must teach you continue with 
time ...) I lay on the value of the screen cursor so that we come down to 
the Y-series. Then I subtract from the X-coordinate also, in the same manner, 8 
pixels, the shift to the right four stages (= division by 16) and multiplying 
2, the arithmetic shift to the left one. Also this value add 
I pointer on the screen. 
   Then I entered BLTCON value, which is only DEST when to clear the 
with blittern, the D0, the number bitplan, for the loop, in D1, and waiting 
that blittern to be completed. 
   Then I entered BLTCON value in - hear and be amazed! - BLTCON0! Wow! And 
after we worm # $ FFFFFFFF, for we do not need any stitches removed 
now, and so can I set BLTDPT and Modular arithmetic is correct. The size 
I'm to 48 pixels wide, thus becoming 8 extra on the right wing 
when we moved 8 steps to the left earlier, and 32 pixels high, which is 
the same thing. 
   Then I add to bitplans-pointer so that we get to the next bitplan 
and so I loops back. 
   There you go ... Back to ShowBobs routine, where I immediately jump on to 
MoveBobs. MoveBobs makes brief, this: 
   Retrieving X and Y-coordinate in turn, increases them with their 
ADD-values, see if they are outside a certain screen border and negate the so - 
case ADD value to change direction. 
   Again in ShowBobs routine ... Here is a kodsnutt similar 
ClearBob thing earlier, settled this puttar out balls instead of 
remove them. 
   The routine PutBob multiplying I first Y-coordinate (as in 
ClearBob routine) and add it to the screen pointer. 
   Then I entered a twisty minterm in D7, which says: "Use the source, A, B 
and C, plus destination D. Mintermen should be (B & A), (C & NA), then read from 
Source B of A is 1, and from C to A source is 0. " 
   I drive a swap on D7 ago, to lurch up the number of high wordet 
(because I'll write to BLTCON as a whole long word) and then download 
I low variation of the X coordinate. I Andar with 15 because we only need 
the 4 lowest bits. 
   Then I share with 16 and passageways by 2 to get the right replacement value. 
This adds value to my screen pointer. 
   Then I shift around D6 four steps to the right, so as to shift the value we 
picked up before the ports in the right position and so I ORar on it 
BLTCON value we have in D7. Then I D6 and swap ORar at it again, 
because we are going to switch the source B too! 
   Then I entered bobmodulon and skarmmodulon. Hmmm, minus 2? Yes, 
because boben only is 16 pixels wide, and 32, we blittar pixels (for 
able to shift right, if you remember?) so modulon have to be negative 
to return to the series ... 
   . BltWt waiting to blittern to be completed, and when we get the green light 
I write in D7 in BLTCON, the worm to # $ ffff0000 (as we came 
agreed on the above, to shift no one to go well) and set a mass 
pointers on both the worm, boben and screen. 
   After that I put in the right Modular arithmetic of A, B, C and D, and finally 
blittern we start by specifying the size of our bLitor-box. Two words, 
Thus 32 pixels, and 16 high. 
   Then I add bitplansstorleken to screen pointer, so that we come to 
exactly the same place fixed in the next bitplan, and doing the same thing with boben. 
Note that we do not add something to mask pointer, since this is only 
in a bitplan, and works for all bitplan in boben. 
   There, it was mostly about the most ... I hope that you relate 
with and that you understand. 
   Note that I included a little routine I have received from Leviticus also 
(hey, hey!), which makes a Setclock Load, then set the system clock right. 
This is good to have, because the demos - when you turn off the multitasking and 
generally do naughty things - make the clock go wrong. Thank you, 
Leviticus! 

It was all about the program this time. To facilitate follow the whole 
you can of course print the text file and read it while you look 
on the program, or you can load it into a text editor that can cope 
of multiple files at a time in different windows (type Cygnus Ed, yeah!) I 
self-use. 


                                  Challenge 
                                  ???????? 
Jajamansan! Time for the challenge again! Let me see MANY contribution this time, 
thanks! 
   Program example, this time saw the ugly out, I think, and the 
depends mostly on the balls do not float up on a sine curve! 
   This is where YOU come in! Make a sine curve for both X and Y (perhaps 
of sinus MY maker? :-)) And do so bobarna follow it! No special 
rules apply, except that you must give the refund to me before the next 
lesson comes out. 
   The most handsome contribution may be ..... hmmm, an honorable mention! So come on 
now! 


                                   Questions 
                                   ?????? 
If you have any questions, please give them the easiest to 22 Acacia Avenue: 

         Nod.1: 036 - 378,007 - 14400BPS DS - 315MB / A3000 
         Nod.2: 036 - 371,021 - 14400BPS HST - Cnet / 25 MHz 

You can also write to me, but then you must enclose the reply postage so that I 
does not become destitute (or simply pay the entry fee to 
demo course area)! The address is: 

                               Vicious Septic 
                                Klosterg. 19 
                              S-56792 Vaggeryd 

(If you send money, wrap an ordinary paper (preferably with something fun letter 
maybe!) around them so that they are not visible through the envelope ...) 


                                  Finally 
                                  ????????? 
Each new lesson in this course is published every other weekend at 22 Acacia 
Avenue of the special "Demo Course" area that I also suboperator 
too. Where can you write me letters, and debate on the demo programming. 
Programs that may be necessary to have in the future will also be 
available there. In order to access the area you must have paid 
entry fee, 100 SKR. 
   The next lesson will be on the base on August 21, so make sure you call when 
and download it! 
   Now it was the end of this time! Cynez!