Extremely Simple Tiled Maps on the Game Boy Advance using the Tiled Editor

Just throwing out there a very simple example of how to get tiling maps working on the Game Boy Advance using Tiled. Code can be found here: https://github.com/victoroliv2/simple-tiled-gba

I used Tiled to design a very basic map:

Screen-Shot-2022-04-03-at-12.36.45-PM

I wrote a Python script that parses the generated .tmx file (XML) and converts it into constant ARM assembly data. I followed the great Tonc asm tutorial. The main idea is that this data is stored in read-only memory (ROM) in the .rodata section. Later, the linker will include those constants in the final binary.

Also important:

Assembly is a good format for exporting data to. Assembling arrays is faster than compilation, the files can be bigger and you can control alignment more easily. Oh, any you can't be tempted to #include the data, because that simply will not work.

Code is here

Then, we have to create our tileset and palletes. I'm using using BG Mode 0 so there are 16 palletes availables with 16 colors each (1 always transparent). So I wrote another script that goes over a tileset PNG file looking at unique RGB colors for each 8x8 tile building palletes (If there are more colors combinations than what's possible to represent in 16 palletes it will fail so the tileset image has to be careful and use few color combinations per tile).

Code is here

Putting all that together we have a very simple GBA demo using Tiled!

Screen-Shot-2022-04-03-at-1.56.31-PM


catboli

I'm a cat-shadow floating in the web.