Looks good, though I would suggest you take advantage of signed math in the following way.
Code:
int tempPwm01;
int topSpeed = 127;
tempPwm01 = (int)pwm01 - 127; //0 center [-127 to 127]
tempPwm01 = tempPwm01 * topSpeed / 254; //Reduce range to
//[-topSpeed / 2 to topSpeed / 2]
pwm01 = tempPwm01 + 127; //127 center
I did wrote it spread out like that to make it easier to understand, but it can all be reduced to 1 statement:
Code:
pwm01 = 127 + ( ((int)pwm01 - 127) * topSpeed / 254 );
As long as you are sure topSpeed will never exceed 254 and will never go below 0 you don't need to min/max anything.
By the way, just to confirm that this is what you are trying to achieve. The above code will turn a pwm value of 254 into 127 + (topSpeed / 2) and a pwm value of 0 into 127 - (topSpeed / 2). It's the same as the C code that you posted but I just want to make sure that's what you want.