- SEPTiC DEMO'S COLLEGE -- 

                                  Lesson 7 
                                  ????????? 
                         Written by Vicious / Septic 

                                  24 Jul 93 



                                  Introduction 
                                  ????????? 
Large valanimerade Bob's, high sinusscrollers and fast-filled vectors have 
one thing in common. They use the powerful thing in Amigan called 
BLITTER. In this lesson we will finally begin to poke a bit of blitterns 
opportunities and learn how to respond. 


                                    Theory 
                                    ????? 
In the first instance, we think of blittern as a copier. The processor is its 
employers, and has not told the processor to work so is the 
only in a corner and songs themselves. 
   But, blittern is not a sluggard, but very effective. As soon 
CPU talked about for what it is to copy it to the launch with 
breakneck speed. Meanwhile, the processor can perform calculations and other things 
and good while waiting to blittern will be completed. 
   Blittern can be used to copy the ordinary from the source to 
destination, but it can also combine different sources to achieve 
interesting results, especially in graphics processing. An example is 
Bob's, which I will address the next time. 


                                  Register 
                                  ???????? 
Before we give blittern orders with the processor, it is important to check 
if it is finished. Otherwise, you may copy it just for 
currently go to hell. 
   Watching it is clear it can be a simple way to do by testing 
bit # 14 (BBUSY) in DMACONR ($ dff002). If it is set so we know that blittern 
are fully and have no time for a new copy yet. 
   Once you have checked whether it is ready and get clearance so you can 
First initialise the various registers as blittern use. 
   To begin with, I usually specify what kind of copying me to do 
and it does BLTCON0 ($ dff040) and BLTCON1 ($ dff042). The two 
Registers are as follows (not in line draw mode): 

    BIT # BLTCON0 BLTCON1 
    ---- ------- ------- 
     15 ASH3 BSH3 
     14 ASH2 BSH2 
     13 ASH1 BSH1 
     12 ASH0 BSH0 
     11 USEA x 
     10 USEB x 
     09 x USEC 
     08 x USED 
     07 LF7 x 
     06 LF6 x 
     05 LF5 x 
     04 LF4 EFE 
     03 LF3 IFE 
     02 LF2 FCI 
     01 LF1 desc 
     00 LF0 LINE 

ASH0-3 - Indicates Shift value for the source A. 
BSH0-3 - Indicates Shift value for the source B. 
USEA-D - Speaking of the blitter channels you want to use. 
LF7-0 - Logical minterm function. 
EFE - Fill exclusive. 
IFE - Fill inklusivt. 
FCI - Fill Carry Input 
Desc - Descending mode (Copy from the bottom up instead of vice versa). 
LINE - Turns on-line fashion. 

Fill pieces and line fashion piece, I will take up in later classes. Right now 
should we concentrate on BLTCON0 and only clear the BLTCON1. 
   Those who are not fully behind flotet - uh, sorry - have been well at this 
team (if you read correctly) noticed that blittern has 4 (four) channels. They 
first three, A, B and C are the source channels and the last, which has the name 
D, is a destination channel. 
   We will this time only use us out of A source and destination D, 
because our copying is a simple type. So, we select only bit # 11 and 
bit # 8 (USEA and USED). 
   You might wonder what the plot is for? Well, blittern works always 
only with the entire WORD, which is the sixteenth pixel (look back on 
lesson on bitplan if you do not remember!) and to move an object at only 
regular sixteen pixels coordinates of the X-point would not be so neat. It is 
This shift to arrive. It simply shifts the data up to fifteen 
step in the wordet to dub to boom, you can let a 
graphic objects to slide out a pixel at a time. 
   However, it can be used to shift to another. Namely, when 
scrolls a text! Program example for this time using the shift production - 
technology to be able to scroll text four pixels at a time. 
   Bits 7 to 0 (LF7-0) in BLTCON0 indicates the logical mintermen, which is 
a very powerful little thing who talks to blittern how the three sources 
will be combined to achieve a special effect. Its complexity makes it 
also quite difficult to understand, so do not get chronic brain now on you 
do not take my explanation. 
   You can combine all three sources A, B and C of up to 256 different 
way with this function generator. Every single bit of it to dub 
will be tested and are affected differently, depending on what kind of minterm chosen. 
   One can visualize it with a truth table (as they have done in Hardware 
The manual, which capitalization is NOT): 

    A B C D BLTCON0 bit MINTERM 
    - - - - ----------- ------- 
    0 0 0? 0 abc (= Note A and not B and not C) 
    0 0 1? 1 abc (= Note A and not B and C) 
    0 1 0? 2 abc etc, etc. .. 
    0 1 1? 3 ABC 
    1 0 0? 4 Abc 
    1 0 1? 5 ABC 
    1 1 0? 6 ABC 
    1 1 1? 7 ABC 

Then read only in the table depending on how you want to combine 
sources. If, for example, we want to put all the pieces in destionationen when A 
or B is 1, we look at the table and look after what bitpositioner as 
A is 1, which is in position 4 to 7, and then at The positions B 
1, and that is the position 2 and 3 and 6 and 7. 
   Then we look only at what pieces we sat, 2 to 7 
and see that we have received century% 11111100, which is $ FC hexadecimal. 
   We see now also the single type of copying us to use to 
scrolling text, because we just have to move from A to D without frills. 
We just put all the pieces that have A bit on, namely the bit 4-7, and may 
century% 11110000, which is $ F0 in hex. 
   But, unfortunately, it is not as easy as just. For when to construct 
more difficult operations (the next time we will look at how to make Bob's) is also required 
some logical equations. 
   An example: 

    D = Ac + B 

Letters stuck together read as AND and a plus indicates OR. Small 
NOTE letters have ahead of them. The expression above is read as "A, and not 
C or B ". This means that the D-piece is only when A is set and C is 0 
or when B is 1. 
   To calculate the figures for this is both tough and difficult, so why have 
I included variables at the end of the sample application that makes use 
minterms of a lot easier. We should not look at them until 
the next section. 

There, it was a bit of BLTCON! After that we talked about for the ivrige 
copy what he will copy, we must specify where he will retrieve data 
and where to go. 
   A source has its pointers in BLTPTA ($ dff050) and the destination D BLTPTD 
($ dff054). Both addresses can be entered as long words but remember that 
it must be within CHIP mem. 

As with bitplan, can blittern add a Modular arithmetic value for each 
series of the copied. This makes it easier if you copy the data that is less 
than the screen is wide. You can then tex move a bob that just is 32 pixels wide 
on a 320-screen and not have to fuss with copying a row at a time and 
then add a wide value to save time, but can initiate blittern 
to manage the whole auto magic. 
   Modulovardet for A source is in BLTAMOD ($ dff064) and the destination D 
in BLTDMOD ($ dff066). 

There is also a mask register in blittern, allowing logical AND of the 
beginning and the end of a copied range. It can thus exorcise 
pixels you do not want in a property that does not really fill up a 
quite evenly word. For now, we let the records be $ FFFF, because we 
do not want to skulk away anything yet. (More on its use next time, so stay 
you to the steel ...) 

Now it's just to get started blittern! And how do you do it? Yes, 
do it by entering dubbing size! As soon blittern get in 
the size of the data field to the copy so put it up and running, so why should 
we always give the size Finally, after it sat all other blitter - 
Registration for the right values. 
   Blittern receiving size as the width and height in the words of the number of rows. 
Register to be key in all this is BLTSIZE ($ dff058). 
   The pieces are then BLTSIZE in the altitude specified in bits 6 to 15 and the width 
in bit 0 to 5. Simple terms, just multiply the height by 64 to 
to force it up into pieces 6 and up, and then add width. 
   A block of 128 * 32 pixels, then the size (32 * 64) + (128/16) = 2056 
($ 808). The height is 32 multiplied by 64, and then adds 
width in words, which is 128 pixels divided by 16 = 8 words. 

There you go! It was a little flukt on what can be done only in the simple 
copying with blittern. Now we can throw us further on the sample. 


                               Program example 
                               ??????????????? 
Scroll Texts may seem enormously sad because they seem to have been of late 
ancient times (yes, at least the late 64: up and began triumftag world 
over) but they show quite well the "square" copy goes to. 
   What you do when you scroll is simply to copy an entire square 
area, where the text is, at a new position in the X-point, a few pixels to 
left (or right :-) if you seen my Slipstro ...) In my program 
scrolls I, on a 384 * 32 screen, a 32 * 32 font with a little poetic text. 
The screen is 384 pixels wide to avoid the ugly edges where the scroll only 
chopped off, and to conceal the fact that our new letters PLOP out on the screen 
instead of slipping into a relaxed and soft. It is 32 high, are completely 
simply because it was not needed more, when the font does not exceed 32. 
   I also added a small mirror effect on the scroll, which is 16 
extra pixels, but this has nothing to the correct screen (which is only 
32 high) to make, but an inverted copy achieved with 
Modular arithmetic negative. 
   But, anyway, so perhaps it is best that I go through the program step 
by step as I usually do. 
   First is the old-fashioned start DRUNKEN (hmmm? It has 
dragged on late lesson 1 and no one has protested, but does it really 
on the A1200 ?!?!?) we studied the past and do not have to grind forward. 
Then the DMA-style, and here you can see that I proposed on blitter-DMAn 
and also BLITTER NASTY bit, which gives full priority over blittern 
processor, so that blittern more time and copying faster. A 
optimal way (which I have seen that Hannibal / Lemon. use) should really 
be to only turn on BLITTER NASTY when waiting to blittern to be 
finished, but I have not managed to do this. 
   After that, we copper list, and then main routine. Here we see 
I only use a sync-routine to sync with the scroll 
breaks beam (try to pick off sync routine to see the difference) 
and getting things to flow nicely. 
   Then skip to the scrolling text my routine and then we take a look at what 
I am doing there. 
   First of all, I subtract from a Scroll Counter. This allows me to 
to be able to know when new characters to be printed. 
   If not ScrollCountern is zero, we jump to. NoNewChar but on the 
however, IS zero, we at the 8. Hmmm, EIGHT? Perhaps you wonder, and the 
I can understand. The real figure should really be 32! But, if 
value would be 32, we would also get scrolling text one pixel each sync 
only, and it is quite slow. I now scrolls text 4 pixels to the left 
each sync, and so it is only the value 32 / 4 = 8 ScrollCountern. Test 
feel free to enter the higher and lower values on this line you will 
noted that the letters will be closer to or farther from each other. 
   Then I jump to the routine NewChar, and then it's just as well that we 
telescopic also on the straightaway. 
   In NewChar I get only a pointer to indicate where in the text we are 
us, that is the sign we are now mush on the screen. After 
reset the D0 (not really necessary, but a security measure 
divide the ring later) I get the sign and jump on it is not zero. Is 
is zero, we just start from the beginning of the text again and try to 
again. 
   Then do I save text pointer again (now pointing it at the next letter which we 
To print the next time) and subtract 32 from D0. If you looked in a 
ASCII table any time (as I hope, otherwise you should do it 
omedelbums!), you hopefully noticed that the first 32 letters 
only control characters. These characters do not we, in our scrolling text, and 
we have not represented them in our font, so why do we fully 
simply on the table so that space may be a value of 0 instead of 32 and 
exclamation points will be 1 instead for 33 etc ... Watch fontbilden to see how 
the characters are presented. (R, D and E are also in the picture fixed in a relatively 
mad positions, namely, &,% and +, so do not be surprised if it does not 
consistent with a true ASCII table!) 
   Then - if we go back to the program again - I reset D1 
(security again, otherwise it can be BUG out ...) and dividing the D0, thus 
letter number, with 10 since there are 10 characters in each line of 
fontbilden. When I do this, I get a response indicating in which row 
the sign says, and a residual (in the upper 16 bits) to talk about what 
position sideways. 
   I move the low 16 bits, then line number to D1 and 
multiply it with a letter height of fontbilden, which is 320 pixels 
wide, thus becoming 320 / 8 bytes = 40 x 32 pixels high. 
   After I clean out the small bits of D0 and moving down the division 
rest there. After that I perform an arithmetic shift to the left two steps, 
which is the same as multiplying by 4 (solid tinge yesterday 
faster), and I do to get the correct character position in the X-point. 
Each letter is 32 pixels wide, and it is notoriously FOUR bytes! 
So, if the sign had position 2, so we multiply it by 4 and 8; 
it means that the graphics for character No. 2 are 8 bytes into 
fontbilden. 
   What do I do next? Well, now we have all offs ether we need, so now I suggest 
on each fontbilden is in memory and then add to A0 to final 
pointing to the correct letter, then we will print on the screen. 
   Then I pointing at the screen, 46 bytes in, because we are writing the character 
far out to right and then I start to move data. 
   The need for two loops of the whole. One who walks around 32 times (as we 
copying row by row in alphabetical graphics) and as one that goes around 4 times 
(because the font has four bitplan). 
   I am moving graphics with move.l that it is exactly 32 pixels and then 
I add the screen width (so that we get to the next line, right under the 
last) to both fontbilden and the correct screen. (Font is 320 pixels 
wide, which is 40 bytes, and the screen is 384 / 8 = 48 ...) 
   When I have copied a letter in a bitplan I go to the next 
bitplan. As the only screen is 32 pixels high, I need not add up 
something to it, but I add to fontbilden its bitplanstorlek 
(40 * 192) less a character height (40 * 32), so I ports in the right place. 
   There, it was NewChar routine. Then we jump back to where we were, in 
Scroll Text routine. 
   Here we jump to the blitter-scrolling routine, ScrollIt. 
   In ScrollIt do we do what we always must do before using 
blittern. It is testing whether it is finished! I make this a busy wait (this e 
demo coding, so who carez?). 
   Then I add source and destination of A0 and A1. The source is 
screenplay +2 (ie 16 pixels to the right) is due to blittern shift to the right 
(except in the descending mode, but that is another story I'm going to get up in a 
later lesson). So, what we do is to move 16 pixels to the left 
and then shift to the right to receive 16-speed shift value. 
   Which shifts the value I see you on the next line, where I write to 
BLTCON0. It is $ c000, but only the three highest bits counted, so it becomes 
$ c, that is 12. Scroll speed is therefore 16-12 = 4, and it knows we 
again from above! 
   Then it says + srca! Dest! A and it is minterms-simplification that 
I talked about before, which makes it easier to combine functions. Srca 
and dest stands for USEA and USED, so that only A and D will be turned on; 
and A: et arising talking about for blittern it to copy everything from A 
D without any modifications. 
   Then I reset BLTCON1 (can be done by writing a 
Long word to BLTCON0, but I wanted to get it all transparent to those who are 
Beginners :-)) and write $ FFFFFFFF to BLTAxWM who are both 
mask registers. 
   In BLTAPT and BLTDPT I write so the source and destination and then 
I write zero to two Modular arithmetic records. 
   Now, last but certainly not least, I write to the size BLTSIZE. 32 
Line height times 4 bitplan plus 8 extra rows and then 23 words width. 

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. 


                                   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 
will not be penniless! The address is: 

                               Vicious Septic 
                                Klosterg. 19 
                              S-56792 Vaggeryd 


                                  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. 
   The next lesson will be on the base on August 7, so make sure you call when 
and download it! 
   Now it was the end of this time! Cynez!