This code auto-scrolls level (or background) layer 2 up or down relative to layer 1, which makes rising and falling layer 2 sections possible without taking away vertical camera freedom.
A couple notes:
-You must set Layer 2 V-Scroll in Lunar Magic to "None", and H-Scroll preferably to "Constant".
-It must be assured that the player can never reach layer 2 scrolled past the area that has been placed in Lunar Magic, or glitchy tiles will appear. This works for the applications shown in the screenshots, as the layer 2 itself impedes the player from going further down (for the lava) or up (for the blocks). For rising layer 2, it is of interest to also account for Mario's death animation, as he falls down a fair amount when dying (the .asm file talks about this in more detail).
There was an issue where layer 2 would keep scrolling up/down during the level end walk, and if it pushed Mario above the screen during the circle fade, could either corrupt the palette, or worst case, hardlock the game. The fix was as simple as adding a single line though, so I added it. Everything else works as intended, so, accepted.
This is a very nice mechanic and definitely seems like the most "logical" movement for autoscrolling layer 2 - I remember when I was learning Lunar Magic, I spent a lot of time trying to create this very effect before realizing it didn't exist in LM.
Perhaps in a future update it could be further improved to include different relative scrolling patterns, such as an oscillating/sinusoidal movement, or maybe even a smash-like movement, but it's still very good as-is.
I was wondering if this would be made someday; just wondering if it works (or can be set up to work) for tall horizontal levels?
Yes, the first screenshot is in fact one.
Ah, awesome! I have one more question about this code though; if layer 2 was a solid floor, and was rising up (like in the DKC2 level Castle Crush), would Mario be able to outrun layer 2, or would it eventually catch up to him if he got far enough ahead of it and stood still?