Skip to content

Expanding The Metatile Count

Team Aqua's Hideout edited this page Oct 5, 2024 · 43 revisions

Here in this tutorial we will increase the cap for metatiles from 1024 to 4096 by removing the redundant collision bit and decreasing the possible elevations from 16 to 8. You can also get 2048 metatiles with just the unused collision bit, without affecting elevation, the process would be largely the same as described here with some changes:

Link to Code Changes (branch of TAH pokeemerald fork)

Code Changes:

Code Change Screenshots
Screenshot 3 Screenshot 3 Screenshot 3

There are a handful of constants that need to be changed in the fieldmap header files. The bit masks have to be changed so that the metatile id goes from 10 to 12 bits. This is what allows the game to register ids up to 4096. The collision section is reduced to 1 bit because thats all that is ever used. The elevation mask is reduced by 1 bit as well to gain more space. This one isn't required if you're okay with 2048 metatiles, but other changes will be required as well. The other changes found in the link are to change the metatile count constants to 2048 for primary and 4096 for total count, and then to change a couple of values in event_object_movement.c from 15 to 7 which is the new elevation max. This needs to be done so that the crossed arrows elevation used for bridges is now updated to the new max, which is now 7.

Porymap Changes

After changing this stuff some updates will need to be made in Porymap, to only use 8 elevations you will want to change the elevation image to collisions.png this new one, and change the max elevation number to 7 which you can do in Porymaps settings here: image collisions

Python Script to Update Existing Maps

With the constants updated and the settings changed in porymap, after reloading you will be able to use 4096 metatiles in your maps. However, you may notice that every single map you have made is broken. This is normal, the binary map data needs to be converted into the new format so porymap can properly recognize it. For that there is a python script in the repo Found Here. This script when in the main pokeemerald folder of your project is ran using: python3 expand_metatiles.py

If you do not have python installed you will need to install it. After running this script all your maps should be converted into the new format. If you used any elevations greater than 6 in your maps those areas will be the wrong elevation and will need to be fixed but 99% of maps don't use any above 5 so that shouldn't be a common issue, Mossdeep is affected in vanilla but idk about anywhere else. Anyway, reload porymap and your maps should be back to normal again. If you did not get rid of the elevation bit, you will have to make changes to the Python program so that the new elevation bitmask is four bits instead of three like it is currently.

Clone this wiki locally