This is a read-only archive!

Spriting and learning

In the mid-1990's I was really into Nintendo games, as was everyone. My favorite was the original NES Final Fantasy. Sometime in my teens I got my first computer, and I decided it would be cool if I had some sprites of that game on my computer.

Before

My first computer ran at 640x480 with 16 colors. I had Windows 3.1 and the most sophisticated image manipulation program around was MS Paint. How could I get sprites into my computer? Well, I had a strategy guide for the game, with blurry photos of all of the enemies, so I just opened up MS Paint, zoomed waaaaaaaay in, and drew all of the sprites pixel-by-pixel. Insane? Maybe, but it's a fun kind of insane.

This took about a year of off-and-on work, but in the end I had something I thought was great. I still have the file:

FF1

Note that my computer couldn't even produce sophisticated colors like "orange" and "brown", so I had to tile red and yellow together so it looks orange from a distance. Oh how computers have progressed since then.

At this point I loved computers but I literally didn't even know what programming was. I had never heard of the internet. I didn't even get a taste of programming until high school.

In 1999 I was in college but still largely ignorant of programming. I decided to start my first website, which was about the NES Final Fantasy that I still liked. I decided to put some sprites on the site. For the first version I chopped up my old image file from above into individual sprite files, but the quality of these was terrible.

So the way I got good sprites was by taking screen-captures of the game in an NES emulator, then in Paint Shop Pro I cropped out the backgrounds. This was much faster than hand-drawing, but it still took months.

This is an example of using a thousand-dollar piece of equipment as a hammer to pound in a nail. It's the most rudimentary form of computer use. It's the kind of thing I cringe at when I see coworkers do it today.

After

Last weekend, many years older and hopefully a tiny bit wiser, I pulled out my copy of the most recent remake of FF1, for the PSP. I decided it'd be cool if I could rip some sprites from this.

So, first I got an ISO of the game and mounted it loopback so I could view the files. In the ISO there's a 100MB BPK file. I didn't know what this is so I opened it in a hex editor and saw that it was some kind of archive. You could clearly see an initial list of filenames with byte offsets and some other flags for each, then a bunch of binary data.

A few google searches later and I found this where someone else had the same idea as I did. There's an extraction script there in some language I don't know, but it wasn't hard to figure out what it was doing.

So then I was going to write a script to extract the BPK but thankfully someone in Japan already did which saved me the trouble of even doing that. Some of the extracted files were themselves archives, but after running the script on its own output a few times I had a bunch of GIM files.

What's a GIM file? Never heard of it. But a quick google search for "GIM to BMP" will net you a program called gimconv. Sadly it's Windows-only, but a batch file or two later and I had a bunch of BMPs like this:

KURO

These files have solid backgrounds, but I want transparent backgrounds. But it isn't hard to make an image's background transparent in Linux using ImageMagick and its nice documentation. One snag is that all the images have different background colors, but I can tell ImageMagick to use the color of the top-left pixel as the transparency color:

for f in *.bmp; do convert -matte -fill none -draw 'color 0,0 replace' $f ${f/bmp/png}; done

Some of these images look like sprite sheets. So let's pick one, chop the sprites into individual files, then make an animated .gif from these sprites (while also adding a transparent border around it).

convert KURO.png -crop 32x32 +repage KURO%d.gif
convert -matte -bordercolor none -border 28 -compose Copy KURO?.gif -delay 25 -dispose Background KURO.gif

Giving us:

KURO

So after a matter of 2-3 hours (most of which was puzzling over some hex data and then googling around), I am already pretty much done. Barely any skill on my part required other than knowing what to look for.

The moral of this story is:

  1. The internet is awesome. It's easy to forget how much better life is with so much knowledge at our fingertips. I can't even remember what it was like without the internet and I'd never want to go back to that.
  2. Learning is fun. What was a year-long job became a few-minutes job with even a rudimentary knowledge of scripting.
  3. ImageMagick is pretty handy.
  4. Old school games are great. FF1 is still fun after 20 years. They keep re-making it for new systems for a good reason.
  5. I got a late start in programming. I wish I would've started at a younger age. Think of how much more I could've accomplished with my time. I'm still playing catch-up in many ways.
  6. Sitting here in front of 3840x1200 pixels worth of million-color monitor screen, typing a story people are going to read in a few minutes in countries I'll never visit, ripping sprites from a portable game device that's probably thousands of times faster than my old NES, I can't even imagine what we're going to be doing with computers in another 15 years.
September 07, 2009 @ 6:57 AM PDT
Cateogory: Programming

10 Comments

Nathan
Quoth Nathan on September 07, 2009 @ 9:41 AM PDT

Shouldn't the last part of 4 be "they keep re-making it for new systems for a good reason"?

Brian
Quoth Brian on September 07, 2009 @ 10:43 AM PDT

Yep, thanks for pointing it out.

Gen2ly
Quoth Gen2ly on September 07, 2009 @ 9:45 PM PDT

I remember the old NES days but never looked back. Looking back, good times. That sprite image you did is insane... but awesome. I got a thing for icon design that I used to collect quite a bit, still drop in on artists like this one from time to time.

Probably messed up on the link, thought markdown be a little easier to do that.

Gen2ly
Quoth Gen2ly on September 07, 2009 @ 9:48 PM PDT

bah /o\

this one

Brian
Quoth Brian on September 08, 2009 @ 3:16 AM PDT

Markdown is OK, it's my explanation of it that sucks, sorry about that. Yeah there's something special about sprites and icons and such. Can't quite put my finger on it but sprite-based RPGs are great.

Ben
Quoth Ben on September 13, 2009 @ 7:43 AM PDT

Great post! Most people just blab, but you did something, and showed it.

Anonymous Cow
Quoth Anonymous Cow on September 18, 2009 @ 4:33 PM PDT

^_^ fun story.

alastair
Quoth alastair on September 20, 2009 @ 11:53 PM PDT

Does this mean you're going to put the PSP FF1 sprites on your FF classic site? :D

Brian
Quoth Brian on September 22, 2009 @ 4:43 AM PDT

Yep. :)

Rasputin
Quoth Rasputin on October 08, 2009 @ 10:41 PM PDT

This is awesome, I've been trying to rip the battle sprites of the main classes and thanks to this little tutorial, I have! Now all we need is one on Final Fantasy 2 for the PSP. Think you could do that at some point? I wanted the battle character sprites from that too.