Skip to content

4. Installing GEMS into your MD program

MDTravis edited this page Sep 25, 2024 · 3 revisions

What version should I use?

This repository has two versions of GEMS set up, that being 2.5 and 2.8. 2.8 is the default branch available, and is the most up-to-date version of GEMS available. 2.5 is older and has less features, but is generally more compatible with existing compiled GEMS projects.

Installing the driver

  • Open the GEMS folder, and copy everything contained within it.
  • Paste the files wherever in your program's source code.
  • If if is not within a folder called "GEMS", open both gems.s and sound.s within a text editor.
  • In the text editor, replace all instances of GEMS/ with the folder you have them located in.
    • Example 1: If the files are in a folder called SRC, replace all instances of GEMS/ with SRC/.
    • Example 2: If the files are in the root directory of your project, simply remove all instances of GEMS/.
    • Example 3: If your files are within a folder inside of a folder, for example, a "GEMS" folder inside of a "SRC" folder, replace all instances of GEMS/ with SRC/GEMS/.
  • Include sound.s somewhere in your program. If it is in a folder, follow the same steps as above.

It is now safe to compile your project. If you don't get any errors, you can continue onto the next steps.

Initializing the driver

  • Insert jsr _sfxinit somewhere in your source code.

Playing a sound

!!! WARNING !!! Address registers a0 and a1 will be destroyed whenever you call a sound. If you don't want this happening, you can for example, replace a0 with a2 and a1 with a3. If the address registers are still being used, you can temporarily store one or both of the address registers somewhere in RAM.

  • To play a sound, insert the following code wherever you want to play the sound:
	move.l	#[SOUND_ID],-(sp)
	jsr	_gemsstartsong		; start song
	adda.w	#4,sp
  • Replace [SOUND_ID] with the ID of your sound.
    • If you want hex 4E, replace it with $4E.
    • If you want decimal 42, replace it with 42.

Stopping all sounds

GEMS has no distinction between music and sound effects, which means two music tracks can play on top of each other. You can avoid this by stopping all sounds by using the following command:

  • jsr _gemsstopall

Clone this wiki locally