fixes the glitch in which the BG's X-position isn't reset when the player exits from a level with H:Variable into a level with H:None
v1.1: ---------------- Fixed a bug where this patch wouldn't consider the fact that AXY were in 16bit mode. Converted to asar format.
This is a very good catch and while the conversion to Asar and the bug fix are very appreciated, I think it could have been pulled off better from an optimization standpoint. Instead of taking advantage of the 16-bit mode around the hijack, you've just added to the patch code to make it work, which results in rather bloated code.
Analyzing the code, we see that the patch places a subroutine jump at $0580CD. The patch code enters 16-bit mode and returns to $0580D1, which immediately enters 8-bit mode - if you look at the surrounding code, you'll see that 16-bit mode is only used to decrement to $47 and $4B. This is not the only waste; you could easily leverage the 16-bit accumulator in the patch code to zero out $1E and $1466 in two instructions instead of four, which would save both time and space. Of course, you need to do an 8-bit load beforehand, but you can use the X register for that instead (it's overwritten at $0580DD, so you don't have to worry about clobbering it).
To sum up, you can change the REP at $0580CB so it only sets A to 16-bit, then change the JSL hijack to a JML hijack, which would allow you to return directly to $0580D3. In the patch code, you should keep in mind that the size of X/Y isn't guaranteed because of the preceding subroutine calls, so you should account for that either by forcing X/Y to be 8-bit or by analyzing the subroutines and checking if they return with 8-bit X/Y. You can probably think of different functionally equivalent combinations; feel free to experiment and see which one is the cleanest.