Pokémon Crystal disassembled source code
github.com
github.com
This allows for a really special type of awesome when you're working on fan translations and ROM hacks. You actually have the opportunity to analyze the work of the developers you idolized when you were younger, and celebrate a their clever hacks or curse them for their spaghetti code, 15 to 25 years later. Furthermore, you can contribute your own clever hacks to the code base.
I know there are a few glitches and bugs, but it's still amazing to me that I can't think of a single 8 or 16 bit game published on Nintendo or Sega's consoles that had game killing bugs during normal gameplay. They didn't lock-up, reboot the system, glitch out, etc. Even when monkeying around with the weird glitches, the games stayed pretty rock solid.
I know today's games are incredibly more complex, but I don't think they go through the rather rigorous gameplay testing of those old days.
(then again, it was every kid's dream to be a gameplay tester, until they found out it was a minimum wage job that involved following a specific script to test a sprite collision bug on level 5 of Yo! Noid for 8 hours straight)
These look like labels and comments to me:
https://github.com/kanzure/pokecrystal/blob/master/engine/ti...
https://github.com/kanzure/pokecrystal/blob/master/battle/ai...
https://github.com/kanzure/pokecrystal/blob/master/home/deco...
https://github.com/kanzure/pokecrystal/blob/master/battle/hi...
1) Pokemon Gold/Silver, the prior versions of Crystal, was programmed by four people. (http://en.wikipedia.org/wiki/Pokémon_Gold_and_Silver#Develop...)
2) Crystal is 1MB in size. Yes, one megabyte.
Is this notable because it's little or because it's a lot?
Zelda III for the SNES was 1MB. Pokemon Red and Blue was 512KB, which is also quite a lot for a Gameboy game.
> Bloat: How and Why UNIX Grew Up (and Out) - Rusty Russell, Matt Evans
> The 'ls' binary on the original release of Unix (version 6) was 4920 bytes long. Thirty six years later, 'ls' on Ubuntu is 105776 bytes. Is this the laziness of modern coders? Increasing features? Does 'cat' really now do 313 times more stuff, or is there something else going on?
It depends on the exact proficiency of the programmers involved and the compiler/platform/etc., but it's not unusual to have an order of magnitude difference or more between the same application written in Asm vs. a high-level language like C.
People have tried to rewrite standard *nix utilities in Asm; one example is Asmutils[1][2] which certainly illustrates the "order of magnitude or more" size difference. If you're curious about extreme size optimisation there are many cool examples of that in the demoscene, like 96KB games[3] and all the 4k/64k intros.
[1] http://en.wikipedia.org/wiki/Asmutils
This is the entire overworld for Kanto, for instance.
http://socks-studio.com/img/blog/tumblr_lkshcyoNE81qhydr5o1_... (Red/Blue)
http://1morecastle.com/wp-content/uploads/2012/09/MQ2-612x49... (Crystal)
It's not as big as you remember it, I'll bet ;)
Even Johto isn't much bigger:
http://members.shaw.ca/dwarkentin/Webpage/graphics/mpics/joh...
And as the person below also mentioned.. No, the credits for Pokemon are extensive. There may only have been four coders, but there were level designers, sprite designers, etc, etc.
edit: oh, I didn't notice your question can be answered two ways. For the other half, I am unsure if it was 4 people on the whole project.
https://github.com/kanzure/pokecrystal/blob/master/trainers/...
It almost looks like a high-level language.
Assembler used: https://github.com/bentley/rgbds
RE tools used: https://github.com/kanzure/pokemon-reverse-engineering-tools
There was a disassembler called Sourcer that would annotate code with a set of predetermined comments based on its knowledge of the PC hardware. For example a sequence of instructions that enabled the interrupt controller by setting a specific bit in its register would be identified and get the comment "enable interrupt controller". I seem to remember IDA can do the same thing, although it's been a while since I last used it.
Unfortunately, I've not sprung for a license, so I can't comment on its efficacy.
printf("You caught them all!\n");
I'm a winner!This is partially because C compilers of the time weren't that great, partially because "everything is a critical section" when you're pushing the limits of extremely limited hardware, and partially because C's virtual machine model does not fit the average 8-bit CPU architecture at all, making pretty much impossible to this day to compile regular C code to (say) 6502 machine code that is anywhere close to optimal.[3]
[1] Ok, many games had custom bytecode interpreters, like SCUMM or the typical RPG's textbox language, but that's not quite the same thing. They could have used FORTH more (were there any games that used FORTH?), but I guess even in the days of HP calculators, people hated RPN.
[2] I guess I'm ignoring the many games done in BASIC for the 8-bit micros, but there's a clear difference in quality between these games and the average NES action game.
[3] There is a C compiler for various 8-bit architectures called cc65, but it chokes on anything resembling modern C. To get anywhere close to the performance of even naively written assembly, you have to hold its hand with machine-specific annotations (like "stick this variable in the zero page," or "make every variable static because the machine has no stack-relative address modes") to the point that it's easier to just write in assembly from the start.
For example, this is the script to choose your starter pokemon: https://github.com/kanzure/pokecrystal/blob/master/maps/Elms...
Well ain't you fancy.
Look at the commit log. Please. This stuff can't be "automatically disassembled" into the great looking codebase it's currently presented as.
Whatever though, I guess asking some people to think for more time than it takes them to click a link is a bit much these days.
Edit: I believe you can do something similar with IDA database dumps. The database doesn't contain the original executable image but instead contains a log of the IDA commands applied to the imported image. Another user can import their executable image and "replay" the IDA commands in the database.
These people put a lot of hard work into something people find interesting. I'm glad this is on hacker news because I'm interested in how these games were written and developed.
Heavens no, it's much easier to complain and criticize other people's work.
I had a feeling "being useful" is something people like OP don't actually do, and checking his online presence only proved me right. This is making me abnormally furious.
I agree that a lot of hard work has gone into the ROM reversing. I also cannot dispute that it is fascinating! I just wish the developers could have gone about the project in a manner that would not besmirch the project with copyright concerns.
[0]: https://www.openjailbreak.org/projects/libpartialzip-1-0/rep...
It's illegal, yes.
It's also : 1) a massive PR blow to sue fans who have taken an interest 2) a legal money-sink on decades old property that isn't producing less profit as a result.
For all you know, this github could have generated revenue for Nintendo through the revitalization of interest in the franchise using nostalgia against current day software developers...
Literally nobody has used this to pirate Crystal.