Requirements: a Pico 2 / Pico 2 W (RP2350) module. There’s no RP2040 build, because the game doesn’t fit. You’ll also need the v1.7 keyboard BIOS and pelrun’s uf2loader.
What to expect: this is an alpha with exactly one tester so far, so bugs, especially late in the game, are likely. The map is 64×40 and the unit pool is capped at 300 to fit in 520KB. Saves go to empsave.dat on the SD card automatically. Movement keys are Empire’s own QWE/AD/ZXC; the arrow keys won’t move your pieces.
For anyone building on Blair’s PDCurses backend: getting this onto hardware turned up three bugs in the shared picocalc/ display layer.
The LCD font didn’t match the 64-column layout, so long lines got garbled.
Keyboard polling only started if the program called raw().
Color attributes were thrown away.
The fixes are in picocalc/pdc*.c in the repo, and any curses program using that layer should benefit.
Colossal Cave Adventure is coming next, in a separate thread.
Thanks again for the quick Rogue fix in v1.2. Since then I’ve ended up with two small pieces that might be useful in the shell and in your other projects. Both are yours to use, change or ignore.
Summary:
A shared clock: the RP2350’s always-on (POWMAN) timer survives the soft reboot UF2 Loader does between programs, so one program can set the time and every program after it can read it, until power-off.
A screenshot function for PDCurses programs on the PicoCalc: Shift+F5 saves the screen as a BMP.
SHARED CLOCK
What I found:
The POWMAN timer runs from the crystal and keeps going through UF2 Loader’s reboot. Only a power-off clears it.
Tested on a Pico 2 W: set the time over NTP in my VirtualT port, quit to your shell, ran Adventure, quit, relaunched VirtualT. The time was still there, with no WiFi needed.
picocalc_clock.h (attached, MIT, written to sit next to your picocalc_shell.h):
picocalc_clock_load(): sets the program’s own time()/localtime() from the shared clock, if it’s set.
picocalc_clock_save(): copies the program’s current time into it.
picocalc_clock_is_set(): tells you whether it holds a real time.
Rule: only real times (NTP, or the user typing it) ever go in, so a program reading it can trust it.
settime (attached, source plus .uf2):
A small program that joins WiFi, gets the time from NTP, saves it to the shared clock and returns to the shell.
If the clock is already set, it shows the time and returns at once (N fetches it again anyway).
Needs a Pico 2 W, with 2.4 GHz WPA2 WiFi. It retries the join up to three times.
settime’s settings, in a plain text file, /settime.cfg (falls back to /virtualt/virtualt.cfg so VirtualT users don’t type their WiFi password twice):
tz is a POSIX TZ string, defaulting to US Pacific; ntp defaults to pool.ntp.org.
The clock itself holds UTC; tz only affects how a program shows it. A shell DATE/TIME command would want the same tz setting, so if you’d rather have one shared settings file (or a TZ variable in /etc/profile), I’m happy to switch settime to that.
Where the shell comes in:
DATE and TIME commands. Real dates on files the shell writes would also need the FAT32 code to stamp them.
A cheap “is the clock set?” test usable from AUTOEXEC.BAT or /etc/profile. That’s the piece I can’t do from outside. settime is about 350 KB because of the CYW43 firmware, so running it from the startup script means the shell rewrites most of it into flash on every return from another program. With a test in the script, it would only run once per power-on.
SCREENSHOTS (pdcshot.c, attached)
For PDCurses on the PicoCalc, built on your text-starter drivers, so it should drop into Rogue’s backend.
It redraws curses’ own screen copy (curscr), using the LCD’s font and our colour map, into a 320x320 24-bit BMP. It doesn’t read back the LCD.
Files go to /screenshots/-NNN.bmp, named from a PICOCALC_APP_NAME define, so programs don’t overwrite each other.
Hooked to F10 (Shift+F5) inside PDC_check_key(), with a beep when done; those few lines are in pdckbd.c if you want them. The output matched the screen exactly in my tests.
The files could get real timestamps from the shared clock, with a small change to the FAT32 driver’s date stamp.
One more thing from the same work: in the key-table lookup, the BIOS’s shifted column is 0 for most keys, so F6-F10, Del and a few others were dropped while Shift was held. The fix is a fallback to the unshifted code when the shifted one is 0. Happy to send the diff if Rogue’s table has the same layout.
None of this is urgent. If any of it is useful, I’m glad to adapt it to whatever fits the shell best.
I am planning to ship the clock enhancement to the shell sometime today. Thank you for the idea and direction. I didn’t implement this feature exactly as presented here, but it does appear to be compatible with VirtualT.