Emulation64.com  ::  EmuTalk.net  ::  DCEmu.co.uk     About  ::  Hosting  ::  Donate 
Home Files Forums Reviews Guides Articles Interviews

Welcome to the Emulation64 Network


    Wednesday, April 02, 2014
Emulating Game Boy Games With Custom/Colorized Sprites

Home Blog
::Developer Shonumi
:: Emutalk post

Emulating Game Boy Games With Custom/Colorized Sprites

When it comes to emulation, one could certainly think that weíve explored just about every aspect of the Game Boy so far. From multiplayer over the serial port, the Game Boy Printer, the Super Game Boy, the Game Boy Color Infrared Port, Rumble Carts, to even the accelerometers in Kirbyís Tilt Ďní Tumble: there isnít much emulators canít handle. However, there will always be new territory to uncover and explore, especially for those with creative minds. In the form of an enhancement or modification, custom sprites is one such example. An emulator with custom sprites has the ability to replace a gameís native graphics with data selected by the user. To my knowledge, no one has ever implemented such a feature into a Game Boy emulator. Until now that is.

Art History 101:

The original Game Boy, Game Boy Pocket, and the Japanese-only Game Boy Light were only capable of displaying graphics using four different shades of gray (this applies only to background tiles, sprites were restricted to 3 shades with one shade reserved for transparency). Each pixel was either completely on, 2/3 on, 1/3 on, or completely off. The monochrome palette lasted until the Super Game Boy came out, allowing games to be played with 32 (sometimes garrish) colored palettes, as well as custom ones. I never owned one, but I do remember having quite a few ďPlay It LoudĒ poster sheets that came with my Game Boy games advertising the Super Game Boy. Eventually the Game Boy Color came out allowing games to be played with colored palettes as well. Still, games that were not Game Boy Color only or backwards compatible games that did not fully utilize the Game Boy Color never really achieved significant colorizations, at least nothing that made them on par with native Game Boy Color games. There is a Game Boy Colorizer ROM hacking tool that aims to help hackers convert old DMG ROMs into fully capable GBC ROMs, but from what I have heard, it can be finnicky at best.

Currently, I am working on my own Game Boy emulator that I plan to call Game Boy Enhanced. It isnít a very original or clever name, but this is my first emulator, so I can afford to be simple and straightforward. Since the project will introduce me to emulator programming, I do want it to be as accurate as I can make it, however, I donít shy away from graphical enhancements when it comes to emulation. This is the future after all, so we might as well be able to make things shiny if we want to. At first, I was planning to have the usual assortment of enhancements that nearly every other emulator has: 2x-3x-4x nearest neighbor scaling, various scaling filters (the HQ family, SuperEagle, 2XSai), save states, and maybe built-in sound-ripping. However, one of the regulars on the Dolphin emulator forums suggested that it would be nice to allow custom sprites as a feature, and this got me thinking.

Dolphin is a pretty advanced emulator; it allows users to dump textures for games, edit them, and then load them into the game. This activity is quite popular in sprucing up old N64 games in the N64 emulation community, and the practice has extended to Gamecube and Wii games now too. I figured it would be possible to do the same with Game Boy Enhanced (GBE for short). Although there are a number of more pressing things to program for GBE, I decided to see if I could implement it anyway. The general theory is similar to how Dolphin operates. Based on the spriteís raw pixel data, GBE generates a unique hash to represent it. GBE stores every hash in a list. When drawing a sprite, GBE compares the current hash against the list. If the hash is in the list, rather than drawing the pixel data obtained from Video RAM (VRAM), GBE will load the custom sprite data from a file. I will go in-depth more about that, but first GBE needs to allow users to get the sprites to modify in the first place.

Taking a dump:

GBE needs to dump the sprites as the game generates them. The general idea is to get the hash and compare it to what we already have in the list. If the hash is already in the list, thereís no need to dump the sprite again, so GBE ignores it. When itís a brand new hash, GBE pulls the pixel data from VRAM and then saves that data to a BMP. The trick here is to make sure that the file is going to be as unique as the sprite itself, so GBE names it after the hash. This will help when loading the modified sprite as well. Since this work was fairly experimental, the hashes were simply 128-bit numbers converted to hexadecimal. Thatís enough to create a unique hash for every possible 8◊8 sprite possible as it takes 32 bytes (128-bits) for the Game Boy to represent an 8◊8 sprite. 8◊16 sprites have yet to be implemented in GBE, so Iím not worrying about that just yet.

Now here comes the fun part: editing tiny 8◊8 bitmaps. Obviously there are a couple of challenges. The first is in determining what youíre looking at exactly. If you donít have a discerning eye, it can be quite difficult to see the sprites youíre after. Of course enlarging the dumps in an image viewer helps, but most larger sprites are a combination of the 8◊8 sprites. Visualizing which ones match together is not unlike a puzzle game in and of itself. The next thing to consider is how you want to edit these sprites. Since whatever data entered here supercedes the Game Boyís color choice, custom sprites are not concerned with things like the palette. The colors in the BMP file are the final colors that will be output to the screen. If the custom sprites decide not to add color, they need only determine what shade of gray each pixel should be, irrespective of any programmed palette.

It takes a keen eye to edit 8◊8 sprites like this. Here we have Mario, obviously.

Once the sprites have been dumped and edited, the next step is to load them back into the emulator. Itís pretty much the reverse of what GBE does when dumping them. Whenever new sprite data is generated, GBE generates a hash for that and tries to load a BMP file named after that hash. Once the BMP file is loaded, it gets stored into a cache. GBE then updates a list of which hashes have already been used to get custom sprite data. The list ensures that the same hash isnít used again to load the BMP file since the cache already contains the custom sprite data. Whenever GBE draws a sprite whose hash matches an entry on the list, GBE draws the custom sprite data pulled from the BMP instead of VRAM. With this, GBE effectively replaces the original pixel data without affecting the rest of the game.

The whole process of custom sprites:

Look at all the colors

The custom pixel data can be anything we choose; it can even exceed the color limits of the Game Boy Color. The limitations enforced on the original system need not apply to GBE, since the emulator has the final say over graphical output, not the original hardware. Itís easy to have a sprite use 10, 20, or even 30 different colors. Although it takes a bit of creativity, thereís nothing stopping sprites from taking on a 16-bit look and feel. The only issue is the screen size (160 x 144 pixels) which makes for relatively small sprites.

However, the possibilities donít just end there. We can completely mod Game Boy games with this method to create custom pixel data for anything. Background tiles are stored and processed in the almost exact same manner as sprites. The method of generating hashes for background tiles and replacing background tiles with custom pixel data is identical, so it wasnít hard to program GBE to manipulate the background as well. Now itís possible to fully colorize original DMG games in a reliable manner. And yet thereís more; consider that this isnít just a method a colorizing sprites, itís a way to make the sprites look like whatever one wants them to look like. How about Tetris with Poke Balls? Super Daisy Land wherein Daisy saves Mario? Master Chief as Mega Man? Anyone with enough time and effort could alter or create just about anything.

If GBE ever catches on, I would hope this to be a defining feature, as it could prove popular within the ROM hacking community (even though, technically, the ROM data is not touched with this process). GBE isnít quite ready for its public release as an open-source project however, as Iím reworking LCD emulation and increasing game compatibility at this moment, and most of the custom sprite code needs to be rewritten as well. It should up on Google Code within a month however, so anyone wanting to play around with this neat feature can have a go.

Other emulators are quite capable of adding this functionality themselves if so desired. The method described here is not specific to Game Boy Enhanced at all nor the original Game Boy games it emulates. GBC, GBA, NES, SNES, Genesis: basically any system that uses sprites can also use custom sprite data. As long as the emulator has some way to view the sprite data (which an emulator needs to, if it ever wants to draw that data onscreen), it can generate a hash and replace the necessary data. Thatís not to say it would be easy to implement in every emulator, only that such possibilities do exist. Personally, I think this is an exciting opportunity for people and communities that want to see new life breathed into games that are now getting to be decades old. It could add interesting twists to games that weíve already been playing for years. I very much look forward to seeing how people apply this technique in the future.

A video of custom sprites in action can be found on my YouTube channel. Itís only Tetris (and not my best game, mind you), and not everything is fully colorized. This is just a proof-of-concept demonstration until the underlying implementation is perfected. Still, it works, and thatís half the battle :)


File Releases

No Description in database.

No Description in database.

No Description in database.

No Description in database.

No Description in database.

Latest Forum Posts

How do you disable au ...
Last Reply: Broke_Artist
Replies: 0

OoT Lens of Truth tex ...
Last Reply: ZNemesis
Replies: 0

2020-10-23 Recent Rel ...
Last Reply: Robbbert
Replies: 0

SM64 Last Impact v1.2 ...
Last Reply: Billy2015
Replies: 2

2020-10-16 Recent Rel ...
Last Reply: Robbbert
Replies: 0

Latest Reviews

NDS - Okamiden
Created by WhiteX

Wii - deBlob 2
Created by WhiteX

Wii: The Conduit
Created by WhiteX

NDS: Hotel Dusk - Room ...
Created by WhiteX

NDS: Elite Beat Agents
Created by WhiteX

Support Guides

Created by Martin

Dolphin Emulator
Created by Martin

Nintendo DS Homebrew.
Created by WhiteX

PSX Plugins: Lewpy's Gl ...
Created by Dark Watcher

PSX Plugins: P.E.Op.S S ...
Created by Dark Watcher

Our Affiliates


44,062,837 Visitors To The Emulation64 Network

Copyright 1999 - 2020 www.emulation64.com