I made a code to fix a bug where if mario moves the screen too fast to the right where the door leading to the ice skating level, the screen stop slightly past the area where it should be, and that the screen gets stuck and can't go back.
EDIT: improved the code.
!stop_right_scroll = $01 ;>scren number to stop at
REP #$20 ;>begin 16 bit value
LDA $1462 ;\so if the screen skips a pixel, still
CMP #!stop_right_scroll*$100 ;|detect and locks the screen
BCC freescreen ;|
CMP #!stop_right_scroll*$100+10 ;|
BCS freescreen ;/
LDA $7E ;\Allow screen to go back even if its
CMP $142C ;|is locked in place. (can go left)
BCC unlock_screen ;/
LDA #!stop_right_scroll*$100 ;\not only lock the screen, also if a pixel or
STA $1462 ;/2 are off, set it to be the correct position
SEP #$20 ;>end 16 bit value
STZ $1411 ;>and stop the screen
LDA $13FE ;\if L/R scroll...
BNE cancel_freeze ;/then cancel freeze
STZ $9D ;>found a way to stop permanent freeze by l/r scroll
STZ $1401 ;and remove akward effects, like it keeps scrolling
STZ $13FD ;right when mario head back after R scroll in border
STZ $13FE ;>also like fade to map instantly as soon mario dies
Give thanks to RPG hacker for working on Asar.