Home
Up

 

Sinister Sound Module

Ok, let's get straight down to business. Anyone can download and use the Sinister Sound Module for free. You may use the module in both commercial and non commercial projects as you see fit. I would just like to see more projects being released on the Jaguar and I know sound code can be an awkward part of development. 

The sound routine is written in 68000 motorola assembler and Jaguar DSP assembler.

Basically, all you need to do is copy the play.s source code file into your project as follows:

player:             .include "play.s"                 ;music/sound effects routine

The .include statement tells the compiler to copy the contents of the file play.s into this location when compiling. The label player: is used when calling the functions of the sound routine as follows:

JSR player                Used to initialize the sound routine (must be called first)
JSR player+4            Used to start a new music module (Soundtracker 4 channel module)
JSR player+8            This should be called in your vertical blanking routine (VBL) to keep sounds playing
JSR player+12          Play a sample
JSR player+16          Clear the sound channels
JSR player+20          Set Music Volume
JSR player+24          Set Effects Volume
JSR player+28          Enable Music (not required if calling player+4)
JSR player+32          Disable Music
JSR player+36          Change channel volume or frequency

There is more detailed information on each of these calls in the play.s routine itself

Somewhere near the start of your code, you will initialize the sound routine, wait for 2 VBL's and set up start volumes for Sound and Effects and here is an example:

jsr player                                  ;init player
bsr wait_vbl                             ;wait one vbl
bsr wait_vbl                             ;and another
move.w #160,d0                     ;0-255 volume
move.w d0,music_vol             ;save music volume in variable music_vol
jsr player+20                           ;set music volume
move.w #220,d0                     ;0-255 volume
move.w d0,effects_vol           ;save effects volume in variable effects_vol
jsr player+24                           ;set efx volume

Your VBL routine might look something like this:

VblRoutine:        movem.l d0-d7/a0-a7,-(sp)        ; store registers on stack
                            add.w #1,intcount                        ; add 1 to vbl counter variable
                            bsr copy_olist                              ; copy new object list over old one
                            jsr player+8                                  ; Call the sound routine
                            move.w #$101,INT1                    ; don't remember what this does
                            move.w #0,INT2                          ; or this but fairly sure you need them :)
                            movem.l (sp)+,d0-d7/a0-a7       ; restore registers to previous contents before returning to non interrupt code
                            rte                                                 ; return from interrupt

To start playing a music module:

lea mod1,a0                           ; address of music module
jsr player+4                             ; start playing

To play a sample:

move.l #samp16_end-samp16,d0             ;sample length
move.l d0,d1                                                 ;loop length (same as total length in this case)
moveq #15,d2                                              ;priority
moveq #0,d3                                                ;default volume (as set at start of program)
moveq #0,d4                                                ;default frequency
lea samp16,a0                                             ;start address
move.l a0,a1                                                 ;loop start address (0 for no loop)
jsr player+12                                                ; Call Start Sample function
move.w d0,movesamp                                ; Store channel number sample is playing on
 

To stop a sample:

move.w #movesamp,d1                             ; get channel number from variable
jsr player+16                                                ;Turn off move sample

 

Hopefully the above snippets of code will be good enough for you to experiment with. If you have any questions, please contact me at sinigord@hotmail.com

Here is the Sound Routine Download Play.s (right click and select save as)

 

Home ] Up ] [ Sinister Sound Module ] Painter Source ]

Send mail to sinigord@hotmail.com with questions or comments about this web site.
Copyright © 2003 Sinister Developments
Last modified: 08/26/03