Problem - Sprites can be drawn at X/Y coordinates >= 0xfff9 to appear
partially over the left/upper screen boundary. But the dirty-rectangle
calculation doesn't account for this, so these updates will only appear
on the screen if something *else* dirties this area of the screen. This
can be observed in /projects/examples/devices/screen.tal where these
edges of the screen show stale content.
Solution - Detect wrapping and expand the dirty rectangle appropriately.
Change screen_change to take Uint16 to make sure values are truncated to
the intended range. Ignore changes that are fully off the screen.
At some point snprintf(3) prototype became guarded off in stdio.h.
Defining _C99_SOURCE makes it visible.
On legacy Darwin, such a guard was not present so the definition
has no impact on the build, but on "modern" macos it has the desired
effect.
Build tested on OS X 10.4 and macos 10.15.
This patch tries to improve the accuracy of our
screen refresh timing. Notably, it tries to ensure
we don't introduce extra delay in our timing based
on how long the screen vector takes to evaluate.
We also try to ensure we only call SDL_Delay when
we have at least 1ms to wait.
For some reason on macOS, the functions `snprintf` and `vsnprintf` are
not in the X/Open 5 (ANSI C89) standard but rather in the X/Open
6 (ISO C99). A simplest solution seems to be to declaring the missing
functions before using them, which is what I did here. Another option
is to use the C99 standard with `#define _XOPEN_SOURCE 600`, which
seems to be an overkill for such a niche issue.
Quoting from the STANDARDS section in `man 3 snprintf` on macOS:
> ...the snprintf() and vsnprintf() functions conform to ISO/IEC
> 9899:1999 (“ISO C99”)...