home *** CD-ROM | disk | FTP | other *** search
/ Da Capo / da_capo_vol1.bin / programs / amiga / edit / octamedv2 / programmers / modplayer / modplayer.doc < prev    next >
Text File  |  1993-03-13  |  10KB  |  264 lines

  1.      Instructions for using "modplayer.a", the stand-alone playroutine
  2.      of OctaMED V2.0
  3.  
  4. "modplayer" is a piece of code (about 3 - 5 KBytes, depending on your needs)
  5. which is linked with your program and plays modules made in OctaMED.
  6.  
  7. "modplayer" contains the following routines:
  8.     InitPlayer
  9.     RemPlayer
  10.     PlayModule
  11.     ContModule
  12.     StopPlayer
  13.     SetTempo
  14.  
  15. The arguments are passed in registers, and return values are returned in d0.
  16. These routines will trash registers d0-d1 and a0-a1.
  17.  
  18. And now the descriptions of each one:
  19. --------------------------------------------------------------------------
  20. InitPlayer -- initialize everything
  21.  
  22. Before you can call the other functions, you must call this function.
  23. It allocates the audio channels, timer, serial port (if MIDI) etc...
  24.  
  25. ARGUMENTS:  none
  26.  
  27. RETURNS:    0 if everything is ok, otherwise something failed.
  28.         If something failed, you can still call the other
  29.         routines - they just don't do anything.
  30. --------------------------------------------------------------------------
  31. RemPlayer -- return everything back
  32.  
  33. Call this when your program exits. It frees the audio channels etc. etc.
  34.  
  35. ARGUMENTS:  none
  36.  
  37. RETURNS:    nothing
  38. --------------------------------------------------------------------------
  39. PlayModule -- start playing a module
  40.  
  41. When you want to start playing call this.
  42.  
  43. ARGUMENTS:  a0 = pointer to the module. Where to get that pointer?
  44.         Don't panic, it's explained later....
  45.  
  46. RETURNS:    nothing
  47. --------------------------------------------------------------------------
  48. StopPlayer -- stop playing
  49.  
  50. ARGUMENTS:  no arguments
  51.  
  52. RETURNS:    nothing
  53. --------------------------------------------------------------------------
  54. ContModule -- continue playing
  55.  
  56. This routine continues playing the module from the point it was stopped.
  57.  
  58. ARGUMENTS:  a0 = pointer to the module
  59.  
  60. RETURNS:    nothing
  61. --------------------------------------------------------------------------
  62. SetTempo -- set the playback tempo
  63.  
  64. ARGUMENTS:  d0 = new tempo (1 - 240)
  65.  
  66. RETURNS:    nothing
  67. --------------------------------------------------------------------------
  68.  
  69. "modplayer.a" is the source code of the music routine. It contains stuff
  70. that may be unnecessary for your purposes, that just takes time and memory.
  71. There are some "switches" at the beginning of the source, that allow you
  72. to turn off features you don't need. They are:
  73.  
  74. MIDI        If the song(s) use(s) only the Amiga audio channels, set
  75.         this to 0.
  76. AUDDEV      For some purposes, you may want to disable the code that
  77.         allocates the audio channels using "audio.device", e.g.
  78.         in a non-multitasking environment. Normally this should
  79.         be 1.
  80. SYNTH       If the song(s) doesn't use synth/hybrid sounds, then this
  81.         can be set to zero.
  82. CHECK       This does some checkings to ensure that several values are
  83.         correct (e.g. is the sample in memory, no Amiga effects on
  84.         MIDI-tracks etc..). If you know that the song is correct,
  85.         you can safely turn the checks off.
  86. RELVOL      If you don't need the "relative volume", this can be zero.
  87. IFF53       If the song doesn't contain IFF 3- or 5-octave samples,
  88.         this can be zero.
  89. HOLD        This turns off the hold/decay features.
  90.  
  91.  
  92. There's an additional flag, EASY. If set, the usage of the player routines
  93. is even more simplified, and you enter the module name into an INCBIN
  94. statement. Then there are two routines (_startmusic, _endmusic) you call
  95. to start and stop the music (the music can be started ONLY ONCE). The
  96. EASY option is suitable for demos etc. where only a single tune is
  97. required. This option also replaces the 'easyplayer.a' from the previous
  98. release of OctaMED and MED.
  99.  
  100. "modplayer.a" also supports multi-modules. It defines a UWORD modnum
  101. (in assembler: _modnum). Set this variable to the number of the song
  102. you want to play before calling PlayModule (0 is the first, 1 is the
  103. second song etc..). For example:
  104.     #include "modplayer.h" /* defines 'modnum' */
  105.     ...
  106.     modnum = 1; /* Play the second module */
  107.     PlayModule(module);
  108.     ...
  109. Assembler:
  110.     xref    _modnum
  111.     xref    _PlayModule
  112.     ...
  113.     move.w  #1,_modnum
  114.     lea _module,a0
  115.     jsr _PlayModule(pc)
  116.     ...
  117.  
  118. Timing
  119. ======
  120. If you need vertical blanking timing, you can set VBLANK to 1 and CIAB to 0.
  121. In normal use this is not recommended (because of the 16 % difference in
  122. playing speed with NTSC and PAL Amigas).
  123.  
  124. Assembling
  125. ==========
  126. "modplayer.a" can be assembled by using A68k V2.61 (or later) or HiSoft
  127. Devpac 2 without need to make changes. Other assemblers may need some
  128. small changes to work correctly (mostly because the directives they support
  129. may be slightly different). The freely distributable assembler, A68k is
  130. available e.g. on Fish disk #314. If you've working on a linker environment
  131. (e.g. programming in C), you've to include the resulted "modplayer.o" in
  132. your .lnk-file.
  133.  
  134. ==========================================================================
  135.  
  136. And how to get some music?
  137.  
  138. You have two ways to get the music:
  139. 1. Include the module in your final executable.
  140. 2. Save the module as a separate disk file and load it when needed
  141.    (this is probably the best way if you have more than one song, and
  142.     you don't want to use multi-modules).
  143.  
  144. First I cover the first method:
  145. --------------------------------------------------------------------------
  146. Including the module in your final executable:
  147.  
  148. The direct object file saving is removed now (you can still use the previous
  149. versions which support it, if you want). There's now another way to convert
  150. the song to an object file.
  151.  
  152. There's a new utility, Objconv, which loads the module and dumps it into an
  153. object file. Here's an example how to use it:
  154.  
  155. - Save the song as a module (MED module!).
  156. - Use Objconv e.g. objconv medmodule mod.o
  157. - Objconv requests the symbol name, enter "song" (without "'s), for example.
  158. - Now there's a file 'mod.o'. Link this file, and the file 'reloc.o'
  159.   with your program.
  160. - In your program, you define the module:
  161.     #include "modplayer.h"
  162.     ...
  163.     extern struct MMD0 far song;
  164.   You must relocate the module before it's used. Do this only once!
  165.   This is done by
  166.     RelocModule(&song);
  167.   RelocModule expects the argument in stack, so use __stdargs, if you've
  168.   turned registerized arguments on.
  169.  
  170. In assembler, you'd do exactly in the same way, except:
  171.     xref    _song
  172.     xref    _RelocModule
  173.     xref    _PlayModule
  174.  
  175.     ... (assuming all init stuff is here)
  176.  
  177.     lea _song,a0
  178.     move.l  a0,-(sp)    ;push in stack
  179.     jsr _RelocModule(pc)
  180.     lea _song,a0    ;this is passed in register a0
  181.     jsr _PlayModule
  182.     ...
  183.  
  184. Note: if you've got an assembler that supports 'incbin' directive or
  185. equivalent, you can use it instead of the Objconv. Relocation is required
  186. in any case.
  187.  
  188. And the second method (loading modules from disk):
  189. --------------------------------------------------------------------------
  190. File "loadmod.a" contains three routines:
  191.     LoadModule
  192.     UnLoadModule
  193.     RelocModule (not external)
  194.  
  195. You usually need only the first two of them. RelocModule is used by
  196. LoadModule.
  197.  
  198. --------------------------------------------------------------------------
  199. LoadModule -- loads a module from disk
  200.  
  201. This function loads a module from disk. Note that relocation is done
  202. automatically, so you must not RelocModule() a module obtained by using
  203. this routine.
  204.  
  205. ARGUMENTS:  a0 = pointer to file name
  206.  
  207. RETURNS:    d0 = pointer to the module, if something failed: 0
  208. --------------------------------------------------------------------------
  209. UnLoadModule -- free the module from memory
  210.  
  211. Frees the module. Remember to StopPlayer() before you unload the module
  212. that is currently playing. Also remember to free all modules you've loaded
  213. before you exit the program.
  214.  
  215. ARGUMENTS:  a0 = pointer to the module (may be 0)
  216.  
  217. RETURNS:    nothing, nothing and nothing
  218. --------------------------------------------------------------------------
  219.  
  220. Just call LoadModule to load the module and send the returned pointer to
  221. PlayModule. Easy??
  222.  
  223. ==========================================================================
  224.  
  225. REMEMBER:   All functions expect the arguments in register