Time limit above 999, random characters in timer
#21
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.
Reply
#22
The strange stuff happening when the hundreds digit is above 9 seems to be an effect of pointer arithmetic. The idea being that when CPU is scarce, pointer arithmetic is a very efficient way to implement a lookup table. Since the table only has 9 digits defined, beyond that the program would simply (try to) read whatever happened to be in RAM at the spots beyond 9.

The real question is whether or not someone could come up with a level that would actually use a significant part of a slightly more than 9 hour limit and still be interesting to play.
Reply
#23
Quote:The real question is whether or not someone could come up with a level that would actually use a significant part of a slightly more than 9 hour limit and still be interesting to play.
And the real answer is no. Slight smile
Reply
#24
Highest possible time limit = 32767

32767 * 1.17 = 38337.39 seconds real time

38337.39 seconds = 10.649275 hours (10:38:57)
[Image: 45782.png]
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)