Would you explain what you are trying to do because the code doesn't make sense? For example, just for this expression:
It looks like you are using integer arithmetic (i.e. motorLeftPower is an integer variable) which means you will always get a zero in the above expression. Let me explain: the expression y*100/128 is pretty much scaling the joystick range (-128 to 127) to the motor range (-100 to 100). Let's say y is 50, so the result will be 50*100/128 which is 39. Then you divide it with 100 and multiply with 100 which totally doesn't make sense. 39/100 in integer arithmetic will give you zero then multiply with 100 will again give you zero. So no matter what value y is (as long as it is within 128), you will always get a zero.
If you are doing arcade drive, it should be very simple:
#define DEADBAND(n,d) ((abs(n) >= (d))? (n): 0)
#define JOYSTICK2MOTOR(n) ((n)*100/128)
#define BOUND(n,low,high) (((n) < (low))? (low): ((n) > (high))? (high): (n))
void ArcadeDrive(int x, int y)
x = DEADBAND(x, 20);
y = DEADBAND(y, 20);
leftMotorPower = BOUND(JOYSTICK2MOTOR(y + x), -100, 100);
rightMotorPower = BOUND(JOYSTICK2MOTOR(y - x), -100, 100);
motor[leftMotor] = leftMotorPower;
motor[rightMotor] = rightMotorPower;
Notice I have defined three macros. It makes the code a lot easier to read. The first macro is DEADBAND. If you are not familiar with conditional expression, it is basically equivalent to:
The second macro is JOYSTICK2MOTOR. It scales the joystick range (-128 to 127) to the motor power range (-100 to 100). It is pretty much self explanatory.
The third macro is to limit the power value to within the motor power range (-100 to 100). It is basically equivalent to:
The first thing the DriveAcade function does is to apply DEADBAND to both the x and y joystick values. Then it calculates the left and right wheel power for arcade style driving. This means the left is adding x to y and the right is subtracting x from y. But by doing this your left and right motor power could exceed the 100 range again (e.g. if after scaling the joystick range to the motor range, both x and y are 100, you will get 200 for the left wheel). So you use the BOUND macro to limit the power back to the range of -100 to 100.
Now if you are picky about this clipping will limit your fine control on the driving, you could do more sophisticated algorithm to scale the motor power such that it gives you a wider range of control. But if your primary concern is to make arcade drive work, the above code should do it.