This code will stop the screen from scrolling past a specific point, useful to make the screen not to show "unessary" empty areas in a level. Unlike other "scroll stoppers" this one doesn't trap the screen, rather allow the screen to go back, It also has a bug fix that if the screen is moving too fast, it stops the screen at the exact pixel position, so the screen isn't slightly past the stopping point while its locked in place. It almost works exactly like smw's area where the screen won't go past. You could even make a "one way" screen. Example, using "scroll left border" on screen boundry $01 while the player's screen spawns at $00, if the player goes past that line, the player can't go back to $00. keep in mind that if the lock animations and sprite flag ($7E:009D) is being set other than by L/R scroll, player getting hurt, player getting a powerup, yoshi haching from his egg or any other smw's freeze effect causes the game to unable to reset the freeze flag back zero again, causing $9D to be stuck at a non-zero value and freezing the game entirely. You'll have to use STZ $9D to cancel the freeze on certin conditions, otherwise motion keeps playing even when its not suppose to (like things still animate as mario getting a powerup). ;-----------------------stop screen from scrolling right----------------------; !stop_right_scroll = $01 ;>screen number to stop on. 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 BRA done_scroll cancel_freeze: LDA $71 BNE done_scroll 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 L scroll in border STZ $13FE ;>also glitches like fade to map instantly as soon mario dies STZ $1400 BRA done_scroll freescreen: SEP #$20 BRA done_scroll unlock_screen: SEP #$20 LDA #$01 STA $1411 done_scroll: RTS ;-------------------------stop screen from scrolling left---------------------; !stop_left_scroll = $01 ;>screen number to stop on. REP #$20 ;>begin 16 bit value LDA $1462 ;\so if the screen skips a pixel, still CMP #!stop_left_scroll*$100-10 ;|detect and locks the screen BCC freescreen ;| CMP #!stop_left_scroll*$100+1 ;| BCS freescreen ;/ LDA $7E ;\Allow screen to go back even if its CMP $142E ;|locked in place (can go right) BCS unlock_screen ;/ LDA #!stop_left_scroll*$100 ;\and set the locked screen in the STA $1462 ;/correct pixel-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 BRA done_scroll cancel_freeze: LDA $71 BNE done_scroll 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 glitches like fade to map instantly as soon mario dies STZ $1400 BRA done_scroll freescreen: SEP #$20 BRA done_scroll unlock_screen: SEP #$20 LDA #$01 STA $1411 done_scroll: RTS ;------------------------stop screen from scrolling down----------------------; !stop_down_scroll = $01 ;>screen number to stop on. !scroll_up_unlock = $0064 ;>if you change $00:F806 (0x07A06), then you ;should change this also (must be 4 digits). REP #$20 ;>begin 16 bit value LDA $1464 ;\so if the screen skips a pixel, still CMP #!stop_down_scroll*$100 ;|detect and locks the screen BCC freescreen ;| CMP #!stop_down_scroll*$100+10 ;| BCS freescreen ;/ LDA $80 ;\Allow screen to go back even if its CMP #!scroll_up_unlock ;|lock in place (can go up) BCC unlock_screen ;/ LDA #!stop_down_scroll*$100 ;\and set the locked screen in the STA $1464 ;/correct pixel-position SEP #$20 ;>end 16 bit value STZ $1412 ;>and stop the screen BRA done_scroll freescreen: SEP #$20 BRA done_scroll unlock_screen: SEP #$20 LDA #$01 STA $1412 done_scroll: RTS ;-----------------------stop screen from scrolling up-------------------------; !stop_up_scroll = $01 ;>screen number to stop on. !scroll_down_unlock = $007D ;>how low mario must be to move the screen down ;(must be 4 digits). REP #$20 ;>begin 16 bit value LDA $1464 ;\so if the screen skips a pixel, still CMP #!stop_up_scroll*$100-10 ;|detect and locks the screen BCC freescreen ;| CMP #!stop_up_scroll*$100+1 ;| BCS freescreen ;/ LDA $80 ;\Allow screen to go back even if its CMP #!scroll_down_unlock ;|lock in place (can go down) BCS unlock_screen ;/ LDA #!stop_up_scroll*$100 ;\and set the locked screen in the STA $1464 ;/correct pixel-position SEP #$20 ;>end 16 bit value STZ $1412 ;>and stop the screen BRA done_scroll freescreen: SEP #$20 BRA done_scroll unlock_screen: SEP #$20 LDA $81 ;\counts as "more than scroll_down_unlock" BMI done_scroll ;/because above screen = go past the line (being negative) LDA #$01 STA $1412 done_scroll: RTS