[4.5.6] MetroidVania Jumping Up Screen Issue - SOLVED

goatgary

New member
I'm working on a game using the MetroidVania module and I've run into an issue related to jumping UP between screens. When jumping UP, the player is taken to the screen "below" instead of "above." Jumping down between screens works as expected.

I'm not sure how to fix this and hope someone else has run into this already.

---
EDIT

I tested this with a fresh project and still encounter the error out of the box.

After doing some testing: the player does go up one screen row and that is where the error happens. I believe the bottom bounds check is firing twice for some reason and adding #$20 to currentNametable. The end result being the player moves to the screen below the original screen.

The only time the error doesn't always seem to happen is after falling down a screen and then jumping back up. Moving left or right while jumping causes the error.

Test map below; spots in green circle work, spots with red X don't

4URkWib.png
 

goatgary

New member
After getting some direction from Joe, I figured this out. Essentially, the top bounds check was never being done so the screen was not changing correctly.

In the doHandlePhysics_MetroidVania.asm file, the section adjusting the Y value was modified to this:

Code:
            ;; is not solid, don't land.
            LDA Object_y_lo,x
            CLC
            ADC Object_v_speed_lo,x
            STA yHold_lo
            LDA Object_y_hi,x
            EOR #$80
            ADC Object_v_speed_hi,x
            EOR #$80
            BVC +setY
                LDA #$00    ; fix wrap to bottom
            +setY
            STA Object_y_hi,x
            STA yHold_hi

The other part of the issue is the top bounds check itself. I'm not using a HUD so the playable area is set to the full screen making #BOUNDS_TOP = #$00

As the top bounds check is done using BCS, it will always branch when #BOUNDS_TOP is #$00.

To fix this, I added a BEQ just before the BCS.

Code:
            CMP #BOUNDS_TOP
            BEQ +atBoundsTop
            BCS +notAtBoundsTop
                
            +atBoundsTop
                CPX player1_object
                BNE +destroyNonPlayerObject
                        LDA #$02
                        STA screenUpdateByte
                        JSR doHandleBounds
                    JMP +notAtBoundsTop
                +destroyNonPlayerObject
                    DestroyObject
            +notAtBoundsTop
 

dale_coop

Moderator
Staff member
Very good analyse and fix. I haven't tested it myself but your fix looks coherent and clean. Love it!!! <3
 

Jonny

Well-known member
Very good analyse and fix. I haven't tested it myself but your fix looks coherent and clean. Love it!!! <3

Did you ever get chance to test this Dale? Did it work for you?

No joy for me yet. Didn't seem to change anything but maybe I did something wrong, not sure.
 

Jonny

Well-known member
Been months... but I think I had tested it and it was working
Ok cool. From what I can gather the 4.5.6 and 4.5.9 doHandlePhysics_MetroidVania.asm are different in those places, I think? I'll take a look at the old one.

I was experimenting having a modified warp tile at the top of my rope (ladder) but that only works going up :(
Going down, I end up being on a solid. Maybe I could change the ladder to not act as a solid when player is stood on it. My way feels like a bodge up job.
 
uh i have an issue that may or may not be related but as i have made my first 3 screens as a metroidvania game i then can jump up a screen and when i do my player drops to the bottom edge of the screen and will act as if there is collisions set to solid underneath that screen but my player should be able to drop back down to the previous screen? if i run off the edge of the screen next to it then my player drops down. there is definately no solid collisions set between screens. pls help
thanks
 
Hey vanderblade, did you use the script from the downloads labelled 4.5.6? im working with ver 4.5.9 but my scripts are from .6 from the tutorial downloads and im having these issues and struggling a bit as my coding knowladge isnt flash lol
 

warpedpipe

Member
After getting some direction from Joe, I figured this out. Essentially, the top bounds check was never being done so the screen was not changing correctly.

In the doHandlePhysics_MetroidVania.asm file, the section adjusting the Y value was modified to this:

Code:
            ;; is not solid, don't land.
            LDA Object_y_lo,x
            CLC
            ADC Object_v_speed_lo,x
            STA yHold_lo
            LDA Object_y_hi,x
            EOR #$80
            ADC Object_v_speed_hi,x
            EOR #$80
            BVC +setY
                LDA #$00    ; fix wrap to bottom
            +setY
            STA Object_y_hi,x
            STA yHold_hi

The other part of the issue is the top bounds check itself. I'm not using a HUD so the playable area is set to the full screen making #BOUNDS_TOP = #$00

As the top bounds check is done using BCS, it will always branch when #BOUNDS_TOP is #$00.

To fix this, I added a BEQ just before the BCS.

Code:
            CMP #BOUNDS_TOP
            BEQ +atBoundsTop
            BCS +notAtBoundsTop
               
            +atBoundsTop
                CPX player1_object
                BNE +destroyNonPlayerObject
                        LDA #$02
                        STA screenUpdateByte
                        JSR doHandleBounds
                    JMP +notAtBoundsTop
                +destroyNonPlayerObject
                    DestroyObject
            +notAtBoundsTop
The top portion of the code edit worked for me in 4.5.9 but the second portion throws an error. Everything seems to be working with only the top code edit.
 
Top Bottom