(SOLVED) [4.5.6] Walking Direction Gets Reset

Craigery

Active member
Hello, I have an odd problem. This was working before the weekend, but I somehow broke it. I have diagonal walking setup for my player, but after walking Down or Right, it affects my Up and Left movement.

LeonWalkingBug080221.gif
Screenshot 2021-08-02 211101.png

Code:
    TXA
    STA temp    ;; assumes the object we want to move is in x.
   
    GetActionStep temp
    CMP #$07
    BEQ +skip
   
            ChangeFacingDirection temp, #FACE_UPRIGHT
            StartMoving temp, #UPRIGHT
            clc
            LDA #$C8
            STA Object_h_speed_lo,x
            LDA #$27
            STA Object_v_speed_lo,x
            JMP +skip

    +skip
RTS

My code is pretty simple so I think there must be something else interfering with it, but I don't know what else to look for. Is there a work around I could use or any ideas?
Thanks
 
Last edited:

mouse spirit

Well-known member
If you didnt do anything to directly cause this, you possibly filled up a bank. Maybe bank14. Just a thought.
It wont always warn you or pull up an error. Check out bank 14 and look at whats in there. If youve been adding things that get passed through there,that may be why.

This is assuming that you didnt happen to alter you input code to make this happen. Accidently ofcourse.
 

Craigery

Active member
If you didnt do anything to directly cause this, you possibly filled up a bank. Maybe bank14. Just a thought.
It wont always warn you or pull up an error. Check out bank 14 and look at whats in there. If youve been adding things that get passed through there,that may be why.

This is assuming that you didnt happen to alter you input code to make this happen. Accidently ofcourse.
Bank 14 is 91% free. 1F is 10% free too.
 

Jonny

Well-known member
Looks like the h and v speeds are wrong but the facing direction and it's animations are correct. All I can think of is maybe those speeds need resetting somewhere?
 

Craigery

Active member
Looks like the h and v speeds are wrong but the facing direction and it's animations are correct. All I can think of is maybe those speeds need resetting somewhere?

If I get hit and recoil it will reset my movement and it will work normally until you press Down or Right again. It has something to do with the moving direction, but I just don't know how/where to reset it.
 

kevin81

Well-known member
I think it might have to do with the way the StartMoving macro works. The macro uses the second argument (#UPRIGHT in your example) to determine if it should change either the object's horizontal or vertical movement. It seems that the macro was not written with diagonal movement in mind, so once the "move down" bit is set to 1 by the macro, it will never be reset to 0 by that macro. Other parts of the game are still able to reset it though, like getting hurt or the recoil script.

I'm not 100 percent sure the following solves it, but I think it's worth the try:

Make a backup of the file \GameEngineData\Routines\BASE_4_5\System\ObjectBehaviors\oStartMovingInADirection.asm (just to be safe), then open it and change line #27 from:
AND temp
to:
AND #%00001111
which should force both horizontal and vertical movement to be updated.

If this works, you could even remove lines 10-24 from that file as it serves no function anymore. Saves a few CPU cycles as well :)
Hope this helps!
 

Craigery

Active member
I think it might have to do with the way the StartMoving macro works. The macro uses the second argument (#UPRIGHT in your example) to determine if it should change either the object's horizontal or vertical movement. It seems that the macro was not written with diagonal movement in mind, so once the "move down" bit is set to 1 by the macro, it will never be reset to 0 by that macro. Other parts of the game are still able to reset it though, like getting hurt or the recoil script.

I'm not 100 percent sure the following solves it, but I think it's worth the try:

Make a backup of the file \GameEngineData\Routines\BASE_4_5\System\ObjectBehaviors\oStartMovingInADirection.asm (just to be safe), then open it and change line #27 from:
AND temp
to:
AND #%00001111
which should force both horizontal and vertical movement to be updated.

If this works, you could even remove lines 10-24 from that file as it serves no function anymore. Saves a few CPU cycles as well :)
Hope this helps!
It worked! Leon is moving around as intended now. Kevin, you are my hero 🤩!!
 

Craigery

Active member
Actually I spoke too soon. Now once a Monster Object moves it causes the Monster and the Player to have the movement problem again. My Monster AI Movement scripts do use the StartMoving macro. @kevin81 any clue?

EDIT: Spoke too soon again, changing it to AND #%11111111 solved the issue. Cheers!
 
Last edited:
Top Bottom