Friday 1 April 2016

Gameboy Tileset Viewer

Continuing on from my experiment last week to load and display the byte values of binary data as coloured dots, this week I've created a picture viewer. My dataset of choice continues to be from the Pokemon Blue Gameboy cartridge. Mostly for nostalgia's sake and also because at less than a Megabyte in size there is a chance to get an overview of it in its entirety onscreen at once.

The original gameboy had a black and white screen which could display 4 colours; black, dark grey, light grey and white. (Although due to the LCD used they tended to be a bit greenish. This meant a pixel's colour could be defined by 2 bits. The Gameboy used a tiling method to display images with each tile composed of 8 by 8 pixels. Essentially this means each tile is 16 bytes in memory. (for a more in depth description see here )

It took me a while to get my JavaScript code to view each part of the input data as being 8-bits but once I got it to stop defaulting to 16-bit it was easy to iterate over an entire bank of the cartridge to get this:


On the left is a rough overview of the 25th, 16KB block of rom. On the right is that same binary data converted into Gameboy tiles. It's so cool to see recognizable tiles from the game! There are grass, flower and tree tiles. Some tiles used for interiors, even the entire ship the SS Anne : 3

What really intrigues me is the tiles which stand out as being identifiable as real tile data, as opposed to some other kind of binary data are visible within the overview on the left. Generally tile data is higher byte values, hence lighter. I expect you could do some neat statistical analysis to automate identification of tile data.

Anyway I'll continue my foray into nostalgia driven disassembly; I've had a look for text encodings and have tried to work out the basic formatting and scripting functions which Pokemon Blue had. ie. printing the players name, playing 'item get' noises and clearing the textbox. Perhaps more usefully I've been looking at the instruction set of the Gameboy's processor, the Z80 (or some variation) I might end up decompiling machine code into actual assembly! :D

No comments:

Post a Comment