home *** CD-ROM | disk | FTP | other *** search
- ****** Instructions for using "modplayer.a", the stand-alone playroutine
- ****** of MED V3.10/OctaMED V1.00
-
- "modplayer" is a piece of code (about 3 - 5 KBytes, depending on your needs)
- which is linked with your program and plays modules made with MED.
-
- "modplayer" contains the following routines:
- InitPlayer
- RemPlayer
- PlayModule
- StopPlayer
- SetTempo
-
- (As you can see, some of the less important functions of V2.10 are removed.
- they are still available on medplayer.library.)
-
- The arguments are passed in registers, and return values are returned in d0.
-
- And now the descriptions of each one:
- --------------------------------------------------------------------------
- InitPlayer -- initialize everything
-
- Before you can call the other functions, you must call this function.
- It allocates the audio channels, timer, serial port (if MIDI) etc...
-
- ARGUMENTS: none
-
- RETURNS: 0 if everything is ok, otherwise something failed.
- If something failed, you can still call the other
- routines - they just don't do anything.
- --------------------------------------------------------------------------
- RemPlayer -- return everything back
-
- Call this when your program exits. It frees the audio channels etc. etc.
-
- ARGUMENTS: none
-
- RETURNS: nothing
- --------------------------------------------------------------------------
- PlayModule -- start playing a module
-
- When you want to start playing call this.
-
- ARGUMENTS: a0 = pointer to the module. Where to get that pointer?
- Don't panic, it's explained later....
-
- RETURNS: nothing
- --------------------------------------------------------------------------
- StopPlayer -- stop playing
-
- ARGUMENTS: no arguments
-
- RETURNS: nothing
- --------------------------------------------------------------------------
- SetTempo -- set the playback tempo
-
- ARGUMENTS: d0 = new tempo (1 - 240)
-
- RETURNS: nothing
- --------------------------------------------------------------------------
-
- "modplayer.a" is the source code of the music routine. It contains stuff
- that may be unnecessary for your purposes, that just takes time and memory.
- There are some "switches" at the beginning of the source, that allow you
- to turn off features you don't need. They are:
-
- MIDI If the song(s) use(s) only the Amiga audio channels, set
- this to 0.
- AUDDEV For some purposes, you may want to disable the code that
- allocates the audio channels using "audio.device", e.g.
- in a non-multitasking environment. Normally this should
- be 1.
- SYNTH If the song(s) doesn't use synth/hybrid sounds, then this
- can be set to zero.
- CHECK This does some checkings to ensure that several values are
- correct (e.g. is the sample in memory, no Amiga effects on
- MIDI-tracks etc..). If you know that the song is correct,
- you can safely turn the checks off.
- RELVOL If you don't need the "relative volume", this can be zero.
- IFF53 If the song doesn't contain IFF 3- or 5-octave samples,
- this can be zero.
-
- Timing
- ======
- If you need vertical blanking timing, you can set VBLANK to 1 and CIAB to 0.
- In normal use this is not recommended (because of the 16 % difference in
- playing speed with NTSC and PAL Amigas).
-
- Assembling
- ==========
- Now you must assemble this file. The "modplayer.a" is directly compatible
- with A68k V2.61 (or later...) and HiSoft Devpac 2. Other assemblers may need
- some small work to assemble it correctly. The A68k V2.61 is available e.g.
- on Fred Fish disk 314.
-
- The result is an object file. Link this file with your program (add the name
- of the .o-file to the .lnk-file)
-
- Now you have the player, but there's still something missing...guess??...
- that's right: the music.
-
- You have two ways to get the music:
- 1. Include the module in your final executable.
- 2. Save the module as a separate disk file and load it when needed
- (this is probably the best way if you have more than one song).
-
- First I cover the first method:
- --------------------------------------------------------------------------
- Including the module in your final executable:
-
- There are two ways to do this:
- 1. Save the module as an object file which you can directly link with your
- program.
- 2. In some assemblers it is possible to include binary files into the code.
- There's a special source "easyplayer.a" for Devpac 2 (see below...)
-
- Again I cover the first method first:
-
- You must load MED and then load the song you want to include. Now select
- "Save song". You should see the save format requester. There are two
- gadgets which save object files: "Obj 1" and "Obj 2". Another problem,
- which one to select??
-
- Well, the reason why there are two gadgets is that Lattice's Blink 5.04,
- which I use, handles the chip bits of the object files in a different way
- to the description in AmigaDOS manual.
- While the the "AmigaDOS-manual" way would be
- 000003EA 40001234,
- hunk_data | hunk size
- chip
-
- Blink uses a format like this:
- 400003EA 00001234
- | hunk_data hunk size
- chip
-
- The "Obj 1" gadget saves the file in Blink format, "Obj 2" saves it in
- the "AmigaDOS manual-format".
-
- I suggest that you first try "Obj 1". If you get an error message when
- linking, then select "Obj 2".
-
- Now you know how to save the object file. The object file has exactly
- one symbol defined: the module (struct MMD0). The name of the symbol
- depends on the file name (so you can have more than one song). If the
- file name you entered was "song", the object file would be "song.o" and
- the module would be defined as "_song" (in C just plain "song").
-
- In C, you would define it this way:
-
- extern struct MMD0 far song; /* remember to include "modplayer.h" */
-
- and to start playing, you'd call (assuming you've already called InitPlayer):
-
- PlayModule(&song);
-
- With assembler, it would look like this:
-
- xref _PlayModule
- xref _song
- ....
- lea _song,a0
- jsr _PlayModule(pc)
-
- Then the another way...
-
- When you have included the module (not an object file!!) as a binary
- module, it must be relocated before it can be used. The easiest way to
- do this is to use _RelocModule, which is in "loadmod.a". After it's
- relocated, send the pointer of the module to PlayModule (NOTE: Remember
- to xdef the _RelocModule-function or strip the function from loadmod.a).
- By the way, never relocate the same module twice. It is 100 % guaranteed
- that it won't work then.
-
- And the second method (loading modules from disk):
- --------------------------------------------------------------------------
- File "loadmod.a" contains three routines:
- LoadModule
- UnLoadModule
- RelocModule (see above)
-
- You need only the first two of them. RelocModule is used by LoadModule.
-
- --------------------------------------------------------------------------
- LoadModule -- load module from disk
-
- Loads and relocates module.
-
- ARGUMENTS: a0 = pointer to the file name
-
- RETURNS: d0 = pointer to the module, if something failed: 0
- --------------------------------------------------------------------------
- UnLoadModule -- free the module from memory
-
- Frees the module. Remember to StopPlayer() before you unload the module
- that is currently playing. Also remember to free all modules you've loaded
- before you exit the program.
-
- ARGUMENTS: a0 = pointer to the module (may be 0)
-
- RETURNS: nothing, nothing and nothing
- --------------------------------------------------------------------------
-
- Just call LoadModule to load the module and send the returned pointer to
- PlayModule. Easy??
-
- ==========================================================================
-
- REMEMBER: All functions expect the arguments in registers. This is
- automatically (??) handled by you when you program in
- assembler, but it is not automatically handled when you
- program in C.
-
- If you have Lattice/SAS C V5.xx, this is done automatically if you include
- "modplayer.h" in all your code modules which call modplayer. If you
- have a compiler which doesn't support argument passing in registers,
- then you have to write the stub routines in assembler.
-
- That was it. See also the small example sources.
-
- ==========================================================================
- easyplayer.a -- easy-to-use player for demos etc.
-
- This is a player designed for playing a single song. It works on Devpac 2
- (not on A68k, because it doesn't have INCBIN-command). To use it, insert
- it into your code (or assemble separately and link). The name of the module
- must be written into the INCBIN-statement. At the beginning of the program,
- call _startmusic, when you're ready to finish, call _endmusic. That's all.
-