Some weeks ago I created a topic asking for help about how to create a level editor for a GBA game, because it's my first rom hacking and I didn't find much tutorials about how to start this project neither "how I should to think in order to do it".
But since GBA is an old and very popular videogame, many fans written very good tutorials about this architecture as well as tools, such emulators and debuggers. But we still lacking a complete tutorial about ROM hacking.
In order to resolve this lacking it and to teach how to do a ROM hacking, I'll explain how I'm doing the level editor for Klonoa: Empire of Dreams game!
I'm writing this manual in Portuguese (my native language) and translating it to English. Feel free to fix my English, please.
If do you want, you can follow this project more closely seeing the source code here: https://github.com/macabeus/klo-gba.js
[EDIT] Hey, now I'm posting these chapters only on Medium. Click here to read the reviewed version.
How is this game?
It's a 2D platform/puzzle game.
This game has many levels and mechanics that the difficulty increase as the player finish each level. This is an addictive game, but in a moment we finish all levels... them... if we could create the own levels?
We already have a level editor for others games, for example, Pokemon has Advance Map. But I feel that lacking a level editor for this awesome Klonoa game. Then, we should to create one!
We'll use two main software: no$gba, mainly to dynamic analysis, and IDA Pro, to static analysis.
no$gba is very good for dynamic analysis, because we already have everything in a single tool. And since it is a reverse tool exclusively for GBA, it has very specific features, like viewer for tile map. But, the debugger for memory and code is very poor if compared to a more generic software like IDA Pro, that has very good tools for static analysis, like graph viewer and memory extractor.
Then, we will use both softwares, because they are complementary.
Okay, let's start!
Part 1: Let's go to stretch the bridgeWell... Our objective is to create a level editor, right? It is a very complex challenge, with many things to do... but let's start by the most obvious way: let's create our tiles on the map!
An important thing when you are doing a reverse engineering is "find and follow the patterns". This is, instead of just "to create tiles" from nothing, let's start by a simpler way: we'll "repeat the tiles" in order to "stretch something on the level". Then a good fit is to find a good structure to stretch on the level, that is, a place which the tiles is regular (sequence of the same tiles), with vacant place around and should be easy to check that we made a change.
Then, the first level has a very good structure: a floating bridge.
One of no$gba tools, Vram Viewer (you can access it by F5), is very useful in our work. Using it you can see the different level background. At Gameboy Advance we have BG 0, BG 1, BG 2 and BG 3. You can see at BG 0 tab we have the blue sky, while at BG 1 we have the images of the second background (a big cactus?), and at BG 3 we have nothing.
The only important to us is BG 2, which we can see the "walkable" tiles.
When hover the mouse on a tile, we get many informations about it. Despite we have many infos, it has just two items really important for us:
- Tile No: this is the tile ID. In this example, all tiles with the ID 9B is exactly this bridge part, which is the left corner. 9A is the ID of the continuous part of the bridge.
- Map address: where the tile is stored in the memory. In this example, it is at 0600F1AD.
Gameboy Advance has many memory sections, each having a different purpose and functionality. If you want to learn more about it, you can read here, but always when I say a new memory section I'll describe it briefly.
Then we know that the address 0600F1AD is where this tile is stored. Nice. Let's go to this memory address!
Amazing! You can see the bridge here in the bytes? Please, note that 00 is a vacant tile, while the others bytes are the tiles displayed at the screen. The sequence 9B 9A 9A ... is the bridge! Then, if we replace the 00s on the left of 9B following the pattern we can stretch the bridge? Let's try!
We stretched the bridge at the memory, then let's run a single frame on the emulator (you can type / to do it)! Then we can see that we really stretched the bridge!! Yeah!
But...... when we run one more frame, we can see that the bridge returns to the normal shape... well... why it happened? How to fix it?
Last edited by akaishi,