- SEPTiC DEMO'S COLLEGE -- 

                                  Classes for 1 
                                  ????????? 
                         Written by Vicious / Septic 

                                  13 Apr 93 



                                  Introduction 
                                  ????????? 
Welcome to the first lesson of this excellent demo school. Here 
you will have the opportunity to learn everything you gone, and dreamed of 
able, but failed to / had time with. We will thrash through all possible 
in the demo world, such as copper bars, sprites, Bob's, textscrollar, line - 
drawing, vectors, circles and much more fun as it can be helpful in 
its future demo programming. 
   I assume that the basic assemblerprogrammering there before 
you start to read, this is only a demo school, to teach demo - 
programming, not a assemblerskola. Example programs are written in 
ASMONAS, but if you use another assembler so it should not be so great 
problems in adapting source for it. 
   The course will to some extent contrary to everything the Commodore advocate on 
system-friendly programming, but I think it is a necessity 
in the demo programming to write their own "quick-and-dirty" practices for 
to squeeze out the maximum of Amigan. Using Commodore's own 
library routines are becoming too slow, and furthermore, it should not 
on the control of the program. 
   If you do not share that view, but merely want to make programs 
certainly will work on any upcoming Amiga, so I recommend you 
to stop reading now. 
   There, then, we were past the formalities and can quickly throw us over 
essentials ... 


                                  Register 
                                  ???????? 
In this title (as you will eventually be quite familiar 
with) should I in each lesson to go through different registers, we need to 
achieve our impact. All these records are thoroughly explained in 
Commodore Hardware Reference Manual, and I recommend that you purchase 
the book if you do not have it, for it is every demo program worldwide Bible. 
However, I will explain the records I use, what they are good for and 
how they are used. 
   To start with, perhaps I should explain a bit around these famous 
hardware registers. By reading or writing to a hardware register 
can communicate directly with the hardware in Amigan. Commodore says it 
should not be to program them directly without going through the resources or libraries, but 
it's best not to do it, to save rastertid. It would be easy to 
read examples of where video beam is on for rasterrad and sync a 
routine immediately after it, or change the background color for each rasterrad and 
creating beautiful copper effects. All this becomes smoother (when you can 
it) and, above all, faster if you use the hardware directly. 
   A very important records that we should start with is DMACON ($ dff096). The 
Steering Amigans DMA, that we can regulate what we want and what we do not 
needs. The things you govern with the registry is: 

    * Blitter priority over DMA 
    * Bitplans DMA (so that it can display graphics) 
    * Copper DMA 
    * Blitter DMA 
    * Sprite DMA 
    * Disk DMA 
    * Audio DMA 

As you can see it's about everything you could possibly imagine having a demo, 
and this registry governs what is visible. Like most other 
Registers are DMACON ($ dff096) a WRITE ONLY register, or you can just 
write to it. If you want to read the current DMA may be read from DMACON's 
counterpart, DMACONR ($ dff002). The records containing interesting 
Information usually have a READ-ONLY counterpart. 
   When you make a demo you should always plan in advance what you really 
should do, how it should look like and so on ... then it becomes too easy to 
decide what to bring to the DMA. Do we need to tex not sprites in his demo 
should I turn off the Sprite DMA, to avoid "spirit flicker," and that unnecessary 
DMA time goes to the sprites that are not shown. 
   We will now look at how the registry works. It is a WORD-register, 
which therefore means it contains 16 pieces. Its construction is 
very common and will return in many other records. Pieces read as 
follows: 

  BIT POSITION DESCRIPTION 
  ? ? ? ???????? ??????????? 
  15 SET / CLR Indicates whether pieces with a 1, cleaned or filled. 
  14 BBUSY Indicates whether blittern working or are vacant. (Read Only) 
  13 BZERO Speaking on if a blitteroperation resulted in 
                   a destination with only zeros. 
  12 X 
  11 X 
  10 BLTPRI Blittern priority processor, which makes 
                   CPU can not steal some bicycles from blitter DMA. 
  09 DMAEN Allows following DMA. 
  08 BPLEN Bitplans DMA switched on. 
  07 COPEN Copper switched on. 
  06 BLTEN Blitter on. 
  05 SPREN Sprite DMA switched on. 
  04 DSKEN Disk DMA switched on. 
  03 AUD3EN Audio Kanal 3 DMA switched on. 
  02 AUD2EN "" "2" "" 
  01 AUD1EN "1" "" 
  00 AUD0EN ' "" 0 "" " 

First and foremost in a program, should save the old DMA setting 
(if you're going to return to the system) before it puts its own. It is 
simply by picking a Word from DMACONR ($ dff002) and save it until 
discontinuing its program. However we must bring bit 15 before you write 
back to DMACON ($ dff096) for the pieces to be. 
   When we saved the old setting, it is customary to clear all the pieces, 
which you do by writing # $ 7fff to DMACON ($ dff096). This makes 
every bit is cleared (because bit 15 is 0). When adjusted all the time 
composing together its own DMA and write it to DMACON ($ dff096). 
(This can be seen in the demonstration activities program Lekt1.s if something is unclear.) 

After all the talk about DMA should we raise a bit of copper. Before 
install its own copper list should also be here (like DMA) save away 
the old copperaddressen (if you're going to return to the system) to 
to restore the old copper list at the end of the program. 
   The retrieval system copper list is not as easy as downloading old 
DMA, since there is no READ-register for copperaddressen. Man 
may instead go through graphics.library (although I do not like to use 
:-) libraries so you will be forced sometimes ...). By opening 
graphics.library and retrieve the value that is on the $ 26 + gfxlib-running link. 
After saving the address, we can calmly enter our own 
copper list of COP1LC ($ dff080). (NOTE: Copper list must be in CHIPMEM!) 
The value is entered as a LONG WORD. After that you should ideally write a WORD 
to COPJMP1 ($ dff088) to force Amigan to start using your own 
copper list. COPJMP1 ($ dff088) is a so-called strobe-register, which is not 
care about what value down, but only that it has written to it. 
The purpose of COPJMP1 ($ dff088) and COPJMP2 ($ dff08a) is that you can have two 
copper lists while on COP1LC ($ dff080) and COP2LC ($ dff084) that can 
jump between each other. 
   If we were to take and describe copper lists. Copper is a notoriously 
Coprocessor working completely independently of the MC68000 processor. Copper is a 
very efficient little helper, which is behind much of Amigans 
graphics options. For example, in a simple way to change colors, DMA, 
Interrupt trigger or even change the resolution anywhere on 
screen. Since copper list is running on each vertical blanking so simplifies 
the update, for example, on bitplanspekare which must be set 
each vbl (vertical blanking), significantly. You can also check blittern 
with it, and update the sprites, etc etc ... In short, copper is very 
anvanbar, but still pretty easy to use! 
   Its simplicity is that it only has three (3) instructions. WAIT; 
MOVE and SKIP. Copper instructions consists of a LONG WORD, or two 
Word. 
   If we start with the instruction WAIT. With it you can wait for the video - 
beam to reach a certain position on the screen and where tex change palettes, or 
something else fun. The two DOC looks like this: 

                                   Word 1 

Bit 0 - Always set to 1 (this plus bit 0 of word 2 is the actual 
            instructional identifier). 
Bit 1-7 - Horizontal stralposition the wait. 
Bit 8-15 - Vertical stralposition the wait. 

                                   Word 2 

Bit 0 - Always set to 0. 
Bit 1-7 - Indicates which bits that must comply with the horizontal 
            stralpositions value. 
Bit 8-14 - Indicates which bits that must comply with the vertical radiation 
            endorsement value. 
Bit 15 - Typically set to 1. (See Hardware Reference Manual for more 
            information.) 

If we take an example of a WAIT instruction, it might look like this: 

    DC.W $ 8007, $ FF00 

This WAIT command waiting for the vertical row $ 80, while 
horizontal postitionen $ 07 is ignored because its bits are zero in the words 2 
($ FF00). 

    DC.W $ A019, $ FFFE 

Here we have held a WAIT command where the horizontal position $ 19 
not be ignored. Here we wait until the position $ A0 vertically and $ 19 
horis. is reached (or excess) before the next instruction is performed. 
   Note that the horizontal value must be odd! Otherwise interpreted it as 
a MOVE command. It must also be within $ 0 - $ e2. 

A MOVE command move a WORD to a hardware register. It can 
such as a color change or a bitplans update. Here is MOVE - 
command's appearance: 

                                   Word 1 

Bit 0 - Always 0. 
Bit 1-8 - Register destination. 
Bit 9-15 - Unused. Ways to 0. 

                                   Word 2 

Bit 0-15 - 16 pieces to be moved to the hardware register. 

MOVE can write to all records of $ dff020. If you have copper 
DANGER bit of COPCON ($ dff02e), you can also write to the registers between 
$ dff010 and $ dff020. 
   To change the background color to white, we write to COLOR00 ($ dff180). If 
we did it with the processor, it would look like this: 

    MOVE.W # $ FFF, $ DFF180 

But with copper MOVE, it will be: 

    DC.W $ 0180, $ 0FFF 

Finally, we have SKIP command. It is used not very much, but for 
the sake of it, we do not skip it. 
   SKIP is fairly similar to WAIT. The check was also the video beam is located, 
and if the position is equal to or greater hope over the next instruction. 

                                   Word 1 

Bit 0 - Always set to 1. 
Bit 1-7 - Horizontal stralposition the wait. 
Bit 8-15 - Vertical stralposition the wait. 

                                   Word 2 

Bit 0 - Always 1. 
Bit 1-7 - Indicates which bits that must comply with the horizontal 
            stralpositions value. 
Bit 8-14 - Indicates which bits that must comply with the vertical radiation 
            endorsement value. 
Bit 15 - Typically set to 1. (See Hardware Reference Manual for more 
            information.) 

SKIP can, for example, used to skip a strobe-writing to COPJMP2 as 
makes copper List 2 begins. Are people like that shark on how it works 
you can create snitsiga copper loops for fun effects. I will 
However, do not go into detail here. 
   If you still do not really understand how copper list is built can 
you look at examples-source. There is a copper list well documented. 

This was what I was going to take up the registervag here in Lesson 1. As I said 
advance is all hardware registers well documented in the Hardware Reference 
Manual, and it SHOULD you have if you want to familiarize yourself with Amigans opportunities 
in the demo programming. 


                                    Setup 
                                    ????? 
Program example of this lesson is very simple, but I thought 
I would start from scratch, so that all related to properly. 
   In short, the program just up the demo "interface", ie that the 
turn off Amigans multitasking system and switch to a separate screen. 
   What I do in my INIT routine is as follows -> First I get something 
called VBR (Vector Base Register). VBR is not on the usual 68,000 
processors, but only at 68,010 and upwards. It is an offset to your computer 
Interrupt and exception registers on a 68,000 are in the beginning of memory. 
The purpose of VBR is that you can move these Interrupt and 
exceptions to register FAST MEM to the computer will be faster. Because 
It is important that its programs do not suppose, for example, vertical 
blanking interruptet is $ 6c address without having to check what VBR - 
the register is set to view the relative from the address plus $ 6c. 
If you think this seems complicated, it's not so bad. Learn just 
, to retrieve VBR in its program to make it work. 
   The next step is to turn the multi-task no. Nothing to speak of. If you want to 
make the coolest routines, and unfortunately stealing all processor 
self .... 
   After that comes a little atypical and temporary conditional routine (which you choose if 
you want by changing the variable DisableCache in early 
program). Routine turns off the cache on computers that have been there (but not on 
machines with KS1.3 or less ...) and why should you do it? Well, 
instruction cache can be trouble for it sometimes when decrunching, also 
data cache, so the best is to turn it off, if you do not use 
its speed in the program. 
   After that I open graphics.library and run OwnBlitter () to take 
blittern over from the system. Then we drive WaitBlit () to wait until we 
got it. After we make a Load View (0) so that we can put our own 
copper list. For safety's sake, we also expect to WaitTOF (twice 
if usern run in interlace ...). 
   Since we have no interrupt at this time to clear only 
Interrupt Control Register. We also clears DMAn (but we 
later ...) 
   Now there are even a conditional part, DisableMotor. An annoying thing 
when you turn off the Interrupt and multitasking is to drive the lamp can sometimes 
continue to shine when the demo runs. This routine quench it by 
turn off the engine. 
   As we return from INIT routine, I will put the DMA I want. 
For the sake of simplicity I have written it (vertically) as the various pieces 
stands for, so that it will be easier to see. What I do is to put on 
only COPPER DMA. 
   Then I put it my own copper list and write to the strobe register 
I told you about at the beginning, COPJMP1 ($ dff088). 
   Main loop contains only a small nonsense routine as changing the background color. 
The loops until you press the left mouse button. 
   After running my UnInit-routine. You could say that it does exactly the opposite 
what INIT routine does. First we restore the old interupt and DMA, then gives 
we blittern back to the system and after we got back 
old view port and the two copper lists used by the system. 
   Now it's just to close intuition.library + graphics.library and (if 
we shut of it) then we restore the cache. 
   Finally, we turn to multi-task again. 
   Much more is there to say about this simple program. Studying the 
carefully and watch how it works. 


                                   Questions 
                                   ?????? 
If there is something you do not understand or who you are, I reply more 
than happy to your questions. Ideally (if you have access to the modem) through 
that you are calling 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 April 24, so make sure you call and when 
download it! 
   Now it was the end of this time! Cynez!