diff --git a/!Arcle/!RunImage,ff8 b/!Arcle/!RunImage,ff8 index ee429f7..d4b0d54 100644 Binary files a/!Arcle/!RunImage,ff8 and b/!Arcle/!RunImage,ff8 differ diff --git a/!Arcle/c/Arcle b/!Arcle/c/Arcle index ddd5e2f..a1cb3c0 100644 --- a/!Arcle/c/Arcle +++ b/!Arcle/c/Arcle @@ -217,6 +217,26 @@ void screen_clear() _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 font = 0; @@ -236,8 +256,20 @@ int main(int argc, char *argv[]) loaddict("dict"); printf("Loading answers...\n"); loadanswers("answers"); - printf("Loading number...\n"); - loadarclenum("arcnum"); + + // 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"); + loadarclenum("arcnum"); + } screen_clear(); diff --git a/README.md b/README.md index e59d130..5bcf97a 100644 --- a/README.md +++ b/README.md @@ -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. -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).