- SEPTiC DEMO'S COLLEGE -- 

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

                                  07 May 93 



                                  Introduction 
                                  ????????? 
Finally time to show pictures! It is well now it is becoming a little more 
interesting ... In this part should I go through how bitplansgrafik works 
and how it demonstrates a simple 32-color image. 
   The first two sessions does not seem to have been no major problems. I 
anyway, I have not had a single question about something, and it is just 
well, for it must mean that I teach everything very well! (Right?) 
   I also introduces a new header (which follows directly below) that will 
to consider what we do in theory. So far have all been pretty obvious 
but in the future, it may be a bit tricky, and an important thing to 
you should be able to program a thing is to understand how it works. 


                                    Theory 
                                    ????? 
A demo would not be much to be if not bitplansgrafik existed. The 
would be no texts, no still images or moving images 
(Bob's, vectors, etc. ..). It was brief, only music and 
best, a couple of copper bars! Therefore, we must be eternally grateful for that 
we can display graphics, and the very simple too! This is Amiga, and we 
need just the slightest effort to show a small picture. 
   But, first and foremost, what is a picture? - As you know, understands the computer 
just ones and zeros. We combine these, we binary numbers, 
that can represent decimal or hexadecimal numbers, which we think is 
easier to deal with. The graphics context, it is easier to talk 
about binary numbers instead of decimal or hexadecimal. In an image correspond 
zero a blank pixel and Ettan a way pixel. A number of winners in memory provides 
Thus a long straight line in the picture. 
   Now you may wonder how only zeros and ones can do so many 
colors Amigan can deliver. Then we introduce a new concept that perhaps 
sounds familiar -> bitplan! With the help of several bitplan we can combine our 
ones and zeros so that they can represent pixels of different colors. 
   This may seem a bit mysterious until you understand how it works, but 
Overall, based on a fairly simple principle. 
   The simplest form of image is 2-color image. It has only ONE 
bitplan containing ones and zeros, where zero represents 
the background color, and Ettan corresponds to the color 1. 
   If we now add a bitplan so we have two bitplan in our image can 
we suddenly draw with FOUR colors. This is because we can get four 
different combinations with our bitplan. 
   If we eg look at the pixel top left of our image and look 
we are a one of the first bitplanet and so we are looking at the pixel furthest 
up to the left in the second bitplanet and see yet another one. A number one on both 
points for the coloring three! 
   , We are adding yet another bitplan with a studio where we have suddenly color 
SEVEN! 
   How bitplanen combined to produce different colors can easily be checked 
by giving each bitplan a special value. Bitplan 1, the value 
1, bitplan 2, the value 2, bitplan 3 value 4 etc.: 

            BITPLAN VALUE 
            ------- ----- 
               1 1 
               2 2 
               3 4 
               4 8 
               5 16 

   When we then going to find out what color it is telescopic is only luck and 
Order on each bitplan and add to its value only if the piece is set. 
So if a piece is set in bitplan 3 and bitplan 5 only, will total 
value: 4 +16 = 20 Thus, color 20! If we take another example, where a 
bit is set in bitplan 1, a bitplan 4 and one in bitplan 5: 1 +8 +16 = 25 
Color 25! Very easy once you can ... If it takes 2 raised the number of 
bitplan so may also be the maximum number of colors. It might be good to 
know ... 

   It can be very difficult to understand how bitplan and things fit together in 
Top ... Usually we do not understand it until later on, and to start 
Having enough to know how to show pictures, not how they are structured. 
   Hope you understand about how it works, for now we are jumping on to 
the records we need to show a picture ... 


                                  Register 
                                  ???????? 
To view an image, you need only turn on BITPLANS-DMA in 
DMACON ($ dff096). Amigan will then cheerfully to show what it knows of (well, 
in almost all cases, but it is not beautiful ...) because it has not received 
any information at all on our image. 
   What we need to do is to point to our image, giving Amigan the right 
the colors and dimensions of the image and then it's done! 
   Like everything else DMA-related shit, all the graphics to be in 
CHIP-mem to be displayed. It makes the simplest by the command SECTION 
DATA, DATA_C, so eliminating the need for increasingly tough minnesallokerande. 
   First we talk about where we have our picture. You have to indicate where each 
bitplan lies and enter all the addresses in the registers BPLxPTH 
($ DFF0E0-$ DFF0F4). Like all DMA-pointers, it must be updated each 
vertical blanking, so naturally we allow copper handle it. 
   We must also specify what screen mode we want to show the picture. We do this in 
Register BPLCON0 ($ DFF100). It looks like this: 

    BIT # BPLCON0 Description 
    ---- ------- ----------- 
     15 HIRES High resolution, 640 pixels wide. 
     14 BPU2 These three pieces indicates the number bitplan 
     13 BPU1 to be used when the image is displayed. They can 
     12 BPU0 include everything from value 0 to 6. 
     11 HOMOD HAM-mode! If you see a HAM-image to this 
                     bitten be set! (Otherwise, the image fuuuul ...:-) 
     10 DBLPF double play fields, can be used to make 
                     parallax scrolling very easy. 
     09 COLOR Composite Color on. (For genlocks-color, I have for me 
                     or INS stuff ... I always have it on!) 
     08 GAUDE Genlock on. Enabling them to genlock to 
                     run a television picture on the background color. 
     07 x Unused. 
     06 x 
     05 x 
     04 x 
     03 LPEN For use by light pen. 
     02 LACE Interlace mode. 
     01 ERSY External resync. Best not to mess ... 
     00 X 

After we specified screen mode will we enter the horizontal 
scroll code, the register BPLCON1 ($ DFF102). 
   If you're going to the hardware scroll their screens use this registry for 
to move the screen 1-16 steps. We will only show a still picture, so we 
the BPLCON1 to its normal value, 0. 
   The Register is as follows: 

    BIT # BPLCON1 Description 
    ---- ------- ----------- 
     15 x Not used. 
     14 x 
     13 x 
     12 X 
     11 X 
     10 X 
     09 x 
     08 x 
     07 PF2H3 horizontal scroll code for regular bitplan. 
     06 PF2H2 "" "" " 
     05 PF2H1 "" "" " 
     04 PF2H0 "" "" " 
     03 PF1H3 horizontal scroll code for the odd bitplan. 
     02 PF1H2 "" "" " 
     01 PF1H1 "" "" " 
     00 PF1H0 "" "" " 

As you can see the odd and even bitplan have different scrollcoder, and it is on 
That way you can get a picture of WOW to share themselves. I will in the next 
lesson going into more of how this register is used and make a program - 
examples that show you how to practice. 
   The further a similar registry, called BPLCON2 ($ DFF104). The 
take care of priority between bitplan and sprites, and even bitplan / bitplan, 
but we do not need to use (than) as it saves me you a briefing 
off. We just put it to zero. 
   Now it's DAX to talk about how wide the screen is. We do this by entering 
start and end on the screen in the registers DDFSTRT ($ DFF092) and DDFSTOP 
($ DFF094). 
   They exceed 8 bits in the two registers are not used, nor the 
two lowest, bits 0 and 1, so it should not be wasting on you :-). 
   There is a simple table which is good to follow when you want to specify 
its screen width: 

    DDFSTRT (Left start position) 
    ------------------------------- 
    Fashion Bits-> H7 H6 H5 H4 H3 H2 H1 H0 
    ---------------------------------------- 
    Extra wide (max) 0 0 1 0 1 0 XX = $ 28 
    Wide 0 0 1 1 0 0 XX = $ 30 
    Normal 0 0 1 1 1 0 XX = $ 38 
    Narrow 0 1 0 0 0 0 XX = $ 40 

    DDFSTOP (Right-stop location) 
    ---------------------------- 
    Fashion Bits-> H7 H6 H5 H4 H3 H2 H1 H0 
    ---------------------------------------- 
    Narrow 1 1 0 0 1 0 XX = $ C8 
    Normal 1 1 0 1 0 0 XX = $ D0 
    Wide (max) 1 1 0 1 1 0 XX = $ D8 

   Selecting Normal in both places so we'll have a 320 pixels wide screen. 
We choose extra wide and wide, we 368 pixels wide, thus overlooking scan. 
Imagine that Normal is 320 pixels and then add to (or subtract) 16 
pixels for every 8 that you add to (or subtracting) to start or 
end position ... So if we have Normal, $ 38 and $ D0, which is 320 pixels 
broad, and we want to increase the screen width by 32 pixels, then we increase 
starting position with 8 and the end position by 8 and we have a screen on 
352 pixels wide. 
   Then we must also talk about how much we want to show the screen. We do this 
in the registers DIWSTRT ($ DFF08E) and DIWSTOP ($ DFF090). The highest 8 bits are 
the vertical position, and 8 is the lowest horizontal. On a normal 
screen, it is customary to bring vertical take-off position to $ 2C and horizontal 
start position to $ 81, which when you add them will be $ 2C81. The 
normal vertical end position tends to be $ 12C, but because we only have 
8 bits, there are the not so successful, because we will handle values up 
to $ 100. No problem, in the vertical end position acting Amigan always 
as if the ninth bit was set, so we only need to enter the century $ 2C, so 
it will be automatically $ 12C! (The stupid with this is that we can not 
specify the final positions over $ 80, then around on the top half of 
screen ...) 
   The normal horizontal end position tends to be $ C1, and the two rates 
together will be $ 2CC1. 
   If you want you can play with these figures a bit of copper list to see 
how it works, and how the image is affected. 
   So, now it was just a little thing left - Modulo! 
   Say that we have drawn a great image that is 512 pixels wide in 
lagupplosning and want to show it in our giant fun demo. We are looking at 
DDFSTRT and DDFSTOP and finds that the maximum screen width is only 368 
pixels! Hu, huh awful! - But, how lucky we have Modulo then! Modulon 
namely, talking about how much Amigan should skip to the end of a series of 
To get to the start of next! 
   If we take our little image, 512 pixels wide, which is 512 / 8 = 64 bytes (we 
counting almost always in bytes, not pixels) wide. We set our screen to 
width 368 pixels, which is 368 / 8 = 46 bytes. It is now modulon coming in, 
and to indicate how much we should skip. We have read 46 bytes now and 
come to the end of the screen, but there is still a part of our 
image that was 64 bytes wide. To get to the next line, we must 
skip the bytes that are left, just 64 bytes minus 46 bytes = 18 
bytes. We have a Modular arithmetic of 18 bytes. 
   Modulon entered in the registers BPL1MOD ($ DFF108) for the odd and bitplan 
BPL2MOD ($ DFF10A) for regular bitplan. 
   A small parenthesis: Earlier we only spent BACKGROUND COLOR-Register 
COLOR00 ($ DFF180). In order to bring the other 31 colors, using the 
subsequent registrena: $ DFF182-$ DFF1BE. 
   Well, that was all the records we need to get a picture. 


                               Program example 
                               ??????????????? 
A very simple program this time. Showing the simplest type of 
image, 320 pixels wide, 256 pixels high lagupplosningsbild, not completely 
unknown, but actually the winning image from The Party II in Aars. Thought 
it was better suited than any picture that I could write myself ;-) 
   The most common image format is the IFF, for example, saving Deluxe Paint all of its 
Photos of the IFF, but it takes the format does not really Amigan the slightest. 
You should show it on screen, it must be converted to the RAW format. The 
can you do with any of the variety program that can do it ... Tex, 
Kefrens IFF Converter, IFF-Master, PixMate mm .... 
   If you want a program that converts IFF -> RAW so use a small 
letter to me (for I am not going to sit and uploads if no need 
program anyway!). 
   The two new routines in the program are two simple things. One routine 
set pekarna on each bitplan in the picture, and the other is right 
colors. 
   If we start with the first routine, SetBplPtr. Where are we first in 
A0 so that it points to the picture beginning, and then moving into the address in 
D0. This we must do to be able to use the SWAP. 
   Then, we point to bitplanspekarna in copper list, where we will enter 
bitplanens started addresses. 
   Since copper can only move one word, 16 bits, at a time and our 
address to bitplanet is 32 bits, copper must do the update of 
bitplanspekaren in two steps. That is why we first move in the 16 lowest 
pieces and then, using the SWAP, changing the 16 pieces to the top 
16 lowest in the D0 and enter the maximum of 16 pieces of copper list. 
   After we add the entire bitplanets size of the D0, therefore, the width 
in bytes times the height. 
   Then, we are increasing at A1 by 8 to get to the next place in the copper list 
and then loops back. 
   The second routine, SetColours, based on that we saved the IFF's image as 
RAW with palette after. Then we can read 32 words there, because our image has 
32 colors, and in turn bring them into the copper list. 
   If we look a little further down the source, on the copper list, so you can see how 
I set the records that I went through in the Registry chapter. 
   First I DIWSTRT to $ 2C81 and DIWSTOP to $ 2CC1. Then put 
I am the normal DDFSTRT and DFFSTOP values, $ 38 and $ D0. After the talk 
I am about how many colors the picture has, 32 colors, then 5 bitplan. Number two in 
$ 5200 indicates that I want COLOR fashionable. 
   Then I reset both BPLCON1 and BPLCON2 and put both smooth and 
odd Modular arithmetic zero because we have a 320 pixels wide screen and our 
picture just is 320 pixels. 
   Then follow the five bitplanspekarna, and where can I make sure I enter 
the 16 highest pieces first and then the 16 lowest since copper is not 
can move more than a word with the MOVE command. 
   After going 32 MOVE command, which puts all 32 colors 
to zero. This is where I enter the correct colors of the routine 
SetColours. 
   It was the only new things in programvag I do not raised before. 
Next time do we raise a little more fun stuff of bitplansgrafik, so stay 
you to steel! 


                                  Challenge 
                                  ???????? 
Yet another new low header, which accounts for a small additional section of the course. 
There is a section most of those who believe themselves to master the things I've taken 
up, and want to test their skills a little. (Even for beginners who may 
learned at an approximate and want to try a little on their own.) 
   In this first challenge, I would like you do on the program so Lekt3.s 
that the picture gently fade in and out, instead of just PLOP forward. So 
to make a FADE! 
   You should start from a black Palette and fade in the colors of the Palette 
so that the image will appear soft. Regardless of whether you succeeded, or just trying 
a little but did not have it work, I would like you to upload your 
attempt to base so I can get a little interesting to watch. 
   How to fade'ar a picture, I take up in the next lesson, and then I will go 
into a little more difficult imaging and special tricks, too. 


                                   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 on May 22, so make sure you call and when 
download it! 
   Now it was the end of this time! Cynez!