ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³ Module Player V1.4 (c) 1994,1995 by Lord Excess of Sound Wizards Int. ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ USING THE SWMP DRIVERS WITH TURBO ASSEMBLER ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ (or any other language allowing inline asm instructions) First you have to unzip the files of archive ASM_SDK.ZIP. Files you need in any case are: SB.DRV : SoundBlaster driver [ 22.2 kHz mono ] SBP.DRV : SoundBlaster Pro driver [ 21.7 kHz stereo ] GUS.DRV : Gravis UltraSound driver [ 44.1 kHz +stereo+ ] MODPLAY.LIB : TASM library that holds all drivers MODPLAY.INC : include file for ModPlay.Lib The rest are example files, which can be important to understand things better. In general you first have to allocate memory and then load one of the drivers into RAM (must be a paragraph address). So you perhaps will be asking at program start which driver to load. After having loaded the selected file, you can use the driver by doing far calls to its first address (driver_segment:0000). Note: Memory allocation must be available via int 21h, subfunction 48h. Therefore you have to adjust your own memory control block first, else the drivers cannot alloc mem for the soundfiles! Convention is that the register BX contains the subfunction number, additional parameters are placed in AX,CX,DX etc. The following subfunctions are available: ÚÄÄINIT DRIVERÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=0, CX,DX=configuration ³ Initialize driver using configuration in CX and DX. ³ Configuration for -SoundBlaster: CL=IRQ NUMBER, CH=1 ³ DX=BASE ADDRESS ³ -SoundBlaster Pro: CL=IRQ NUMBER, CH=DMA CHANNEL ³ DX=BASE ADDRESS ³ -Gravis UltraSound: CL=GF1 IRQ, CH=MIDI IRQ ³ DX=BASE ADDRESS ³ -> Returns AX=driver version if successful, else 0. ³ Note: If the driver was initialized correctly, it HAS TO BE CLOSED ³ at program end using subfunction #1. À ÚÄÄCLOSE DRIVERÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=1 ³ Close driver, stop playing, put soundcard in a safe state, ³ restore all interrupt vectors etc. À ÚÄÄLOAD MODULEÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=2, DS:DX=filename ³ Stop any sound output and load modulefile stored in ds:dx, which ³ has to end with a zero byte. Does not start playing the song. ³ -> Returns AX=number of channels (4,6,8) if successful, else zero. À ÚÄÄSTART MODULEÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=3 ³ Start playing previously loaded song. À ÚÄÄSTOP MODULEÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=4 ³ Stop any sound output at once. À ÚÄÄMAIN VOLUMEÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=5, AL=volume ³ Change mainvolume. Valid values are between 0 (lowest) and ³ 64 (loudest). À ÚÄÄSTATUSÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=6 ³ Get driver's playing status ³ -> Returns AX=1 if sound is being played, else zero. À ÚÄÄGET POSITIONÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=7, AL=0 ³ Get playing position (to syncronize graphic effects). ³ -> Returns AH=PatternNumber, AL=LineNumber (AX=0 if not playing). À ÚÄÄSET POSITIONÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=7, AL<>0 ³ Set playing position. Value in AL is added to current players ³ pattern position. You cannot step below first and past last ³ pattern. Reasonable values are 1 or -1 (0FFh). À ÚÄÄPEAKSÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=8, ES:DI=peak buffer ³ Copy the volume settings of each channel to peak buffer, which ³ has to hold a maximum of 8 bytes. The number of channels is ³ known after successful load of modulefile (subfunction #2). ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ All registers will contain the same value after a subfunction call, except AX, which will contain anything different from zero if the call was successful. Using this conventions you can link the drivers in any programming language, that supports inline assembly instructions. TASM users can have things a little bit easier, if using the library MODPLAY.LIB. You just have to add the statement INCLUDE MODPLAY.INC into your asm source and the drivers plus a fully automatic hardware detection are linked. This gives you two new procs called Mod_Driver : general far call address to drivers Mod_End_Seg : far proc that returns last segment in ax The big advantage of this library is that you do not have to load drivers into memory. You call Mod_Driver as shown above, only the first function is altered slightly containing now the option to choose which driver to use: ÚÄÄSELECT AND INIT DRIVERÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ BX=0, AX=sounddevice (CX,DX=configuration) ³ Initialize driver selected by register AX. If AX=0 a detection ³ will decide which driver to use, and then try to inizialize it. ³ This should work in most cases. But you have the opportunity to ³ bypass the detection, and manually select and setup the driver. ³ In this case ³ AX=1 stands for SoundBlaster driver ³ AX=2 " " SoundBlaster Pro driver ³ AX=3 " " Gravis UltraSound driver ³ and CX,DX must hold the configuration as required by the common ³ function #0. ³ -> Returns AX=driver version if successfull, else zero. À The second proc called Mod_End_Seg returns in register AX the last segment address of the player to which you can adjust the main program's memory control block. The new initialisation copies the selected driver to the lowest possible memory location (over the first driver) to avoid wasting ram. ÚÄÄGET DRIVER END ADDRESSÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ ³ -> Returns AX=driver end segment (unused) ³ Note: Only call this proc after initialisation! À There is also an example file available to illustrate you the use of this library. It is coded in very, very easy assembler. Of course I do know segment instructions, but this wouldn't make the source more readable. Lord Excess in June '95