Double jump in NESmaker 4.5.6 metrovania

baardbi

Well-known member
PS!!!! This tutorial is outdated. I made a new tutorial that is much better:




I could't find an input script that enabled double jump in 4.5.6, so I thought I would make one myself. I thought I had a good idea, but now I'm not even sure that this will work at all...

In my game the player will get a double jump power up later in the game. To keep track of things I made two user variables. One variable checks if the player has the power up at all and the other varibale checks how many times the player has jumped (I just want him to be able to jump two times).

Am I way off or is there a chance to save my modified jump script? Here it is:

Modified jump_throughPlat.asm from the MOD_PlatformerBase (my modifications are at the bottom of the script)

Code:
;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Only can jump if the place below feet is free.
    SwitchBank #$1C
    LDY Object_type,x
    LDA ObjectBboxTop,y
    CLC
    ADC ObjectHeight,y
    sta temp2
   
    LDA Object_x_hi,x
    CLC
    ADC ObjectBboxLeft,y
    STA temp
    JSR getPointColTable
   
    LDA Object_y_hi,x
    CLC
    ADC #$02
    CLC
    ADC temp2
    STA temp1
    CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore
        JMP +doJump
    +checkMore
   
    CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore
        JMP +doJump
    +checkMore
     CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is prize block .
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore
        JMP +doJump
    +checkMore
    CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
     BNE +dontDoJump
          JMP  +doJump
        +dontDoJump
            ;; check second point.
        LDY Object_type,x
        LDA ObjectWidth,y
        CLC
        ADC temp
        STA temp
        JSR getPointColTable
        CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
                                            ;;; if it is (equal), can jump.
                                            ;;; if not, skips jumping.         
        BEQ +doJump
       
        CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
        CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
        CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
            JMP +skipJumping

;;;;;;;;;;;;;;;;;;; Baardbi modified start

doubleJump:
+doJump:
    TXA
    STA temp ;; assumes the object we want to move is in x.
    ;PlaySound #sfx_thump

    LDY Object_type,x
    LDA ObjectJumpSpeedLo,y
    EOR #$FF
    STA Object_v_speed_lo,x
    LDA ObjectJumpSpeedHi,y
    EOR #$FF
    STA Object_v_speed_hi,x
       
    TXA
    STA temp ;; assumes the object we want to move is in x.
 ;  change the object's action so that he is in jump mode.
 
    LDA gotDoubleJump                ;User variable to check if the player has double jump power up (1 = yes)
    CMP #$01
    BNE +skipJumping
    INC doubleJumpCounter            ;User variable that checks the number of times the player has jumped
    LDA doubleJumpCounter
    CMP #$02
    BEQ noMoreDoubleJumpsForYou        ;Has already jumped a second time
    JMP doubleJump
noMoreDoubleJumpsForYou:
    LDA #$00
    STA doubleJumpCounter
    RTS
+skipJumping:
    ReturnBank
    RTS
   
;;;;;;;;;;;;;;;;;;; Baardbi modified stop
 
Last edited:

mouse spirit

Well-known member
Maybe like this instead
Code:
LDA gotDoubleJump ;;;;;;;;;;;;;do we have doublejump?
CMP #$01
BNE +++

LDA doubleJumpCounter ;;;;;;;;;;;;;;;;;we do have doublejump so have we used all our jumps?
CMP #$02
BEQ +
JMP ++
+
RTS
++
JMP +doJump
+++
;;;;;;;rest of jump code



+doJump:
INC doubleJumpCounter   ;;;;;;;;;;we are jumping so increase jump counter no matter what
put this at the begining of the code.

Please adjust accordingly, but this should be it.
We want every jump to inc the counter unless above or equal to 2
This method, when we press jump, doublejumpcounter will increase when not 2.
We jump twice, we cant jump more.
We need to set doublejump to 0 when you touch the ground or something though
 

mouse spirit

Well-known member
No problem, I re edited the first post i did. Possibly this will work better....
it should work in theory! But we still need to reset doubleJumpCounter somehow.
 

mouse spirit

Well-known member
Ok so for release jump input......
Code:
LDA gotDoubleJump ;;;;;do we have item doublejump
CMP #$01
BNE +++

LDA doubleJumpCounter ;;;;;;;;;;;;;;;;;we do have double jump so have we used all jumps?
CMP #$02
BEQ +++
CMP #$01
BEQ ++ ;;;;;;;;;;;;;;;;;;;;;;;;;this is the only situation where it doesnt reset jumpcounter to 0 when relesing jump
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;which is potentially a problem.....
+++
LDA #$00
STA doubleJumpCounter
++


We may still have to help reset jumpcounter to 00 even more but this should help.
The problem we will have is that if you jump once when you do have double jump'
It would then let you jump once on the next "jumps sequence you do" because
the counter would still be 01.
But then it would be fine if you always double jump.


heres for the jump input again...

Code:
LDA gotDoubleJump ;;;;;;;;;;;;;do we have doublejump?
CMP #$01
BNE +++

LDA doubleJumpCounter ;;;;;;;;;;;;;;;;;we do have doublejump so have we used all our jumps?
CMP #$02
BEQ +
JMP ++
+
RTS
++
JMP +doJump
+++
;;;;;;;rest of jump code



+doJump:
INC doubleJumpCounter   ;;;;;;;;;;we are jumping so increase jump counter no matter what

These work together to act right, in theory! And they only work if you
press button to jump,and release the same button.
Meaning it works like a normal A button jump or B button jump.
 

mouse spirit

Well-known member
Awesome! Try it out and let me know. Im on here most of the time.
Also i am in 4.1.5 so you might have to edit some stuff.All of this seems like basic
type language so i hope not.
 

baardbi

Well-known member
Hmmm... I can't get it to work. Could it be that A-release is setting the jump counter to 0 every time I release the A button, so that the counter never really counts up from 1..? But if that was the case I would be able to have never ending jumping. Now I can only jump once.

Here are the scripts I'm using now:

Press A:

Code:
;;;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Only can jump if the place below feet is free.
    SwitchBank #$1C
    LDY Object_type,x
    LDA ObjectBboxTop,y
    CLC
    ADC ObjectHeight,y
    sta temp2
    
    LDA Object_x_hi,x
    CLC
    ADC ObjectBboxLeft,y
    STA temp
    JSR getPointColTable
    
    LDA Object_y_hi,x
    CLC
    ADC #$02
    CLC
    ADC temp2
    STA temp1
    CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
    
    CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
     CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is prize block .
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
    CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
     BNE +dontDoJump
          JMP  +doJump
        +dontDoJump
            ;; check second point.
        LDY Object_type,x
        LDA ObjectWidth,y
        CLC
        ADC temp
        STA temp
        JSR getPointColTable
        CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
                                            ;;; if it is (equal), can jump.
                                            ;;; if not, skips jumping.          
        BEQ +doJump
        
        CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
        CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
        CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
            JMP +skipJumping

LDA gotDoubleJump ;;;;;;;;;;;;;do we have doublejump?
CMP #$01
BNE +++

LDA doubleJumpCounter ;;;;;;;;;;;;;;;;;we do have doublejump so have we used all our jumps?
CMP #$02
BEQ +
JMP ++
+
RTS
++
JMP +doJump
+++
;;;;;;;rest of jump code

+doJump:
INC doubleJumpCounter   ;;;;;;;;;;we are jumping so increase jump counter no matter what

    TXA
    STA temp ;; assumes the object we want to move is in x.
    ;PlaySound #sfx_thump

    LDY Object_type,x
    LDA ObjectJumpSpeedLo,y
    EOR #$FF
    STA Object_v_speed_lo,x
    LDA ObjectJumpSpeedHi,y
    EOR #$FF
    STA Object_v_speed_hi,x
        
    TXA
    STA temp ;; assumes the object we want to move is in x.
 ;  change the object's action so that he is in jump mode.
 

+skipJumping:
    ReturnBank
    RTS
	
;;;;;;;;;;;;;;;;;;; Baardbi modified stop

Release A:

Code:
LDA gotDoubleJump ;;;;;do we have item doublejump
CMP #$01
BNE +++

LDA doubleJumpCounter ;;;;;;;;;;;;;;;;;we do have double jump so have we used all jumps?
CMP #$02
BEQ +++
CMP #$01
BEQ ++ ;;;;;;;;;;;;;;;;;;;;;;;;;this is the only situation where it doesnt reset jumpcounter to 0 when relesing jump
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;which is potentially a problem.....
+++
LDA #$00
STA doubleJumpCounter
++
 

mouse spirit

Well-known member
We gotta put my code at the very top on the press jump script.

Code:
LDA gotDoubleJump ;;;;;;;;;;;;;do we have doublejump?
CMP #$01
BNE +++

LDA doubleJumpCounter ;;;;;;;;;;;;;;;;;we do have doublejump so have we used all our jumps?
CMP #$02
BEQ +
JMP ++
+
RTS
++
JMP +doJump
+++

;;;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Only can jump if the place below feet is free.
    SwitchBank #$1C
    LDY Object_type,x
    LDA ObjectBboxTop,y
    CLC
    ADC ObjectHeight,y
    sta temp2
    
    LDA Object_x_hi,x
    CLC
    ADC ObjectBboxLeft,y
    STA temp
    JSR getPointColTable
    
    LDA Object_y_hi,x
    CLC
    ADC #$02
    CLC
    ADC temp2
    STA temp1
    CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
    
    CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
     CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is prize block .
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
    CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
     BNE +dontDoJump
          JMP  +doJump
        +dontDoJump
            ;; check second point.
        LDY Object_type,x
        LDA ObjectWidth,y
        CLC
        ADC temp
        STA temp
        JSR getPointColTable
        CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
                                            ;;; if it is (equal), can jump.
                                            ;;; if not, skips jumping.          
        BEQ +doJump
        
        CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
        CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
        CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
            JMP +skipJumping

;;;;;;;;;;;;;;;;;;; Baardbi modified start



+doJump:

INC doubleJumpCounter   ;;;;;;;;;;we are jumping so increase jump counter no matter what;;;;;;;;;;;;;;;;;;;;;;;;;;

    TXA
    STA temp ;; assumes the object we want to move is in x.
    ;PlaySound #sfx_thump

    LDY Object_type,x
    LDA ObjectJumpSpeedLo,y
    EOR #$FF
    STA Object_v_speed_lo,x
    LDA ObjectJumpSpeedHi,y
    EOR #$FF
    STA Object_v_speed_hi,x
        
    TXA
    STA temp ;; assumes the object we want to move is in x.
 ;  change the object's action so that he is in jump mode.
 
    ReturnBank
    RTS
	
;;;;;;;;;;;;;;;;;;; Baardbi modified stop

That was my bad.
 

mouse spirit

Well-known member
I also put the INC in the right spot,try just to copy past the code above.

Its possible you will get outofrange errors, we may have to
hop skip aaaand jmp.
 

baardbi

Well-known member
When I put the code at the top the player just twitches a little bit and doesn't move from the ground.

doublejumpproblem.gif
 

mouse spirit

Well-known member
ok . Make sure to copy the code i have here and replace your whole code.

Code:
LDA gotDoubleJump ;;;;;;;;;;;;;do we have doublejump?
CMP #$01
BNE +++

LDA doubleJumpCounter ;;;;;;;;;;;;;;;;;we do have doublejump so have we used all our jumps?
CMP #$02
BEQ +
JMP ++
+
RTS
++
JMP +doJump
+++

;;;; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Only can jump if the place below feet is free.
    SwitchBank #$1C
    LDY Object_type,x
    LDA ObjectBboxTop,y
    CLC
    ADC ObjectHeight,y
    sta temp2
    
    LDA Object_x_hi,x
    CLC
    ADC ObjectBboxLeft,y
    STA temp
    JSR getPointColTable
    
    LDA Object_y_hi,x
    CLC
    ADC #$02
    CLC
    ADC temp2
    STA temp1
    CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
    
    CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
     CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is prize block .
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
    BNE +checkMore 
        JMP +doJump
    +checkMore
    CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
     BNE +dontDoJump
          JMP  +doJump
        +dontDoJump
            ;; check second point.
        LDY Object_type,x
        LDA ObjectWidth,y
        CLC
        ADC temp
        STA temp
        JSR getPointColTable
        CheckCollisionPoint temp, temp1, #$01, tempA ;; check below feet to see if it is solid.
                                            ;;; if it is (equal), can jump.
                                            ;;; if not, skips jumping.          
        BEQ +doJump
        
        CheckCollisionPoint temp, temp1, #$07, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
        CheckCollisionPoint temp, temp1, #$09, tempA ;; check below feet to see if it is jumpthrough platform.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
        CheckCollisionPoint temp, temp1, #$0A, tempA ;; check below feet to see if it is ladder.
                                        ;;; if it is (equal), can jump.
                                        ;;; if not, skips jumping.
        BEQ +doJump
            JMP +skipJumping

;;;;;;;;;;;;;;;;;;; Baardbi modified start



+doJump:

INC doubleJumpCounter   ;;;;;;;;;;we are jumping so increase jump counter no matter what;;;;;;;;;;;;;;;;;;;;;;;;;;

    TXA
    STA temp ;; assumes the object we want to move is in x.
    ;PlaySound #sfx_thump

    LDY Object_type,x
    LDA ObjectJumpSpeedLo,y
    EOR #$FF
    STA Object_v_speed_lo,x
    LDA ObjectJumpSpeedHi,y
    EOR #$FF
    STA Object_v_speed_hi,x
        
    TXA
    STA temp ;; assumes the object we want to move is in x.
 ;  change the object's action so that he is in jump mode.
 
    ReturnBank
    RTS
	
;;;;;;;;;;;;;;;;;;; Baardbi modified stop

As we needed to edit some stuff out in the original code too.If it doesnt work,
we should be close.
 

mouse spirit

Well-known member
I see what you mean with the counter constantly being reset but it shouldnt
since you would have to release A to make it go to 0.
 

baardbi

Well-known member
He stil does the same twitchy thing (like in the GIF i posted). I'm trying to find out why he doesn't jump in the first place.
 

baardbi

Well-known member
OK. Thank you for your help so far. It's great to discuss these things with other NESmakers.
 

mouse spirit

Well-known member
No problem. I got it working well in 4.1.5 when i take out some check platform code in my jump script. I will keep you updated.
 
Top Bottom