Large-world Map Engine w/ Editor

Published 2023-06-12



So this started on this thread by weeble but I ended up rather... running away with the code idea and overhauling it drastically.

While I've resumed working w/ Weeble on this in his original thread, I'm keeping this thread updated as well as I make changes.

V2.0 details








Also with V2.1 I've moved the various data tables needed outside of the sprite sheet, copied up from page 3 which is the one tiles are rendered into in-game, so all of the first two sprite pages are available for graphics as is the first two rows and change of page #2.

With V2.2 I've added the initial code for clipping regions, to avoid redrawing the entire screen every frame. This is a MASSIVE speedup, pushing CPU usage outside of screen-transition periods down to 5% CPU at 60fps in most cases. I'm working on a '16x16 bitfield' based solution that will instead re-render the screen in regions as small as 8x8 pixels per frame, allowing for multiple moving objects that way.

I've also cut the CPU used for baking the tile graphics in half from ~2.5 frames at 60fps to ~1.3 frames at 60fps with this release, while the token count and overall codesize has actually gone down.

Finally, the game picks a random room in the entire 16x16 grid to start you in, so you get different areas of the maze each time you restart the cart. So hit Ctrl+R a few times to see all the various biomes.

As a caveat I have removed the 'biome viewer' in this version for now, as I'm redesigning the interface to be a general-purpose editor for the maze itself, including setting biomes on the maze and editing individual biomes directly.

As of V2.3 I've integrated newer 'cavern generation' code that weeble came up with, to avoid blocking paths and allowing for much denser 'crazyness' to occur, as well as my 'context sensitive dithering' code which makes the transition tiles look much more alive and distinct now.

I'm working on some additional cavern smoothing functions to retain the 'crowded' feel without having quite so many dead side-passages at times, and adding a caching layer for the more expensive parts of the room-generation, to allow much of it to be generated in the background as you walk around a room to get to the next exit.

V2.4 adds a fourth unique room design for some biomes, one with much deeper, winding passages and a crowded feel.

V2.5 adds a MASSIVE speedup to the bake_tiles function by calculating the 'masked' tiles a full 32-bit row of 8 pixels at a time. So one fourth as many calculations in exchange for a bit of bit-shifting to load/save the values, but overall it's a HUGE win, including on token-count! Only 2814 tokens current! :D As a note, the masking colors are now 2/3, 4, 5, and 6/7, with values 0, 1, and all those above 7 MUST be avoided in the masks now.

As an interim release, V2.5-caching includes a further sped up tile-rendering codebase which is also moving some data from peek/poke memory to lua memory, taking up roughly 128k of the 1MB available with pre-rendering graphics tiles organized for faster rendering. This transition is freeing up enough speed that I am preparing to remove the 'biome' approach and allow direct per-maze-room assignment of walls, floors, and borders (including palettes) to simplify world painting. The trade-off is worlds will take ~768 bytes of sprite/map memory to store instead of ~512 bytes as they are now.