.Mod to Gameboy Music Conversions
By Thomas Engdahl ***Under Construction***(But has a start and a finish)
This page will have tutorials on:
Finding, creating, transposing .mod files for GameBoy music.
Contents
About .Mod Files
Getting .Mod Files
You will need the mod tracker. You can get this from http://www.modplug.com/
A good place to get mod files. http://modarchive.org/
Understanding .Mod Files
Use the mod tracker to edit and look at .mod files. Make sure there are 4 channels. These channels correspond to the 4 sound circuits in the game boy. The conversion will only care about the note pitches, instrument number, and volume. All other effects will be lost in the conversion.
=== The Conversion == Once a song is ready to be converted use the mod2lp.exe file to convert the mod file into an assembly language ready table. You can get it here under projects: http://members.fortunecity.com/lemon26/
To use the mod2lp.exe file place the exe and the mod file in the same folder. Then go into dos and goto the directory. Then type "mod2lp -a 'filename' " That will convert your mod file into a file "songname".inc (make sure to inspect your file, the converter likes to remove pattern 0)
Making An Order Table
- Now you will need an order table. Here is an example. Tictacorder.INC
This file defines what order the music patterns are played in the mod file and can also be used to define where songs start with labels. If you watch the mod files play in the mod tracker you will notice that it will play 64 steps then goto the next pattern. The row of numbers it plays though are the patterns. Each pattern has 64 steps of unique data and can be played or repeated in any order.
The Player File
- Here is the player file. You will need to edit the global values on the top and then include this in your main game file.
- Edit the global tempo,steps per pattern, and total number of patterns. Also the function just below will allow you to swap channels aka route mod channel X to gameboy sound circuit Y. Say your drum stuff in the mod file is in channel 2, then you would want to move that channel to voice 3(0-3) which is the noise circuit. Then you would call voice 3 after you load A register with 1(again the offset,1=channel2).
A Musical Function Include File
- Here is an include file I created for the player. There is a sound interrupt macro that works with the player to make sure sound effects are not affected by the music. Look at the 2 sound effects defined in the include file. Before the sound is sent to the sound circuit, call the "setchint \1" macro where 1 is the channel your sound will be. The set and release music interrupt pauses the music. There is also a change song macro which could easily be used or converted for a change tempo macro.
Editing Your Main Code for Music
- Next you will need to include the music table, order, player, and music files into your game. Also you will need to include the lemon_play call in the vblank interrupt. Here is an example with comments.
- There are some other considerations you must make before you use the lemon player code as I have realized when helping Adam add music to his code. Make sure you enable the V_blank interrupt and turn it on AFTER you have loaded your tile data otherwise the graphics will halt. Also you will need to call "lemon_init" during your initialization process in order to initialize the lemon player (so the song will start at the beginning). Yet another thing to look out for; the Lemon player variables start at $D000, the beginning of that ram sector. If you have make variables there you will need to move your variables or move the variables of the lemon player by editing the section at the very bottom of the player file where the variable section is defined.
After making these changes in Adam's game he was able to get the music going no problem.
Overview
Mod to lp1. This creates "songname".inc from mod file. This is music data for $4000 section
Create an "songname"order.inc to tell the player the order the patterns should be played in. Add labels where you want songs to start or if you want to jump to that position in a song.
Condition your player file: Pick the default tempo, total number of patterns, steps in a pattern (default is 64). Also use voice order function on top to pick where which mod channel goes to which gameboy sound circuit.
- Condition your main code file. Make sure to include the music macros if you want sound effect interrupts etc. Make sure to call the lemon_play in the vblank (Use my function to be safe and push all your registers b4 you do it, which is done in the function) Make sure to include the player file. Make sure to add the "songname"inc and "songname"order.inc in the $4000 section of your code.
Assemble the code and enjoy music!
Remarks and Examples
- Hope this helps you out. I know this was brief but it should get you mostly through the process. The hardest part I think for the beginner is getting the mod file the way you want it. I recommend making a mod file from scratch. Make row row your boat and see how it reacts to the player. There are a lot of issues that arise with trying to convert an already made mod file from the internet to the gameboy. I have an advantage there because I already know mod files fairly well. I am going to post this zip file. It has the left over materials from making songs.
There should be in each folder
1.original mod
2.edited mod for mod2lp1 ("modname"ed.mod)
3."songname".inc
4."songname"order.inc (you can really just name this anything, I put the word order to keep track.
5.A custom player file. (not the playerT3 linked above)
6.A source file that is designed just to play music only. "songname"song.asm
7.The assembled source just to test song. "songname"song.gb
Enjoy and try to use these files to get familiar with how things will sound.
You can listen to some of the songs in the music package as Mp3's here on my Blog:
http://cratel.wichita.edu/blogs/tgeegt/2008/05/07/gameboy-music/