27-Aug-2017, 12:39 PM
Quote:Signed and unsigned integers have the same bit representations; the difference is how the bits are interpreted (see https://en.wikipedia.org/wiki/Two's_complement).
I think the variable that stores the time limit is designated as a signed integer since time limits past 32767 are frozen, but the code that handles the timer display is looking at the bits directly to determine the last two digits.
Yes, I think something like this must be the case. Presumably the game checks whether the time limit is greater than 0 to see whether the level is timed. This, probably, also explains why the digits become yellow: the time remaining is <= 15 seconds.
Quote:* I was a bit ambiguous above; it is the time bonus points that overflow, which starts as early as time=3277. (since 32770 > 32767) It is not unique to time limits above 32768, and in fact there is no discontinuity between the time bonus points at time=32767 (-10) and time=32768 (0).
Ah, OK. Note that this is fully consistent with signed 16-bit arithmetic. With either signed or unsigned, we are working modulo 65536, and the only difference is what range of values we normalize the final result to. Or, more concretely, -2^15 * 10 is divisible by 2^16, so when coerced to the range [-2^15, 2^15) we get 0.