Import Cardgame 0.1.15 upstream source snapshot

Original author: Pierre Sarrazin. Public-domain library and demo.
Source: http://sarrazip.com/dev/cardgame-0.1.15.tar.gz
Archive SHA-256: ca706dddd96fec63b829f8958c2e47485b0e1166129d45fda0b6369404c1bb54
This commit is contained in:
Brian Holman committed 2026-11-09 23:35:21 -07:00
commit d3a54e24ee
39 files changed
+2603

No files matched your search

+42
View File
@@ -0,0 +1,42 @@
#include "cardgame.h"
#ifdef OS9
#define getTimer() (OS9Timer_getTimer())
#endif
byte
waitForKeyWithAnimatedCursor(KeyboardPollFunction poll,
void *userdata,
word ticksPerCursorPeriod,
GetTimerFunction getTimerValue)
{
byte prevCursorState;
word nearEndOfPeriod;
if (ticksPerCursorPeriod > 0) // if cursor wanted
{
invertCharAtCursor();
prevCursorState = 1;
nearEndOfPeriod = ticksPerCursorPeriod * 3 / 4;
}
else
prevCursorState = 0;
byte key;
while ((key = (*poll)(userdata)) == 0)
{
if (ticksPerCursorPeriod > 0)
{
word now = (*getTimerValue)(userdata);
byte currentCursorState = (now % ticksPerCursorPeriod < nearEndOfPeriod);
if (currentCursorState != prevCursorState)
{
invertCharAtCursor();
prevCursorState = currentCursorState;
}
}
}
if (prevCursorState)
invertCharAtCursor();
return key;
}