Monday 16 September 2019

Update 3 - The big big biiiiig map

Update 3 - The big big biiiiig map

Could have been bigger

The map is big. It's a 32000x32000 pixels map. And it could have been bigger. You can make map as larg as 64000x64000 pixels. But it would take a lot of time to make such an enormous map. That's the main reason I made a smaller map. 

Almost the same size of a regular map in memory 

Also it's big, this map take only 6k of rom. A regular sonic map take about 5k. This map is 36x bigger in pixel than a regular sonic map but only 1.2x bigger in memory.

The secret

The map has a fractal structure. Which means it is devided into subparts. 
First of all there are tiles which are 8x8 pixels in size. 
Then you have metatiles which are 2x2 tiles in size.
Then you have clusters which are 8x8 metatiles in size.
Then you have super clusters which are 8x8 clusters in size.
Then finaly the map or hyper cluster which size vary. In this video it's 32x32 super clusters in size.



  A tile

 A metatile

 A cluster


 A super cluster

A minnor drawback

There is actualy a con to this map structure. Smaller maps take a lot of space in comparaison to large maps. For instance a 10240x512 will be 4k. It's 195 times smaller in pixel size than a 32kx32k map but only 1.5 smaller in memory. This is due to the fact that the size largely depend on the number of clusters. 1 cluster take 8x8=64 bytes. 60 of them take 60x64=3840byte almost 4k.

To fix this I need to devide the map even more. To have cluster made of sub clusters (or big metatiles) 


I hope to cut in half the amount of memory taken by clusters.

Behind the curtain

I had to do massive optimisation on the scroller. The part of the code that draw tiles as the camera moves in the games. I had to learn Z80 assembly. I actualy never realy coded in assembly before. I only had small experience with code made by the compiler. 

Also because I'm coding on a laptop with a bad posture, my back was begining to hurt me a lot.
So each days I need to do streching and yoga in order to continue coding. I really want to continue this project. I'll do what ever it takes to do it. Even if I have to meditate each day :)

What to do next?

The end goal ,like I said in the video is to make a fully functional 2d seamless open world engine for the master system. And for that now I need to be able to put objects in the scene/map.

I will also need to optimize the code, convert my c code into asm code.