I had to remove this as a GBJam entry because it's not a game and it breaks the original content rule
Pokemon Red But the Music Isn't Chiptune
A downloadable ROM
This is a ROM hack (a modified version of the original ROM) of the Pokemon Gen 1 (Red/Blue) games.
It's been modified to play high quality songs in place of the original chiptune-style music. It's been tested on a real Gameboy Color: https://youtu.be/gsRcPXIWDoM
This is harder than it sounds. The Gameboy has four "voices" that can make sounds - two square wave generators, a white noise generator, and a "custom waveform generator". The waveform generator, used as intended, lets you pre-program a waveform like a square wave, or a sawtooth wave, or something resembling a particular instrument, and then play it at various frequencies. It can play a 32-sample loop of 4-bit samples.
Instead, we are updating the waveform every 32 samples, so each sample is only ever played once. This gives us the ability to play any 4-bit audio we like. However, 4-bit is not very good audio. So we also change the volume control, which ranges between 1 and 8, every time a sample is played. This gives us a far wider range of values, allowing something approximating 7-bit audio. I've used this technique in the past on my Steamed Hams project (https://ekimekim.itch.io/steamed-hams-but-it-plays-on-a-game-boy-color-audio-onl...), and credit goes to this TASVideos run (http://tasvideos.org/3358M.html) for the original idea.
This was not straightforward to implement while not disturbing the existing ROM's logic, and you can consult my commit history for the gory details. Some highlights include porting the original Gameboy palette swapping code to use Gameboy Color palettes instead (though it's all still black and white), running the CPU at double speed in order to get the extra CPU time needed for the audio updates, and timing an OAM DMA process down to the cycle so that it only barely fits in between one audio update and the next.
The audio I chose to replace the original music with is mostly drawn from covers of those original songs.
If you would like to make a version with your own songs, the code is available at https://github.com/ekimekim/pokered (though the music assets are not). The repo is set up for you to easily pull additional tracks from youtube or other sources.
The code is based off the excellent disassembly project https://github.com/pret/pokered. This project would not have been possible without their efforts to understand and document the original ROM.
It should be noted that there are a number of limitations with this ROM:
* In stereo, music only plays in the left ear. Sound effects only play in the right.
This is required due to the abuse of the volume control to get more sample range, which would distort sound effects if they shared the same volume control.
Left and right volumes are controlled independently.
* Cable club / trading will not work and may crash your game
* There is only room for ~10min of audio in the cart. Some songs were cut and replaced with existing songs.
* Because all the music I'm using is copyrighted, I can't include it in the repo.
I hope at some point to make a version that sources entirely from online sources so anyone can build my version without needing the tracks on my local computer.
* This isn't super well tested, you'll probably find bugs. For a start, something's buggy with the battle menu, causing a audible artifact. I've run out of time to fix it.
And just in case anyone gets the wrong idea, I don't think there's anything wrong with chiptunes. It's a genre I love and I think the original pokemon soundtrack is great.
I did this less because I felt there was anything wrong with the original ROM, and more just to prove that I could :D
Download the ROM and play in your Gameboy Color emulator of choice.
I've tested it with Gambatte (https://github.com/sinamas/gambatte) and on real hardware, but this ROM may strain many emulators due to its tight timing and use of obscure behaviours.