Skip to content

Keep a C128 crt's clock record at the TR's local time - #62

Closed
kfox wants to merge 7 commits into
SensoriumEmbedded:mainfrom
kfox:c128-crt-clock
Closed

kfox wants to merge 7 commits into
SensoriumEmbedded:mainfrom
kfox:c128-crt-clock

Conversation

@kfox

@kfox kfox commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

Stacked on #59 (C128 .crt launch): the first commits here are #59's. Review the last three, starting at 9a798ca.

A C128 crt can carry a clock record: the tag TRCLOCK, a version byte $01, then century, year (0–99), month, day, hour (0–23), minute and second. When LaunchC128Cart maps the cart, it searches the ROML image (then ROMH) for the tag. While the cart runs, both images' loop() write the RTC's local time into the record every 100 ms; the time zone comes from eepAdTimezone. FreeCrtChips drops the pointer, so nothing is written once the chips are freed. Chips that MinimalBoot swapped out to SD are skipped.

The first user is GEOS 128. Built with tools/c128/geos128crt.py (#60), its loader reads the record once GEOS is unpacked, then sets CIA1's TOD and GEOS's date from it. Before this, every boot started at 1:00 PM on 3/23/92. The record format and the C128 side are in tools/c128/README.md, "The boot clock". The C128 reads until two reads agree, so a write landing mid-read is harmless.

Verified

  • build:tr and build:tr-plus (linux/amd64, Teensyduino 1.61.0).
  • TR+ in an NTSC C128, this branch merged with GeoRAM IO handler for GEOS 64, sharing the REU's RAM bank code #61: a GEOS 128 (Am1581) crt built with --clock 1999-01-01T00:00 boots from a D81 on an SD2IEC. The DeskTop shows 01/01/19 01:12 AM, which is the TR's RTC. That RTC was never set, so it started at the Teensy core's Jan 1 2019 default when it found the RTC stopped. Not tested: a set RTC, MinimalBoot, an original TR.

Draft until the GEOS package is complete.

kfox added 7 commits October 14, 2026 19:43
A "C128 CARTRIDGE" file was routed by its first chip's load address, and
only $0000 meant C128 mode. The CRT spec puts a generic C128 cart's ROML
at $8000 and ROMH at $C000, so a spec .crt with an 8k ROML matched the C64
8k rule and started in C64 mode, and 16k or 32k ones never reached C128
mode at all. x128 refuses the $0000 layout.

The signature now decides. A C128 crt maps an 8k or 16k chip at $8000 to
ROML and one at $C000 to ROMH, with the ROM masks sized to each chip, and
anything else is refused with a message. Nonzero C128 hardware types are
refused instead of being looked up in the C64 list, where 1 means Action
Replay rather than Warpspeed128. Both the main and minimal parsers change.

The 789010 diagnostic cart in the menu moves its ROML to $8000, which is
the copy of it the VICE manual uses as its generic C128 example.
The C128 layout rules move with StructCrtChip into a pure header, CrtChips.h, as MapC128Cart, which returns both images and their masks. The launch in both builds checks its result and refuses with a message instead of resetting into an empty cart. Both builds reset the ROM masks before every launch, since a direct remote launch skips SetUpMainMenuROM and would otherwise inherit a C128 cart's 16k masks. vm/tests/c128cart_test holds the accepted and refused layouts, run by verify:extensions.
MinimalBoot has no direct remote launch and its setup already sets the masks, so the per-launch reset there goes. A test comment claimed a check the test does not make.
The C128 signature, HW-type refusal, layout check and launch mapping move into MinimalBoot/Common/C128Crt.h, so the main and MinimalBoot images call the same code instead of carrying copies. The launch applies the map SetTypeFromCRT saved rather than checking the layout a second time.
A C128 crt can carry a TRCLOCK record (tools/c128/README.md). At launch
the TR finds it in the cart's ROM image and, while the cart runs, writes
its RTC's local date and time there every 100 ms, so a GEOS 128 crt
built with geos128crt.py boots with the TR's clock.
@kfox

kfox commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Closing: the clock record was only for Python-built GEOS 128 crts. GEOS 128 will launch the way GEOS 64 does, and the firmware writes the RTC time into the boot image at launch (GeosSetClock), so no crt needs a record the TR keeps updated.

@kfox kfox closed this Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant