I don't know if anyone else has done this and submitted it yet, so here goes.
I've been analyzing the Knytt Stories code very thoroughly, and trying to optimize it into being more flexible. Varying tile sizes, top down or side scroller formats. Multiple tilesets. ETC. One major aspect is Scrolling. Knytt Stories is what would be classified as a "Metroidvania." Large single environment, on a large grid. Also akin to a Zelda.
In this example I have completely recoded the engine from scratch to include single large environments. These levels are scrolled and rendered in real time, as apposed to rendering an entire screen between screens as Knytt did.
The example shown here is a remake of the first Super Mario Bros. Levels scroll horizontally and render as you go.
I've included two modes: The classic "can't go backwards" mode, which erases the level as you go forward, and a new style which renders the level as you go, but keeps the rest still in memory for back tracking.
The Mario Level file shows how these examples. The "How Mario Works" file is a zoomed-out view of a Mario game. You can actually see the level rendering as you go. It helps in comprehending the out-of-sight rendering system used.
The example only uses 1 layer, and all BGs are obstacles.
Now since this engine is crucial to my upcoming projects, I have scrapped a lot of functions and comments from the file, so as to not leak the full code. But I hope some can still learn from it.
What this engine is, basically, is the very backbone of all NES games core map rendering engines. Gotta start with the basics!