Wednesday, July 22, 2009

Retuning an Underclocked Game Boy

The Problem
There is a modification to an original Game Boy that involves replacing the internal crystal oscillator with one of a different value, documented by the genius Gieskes. Often, a value of 2MHz is used to replace the default value of 4.194304 MHz because 2MHz crystals are easy to find in shops and on the internet, or at least thats what I do.

However, this creates a problem, in the sense that the crystal oscillator is responsible for controlling all timing aspects of the Game Boy including the frequency pitches of the pulse oscillators.

As a result, the underclocked Game Boy plays back just under an octave lower than its unmodified counterpart. This tuning difference is annoying and means that its not very satisfying to use an underclocked Game Boy at the same time as a normal Game Boy or any other instrument.


The Solution
The idea for a solution to this problem comes form Tom Gilmore aka 10k.

The easiest way to remedy this problem is to simply replace the tuning table inside of LSDJ with a newly created tuning table that uses 4Mhz as a master clock source (which is 2 * 2MHz) instead of
4.194304 MHz. As a result, a C3 will play back on the unmodified Game Boy as a C2, instead of some disgustingly out of tune B or something similar.

Open up the LSDJ ROM in a hex editor. I use Hex Fiend for OS X. Find the tuning table in the LSDJ, which starts just after location $6D30 with the bytes 2C 00 9C 00 06 01 etc. Select
216 bytes starting with 2C and 00.

Now, paste the following 216 bytes over that area of memory:

8900
F400
5901
B901
1302
6802
B902
0403
4C03
9003
CF03
0C04
4404
7A04
AD04
DC04
0A05
3405
5C05
8205
A605
C805
E805
0606
2206
3D06
5606
6E06
8506
9A06
AE06
C106
D306
E406
F406
0307
1107
1F07
2B07
3707
4207
4D07
5707
6107
6A07
7207
7A07
8107
8907
8F07
9607
9C07
A107
A707
AC07
B007
B507
B907
BD07
C107
C407
C807
CB07
CE07
D107
D307
D607
D807
DA07
DC07
DE07
E007
E207
E407
E507
E707
E807
EA07
EB07
EC07
ED07
EE07
EF07
F007
F107
F207
F307
F307
F407
F507
F507
F607
F707
F707
F807
F807
F907
F907
F907
FA07
FA07
FA07
FB07
FB07
FB07
FC07
FC07
FC07

Save your ROM file, flash it onto a cart and then pop it into your underclocked GB. Enjoy! You can sync your normal Game Boy as slave from your underclocked Game Boy as master.


Demo Video

8 comments:

nitro2k01 said...

Or, you can use the microtuner tool, as described here.

Sebastian Tomczak said...

Yes, I've blogged about that microtuner tool too, Nitro, but - it seems it hasn't worked for everyone and this is a very straightforward way of doing things (for me at least).

10k said...

The contrast in the value of the game boys pictured in the video was an interesting touch (assuming it is a GB Light).

10k said...

"June 25th 2009 8:33 PM - Re: [underclocking] tracking the elusive 2.097152mhz crystal oscillator" - Nitro2k01. Beaten! Funny part is I never read it.

10k said...

"June 25th 2009 8:33 PM - Re: [underclocking] tracking the elusive 2.097152mhz crystal oscillator" - Nitro2k01. Beaten! Funny part is I never read it.

Anonymous said...

thank you so much. Did you know if there is this kind of tricks for a 8Mhz crystal ?

Sebastian Tomczak said...

Hi, so in theory, the same pitch table should also work for an 8MHz clock, simply try out the above procedure because I haven't actually tried it out with an overclocked GB.

Cheers,

Dan said...

I tried this on version 4.0.5 and some of the coding was different, so literally pasted over the code starting from ---- C3 upto B.B and when i put the cart into my gameboy it would not boot up. Do you have the specific code for this version or any other versions? i would only need it for 3.8.7 and 4.0.5