crazygrouptrio
Active member
In making Tryptic I came to the realization that having lots of set Inputs can cause your game to run slowly! And if you have a 4 directional game and use the provided NESmaker input scripts you'll be using 16 different inputs just for moving! (Move, Stop, Start Action, Stop Action for each direction). To cut this down, I simply combined the movement and change action scripts. This cuts down on inputs, and actually frees up a small amount of bank space.
Move Left:
Now every other direction is slightly different:
Move Right:
Use this same code for Up and Down if you need and just replace the movement directions. There's no reason to use the "check if we're walking" portion of the code in each script when we can just jump to it, which is part of why this saves space. Now just assign it to "Hold" in your inputs just as you normally would for the StartMoving scripts.
Now we just need to stop movement and set action to Idle:
Stop Movement:
You can swap out the middle portion depending on what type of game you have. Set it to "Release" just as you would for the default stop movement.
And that's it! We've cut our number of inputs in half!
Here's a rundown:
Advantages:
* Less inputs
* Less slow down
* Less bank space
* Fixes the "return to walking after attacking" issue
Disadvantages:
* A little less fluid in 4 directional games, but still playable
Move Left:
Code:
STX temp ;; assumes the object we want to move is in x.
StartMoving temp, #LEFT
STX temp ;; assumes the object we want to move is in x.
ChangeFacingDirection temp, #FACE_LEFT
checkWalkAction:
; check for actions where we don't want to change to walking action
; such as walking or jumping
GetActionStep temp
CMP #$01 ; walk
BEQ +done
CMP #$02 ; jump
BEQ +done
CMP #$07 ; hurt
BEQ +done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
ChangeActionStep temp, #$01 ;; assumes that "walk" is in action 1
+done
RTS
Now every other direction is slightly different:
Move Right:
Code:
STX temp ;; assumes the object we want to move is in x.
StartMoving temp, #RIGHT
STX temp ;; assumes the object we want to move is in x.
ChangeFacingDirection temp, #FACE_RIGHT
JMP checkWalkAction
RTS
Use this same code for Up and Down if you need and just replace the movement directions. There's no reason to use the "check if we're walking" portion of the code in each script when we can just jump to it, which is part of why this saves space. Now just assign it to "Hold" in your inputs just as you normally would for the StartMoving scripts.
Now we just need to stop movement and set action to Idle:
Stop Movement:
Code:
STX temp ;; assumes the object we want to move is in x.
GetActionStep temp
CMP #$07
BNE +notHurt
JMP +done
+notHurt
; use this for 4 directional game - adventure
LDA gamepad
AND #%11110000
BEQ changeToStop_NoDpadPressed
JMP +done
; use this for 2 directional game - i.e. platformer, metroidvania
; LDA gamepad
; AND #%11000000
; BEQ changeToStop_NoDpadPressed
; JMP +done
changeToStop_NoDpadPressed:
ChangeActionStep temp, #$00 ;; assumes that "idle" is in action 0
StopMoving temp, #$FF, #$00
+done
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
RTS
You can swap out the middle portion depending on what type of game you have. Set it to "Release" just as you would for the default stop movement.
And that's it! We've cut our number of inputs in half!
Here's a rundown:
Advantages:
* Less inputs
* Less slow down
* Less bank space
* Fixes the "return to walking after attacking" issue
Disadvantages:
* A little less fluid in 4 directional games, but still playable