With this code, you can easily create a unique password system for your level. Set 1-10 inputs that have to be done in the correct order and one of these things will happen:
-Kill the player
-Hurt the player
-Give the player 1-UP(s)
-Give the player a Power-UP
-Give the player some coins
-Give the player Star-Power
-End the level (normal exit)
-End the level (secret exit), triggers the keyhole animation
-Spawn a sprite
-Change ON/OFF Switch state
-Teleport to current screen exit
-Teleport the player to the overworld, no event triggered
-Teleport the player to a different overworld position
Every option is very customizable, so make sure to change the defines in the asm file.
Tested with: LM 3.04, UberASMTool 1.4, SA-1 1.32, Snes9x 1.6. The code works well and it has a lot of interesting options, so accepted.
I found a couple of small issues that would be nice to fix in an update: when enabling the PSwitch option, the song doesn't change. Also, for the silver PSwitch, you need to add a "JSL $02B9BD" to turn all the on-screen sprites to silver coins.
Besides that, it would be nice to make an update to optimize the code (it's not a major issue, but it could also be a useful exercise for you ). Right now you've encoded the different inputs with separate defines, so there's no room for expansion and there's a lot of duplicate code to check all the different inputs. A much compact (and faster, probably) way to do this could be to encode the inputs in a table (that could be expanded beyond 10 entries), so you wouldn't need to check !freeRAM for each possible value and jump to the different (but basically identical) subsections: you could just use the same code, pulling the correct value from the table using !freeRAM as the index.