Custom PCM sound effects

From Glitch City Wiki
Jump to navigation Jump to search
This article is outdated

Feel free to update it.

Reason given: Proposed adjustment for more accurate sounds


Arbitrary code execution can be used to create custom PCM sound effects (WAV like audio) in the Game Boy Pokémon games. This type of exploit was also previously achieved in MrWint's Pokémon Yellow multi-game TAS.

English Yellow

YouTube video by ChickasaurusGL


Note this method is outdated. A newer method was proposed for more accurate sounds.

1) Set up ACE

2) Set up an ACE memory editor

3) Write the following routine at your access point

061C219F7ECD843E3E02EA00401E003E

002100A019191946232A666F0E040D28

05CD641E18F8F3C5E53E80E0263E77E0

24AFE01A2130FF11FCCB7E12133EFF22

7DFE4020F53E80E01AF025F644E0253E

FFE01B3E20E01C3EFFE01D3E87E01EE1

C1CD5001AFEAF3C0EAF4C03E80E026A

FE01A2130FF11FCCB1A13227DFE4020F

83E80E01AF025E6BBE025AFEA2AC0EA2

BC0EA2CC0EA2DC0F0B8FBC9

(This is a modified version of 3C:4000; that plays the first PCM audio at 2:A000 in SRAM)

4) Get a very short music file you want to use as your Pikachu cry (about 1 second long)

5) Use ffmpeg and downgrade the music file to 4-bit uncompressed PCM, 6000hz.

If not familiar, put ffmpeg in the same folder as your music file, open Notepad and write the following;

ffmpeg  -i "[original music filename with extension (e.g. .mp3) here]" -ac 1 -ar 6000 -acodec adpcm_ms [desired filename].wav

pause

(The pause is optional and is in case there are any errors, otherwise the command prompt will exit automatically. Here there is a new line before pause.)

Save this file as crymaker.bat or anything .bat.

Then, run the .bat file (again it will need to be in the same directory as ffmpeg and your music file).

(Note: This is not the correct file format Game Freak used, but this works)

6) The new .wav file will probably not work properly on some operating systems, but if everything went to plan it will work when you import it in the game. The file size of the wav file should be quite small. You will need to use a hex editor (such as HxD, it's free) to copy all the bytes after the "data" ANSI string (for my example this is at 0x98). Save this somewhere (e.g. Pastebin if you want).

7) Use ACE to write the following at 2:A000; 02 03 a0 (+two more bytes that represent the hexadecimal file size. Use Windows Calculator to take away the end of the file offset and e.g. 0x98 on the hex editor, then add 1 to get the file size. Then swap the digits.

In order to write at 2:A000, if you are using BGB emulator, go into the debugger and double click on DA8C (which is just after opening the SRAM bank in your code), then activate ACE early and BGB should pause. Afterwards you can right click and select "go to...". Enter 2:A000, and select OK to jump there in the debugger. From there you should be able to write those bytes (where otherwise they would likely be unchangable FF bytes due to locked SRAM). It is also possible to write to this region of SRAM without a debugger.

8) At 2:A005 paste the bytes from earlier. Usually, there should be just enough space in SRAM for this (SRAM is A000-BFFF or 8192 bytes). If not, get rid of unneeded groups of 00 bytes in the file and modify the file size in step 7 accordingly.

9) Save the game and reset. Now when you run your code, your custom cry should play.