[4.5.9] Drop through OneWay Tile (when down is pressed)

Jonny

Well-known member
This is a very short and simple tutorial solely because I've been searching for the ideal way to do this but couldn't find one.
I thought there might be some new users trying to do this same thing and struggling to find info like I was.
Note: In earlier versions of NesMaker this was done in the simplejump script, but going though older posts there seems to be issues with that method.
Please comment if there's an easier or better way to do this. I'm sure it's been done a million times before in 4.5.X but, like I say, I could'nt find any 'how to' info.

I made this work by adding a condition (check) to the physics script before it changes the OneWay Tile to a solid...

Find where +isOneWaySolid is defined (somewhere around line 570 or after) and add this before the Object_v_speed stuff...

Code:
;;; UPDATED CORRECTION - Thanks Dale ;;;

LDA gamepad
    AND #%00100000                  ;; DOWN GAMEPAD PRESS ;;
    BNE +doPressDown
 
    ;; DOWN NOT PRESSED ;;

    JMP +doneDownPress
+doPressDown:

    ;; DOWN IS PRESSED ;;
    
    JMP +notSolid                   ;; DONT MAKE SOLID    ;;
+doneDownPress:

droponeway.gif
 
Last edited:

Jonny

Well-known member
I forgot to mention that I had to put a JMP in before this because the added code pushed it too far for a branch. So, if you try it and get an 'out of range' error that's what needs fixing.
 

dale_coop

Moderator
Staff member
Great idea...
I would just like to point out that the comments are not correct.

It should be:
Code:
    LDA gamepad
    AND #%00100000                  ;; DOWN GAMEPAD PRESS ;;
    BNE +doPressDown
   
    ;; HERE the DOWN button is NOT pressed ;;

    JMP +doneDownPress
+doPressDown:
    JMP +notSolid                   ;; DONT MAKE SOLID    ;;
+doneDownPress:
 

Jonny

Well-known member
You're right, I've got it back to front... sorry about that.

I've updated original post with this...

Code:
    LDA gamepad
    AND #%00100000                  ;; DOWN GAMEPAD PRESS ;;
    BNE +doPressDown
  
    ;; DOWN NOT PRESSED ;;

    JMP +doneDownPress
+doPressDown:

    ;; DOWN IS PRESSED ;;
    
    JMP +notSolid                   ;; DONT MAKE SOLID    ;;
+doneDownPress:
 

dale_coop

Moderator
Staff member
Your script was great btw, it was just the label and comment that might have confused some nesmaker users ;)
Thank you for sharing it :)
 

Jonny

Well-known member
Definitely. I'd rather it was correct so thank you.

I'm doing a dash attack next. I'll do a better job of checking it all next time 🙂
 

Subotai

Active member
Good job Jonny and thanks for sharing your script.

When you say : forgot to mention that I had to put a JMP in before this because the added code pushed it too far for a branch. So, if you try it and get an 'out of range' error that's what needs fixing.

We must Jump to what ?

Code:
    JMP to ????
    LDA gamepad
    AND #%00100000                  ;; DOWN GAMEPAD PRESS ;;
    BNE +doPressDown

    ;; DOWN NOT PRESSED ;;

    JMP +doneDownPress
+doPressDown:

    ;; DOWN IS PRESSED ;;
   
    JMP +notSolid                   ;; DONT MAKE SOLID    ;;
+doneDownPress:
 

dale_coop

Moderator
Staff member
When you have a 'branch out of range' error on a, for example:
Code:
  BEQ +doThis     ;; if is equal branch out to the next +doThis label

You need to reverse the condition and do a jump:
Code:
  BNE +skipThis     ;; if is NOT equal branch out to the next +skipThis label
  JUMP +doThis    ;; else, jump to the next +doThis label
+skipThis:
 

Subotai

Active member
When you have a 'branch out of range' error on a, for example:
Code:
  BEQ +doThis     ;; if is equal branch out to the next +doThis label

You need to reverse the condition and do a jump:
Code:
  BNE +skipThis     ;; if is NOT equal branch out to the next +skipThis label
  JUMP +doThis    ;; else, jump to the next +doThis label
+skipThis:

Like this ?

Code:
    ;;; UPDATED CORRECTION - Thanks Dale ;;;
    BNE +skipThis
        JUMP +doThis
        +doThis
        LDA gamepad
        AND #%00100000                  ;; DOWN GAMEPAD PRESS ;;
        BNE +doPressDown
        ;; DOWN NOT PRESSED ;;
        JMP +doneDownPress
        +doPressDown:
        ;; DOWN IS PRESSED ;;
        JMP +notSolid                   ;; DONT MAKE SOLID    ;;
        +doneDownPress:
    +skipThis

It gives me "illegal instruction" on line : JUMP +doThis
 

Jonny

Well-known member
Apologies all, I should have explained that part properly in the original post. Glad you got it working though.
 

Jonny

Well-known member
I thought pressing down + a does that already?
Was it changed in the newer versions?
It didn't work like that for me (obviously) but tbh you got me thinking now! I don't recollect changing anything that would stop that function.

I know for earlier versions I didn't have to do anything as it was part of the jump script (press down and jump button).
 

puppydrum64

Active member
This is a very short and simple tutorial solely because I've been searching for the ideal way to do this but couldn't find one.
I thought there might be some new users trying to do this same thing and struggling to find info like I was.
Note: In earlier versions of NesMaker this was done in the simplejump script, but going though older posts there seems to be issues with that method.
Please comment if there's an easier or better way to do this. I'm sure it's been done a million times before in 4.5.X but, like I say, I could'nt find any 'how to' info.

I made this work by adding a condition (check) to the physics script before it changes the OneWay Tile to a solid...

Find where +isOneWaySolid is defined (somewhere around line 570 or after) and add this before the Object_v_speed stuff...

Code:
;;; UPDATED CORRECTION - Thanks Dale ;;;

LDA gamepad
    AND #%00100000                  ;; DOWN GAMEPAD PRESS ;;
    BNE +doPressDown

    ;; DOWN NOT PRESSED ;;

    JMP +doneDownPress
+doPressDown:

    ;; DOWN IS PRESSED ;;
   
    JMP +notSolid                   ;; DONT MAKE SOLID    ;;
+doneDownPress:

View attachment 4163
Quick question: What are the other codes for the other buttons (if Down is #%00100000?) I can't find them in the asm files
 

TakuikaNinja

Active member
Quick question: What are the other codes for the other buttons (if Down is #%00100000?) I can't find them in the asm files
There are constants you can use to indicate directions (both moving & facing) in BASE_4_5\System\SystemConstants.asm
Perhaps those might help?
 

Jonny

Well-known member
Quick question: What are the other codes for the other buttons (if Down is #%00100000?) I can't find them in the asm files


This is where I go for reference but you could also search on NesDev. Someone did a nice reference guide for a few things like this on this forum but I can't find it.
 

vanderblade

Active member
Thanks for this, Jonny. I added another condition so players have to hold DOWN + press A to fall through the One-Way Platform. I think most will probably want that functionality. My code is not efficient, but it works. And yes, adding the JMP above all this is necessary. Maybe we can instruct new users how to do this for those stumbling upon this thread?

In any case, here's my addition to your code that adds the requirement to press A while pressing down:

Code:
        LDA gamepad
        AND #%00100000     ;; DOWN GAMEPAD PRESS ;;
        BNE +doPressDown
        JMP +doneDownPress ;; DOWN NOT PRESSED ;;
        
        +doPressDown: ;; DOWN IS PRESSED ;;
        
        LDA gamepad
        AND #%00000001 ;; is the A button pressed?
        BNE +
        JMP +doneDownPress
        
        +
        JMP +notSolid  ;; DONT MAKE SOLID    ;;
        
        +doneDownPress:
 
Top Bottom