BAD MOOD module interface,
proof of principle
==========================

The intention is that the AI etc in BAD MOOD should be handled by
external modules, created using standard compilers.
This little program shows how this can work.

The code is 100% C, but completely undocumented.
I compiled it using PureC, but I think Lattice C and gcc should be fine to.

To run the program, double click RELOCATE.TTP and give the same name in the
parameter dialog. If you're in a shell, type 'relocate relocate.ttp'.
(Since BAD MOOD is Falcon only, I didn't bother compiling the code for
 68000, but a simple recompile would take care of that.)

Operation
---------
- Repeat five times with the filename supplied on the command line.
  The program itself is a module as well as the 'OS'.
  - Load the module and relocate it by hand. 
  - Search for a 'Magic Number', which marks a known structure that
    contains the address of an initialization routine.
  - Once found, execute the initialization routine by simply calling it.
    The routine will use the same stack as the parent program, but all
    data is local thanks to the relocation.
    As parameters are sent the address of a callback function and of a
    structure than contains pointers to everything of interest. The former
    was mostly included as a test, but the latter will be used for all
    accesses by the module to the outside world.
  - The initialization routine can do whatever it likes, but in this case
    it just (well, it actually does a few more things, but...) tries to
    register another routine for later execution.
- Repeat twenty times.
  - Repeat for all registered routines.
    - Call the routine in question with the iteration number as parameter.
      The routine will execute and, for certain iteration numbers, print
      a short message to let you know it's there.

Johan Klockars, 971106
