Gameboy project week 8: The white Nintendo Power official flash cartridge, a tale of reverse engineering, sweat and tears

February 25th, 2013

npdump-130224 026

This week’s project concerns this cartridge, the official Nintendo Power flash cartridge. It used to actually be sold by Nintendo for 2500 yen and you could by games from a special kiosk starting at 800 yen at the Lawson department store. (About US$27 and US$9 respectively at today’s exchange rate.) The kiosks are long gone, but the cartridges remain in the wild. (However one page in Japanese from the time remains. It mentions how the launch is delayed because of the earthquake in Taiwan, the massive 921 earthquake)

Since these are flash cartridges they are in theory writeable, which would make them useful for, for example Little Sound Dj or other homebrew software. However, writing to them has proven difficult. The currently only known way of writing to them is with a software called FMGBx by Mootan. The program works but requires flasher hardware that is difficult to get and and in all cases are using an LPT port interface. Options include Bungs GB Xchange, a modified GBA flasher and two homebrew solutions using discrete 74hc logic. Clearly, there’s room for improvement.
Read on…

Gameboy project week 7: A ROM for showing custom graphics

February 19th, 2013

As per usual, this week’s project is fashionably late. This week’s project is an image viewer ROM which you can use to show custom graphics on the screen. This is for example useful for modders who want to display a logo on the screen when doing a photoshoot. I’ve been making these ROMs for people on request, but even so, I have been limited to using an old DOS utility (yes, DOS, not just command line) called PCX2GB. However, this application is slow and buggy, and with the advent of 64-bit operating systems, DOS applications can no longer run natively. So for every one of those ROMs I’ve made, I’ve had to start DOSBox, then include the files that PCX2GB output into the project and recompile the ROM.

This project sets out to change that. The project consists of two parts. A Gameboy ROM which can be patched with one or more images, and Python script that converts the image to the Gameboy tile format and does the appropriate patching. The result is a Gameboy ROM you can use to show the images.


The patcher is a Python script, which means you need to install Python to run it. You should install the 32-bit version of Python 2.7 — the one marked x86 instead of x86-64. Sorry to those who prefer 3.x.
Additionally, you need PIL, or Python Image Library which is used to load the image files.

How to use the patcher

To use the patcher you need to prepare as many images as you want, which are exactly 160*144 pixels and color reduced to contain a palette of exactly 4 colors/shades of gray. The actual color depth of the file can be anything, as long as the image contains exactly 4 unique colors. The image can be in any format that PIL can load, which is almost any format. Avoid using JPEG images however. Use PNG, GIF or BMP.

When you have correctly installed Python 2.7 and PIL, you can use the patcher by giving the following command, with sample output:

python image1.png image2.png image3.png
===Processing image1.png
Optimized image to 127 tiles.
===Processing image2.png
Could not optimize image to below 256 tiles. Image stored as 360 tile image.
===Processing image3.png
Warning! Image has only 2 unique colors (instead of exactly 4.) Color table will
Optimized image to 5 tiles.
===Processing image4.png
Could not optimize image to below 256 tiles. Image stored as 360 tile image.
===Processing image5.png
Could not optimize image to below 256 tiles. Image stored as 360 tile image.

The first agument, is the name of the GB file to be produced. This is then followed by any number of image file names (up to potentially 256 images.) The output tries to be informative about what the patcher is doing.


imagerom.gbbase is the actual viewer code. This is used as the base ROM for the finished product, thus the different file extension. If you run this standalone (which there is no point in doing) you will see an X shape and hear two dissonant tones, as a warning message.

The Gameboy software

The Gameboy software is dead simple. Press left or right to scroll through the pictures or press A to invert the palette

Note on the inner workings of the patcher and ROM

The Gamboy graphics hardware is working with tiles, which are addressable 8*8 pixel blocks. If an image has repeated instances of the same 8*8 pixel area, those can be addressed as the same tile. The patcher tries, if possible, to “compress” an image this by removing redundant tiles. However, if an image contains more than 256 unique tiles, it instead displays the image with no repeated tiles, for a total of 360 tiles being displayed on the visible area of the DMG screen.


The download also comes with a cople of image that you can play around with until you make your own image.

Gameboy project week 6: Can I have an A-MEN?

February 11th, 2013

Fixed the download link at the bottom of the post.

I’m tired. I need a break. What better choice than the amen? Probably a dozen, but nevermind that.

This week’s ROM is a sample masher that lets you apply live effects and rearrangement to a loop. As such, it’s using the wave channel. During the development of my sample playback routine, I accidentally discovered a solution to an old problem. The wave channel on the Gameboy has a buffer containing 32 samples, or 16 bytes which is normally used to store a repeating wave form such as a sawtooth wave, square wave or sine wave. However, if you continually reload the buffer with new data, you can play a sampled waveform. This is all well except that the channel needs to be stopped before the buffer can be reloaded. The problem is that this causes a small spike in the waveform. It is noticeable on a DMG, but completely abhorrent on a GBA, to the point of making kit instruments unusable. I found a solution to this problem which is simple and elegant, which is to simply turn off the channel in ff25, the sound routing register, while the buffer is being refilled.

With some swift work from Johan, this fix, which I call the antispike fix, is now included in the latest version of LSDj, 4.7.0. And kit instruments now sound eh-ok on GBA.

So, this week’s ROM is a simple, GUI-less ROM which lets you process a short loop, for example an Amen. This is another “failed” project in that it doesn’t have all the functionality I originally wanted to include. Here’s the functionality in this version of the ROM:

  • You can press start to start or stop playback of the loop.
  • The loop can be freely pitched by pressing select+up/down.
  • While the loop is playing, the ROM sends out an LSDj compatible sync signal on the link port.
  • You can press the D pad to rearrange the loop in 16th “slices”.
  • You can apply effects by holding either B or A, or both. B enables a granular/repeater effect. B+up/down controls the repeat size. A enables a stutter effect. A+left/right controls the stutter length.
  • Effect values can not be changed while one direction on the D pad is held down. While this might sound strange, the purpose of this is that you could be able to “roll” around on the D pad to mash the beat while an effect is triggered without changing the effect values.
  • Finally, you can press select+start to enable a “special” effect. When this effect is active, the pitch of the wave channel does not follow the general pitch of the loop. This causes a phasing type effect when adjuting the pitch.

Sound examples, some notes on the development process as well as information about how to replace the sample with your own sounds will follow shortly.

Fixed link: Download

Gameboy project week 5: LittleFM 0.5 (finally) released

February 4th, 2013

This week’s project is (again) slightly late, but hopefully worth the wait. This is the latest and greatest version of LittleFM, and alternative file manager for LSD. Here are the key features in this version:

Key features

  • LittleFM now comes with a Java based patcher application for easy application to any unpatched LSDj ROM, including (most probably) future versions. No more IPS patches that only work with a single version of LSDj.
  • LittleFM is fully Drag’n'derp compatible. This includes interfacing with the virtual “file system” of the Derp and making sure that any song data stored in flash will be copied back when you copy the GB file off of the cartridge.
  • LittleFM now supports song trading over a link cable. Currently only in the form of transfering a whole 128 kB sav at a time, but this may still be useful for backups and redundancy.
  • LittleFM now checks that the SRAM is ok, both in terms of hardware and corruption. If the SRAM is corrupt or uninitialized, LittleFM will offer you to initialize it, but also to leave it as is. If the SRAM is malfunctioning on the hardware level, the program will halt with an error message.
  • The stupid screen scroll bug is gone! You can now scroll to the bottom of the song list in SAVs with 32 songs, without problems.

I’ve also made a number of under the hood tweaks and small bug fixes.

Some notes on the features

ShitStrapOn, the patcher application

If you have Java installed, starting the application should be as simple double clicking the file. Should you need to execute it manually from the command line, you should be able to run it with something like java -jar ShitStrapOn.jar

The patcher will ask for three things, a clean LSDj ROM, the file, and a location where to sav the output. However, it will search for and not ask for it, if the program finds the file in the same directory as the .jar file. A clean LSDj ROM means one that has not been patched with LittleFM and does not contain any LittleFM save data in ROM. The ROM may still have ny number of kits, so long as there is one free slot where LittleFM can reside.

The name originally meant bootstrap for Shitwave. Since, then, however, the project has come to be used for patching LSDj ROMs with LittleFM. If you’re offended by the name, (or the subtext, a dirty dildo in LSDj’s ass,) too bad for you.

Link cable support

LittleFM sav trading
The link feature is a hardware feature, and any attempt to use it with any emulator is likely to end in missed bytes and tears. In my experience so far, it works perfectly both between a DMG and a DMG, and a GBC and a DMG. A GBC can send data about twice as fast DMG. (Well, it can transmit much faster than that, actually, but the *2 mode is what I’ve found to be safe for these transfers.)

LittleFM will show a progress bar as the transfer progresses. If all is well, both sides will move their progress bar in synch, and will both show OK on their respective side. If a transfer is stalled, it is safe to turn off the Gameboy, as long as no data is currently being actively transmitted or received.

You can use the Nanoloop MIDI adapter with, sort of. Sending data from the PC usually works ok-ish. However, make sure that the receving Gameboy shows ok at the end of the transfer, and that songs load correctly when the transfer is finished. Receiving data from the Gameboy to the PC can work but is extremely touchy. You may lose bytes in transit, with or without an error message. Be extremely wary of corruption, and make sure the received file is 131072 bytes big. Not a single byte less or more! Remember, unlike LSDj’s own file manager, LFM will give you an error on almost every kind of corruption, so use it to detect errors early.

Please also the previous post about LittleFM 0.4.The same basic precautions apply. Pressing erase flash in the Bleepbloop/Smartboy etc type flasher application will delete all songs stored in flash. Save project will overwrite whatever was in that flash slot before.

Have fun and be safe, and report any issue to me.

Download LittleFM.

And a quick plug: If you have an older flash cart (for example belonging to an older LPT port flasher) then I would like to borrow the cartridge for a while for science, to make it work well with LittleFM and other software I have in the pipeline.