    This file contains two parts. The first is SpaceMission
technical support and the second is a short history lesson
about Barbarian Minds Software.  Of course nobody is going
read the second part but it's included anyway!




***********************************************************
***********************************************************

             Part one - Space mission technical support

***********************************************************
***********************************************************

    Although I have written many programs in the past, I'm
quite proud of this one.  Not that it's the best thing ever
coded but it turned out to be quite a reasonable game.  Most
important of all, it is the best ORGANIZED program I 've ever
written.  I spent more time with a pen and paper than with the
computer.  When I had my ideas written down in a clear manner,
all I had to do is to punch it in.  At the end, I had only one
bug to face!  But that is what good programming is all about.
Planning ahead of time.

    If you expect to find a line by line technical report here,
forget it.  I don't have the time to explain a 20k program and
another 30k of data line by line.  Instead, I hope to describe
the main ideas behind SpaceMission and how they were accomplished
in AMOS.
    Another thing, this doc will not be much help to advanced
programmers, as it is more suitable for novices who are trying to
build better programs.  Let's get down to some brain work!




  Leading concept: Dynamic Allocation.
  -----------------------------------

    The Leading idea behind the whole program is Dynamic
allocations.  "What the hell is that?" I can here some of you
say.  Well, imagine you are standing in a bank with 16 clerks
(big bank).  Every customer goes to one of the windows, and
when he finishes his actions HE FREES HIS POSITION TO THE
NEXT IN LINE.

    That is what Dynamic allocation is all about. Freeing an
unused position to someone else. The need to free locations comes
when we are limited in resources. If that bank had an infinite
amount of clerks, the customers would simply stand in their
positions forever and let the others be served by other clerks.
That is really an ideal situation, since in order to Dynamically
allocate you need two actions.  The first is to free the location
and the second is to fill it with the next in line, while in
infinite mode you only need one action (filling the next in line
in.)

    What has that got to do with SpaceMission?  If you think of
the game for a second, you probably remember quite a large number
of ships attacking you.  Now, AMOS can handle only 16 AMAL
interrupts at once.  If I intended to move the Bobs using
interrupts only, I would be able to handle only up to 16 bobs.
That is where dynamic allocation comes in to play.  In
SpaceMission, each bob is turned off when it finishes its
movement sequence, freeing its interrupt to the next bob in line.



  Putting it into code.
  ---------------------

  Well, In Space-mission, I used a 15 elements long array in order
to maintain the condition of the different interrupts channel. An
element which is equal to one means the channel is allocated
while an element which is equal to zero means an disallocated
channel. Let's say we want to see if a bob finished his movement
so we can disallocate his interrupt:

For _loop = 1 to 15 : Rem We need to loop through the whole
                      Rem channels.
 If _Free_Channel(_loop)=1 :Rem_Free_channel() is the array which
                            Rem Contain the interrupts condition.
                            Rem we want to check only channels
                            Rem which are considered allocated at
                            Rem the moment.
      If ((Chanmv(_loop)=0) And (Chanan(_loop)=0)) : Rem If the
                                                Rem channel
                                                Rem is not moving
                                                Rem or animating
                                                Rem then....
        _Free_channel(_loop)=0 : Rem DISALLOCATE IT!
      End If
    End If
  Next _loop


    That's one part.  Now, how do we allocate?!?! Well, first
we need to find a Disallocated channel and then allocate it:

  _dal_channel = 0 : Rem If a disallocated channel is found,
                     Rem This verible will be different then Zero
  For _loop = 1 to 15 : Rem looping through all of the channels
    If _Free_channel(_loop)=0 : Rem Found a disallocated channel!
    _dal_channel = _loop : Rem get the Disallocated channel into
                             Rem the element _dal_channel.
      _loop = 15 : Rem this little trick causes the loop to
                   Rem Terminate at once.
    End If
  Next _Loop

If _dal_channel > 0 : Rem Ah ha! we found a disallocated channel.
  _free_channel (_dal_channel) = 1 : Rem Allocate it....
End if



  Ok, Here is a complete program which uses this method. It will
display 15 square bobs moving on the screen from side to side.
Notice that after bob 15 no bobs are drawn until a bob leaves
the screen. That's because there are no free channels to
allocate.

(The following example is included on the disk.
The program is called Smex1.amos)


Screen Open 0,320,200,8,Lowres            | Opening a Screen.
Dim _FREE_CHANNEL(15)                     | declaring the array.
  Cls 0                                    \
  Bar 0,0 To 4,4                            \   Getting a small
  Get Bob 1,0,0 To 4,4                       \  square bob and
  Cls 0                                       - resetting the
  For _LOOP=1 To 15                          /  _free_channel()
    _FREE_CHANNEL(_LOOP)=0                  /   array.
  Next _LOOP                               /
  Double Buffer
'
  _START:
'--------------------------------------------------
' Disallocate a channel!
'
  For _LOOP=1 To 15
    If _FREE_CHANNEL(_LOOP)=1
      If((Chanmv(_LOOP)=0) and(Chanan(_LOOP)=0))
        Bob Off _LOOP
        _FREE_CHANNEL(_LOOP)=0
      End If
    End If
  Next _LOOP
'--------------------------------------------------
' Allocating a Channel
'
  _DISALLO=0
  For _LOOP=1 To 15
    If _FREE_CHANNEL(_LOOP)=0
      _DISALLO=_LOOP
      _LOOP=16
    End If
  Next _LOOP
  If _DISALLO>0
    Bob _DISALLO,0,50,1
    Channel _DISALLO To Bob _DISALLO
    Amal _DISALLO,"Move 320,0,320"
    Amal On _DISALLO
    _FREE_CHANNEL(_DISALLO)=1
    Wait 5
  End If
  Goto _START
'
'---------------------------------------------------




  The Actions database - Motor of attack waves.
  ---------------------------------------------

  Let's return to the real `life' bank and look at a day's work.
People come in, finish their business and go out. Now, imagine
you could control those people's actions. Imagine you could tell
them when to get in, what to do, and when to leave. Then you
would get something which could reassemble an attack zone in
SpaceMmission.  Ships come in whenever you decide, move in a
certain form and get out.

    We can divide the process into two parts:
One is timing and the second is movement form.

  First part first. How do we deal with timing? Well, the part in
our program which gets the ships going is the allocation part.
If we will could call it only when we want a ship on the screen
then we are actually timing the ships entrance. For a timer we
could use an increasing counter, but AMOS supplies us with access
to the built in computer timer. 50 ticks of that timer equals a
single second. We will use a few data statements to tell the
computer when to call the allocation routine.


(The following example is included on the disk.
The program is called Smex2.amos)

Screen Open 0,320,200,8,Lowres
Dim _FREE_CHANNEL(15)
  Cls 0
  Bar 0,0 To 4,4
  Get Bob 1,0,0 To 4,4
  Cls 0
  For _LOOP=1 To 15
    _FREE_CHANNEL(_LOOP)=0
  Next _LOOP
  Double Buffer
  Timer=0          : Rem Most important, resetting the timer!
  Restore TIMEBASE
  Read ACTIONTIME : Rem here we read the first action time data
                    Rem piece.
'
  _START:
'--------------------------------------------------
' Disallocate a channel!
'
  For _LOOP=1 To 15
    If _FREE_CHANNEL(_LOOP)=1
      If((Chanmv(_LOOP)=0) and(Chanan(_LOOP)=0))
        Bob Off _LOOP
        _FREE_CHANNEL(_LOOP)=0
      End If
    End If
  Next _LOOP
'--------------------------------------------------
' Check if time for next action arrived  \   Here is the part
'                                         \  where we sequence
If((Timer/50)<ACTIONTIME) Then Goto _START = the ships entrance.
  Read ACTIONTIME                         /
  If ACTIONTIME=30 Then End              / Each wave last a max
'----------------------------------------------  of 30 seconds.
' Allocating a Channel
'
  _DISALLO=0
  For _LOOP=1 To 15
    If _FREE_CHANNEL(_LOOP)=0
      _DISALLO=_LOOP
      _LOOP=16
    End If
  Next _LOOP
  If _DISALLO>0
    Bob _DISALLO,0,50,1
    Channel _DISALLO To Bob _DISALLO
    Amal _DISALLO,"Move 320,0,320"
    Amal On _DISALLO
    _FREE_CHANNEL(_DISALLO)=1
  End If
  Goto _START
'--------------------------------------------------
' The time base
'
TIMEBASE:
Data 3,5,6,8,10,12,13,14,15,16,17,20,22,24,26,30



    As you probably noticed, SpaceMission many movement forms.
Some ships comes from front, others from behind, bullets come
right at you and if you got to higher levels you might even see
ships who move in strange sine pattern.The movement patterns
resemble the second part of the actions base. In SpaceMission,
each data line is divided to two. The first item is the time
of the action, and the others define the type of movement.

    Now, let's decide on two types of movements. The first will be
a movement from left to right, and the other (number two) from the
top of the screen to the bottom.  See how few modifications to the
previous program completes our task?

(The following example is included in the disk.
The program is called Smex3.amos)

Screen Open 0,320,200,8,Lowres
Dim _FREE_CHANNEL(15)
  Cls 0
  Bar 0,0 To 4,4
  Get Bob 1,0,0 To 4,4
  Cls 0
  For _LOOP=1 To 15
    _FREE_CHANNEL(_LOOP)=0
  Next _LOOP
  Double Buffer
  Timer=0
  Restore TIMEBASE
  Read ACTIONTIME
'
  _START:
'--------------------------------------------------
' Disallocate a channel!
'
  For _LOOP=1 To 15
    If _FREE_CHANNEL(_LOOP)=1
      If((Chanmv(_LOOP)=0) and(Chanan(_LOOP)=0))
        Bob Off _LOOP
        _FREE_CHANNEL(_LOOP)=0
      End If
    End If
  Next _LOOP
'--------------------------------------------------
' Check if time for next action arrived...
'
  If((Timer/50)<ACTIONTIME) Then Goto _START
 Read ACTIONTYPE                       - Here we read the action
                                         type (attack pattern)
 Read ACTIONTIME                       - And the time of the
                                         next action.
 If ACTIONTIME=30 Then End
'--------------------------------------------------
' Allocating a Channel
'
  _DISALLO=0
  For _LOOP=1 To 15
    If _FREE_CHANNEL(_LOOP)=0
      _DISALLO=_LOOP
      _LOOP=16
    End If
  Next _LOOP
  If _DISALLO>0
    If ACTIONTYPE=1                      \   The different attack
      Bob _DISALLO,0,50,1                 \  pattern require
    End If                                 | different start
    If ACTIONTYPE=2                        | position
      Bob _DISALLO,100,0,                 /
    End If                               /
    Channel _DISALLO To Bob _DISALLO
    If ACTIONTYPE=1                          - first action type,
      Amal _DISALLO,"Move 320,0,320"           move from right to
    End If                                     left.
    If ACTIONTYPE=2                          - second action type,
      Amal _DISALLO,"Move 0,200,200"           move from top to
    End If                                     bottom.
    Amal On _DISALLO
    _FREE_CHANNEL(_DISALLO)=1
  End If
  Goto _START
'--------------------------------------------------
' The Action base - First data item represent the time
'                   and the second represent the attack pattern.
'
TIMEBASE:
Data 3,1
Data 5,1
Data 6,1
Data 8,1
Data 10,2
Data 12,1
Data 13,2
Data 14,2
Data 15,1
Data 16,2
Data 17,1
Data 20,2
Data 22,2
Data 24,2
Data 26,1
Data 30


  In Space-mission itself, a data line as much more complicated.
For example:

data 200      ,           12     ,       3       ,     200


|the time of  |The action type - | The bob       | The amount of
|  the action.|   for example move    | Index in the  | steps needed
|                 |   move from left to   | bob's bank    | for the bob
|                 |   right.              | To allow      | to get from
|                 |                       | different bobs| left to
|                 |                       | assigned to   | right. this
|                 |                       | the action.   | allow
|                 |                       |               | different
|                 |                       |               | speed assigned
|                 |                       |               | to the action.

  (This is only an example. not an actual part of space-mission.)







  Collisions
  ----------

  In realty, only 12 channels are assigned to the enemy bobs
in space mission. The first bob is your space ship, bobs
number 2 to 4 are the bullets you shot. This mechanism of
deciding what channels are assigned to which function make it
easy to write collision detection routines. For example, if bob
1 collide with anything from channels 5 and above
( col = bob col (1, 5 to 16)) then my ship fried itself on an
enemy ship. On the other hand, if one of my bullets
(channels 2 to 4) hit an enemy ship (channels 5 and above)
then I can smile as the enemy ship burns beautifully into the
dark space.

  This is the real beauty about the whole system. After I let a
bob go, I don't really know what happens with it, I don't have
to keep it's coordinates, and can totally ignore it's behavior.
I *DO* have to make periodical checks to see if it collided
into something. Even when that happenes, I don't really know
where on the screen the collision occurred, neither do I care!
All I have to check is what channel bumped into what channel and
if some result should emerge from it (explosion sound, an
animation sequence, a score update, etc.)  As for how to program
those, well, I will leave this to your vivid imagination.






  Problems during coding.
  -----------------------

  Okay people, let's admit it (and I know some people are not
going to like this statement.) AMOS is relatively a slow
language. No, not compared to other basics but to the more
popular languages such as C and assembler. If I have any sort
of problems in this game it was the speed of its execution.
Since the machine has to control so many blitter objects at once,
the execution of the original program is majorly decreased.  I
started noticing the problem when the bullets went right through
the enemy ships without blowing them up.  They simply passed each
other before the computer got to the collision detection routines.
I had to use an UPDATE EVERY 2 command to make the computer
access the interrupts last (which makes the program run a little
faster) but as the program got bigger, this has also proven to be
of little help. The compiled program does much better, but in some
rare cases it still misses.






    Well, that's about it for the ideas behind the program. There
are of course many more points to look over in SpaceMission, and
many more problems to face, but I trust you'd like to try them
out for yourselves.  The source code, by the way, is available
upon request from me by sending mail either to
broner@black.bgu.ac.il or by snail mail to
    Gal-on Broner
    P.O. Box 5418
    Beer-sheva, Israel.
                      don't forget to add a blank formatted disk
                      inside the envelope.....


*************************************************************
*************************************************************

              Part two - History of barbarian minds.

*************************************************************
*************************************************************

  Barbarian minds group was forms back in 1986 by two members -
Gal-on Broner and Yuval miinster. It's main idea was creating
games and puzzles who stress the thinking helmet to it's limits.
We had an *pple computer back then and we weren't great
programmers.  Well, we are not great programmers today, but we
did make quite a giant step since then.

  The group got bigger along the years and expanded to other
computers as well. The Amiga section of the group is headed by
Gal-on Broner, writer of Space mission and the technical support.

  In the end of 1992, at one of the holidays, Barbarian Minds
changed its face. First, the name was changed to Barbarian Minds
Software. We felt that we are capable of creating better and
more professional programs than before, and the change of name
is a small mark of a big step forward. Barbarian minds will
release at a faster pace public domain and Testware programs.  In
cases where money will be requested, we will make sure that the
software really deserves it and the sums will be truly lower than
other Shareware/Testware programs on the market.

  One of Barbarian Minds main projects is the AmoNER magazine.
Although is has had some problems during its creation, it is now
beginning to gain the final touch which requires a more stable
distribution.

    Please keep in touch with us. We would like to hear your
comments.  Addresses appear in the policy guidelines available on
the AmoNER Disks.