The Gameboy program Pounder by 8cylinder lets the user trigger drum samples using the buttons and the directional pad. By hacking and replacing certain sections of the Gameboy ROM file, it is easy to replace the samples that are triggered. The aim of this post is to get you started - there are few different ways of going about replacing the sample data inside of the ROM.
What You Will Need
• Max/MSP or Max/MSP runtime (free) from Cyclin74.com
• The audio2fourbits_cr.maxpat Max/MSP patch
• Spreadsheet editor such as Microsoft Office or Open Office (free) from OpenOffice.org
• The dec2hex.xls MS Excel spreadsheet
• A hex editor such as HexFiend for OS X (free) from RidiculousFish.com
• The pounder2_001.gb Gameboy ROM file from 8cylinder
1. Load and Create New Sample
Load your new sample into the Max/MSP patch audio2fourbits_cr.maxpat. Hit the READ button. Set the length of samples (in the SAMPLES field) to two times that of the length as listed in the sample position in the ROM file (see Sample Position section, below). This is because we are using 4bit samples, and we can fit two 4bit samples into each byte. Hence, we are fitting twice the number of audio samples into the sample area as there are bytes. For example, sample #0 takes up 468 bytes, so we must set the SAMPLES filed to 468 x 2 samples = 936 samples.
The OVERSAMPLE field lets you adjust the sample rate of the sample output data. For example, if your original sample has a sample rate of 44.1KHz, an OVERSAMPLE rate of 2.0 will divide your sample rate by 2 and so on. Once you have adjusted the SAMPLE RATE field, hit the STOP then the CLEAR button. Finally, hit the GO button. The sample is converted into 4 bit audio data.
Open the text object by double-clicking on the "text" object to the left of the READ button. Copy the entire contents of the text object into your copy clipboard.
2. Sample Position
The following list shows where each sample is in the ROM file. The following parameters are shown: sample number, sample length in bytes (not audio samples), sample offset in ROM file. As a reference point, sample #0 is equivalent to the sample that is triggered from bank A when the A button is pressed.
0 - 468 @ 16400
1 - 468 @ 32784
2 - 468 @ 49168
3 - 468 @ 65552
4 - 468 @ 81936
5 - 468 @ 98320
6 - 468 @ 114704
7 - (blank?)
8 - 469 @ 147472
9 - 471 @ 163856
10 - 469 @ 180240
11 - 468 @ 196624
12 - 540 @ 213008
13 - 470 @ 229392
14 - 468 @ 245776
15 - 540 @ 262160
16 - 1124 @ 278544
17 - 569 @ 294928
18 - (blank?)
19 - 89 @ 327696
20 - 49 @ 344080
21 - 534 @ 360464
22 - 900 @ 376848
23 - 613 @ 393232
3. Generate HEX Numbers in Spreadsheet
Open the dec2hex.xls spreadsheet. Delete all of the data contents of the column marked Data. Paste the contents of the clipboard to the column marked Data. The two columns marked High Nibble and Low Nibble will automatically re-calculate.
Copy the entire data contents of the two columns marked High Nibble and Low Nibble into your copy clipboard.
4. Edit the Game Boy ROM File
Find the offset location (as seen in the section Sample Position, above) for the sample that you are wishing to replace. Your hex editor will have a menu item to allow you to jump to a specific point in the ROM file. For example, sample #0 is located at an offset of 16,400 bytes. Set your hex editor to "overwrite mode" and paste the data from the spreadsheet.
Repeat these four steps to replace all samples in the ROM.