1st gen Pokémon sprite decompression algorithm in Rust
Go to file
2021-05-18 20:55:57 -05:00
src Fix overflow handling when calculating the offsets 2021-05-18 20:55:57 -05:00
.gitignore Ignore .bin files 2021-05-16 23:26:21 -05:00
Cargo.lock Update project name 2021-05-16 23:28:03 -05:00
Cargo.toml Update project name 2021-05-16 23:28:03 -05:00
README.md Update README.md 2021-05-17 04:44:36 +00:00

1st gen Pokémon decompression algorithm in Rust

This is a mini-project I made just for fun and for practicing with bitwising and the Rust language. The code is not the cleanest ever, but I have plans to improve it later.

The 1st generation Pokémon sprites are compressed with a very interesting algorithm very well explained here and here by the Youtube channel Retro Game Mechanics Explained. He also has a Github profile and he made a tool which was very useful for me during the development of this mini-project: http://www.dotsarecool.com/rgme/tech/gen1decompress.html.

I tried to implement the whole algorithm by myself (by only taking the videos as reference) but I struggled a bit with the delta-coding step, so I took some reference from this project (Thanks btw!).

I haven't tested every single Pokémon yet (I wanna try if this works with glitched Pokémon). Feel free to test it with other pokémon!

Usage

You will need to have Rust installed in order to compile the project.

cargo run compressed_pokemon_file
// or
./pokemon_sprite compressed_pokemon_file

Where can I find a compressed Pokémon file? I wanna catch em' all!

I'm not sure if I can redistribute this files, but if you have a ROM of Pokémon Yellow (US) you can extract this (misteryous) Pokémon with this command!

dd if=pokemon-yellow-rom.gb of=who-is-that-pokemon.bin ibs=1 skip=183637 count=244

Or instead, you can use the Alex's tool to dump the sprites from a ROM file or for compressing your own images: http://www.dotsarecool.com/rgme/tech/gen1decompress.html

Contribution

As I mentioned, this is a project I made just for fun and practicing, but PR's and suggestions are welcome!

Checklist

  • Test with more Pokémon (only Pokémons with mode 2 and 3 tested)
  • Use (or create) a pixel engine to render the sprites instead of drawing them on the terminal
  • Clean the code
  • Parameters for changing the sprite size or color palette