Map loading & scrolling: is my theory right?
Posted: Wed Jan 18, 2017 10:10 pm
While waiting for help with my PCM code, I also want to work on my map loading & scrolling. I'm sick and my mental capacity is sort of shit right now, so I want to get a second opinion on whether what I'm thinking is correct.
So, I'm thinking of having my tilesets be stored as paletted PNGs storing 16px chunks, which my custom content tool as mentioned in the other thread converts into a dump of 8px tiles (each 16px chunk is converted into four 8px tiles, laid out from left to right, top to bottom). Then my map file stores the 16px chunk indices (probably going to write a converter for Tiled maps, and in Tiled just have it treat the tileset as a 16px tileset), which at runtime when I go to load a map is converted into SGDKs Map structure, having it convert each chunk index into actual tile indices (so for example if my game map was 32x32 chunks, the resulting Map structure would be 64x64 actual tiles).
Then, to implement scrolling, I can reference this code: https://github.com/kcowolf/GenScrolling ... llingMap.c
So that the idea is I store buffers for rows and columns, and when the camera moves by one tile I retrieve each tile of the row or column from the Map structure into the appropriate buffer and then DMA that into a 64x64 tile plane in VDP.
The nice thing is that I actually plan to only support moving a tile at a time (old school JRPG style), so I can probably simplify the scrolling code to just load a new row/column when the routine to move by one tile is triggered (rather than checking the camera's pixel position).
Does this sound correct and reasonable? I think it's probably sound but then again I've got a bad mental fog right now and I'm more used to working with Unity/C# than with C and SGDK.
So, I'm thinking of having my tilesets be stored as paletted PNGs storing 16px chunks, which my custom content tool as mentioned in the other thread converts into a dump of 8px tiles (each 16px chunk is converted into four 8px tiles, laid out from left to right, top to bottom). Then my map file stores the 16px chunk indices (probably going to write a converter for Tiled maps, and in Tiled just have it treat the tileset as a 16px tileset), which at runtime when I go to load a map is converted into SGDKs Map structure, having it convert each chunk index into actual tile indices (so for example if my game map was 32x32 chunks, the resulting Map structure would be 64x64 actual tiles).
Then, to implement scrolling, I can reference this code: https://github.com/kcowolf/GenScrolling ... llingMap.c
So that the idea is I store buffers for rows and columns, and when the camera moves by one tile I retrieve each tile of the row or column from the Map structure into the appropriate buffer and then DMA that into a 64x64 tile plane in VDP.
The nice thing is that I actually plan to only support moving a tile at a time (old school JRPG style), so I can probably simplify the scrolling code to just load a new row/column when the routine to move by one tile is triggered (rather than checking the camera's pixel position).
Does this sound correct and reasonable? I think it's probably sound but then again I've got a bad mental fog right now and I'm more used to working with Unity/C# than with C and SGDK.