[4.5.6] do_StopScrolling Fix for metroVania Module

TakuikaNinja

Active member
It's me again with another bug fix!
This time, the issue revolves around how the screen scroll behaves when the player stops moving.
By default, the game doesn't check if the player is beyond the "scroll pad" when the D-pad is released.
This means rapidly pressing and releasing a direction will move the player without scrolling, so you can end up in situations like this!



Obviously we don't want that! So here's how to fix it, assuming you've already imported the input links from the tutorial:
  1. Create a new .asm file and call it something like "do_stopScrolling_metroVania.asm". Save it in "Routines\BASE_4_5\Game\MOD_MetroidVania\Inputs\" for convenience.
  2. Copy and paste the following code into the file and save it:
    Code:
    ;;; this will stop the camera from moving.
    ;;; great for release events in 2-way scrolling.
    
    LDX player1_object
        LDA Object_x_hi,x
        SEC
        SBC camX
        CMP #LEFT_SCROLL_PAD
        BEQ +doActivateScrollByteL
        BCC +doActivateScrollByteL
            JMP +nextCheck
    +nextCheck
    	CMP #RIGHT_SCROLL_PAD
        BEQ +doActivateScrollByteR
        BCS +doActivateScrollByteR
            JMP +resetScroll
    +doActivateScrollByteL
        LDA scrollByte
        AND #%01000000
        BEQ +notChangingCamDirectionForUpdateL
        LDA scrollByte
        ORA #%00000010
    +notChangingCamDirectionForUpdateL
        AND #%00111111
        ORA #%10000000
        STA scrollByte
    	RTS
    +doActivateScrollByteR
        LDA scrollByte
        AND #%01000000
        BNE +notChangingCamDirectionForUpdateR
        LDA scrollByte
        ORA #%00000010
    +notChangingCamDirectionForUpdateR
        AND #%00111111
        ORA #%11000000 
        STA scrollByte
    	RTS
    +resetScroll
    	LDA scrollByte
    	AND #%00001111
    	STA scrollByte
    	RTS
  3. In the input editor, remove these script associations:

  4. Go to Scripts -> Input Scripts. Remove "do_stopScrolling.asm", then add "do_stopScrolling_metroVania.asm".

  5. Go back to the input editor and add these script associations:

  6. Export the game! If you see weird tiles loading, an extra export should do the trick.
    (NESmaker sometimes mucks it up for some reason)

And that's it! (Yes, I know I haven't shared my method of setting up sprite 0 parallax yet. The guide for that will be up soon.)
 
Top Bottom