TRG for SEGA Master System / SEGA Game Gear is a simple tool for triggering audio samples in real time using the control pad. Works in an emulator and on hardware. This is a tutorial on how to insert your own samples into the software.
- TRG source code file (http://milkcrate.com.au/_other/chipmusic_software/sms/TRG_20110502.sms)
- Context editor (http://www.context.cx/)
- WLA DX assembler (http://www.villehelin.com/wla.html)
- Sample converter patch (http://milkcrate.com.au/_other/chipmusic_software/sms/misc/sample_converter.maxpat)
- Max/MSP runtime (http://cycling74.com/downloads/)
1. Prepare Samples
Make your samples as loud as you can. Clip them if you want - keep in mind that the SN76489 plays back samples very quietly! This is especially the case if you are using a Game Gear with dying capacitors in it - these are notorious for causing a very quiet sound output.
2. Prepare Software
Set up WLA DX / Context as outlined by Maxim in his How To Program tutorial (see here: http://www.smspower.org/maxim/HowToProgram/SettingItUp).
3. Import a sample
Use the Max MSP audio sample converter patch to convert a sample to a text format. Open a sample by using the read button, and navigate to the sample.
Use the number box to set an undersampling ratio. The default is 8. The higher the undersampling ratio, the less data the sample takes up - but the lower the sound quality (as the effective sampling rate is lower). I suggest a ratio between 5 and 10.
Click on the toggle connected to the metro 1 object. This will convert up to 1000 samples of your chosen sample - at the chosen undersampling ratio.
Double-click on the on the text object to open up the converted sample data. Copy the sample data.
4. Format the Data
Format the data by pasting it into a new text file using WordPad or TextEdit. Truncate the sample date if there are superfluous 7's at the start or at the end of the data in order to save space in the ROM.
Then, using the find and replace function, replace all space characters with a comma, followed by a space.
5. Insert the Data into the Source Code
Open up the source code .asm file in the Context editor. Copy the formatted audio sample data from the text file to the .asm file. First, choose a sample that you want to replace. In this example, we will use sample number one. Find the start of the sample, which is denoted by the label "Sample_01". Delete the existing data (which is found after the .db definition, below the "Sample_01" label).
Paste the new data after the .db definition.
Repeat steps 3 - 5 in order to add additional samples.
6. Compile a New ROM
Use the compile function of Context / WLA DX to create a new .SMS file that can be used with an emulator or on hardware.