mirror of
https://github.com/Torrididdle/Arcle.git
synced 2026-05-26 15:53:48 +01:00
Date support
This commit is contained in:
Binary file not shown.
@@ -217,6 +217,26 @@ void screen_clear()
|
|||||||
_kernel_swi(OS_WriteC,&inreg,&outreg);
|
_kernel_swi(OS_WriteC,&inreg,&outreg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int get_days_since_1jan1900()
|
||||||
|
{
|
||||||
|
char datebuffer[5];
|
||||||
|
unsigned int date;
|
||||||
|
|
||||||
|
// Get centiseconds since 1 Jan 1900
|
||||||
|
datebuffer[0] = 3;
|
||||||
|
inreg.r[0] = 14;
|
||||||
|
inreg.r[1] = (int)datebuffer;
|
||||||
|
_kernel_swi(OS_Word,&inreg,&outreg);
|
||||||
|
|
||||||
|
// Drop a byte to get centiseconds/255 (so we can store in uint32)
|
||||||
|
date = datebuffer[1] + (datebuffer[2] << 8) + (datebuffer[3] << 16) + (datebuffer[4] << 24);
|
||||||
|
|
||||||
|
// Turn into days (there are 33750 255th-centiseconds in a day)
|
||||||
|
date = date / 33750;
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int font = 0;
|
int font = 0;
|
||||||
@@ -236,8 +256,20 @@ int main(int argc, char *argv[])
|
|||||||
loaddict("dict");
|
loaddict("dict");
|
||||||
printf("Loading answers...\n");
|
printf("Loading answers...\n");
|
||||||
loadanswers("answers");
|
loadanswers("answers");
|
||||||
|
|
||||||
|
// Start 19th of June 2021 with 0
|
||||||
|
arclenum = get_days_since_1jan1900() - 44364;
|
||||||
|
|
||||||
|
// In case we have gone past Oct 2027 we can just loop
|
||||||
|
while(arclenum > 2309)
|
||||||
|
arclenum = arclenum - 2309;
|
||||||
|
|
||||||
|
// If we pre-date wordle (perhaps clock not set) go with what's on file
|
||||||
|
if(arclenum < 0)
|
||||||
|
{
|
||||||
printf("Loading number...\n");
|
printf("Loading number...\n");
|
||||||
loadarclenum("arcnum");
|
loadarclenum("arcnum");
|
||||||
|
}
|
||||||
|
|
||||||
screen_clear();
|
screen_clear();
|
||||||
|
|
||||||
|
|||||||
@@ -3,4 +3,4 @@ An implementation of Wordle for the Acorn Archimedes series.
|
|||||||
|
|
||||||
Done using SWI calls as a challenge. Code is pretty messy, Sunday afternoon job and a hack-together from some old RiscOS stuff I've done.
|
Done using SWI calls as a challenge. Code is pretty messy, Sunday afternoon job and a hack-together from some old RiscOS stuff I've done.
|
||||||
|
|
||||||
Starts at the very first wordle, will move forwards as you get them right. No date handling etc yet.
|
Attempts to find the right word from the system clock. If the clock is un-set or pre-dates the first word then it starts at the beginning (or the one after the last one you've completed if appropriate).
|
||||||
|
|||||||
Reference in New Issue
Block a user