4.5.6 - 8 directions and Input Script Order

drexegar

Member
NOTE: This easy technique was done in Shooter Module but should work with other modules.

So moving in 4 directions is kinda of lame for ship movement.

So I took a wild guess and copy a input script and adding the #UPLEFT #UPRIGHT #DOWNLEFT #DOWNRIGHT works.

For Example I took the original moveUp_shooter.asm: (by default the directional animation is commented out for Shooter Module, so you need uncomment if you want to use directions)
Code:
;;;; 
    TXA
    STA temp ;; assumes the object we want to move is in x.

    StartMoving temp, #UP
     ;   TXA
     ;   STA temp ;; assumes the object we want to move is in x.
     ;   ChangeFacingDirection temp, #FACE_UP
 
    RTS


and change the direction to one of the diagonal values nesmaker supports.
Code:
;;;; 
    TXA
    STA temp ;; assumes the object we want to move is in x.

    StartMoving temp, #UPRIGHT
     ;   TXA
     ;   STA temp ;; assumes the object we want to move is in x.
     ;   ChangeFacingDirection temp, #FACE_UPRIGHT
 
    RTS


So I did this for the rest and through in inputs and put it in a separate folder not to mix with defaults...
But I ended up with a problem... It didn't work right.

but DOWNLEFT did work...

So since nes works line by line and I know coding a bit, I took a quick guess that the order may be holding up the inputs So here is the order and THIS WORKED!

InputOrder.jpg

So first is to the check for regular inputs which are important to Start the character moving, than the diagonal inputs which will only have to detect 1 more input since the 1 is already detected from the regular scripts, and the release for last.

So Order is very important!

Recommend that all GAMEPLAY scripts should be on top and your lesser scripts like OPTIONS, TITLE SCREEN, SHOP Stuff be on the bottom, since you want your controls to respond as fast as possible.
 

mouse spirit

Well-known member
Ha. Very nice. I wondered about the order of inputs there and so i have always tried to order them in a priority fashion. Not knowing if it actually helped in 4.1.5
 

PasseGaming

Active member
Aww sweet, I'll give this a try. I was looking for something along these lines!

I have a question though, do you not need a release script for those commands? I don't see any in your screenshot.
 
Last edited:

CutterCross

Active member
Aww sweet, I'll give this a try. I was looking for something along these lines!

I have a question though, do you not need a release script for those commands? I don't see any in your screenshot.
The stopMoving.asm script assignments for UDLR release takes care of the diagonals too. No need to add 4 extra.
 

PasseGaming

Active member
Okay, I know this thread is quite old but I decided to implement this into my game to help solve the movement issues im having with my shooter module game. Problem is the player still seems to stick a little when changing direction rapidly. With these scripts it does seem better but not quite as smooth as I had hoped for. Has anyone managed to improve upon these scripts?
 

LOKIOLR

New member
Okay, I know this thread is quite old but I decided to implement this into my game to help solve the movement issues im having with my shooter module game. Problem is the player still seems to stick a little when changing direction rapidly. With these scripts it does seem better but not quite as smooth as I had hoped for. Has anyone managed to improve upon these scripts?
I have 8 direction, (4 sprite facing directions) movement in Pixel Poops: Number Two for two players. I put all my movement scripts into one and that works ok for me.

Code:
    TXA
    STA temp ;; assumes the object we want to move is in x.
       
    LDA controllerNumber_hold
    BEQ +
        ;; we are checking controller 2.
        LDA gamepad2
        AND #%11110000
        STA temp1
        JMP CheckingDpadButtons
    +
    ;; we are checking controller 1.
    LDA gamepad
    AND #%11110000
    STA temp1
    JMP CheckingDpadButtons

    ;LDA Object_direction,x
    ;AND #%00001111
    ;STA Object_direction,x
     
CheckingDpadButtons:
 
    LDA #$FF
    STA tempC
    STA temp2
 
    LDA temp1
    BNE +
        JMP changeToStop_NoDpadPressed
    +
    CMP #%00010000 ; UP
    BNE +
        LDA Object_direction,x
        AND #%11001111
        STA Object_direction,x
        LDA #UP
        STA tempC
        LDA #FACE_UP
        STA temp2
        JMP changeToMove_DpadPressed
    +
    CMP #%01010000 ; UP LEFT
    BNE +
        LDA Object_direction,x
        AND #%00001111
        STA Object_direction,x
        LDA #UPLEFT
        STA tempC
        ;LDA #FACE_UPLEFT
        ;STA temp2
        JMP changeToMove_DpadPressed
    +
    CMP #%01000000 ; LEFT
    BNE +
        LDA Object_direction,x
        AND #%00111111
        STA Object_direction,x
        LDA #LEFT
        STA tempC
        LDA #FACE_LEFT
        STA temp2
        JMP changeToMove_DpadPressed
    +
    CMP #%01100000 ; DOWN LEFT
    BNE +
        LDA Object_direction,x
        AND #%00001111
        STA Object_direction,x
        LDA #DOWNLEFT
        STA tempC
        ;LDA #FACE_DOWNLEFT
        ;STA temp2
        JMP changeToMove_DpadPressed
    +
    CMP #%00100000 ; DOWN
    BNE +
        LDA Object_direction,x
        AND #%11001111
        STA Object_direction,x
        LDA #DOWN
        STA tempC
        LDA #FACE_DOWN
        STA temp2
        JMP changeToMove_DpadPressed
    +
    CMP #%10100000 ; DOWN RIGHT
    BNE +
        LDA Object_direction,x
        AND #%00001111
        STA Object_direction,x
        LDA #DOWNRIGHT
        STA tempC
        ;LDA #FACE_DOWNRIGHT
        ;STA temp2
        JMP changeToMove_DpadPressed
    +
    CMP #%10010000 ; UP RIGHT
    BNE +
        LDA Object_direction,x
        AND #%00001111
        STA Object_direction,x
        LDA #UPRIGHT
        STA tempC
        ;LDA #FACE_UPRIGHT
        ;STA temp2
        JMP changeToMove_DpadPressed
    +
    CMP #%10000000 ; RIGHT
    BNE +
        LDA Object_direction,x
        AND #%00111111
        STA Object_direction,x
        LDA #RIGHT
        STA tempC
        LDA #FACE_RIGHT
        STA temp2
        JMP changeToMove_DpadPressed
    +
 
    RTS
             
changeToStop_NoDpadPressed:
 
    LDA Object_direction,x
    AND #%00001111
    STA Object_direction,x
    ;+setObDir

    LDA stageClear
    STX temp
    BNE + ;if Stage clear flag set, change to celebration, otherwise idle.
        ;STX temp
        ;StopMoving temp, #$FF
        ChangeActionStep temp, #$00 ;; idle action
        RTS
    +
    ChangeActionStep temp, #$03 ;; change to celebration action if idle.
        ;arg0 = what object?
        ;arg1 = what behavior?
   
    RTS
 
changeToMove_DpadPressed:
    
    STX temp
    GetActionStep temp
    CMP #$01
    BEQ +
        ChangeActionStep temp, #$01 ;running action
    +
    STX temp
    StartMoving temp, tempC
    LDA temp2
    CMP #$FF
    BEQ +
        STX temp
        ChangeFacingDirection temp, temp2
    +    
    RTS

Input setup (order doesn't really matter):
movement input.png

This may or may not work depending on what other movement you have setup. If you want to add the diagonal facing directions, just uncomment the LDA and STA temp2 lines. It's messy but it works alright.

You can also try the demo of my game to see if that movement works for what your game needs.
 
Last edited:

PasseGaming

Active member
I'll give it a try, thank you. Looks much more complicated then what I was using, I just need the ship to move around smoothly. It's a auto-scrolling game so that's all it really needs to do.

Also it's a one player game, do you think it's a good idea to comment out the controller 2 check?
 

PasseGaming

Active member
This should work in adventure with no problem. All i'm doing is enabling controls that are in nesmaker already.

Your script is the one I am using, it sticks a little bit but it's the best one that's currently out there. I was referring to Lokiolr script.
 

drexegar

Member
Your script is the one I am using, it sticks a little bit but it's the best one that's currently out there. I was referring to Lokiolr script.
oh I see now! It's cool to have all your scripts together, but I rather have my code separate for the sake of a combination of space and speed and focus.

But I can see that in the future that now i know more ASM, I would try to do things from scratch similar to Lokiolr.
 

ronin1011

Member
Hey I implemented this in my shooter game and after a death from an enemy or enemy projectile, when the screen restarts my char moves on his own. I still have 8 dir control just doesn't stop when I release the d-pad. Also, my char becomes invincible and wont take damage from any enemies lol. Any ideas?
Thanks.
 

drexegar

Member
Hey I implemented this in my shooter game and after a death from an enemy or enemy projectile, when the screen restarts my char moves on his own. I still have 8 dir control just doesn't stop when I release the d-pad. Also, my char becomes invincible and wont take damage from any enemies lol. Any ideas?
Thanks.
A quick solution which I recommend, is on death, is to destroy the player and replace it with a death object (explosion), this is a quick way to disable the controls with out using code.
 

ronin1011

Member
A quick solution which I recommend, is on death, is to destroy the player and replace it with a death object (explosion), this is a quick way to disable the controls with out using code.
Thanks. Yeah I still haven't figured out how to do that. Lol
 

NotAChance

New member
Question for that smarties regarding 8-drirection movement... What would I need to add to my diagonal scrips to reduce my players movement speed?

Being able to move on diagonals at the same speed as I do on the X and Y axis' feels a bit overpowered. Like I'm traversaing space too quickly. I'm trying to figure out how to dampen that a bit.
 

vanderblade

Active member
I've been using this method to achieve 8-way movement in 4.5.9 for months now, but the controls still feel off, especially on original hardware, which I'm starting to test on at the moment. Using 8-way movement in 4.1.5 worked just fine and felt smooth.

I'm wondering if it's because in 4.1.5 there is a unique stop script for each of the four principle directions (UDLR), whereas in 4.5.9, it's just a general stop all movement script.

Anybody feel like they have SMOOTH 8-way controls in the latest version of NESMaker?
 
Top Bottom