"Idiot Guide to BOBS"



                           IDIOTS  GUIDE 1
                           ~~~~~~~~~~~~~~~
                        MAKING AND USING BOBS 
                        ~~~~~~~~~~~~~~~~~~~~~
                          By Tony Greenwood
                        For  STOSSER DISKZINE
                        ~~~~~~~~~~~~~~~~~~~~~

The expression "Idiots Guide" is not an insult, when i started 
learning basic i used an idiots guide in the form of a book i took out 
of the local library.  The first paragraph stated that "We treat you 
like a novice, we presume you to know absolutely nothing about 
computers".  If it were not for that book then i would be a stamp 
collector, train spotter or have some other hobby rather than 
computing. 

Well i am not going to go that far, I will presume you to know how to 
use your computer, I will also presume you to know how to use STOS to 
a certain extent.  But i presume you to know nothing about whatever 
subject the idiot guide is covering.  This month it's  the Missing 
Links BOB commands. 

If anyone wants an idiot guide to ANY subject relating to STOS then  
get in touch and we will sort it out for you.  Can't say fairer than 
that now can we?. 

 
First off BOB 

What is a BOB?, a sprite is the simple answer, but we all have to  
agree that sprites can be slow, jerky, unresponsive, and a little 
limiting.  I would have to say that there are two main advantages of  
BOB against sprites.  The first being SPEED, and the second being the 
amount of BOBS you can have and control on screen at any given time.  
There are other advantages of course but these in my opinion are the 
main two.

If you are making a program that just uses a sprite or two and nothing 
much else is happening on screen, then there probably is not much  
point in using BOBS.  If however you want a main charactor and  
20, 30 or 40  baddies whizzing round then BOBS and JOEYS are for you. 

If you are going to use BOBS or JOEYS then forget everything you know 
about sprites as there is no comparison.  You cannot use string$ to 
animate BOBS and JOEYS so no ANIM command or similar.  Also no MOVE 
commands.  All your animations and moving has to be done using 
variables, but it is well worth it!.

Although the MISSING LINK extension is without doubt the best thing to 
ever happen to STOS.  I think you will agree that the accompanying doc 
file (instructions), leave a lot to be desired for the low to medium  
experienced STOS programmer.  I have to admit that i found it more 
than a little daunting at first ( second and third ) glance.  I would 
personally place myself in the medium catagory of STOS programmers. 
Therefore this is not the definitive guide, but hopefully helpful.

One of the things that "got" me about the missing link doc was the 
constant reference to "presuming your bob data is in bank 5".  But  
with no explanation of how to get it into a bank.  So the first thing 
we are going to do is make some BOBS.

Load up your STOS sprite editor, this is normally an ACB but you may 
have it as a BAS file.  Once loaded you will need to design a sprite,  
or preferably a series of sprites for us to animate.  Set the size to  
32x32.  This is for our examples, and contrary to belief is not the 
BOB size limit.  Just for arguments sake lets make a ball,  start with 
a small ball then make some larger versions of it.  Make five 
altogether, then if you can imagine it we will animate it to bounce 
along as if we where looking from above, not an inventive idea but 
will serve our purpose for now. 

Once you have drawn the five images of the various sizes of the ball 
then save it out as BALL.MBK.  Just the normal sprite bank that you 
should already know how to do.

In order to convert this into BOB then we must use the MAKE.BAS/PRG. 
The make comes as a basic file but can be compiled or can be renamed  
to MAKE.ACB as i have done.  Whatever you have it as, i want you to 
now run it. 

You should now be confronted with a black screen with a series of drop 
down menus.  Find LOAD and click on SPRITES.  Using the fileselector 
click on your BALL.MBK and seconds later your previously designed 
sprites will be loaded. 

Now we are ready to begin, place your mouse over the MAKE at the top 
of the screen and a menu will drop down.  Click on BOBS, you will then 
be confronted by the words 

                        MAKE BOB DATA
                        IMAGES
                        QUIT

Placing your mouse over the word MAKE BOB DATA will obviously make the 
BOBS, but wait!!.  This is where we get down to the nitty gritty, its 
the IMAGES option that BOBS is all about.  This is the whole idea of 
using BOBS.  I will need to explain why and what its all about, you 
will need to read the next bit very carefully.

You will by now have noticed that there is a 16 pixel boundry to your 
graphical operations onto your screen.  For example if you SCREENCOPY  
a picture to the screen for viewing at X coordinates 0 then the 
picture is copied to the screen exactly where you want it.  If you 
copy to the screen at X coordintes 1t then again it will be alright.  
But you cannot copy to X coordinates 1-15.

Lets say you have a picture in bank 5
eg 1: 

SCREEN COPY 5,0,0,320,200 to PHYSIC,0,0 

Will take your picture from bank 5 and place it onto the screen.
  
eg 2: 

SCREEN COPY 5,0,0,320,200 to PHYSIC,16,0

Will take your picture from bank 5 and place it onto the screen 16 
pixels to the right leaving a 16 pixel wide blank space down the left 
hand side of the screen.
  
eg 3: 

SCREEN COPY 5,0,0,320,200 to PHYSIC,15,0

Will have the same result as eg 2 because you cannot use X coordinates 
other than multiples of 16 ie: 0,16,32,48,etc etc....

So STOS had to overcome this problem in order to be able to move 
sprites around the screen.  STOS takes the sprite you want to display,  
takes the co-ordinates you want to display it at, then scrolls it over  
to that position then displays it.  So lets say you want a sprite to 
be placed on the screen at 7 pixels across.....  

SPRITE 1,7,100,1,  

STOS will take the sprite to an area you cannot see ( Buffer ), and 
place it at POSITON O,100 (thats 0 across and 100 down).  It then 
scrolls it 7 pixels to the right until it is at the desired 
co-ordinates, then copys it to the screen.  As far as the 
user/programmer can see, it is just placing the sprite at exactly the 
X co-ordinates you wanted it to.  But it has been PRE-SHIFTED, and 
that basically is what PRE-SHIFTING is all about.  I am sure you have 
heard the expression before so now you know.  The problem with SPRITES 
is that the PRE-SHIFTING is being done everytime you use the SPRITE 
command.  So lets say you have ten sprites on the screen at all 
different positions, then STOS has to do all that preshifting all the 
time.  This is using valuable computer time ( Processor time ), which
is why you will start to find your SPRITES getting slower and jerky 
if you start to use too many of them or the few you are using are 
large sprites.  Put simply, you are overworking the system as STOS 
just does not have enough time to do all that preshifting.  Hence the 
limit of how many sprites you can have on the screen.

Hopefully you now understand a little about preshifting.  The 
advantage of BOBS is that we can do all that preshifting before we  
even save the sprite/BOB.  As you can imagine, this will speed up your 
program to the point of no comparison.  If you have a program/game 
that uses 10-15 sprites on screen at once you will know how bad it 
looks.  By replacing all your sprite commands with the new BOB 
commands you will not only see the difference but could add another 
10-15 or loads more BOBS to the same routine and it would still be 
faster than your original using sprites, faster and smoother.

Back to the MAKE, place your mouse over IMAGES and press the mousekey, 
you will then be confronted by yet another set of words. 

  IMAGES number
  SPRITE number
  COPY TO ALL
  END
 
Place your mouse over SPRITE and click the right mouse button, keep it 
pressed then do the same with the left mouse button.  You should see  
your sprites of the ball you made in the top left corner.  So using  
left and right mouse buttons you can choose each individual sprite to 
pre shift.  Now doing the above i want you to have SPRITE 1 showing.

Now move your mouse over the IMAGES and do the same with the mouse 
keys and you will see the number changing from anything between 1 and 
16.  These are the number of images, as you will have gathered this 
means we can have different amount of images for each sprite/BOB.

An explanation is now needed of how many images we want, as we now 
know there is a 16 pixel boundry we have to figure out where we want 
our sprite/BOB to be, lets say the ball is going to move very fast

 eg:10 X=0
    20 FOR N = 0 TO 20
    30 SPRITE 1,X,100,1
    40 X=X+16
    50 NEXT N

This would send your sprite across the screen very fast and only need 
one image as no pre shifting would be needed.
   
*** NOTE I HAVE USED THE SPRITE COMMAND PURELY FOR EXAMPLE REASONS ***
       *** AND WE WILL GET ONTO THE ACTUAL BOB COMMAND LATER ***

   The same routine but with line 40 changed to
    40 X=X+8 :rem would need 2 images 
    40 X=X+4 :rem 4 images
    40 X=X+2 :rem 8 images
    40 X=X+1 :rem all 16 images would be needed

Lets say you have a whole bank full of sprites and some are going to 
be moving slowly (1 pixel at a time) then you can have these at 16 
images.  But lets say some are not going to move at all.  Depending on  
their set co-ordinates then you could just have one image.  Why not 
have them all at 16 images and have done with it?.  Well because we 
are pre shifting them.  Therefore in the bank, unlike sprites that  
have one image then are preshifted.  We have already pre-shifted them  
and therefore have all the images needed in the bank.

Lets say we now click on IMAGES 16 for all our 5 sprites of our ball, 
then  save.  We would have a bank not containing five images of the  
ball, but 5 times 16 images of the ball, a rather large bank. 
Especially if you are making a game that needs 20-30 or so 
sprites/BOBS and make them all 16 images.  This is probably the only 
drawback that you can end up with very large banks, but believe me 
the performance and speed of BOBS will make up for it. 

Back to MAKE, and we are ready to make some BOBS, first we decide how 
fast we want the ball to move.  16 pixels at a time would be too fast  
and unviewable as it whizzes accross the screen.  Lets for arguments 
sake make it move at four pixels at a time, a nice easy speed.

We want all images to move at 4 pixels, so using the left and right 
mouse buttons you should click on SPRITE until you see number 1,  then 
click on image until you see number 4.  Then repeat until all five  
images of the ball have a corresponding 4.

                               IMAGE 4
                               SPRITE 1 etc etc......

You can as a short cut set SPRITE 1 to 4 IMAGES then click both mouse 
buttons at once and all your SPRITES will be set to 4.

When you have done that then click on END, this just ends this section 
and not the whole program, you will then be back to the screen that 
looks like..... 

                         MAKE BOB DATA
                         IMAGES
                         QUIT

Well we have done IMAGES so now click on MAKE BOB DATA, you will then 
be able to see the SPRITES of the ball being pre-shifted.

When its finished click on QUIT, again this just quits this section 
not the program.

You should then be back to the main screen and the drop down menus, go 
to the SAVE sections and click on BOBS.  A few seconds later and you  
have your bobs saved to disk.......hoooray!

HOW TO USE THEM

Before i start there are a couple of things to point out, the most 
important is when you are calling your BOBS from a bank.  You can load 
your BOBS into any bank you wish 1-15, but whenever you mention the 
bank in your command then you must call the actual address.
 
For all the examples below i will use bank 5, but we have to call the 
bank as START(5) and not simply 5.  This is how you call an actual 
address, plus calling your banks in this way is good programming  
practice for all bank operations especially if there is any eraseing 
or reserving banks in your program.

To add a little extra speed then using a variable is even quicker for 
all such bank operations eg:  S5 = START (5).  But again if after you 
have assigned this variable you then erase or reserve a bank then S5 
may not  = the  start of bank 5.  The best pratice would be to set up 
all your banks then set your variables for the banks.  It is slightly 
faster, by faster i mean takes less computer time.

To get the correct colour of your BOBS ( Palette ) you will need to 
use VARIABLE=PALT(START(BANK)).  So in our routine we could have 
something like P=PALT(START(5))

    Right lets start the routine

10 KEY OFF:MODE 0:CURS OFF:HIDE ON etc etc :REM normal set up
20 BOB 0,0,320,200,0,1 :REM set clip zone, this is the area that the 
                        bobs will be shown in.  If you only want your 
                        bobs to be shown at the left hand side of the 
                        screen then just set the clip zone smaller.  
                        The first four numbers are the area that the 
                        bobs can be viewed in.  The last two numbers 
                        0,1 i have no idea.  As far as i know they are 
                        there for possible future updates by the 
                        makers of the missing link.
30 P=PALT(START(5)) :   REM get the colour of the BOB if you want to,  
                        P could have been any variable you want.
40 S5=START(5):         REM assign variable to bank for ease of 
                        programming and maybe a little extra computer 
                        time.
50 BOB LOGIC,S5,0,96,96,0:  REM BOB tells us we want a BOB. LOGIC 
                        tells us where to put the BOB, this can be 
                        any screen, physic, back, or a bank thats been  
                        reserved as a screen.  0 tells us the image  
                        we want, remember when you made the sprites 
                        they where sprite 1, 2, 3, 4 and  5, well when 
                        we used the make program, they where all 
                        renumbered down one.  So they are now numbered 
                        0, 1, 2, 3 and 4.  Again this is good 
                        programming sense by top notch and good 
                        programming practice for us.  You should know 
                        that all computer operations start from 0.  
                        When you dim an array it starts from 0: when 
                        you use a loop its normally something like 
                        FOR N=0 TO number.  So for the first bob we 
                        call it as 0 and the second would be called 
                        as 1 etc etc.  96,96 are the x and y 
                        coordinates to place the BOB.  The last 0 is 
                        again nothing to concern yourself with as no 
                        one knows what its for. 
  
Hooray we have made a BOB and placed it on the screen. 
Phooey its not doing much is it.

Add these lines to the above routine,

45 LOGIC=BACK :         REM work on back screen where no one can see 
                        us.
46 X=96:Y=96:IMG=0:TM=0:REM variable for coordinates and img and a 
                        timer?.
47 REPEAT :  WIPE LOGIC:REM start a loop and clear the screen we are 
                        working on.  Wipe is so much faster than CLS 
                        that its hard to compare.  Twice as fast would 
                        be a gross understatement.  We need to wipe it  
                        every time or the BOB would leave a trail as 
                        unlike sprites, it doesn't erase itself.  You  
                        could also use WASH that will let you set a 
                        small area to clear.  But this doc is about 
                        BOBS not clearing the screen so use WIPE for 
                        now.  If you are moving your BOB across a 
                        picture then simply replace WIPE LOGIC with  
                        something like FASTCOPY PICTURE FROM BANK TO  
                        LOGIC.  Suppose you have a picture in bank 7,  
                        FASTCOPY START(7),LOGIC very fast screen copy!
48 IF JRIGHT THEN X=X+4:REM obvious!
49 IF JLEFT THEN X=X-4 :REM just as obvious
60 INC TM:IF TM>20 THEN TM=0 :INC IMG :  IF IMG>4 THEN IMG=0 :REM If 
                        we simply increased image then it would go far 
                        too fast, so the timer is to slow it down, if 
                        still too fast then change 20 to a higher 
                        number, if to slow then change 20 to a lower 
                        number.
100 SCREENSWAP : WAITVBL: UNTIL HARDKEY=57 : DEFAULT :END :REM check 
                        for spacebar being pressed and end.
  
CHANGE line 50 to BOB LOGIC,S5,IMG,X,Y,0

You should now be able to move your ball left and right with the 
joysticK and it should be animating.  You will notice that there has 
been no mention of up down, well there is no 16 pixel boundry for up 
and down so no problem.

Well has this helped you make a start with BOBS, alright i havent told 
you how to make a full blown game with them.  But there is enough to  
get you started and certainly more info than the missing link doc 
gives you.  No real complaints about the doc because with the amount  
of exellent commands, it would take something bigger than war and 
peace if they were to go into this much explanation for each command,  
so i am not knocking the top notch missing link doc.  

This article has taken me a long time to make and wasn't the easiest 
thing to do.  I will make another idiots guide on any subject you want
but i am not going to write one if no one is going to read it.  So 
what i am saying is if you ask for an idiots guide to a subject or 
command then i will do it.


                       Tony Greenwood 05/05/94 


To STOSSER Home Page