
****************************
Rebuilding the Defender game
****************************

Defender has been designed so that you can easily modify many
aspects of the game and incorporate your own ideas.

Changing the game will involve changing various files on the
Defender disk, so please make a copy of your master disk and
only work on the copy.  Then, if you have problems with your
modified disk after changing one of the files, you can simply
replace the original file from your master disk.

There are various ways in which you can change the Defender
game and we will describe them each in more detail below.

The general idea is that you can change any of several data
files which Defender uses to define graphic imagery, sounds,
music, and general gameplay parameters.

--------------------------------
The "Rebuild_Defender" operation
--------------------------------

Any changes you make to the graphics, sound, or music files
will take place automatically when you play the game, and
require no further preparation.

However, if you change the gameplay parameter configuration
files, you will need to rebuild the game program to have your
changes take effect.

To do this you need to use the "Rebuild_Defender" command.

This is very simple: all you have to do is double click the
"Rebuild Defender" icon, and the software will automatically
be reconfigured and written back to the disk.  After this,
your new parameters will be incorporated into the game code.

*****************
Changing graphics
*****************

The following files are all graphic definitions, and are simple
IFF files which you can edit in any Amiga art package.

You MUST keep the number of colours and the overall dimensions
of all these files. You are only free to change the actual
graphic imagery.

Here is a description of what each file does, along with a few
simple rules which you need to observe in each case.

--------------------------------------------------------------
Dat1A  - Imagery for the top screen slice (scanner) foreground
--------------------------------------------------------------

The central scanner area needs to be kept as "colour 0", which
will appear transparent and allow the scanner landscape on the
background scrolling playfield to be seen.

-----------------------------------------------------------
Dat1B  - Imagery for the top screen slice scanner landscape
-----------------------------------------------------------

The imagery here is a scaled down representaion of the main
landscape display.  If you change the main landscape, you need
to change this picture to represent your new landscape. Take
care to retain exactly the same size of image and offset from
the left edge of the screen.

---------------------------------------------------
Dat2A  - Imagery for the main playfield "landscape"
---------------------------------------------------

In this picture the first and last sections are both identical.

Considering horizontal dimensions, going left to right,you have:

1. A 16 pixel border.
2. 1280 pixels of landscape.
3. 320 pixels which repeat the first 320 of the 1280 landscape.
4. Another 16 pixel border.

If you do not take care to repeat the first 320 pixel section
exactly, you will get a "glitch" as the screen scrolls.

------------------------------------
Dat2B  - Imagery for the "starfield"
------------------------------------

In this picture the first and last sections are both identical.

Considering horizontal dimensions, going left to right,you have:

1. A 16 pixel border.
2. 640 pixels of starfield.
3. 320 pixels which repeat the first 320 of the 640 starfield.
4. Another 16 pixel border.

If you do not take care to repeat the first 320 pixel section
exactly, you will get a "glitch" as the screen scrolls.

-------------------------------------------
Dat3   - Imagery for the lower screen slice
-------------------------------------------

This is non-critical except for dimensions and number of colours.

------------------------------------------------
Dat4   - Imagery for all dynamic graphic objects
------------------------------------------------

This is the most interesting, but also the most critical to edit.

In this picture you will find representations of all graphic objects
and animation frames.

It is vital that you redraw objects exactly in the same position as
they were originally, since the game software will look in precise
positions for each object image.  Note that the game software reads
animation frames for each object as a left-to-right sequence of
identically sized frames. This means that for "sequential" objects
you must retain both the frame size and position.

While keeping frame size and position you are free to change the shape
of any object, provided that you retain the same overall object size.

If you edit an animated object which was origianally 9 pixels wide
and 7 pixels deep, you must make all your new frames 9x7 also. This
only refers to the overall object "frame", and you can, if you wish,
make the object smaller within its 9x7 frame.  If you do make the
object image itself smaller, the game software will automatically
recalculate things like collision masks, so that the smaller object
will behave perfectly correctly within the gameplay.

The best idea to start with is to simply edit the pixels of existing
objects, observing the changes you make when you play the game.

**********************
Changing sound effects
**********************

Dat5   - Module containing all sound effects

The sound effects are all stored in a MED2 (PD Version of MED) music
module, so you can use the freely available MED2 software to change
any of the samples.

*******************
Changing load music
*******************

Def.mod - Soundtracker format music module.

Simple replace "Def.mod" with any soundtracker format module.

************************
Changing game parameters
************************

Because the game comes in two versions with different frame rates for
fast and slow Amigas (50 frames/sec and 25 frames/sec), there are two
configuration files.

These two configuration files determine all the overall characteristics
of each level of the game, such as number of enemies, object speeds etc.

You only need change the file relating to the version of the game you
intend to play.  In general, any Amiga with a 25mzh or better CPU will
run the fast 50frames/sec version, with all slower machines needing to
use the 25frames/sec version.

For the rest of this text all specific references will be to the "25"
file only, for the sake of simplicity, but all comments apply equally
to the "50" file also of course.

Use the "Edit_Defender25" icon to edit the game parameter file, or
simply edit the file "DefenderSetup.25" in any ASCII text editor.

The DefenderSetup files are actually small Helios program files, and
will give you an interesting insight into Helios programming.

Remember that after editing either of these files, you need to use
"Rebuild_Defender" to make your changes effective.

*******************************
Editing the configuration files
*******************************

These are actual HeliOS source code program files and you must
be careful to obey a few simple rules when editing them or the
Helios compiler will not understand your alterations.

Take care:

1. Please do not edit your original copies of the files!  Always
   keep copies of the originals for reference in case you change
   the files in some way which prevents them from working correctly.

2. Notice that there are "\" characters within some lines of text,
   and each "\" has a space before and after it.  You must be careful
   not to remove the "\" characters (or the spaces before and after)
   because HeliOS uses them to recognise "comments" from code.

3. Do not change anything until you have read the notes below
   carefully, and then only change numbers as instructed.

4. Do NOT insert any text into this file....or if you really MUST
   do so, please ensure that each new line of text is preceded by
   the comment marker "\" with enclosing spaces.

------------------
Editing procedures
------------------

By default, if you are using the Workbench icons, you will be editing
the text from within the simple "Ed" text editor which is provided
with the Amiga.  The "Ed" text editor allows you to alter text and 
simply resave it with the same name.

If you prefer, you can use any other text editor to change the
files, but please remember that they MUST be saved with the same
name, and you MUST use an ASCII text editor.  

In case you are not sure about what an ASCII text editor is, it is 
simply an editor which produces a file which contains only ASCII text 
characters, with no other special "formatting" information.  If you 
choose to use a word processing program for editing you must remember 
to save the edited files as pure "ASCII" rather than as full word 
processor files which may contain text formatting information.

----------
What to do
----------

To give you the experience of writing an actual Helios program
rather than simply editing a data table, the configuration files
are actually the source code for short Helios programs.  You can
change the files in any text editor and then you use the "Rebuild"
operation to recompile the whole program using your new code.
This will give you a completely new customised version of the
Defender game containing your new alterations.

This process is exactly the same as if you were rewriting the full
Defender program: you change the source code, which is simply a
text file, then tell Helios to recompile the game.  Obviously the
full game source code is rather more complex, but in principle the
operations involved in fully reprogramming a Helios game are exactly
what you have here.

The first part of each configuration file contains 9 sections, each
of which is the source code for a Helios subroutine which defines the
playing characteristics of one of the 9 successive game levels.  Each
of these level definition sections starts with a line which contains
a ":" (colon) character followed by a space and then a subroutine
name in the form "25InitLevelx".  The end of a section of source
code is marked by the use of a ";" (semicolon) character.

For example, you will find a line looking something like this:

 : 25InitLevel1

This is the name "header" for a short section of source code, or
"subroutine" which defines how the game operates on Level1.

Following this line you will find a number of "definition" lines,
after which you will see a line with just ";" like this:

 ;

After this "end of definition" marker, you will see the start of
the next definition section, and so on......

So, to change the characteristics of Level1, scroll down the file
until you find the line containing "  : 25InitLevel1", which tells
you that you are at the start of the Level1 definition.  The next
lines, after the subroutine name, contain text which defines game
level parameters.  To change the characteristics of Level1 simply
change the numbers at the start of each line: the comments on each
line tell you what feature of the game each number relates to.

You can change the characteristics of each of the 9 game levels.

If the player gets past level 9, the whole cycle will restart but on
a higher difficulty level.  In this case all parameters specified here
are increased at the start of each full 9-level cycle so that the game
retains the same overall pattern but with ever-increasing difficulty.

The lower section of the file, after the game "level definitions",
specifies parameters which affect the game as a whole (such as the
distance your ship is offset from the centre of the screen when at
rest, or the acceleration of your ship).

These general configuration parameters are contained in a subroutine
called "25CONFIG".

Hint:

It is here that you will find two very important parameters called
"StartLives" and "StartSmarts".

You can guess what these control......

--------------------------
Editing Helios source code
--------------------------

As already mentioned, the configuration files are actually the source
code of a mini-program which operates within the main game program, so
you need to be careful to obey a few simple programming rules:

First, here are a few "DO NOTs!":

1. Do not remove any "\" characters, which are line "comment markers"
   telling the program interpreter to ignore all information after this
   symbol on any line.

2. Do not remove any ":" or ";" characters, which are used to define
   the start and end of subroutines by the interpreter.

3. Not not remove any "!"s, "!L"s, or "D!"s.

4. Do not change ANY of the embedded names, which means any text word
   which appears BEFORE the "\" on any line.

5. In short, do not change anything other than the parameters at the
   start of lines!

This only leaves you with TWO things you can do!

Here they are:

1. Change the numeric parameters which appear at the start of each line.

2. Change the digits of "01010001100etc" numbers which appear in
   the FrameMask definitions.  The length of these strings of "1"s
   and "0"s should not be changed - there should be 32 characters
   in each string, immediately followed by a "." character.  It is
   important not to remove the "." character.

   Note:

   The "1"s represent frames in which the object will move during
   each 32 frame sequence.

   The "0"s represent frames where the object will remain stationery.


Distances and ranges are defined in pixels, with the full screen width
being 320 pixels.

Speeds are defined in pixels-per-frame.

That really is all you need to know: just take care to note down exactly
what you change in case it doesn't work out how you expected!

Good Luck!

And......Have Fun!

**************
Going further?
**************

If you enjoyed experimenting with this game, and you would like to try
more extensive reprogramming, full commented source code is available
along with a HeliOS compiler which will allow you to change any and
every aspect of the game.




