My code without switch:
proc
moveUpdateNoSwitch()
// . = direction to move
if(horz != 0) updateStraightMovement()
else updateAngularMovement()
if(!m) return
// Deal with positive vertical movement
if(vert == 1)
if(horz == 1) . = 5
else if(horz == -1) . = 9
else . = 1
// Deal with negative vertical movement
else if(vert == -1)
if(horz == 1) . = 6
else if(horz == -1) . = 10
else . = 2
// Deal with no vertical movement
else if(vert == 0)
if(horz == 1) . = 4
else if(horz == -1) . = 8
// Going to skip running movement as it's not what we're testing
Your code using swtich with some go-faster edits.
moveUpdateSwitch()
if(horz != 0) updateStraightMovement()
else updateAngularMovement()
if(!m) return
switch(vert)
if(1) switch(horz)
if(1)
. = 5
if(-1)
. = 9
else
. = 1
if(-1) switch(horz)
if(1)
. = 6
if(-1)
. = 10
else
. = 2
else if(!vert) switch(horz)
if(1)
. = 4
if(-1)
. = 8
// Going to skip running movement as it's not what we're testing
Update procs used:
updateAngularMovement()
pmove += round(speed/sqrt2)
m = round(pmove/10)
pmove %= 10
updateStraightMovement()
pmove += speed
m = round(pmove/10)
pmove %= 10
I'm going to use the updateMovement procs from my earlier posts and run our code in the profiler.